aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLars Uebernickel <lars.uebernickel@canonical.com>2012-12-20 17:46:15 +0100
committerLars Uebernickel <lars.uebernickel@canonical.com>2012-12-20 17:46:15 +0100
commitdd756106c02cabc79c7429e42ff6658bd37bba6c (patch)
treed2b3cec61049e1c8851f863d931ca4c706d2158c
parent27613150b42e0846f3741e4b4db1b7271b432fad (diff)
downloadayatana-indicator-messages-dd756106c02cabc79c7429e42ff6658bd37bba6c.tar.gz
ayatana-indicator-messages-dd756106c02cabc79c7429e42ff6658bd37bba6c.tar.bz2
ayatana-indicator-messages-dd756106c02cabc79c7429e42ff6658bd37bba6c.zip
ImApplicationList: add "remove-all" signal
This is a temporary hack to work around a crash in QMenuModel.
-rw-r--r--src/im-application-list.c12
-rw-r--r--src/im-phone-menu.c20
-rw-r--r--src/im-phone-menu.h2
-rw-r--r--src/messages-service.c2
4 files changed, 36 insertions, 0 deletions
diff --git a/src/im-application-list.c b/src/im-application-list.c
index 959a820..9a673c9 100644
--- a/src/im-application-list.c
+++ b/src/im-application-list.c
@@ -45,6 +45,7 @@ enum
MESSAGE_ADDED,
MESSAGE_REMOVED,
APP_STOPPED,
+ REMOVE_ALL,
N_SIGNALS
};
@@ -251,6 +252,8 @@ im_application_list_remove_all (GSimpleAction *action,
GHashTableIter iter;
Application *app;
+ g_signal_emit (list, signals[REMOVE_ALL], 0);
+
g_hash_table_iter_init (&iter, list->applications);
while (g_hash_table_iter_next (&iter, NULL, (gpointer *) &app))
{
@@ -377,6 +380,15 @@ im_application_list_class_init (ImApplicationListClass *klass)
G_TYPE_NONE,
1,
G_TYPE_STRING);
+
+ signals[REMOVE_ALL] = g_signal_new ("remove-all",
+ IM_TYPE_APPLICATION_LIST,
+ G_SIGNAL_RUN_FIRST,
+ 0,
+ NULL, NULL,
+ g_cclosure_marshal_VOID__VOID,
+ G_TYPE_NONE,
+ 0);
}
static void
diff --git a/src/im-phone-menu.c b/src/im-phone-menu.c
index 922dc82..3d5f94d 100644
--- a/src/im-phone-menu.c
+++ b/src/im-phone-menu.c
@@ -309,3 +309,23 @@ im_phone_menu_remove_application (ImPhoneMenu *menu,
im_phone_menu_remove_all_for_app (menu->source_section, app_id);
im_phone_menu_remove_all_for_app (menu->message_section, app_id);
}
+
+void
+im_phone_menu_remove_all (ImPhoneMenu *menu)
+{
+ g_return_if_fail (IM_IS_PHONE_MENU (menu));
+
+ while (g_menu_model_get_n_items (G_MENU_MODEL (menu->toplevel_menu)))
+ g_menu_remove (menu->toplevel_menu, 0);
+
+ g_object_unref (menu->message_section);
+ g_object_unref (menu->source_section);
+
+ menu->message_section = g_menu_new ();
+ menu->source_section = g_menu_new ();
+
+ g_signal_connect_swapped (menu->message_section, "items-changed",
+ G_CALLBACK (im_phone_menu_update_toplevel), menu);
+ g_signal_connect_swapped (menu->source_section, "items-changed",
+ G_CALLBACK (im_phone_menu_update_toplevel), menu);
+}
diff --git a/src/im-phone-menu.h b/src/im-phone-menu.h
index 84908e2..258ce73 100644
--- a/src/im-phone-menu.h
+++ b/src/im-phone-menu.h
@@ -65,4 +65,6 @@ void im_phone_menu_remove_source (ImPhoneMenu *men
void im_phone_menu_remove_application (ImPhoneMenu *menu,
const gchar *app_id);
+void im_phone_menu_remove_all (ImPhoneMenu *menu);
+
#endif
diff --git a/src/messages-service.c b/src/messages-service.c
index 27bce4e..c2ca1a0 100644
--- a/src/messages-service.c
+++ b/src/messages-service.c
@@ -172,6 +172,8 @@ main (int argc, char ** argv)
G_CALLBACK (im_phone_menu_remove_message), menu);
g_signal_connect_swapped (applications, "app-stopped",
G_CALLBACK (im_phone_menu_remove_application), menu);
+ g_signal_connect_swapped (applications, "remove-all",
+ G_CALLBACK (im_phone_menu_remove_all), menu);
g_main_loop_run(mainloop);