pidgin/pidgin

Split keypad into its own widget

23 months ago, Elliott Sales de Andrade
27d70d93355d
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/
Title: Connection Signals
Slug: connection-signals
## Connection Signals
### Signal List
* [online](#online)
* [offline](#offline)
* [signing-on](#signing-on)
* [signed-on](#signed-on)
* [autojoin](#autojoin)
* [signing-off](#signing-off)
* [signed-off](#signed-off)
* [connection-error](#connection-error)
### Signal Details
#### online
```c
void user_function(gpointer user_data);
```
Emitted when the first connection has connected when all connections were
previously not connected.
**Parameters:**
**user_data**
: user data set when the signal handler was connected.
----
#### offline
```c
void user_function(gpointer user_data);
```
Emitted when the last connected connection has disconnected.
**Parameters:**
**user_data**
: user data set when the signal handler was connected.
----
#### signing-on
```c
void user_function(PurpleConnection *gc, gpointer user_data);
```
Emitted when a connection is about to sign on.
**Parameters:**
**gc**
: The connection that is about to sign on.
**user_data**
: user data set when the signal handler was connected.
----
#### signed-on
```c
void user_function(PurpleConnection *gc, gpointer user_data);
```
Emitted when a connection has signed on.
**Parameters:**
**gc**
: The connection that has signed on.
**user_data**
: user data set when the signal handler was connected.
----
#### autojoin
```c
gboolean user_function(PurpleConnection *gc, gpointer user_data);
```
Emitted when a connection has signed on, after the signed-on signal, to signal
UIs to autojoin chats if they wish. UIs should connect to this with
`PURPLE_SIGNAL_PRIORITY_HIGHEST` to allow plugins to block this signal before
the UI sees it and then re-emit it later.
**Parameters:**
**gc**
: The connection that has signed on.
**user_data**
: user data set when the signal handler was connected.
**Returns:**
`TRUE` if the signal was handled or `FALSE` otherwise. In practice, the return
value is irrelevant, as it really only exists so plugins can block the UI's
autojoin.
----
#### signing-off
```c
void user_function(PurpleConnection *gc, gpointer user_data);
```
Emitted when a connection is about to sign off.
**Parameters:**
**gc**
: The connection that is about to sign off.
**user_data**
: user data set when the signal handler was connected.
----
#### signed-off
```c
void user_function(PurpleConnection *gc, gpointer user_data);
```
Emitted when a connection has signed off.
**Parameters:**
**gc**
: The connection that has signed off.
**user_data**
: user data set when the signal handler was connected.
----
#### connection-error
```c
void user_function(PurpleConnection *gc,
PurpleConnectionError err,
const gchar *desc,
gpointer user_data);
```
Emitted when a connection error occurs, before `"signed"`-off.
**Parameters:**
**gc**
: The connection on which the error has occurred.
**err**
: The error that occurred.
**desc**
: A description of the error, giving more information.
**user_data**
: user data set when the signal handler was connected.