[empathy] Don't display context menu when right clicking on a fake group



commit b92ad3740762d958364d4f9421095b088f0d845b
Author: Guillaume Desmottes <guillaume desmottes collabora co uk>
Date:   Tue Mar 9 17:25:14 2010 +0100

    Don't display context menu when right clicking on a fake group
    
    Those can't be renamed.

 libempathy-gtk/empathy-contact-list-view.c |   16 ++++++++++++----
 libempathy-gtk/empathy-contact-list-view.h |    3 ++-
 2 files changed, 14 insertions(+), 5 deletions(-)
---
diff --git a/libempathy-gtk/empathy-contact-list-view.c b/libempathy-gtk/empathy-contact-list-view.c
index 5b66868..7165837 100644
--- a/libempathy-gtk/empathy-contact-list-view.c
+++ b/libempathy-gtk/empathy-contact-list-view.c
@@ -1510,7 +1510,8 @@ empathy_contact_list_view_get_flags (EmpathyContactListView *view)
 }
 
 gchar *
-empathy_contact_list_view_get_selected_group (EmpathyContactListView *view)
+empathy_contact_list_view_get_selected_group (EmpathyContactListView *view,
+					      gboolean *is_fake_group)
 {
 	EmpathyContactListViewPriv *priv;
 	GtkTreeSelection          *selection;
@@ -1518,6 +1519,7 @@ empathy_contact_list_view_get_selected_group (EmpathyContactListView *view)
 	GtkTreeModel              *model;
 	gboolean                   is_group;
 	gchar                     *name;
+	gboolean                   fake;
 
 	g_return_val_if_fail (EMPATHY_IS_CONTACT_LIST_VIEW (view), NULL);
 
@@ -1531,6 +1533,7 @@ empathy_contact_list_view_get_selected_group (EmpathyContactListView *view)
 	gtk_tree_model_get (model, &iter,
 			    EMPATHY_CONTACT_LIST_STORE_COL_IS_GROUP, &is_group,
 			    EMPATHY_CONTACT_LIST_STORE_COL_NAME, &name,
+			    EMPATHY_CONTACT_LIST_STORE_COL_IS_FAKE_GROUP, &fake,
 			    -1);
 
 	if (!is_group) {
@@ -1538,6 +1541,9 @@ empathy_contact_list_view_get_selected_group (EmpathyContactListView *view)
 		return NULL;
 	}
 
+	if (is_fake_group != NULL)
+		*is_fake_group = fake;
+
 	return name;
 }
 
@@ -1574,7 +1580,7 @@ contact_list_view_group_remove_activate_cb (GtkMenuItem            *menuitem,
 	EmpathyContactListViewPriv *priv = GET_PRIV (view);
 	gchar                      *group;
 
-	group = empathy_contact_list_view_get_selected_group (view);
+	group = empathy_contact_list_view_get_selected_group (view, NULL);
 	if (group) {
 		gchar     *text;
 		GtkWindow *parent;
@@ -1602,6 +1608,7 @@ empathy_contact_list_view_get_group_menu (EmpathyContactListView *view)
 	GtkWidget                  *menu;
 	GtkWidget                  *item;
 	GtkWidget                  *image;
+	gboolean                   is_fake_group;
 
 	g_return_val_if_fail (EMPATHY_IS_CONTACT_LIST_VIEW (view), NULL);
 
@@ -1610,8 +1617,9 @@ empathy_contact_list_view_get_group_menu (EmpathyContactListView *view)
 		return NULL;
 	}
 
-	group = empathy_contact_list_view_get_selected_group (view);
-	if (!group) {
+	group = empathy_contact_list_view_get_selected_group (view, &is_fake_group);
+	if (!group || is_fake_group) {
+		/* We can't alter fake groups */
 		return NULL;
 	}
 
diff --git a/libempathy-gtk/empathy-contact-list-view.h b/libempathy-gtk/empathy-contact-list-view.h
index 17de523..41b968d 100644
--- a/libempathy-gtk/empathy-contact-list-view.h
+++ b/libempathy-gtk/empathy-contact-list-view.h
@@ -73,7 +73,8 @@ EmpathyContactListView *   empathy_contact_list_view_new                (Empathy
 								         EmpathyContactFeatureFlags      contact_features);
 EmpathyContact *           empathy_contact_list_view_dup_selected       (EmpathyContactListView         *view);
 EmpathyContactListFlags    empathy_contact_list_view_get_flags          (EmpathyContactListView         *view);
-gchar *                    empathy_contact_list_view_get_selected_group (EmpathyContactListView         *view);
+gchar *                    empathy_contact_list_view_get_selected_group (EmpathyContactListView         *view,
+									 gboolean *is_fake_group);
 GtkWidget *                empathy_contact_list_view_get_contact_menu   (EmpathyContactListView         *view);
 GtkWidget *                empathy_contact_list_view_get_group_menu     (EmpathyContactListView         *view);
 



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