aboutsummaryrefslogtreecommitdiffstats
path: root/libempathy-gtk/empathy-contact-menu.c
diff options
context:
space:
mode:
authorXavier Claessens <xclaesse@src.gnome.org>2008-10-13 16:04:24 +0800
committerXavier Claessens <xclaesse@src.gnome.org>2008-10-13 16:04:24 +0800
commit57fb0abe30460760b4b4467a44d12c89bccd9d02 (patch)
tree20af52fac705ad51ae38486e55cf86c0379e93df /libempathy-gtk/empathy-contact-menu.c
parente82bb66dbcb1d935de1c8063822003a70ab452da (diff)
downloadgsoc2013-empathy-57fb0abe30460760b4b4467a44d12c89bccd9d02.tar
gsoc2013-empathy-57fb0abe30460760b4b4467a44d12c89bccd9d02.tar.gz
gsoc2013-empathy-57fb0abe30460760b4b4467a44d12c89bccd9d02.tar.bz2
gsoc2013-empathy-57fb0abe30460760b4b4467a44d12c89bccd9d02.tar.lz
gsoc2013-empathy-57fb0abe30460760b4b4467a44d12c89bccd9d02.tar.xz
gsoc2013-empathy-57fb0abe30460760b4b4467a44d12c89bccd9d02.tar.zst
gsoc2013-empathy-57fb0abe30460760b4b4467a44d12c89bccd9d02.zip
Display invite menu entry in the contact menu
svn path=/trunk/; revision=1581
Diffstat (limited to 'libempathy-gtk/empathy-contact-menu.c')
-rw-r--r--libempathy-gtk/empathy-contact-menu.c92
1 files changed, 92 insertions, 0 deletions
diff --git a/libempathy-gtk/empathy-contact-menu.c b/libempathy-gtk/empathy-contact-menu.c
index 81c94a6db..209664766 100644
--- a/libempathy-gtk/empathy-contact-menu.c
+++ b/libempathy-gtk/empathy-contact-menu.c
@@ -29,6 +29,7 @@
#include <libempathy/empathy-log-manager.h>
#include <libempathy/empathy-dispatcher.h>
#include <libempathy/empathy-utils.h>
+#include <libempathy/empathy-chatroom-manager.h>
#include "empathy-contact-menu.h"
#include "empathy-images.h"
@@ -73,6 +74,11 @@ empathy_contact_menu_new (EmpathyContact *contact,
gtk_widget_show (item);
}
+ /* Invite */
+ item = empathy_contact_invite_menu_item_new (contact);
+ gtk_menu_shell_append (shell, item);
+ gtk_widget_show (item);
+
/* Separator */
if (features & (EMPATHY_CONTACT_FEATURE_EDIT |
EMPATHY_CONTACT_FEATURE_INFO)) {
@@ -234,3 +240,89 @@ empathy_contact_edit_menu_item_new (EmpathyContact *contact)
return item;
}
+static void
+contact_room_sub_menu_item_activate_cb (EmpathyContact *contact)
+{
+ /* TODO */
+}
+
+static GtkWidget *
+create_room_sub_menu_item (EmpathyContact *contact,
+ EmpathyChatroom *chatroom)
+{
+ GtkWidget *item;
+
+ g_return_val_if_fail (EMPATHY_IS_CONTACT (contact), NULL);
+ g_return_val_if_fail (EMPATHY_IS_CHATROOM (chatroom), NULL);
+
+ item = gtk_menu_item_new_with_label (empathy_chatroom_get_name (chatroom));
+
+ g_signal_connect_swapped (item, "activate",
+ G_CALLBACK (contact_room_sub_menu_item_activate_cb),
+ contact);
+
+ return item;
+}
+
+GtkWidget *
+empathy_contact_invite_menu_item_new (EmpathyContact *contact)
+{
+ GtkWidget *item;
+ GtkWidget *image;
+ GtkWidget *room_item;
+ EmpathyChatroomManager *mgr;
+ GList *rooms, *l;
+ GtkWidget *submenu;
+ GtkMenuShell *submenu_shell;
+ gboolean have_rooms = FALSE;
+
+ g_return_val_if_fail (EMPATHY_IS_CONTACT (contact), NULL);
+
+ item = gtk_image_menu_item_new_with_mnemonic (_("_Invite to..."));
+ image = gtk_image_new_from_icon_name (EMPATHY_IMAGE_GROUP_MESSAGE,
+ GTK_ICON_SIZE_MENU);
+ gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (item), image);
+
+ mgr = empathy_chatroom_manager_new ();
+ rooms = empathy_chatroom_manager_get_chatrooms (mgr,
+ empathy_contact_get_account (contact));
+
+ /* create rooms sub menu */
+ submenu = gtk_menu_new ();
+ submenu_shell = GTK_MENU_SHELL (submenu);
+
+ for (l = rooms; l != NULL; l = g_list_next (l))
+ {
+ EmpathyChatroom *room = l->data;
+ TpChannel *channel;
+
+ g_object_get (room, "tp-channel", &channel, NULL);
+ if (channel != NULL)
+ {
+ have_rooms = TRUE;
+
+ room_item = create_room_sub_menu_item (contact, room);
+ gtk_menu_shell_append (submenu_shell, room_item);
+ gtk_widget_show (room_item);
+
+ g_object_unref (channel);
+ }
+ }
+
+ if (have_rooms)
+ {
+ gtk_menu_item_set_submenu (GTK_MENU_ITEM (item), submenu);
+ }
+ else
+ {
+ gtk_widget_set_sensitive (item, FALSE);
+ gtk_widget_destroy (submenu);
+ }
+
+ gtk_widget_show (image);
+
+ g_object_unref (mgr);
+ g_list_free (rooms);
+
+ return item;
+}