summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEmilio Pozuelo Monfort <emilio.pozuelo@collabora.co.uk>2011-07-26 15:10:06 (GMT)
committerEmilio Pozuelo Monfort <emilio.pozuelo@collabora.co.uk>2011-07-26 15:47:31 (GMT)
commit677445433133cf7532eda340e53566d9c59b7fb8 (patch)
tree56749429a1525cba8958ce1ede93585a69261963
parente068d3348c3d3e957d078eba84f749910386d91f (diff)
downloadempathy-dialpad-entry.tar.gz
empathy-dialpad-entry.tar.xz
Allow to use the dialpad from the keyboarddialpad-entry
-rw-r--r--libempathy-gtk/empathy-ui-utils.c82
-rw-r--r--libempathy-gtk/empathy-ui-utils.h1
-rw-r--r--src/empathy-call-window.c5
-rw-r--r--src/empathy-streamed-media-window.c1
4 files changed, 77 insertions, 12 deletions
diff --git a/libempathy-gtk/empathy-ui-utils.c b/libempathy-gtk/empathy-ui-utils.c
index 569df44..fb54d8d 100644
--- a/libempathy-gtk/empathy-ui-utils.c
+++ b/libempathy-gtk/empathy-ui-utils.c
@@ -2012,6 +2012,20 @@ empathy_individual_match_string (FolksIndividual *individual,
return retval;
}
+static void
+dtmf_dialpad_accel_cb (GtkAccelGroup *accelgroup,
+ GObject *object,
+ guint key,
+ GdkModifierType mod,
+ GtkButton *button)
+{
+ if (gtk_widget_is_sensitive (GTK_WIDGET (button)))
+ {
+ gtk_button_pressed (button);
+ gtk_button_released (button);
+ }
+}
+
static gboolean
dtmf_dialpad_button_pressed_cb (GObject *button,
GtkEntry *entry)
@@ -2027,6 +2041,7 @@ dtmf_dialpad_button_pressed_cb (GObject *button,
GtkWidget *
empathy_create_dtmf_dialpad (GObject *self,
+ GtkAccelGroup *accel_group,
GCallback dtmf_button_pressed_cb,
GCallback dtmf_button_released_cb)
{
@@ -2037,18 +2052,32 @@ empathy_create_dtmf_dialpad (GObject *self,
const gchar *label;
const gchar *sublabel;
TpDTMFEvent event;
- } dtmfbuttons[] = { { "1", "", TP_DTMF_EVENT_DIGIT_1 },
- { "2", "abc", TP_DTMF_EVENT_DIGIT_2 },
- { "3", "def", TP_DTMF_EVENT_DIGIT_3 },
- { "4", "ghi", TP_DTMF_EVENT_DIGIT_4 },
- { "5", "jkl", TP_DTMF_EVENT_DIGIT_5 },
- { "6", "mno", TP_DTMF_EVENT_DIGIT_6 },
- { "7", "pqrs", TP_DTMF_EVENT_DIGIT_7 },
- { "8", "tuv", TP_DTMF_EVENT_DIGIT_8 },
- { "9", "wxyz", TP_DTMF_EVENT_DIGIT_9 },
- { "#", "", TP_DTMF_EVENT_HASH },
- { "0", "", TP_DTMF_EVENT_DIGIT_0 },
- { "*", "", TP_DTMF_EVENT_ASTERISK },
+ guint accel1;
+ guint accel2;
+ } dtmfbuttons[] = { { "1", "", TP_DTMF_EVENT_DIGIT_1,
+ GDK_KEY_1, GDK_KEY_KP_1 },
+ { "2", "abc", TP_DTMF_EVENT_DIGIT_2,
+ GDK_KEY_2, GDK_KEY_KP_2 },
+ { "3", "def", TP_DTMF_EVENT_DIGIT_3,
+ GDK_KEY_3, GDK_KEY_KP_3 },
+ { "4", "ghi", TP_DTMF_EVENT_DIGIT_4,
+ GDK_KEY_4, GDK_KEY_KP_4 },
+ { "5", "jkl", TP_DTMF_EVENT_DIGIT_5,
+ GDK_KEY_5, GDK_KEY_KP_5 },
+ { "6", "mno", TP_DTMF_EVENT_DIGIT_6,
+ GDK_KEY_6, GDK_KEY_KP_6 },
+ { "7", "pqrs", TP_DTMF_EVENT_DIGIT_7,
+ GDK_KEY_7, GDK_KEY_KP_7 },
+ { "8", "tuv", TP_DTMF_EVENT_DIGIT_8,
+ GDK_KEY_8, GDK_KEY_KP_8 },
+ { "9", "wxyz", TP_DTMF_EVENT_DIGIT_9,
+ GDK_KEY_9, GDK_KEY_KP_9 },
+ { "#", "", TP_DTMF_EVENT_HASH,
+ GDK_KEY_numbersign, 0 },
+ { "0", "", TP_DTMF_EVENT_DIGIT_0,
+ GDK_KEY_0, GDK_KEY_KP_0 },
+ { "*", "", TP_DTMF_EVENT_ASTERISK,
+ GDK_KEY_asterisk, GDK_KEY_KP_Multiply },
{ NULL, } };
box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 3);
@@ -2099,6 +2128,35 @@ empathy_create_dtmf_dialpad (GObject *self,
g_object_set_qdata (G_OBJECT (button), button_quark,
GUINT_TO_POINTER (dtmfbuttons[i].event));
+ /* Accelerators */
+ if (accel_group != NULL)
+ {
+ GClosure *closure;
+
+ closure = g_cclosure_new (
+ G_CALLBACK (dtmf_dialpad_accel_cb),
+ button,
+ NULL);
+
+ gtk_accel_group_connect (accel_group,
+ dtmfbuttons[i].accel1,
+ 0, 0,
+ closure);
+
+ if (dtmfbuttons[i].accel2 != 0)
+ {
+ closure = g_cclosure_new (
+ G_CALLBACK (dtmf_dialpad_accel_cb),
+ button,
+ NULL);
+
+ gtk_accel_group_connect (accel_group,
+ dtmfbuttons[i].accel2,
+ 0, 0,
+ closure);
+ }
+ }
+
/* To update the GtkEntry */
g_signal_connect (G_OBJECT (button), "pressed",
G_CALLBACK (dtmf_dialpad_button_pressed_cb), entry);
diff --git a/libempathy-gtk/empathy-ui-utils.h b/libempathy-gtk/empathy-ui-utils.h
index 1bfaf24..1c72702 100644
--- a/libempathy-gtk/empathy-ui-utils.h
+++ b/libempathy-gtk/empathy-ui-utils.h
@@ -144,6 +144,7 @@ void empathy_send_file_from_uri_list (EmpathyContact *conta
void empathy_send_file_with_file_chooser (EmpathyContact *contact);
void empathy_receive_file_with_file_chooser (EmpathyFTHandler *handler);
GtkWidget * empathy_create_dtmf_dialpad (GObject *self,
+ GtkAccelGroup *accel_group,
GCallback pressed_cb,
GCallback released_cb);
diff --git a/src/empathy-call-window.c b/src/empathy-call-window.c
index 92baf6d..ffccf4f 100644
--- a/src/empathy-call-window.c
+++ b/src/empathy-call-window.c
@@ -958,6 +958,7 @@ static void
empathy_call_window_init (EmpathyCallWindow *self)
{
EmpathyCallWindowPriv *priv;
+ GtkAccelGroup *accel_group;
GtkBuilder *gui;
GtkWidget *top_vbox;
GtkWidget *page;
@@ -1105,7 +1106,11 @@ empathy_call_window_init (EmpathyCallWindow *self)
ev_sidebar_add_page (EV_SIDEBAR (priv->sidebar), "video-input",
_("Video input"), page);
+ accel_group = gtk_accel_group_new ();
+ gtk_window_add_accel_group (GTK_WINDOW (self), accel_group);
+
priv->dtmf_panel = empathy_create_dtmf_dialpad (G_OBJECT (self),
+ accel_group,
G_CALLBACK (dtmf_button_pressed_cb),
G_CALLBACK (dtmf_button_released_cb));
ev_sidebar_add_page (EV_SIDEBAR (priv->sidebar), "dialpad",
diff --git a/src/empathy-streamed-media-window.c b/src/empathy-streamed-media-window.c
index d60c075..d3894a2 100644
--- a/src/empathy-streamed-media-window.c
+++ b/src/empathy-streamed-media-window.c
@@ -1134,6 +1134,7 @@ empathy_streamed_media_window_init (EmpathyStreamedMediaWindow *self)
_("Video input"), page);
priv->dtmf_panel = empathy_create_dtmf_dialpad (G_OBJECT (self),
+ NULL,
G_CALLBACK (dtmf_button_pressed_cb),
G_CALLBACK (dtmf_button_released_cb));
ev_sidebar_add_page (EV_SIDEBAR (priv->sidebar), "dialpad",