[gtk+/dialogs] Add a convenience accessor



commit 52412e10d220055b4367419963e6798ac51bfdf3
Author: Matthias Clasen <mclasen redhat com>
Date:   Thu Jan 16 22:51:14 2014 -0500

    Add a convenience accessor

 docs/reference/gtk/gtk3-sections.txt |    1 +
 gtk/gtkappchooserdialog.c            |    4 +---
 gtk/gtkcustompaperunixdialog.c       |    4 +---
 gtk/gtkdialog.c                      |   21 +++++++++++++++++++++
 gtk/gtkdialog.h                      |    3 ++-
 gtk/gtkprintunixdialog.c             |    3 +--
 6 files changed, 27 insertions(+), 9 deletions(-)
---
diff --git a/docs/reference/gtk/gtk3-sections.txt b/docs/reference/gtk/gtk3-sections.txt
index 70f0e0a..80d8a18 100644
--- a/docs/reference/gtk/gtk3-sections.txt
+++ b/docs/reference/gtk/gtk3-sections.txt
@@ -1034,6 +1034,7 @@ gtk_dialog_get_widget_for_response
 gtk_dialog_get_action_area
 gtk_dialog_get_content_area
 gtk_dialog_get_header_bar
+gtk_dialog_get_use_header_bar
 <SUBSECTION>
 gtk_alternative_dialog_button_order
 gtk_dialog_set_alternative_button_order
diff --git a/gtk/gtkappchooserdialog.c b/gtk/gtkappchooserdialog.c
index f7264f9..17885cf 100644
--- a/gtk/gtkappchooserdialog.c
+++ b/gtk/gtkappchooserdialog.c
@@ -436,7 +436,6 @@ ensure_software_button (GtkAppChooserDialog *self)
   if (g_find_program_in_path ("gnome-software"))
     {
       GtkWidget *parent;
-      gboolean use_header;
 
       self->priv->software_button = gtk_button_new_with_label (_("Software"));
       gtk_button_set_always_show_image (GTK_BUTTON (self->priv->software_button), TRUE);
@@ -446,8 +445,7 @@ ensure_software_button (GtkAppChooserDialog *self)
                         G_CALLBACK (software_button_clicked_cb), self);
       gtk_widget_show (self->priv->software_button);
       
-      g_object_get (self, "use-header-bar", &use_header, NULL);
-      if (use_header)
+      if (gtk_dialog_get_use_header_bar (GTK_DIALOG (self)))
         {
           parent = gtk_dialog_get_header_bar (GTK_DIALOG (self));
           gtk_header_bar_pack_end (GTK_HEADER_BAR (parent), self->priv->software_button);
diff --git a/gtk/gtkcustompaperunixdialog.c b/gtk/gtkcustompaperunixdialog.c
index ec2c117..e2d3b99 100644
--- a/gtk/gtkcustompaperunixdialog.c
+++ b/gtk/gtkcustompaperunixdialog.c
@@ -323,12 +323,10 @@ gtk_custom_paper_unix_dialog_constructor (GType            type,
                                           GObjectConstructParam *params)
 {
   GObject *object;
-  gboolean use_header;
 
   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)
+  if (!gtk_dialog_get_use_header_bar (GTK_DIALOG (object)))
     {
       gtk_dialog_add_buttons (GTK_DIALOG (object),
                               _("_Close"), GTK_RESPONSE_CLOSE,
diff --git a/gtk/gtkdialog.c b/gtk/gtkdialog.c
index 41c2a83..25d77da 100644
--- a/gtk/gtkdialog.c
+++ b/gtk/gtkdialog.c
@@ -1799,3 +1799,24 @@ gtk_dialog_get_content_area (GtkDialog *dialog)
 
   return dialog->priv->vbox;
 }
+
+/**
+ * gtk_dialog_get_use_header_bar:
+ * @dialog: a #GtkDialog
+ *
+ * Returns whether the dialog is using a header
+ * bar for action widgets instead of the action
+ * area.
+ *
+ * Returns: %TRUE if the header bar is used
+ *
+ * Since: 3.12
+ */
+gboolean
+gtk_dialog_get_use_header_bar (GtkDialog *dialog)
+{
+  g_return_val_if_fail (GTK_IS_DIALOG (dialog), FALSE);
+
+  return dialog->priv->use_header_bar;
+}
+
diff --git a/gtk/gtkdialog.h b/gtk/gtkdialog.h
index 3761f7d..4b1c9e7 100644
--- a/gtk/gtkdialog.h
+++ b/gtk/gtkdialog.h
@@ -197,7 +197,8 @@ GDK_AVAILABLE_IN_ALL
 GtkWidget * gtk_dialog_get_content_area (GtkDialog *dialog);
 GDK_AVAILABLE_IN_3_12
 GtkWidget * gtk_dialog_get_header_bar   (GtkDialog *dialog);
-
+GDK_AVAILABLE_IN_3_12
+gboolean    gtk_dialog_get_use_header_bar (GtkDialog *dialog);
 G_END_DECLS
 
 #endif /* __GTK_DIALOG_H__ */
diff --git a/gtk/gtkprintunixdialog.c b/gtk/gtkprintunixdialog.c
index 0bb6b34..046ed53 100644
--- a/gtk/gtkprintunixdialog.c
+++ b/gtk/gtkprintunixdialog.c
@@ -806,8 +806,7 @@ gtk_print_unix_dialog_constructor (GType                  type,
 
   object = G_OBJECT_CLASS (gtk_print_unix_dialog_parent_class)->constructor (type, n_params, params);
 
-  g_object_get (object, "use-header-bar", &use_header, NULL);
-  if (use_header)
+  if (gtk_dialog_get_use_header_bar (GTK_DIALOG (object)))
     {
        /* Reorder the preview button */
        GtkWidget *button, *parent;


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]