[gnome-builder/wip/chergert/layout: 18/118] editor: handle modified state properly after closing last document



commit 2c4ce2883acf421b4aab773a9dc9b91b6e89b1e5
Author: Christian Hergert <chergert redhat com>
Date:   Tue Jun 27 18:19:49 2017 -0700

    editor: handle modified state properly after closing last document

 libide/layout/ide-layout-private.h      |    4 ++++
 libide/layout/ide-layout-stack-header.c |   20 +++++++++++++++-----
 libide/layout/ide-layout-stack-header.h |    2 --
 libide/layout/ide-layout-stack.c        |    6 +++++-
 4 files changed, 24 insertions(+), 8 deletions(-)
---
diff --git a/libide/layout/ide-layout-private.h b/libide/layout/ide-layout-private.h
index df1fbe9..ae56aad 100644
--- a/libide/layout/ide-layout-private.h
+++ b/libide/layout/ide-layout-private.h
@@ -51,5 +51,9 @@ void            _ide_layout_stack_header_hide             (IdeLayoutStackHeader
 void            _ide_layout_stack_header_popdown          (IdeLayoutStackHeader *self);
 void            _ide_layout_stack_header_set_views        (IdeLayoutStackHeader *self,
                                                            GListModel           *model);
+void            _ide_layout_stack_header_set_title        (IdeLayoutStackHeader *self,
+                                                           const gchar          *title);
+void            _ide_layout_stack_header_set_modified     (IdeLayoutStackHeader *self,
+                                                           gboolean              modified);
 
 G_END_DECLS
diff --git a/libide/layout/ide-layout-stack-header.c b/libide/layout/ide-layout-stack-header.c
index cc9dd56..1c9597f 100644
--- a/libide/layout/ide-layout-stack-header.c
+++ b/libide/layout/ide-layout-stack-header.c
@@ -311,7 +311,7 @@ ide_layout_stack_header_set_property (GObject      *object,
   switch (prop_id)
     {
     case PROP_MODIFIED:
-      gtk_widget_set_visible (GTK_WIDGET (self->title_modified), g_value_get_boolean (value));
+      _ide_layout_stack_header_set_modified (self, g_value_get_boolean (value));
       break;
 
     case PROP_SHOW_CLOSE_BUTTON:
@@ -319,7 +319,7 @@ ide_layout_stack_header_set_property (GObject      *object,
       break;
 
     case PROP_TITLE:
-      ide_layout_stack_header_set_title (self, g_value_get_string (value));
+      _ide_layout_stack_header_set_title (self, g_value_get_string (value));
       break;
 
     default:
@@ -350,7 +350,7 @@ ide_layout_stack_header_class_init (IdeLayoutStackHeaderClass *klass)
                           "Modified",
                           "If the current document is modified",
                           FALSE,
-                          (G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
+                          (G_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY | G_PARAM_STATIC_STRINGS));
 
   properties [PROP_TITLE] =
     g_param_spec_string ("title",
@@ -439,11 +439,21 @@ ide_layout_stack_header_add_custom_title (IdeLayoutStackHeader *self,
 }
 
 void
-ide_layout_stack_header_set_title (IdeLayoutStackHeader *self,
-                                   const gchar          *title)
+_ide_layout_stack_header_set_title (IdeLayoutStackHeader *self,
+                                    const gchar          *title)
 {
   g_return_if_fail (IDE_IS_LAYOUT_STACK_HEADER (self));
 
   gtk_label_set_label (GTK_LABEL (self->title_label), title);
   g_object_notify_by_pspec (G_OBJECT (self), properties [PROP_TITLE]);
 }
+
+void
+_ide_layout_stack_header_set_modified (IdeLayoutStackHeader *self,
+                                       gboolean              modified)
+{
+  g_return_if_fail (IDE_IS_LAYOUT_STACK_HEADER (self));
+
+  gtk_widget_set_visible (GTK_WIDGET (self->title_modified), modified);
+  g_object_notify_by_pspec (G_OBJECT (self), properties [PROP_MODIFIED]);
+}
diff --git a/libide/layout/ide-layout-stack-header.h b/libide/layout/ide-layout-stack-header.h
index 5952836..e923775 100644
--- a/libide/layout/ide-layout-stack-header.h
+++ b/libide/layout/ide-layout-stack-header.h
@@ -27,8 +27,6 @@ G_BEGIN_DECLS
 G_DECLARE_FINAL_TYPE (IdeLayoutStackHeader, ide_layout_stack_header, IDE, LAYOUT_STACK_HEADER, 
DzlPriorityBox)
 
 GtkWidget *ide_layout_stack_header_new              (void);
-void       ide_layout_stack_header_set_title        (IdeLayoutStackHeader *self,
-                                                     const gchar          *title);
 void       ide_layout_stack_header_add_custom_title (IdeLayoutStackHeader *self,
                                                      GtkWidget            *widget,
                                                      gint                  priority);
diff --git a/libide/layout/ide-layout-stack.c b/libide/layout/ide-layout-stack.c
index f5f30ac..6db2a55 100644
--- a/libide/layout/ide-layout-stack.c
+++ b/libide/layout/ide-layout-stack.c
@@ -115,8 +115,12 @@ ide_layout_stack_bindings_notify_source (IdeLayoutStack  *self,
   g_assert (IDE_IS_LAYOUT_STACK (self));
 
   source = dzl_binding_group_get_source (bindings);
+
   if (source == NULL)
-    ide_layout_stack_header_set_title (priv->header, _("No Open Pages"));
+    {
+      _ide_layout_stack_header_set_title (priv->header, _("No Open Pages"));
+      _ide_layout_stack_header_set_modified (priv->header, FALSE);
+    }
 }
 
 static void


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