pidgin/pidgin

Convert PurpleXferUiOps.add_thumbnail to a signal.

16 months ago, Elliott Sales de Andrade
e6692de3b4de
Parents 39eb6d1b71ff
Children 263f9375fc8d
Convert PurpleXferUiOps.add_thumbnail to a signal.
--- a/ChangeLog.API Sat Dec 21 21:09:12 2019 -0500
+++ b/ChangeLog.API Sat Dec 21 21:51:21 2019 -0500
@@ -480,6 +480,8 @@
* PurplePluginProtocolInfo.add_buddies_with_invite
* PurplePluginProtocolInfo.get_cb_away
* PurpleValue, use GValue instead.
+ * PurpleXferUiOps.add_thumbnail. Use PurpleXfer::add-thumbnail
+ instead.
* PurpleXferUiOps.cancel_local and
PurpleXferUiOps.cancel_remote. Use notify::status on
#PurpleXfer objects instead.
--- a/finch/gntxfer.c Sat Dec 21 21:09:12 2019 -0500
+++ b/finch/gntxfer.c Sat Dec 21 21:51:21 2019 -0500
@@ -526,8 +526,7 @@
{
finch_xfer_new_xfer,
finch_xfer_destroy,
- finch_xfer_add_xfer,
- NULL /* add_thumbnail */
+ finch_xfer_add_xfer
};
/**************************************************************************
--- a/libpurple/xfer.c Sat Dec 21 21:09:12 2019 -0500
+++ b/libpurple/xfer.c Sat Dec 21 21:51:21 2019 -0500
@@ -130,6 +130,7 @@
SIG_READ_LOCAL,
SIG_WRITE_LOCAL,
SIG_DATA_NOT_SENT,
+ SIG_ADD_THUMBNAIL,
SIG_LAST
};
static guint signals[SIG_LAST] = {0};
@@ -1923,14 +1924,9 @@
void
purple_xfer_prepare_thumbnail(PurpleXfer *xfer, const gchar *formats)
{
- PurpleXferUiOps *ui_ops;
-
g_return_if_fail(PURPLE_IS_XFER(xfer));
- ui_ops = purple_xfer_get_ui_ops(xfer);
- if (ui_ops && ui_ops->add_thumbnail) {
- ui_ops->add_thumbnail(xfer, formats);
- }
+ g_signal_emit(xfer, signals[SIG_ADD_THUMBNAIL], 0, formats, NULL);
}
void purple_xfer_set_ui_data(PurpleXfer *xfer, gpointer ui_data)
@@ -2378,6 +2374,18 @@
G_STRUCT_OFFSET(PurpleXferClass, data_not_sent),
g_signal_accumulator_first_wins, NULL, NULL, G_TYPE_BOOLEAN, 2,
G_TYPE_POINTER, G_TYPE_ULONG);
+
+ /**
+ * PurpleXfer::add-thumbnail:
+ * @formats: A comma-separated string of allowed image formats.
+ *
+ * Request that a thumbnail be added to a file transfer.
+ *
+ * Since: 3.0.0
+ */
+ signals[SIG_ADD_THUMBNAIL] = g_signal_new(
+ "add-thumbnail", G_TYPE_FROM_CLASS(klass), G_SIGNAL_ACTION, 0, NULL,
+ NULL, NULL, G_TYPE_NONE, 1, G_TYPE_STRING);
}
PurpleXfer *
--- a/libpurple/xfer.h Sat Dec 21 21:09:12 2019 -0500
+++ b/libpurple/xfer.h Sat Dec 21 21:51:21 2019 -0500
@@ -101,7 +101,6 @@
* @new_xfer: UI op that's called after a new transfer is created.
* @destroy: UI op that's called when a transfer is being destroyed.
* @add_xfer: UI op that's called when a transfer should be added to the UI.
- * @add_thumbnail: Op to create a thumbnail image for a file transfer
*
* File transfer UI operations.
*
@@ -113,7 +112,6 @@
void (*new_xfer)(PurpleXfer *xfer);
void (*destroy)(PurpleXfer *xfer);
void (*add_xfer)(PurpleXfer *xfer);
- void (*add_thumbnail)(PurpleXfer *xfer, const gchar *formats);
};
/**
--- a/pidgin/gtkxfer.c Sat Dec 21 21:09:12 2019 -0500
+++ b/pidgin/gtkxfer.c Sat Dec 21 21:51:21 2019 -0500
@@ -901,63 +901,9 @@
* File Transfer UI Ops
**************************************************************************/
static void
-pidgin_xfer_new_xfer(PurpleXfer *xfer)
-{
- PidginXferUiData *data;
-
- /* This is where we're setting xfer's "ui_data" for the first time. */
- data = g_new0(PidginXferUiData, 1);
- purple_xfer_set_ui_data(xfer, data);
-}
-
-static void
-pidgin_xfer_destroy(PurpleXfer *xfer)
-{
- PidginXferUiData *data;
-
- data = purple_xfer_get_ui_data(xfer);
- if (data) {
- g_free(data->name);
- g_free(data);
- purple_xfer_set_ui_data(xfer, NULL);
- }
-}
-
-static void
-pidgin_xfer_progress_notify(PurpleXfer *xfer, G_GNUC_UNUSED GParamSpec *pspec,
- G_GNUC_UNUSED gpointer data)
-{
- pidgin_xfer_dialog_update_xfer(xfer_dialog, xfer);
-}
-
-static void
-pidgin_xfer_status_notify(PurpleXfer *xfer, G_GNUC_UNUSED GParamSpec *pspec,
+pidgin_xfer_add_thumbnail(PurpleXfer *xfer, const gchar *formats,
G_GNUC_UNUSED gpointer data)
{
- if (xfer_dialog) {
- if (purple_xfer_is_cancelled(xfer)) {
- pidgin_xfer_dialog_cancel_xfer(xfer_dialog, xfer);
- }
- }
-}
-
-static void
-pidgin_xfer_add_xfer(PurpleXfer *xfer)
-{
- if (xfer_dialog == NULL)
- xfer_dialog = pidgin_xfer_dialog_new();
-
- pidgin_xfer_dialog_add_xfer(xfer_dialog, xfer);
-
- g_signal_connect(xfer, "notify::progress",
- G_CALLBACK(pidgin_xfer_progress_notify), NULL);
- g_signal_connect(xfer, "notify::status",
- G_CALLBACK(pidgin_xfer_status_notify), NULL);
-}
-
-static void
-pidgin_xfer_add_thumbnail(PurpleXfer *xfer, const gchar *formats)
-{
purple_debug_info("xfer", "creating thumbnail for transfer\n");
if (purple_xfer_get_size(xfer) <= PIDGIN_XFER_MAX_SIZE_IMAGE_THUMBNAIL) {
@@ -1016,12 +962,70 @@
}
}
+static void
+pidgin_xfer_new_xfer(PurpleXfer *xfer)
+{
+ PidginXferUiData *data;
+
+ /* This is where we're setting xfer's "ui_data" for the first time. */
+ data = g_new0(PidginXferUiData, 1);
+ purple_xfer_set_ui_data(xfer, data);
+
+ g_signal_connect(xfer, "add-thumbnail",
+ G_CALLBACK(pidgin_xfer_add_thumbnail), NULL);
+}
+
+static void
+pidgin_xfer_destroy(PurpleXfer *xfer)
+{
+ PidginXferUiData *data;
+
+ data = purple_xfer_get_ui_data(xfer);
+ if (data) {
+ g_free(data->name);
+ g_free(data);
+ purple_xfer_set_ui_data(xfer, NULL);
+ }
+}
+
+static void
+pidgin_xfer_progress_notify(PurpleXfer *xfer, G_GNUC_UNUSED GParamSpec *pspec,
+ G_GNUC_UNUSED gpointer data)
+{
+ pidgin_xfer_dialog_update_xfer(xfer_dialog, xfer);
+}
+
+static void
+pidgin_xfer_status_notify(PurpleXfer *xfer, G_GNUC_UNUSED GParamSpec *pspec,
+ G_GNUC_UNUSED gpointer data)
+{
+ if (xfer_dialog) {
+ if (purple_xfer_is_cancelled(xfer)) {
+ pidgin_xfer_dialog_cancel_xfer(xfer_dialog, xfer);
+ }
+ }
+}
+
+static void
+pidgin_xfer_add_xfer(PurpleXfer *xfer)
+{
+ if (xfer_dialog == NULL) {
+ xfer_dialog = pidgin_xfer_dialog_new();
+ }
+
+ pidgin_xfer_dialog_add_xfer(xfer_dialog, xfer);
+
+ g_signal_connect(xfer, "notify::progress",
+ G_CALLBACK(pidgin_xfer_progress_notify), NULL);
+ g_signal_connect(xfer, "notify::status",
+ G_CALLBACK(pidgin_xfer_status_notify), NULL);
+}
+
static PurpleXferUiOps ops =
{
pidgin_xfer_new_xfer,
pidgin_xfer_destroy,
- pidgin_xfer_add_xfer,
- pidgin_xfer_add_thumbnail
+ pidgin_xfer_add_xfer
};
/**************************************************************************