pidgin/pidgin

d08b9a655b0e
Parents 5c79e2bb862b
Children f8771a229df1
Remove pidgin_create_icon_from_protocol and pidgin_create_protocol_icon

Testing Done:
Compiled.

Reviewed at https://reviews.imfreedom.org/r/1628/
--- a/ChangeLog.API Tue Aug 23 02:01:50 2022 -0500
+++ b/ChangeLog.API Tue Aug 23 02:25:05 2022 -0500
@@ -927,6 +927,8 @@
* pidgin_conversations_fill_menu
* pidgin_conversations_get_unseen_all
* pidgin_create_dialog, use pidgin_dialog_new instead.
+ * pidgin_create_icon_from_protocol
+ * pidgin_create_protocol_icon
* pidgin_create_small_button, use pidgin_close_button_new instead.
* pidgin_create_status_icon
* pidgin_create_window, use pidgin_window_new instead.
--- a/pidgin/gtkblist.c Tue Aug 23 02:01:50 2022 -0500
+++ b/pidgin/gtkblist.c Tue Aug 23 02:25:05 2022 -0500
@@ -89,7 +89,7 @@
NODE_COLUMN,
EMBLEM_COLUMN,
EMBLEM_VISIBLE_COLUMN,
- PROTOCOL_ICON_COLUMN,
+ PROTOCOL_ICON_NAME_COLUMN,
BLIST_COLUMNS
};
@@ -1897,18 +1897,17 @@
static void
add_tip_for_account(GtkWidget *grid, gint row, PurpleAccount *account)
{
- GdkPixbuf *protocol_icon = NULL;
+ PurpleProtocol *protocol = NULL;
GtkWidget *image = NULL;
GtkWidget *name = NULL;
-
- protocol_icon = pidgin_create_protocol_icon(account, PIDGIN_PROTOCOL_ICON_SMALL);
- if (purple_account_is_disconnected(account)) {
- gdk_pixbuf_saturate_and_pixelate(protocol_icon, protocol_icon, 0.0, FALSE);
- }
- image = gtk_image_new_from_pixbuf(protocol_icon);
+ const gchar *icon_name = NULL;
+
+ protocol = purple_account_get_protocol(account);
+ icon_name = purple_protocol_get_icon_name(protocol);
+
+ image = gtk_image_new_from_icon_name(icon_name);
gtk_image_set_pixel_size(GTK_IMAGE(image), STATUS_SIZE);
gtk_grid_attach(GTK_GRID(grid), image, 0, row, 1, 1);
- g_clear_object(&protocol_icon);
name = gtk_label_new(purple_account_get_username(account));
gtk_label_set_xalign(GTK_LABEL(name), 0);
@@ -1965,13 +1964,13 @@
gtk_grid_attach(GTK_GRID(grid), name, 1, row, 1, 1);
if (account != NULL) {
- GdkPixbuf *protocol_icon = pidgin_create_protocol_icon(
- account, PIDGIN_PROTOCOL_ICON_SMALL);
- image = gtk_image_new_from_pixbuf(protocol_icon);
+ PurpleProtocol *protocol = purple_account_get_protocol(account);
+ const gchar *icon_name = purple_protocol_get_icon_name(protocol);
+
+ image = gtk_image_new_from_icon_name(icon_name);
gtk_image_set_pixel_size(GTK_IMAGE(image), STATUS_SIZE);
gtk_widget_set_halign(image, GTK_ALIGN_END);
gtk_grid_attach(GTK_GRID(grid), image, 2, row, 1, 1);
- g_clear_object(&protocol_icon);
}
tooltip_text = pidgin_get_tooltip_text(node, full);
@@ -1986,12 +1985,6 @@
}
avatar = pidgin_blist_get_buddy_icon(node, !full, FALSE);
-#if 0 /* Protocol Icon as avatar */
- if(!avatar && full) {
- avatar = pidgin_create_protocol_icon(account, PIDGIN_PROTOCOL_ICON_LARGE);
- }
-#endif
-
if (avatar != NULL) {
avatar_image = gtk_image_new_from_pixbuf(avatar);
gtk_widget_set_halign(avatar_image, GTK_ALIGN_END);
@@ -2980,7 +2973,7 @@
rend = gtk_cell_renderer_pixbuf_new();
gtk_tree_view_column_pack_start(column, rend, FALSE);
gtk_tree_view_column_set_attributes(column, rend,
- "pixbuf", PROTOCOL_ICON_COLUMN,
+ "icon-name", PROTOCOL_ICON_NAME_COLUMN,
NULL);
g_object_set(rend, "xalign", 0.0, "xpad", 3, "ypad", 0, NULL);
@@ -3097,7 +3090,7 @@
G_TYPE_POINTER, /* Node */
GDK_TYPE_PIXBUF, /* Emblem */
G_TYPE_BOOLEAN, /* Emblem visible */
- GDK_TYPE_PIXBUF /* Protocol icon */
+ G_TYPE_STRING /* Protocol icon */
);
gtkblist->treeview = gtk_tree_view_new_with_model(GTK_TREE_MODEL(gtkblist->treemodel));
@@ -3469,10 +3462,12 @@
static void buddy_node(PurpleBuddy *buddy, GtkTreeIter *iter, PurpleBlistNode *node)
{
PurplePresence *presence = purple_buddy_get_presence(buddy);
- GdkPixbuf *status, *avatar, *emblem, *protocol_icon;
+ PurpleProtocol *protocol = NULL;
+ GdkPixbuf *status, *avatar, *emblem;
char *mark;
char *idle = NULL;
gboolean selected = (gtkblist->selected_node == node);
+ const gchar *protocol_icon_name = NULL;
if(editing_blist) {
return;
@@ -3491,7 +3486,8 @@
emblem = pidgin_blist_get_emblem(PURPLE_BLIST_NODE(buddy));
mark = pidgin_blist_get_name_markup(buddy, selected, TRUE);
- protocol_icon = pidgin_create_protocol_icon(purple_buddy_get_account(buddy), PIDGIN_PROTOCOL_ICON_SMALL);
+ protocol = purple_account_get_protocol(purple_buddy_get_account(buddy));
+ protocol_icon_name = purple_protocol_get_icon_name(protocol);
gtk_tree_store_set(gtkblist->treemodel, iter,
STATUS_ICON_COLUMN, status,
@@ -3500,7 +3496,7 @@
BUDDY_ICON_COLUMN, avatar,
EMBLEM_COLUMN, emblem,
EMBLEM_VISIBLE_COLUMN, (emblem != NULL),
- PROTOCOL_ICON_COLUMN, protocol_icon,
+ PROTOCOL_ICON_NAME_COLUMN, protocol_icon_name,
-1);
g_free(mark);
@@ -3511,8 +3507,6 @@
g_object_unref(status);
if(avatar)
g_object_unref(avatar);
- if(protocol_icon)
- g_object_unref(protocol_icon);
}
/* This is a variation on the original gtk_blist_update_contact. Here we
@@ -3627,12 +3621,14 @@
chat = (PurpleChat*)node;
if(purple_account_is_connected(purple_chat_get_account(chat))) {
+ PurpleProtocol *protocol = NULL;
GtkTreeIter iter;
- GdkPixbuf *status, *avatar, *emblem, *protocol_icon;
+ GdkPixbuf *status, *avatar, *emblem;
const gchar *color = NULL;
gchar *mark, *tmp;
gboolean selected = (gtkblist->selected_node == node);
gboolean nick_said = FALSE;
+ const gchar *protocol_icon_name = NULL;
if (!insert_node(list, node, &iter))
return;
@@ -3654,7 +3650,8 @@
mark = tmp;
}
- protocol_icon = pidgin_create_protocol_icon(purple_chat_get_account(chat), PIDGIN_PROTOCOL_ICON_SMALL);
+ protocol = purple_account_get_protocol(purple_chat_get_account(chat));
+ protocol_icon_name = purple_protocol_get_icon_name(protocol);
gtk_tree_store_set(gtkblist->treemodel, &iter,
STATUS_ICON_COLUMN, status,
@@ -3662,7 +3659,7 @@
BUDDY_ICON_COLUMN, avatar,
EMBLEM_COLUMN, emblem,
EMBLEM_VISIBLE_COLUMN, emblem != NULL,
- PROTOCOL_ICON_COLUMN, protocol_icon,
+ PROTOCOL_ICON_NAME_COLUMN, protocol_icon_name,
NAME_COLUMN, mark,
-1);
@@ -3673,9 +3670,6 @@
g_object_unref(status);
if(avatar)
g_object_unref(avatar);
- if(protocol_icon)
- g_object_unref(protocol_icon);
-
} else {
pidgin_blist_hide_node(list, node, TRUE);
}
--- a/pidgin/gtknotify.c Tue Aug 23 02:01:50 2022 -0500
+++ b/pidgin/gtknotify.c Tue Aug 23 02:25:05 2022 -0500
@@ -111,15 +111,17 @@
static void
pidgin_widget_decorate_account(GtkWidget *cont, PurpleAccount *account)
{
+ PurpleProtocol *protocol = NULL;
GtkWidget *image;
- GdkPixbuf *pixbuf;
+ const gchar *icon_name = NULL;
if (!account)
return;
- pixbuf = pidgin_create_protocol_icon(account, PIDGIN_PROTOCOL_ICON_SMALL);
- image = gtk_image_new_from_pixbuf(pixbuf);
- g_object_unref(G_OBJECT(pixbuf));
+ protocol = purple_account_get_protocol(account);
+ icon_name = purple_protocol_get_icon_name(protocol);
+
+ image = gtk_image_new_from_icon_name(icon_name);
gtk_widget_set_tooltip_text(image,
purple_account_get_username(account));
@@ -322,20 +324,22 @@
void *data_)
{
PidginNotifySearchResultsData *data = data_;
+ PurpleProtocol *protocol = NULL;
GtkListStore *model = data->model;
GtkTreeIter iter;
- GdkPixbuf *pixbuf;
GList *row, *column;
guint n;
+ const gchar *icon_name = NULL;
gtk_list_store_clear(data->model);
- pixbuf = pidgin_create_protocol_icon(purple_connection_get_account(gc), PIDGIN_PROTOCOL_ICON_SMALL);
+ protocol = purple_account_get_protocol(purple_connection_get_account(gc));
+ icon_name = purple_protocol_get_icon_name(protocol);
for (row = results->rows; row != NULL; row = row->next) {
gtk_list_store_append(model, &iter);
- gtk_list_store_set(model, &iter, 0, pixbuf, -1);
+ gtk_list_store_set(model, &iter, 0, icon_name, -1);
n = 1;
for (column = row->data; column != NULL; column = column->next) {
@@ -348,9 +352,6 @@
n++;
}
}
-
- if (pixbuf != NULL)
- g_object_unref(pixbuf);
}
static void *
@@ -443,7 +444,7 @@
renderer = gtk_cell_renderer_pixbuf_new();
gtk_tree_view_insert_column_with_attributes(GTK_TREE_VIEW(treeview),
- -1, "", renderer, "pixbuf", 0, NULL);
+ -1, "", renderer, "icon-name", 0, NULL);
i = 1;
for (columniter = results->columns; columniter != NULL; columniter = columniter->next) {
--- a/pidgin/gtkrequest.c Tue Aug 23 02:01:50 2022 -0500
+++ b/pidgin/gtkrequest.c Tue Aug 23 02:25:05 2022 -0500
@@ -89,20 +89,18 @@
static void
pidgin_widget_decorate_account(GtkWidget *cont, PurpleAccount *account)
{
+ PurpleProtocol *protocol = NULL;
GtkWidget *image;
- GdkPixbuf *pixbuf;
+ const gchar *icon_name = NULL;
if(!PURPLE_IS_ACCOUNT(account)) {
return;
}
- pixbuf = pidgin_create_protocol_icon(account, PIDGIN_PROTOCOL_ICON_SMALL);
- if(!GDK_IS_PIXBUF(pixbuf)) {
- return;
- }
-
- image = gtk_image_new_from_pixbuf(pixbuf);
- g_object_unref(G_OBJECT(pixbuf));
+ protocol = purple_account_get_protocol(account);
+ icon_name = purple_protocol_get_icon_name(protocol);
+
+ image = gtk_image_new_from_icon_name(icon_name);
gtk_widget_set_tooltip_text(image, purple_account_get_username(account));
@@ -1557,7 +1555,6 @@
_pidgin_datasheet_stock_icon_get(const gchar *stock_name)
{
GdkPixbuf *image = NULL;
- gchar *domain, *id;
if (stock_name == NULL)
return NULL;
@@ -1572,46 +1569,9 @@
return image;
}
- domain = g_strdup(stock_name);
- id = strchr(domain, '/');
- if (!id) {
- g_free(domain);
- return NULL;
- }
- id[0] = '\0';
- id++;
-
- if (purple_strequal(domain, "protocol")) {
- PurpleAccount *account;
- PurpleAccountManager *manager = NULL;
- gchar *protocol_id, *accountname;
-
- protocol_id = id;
- accountname = strchr(id, ':');
-
- if (!accountname) {
- g_free(domain);
- return NULL;
- }
-
- accountname[0] = '\0';
- accountname++;
-
- manager = purple_account_manager_get_default();
- account = purple_account_manager_find(manager, accountname,
- protocol_id);
- if(account) {
- image = pidgin_create_protocol_icon(account,
- PIDGIN_PROTOCOL_ICON_SMALL);
- }
- } else {
- purple_debug_error("gtkrequest", "Unknown domain: %s", domain);
- g_free(domain);
- return NULL;
- }
-
- g_hash_table_insert(datasheet_stock, g_strdup(stock_name), image);
- return image;
+ purple_debug_error("gtkrequest", "Unknown icon: %s", stock_name);
+
+ return NULL;
}
static PurpleRequestDatasheetRecord*
--- a/pidgin/gtkutils.c Tue Aug 23 02:01:50 2022 -0500
+++ b/pidgin/gtkutils.c Tue Aug 23 02:25:05 2022 -0500
@@ -121,58 +121,6 @@
return vbox2;
}
-GdkPixbuf *
-pidgin_create_icon_from_protocol(PurpleProtocol *protocol,
- PidginProtocolIconSize size,
- PurpleAccount *account)
-{
- GdkPixbuf *pixbuf;
- const char *protoname = NULL;
- const gchar *icon_name = NULL;
- char *tmp;
- GtkIconTheme *theme = NULL;
- gint dimensions = 0;
-
- theme = gtk_icon_theme_get_default();
- if(size == PIDGIN_PROTOCOL_ICON_SMALL) {
- dimensions = 16;
- } else if(size == PIDGIN_PROTOCOL_ICON_MEDIUM) {
- dimensions = 22;
- } else {
- dimensions = 48;
- }
-
- /* If the protocol specified an icon-name try to load it from the icon
- * theme.
- */
- icon_name = purple_protocol_get_icon_name(protocol);
- if(icon_name != NULL) {
- pixbuf = gtk_icon_theme_load_icon(theme, icon_name, dimensions,
- GTK_ICON_LOOKUP_FORCE_SIZE, NULL);
-
- if(GDK_IS_PIXBUF(pixbuf)) {
- return pixbuf;
- }
-
- }
-
- protoname = purple_protocol_get_list_icon(protocol, account, NULL);
- if (protoname == NULL) {
- return NULL;
- }
-
- /*
- * Status icons will be themeable too, and then it will look up
- * protoname from the theme
- */
- tmp = g_strconcat("im-", protoname, NULL);
- pixbuf = gtk_icon_theme_load_icon(theme, tmp, dimensions,
- GTK_ICON_LOOKUP_FORCE_SIZE, NULL);
- g_free(tmp);
-
- return pixbuf;
-}
-
static void
aop_option_menu_select_by_data(GtkWidget *optmenu, gpointer data)
{
@@ -263,19 +211,6 @@
*height = 100;
}
-GdkPixbuf *
-pidgin_create_protocol_icon(PurpleAccount *account, PidginProtocolIconSize size)
-{
- PurpleProtocol *protocol;
-
- g_return_val_if_fail(account != NULL, NULL);
-
- protocol = purple_account_get_protocol(account);
- if (protocol == NULL)
- return NULL;
- return pidgin_create_icon_from_protocol(protocol, size, account);
-}
-
static gboolean buddyname_completion_match_func(GtkEntryCompletion *completion,
const gchar *key, GtkTreeIter *iter, gpointer user_data)
{
--- a/pidgin/gtkutils.h Tue Aug 23 02:01:50 2022 -0500
+++ b/pidgin/gtkutils.h Tue Aug 23 02:25:05 2022 -0500
@@ -140,44 +140,6 @@
void pidgin_buddy_icon_get_scale_size(GdkPixbuf *buf, PurpleBuddyIconSpec *spec, PurpleBuddyIconScaleFlags rules, int *width, int *height);
/**
- * pidgin_create_protocol_icon:
- * @account: The account.
- * @size: The size of the icon to return.
- *
- * Returns the base image to represent the account, based on
- * the currently selected theme.
- *
- * Returns: (transfer full): A newly-created pixbuf with a reference count of 1,
- * or NULL if any of several error conditions occurred:
- * the file could not be opened, there was no loader
- * for the file's format, there was not enough memory
- * to allocate the image buffer, or the image file
- * contained invalid data.
- */
-GdkPixbuf *pidgin_create_protocol_icon(PurpleAccount *account, PidginProtocolIconSize size);
-
-/**
- * pidgin_create_icon_from_protocol:
- * @protocol: The #PurpleProtocol instance.
- * @size: The size of the icon to return.
- * @account: (nullable): An optional #PurpleAccount to use.
- *
- * Returns the base image to represent @protocol based on the currently
- * selected theme. If @account is not %NULL then the returned icon will
- * represent the account.
- *
- * Returns: (transfer full): A newly-created pixbuf with a reference count of 1,
- * or NULL if any of several error conditions occurred:
- * the file could not be opened, there was no loader
- * for the file's format, there was not enough memory
- * to allocate the image buffer, or the image file
- * contained invalid data.
- *
- * Since: 3.0.0
- */
-GdkPixbuf *pidgin_create_icon_from_protocol(PurpleProtocol *protocol, PidginProtocolIconSize size, PurpleAccount *account);
-
-/**
* pidgin_convert_buddy_icon:
* @protocol: The protocol to convert the icon
* @path: The path of a file to convert
--- a/pidgin/pidginaccountstore.c Tue Aug 23 02:01:50 2022 -0500
+++ b/pidgin/pidginaccountstore.c Tue Aug 23 02:25:05 2022 -0500
@@ -37,12 +37,14 @@
pidgin_account_store_add_account(PidginAccountStore *store,
PurpleAccount *account)
{
+ PurpleProtocol *protocol = NULL;
GtkTreeIter iter;
GdkPixbuf *pixbuf = NULL;
gchar *markup = NULL;
- const gchar *alias = NULL;
+ const gchar *alias = NULL, *icon_name = NULL;
- pixbuf = pidgin_create_protocol_icon(account, PIDGIN_PROTOCOL_ICON_SMALL);
+ protocol = purple_account_get_protocol(account);
+ icon_name = purple_protocol_get_icon_name(protocol);
alias = purple_account_get_private_alias(account);
if(alias != NULL) {
@@ -62,11 +64,10 @@
&iter,
PIDGIN_ACCOUNT_STORE_COLUMN_ACCOUNT, account,
PIDGIN_ACCOUNT_STORE_COLUMN_MARKUP, markup,
- PIDGIN_ACCOUNT_STORE_COLUMN_ICON, pixbuf,
+ PIDGIN_ACCOUNT_STORE_COLUMN_ICON_NAME, icon_name,
-1
);
- g_clear_object(&pixbuf);
g_free(markup);
}
@@ -150,7 +151,7 @@
GType types[PIDGIN_ACCOUNT_STORE_N_COLUMNS] = {
PURPLE_TYPE_ACCOUNT,
G_TYPE_STRING,
- GDK_TYPE_PIXBUF,
+ G_TYPE_STRING,
};
gtk_list_store_set_column_types(
--- a/pidgin/pidginaccountstore.h Tue Aug 23 02:01:50 2022 -0500
+++ b/pidgin/pidginaccountstore.h Tue Aug 23 02:25:05 2022 -0500
@@ -57,7 +57,7 @@
typedef enum {
PIDGIN_ACCOUNT_STORE_COLUMN_ACCOUNT,
PIDGIN_ACCOUNT_STORE_COLUMN_MARKUP,
- PIDGIN_ACCOUNT_STORE_COLUMN_ICON,
+ PIDGIN_ACCOUNT_STORE_COLUMN_ICON_NAME,
/*< private >*/
PIDGIN_ACCOUNT_STORE_N_COLUMNS,
} PidginAccountStoreColumn;
--- a/pidgin/resources/Accounts/chooser.ui Tue Aug 23 02:01:50 2022 -0500
+++ b/pidgin/resources/Accounts/chooser.ui Tue Aug 23 02:25:05 2022 -0500
@@ -31,7 +31,7 @@
<child>
<object class="GtkCellRendererPixbuf"/>
<attributes>
- <attribute name="pixbuf">2</attribute>
+ <attribute name="icon-name">2</attribute>
</attributes>
</child>
<child>