[Xfce4-commits] <xfce4-weather-plugin:master> Config: Add a button for opening/creating the user icon themes directory.

Harald Judt noreply at xfce.org
Fri Mar 29 00:50:02 CET 2013


Updating branch refs/heads/master
         to 7f2257c3e67d2df262592b4839852fd5b746365d (commit)
       from add24d3e35db5724a3b6a1efe47274fc809b4992 (commit)

commit 7f2257c3e67d2df262592b4839852fd5b746365d
Author: Harald Judt <h.judt at gmx.at>
Date:   Fri Mar 29 00:46:54 2013 +0100

    Config: Add a button for opening/creating the user icon themes directory.
    
    The button opens the directory in the file manager, so that the user doesn't
    have to waste time navigating around. If the directory doesn't exist, it
    will try to create it.

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

diff --git a/panel-plugin/weather-config.c b/panel-plugin/weather-config.c
index f562684..2035bae 100644
--- a/panel-plugin/weather-config.c
+++ b/panel-plugin/weather-config.c
@@ -1089,6 +1089,23 @@ combo_icon_theme_changed(GtkWidget *combo,
 
 
 static void
+button_icons_dir_clicked(GtkWidget *button,
+                         gpointer user_data)
+{
+    xfceweather_dialog *dialog = (xfceweather_dialog *) user_data;
+    gchar *dir, *command;
+
+    dir = get_user_icons_dir();
+    g_mkdir_with_parents(dir, 0755);
+    command = g_strdup_printf("exo-open %s", dir);
+    g_free(dir);
+    xfce_spawn_command_line_on_screen(gdk_screen_get_default(),
+                                      command, FALSE, TRUE, NULL);
+    g_free(command);
+}
+
+
+static void
 check_single_row_toggled(GtkWidget *button,
                          gpointer user_data)
 {
@@ -1170,8 +1187,9 @@ check_round_values_toggled(GtkWidget *button,
 static GtkWidget *
 create_appearance_page(xfceweather_dialog *dialog)
 {
-    GtkWidget *palign, *page, *sep, *hbox, *vbox, *label;
+    GtkWidget *palign, *page, *sep, *hbox, *vbox, *label, *image;
     GtkSizeGroup *sg;
+    GtkSettings *default_settings;
     icon_theme *theme;
     gchar *text;
     gint i;
@@ -1192,6 +1210,18 @@ create_appearance_page(xfceweather_dialog *dialog)
                   "you open this config dialog."));
     ADD_COMBO(dialog->combo_icon_theme);
     gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
+    default_settings = gtk_settings_get_default();
+    g_object_set(default_settings, "gtk-button-images", TRUE, NULL);
+    image = gtk_image_new();
+    gtk_image_set_from_stock(GTK_IMAGE(image), GTK_STOCK_OPEN,
+                             GTK_ICON_SIZE_BUTTON);
+    dialog->button_icons_dir = gtk_button_new();
+    gtk_button_set_image(GTK_BUTTON(dialog->button_icons_dir), image);
+    gtk_box_pack_start(GTK_BOX(hbox), dialog->button_icons_dir,
+                       FALSE, FALSE, 0);
+    SET_TOOLTIP(dialog->button_icons_dir,
+                _("Open the user icon themes directory in your file manager, "
+                  "creating it if necessary."));
     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);
@@ -1985,6 +2015,8 @@ setup_notebook_signals(xfceweather_dialog *dialog)
     /* appearance page */
     g_signal_connect(dialog->combo_icon_theme, "changed",
                      G_CALLBACK(combo_icon_theme_changed), dialog);
+    g_signal_connect(dialog->button_icons_dir, "clicked",
+                     G_CALLBACK(button_icons_dir_clicked), dialog);
     g_signal_connect(dialog->check_single_row, "toggled",
                      G_CALLBACK(check_single_row_toggled), dialog);
     g_signal_connect(dialog->combo_tooltip_style, "changed",
diff --git a/panel-plugin/weather-config.h b/panel-plugin/weather-config.h
index 490c164..7b338e8 100644
--- a/panel-plugin/weather-config.h
+++ b/panel-plugin/weather-config.h
@@ -52,6 +52,7 @@ typedef struct {
     /* appearance page */
     GtkWidget *combo_icon_theme;
     GArray *icon_themes;
+    GtkWidget *button_icons_dir;
     GtkWidget *combo_tooltip_style;
     GtkWidget *combo_forecast_layout;
     GtkWidget *spin_forecast_days;


More information about the Xfce4-commits mailing list