[empathy] Factor out dialpad into a utility function



commit c5c0cd8d6f433896b406287cf5be078670cb734d
Author: Danielle Madeley <danielle madeley collabora co uk>
Date:   Fri May 13 13:19:49 2011 +1000

    Factor out dialpad into a utility function
    
    The dialpad is shared between empathy-call and empathy-av.
    
    Really it would be nice to make the dialpad its own little widget that emits
    signals with DTMF event ids, but I've got things to get done.
    
    Conflicts:
    
    	libempathy-gtk/empathy-ui-utils.c
    	src/empathy-call-window.c
    	src/empathy-streamed-media-window.c

 libempathy-gtk/empathy-ui-utils.c   |   47 +++++++++++++++++++++++++++++++
 libempathy-gtk/empathy-ui-utils.h   |    5 +++
 src/empathy-call-window.c           |   53 ++--------------------------------
 src/empathy-streamed-media-window.c |   53 ++--------------------------------
 4 files changed, 60 insertions(+), 98 deletions(-)
---
diff --git a/libempathy-gtk/empathy-ui-utils.c b/libempathy-gtk/empathy-ui-utils.c
index 7e4a823..77a1339 100644
--- a/libempathy-gtk/empathy-ui-utils.c
+++ b/libempathy-gtk/empathy-ui-utils.c
@@ -2011,3 +2011,50 @@ empathy_individual_match_string (FolksIndividual *individual,
    * contact's vCard for example. */
   return retval;
 }
+
+GtkWidget *
+empathy_create_dtmf_dialpad (GObject *self,
+    GCallback dtmf_button_pressed_cb,
+    GCallback dtmf_button_released_cb)
+{
+  GtkWidget *table;
+  int i;
+  GQuark button_quark;
+  struct {
+    const gchar *label;
+    TpDTMFEvent event;
+  } dtmfbuttons[] = { { "1", TP_DTMF_EVENT_DIGIT_1 },
+                      { "2", TP_DTMF_EVENT_DIGIT_2 },
+                      { "3", TP_DTMF_EVENT_DIGIT_3 },
+                      { "4", TP_DTMF_EVENT_DIGIT_4 },
+                      { "5", TP_DTMF_EVENT_DIGIT_5 },
+                      { "6", TP_DTMF_EVENT_DIGIT_6 },
+                      { "7", TP_DTMF_EVENT_DIGIT_7 },
+                      { "8", TP_DTMF_EVENT_DIGIT_8 },
+                      { "9", TP_DTMF_EVENT_DIGIT_9 },
+                      { "#", TP_DTMF_EVENT_HASH },
+                      { "0", TP_DTMF_EVENT_DIGIT_0 },
+                      { "*", TP_DTMF_EVENT_ASTERISK },
+                      { NULL, } };
+
+  button_quark = g_quark_from_static_string (EMPATHY_DTMF_BUTTON_ID);
+
+  table = gtk_table_new (4, 3, TRUE);
+
+  for (i = 0; dtmfbuttons[i].label != NULL; i++)
+    {
+      GtkWidget *button = gtk_button_new_with_label (dtmfbuttons[i].label);
+      gtk_table_attach (GTK_TABLE (table), button, i % 3, i % 3 + 1,
+        i/3, i/3 + 1, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 1, 1);
+
+      g_object_set_qdata (G_OBJECT (button), button_quark,
+        GUINT_TO_POINTER (dtmfbuttons[i].event));
+
+      g_signal_connect (G_OBJECT (button), "pressed",
+        dtmf_button_pressed_cb, self);
+      g_signal_connect (G_OBJECT (button), "released",
+        dtmf_button_released_cb, self);
+    }
+
+  return table;
+}
diff --git a/libempathy-gtk/empathy-ui-utils.h b/libempathy-gtk/empathy-ui-utils.h
index f61e9e3..1bfaf24 100644
--- a/libempathy-gtk/empathy-ui-utils.h
+++ b/libempathy-gtk/empathy-ui-utils.h
@@ -49,6 +49,8 @@ G_BEGIN_DECLS
 					    (x) < gdk_screen_width () && \
 					    (y) < gdk_screen_height ())
 
+#define EMPATHY_DTMF_BUTTON_ID "empathy-call-dtmf-button-id"
+
 typedef void (*EmpathyPixbufAvatarFromIndividualCb) (FolksIndividual *individual,
 		GdkPixbuf *pixbuf,
 		gpointer user_data);
@@ -141,6 +143,9 @@ void        empathy_send_file_from_uri_list             (EmpathyContact   *conta
 							 const gchar      *uri_list);
 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,
+							 GCallback pressed_cb,
+							 GCallback released_cb);
 
 /* Misc */
 void        empathy_make_color_whiter                   (GdkRGBA *color);
diff --git a/src/empathy-call-window.c b/src/empathy-call-window.c
index 343c692..92baf6d 100644
--- a/src/empathy-call-window.c
+++ b/src/empathy-call-window.c
@@ -61,8 +61,6 @@
 #include "empathy-video-src.h"
 #include "ev-sidebar.h"
 
-#define BUTTON_ID "empathy-call-dtmf-button-id"
-
 #define CONTENT_HBOX_BORDER_WIDTH 6
 #define CONTENT_HBOX_SPACING 3
 #define CONTENT_HBOX_CHILDREN_PACKING_PADDING 3
@@ -324,7 +322,7 @@ dtmf_button_pressed_cb (GtkButton *button, EmpathyCallWindow *window)
 
   g_object_get (priv->handler, "call-channel", &call, NULL);
 
-  button_quark = g_quark_from_static_string (BUTTON_ID);
+  button_quark = g_quark_from_static_string (EMPATHY_DTMF_BUTTON_ID);
   event = GPOINTER_TO_UINT (g_object_get_qdata (G_OBJECT (button),
     button_quark));
 
@@ -347,51 +345,6 @@ dtmf_button_released_cb (GtkButton *button, EmpathyCallWindow *window)
 }
 
 static GtkWidget *
-empathy_call_window_create_dtmf (EmpathyCallWindow *self)
-{
-  GtkWidget *table;
-  int i;
-  GQuark button_quark;
-  struct {
-    const gchar *label;
-    TpDTMFEvent event;
-  } dtmfbuttons[] = { { "1", TP_DTMF_EVENT_DIGIT_1 },
-                      { "2", TP_DTMF_EVENT_DIGIT_2 },
-                      { "3", TP_DTMF_EVENT_DIGIT_3 },
-                      { "4", TP_DTMF_EVENT_DIGIT_4 },
-                      { "5", TP_DTMF_EVENT_DIGIT_5 },
-                      { "6", TP_DTMF_EVENT_DIGIT_6 },
-                      { "7", TP_DTMF_EVENT_DIGIT_7 },
-                      { "8", TP_DTMF_EVENT_DIGIT_8 },
-                      { "9", TP_DTMF_EVENT_DIGIT_9 },
-                      { "#", TP_DTMF_EVENT_HASH },
-                      { "0", TP_DTMF_EVENT_DIGIT_0 },
-                      { "*", TP_DTMF_EVENT_ASTERISK },
-                      { NULL, } };
-
-  button_quark = g_quark_from_static_string (BUTTON_ID);
-
-  table = gtk_table_new (4, 3, TRUE);
-
-  for (i = 0; dtmfbuttons[i].label != NULL; i++)
-    {
-      GtkWidget *button = gtk_button_new_with_label (dtmfbuttons[i].label);
-      gtk_table_attach (GTK_TABLE (table), button, i % 3, i % 3 + 1,
-        i/3, i/3 + 1, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 1, 1);
-
-      g_object_set_qdata (G_OBJECT (button), button_quark,
-        GUINT_TO_POINTER (dtmfbuttons[i].event));
-
-      g_signal_connect (G_OBJECT (button), "pressed",
-        G_CALLBACK (dtmf_button_pressed_cb), self);
-      g_signal_connect (G_OBJECT (button), "released",
-        G_CALLBACK (dtmf_button_released_cb), self);
-    }
-
-  return table;
-}
-
-static GtkWidget *
 empathy_call_window_create_video_input_add_slider (EmpathyCallWindow *self,
   gchar *label_text, GtkWidget *bin)
 {
@@ -1152,7 +1105,9 @@ empathy_call_window_init (EmpathyCallWindow *self)
   ev_sidebar_add_page (EV_SIDEBAR (priv->sidebar), "video-input",
       _("Video input"), page);
 
-  priv->dtmf_panel = empathy_call_window_create_dtmf (self);
+  priv->dtmf_panel = empathy_create_dtmf_dialpad (G_OBJECT (self),
+      G_CALLBACK (dtmf_button_pressed_cb),
+      G_CALLBACK (dtmf_button_released_cb));
   ev_sidebar_add_page (EV_SIDEBAR (priv->sidebar), "dialpad",
       _("Dialpad"), priv->dtmf_panel);
 
diff --git a/src/empathy-streamed-media-window.c b/src/empathy-streamed-media-window.c
index 19b7b2f..d60c075 100644
--- a/src/empathy-streamed-media-window.c
+++ b/src/empathy-streamed-media-window.c
@@ -54,8 +54,6 @@
 #include "empathy-video-src.h"
 #include "ev-sidebar.h"
 
-#define BUTTON_ID "empathy-call-dtmf-button-id"
-
 #define CONTENT_HBOX_BORDER_WIDTH 6
 #define CONTENT_HBOX_SPACING 3
 #define CONTENT_HBOX_CHILDREN_PACKING_PADDING 3
@@ -346,7 +344,7 @@ dtmf_button_pressed_cb (GtkButton *button, EmpathyStreamedMediaWindow *window)
 
   g_object_get (priv->handler, "tp-call", &call, NULL);
 
-  button_quark = g_quark_from_static_string (BUTTON_ID);
+  button_quark = g_quark_from_static_string (EMPATHY_DTMF_BUTTON_ID);
   event = GPOINTER_TO_UINT (g_object_get_qdata (G_OBJECT (button),
     button_quark));
 
@@ -369,51 +367,6 @@ dtmf_button_released_cb (GtkButton *button, EmpathyStreamedMediaWindow *window)
 }
 
 static GtkWidget *
-empathy_streamed_media_window_create_dtmf (EmpathyStreamedMediaWindow *self)
-{
-  GtkWidget *table;
-  int i;
-  GQuark button_quark;
-  struct {
-    const gchar *label;
-    TpDTMFEvent event;
-  } dtmfbuttons[] = { { "1", TP_DTMF_EVENT_DIGIT_1 },
-                      { "2", TP_DTMF_EVENT_DIGIT_2 },
-                      { "3", TP_DTMF_EVENT_DIGIT_3 },
-                      { "4", TP_DTMF_EVENT_DIGIT_4 },
-                      { "5", TP_DTMF_EVENT_DIGIT_5 },
-                      { "6", TP_DTMF_EVENT_DIGIT_6 },
-                      { "7", TP_DTMF_EVENT_DIGIT_7 },
-                      { "8", TP_DTMF_EVENT_DIGIT_8 },
-                      { "9", TP_DTMF_EVENT_DIGIT_9 },
-                      { "#", TP_DTMF_EVENT_HASH },
-                      { "0", TP_DTMF_EVENT_DIGIT_0 },
-                      { "*", TP_DTMF_EVENT_ASTERISK },
-                      { NULL, } };
-
-  button_quark = g_quark_from_static_string (BUTTON_ID);
-
-  table = gtk_table_new (4, 3, TRUE);
-
-  for (i = 0; dtmfbuttons[i].label != NULL; i++)
-    {
-      GtkWidget *button = gtk_button_new_with_label (dtmfbuttons[i].label);
-      gtk_table_attach (GTK_TABLE (table), button, i % 3, i % 3 + 1,
-        i/3, i/3 + 1, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 1, 1);
-
-      g_object_set_qdata (G_OBJECT (button), button_quark,
-        GUINT_TO_POINTER (dtmfbuttons[i].event));
-
-      g_signal_connect (G_OBJECT (button), "pressed",
-        G_CALLBACK (dtmf_button_pressed_cb), self);
-      g_signal_connect (G_OBJECT (button), "released",
-        G_CALLBACK (dtmf_button_released_cb), self);
-    }
-
-  return table;
-}
-
-static GtkWidget *
 empathy_streamed_media_window_create_video_input_add_slider (EmpathyStreamedMediaWindow *self,
   gchar *label_text, GtkWidget *bin)
 {
@@ -1180,7 +1133,9 @@ empathy_streamed_media_window_init (EmpathyStreamedMediaWindow *self)
   ev_sidebar_add_page (EV_SIDEBAR (priv->sidebar), "video-input",
       _("Video input"), page);
 
-  priv->dtmf_panel = empathy_streamed_media_window_create_dtmf (self);
+  priv->dtmf_panel = empathy_create_dtmf_dialpad (G_OBJECT (self),
+      G_CALLBACK (dtmf_button_pressed_cb),
+      G_CALLBACK (dtmf_button_released_cb));
   ev_sidebar_add_page (EV_SIDEBAR (priv->sidebar), "dialpad",
       _("Dialpad"), priv->dtmf_panel);
 



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