[gnome-todo/wip/gbsneto/plugins: 6/18] plugin-dialog: simplify empty placeholder logic
- From: Georges Basile Stavracas Neto <gbsneto src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-todo/wip/gbsneto/plugins: 6/18] plugin-dialog: simplify empty placeholder logic
- Date: Mon, 18 Jan 2016 19:05:13 +0000 (UTC)
commit 50a3b120b0feead46ccc2add2df630fc5402519d
Author: Georges Basile Stavracas Neto <georges stavracas gmail com>
Date: Fri Jan 15 23:34:39 2016 -0200
plugin-dialog: simplify empty placeholder logic
I totally forgot about gtk_list_box_set_placeholder.
data/ui/plugin-dialog.ui | 69 ++++++++++++++++++---------------------
src/plugin/gtd-plugin-dialog.c | 14 ++------
2 files changed, 36 insertions(+), 47 deletions(-)
---
diff --git a/data/ui/plugin-dialog.ui b/data/ui/plugin-dialog.ui
index 88fa735..58867da 100644
--- a/data/ui/plugin-dialog.ui
+++ b/data/ui/plugin-dialog.ui
@@ -24,43 +24,6 @@
<property name="transition_type">slide-left-right</property>
<property name="interpolate_size">True</property>
<child>
- <object class="GtkBox">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="halign">center</property>
- <property name="valign">center</property>
- <property name="hexpand">True</property>
- <property name="vexpand">True</property>
- <property name="orientation">vertical</property>
- <property name="spacing">12</property>
- <child>
- <object class="GtkImage">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="xalign">0.5</property>
- <property name="pixel_size">64</property>
- <property name="icon_name">preferences-system-symbolic</property>
- <style>
- <class name="dim-label"/>
- </style>
- </object>
- </child>
- <child>
- <object class="GtkLabel">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="label" translatable="yes">No extensions found</property>
- <style>
- <class name="dim-label"/>
- </style>
- </object>
- </child>
- </object>
- <packing>
- <property name="name">empty</property>
- </packing>
- </child>
- <child>
<object class="GtkScrolledWindow">
<property name="visible">True</property>
<property name="can_focus">True</property>
@@ -127,4 +90,36 @@
</object>
</child>
</template>
+ <object class="GtkBox" id="extension_list_placeholder">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="halign">center</property>
+ <property name="valign">center</property>
+ <property name="hexpand">True</property>
+ <property name="vexpand">True</property>
+ <property name="orientation">vertical</property>
+ <property name="spacing">18</property>
+ <child>
+ <object class="GtkImage">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="xalign">0.5</property>
+ <property name="pixel_size">64</property>
+ <property name="icon_name">preferences-system-symbolic</property>
+ <style>
+ <class name="dim-label"/>
+ </style>
+ </object>
+ </child>
+ <child>
+ <object class="GtkLabel">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="label" translatable="yes">No extensions found</property>
+ <style>
+ <class name="dim-label"/>
+ </style>
+ </object>
+ </child>
+ </object>
</interface>
diff --git a/src/plugin/gtd-plugin-dialog.c b/src/plugin/gtd-plugin-dialog.c
index 996a441..e8d91da 100644
--- a/src/plugin/gtd-plugin-dialog.c
+++ b/src/plugin/gtd-plugin-dialog.c
@@ -29,6 +29,7 @@ struct _GtdPluginDialog
GtkDialog parent;
GtkWidget *back_button;
+ GtkWidget *extension_list_placeholder;
GtkWidget *frame;
GtkWidget *listbox;
GtkWidget *stack;
@@ -221,11 +222,9 @@ plugin_unloaded (GtdPluginManager *manager,
GtdActivatable *activatable,
GtdPluginDialog *self)
{
- gboolean contains;
GList *children;
GList *l;
- contains = FALSE;
children = gtk_container_get_children (GTK_CONTAINER (self->listbox));
for (l = children; l != NULL; l = l->next)
@@ -237,18 +236,10 @@ plugin_unloaded (GtdPluginManager *manager,
if (row_activatable == activatable)
{
gtk_container_remove (GTK_CONTAINER (self->listbox), l->data);
- contains = TRUE;
break;
}
}
- /* If there are no extensions left, go back to the 'empty' view */
- if (g_list_length (children) == 0 ||
- (g_list_length (children) == 1 && contains))
- {
- gtk_stack_set_visible_child_name (GTK_STACK (self->stack), "empty");
- }
-
g_free (children);
}
@@ -273,6 +264,7 @@ gtd_plugin_dialog_class_init (GtdPluginDialogClass *klass)
gtk_widget_class_set_template_from_resource (widget_class, "/org/gnome/todo/ui/plugin-dialog.ui");
gtk_widget_class_bind_template_child (widget_class, GtdPluginDialog, back_button);
+ gtk_widget_class_bind_template_child (widget_class, GtdPluginDialog, extension_list_placeholder);
gtk_widget_class_bind_template_child (widget_class, GtdPluginDialog, frame);
gtk_widget_class_bind_template_child (widget_class, GtdPluginDialog, listbox);
gtk_widget_class_bind_template_child (widget_class, GtdPluginDialog, stack);
@@ -306,6 +298,8 @@ gtd_plugin_dialog_init (GtdPluginDialog *self)
sort_extensions,
NULL,
NULL);
+
+ gtk_list_box_set_placeholder (GTK_LIST_BOX (self->listbox), self->extension_list_placeholder);
}
GtkWidget*
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]