[gnome-builder] editor-sidebar: move code for more reuse



commit a46d1c5bb77c59271115d1add017bb56a2c767fd
Author: Christian Hergert <chergert redhat com>
Date:   Tue Nov 14 15:00:20 2017 -0800

    editor-sidebar: move code for more reuse
    
    I'm going to need this, so shuffling it as a separate commit.

 src/libide/editor/ide-editor-sidebar.c |   48 ++++++++++++++++---------------
 1 files changed, 25 insertions(+), 23 deletions(-)
---
diff --git a/src/libide/editor/ide-editor-sidebar.c b/src/libide/editor/ide-editor-sidebar.c
index 2e4ecce..d9bcc9d 100644
--- a/src/libide/editor/ide-editor-sidebar.c
+++ b/src/libide/editor/ide-editor-sidebar.c
@@ -118,6 +118,31 @@ ide_editor_sidebar_open_pages_row_activated (IdeEditorSidebar *self,
 }
 
 static void
+ide_editor_sidebar_open_pages_items_changed (IdeEditorSidebar *self,
+                                             guint             position,
+                                             guint             added,
+                                             guint             removed,
+                                             GListModel       *model)
+{
+  g_assert (IDE_IS_EDITOR_SIDEBAR (self));
+  g_assert (G_IS_LIST_MODEL (model));
+
+  /*
+   * Sets the visibility of our page list widgets only when the listmodel has
+   * views within it. We try to be careful about being safe when the widget is
+   * in destruction and an items-changed signal arrives.
+   */
+
+  if (self->open_pages_section != NULL)
+    {
+      gboolean has_items = g_list_model_get_n_items (model) > 0;
+      gboolean show = g_settings_get_boolean (self->settings, "show-open-files");
+
+      gtk_widget_set_visible (GTK_WIDGET (self->open_pages_section), show && has_items);
+    }
+}
+
+static void
 ide_editor_sidebar_destroy (GtkWidget *widget)
 {
   IdeEditorSidebar *self = (IdeEditorSidebar *)widget;
@@ -406,29 +431,6 @@ create_open_page_row (gpointer item,
   return GTK_WIDGET (row);
 }
 
-static void
-ide_editor_sidebar_open_pages_items_changed (IdeEditorSidebar *self,
-                                             guint             position,
-                                             guint             added,
-                                             guint             removed,
-                                             GListModel       *model)
-{
-  g_assert (IDE_IS_EDITOR_SIDEBAR (self));
-  g_assert (G_IS_LIST_MODEL (model));
-
-  /*
-   * Sets the visibility of our page list widgets only when the listmodel has
-   * views within it. We try to be careful about being safe when the widget is
-   * in destruction and an items-changed signal arrives.
-   */
-
-  if (self->open_pages_section != NULL)
-    {
-      gboolean has_items = g_list_model_get_n_items (model) > 0;
-      gtk_widget_set_visible (GTK_WIDGET (self->open_pages_section), has_items);
-    }
-}
-
 /**
  * _ide_editor_sidebar_set_open_pages:
  * @self: a #IdeEditorSidebar


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