aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--libempathy-gtk/empathy-contact-menu.c92
-rw-r--r--libempathy-gtk/empathy-contact-menu.h1
2 files changed, 93 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;
+}
diff --git a/libempathy-gtk/empathy-contact-menu.h b/libempathy-gtk/empathy-contact-menu.h
index dd8d16147..16324979c 100644
--- a/libempathy-gtk/empathy-contact-menu.h
+++ b/libempathy-gtk/empathy-contact-menu.h
@@ -45,6 +45,7 @@ GtkWidget * empathy_contact_call_menu_item_new (EmpathyContact *cont
GtkWidget * empathy_contact_log_menu_item_new (EmpathyContact *contact);
GtkWidget * empathy_contact_info_menu_item_new (EmpathyContact *contact);
GtkWidget * empathy_contact_edit_menu_item_new (EmpathyContact *contact);
+GtkWidget * empathy_contact_invite_menu_item_new (EmpathyContact *contact);
G_END_DECLS