[gtk/wip/baedert/box2: 5/10] dialog: Expose the content area as a separate GtkBox child



commit 7aff91b65a91bdec57dc31ef47ba166bb575da3a
Author: Timm Bäder <mail baedert org>
Date:   Wed Dec 26 09:00:08 2018 +0100

    dialog: Expose the content area as a separate GtkBox child
    
    This way, the "vbox" internal child does not contain anything by
    default. It previously did contain "internal" widgetry like the action
    area.

 demos/widget-factory/widget-factory.ui |  6 +++---
 gtk/gtkdialog.c                        | 12 ++++++------
 gtk/ui/gtkaboutdialog.ui               |  4 ++--
 gtk/ui/gtkappchooserdialog.ui          |  2 +-
 gtk/ui/gtkcolorchooserdialog.ui        |  2 +-
 gtk/ui/gtkdialog.ui                    | 10 +++++++++-
 gtk/ui/gtkfilechooserdialog.ui         |  4 ++--
 gtk/ui/gtkfontchooserdialog.ui         |  2 +-
 gtk/ui/gtkmessagedialog.ui             |  2 +-
 gtk/ui/gtkpagesetupunixdialog.ui       |  2 +-
 gtk/ui/gtkprintunixdialog.ui           |  2 +-
 testsuite/gtk/builder.c                |  5 ++---
 12 files changed, 30 insertions(+), 23 deletions(-)
---
diff --git a/demos/widget-factory/widget-factory.ui b/demos/widget-factory/widget-factory.ui
index d1ad3ffaff..4363d5a954 100644
--- a/demos/widget-factory/widget-factory.ui
+++ b/demos/widget-factory/widget-factory.ui
@@ -3283,7 +3283,7 @@ bad things might happen.</property>
     <property name="use-header-bar">1</property>
     <property name="title" translatable="yes">Zelda</property>
     <property name="hide-on-close">1</property>
-    <child internal-child="vbox">
+    <child internal-child="content_area">
       <object class="GtkBox">
         <child>
           <object class="GtkLabel">
@@ -3322,7 +3322,7 @@ bad things might happen.</property>
     <property name="use-header-bar">1</property>
     <property name="title" translatable="yes">Settings</property>
     <property name="hide-on-close">1</property>
-    <child internal-child="vbox">
+    <child internal-child="content_area">
       <object class="GtkBox">
         <child>
           <object class="GtkGrid">
@@ -3443,7 +3443,7 @@ bad things might happen.</property>
     <property name="use-header-bar">1</property>
     <property name="title" translatable="yes">Choose one</property>
     <property name="hide-on-close">1</property>
-    <child internal-child="vbox">
+    <child internal-child="content_area">
       <object class="GtkBox">
         <child>
           <object class="GtkFlowBox" id="selection_flowbox">
diff --git a/gtk/gtkdialog.c b/gtk/gtkdialog.c
index 756446aaa8..3604c592c9 100644
--- a/gtk/gtkdialog.c
+++ b/gtk/gtkdialog.c
@@ -133,8 +133,8 @@
  * # GtkDialog as GtkBuildable
  *
  * The GtkDialog implementation of the #GtkBuildable interface exposes the
- * @vbox and @action_area as internal children with the names “vbox” and
- * “action_area”.
+ * @message_area and @action_area as internal children with the names
+ * “action_area” and “action_area”.
  *
  * GtkDialog supports a custom <action-widgets> element, which can contain
  * multiple <action-widget> elements. The “response” attribute specifies a
@@ -170,9 +170,9 @@
 
 typedef struct
 {
-  GtkWidget *vbox;
   GtkWidget *headerbar;
   GtkWidget *action_area;
+  GtkWidget *content_area;
   GtkWidget *action_box;
   GtkSizeGroup *size_group;
 
@@ -592,9 +592,9 @@ gtk_dialog_class_init (GtkDialogClass *class)
   /* Bind class to template
    */
   gtk_widget_class_set_template_from_resource (widget_class, "/org/gtk/libgtk/ui/gtkdialog.ui");
-  gtk_widget_class_bind_template_child_internal_private (widget_class, GtkDialog, vbox);
   gtk_widget_class_bind_template_child_internal_private (widget_class, GtkDialog, headerbar);
   gtk_widget_class_bind_template_child_internal_private (widget_class, GtkDialog, action_area);
+  gtk_widget_class_bind_template_child_internal_private (widget_class, GtkDialog, content_area);
   gtk_widget_class_bind_template_child_private (widget_class, GtkDialog, action_box);
 
   gtk_widget_class_set_css_name (widget_class, I_("dialog"));
@@ -727,7 +727,7 @@ gtk_dialog_close (GtkDialog *dialog)
  * Creates a new dialog box.
  *
  * Widgets should not be packed into this #GtkWindow
- * directly, but into the @vbox and @action_area, as described above.
+ * directly, but into the @content_area and @action_area, as described above.
  *
  * Returns: the new dialog as a #GtkWidget
  */
@@ -1621,5 +1621,5 @@ gtk_dialog_get_content_area (GtkDialog *dialog)
 
   g_return_val_if_fail (GTK_IS_DIALOG (dialog), NULL);
 
-  return priv->vbox;
+  return priv->content_area;
 }
diff --git a/gtk/ui/gtkaboutdialog.ui b/gtk/ui/gtkaboutdialog.ui
index 180151f66e..d6a9fbd016 100644
--- a/gtk/ui/gtkaboutdialog.ui
+++ b/gtk/ui/gtkaboutdialog.ui
@@ -15,8 +15,8 @@
         </child>
       </object>
     </child>
-    <child internal-child="vbox">
-      <object class="GtkBox" id="dialog-vbox1">
+    <child internal-child="content_area">
+      <object class="GtkBox">
         <property name="orientation">vertical</property>
         <property name="spacing">2</property>
         <property name="margin">5</property>
diff --git a/gtk/ui/gtkappchooserdialog.ui b/gtk/ui/gtkappchooserdialog.ui
index 9c09d757c7..27a0a62114 100644
--- a/gtk/ui/gtkappchooserdialog.ui
+++ b/gtk/ui/gtkappchooserdialog.ui
@@ -4,7 +4,7 @@
   <template class="GtkAppChooserDialog" parent="GtkDialog">
     <property name="title" translatable="yes">Select Application</property>
     <property name="type-hint">dialog</property>
-    <child internal-child="vbox">
+    <child internal-child="content_area">
       <object class="GtkBox" id="dialog-vbox1">
         <property name="orientation">vertical</property>
         <property name="spacing">2</property>
diff --git a/gtk/ui/gtkcolorchooserdialog.ui b/gtk/ui/gtkcolorchooserdialog.ui
index 347fc6f99f..814222f912 100644
--- a/gtk/ui/gtkcolorchooserdialog.ui
+++ b/gtk/ui/gtkcolorchooserdialog.ui
@@ -5,7 +5,7 @@
     <property name="title" translatable="yes">Select a Color</property>
     <property name="type-hint">dialog</property>
     <property name="resizable">0</property>
-    <child internal-child="vbox">
+    <child internal-child="content_area">
       <object class="GtkBox" id="dialog-vbox1">
         <property name="orientation">vertical</property>
         <property name="spacing">2</property>
diff --git a/gtk/ui/gtkdialog.ui b/gtk/ui/gtkdialog.ui
index d2d2638947..1bd869b6c5 100644
--- a/gtk/ui/gtkdialog.ui
+++ b/gtk/ui/gtkdialog.ui
@@ -10,11 +10,19 @@
       </object>
     </child>
     <child>
-      <object class="GtkBox" id="vbox">
+      <object class="GtkBox">
         <property name="orientation">vertical</property>
         <style>
           <class name="dialog-vbox"/>
         </style>
+
+        <!-- This is empty here and just exists so we can expose it as
+             GtkDialog API. -->
+        <child>
+          <object class="GtkBox" id="content_area">
+          </object>
+        </child>
+
         <child>
           <object class="GtkBox" id="action_box">
             <style>
diff --git a/gtk/ui/gtkfilechooserdialog.ui b/gtk/ui/gtkfilechooserdialog.ui
index 1b37a4ce0e..fac32bca11 100644
--- a/gtk/ui/gtkfilechooserdialog.ui
+++ b/gtk/ui/gtkfilechooserdialog.ui
@@ -6,8 +6,8 @@
     <property name="type-hint">dialog</property>
     <property name="default-width">600</property>
     <signal name="response" handler="response_cb" swapped="no"/>
-    <child internal-child="vbox">
-      <object class="GtkBox" id="dialog-vbox1">
+    <child internal-child="content_area">
+      <object class="GtkBox">
         <property name="orientation">vertical</property>
         <child internal-child="action_area">
           <object class="GtkButtonBox" id="dialog-action_area1">
diff --git a/gtk/ui/gtkfontchooserdialog.ui b/gtk/ui/gtkfontchooserdialog.ui
index e6fb4ec3a6..cb244a94a0 100644
--- a/gtk/ui/gtkfontchooserdialog.ui
+++ b/gtk/ui/gtkfontchooserdialog.ui
@@ -4,7 +4,7 @@
   <template class="GtkFontChooserDialog" parent="GtkDialog">
     <property name="title" translatable="yes">Select Font</property>
     <property name="type-hint">dialog</property>
-    <child internal-child="vbox">
+    <child internal-child="content_area">
       <object class="GtkBox" id="dialog-vbox1">
         <property name="orientation">vertical</property>
         <property name="spacing">2</property>
diff --git a/gtk/ui/gtkmessagedialog.ui b/gtk/ui/gtkmessagedialog.ui
index 35834d9d48..7b4588fb80 100644
--- a/gtk/ui/gtkmessagedialog.ui
+++ b/gtk/ui/gtkmessagedialog.ui
@@ -9,7 +9,7 @@
     <child internal-child="headerbar">
       <object class="GtkHeaderBar" id="headerbar1"/>
     </child>
-    <child internal-child="vbox">
+    <child internal-child="content_area">
       <object class="GtkBox" id="dialog-vbox1">
         <property name="orientation">vertical</property>
         <property name="spacing">20</property>
diff --git a/gtk/ui/gtkpagesetupunixdialog.ui b/gtk/ui/gtkpagesetupunixdialog.ui
index 4b0b948f0c..4e94af14db 100644
--- a/gtk/ui/gtkpagesetupunixdialog.ui
+++ b/gtk/ui/gtkpagesetupunixdialog.ui
@@ -27,7 +27,7 @@
     <property name="resizable">0</property>
     <property name="type-hint">dialog</property>
     <property name="title" translatable="yes">Page Setup</property>
-    <child internal-child="vbox">
+    <child internal-child="content_area">
       <object class="GtkBox" id="dialog-vbox1">
         <property name="orientation">vertical</property>
         <property name="spacing">2</property>
diff --git a/gtk/ui/gtkprintunixdialog.ui b/gtk/ui/gtkprintunixdialog.ui
index 056877c5c0..71ffe20151 100644
--- a/gtk/ui/gtkprintunixdialog.ui
+++ b/gtk/ui/gtkprintunixdialog.ui
@@ -51,7 +51,7 @@
     <property name="type-hint">dialog</property>
     <signal name="notify::page-setup" handler="redraw_page_layout_preview" swapped="no"/>
     <signal name="response" handler="error_dialogs" swapped="no"/>
-    <child internal-child="vbox">
+    <child internal-child="content_area">
       <object class="GtkBox" id="dialog-vbox1">
         <property name="orientation">vertical</property>
         <property name="spacing">2</property>
diff --git a/testsuite/gtk/builder.c b/testsuite/gtk/builder.c
index 6d320bf454..d47f91e5fc 100644
--- a/testsuite/gtk/builder.c
+++ b/testsuite/gtk/builder.c
@@ -918,7 +918,7 @@ test_children (void)
     "<interface>"
     "  <object class=\"GtkDialog\" id=\"dialog1\">"
     "    <property name=\"use_header_bar\">1</property>"
-    "    <child internal-child=\"vbox\">"
+    "    <child internal-child=\"content_area\">"
     "      <object class=\"GtkBox\" id=\"dialog1-vbox\">"
     "        <property name=\"orientation\">vertical</property>"
     "          <child internal-child=\"action_area\">"
@@ -961,7 +961,6 @@ test_children (void)
   g_assert (vbox != NULL);
   g_assert (GTK_IS_BOX (vbox));
   g_assert (gtk_orientable_get_orientation (GTK_ORIENTABLE (vbox)) == GTK_ORIENTATION_VERTICAL);
-  g_assert (strcmp (gtk_buildable_get_name (GTK_BUILDABLE (gtk_widget_get_parent (GTK_WIDGET (vbox)))), 
"dialog1") == 0);
   g_assert (strcmp (gtk_buildable_get_name (GTK_BUILDABLE (content_area)), "dialog1-vbox") == 0);
 
   action_area = gtk_builder_get_object (builder, "dialog1-action_area");
@@ -1334,7 +1333,7 @@ test_dialog (void)
   const gchar buffer1[] =
     "<interface>"
     "  <object class=\"GtkDialog\" id=\"dialog1\">"
-    "    <child internal-child=\"vbox\">"
+    "    <child internal-child=\"content_area\">"
     "      <object class=\"GtkBox\" id=\"dialog1-vbox\">"
     "        <property name=\"orientation\">vertical</property>"
     "          <child internal-child=\"action_area\">"


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