aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorXavier Claessens <xclaesse@src.gnome.org>2008-04-25 17:33:29 +0800
committerXavier Claessens <xclaesse@src.gnome.org>2008-04-25 17:33:29 +0800
commit50efb94e69a9cccebb7475f1977e7eb1f749f362 (patch)
tree60f490e3c7896e5ecb5b2cda835030ebfc1630ef
parent9d5d80ba33f31e935c7335be6fa89ecd183b85bc (diff)
downloadgsoc2013-empathy-50efb94e69a9cccebb7475f1977e7eb1f749f362.tar
gsoc2013-empathy-50efb94e69a9cccebb7475f1977e7eb1f749f362.tar.gz
gsoc2013-empathy-50efb94e69a9cccebb7475f1977e7eb1f749f362.tar.bz2
gsoc2013-empathy-50efb94e69a9cccebb7475f1977e7eb1f749f362.tar.lz
gsoc2013-empathy-50efb94e69a9cccebb7475f1977e7eb1f749f362.tar.xz
gsoc2013-empathy-50efb94e69a9cccebb7475f1977e7eb1f749f362.tar.zst
gsoc2013-empathy-50efb94e69a9cccebb7475f1977e7eb1f749f362.zip
Create contact menu in empathy-contact-menu.h
svn path=/trunk/; revision=1046
-rw-r--r--libempathy-gtk/empathy-chat.c44
-rw-r--r--libempathy-gtk/empathy-contact-list-view.c344
-rw-r--r--libempathy-gtk/empathy-contact-list-view.h35
-rw-r--r--libempathy-gtk/empathy-contact-menu.c63
-rw-r--r--libempathy-gtk/empathy-contact-menu.h22
-rw-r--r--megaphone/src/megaphone-applet.c3
-rw-r--r--python/pyempathy/pyempathy.defs7
-rw-r--r--python/pyempathygtk/pyempathygtk.defs116
-rwxr-xr-xpython/update-binding.sh1
-rw-r--r--src/empathy-main-window.c27
10 files changed, 348 insertions, 314 deletions
diff --git a/libempathy-gtk/empathy-chat.c b/libempathy-gtk/empathy-chat.c
index 55282d164..22b6f46bb 100644
--- a/libempathy-gtk/empathy-chat.c
+++ b/libempathy-gtk/empathy-chat.c
@@ -1203,12 +1203,11 @@ chat_set_show_contacts (EmpathyChat *chat, gboolean show)
store = empathy_contact_list_store_new (EMPATHY_CONTACT_LIST (priv->tp_chat));
priv->contact_list_view = GTK_WIDGET (empathy_contact_list_view_new (store,
- EMPATHY_CONTACT_LIST_FEATURE_CONTACT_CHAT |
- EMPATHY_CONTACT_LIST_FEATURE_CONTACT_CALL |
- EMPATHY_CONTACT_LIST_FEATURE_CONTACT_LOG |
- EMPATHY_CONTACT_LIST_FEATURE_CONTACT_FT |
- EMPATHY_CONTACT_LIST_FEATURE_CONTACT_INVITE |
- EMPATHY_CONTACT_LIST_FEATURE_CONTACT_INFO));
+ EMPATHY_CONTACT_LIST_FEATURE_NONE,
+ EMPATHY_CONTACT_FEATURE_CHAT |
+ EMPATHY_CONTACT_FEATURE_CALL |
+ EMPATHY_CONTACT_FEATURE_LOG |
+ EMPATHY_CONTACT_FEATURE_INFO));
gtk_container_add (GTK_CONTAINER (priv->scrolled_window_contacts),
priv->contact_list_view);
gtk_widget_show (priv->contact_list_view);
@@ -1709,39 +1708,16 @@ empathy_chat_get_contact_menu (EmpathyChat *chat)
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);
+ menu = empathy_contact_menu_new (priv->remote_contact,
+ EMPATHY_CONTACT_FEATURE_CALL |
+ EMPATHY_CONTACT_FEATURE_LOG |
+ EMPATHY_CONTACT_FEATURE_INFO);
}
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);
- }
+ menu = empathy_contact_list_view_get_contact_menu (view);
}
return menu;
diff --git a/libempathy-gtk/empathy-contact-list-view.c b/libempathy-gtk/empathy-contact-list-view.c
index b0bfdf909..646629bb0 100644
--- a/libempathy-gtk/empathy-contact-list-view.c
+++ b/libempathy-gtk/empathy-contact-list-view.c
@@ -41,7 +41,6 @@
#include "empathy-contact-list-view.h"
#include "empathy-contact-list-store.h"
-#include "empathy-contact-menu.h"
#include "empathy-images.h"
#include "empathy-cell-renderer-expander.h"
#include "empathy-cell-renderer-text.h"
@@ -62,9 +61,10 @@
#define GET_PRIV(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), EMPATHY_TYPE_CONTACT_LIST_VIEW, EmpathyContactListViewPriv))
typedef struct {
- EmpathyContactListStore *store;
- GtkTreeRowReference *drag_row;
- EmpathyContactListFeatures features;
+ EmpathyContactListStore *store;
+ GtkTreeRowReference *drag_row;
+ EmpathyContactListFeatureFlags list_features;
+ EmpathyContactFeatureFlags contact_features;
} EmpathyContactListViewPriv;
typedef struct {
@@ -81,7 +81,9 @@ typedef struct {
enum {
PROP_0,
- PROP_FEATURES
+ PROP_STORE,
+ PROP_LIST_FEATURES,
+ PROP_CONTACT_FEATURES,
};
enum DndDragType {
@@ -388,67 +390,55 @@ contact_list_view_drag_drop (GtkWidget *widget,
return FALSE;
}
+typedef struct {
+ EmpathyContactListView *view;
+ guint button;
+ guint32 time;
+} MenuPopupData;
+
static gboolean
-contact_list_view_button_press_event_cb (EmpathyContactListView *view,
- GdkEventButton *event,
- gpointer user_data)
+contact_list_view_popup_menu_idle_cb (gpointer user_data)
{
- EmpathyContactListViewPriv *priv;
- EmpathyContact *contact;
- GtkTreePath *path;
- GtkTreeSelection *selection;
- GtkTreeModel *model;
- GtkTreeIter iter;
- gboolean row_exists;
- GtkWidget *menu;
-
- priv = GET_PRIV (view);
-
- if (event->button != 3) {
- return FALSE;
- }
-
- selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (view));
- model = gtk_tree_view_get_model (GTK_TREE_VIEW (view));
-
- gtk_widget_grab_focus (GTK_WIDGET (view));
-
- row_exists = gtk_tree_view_get_path_at_pos (GTK_TREE_VIEW (view),
- event->x, event->y,
- &path,
- NULL, NULL, NULL);
- if (!row_exists) {
- return FALSE;
- }
-
- gtk_tree_selection_unselect_all (selection);
- gtk_tree_selection_select_path (selection, path);
-
- gtk_tree_model_get_iter (model, &iter, path);
- gtk_tree_path_free (path);
+ MenuPopupData *data = user_data;
+ GtkWidget *menu;
- gtk_tree_model_get (model, &iter,
- EMPATHY_CONTACT_LIST_STORE_COL_CONTACT, &contact,
- -1);
-
- if (contact) {
- menu = empathy_contact_list_view_get_contact_menu (view, contact);
- g_object_unref (contact);
- } else {
- menu = empathy_contact_list_view_get_group_menu (view);
+ menu = empathy_contact_list_view_get_contact_menu (data->view);
+ if (!menu) {
+ menu = empathy_contact_list_view_get_group_menu (data->view);
}
if (!menu) {
- return FALSE;
+ goto OUT;
}
gtk_widget_show (menu);
gtk_menu_popup (GTK_MENU (menu),
NULL, NULL, NULL, NULL,
- event->button, event->time);
+ data->button, data->time);
- return TRUE;
+OUT:
+ g_slice_free (MenuPopupData, data);
+
+ return FALSE;
+}
+
+static gboolean
+contact_list_view_button_press_event_cb (EmpathyContactListView *view,
+ GdkEventButton *event,
+ gpointer user_data)
+{
+ if (event->button == 3) {
+ MenuPopupData *data;
+
+ data = g_slice_new (MenuPopupData);
+ data->view = view;
+ data->button = event->button;
+ data->time = event->time;
+ g_idle_add (contact_list_view_popup_menu_idle_cb, data);
+ }
+
+ return FALSE;
}
static void
@@ -462,7 +452,7 @@ contact_list_view_row_activated_cb (EmpathyContactListView *view,
GtkTreeModel *model;
GtkTreeIter iter;
- if (!(priv->features & EMPATHY_CONTACT_LIST_FEATURE_CONTACT_CHAT)) {
+ if (!(priv->contact_features & EMPATHY_CONTACT_FEATURE_CHAT)) {
return;
}
@@ -489,7 +479,7 @@ contact_list_view_voip_activated_cb (EmpathyCellRendererActivatable *cell,
GtkTreeIter iter;
EmpathyContact *contact;
- if (!(priv->features & EMPATHY_CONTACT_LIST_FEATURE_CONTACT_CALL)) {
+ if (!(priv->contact_features & EMPATHY_CONTACT_FEATURE_CALL)) {
return;
}
@@ -693,7 +683,7 @@ contact_list_view_row_expand_or_collapse_cb (EmpathyContactListView *view,
gchar *name;
gboolean expanded;
- if (!(priv->features & EMPATHY_CONTACT_LIST_FEATURE_GROUPS_SAVE)) {
+ if (!(priv->list_features & EMPATHY_CONTACT_LIST_FEATURE_GROUPS_SAVE)) {
return;
}
@@ -729,7 +719,7 @@ contact_list_view_row_has_child_toggled_cb (GtkTreeModel *model,
return;
}
- if (!(priv->features & EMPATHY_CONTACT_LIST_FEATURE_GROUPS_SAVE) ||
+ if (!(priv->list_features & EMPATHY_CONTACT_LIST_FEATURE_GROUPS_SAVE) ||
empathy_contact_group_get_expanded (name)) {
g_signal_handlers_block_by_func (view,
contact_list_view_row_expand_or_collapse_cb,
@@ -865,6 +855,40 @@ contact_list_view_setup (EmpathyContactListView *view)
}
static void
+contact_list_view_set_list_features (EmpathyContactListView *view,
+ EmpathyContactListFeatureFlags features)
+{
+ EmpathyContactListViewPriv *priv = GET_PRIV (view);
+
+ g_return_if_fail (EMPATHY_IS_CONTACT_LIST_VIEW (view));
+
+ priv->list_features = features;
+
+ /* Update DnD source/dest */
+ if (features & EMPATHY_CONTACT_LIST_FEATURE_CONTACT_DRAG) {
+ gtk_drag_source_set (GTK_WIDGET (view),
+ GDK_BUTTON1_MASK,
+ drag_types_source,
+ G_N_ELEMENTS (drag_types_source),
+ GDK_ACTION_MOVE | GDK_ACTION_COPY);
+ } else {
+ gtk_drag_source_unset (GTK_WIDGET (view));
+
+ }
+
+ if (features & EMPATHY_CONTACT_LIST_FEATURE_CONTACT_DROP) {
+ gtk_drag_dest_set (GTK_WIDGET (view),
+ GTK_DEST_DEFAULT_ALL,
+ drag_types_dest,
+ G_N_ELEMENTS (drag_types_dest),
+ GDK_ACTION_MOVE | GDK_ACTION_COPY);
+ } else {
+ /* FIXME: URI could still be droped depending on FT feature */
+ gtk_drag_dest_unset (GTK_WIDGET (view));
+ }
+}
+
+static void
contact_list_view_finalize (GObject *object)
{
EmpathyContactListViewPriv *priv;
@@ -889,8 +913,14 @@ contact_list_view_get_property (GObject *object,
priv = GET_PRIV (object);
switch (param_id) {
- case PROP_FEATURES:
- g_value_set_flags (value, priv->features);
+ case PROP_STORE:
+ g_value_set_object (value, priv->store);
+ break;
+ case PROP_LIST_FEATURES:
+ g_value_set_flags (value, priv->list_features);
+ break;
+ case PROP_CONTACT_FEATURES:
+ g_value_set_flags (value, priv->contact_features);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
@@ -905,13 +935,18 @@ contact_list_view_set_property (GObject *object,
GParamSpec *pspec)
{
EmpathyContactListView *view = EMPATHY_CONTACT_LIST_VIEW (object);
- EmpathyContactListViewPriv *priv;
-
- priv = GET_PRIV (object);
+ EmpathyContactListViewPriv *priv = GET_PRIV (object);
switch (param_id) {
- case PROP_FEATURES:
- empathy_contact_list_view_set_features (view, g_value_get_flags (value));
+ case PROP_STORE:
+ priv->store = g_value_dup_object (value);
+ contact_list_view_setup (view);
+ break;
+ case PROP_LIST_FEATURES:
+ contact_list_view_set_list_features (view, g_value_get_flags (value));
+ break;
+ case PROP_CONTACT_FEATURES:
+ priv->contact_features = g_value_get_flags (value);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
@@ -951,12 +986,27 @@ empathy_contact_list_view_class_init (EmpathyContactListViewClass *klass)
3, EMPATHY_TYPE_CONTACT, G_TYPE_STRING, G_TYPE_STRING);
g_object_class_install_property (object_class,
- PROP_FEATURES,
- g_param_spec_flags ("features",
+ PROP_STORE,
+ g_param_spec_object ("store",
+ "The store of the view",
+ "The store of the view",
+ EMPATHY_TYPE_CONTACT_LIST_STORE,
+ G_PARAM_CONSTRUCT_ONLY | G_PARAM_READWRITE));
+ g_object_class_install_property (object_class,
+ PROP_LIST_FEATURES,
+ g_param_spec_flags ("list-features",
"Features of the view",
"Falgs for all enabled features",
- EMPATHY_TYPE_CONTACT_LIST_FEATURES,
- 0,
+ EMPATHY_TYPE_CONTACT_LIST_FEATURE_FLAGS,
+ EMPATHY_CONTACT_LIST_FEATURE_NONE,
+ G_PARAM_READWRITE));
+ g_object_class_install_property (object_class,
+ PROP_CONTACT_FEATURES,
+ g_param_spec_flags ("contact-features",
+ "Features of the contact menu",
+ "Falgs for all enabled features for the menu",
+ EMPATHY_TYPE_CONTACT_FEATURE_FLAGS,
+ EMPATHY_CONTACT_FEATURE_NONE,
G_PARAM_READWRITE));
g_type_class_add_private (object_class, sizeof (EmpathyContactListViewPriv));
@@ -992,69 +1042,17 @@ empathy_contact_list_view_init (EmpathyContactListView *view)
}
EmpathyContactListView *
-empathy_contact_list_view_new (EmpathyContactListStore *store,
- EmpathyContactListFeatures features)
+empathy_contact_list_view_new (EmpathyContactListStore *store,
+ EmpathyContactListFeatureFlags list_features,
+ EmpathyContactFeatureFlags contact_features)
{
- EmpathyContactListView *view;
- EmpathyContactListViewPriv *priv;
-
g_return_val_if_fail (EMPATHY_IS_CONTACT_LIST_STORE (store), NULL);
- view = g_object_new (EMPATHY_TYPE_CONTACT_LIST_VIEW,
- "features", features,
- NULL);
-
- priv = GET_PRIV (view);
- priv->store = g_object_ref (store);
- contact_list_view_setup (EMPATHY_CONTACT_LIST_VIEW (view));
-
- return view;
-}
-
-void
-empathy_contact_list_view_set_features (EmpathyContactListView *view,
- EmpathyContactListFeatures features)
-{
- EmpathyContactListViewPriv *priv = GET_PRIV (view);
-
- g_return_if_fail (EMPATHY_IS_CONTACT_LIST_VIEW (view));
-
- priv->features = features;
-
- /* Update DnD source/dest */
- if (features & EMPATHY_CONTACT_LIST_FEATURE_CONTACT_DRAG) {
- gtk_drag_source_set (GTK_WIDGET (view),
- GDK_BUTTON1_MASK,
- drag_types_source,
- G_N_ELEMENTS (drag_types_source),
- GDK_ACTION_MOVE | GDK_ACTION_COPY);
- } else {
- gtk_drag_source_unset (GTK_WIDGET (view));
-
- }
-
- if (features & EMPATHY_CONTACT_LIST_FEATURE_CONTACT_DROP) {
- gtk_drag_dest_set (GTK_WIDGET (view),
- GTK_DEST_DEFAULT_ALL,
- drag_types_dest,
- G_N_ELEMENTS (drag_types_dest),
- GDK_ACTION_MOVE | GDK_ACTION_COPY);
- } else {
- /* FIXME: URI could still be droped depending on FT feature */
- gtk_drag_dest_unset (GTK_WIDGET (view));
- }
-
- g_object_notify (G_OBJECT (view), "features");
-}
-
-EmpathyContactListFeatures
-empathy_contact_list_view_get_features (EmpathyContactListView *view)
-{
- EmpathyContactListViewPriv *priv = GET_PRIV (view);
-
- g_return_val_if_fail (EMPATHY_IS_CONTACT_LIST_VIEW (view), FALSE);
-
- return priv->features;
+ return g_object_new (EMPATHY_TYPE_CONTACT_LIST_VIEW,
+ "store", store,
+ "contact-features", contact_features,
+ "list-features", list_features,
+ NULL);
}
EmpathyContact *
@@ -1180,14 +1178,20 @@ GtkWidget *
empathy_contact_list_view_get_group_menu (EmpathyContactListView *view)
{
EmpathyContactListViewPriv *priv = GET_PRIV (view);
+ gchar *group;
GtkWidget *menu;
GtkWidget *item;
GtkWidget *image;
g_return_val_if_fail (EMPATHY_IS_CONTACT_LIST_VIEW (view), NULL);
- if (!(priv->features & (EMPATHY_CONTACT_LIST_FEATURE_GROUPS_RENAME |
- EMPATHY_CONTACT_LIST_FEATURE_GROUPS_REMOVE))) {
+ if (!(priv->list_features & (EMPATHY_CONTACT_LIST_FEATURE_GROUPS_RENAME |
+ EMPATHY_CONTACT_LIST_FEATURE_GROUPS_REMOVE))) {
+ return NULL;
+ }
+
+ group = empathy_contact_list_view_get_selected_group (view);
+ if (!group) {
return NULL;
}
@@ -1203,7 +1207,7 @@ empathy_contact_list_view_get_group_menu (EmpathyContactListView *view)
view);
}*/
- if (priv->features & EMPATHY_CONTACT_LIST_FEATURE_GROUPS_REMOVE) {
+ if (priv->list_features & EMPATHY_CONTACT_LIST_FEATURE_GROUPS_REMOVE) {
item = gtk_image_menu_item_new_with_mnemonic (_("_Remove"));
image = gtk_image_new_from_icon_name (GTK_STOCK_REMOVE,
GTK_ICON_SIZE_MENU);
@@ -1215,6 +1219,8 @@ empathy_contact_list_view_get_group_menu (EmpathyContactListView *view)
view);
}
+ g_free (group);
+
return menu;
}
@@ -1248,89 +1254,53 @@ contact_list_view_remove_activate_cb (GtkMenuItem *menuitem,
}
GtkWidget *
-empathy_contact_list_view_get_contact_menu (EmpathyContactListView *view,
- EmpathyContact *contact)
+empathy_contact_list_view_get_contact_menu (EmpathyContactListView *view)
{
EmpathyContactListViewPriv *priv = GET_PRIV (view);
+ EmpathyContact *contact;
GtkWidget *menu;
- GtkMenuShell *shell;
GtkWidget *item;
GtkWidget *image;
g_return_val_if_fail (EMPATHY_IS_CONTACT_LIST_VIEW (view), NULL);
- g_return_val_if_fail (EMPATHY_IS_CONTACT (contact), NULL);
-
- if (!(priv->features & (EMPATHY_CONTACT_LIST_FEATURE_CONTACT_CHAT |
- EMPATHY_CONTACT_LIST_FEATURE_CONTACT_CALL |
- EMPATHY_CONTACT_LIST_FEATURE_CONTACT_LOG |
- EMPATHY_CONTACT_LIST_FEATURE_CONTACT_FT |
- EMPATHY_CONTACT_LIST_FEATURE_CONTACT_INVITE |
- EMPATHY_CONTACT_LIST_FEATURE_CONTACT_EDIT |
- EMPATHY_CONTACT_LIST_FEATURE_CONTACT_INFO |
- EMPATHY_CONTACT_LIST_FEATURE_CONTACT_REMOVE))) {
- return NULL;
- }
- menu = gtk_menu_new ();
- shell = GTK_MENU_SHELL (menu);
-
- /* Main items */
- if (priv->features & EMPATHY_CONTACT_LIST_FEATURE_CONTACT_CHAT) {
- item = empathy_contact_chat_menu_item_new (contact);
- gtk_menu_shell_append (shell, item);
- gtk_widget_show (item);
- }
- if (priv->features & EMPATHY_CONTACT_LIST_FEATURE_CONTACT_CALL) {
- item = empathy_contact_call_menu_item_new (contact);
- gtk_menu_shell_append (shell, item);
- gtk_widget_show (item);
- }
- if (priv->features & EMPATHY_CONTACT_LIST_FEATURE_CONTACT_LOG) {
- item = empathy_contact_log_menu_item_new (contact);
- gtk_menu_shell_append (shell, item);
- gtk_widget_show (item);
+ contact = empathy_contact_list_view_get_selected (view);
+ if (!contact) {
+ return NULL;
}
- /* Separator */
- if (priv->features & (EMPATHY_CONTACT_LIST_FEATURE_CONTACT_EDIT |
- EMPATHY_CONTACT_LIST_FEATURE_CONTACT_INFO)) {
- item = gtk_separator_menu_item_new ();
- gtk_menu_shell_append (shell, item);
- gtk_widget_show (item);
- }
+ menu = empathy_contact_menu_new (contact, priv->contact_features);
- /* More items */
- if (priv->features & EMPATHY_CONTACT_LIST_FEATURE_CONTACT_EDIT) {
- item = empathy_contact_edit_menu_item_new (contact);
- gtk_menu_shell_append (shell, item);
- gtk_widget_show (item);
- }
- if (priv->features & EMPATHY_CONTACT_LIST_FEATURE_CONTACT_INFO) {
- item = empathy_contact_info_menu_item_new (contact);
- gtk_menu_shell_append (shell, item);
- gtk_widget_show (item);
+ if (!menu &&
+ !(priv->list_features & EMPATHY_CONTACT_LIST_FEATURE_CONTACT_REMOVE)) {
+ g_object_unref (contact);
+ return NULL;
}
- /* Separator */
- if (priv->features & EMPATHY_CONTACT_LIST_FEATURE_CONTACT_REMOVE) {
+ if (menu) {
+ /* Separator */
item = gtk_separator_menu_item_new ();
- gtk_menu_shell_append (shell, item);
+ gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
gtk_widget_show (item);
+ } else {
+ menu = gtk_menu_new ();
}
- /* Custom items */
- if (priv->features & EMPATHY_CONTACT_LIST_FEATURE_CONTACT_REMOVE) {
+ /* Remove contact */
+ if (priv->list_features & EMPATHY_CONTACT_LIST_FEATURE_CONTACT_REMOVE) {
item = gtk_image_menu_item_new_with_mnemonic (_("_Remove"));
image = gtk_image_new_from_icon_name (GTK_STOCK_REMOVE,
GTK_ICON_SIZE_MENU);
gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (item), image);
- gtk_menu_shell_append (shell, item);
+ gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
gtk_widget_show (item);
g_signal_connect (item, "activate",
G_CALLBACK (contact_list_view_remove_activate_cb),
view);
}
+ g_object_unref (contact);
+
return menu;
}
diff --git a/libempathy-gtk/empathy-contact-list-view.h b/libempathy-gtk/empathy-contact-list-view.h
index 34f194b14..47159fd24 100644
--- a/libempathy-gtk/empathy-contact-list-view.h
+++ b/libempathy-gtk/empathy-contact-list-view.h
@@ -31,6 +31,7 @@
#include <libempathy/empathy-contact.h>
#include "empathy-contact-list-store.h"
+#include "empathy-contact-menu.h"
G_BEGIN_DECLS
@@ -49,18 +50,11 @@ typedef enum {
EMPATHY_CONTACT_LIST_FEATURE_GROUPS_SAVE = 1 << 0,
EMPATHY_CONTACT_LIST_FEATURE_GROUPS_RENAME = 1 << 1,
EMPATHY_CONTACT_LIST_FEATURE_GROUPS_REMOVE = 1 << 2,
- EMPATHY_CONTACT_LIST_FEATURE_CONTACT_CHAT = 1 << 3,
- EMPATHY_CONTACT_LIST_FEATURE_CONTACT_CALL = 1 << 4,
- EMPATHY_CONTACT_LIST_FEATURE_CONTACT_LOG = 1 << 5,
- EMPATHY_CONTACT_LIST_FEATURE_CONTACT_FT = 1 << 6,
- EMPATHY_CONTACT_LIST_FEATURE_CONTACT_INVITE = 1 << 7,
- EMPATHY_CONTACT_LIST_FEATURE_CONTACT_EDIT = 1 << 8,
- EMPATHY_CONTACT_LIST_FEATURE_CONTACT_INFO = 1 << 9,
- EMPATHY_CONTACT_LIST_FEATURE_CONTACT_REMOVE = 1 << 10,
- EMPATHY_CONTACT_LIST_FEATURE_CONTACT_DROP = 1 << 11,
- EMPATHY_CONTACT_LIST_FEATURE_CONTACT_DRAG = 1 << 12,
- EMPATHY_CONTACT_LIST_FEATURE_ALL = (1 << 13) - 1,
-} EmpathyContactListFeatures;
+ EMPATHY_CONTACT_LIST_FEATURE_CONTACT_REMOVE = 1 << 3,
+ EMPATHY_CONTACT_LIST_FEATURE_CONTACT_DROP = 1 << 4,
+ EMPATHY_CONTACT_LIST_FEATURE_CONTACT_DRAG = 1 << 5,
+ EMPATHY_CONTACT_LIST_FEATURE_ALL = (1 << 6) - 1,
+} EmpathyContactListFeatureFlags;
struct _EmpathyContactListView {
GtkTreeView parent;
@@ -71,16 +65,13 @@ struct _EmpathyContactListViewClass {
};
GType empathy_contact_list_view_get_type (void) G_GNUC_CONST;
-EmpathyContactListView * empathy_contact_list_view_new (EmpathyContactListStore *store,
- EmpathyContactListFeatures features);
-void empathy_contact_list_view_set_features (EmpathyContactListView *view,
- EmpathyContactListFeatures features);
-EmpathyContactListFeatures empathy_contact_list_view_get_features (EmpathyContactListView *view);
-EmpathyContact * empathy_contact_list_view_get_selected (EmpathyContactListView *view);
-gchar * empathy_contact_list_view_get_selected_group (EmpathyContactListView *view);
-GtkWidget * empathy_contact_list_view_get_contact_menu (EmpathyContactListView *view,
- EmpathyContact *contact);
-GtkWidget * empathy_contact_list_view_get_group_menu (EmpathyContactListView *view);
+EmpathyContactListView * empathy_contact_list_view_new (EmpathyContactListStore *store,
+ EmpathyContactListFeatureFlags list_features,
+ EmpathyContactFeatureFlags contact_features);
+EmpathyContact * empathy_contact_list_view_get_selected (EmpathyContactListView *view);
+gchar * empathy_contact_list_view_get_selected_group (EmpathyContactListView *view);
+GtkWidget * empathy_contact_list_view_get_contact_menu (EmpathyContactListView *view);
+GtkWidget * empathy_contact_list_view_get_group_menu (EmpathyContactListView *view);
G_END_DECLS
diff --git a/libempathy-gtk/empathy-contact-menu.c b/libempathy-gtk/empathy-contact-menu.c
index 4509dd171..b06bcd3e4 100644
--- a/libempathy-gtk/empathy-contact-menu.c
+++ b/libempathy-gtk/empathy-contact-menu.c
@@ -37,6 +37,69 @@
#define DEBUG_DOMAIN "ContactMenu"
GtkWidget *
+empathy_contact_menu_new (EmpathyContact *contact,
+ EmpathyContactFeatureFlags features)
+{
+ GtkWidget *menu;
+ GtkMenuShell *shell;
+ GtkWidget *item;
+
+ g_return_val_if_fail (EMPATHY_IS_CONTACT (contact), NULL);
+
+ if (features == EMPATHY_CONTACT_FEATURE_NONE) {
+ return NULL;
+ }
+
+ menu = gtk_menu_new ();
+ shell = GTK_MENU_SHELL (menu);
+
+ /* Chat */
+ if (features & EMPATHY_CONTACT_FEATURE_CHAT) {
+ item = empathy_contact_chat_menu_item_new (contact);
+ gtk_menu_shell_append (shell, item);
+ gtk_widget_show (item);
+ }
+
+ /* Call */
+ if (features & EMPATHY_CONTACT_FEATURE_CALL) {
+ item = empathy_contact_call_menu_item_new (contact);
+ gtk_menu_shell_append (shell, item);
+ gtk_widget_show (item);
+ }
+
+ /* Log */
+ if (features & EMPATHY_CONTACT_FEATURE_LOG) {
+ item = empathy_contact_log_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)) {
+ item = gtk_separator_menu_item_new ();
+ gtk_menu_shell_append (shell, item);
+ gtk_widget_show (item);
+ }
+
+ /* Edit */
+ if (features & EMPATHY_CONTACT_FEATURE_EDIT) {
+ item = empathy_contact_edit_menu_item_new (contact);
+ gtk_menu_shell_append (shell, item);
+ gtk_widget_show (item);
+ }
+
+ /* Info */
+ if (features & EMPATHY_CONTACT_FEATURE_INFO) {
+ item = empathy_contact_info_menu_item_new (contact);
+ gtk_menu_shell_append (shell, item);
+ gtk_widget_show (item);
+ }
+
+ return menu;
+}
+
+GtkWidget *
empathy_contact_chat_menu_item_new (EmpathyContact *contact)
{
GtkWidget *item;
diff --git a/libempathy-gtk/empathy-contact-menu.h b/libempathy-gtk/empathy-contact-menu.h
index 4b9427b76..dd8d16147 100644
--- a/libempathy-gtk/empathy-contact-menu.h
+++ b/libempathy-gtk/empathy-contact-menu.h
@@ -28,11 +28,23 @@
G_BEGIN_DECLS
-GtkWidget * empathy_contact_chat_menu_item_new (EmpathyContact *contact);
-GtkWidget * empathy_contact_call_menu_item_new (EmpathyContact *contact);
-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);
+typedef enum {
+ EMPATHY_CONTACT_FEATURE_NONE = 0,
+ EMPATHY_CONTACT_FEATURE_CHAT = 1 << 0,
+ EMPATHY_CONTACT_FEATURE_CALL = 1 << 1,
+ EMPATHY_CONTACT_FEATURE_LOG = 1 << 2,
+ EMPATHY_CONTACT_FEATURE_EDIT = 1 << 3,
+ EMPATHY_CONTACT_FEATURE_INFO = 1 << 4,
+ EMPATHY_CONTACT_FEATURE_ALL = (1 << 5) - 1,
+} EmpathyContactFeatureFlags;
+
+GtkWidget * empathy_contact_menu_new (EmpathyContact *contact,
+ EmpathyContactFeatureFlags features);
+GtkWidget * empathy_contact_chat_menu_item_new (EmpathyContact *contact);
+GtkWidget * empathy_contact_call_menu_item_new (EmpathyContact *contact);
+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);
G_END_DECLS
diff --git a/megaphone/src/megaphone-applet.c b/megaphone/src/megaphone-applet.c
index 17ae2c50b..ad0952891 100644
--- a/megaphone/src/megaphone-applet.c
+++ b/megaphone/src/megaphone-applet.c
@@ -366,7 +366,8 @@ megaphone_applet_show_preferences (MegaphoneApplet *applet)
"sort-criterium", EMPATHY_CONTACT_LIST_STORE_SORT_NAME,
NULL);
contact_list = empathy_contact_list_view_new (contact_store,
- EMPATHY_CONTACT_LIST_FEATURE_NONE);
+ EMPATHY_CONTACT_LIST_FEATURE_NONE,
+ EMPATHY_CONTACT_FEATURE_NONE);
g_object_unref (contact_manager);
g_object_unref (contact_store);
gtk_widget_show (GTK_WIDGET (contact_list));
diff --git a/python/pyempathy/pyempathy.defs b/python/pyempathy/pyempathy.defs
index 99e068067..a722461c4 100644
--- a/python/pyempathy/pyempathy.defs
+++ b/python/pyempathy/pyempathy.defs
@@ -150,6 +150,7 @@
(values
'("as-is" "EMPATHY_REGEX_AS_IS")
'("browser" "EMPATHY_REGEX_BROWSER")
+ '("apt" "EMPATHY_REGEX_APT")
'("email" "EMPATHY_REGEX_EMAIL")
'("other" "EMPATHY_REGEX_OTHER")
'("all" "EMPATHY_REGEX_ALL")
@@ -1597,6 +1598,12 @@
(return-type "McAccount*")
)
+(define-method get_channel
+ (of-object "EmpathyTpChat")
+ (c-name "empathy_tp_chat_get_channel")
+ (return-type "TpChannel*")
+)
+
(define-method is_ready
(of-object "EmpathyTpChat")
(c-name "empathy_tp_chat_is_ready")
diff --git a/python/pyempathygtk/pyempathygtk.defs b/python/pyempathygtk/pyempathygtk.defs
index fd3ca2015..604c959cd 100644
--- a/python/pyempathygtk/pyempathygtk.defs
+++ b/python/pyempathygtk/pyempathygtk.defs
@@ -152,22 +152,15 @@
)
)
-(define-flags ContactListFeatures
+(define-flags ContactListFeatureFlags
(in-module "Empathy")
- (c-name "EmpathyContactListFeatures")
- (gtype-id "EMPATHY_TYPE_CONTACT_LIST_FEATURES")
+ (c-name "EmpathyContactListFeatureFlags")
+ (gtype-id "EMPATHY_TYPE_CONTACT_LIST_FEATURE_FLAGS")
(values
'("none" "EMPATHY_CONTACT_LIST_FEATURE_NONE")
'("groups-save" "EMPATHY_CONTACT_LIST_FEATURE_GROUPS_SAVE")
'("groups-rename" "EMPATHY_CONTACT_LIST_FEATURE_GROUPS_RENAME")
'("groups-remove" "EMPATHY_CONTACT_LIST_FEATURE_GROUPS_REMOVE")
- '("contact-chat" "EMPATHY_CONTACT_LIST_FEATURE_CONTACT_CHAT")
- '("contact-call" "EMPATHY_CONTACT_LIST_FEATURE_CONTACT_CALL")
- '("contact-log" "EMPATHY_CONTACT_LIST_FEATURE_CONTACT_LOG")
- '("contact-ft" "EMPATHY_CONTACT_LIST_FEATURE_CONTACT_FT")
- '("contact-invite" "EMPATHY_CONTACT_LIST_FEATURE_CONTACT_INVITE")
- '("contact-edit" "EMPATHY_CONTACT_LIST_FEATURE_CONTACT_EDIT")
- '("contact-info" "EMPATHY_CONTACT_LIST_FEATURE_CONTACT_INFO")
'("contact-remove" "EMPATHY_CONTACT_LIST_FEATURE_CONTACT_REMOVE")
'("contact-drop" "EMPATHY_CONTACT_LIST_FEATURE_CONTACT_DROP")
'("contact-drag" "EMPATHY_CONTACT_LIST_FEATURE_CONTACT_DRAG")
@@ -189,6 +182,21 @@
)
)
+(define-flags ContactFeatureFlags
+ (in-module "Empathy")
+ (c-name "EmpathyContactFeatureFlags")
+ (gtype-id "EMPATHY_TYPE_CONTACT_FEATURE_FLAGS")
+ (values
+ '("none" "EMPATHY_CONTACT_FEATURE_NONE")
+ '("chat" "EMPATHY_CONTACT_FEATURE_CHAT")
+ '("call" "EMPATHY_CONTACT_FEATURE_CALL")
+ '("log" "EMPATHY_CONTACT_FEATURE_LOG")
+ '("edit" "EMPATHY_CONTACT_FEATURE_EDIT")
+ '("info" "EMPATHY_CONTACT_FEATURE_INFO")
+ '("all" "EMPATHY_CONTACT_FEATURE_ALL")
+ )
+)
+
;; From empathy-images.h
@@ -325,6 +333,12 @@
(return-type "guint")
)
+(define-method get_contact_menu
+ (of-object "EmpathyChat")
+ (c-name "empathy_chat_get_contact_menu")
+ (return-type "GtkWidget*")
+)
+
(define-method clear
(of-object "EmpathyChat")
(c-name "empathy_chat_clear")
@@ -450,15 +464,6 @@
)
)
-(define-method set_margin
- (of-object "EmpathyChatView")
- (c-name "empathy_chat_view_set_margin")
- (return-type "none")
- (parameters
- '("gint" "margin")
- )
-)
-
(define-method scroll
(of-object "EmpathyChatView")
(c-name "empathy_chat_view_scroll")
@@ -569,15 +574,6 @@
)
)
-(define-method set_is_group_chat
- (of-object "EmpathyChatView")
- (c-name "empathy_chat_view_set_is_group_chat")
- (return-type "none")
- (parameters
- '("gboolean" "is_group_chat")
- )
-)
-
(define-method get_last_timestamp
(of-object "EmpathyChatView")
(c-name "empathy_chat_view_get_last_timestamp")
@@ -1286,25 +1282,11 @@
(return-type "EmpathyContactListView*")
(parameters
'("EmpathyContactListStore*" "store")
- '("EmpathyContactListFeatures" "features")
+ '("EmpathyContactListFeatureFlags" "list_features")
+ '("EmpathyContactFeatureFlags" "contact_features")
)
)
-(define-method set_features
- (of-object "EmpathyContactListView")
- (c-name "empathy_contact_list_view_set_features")
- (return-type "none")
- (parameters
- '("EmpathyContactListFeatures" "features")
- )
-)
-
-(define-method get_features
- (of-object "EmpathyContactListView")
- (c-name "empathy_contact_list_view_get_features")
- (return-type "EmpathyContactListFeatures")
-)
-
(define-method get_selected
(of-object "EmpathyContactListView")
(c-name "empathy_contact_list_view_get_selected")
@@ -1321,9 +1303,6 @@
(of-object "EmpathyContactListView")
(c-name "empathy_contact_list_view_get_contact_menu")
(return-type "GtkWidget*")
- (parameters
- '("EmpathyContact*" "contact")
- )
)
(define-method get_group_menu
@@ -1809,3 +1788,46 @@
)
+
+;; From empathy-contact-menu.h
+
+(define-method menu_new
+ (of-object "EmpathyContact")
+ (c-name "empathy_contact_menu_new")
+ (return-type "GtkWidget*")
+ (parameters
+ '("EmpathyContactFeatureFlags" "features")
+ )
+)
+
+(define-method chat_menu_item_new
+ (of-object "EmpathyContact")
+ (c-name "empathy_contact_chat_menu_item_new")
+ (return-type "GtkWidget*")
+)
+
+(define-method call_menu_item_new
+ (of-object "EmpathyContact")
+ (c-name "empathy_contact_call_menu_item_new")
+ (return-type "GtkWidget*")
+)
+
+(define-method log_menu_item_new
+ (of-object "EmpathyContact")
+ (c-name "empathy_contact_log_menu_item_new")
+ (return-type "GtkWidget*")
+)
+
+(define-method info_menu_item_new
+ (of-object "EmpathyContact")
+ (c-name "empathy_contact_info_menu_item_new")
+ (return-type "GtkWidget*")
+)
+
+(define-method edit_menu_item_new
+ (of-object "EmpathyContact")
+ (c-name "empathy_contact_edit_menu_item_new")
+ (return-type "GtkWidget*")
+)
+
+
diff --git a/python/update-binding.sh b/python/update-binding.sh
index 4f780aedc..b39341ffc 100755
--- a/python/update-binding.sh
+++ b/python/update-binding.sh
@@ -67,6 +67,7 @@ python /usr/share/pygtk/2.0/codegen/h2def.py \
empathy-smiley-manager.h \
empathy-cell-renderer-text.h \
empathy-spell.h \
+ empathy-contact-menu.h \
> ../python/pyempathygtk/pyempathygtk.defs
# Keep original version
diff --git a/src/empathy-main-window.c b/src/empathy-main-window.c
index 7b616f4ab..089fb98b7 100644
--- a/src/empathy-main-window.c
+++ b/src/empathy-main-window.c
@@ -291,7 +291,8 @@ empathy_main_window_show (void)
list_iface = EMPATHY_CONTACT_LIST (empathy_contact_manager_new ());
window->list_store = empathy_contact_list_store_new (list_iface);
window->list_view = empathy_contact_list_view_new (window->list_store,
- EMPATHY_CONTACT_LIST_FEATURE_ALL);
+ EMPATHY_CONTACT_LIST_FEATURE_ALL,
+ EMPATHY_CONTACT_FEATURE_ALL);
g_object_unref (list_iface);
gtk_widget_show (GTK_WIDGET (window->list_view));
@@ -594,53 +595,43 @@ main_window_edit_button_press_event_cb (GtkWidget *widget,
GdkEventButton *event,
EmpathyMainWindow *window)
{
- EmpathyContact *contact;
- gchar *group;
+ GtkWidget *submenu;
if (!event->button == 1) {
return FALSE;
}
- group = empathy_contact_list_view_get_selected_group (window->list_view);
- if (group) {
+ submenu = empathy_contact_list_view_get_contact_menu (window->list_view);
+ if (submenu) {
GtkMenuItem *item;
GtkWidget *label;
- GtkWidget *submenu;
item = GTK_MENU_ITEM (window->edit_context);
label = gtk_bin_get_child (GTK_BIN (item));
- gtk_label_set_text (GTK_LABEL (label), _("Group"));
+ gtk_label_set_text (GTK_LABEL (label), _("Contact"));
gtk_widget_show (window->edit_context);
gtk_widget_show (window->edit_context_separator);
- submenu = empathy_contact_list_view_get_group_menu (window->list_view);
gtk_menu_item_set_submenu (item, submenu);
- g_free (group);
-
return FALSE;
}
- contact = empathy_contact_list_view_get_selected (window->list_view);
- if (contact) {
+ submenu = empathy_contact_list_view_get_group_menu (window->list_view);
+ if (submenu) {
GtkMenuItem *item;
GtkWidget *label;
- GtkWidget *submenu;
item = GTK_MENU_ITEM (window->edit_context);
label = gtk_bin_get_child (GTK_BIN (item));
- gtk_label_set_text (GTK_LABEL (label), _("Contact"));
+ gtk_label_set_text (GTK_LABEL (label), _("Group"));
gtk_widget_show (window->edit_context);
gtk_widget_show (window->edit_context_separator);
- submenu = empathy_contact_list_view_get_contact_menu (window->list_view,
- contact);
gtk_menu_item_set_submenu (item, submenu);
- g_object_unref (contact);
-
return FALSE;
}