reduce the number if XCURSOR ifdefs and get rid of the special treatment

2007-10-27  Jens Granseuer  <jensgr@gmx.net>

	* appearance-style.c: (cursor_size_scale_value_changed_cb),
	(update_cursor_size_scale), (cursor_theme_changed), (prepare_list):
	* appearance-themes.c: (theme_load_from_gconf):
	* theme-util.h: reduce the number if XCURSOR ifdefs and get rid of the
	special treatment for the default cursor theme

2007-10-27  Jens Granseuer  <jensgr@gmx.net>

	* gnome-theme-info.c: (look_for_cursor_theme), (read_cursor_fonts),
	(gnome_theme_init): ensure we always have the "default" cursor theme in
	the list

svn path=/trunk/; revision=8214
This commit is contained in:
Jens Granseuer 2007-10-27 13:59:36 +00:00 committed by Jens Granseuer
parent 298d6fbf4f
commit dbd00f0edd
6 changed files with 53 additions and 50 deletions

View file

@ -1,3 +1,11 @@
2007-10-27 Jens Granseuer <jensgr@gmx.net>
* appearance-style.c: (cursor_size_scale_value_changed_cb),
(update_cursor_size_scale), (cursor_theme_changed), (prepare_list):
* appearance-themes.c: (theme_load_from_gconf):
* theme-util.h: reduce the number if XCURSOR ifdefs and get rid of the
special treatment for the default cursor theme
2007-10-27 Jens Granseuer <jensgr@gmx.net> 2007-10-27 Jens Granseuer <jensgr@gmx.net>
If the cursor theme changes, and the currently set size is not If the cursor theme changes, and the currently set size is not

View file

@ -370,10 +370,33 @@ cursor_size_changed_cb (int size, AppearanceData *data)
gconf_client_set_int (data->client, CURSOR_SIZE_KEY, size, NULL); gconf_client_set_int (data->client, CURSOR_SIZE_KEY, size, NULL);
} }
static void
cursor_size_scale_value_changed_cb (GtkRange *range, AppearanceData *data)
{
GnomeThemeCursorInfo *theme;
gchar *name;
name = gconf_client_get_string (data->client, CURSOR_THEME_KEY, NULL);
if (name == NULL)
return;
theme = gnome_theme_cursor_info_find (name);
g_free (name);
if (theme) {
gint size;
size = g_array_index (theme->sizes, gint, (int) gtk_range_get_value (range));
cursor_size_changed_cb (size, data);
}
}
#endif
static void static void
update_cursor_size_scale (GnomeThemeCursorInfo *theme, update_cursor_size_scale (GnomeThemeCursorInfo *theme,
AppearanceData *data) AppearanceData *data)
{ {
#ifdef HAVE_XCURSOR
GtkWidget *cursor_size_scale; GtkWidget *cursor_size_scale;
GtkWidget *cursor_size_label; GtkWidget *cursor_size_label;
GtkWidget *cursor_size_small_label; GtkWidget *cursor_size_small_label;
@ -441,8 +464,8 @@ update_cursor_size_scale (GnomeThemeCursorInfo *theme,
if (size != gconf_size) if (size != gconf_size)
cursor_size_changed_cb (size, data); cursor_size_changed_cb (size, data);
}
#endif #endif
}
static void static void
cursor_theme_changed (GConfPropertyEditor *peditor, cursor_theme_changed (GConfPropertyEditor *peditor,
@ -456,9 +479,7 @@ cursor_theme_changed (GConfPropertyEditor *peditor,
if (value && (name = gconf_value_get_string (value))) if (value && (name = gconf_value_get_string (value)))
theme = gnome_theme_cursor_info_find (name); theme = gnome_theme_cursor_info_find (name);
#ifdef HAVE_XCURSOR
update_cursor_size_scale (theme, data); update_cursor_size_scale (theme, data);
#endif
gtk_widget_set_sensitive (glade_xml_get_widget (data->xml, "cursor_themes_delete"), gtk_widget_set_sensitive (glade_xml_get_widget (data->xml, "cursor_themes_delete"),
theme_is_writable (theme, THEME_TYPE_CURSOR)); theme_is_writable (theme, THEME_TYPE_CURSOR));
@ -526,29 +547,6 @@ cursor_theme_delete_cb (GtkWidget *button, AppearanceData *data)
generic_theme_delete ("cursor_themes_list", THEME_TYPE_CURSOR, data); generic_theme_delete ("cursor_themes_list", THEME_TYPE_CURSOR, data);
} }
#ifdef HAVE_XCURSOR
static void
cursor_size_scale_value_changed_cb (GtkRange *range, AppearanceData *data)
{
GnomeThemeCursorInfo *theme;
gchar *name;
name = gconf_client_get_string (data->client, CURSOR_THEME_KEY, NULL);
if (name == NULL)
return;
theme = gnome_theme_cursor_info_find (name);
g_free (name);
if (theme) {
gint size;
size = g_array_index (theme->sizes, gint, (int) gtk_range_get_value (range));
cursor_size_changed_cb (size, data);
}
}
#endif
static void static void
add_to_treeview (const gchar *tv_name, add_to_treeview (const gchar *tv_name,
const gchar *theme_name, const gchar *theme_name,
@ -762,11 +760,7 @@ prepare_list (AppearanceData *data, GtkWidget *list, ThemeType type, GCallback c
case THEME_TYPE_CURSOR: case THEME_TYPE_CURSOR:
themes = gnome_theme_cursor_info_find_all (); themes = gnome_theme_cursor_info_find_all ();
thumbnail = NULL; thumbnail = NULL;
#ifdef HAVE_XCURSOR
key = CURSOR_THEME_KEY; key = CURSOR_THEME_KEY;
#else
key = CURSOR_FONT_KEY;
#endif
generator = NULL; generator = NULL;
thumb_cb = NULL; thumb_cb = NULL;
break; break;
@ -816,17 +810,6 @@ prepare_list (AppearanceData *data, GtkWidget *list, ThemeType type, GCallback c
} }
g_list_free (themes); g_list_free (themes);
#ifdef HAVE_XCURSOR
if (type == THEME_TYPE_CURSOR && !gnome_theme_cursor_info_find ("default")) {
GtkTreeIter i;
gtk_list_store_insert_with_values (store, &i, 0,
COL_LABEL, _("Default Pointer"),
COL_NAME, "default",
COL_THUMBNAIL, NULL,
-1);
}
#endif
sort_model = gtk_tree_model_sort_new_with_model (GTK_TREE_MODEL (store)); sort_model = gtk_tree_model_sort_new_with_model (GTK_TREE_MODEL (store));
gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (sort_model), gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (sort_model),
COL_LABEL, GTK_SORT_ASCENDING); COL_LABEL, GTK_SORT_ASCENDING);

View file

@ -245,11 +245,9 @@ theme_load_from_gconf (GConfClient *client)
if (theme->icon_theme_name == NULL) if (theme->icon_theme_name == NULL)
theme->icon_theme_name = g_strdup ("gnome"); theme->icon_theme_name = g_strdup ("gnome");
#ifdef HAVE_XCURSOR
theme->cursor_theme_name = gconf_client_get_string (client, CURSOR_THEME_KEY, NULL); theme->cursor_theme_name = gconf_client_get_string (client, CURSOR_THEME_KEY, NULL);
#ifdef HAVE_XCURSOR
theme->cursor_size = gconf_client_get_int (client, CURSOR_SIZE_KEY, NULL); theme->cursor_size = gconf_client_get_int (client, CURSOR_SIZE_KEY, NULL);
#else
theme->cursor_theme_name = gconf_client_get_string (client, CURSOR_FONT_KEY, NULL);
#endif #endif
if (theme->cursor_theme_name == NULL) if (theme->cursor_theme_name == NULL)
theme->cursor_theme_name = g_strdup ("default"); theme->cursor_theme_name = g_strdup ("default");

View file

@ -22,15 +22,19 @@
#define METACITY_THEME_KEY "/apps/metacity/general/theme" #define METACITY_THEME_KEY "/apps/metacity/general/theme"
#define ICON_THEME_KEY "/desktop/gnome/interface/icon_theme" #define ICON_THEME_KEY "/desktop/gnome/interface/icon_theme"
#define COLOR_SCHEME_KEY "/desktop/gnome/interface/gtk_color_scheme" #define COLOR_SCHEME_KEY "/desktop/gnome/interface/gtk_color_scheme"
#define CURSOR_FONT_KEY "/desktop/gnome/peripherals/mouse/cursor_font"
#define CURSOR_THEME_KEY "/desktop/gnome/peripherals/mouse/cursor_theme"
#define CURSOR_SIZE_KEY "/desktop/gnome/peripherals/mouse/cursor_size"
#define LOCKDOWN_KEY "/desktop/gnome/lockdown/disable_theme_settings" #define LOCKDOWN_KEY "/desktop/gnome/lockdown/disable_theme_settings"
#define BACKGROUND_KEY "/desktop/gnome/background/picture_filename" #define BACKGROUND_KEY "/desktop/gnome/background/picture_filename"
#define APPLICATION_FONT_KEY "/desktop/gnome/interface/font_name" #define APPLICATION_FONT_KEY "/desktop/gnome/interface/font_name"
#define DESKTOP_FONT_KEY "/apps/nautilus/preferences/desktop_font" #define DESKTOP_FONT_KEY "/apps/nautilus/preferences/desktop_font"
#define MONOSPACE_FONT_KEY "/desktop/gnome/interface/monospace_font_name" #define MONOSPACE_FONT_KEY "/desktop/gnome/interface/monospace_font_name"
#ifdef HAVE_XCURSOR
# define CURSOR_THEME_KEY "/desktop/gnome/peripherals/mouse/cursor_theme"
# define CURSOR_SIZE_KEY "/desktop/gnome/peripherals/mouse/cursor_size"
#else
# define CURSOR_THEME_KEY "/desktop/gnome/peripherals/mouse/cursor_font"
#endif
enum { enum {
COL_THUMBNAIL, COL_THUMBNAIL,
COL_LABEL, COL_LABEL,

View file

@ -1,3 +1,9 @@
2007-10-27 Jens Granseuer <jensgr@gmx.net>
* gnome-theme-info.c: (look_for_cursor_theme), (read_cursor_fonts),
(gnome_theme_init): ensure we always have the "default" cursor theme in
the list
2007-10-27 Jens Granseuer <jensgr@gmx.net> 2007-10-27 Jens Granseuer <jensgr@gmx.net>
* gnome-theme-info.c (gnome_theme_is_writable): * gnome-theme-info.c (gnome_theme_is_writable):

View file

@ -1085,7 +1085,7 @@ look_for_cursor_theme (const gchar *theme_dir)
{ {
gchar *cursors_dir = g_build_filename (theme_dir, "cursors", NULL); gchar *cursors_dir = g_build_filename (theme_dir, "cursors", NULL);
if (g_file_test (cursors_dir, G_FILE_TEST_IS_DIR) || g_str_has_suffix (theme_dir, "default")) if (g_file_test (cursors_dir, G_FILE_TEST_IS_DIR))
read_cursor_theme (theme_dir); read_cursor_theme (theme_dir);
g_free (cursors_dir); g_free (cursors_dir);
@ -1801,7 +1801,7 @@ read_cursor_fonts (void)
theme_info = gnome_theme_cursor_info_new (); theme_info = gnome_theme_cursor_info_new ();
filename = g_build_filename (GNOMECC_DATA_DIR "/pixmaps", builtins[i][3], NULL); filename = g_build_filename (GNOMECC_DATA_DIR, "pixmaps", builtins[i][3], NULL);
theme_info->thumbnail = gdk_pixbuf_new_from_file (filename, NULL); theme_info->thumbnail = gdk_pixbuf_new_from_file (filename, NULL);
g_free (filename); g_free (filename);
@ -1980,7 +1980,11 @@ gnome_theme_init (gboolean *monitor_not_added)
result = add_top_icon_theme_dir_monitor (top_theme_dir_uri, &real_monitor_not_added, 0, NULL); result = add_top_icon_theme_dir_monitor (top_theme_dir_uri, &real_monitor_not_added, 0, NULL);
gnome_vfs_uri_unref (top_theme_dir_uri); gnome_vfs_uri_unref (top_theme_dir_uri);
#ifndef HAVE_XCURSOR #ifdef HAVE_XCURSOR
/* make sure we have the default theme */
if (!gnome_theme_cursor_info_find ("default"))
read_cursor_theme ("default");
#else
/* If we don't have Xcursor, use the built-in cursor fonts instead */ /* If we don't have Xcursor, use the built-in cursor fonts instead */
read_cursor_fonts (); read_cursor_fonts ();
#endif #endif