diff options
author | William Jon McCann <william.jon.mccann@gmail.com> | 2013-12-08 15:58:00 +0100 |
---|---|---|
committer | Matthias Clasen <mclasen@redhat.com> | 2014-01-17 17:52:08 -0500 |
commit | b0caf23977887a773eb3f8f2c41fc33a520dfc9a (patch) | |
tree | edb6e930fe2a258b45534f74fd84f80a72acc13f /gtk/gtkcustompaperunixdialog.c | |
parent | f2d6ed3290d94845af543826292bdd47fa19506c (diff) | |
download | gtk+-b0caf23977887a773eb3f8f2c41fc33a520dfc9a.tar.gz |
custom paper dialog: Use headerbar
Make the custom paper dialog use a headerbar when desired.
https://bugzilla.gnome.org/show_bug.cgi?id=720059
Diffstat (limited to 'gtk/gtkcustompaperunixdialog.c')
-rw-r--r-- | gtk/gtkcustompaperunixdialog.c | 41 |
1 files changed, 31 insertions, 10 deletions
diff --git a/gtk/gtkcustompaperunixdialog.c b/gtk/gtkcustompaperunixdialog.c index 09fb139dad..ec2c11725a 100644 --- a/gtk/gtkcustompaperunixdialog.c +++ b/gtk/gtkcustompaperunixdialog.c @@ -37,6 +37,7 @@ #include "gtkcustompaperunixdialog.h" #include "gtkprintbackend.h" #include "gtkprintutils.h" +#include "gtkdialogprivate.h" #define LEGACY_CUSTOM_PAPER_FILENAME ".gtk-custom-papers" #define CUSTOM_PAPER_FILENAME "custom-papers" @@ -89,6 +90,9 @@ enum { G_DEFINE_TYPE_WITH_PRIVATE (GtkCustomPaperUnixDialog, gtk_custom_paper_unix_dialog, GTK_TYPE_DIALOG) +static GObject *gtk_custom_paper_unix_dialog_constructor (GType type, + guint n_params, + GObjectConstructParam *params); static void gtk_custom_paper_unix_dialog_finalize (GObject *object); static void populate_dialog (GtkCustomPaperUnixDialog *dialog); static void printer_added_cb (GtkPrintBackend *backend, @@ -269,6 +273,7 @@ _gtk_print_save_custom_papers (GtkListStore *store) static void gtk_custom_paper_unix_dialog_class_init (GtkCustomPaperUnixDialogClass *class) { + G_OBJECT_CLASS (class)->constructor = gtk_custom_paper_unix_dialog_constructor; G_OBJECT_CLASS (class)->finalize = gtk_custom_paper_unix_dialog_finalize; } @@ -291,6 +296,8 @@ gtk_custom_paper_unix_dialog_init (GtkCustomPaperUnixDialog *dialog) dialog->priv = gtk_custom_paper_unix_dialog_get_instance_private (dialog); priv = dialog->priv; + gtk_dialog_set_use_header_bar_from_setting (GTK_DIALOG (dialog)); + priv->print_backends = NULL; priv->request_details_printer = NULL; @@ -307,13 +314,29 @@ gtk_custom_paper_unix_dialog_init (GtkCustomPaperUnixDialog *dialog) populate_dialog (dialog); - gtk_dialog_add_buttons (GTK_DIALOG (dialog), - _("_Close"), GTK_RESPONSE_CLOSE, - NULL); + g_signal_connect (dialog, "response", G_CALLBACK (custom_paper_dialog_response_cb), NULL); +} - gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_CLOSE); +static GObject * +gtk_custom_paper_unix_dialog_constructor (GType type, + guint n_params, + GObjectConstructParam *params) +{ + GObject *object; + gboolean use_header; - g_signal_connect (dialog, "response", G_CALLBACK (custom_paper_dialog_response_cb), NULL); + object = G_OBJECT_CLASS (gtk_custom_paper_unix_dialog_parent_class)->constructor (type, n_params, params); + + g_object_get (object, "use-header-bar", &use_header, NULL); + if (!use_header) + { + gtk_dialog_add_buttons (GTK_DIALOG (object), + _("_Close"), GTK_RESPONSE_CLOSE, + NULL); + gtk_dialog_set_default_response (GTK_DIALOG (object), GTK_RESPONSE_CLOSE); + } + + return object; } static void @@ -381,7 +404,7 @@ gtk_custom_paper_unix_dialog_finalize (GObject *object) */ GtkWidget * _gtk_custom_paper_unix_dialog_new (GtkWindow *parent, - const gchar *title) + const gchar *title) { GtkWidget *result; @@ -1015,10 +1038,9 @@ populate_dialog (GtkCustomPaperUnixDialog *dialog) GtkStyleContext *context; content_area = gtk_dialog_get_content_area (cpu_dialog); -G_GNUC_BEGIN_IGNORE_DEPRECATIONS +G_GNUC_BEGIN_IGNORE_DEPRECATIONS action_area = gtk_dialog_get_action_area (cpu_dialog); -G_GNUC_END_IGNORE_DEPRECATIONS - +G_GNUC_END_IGNORE_DEPRECATIONS gtk_container_set_border_width (GTK_CONTAINER (dialog), 5); gtk_box_set_spacing (GTK_BOX (content_area), 2); /* 2 * 5 + 2 = 12 */ gtk_container_set_border_width (GTK_CONTAINER (action_area), 5); @@ -1219,6 +1241,5 @@ G_GNUC_END_IGNORE_DEPRECATIONS add_custom_paper (dialog); } - gtk_window_present (GTK_WINDOW (dialog)); load_print_backends (dialog); } |