[Xfce4-commits] <xfce4-weather-plugin:master> Implement icon theme selection via config dialog.

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


Updating branch refs/heads/master
         to c16119a6c0f91e5736f935a58cf14cb5b42a7740 (commit)
       from 5dc37d7b76fdca4893b4e5a329b03f090b0b779c (commit)

commit c16119a6c0f91e5736f935a58cf14cb5b42a7740
Author: Harald Judt <h.judt at gmx.at>
Date:   Tue Nov 27 16:02:32 2012 +0100

    Implement icon theme selection via config dialog.
    
    Show all available themes in the icon theme combo box in the appearance page.
    If the selection changes, update the icon in the panel.

 panel-plugin/weather-config.c |   36 +++++++++++++++++++++++++++++++++++-
 panel-plugin/weather-config.h |    1 +
 panel-plugin/weather.c        |   10 +++++++++-
 panel-plugin/weather.h        |    2 ++
 4 files changed, 47 insertions(+), 2 deletions(-)

diff --git a/panel-plugin/weather-config.c b/panel-plugin/weather-config.c
index 9763650..ddaf3df 100644
--- a/panel-plugin/weather-config.c
+++ b/panel-plugin/weather-config.c
@@ -697,6 +697,28 @@ create_units_page(xfceweather_dialog *dialog)
 
 
 static void
+combo_icon_theme_changed(GtkWidget *combo,
+                         gpointer user_data)
+{
+    xfceweather_dialog *dialog = (xfceweather_dialog *) user_data;
+    icon_theme *theme;
+    gint i;
+
+    i = gtk_combo_box_get_active(GTK_COMBO_BOX(combo));
+    if (G_UNLIKELY(i == -1))
+        return;
+
+    theme = g_array_index(dialog->icon_themes, icon_theme*, i);
+    if (G_UNLIKELY(theme == NULL))
+        return;
+
+    icon_theme_free(dialog->wd->icon_theme);
+    dialog->wd->icon_theme = icon_theme_copy(theme);
+    update_icon(dialog->wd);
+}
+
+
+static void
 combo_tooltip_style_changed(GtkWidget *combo,
                             gpointer user_data)
 {
@@ -740,6 +762,8 @@ create_appearance_page(xfceweather_dialog *dialog)
 {
     GtkWidget *palign, *page, *hbox, *vbox, *label;
     GtkSizeGroup *sg;
+    icon_theme *theme;
+    guint i;
 
     ADD_PAGE(TRUE);
     sg = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL);
@@ -749,8 +773,18 @@ create_appearance_page(xfceweather_dialog *dialog)
     hbox = gtk_hbox_new(FALSE, BORDER);
     ADD_LABEL(_("_Icon theme:"), sg);
     ADD_COMBO(dialog->combo_icon_theme);
-    ADD_COMBO_VALUE(dialog->combo_icon_theme, "Liquid");
     gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
+    dialog->icon_themes = find_icon_themes();
+    for (i = 0; i < dialog->icon_themes->len; i++) {
+        theme = g_array_index(dialog->icon_themes, icon_theme*, i);
+        ADD_COMBO_VALUE(dialog->combo_icon_theme, theme->name);
+        /* set selection to current theme */
+        if (G_LIKELY(dialog->wd->icon_theme) &&
+            !strcmp(theme->dir, dialog->wd->icon_theme->dir))
+            SET_COMBO_VALUE(dialog->combo_icon_theme, i);
+    }
+    g_signal_connect(dialog->combo_icon_theme, "changed",
+                     G_CALLBACK(combo_icon_theme_changed), dialog);
 
     /* tooltip style */
     hbox = gtk_hbox_new(FALSE, BORDER);
diff --git a/panel-plugin/weather-config.h b/panel-plugin/weather-config.h
index 4fba442..b54606f 100644
--- a/panel-plugin/weather-config.h
+++ b/panel-plugin/weather-config.h
@@ -46,6 +46,7 @@ typedef struct {
 
     /* appearance page */
     GtkWidget *combo_icon_theme;
+    GArray *icon_themes;
     GtkWidget *combo_tooltip_style;
     GtkWidget *combo_forecast_layout;
     GtkWidget *spin_forecast_days;
diff --git a/panel-plugin/weather.c b/panel-plugin/weather.c
index e4e2d90..298e144 100644
--- a/panel-plugin/weather.c
+++ b/panel-plugin/weather.c
@@ -161,7 +161,7 @@ make_label(const xfceweather_data *data,
 }
 
 
-static void
+void
 update_icon(xfceweather_data *data)
 {
     GdkPixbuf *icon = NULL;
@@ -759,7 +759,9 @@ xfceweather_dialog_response(GtkWidget *dlg,
                             xfceweather_dialog *dialog)
 {
     xfceweather_data *data = (xfceweather_data *) dialog->wd;
+    icon_theme *theme;
     gboolean result;
+    guint i;
 
     if (response == GTK_RESPONSE_HELP) {
         /* show help */
@@ -780,6 +782,12 @@ xfceweather_dialog_response(GtkWidget *dlg,
 
         gtk_list_store_clear(dialog->model_datatypes);
 
+        for (i = 0; i < dialog->icon_themes->len; i++) {
+            theme = g_array_index(dialog->icon_themes, icon_theme*, i);
+            icon_theme_free(theme);
+            g_array_free(dialog->icon_themes, TRUE);
+        }
+
         g_slice_free(xfceweather_dialog, dialog);
 
         xfce_panel_plugin_unblock_menu(data->plugin);
diff --git a/panel-plugin/weather.h b/panel-plugin/weather.h
index 70cd5d1..a4993d6 100644
--- a/panel-plugin/weather.h
+++ b/panel-plugin/weather.h
@@ -102,6 +102,8 @@ void weather_http_queue_request(SoupSession *session,
 
 void scrollbox_set_visible(xfceweather_data *data);
 
+void update_icon(xfceweather_data *data);
+
 void update_scrollbox(xfceweather_data *data);
 
 GArray* labels_clear(GArray *array);


More information about the Xfce4-commits mailing list