[gnome-builder] symbol-tree: add empty state for symbol tree



commit 038be225573ab98451affe91840ae3d5ff9e958b
Author: Christian Hergert <chergert redhat com>
Date:   Mon Oct 17 18:16:01 2016 -0700

    symbol-tree: add empty state for symbol tree

 plugins/symbol-tree/symbol-tree-panel.c  |   14 ++++++++++-
 plugins/symbol-tree/symbol-tree-panel.ui |   33 ++++++++++++++++++++++++-----
 2 files changed, 39 insertions(+), 8 deletions(-)
---
diff --git a/plugins/symbol-tree/symbol-tree-panel.c b/plugins/symbol-tree/symbol-tree-panel.c
index cec6e82..b4ac9fd 100644
--- a/plugins/symbol-tree/symbol-tree-panel.c
+++ b/plugins/symbol-tree/symbol-tree-panel.c
@@ -38,10 +38,12 @@ struct _SymbolTreePanel
 
   GCancellable   *cancellable;
   EggTaskCache   *symbols_cache;
-  IdeTree        *tree;
-  GtkSearchEntry *search_entry;
   GHashTable     *destroy_connected;
 
+  GtkSearchEntry *search_entry;
+  GtkStack       *stack;
+  IdeTree        *tree;
+
   IdeBuffer      *last_document;
   gsize           last_change_count;
 
@@ -84,6 +86,7 @@ get_cached_symbol_tree_cb (GObject      *object,
       if (!g_error_matches (error, G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED) &&
           !g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED))
         g_warning ("%s", error->message);
+      gtk_stack_set_visible_child_name (self->stack, "empty-state");
       return;
     }
 
@@ -111,6 +114,8 @@ get_cached_symbol_tree_cb (GObject      *object,
       while (gtk_tree_model_iter_next (model, &iter));
     }
 
+  gtk_stack_set_visible_child_name (self->stack, "symbols");
+
   IDE_EXIT;
 }
 
@@ -203,6 +208,10 @@ refresh_tree (SymbolTreePanel *self)
                                     get_cached_symbol_tree_cb,
                                     g_object_ref (self));
         }
+      else
+        {
+          gtk_stack_set_visible_child_name (self->stack, "empty-state");
+        }
     }
 }
 
@@ -336,6 +345,7 @@ symbol_tree_panel_class_init (SymbolTreePanelClass *klass)
   gtk_widget_class_set_css_name (widget_class, "symboltreepanel");
   gtk_widget_class_set_template_from_resource (widget_class, 
"/org/gnome/builder/plugins/symbol-tree/symbol-tree-panel.ui");
   gtk_widget_class_bind_template_child (widget_class, SymbolTreePanel, tree);
+  gtk_widget_class_bind_template_child (widget_class, SymbolTreePanel, stack);
   gtk_widget_class_bind_template_child (widget_class, SymbolTreePanel, search_entry);
 }
 
diff --git a/plugins/symbol-tree/symbol-tree-panel.ui b/plugins/symbol-tree/symbol-tree-panel.ui
index c6f3050..489534f 100644
--- a/plugins/symbol-tree/symbol-tree-panel.ui
+++ b/plugins/symbol-tree/symbol-tree-panel.ui
@@ -14,16 +14,37 @@
           </object>
         </child>
         <child>
-          <object class="GtkScrolledWindow">
-            <property name="expand">true</property>
+          <object class="GtkStack" id="stack">
             <property name="visible">true</property>
             <child>
-              <object class="IdeTree" id="tree">
-                <property name="activate-on-single-click">true</property>
-                <property name="headers-visible">false</property>
-                <property name="show-icons">true</property>
+              <object class="EggEmptyState">
+                <property name="border-width">12</property>
+                <property name="pixel-size">64</property>
+                <property name="icon-name">lang-function-symbolic</property>
+                <property name="title" translatable="yes">No symbols</property>
+                <property name="subtitle" translatable="yes">Open a file to see symbols within the 
file</property>
                 <property name="visible">true</property>
               </object>
+              <packing>
+                <property name="name">empty-state</property>
+              </packing>
+            </child>
+            <child>
+              <object class="GtkScrolledWindow">
+                <property name="expand">true</property>
+                <property name="visible">true</property>
+                <child>
+                  <object class="IdeTree" id="tree">
+                    <property name="activate-on-single-click">true</property>
+                    <property name="headers-visible">false</property>
+                    <property name="show-icons">true</property>
+                    <property name="visible">true</property>
+                  </object>
+                </child>
+              </object>
+              <packing>
+                <property name="name">symbols</property>
+              </packing>
             </child>
           </object>
         </child>


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