Rename the pidgin_style_* api to pidgin_style_context_*
Testing Done:
Compiled and ran locally.
Reviewed at https://reviews.imfreedom.org/r/409/
--- a/doc/reference/pidgin/pidgin-docs.xml Mon Jan 11 00:06:00 2021 -0600
+++ b/doc/reference/pidgin/pidgin-docs.xml Mon Jan 11 00:20:09 2021 -0600
@@ -79,7 +79,7 @@
<xi:include href="xml/pidginpresence.xml" />
<xi:include href="xml/pidginpresenceicon.xml" />
<xi:include href="xml/pidginstock.xml" />
- <xi:include href="xml/pidginstyle.xml" />
+ <xi:include href="xml/pidginstylecontext.xml" /> <xi:include href="xml/pidgintalkatu.xml" />
<xi:include href="xml/pidgintooltip.xml" />
<xi:include href="xml/pidginwindow.xml" />
--- a/pidgin/gtkblist.c Mon Jan 11 00:06:00 2021 -0600
+++ b/pidgin/gtkblist.c Mon Jan 11 00:20:09 2021 -0600
@@ -54,7 +54,7 @@
#include "pidgin/pidginlog.h"
#include "pidgin/pidginmooddialog.h"
#include "pidgin/pidginplugininfo.h"
-#include "pidgin/pidginstyle.h"
+#include "pidgin/pidginstylecontext.h" #include "pidgin/pidgintooltip.h"
#include "pidgin/pidginwindow.h"
#include "pidginmenutray.h"
@@ -3894,7 +3894,7 @@
theme = pidgin_blist_get_theme();
- dim_grey = pidgin_style_is_dark(NULL) ? "light slate grey" : "dim grey";
+ dim_grey = pidgin_style_context_is_dark(NULL) ? "light slate grey" : "dim grey"; if (purple_presence_is_idle(presence)) {
@@ -5899,7 +5899,7 @@
textcolor = pidgin_theme_font_get_color_describe(pair);
/* If no theme them default to making idle buddy names grey */
- textcolor = pidgin_style_is_dark(NULL) ? "light slate grey" : "dim grey";
+ textcolor = pidgin_style_context_is_dark(NULL) ? "light slate grey" : "dim grey"; idle = g_strdup_printf("<span color='%s' font_desc='%s'>%d:%02d</span>",
--- a/pidgin/gtkconv.c Mon Jan 11 00:06:00 2021 -0600
+++ b/pidgin/gtkconv.c Mon Jan 11 00:20:09 2021 -0600
@@ -59,7 +59,7 @@
#include "pidginmessage.h"
#include "pidginpresenceicon.h"
-#include "pidginstyle.h"
+#include "pidginstylecontext.h" #include "pidgintooltip.h"
#include "pidginwindow.h"
@@ -7869,8 +7869,8 @@
gdk_rgba_parse(&nick_highlight, DEFAULT_HIGHLIGHT_COLOR);
gdk_rgba_parse(&send_color, DEFAULT_SEND_COLOR);
- pidgin_style_adjust_contrast(NULL, &nick_highlight);
- pidgin_style_adjust_contrast(NULL, &send_color);
+ pidgin_style_context_adjust_contrast(NULL, &nick_highlight); + pidgin_style_context_adjust_contrast(NULL, &send_color); srand(background.red * 65535 + background.green * 65535 + background.blue * 65535 + 1);
--- a/pidgin/meson.build Mon Jan 11 00:06:00 2021 -0600
+++ b/pidgin/meson.build Mon Jan 11 00:20:09 2021 -0600
@@ -60,7 +60,7 @@
'pidginprotocolchooser.c',
+ 'pidginstylecontext.c', @@ -131,7 +131,7 @@
'pidginprotocolchooser.h',
+ 'pidginstylecontext.h', --- a/pidgin/pidginstyle.c Mon Jan 11 00:06:00 2021 -0600
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,72 +0,0 @@
- * Pidgin - Internet Messenger
- * Copyright (C) Pidgin Developers <devel@pidgin.im>
- * Pidgin is the legal property of its developers, whose names are too numerous
- * to list here. Please refer to the COPYRIGHT file distributed with this
- * This program is free software; you can redistribute it and/or modify
- * under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- * You should have received a copy of the GNU General Public License
- * along with this library; if not, see <https://www.gnu.org/licenses/>.
-#include "pidgin/pidginstyle.h"
-static gboolean dark_mode_have_cache = FALSE;
-static gboolean dark_mode_cached_value = FALSE;
-pidgin_style_is_dark(GtkStyle *style) {
- G_GNUC_BEGIN_IGNORE_DEPRECATIONS
- gdouble luminance = 0.0;
- if(dark_mode_have_cache) {
- return dark_mode_cached_value;
- style = gtk_widget_get_default_style();
- bg = style->base[GTK_STATE_NORMAL];
- /* magic values are taken from https://en.wikipedia.org/wiki/Luma_(video)
- * Rec._601_luma_versus_Rec._709_luma_coefficients.
- luminance = (0.299 * bg.red) + (0.587 * bg.green) + (0.114 * bg.blue);
- G_GNUC_END_IGNORE_DEPRECATIONS
- dark_mode_cached_value = (luminance < 0x7FFF);
- dark_mode_have_cache = TRUE;
- return dark_mode_cached_value;
-pidgin_style_adjust_contrast(GtkStyle *style, GdkRGBA *rgba) {
- if (pidgin_style_is_dark(style)) {
- gtk_rgb_to_hsv(rgba->red, rgba->green, rgba->blue, &h, &s, &v);
- gtk_hsv_to_rgb(h, s, v, &rgba->red, &rgba->green, &rgba->blue);
--- a/pidgin/pidginstyle.h Mon Jan 11 00:06:00 2021 -0600
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,69 +0,0 @@
- * Pidgin - Internet Messenger
- * Copyright (C) Pidgin Developers <devel@pidgin.im>
- * Pidgin is the legal property of its developers, whose names are too numerous
- * to list here. Please refer to the COPYRIGHT file distributed with this
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- * You should have received a copy of the GNU General Public License
- * along with this library; if not, see <https://www.gnu.org/licenses/>.
-#if !defined(PIDGIN_GLOBAL_HEADER_INSIDE) && !defined(PIDGIN_COMPILATION)
-# error "only <pidgin.h> may be included directly"
- * @section_id: pidgin-pidginstyle
- * @short_description: <filename>gtkstyle.h</filename>
- * The style API contains some helpers regarding #GtkStyle.
- * pidgin_style_is_dark:
- * @style: The #GtkStyle in use, or %NULL to use a cached version.
- * Gets whether or not dark mode is enabled.
- * Returns: %TRUE if dark mode is enabled and foreground colours should be
-gboolean pidgin_style_is_dark(GtkStyle *style);
- * pidgin_style_adjust_contrast:
- * @style: The #GtkStyle in use.
- * @color: (inout): Color to be lightened. Transformed color will be written
- * Lighten a color if dark mode is enabled.
-void pidgin_style_adjust_contrast(GtkStyle *style, GdkRGBA *color);
-#endif /* PIDGIN_STYLE_H */
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/pidgin/pidginstylecontext.c Mon Jan 11 00:20:09 2021 -0600
@@ -0,0 +1,76 @@
+ * Pidgin - Internet Messenger + * Copyright (C) Pidgin Developers <devel@pidgin.im> + * Pidgin is the legal property of its developers, whose names are too numerous + * to list here. Please refer to the COPYRIGHT file distributed with this + * This program is free software; you can redistribute it and/or modify + * under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * You should have received a copy of the GNU General Public License + * along with this library; if not, see <https://www.gnu.org/licenses/>. +#include "pidgin/pidginstylecontext.h" +static gboolean dark_mode_have_cache = FALSE; +static gboolean dark_mode_cached_value = FALSE; +/****************************************************************************** + *****************************************************************************/ +pidgin_style_context_is_dark(GtkStyleContext *context) { + gdouble luminance = 0.0; + if(dark_mode_have_cache) { + return dark_mode_cached_value; + context = gtk_style_context_new(); + g_object_ref(G_OBJECT(context)); + gtk_style_context_get(context, GTK_STATE_FLAG_NORMAL, + GTK_STYLE_PROPERTY_BACKGROUND_COLOR, &bg, + g_object_unref(G_OBJECT(context)); + /* magic values are taken from https://en.wikipedia.org/wiki/Luma_(video) + * Rec._601_luma_versus_Rec._709_luma_coefficients. + luminance = (0.299 * bg.red) + (0.587 * bg.green) + (0.114 * bg.blue); + dark_mode_cached_value = (luminance < 0x7FFF); + dark_mode_have_cache = TRUE; + return dark_mode_cached_value; +pidgin_style_context_adjust_contrast(GtkStyleContext *context, GdkRGBA *rgba) { + if(pidgin_style_context_is_dark(context)) { + gtk_rgb_to_hsv(rgba->red, rgba->green, rgba->blue, &h, &s, &v); + gtk_hsv_to_rgb(h, s, v, &rgba->red, &rgba->green, &rgba->blue); --- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/pidgin/pidginstylecontext.h Mon Jan 11 00:20:09 2021 -0600
@@ -0,0 +1,69 @@
+ * Pidgin - Internet Messenger + * Copyright (C) Pidgin Developers <devel@pidgin.im> + * Pidgin is the legal property of its developers, whose names are too numerous + * to list here. Please refer to the COPYRIGHT file distributed with this + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * You should have received a copy of the GNU General Public License + * along with this library; if not, see <https://www.gnu.org/licenses/>. +#if !defined(PIDGIN_GLOBAL_HEADER_INSIDE) && !defined(PIDGIN_COMPILATION) +# error "only <pidgin.h> may be included directly" + * SECTION:pidginstylecontext + * @section_id: pidgin-pidginstylecontext + * @short_description: Dark theme helpers. + * @title: GtkStyleContext Helpers + * A collection of API to help with handling dark themes. +#ifndef PIDGIN_STYLE_CONTEXT_H +#define PIDGIN_STYLE_CONTEXT_H + * pidgin_style_context_is_dark: + * @context: The #GtkStyleContext to use, or %NULL to use a cached version. + * Gets whether or not dark mode is enabled. + * Returns: %TRUE if dark mode is enabled and foreground colours should be +gboolean pidgin_style_context_is_dark(GtkStyleContext *context); + * pidgin_style_context_adjust_contrast: + * @context: The #GtkStyleContext in use. + * @color: (inout): Color to be lightened. Transformed color will be written + * Lighten a color if dark mode is enabled. +void pidgin_style_context_adjust_contrast(GtkStyleContext *context, GdkRGBA *color); +#endif /* PIDGIN_STYLE_CONTEXT_H */ --- a/po/POTFILES.in Mon Jan 11 00:06:00 2021 -0600
+++ b/po/POTFILES.in Mon Jan 11 00:20:09 2021 -0600
@@ -350,7 +350,7 @@
pidgin/pidginpresenceicon.c
+pidgin/pidginstylecontext.c