Adjusted for the API changes in theme-thumbnail.c. Thumbnail requestes are
2007-06-25 Denis Washington <denisw@svn.gnome.org> * appearance-themes.c: Adjusted for the API changes in theme-thumbnail.c. Thumbnail requestes are now directly queued by generate_*_async(), so do not maintain an own queue anymore. * appearance-style.c: Use the new asynchronous thumbnail generation functions, and replace all occurrences of "metacity_themes_list" with the correct "window_themes_list". * appearance.h: Remove "theme_queue", it is not needed anymore. svn path=/trunk/; revision=7776
This commit is contained in:
parent
443068f132
commit
304ee0d357
4 changed files with 89 additions and 47 deletions
|
@ -1,3 +1,17 @@
|
||||||
|
2007-06-25 Denis Washington <denisw@svn.gnome.org>
|
||||||
|
|
||||||
|
* appearance-themes.c:
|
||||||
|
Adjusted for the API changes in theme-thumbnail.c. Thumbnail requestes are
|
||||||
|
now directly queued by generate_*_async(), so do not maintain an own queue
|
||||||
|
anymore.
|
||||||
|
|
||||||
|
* appearance-style.c:
|
||||||
|
Use the new asynchronous thumbnail generation functions, and replace all
|
||||||
|
occurrences of "metacity_themes_list" with the correct "window_themes_list".
|
||||||
|
|
||||||
|
* appearance.h:
|
||||||
|
Remove "theme_queue", it is not needed anymore.
|
||||||
|
|
||||||
2007-06-24 Jens Granseuer <jensgr@gmx.net>
|
2007-06-24 Jens Granseuer <jensgr@gmx.net>
|
||||||
|
|
||||||
* Makefile.am:
|
* Makefile.am:
|
||||||
|
|
|
@ -494,6 +494,28 @@ update_in_treeview (const gchar *tv_name,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
update_thumbnail_in_treeview (const gchar *tv_name,
|
||||||
|
const gchar *theme_name,
|
||||||
|
GdkPixbuf *theme_thumbnail,
|
||||||
|
AppearanceData *data)
|
||||||
|
{
|
||||||
|
GtkTreeView *treeview;
|
||||||
|
GtkListStore *model;
|
||||||
|
GtkTreeIter iter;
|
||||||
|
|
||||||
|
treeview = GTK_TREE_VIEW (glade_xml_get_widget (data->xml, tv_name));
|
||||||
|
model = GTK_LIST_STORE (
|
||||||
|
gtk_tree_model_sort_get_model (
|
||||||
|
GTK_TREE_MODEL_SORT (gtk_tree_view_get_model (treeview))));
|
||||||
|
|
||||||
|
if (theme_find_in_model (GTK_TREE_MODEL (model), theme_name, &iter)) {
|
||||||
|
gtk_list_store_set (model, &iter,
|
||||||
|
COL_THUMBNAIL, theme_thumbnail,
|
||||||
|
-1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
changed_on_disk_cb (GnomeThemeType type,
|
changed_on_disk_cb (GnomeThemeType type,
|
||||||
gpointer theme,
|
gpointer theme,
|
||||||
|
@ -508,7 +530,7 @@ changed_on_disk_cb (GnomeThemeType type,
|
||||||
if (info->has_gtk)
|
if (info->has_gtk)
|
||||||
remove_from_treeview ("gtk_themes_list", info->name, data);
|
remove_from_treeview ("gtk_themes_list", info->name, data);
|
||||||
if (info->has_metacity)
|
if (info->has_metacity)
|
||||||
remove_from_treeview ("metacity_themes_list", info->name, data);
|
remove_from_treeview ("window_themes_list", info->name, data);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
GdkPixbuf *thumbnail;
|
GdkPixbuf *thumbnail;
|
||||||
|
@ -529,9 +551,9 @@ changed_on_disk_cb (GnomeThemeType type,
|
||||||
thumbnail = generate_metacity_theme_thumbnail (info);
|
thumbnail = generate_metacity_theme_thumbnail (info);
|
||||||
|
|
||||||
if (change_type == GNOME_THEME_CHANGE_CREATED)
|
if (change_type == GNOME_THEME_CHANGE_CREATED)
|
||||||
add_to_treeview ("metacity_themes_list", info->name, info->name, thumbnail, data);
|
add_to_treeview ("window_themes_list", info->name, info->name, thumbnail, data);
|
||||||
else if (change_type == GNOME_THEME_CHANGE_CHANGED)
|
else if (change_type == GNOME_THEME_CHANGE_CHANGED)
|
||||||
update_in_treeview ("metacity_themes_list", info->name, info->name, thumbnail, data);
|
update_in_treeview ("window_themes_list", info->name, info->name, thumbnail, data);
|
||||||
|
|
||||||
if (thumbnail)
|
if (thumbnail)
|
||||||
g_object_unref (thumbnail);
|
g_object_unref (thumbnail);
|
||||||
|
@ -557,6 +579,30 @@ changed_on_disk_cb (GnomeThemeType type,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
gtk_theme_thumbnail_cb (GdkPixbuf *pixbuf,
|
||||||
|
gchar *theme_name,
|
||||||
|
AppearanceData *data)
|
||||||
|
{
|
||||||
|
update_thumbnail_in_treeview ("gtk_themes_list", theme_name, pixbuf, data);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
metacity_theme_thumbnail_cb (GdkPixbuf *pixbuf,
|
||||||
|
gchar *theme_name,
|
||||||
|
AppearanceData *data)
|
||||||
|
{
|
||||||
|
update_thumbnail_in_treeview ("window_themes_list", theme_name, pixbuf, data);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
icon_theme_thumbnail_cb (GdkPixbuf *pixbuf,
|
||||||
|
gchar *theme_name,
|
||||||
|
AppearanceData *data)
|
||||||
|
{
|
||||||
|
update_thumbnail_in_treeview ("icon_themes_list", theme_name, pixbuf, data);
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
prepare_list (AppearanceData *data, GtkWidget *list, ThemeType type, GCallback callback)
|
prepare_list (AppearanceData *data, GtkWidget *list, ThemeType type, GCallback callback)
|
||||||
{
|
{
|
||||||
|
@ -617,15 +663,24 @@ prepare_list (AppearanceData *data, GtkWidget *list, ThemeType type, GCallback c
|
||||||
switch (type)
|
switch (type)
|
||||||
{
|
{
|
||||||
case THEME_TYPE_GTK:
|
case THEME_TYPE_GTK:
|
||||||
thumbnail = generate_gtk_theme_thumbnail ((GnomeThemeInfo *) l->data);
|
generate_gtk_theme_thumbnail_async ((GnomeThemeInfo *) l->data,
|
||||||
|
(ThemeThumbnailFunc) gtk_theme_thumbnail_cb,
|
||||||
|
data,
|
||||||
|
NULL);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case THEME_TYPE_ICON:
|
case THEME_TYPE_ICON:
|
||||||
thumbnail = generate_icon_theme_thumbnail ((GnomeThemeIconInfo *) l->data);
|
generate_icon_theme_thumbnail_async ((GnomeThemeIconInfo *) l->data,
|
||||||
|
(ThemeThumbnailFunc) icon_theme_thumbnail_cb,
|
||||||
|
data,
|
||||||
|
NULL);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case THEME_TYPE_WINDOW:
|
case THEME_TYPE_WINDOW:
|
||||||
thumbnail = generate_metacity_theme_thumbnail ((GnomeThemeInfo *) l->data);
|
generate_metacity_theme_thumbnail_async ((GnomeThemeInfo *) l->data,
|
||||||
|
(ThemeThumbnailFunc) metacity_theme_thumbnail_cb,
|
||||||
|
data,
|
||||||
|
NULL);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
@ -686,8 +741,8 @@ style_init (AppearanceData *data)
|
||||||
g_signal_connect (w, "response", (GCallback) style_response_cb, NULL);
|
g_signal_connect (w, "response", (GCallback) style_response_cb, NULL);
|
||||||
g_signal_connect (w, "delete_event", (GCallback) gtk_true, NULL);
|
g_signal_connect (w, "delete_event", (GCallback) gtk_true, NULL);
|
||||||
|
|
||||||
prepare_list (data, glade_xml_get_widget (data->xml, "gtk_themes_list"), THEME_TYPE_GTK, (GCallback) gtk_theme_changed);
|
|
||||||
prepare_list (data, glade_xml_get_widget (data->xml, "window_themes_list"), THEME_TYPE_WINDOW, (GCallback) window_theme_changed);
|
prepare_list (data, glade_xml_get_widget (data->xml, "window_themes_list"), THEME_TYPE_WINDOW, (GCallback) window_theme_changed);
|
||||||
|
prepare_list (data, glade_xml_get_widget (data->xml, "gtk_themes_list"), THEME_TYPE_GTK, (GCallback) gtk_theme_changed);
|
||||||
prepare_list (data, glade_xml_get_widget (data->xml, "icon_themes_list"), THEME_TYPE_ICON, (GCallback) icon_theme_changed);
|
prepare_list (data, glade_xml_get_widget (data->xml, "icon_themes_list"), THEME_TYPE_ICON, (GCallback) icon_theme_changed);
|
||||||
|
|
||||||
w = glade_xml_get_widget (data->xml, "color_scheme_message_hbox");
|
w = glade_xml_get_widget (data->xml, "color_scheme_message_hbox");
|
||||||
|
|
|
@ -30,7 +30,7 @@
|
||||||
|
|
||||||
#define CUSTOM_THEME_NAME "__custom__"
|
#define CUSTOM_THEME_NAME "__custom__"
|
||||||
|
|
||||||
static void theme_thumbnail_done_cb (GdkPixbuf *pixbuf, AppearanceData *data);
|
static void theme_thumbnail_done_cb (GdkPixbuf *pixbuf, gchar *theme_name, AppearanceData *data);
|
||||||
|
|
||||||
static gchar *
|
static gchar *
|
||||||
get_default_string_from_key (GConfClient *client, const char *key)
|
get_default_string_from_key (GConfClient *client, const char *key)
|
||||||
|
@ -86,23 +86,11 @@ theme_load_from_gconf (GConfClient *client, GnomeThemeMetaInfo *theme)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
|
||||||
theme_thumbnail_generate (AppearanceData *data)
|
|
||||||
{
|
|
||||||
generate_theme_thumbnail_async (data->theme_queue->data,
|
|
||||||
(ThemeThumbnailFunc) theme_thumbnail_done_cb, data, NULL);
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
theme_queue_for_thumbnail (GnomeThemeMetaInfo *theme, AppearanceData *data)
|
theme_thumbnail_generate (GnomeThemeMetaInfo *info, AppearanceData *data)
|
||||||
{
|
{
|
||||||
gboolean idle = (data->theme_queue == NULL);
|
generate_meta_theme_thumbnail_async (info,
|
||||||
|
(ThemeThumbnailFunc) theme_thumbnail_done_cb, data, NULL);
|
||||||
data->theme_queue = g_slist_append (data->theme_queue, theme);
|
|
||||||
|
|
||||||
if (idle)
|
|
||||||
theme_thumbnail_generate (data);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static gchar *
|
static gchar *
|
||||||
|
@ -252,7 +240,7 @@ theme_set_custom_from_theme (const GnomeThemeMetaInfo *info, AppearanceData *dat
|
||||||
gtk_tree_path_free (path);
|
gtk_tree_path_free (path);
|
||||||
|
|
||||||
/* update the theme thumbnail */
|
/* update the theme thumbnail */
|
||||||
theme_queue_for_thumbnail (custom, data);
|
theme_thumbnail_generate (custom, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Theme Callbacks **/
|
/** Theme Callbacks **/
|
||||||
|
@ -273,7 +261,7 @@ theme_changed_on_disk_cb (GnomeThemeType type,
|
||||||
COL_NAME, meta->name,
|
COL_NAME, meta->name,
|
||||||
COL_THUMBNAIL, data->theme_icon,
|
COL_THUMBNAIL, data->theme_icon,
|
||||||
-1);
|
-1);
|
||||||
theme_queue_for_thumbnail (meta, data);
|
theme_thumbnail_generate (meta, data);
|
||||||
|
|
||||||
} else if (change_type == GNOME_THEME_CHANGE_DELETED) {
|
} else if (change_type == GNOME_THEME_CHANGE_DELETED) {
|
||||||
GtkTreeIter iter;
|
GtkTreeIter iter;
|
||||||
|
@ -282,35 +270,24 @@ theme_changed_on_disk_cb (GnomeThemeType type,
|
||||||
gtk_list_store_remove (data->theme_store, &iter);
|
gtk_list_store_remove (data->theme_store, &iter);
|
||||||
|
|
||||||
} else if (change_type == GNOME_THEME_CHANGE_CHANGED) {
|
} else if (change_type == GNOME_THEME_CHANGE_CHANGED) {
|
||||||
theme_queue_for_thumbnail (meta, data);
|
theme_thumbnail_generate (meta, data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
theme_thumbnail_done_cb (GdkPixbuf *pixbuf, AppearanceData *data)
|
theme_thumbnail_done_cb (GdkPixbuf *pixbuf, gchar *theme_name, AppearanceData *data)
|
||||||
{
|
{
|
||||||
GnomeThemeMetaInfo *info = data->theme_queue->data;
|
|
||||||
|
|
||||||
g_return_if_fail (info != NULL);
|
|
||||||
|
|
||||||
/* find item in model and update thumbnail */
|
/* find item in model and update thumbnail */
|
||||||
if (pixbuf) {
|
if (pixbuf) {
|
||||||
GtkTreeIter iter;
|
GtkTreeIter iter;
|
||||||
GtkTreeModel *model = GTK_TREE_MODEL (data->theme_store);
|
GtkTreeModel *model = GTK_TREE_MODEL (data->theme_store);
|
||||||
|
|
||||||
if (theme_find_in_model (model, info->name, &iter))
|
if (theme_find_in_model (model, theme_name, &iter))
|
||||||
gtk_list_store_set (data->theme_store, &iter, COL_THUMBNAIL, pixbuf, -1);
|
gtk_list_store_set (data->theme_store, &iter, COL_THUMBNAIL, pixbuf, -1);
|
||||||
|
|
||||||
g_object_unref (pixbuf);
|
g_object_unref (pixbuf);
|
||||||
}
|
}
|
||||||
|
|
||||||
data->theme_queue = g_slist_remove (data->theme_queue, info);
|
|
||||||
|
|
||||||
if (data->theme_queue)
|
|
||||||
/* we can't call theme_thumbnail_generate directly since the thumbnail
|
|
||||||
* factory hasn't yet cleaned up at this point */
|
|
||||||
g_idle_add ((GSourceFunc) theme_thumbnail_generate, data);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** GUI Callbacks **/
|
/** GUI Callbacks **/
|
||||||
|
@ -503,7 +480,6 @@ themes_init (AppearanceData *data)
|
||||||
gnome_theme_init (NULL);
|
gnome_theme_init (NULL);
|
||||||
gnome_wm_manager_init ();
|
gnome_wm_manager_init ();
|
||||||
|
|
||||||
data->theme_queue = NULL;
|
|
||||||
data->theme_save_dialog = NULL;
|
data->theme_save_dialog = NULL;
|
||||||
data->theme_custom = gnome_theme_meta_info_new ();
|
data->theme_custom = gnome_theme_meta_info_new ();
|
||||||
data->theme_icon = gdk_pixbuf_new_from_file (GNOMECC_PIXMAP_DIR "/theme-thumbnailing.png", NULL);
|
data->theme_icon = gdk_pixbuf_new_from_file (GNOMECC_PIXMAP_DIR "/theme-thumbnailing.png", NULL);
|
||||||
|
@ -524,14 +500,14 @@ themes_init (AppearanceData *data)
|
||||||
for (l = theme_list; l; l = l->next) {
|
for (l = theme_list; l; l = l->next) {
|
||||||
GnomeThemeMetaInfo *info = l->data;
|
GnomeThemeMetaInfo *info = l->data;
|
||||||
|
|
||||||
data->theme_queue = g_slist_prepend (data->theme_queue, info);
|
|
||||||
|
|
||||||
gtk_list_store_insert_with_values (theme_store, NULL, 0,
|
gtk_list_store_insert_with_values (theme_store, NULL, 0,
|
||||||
COL_LABEL, info->readable_name,
|
COL_LABEL, info->readable_name,
|
||||||
COL_NAME, info->name,
|
COL_NAME, info->name,
|
||||||
COL_THUMBNAIL, data->theme_icon,
|
COL_THUMBNAIL, data->theme_icon,
|
||||||
-1);
|
-1);
|
||||||
|
|
||||||
|
theme_thumbnail_generate (info, data);
|
||||||
|
|
||||||
if (!meta_theme && theme_is_equal (data->theme_custom, info))
|
if (!meta_theme && theme_is_equal (data->theme_custom, info))
|
||||||
meta_theme = info;
|
meta_theme = info;
|
||||||
}
|
}
|
||||||
|
@ -540,13 +516,14 @@ themes_init (AppearanceData *data)
|
||||||
if (!meta_theme) {
|
if (!meta_theme) {
|
||||||
/* add custom theme */
|
/* add custom theme */
|
||||||
meta_theme = data->theme_custom;
|
meta_theme = data->theme_custom;
|
||||||
data->theme_queue = g_slist_prepend (data->theme_queue, meta_theme);
|
|
||||||
|
|
||||||
gtk_list_store_insert_with_values (theme_store, NULL, 0,
|
gtk_list_store_insert_with_values (theme_store, NULL, 0,
|
||||||
COL_LABEL, meta_theme->readable_name,
|
COL_LABEL, meta_theme->readable_name,
|
||||||
COL_NAME, meta_theme->name,
|
COL_NAME, meta_theme->name,
|
||||||
COL_THUMBNAIL, data->theme_icon,
|
COL_THUMBNAIL, data->theme_icon,
|
||||||
-1);
|
-1);
|
||||||
|
|
||||||
|
theme_thumbnail_generate (meta_theme, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
w = glade_xml_get_widget (data->xml, "theme_list");
|
w = glade_xml_get_widget (data->xml, "theme_list");
|
||||||
|
@ -571,15 +548,12 @@ themes_init (AppearanceData *data)
|
||||||
if (is_locked_down (data->client)) {
|
if (is_locked_down (data->client)) {
|
||||||
/* FIXME: determine what needs disabling */
|
/* FIXME: determine what needs disabling */
|
||||||
}
|
}
|
||||||
|
|
||||||
theme_thumbnail_generate (data);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
themes_shutdown (AppearanceData *data)
|
themes_shutdown (AppearanceData *data)
|
||||||
{
|
{
|
||||||
gnome_theme_meta_info_free (data->theme_custom);
|
gnome_theme_meta_info_free (data->theme_custom);
|
||||||
g_slist_free (data->theme_queue);
|
|
||||||
|
|
||||||
if (data->theme_icon)
|
if (data->theme_icon)
|
||||||
g_object_unref (data->theme_icon);
|
g_object_unref (data->theme_icon);
|
||||||
|
|
|
@ -53,7 +53,6 @@ typedef struct {
|
||||||
|
|
||||||
/* themes */
|
/* themes */
|
||||||
GtkListStore *theme_store;
|
GtkListStore *theme_store;
|
||||||
GSList *theme_queue;
|
|
||||||
GnomeThemeMetaInfo *theme_custom;
|
GnomeThemeMetaInfo *theme_custom;
|
||||||
GdkPixbuf *theme_icon;
|
GdkPixbuf *theme_icon;
|
||||||
GtkWidget *theme_save_dialog;
|
GtkWidget *theme_save_dialog;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue