diff options
author | Guillaume Desmottes <guillaume.desmottes@collabora.co.uk> | 2011-12-14 19:54:37 +0800 |
---|---|---|
committer | Guillaume Desmottes <guillaume.desmottes@collabora.co.uk> | 2011-12-14 20:24:04 +0800 |
commit | a5bde7ca2676d538c0534b7acaf72ec47005649b (patch) | |
tree | e0eaff2be38e68d479f8bdce88281a5e949190bb | |
parent | fe992c09a3401012f17058a7e2571617591729fc (diff) | |
download | gsoc2013-empathy-a5bde7ca2676d538c0534b7acaf72ec47005649b.tar gsoc2013-empathy-a5bde7ca2676d538c0534b7acaf72ec47005649b.tar.gz gsoc2013-empathy-a5bde7ca2676d538c0534b7acaf72ec47005649b.tar.bz2 gsoc2013-empathy-a5bde7ca2676d538c0534b7acaf72ec47005649b.tar.lz gsoc2013-empathy-a5bde7ca2676d538c0534b7acaf72ec47005649b.tar.xz gsoc2013-empathy-a5bde7ca2676d538c0534b7acaf72ec47005649b.tar.zst gsoc2013-empathy-a5bde7ca2676d538c0534b7acaf72ec47005649b.zip |
individual_menu_add_personas: add the block menu item, if needed
This allow user to select the personas he wants to block.
Note that I didn't pass an EmpathyContact as second argument to
empathy_individiual_block_menu_item_new() as we currently do with most
item_new() methods. Instead I just craft a new individual containing only the
persona we care about. This approach is much cleaner as we don't have to deal
with 2 different code paths. I filed bug #666163 to do the same with the
existing functions.
https://bugzilla.gnome.org/show_bug.cgi?id=665038
-rw-r--r-- | libempathy-gtk/empathy-individual-menu.c | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/libempathy-gtk/empathy-individual-menu.c b/libempathy-gtk/empathy-individual-menu.c index 3938b01ab..fa97877c0 100644 --- a/libempathy-gtk/empathy-individual-menu.c +++ b/libempathy-gtk/empathy-individual-menu.c @@ -79,6 +79,9 @@ static guint signals[LAST_SIGNAL]; G_DEFINE_TYPE (EmpathyIndividualMenu, empathy_individual_menu, GTK_TYPE_MENU); +static GtkWidget * empathy_individiual_block_menu_item_new ( + FolksIndividual *individual); + static void individual_menu_add_personas (GtkMenuShell *menu, FolksIndividual *individual, @@ -131,6 +134,8 @@ individual_menu_add_personas (GtkMenuShell *menu, FolksPersonaStore *store; const gchar *account; GtkWidget *action; + /* Individual containing only persona */ + FolksIndividual *single_individual; if (!empathy_folks_persona_is_interesting (FOLKS_PERSONA (persona))) goto while_finish; @@ -140,6 +145,8 @@ individual_menu_add_personas (GtkMenuShell *menu, goto while_finish; contact = empathy_contact_dup_from_tp_contact (tp_contact); + single_individual = empathy_create_individual_from_tp_contact ( + tp_contact); store = folks_persona_get_store (FOLKS_PERSONA (persona)); account = folks_persona_store_get_display_name (store); @@ -213,11 +220,26 @@ individual_menu_add_personas (GtkMenuShell *menu, gtk_menu_shell_append (GTK_MENU_SHELL (contact_submenu), action); gtk_widget_show (action); + /* Block */ + if (features & EMPATHY_INDIVIDUAL_FEATURE_BLOCK && + (item = empathy_individiual_block_menu_item_new (single_individual)) + != NULL) { + GtkWidget *sep; + + sep = gtk_separator_menu_item_new (); + gtk_menu_shell_append (GTK_MENU_SHELL (contact_submenu), sep); + gtk_widget_show (sep); + + gtk_menu_shell_append (GTK_MENU_SHELL (contact_submenu), item); + gtk_widget_show (item); + } + gtk_menu_shell_append (GTK_MENU_SHELL (menu), contact_item); gtk_widget_show (contact_item); g_free (label); g_object_unref (contact); + g_object_unref (single_individual); while_finish: g_clear_object (&persona); |