forked from AuroraMiddleware/gtk
Show dialog titles
We want to present a clean, rounded top when there is nothing else to show, but many dialogs in applications rely on showing information in their title, so add a label and show the title when it is not empty.
This commit is contained in:
parent
2f43800aa3
commit
3504f49473
@ -271,6 +271,18 @@ add_cb (GtkContainer *container,
|
|||||||
gtk_widget_show (GTK_WIDGET (container));
|
gtk_widget_show (GTK_WIDGET (container));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
update_title (GObject *dialog,
|
||||||
|
GParamSpec *pspec,
|
||||||
|
GtkWidget *label)
|
||||||
|
{
|
||||||
|
const gchar *title;
|
||||||
|
|
||||||
|
title = gtk_window_get_title (GTK_WINDOW (dialog));
|
||||||
|
gtk_label_set_label (GTK_LABEL (label), title);
|
||||||
|
gtk_widget_set_visible (label, title && title[0]);
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
apply_use_header_bar (GtkDialog *dialog)
|
apply_use_header_bar (GtkDialog *dialog)
|
||||||
{
|
{
|
||||||
@ -284,9 +296,15 @@ apply_use_header_bar (GtkDialog *dialog)
|
|||||||
|
|
||||||
if (gtk_window_get_type_hint (GTK_WINDOW (dialog)) == GDK_WINDOW_TYPE_HINT_DIALOG)
|
if (gtk_window_get_type_hint (GTK_WINDOW (dialog)) == GDK_WINDOW_TYPE_HINT_DIALOG)
|
||||||
{
|
{
|
||||||
|
GtkWidget *label;
|
||||||
|
|
||||||
box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
|
box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
|
||||||
gtk_widget_show (box);
|
gtk_widget_show (box);
|
||||||
gtk_widget_set_size_request (box, -1, 16);
|
gtk_widget_set_size_request (box, -1, 16);
|
||||||
|
label = gtk_label_new ("");
|
||||||
|
gtk_style_context_add_class (gtk_widget_get_style_context (label), "title");
|
||||||
|
gtk_box_set_center_widget (GTK_BOX (box), label);
|
||||||
|
g_signal_connect (dialog, "notify::title", G_CALLBACK (update_title), label);
|
||||||
}
|
}
|
||||||
|
|
||||||
gtk_window_set_titlebar (GTK_WINDOW (dialog), box);
|
gtk_window_set_titlebar (GTK_WINDOW (dialog), box);
|
||||||
|
Loading…
Reference in New Issue
Block a user