[gnome-text-editor] infobar: move widgetry into a box



commit 897677e4e261ee3aefbefca900ef50f25b82811a
Author: Christian Hergert <chergert redhat com>
Date:   Mon Jan 10 15:31:09 2022 -0800

    infobar: move widgetry into a box
    
    So we can add additional infobar/banner at some point into a single
    EditorInfoBar widget.

 src/editor-info-bar.c  |  6 ++++-
 src/editor-info-bar.ui | 61 +++++++++++++++++++++++++++-----------------------
 2 files changed, 38 insertions(+), 29 deletions(-)
---
diff --git a/src/editor-info-bar.c b/src/editor-info-bar.c
index e5bf4c2..9a17161 100644
--- a/src/editor-info-bar.c
+++ b/src/editor-info-bar.c
@@ -31,6 +31,9 @@ struct _EditorInfoBar
 
   EditorDocument *document;
 
+  GtkBox         *box;
+
+  /* Discard widgetry */
   GtkInfoBar     *infobar;
   GtkButton      *close;
   GtkButton      *discard;
@@ -144,7 +147,7 @@ editor_info_bar_dispose (GObject *object)
   EditorInfoBar *self = (EditorInfoBar *)object;
 
   g_clear_object (&self->document);
-  g_clear_pointer ((GtkWidget **)&self->infobar, gtk_widget_unparent);
+  g_clear_pointer ((GtkWidget **)&self->box, gtk_widget_unparent);
 
   G_OBJECT_CLASS (editor_info_bar_parent_class)->dispose (object);
 }
@@ -220,6 +223,7 @@ editor_info_bar_class_init (EditorInfoBarClass *klass)
 
   gtk_widget_class_set_layout_manager_type (widget_class, GTK_TYPE_BIN_LAYOUT);
   gtk_widget_class_set_template_from_resource (widget_class, "/org/gnome/TextEditor/ui/editor-info-bar.ui");
+  gtk_widget_class_bind_template_child (widget_class, EditorInfoBar, box);
   gtk_widget_class_bind_template_child (widget_class, EditorInfoBar, discard);
   gtk_widget_class_bind_template_child (widget_class, EditorInfoBar, infobar);
   gtk_widget_class_bind_template_child (widget_class, EditorInfoBar, save);
diff --git a/src/editor-info-bar.ui b/src/editor-info-bar.ui
index 519e9ce..fbce818 100644
--- a/src/editor-info-bar.ui
+++ b/src/editor-info-bar.ui
@@ -2,40 +2,45 @@
 <interface>
   <template class="EditorInfoBar" parent="GtkWidget">
     <child>
-      <object class="GtkInfoBar" id="infobar">
-        <property name="message-type">warning</property>
-        <property name="show-close-button">True</property>
-        <property name="revealed">False</property>
+      <object class="GtkBox" id="box">
+        <property name="orientation">vertical</property>
         <child>
-          <object class="GtkBox">
-            <property name="orientation">vertical</property>
+          <object class="GtkInfoBar" id="infobar">
+            <property name="message-type">warning</property>
+            <property name="show-close-button">True</property>
+            <property name="revealed">False</property>
             <child>
-              <object class="GtkLabel" id="title">
-                <property name="halign">start</property>
-                <property name="label" translatable="yes">Document Restored</property>
-                <attributes>
-                  <attribute name="weight" value="bold"/>
-                </attributes>
+              <object class="GtkBox">
+                <property name="orientation">vertical</property>
+                <child>
+                  <object class="GtkLabel" id="title">
+                    <property name="halign">start</property>
+                    <property name="label" translatable="yes">Document Restored</property>
+                    <attributes>
+                      <attribute name="weight" value="bold"/>
+                    </attributes>
+                  </object>
+                </child>
+                <child>
+                  <object class="GtkLabel" id="subtitle">
+                    <property name="halign">start</property>
+                    <property name="label" translatable="yes">Unsaved document has been restored.</property>
+                  </object>
+                </child>
               </object>
             </child>
-            <child>
-              <object class="GtkLabel" id="subtitle">
-                <property name="halign">start</property>
-                <property name="label" translatable="yes">Unsaved document has been restored.</property>
+            <child type="action">
+              <object class="GtkButton" id="discard">
+                <property name="label" translatable="yes">_Discard…</property>
+                <property name="use-underline">True</property>
+              </object>
+            </child>
+            <child type="action">
+              <object class="GtkButton" id="save">
+                <property name="margin-start">6</property>
+                <property name="use-underline">True</property>
               </object>
             </child>
-          </object>
-        </child>
-        <child type="action">
-          <object class="GtkButton" id="discard">
-            <property name="label" translatable="yes">_Discard…</property>
-            <property name="use-underline">True</property>
-          </object>
-        </child>
-        <child type="action">
-          <object class="GtkButton" id="save">
-            <property name="margin-start">6</property>
-            <property name="use-underline">True</property>
           </object>
         </child>
       </object>


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