empathy r1045 - in trunk: libempathy-gtk src



Author: xclaesse
Date: Fri Apr 25 09:33:16 2008
New Revision: 1045
URL: http://svn.gnome.org/viewvc/empathy?rev=1045&view=rev

Log:
Setup contact submenu in chat window.


Modified:
   trunk/libempathy-gtk/empathy-chat.c
   trunk/libempathy-gtk/empathy-chat.h
   trunk/src/empathy-chat-window.c
   trunk/src/empathy-chat-window.glade

Modified: trunk/libempathy-gtk/empathy-chat.c
==============================================================================
--- trunk/libempathy-gtk/empathy-chat.c	(original)
+++ trunk/libempathy-gtk/empathy-chat.c	Fri Apr 25 09:33:16 2008
@@ -48,6 +48,7 @@
 #include "empathy-spell-dialog.h"
 #include "empathy-contact-list-store.h"
 #include "empathy-contact-list-view.h"
+#include "empathy-contact-menu.h"
 #include "empathy-ui-utils.h"
 
 #define GET_PRIV(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), EMPATHY_TYPE_CHAT, EmpathyChatPriv))
@@ -1699,6 +1700,53 @@
 	return 0;
 }
 
+GtkWidget *
+empathy_chat_get_contact_menu (EmpathyChat *chat)
+{
+	EmpathyChatPriv *priv = GET_PRIV (chat);
+	GtkWidget       *menu = NULL;
+
+	g_return_val_if_fail (EMPATHY_IS_CHAT (chat), NULL);
+
+	if (priv->remote_contact) {
+		GtkMenuShell *shell;
+		GtkWidget    *item;
+
+		menu = gtk_menu_new ();
+		shell = GTK_MENU_SHELL (menu);
+
+		item = empathy_contact_call_menu_item_new (priv->remote_contact);
+		gtk_menu_shell_append (shell, item);
+		gtk_widget_show (item);
+
+		item = empathy_contact_log_menu_item_new (priv->remote_contact);
+		gtk_menu_shell_append (shell, item);
+		gtk_widget_show (item);
+
+		/* Separator */
+		item = gtk_separator_menu_item_new ();
+		gtk_menu_shell_append (shell, item);
+		gtk_widget_show (item);
+
+		item = empathy_contact_info_menu_item_new (priv->remote_contact);
+		gtk_menu_shell_append (shell, item);
+		gtk_widget_show (item);
+	}
+	else if (priv->contact_list_view) {
+		EmpathyContactListView *view;
+		EmpathyContact         *contact;
+
+		view = EMPATHY_CONTACT_LIST_VIEW (priv->contact_list_view);
+		contact = empathy_contact_list_view_get_selected (view);
+		if (contact) {
+			menu = empathy_contact_list_view_get_contact_menu (view, contact);
+			g_object_unref (contact);
+		}
+	}
+
+	return menu;
+}
+
 void
 empathy_chat_clear (EmpathyChat *chat)
 {

Modified: trunk/libempathy-gtk/empathy-chat.h
==============================================================================
--- trunk/libempathy-gtk/empathy-chat.h	(original)
+++ trunk/libempathy-gtk/empathy-chat.h	Fri Apr 25 09:33:16 2008
@@ -72,6 +72,7 @@
 const gchar *      empathy_chat_get_subject          (EmpathyChat   *chat);
 EmpathyContact *   empathy_chat_get_remote_contact   (EmpathyChat   *chat);
 guint              empathy_chat_get_members_count    (EmpathyChat   *chat);
+GtkWidget *        empathy_chat_get_contact_menu     (EmpathyChat   *chat);
 void               empathy_chat_clear                (EmpathyChat   *chat);
 void               empathy_chat_scroll_down          (EmpathyChat   *chat);
 void               empathy_chat_cut                  (EmpathyChat   *chat);

Modified: trunk/src/empathy-chat-window.c
==============================================================================
--- trunk/src/empathy-chat-window.c	(original)
+++ trunk/src/empathy-chat-window.c	Fri Apr 25 09:33:16 2008
@@ -454,12 +454,28 @@
 }
 
 static void
+chat_window_conv_activate_cb (GtkWidget         *menuitem,
+			      EmpathyChatWindow *window)
+{
+	EmpathyChatWindowPriv *priv = GET_PRIV (window);
+	GtkWidget             *submenu = NULL;
+
+	submenu = empathy_chat_get_contact_menu (priv->current_chat);
+	if (submenu) {
+		gtk_menu_item_set_submenu (GTK_MENU_ITEM (priv->menu_conv_contact),
+					   submenu);
+		gtk_widget_show (priv->menu_conv_contact);
+		gtk_widget_show (submenu);
+	} else {
+		gtk_widget_hide (priv->menu_conv_contact);
+	}
+}
+
+static void
 chat_window_clear_activate_cb (GtkWidget        *menuitem,
 			       EmpathyChatWindow *window)
 {
-	EmpathyChatWindowPriv *priv;
-
-	priv = GET_PRIV (window);
+	EmpathyChatWindowPriv *priv = GET_PRIV (window);
 
 	empathy_chat_clear (priv->current_chat);
 }
@@ -1120,6 +1136,7 @@
 	empathy_glade_connect (glade,
 			      window,
 			      "chat_window", "configure-event", chat_window_configure_event_cb,
+			      "menu_conv", "activate", chat_window_conv_activate_cb,
 			      "menu_conv_clear", "activate", chat_window_clear_activate_cb,
 			      "menu_conv_close", "activate", chat_window_close_activate_cb,
 			      "menu_edit", "activate", chat_window_edit_activate_cb,

Modified: trunk/src/empathy-chat-window.glade
==============================================================================
--- trunk/src/empathy-chat-window.glade	(original)
+++ trunk/src/empathy-chat-window.glade	Fri Apr 25 09:33:16 2008
@@ -42,11 +42,6 @@
                       </widget>
                     </child>
                     <child>
-                      <widget class="GtkSeparatorMenuItem" id="separator7">
-                        <property name="visible">True</property>
-                      </widget>
-                    </child>
-                    <child>
                       <widget class="GtkMenuItem" id="menu_conv_contact">
                         <property name="visible">True</property>
                         <property name="label" translatable="yes">_Contact</property>
@@ -54,7 +49,7 @@
                       </widget>
                     </child>
                     <child>
-                      <widget class="GtkSeparatorMenuItem" id="separator1">
+                      <widget class="GtkSeparatorMenuItem" id="separator7">
                         <property name="visible">True</property>
                       </widget>
                     </child>



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