[Xfce4-commits] <xfce4-weather-plugin:master> Allow removing applied scrollbox color by middle-click.

Harald Judt noreply at xfce.org
Tue Nov 27 16:46:30 CET 2012


Updating branch refs/heads/master
         to 2d7b86da82655536695a8b2e6ed00befc123e6e9 (commit)
       from 2dc70062a2148e6adcfb7a4048723d2c36be6780 (commit)

commit 2d7b86da82655536695a8b2e6ed00befc123e6e9
Author: Harald Judt <h.judt at gmx.at>
Date:   Mon Nov 26 11:07:55 2012 +0100

    Allow removing applied scrollbox color by middle-click.

 panel-plugin/weather-config.c    |   28 ++++++++++++++++++++++++++++
 panel-plugin/weather-debug.c     |    2 ++
 panel-plugin/weather-scrollbox.c |   16 ++++++++++++++++
 panel-plugin/weather-scrollbox.h |    2 ++
 panel-plugin/weather.c           |   11 +++++++++--
 panel-plugin/weather.h           |    1 +
 6 files changed, 58 insertions(+), 2 deletions(-)

diff --git a/panel-plugin/weather-config.c b/panel-plugin/weather-config.c
index 0ab5c1a..2108933 100644
--- a/panel-plugin/weather-config.c
+++ b/panel-plugin/weather-config.c
@@ -821,6 +821,29 @@ button_scrollbox_font_clicked(GtkWidget *button,
 }
 
 
+static gboolean
+button_scrollbox_color_pressed(GtkWidget *button,
+                               GdkEventButton *event,
+                               gpointer user_data)
+{
+    xfceweather_dialog *dialog = (xfceweather_dialog *) user_data;
+    GtkStyle *style;
+    GdkColor color;
+    gchar *colstr;
+
+    if (event->type != GDK_BUTTON_PRESS)
+        return FALSE;
+
+    if (event->button == 2) {
+        dialog->wd->scrollbox_use_color = FALSE;
+        gtk_scrollbox_clear_color(GTK_SCROLLBOX(dialog->wd->scrollbox));
+        return TRUE;
+    }
+
+    return FALSE;
+}
+
+
 static void
 button_scrollbox_color_set(GtkWidget *button,
                            gpointer user_data)
@@ -831,6 +854,7 @@ button_scrollbox_color_set(GtkWidget *button,
                                &(dialog->wd->scrollbox_color));
     gtk_scrollbox_set_color(GTK_SCROLLBOX(dialog->wd->scrollbox),
                             dialog->wd->scrollbox_color);
+    dialog->wd->scrollbox_use_color = TRUE;
 }
 
 
@@ -1059,6 +1083,10 @@ create_scrollbox_page(xfceweather_dialog *dialog)
     gtk_box_pack_start(GTK_BOX(hbox), dialog->button_scrollbox_color,
                        FALSE, FALSE, 0 );
     gtk_box_pack_start(GTK_BOX(page), hbox, FALSE, FALSE, 0);
+    g_signal_connect(G_OBJECT(dialog->button_scrollbox_color),
+                     "button-press-event",
+                     G_CALLBACK(button_scrollbox_color_pressed),
+                     dialog);
     g_signal_connect(dialog->button_scrollbox_color, "color-set",
                      G_CALLBACK(button_scrollbox_color_set), dialog);
 
diff --git a/panel-plugin/weather-debug.c b/panel-plugin/weather-debug.c
index ea0d4d3..cf60b8a 100644
--- a/panel-plugin/weather-debug.c
+++ b/panel-plugin/weather-debug.c
@@ -413,6 +413,7 @@ weather_dump_plugindata(const xfceweather_data *data)
                            "  scrollbox lines: %d\n"
                            "  scrollbox font: %s\n"
                            "  scrollbox color: %s\n"
+                           "  scrollbox use color: %s\n"
                            "  animate scrollbox: %s\n"
                            "  --------------------------------------------",
                            data->panel_size,
@@ -431,6 +432,7 @@ weather_dump_plugindata(const xfceweather_data *data)
                            data->scrollbox_lines,
                            data->scrollbox_font,
                            gdk_color_to_string(&(data->scrollbox_color)),
+                           YESNO(data->scrollbox_use_color),
                            YESNO(data->scrollbox_animate));
     g_free(last_astro_update);
     g_free(last_data_update);
diff --git a/panel-plugin/weather-scrollbox.c b/panel-plugin/weather-scrollbox.c
index 7317a68..0946253 100644
--- a/panel-plugin/weather-scrollbox.c
+++ b/panel-plugin/weather-scrollbox.c
@@ -389,6 +389,22 @@ gtk_scrollbox_set_color(GtkScrollbox *self,
                                       color.green,
                                       color.blue);
     pango_attr_list_change(self->pattr_list, pattr);
+
+    /* update all labels */
+    gtk_scrollbox_set_font(self, NULL);
+    gtk_widget_queue_resize(GTK_WIDGET(self));
+}
+
+
+void
+gtk_scrollbox_clear_color(GtkScrollbox *self)
+{
+    g_return_if_fail(GTK_IS_SCROLLBOX(self));
+
+    pango_attr_list_unref(self->pattr_list);
+    self->pattr_list = pango_attr_list_new();
+
+    /* update all labels */
     gtk_scrollbox_set_font(self, NULL);
     gtk_widget_queue_resize(GTK_WIDGET(self));
 }
diff --git a/panel-plugin/weather-scrollbox.h b/panel-plugin/weather-scrollbox.h
index 7a1c320..216dcc0 100644
--- a/panel-plugin/weather-scrollbox.h
+++ b/panel-plugin/weather-scrollbox.h
@@ -80,6 +80,8 @@ void gtk_scrollbox_set_fontname(GtkScrollbox *self,
 void gtk_scrollbox_set_color(GtkScrollbox *self,
                              const GdkColor color);
 
+void gtk_scrollbox_clear_color(GtkScrollbox *self);
+
 G_END_DECLS
 
 #endif
diff --git a/panel-plugin/weather.c b/panel-plugin/weather.c
index 31f0fbe..6ee3568 100644
--- a/panel-plugin/weather.c
+++ b/panel-plugin/weather.c
@@ -572,6 +572,9 @@ xfceweather_read_config(XfcePanelPlugin *plugin,
     if (value)
         gdk_color_parse("#rrrrggggbbbb", &(data->scrollbox_color));
 
+    data->scrollbox_use_color =
+        xfce_rc_read_bool_entry(rc, "scrollbox_use_color", FALSE);
+
     data->scrollbox_animate =
         xfce_rc_read_bool_entry(rc, "scrollbox_animate", TRUE);
     gtk_scrollbox_set_animate(GTK_SCROLLBOX(data->scrollbox),
@@ -654,6 +657,9 @@ xfceweather_write_config(XfcePanelPlugin *plugin,
     xfce_rc_write_entry(rc, "scrollbox_color", value);
     g_free(value);
 
+    xfce_rc_write_bool_entry(rc, "scrollbox_use_color",
+                             data->scrollbox_use_color);
+
     for (i = 0; i < data->labels->len; i++) {
         g_snprintf(label, 10, "label%d", i);
         xfce_rc_write_int_entry(rc, label,
@@ -1282,8 +1288,9 @@ weather_construct(XfcePanelPlugin *plugin)
     scrollbox_set_visible(data);
     gtk_scrollbox_set_fontname(GTK_SCROLLBOX(data->scrollbox),
                                data->scrollbox_font);
-    gtk_scrollbox_set_color(GTK_SCROLLBOX(data->scrollbox),
-                            data->scrollbox_color);
+    if (data->scrollbox_use_color)
+        gtk_scrollbox_set_color(GTK_SCROLLBOX(data->scrollbox),
+                                data->scrollbox_color);
 
 #if LIBXFCE4PANEL_CHECK_VERSION(4,9,0)
     xfceweather_set_mode(plugin, xfce_panel_plugin_get_mode(plugin), data);
diff --git a/panel-plugin/weather.h b/panel-plugin/weather.h
index 34122ec..ca97c65 100644
--- a/panel-plugin/weather.h
+++ b/panel-plugin/weather.h
@@ -58,6 +58,7 @@ typedef struct {
     guint scrollbox_lines;
     gchar *scrollbox_font;
     GdkColor scrollbox_color;
+    gboolean scrollbox_use_color;
     gboolean scrollbox_animate;
     GArray *labels;
 


More information about the Xfce4-commits mailing list