[Xfce4-commits] r27045 - xfce-mcs-plugins/branches/xfce-plugins-stephan/dialogs/appearance-settings
Stephan Arts
stephan at xfce.org
Mon Jun 9 21:32:09 CEST 2008
Author: stephan
Date: 2008-06-09 19:32:09 +0000 (Mon, 09 Jun 2008)
New Revision: 27045
Modified:
xfce-mcs-plugins/branches/xfce-plugins-stephan/dialogs/appearance-settings/appearance-dialog.glade
xfce-mcs-plugins/branches/xfce-plugins-stephan/dialogs/appearance-settings/main.c
Log:
Improve theme-selection
Modified: xfce-mcs-plugins/branches/xfce-plugins-stephan/dialogs/appearance-settings/appearance-dialog.glade
===================================================================
--- xfce-mcs-plugins/branches/xfce-plugins-stephan/dialogs/appearance-settings/appearance-dialog.glade 2008-06-08 20:21:19 UTC (rev 27044)
+++ xfce-mcs-plugins/branches/xfce-plugins-stephan/dialogs/appearance-settings/appearance-dialog.glade 2008-06-09 19:32:09 UTC (rev 27045)
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE glade-interface SYSTEM "glade-2.0.dtd">
-<!--Generated with glade3 3.4.2 on Mon May 12 21:42:13 2008 -->
+<!--Generated with glade3 3.4.5 on Mon Jun 9 21:06:28 2008 -->
<glade-interface>
<requires lib="xfce4"/>
<widget class="GtkDialog" id="appearance-settings-dialog">
@@ -32,73 +32,127 @@
<property name="visible">True</property>
<property name="can_focus">True</property>
<child>
- <widget class="GtkVBox" id="vbox8">
+ <widget class="GtkFrame" id="frame6">
<property name="visible">True</property>
- <property name="border_width">5</property>
+ <property name="label_xalign">0</property>
+ <property name="shadow_type">GTK_SHADOW_NONE</property>
<child>
- <widget class="GtkScrolledWindow" id="scrolledwindow1">
+ <widget class="GtkAlignment" id="alignment6">
<property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="hscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
- <property name="vscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
- <property name="shadow_type">GTK_SHADOW_IN</property>
+ <property name="left_padding">12</property>
<child>
- <widget class="GtkIconView" id="theme_icon_view">
+ <widget class="GtkNotebook" id="notebook2">
<property name="visible">True</property>
<property name="can_focus">True</property>
- <property name="columns">3</property>
- <property name="item_width">128</property>
+ <child>
+ <widget class="GtkVBox" id="vbox8">
+ <property name="visible">True</property>
+ <child>
+ <widget class="GtkLabel" id="label14">
+ <property name="visible">True</property>
+ <property name="xalign">0</property>
+ <property name="xpad">6</property>
+ <property name="ypad">6</property>
+ <property name="label" translatable="yes">Please select the gtk-theme you want to use</property>
+ </widget>
+ <packing>
+ <property name="expand">False</property>
+ </packing>
+ </child>
+ <child>
+ <widget class="GtkScrolledWindow" id="scrolledwindow1">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="hscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
+ <property name="vscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
+ <property name="shadow_type">GTK_SHADOW_IN</property>
+ <child>
+ <widget class="GtkTreeView" id="gtk_theme_treeview">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="headers_visible">False</property>
+ <property name="headers_clickable">True</property>
+ </widget>
+ </child>
+ </widget>
+ <packing>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </widget>
+ </child>
+ <child>
+ <widget class="GtkLabel" id="label12">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes">Gtk Theme</property>
+ </widget>
+ <packing>
+ <property name="type">tab</property>
+ <property name="tab_fill">False</property>
+ </packing>
+ </child>
+ <child>
+ <widget class="GtkVBox" id="vbox9">
+ <property name="visible">True</property>
+ <child>
+ <widget class="GtkLabel" id="label13">
+ <property name="visible">True</property>
+ <property name="xalign">0</property>
+ <property name="xpad">6</property>
+ <property name="ypad">6</property>
+ <property name="label" translatable="yes">Please select the icon-theme you want to use:</property>
+ </widget>
+ <packing>
+ <property name="expand">False</property>
+ </packing>
+ </child>
+ <child>
+ <widget class="GtkScrolledWindow" id="scrolledwindow2">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="hscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
+ <property name="vscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
+ <property name="shadow_type">GTK_SHADOW_IN</property>
+ <child>
+ <widget class="GtkIconView" id="icon_theme_iconview">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="pixbuf_column">0</property>
+ <property name="text_column">1</property>
+ </widget>
+ </child>
+ </widget>
+ <packing>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </widget>
+ <packing>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ <child>
+ <widget class="GtkLabel" id="label15">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes">Icon theme</property>
+ </widget>
+ <packing>
+ <property name="type">tab</property>
+ <property name="position">1</property>
+ <property name="tab_fill">False</property>
+ </packing>
+ </child>
</widget>
</child>
</widget>
</child>
<child>
- <widget class="GtkHButtonBox" id="hbuttonbox1">
+ <widget class="GtkLabel" id="label11">
<property name="visible">True</property>
- <property name="border_width">3</property>
- <child>
- <widget class="GtkButton" id="theme_edit_button">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="receives_default">True</property>
- <property name="label" translatable="yes">gtk-edit</property>
- <property name="use_stock">True</property>
- <property name="response_id">0</property>
- </widget>
- </child>
- <child>
- <widget class="GtkButton" id="theme_delete_button">
- <property name="visible">True</property>
- <property name="sensitive">False</property>
- <property name="can_focus">True</property>
- <property name="receives_default">True</property>
- <property name="label" translatable="yes">gtk-delete</property>
- <property name="use_stock">True</property>
- <property name="response_id">0</property>
- </widget>
- <packing>
- <property name="position">1</property>
- </packing>
- </child>
- <child>
- <widget class="GtkButton" id="theme_save_as_button">
- <property name="visible">True</property>
- <property name="sensitive">False</property>
- <property name="can_focus">True</property>
- <property name="receives_default">True</property>
- <property name="label" translatable="yes">gtk-save-as</property>
- <property name="use_stock">True</property>
- <property name="response_id">0</property>
- </widget>
- <packing>
- <property name="position">2</property>
- </packing>
- </child>
+ <property name="use_markup">True</property>
</widget>
<packing>
- <property name="expand">False</property>
- <property name="fill">False</property>
- <property name="position">1</property>
+ <property name="type">label_item</property>
</packing>
</child>
</widget>
Modified: xfce-mcs-plugins/branches/xfce-plugins-stephan/dialogs/appearance-settings/main.c
===================================================================
--- xfce-mcs-plugins/branches/xfce-plugins-stephan/dialogs/appearance-settings/main.c 2008-06-08 20:21:19 UTC (rev 27044)
+++ xfce-mcs-plugins/branches/xfce-plugins-stephan/dialogs/appearance-settings/main.c 2008-06-09 19:32:09 UTC (rev 27045)
@@ -33,6 +33,11 @@
#include <xfconf/xfconf.h>
#include "appearance-dialog.glade.h"
+typedef enum {
+ THEME_TYPE_ICONS,
+ THEME_TYPE_GTK,
+} ThemeType;
+
typedef struct {
GtkWidget *slave;
XfconfChannel *channel;
@@ -50,18 +55,51 @@
};
void
-cb_icon_view_selection_changed (GtkIconView *icon_view, XfconfChannel *channel)
+cb_icon_theme_iconview_selection_changed (GtkIconView *icon_view, XfconfChannel *channel)
{
GList *list = gtk_icon_view_get_selected_items (icon_view);
GtkTreeModel *model = gtk_icon_view_get_model (icon_view);
GtkTreeIter iter;
GValue value = {0,};
+ /* valid failure */
+ if ( g_list_length (list) == 0)
+ return;
+
+ /* everything else is invalid */
g_return_if_fail (g_list_length (list) == 1);
gtk_tree_model_get_iter (model, &iter, list->data);
gtk_tree_model_get_value (model, &iter, 1, &value);
+ xfconf_channel_set_property (channel, "/Net/IconThemeName", &value);
+
+ g_value_unset (&value);
+
+ g_list_foreach (list, (GFunc)gtk_tree_path_free, NULL);
+ g_list_free (list);
+
+}
+
+void
+cb_gtk_theme_treeview_row_activated (GtkTreeView *tree_view, GtkTreePath *path, GtkTreeViewColumn *column, XfconfChannel *channel)
+{
+ GtkTreeSelection *selection = gtk_tree_view_get_selection (tree_view);
+ GtkTreeModel *model = NULL;
+ GList *list = gtk_tree_selection_get_selected_rows (selection, &model);
+ GtkTreeIter iter;
+ GValue value = {0,};
+
+ /* valid failure */
+ if ( g_list_length (list) == 0)
+ return;
+
+ /* everything else is invalid */
+ g_return_if_fail (g_list_length (list) == 1);
+
+ gtk_tree_model_get_iter (model, &iter, list->data);
+ gtk_tree_model_get_value (model, &iter, 0, &value);
+
xfconf_channel_set_property (channel, "/Net/ThemeName", &value);
g_value_unset (&value);
@@ -212,104 +250,160 @@
}
}
-/**
- * TODO: Fix icon-theme-spec compliance
- */
-void
-check_themes (GtkListStore *list_store, GtkIconView *icon_view, XfconfChannel *channel)
+GList *
+read_themes_from_dir (const gchar *dir_name, ThemeType type)
{
- GtkTreeIter iter;
- GtkIconTheme *icon_theme = gtk_icon_theme_get_default();
- gchar *dir_name;
- GDir *dir;
- const gchar *theme_name;
- const gchar *data_dir_name;
- gchar *gtk_theme_name;
- gchar *active_theme_name = xfconf_channel_get_string (channel, "/Net/ThemeName", "Default");
+ GList *theme_list = NULL;
+ const gchar *theme_name = NULL;
+ gchar *theme_index;
+ GDir *dir = g_dir_open (dir_name, 0, NULL);
- dir_name = g_build_filename (g_get_home_dir (), ".themes", NULL);
- dir = g_dir_open (dir_name, 0, NULL);
-
if (dir)
{
theme_name = g_dir_read_name (dir);
while (theme_name)
{
- gtk_theme_name = g_build_filename (dir_name, theme_name, "gtk-2.0", NULL);
+ switch (type)
+ {
+ case THEME_TYPE_ICONS:
+ theme_index = g_build_filename (dir_name, theme_name, "index.theme", NULL);
- if (g_file_test (gtk_theme_name, G_FILE_TEST_EXISTS | G_FILE_TEST_IS_DIR))
- {
- gtk_list_store_append(list_store, &iter);
- gtk_list_store_set(list_store, &iter, 0, gtk_icon_theme_load_icon (icon_theme, "image-missing", 48, 0, NULL), 1, theme_name, -1);
+ if (g_file_test (theme_index, G_FILE_TEST_EXISTS))
+ {
+ /* unfortunately, need to strdup here because the
+ * resources allocated to the dir get released once
+ * the dir is closed at the end of this function
+ */
+ theme_list = g_list_append (theme_list, g_strdup(theme_name));
+ }
+
+ g_free (theme_index);
+ break;
+ case THEME_TYPE_GTK:
+ theme_index = g_build_filename (dir_name, theme_name, "gtk-2.0", "gtkrc", NULL);
+
+ if (g_file_test (theme_index, G_FILE_TEST_EXISTS))
+ {
+ /* unfortunately, need to strdup here because the
+ * resources allocated to the dir get released once
+ * the dir is closed at the end of this function
+ */
+ theme_list = g_list_append (theme_list, g_strdup(theme_name));
+ }
+
+ g_free (theme_index);
+ break;
}
- if (strcmp (theme_name, active_theme_name) == 0)
- {
- GtkTreePath *path = gtk_tree_model_get_path (GTK_TREE_MODEL (list_store), &iter);
- gtk_icon_view_select_path (icon_view, path);
- }
-
- g_free (gtk_theme_name);
+
theme_name = g_dir_read_name (dir);
}
+
+ g_dir_close (dir);
}
+
+ return theme_list;
+}
+
+/**
+ * TODO: Fix icon-theme-spec compliance
+ */
+void
+check_icon_themes (GtkListStore *list_store, GtkIconView *icon_view, XfconfChannel *channel)
+{
+ gchar *dir_name;
+ gchar *active_theme_name = xfconf_channel_get_string (channel, "/Net/IconThemeName", "Default");
+ const gchar * const *xdg_system_data_dirs = g_get_system_data_dirs();
+ GList *user_theme_list = NULL;
+ GList *xdg_user_theme_list = NULL;
+ GList *xdg_system_theme_list = NULL;
+ GList *list_iter = NULL;
+ GtkTreeIter iter;
+
+ dir_name = g_build_filename (g_get_home_dir (), ".icons", NULL);
+ user_theme_list = read_themes_from_dir (dir_name, THEME_TYPE_ICONS);
g_free (dir_name);
-#if 0
- dir_name = g_build_filename (g_get_user_data_dir(), "themes", NULL);
- dir = g_dir_open (dir_name, 0, NULL);
+ dir_name = g_build_filename (g_get_user_data_dir(), "icons", NULL);
+ xdg_user_theme_list = read_themes_from_dir (dir_name, THEME_TYPE_ICONS);
+ g_free (dir_name);
- if (dir)
+ while (*xdg_system_data_dirs)
{
- theme_name = g_dir_read_name (dir);
+ dir_name = g_build_filename (*xdg_system_data_dirs, "icons", NULL);
+ xdg_system_theme_list = g_list_concat (xdg_system_theme_list, read_themes_from_dir (dir_name, THEME_TYPE_ICONS));
+ g_free (dir_name);
- while (theme_name)
- {
- gtk_theme_name = g_build_filename (dir_name, theme_name, "gtk-2.0", NULL);
+ xdg_system_data_dirs++;
+ }
- if (g_file_test (gtk_theme_name, G_FILE_TEST_EXISTS | G_FILE_TEST_IS_DIR))
- {
- gtk_list_store_append(list_store, &iter);
- gtk_list_store_set(list_store, &iter, 0, gtk_icon_theme_load_icon (icon_theme, "image-missing", 48, 0, NULL), 1, theme_name, -1);
- }
-
- g_free (gtk_theme_name);
- theme_name = g_dir_read_name (dir);
- }
+ for (list_iter = user_theme_list; list_iter != NULL; list_iter = g_list_next (list_iter))
+ {
+ gtk_list_store_insert (list_store, &iter, 0);
+ gtk_list_store_set (list_store, &iter, 0, NULL, 1, list_iter->data, -1);
}
- g_free (dir_name);
-#endif
+ for (list_iter = xdg_user_theme_list; list_iter != NULL; list_iter = g_list_next (list_iter))
+ {
+ gtk_list_store_insert (list_store, &iter, 0);
+ gtk_list_store_set (list_store, &iter, 0, NULL, 1, list_iter->data, -1);
+ }
+ for (list_iter = xdg_system_theme_list; list_iter != NULL; list_iter = g_list_next (list_iter))
+ {
+ gtk_list_store_insert (list_store, &iter, 0);
+ gtk_list_store_set (list_store, &iter, 0, NULL, 1, list_iter->data, -1);
+ }
+}
- dir_name = g_build_filename ("/usr/share","themes", NULL);
- dir = g_dir_open (dir_name, 0, NULL);
+void
+check_gtk_themes (GtkListStore *list_store, GtkTreeView *tree_view, XfconfChannel *channel)
+{
+ gchar *dir_name;
+ gchar *active_theme_name = xfconf_channel_get_string (channel, "/Net/ThemeName", "Default");
+ const gchar * const *xdg_system_data_dirs = g_get_system_data_dirs();
+ GList *user_theme_list = NULL;
+ GList *xdg_user_theme_list = NULL;
+ GList *xdg_system_theme_list = NULL;
+ GList *list_iter = NULL;
+ GtkTreeIter iter;
- if (dir)
+ dir_name = g_build_filename (g_get_home_dir (), ".themes", NULL);
+ user_theme_list = read_themes_from_dir (dir_name, THEME_TYPE_GTK);
+ g_free (dir_name);
+
+ dir_name = g_build_filename (g_get_user_data_dir(), "themes", NULL);
+ xdg_user_theme_list, read_themes_from_dir (dir_name, THEME_TYPE_GTK);
+ g_free (dir_name);
+
+ while (*xdg_system_data_dirs)
{
- theme_name = g_dir_read_name (dir);
+ dir_name = g_build_filename (*xdg_system_data_dirs, "themes", NULL);
+ xdg_system_theme_list = g_list_concat (xdg_system_theme_list, read_themes_from_dir (dir_name, THEME_TYPE_ICONS));
+ g_free (dir_name);
- while (theme_name)
- {
- gtk_theme_name = g_build_filename (dir_name, theme_name, "gtk-2.0", NULL);
+ xdg_system_data_dirs++;
+ }
- if (g_file_test (gtk_theme_name, G_FILE_TEST_EXISTS | G_FILE_TEST_IS_DIR))
- {
- gtk_list_store_append(list_store, &iter);
- gtk_list_store_set(list_store, &iter, 0, gtk_icon_theme_load_icon (icon_theme, "image-missing", 48, 0, NULL), 1, theme_name, -1);
- }
- if (strcmp (theme_name, active_theme_name) == 0)
- {
- GtkTreePath *path = gtk_tree_model_get_path (GTK_TREE_MODEL (list_store), &iter);
- gtk_icon_view_select_path (icon_view, path);
- }
+ for (list_iter = user_theme_list; list_iter != NULL; list_iter = g_list_next (list_iter))
+ {
+ gtk_list_store_insert (list_store, &iter, 0);
+ gtk_list_store_set (list_store, &iter, 0, list_iter->data, -1);
+ }
- g_free (gtk_theme_name);
- theme_name = g_dir_read_name (dir);
- }
+ for (list_iter = xdg_user_theme_list; list_iter != NULL; list_iter = g_list_next (list_iter))
+ {
+ gtk_list_store_insert (list_store, &iter, 0);
+ gtk_list_store_set (list_store, &iter, 0, list_iter->data, -1);
}
+ for (list_iter = xdg_system_theme_list; list_iter != NULL; list_iter = g_list_next (list_iter))
+ {
+ gtk_list_store_insert (list_store, &iter, 0);
+ gtk_list_store_set (list_store, &iter, 0, list_iter->data, -1);
+ }
+
}
@@ -320,6 +414,7 @@
GtkTreeIter iter;
GtkListStore *list_store;
GtkCellRenderer *renderer;
+ GtkTreeSelection *selection;
XfconfChannel *xsettings_channel = xfconf_channel_new("xsettings");
@@ -336,18 +431,29 @@
GtkWidget *rgba_check = glade_xml_get_widget (gxml, "xft_rgba_check_button");
GtkWidget *custom_dpi_check = glade_xml_get_widget (gxml, "xft_custom_dpi_check_button");
GtkWidget *custom_dpi_spin = glade_xml_get_widget (gxml, "xft_custom_dpi_spin_button");
- GtkWidget *icon_view = glade_xml_get_widget (gxml, "theme_icon_view");
+ GtkWidget *icon_theme_iconview = glade_xml_get_widget (gxml, "icon_theme_iconview");
+ GtkWidget *gtk_theme_treeview = glade_xml_get_widget (gxml, "gtk_theme_treeview");
/* Fill the theme-icons */
+ /* Check icon-themes */
list_store = gtk_list_store_new(2, GDK_TYPE_PIXBUF, G_TYPE_STRING);
- gtk_icon_view_set_pixbuf_column (GTK_ICON_VIEW (icon_view), 0);
- gtk_icon_view_set_text_column (GTK_ICON_VIEW (icon_view), 1);
- gtk_icon_view_set_model (GTK_ICON_VIEW (icon_view), GTK_TREE_MODEL (list_store));
- gtk_icon_view_set_selection_mode (GTK_ICON_VIEW (icon_view), GTK_SELECTION_SINGLE);
+ gtk_icon_view_set_model (GTK_ICON_VIEW (icon_theme_iconview), GTK_TREE_MODEL (list_store));
- check_themes (list_store, GTK_ICON_VIEW (icon_view), xsettings_channel);
+ check_icon_themes (list_store, GTK_ICON_VIEW (icon_theme_iconview), xsettings_channel);
+ /* Check gtk-themes */
+ list_store = gtk_list_store_new(1, G_TYPE_STRING);
+
+ renderer = gtk_cell_renderer_text_new();
+ gtk_tree_view_set_model (GTK_TREE_VIEW (gtk_theme_treeview), GTK_TREE_MODEL (list_store));
+ gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (gtk_theme_treeview), 0, _("Theme name"), renderer, "text", 0, NULL);
+
+ selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (gtk_theme_treeview));
+ gtk_tree_selection_set_mode (selection, GTK_SELECTION_SINGLE);
+
+ check_gtk_themes (list_store, GTK_TREE_VIEW (gtk_theme_treeview), xsettings_channel);
+
/* Fill the combo-boxes */
/* ToolbarStyle combo */
list_store = gtk_list_store_new(1, G_TYPE_STRING);
@@ -517,7 +623,8 @@
}
}
- g_signal_connect (G_OBJECT(icon_view), "selection_changed", G_CALLBACK(cb_icon_view_selection_changed), xsettings_channel);
+ g_signal_connect (G_OBJECT(gtk_theme_treeview), "row-activated", G_CALLBACK (cb_gtk_theme_treeview_row_activated), xsettings_channel);
+ g_signal_connect (G_OBJECT(icon_theme_iconview), "selection_changed", G_CALLBACK (cb_icon_theme_iconview_selection_changed), xsettings_channel);
g_signal_connect (G_OBJECT(toolbar_style_combo), "changed", G_CALLBACK(cb_toolbar_style_combo_changed), xsettings_channel);
g_signal_connect (G_OBJECT(hinting_style_combo), "changed", G_CALLBACK(cb_hinting_style_combo_changed), xsettings_channel);
More information about the Xfce4-commits
mailing list