Update copyright info to have correct years (2003-2004)

2004-06-28  Rodney Dawes  <dobey@novell.com>

	* *.[ch]: Update copyright info to have correct years (2003-2004)

	* gnome-wp-capplet.c (gnome_wp_capplet_scroll_to_item):
	Abstract this code out so that we don't have to duplicated it every
	time we want to scroll to a particular item in the list

	(gnome_wp_add_image): Update this to return the new item that we
	created, and don't scroll to or set as the wallpaper, every time we
	call this function
	Use the new gnome_wp_item_new () call to create items

	(gnome_wp_add_images): Change the API to not use the files argument
	any longer, as we don't need it without the GTK+ 2.2 compat code
	Add all the items to the list and select the last one when finished

	(gnome_wp_file_open_dialog): Update to not pass in the files argument
	to gnome_wp_add_images () and free the GSList of filenames

	(bg_add_multiple_files): merge this code into the normal callback for
	when images are dragged to the dialog

	(bg_properties_dragged_image): Don't check if the list is more than
	1 or not here, and always call gnome_wp_add_images () with the full
	list that we are given
	Convert the GList of GnomeVFSURIs that we get from gnome-vfs to a
	GSList of char * uris to pass into gnome_wp_add_images ()

	(gnome_wp_load_stuffs, gnome_wp_file_changed):
	Use the new gnome_wp_capplet_scroll_to_item () and gnome_wp_item_new ()
	API calls instead of duplicating code

	* gnome-wp-capplet.h: Remove the GConf key path defines from here

	* gnome-wp-item.[ch]: Add the gnome_wp_item_new () call to create the
	GnomeWPItem structure for storing wallpapers in

	* gnome-wp-utils.h: Put the GConf key path defines in here

	* gnome-wp-xml.c (gnome_wp_load_legacy): Use the gnome_wp_item_new ()
	call to create items from the old legacy (XD2 capplet) list file
This commit is contained in:
Rodney Dawes 2004-06-28 18:51:21 +00:00 committed by Rodney Dawes
parent fb35d020a6
commit 4d87d80f3e
11 changed files with 171 additions and 353 deletions

View file

@ -1,3 +1,46 @@
2004-06-28 Rodney Dawes <dobey@novell.com>
* *.[ch]: Update copyright info to have correct years (2003-2004)
* gnome-wp-capplet.c (gnome_wp_capplet_scroll_to_item):
Abstract this code out so that we don't have to duplicated it every
time we want to scroll to a particular item in the list
(gnome_wp_add_image): Update this to return the new item that we
created, and don't scroll to or set as the wallpaper, every time we
call this function
Use the new gnome_wp_item_new () call to create items
(gnome_wp_add_images): Change the API to not use the files argument
any longer, as we don't need it without the GTK+ 2.2 compat code
Add all the items to the list and select the last one when finished
(gnome_wp_file_open_dialog): Update to not pass in the files argument
to gnome_wp_add_images () and free the GSList of filenames
(bg_add_multiple_files): merge this code into the normal callback for
when images are dragged to the dialog
(bg_properties_dragged_image): Don't check if the list is more than
1 or not here, and always call gnome_wp_add_images () with the full
list that we are given
Convert the GList of GnomeVFSURIs that we get from gnome-vfs to a
GSList of char * uris to pass into gnome_wp_add_images ()
(gnome_wp_load_stuffs, gnome_wp_file_changed):
Use the new gnome_wp_capplet_scroll_to_item () and gnome_wp_item_new ()
API calls instead of duplicating code
* gnome-wp-capplet.h: Remove the GConf key path defines from here
* gnome-wp-item.[ch]: Add the gnome_wp_item_new () call to create the
GnomeWPItem structure for storing wallpapers in
* gnome-wp-utils.h: Put the GConf key path defines in here
* gnome-wp-xml.c (gnome_wp_load_legacy): Use the gnome_wp_item_new ()
call to create items from the old legacy (XD2 capplet) list file
2004-05-14 Muktha Narayan <muktha.narayan@wipro.com> 2004-05-14 Muktha Narayan <muktha.narayan@wipro.com>
* gnome-wp-capplet.c (set_accessible_name): New * gnome-wp-capplet.c (set_accessible_name): New

View file

@ -1,7 +1,7 @@
/* /*
* Authors: Rodney Dawes <dobey@ximian.com> * Authors: Rodney Dawes <dobey@ximian.com>
* *
* Copyright 2003 Novell, Inc. (www.novell.com) * Copyright 2003-2004 Novell, Inc. (www.novell.com)
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of version 2 of the GNU General Public License * it under the terms of version 2 of the GNU General Public License
@ -74,87 +74,47 @@ static void wp_properties_help (GtkWindow * parent, char const * helpfile,
} }
} }
static void gnome_wp_add_image (GnomeWPCapplet * capplet, static void gnome_wp_capplet_scroll_to_item (GnomeWPCapplet * capplet,
const gchar * filename) { GnomeWPItem * item) {
GnomeWPItem * item;
GtkTreePath * path; GtkTreePath * path;
GdkColor color1, color2;
g_return_if_fail (capplet != NULL);
g_return_if_fail (item != NULL);
path = gtk_tree_row_reference_get_path (item->rowref);
gtk_tree_view_set_cursor (GTK_TREE_VIEW (capplet->treeview), path,
NULL, FALSE);
gtk_tree_view_scroll_to_cell (GTK_TREE_VIEW (capplet->treeview),
path, NULL, TRUE, 0.5, 0.0);
gtk_tree_path_free (path);
}
static GnomeWPItem * gnome_wp_add_image (GnomeWPCapplet * capplet,
const gchar * filename) {
GnomeWPItem * item;
item = g_hash_table_lookup (capplet->wphash, filename); item = g_hash_table_lookup (capplet->wphash, filename);
if (item != NULL) { if (item != NULL) {
GtkTreePath * path;
if (item->deleted) { if (item->deleted) {
item->deleted = FALSE; item->deleted = FALSE;
wp_props_load_wallpaper (item->filename, item, capplet); wp_props_load_wallpaper (item->filename, item, capplet);
} }
path = gtk_tree_row_reference_get_path (item->rowref);
gtk_tree_view_set_cursor (GTK_TREE_VIEW (capplet->treeview), path,
NULL, FALSE);
gtk_tree_view_scroll_to_cell (GTK_TREE_VIEW (capplet->treeview),
path, NULL, TRUE, 0.5, 0.0);
gtk_tree_path_free (path);
return;
}
item = g_new0 (GnomeWPItem, 1);
item->filename = g_strdup (filename);
item->fileinfo = gnome_wp_info_new (item->filename, capplet->thumbs);
item->shade_type = gconf_client_get_string (capplet->client,
WP_SHADING_KEY, NULL);
item->pri_color = gconf_client_get_string (capplet->client,
WP_PCOLOR_KEY, NULL);
item->sec_color = gconf_client_get_string (capplet->client,
WP_SCOLOR_KEY, NULL);
gdk_color_parse (item->pri_color, &color1);
gdk_color_parse (item->sec_color, &color2);
item->pcolor = gdk_color_copy (&color1);
item->scolor = gdk_color_copy (&color2);
if (!strncmp (item->fileinfo->mime_type, "image/", strlen ("image/"))) {
if (item->name == NULL) {
item->name = g_strdup (item->fileinfo->name);
}
item->options = gconf_client_get_string (capplet->client,
WP_OPTIONS_KEY,
NULL);
if (!strcmp (item->options, "none")) {
item->options = g_strdup ("wallpaper");
}
gnome_wp_item_update_description (item);
g_hash_table_insert (capplet->wphash, g_strdup (item->filename), item);
wp_props_load_wallpaper (item->filename, item, capplet);
gconf_client_set_string (capplet->client, WP_FILE_KEY,
item->filename, NULL);
gconf_client_set_string (capplet->client, WP_OPTIONS_KEY,
item->options, NULL);
path = gtk_tree_row_reference_get_path (item->rowref);
gtk_tree_view_set_cursor (GTK_TREE_VIEW (capplet->treeview), path,
NULL, FALSE);
gtk_tree_view_scroll_to_cell (GTK_TREE_VIEW (capplet->treeview),
path, NULL, TRUE, 0.5, 0.0);
gtk_tree_path_free (path);
} else { } else {
gnome_wp_item_free (item); item = gnome_wp_item_new (filename, capplet->wphash, capplet->thumbs);
if (item != NULL) {
wp_props_load_wallpaper (item->filename, item, capplet);
}
} }
return item;
} }
static void gnome_wp_add_images (GnomeWPCapplet * capplet, static void gnome_wp_add_images (GnomeWPCapplet * capplet,
GSList * images, GSList * images) {
gchar ** files) {
GdkCursor * cursor; GdkCursor * cursor;
gint i; GnomeWPItem * item;
item = NULL;
cursor = gdk_cursor_new_for_display (gdk_display_get_default (), cursor = gdk_cursor_new_for_display (gdk_display_get_default (),
GDK_WATCH); GDK_WATCH);
gdk_window_set_cursor (capplet->window->window, cursor); gdk_window_set_cursor (capplet->window->window, cursor);
@ -162,15 +122,15 @@ static void gnome_wp_add_images (GnomeWPCapplet * capplet,
if (images != NULL) { if (images != NULL) {
for (; images != NULL; images = images->next) { for (; images != NULL; images = images->next) {
gnome_wp_add_image (capplet, images->data); item = gnome_wp_add_image (capplet, images->data);
}
} else {
for (i = 0; files && files[i]; i++) {
gnome_wp_add_image (capplet, files[i]);
} }
} }
gdk_window_set_cursor (capplet->window->window, NULL); gdk_window_set_cursor (capplet->window->window, NULL);
if (item != NULL) {
gnome_wp_capplet_scroll_to_item (capplet, item);
}
} }
static void gnome_wp_file_open_dialog (GtkWidget * widget, static void gnome_wp_file_open_dialog (GtkWidget * widget,
@ -180,7 +140,8 @@ static void gnome_wp_file_open_dialog (GtkWidget * widget,
switch (gtk_dialog_run (GTK_DIALOG (capplet->filesel))) { switch (gtk_dialog_run (GTK_DIALOG (capplet->filesel))) {
case GTK_RESPONSE_OK: case GTK_RESPONSE_OK:
files = gtk_file_chooser_get_filenames (GTK_FILE_CHOOSER (capplet->filesel)); files = gtk_file_chooser_get_filenames (GTK_FILE_CHOOSER (capplet->filesel));
gnome_wp_add_images (capplet, files, NULL); gnome_wp_add_images (capplet, files);
g_slist_free (files);
case GTK_RESPONSE_CANCEL: case GTK_RESPONSE_CANCEL:
default: default:
gtk_widget_hide (capplet->filesel); gtk_widget_hide (capplet->filesel);
@ -188,44 +149,6 @@ static void gnome_wp_file_open_dialog (GtkWidget * widget,
} }
} }
static void bg_add_multiple_files (GnomeVFSURI * uri,
GnomeWPCapplet * capplet) {
GnomeWPItem * item;
GdkColor color1, color2;
item = g_hash_table_lookup (capplet->wphash, gnome_vfs_uri_get_path (uri));
if (item != NULL) {
return;
}
item = g_new0 (GnomeWPItem, 1);
item->filename = gnome_vfs_unescape_string_for_display (gnome_vfs_uri_get_path (uri));
item->fileinfo = gnome_wp_info_new (item->filename, capplet->thumbs);
item->name = g_strdup (item->fileinfo->name);
item->options = gconf_client_get_string (capplet->client,
WP_OPTIONS_KEY,
NULL);
item->shade_type = gconf_client_get_string (capplet->client,
WP_SHADING_KEY, NULL);
item->pri_color = gconf_client_get_string (capplet->client,
WP_PCOLOR_KEY, NULL);
item->sec_color = gconf_client_get_string (capplet->client,
WP_SCOLOR_KEY, NULL);
gdk_color_parse (item->pri_color, &color1);
gdk_color_parse (item->sec_color, &color2);
item->pcolor = gdk_color_copy (&color1);
item->scolor = gdk_color_copy (&color2);
gnome_wp_item_update_description (item);
g_hash_table_insert (capplet->wphash, g_strdup (item->filename), item);
wp_props_load_wallpaper (item->filename, item, capplet);
}
static void bg_properties_dragged_image (GtkWidget * widget, static void bg_properties_dragged_image (GtkWidget * widget,
GdkDragContext * context, GdkDragContext * context,
gint x, gint y, gint x, gint y,
@ -235,77 +158,27 @@ static void bg_properties_dragged_image (GtkWidget * widget,
if (info == TARGET_URI_LIST || info == TARGET_BGIMAGE) { if (info == TARGET_URI_LIST || info == TARGET_BGIMAGE) {
GList * uris; GList * uris;
GSList * realuris = NULL;
uris = gnome_vfs_uri_list_parse ((gchar *) selection_data->data); uris = gnome_vfs_uri_list_parse ((gchar *) selection_data->data);
if (uris != NULL && uris->data != NULL) { if (uris != NULL && uris->data != NULL) {
if (g_list_length (uris) == 1) { GdkCursor * cursor;
GnomeVFSURI * uri = (GnomeVFSURI *) uris->data;
GnomeWPItem * item;
GtkTreePath * path;
item = g_hash_table_lookup (capplet->wphash, cursor = gdk_cursor_new_for_display (gdk_display_get_default (),
gnome_vfs_uri_get_path (uri)); GDK_WATCH);
gdk_window_set_cursor (capplet->window->window, cursor);
gdk_cursor_unref (cursor);
if (item == NULL) { for (; uris != NULL; uris = uris->next) {
GdkColor color1, color2; realuris = g_slist_append (realuris,
g_strdup (gnome_vfs_uri_get_path (uris->data)));
item = g_new0 (GnomeWPItem, 1);
item->filename = gnome_vfs_unescape_string_for_display (gnome_vfs_uri_get_path (uri));
item->fileinfo = gnome_wp_info_new (item->filename, capplet->thumbs);
item->name = g_strdup (item->fileinfo->name);
item->options = gconf_client_get_string (capplet->client,
WP_OPTIONS_KEY,
NULL);
item->shade_type = gconf_client_get_string (capplet->client,
WP_SHADING_KEY, NULL);
item->pri_color = gconf_client_get_string (capplet->client,
WP_PCOLOR_KEY, NULL);
item->sec_color = gconf_client_get_string (capplet->client,
WP_SCOLOR_KEY, NULL);
gdk_color_parse (item->pri_color, &color1);
gdk_color_parse (item->sec_color, &color2);
item->pcolor = gdk_color_copy (&color1);
item->scolor = gdk_color_copy (&color2);
gnome_wp_item_update_description (item);
g_hash_table_insert (capplet->wphash, g_strdup (item->filename),
item);
wp_props_load_wallpaper (item->filename, item, capplet);
} else if (item->deleted) {
item->deleted = FALSE;
wp_props_load_wallpaper (item->filename, item, capplet);
}
gconf_client_set_string (capplet->client, WP_FILE_KEY,
item->filename, NULL);
gconf_client_set_string (capplet->client, WP_OPTIONS_KEY,
item->options, NULL);
path = gtk_tree_row_reference_get_path (item->rowref);
gtk_tree_view_set_cursor (GTK_TREE_VIEW (capplet->treeview), path,
NULL, FALSE);
gtk_tree_view_scroll_to_cell (GTK_TREE_VIEW (capplet->treeview),
path, NULL, TRUE, 0.5, 0.0);
gtk_tree_path_free (path);
} else if (g_list_length (uris) > 1) {
GdkCursor * cursor;
cursor = gdk_cursor_new_for_display (gdk_display_get_default (),
GDK_WATCH);
gdk_window_set_cursor (capplet->window->window, cursor);
gdk_cursor_unref (cursor);
g_list_foreach (uris, (GFunc) bg_add_multiple_files, capplet);
gdk_window_set_cursor (capplet->window->window, NULL);
} }
gnome_wp_add_images (capplet, realuris);
gdk_window_set_cursor (capplet->window->window, NULL);
} }
gnome_vfs_uri_list_free (uris); gnome_vfs_uri_list_free (uris);
g_slist_free (realuris);
} }
} }
@ -715,7 +588,6 @@ static gboolean gnome_wp_load_stuffs (void * data) {
GnomeWPCapplet * capplet = (GnomeWPCapplet *) data; GnomeWPCapplet * capplet = (GnomeWPCapplet *) data;
gchar * imagepath, * style; gchar * imagepath, * style;
GnomeWPItem * item; GnomeWPItem * item;
GtkTreePath * path;
style = gconf_client_get_string (capplet->client, style = gconf_client_get_string (capplet->client,
WP_OPTIONS_KEY, WP_OPTIONS_KEY,
@ -738,12 +610,7 @@ static gboolean gnome_wp_load_stuffs (void * data) {
wp_props_load_wallpaper (item->filename, item, capplet); wp_props_load_wallpaper (item->filename, item, capplet);
} }
path = gtk_tree_row_reference_get_path (item->rowref); gnome_wp_capplet_scroll_to_item (capplet, item);
gtk_tree_view_set_cursor (GTK_TREE_VIEW (capplet->treeview), path,
NULL, FALSE);
gtk_tree_view_scroll_to_cell (GTK_TREE_VIEW (capplet->treeview),
path, NULL, TRUE, 0.5, 0.0);
gtk_tree_path_free (path);
gnome_wp_option_menu_set (capplet, item->options, FALSE); gnome_wp_option_menu_set (capplet, item->options, FALSE);
gnome_wp_option_menu_set (capplet, item->shade_type, TRUE); gnome_wp_option_menu_set (capplet, item->shade_type, TRUE);
@ -757,44 +624,11 @@ static gboolean gnome_wp_load_stuffs (void * data) {
item->scolor->green, item->scolor->green,
item->scolor->blue, 65535); item->scolor->blue, 65535);
} else if (strcmp (style, "none") != 0) { } else if (strcmp (style, "none") != 0) {
GdkColor color1, color2; item = gnome_wp_item_new (imagepath, capplet->wphash, capplet->thumbs);
if (item != NULL) {
item = g_new0 (GnomeWPItem, 1);
item->filename = g_strdup (imagepath);
item->shade_type = gconf_client_get_string (capplet->client,
WP_SHADING_KEY, NULL);
item->pri_color = gconf_client_get_string (capplet->client,
WP_PCOLOR_KEY, NULL);
item->sec_color = gconf_client_get_string (capplet->client,
WP_SCOLOR_KEY, NULL);
gdk_color_parse (item->pri_color, &color1);
gdk_color_parse (item->sec_color, &color2);
item->pcolor = gdk_color_copy (&color1);
item->scolor = gdk_color_copy (&color2);
if (g_file_test (item->filename, G_FILE_TEST_EXISTS)) {
item->fileinfo = gnome_wp_info_new (item->filename, capplet->thumbs);
item->name = g_strdup (item->fileinfo->name);
item->options = gconf_client_get_string (capplet->client,
WP_OPTIONS_KEY,
NULL);
item->deleted = FALSE;
gnome_wp_item_update_description (item);
g_hash_table_insert (capplet->wphash, g_strdup (item->filename), item);
wp_props_load_wallpaper (item->filename, item, capplet); wp_props_load_wallpaper (item->filename, item, capplet);
path = gtk_tree_row_reference_get_path (item->rowref); gnome_wp_capplet_scroll_to_item (capplet, item);
gtk_tree_view_set_cursor (GTK_TREE_VIEW (capplet->treeview), path,
NULL, FALSE);
gtk_tree_view_scroll_to_cell (GTK_TREE_VIEW (capplet->treeview),
path, NULL, TRUE, 0.5, 0.0);
gtk_tree_path_free (path);
gnome_color_picker_set_i16 (GNOME_COLOR_PICKER (capplet->pc_picker), gnome_color_picker_set_i16 (GNOME_COLOR_PICKER (capplet->pc_picker),
item->pcolor->red, item->pcolor->red,
@ -807,43 +641,15 @@ static gboolean gnome_wp_load_stuffs (void * data) {
gnome_wp_option_menu_set (capplet, item->options, FALSE); gnome_wp_option_menu_set (capplet, item->options, FALSE);
gnome_wp_option_menu_set (capplet, item->shade_type, TRUE); gnome_wp_option_menu_set (capplet, item->shade_type, TRUE);
} else {
gnome_wp_item_free (item);
} }
} }
item = g_hash_table_lookup (capplet->wphash, "(none)"); item = g_hash_table_lookup (capplet->wphash, "(none)");
if (item == NULL) { if (item == NULL) {
GdkColor color1, color2; item = gnome_wp_item_new ("(none)", capplet->wphash, capplet->thumbs);
if (item != NULL) {
item = g_new0 (GnomeWPItem, 1); wp_props_load_wallpaper (item->filename, item, capplet);
}
item->deleted = FALSE;
item->filename = g_strdup ("(none)");
item->shade_type = gconf_client_get_string (capplet->client,
WP_SHADING_KEY, NULL);
item->pri_color = gconf_client_get_string (capplet->client,
WP_PCOLOR_KEY, NULL);
item->sec_color = gconf_client_get_string (capplet->client,
WP_SCOLOR_KEY, NULL);
gdk_color_parse (item->pri_color, &color1);
gdk_color_parse (item->sec_color, &color2);
item->pcolor = gdk_color_copy (&color1);
item->scolor = gdk_color_copy (&color2);
item->fileinfo = gnome_wp_info_new (item->filename, capplet->thumbs);
item->name = g_strdup (item->fileinfo->name);
item->options = gconf_client_get_string (capplet->client,
WP_OPTIONS_KEY,
NULL);
gnome_wp_item_update_description (item);
g_hash_table_insert (capplet->wphash, g_strdup (item->filename), item);
wp_props_load_wallpaper (item->filename, item, capplet);
} else { } else {
if (item->deleted == TRUE) { if (item->deleted == TRUE) {
item->deleted = FALSE; item->deleted = FALSE;
@ -851,12 +657,7 @@ static gboolean gnome_wp_load_stuffs (void * data) {
} }
if (!strcmp (style, "none")) { if (!strcmp (style, "none")) {
path = gtk_tree_row_reference_get_path (item->rowref); gnome_wp_capplet_scroll_to_item (capplet, item);
gtk_tree_view_set_cursor (GTK_TREE_VIEW (capplet->treeview), path,
NULL, FALSE);
gtk_tree_view_scroll_to_cell (GTK_TREE_VIEW (capplet->treeview),
path, NULL, TRUE, 0.5, 0.0);
gtk_tree_path_free (path);
} }
} }
g_free (imagepath); g_free (imagepath);
@ -889,7 +690,6 @@ static void gnome_wp_file_changed (GConfClient * client, guint id,
GtkTreeSelection * selection; GtkTreeSelection * selection;
GtkTreeModel * model; GtkTreeModel * model;
GtkTreeIter iter; GtkTreeIter iter;
GtkTreePath * path;
GnomeWPItem * item; GnomeWPItem * item;
gchar * wpfile, * selected; gchar * wpfile, * selected;
@ -901,52 +701,13 @@ static void gnome_wp_file_changed (GConfClient * client, guint id,
gtk_tree_model_get (model, &iter, 2, &selected, -1); gtk_tree_model_get (model, &iter, 2, &selected, -1);
if (strcmp (selected, wpfile) != 0) { if (strcmp (selected, wpfile) != 0) {
if (item != NULL) { if (item != NULL) {
path = gtk_tree_row_reference_get_path (item->rowref); gnome_wp_capplet_scroll_to_item (capplet, item);
gtk_tree_view_set_cursor (GTK_TREE_VIEW (capplet->treeview), path,
NULL, FALSE);
gtk_tree_view_scroll_to_cell (GTK_TREE_VIEW (capplet->treeview),
path, NULL, TRUE, 0.5, 0.0);
gtk_tree_path_free (path);
} else { } else {
GdkColor color1, color2; item = gnome_wp_item_new (wpfile, capplet->wphash, capplet->thumbs);
if (item != NULL) {
item = g_new0 (GnomeWPItem, 1);
item->filename = g_strdup (wpfile);
item->shade_type = gconf_client_get_string (capplet->client,
WP_SHADING_KEY, NULL);
item->pri_color = gconf_client_get_string (capplet->client,
WP_PCOLOR_KEY, NULL);
item->sec_color = gconf_client_get_string (capplet->client,
WP_SCOLOR_KEY, NULL);
gdk_color_parse (item->pri_color, &color1);
gdk_color_parse (item->sec_color, &color2);
item->pcolor = gdk_color_copy (&color1);
item->scolor = gdk_color_copy (&color2);
if (g_file_test (item->filename, G_FILE_TEST_EXISTS)) {
item->fileinfo = gnome_wp_info_new (item->filename, capplet->thumbs);
item->name = g_strdup (item->fileinfo->name);
item->options = gconf_client_get_string (capplet->client,
WP_OPTIONS_KEY,
NULL);
gnome_wp_item_update_description (item);
g_hash_table_insert (capplet->wphash,
g_strdup (item->filename), item);
wp_props_load_wallpaper (item->filename, item, capplet); wp_props_load_wallpaper (item->filename, item, capplet);
path = gtk_tree_row_reference_get_path (item->rowref); gnome_wp_capplet_scroll_to_item (capplet, item);
gtk_tree_view_set_cursor (GTK_TREE_VIEW (capplet->treeview), path,
NULL, FALSE);
gtk_tree_view_scroll_to_cell (GTK_TREE_VIEW (capplet->treeview),
path, NULL, TRUE, 0.5, 0.0);
gtk_tree_path_free (path);
} else {
gnome_wp_item_free (item);
} }
} }
} }

View file

@ -1,7 +1,7 @@
/* /*
* Authors: Rodney Dawes <dobey@ximian.com> * Authors: Rodney Dawes <dobey@ximian.com>
* *
* Copyright 2003 Novell, Inc. (www.novell.com) * Copyright 2003-2004 Novell, Inc. (www.novell.com)
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of version 2 of the GNU General Public License * it under the terms of version 2 of the GNU General Public License
@ -99,15 +99,6 @@ typedef enum {
GNOME_WP_SCALE_TYPE_TILED GNOME_WP_SCALE_TYPE_TILED
} GnomeWPScaleType; } GnomeWPScaleType;
#define WP_PATH_KEY "/desktop/gnome/background"
#define WP_FILE_KEY WP_PATH_KEY "/picture_filename"
#define WP_OPTIONS_KEY WP_PATH_KEY "/picture_options"
#define WP_SHADING_KEY WP_PATH_KEY "/color_shading_type"
#define WP_PCOLOR_KEY WP_PATH_KEY "/primary_color"
#define WP_SCOLOR_KEY WP_PATH_KEY "/secondary_color"
#define WP_KEYBOARD_PATH "/desktop/gnome/peripherals/keyboard"
#define WP_DELAY_KEY WP_KEYBOARD_PATH "/delay"
void gnome_wp_main_quit (GnomeWPCapplet * capplet); void gnome_wp_main_quit (GnomeWPCapplet * capplet);
#endif #endif

View file

@ -1,7 +1,7 @@
/* /*
* Authors: Rodney Dawes <dobey@ximian.com> * Authors: Rodney Dawes <dobey@ximian.com>
* *
* Copyright 2003 Novell, Inc. (www.novell.com) * Copyright 2003-2004 Novell, Inc. (www.novell.com)
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of version 2 of the GNU General Public License * it under the terms of version 2 of the GNU General Public License

View file

@ -1,7 +1,7 @@
/* /*
* Authors: Rodney Dawes <dobey@ximian.com> * Authors: Rodney Dawes <dobey@ximian.com>
* *
* Copyright 2003 Novell, Inc. (www.novell.com) * Copyright 2003-2004 Novell, Inc. (www.novell.com)
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of version 2 of the GNU General Public License * it under the terms of version 2 of the GNU General Public License

View file

@ -1,7 +1,7 @@
/* /*
* Authors: Rodney Dawes <dobey@ximian.com> * Authors: Rodney Dawes <dobey@ximian.com>
* *
* Copyright 2003 Novell, Inc. (www.novell.com) * Copyright 2003-2004 Novell, Inc. (www.novell.com)
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of version 2 of the GNU General Public License * it under the terms of version 2 of the GNU General Public License
@ -20,6 +20,7 @@
#include <config.h> #include <config.h>
#include <gconf/gconf-client.h>
#include <gnome.h> #include <gnome.h>
#include <string.h> #include <string.h>
#include <libgnomevfs/gnome-vfs-mime-handlers.h> #include <libgnomevfs/gnome-vfs-mime-handlers.h>
@ -27,6 +28,51 @@
#include "gnome-wp-item.h" #include "gnome-wp-item.h"
#include "gnome-wp-utils.h" #include "gnome-wp-utils.h"
GnomeWPItem * gnome_wp_item_new (const gchar * filename,
GHashTable * wallpapers,
GnomeThumbnailFactory * thumbnails) {
GnomeWPItem * item = NULL;
GdkColor color1, color2;
GConfClient * client;
client = gconf_client_get_default ();
item = g_new0 (GnomeWPItem, 1);
item->filename = g_strdup (filename);
item->fileinfo = gnome_wp_info_new (item->filename, thumbnails);
item->shade_type = gconf_client_get_string (client, WP_SHADING_KEY, NULL);
item->pri_color = gconf_client_get_string (client, WP_PCOLOR_KEY, NULL);
item->sec_color = gconf_client_get_string (client, WP_SCOLOR_KEY, NULL);
gdk_color_parse (item->pri_color, &color1);
gdk_color_parse (item->sec_color, &color2);
item->pcolor = gdk_color_copy (&color1);
item->scolor = gdk_color_copy (&color2);
if (!strncmp (item->fileinfo->mime_type, "image/", strlen ("image/"))) {
if (item->name == NULL) {
item->name = g_strdup (item->fileinfo->name);
}
item->options = gconf_client_get_string (client, WP_OPTIONS_KEY, NULL);
if (!strcmp (item->options, "none")) {
item->options = g_strdup ("wallpaper");
}
gnome_wp_item_update_description (item);
g_hash_table_insert (wallpapers, g_strdup (item->filename), item);
} else {
gnome_wp_item_free (item);
item = NULL;
}
return item;
}
void gnome_wp_item_free (GnomeWPItem * item) { void gnome_wp_item_free (GnomeWPItem * item) {
if (item == NULL) { if (item == NULL) {
return; return;

View file

@ -1,7 +1,7 @@
/* /*
* Authors: Rodney Dawes <dobey@ximian.com> * Authors: Rodney Dawes <dobey@ximian.com>
* *
* Copyright 2003 Novell, Inc. (www.novell.com) * Copyright 2003-2004 Novell, Inc. (www.novell.com)
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of version 2 of the GNU General Public License * it under the terms of version 2 of the GNU General Public License
@ -58,6 +58,9 @@ struct _GnomeWPItem {
gint height; gint height;
}; };
GnomeWPItem * gnome_wp_item_new (const gchar * filename,
GHashTable * wallpapers,
GnomeThumbnailFactory * thumbnails);
void gnome_wp_item_free (GnomeWPItem * item); void gnome_wp_item_free (GnomeWPItem * item);
GdkPixbuf * gnome_wp_item_get_thumbnail (GnomeWPItem * item, GdkPixbuf * gnome_wp_item_get_thumbnail (GnomeWPItem * item,
GnomeThumbnailFactory * thumbs); GnomeThumbnailFactory * thumbs);

View file

@ -1,7 +1,7 @@
/* /*
* Authors: Rodney Dawes <dobey@ximian.com> * Authors: Rodney Dawes <dobey@ximian.com>
* *
* Copyright 2003 Novell, Inc. (www.novell.com) * Copyright 2003-2004 Novell, Inc. (www.novell.com)
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of version 2 of the GNU General Public License * it under the terms of version 2 of the GNU General Public License

View file

@ -1,7 +1,7 @@
/* /*
* Authors: Rodney Dawes <dobey@ximian.com> * Authors: Rodney Dawes <dobey@ximian.com>
* *
* Copyright 2003 Novell, Inc. (www.novell.com) * Copyright 2003-2004 Novell, Inc. (www.novell.com)
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of version 2 of the GNU General Public License * it under the terms of version 2 of the GNU General Public License
@ -24,6 +24,15 @@
#include <glib.h> #include <glib.h>
#include <gtk/gtk.h> #include <gtk/gtk.h>
#define WP_PATH_KEY "/desktop/gnome/background"
#define WP_FILE_KEY WP_PATH_KEY "/picture_filename"
#define WP_OPTIONS_KEY WP_PATH_KEY "/picture_options"
#define WP_SHADING_KEY WP_PATH_KEY "/color_shading_type"
#define WP_PCOLOR_KEY WP_PATH_KEY "/primary_color"
#define WP_SCOLOR_KEY WP_PATH_KEY "/secondary_color"
#define WP_KEYBOARD_PATH "/desktop/gnome/peripherals/keyboard"
#define WP_DELAY_KEY WP_KEYBOARD_PATH "/delay"
G_BEGIN_DECLS G_BEGIN_DECLS
GdkPixbuf * gnome_wp_pixbuf_new_gradient (GtkOrientation orientation, GdkPixbuf * gnome_wp_pixbuf_new_gradient (GtkOrientation orientation,

View file

@ -1,7 +1,7 @@
/* /*
* Authors: Rodney Dawes <dobey@ximian.com> * Authors: Rodney Dawes <dobey@ximian.com>
* *
* Copyright 2003 Novell, Inc. (www.novell.com) * Copyright 2003-2004 Novell, Inc. (www.novell.com)
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of version 2 of the GNU General Public License * it under the terms of version 2 of the GNU General Public License
@ -56,7 +56,6 @@ static void gnome_wp_xml_set_bool (const xmlNode * parent,
static void gnome_wp_load_legacy (GnomeWPCapplet * capplet) { static void gnome_wp_load_legacy (GnomeWPCapplet * capplet) {
FILE * fp; FILE * fp;
gchar * foo, * filename; gchar * foo, * filename;
GdkColor color1, color2;
filename = g_build_filename (g_get_home_dir (), ".gnome2", filename = g_build_filename (g_get_home_dir (), ".gnome2",
"wallpapers.list", NULL); "wallpapers.list", NULL);
@ -80,42 +79,8 @@ static void gnome_wp_load_legacy (GnomeWPCapplet * capplet) {
continue; continue;
} }
item = g_new0 (GnomeWPItem, 1); item = gnome_wp_item_new (foo, capplet->wphash, capplet->thumbs);
if (item != NULL && item->fileinfo == NULL) {
item->filename = g_strdup (foo);
item->fileinfo = gnome_wp_info_new (item->filename, capplet->thumbs);
if (item->fileinfo == NULL) {
gnome_wp_item_free (item);
continue;
}
item->shade_type = gconf_client_get_string (capplet->client,
WP_SHADING_KEY, NULL);
item->pri_color = gconf_client_get_string (capplet->client,
WP_PCOLOR_KEY, NULL);
item->sec_color = gconf_client_get_string (capplet->client,
WP_SCOLOR_KEY, NULL);
gdk_color_parse (item->pri_color, &color1);
gdk_color_parse (item->sec_color, &color2);
item->pcolor = gdk_color_copy (&color1);
item->scolor = gdk_color_copy (&color2);
if (!strncmp (item->fileinfo->mime_type, "image/",
strlen ("image/"))) {
if (item->name == NULL) {
item->name = g_strdup (item->fileinfo->name);
}
item->options = gconf_client_get_string (capplet->client,
WP_OPTIONS_KEY,
NULL);
gnome_wp_item_update_description (item);
g_hash_table_insert (capplet->wphash, g_strdup (item->filename), item);
} else {
gnome_wp_item_free (item); gnome_wp_item_free (item);
} }
} }

View file

@ -1,7 +1,7 @@
/* /*
* Authors: Rodney Dawes <dobey@ximian.com> * Authors: Rodney Dawes <dobey@ximian.com>
* *
* Copyright 2003 Novell, Inc. (www.novell.com) * Copyright 2003-2004 Novell, Inc. (www.novell.com)
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of version 2 of the GNU General Public License * it under the terms of version 2 of the GNU General Public License