summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--stickynotes/stickynotes.c50
-rw-r--r--stickynotes/stickynotes_applet.c30
-rw-r--r--stickynotes/stickynotes_applet_callbacks.c32
3 files changed, 77 insertions, 35 deletions
diff --git a/stickynotes/stickynotes.c b/stickynotes/stickynotes.c
index b826ae63..46001514 100644
--- a/stickynotes/stickynotes.c
+++ b/stickynotes/stickynotes.c
@@ -326,8 +326,6 @@ void stickynote_free(StickyNote *note)
/* Change the sticky note title and color */
void stickynote_change_properties (StickyNote *note)
{
- GdkColor color;
- GdkColor font_color;
char *color_str = NULL;
gtk_entry_set_text(GTK_ENTRY(note->w_entry),
@@ -345,10 +343,16 @@ void stickynote_change_properties (StickyNote *note)
if (color_str)
{
+#if GTK_CHECK_VERSION (3, 0, 0)
+ GdkRGBA color;
+ gdk_rgba_parse (&color, color_str);
+ gtk_color_button_set_rgba (GTK_COLOR_BUTTON (note->w_color), &color);
+#else
+ GdkColor color;
gdk_color_parse (color_str, &color);
+ gtk_color_button_set_color (GTK_COLOR_BUTTON (note->w_color), &color);
+#endif
g_free (color_str);
- gtk_color_button_set_color (GTK_COLOR_BUTTON (note->w_color),
- &color);
}
if (note->font_color)
@@ -360,10 +364,16 @@ void stickynote_change_properties (StickyNote *note)
if (color_str)
{
+#if GTK_CHECK_VERSION (3, 0, 0)
+ GdkRGBA font_color;
+ gdk_rgba_parse (&font_color, color_str);
+ gtk_color_button_set_rgba (GTK_COLOR_BUTTON (note->w_font_color), &font_color);
+#else
+ GdkColor font_color;
gdk_color_parse (color_str, &font_color);
+ gtk_color_button_set_color (GTK_COLOR_BUTTON (note->w_font_color), &font_color);
+#endif
g_free (color_str);
- gtk_color_button_set_color (GTK_COLOR_BUTTON (note->w_font_color),
- &font_color);
}
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(note->w_def_font),
@@ -481,34 +491,39 @@ stickynote_set_color (StickyNote *note,
/* Do not use custom colors if "use_system_color" is enabled */
if (color_str_actual) {
- /* Custom colors */
- GdkColor colors[6];
-#if !GTK_CHECK_VERSION (3, 0, 0)
- gboolean success[6];
+#if GTK_CHECK_VERSION (3, 0, 0)
+ GdkRGBA color;
+ gdk_rgba_parse (&color, color_str_actual);
#endif
-
/* Make 4 shades of the color, getting darker from the
* original, plus black and white */
+ GdkColor colors[6];
gint i;
for (i = 0; i <= 3; i++)
{
gdk_color_parse (color_str_actual, &colors[i]);
-
+#if GTK_CHECK_VERSION (3, 0, 0)
+ colors[i].red = (color.red * (10 - i)) / 10;
+ colors[i].green = (color.green * (10 - i)) / 10;
+ colors[i].blue = (color.blue * (10 - i)) / 10;
+#else
colors[i].red = (colors[i].red * (10 - i)) / 10;
colors[i].green = (colors[i].green * (10 - i)) / 10;
colors[i].blue = (colors[i].blue * (10 - i)) / 10;
+#endif
}
gdk_color_parse ("black", &colors[4]);
gdk_color_parse ("white", &colors[5]);
#if !GTK_CHECK_VERSION (3, 0, 0)
+ gboolean success[6];
+
/* Allocate these colors */
gdk_colormap_alloc_colors (gtk_widget_get_colormap (note->w_window),
colors, 6, FALSE, TRUE, success);
#endif
-
/* Apply colors to style */
rc_style->base[GTK_STATE_NORMAL] = colors[0];
rc_style->bg[GTK_STATE_PRELIGHT] = colors[1];
@@ -544,7 +559,16 @@ stickynote_set_color (StickyNote *note,
{
GdkColor font_color;
+#if GTK_CHECK_VERSION (3, 0, 0)
+ GdkRGBA color;
+
+ gdk_rgba_parse (&color, font_color_str_actual);
+ font_color.red = color.red;
+ font_color.green = color.green;
+ font_color.blue = color.blue;
+#else
gdk_color_parse (font_color_str_actual, &font_color);
+#endif
gtk_widget_modify_text (note->w_window,
GTK_STATE_NORMAL, &font_color);
diff --git a/stickynotes/stickynotes_applet.c b/stickynotes/stickynotes_applet.c
index 133ca2bf..ed5563ae 100644
--- a/stickynotes/stickynotes_applet.c
+++ b/stickynotes/stickynotes_applet.c
@@ -452,10 +452,13 @@ stickynotes_applet_update_prefs (void)
gboolean sys_color, sys_font, sticky, force_default, desktop_hide;
char *font_str;
char *color_str, *font_color_str;
+#if GTK_CHECK_VERSION (3, 0, 0)
+ GdkRGBA color, font_color;
+#else
GdkColor color, font_color;
+#endif
width = g_settings_get_int (stickynotes->settings, "default-width");
-
width = MAX (width, 1);
height = g_settings_get_int (stickynotes->settings, "default-height");
height = MAX (height, 1);
@@ -483,10 +486,15 @@ stickynotes_applet_update_prefs (void)
font_color_str = g_strdup ("#000000");
}
+#if GTK_CHECK_VERSION (3, 0, 0)
+ gdk_rgba_parse (&color, color_str);
+ gdk_rgba_parse (&font_color, font_color_str);
+#else
gdk_color_parse (color_str, &color);
- g_free (color_str);
-
gdk_color_parse (font_color_str, &font_color);
+#endif
+
+ g_free (color_str);
g_free (font_color_str);
gtk_adjustment_set_value (stickynotes->w_prefs_width, width);
@@ -507,13 +515,15 @@ stickynotes_applet_update_prefs (void)
GTK_TOGGLE_BUTTON (stickynotes->w_prefs_desktop),
desktop_hide);
- gtk_color_button_set_color (
- GTK_COLOR_BUTTON (stickynotes->w_prefs_color), &color);
- gtk_color_button_set_color (
- GTK_COLOR_BUTTON (stickynotes->w_prefs_font_color),
- &font_color);
- gtk_font_button_set_font_name (
- GTK_FONT_BUTTON (stickynotes->w_prefs_font), font_str);
+#if GTK_CHECK_VERSION (3, 0, 0)
+ gtk_color_button_set_rgba (GTK_COLOR_BUTTON (stickynotes->w_prefs_color), &color);
+ gtk_color_button_set_rgba (GTK_COLOR_BUTTON (stickynotes->w_prefs_font_color), &font_color);
+#else
+ gtk_color_button_set_color (GTK_COLOR_BUTTON (stickynotes->w_prefs_color), &color);
+ gtk_color_button_set_color (GTK_COLOR_BUTTON (stickynotes->w_prefs_font_color), &font_color);
+#endif
+
+ gtk_font_button_set_font_name (GTK_FONT_BUTTON (stickynotes->w_prefs_font), font_str);
g_free (font_str);
if (g_settings_is_writable (stickynotes->settings, "default-color"))
diff --git a/stickynotes/stickynotes_applet_callbacks.c b/stickynotes/stickynotes_applet_callbacks.c
index 4af87044..6414db5c 100644
--- a/stickynotes/stickynotes_applet_callbacks.c
+++ b/stickynotes/stickynotes_applet_callbacks.c
@@ -469,23 +469,31 @@ preferences_save_cb (gpointer data)
void
preferences_color_cb (GtkWidget *button, gpointer data)
{
- GdkColor color, font_color;
char *color_str, *font_color_str;
- gtk_color_button_get_color (
- GTK_COLOR_BUTTON (stickynotes->w_prefs_color), &color);
- gtk_color_button_get_color (
- GTK_COLOR_BUTTON (stickynotes->w_prefs_font_color),
- &font_color);
+#if GTK_CHECK_VERSION (3, 0, 0)
+ GdkRGBA color, font_color;
+
+ gtk_color_button_get_rgba (GTK_COLOR_BUTTON (stickynotes->w_prefs_color), &color);
+ gtk_color_button_get_rgba (GTK_COLOR_BUTTON (stickynotes->w_prefs_font_color), &font_color);
+
+ color_str = gdk_rgba_to_string (&color);
+ font_color_str = gdk_rgba_to_string (&font_color);
+#else
+ GdkColor color, font_color;
+
+ gtk_color_button_get_color (GTK_COLOR_BUTTON (stickynotes->w_prefs_color), &color);
+ gtk_color_button_get_color (GTK_COLOR_BUTTON (stickynotes->w_prefs_font_color), &font_color);
color_str = g_strdup_printf ("#%.2x%.2x%.2x",
- color.red / 256,
- color.green / 256,
- color.blue / 256);
+ color.red / 256,
+ color.green / 256,
+ color.blue / 256);
font_color_str = g_strdup_printf ("#%.2x%.2x%.2x",
- font_color.red / 256,
- font_color.green / 256,
- font_color.blue / 256);
+ font_color.red / 256,
+ font_color.green / 256,
+ font_color.blue / 256);
+#endif
g_settings_set_string (stickynotes->settings, "default-color", color_str);
g_settings_set_string (stickynotes->settings, "default-font-color", font_color_str);