[ekiga] Support to send DTMFs from anywhere in the main GUI.



commit 366335cf12bd366dccbf4361f0de37eb01b53702
Author: Damien Sandras <dsandras seconix com>
Date:   Sun May 17 17:14:42 2009 +0200

    Support to send DTMFs from anywhere in the main GUI.
    
    Formerly, when you were in call and wanted to send a DTMF, it was
    necessary to switch to dialpad and press the appropriate button.
    
    It is now possible to press any allowed key from anywhere in the main
    window when it has the focus. That way, the user does not have to
    constantly switch between the dialpad and the roster when he wants
    to input DTMFs to a remote system.
---
 src/gui/main.cpp |   34 ++++++++++++++++++++++++++++++++++
 1 files changed, 34 insertions(+), 0 deletions(-)

diff --git a/src/gui/main.cpp b/src/gui/main.cpp
index 9be08c4..8762bcc 100644
--- a/src/gui/main.cpp
+++ b/src/gui/main.cpp
@@ -389,6 +389,15 @@ static void panel_section_changed_cb (GtkNotebook *,
 
 
 /* DESCRIPTION  :  This callback is called when the user 
+ *                 presses a key. 
+ * BEHAVIOR     :  Sends a DTMF if we are in a call.
+ * PRE          :  A valid pointer to the main window GMObject.
+ */
+static gboolean key_press_event_cb (EkigaMainWindow *mw,
+                                    GdkEventKey *key);
+
+
+/* DESCRIPTION  :  This callback is called when the user 
  *                 clicks on the dialpad button.
  * BEHAVIOR     :  Generates a dialpad event.
  * PRE          :  A valid pointer to the main window GMObject.
@@ -2090,6 +2099,28 @@ dialpad_button_clicked_cb (EkigaDialpad  * /* dialpad */,
 }
 
 
+static gboolean
+key_press_event_cb (EkigaMainWindow *mw,
+                    GdkEventKey *key)
+{
+  const char valid_dtmfs[] = "1234567890#*";
+  unsigned i = 0;
+
+  if (mw->priv->current_call) {
+    while (i < strlen (valid_dtmfs)) {
+      if (key->string[0] && key->string[0] == valid_dtmfs[i]) {
+        mw->priv->current_call->send_dtmf (key->string[0]);
+        return true;
+      }
+      i++;
+    }
+  }
+
+  return false;
+}
+
+
+
 static gint 
 window_closed_cb (G_GNUC_UNUSED GtkWidget *widget,
 		  G_GNUC_UNUSED GdkEvent *event,
@@ -3439,6 +3470,9 @@ ekiga_main_window_init_dialpad (EkigaMainWindow *mw)
   label = gtk_label_new (_("Dialpad"));
   gtk_notebook_append_page (GTK_NOTEBOOK (mw->priv->main_notebook),
 			    alignment, label);
+
+  g_signal_connect (G_OBJECT (mw), "key-press-event",
+                    G_CALLBACK (key_press_event_cb), mw);
 }
 
 



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