aboutsummaryrefslogtreecommitdiffstats
path: root/libempathy-gtk
diff options
context:
space:
mode:
authorGuillaume Desmottes <guillaume.desmottes@collabora.co.uk>2012-06-01 21:00:35 +0800
committerGuillaume Desmottes <guillaume.desmottes@collabora.co.uk>2012-06-14 15:21:49 +0800
commita96c2a5c0ac5133ab8b7a14fab0f2857cead162d (patch)
tree95c9305295e9461b5575e8576a395072855dfc54 /libempathy-gtk
parent785ce2292d3b61afd25099fd87eb3b7fbf4f4270 (diff)
downloadgsoc2013-empathy-a96c2a5c0ac5133ab8b7a14fab0f2857cead162d.tar
gsoc2013-empathy-a96c2a5c0ac5133ab8b7a14fab0f2857cead162d.tar.gz
gsoc2013-empathy-a96c2a5c0ac5133ab8b7a14fab0f2857cead162d.tar.bz2
gsoc2013-empathy-a96c2a5c0ac5133ab8b7a14fab0f2857cead162d.tar.lz
gsoc2013-empathy-a96c2a5c0ac5133ab8b7a14fab0f2857cead162d.tar.xz
gsoc2013-empathy-a96c2a5c0ac5133ab8b7a14fab0f2857cead162d.tar.zst
gsoc2013-empathy-a96c2a5c0ac5133ab8b7a14fab0f2857cead162d.zip
Add popup-individual-menu signal
Diffstat (limited to 'libempathy-gtk')
-rw-r--r--libempathy-gtk/empathy-roster-view.c73
1 files changed, 73 insertions, 0 deletions
diff --git a/libempathy-gtk/empathy-roster-view.c b/libempathy-gtk/empathy-roster-view.c
index dadc044c8..28aac164c 100644
--- a/libempathy-gtk/empathy-roster-view.c
+++ b/libempathy-gtk/empathy-roster-view.c
@@ -21,6 +21,7 @@ enum
enum
{
SIG_INDIVIDUAL_ACTIVATED,
+ SIG_POPUP_INDIVIDUAL_MENU,
LAST_SIGNAL
};
@@ -815,11 +816,73 @@ empathy_roster_view_child_activated (EggListBox *box,
}
static void
+fire_popup_individual_menu (EmpathyRosterView *self,
+ GtkWidget *child,
+ guint button,
+ guint time)
+{
+ EmpathyRosterContact *contact;
+ FolksIndividual *individual;
+
+ if (!EMPATHY_IS_ROSTER_CONTACT (child))
+ return;
+
+ contact = EMPATHY_ROSTER_CONTACT (child);
+ individual = empathy_roster_contact_get_individual (contact);
+
+ g_signal_emit (self, signals[SIG_POPUP_INDIVIDUAL_MENU], 0,
+ individual, button, time);
+}
+
+static gboolean
+empathy_roster_view_button_press_event (GtkWidget *widget,
+ GdkEventButton *event)
+{
+ EmpathyRosterView *self = EMPATHY_ROSTER_VIEW (widget);
+ gboolean (*chain_up) (GtkWidget *, GdkEventButton *) =
+ ((GtkWidgetClass *) empathy_roster_view_parent_class)->button_press_event;
+
+ if (event->button == 3)
+ {
+ GtkWidget *child;
+
+ child = egg_list_box_get_child_at_y (EGG_LIST_BOX (self), event->y);
+
+ if (child != NULL)
+ fire_popup_individual_menu (self, child, event->button, event->time);
+ }
+
+ return chain_up (widget, event);
+}
+
+static gboolean
+empathy_roster_view_key_press_event (GtkWidget *widget,
+ GdkEventKey *event)
+{
+ EmpathyRosterView *self = EMPATHY_ROSTER_VIEW (widget);
+ gboolean (*chain_up) (GtkWidget *, GdkEventKey *) =
+ ((GtkWidgetClass *) empathy_roster_view_parent_class)->key_press_event;
+
+ if (event->keyval == GDK_KEY_Menu)
+ {
+ GtkWidget *child;
+
+ child = egg_list_box_get_selected_child (EGG_LIST_BOX (self));
+
+ if (child != NULL)
+ fire_popup_individual_menu (self, child, 0, event->time);
+ }
+
+ return chain_up (widget, event);
+}
+
+static void
empathy_roster_view_class_init (
EmpathyRosterViewClass *klass)
{
GObjectClass *oclass = G_OBJECT_CLASS (klass);
EggListBoxClass *box_class = EGG_LIST_BOX_CLASS (klass);
+ GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
GParamSpec *spec;
oclass->get_property = empathy_roster_view_get_property;
@@ -828,6 +891,9 @@ empathy_roster_view_class_init (
oclass->dispose = empathy_roster_view_dispose;
oclass->finalize = empathy_roster_view_finalize;
+ widget_class->button_press_event = empathy_roster_view_button_press_event;
+ widget_class->key_press_event = empathy_roster_view_key_press_event;
+
box_class->child_activated = empathy_roster_view_child_activated;
spec = g_param_spec_object ("manager", "Manager",
@@ -855,6 +921,13 @@ empathy_roster_view_class_init (
G_TYPE_NONE,
1, FOLKS_TYPE_INDIVIDUAL);
+ signals[SIG_POPUP_INDIVIDUAL_MENU] = g_signal_new ("popup-individual-menu",
+ G_OBJECT_CLASS_TYPE (klass),
+ G_SIGNAL_RUN_LAST,
+ 0, NULL, NULL, NULL,
+ G_TYPE_NONE,
+ 3, FOLKS_TYPE_INDIVIDUAL, G_TYPE_UINT, G_TYPE_UINT);
+
g_type_class_add_private (klass, sizeof (EmpathyRosterViewPriv));
}