[gnome-text-editor] window: add page indicator to titlebar



commit 08bb869e3d6959ff84c7da9fb4b289884bec866b
Author: Christian Hergert <chergert redhat com>
Date:   Mon Jan 10 15:08:40 2022 -0800

    window: add page indicator to titlebar
    
    That way we have the same information as the tab when the tab is not
    visible to the user.
    
    Related #262

 src/editor-window-private.h |  1 +
 src/editor-window.c         | 18 ++++++++++++++++++
 src/editor-window.ui        | 28 ++++++++++++++++++++++------
 3 files changed, 41 insertions(+), 6 deletions(-)
---
diff --git a/src/editor-window-private.h b/src/editor-window-private.h
index 27ec6b5..5ddd055 100644
--- a/src/editor-window-private.h
+++ b/src/editor-window-private.h
@@ -44,6 +44,7 @@ struct _EditorWindow
   GtkLabel             *title;
   GtkLabel             *subtitle;
   GtkLabel             *is_modified;
+  GtkImage             *indicator;
   EditorOpenPopover    *open_menu_popover;
   GtkBox               *position_box;
   EditorPositionLabel  *position_label;
diff --git a/src/editor-window.c b/src/editor-window.c
index 4e5e44b..51369aa 100644
--- a/src/editor-window.c
+++ b/src/editor-window.c
@@ -750,6 +750,16 @@ on_show_help_overlay_cb (GtkWidget  *widget,
     }
 }
 
+static gboolean
+indicator_to_boolean (GBinding     *binding,
+                      const GValue *from_value,
+                      GValue       *to_value,
+                      gpointer      user_data)
+{
+  g_value_set_boolean (to_value, g_value_get_object (from_value) != NULL);
+  return TRUE;
+}
+
 static void
 editor_window_dispose (GObject *object)
 {
@@ -848,6 +858,7 @@ editor_window_class_init (EditorWindowClass *klass)
   gtk_widget_class_set_template_from_resource (widget_class, "/org/gnome/TextEditor/ui/editor-window.ui");
 
   gtk_widget_class_bind_template_child (widget_class, EditorWindow, empty);
+  gtk_widget_class_bind_template_child (widget_class, EditorWindow, indicator);
   gtk_widget_class_bind_template_child (widget_class, EditorWindow, is_modified);
   gtk_widget_class_bind_template_child (widget_class, EditorWindow, open_menu_button);
   gtk_widget_class_bind_template_child (widget_class, EditorWindow, open_menu_popover);
@@ -1004,6 +1015,13 @@ editor_window_init (EditorWindow *self)
                                   self, "title",
                                   G_BINDING_SYNC_CREATE,
                                   transform_window_title, NULL, NULL, NULL);
+  editor_binding_group_bind_full (self->page_bindings, "indicator",
+                                  self->indicator, "visible",
+                                  G_BINDING_SYNC_CREATE,
+                                  indicator_to_boolean, NULL, NULL, NULL);
+  editor_binding_group_bind (self->page_bindings, "indicator",
+                             self->indicator, "gicon",
+                             G_BINDING_SYNC_CREATE);
   editor_binding_group_bind (self->page_bindings, "title",
                              self->title, "label",
                              G_BINDING_SYNC_CREATE);
diff --git a/src/editor-window.ui b/src/editor-window.ui
index f3aefc8..8eed29a 100644
--- a/src/editor-window.ui
+++ b/src/editor-window.ui
@@ -42,12 +42,28 @@
                   </object>
                 </child>
                 <child>
-                  <object class="GtkLabel" id="subtitle">
-                    <property name="ellipsize">middle</property>
-                    <attributes>
-                      <attribute name="scale" value="0.8222"/>
-                      <attribute name="foreground-alpha" value="32767"/>
-                    </attributes>
+                  <object class="GtkCenterBox">
+                    <child type="start">
+                      <object class="GtkImage" id="indicator">
+                        <property name="hexpand">true</property>
+                        <property name="halign">end</property>
+                        <property name="visible">false</property>
+                        <property name="margin-end">6</property>
+                        <property name="pixel-size">12</property>
+                        <style>
+                          <class name="dim-label"/>
+                        </style>
+                      </object>
+                    </child>
+                    <child type="center">
+                      <object class="GtkLabel" id="subtitle">
+                        <property name="ellipsize">middle</property>
+                        <attributes>
+                          <attribute name="scale" value="0.8222"/>
+                          <attribute name="foreground-alpha" value="32767"/>
+                        </attributes>
+                      </object>
+                    </child>
                   </object>
                 </child>
               </object>


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