2007-05-02 14:04:53 +00:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2007 The GNOME Foundation
|
2007-05-02 14:19:39 +00:00
|
|
|
* Written by Rodney Dawes <dobey@ximian.com>
|
|
|
|
* Denis Washington <denisw@svn.gnome.org>
|
2007-05-02 14:04:53 +00:00
|
|
|
* All Rights Reserved
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License along
|
|
|
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "appearance.h"
|
|
|
|
#include "gnome-wp-info.h"
|
|
|
|
#include "gnome-wp-item.h"
|
|
|
|
#include "gnome-wp-utils.h"
|
|
|
|
#include "gnome-wp-xml.h"
|
2007-05-10 16:31:18 +00:00
|
|
|
#include "wp-cellrenderer.h"
|
2007-05-02 14:04:53 +00:00
|
|
|
#include <glib/gi18n.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <gconf/gconf-client.h>
|
|
|
|
#include <libgnomeui/gnome-thumbnail.h>
|
|
|
|
|
|
|
|
typedef enum {
|
|
|
|
GNOME_WP_SHADE_TYPE_SOLID,
|
|
|
|
GNOME_WP_SHADE_TYPE_HORIZ,
|
|
|
|
GNOME_WP_SHADE_TYPE_VERT
|
|
|
|
} GnomeWPShadeType;
|
|
|
|
|
|
|
|
typedef enum {
|
|
|
|
GNOME_WP_SCALE_TYPE_CENTERED,
|
|
|
|
GNOME_WP_SCALE_TYPE_STRETCHED,
|
|
|
|
GNOME_WP_SCALE_TYPE_SCALED,
|
|
|
|
GNOME_WP_SCALE_TYPE_ZOOM,
|
|
|
|
GNOME_WP_SCALE_TYPE_TILED
|
|
|
|
} GnomeWPScaleType;
|
|
|
|
|
2007-05-02 15:26:07 +00:00
|
|
|
enum {
|
|
|
|
TARGET_URI_LIST,
|
2007-09-23 12:23:26 +00:00
|
|
|
TARGET_BGIMAGE
|
2007-05-02 15:26:07 +00:00
|
|
|
};
|
|
|
|
|
2007-09-23 12:23:26 +00:00
|
|
|
static const GtkTargetEntry drop_types[] = {
|
2007-05-02 15:26:07 +00:00
|
|
|
{"text/uri-list", 0, TARGET_URI_LIST},
|
2007-09-23 12:23:26 +00:00
|
|
|
{ "property/bgimage", 0, TARGET_BGIMAGE }
|
|
|
|
};
|
|
|
|
|
|
|
|
static const GtkTargetEntry drag_types[] = {
|
|
|
|
{"text/uri-list", GTK_TARGET_OTHER_WIDGET, TARGET_URI_LIST}
|
2007-05-02 15:26:07 +00:00
|
|
|
};
|
2007-05-11 22:04:03 +00:00
|
|
|
|
2007-05-02 14:04:53 +00:00
|
|
|
static void
|
2007-05-12 13:30:05 +00:00
|
|
|
select_item (AppearanceData *data,
|
|
|
|
GnomeWPItem * item,
|
|
|
|
gboolean scroll)
|
2007-05-02 14:04:53 +00:00
|
|
|
{
|
|
|
|
GtkTreePath *path;
|
|
|
|
|
|
|
|
g_return_if_fail (data != NULL);
|
|
|
|
|
|
|
|
if (item == NULL)
|
|
|
|
return;
|
|
|
|
|
|
|
|
path = gtk_tree_row_reference_get_path (item->rowref);
|
|
|
|
|
2007-05-10 16:31:18 +00:00
|
|
|
gtk_icon_view_select_path (data->wp_view, path);
|
2007-05-12 13:30:05 +00:00
|
|
|
|
|
|
|
if (scroll)
|
|
|
|
gtk_icon_view_scroll_to_path (data->wp_view, path, FALSE, 0.5, 0.0);
|
|
|
|
|
2007-05-02 14:04:53 +00:00
|
|
|
gtk_tree_path_free (path);
|
|
|
|
}
|
|
|
|
|
2007-05-10 16:31:18 +00:00
|
|
|
static GnomeWPItem *
|
|
|
|
get_selected_item (AppearanceData *data,
|
|
|
|
GtkTreeIter *iter)
|
|
|
|
{
|
|
|
|
GnomeWPItem *item = NULL;
|
|
|
|
GList *selected;
|
|
|
|
|
|
|
|
selected = gtk_icon_view_get_selected_items (data->wp_view);
|
|
|
|
|
|
|
|
if (selected != NULL)
|
|
|
|
{
|
|
|
|
GtkTreeIter sel_iter;
|
|
|
|
gchar *wpfile;
|
|
|
|
|
|
|
|
gtk_tree_model_get_iter (data->wp_model, &sel_iter,
|
|
|
|
selected->data);
|
|
|
|
|
2007-05-11 22:04:03 +00:00
|
|
|
g_list_foreach (selected, (GFunc) gtk_tree_path_free, NULL);
|
|
|
|
g_list_free (selected);
|
|
|
|
|
2007-05-10 16:31:18 +00:00
|
|
|
if (iter)
|
|
|
|
*iter = sel_iter;
|
|
|
|
|
|
|
|
gtk_tree_model_get (data->wp_model, &sel_iter, 2, &wpfile, -1);
|
|
|
|
|
|
|
|
item = g_hash_table_lookup (data->wp_hash, wpfile);
|
|
|
|
g_free (wpfile);
|
|
|
|
}
|
|
|
|
|
|
|
|
return item;
|
|
|
|
}
|
|
|
|
|
2007-05-02 14:04:53 +00:00
|
|
|
static void
|
|
|
|
wp_props_load_wallpaper (gchar *key,
|
|
|
|
GnomeWPItem *item,
|
|
|
|
AppearanceData *data)
|
|
|
|
{
|
|
|
|
GtkTreeIter iter;
|
|
|
|
GtkTreePath *path;
|
|
|
|
GdkPixbuf *pixbuf;
|
|
|
|
|
|
|
|
if (item->deleted == TRUE)
|
|
|
|
return;
|
|
|
|
|
2007-05-10 16:31:18 +00:00
|
|
|
gtk_list_store_append (GTK_LIST_STORE (data->wp_model), &iter);
|
2007-05-02 14:04:53 +00:00
|
|
|
|
use thumbnail factory to store and retrieve metatheme thumbs (bug #448968)
2007-08-03 Jens Granseuer <jensgr@gmx.net>
* appearance-desktop.c: (wp_props_load_wallpaper), (wp_add_image),
(wp_scale_type_changed), (wp_shade_type_changed),
(wp_update_preview), (wp_load_stuffs), (desktop_init),
(desktop_shutdown):
* appearance-main.c: (init_appearance_data),
(main_window_response):
* appearance-themes.c: (theme_get_mtime), (theme_thumbnail_update),
(theme_get_thumbnail_from_cache), (theme_thumbnail_done_cb),
(theme_thumbnail_generate):
* appearance.h:
* gnome-wp-xml.c: (gnome_wp_load_legacy), (gnome_wp_xml_load_xml):
use thumbnail factory to store and retrieve metatheme thumbs
(bug #448968)
svn path=/trunk/; revision=7955
2007-08-03 19:53:14 +00:00
|
|
|
pixbuf = gnome_wp_item_get_thumbnail (item, data->thumb_factory);
|
2007-05-02 14:04:53 +00:00
|
|
|
gnome_wp_item_update_description (item);
|
|
|
|
|
2007-06-15 17:57:49 +00:00
|
|
|
gtk_list_store_set (GTK_LIST_STORE (data->wp_model), &iter,
|
|
|
|
0, pixbuf,
|
|
|
|
1, item->description,
|
|
|
|
2, item->filename,
|
|
|
|
-1);
|
|
|
|
|
2007-05-02 14:04:53 +00:00
|
|
|
if (pixbuf != NULL)
|
|
|
|
g_object_unref (pixbuf);
|
|
|
|
|
2007-05-10 16:31:18 +00:00
|
|
|
path = gtk_tree_model_get_path (data->wp_model, &iter);
|
|
|
|
item->rowref = gtk_tree_row_reference_new (data->wp_model, path);
|
2007-05-02 14:04:53 +00:00
|
|
|
gtk_tree_path_free (path);
|
|
|
|
}
|
|
|
|
|
|
|
|
static GnomeWPItem *
|
|
|
|
wp_add_image (AppearanceData *data,
|
|
|
|
const gchar *filename)
|
|
|
|
{
|
|
|
|
GnomeWPItem *item;
|
|
|
|
|
|
|
|
item = g_hash_table_lookup (data->wp_hash, filename);
|
|
|
|
|
|
|
|
if (item != NULL)
|
|
|
|
{
|
|
|
|
if (item->deleted)
|
|
|
|
{
|
|
|
|
item->deleted = FALSE;
|
|
|
|
wp_props_load_wallpaper (item->filename, item, data);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
use thumbnail factory to store and retrieve metatheme thumbs (bug #448968)
2007-08-03 Jens Granseuer <jensgr@gmx.net>
* appearance-desktop.c: (wp_props_load_wallpaper), (wp_add_image),
(wp_scale_type_changed), (wp_shade_type_changed),
(wp_update_preview), (wp_load_stuffs), (desktop_init),
(desktop_shutdown):
* appearance-main.c: (init_appearance_data),
(main_window_response):
* appearance-themes.c: (theme_get_mtime), (theme_thumbnail_update),
(theme_get_thumbnail_from_cache), (theme_thumbnail_done_cb),
(theme_thumbnail_generate):
* appearance.h:
* gnome-wp-xml.c: (gnome_wp_load_legacy), (gnome_wp_xml_load_xml):
use thumbnail factory to store and retrieve metatheme thumbs
(bug #448968)
svn path=/trunk/; revision=7955
2007-08-03 19:53:14 +00:00
|
|
|
item = gnome_wp_item_new (filename, data->wp_hash, data->thumb_factory);
|
2007-05-02 14:04:53 +00:00
|
|
|
|
|
|
|
if (item != NULL)
|
|
|
|
{
|
|
|
|
wp_props_load_wallpaper (item->filename, item, data);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return item;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
wp_add_images (AppearanceData *data,
|
|
|
|
GSList *images)
|
|
|
|
{
|
2007-05-02 15:26:07 +00:00
|
|
|
GdkWindow *window;
|
|
|
|
GdkCursor *cursor;
|
|
|
|
GnomeWPItem *item;
|
2007-05-02 14:04:53 +00:00
|
|
|
|
2007-08-07 21:46:06 +00:00
|
|
|
window = glade_xml_get_widget (data->xml, "appearance_window")->window;
|
2007-05-03 13:57:09 +00:00
|
|
|
|
2007-05-02 14:04:53 +00:00
|
|
|
item = NULL;
|
2007-05-02 15:26:07 +00:00
|
|
|
cursor = gdk_cursor_new_for_display (gdk_display_get_default (),
|
2007-05-02 14:04:53 +00:00
|
|
|
GDK_WATCH);
|
2007-05-02 15:26:07 +00:00
|
|
|
gdk_window_set_cursor (window, cursor);
|
|
|
|
gdk_cursor_unref (cursor);
|
2007-05-02 14:04:53 +00:00
|
|
|
|
|
|
|
while (images != NULL)
|
|
|
|
{
|
|
|
|
gchar *uri = images->data;
|
|
|
|
|
|
|
|
item = wp_add_image (data, uri);
|
|
|
|
images = g_slist_remove (images, uri);
|
|
|
|
g_free (uri);
|
|
|
|
}
|
|
|
|
|
2007-05-02 15:26:07 +00:00
|
|
|
gdk_window_set_cursor (window, NULL);
|
2007-05-02 14:04:53 +00:00
|
|
|
|
|
|
|
if (item != NULL)
|
|
|
|
{
|
2007-05-12 13:30:05 +00:00
|
|
|
select_item (data, item, TRUE);
|
2007-05-02 14:04:53 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
wp_option_menu_set (AppearanceData *data,
|
|
|
|
const gchar *value,
|
|
|
|
gboolean shade_type)
|
|
|
|
{
|
|
|
|
if (shade_type)
|
|
|
|
{
|
|
|
|
if (!strcmp (value, "horizontal-gradient"))
|
|
|
|
{
|
|
|
|
gtk_combo_box_set_active (GTK_COMBO_BOX (data->wp_color_menu),
|
|
|
|
GNOME_WP_SHADE_TYPE_HORIZ);
|
|
|
|
gtk_widget_show (data->wp_scpicker);
|
|
|
|
}
|
|
|
|
else if (!strcmp (value, "vertical-gradient"))
|
|
|
|
{
|
|
|
|
gtk_combo_box_set_active (GTK_COMBO_BOX (data->wp_color_menu),
|
|
|
|
GNOME_WP_SHADE_TYPE_VERT);
|
|
|
|
gtk_widget_show (data->wp_scpicker);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
gtk_combo_box_set_active (GTK_COMBO_BOX (data->wp_color_menu),
|
|
|
|
GNOME_WP_SHADE_TYPE_SOLID);
|
|
|
|
gtk_widget_hide (data->wp_scpicker);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (!strcmp (value, "centered"))
|
|
|
|
{
|
|
|
|
gtk_combo_box_set_active (GTK_COMBO_BOX (data->wp_style_menu),
|
|
|
|
GNOME_WP_SCALE_TYPE_CENTERED);
|
|
|
|
}
|
|
|
|
else if (!strcmp (value, "stretched"))
|
|
|
|
{
|
|
|
|
gtk_combo_box_set_active (GTK_COMBO_BOX (data->wp_style_menu),
|
|
|
|
GNOME_WP_SCALE_TYPE_STRETCHED);
|
|
|
|
}
|
|
|
|
else if (!strcmp (value, "scaled"))
|
|
|
|
{
|
|
|
|
gtk_combo_box_set_active (GTK_COMBO_BOX (data->wp_style_menu),
|
|
|
|
GNOME_WP_SCALE_TYPE_SCALED);
|
|
|
|
}
|
|
|
|
else if (!strcmp (value, "zoom"))
|
|
|
|
{
|
|
|
|
gtk_combo_box_set_active (GTK_COMBO_BOX (data->wp_style_menu),
|
|
|
|
GNOME_WP_SCALE_TYPE_ZOOM);
|
|
|
|
}
|
|
|
|
else if (!strcmp (value, "none"))
|
|
|
|
{
|
|
|
|
gtk_combo_box_set_active (GTK_COMBO_BOX (data->wp_style_menu),
|
|
|
|
GNOME_WP_SCALE_TYPE_TILED);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
wp_set_sensitivities (AppearanceData *data)
|
|
|
|
{
|
|
|
|
GnomeWPItem *item;
|
|
|
|
gchar *filename = NULL;
|
|
|
|
|
2007-05-10 16:31:18 +00:00
|
|
|
item = get_selected_item (data, NULL);
|
2007-05-02 14:04:53 +00:00
|
|
|
|
2007-05-10 16:31:18 +00:00
|
|
|
if (item != NULL)
|
2007-05-02 14:04:53 +00:00
|
|
|
filename = item->filename;
|
|
|
|
|
|
|
|
if (!gconf_client_key_is_writable (data->client, WP_OPTIONS_KEY, NULL)
|
|
|
|
|| (filename && !strcmp (filename, "(none)")))
|
|
|
|
gtk_widget_set_sensitive (data->wp_style_menu, FALSE);
|
|
|
|
else
|
|
|
|
gtk_widget_set_sensitive (data->wp_style_menu, TRUE);
|
|
|
|
|
|
|
|
if (!gconf_client_key_is_writable (data->client, WP_SHADING_KEY, NULL))
|
|
|
|
gtk_widget_set_sensitive (data->wp_color_menu, FALSE);
|
|
|
|
else
|
|
|
|
gtk_widget_set_sensitive (data->wp_color_menu, TRUE);
|
|
|
|
|
|
|
|
if (!gconf_client_key_is_writable (data->client, WP_PCOLOR_KEY, NULL))
|
|
|
|
gtk_widget_set_sensitive (data->wp_pcpicker, FALSE);
|
|
|
|
else
|
|
|
|
gtk_widget_set_sensitive (data->wp_pcpicker, TRUE);
|
|
|
|
|
|
|
|
if (!gconf_client_key_is_writable (data->client, WP_SCOLOR_KEY, NULL))
|
|
|
|
gtk_widget_set_sensitive (data->wp_scpicker, FALSE);
|
|
|
|
else
|
|
|
|
gtk_widget_set_sensitive (data->wp_scpicker, TRUE);
|
|
|
|
|
|
|
|
if (!filename || !strcmp (filename, "(none)"))
|
|
|
|
gtk_widget_set_sensitive (data->wp_rem_button, FALSE);
|
|
|
|
else
|
|
|
|
gtk_widget_set_sensitive (data->wp_rem_button, TRUE);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
wp_scale_type_changed (GtkComboBox *combobox,
|
|
|
|
AppearanceData *data)
|
|
|
|
{
|
2007-05-10 16:31:18 +00:00
|
|
|
GnomeWPItem *item;
|
2007-05-02 14:04:53 +00:00
|
|
|
GtkTreeIter iter;
|
2007-05-10 16:31:18 +00:00
|
|
|
GdkPixbuf *pixbuf;
|
2007-05-02 14:04:53 +00:00
|
|
|
|
2007-05-10 16:31:18 +00:00
|
|
|
item = get_selected_item (data, &iter);
|
2007-05-02 14:04:53 +00:00
|
|
|
|
|
|
|
if (item == NULL)
|
|
|
|
return;
|
|
|
|
|
|
|
|
g_free (item->options);
|
|
|
|
|
|
|
|
switch (gtk_combo_box_get_active (GTK_COMBO_BOX (data->wp_style_menu)))
|
|
|
|
{
|
|
|
|
case GNOME_WP_SCALE_TYPE_CENTERED:
|
|
|
|
item->options = g_strdup ("centered");
|
|
|
|
break;
|
|
|
|
case GNOME_WP_SCALE_TYPE_STRETCHED:
|
|
|
|
item->options = g_strdup ("stretched");
|
|
|
|
break;
|
|
|
|
case GNOME_WP_SCALE_TYPE_SCALED:
|
|
|
|
item->options = g_strdup ("scaled");
|
|
|
|
break;
|
|
|
|
case GNOME_WP_SCALE_TYPE_ZOOM:
|
|
|
|
item->options = g_strdup ("zoom");
|
|
|
|
break;
|
|
|
|
case GNOME_WP_SCALE_TYPE_TILED:
|
|
|
|
item->options = g_strdup ("wallpaper");
|
|
|
|
break;
|
2007-05-11 23:22:03 +00:00
|
|
|
default:
|
|
|
|
item->options = g_strdup ("none");
|
|
|
|
break;
|
2007-05-02 14:04:53 +00:00
|
|
|
}
|
|
|
|
|
use thumbnail factory to store and retrieve metatheme thumbs (bug #448968)
2007-08-03 Jens Granseuer <jensgr@gmx.net>
* appearance-desktop.c: (wp_props_load_wallpaper), (wp_add_image),
(wp_scale_type_changed), (wp_shade_type_changed),
(wp_update_preview), (wp_load_stuffs), (desktop_init),
(desktop_shutdown):
* appearance-main.c: (init_appearance_data),
(main_window_response):
* appearance-themes.c: (theme_get_mtime), (theme_thumbnail_update),
(theme_get_thumbnail_from_cache), (theme_thumbnail_done_cb),
(theme_thumbnail_generate):
* appearance.h:
* gnome-wp-xml.c: (gnome_wp_load_legacy), (gnome_wp_xml_load_xml):
use thumbnail factory to store and retrieve metatheme thumbs
(bug #448968)
svn path=/trunk/; revision=7955
2007-08-03 19:53:14 +00:00
|
|
|
pixbuf = gnome_wp_item_get_thumbnail (item, data->thumb_factory);
|
2007-05-10 16:31:18 +00:00
|
|
|
gtk_list_store_set (GTK_LIST_STORE (data->wp_model),
|
2007-05-02 14:04:53 +00:00
|
|
|
&iter,
|
|
|
|
0, pixbuf,
|
|
|
|
-1);
|
2007-06-15 17:57:49 +00:00
|
|
|
if (pixbuf != NULL)
|
|
|
|
g_object_unref (pixbuf);
|
2007-05-02 14:04:53 +00:00
|
|
|
|
|
|
|
gconf_client_set_string (data->client, WP_OPTIONS_KEY, item->options, NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
wp_shade_type_changed (GtkWidget *combobox,
|
|
|
|
AppearanceData *data)
|
|
|
|
{
|
2007-05-10 16:31:18 +00:00
|
|
|
GnomeWPItem *item;
|
2007-05-02 14:04:53 +00:00
|
|
|
GtkTreeIter iter;
|
|
|
|
GdkPixbuf *pixbuf;
|
|
|
|
|
2007-05-10 16:31:18 +00:00
|
|
|
item = get_selected_item (data, &iter);
|
2007-05-02 14:04:53 +00:00
|
|
|
|
|
|
|
if (item == NULL)
|
|
|
|
return;
|
|
|
|
|
|
|
|
g_free (item->shade_type);
|
|
|
|
|
|
|
|
switch (gtk_combo_box_get_active (GTK_COMBO_BOX (data->wp_color_menu)))
|
|
|
|
{
|
|
|
|
case GNOME_WP_SHADE_TYPE_HORIZ:
|
|
|
|
item->shade_type = g_strdup ("horizontal-gradient");
|
|
|
|
gtk_widget_show (data->wp_scpicker);
|
|
|
|
break;
|
|
|
|
case GNOME_WP_SHADE_TYPE_VERT:
|
|
|
|
item->shade_type = g_strdup ("vertical-gradient");
|
|
|
|
gtk_widget_show (data->wp_scpicker);
|
|
|
|
break;
|
|
|
|
case GNOME_WP_SHADE_TYPE_SOLID:
|
|
|
|
default:
|
|
|
|
item->shade_type = g_strdup ("solid");
|
|
|
|
gtk_widget_hide (data->wp_scpicker);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
use thumbnail factory to store and retrieve metatheme thumbs (bug #448968)
2007-08-03 Jens Granseuer <jensgr@gmx.net>
* appearance-desktop.c: (wp_props_load_wallpaper), (wp_add_image),
(wp_scale_type_changed), (wp_shade_type_changed),
(wp_update_preview), (wp_load_stuffs), (desktop_init),
(desktop_shutdown):
* appearance-main.c: (init_appearance_data),
(main_window_response):
* appearance-themes.c: (theme_get_mtime), (theme_thumbnail_update),
(theme_get_thumbnail_from_cache), (theme_thumbnail_done_cb),
(theme_thumbnail_generate):
* appearance.h:
* gnome-wp-xml.c: (gnome_wp_load_legacy), (gnome_wp_xml_load_xml):
use thumbnail factory to store and retrieve metatheme thumbs
(bug #448968)
svn path=/trunk/; revision=7955
2007-08-03 19:53:14 +00:00
|
|
|
pixbuf = gnome_wp_item_get_thumbnail (item, data->thumb_factory);
|
2007-05-10 16:31:18 +00:00
|
|
|
gtk_list_store_set (GTK_LIST_STORE (data->wp_model), &iter,
|
2007-05-02 14:04:53 +00:00
|
|
|
0, pixbuf,
|
|
|
|
-1);
|
2007-06-15 17:57:49 +00:00
|
|
|
if (pixbuf != NULL)
|
|
|
|
g_object_unref (pixbuf);
|
|
|
|
|
2007-05-02 14:04:53 +00:00
|
|
|
gconf_client_set_string (data->client, WP_SHADING_KEY,
|
|
|
|
item->shade_type, NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
wp_color_changed (AppearanceData *data,
|
|
|
|
gboolean update)
|
|
|
|
{
|
2007-05-10 16:31:18 +00:00
|
|
|
GnomeWPItem *item;
|
2007-05-02 14:04:53 +00:00
|
|
|
|
2007-05-10 16:31:18 +00:00
|
|
|
item = get_selected_item (data, NULL);
|
2007-05-02 14:04:53 +00:00
|
|
|
|
|
|
|
if (item == NULL)
|
|
|
|
return;
|
|
|
|
|
|
|
|
gtk_color_button_get_color (GTK_COLOR_BUTTON (data->wp_pcpicker), item->pcolor);
|
2007-05-11 23:22:03 +00:00
|
|
|
gtk_color_button_get_color (GTK_COLOR_BUTTON (data->wp_scpicker), item->scolor);
|
2007-05-02 14:04:53 +00:00
|
|
|
|
|
|
|
if (update)
|
|
|
|
{
|
2007-11-03 10:57:05 +00:00
|
|
|
gchar *pcolor, *scolor;
|
|
|
|
|
|
|
|
pcolor = gdk_color_to_string (item->pcolor);
|
|
|
|
scolor = gdk_color_to_string (item->scolor);
|
|
|
|
gconf_client_set_string (data->client, WP_PCOLOR_KEY, pcolor, NULL);
|
|
|
|
gconf_client_set_string (data->client, WP_SCOLOR_KEY, scolor, NULL);
|
|
|
|
g_free (pcolor);
|
|
|
|
g_free (scolor);
|
2007-05-02 14:04:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
wp_shade_type_changed (NULL, data);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
wp_scolor_changed (GtkWidget *widget,
|
|
|
|
AppearanceData *data)
|
|
|
|
{
|
|
|
|
wp_color_changed (data, TRUE);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
wp_remove_wallpaper (GtkWidget *widget,
|
|
|
|
AppearanceData *data)
|
|
|
|
{
|
2007-05-10 16:31:18 +00:00
|
|
|
GnomeWPItem *item;
|
2007-05-02 14:04:53 +00:00
|
|
|
GtkTreeIter iter;
|
2007-05-10 16:31:18 +00:00
|
|
|
GtkTreePath *path;
|
2007-05-02 14:04:53 +00:00
|
|
|
|
2007-05-10 16:31:18 +00:00
|
|
|
item = get_selected_item (data, &iter);
|
2007-05-02 14:04:53 +00:00
|
|
|
|
2007-05-10 16:31:18 +00:00
|
|
|
if (item)
|
2007-05-02 14:04:53 +00:00
|
|
|
{
|
|
|
|
item->deleted = TRUE;
|
|
|
|
|
2007-05-10 16:31:18 +00:00
|
|
|
if (gtk_list_store_remove (GTK_LIST_STORE (data->wp_model), &iter))
|
|
|
|
path = gtk_tree_model_get_path (data->wp_model, &iter);
|
2007-05-02 14:04:53 +00:00
|
|
|
else
|
|
|
|
path = gtk_tree_path_new_first ();
|
|
|
|
|
2007-05-12 11:29:58 +00:00
|
|
|
gtk_icon_view_select_path (data->wp_view, path);
|
2007-05-02 14:04:53 +00:00
|
|
|
gtk_tree_path_free (path);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2007-05-03 13:57:09 +00:00
|
|
|
wp_uri_changed (const gchar *uri,
|
|
|
|
AppearanceData *data)
|
2007-05-02 14:04:53 +00:00
|
|
|
{
|
2007-05-10 16:31:18 +00:00
|
|
|
GnomeWPItem *item, *selected;
|
2007-05-02 14:04:53 +00:00
|
|
|
|
2007-05-03 13:57:09 +00:00
|
|
|
item = g_hash_table_lookup (data->wp_hash, uri);
|
2007-05-10 16:31:18 +00:00
|
|
|
selected = get_selected_item (data, NULL);
|
2007-05-02 14:04:53 +00:00
|
|
|
|
2007-05-10 16:31:18 +00:00
|
|
|
if (selected != NULL && strcmp (selected->filename, uri) != 0)
|
2007-05-02 14:04:53 +00:00
|
|
|
{
|
2007-05-10 16:31:18 +00:00
|
|
|
if (item == NULL)
|
|
|
|
item = wp_add_image (data, uri);
|
2007-05-03 13:57:09 +00:00
|
|
|
|
2007-05-12 13:30:05 +00:00
|
|
|
select_item (data, item, TRUE);
|
2007-05-02 14:04:53 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-05-03 13:57:09 +00:00
|
|
|
static void
|
|
|
|
wp_file_changed (GConfClient *client, guint id,
|
|
|
|
GConfEntry *entry,
|
|
|
|
AppearanceData *data)
|
|
|
|
{
|
|
|
|
const gchar *uri;
|
|
|
|
gchar *wpfile;
|
|
|
|
|
|
|
|
uri = gconf_value_get_string (entry->value);
|
|
|
|
|
|
|
|
if (g_utf8_validate (uri, -1, NULL) && g_file_test (uri, G_FILE_TEST_EXISTS))
|
|
|
|
wpfile = g_strdup (uri);
|
|
|
|
else
|
|
|
|
wpfile = g_filename_from_utf8 (uri, -1, NULL, NULL, NULL);
|
|
|
|
|
|
|
|
wp_uri_changed (wpfile, data);
|
|
|
|
|
|
|
|
g_free (wpfile);
|
|
|
|
}
|
|
|
|
|
2007-05-02 14:04:53 +00:00
|
|
|
static void
|
|
|
|
wp_options_changed (GConfClient *client, guint id,
|
|
|
|
GConfEntry *entry,
|
2007-05-03 13:57:09 +00:00
|
|
|
AppearanceData *data)
|
2007-05-02 14:04:53 +00:00
|
|
|
{
|
|
|
|
GnomeWPItem *item;
|
2007-05-03 13:57:09 +00:00
|
|
|
const gchar *option;
|
2007-05-02 14:04:53 +00:00
|
|
|
|
2007-05-03 13:57:09 +00:00
|
|
|
option = gconf_value_get_string (entry->value);
|
|
|
|
|
|
|
|
/* "none" means we don't use a background image */
|
|
|
|
if (option == NULL || !strcmp (option, "none"))
|
|
|
|
{
|
|
|
|
/* temporarily disconnect so we don't override settings when
|
|
|
|
* updating the selection */
|
|
|
|
data->wp_update_gconf = FALSE;
|
|
|
|
wp_uri_changed ("(none)", data);
|
|
|
|
data->wp_update_gconf = TRUE;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2007-05-10 16:31:18 +00:00
|
|
|
item = get_selected_item (data, NULL);
|
2007-05-02 14:04:53 +00:00
|
|
|
|
2007-05-10 16:31:18 +00:00
|
|
|
if (item != NULL)
|
2007-05-02 14:04:53 +00:00
|
|
|
{
|
2007-05-10 16:31:18 +00:00
|
|
|
g_free (item->options);
|
|
|
|
item->options = g_strdup (option);
|
|
|
|
wp_option_menu_set (data, item->options, FALSE);
|
2007-05-02 14:04:53 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
wp_shading_changed (GConfClient *client, guint id,
|
|
|
|
GConfEntry *entry,
|
|
|
|
AppearanceData *data)
|
|
|
|
{
|
|
|
|
GnomeWPItem *item;
|
|
|
|
|
|
|
|
wp_set_sensitivities (data);
|
|
|
|
|
2007-05-10 16:31:18 +00:00
|
|
|
item = get_selected_item (data, NULL);
|
2007-05-02 14:04:53 +00:00
|
|
|
|
2007-05-10 16:31:18 +00:00
|
|
|
if (item != NULL)
|
2007-05-02 14:04:53 +00:00
|
|
|
{
|
2007-05-10 16:31:18 +00:00
|
|
|
g_free (item->shade_type);
|
|
|
|
item->shade_type = g_strdup (gconf_value_get_string (entry->value));
|
|
|
|
wp_option_menu_set (data, item->shade_type, TRUE);
|
2007-05-02 14:04:53 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
wp_color1_changed (GConfClient *client, guint id,
|
|
|
|
GConfEntry *entry,
|
|
|
|
AppearanceData *data)
|
|
|
|
{
|
|
|
|
GdkColor color;
|
|
|
|
const gchar *colorhex;
|
|
|
|
|
|
|
|
colorhex = gconf_value_get_string (entry->value);
|
|
|
|
|
|
|
|
gdk_color_parse (colorhex, &color);
|
|
|
|
|
|
|
|
gtk_color_button_set_color (GTK_COLOR_BUTTON (data->wp_pcpicker), &color);
|
|
|
|
|
|
|
|
wp_color_changed (data, FALSE);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
wp_color2_changed (GConfClient *client, guint id,
|
|
|
|
GConfEntry *entry,
|
|
|
|
AppearanceData *data)
|
|
|
|
{
|
|
|
|
GdkColor color;
|
|
|
|
const gchar *colorhex;
|
|
|
|
|
|
|
|
wp_set_sensitivities (data);
|
|
|
|
|
|
|
|
colorhex = gconf_value_get_string (entry->value);
|
|
|
|
|
|
|
|
gdk_color_parse (colorhex, &color);
|
|
|
|
|
|
|
|
gtk_color_button_set_color (GTK_COLOR_BUTTON (data->wp_scpicker), &color);
|
|
|
|
|
|
|
|
wp_color_changed (data, FALSE);
|
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
2007-05-11 23:22:03 +00:00
|
|
|
wp_props_wp_set (AppearanceData *data, GnomeWPItem *item)
|
2007-05-02 14:04:53 +00:00
|
|
|
{
|
|
|
|
GConfChangeSet *cs;
|
2007-11-03 10:57:05 +00:00
|
|
|
gchar *pcolor, *scolor;
|
2007-05-02 14:04:53 +00:00
|
|
|
|
2007-05-11 23:22:03 +00:00
|
|
|
cs = gconf_change_set_new ();
|
2007-05-02 14:04:53 +00:00
|
|
|
|
2007-05-11 23:22:03 +00:00
|
|
|
if (!strcmp (item->filename, "(none)"))
|
2007-05-02 14:04:53 +00:00
|
|
|
{
|
2007-05-11 23:22:03 +00:00
|
|
|
gconf_change_set_set_string (cs, WP_OPTIONS_KEY, "none");
|
|
|
|
gconf_change_set_set_string (cs, WP_FILE_KEY, "");
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
gchar *uri;
|
2007-05-02 14:04:53 +00:00
|
|
|
|
2007-05-11 23:22:03 +00:00
|
|
|
if (g_utf8_validate (item->filename, -1, NULL))
|
|
|
|
uri = g_strdup (item->filename);
|
2007-05-02 14:04:53 +00:00
|
|
|
else
|
2007-05-11 23:22:03 +00:00
|
|
|
uri = g_filename_to_utf8 (item->filename, -1, NULL, NULL, NULL);
|
2007-05-02 14:04:53 +00:00
|
|
|
|
2007-10-09 18:58:38 +00:00
|
|
|
if (uri == NULL) {
|
|
|
|
g_warning ("Failed to convert filename to UTF-8: %s\n", item->filename);
|
|
|
|
} else {
|
|
|
|
gconf_change_set_set_string (cs, WP_FILE_KEY, uri);
|
|
|
|
g_free (uri);
|
|
|
|
}
|
2007-05-02 14:04:53 +00:00
|
|
|
|
2007-05-11 23:22:03 +00:00
|
|
|
gconf_change_set_set_string (cs, WP_OPTIONS_KEY, item->options);
|
|
|
|
}
|
2007-05-02 14:04:53 +00:00
|
|
|
|
2007-05-11 23:22:03 +00:00
|
|
|
gconf_change_set_set_string (cs, WP_SHADING_KEY, item->shade_type);
|
2007-05-02 14:04:53 +00:00
|
|
|
|
2007-11-03 10:57:05 +00:00
|
|
|
pcolor = gdk_color_to_string (item->pcolor);
|
|
|
|
scolor = gdk_color_to_string (item->scolor);
|
|
|
|
gconf_change_set_set_string (cs, WP_PCOLOR_KEY, pcolor);
|
|
|
|
gconf_change_set_set_string (cs, WP_SCOLOR_KEY, scolor);
|
|
|
|
g_free (pcolor);
|
|
|
|
g_free (scolor);
|
2007-05-02 14:04:53 +00:00
|
|
|
|
2007-05-11 23:22:03 +00:00
|
|
|
gconf_client_commit_change_set (data->client, cs, TRUE, NULL);
|
2007-05-02 14:04:53 +00:00
|
|
|
|
2007-05-11 23:22:03 +00:00
|
|
|
gconf_change_set_unref (cs);
|
2007-05-02 14:04:53 +00:00
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
wp_props_wp_selected (GtkTreeSelection *selection,
|
|
|
|
AppearanceData *data)
|
|
|
|
{
|
|
|
|
GnomeWPItem *item;
|
|
|
|
|
2007-05-10 16:31:18 +00:00
|
|
|
item = get_selected_item (data, NULL);
|
2007-05-02 14:04:53 +00:00
|
|
|
|
2007-05-10 16:31:18 +00:00
|
|
|
if (item != NULL)
|
|
|
|
{
|
2007-05-02 14:04:53 +00:00
|
|
|
wp_set_sensitivities (data);
|
|
|
|
|
|
|
|
if (strcmp (item->filename, "(none)") != 0)
|
|
|
|
wp_option_menu_set (data, item->options, FALSE);
|
|
|
|
|
|
|
|
wp_option_menu_set (data, item->shade_type, TRUE);
|
|
|
|
|
|
|
|
gtk_color_button_set_color (GTK_COLOR_BUTTON (data->wp_pcpicker),
|
|
|
|
item->pcolor);
|
|
|
|
gtk_color_button_set_color (GTK_COLOR_BUTTON (data->wp_scpicker),
|
|
|
|
item->scolor);
|
2007-05-11 23:22:03 +00:00
|
|
|
|
|
|
|
if (data->wp_update_gconf)
|
|
|
|
wp_props_wp_set (data, item);
|
2007-05-02 14:04:53 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
gtk_widget_set_sensitive (data->wp_rem_button, FALSE);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
wp_file_open_dialog (GtkWidget *widget,
|
|
|
|
AppearanceData *data)
|
|
|
|
{
|
|
|
|
GSList *files;
|
|
|
|
|
|
|
|
switch (gtk_dialog_run (GTK_DIALOG (data->wp_filesel)))
|
|
|
|
{
|
|
|
|
case GTK_RESPONSE_OK:
|
2007-07-31 21:15:02 +00:00
|
|
|
files = gtk_file_chooser_get_filenames (data->wp_filesel);
|
2007-05-02 14:04:53 +00:00
|
|
|
wp_add_images (data, files);
|
|
|
|
case GTK_RESPONSE_CANCEL:
|
|
|
|
default:
|
2007-07-31 21:15:02 +00:00
|
|
|
gtk_widget_hide (GTK_WIDGET (data->wp_filesel));
|
2007-05-02 14:04:53 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-05-02 15:26:07 +00:00
|
|
|
static void
|
2007-09-23 12:23:26 +00:00
|
|
|
wp_drag_received (GtkWidget *widget,
|
2007-05-02 15:26:07 +00:00
|
|
|
GdkDragContext *context,
|
|
|
|
gint x, gint y,
|
|
|
|
GtkSelectionData *selection_data,
|
|
|
|
guint info, guint time,
|
|
|
|
AppearanceData *data)
|
|
|
|
{
|
|
|
|
if (info == TARGET_URI_LIST || info == TARGET_BGIMAGE)
|
|
|
|
{
|
|
|
|
GList * uris;
|
|
|
|
GSList * realuris = NULL;
|
|
|
|
|
|
|
|
uris = gnome_vfs_uri_list_parse ((gchar *) selection_data->data);
|
|
|
|
|
|
|
|
if (uris != NULL && uris->data != NULL)
|
|
|
|
{
|
|
|
|
GdkWindow *window;
|
|
|
|
GdkCursor *cursor;
|
|
|
|
|
2007-08-07 21:46:06 +00:00
|
|
|
window = glade_xml_get_widget (data->xml, "appearance_window")->window;
|
2007-05-03 13:57:09 +00:00
|
|
|
|
2007-05-02 15:26:07 +00:00
|
|
|
cursor = gdk_cursor_new_for_display (gdk_display_get_default (),
|
|
|
|
GDK_WATCH);
|
|
|
|
gdk_window_set_cursor (window, cursor);
|
|
|
|
gdk_cursor_unref (cursor);
|
|
|
|
|
|
|
|
for (; uris != NULL; uris = uris->next)
|
|
|
|
{
|
|
|
|
realuris = g_slist_append (realuris,
|
|
|
|
g_strdup (gnome_vfs_uri_get_path (uris->data)));
|
|
|
|
}
|
2007-05-03 13:57:09 +00:00
|
|
|
|
2007-05-02 15:26:07 +00:00
|
|
|
wp_add_images (data, realuris);
|
|
|
|
gdk_window_set_cursor (window, NULL);
|
|
|
|
}
|
|
|
|
gnome_vfs_uri_list_free (uris);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-09-23 12:23:26 +00:00
|
|
|
static void
|
|
|
|
wp_drag_get_data (GtkWidget *widget,
|
|
|
|
GdkDragContext *context,
|
|
|
|
GtkSelectionData *selection_data,
|
|
|
|
guint type, guint time,
|
|
|
|
AppearanceData *data)
|
|
|
|
{
|
|
|
|
if (type == TARGET_URI_LIST) {
|
|
|
|
GnomeWPItem *item = get_selected_item (data, NULL);
|
|
|
|
|
|
|
|
if (item != NULL) {
|
|
|
|
gchar *uris[] = { item->filename, NULL };
|
|
|
|
gtk_selection_data_set_uris (selection_data, uris);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-06-17 15:55:58 +00:00
|
|
|
static gboolean
|
|
|
|
wp_view_tooltip_cb (GtkWidget *widget,
|
|
|
|
gint x,
|
|
|
|
gint y,
|
|
|
|
gboolean keyboard_mode,
|
|
|
|
GtkTooltip *tooltip,
|
|
|
|
AppearanceData *data)
|
|
|
|
{
|
|
|
|
GtkTreeIter iter;
|
|
|
|
gchar *wpfile;
|
|
|
|
GnomeWPItem *item;
|
|
|
|
|
2007-07-23 18:43:37 +00:00
|
|
|
if (gtk_icon_view_get_tooltip_context (data->wp_view,
|
|
|
|
&x, &y,
|
2007-07-23 18:21:39 +00:00
|
|
|
keyboard_mode,
|
2007-07-23 18:43:37 +00:00
|
|
|
NULL,
|
2007-07-23 18:21:39 +00:00
|
|
|
NULL,
|
|
|
|
&iter))
|
|
|
|
{
|
|
|
|
gtk_tree_model_get (data->wp_model, &iter, 2, &wpfile, -1);
|
|
|
|
item = g_hash_table_lookup (data->wp_hash, wpfile);
|
|
|
|
g_free (wpfile);
|
2007-06-17 15:55:58 +00:00
|
|
|
|
2007-07-23 18:21:39 +00:00
|
|
|
gtk_tooltip_set_markup (tooltip, item->description);
|
2007-07-23 18:43:37 +00:00
|
|
|
|
2007-07-23 18:21:39 +00:00
|
|
|
return TRUE;
|
|
|
|
}
|
2007-07-23 18:43:37 +00:00
|
|
|
|
2007-07-23 18:21:39 +00:00
|
|
|
return FALSE;
|
2007-06-17 15:55:58 +00:00
|
|
|
}
|
|
|
|
|
2007-05-02 14:04:53 +00:00
|
|
|
static gint
|
|
|
|
wp_list_sort (GtkTreeModel *model,
|
|
|
|
GtkTreeIter *a, GtkTreeIter *b,
|
|
|
|
AppearanceData *data)
|
|
|
|
{
|
|
|
|
gchar *foo, *bar;
|
|
|
|
gchar *desca, *descb;
|
|
|
|
gint retval;
|
|
|
|
|
|
|
|
gtk_tree_model_get (model, a, 1, &desca, 2, &foo, -1);
|
|
|
|
gtk_tree_model_get (model, b, 1, &descb, 2, &bar, -1);
|
|
|
|
|
|
|
|
if (!strcmp (foo, "(none)"))
|
|
|
|
{
|
|
|
|
retval = -1;
|
|
|
|
}
|
|
|
|
else if (!strcmp (bar, "(none)"))
|
|
|
|
{
|
|
|
|
retval = 1;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
retval = g_utf8_collate (desca, descb);
|
|
|
|
}
|
|
|
|
|
|
|
|
g_free (desca);
|
|
|
|
g_free (descb);
|
|
|
|
g_free (foo);
|
|
|
|
g_free (bar);
|
|
|
|
|
|
|
|
return retval;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
wp_update_preview (GtkFileChooser *chooser,
|
|
|
|
AppearanceData *data)
|
|
|
|
{
|
|
|
|
gchar *uri;
|
|
|
|
|
|
|
|
uri = gtk_file_chooser_get_preview_uri (chooser);
|
|
|
|
|
|
|
|
if (uri)
|
|
|
|
{
|
|
|
|
GdkPixbuf *pixbuf = NULL;
|
|
|
|
gchar *mime_type;
|
|
|
|
|
|
|
|
mime_type = gnome_vfs_get_mime_type (uri);
|
|
|
|
|
|
|
|
if (mime_type)
|
|
|
|
{
|
use thumbnail factory to store and retrieve metatheme thumbs (bug #448968)
2007-08-03 Jens Granseuer <jensgr@gmx.net>
* appearance-desktop.c: (wp_props_load_wallpaper), (wp_add_image),
(wp_scale_type_changed), (wp_shade_type_changed),
(wp_update_preview), (wp_load_stuffs), (desktop_init),
(desktop_shutdown):
* appearance-main.c: (init_appearance_data),
(main_window_response):
* appearance-themes.c: (theme_get_mtime), (theme_thumbnail_update),
(theme_get_thumbnail_from_cache), (theme_thumbnail_done_cb),
(theme_thumbnail_generate):
* appearance.h:
* gnome-wp-xml.c: (gnome_wp_load_legacy), (gnome_wp_xml_load_xml):
use thumbnail factory to store and retrieve metatheme thumbs
(bug #448968)
svn path=/trunk/; revision=7955
2007-08-03 19:53:14 +00:00
|
|
|
pixbuf = gnome_thumbnail_factory_generate_thumbnail (data->thumb_factory,
|
2007-05-02 14:04:53 +00:00
|
|
|
uri,
|
|
|
|
mime_type);
|
2007-05-11 22:04:03 +00:00
|
|
|
g_free (mime_type);
|
2007-05-02 14:04:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (pixbuf != NULL)
|
|
|
|
{
|
|
|
|
gtk_image_set_from_pixbuf (GTK_IMAGE (data->wp_image), pixbuf);
|
|
|
|
g_object_unref (pixbuf);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
gtk_image_set_from_stock (GTK_IMAGE (data->wp_image),
|
|
|
|
"gtk-dialog-question",
|
|
|
|
GTK_ICON_SIZE_DIALOG);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
gtk_file_chooser_set_preview_widget_active (chooser, TRUE);
|
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
wp_load_stuffs (void *user_data)
|
|
|
|
{
|
|
|
|
AppearanceData *data;
|
|
|
|
gchar * imagepath, * style, * uri;
|
|
|
|
GnomeWPItem * item;
|
|
|
|
|
|
|
|
data = (AppearanceData *) user_data;
|
|
|
|
|
|
|
|
gnome_wp_xml_load_list (data);
|
|
|
|
g_hash_table_foreach (data->wp_hash, (GHFunc) wp_props_load_wallpaper,
|
|
|
|
data);
|
|
|
|
|
|
|
|
/*gdk_window_set_cursor (data->window->window, NULL);*/
|
|
|
|
|
|
|
|
style = gconf_client_get_string (data->client,
|
|
|
|
WP_OPTIONS_KEY,
|
|
|
|
NULL);
|
|
|
|
if (style == NULL)
|
|
|
|
style = g_strdup ("none");
|
|
|
|
|
|
|
|
uri = gconf_client_get_string (data->client,
|
|
|
|
WP_FILE_KEY,
|
|
|
|
NULL);
|
|
|
|
if (uri == NULL)
|
|
|
|
uri = g_strdup ("(none)");
|
|
|
|
|
|
|
|
if (g_utf8_validate (uri, -1, NULL) && g_file_test (uri, G_FILE_TEST_EXISTS))
|
|
|
|
imagepath = g_strdup (uri);
|
|
|
|
else
|
|
|
|
imagepath = g_filename_from_utf8 (uri, -1, NULL, NULL, NULL);
|
|
|
|
|
|
|
|
g_free (uri);
|
|
|
|
|
|
|
|
item = g_hash_table_lookup (data->wp_hash, imagepath);
|
|
|
|
|
|
|
|
if (item != NULL && strcmp (style, "none") != 0)
|
|
|
|
{
|
|
|
|
if (item->deleted == TRUE)
|
|
|
|
{
|
|
|
|
item->deleted = FALSE;
|
|
|
|
wp_props_load_wallpaper (item->filename, item, data);
|
|
|
|
}
|
|
|
|
|
2007-05-12 13:30:05 +00:00
|
|
|
select_item (data, item, FALSE);
|
2007-05-02 14:04:53 +00:00
|
|
|
|
|
|
|
wp_option_menu_set (data, item->options, FALSE);
|
|
|
|
wp_option_menu_set (data, item->shade_type, TRUE);
|
|
|
|
|
|
|
|
gtk_color_button_set_color (GTK_COLOR_BUTTON (data->wp_pcpicker), item->pcolor);
|
|
|
|
gtk_color_button_set_color (GTK_COLOR_BUTTON (data->wp_scpicker), item->scolor);
|
|
|
|
|
|
|
|
}
|
|
|
|
else if (strcmp (style, "none") != 0)
|
|
|
|
{
|
|
|
|
item = wp_add_image (data, imagepath);
|
2007-05-12 13:30:05 +00:00
|
|
|
select_item (data, item, FALSE);
|
2007-05-02 14:04:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
item = g_hash_table_lookup (data->wp_hash, "(none)");
|
|
|
|
if (item == NULL)
|
|
|
|
{
|
use thumbnail factory to store and retrieve metatheme thumbs (bug #448968)
2007-08-03 Jens Granseuer <jensgr@gmx.net>
* appearance-desktop.c: (wp_props_load_wallpaper), (wp_add_image),
(wp_scale_type_changed), (wp_shade_type_changed),
(wp_update_preview), (wp_load_stuffs), (desktop_init),
(desktop_shutdown):
* appearance-main.c: (init_appearance_data),
(main_window_response):
* appearance-themes.c: (theme_get_mtime), (theme_thumbnail_update),
(theme_get_thumbnail_from_cache), (theme_thumbnail_done_cb),
(theme_thumbnail_generate):
* appearance.h:
* gnome-wp-xml.c: (gnome_wp_load_legacy), (gnome_wp_xml_load_xml):
use thumbnail factory to store and retrieve metatheme thumbs
(bug #448968)
svn path=/trunk/; revision=7955
2007-08-03 19:53:14 +00:00
|
|
|
item = gnome_wp_item_new ("(none)", data->wp_hash, data->thumb_factory);
|
2007-05-02 14:04:53 +00:00
|
|
|
if (item != NULL)
|
|
|
|
{
|
|
|
|
wp_props_load_wallpaper (item->filename, item, data);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (item->deleted == TRUE)
|
|
|
|
{
|
|
|
|
item->deleted = FALSE;
|
|
|
|
wp_props_load_wallpaper (item->filename, item, data);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!strcmp (style, "none"))
|
|
|
|
{
|
2007-05-12 13:30:05 +00:00
|
|
|
select_item (data, item, FALSE);
|
2007-05-11 23:22:03 +00:00
|
|
|
wp_option_menu_set (data, style, FALSE);
|
2007-05-02 14:04:53 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
g_free (imagepath);
|
|
|
|
g_free (style);
|
|
|
|
|
2007-07-12 20:52:15 +00:00
|
|
|
if (data->wp_uris) {
|
|
|
|
wp_add_images (data, data->wp_uris);
|
|
|
|
data->wp_uris = NULL;
|
|
|
|
}
|
|
|
|
|
2007-05-02 14:04:53 +00:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2007-05-12 13:30:05 +00:00
|
|
|
static void
|
|
|
|
wp_select_after_realize (GtkWidget *widget,
|
|
|
|
AppearanceData *data)
|
|
|
|
{
|
2007-08-22 17:16:02 +00:00
|
|
|
GnomeWPItem *item = get_selected_item (data, NULL);
|
|
|
|
|
|
|
|
if (item == NULL)
|
|
|
|
item = g_hash_table_lookup (data->wp_hash, "(none)");
|
|
|
|
|
|
|
|
select_item (data, item, TRUE);
|
2007-05-12 13:30:05 +00:00
|
|
|
}
|
|
|
|
|
2007-05-02 14:04:53 +00:00
|
|
|
void
|
2007-07-12 20:52:15 +00:00
|
|
|
desktop_init (AppearanceData *data,
|
|
|
|
const gchar **uris)
|
2007-05-02 14:04:53 +00:00
|
|
|
{
|
2007-05-07 18:22:01 +00:00
|
|
|
GtkWidget *add_button;
|
2007-07-29 17:45:51 +00:00
|
|
|
GtkCellRenderer *cr;
|
2007-05-02 14:04:53 +00:00
|
|
|
GtkFileFilter *filter;
|
2007-07-31 21:15:02 +00:00
|
|
|
const gchar *pictures;
|
2007-11-18 13:02:19 +00:00
|
|
|
const gchar *start_dir;
|
2007-05-02 14:04:53 +00:00
|
|
|
|
2007-07-28 14:15:48 +00:00
|
|
|
g_object_set (gtk_settings_get_default (), "gtk-tooltip-timeout", 500, NULL);
|
2007-06-17 15:55:58 +00:00
|
|
|
|
2007-05-12 13:30:05 +00:00
|
|
|
data->wp_update_gconf = TRUE;
|
2007-06-15 17:57:49 +00:00
|
|
|
|
2007-07-12 20:52:15 +00:00
|
|
|
data->wp_uris = NULL;
|
|
|
|
if (uris != NULL) {
|
|
|
|
while (*uris != NULL) {
|
|
|
|
data->wp_uris = g_slist_append (data->wp_uris, g_strdup (*uris));
|
|
|
|
uris++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-05-02 14:04:53 +00:00
|
|
|
data->wp_hash = g_hash_table_new (g_str_hash, g_str_equal);
|
|
|
|
|
|
|
|
gconf_client_add_dir (data->client, WP_KEYBOARD_PATH,
|
|
|
|
GCONF_CLIENT_PRELOAD_ONELEVEL, NULL);
|
|
|
|
gconf_client_add_dir (data->client, WP_PATH_KEY,
|
|
|
|
GCONF_CLIENT_PRELOAD_ONELEVEL, NULL);
|
|
|
|
|
|
|
|
gconf_client_notify_add (data->client,
|
|
|
|
WP_FILE_KEY,
|
|
|
|
(GConfClientNotifyFunc) wp_file_changed,
|
|
|
|
data, NULL, NULL);
|
|
|
|
gconf_client_notify_add (data->client,
|
|
|
|
WP_OPTIONS_KEY,
|
|
|
|
(GConfClientNotifyFunc) wp_options_changed,
|
|
|
|
data, NULL, NULL);
|
|
|
|
gconf_client_notify_add (data->client,
|
|
|
|
WP_SHADING_KEY,
|
|
|
|
(GConfClientNotifyFunc) wp_shading_changed,
|
|
|
|
data, NULL, NULL);
|
|
|
|
gconf_client_notify_add (data->client,
|
|
|
|
WP_PCOLOR_KEY,
|
|
|
|
(GConfClientNotifyFunc) wp_color1_changed,
|
|
|
|
data, NULL, NULL);
|
|
|
|
gconf_client_notify_add (data->client,
|
|
|
|
WP_SCOLOR_KEY,
|
|
|
|
(GConfClientNotifyFunc) wp_color2_changed,
|
|
|
|
data, NULL, NULL);
|
|
|
|
|
|
|
|
data->wp_model = GTK_TREE_MODEL (gtk_list_store_new (3, GDK_TYPE_PIXBUF,
|
|
|
|
G_TYPE_STRING,
|
|
|
|
G_TYPE_STRING));
|
|
|
|
|
2007-05-10 16:31:18 +00:00
|
|
|
data->wp_view = GTK_ICON_VIEW (glade_xml_get_widget (data->xml, "wp_view"));
|
|
|
|
gtk_icon_view_set_model (data->wp_view, GTK_TREE_MODEL (data->wp_model));
|
|
|
|
|
2007-07-28 14:15:48 +00:00
|
|
|
g_signal_connect_after (data->wp_view, "realize",
|
2007-08-07 21:46:06 +00:00
|
|
|
(GCallback) wp_select_after_realize, data);
|
2007-05-12 13:30:05 +00:00
|
|
|
|
2007-05-10 16:31:18 +00:00
|
|
|
gtk_cell_layout_clear (GTK_CELL_LAYOUT (data->wp_view));
|
2007-05-02 14:04:53 +00:00
|
|
|
|
2007-07-29 17:45:51 +00:00
|
|
|
cr = cell_renderer_wallpaper_new ();
|
|
|
|
g_object_set (cr, "xpad", 5, "ypad", 5, NULL);
|
2007-05-02 14:04:53 +00:00
|
|
|
|
2007-07-29 17:45:51 +00:00
|
|
|
gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (data->wp_view), cr, TRUE);
|
|
|
|
gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (data->wp_view), cr,
|
2007-05-10 16:31:18 +00:00
|
|
|
"pixbuf", 0,
|
|
|
|
NULL);
|
2007-05-02 14:04:53 +00:00
|
|
|
|
|
|
|
gtk_tree_sortable_set_sort_func (GTK_TREE_SORTABLE (data->wp_model), 2,
|
|
|
|
(GtkTreeIterCompareFunc) wp_list_sort,
|
|
|
|
data, NULL);
|
|
|
|
|
|
|
|
gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (data->wp_model),
|
|
|
|
2, GTK_SORT_ASCENDING);
|
2007-05-16 16:15:45 +00:00
|
|
|
|
|
|
|
gtk_drag_dest_set (GTK_WIDGET (data->wp_view), GTK_DEST_DEFAULT_ALL, drop_types,
|
2007-07-28 14:15:48 +00:00
|
|
|
G_N_ELEMENTS (drop_types), GDK_ACTION_COPY | GDK_ACTION_MOVE);
|
|
|
|
g_signal_connect (data->wp_view, "drag_data_received",
|
2007-09-23 12:23:26 +00:00
|
|
|
(GCallback) wp_drag_received, data);
|
|
|
|
|
|
|
|
gtk_drag_source_set (GTK_WIDGET (data->wp_view), GDK_BUTTON1_MASK,
|
|
|
|
drag_types, G_N_ELEMENTS (drag_types), GDK_ACTION_COPY);
|
|
|
|
g_signal_connect (data->wp_view, "drag-data-get",
|
|
|
|
(GCallback) wp_drag_get_data, data);
|
2007-05-02 15:26:07 +00:00
|
|
|
|
2007-05-04 17:11:12 +00:00
|
|
|
data->wp_style_menu = glade_xml_get_widget (data->xml, "wp_style_menu");
|
2007-05-02 14:04:53 +00:00
|
|
|
|
2007-07-28 14:15:48 +00:00
|
|
|
g_signal_connect (data->wp_style_menu, "changed",
|
2007-08-07 21:46:06 +00:00
|
|
|
(GCallback) wp_scale_type_changed, data);
|
2007-05-02 14:04:53 +00:00
|
|
|
|
2007-05-04 17:11:12 +00:00
|
|
|
data->wp_color_menu = glade_xml_get_widget (data->xml, "wp_color_menu");
|
2007-05-02 14:04:53 +00:00
|
|
|
|
2007-07-28 14:15:48 +00:00
|
|
|
g_signal_connect (data->wp_color_menu, "changed",
|
2007-08-07 21:46:06 +00:00
|
|
|
(GCallback) wp_shade_type_changed, data);
|
2007-05-02 14:04:53 +00:00
|
|
|
|
2007-05-04 17:11:12 +00:00
|
|
|
data->wp_scpicker = glade_xml_get_widget (data->xml, "wp_scpicker");
|
2007-05-02 14:04:53 +00:00
|
|
|
|
2007-07-28 14:15:48 +00:00
|
|
|
g_signal_connect (data->wp_scpicker, "color-set",
|
2007-08-07 21:46:06 +00:00
|
|
|
(GCallback) wp_scolor_changed, data);
|
2007-05-02 14:04:53 +00:00
|
|
|
|
2007-05-04 17:11:12 +00:00
|
|
|
data->wp_pcpicker = glade_xml_get_widget (data->xml, "wp_pcpicker");
|
2007-05-02 14:04:53 +00:00
|
|
|
|
2007-07-28 14:15:48 +00:00
|
|
|
g_signal_connect (data->wp_pcpicker, "color-set",
|
2007-08-07 21:46:06 +00:00
|
|
|
(GCallback) wp_scolor_changed, data);
|
2007-05-02 14:04:53 +00:00
|
|
|
|
2007-05-07 18:22:01 +00:00
|
|
|
add_button = glade_xml_get_widget (data->xml, "wp_add_button");
|
|
|
|
gtk_button_set_image (GTK_BUTTON (add_button),
|
|
|
|
gtk_image_new_from_stock ("gtk-add", GTK_ICON_SIZE_BUTTON));
|
|
|
|
|
2007-07-28 14:15:48 +00:00
|
|
|
g_signal_connect (add_button, "clicked",
|
2007-08-07 21:46:06 +00:00
|
|
|
(GCallback) wp_file_open_dialog, data);
|
2007-05-07 18:22:01 +00:00
|
|
|
|
2007-05-04 17:11:12 +00:00
|
|
|
data->wp_rem_button = glade_xml_get_widget (data->xml, "wp_rem_button");
|
2007-05-02 14:04:53 +00:00
|
|
|
|
2007-07-28 14:15:48 +00:00
|
|
|
g_signal_connect (data->wp_rem_button, "clicked",
|
2007-08-07 21:46:06 +00:00
|
|
|
(GCallback) wp_remove_wallpaper, data);
|
2007-05-02 14:04:53 +00:00
|
|
|
|
|
|
|
g_idle_add (wp_load_stuffs, data);
|
|
|
|
|
2007-07-28 14:15:48 +00:00
|
|
|
g_signal_connect (data->wp_view, "selection-changed",
|
2007-08-07 21:46:06 +00:00
|
|
|
(GCallback) wp_props_wp_selected, data);
|
2007-07-28 14:15:48 +00:00
|
|
|
g_signal_connect (data->wp_view, "query-tooltip",
|
2007-08-07 21:46:06 +00:00
|
|
|
(GCallback) wp_view_tooltip_cb, data);
|
2007-06-17 15:55:58 +00:00
|
|
|
|
2007-05-02 14:04:53 +00:00
|
|
|
wp_set_sensitivities (data);
|
|
|
|
|
2007-07-31 21:15:02 +00:00
|
|
|
data->wp_filesel = GTK_FILE_CHOOSER (
|
|
|
|
gtk_file_chooser_dialog_new_with_backend (_("Add Wallpaper"),
|
2007-05-04 17:11:12 +00:00
|
|
|
GTK_WINDOW (glade_xml_get_widget (data->xml, "appearance_window")),
|
2007-05-02 14:04:53 +00:00
|
|
|
GTK_FILE_CHOOSER_ACTION_OPEN,
|
|
|
|
"gtk+",
|
|
|
|
GTK_STOCK_CANCEL,
|
|
|
|
GTK_RESPONSE_CANCEL,
|
|
|
|
GTK_STOCK_OPEN,
|
|
|
|
GTK_RESPONSE_OK,
|
2007-07-31 21:15:02 +00:00
|
|
|
NULL));
|
2007-05-02 14:04:53 +00:00
|
|
|
|
2007-07-31 21:15:02 +00:00
|
|
|
gtk_file_chooser_set_select_multiple (data->wp_filesel, TRUE);
|
|
|
|
gtk_file_chooser_set_use_preview_label (data->wp_filesel, FALSE);
|
|
|
|
|
2007-11-18 13:02:19 +00:00
|
|
|
start_dir = g_get_home_dir ();
|
|
|
|
|
|
|
|
if (g_file_test ("/usr/share/backgrounds", G_FILE_TEST_IS_DIR)) {
|
|
|
|
gtk_file_chooser_add_shortcut_folder (data->wp_filesel,
|
|
|
|
"/usr/share/backgrounds", NULL);
|
|
|
|
start_dir = "/usr/share/backgrounds";
|
|
|
|
}
|
|
|
|
|
2007-07-31 21:15:02 +00:00
|
|
|
pictures = g_get_user_special_dir (G_USER_DIRECTORY_PICTURES);
|
|
|
|
if (pictures != NULL && g_file_test (pictures, G_FILE_TEST_IS_DIR)) {
|
|
|
|
gtk_file_chooser_add_shortcut_folder (data->wp_filesel, pictures, NULL);
|
2007-11-18 13:02:19 +00:00
|
|
|
start_dir = pictures;
|
2007-07-31 21:15:02 +00:00
|
|
|
}
|
2007-05-02 14:04:53 +00:00
|
|
|
|
2007-11-18 13:02:19 +00:00
|
|
|
gtk_file_chooser_set_current_folder (data->wp_filesel, start_dir);
|
|
|
|
|
2007-05-02 14:04:53 +00:00
|
|
|
filter = gtk_file_filter_new ();
|
|
|
|
gtk_file_filter_add_pixbuf_formats (filter);
|
|
|
|
gtk_file_filter_set_name (filter, _("Images"));
|
2007-07-31 21:15:02 +00:00
|
|
|
gtk_file_chooser_add_filter (data->wp_filesel, filter);
|
2007-05-02 14:04:53 +00:00
|
|
|
|
|
|
|
filter = gtk_file_filter_new ();
|
2007-05-04 19:40:47 +00:00
|
|
|
gtk_file_filter_set_name (filter, _("All files"));
|
2007-05-02 14:04:53 +00:00
|
|
|
gtk_file_filter_add_pattern (filter, "*");
|
2007-07-31 21:15:02 +00:00
|
|
|
gtk_file_chooser_add_filter (data->wp_filesel, filter);
|
2007-05-02 14:04:53 +00:00
|
|
|
|
|
|
|
data->wp_image = gtk_image_new ();
|
2007-07-31 21:15:02 +00:00
|
|
|
gtk_file_chooser_set_preview_widget (data->wp_filesel, data->wp_image);
|
2007-05-02 14:04:53 +00:00
|
|
|
gtk_widget_set_size_request (data->wp_image, 128, -1);
|
|
|
|
|
|
|
|
gtk_widget_show (data->wp_image);
|
|
|
|
|
|
|
|
g_signal_connect (data->wp_filesel, "update-preview",
|
2007-08-07 21:46:06 +00:00
|
|
|
(GCallback) wp_update_preview, data);
|
2007-05-02 14:04:53 +00:00
|
|
|
}
|
2007-06-04 20:23:47 +00:00
|
|
|
|
|
|
|
void
|
|
|
|
desktop_shutdown (AppearanceData *data)
|
|
|
|
{
|
|
|
|
gnome_wp_xml_save_list (data);
|
2007-07-12 20:52:15 +00:00
|
|
|
g_slist_foreach (data->wp_uris, (GFunc) g_free, NULL);
|
|
|
|
g_slist_free (data->wp_uris);
|
2007-06-04 20:23:47 +00:00
|
|
|
g_object_ref_sink (data->wp_filesel);
|
|
|
|
g_object_unref (data->wp_filesel);
|
|
|
|
}
|