diff options
Diffstat (limited to 'pidgin/gtkutils.c')
-rw-r--r-- | pidgin/gtkutils.c | 185 |
1 files changed, 100 insertions, 85 deletions
diff --git a/pidgin/gtkutils.c b/pidgin/gtkutils.c index 82ec16648c..34b3a79d1b 100644 --- a/pidgin/gtkutils.c +++ b/pidgin/gtkutils.c @@ -680,7 +680,6 @@ static AopMenu * create_protocols_menu(const char *default_proto_id) { AopMenu *aop_menu = NULL; - PurplePluginProtocolInfo *prpl_info; PurplePlugin *plugin; GdkPixbuf *pixbuf = NULL; GtkSizeGroup *sg; @@ -702,7 +701,6 @@ create_protocols_menu(const char *default_proto_id) p = p->next, i++) { plugin = (PurplePlugin *)p->data; - prpl_info = PURPLE_PLUGIN_PROTOCOL_INFO(plugin); if (gtalk_name && strcmp(gtalk_name, plugin->info->name) < 0) { char *filename = g_build_filename(DATADIR, "pixmaps", "pidgin", "protocols", @@ -784,8 +782,6 @@ create_account_menu(PurpleAccount *default_account, sg = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL); for (p = list, i = 0; p != NULL; p = p->next, i++) { - PurplePlugin *plugin; - if (show_all) account = (PurpleAccount *)p->data; else { @@ -799,8 +795,6 @@ create_account_menu(PurpleAccount *default_account, continue; } - plugin = purple_find_prpl(purple_account_get_protocol_id(account)); - pixbuf = pidgin_create_prpl_icon(account, PIDGIN_PRPL_ICON_SMALL); if (pixbuf) { @@ -1036,7 +1030,7 @@ pidgin_parse_x_im_contact(const char *msg, gboolean all_accounts, char *username = NULL; char *alias = NULL; char *str; - char *c, *s; + char *s; gboolean valid; g_return_val_if_fail(msg != NULL, FALSE); @@ -1078,7 +1072,7 @@ pidgin_parse_x_im_contact(const char *msg, gboolean all_accounts, if (*s == '\r') *s++ = '\0'; if (*s == '\n') *s++ = '\0'; - if ((c = strchr(key, ':')) != NULL) + if (strchr(key, ':') != NULL) { if (!g_ascii_strcasecmp(key, "X-IM-Username:")) username = g_strdup(value); @@ -2469,7 +2463,7 @@ pidgin_convert_buddy_icon(PurplePlugin *plugin, const char *path, size_t *len) break; } - if (spec->max_filesize == 0 || length < spec->max_filesize) { + if (spec->max_filesize == 0 || length <= spec->max_filesize) { /* We were able to save the image as this image type and have it be within the size constraints. Great! Return the image. */ @@ -2507,7 +2501,7 @@ pidgin_convert_buddy_icon(PurplePlugin *plugin, const char *path, size_t *len) new_height = orig_height * scale_factor; g_object_unref(G_OBJECT(pixbuf)); pixbuf = gdk_pixbuf_scale_simple(original, new_width, new_height, GDK_INTERP_HYPER); - } while (new_width > 10 || new_height > 10); + } while ((new_width > 10 || new_height > 10) && new_width > spec->min_width && new_height > spec->min_height); g_strfreev(prpl_formats); g_object_unref(G_OBJECT(pixbuf)); g_object_unref(G_OBJECT(original)); @@ -2611,18 +2605,11 @@ old_mini_dialog_destroy_cb(GtkWidget *dialog, } } -GtkWidget * -pidgin_make_mini_dialog(PurpleConnection *gc, - const char *icon_name, - const char *primary, - const char *secondary, - void *user_data, - ...) +static void +mini_dialog_init(PidginMiniDialog *mini_dialog, PurpleConnection *gc, void *user_data, va_list args) { - PidginMiniDialog *mini_dialog; const char *button_text; GList *cb_datas = NULL; - va_list args; static gboolean first_call = TRUE; if (first_call) { @@ -2632,12 +2619,10 @@ pidgin_make_mini_dialog(PurpleConnection *gc, PURPLE_CALLBACK(connection_signed_off_cb), NULL); } - mini_dialog = pidgin_mini_dialog_new(primary, secondary, icon_name); g_object_set_data(G_OBJECT(mini_dialog), "gc" ,gc); g_signal_connect(G_OBJECT(mini_dialog), "destroy", G_CALLBACK(alert_killed_cb), NULL); - va_start(args, user_data); while ((button_text = va_arg(args, char*))) { struct _old_button_clicked_cb_data *data = NULL; PidginMiniDialogCallback wrapper_cb = NULL; @@ -2654,12 +2639,40 @@ pidgin_make_mini_dialog(PurpleConnection *gc, wrapper_cb, data); cb_datas = g_list_append(cb_datas, data); } - va_end(args); g_signal_connect(G_OBJECT(mini_dialog), "destroy", G_CALLBACK(old_mini_dialog_destroy_cb), cb_datas); +} +#define INIT_AND_RETURN_MINI_DIALOG(mini_dialog) \ + va_list args; \ + va_start(args, user_data); \ + mini_dialog_init(mini_dialog, gc, user_data, args); \ + va_end(args); \ return GTK_WIDGET(mini_dialog); + +GtkWidget * +pidgin_make_mini_dialog(PurpleConnection *gc, + const char *icon_name, + const char *primary, + const char *secondary, + void *user_data, + ...) +{ + PidginMiniDialog *mini_dialog = pidgin_mini_dialog_new(primary, secondary, icon_name); + INIT_AND_RETURN_MINI_DIALOG(mini_dialog); +} + +GtkWidget * +pidgin_make_mini_dialog_with_custom_icon(PurpleConnection *gc, + GdkPixbuf *custom_icon, + const char *primary, + const char *secondary, + void *user_data, + ...) +{ + PidginMiniDialog *mini_dialog = pidgin_mini_dialog_new_with_custom_icon(primary, secondary, custom_icon); + INIT_AND_RETURN_MINI_DIALOG(mini_dialog); } /* @@ -2771,79 +2784,78 @@ gboolean pidgin_tree_view_search_equal_func(GtkTreeModel *model, gint column, gboolean pidgin_gdk_pixbuf_is_opaque(GdkPixbuf *pixbuf) { - int width, height, rowstride, i; - unsigned char *pixels; - unsigned char *row; + int height, rowstride, i; + unsigned char *pixels; + unsigned char *row; - if (!gdk_pixbuf_get_has_alpha(pixbuf)) - return TRUE; + if (!gdk_pixbuf_get_has_alpha(pixbuf)) + return TRUE; - width = gdk_pixbuf_get_width (pixbuf); - height = gdk_pixbuf_get_height (pixbuf); - rowstride = gdk_pixbuf_get_rowstride (pixbuf); - pixels = gdk_pixbuf_get_pixels (pixbuf); + height = gdk_pixbuf_get_height (pixbuf); + rowstride = gdk_pixbuf_get_rowstride (pixbuf); + pixels = gdk_pixbuf_get_pixels (pixbuf); - row = pixels; - for (i = 3; i < rowstride; i+=4) { - if (row[i] < 0xfe) - return FALSE; - } + row = pixels; + for (i = 3; i < rowstride; i+=4) { + if (row[i] < 0xfe) + return FALSE; + } - for (i = 1; i < height - 1; i++) { - row = pixels + (i*rowstride); - if (row[3] < 0xfe || row[rowstride-1] < 0xfe) { - return FALSE; - } - } + for (i = 1; i < height - 1; i++) { + row = pixels + (i * rowstride); + if (row[3] < 0xfe || row[rowstride - 1] < 0xfe) { + return FALSE; + } + } - row = pixels + ((height-1) * rowstride); - for (i = 3; i < rowstride; i+=4) { - if (row[i] < 0xfe) - return FALSE; - } + row = pixels + ((height - 1) * rowstride); + for (i = 3; i < rowstride; i += 4) { + if (row[i] < 0xfe) + return FALSE; + } - return TRUE; + return TRUE; } void pidgin_gdk_pixbuf_make_round(GdkPixbuf *pixbuf) { int width, height, rowstride; - guchar *pixels; - if (!gdk_pixbuf_get_has_alpha(pixbuf)) - return; - width = gdk_pixbuf_get_width(pixbuf); - height = gdk_pixbuf_get_height(pixbuf); - rowstride = gdk_pixbuf_get_rowstride(pixbuf); - pixels = gdk_pixbuf_get_pixels(pixbuf); - - if (width < 6 || height < 6) - return; - /* Top left */ - pixels[3] = 0; - pixels[7] = 0x80; - pixels[11] = 0xC0; - pixels[rowstride + 3] = 0x80; - pixels[rowstride * 2 + 3] = 0xC0; - - /* Top right */ - pixels[width * 4 - 1] = 0; - pixels[width * 4 - 5] = 0x80; - pixels[width * 4 - 9] = 0xC0; - pixels[rowstride + (width * 4) - 1] = 0x80; - pixels[(2 * rowstride) + (width * 4) - 1] = 0xC0; - - /* Bottom left */ - pixels[(height - 1) * rowstride + 3] = 0; - pixels[(height - 1) * rowstride + 7] = 0x80; - pixels[(height - 1) * rowstride + 11] = 0xC0; - pixels[(height - 2) * rowstride + 3] = 0x80; - pixels[(height - 3) * rowstride + 3] = 0xC0; - - /* Bottom right */ - pixels[height * rowstride - 1] = 0; - pixels[(height - 1) * rowstride - 1] = 0x80; - pixels[(height - 2) * rowstride - 1] = 0xC0; - pixels[height * rowstride - 5] = 0x80; - pixels[height * rowstride - 9] = 0xC0; + guchar *pixels; + if (!gdk_pixbuf_get_has_alpha(pixbuf)) + return; + width = gdk_pixbuf_get_width(pixbuf); + height = gdk_pixbuf_get_height(pixbuf); + rowstride = gdk_pixbuf_get_rowstride(pixbuf); + pixels = gdk_pixbuf_get_pixels(pixbuf); + + if (width < 6 || height < 6) + return; + /* Top left */ + pixels[3] = 0; + pixels[7] = 0x80; + pixels[11] = 0xC0; + pixels[rowstride + 3] = 0x80; + pixels[rowstride * 2 + 3] = 0xC0; + + /* Top right */ + pixels[width * 4 - 1] = 0; + pixels[width * 4 - 5] = 0x80; + pixels[width * 4 - 9] = 0xC0; + pixels[rowstride + (width * 4) - 1] = 0x80; + pixels[(2 * rowstride) + (width * 4) - 1] = 0xC0; + + /* Bottom left */ + pixels[(height - 1) * rowstride + 3] = 0; + pixels[(height - 1) * rowstride + 7] = 0x80; + pixels[(height - 1) * rowstride + 11] = 0xC0; + pixels[(height - 2) * rowstride + 3] = 0x80; + pixels[(height - 3) * rowstride + 3] = 0xC0; + + /* Bottom right */ + pixels[height * rowstride - 1] = 0; + pixels[(height - 1) * rowstride - 1] = 0x80; + pixels[(height - 2) * rowstride - 1] = 0xC0; + pixels[height * rowstride - 5] = 0x80; + pixels[height * rowstride - 9] = 0xC0; } const char *pidgin_get_dim_grey_string(GtkWidget *widget) { @@ -3484,6 +3496,9 @@ void pidgin_utils_init(void) "GtkWidget::focus-line-width = 0\n" "xthickness = 0\n" "ythickness = 0\n" + "GtkContainer::border-width = 0\n" + "GtkButton::inner-border = {0, 0, 0, 0}\n" + "GtkButton::default-border = {0, 0, 0, 0}\n" "}\n" "widget \"*.pidgin-small-close-button\" style \"pidgin-small-close-button\""); |