[gtk+] font dialog: Use headerbar



commit 3eb2430a9880e804d87d9b9de1badbc0dbaf5bee
Author: William Jon McCann <william jon mccann gmail com>
Date:   Sun Dec 8 15:09:46 2013 +0100

    font dialog: Use headerbar
    
    Make the font chooser dialog use a headerbar
    when desired.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=720059

 gtk/gtkfontchooserdialog.c    |   15 ++++++++++--
 gtk/gtkfontchooserdialog.ui   |   48 +----------------------------------------
 gtk/gtkfontchooserdialog.ui.h |    4 +--
 3 files changed, 14 insertions(+), 53 deletions(-)
---
diff --git a/gtk/gtkfontchooserdialog.c b/gtk/gtkfontchooserdialog.c
index 124fb10..d54d30a 100644
--- a/gtk/gtkfontchooserdialog.c
+++ b/gtk/gtkfontchooserdialog.c
@@ -34,6 +34,8 @@
 #include "gtkbuildable.h"
 #include "gtkprivate.h"
 #include "gtkwidget.h"
+#include "gtksettings.h"
+#include "gtkdialogprivate.h"
 
 struct _GtkFontChooserDialogPrivate
 {
@@ -56,7 +58,7 @@ struct _GtkFontChooserDialogPrivate
  * <title>GtkFontChooserDialog as GtkBuildable</title>
  * The GtkFontChooserDialog implementation of the GtkBuildable interface
  * exposes the buttons with the names
- * "select_button" and "cancel_button.
+ * "select_button" and "cancel_button".
  * </refsect2>
  *
  * Since: 3.2
@@ -137,8 +139,6 @@ gtk_font_chooser_dialog_class_init (GtkFontChooserDialogClass *klass)
                                               "/org/gtk/libgtk/gtkfontchooserdialog.ui");
 
   gtk_widget_class_bind_template_child_private (widget_class, GtkFontChooserDialog, fontchooser);
-  gtk_widget_class_bind_template_child_private (widget_class, GtkFontChooserDialog, select_button);
-  gtk_widget_class_bind_template_child_private (widget_class, GtkFontChooserDialog, cancel_button);
   gtk_widget_class_bind_template_callback (widget_class, font_activated_cb);
 }
 
@@ -151,6 +151,12 @@ gtk_font_chooser_dialog_init (GtkFontChooserDialog *fontchooserdiag)
   priv = fontchooserdiag->priv;
 
   gtk_widget_init_template (GTK_WIDGET (fontchooserdiag));
+  gtk_dialog_set_use_header_bar_from_setting (GTK_DIALOG (fontchooserdiag));
+  gtk_dialog_add_buttons (GTK_DIALOG (fontchooserdiag),
+                          _("_Cancel"), GTK_RESPONSE_CANCEL,
+                          _("_Select"), GTK_RESPONSE_OK,
+                          NULL);
+  gtk_dialog_set_default_response (GTK_DIALOG (fontchooserdiag), GTK_RESPONSE_OK);
 G_GNUC_BEGIN_IGNORE_DEPRECATIONS
   gtk_dialog_set_alternative_button_order (GTK_DIALOG (fontchooserdiag),
                                            GTK_RESPONSE_OK,
@@ -158,6 +164,9 @@ G_GNUC_BEGIN_IGNORE_DEPRECATIONS
                                            -1);
 G_GNUC_END_IGNORE_DEPRECATIONS
 
+  priv->select_button = gtk_dialog_get_widget_for_response (GTK_DIALOG (fontchooserdiag), GTK_RESPONSE_OK);
+  priv->cancel_button = gtk_dialog_get_widget_for_response (GTK_DIALOG (fontchooserdiag), 
GTK_RESPONSE_CANCEL);
+
   _gtk_font_chooser_set_delegate (GTK_FONT_CHOOSER (fontchooserdiag),
                                   GTK_FONT_CHOOSER (priv->fontchooser));
 }
diff --git a/gtk/gtkfontchooserdialog.ui b/gtk/gtkfontchooserdialog.ui
index 268c8f3..a1dea23 100644
--- a/gtk/gtkfontchooserdialog.ui
+++ b/gtk/gtkfontchooserdialog.ui
@@ -4,55 +4,13 @@
   <template class="GtkFontChooserDialog" parent="GtkDialog">
     <property name="can_focus">False</property>
     <property name="border_width">5</property>
-    <property name="title" translatable="yes">Font Selection</property>
+    <property name="title" translatable="yes">Select Font</property>
     <property name="type_hint">dialog</property>
     <child internal-child="vbox">
       <object class="GtkBox" id="dialog-vbox1">
         <property name="can_focus">False</property>
         <property name="orientation">vertical</property>
         <property name="spacing">2</property>
-        <child internal-child="action_area">
-          <object class="GtkButtonBox" id="dialog-action_area1">
-            <property name="can_focus">False</property>
-            <property name="layout_style">end</property>
-            <child>
-              <object class="GtkButton" id="cancel_button">
-                <property name="label" translatable="yes">_Cancel</property>
-                <property name="visible">True</property>
-                <property name="can_focus">True</property>
-                <property name="receives_default">True</property>
-                <property name="use_underline">True</property>
-              </object>
-              <packing>
-                <property name="expand">False</property>
-                <property name="fill">True</property>
-                <property name="position">0</property>
-              </packing>
-            </child>
-            <child>
-              <object class="GtkButton" id="select_button">
-                <property name="label" translatable="yes">_Select</property>
-                <property name="visible">True</property>
-                <property name="can_focus">True</property>
-                <property name="can_default">True</property>
-                <property name="has_default">True</property>
-                <property name="receives_default">True</property>
-                <property name="use_underline">True</property>
-              </object>
-              <packing>
-                <property name="expand">False</property>
-                <property name="fill">True</property>
-                <property name="position">1</property>
-              </packing>
-            </child>
-          </object>
-          <packing>
-            <property name="expand">False</property>
-            <property name="fill">True</property>
-            <property name="pack_type">end</property>
-            <property name="position">0</property>
-          </packing>
-        </child>
         <child>
           <object class="GtkFontChooserWidget" id="fontchooser">
             <property name="visible">True</property>
@@ -70,9 +28,5 @@
         </child>
       </object>
     </child>
-    <action-widgets>
-      <action-widget response="-6">cancel_button</action-widget>
-      <action-widget response="-5">select_button</action-widget>
-    </action-widgets>
   </template>
 </interface>
diff --git a/gtk/gtkfontchooserdialog.ui.h b/gtk/gtkfontchooserdialog.ui.h
index dc7de1e..3078a6d 100644
--- a/gtk/gtkfontchooserdialog.ui.h
+++ b/gtk/gtkfontchooserdialog.ui.h
@@ -1,3 +1 @@
-N_("Font Selection");
-N_("_Cancel");
-N_("_Select");
+N_("Select Font");


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