summaryrefslogtreecommitdiff
path: root/netspeed/src/netspeed.c
diff options
context:
space:
mode:
authorraveit65 <[email protected]>2016-08-01 09:20:22 +0200
committerraveit65 <[email protected]>2016-08-01 10:50:35 +0200
commitb16122c9246c914c7c8cca47f7627a089de0e8b8 (patch)
tree17d6dcc97b5beea967a0f3b6751f3111060e04e5 /netspeed/src/netspeed.c
parent4d035c35dcc95220d9f3adb93d042a4b671af4b0 (diff)
downloadmate-applets-b16122c9246c914c7c8cca47f7627a089de0e8b8.tar.bz2
mate-applets-b16122c9246c914c7c8cca47f7627a089de0e8b8.tar.xz
GTK+-3 netspeed: write valid rgb color values to gsettings
Previous commit writes garbage to gsettings, in result no graphs are displayed with a new start of the applet. Now we have rgb values in gsettings values.
Diffstat (limited to 'netspeed/src/netspeed.c')
-rw-r--r--netspeed/src/netspeed.c41
1 files changed, 28 insertions, 13 deletions
diff --git a/netspeed/src/netspeed.c b/netspeed/src/netspeed.c
index 23b2b7c2..6d0c56d0 100644
--- a/netspeed/src/netspeed.c
+++ b/netspeed/src/netspeed.c
@@ -97,7 +97,8 @@ typedef struct
gboolean show_icon, short_unit;
gboolean show_quality_icon;
#if GTK_CHECK_VERSION (3, 0, 0)
- GdkRGBA in_color, out_color;
+ GdkRGBA in_color;
+ GdkRGBA out_color;
#else
GdkColor in_color, out_color;
#endif
@@ -1137,16 +1138,23 @@ da_expose_event(GtkWidget *widget, GdkEventExpose *event, gpointer data)
return FALSE;
}
-static void
#if GTK_CHECK_VERSION (3, 0, 0)
-incolor_changed_cb (GtkColorChooser *cb, gpointer data)
+static void
+incolor_changed_cb (GtkColorChooser *button, gpointer data)
{
MateNetspeedApplet *applet = (MateNetspeedApplet*)data;
- gchar *color;
- GdkRGBA clr;
+ GdkRGBA color;
+ gchar *string;
+
+ gtk_color_chooser_get_rgba (GTK_COLOR_CHOOSER (button), &color);
+ applet->in_color = color;
- gtk_color_chooser_get_rgba (cb, &clr);
+ string = gdk_rgba_to_string (&color);
+ g_settings_set_string (applet->gsettings, "in-color", string);
+ g_free (string);
+}
#else
+static void
incolor_changed_cb (GtkColorButton *cb, gpointer data)
{
MateNetspeedApplet *applet = (MateNetspeedApplet*)data;
@@ -1154,24 +1162,31 @@ incolor_changed_cb (GtkColorButton *cb, gpointer data)
GdkColor clr;
gtk_color_button_get_color (cb, &clr);
-#endif
applet->in_color = clr;
color = g_strdup_printf ("#%04x%04x%04x", clr.red, clr.green, clr.blue);
g_settings_set_string (applet->gsettings, "in-color", color);
g_free (color);
}
+#endif
-static void
#if GTK_CHECK_VERSION (3, 0, 0)
-outcolor_changed_cb (GtkColorChooser *cb, gpointer data)
+static void
+outcolor_changed_cb (GtkColorChooser *button, gpointer data)
{
MateNetspeedApplet *applet = (MateNetspeedApplet*)data;
- gchar *color;
- GdkRGBA clr;
+ GdkRGBA color;
+ gchar *string;
+
+ gtk_color_chooser_get_rgba (GTK_COLOR_CHOOSER (button), &color);
+ applet->out_color = color;
- gtk_color_chooser_get_rgba (cb, &clr);
+ string = gdk_rgba_to_string (&color);
+ g_settings_set_string (applet->gsettings, "out-color", string);
+ g_free (string);
+}
#else
+static void
outcolor_changed_cb (GtkColorButton *cb, gpointer data)
{
MateNetspeedApplet *applet = (MateNetspeedApplet*)data;
@@ -1179,13 +1194,13 @@ outcolor_changed_cb (GtkColorButton *cb, gpointer data)
GdkColor clr;
gtk_color_button_get_color (cb, &clr);
-#endif
applet->out_color = clr;
color = g_strdup_printf ("#%04x%04x%04x", clr.red, clr.green, clr.blue);
g_settings_set_string (applet->gsettings, "out-color", color);
g_free (color);
}
+#endif
/* Handle info dialog response event
*/