[gnome-builder] project-tree: create node with child properties



commit ef70548d2aa2921d1f8c389e807cd02765aea40b
Author: Christian Hergert <chergert redhat com>
Date:   Sat Dec 9 03:23:26 2017 -0800

    project-tree: create node with child properties
    
    We no longer need to set these properties after attaching the
    node to the tree, so this can be cleaned up a bit.

 src/plugins/project-tree/gb-project-tree-builder.c |   14 ++++++--------
 1 files changed, 6 insertions(+), 8 deletions(-)
---
diff --git a/src/plugins/project-tree/gb-project-tree-builder.c 
b/src/plugins/project-tree/gb-project-tree-builder.c
index fcc5071..cdf98f6 100644
--- a/src/plugins/project-tree/gb-project-tree-builder.c
+++ b/src/plugins/project-tree/gb-project-tree-builder.c
@@ -101,7 +101,7 @@ gb_project_tree_builder_add (GbProjectTreeBuilder *self,
   display_name = gb_project_file_get_display_name (item);
   icon_name = gb_project_file_get_icon_name (item);
 
-  if (g_strcmp0 (icon_name, "folder-symbolic") == 0)
+  if (is_dir)
     expanded = "folder-open-symbolic";
 
   is_dir = g_file_info_get_file_type (file_info) == G_FILE_TYPE_DIRECTORY;
@@ -350,6 +350,7 @@ build_file (GbProjectTreeBuilder *self,
       const gchar *icon_name;
       const gchar *expanded = NULL;
       gboolean ignored;
+      gboolean is_dir;
 
       name = g_file_info_get_name (item_file_info);
       item_file = g_file_get_child (file, name);
@@ -362,12 +363,15 @@ build_file (GbProjectTreeBuilder *self,
 
       display_name = gb_project_file_get_display_name (item);
       icon_name = gb_project_file_get_icon_name (item);
+      is_dir = g_file_info_get_file_type (item_file_info) == G_FILE_TYPE_DIRECTORY;
 
-      if (g_strcmp0 (icon_name, "folder-symbolic") == 0)
+      if (is_dir)
         expanded = "folder-open-symbolic";
 
       child = g_object_new (DZL_TYPE_TREE_NODE,
                             "icon-name", icon_name,
+                            "children-possible", is_dir,
+                            "reset-on-collapse", is_dir,
                             "expanded-icon-name", expanded,
                             "text", display_name,
                             "item", item,
@@ -376,12 +380,6 @@ build_file (GbProjectTreeBuilder *self,
 
       dzl_tree_node_insert_sorted (node, child, compare_nodes_func, self);
 
-      if (g_file_info_get_file_type (item_file_info) == G_FILE_TYPE_DIRECTORY)
-        {
-          dzl_tree_node_set_children_possible (child, TRUE);
-          dzl_tree_node_set_reset_on_collapse (child, TRUE);
-        }
-
       count++;
     }
 


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