diff --git a/capplets/theme-switcher/ChangeLog b/capplets/theme-switcher/ChangeLog index bee644e26..6785ba54e 100644 --- a/capplets/theme-switcher/ChangeLog +++ b/capplets/theme-switcher/ChangeLog @@ -1,3 +1,17 @@ +2002-04-26 Seth Nickell + + * Makefile.am: + * gnome-font-and-theme-properties.c: + * gnome-font-and-theme-properties.glade: + * gtk-theme-selector.glade: + * main.c: + * theme-properties.glade: + * theme-switcher.c: (create_dialog), (theme_selection_changed), + (read_themes), (theme_key_changed), (theme_changed_func), + (sort_func), (setup_dialog), (main): + + Move the font code into a seperate capplet. + Thu Apr 18 19:35:42 2002 Jonathan Blandford * gnome-font-and-theme-properties.c (setup_dialog): handle new diff --git a/capplets/theme-switcher/Makefile.am b/capplets/theme-switcher/Makefile.am index 7a79e71e1..3c6e994c8 100644 --- a/capplets/theme-switcher/Makefile.am +++ b/capplets/theme-switcher/Makefile.am @@ -1,9 +1,9 @@ -bin_PROGRAMS = gnome-font-and-theme-properties +bin_PROGRAMS = gnome-theme-properties -gnome_font_and_theme_properties_LDADD = $(GNOMECC_CAPPLETS_LIBS) -gnome_font_and_theme_properties_SOURCES = \ - gnome-font-and-theme-properties.c -gnome_font_and_theme_properties_LDFLAGS = -export-dynamic +gnome_theme_properties_LDADD = $(GNOMECC_CAPPLETS_LIBS) +gnome_theme_properties_SOURCES = \ + theme-switcher.c +gnome_theme_properties_LDFLAGS = -export-dynamic @INTLTOOL_DESKTOP_RULE@ @@ -12,7 +12,7 @@ Desktop_in_files = gtk-theme-selector.desktop.in desktop_DATA = $(Desktop_in_files:.desktop.in=.desktop) gladedir = $(GNOMECC_GLADE_DIR) -glade_DATA = gnome-font-and-theme-properties.glade +glade_DATA = theme-properties.glade INCLUDES = \ $(GNOMECC_CAPPLETS_CFLAGS) \ diff --git a/capplets/theme-switcher/gnome-font-and-theme-properties.glade b/capplets/theme-switcher/gnome-font-and-theme-properties.glade deleted file mode 100644 index 854c611f6..000000000 --- a/capplets/theme-switcher/gnome-font-and-theme-properties.glade +++ /dev/null @@ -1,320 +0,0 @@ - - - - - - - - True - Font and Theme Properties - GTK_WINDOW_TOPLEVEL - GTK_WIN_POS_NONE - False - True - False - False - - - - 2 - True - False - 0 - - - - 5 - True - GTK_BUTTONBOX_END - 10 - - - - True - True - True - gtk-help - True - GTK_RELIEF_NORMAL - -11 - - - - - - True - True - True - gtk-close - True - GTK_RELIEF_NORMAL - -7 - - - - - 0 - False - True - GTK_PACK_END - - - - - - True - True - True - True - GTK_POS_TOP - False - 2 - 2 - False - - - - 8 - True - False - 8 - - - - - - - - True - False - 0 - - - - True - Available themes - 0 - GTK_SHADOW_ETCHED_IN - - - - 4 - True - False - 4 - - - - - - - - True - True - GTK_POLICY_ALWAYS - GTK_POLICY_ALWAYS - GTK_SHADOW_ETCHED_IN - GTK_CORNER_TOP_LEFT - - - - True - True - False - True - False - True - - - - - 0 - True - True - - - - - - - - - - - 0 - True - True - - - - - - - - - 0 - True - True - - - - - - - - - False - True - - - - - - True - Themes - False - False - GTK_JUSTIFY_LEFT - False - False - 0.5 - 0.5 - 0 - 0 - - - tab - - - - - - 4 - True - 3 - 2 - False - 4 - 4 - - - - True - Application - False - False - GTK_JUSTIFY_LEFT - False - False - 0.5 - 0.5 - 0 - 0 - - - 0 - 1 - 0 - 1 - fill - - - - - - - True - Desktop - False - False - GTK_JUSTIFY_LEFT - False - False - 0 - 0.5 - 0 - 0 - - - 0 - 1 - 1 - 2 - fill - - - - - - - True - True - GNOME_FONT_PICKER_MODE_FONT_INFO - True - True - 14 - - - 1 - 2 - 0 - 1 - fill - - - - - - True - True - GNOME_FONT_PICKER_MODE_FONT_INFO - True - True - 14 - - - 1 - 2 - 1 - 2 - fill - - - - - - False - True - - - - - - True - Fonts - False - False - GTK_JUSTIFY_LEFT - False - False - 0.5 - 0.5 - 0 - 0 - - - tab - - - - - 0 - True - True - - - - - - - diff --git a/capplets/theme-switcher/gtk-theme-selector.glade b/capplets/theme-switcher/gtk-theme-selector.glade deleted file mode 100644 index 3acbca764..000000000 --- a/capplets/theme-switcher/gtk-theme-selector.glade +++ /dev/null @@ -1,178 +0,0 @@ - - - - - - - - True - Gtk+ Theme - GTK_WINDOW_TOPLEVEL - GTK_WIN_POS_NONE - False - True - False - True - - - - - - 2 - False - 4 - - - - 5 - GTK_BUTTONBOX_END - 10 - - - - True - gtk-close - True - GTK_RELIEF_NORMAL - 2 - - - - - 0 - False - True - GTK_PACK_END - - - - - - True - 0 - GTK_SHADOW_ETCHED_IN - - - - 4 - True - False - 4 - - - - True - GTK_POLICY_AUTOMATIC - GTK_POLICY_AUTOMATIC - GTK_SHADOW_NONE - GTK_CORNER_TOP_LEFT - - - - True - False - False - False - True - - - - - 0 - True - True - - - - - - True - False - 4 - - - - - - - - - - - - True - Install new theme... - True - GTK_RELIEF_NORMAL - - - - 0 - False - True - - - - - 0 - False - True - - - - - - - 0 - True - True - - - - - - True - 0 - GTK_SHADOW_ETCHED_IN - - - - 4 - True - False - 0 - - - - True - 0 - GTK_SHADOW_ETCHED_IN - - - - True - OAFIID:GNOME_Theme_Preview - - - - - - 0 - True - True - - - - - - - 0 - True - True - - - - - - - diff --git a/capplets/theme-switcher/main.c b/capplets/theme-switcher/main.c deleted file mode 100644 index d8b46c67a..000000000 --- a/capplets/theme-switcher/main.c +++ /dev/null @@ -1,255 +0,0 @@ -#include - -#include -#include -#include -#include - -#include -#include -#include - -static GladeXML *xml; -static gchar** themes = NULL; -static GtkListStore *model; -static gboolean ignore_select = FALSE; - -enum -{ - RESPONSE_APPLY = 1, - RESPONSE_CLOSE -}; - -static void -themes_list_add_dir (GArray *arr, const char *dirname) -{ - DIR *dir; - struct dirent *de; - const gchar *suffix = "gtk-2.0"; - - g_return_if_fail (arr != NULL); - g_return_if_fail (dirname != NULL); - - dir = opendir (dirname); - if (!dir) - return; - - while ((de = readdir (dir))) - { - char *tmp; - - if (de->d_name[0] == '.') - continue; - - tmp = g_build_filename (dirname, de->d_name, suffix, NULL); - if (!g_file_test (tmp, G_FILE_TEST_IS_DIR)) - { - g_free (tmp); - continue; - } - g_free (tmp); - - tmp = g_build_filename (dirname, de->d_name, NULL); - g_array_append_val (arr, tmp); - } - - closedir (dir); -} - -static void -themes_list_refresh (void) -{ - GArray *arr; - gchar *dir; - gchar *def; - int i; - GtkTreeSelection *sel = gtk_tree_view_get_selection (GTK_TREE_VIEW (glade_xml_get_widget (xml, "tree1"))); - - if (themes) - g_strfreev (themes); - - arr = g_array_new (TRUE, TRUE, sizeof (gchar*)); - - dir = g_build_filename (g_get_home_dir (), ".themes", NULL); - themes_list_add_dir (arr, dir); - g_free (dir); - - dir = gtk_rc_get_theme_dir (); - themes_list_add_dir (arr, dir); - g_free (dir); - - themes = (gchar**) arr->data; - g_array_free (arr, FALSE); - - def = gconf_client_get_string (gconf_client_get_default (), "/desktop/gnome/interface/gtk_theme", NULL); - - gtk_list_store_clear (model); - for (i = 0; themes[i] != NULL; i++) - { - GtkTreeIter iter; - gchar *basename; - basename = g_path_get_basename (themes[i]); - gtk_list_store_append (model, &iter); - gtk_list_store_set (model, &iter, 0, basename, -1); - if (def && !strcmp (def, basename)) - { - ignore_select = TRUE; - gtk_tree_selection_select_iter (sel, &iter); - ignore_select = FALSE; - } - g_free (basename); - } -} - -static void -select_foreach_cb (GtkTreeModel *model, GtkTreePath *path, - GtkTreeIter *iter, int *index) -{ - int *inds = gtk_tree_path_get_indices (path); - *index = *inds; -} - -#if 0 -static gchar* get_selected_theme (void) -{ - int index = -1; - gchar *theme; - GtkTreeView *view = GTK_TREE_VIEW (glade_xml_get_widget (xml, "tree1")); - - gtk_tree_selection_selected_foreach (gtk_tree_view_get_selection (view), (GtkTreeSelectionForeachFunc) select_foreach_cb, &index); - - if (index == -1) - return NULL; - - theme = g_build_filename (themes[index], "gtk-2.0", "gtkrc", NULL); - return theme; -} -#endif - -static gchar* get_selected_theme_name (void) -{ - int index = -1; - GtkTreeView *view = GTK_TREE_VIEW (glade_xml_get_widget (xml, "tree1")); - - gtk_tree_selection_selected_foreach (gtk_tree_view_get_selection (view), (GtkTreeSelectionForeachFunc) select_foreach_cb, &index); - - if (index == -1) - return NULL; - - return g_path_get_basename (themes[index]); -} - -static void -apply_cb (void) -{ - gchar *name = get_selected_theme_name (); - if (name) - { - gconf_client_set_string (gconf_client_get_default (), "/desktop/gnome/interface/gtk_theme", name, NULL); - g_free (name); - } -} - -void -response_cb (GtkDialog *dialog, gint r, gpointer data) -{ - switch (r) - { - case RESPONSE_CLOSE: - gtk_main_quit (); - break; - } -} - -static void -select_cb (GtkTreeSelection *sel, GtkButton *b) -{ -#if 0 - GtkWidget *control; - gchar *theme; - - theme = get_selected_theme (); - if (!theme) - return; - - control = glade_xml_get_widget (xml, "control1"); - bonobo_widget_set_property (BONOBO_WIDGET (control), - "theme", TC_CORBA_string, - theme, NULL); - g_free (theme); -#endif - if (!ignore_select) - apply_cb (); -} - -static void -fsel_ok_cb (GtkButton *b, GtkFileSelection *sel) -{ - const gchar *filename = gtk_file_selection_get_filename (sel); - gchar *command; - gchar *todir; - - if (!filename) - return; - - todir = g_build_filename (g_get_home_dir (), ".themes", NULL); - if (!g_file_test (todir, G_FILE_TEST_IS_DIR)) - mkdir (todir, S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH); - - command = g_strdup_printf ("gzip -d -c < \"%s\" | tar xf - -C \"%s\"", filename, todir); - system (command); - g_free (command); - g_free (todir); - gtk_widget_destroy (GTK_WIDGET (sel)); - - themes_list_refresh (); -} - -void -install_cb (GtkButton *b, gpointer data) -{ - GtkFileSelection *sel = GTK_FILE_SELECTION (gtk_file_selection_new (_("Select a theme to install"))); - g_signal_connect (G_OBJECT (sel->ok_button), "clicked", (GCallback) fsel_ok_cb, sel); - g_signal_connect_swapped (G_OBJECT (sel->cancel_button), "clicked", (GCallback) gtk_widget_destroy, sel); - gtk_widget_show_all (GTK_WIDGET (sel)); -} - -static void -setup_list (void) -{ - GtkTreeView *view; - GtkCellRenderer *cell; - GtkTreeSelection *sel; - - model = gtk_list_store_new (1, G_TYPE_STRING); - - view = GTK_TREE_VIEW (glade_xml_get_widget (xml, "tree1")); - g_object_set (G_OBJECT (view), "model", model, NULL); - cell = gtk_cell_renderer_text_new (); - gtk_tree_view_insert_column_with_attributes (view, -1, "", cell, "text", 0, NULL); - - themes_list_refresh (); - - sel = gtk_tree_view_get_selection (view); - g_signal_connect (G_OBJECT (sel), "changed", (GCallback) select_cb, NULL); -} - -int -main (int argc, char **argv) -{ - bindtextdomain (GETTEXT_PACKAGE, GNOMELOCALEDIR); - bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8"); - textdomain (GETTEXT_PACKAGE); - - gnome_program_init ("gtk-theme-selector", VERSION, - LIBGNOMEUI_MODULE, argc, argv, NULL); - - xml = glade_xml_new (GNOMECC_DATA_DIR "/interfaces/gtk-theme-selector.glade", NULL, NULL); - setup_list (); - - glade_xml_signal_autoconnect (xml); - gtk_main (); - - return 0; -} - diff --git a/capplets/theme-switcher/theme-properties.glade b/capplets/theme-switcher/theme-properties.glade new file mode 100644 index 000000000..3d2a1d240 --- /dev/null +++ b/capplets/theme-switcher/theme-properties.glade @@ -0,0 +1,134 @@ + + + + + + + True + Theme Properties + GTK_WINDOW_TOPLEVEL + GTK_WIN_POS_NONE + False + True + False + False + + + + 2 + True + False + 0 + + + + 5 + True + GTK_BUTTONBOX_END + 10 + + + + True + True + True + gtk-help + True + GTK_RELIEF_NORMAL + -11 + + + + + + True + True + True + gtk-close + True + GTK_RELIEF_NORMAL + -7 + + + + + 0 + False + True + GTK_PACK_END + + + + + + True + 0 + 0.5 + GTK_SHADOW_ETCHED_IN + + + + 4 + True + False + 4 + + + + True + True + GTK_POLICY_ALWAYS + GTK_POLICY_ALWAYS + GTK_SHADOW_ETCHED_IN + GTK_CORNER_TOP_LEFT + + + + True + True + False + True + False + True + + + + + 0 + True + True + + + + + + + + True + Available themes + False + False + GTK_JUSTIFY_LEFT + False + False + 0.5 + 0.5 + 0 + 0 + + + label_item + + + + + 0 + True + True + + + + + + + diff --git a/capplets/theme-switcher/gnome-font-and-theme-properties.c b/capplets/theme-switcher/theme-switcher.c similarity index 89% rename from capplets/theme-switcher/gnome-font-and-theme-properties.c rename to capplets/theme-switcher/theme-switcher.c index dbdbc52b0..f17cd60b9 100644 --- a/capplets/theme-switcher/gnome-font-and-theme-properties.c +++ b/capplets/theme-switcher/theme-switcher.c @@ -15,9 +15,6 @@ #include "gconf-property-editor.h" #define GTK_THEME_KEY "/desktop/gnome/interface/gtk_theme" -#define GTK_FONT_KEY "/desktop/gnome/interface/font_name" -#define DESKTOP_FONT_NAME_KEY "/apps/nautilus/preferences/default_font" -#define DESKTOP_FONT_SIZE_KEY "/apps/nautilus/preferences/default_font_size" #define MAX_ELEMENTS_BEFORE_SCROLLING 8 @@ -35,7 +32,7 @@ create_dialog (void) { GladeXML *dialog; - dialog = glade_xml_new (GLADEDIR "/gnome-font-and-theme-properties.glade", "font_and_theme_dialog", NULL); + dialog = glade_xml_new (GLADEDIR "/theme-properties.glade", "theme_dialog", NULL); return dialog; } @@ -208,7 +205,6 @@ setup_dialog (GladeXML *dialog) GtkWidget *widget; GtkTreeModel *model; GtkTreeSelection *selection; - GObject *peditor; client = gconf_client_get_default (); @@ -234,19 +230,7 @@ setup_dialog (GladeXML *dialog) read_themes (dialog); theme_common_register_theme_change (theme_changed_func, dialog); - peditor = gconf_peditor_new_font (NULL, GTK_FONT_KEY, - WID ("application_font"), - PEDITOR_FONT_COMBINED, NULL); - - peditor = gconf_peditor_new_font (NULL, DESKTOP_FONT_NAME_KEY, - WID ("desktop_font"), - PEDITOR_FONT_NAME, NULL); - - peditor = gconf_peditor_new_font (NULL, DESKTOP_FONT_SIZE_KEY, - WID ("desktop_font"), - PEDITOR_FONT_SIZE, NULL); - - widget = WID ("font_and_theme_dialog"); + widget = WID ("theme_dialog"); gtk_widget_show (widget); g_signal_connect (G_OBJECT (widget), "response", gtk_main_quit, NULL);