[gnome-panel] menu: add GpMenu::loaded signal
- From: Alberts Muktupāvels <muktupavels src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-panel] menu: add GpMenu::loaded signal
- Date: Thu, 13 Sep 2018 09:22:09 +0000 (UTC)
commit c268691b8759c868538a717cf9945357cf395fe6
Author: Alberts Muktupāvels <alberts muktupavels gmail com>
Date: Wed Sep 12 02:01:09 2018 +0300
menu: add GpMenu::loaded signal
modules/menu/gp-menu.c | 26 +++++++++++++++++++++++---
1 file changed, 23 insertions(+), 3 deletions(-)
---
diff --git a/modules/menu/gp-menu.c b/modules/menu/gp-menu.c
index 89ef0172f..9d6f69d39 100644
--- a/modules/menu/gp-menu.c
+++ b/modules/menu/gp-menu.c
@@ -34,6 +34,7 @@ struct _GpMenu
GMenuTree *tree;
+ gboolean loaded;
gboolean empty;
GpAppendMenuItemsFunc append_func;
@@ -47,6 +48,15 @@ struct _GpMenu
gchar *path;
};
+enum
+{
+ LOADED,
+
+ LAST_SIGNAL
+};
+
+static guint menu_signals[LAST_SIGNAL] = { 0 };
+
enum
{
PROP_0,
@@ -292,14 +302,13 @@ static void
menu_reload (GpMenu *menu)
{
GError *error;
- gboolean loaded;
GList *children;
gboolean empty;
gtk_container_foreach (GTK_CONTAINER (menu), remove_item, NULL);
error = NULL;
- loaded = gmenu_tree_load_sync (menu->tree, &error);
+ menu->loaded = gmenu_tree_load_sync (menu->tree, &error);
if (error != NULL)
{
@@ -309,7 +318,7 @@ menu_reload (GpMenu *menu)
g_clear_error (&error);
}
- if (loaded)
+ if (menu->loaded)
{
const gchar *path;
GMenuTreeDirectory *directory;
@@ -328,6 +337,8 @@ menu_reload (GpMenu *menu)
if (menu->append_func != NULL)
menu->append_func (GTK_MENU (menu), menu->append_data);
+
+ g_signal_emit (menu, menu_signals[LOADED], 0);
}
children = gtk_container_get_children (GTK_CONTAINER (menu));
@@ -562,6 +573,14 @@ install_properties (GObjectClass *object_class)
g_object_class_install_properties (object_class, LAST_PROP, menu_properties);
}
+static void
+install_signals (void)
+{
+ menu_signals[LOADED] =
+ g_signal_new ("loaded", GP_TYPE_MENU, G_SIGNAL_RUN_LAST,
+ 0, NULL, NULL, NULL, G_TYPE_NONE, 0);
+}
+
static void
gp_menu_class_init (GpMenuClass *menu_class)
{
@@ -576,6 +595,7 @@ gp_menu_class_init (GpMenuClass *menu_class)
object_class->set_property = gp_menu_set_property;
install_properties (object_class);
+ install_signals ();
}
static void
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]