Tue, 02 Aug 2022 00:20:10 -0500
Split keypad into its own widget
Testing Done:
Temporarily added a `GtkMenuButton` with a `GtkPopover` containing this widget to the media window, so I could check the buttons. Not sure that it totally works in the final window as I didn't start a real media session.
```
diff --git a/pidgin/gtkmedia.c b/pidgin/gtkmedia.c
--- a/pidgin/gtkmedia.c
+++ b/pidgin/gtkmedia.c
@@ -261,6 +261,14 @@
}
static void
+pidgin_media_dtmf_key_pressed_debug_cb(G_GNUC_UNUSED PidginKeypad *keypad,
+ gchar num,
+ G_GNUC_UNUSED gpointer data)
+{
+ g_message("DTMF key pressed! %c", num);
+}
+
+static void
pidgin_media_init (PidginMedia *media)
{
GtkWidget *vbox;
@@ -289,6 +297,27 @@
gtk_box_pack_start(GTK_BOX(vbox), media->priv->display, TRUE, TRUE, 6);
gtk_widget_show(vbox);
+ {
+ GtkWidget *button = NULL;
+ GtkWidget *keypad = NULL;
+ GtkWidget *popover = NULL;
+
+ button = gtk_menu_button_new();
+ popover = gtk_popover_new(button);
+ gtk_menu_button_set_popover(GTK_MENU_BUTTON(button), popover);
+
+ keypad = pidgin_keypad_new();
+ pidgin_keypad_set_key_capture_widget(PIDGIN_KEYPAD(keypad),
+ GTK_WIDGET(media));
+ g_signal_connect(keypad, "pressed",
+ G_CALLBACK(pidgin_media_dtmf_key_pressed_debug_cb),
+ NULL);
+ gtk_container_add(GTK_CONTAINER(popover), keypad);
+
+ gtk_box_pack_start(GTK_BOX(vbox), button, FALSE, FALSE, 0);
+ gtk_widget_show(button);
+ }
+
g_signal_connect(G_OBJECT(media), "delete-event",
G_CALLBACK(pidgin_media_delete_event_cb), media);
```
Reviewed at https://reviews.imfreedom.org/r/1565/
|
41478
27d70d93355d
Split keypad into its own widget
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
1 | /* |
|
27d70d93355d
Split keypad into its own widget
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
2 | * Pidgin - Internet Messenger |
|
27d70d93355d
Split keypad into its own widget
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
3 | * Copyright (C) Pidgin Developers <devel@pidgin.im> |
|
27d70d93355d
Split keypad into its own widget
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
4 | * |
|
27d70d93355d
Split keypad into its own widget
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
5 | * Pidgin is the legal property of its developers, whose names are too numerous |
|
27d70d93355d
Split keypad into its own widget
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
6 | * to list here. Please refer to the COPYRIGHT file distributed with this |
|
27d70d93355d
Split keypad into its own widget
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
7 | * source distribution. |
|
27d70d93355d
Split keypad into its own widget
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
8 | * |
|
27d70d93355d
Split keypad into its own widget
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
9 | * This program is free software; you can redistribute it and/or modify |
|
27d70d93355d
Split keypad into its own widget
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
10 | * it under the terms of the GNU General Public License as published by |
|
27d70d93355d
Split keypad into its own widget
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
11 | * the Free Software Foundation; either version 2 of the License, or |
|
27d70d93355d
Split keypad into its own widget
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
12 | * (at your option) any later version. |
|
27d70d93355d
Split keypad into its own widget
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
13 | * |
|
27d70d93355d
Split keypad into its own widget
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
14 | * This program is distributed in the hope that it will be useful, |
|
27d70d93355d
Split keypad into its own widget
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
27d70d93355d
Split keypad into its own widget
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
27d70d93355d
Split keypad into its own widget
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
17 | * GNU General Public License for more details. |
|
27d70d93355d
Split keypad into its own widget
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
18 | * |
|
27d70d93355d
Split keypad into its own widget
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
19 | * You should have received a copy of the GNU General Public License |
|
27d70d93355d
Split keypad into its own widget
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
20 | * along with this program; if not, see <https://www.gnu.org/licenses/>. |
|
27d70d93355d
Split keypad into its own widget
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
21 | */ |
|
27d70d93355d
Split keypad into its own widget
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
22 | |
|
27d70d93355d
Split keypad into its own widget
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
23 | #if !defined(PIDGIN_GLOBAL_HEADER_INSIDE) && !defined(PIDGIN_COMPILATION) |
|
27d70d93355d
Split keypad into its own widget
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
24 | # error "only <pidgin.h> may be included directly" |
|
27d70d93355d
Split keypad into its own widget
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
25 | #endif |
|
27d70d93355d
Split keypad into its own widget
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
26 | |
|
27d70d93355d
Split keypad into its own widget
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
27 | #ifndef PIDGIN_KEYPAD_H |
|
27d70d93355d
Split keypad into its own widget
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
28 | #define PIDGIN_KEYPAD_H |
|
27d70d93355d
Split keypad into its own widget
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
29 | |
|
27d70d93355d
Split keypad into its own widget
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
30 | #include <gtk/gtk.h> |
|
27d70d93355d
Split keypad into its own widget
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
31 | |
|
27d70d93355d
Split keypad into its own widget
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
32 | #include <purple.h> |
|
27d70d93355d
Split keypad into its own widget
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
33 | |
|
27d70d93355d
Split keypad into its own widget
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
34 | /** |
|
27d70d93355d
Split keypad into its own widget
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
35 | * PidginKeypad: |
|
27d70d93355d
Split keypad into its own widget
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
36 | * |
|
27d70d93355d
Split keypad into its own widget
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
37 | * #PidginKeypad is a widget that displays a DTMF keypad, with the digits 0-9, |
|
27d70d93355d
Split keypad into its own widget
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
38 | * an asterisk, and a number sign. |
|
27d70d93355d
Split keypad into its own widget
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
39 | * |
|
27d70d93355d
Split keypad into its own widget
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
40 | * Since: 3.0.0 |
|
27d70d93355d
Split keypad into its own widget
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
41 | */ |
|
27d70d93355d
Split keypad into its own widget
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
42 | |
|
27d70d93355d
Split keypad into its own widget
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
43 | G_BEGIN_DECLS |
|
27d70d93355d
Split keypad into its own widget
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
44 | |
|
27d70d93355d
Split keypad into its own widget
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
45 | #define PIDGIN_TYPE_KEYPAD pidgin_keypad_get_type() |
|
27d70d93355d
Split keypad into its own widget
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
46 | G_DECLARE_FINAL_TYPE(PidginKeypad, pidgin_keypad, PIDGIN, KEYPAD, GtkGrid) |
|
27d70d93355d
Split keypad into its own widget
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
47 | |
|
27d70d93355d
Split keypad into its own widget
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
48 | /** |
|
27d70d93355d
Split keypad into its own widget
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
49 | * pidgin_keypad_new: |
|
27d70d93355d
Split keypad into its own widget
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
50 | * |
|
27d70d93355d
Split keypad into its own widget
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
51 | * Creates a new #PidginKeypad. |
|
27d70d93355d
Split keypad into its own widget
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
52 | * |
|
27d70d93355d
Split keypad into its own widget
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
53 | * Returns: (transfer full): The new instance. |
|
27d70d93355d
Split keypad into its own widget
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
54 | * |
|
27d70d93355d
Split keypad into its own widget
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
55 | * Since: 3.0.0 |
|
27d70d93355d
Split keypad into its own widget
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
56 | */ |
|
27d70d93355d
Split keypad into its own widget
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
57 | GtkWidget *pidgin_keypad_new(void); |
|
27d70d93355d
Split keypad into its own widget
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
58 | |
|
27d70d93355d
Split keypad into its own widget
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
59 | /** |
|
27d70d93355d
Split keypad into its own widget
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
60 | * pidgin_keypad_set_key_capture_widget: |
|
27d70d93355d
Split keypad into its own widget
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
61 | * @keypad: The keypad. |
|
27d70d93355d
Split keypad into its own widget
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
62 | * @widget: A widget to capture keys from. |
|
27d70d93355d
Split keypad into its own widget
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
63 | * |
|
27d70d93355d
Split keypad into its own widget
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
64 | * Sets @widget as the widget that @keypad will capture key events from. |
|
27d70d93355d
Split keypad into its own widget
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
65 | * |
|
27d70d93355d
Split keypad into its own widget
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
66 | * If key events are handled by the keypad, the DTMF digits will be captured |
|
27d70d93355d
Split keypad into its own widget
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
67 | * and trigger the pressed signal on @keypad. |
|
27d70d93355d
Split keypad into its own widget
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
68 | * |
|
27d70d93355d
Split keypad into its own widget
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
69 | * Since: 3.0.0 |
|
27d70d93355d
Split keypad into its own widget
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
70 | */ |
|
27d70d93355d
Split keypad into its own widget
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
71 | void pidgin_keypad_set_key_capture_widget(PidginKeypad *keypad, GtkWidget *widget); |
|
27d70d93355d
Split keypad into its own widget
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
72 | |
|
27d70d93355d
Split keypad into its own widget
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
73 | G_END_DECLS |
|
27d70d93355d
Split keypad into its own widget
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
74 | |
|
27d70d93355d
Split keypad into its own widget
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
75 | #endif /* PIDGIN_KEYPAD_H */ |