empathy r1581 - trunk/libempathy-gtk



Author: xclaesse
Date: Mon Oct 13 08:04:24 2008
New Revision: 1581
URL: http://svn.gnome.org/viewvc/empathy?rev=1581&view=rev

Log:
Display invite menu entry in the contact menu

Modified:
   trunk/libempathy-gtk/empathy-contact-menu.c
   trunk/libempathy-gtk/empathy-contact-menu.h

Modified: trunk/libempathy-gtk/empathy-contact-menu.c
==============================================================================
--- trunk/libempathy-gtk/empathy-contact-menu.c	(original)
+++ trunk/libempathy-gtk/empathy-contact-menu.c	Mon Oct 13 08:04:24 2008
@@ -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 @@
 		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 @@
 	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;
+}

Modified: trunk/libempathy-gtk/empathy-contact-menu.h
==============================================================================
--- trunk/libempathy-gtk/empathy-contact-menu.h	(original)
+++ trunk/libempathy-gtk/empathy-contact-menu.h	Mon Oct 13 08:04:24 2008
@@ -45,6 +45,7 @@
 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
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]