Switch the binary name to gnome-background-properties, Based on patch from

2004-02-01  Rodney Dawes  <dobey@ximian.com>

	* Makefile.am: Switch the binary name to gnome-background-properties,
	  Based on patch from Seth Nickell
	* background.desktop.in: Use gnome-background-properties here also,
	  based on patch from Seth Nickell
	* gnome-wp-capplet.c: Fix a bug where you can't re-add a wallpaper
	  after you remove it
	  Use the new gnome_wp_item_update_description () call
	  Use a GConfChangeSet to change the gconf keys, based on a patch
	  from Seth Nickell
	  Select the first item in the list ("No Wallpaper") when the wallpaper
	  is removed, based on a patch from Seth Nickell
	  Do the rc string parsing before creating the window, and change some
	  defaults so we can fix the spacing between widgets and the border
	  Fix spacing between widgets and window border
	* gnome-wp-item.[ch]: Add update_description function to clean up
	  code, based on patch from Seth Nickell
	  Fix a crash when trying to thumbnail very wide images that are very
	  short, while trying to maintain aspect ratio
	* gnome-wp-xml.c: Use backgrounds.xml instead of wp-list.xml, and
	  migrate the old wp-list.xml over if backgrounds.xml doesn't exist
	  yet, based on patch from Seth Nickell
This commit is contained in:
Rodney Dawes 2004-02-01 20:57:47 +00:00 committed by Rodney Dawes
parent 82edf41b76
commit 5e266cc532
7 changed files with 110 additions and 69 deletions

View file

@ -1,3 +1,27 @@
2004-02-01 Rodney Dawes <dobey@ximian.com>
* Makefile.am: Switch the binary name to gnome-background-properties,
Based on patch from Seth Nickell
* background.desktop.in: Use gnome-background-properties here also,
based on patch from Seth Nickell
* gnome-wp-capplet.c: Fix a bug where you can't re-add a wallpaper
after you remove it
Use the new gnome_wp_item_update_description () call
Use a GConfChangeSet to change the gconf keys, based on a patch
from Seth Nickell
Select the first item in the list ("No Wallpaper") when the wallpaper
is removed, based on a patch from Seth Nickell
Do the rc string parsing before creating the window, and change some
defaults so we can fix the spacing between widgets and the border
Fix spacing between widgets and window border
* gnome-wp-item.[ch]: Add update_description function to clean up
code, based on patch from Seth Nickell
Fix a crash when trying to thumbnail very wide images that are very
short, while trying to maintain aspect ratio
* gnome-wp-xml.c: Use backgrounds.xml instead of wp-list.xml, and
migrate the old wp-list.xml over if backgrounds.xml doesn't exist
yet, based on patch from Seth Nickell
2004-01-18 Rodney Dawes <dobey@ximian.com>
* gnome-wp-capplet.c: Enable the Help button (#131286)

View file

@ -1,16 +1,18 @@
WALLPAPER_DATADIR = $(datadir)/gnome-wallpaper-properties
WALLPAPER_DATADIR = $(datadir)/gnome-background-properties
INCLUDES = $(GNOMECC_CAPPLETS_CFLAGS) -DWALLPAPER_DATADIR=\""$(WALLPAPER_DATADIR)"\"
INCLUDES = \
$(GNOMECC_CAPPLETS_CFLAGS) \
-DWALLPAPER_DATADIR=\""$(WALLPAPER_DATADIR)"\"
bin_PROGRAMS = gnome-wallpaper-properties
bin_PROGRAMS = gnome-background-properties
noinst_LTLIBRARIES = libgnomewp.la
gnome_wallpaper_properties_LDADD = \
gnome_background_properties_LDADD = \
$(GNOMECC_CAPPLETS_LIBS) \
libgnomewp.la
gnome_wallpaper_properties_SOURCES = \
gnome_background_properties_SOURCES = \
gnome-wp-capplet.c gnome-wp-capplet.h \
gnome-wp-info.c gnome-wp-info.h

View file

@ -2,7 +2,7 @@
Encoding=UTF-8
_Name=Desktop Wallpaper
_Comment=Desktop Wallpaper Preferences
Exec=gnome-wallpaper-properties
Exec=gnome-background-properties
Icon=gnome-settings-background
Terminal=false
Type=Application

View file

@ -81,6 +81,7 @@ static void gnome_wp_file_open_cancel (GtkWidget * widget, gpointer data) {
static void gnome_wp_file_open_get_files (GtkWidget * widget,
GnomeWPCapplet * capplet) {
GtkWidget * filesel;
GnomeWPItem * selected;
GdkColor color1, color2;
gchar ** files;
GdkCursor * cursor;
@ -102,6 +103,11 @@ static void gnome_wp_file_open_get_files (GtkWidget * widget,
if (item != NULL) {
GtkTreePath * path;
if (item->deleted) {
item->deleted = FALSE;
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);
@ -139,10 +145,7 @@ static void gnome_wp_file_open_get_files (GtkWidget * widget,
WP_OPTIONS_KEY,
NULL);
item->description = g_strdup_printf ("<b>%s</b>\n%s (%LuK)",
item->name,
gnome_vfs_mime_get_description (item->fileinfo->mime_type),
item->fileinfo->size / 1024);
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);
@ -211,10 +214,7 @@ static void bg_add_multiple_files (GnomeVFSURI * uri,
item->pcolor = gdk_color_copy (&color1);
item->scolor = gdk_color_copy (&color2);
item->description = g_strdup_printf ("<b>%s</b>\n%s (%LuK)",
item->name,
gnome_vfs_mime_get_description (item->fileinfo->mime_type),
item->fileinfo->size / 1024);
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);
@ -266,10 +266,7 @@ static void bg_properties_dragged_image (GtkWidget * widget,
item->pcolor = gdk_color_copy (&color1);
item->scolor = gdk_color_copy (&color2);
item->description = g_strdup_printf ("<b>%s</b>\n%s (%LuK)",
item->name,
gnome_vfs_mime_get_description (item->fileinfo->mime_type),
item->fileinfo->size / 1024);
gnome_wp_item_update_description (item);
g_hash_table_insert (capplet->wphash, g_strdup (item->filename),
item);
@ -389,6 +386,7 @@ static gboolean gnome_wp_props_wp_set (GnomeWPCapplet * capplet) {
GtkTreeModel * model;
GtkTreeSelection * selection;
GnomeWPItem * item;
GConfChangeSet * cs;
gchar * wpfile;
GdkPixbuf * pixbuf;
@ -398,29 +396,29 @@ static gboolean gnome_wp_props_wp_set (GnomeWPCapplet * capplet) {
item = g_hash_table_lookup (capplet->wphash, wpfile);
cs = gconf_change_set_new ();
if (!strcmp (item->filename, "(none)")) {
gconf_client_set_string (capplet->client, WP_OPTIONS_KEY,
"none", NULL);
gconf_change_set_set_string (cs, WP_OPTIONS_KEY, "none");
gtk_widget_set_sensitive (capplet->wp_opts, FALSE);
gtk_widget_set_sensitive (capplet->rm_button, FALSE);
} else {
gtk_widget_set_sensitive (capplet->wp_opts, TRUE);
gtk_widget_set_sensitive (capplet->rm_button, TRUE);
gconf_client_set_string (capplet->client, WP_FILE_KEY,
item->filename, NULL);
gconf_client_set_string (capplet->client, WP_OPTIONS_KEY,
item->options, NULL);
gconf_change_set_set_string (cs, WP_FILE_KEY, item->filename);
gconf_change_set_set_string (cs, WP_OPTIONS_KEY, item->options);
gnome_wp_option_menu_set (capplet, item->options, FALSE);
}
gconf_client_set_string (capplet->client, WP_SHADING_KEY,
item->shade_type, NULL);
gconf_change_set_set_string (cs, WP_SHADING_KEY, item->shade_type);
gnome_wp_option_menu_set (capplet, item->shade_type, TRUE);
gconf_client_set_string (capplet->client, WP_PCOLOR_KEY,
item->pri_color, NULL);
gconf_client_set_string (capplet->client, WP_SCOLOR_KEY,
item->sec_color, NULL);
gconf_change_set_set_string (cs, WP_PCOLOR_KEY, item->pri_color);
gconf_change_set_set_string (cs, WP_SCOLOR_KEY, item->sec_color);
gconf_client_commit_change_set (capplet->client, cs, TRUE, NULL);
gconf_change_set_unref (cs);
gnome_color_picker_set_i16 (GNOME_COLOR_PICKER (capplet->pc_picker),
item->pcolor->red,
@ -672,6 +670,7 @@ static void gnome_wp_remove_wallpaper (GtkWidget * widget,
GnomeWPCapplet * capplet) {
GtkTreeIter iter;
GtkTreeModel * model;
GtkTreePath * first;
GtkTreeSelection * selection;
gchar * wpfile;
@ -690,6 +689,10 @@ static void gnome_wp_remove_wallpaper (GtkWidget * widget,
gtk_list_store_remove (GTK_LIST_STORE (model), &iter);
}
first = gtk_tree_path_new_first ();
gtk_tree_view_set_cursor (GTK_TREE_VIEW (capplet->treeview),
first, NULL, FALSE);
gtk_tree_path_free (first);
}
static gboolean gnome_wp_load_stuffs (void * data) {
@ -760,10 +763,7 @@ static gboolean gnome_wp_load_stuffs (void * data) {
NULL);
item->deleted = FALSE;
item->description = g_strdup_printf ("<b>%s</b>\n%s (%LuK)",
item->name,
gnome_vfs_mime_get_description (item->fileinfo->mime_type),
item->fileinfo->size / 1024);
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);
@ -820,7 +820,7 @@ static gboolean gnome_wp_load_stuffs (void * data) {
WP_OPTIONS_KEY,
NULL);
item->description = g_strdup_printf ("<b>%s</b>", item->name);
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);
@ -903,11 +903,7 @@ static void gnome_wp_file_changed (GConfClient * client, guint id,
WP_OPTIONS_KEY,
NULL);
item->description = g_strdup_printf ("<b>%s</b>\n%s (%LuK)",
item->name,
gnome_vfs_mime_get_description (item->fileinfo->mime_type),
item->fileinfo->size / 1024);
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);
@ -1090,6 +1086,17 @@ static void wallpaper_properties_init (void) {
GdkCursor * cursor;
gchar * icofile;
gtk_rc_parse_string ("style \"wp-tree-defaults\" {\n"
" GtkTreeView::horizontal-separator = 6\n"
" GtkTreeView::vertical-separator = 6\n"
"} widget_class \"*TreeView*\""
" style \"wp-tree-defaults\"\n\n"
"style \"wp-dialog-defaults\" {\n"
" GtkDialog::action-area-border = 0\n"
" GtkDialog::content-area-border = 0\n"
"} widget_class \"*GtkDialog*\""
" style \"wp-dialog-defaults\"");
capplet = g_new0 (GnomeWPCapplet, 1);
if (capplet->client == NULL) {
@ -1178,9 +1185,11 @@ static void wallpaper_properties_init (void) {
GTK_RESPONSE_CLOSE);
gtk_widget_show (label);
gtk_container_set_border_width (GTK_CONTAINER (GTK_DIALOG (capplet->window)->action_area), 12);
/* Main Contents */
vbox = gtk_vbox_new (FALSE, 6);
gtk_container_set_border_width (GTK_CONTAINER (vbox), 6);
gtk_container_set_border_width (GTK_CONTAINER (vbox), 12);
gtk_box_pack_start (GTK_BOX (GTK_DIALOG (capplet->window)->vbox), vbox,
TRUE, TRUE, 0);
gtk_widget_show (vbox);
@ -1192,7 +1201,7 @@ static void wallpaper_properties_init (void) {
gtk_widget_show (clabel);
/* Treeview stuff goes in here */
hbox = gtk_hbox_new (FALSE, 6);
hbox = gtk_hbox_new (FALSE, 12);
gtk_box_pack_start (GTK_BOX (vbox), hbox, TRUE, TRUE, 0);
gtk_widget_show (hbox);
@ -1200,10 +1209,6 @@ static void wallpaper_properties_init (void) {
gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
gtk_widget_show (label);
label = gtk_label_new ("");
gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
gtk_widget_show (label);
swin = gtk_scrolled_window_new (NULL, NULL);
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (swin),
GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
@ -1248,12 +1253,6 @@ static void wallpaper_properties_init (void) {
gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (capplet->model),
2, GTK_SORT_ASCENDING);
gtk_rc_parse_string ("style \"wp-tree-defaults\" {\n"
" GtkTreeView::horizontal-separator = 6\n"
" GtkTreeView::vertical-separator = 6\n"
"} widget_class \"*TreeView*\""
" style \"wp-tree-defaults\"");
/* Need to add sorting stuff and whatnot */
gtk_widget_show (swin);

View file

@ -89,6 +89,9 @@ GdkPixbuf * gnome_wp_item_get_thumbnail (GnomeWPItem * item,
h = gdk_pixbuf_get_height (pixbuf);
ratio = h / 48;
if (ratio == 0)
ratio = w / 64;
if (ratio == 1)
ratio = 2;
@ -133,3 +136,14 @@ GdkPixbuf * gnome_wp_item_get_thumbnail (GnomeWPItem * item,
return scaled;
}
void gnome_wp_item_update_description (GnomeWPItem * item) {
if (!strcmp (item->filename, "(none)")) {
item->description = g_strdup_printf ("<b>%s</b>", item->name);
} else {
item->description = g_strdup_printf ("<b>%s</b>\n%s (%LuK)",
item->name,
gnome_vfs_mime_get_description (item->fileinfo->mime_type),
item->fileinfo->size / 1024);
}
}

View file

@ -57,6 +57,7 @@ struct _GnomeWPItem {
void gnome_wp_item_free (GnomeWPItem * item);
GdkPixbuf * gnome_wp_item_get_thumbnail (GnomeWPItem * item,
GnomeThumbnailFactory * thumbs);
void gnome_wp_item_update_description (GnomeWPItem * item);
#endif

View file

@ -109,11 +109,7 @@ static void gnome_wp_load_legacy (GnomeWPCapplet * capplet) {
WP_OPTIONS_KEY,
NULL);
item->description = g_strdup_printf ("<b>%s</b>\n%s (%LuK)",
item->name,
gnome_vfs_mime_get_description (item->fileinfo->mime_type),
item->fileinfo->size / 1024);
gnome_wp_item_update_description (item);
g_hash_table_insert (capplet->wphash, g_strdup (item->filename), item);
} else {
gnome_wp_item_free (item);
@ -209,18 +205,12 @@ static void gnome_wp_xml_load_xml (GnomeWPCapplet * capplet,
g_file_test (wp->filename, G_FILE_TEST_EXISTS)) ||
!strcmp (wp->filename, "(none)")) {
wp->fileinfo = gnome_wp_info_new (wp->filename, capplet->thumbs);
if (wp->name == NULL) {
if (wp->name == NULL || !strcmp (wp->filename, "(none)")) {
wp->name = g_strdup (wp->fileinfo->name);
}
if (!strcmp (wp->filename, "(none)")) {
wp->description = g_strdup_printf ("<b>%s</b>", wp->name);
} else {
wp->description = g_strdup_printf ("<b>%s</b>\n%s (%LuK)",
wp->name,
gnome_vfs_mime_get_description (wp->fileinfo->mime_type),
wp->fileinfo->size / 1024);
}
gnome_wp_item_update_description (wp);
g_hash_table_insert (capplet->wphash, g_strdup (wp->filename), wp);
} else {
gnome_wp_item_free (wp);
@ -257,11 +247,19 @@ void gnome_wp_xml_load_list (GnomeWPCapplet * capplet) {
wpdbfile = g_build_filename (g_get_home_dir (),
".gnome2",
"wp-list.xml",
"backgrounds.xml",
NULL);
if (g_file_test (wpdbfile, G_FILE_TEST_EXISTS)) {
gnome_wp_xml_load_xml (capplet, wpdbfile);
} else {
wpdbfile = g_build_filename (g_get_home_dir (),
".gnome2",
"wp-list.xml",
NULL);
if (g_file_test (wpdbfile, G_FILE_TEST_EXISTS)) {
gnome_wp_xml_load_xml (capplet, wpdbfile);
}
}
g_free (wpdbfile);
@ -345,7 +343,10 @@ void gnome_wp_xml_save_list (GnomeWPCapplet * capplet) {
g_hash_table_foreach (capplet->wphash,
(GHFunc) gnome_wp_list_flatten, &list);
wpfile = g_strconcat (g_get_home_dir (), "/.gnome2/wp-list.xml", NULL);
wpfile = g_build_filename (g_get_home_dir (),
"/.gnome2",
"backgrounds.xml",
NULL);
xmlKeepBlanksDefault (0);