[gnome-builder] editor: add empty state icon and blurb



commit 99922fe832ba3e18d2d0123ab0f98d107409971b
Author: Christian Hergert <chergert redhat com>
Date:   Mon Feb 15 19:51:01 2016 -0800

    editor: add empty state icon and blurb

 data/ui/ide-editor-perspective.ui      |   50 +++++++++++++++++++++++++++++++-
 libide/editor/ide-editor-perspective.c |   21 +++++++++++++
 libide/ide-layout-grid.c               |   14 +++++++++
 3 files changed, 84 insertions(+), 1 deletions(-)
---
diff --git a/data/ui/ide-editor-perspective.ui b/data/ui/ide-editor-perspective.ui
index ae49965..e3e14a7 100644
--- a/data/ui/ide-editor-perspective.ui
+++ b/data/ui/ide-editor-perspective.ui
@@ -10,11 +10,59 @@
           </object>
         </child>
         <child internal-child="stack">
-          <object class="GtkStack">
+          <object class="GtkStack" id="content_stack">
+            <child>
+              <object class="GtkBox">
+                <property name="halign">center</property>
+                <property name="valign">center</property>
+                <property name="orientation">vertical</property>
+                <property name="spacing">12</property>
+                <property name="visible">true</property>
+                <child>
+                  <object class="GtkImage">
+                    <property name="icon-name">text-editor-symbolic</property>
+                    <property name="pixel-size">128</property>
+                    <property name="visible">true</property>
+                    <style>
+                      <class name="dim-label"/>
+                    </style>
+                  </object>
+                </child>
+                <child>
+                  <object class="GtkLabel">
+                    <property name="label" translatable="yes">No open files</property>
+                    <property name="visible">true</property>
+                    <style>
+                      <class name="dim-label"/>
+                    </style>
+                    <attributes>
+                      <attribute name="scale" value="2.0"/>
+                      <attribute name="weight" value="bold"/>
+                    </attributes>
+                  </object>
+                </child>
+                <child>
+                  <object class="GtkLabel">
+                    <property name="label" translatable="yes">Try opening a file using the search box at the 
top</property>
+                    <property name="wrap">true</property>
+                    <property name="visible">true</property>
+                    <style>
+                      <class name="dim-label"/>
+                    </style>
+                  </object>
+                </child>
+              </object>
+              <packing>
+                <property name="name">empty_state</property>
+              </packing>
+            </child>
             <child>
               <object class="IdeLayoutGrid" id="grid">
                 <property name="visible">true</property>
               </object>
+              <packing>
+                <property name="name">grid</property>
+              </packing>
             </child>
           </object>
         </child>
diff --git a/libide/editor/ide-editor-perspective.c b/libide/editor/ide-editor-perspective.c
index 9f4c0a9..4aaa499 100644
--- a/libide/editor/ide-editor-perspective.c
+++ b/libide/editor/ide-editor-perspective.c
@@ -313,6 +313,21 @@ ide_editor_perspective_add (GtkContainer *container,
 }
 
 static void
+ide_editor_perspective_grid_empty (IdeEditorPerspective *self,
+                                   IdeLayoutGrid        *grid)
+{
+  GtkWidget *stack;
+
+  g_assert (IDE_IS_EDITOR_PERSPECTIVE (self));
+  g_assert (IDE_IS_LAYOUT_GRID (grid));
+
+  stack = gtk_widget_get_ancestor (GTK_WIDGET (grid), GTK_TYPE_STACK);
+
+  if (stack != NULL)
+    gtk_stack_set_visible_child_name (GTK_STACK (stack), "empty_state");
+}
+
+static void
 ide_editor_perspective_class_init (IdeEditorPerspectiveClass *klass)
 {
   GObjectClass *object_class = G_OBJECT_CLASS (klass);
@@ -374,6 +389,12 @@ ide_editor_perspective_init (IdeEditorPerspective *self)
 
   gtk_widget_init_template (GTK_WIDGET (self));
 
+  g_signal_connect_object (self->grid,
+                           "empty",
+                           G_CALLBACK (ide_editor_perspective_grid_empty),
+                           self,
+                           G_CONNECT_SWAPPED);
+
   g_action_map_add_action_entries (G_ACTION_MAP (self->actions), entries,
                                    G_N_ELEMENTS (entries), self);
 
diff --git a/libide/ide-layout-grid.c b/libide/ide-layout-grid.c
index 377dfd1..bec9f20 100644
--- a/libide/ide-layout-grid.c
+++ b/libide/ide-layout-grid.c
@@ -35,8 +35,15 @@ struct _IdeLayoutGrid
 
 G_DEFINE_TYPE (IdeLayoutGrid, ide_layout_grid, GTK_TYPE_BIN)
 
+enum {
+  EMPTY,
+  LAST_SIGNAL
+};
+
 static void ide_layout_grid_make_homogeneous (IdeLayoutGrid *self);
 
+static guint signals [LAST_SIGNAL];
+
 GtkWidget *
 ide_layout_grid_new (void)
 {
@@ -255,6 +262,7 @@ ide_layout_grid_stack_empty (IdeLayoutGrid  *self,
   if (g_list_length (stacks) == 1)
     {
       ide_widget_action (GTK_WIDGET (self), "perspective", "global-search", NULL);
+      g_signal_emit (self, signals [EMPTY], 0);
       goto cleanup;
     }
 
@@ -818,6 +826,12 @@ ide_layout_grid_class_init (IdeLayoutGridClass *klass)
   widget_class->hierarchy_changed = ide_layout_grid_hierarchy_changed;
   widget_class->size_allocate = ide_layout_grid_size_allocate;
 
+  signals [EMPTY] =
+    g_signal_new ("empty",
+                  G_TYPE_FROM_CLASS (klass),
+                  G_SIGNAL_RUN_LAST,
+                  0, NULL, NULL, NULL, G_TYPE_NONE, 0);
+
   gtk_widget_class_set_css_name (widget_class, "layoutgrid");
 }
 


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