/pidgin/main: 0185eb26ac7d: Use GdkRGBA instead of GdkColor.
Elliott Sales de Andrade <[email protected]> Tue, 06 Sep 2016 15:45:50 -0400
| Newsgroups | gmane.comp.gnome.gaim.cvs |
|---|---|
| Message-ID | <[email protected]> |
Changeset: 0185eb26ac7dbb01f468c0f7f5352ea7af545f35 Author: Elliott Sales de Andrade <[email protected]> Date: 2016-09-04 04:45 -0400 Branch: default URL: https://hg.pidgin.im/pidgin/main/rev/0185eb26ac7d Description: Use GdkRGBA instead of GdkColor. diffstat: pidgin/gtk3compat.h | 30 ------------ pidgin/gtkblist-theme-loader.c | 24 ++++---- pidgin/gtkblist-theme.c | 77 ++++++++++++++++-------------- pidgin/gtkblist-theme.h | 24 ++++---- pidgin/gtkblist.c | 26 +++++----- pidgin/gtkconv-theme.c | 7 +- pidgin/gtkconv.c | 102 ++++++++++++++++++++++------------------ pidgin/gtknickcolors.h | 50 ++++++++++---------- pidgin/gtkwebviewtoolbar.c | 86 +++++++-------------------------- pidgin/gtkwhiteboard.c | 34 +++++-------- pidgin/plugins/screencap.c | 16 ++---- 11 files changed, 200 insertions(+), 276 deletions(-) diffs (truncated from 1317 to 300 lines): diff --git a/pidgin/gtk3compat.h b/pidgin/gtk3compat.h --- a/pidgin/gtk3compat.h +++ b/pidgin/gtk3compat.h @@ -32,7 +32,6 @@ */ #include <gtk/gtk.h> -#include <math.h> #if GTK_CHECK_VERSION(3,16,0) @@ -53,34 +52,5 @@ gtk_label_set_alignment(GtkLabel *label, #endif /* 3.16.0 */ - -#if GTK_CHECK_VERSION(3,4,0) - -static inline void -pidgin_color_chooser_set_rgb(GtkColorChooser *chooser, const GdkColor *rgb) -{ - GdkRGBA rgba; - - rgba.red = rgb->red / 65535.0; - rgba.green = rgb->green / 65535.0; - rgba.blue = rgb->blue / 65535.0; - rgba.alpha = 1.0; - - gtk_color_chooser_set_rgba(chooser, &rgba); -} - -static inline void -pidgin_color_chooser_get_rgb(GtkColorChooser *chooser, GdkColor *rgb) -{ - GdkRGBA rgba; - - gtk_color_chooser_get_rgba(chooser, &rgba); - rgb->red = (int)round(rgba.red * 65535.0); - rgb->green = (int)round(rgba.green * 65535.0); - rgb->blue = (int)round(rgba.blue * 65535.0); -} - -#endif /* 3.4.0 and gtk_color_chooser_ */ - #endif /* _PIDGINGTK3COMPAT_H_ */ diff --git a/pidgin/gtkblist-theme-loader.c b/pidgin/gtkblist-theme-loader.c --- a/pidgin/gtkblist-theme-loader.c +++ b/pidgin/gtkblist-theme-loader.c @@ -47,25 +47,25 @@ pidgin_theme_font_parse(PurpleXmlNode *n { const char *font; const char *colordesc; - GdkColor color; + GdkRGBA color; font = purple_xmlnode_get_attrib(node, "font"); if ((colordesc = purple_xmlnode_get_attrib(node, "color")) == NULL || - !gdk_color_parse(colordesc, &color)) - gdk_color_parse(DEFAULT_TEXT_COLOR, &color); + !gdk_rgba_parse(&color, colordesc)) + gdk_rgba_parse(&color, DEFAULT_TEXT_COLOR); return pidgin_theme_font_new(font, &color); } -static GdkColor * +static GdkRGBA * parse_color(PurpleXmlNode *node, const char *tag) { const char *temp = purple_xmlnode_get_attrib(node, tag); - GdkColor color; + GdkRGBA color; - if (temp && gdk_color_parse(temp, &color)) { - return gdk_color_copy(&color); + if (temp && gdk_rgba_parse(&color, temp)) { + return gdk_rgba_copy(&color); } else { return NULL; } @@ -78,7 +78,7 @@ pidgin_blist_loader_build(const gchar *t gchar *dir, *filename_full, *data = NULL; const gchar *temp, *name; gboolean success = TRUE; - GdkColor *bgcolor, *expanded_bgcolor, *collapsed_bgcolor, *contact_color; + GdkRGBA *bgcolor, *expanded_bgcolor, *collapsed_bgcolor, *contact_color; PidginThemeFont *expanded, *collapsed, *contact, *online, *away, *offline, *idle, *message, *message_nick_said, *status; PidginBlistLayout layout; PidginBlistTheme *theme; @@ -238,13 +238,13 @@ pidgin_blist_loader_build(const gchar *t } if (bgcolor) - gdk_color_free(bgcolor); + gdk_rgba_free(bgcolor); if (expanded_bgcolor) - gdk_color_free(expanded_bgcolor); + gdk_rgba_free(expanded_bgcolor); if (collapsed_bgcolor) - gdk_color_free(collapsed_bgcolor); + gdk_rgba_free(collapsed_bgcolor); if (contact_color) - gdk_color_free(contact_color); + gdk_rgba_free(contact_color); return PURPLE_THEME(theme); } diff --git a/pidgin/gtkblist-theme.c b/pidgin/gtkblist-theme.c --- a/pidgin/gtkblist-theme.c +++ b/pidgin/gtkblist-theme.c @@ -35,18 +35,18 @@ typedef struct { /* Buddy list */ gdouble opacity; - GdkColor *bgcolor; + GdkRGBA *bgcolor; PidginBlistLayout *layout; /* groups */ - GdkColor *expanded_color; + GdkRGBA *expanded_color; PidginThemeFont *expanded; - GdkColor *collapsed_color; + GdkRGBA *collapsed_color; PidginThemeFont *collapsed; /* buddy */ - GdkColor *contact_color; + GdkRGBA *contact_color; PidginThemeFont *contact; @@ -65,7 +65,7 @@ struct _PidginThemeFont { gchar *font; gchar color[10]; - GdkColor *gdkcolor; + GdkRGBA *gdkcolor; }; /****************************************************************************** @@ -105,7 +105,7 @@ static GParamSpec *properties[PROP_LAST] *****************************************************************************/ PidginThemeFont * -pidgin_theme_font_new(const gchar *face, GdkColor *color) +pidgin_theme_font_new(const gchar *face, GdkRGBA *color) { PidginThemeFont *font = g_new0(PidginThemeFont, 1); font->font = g_strdup(face); @@ -120,7 +120,7 @@ pidgin_theme_font_free(PidginThemeFont * if (pair != NULL) { g_free(pair->font); if (pair->gdkcolor) - gdk_color_free(pair->gdkcolor); + gdk_rgba_free(pair->gdkcolor); g_free(pair); } } @@ -137,7 +137,7 @@ copy_font_and_color(const PidginThemeFon copy->font = g_strdup(pair->font); strncpy(copy->color, pair->color, sizeof(copy->color) - 1); if (pair->gdkcolor) - copy->gdkcolor = pair->gdkcolor ? gdk_color_copy(pair->gdkcolor) : NULL; + copy->gdkcolor = pair->gdkcolor ? gdk_rgba_copy(pair->gdkcolor) : NULL; return copy; } @@ -152,17 +152,20 @@ pidgin_theme_font_set_font_face(PidginTh } void -pidgin_theme_font_set_color(PidginThemeFont *font, const GdkColor *color) +pidgin_theme_font_set_color(PidginThemeFont *font, const GdkRGBA *color) { g_return_if_fail(font); if (font->gdkcolor) - gdk_color_free(font->gdkcolor); + gdk_rgba_free(font->gdkcolor); - font->gdkcolor = color ? gdk_color_copy(color) : NULL; + font->gdkcolor = color ? gdk_rgba_copy(color) : NULL; if (color) g_snprintf(font->color, sizeof(font->color), - "#%02x%02x%02x", color->red >> 8, color->green >> 8, color->blue >> 8); + "#%02x%02x%02x", + (unsigned int)(color->red * 255), + (unsigned int)(color->green * 255), + (unsigned int)(color->blue * 255)); else font->color[0] = '\0'; } @@ -174,7 +177,7 @@ pidgin_theme_font_get_font_face(PidginTh return font->font; } -const GdkColor * +const GdkRGBA * pidgin_theme_font_get_color(PidginThemeFont *font) { g_return_val_if_fail(font, NULL); @@ -323,20 +326,20 @@ pidgin_blist_theme_finalize(GObject *obj /* Buddy List */ if (priv->bgcolor) - gdk_color_free(priv->bgcolor); + gdk_rgba_free(priv->bgcolor); g_free(priv->layout); /* Group */ if (priv->expanded_color) - gdk_color_free(priv->expanded_color); + gdk_rgba_free(priv->expanded_color); pidgin_theme_font_free(priv->expanded); if (priv->collapsed_color) - gdk_color_free(priv->collapsed_color); + gdk_rgba_free(priv->collapsed_color); pidgin_theme_font_free(priv->collapsed); /* Buddy */ if (priv->contact_color) - gdk_color_free(priv->contact_color); + gdk_rgba_free(priv->contact_color); pidgin_theme_font_free(priv->contact); pidgin_theme_font_free(priv->online); pidgin_theme_font_free(priv->away); @@ -372,7 +375,7 @@ pidgin_blist_theme_class_init(PidginBlis properties[PROP_BACKGROUND_COLOR] = g_param_spec_boxed("background-color", "Background Color", "The background color for the buddy list", - GDK_TYPE_COLOR, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS); + GDK_TYPE_RGBA, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS); properties[PROP_OPACITY] = g_param_spec_double("opacity", "Opacity", "The opacity of the buddy list", @@ -386,7 +389,7 @@ pidgin_blist_theme_class_init(PidginBlis properties[PROP_EXPANDED_COLOR] = g_param_spec_boxed("expanded-color", "Expanded Background Color", "The background color of an expanded group", - GDK_TYPE_COLOR, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS); + GDK_TYPE_RGBA, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS); properties[PROP_EXPANDED_TEXT] = g_param_spec_pointer("expanded-text", "Expanded Text", @@ -396,7 +399,7 @@ pidgin_blist_theme_class_init(PidginBlis properties[PROP_COLLAPSED_COLOR] = g_param_spec_boxed("collapsed-color", "Collapsed Background Color", "The background color of a collapsed group", - GDK_TYPE_COLOR, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS); + GDK_TYPE_RGBA, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS); properties[PROP_COLLAPSED_TEXT] = g_param_spec_pointer("collapsed-text", "Collapsed Text", @@ -407,7 +410,7 @@ pidgin_blist_theme_class_init(PidginBlis properties[PROP_CONTACT_COLOR] = g_param_spec_boxed("contact-color", "Contact/Chat Background Color", "The background color of a contact or chat", - GDK_TYPE_COLOR, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS); + GDK_TYPE_RGBA, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS); properties[PROP_CONTACT] = g_param_spec_pointer("contact", "Contact Text", @@ -530,7 +533,7 @@ pidgin_blist_layout_get_type(void) /* get methods */ -GdkColor * +GdkRGBA * pidgin_blist_theme_get_background_color(PidginBlistTheme *theme) { PidginBlistThemePrivate *priv; @@ -566,7 +569,7 @@ pidgin_blist_theme_get_layout(PidginBlis return priv->layout; } -GdkColor * +GdkRGBA * pidgin_blist_theme_get_expanded_background_color(PidginBlistTheme *theme) { PidginBlistThemePrivate *priv; @@ -590,7 +593,7 @@ pidgin_blist_theme_get_expanded_text_inf return priv->expanded; } -GdkColor * +GdkRGBA * pidgin_blist_theme_get_collapsed_background_color(PidginBlistTheme *theme) { PidginBlistThemePrivate *priv; @@ -614,7 +617,7 @@ pidgin_blist_theme_get_collapsed_text_in return priv->collapsed; } -GdkColor * +GdkRGBA * pidgin_blist_theme_get_contact_color(PidginBlistTheme *theme) _______________________________________________ Commits mailing list [email protected] https://pidgin.im/cgi-bin/mailman/listinfo/commits