From 5f9e193597214f6b15a337716ef8f73c555724a8 Mon Sep 17 00:00:00 2001 From: Jody Goldberg Date: Wed, 3 Jul 2002 02:48:12 +0000 Subject: [PATCH] http://bugzilla.gnome.org/show_bug.cgi?id=84014 unescape the path. 2002-07-02 Jody Goldberg http://bugzilla.gnome.org/show_bug.cgi?id=84014 * background-properties-capplet.c (drag_data_received_cb) : unescape the path. --- capplets/background/ChangeLog | 10 + .../background-properties-capplet.c | 14 +- capplets/background/main.c | 314 ------------------ 3 files changed, 17 insertions(+), 321 deletions(-) delete mode 100644 capplets/background/main.c diff --git a/capplets/background/ChangeLog b/capplets/background/ChangeLog index ce74b2a96..a92120b7c 100644 --- a/capplets/background/ChangeLog +++ b/capplets/background/ChangeLog @@ -1,3 +1,13 @@ +2002-07-02 Jody Goldberg + + http://bugzilla.gnome.org/show_bug.cgi?id=84014 + * background-properties-capplet.c (drag_data_received_cb) : unescape + the path. + +2002-06-27 Jody Goldberg + + * background-properties-capplet.c (main) : use capplet_set_icon. + 2002-06-18 Jody Goldberg http://bugzilla.gnome.org/show_bug.cgi?id=85628 diff --git a/capplets/background/background-properties-capplet.c b/capplets/background/background-properties-capplet.c index 62a7b8fff..c9924b29c 100644 --- a/capplets/background/background-properties-capplet.c +++ b/capplets/background/background-properties-capplet.c @@ -500,8 +500,12 @@ drag_data_received_cb (GtkWidget *widget, GdkDragContext *context, GnomeVFSURI *uri = (GnomeVFSURI *) uris->data; GConfEntry *entry; GConfValue *value = gconf_value_new (GCONF_VALUE_STRING); - - gconf_value_set_string (value, gnome_vfs_uri_get_path (uri)); + gchar *base; + + base = gnome_vfs_unescape_string (gnome_vfs_uri_get_path (uri), + G_DIR_SEPARATOR_S); + gconf_value_set_string (value, base); + g_free (base); /* Hmm, should we bother with changeset here? */ gconf_client_set (client, BG_PREFERENCES_PICTURE_FILENAME, value, NULL); @@ -550,7 +554,6 @@ main (int argc, char **argv) GladeXML *dialog; GtkWidget *dialog_win; ApplierSet *set; - GdkPixbuf *pixbuf; static gboolean get_legacy; static struct poptOption cap_options[] = { @@ -588,10 +591,6 @@ main (int argc, char **argv) gtk_dialog_set_default_response (GTK_DIALOG (dialog_win), GTK_RESPONSE_CLOSE); - pixbuf = gdk_pixbuf_new_from_file (GNOMECC_DATA_DIR "/icons/background-capplet.png", NULL); - gtk_window_set_icon (GTK_WINDOW(dialog_win), pixbuf); - gdk_pixbuf_unref (pixbuf); - g_signal_connect (G_OBJECT (dialog_win), "response", G_CALLBACK (cb_dialog_response), NULL); @@ -609,6 +608,7 @@ main (int argc, char **argv) g_object_weak_ref (G_OBJECT (dialog_win), (GWeakNotify) applier_set_free, set); gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog_win)->vbox), WID ("prefs_widget"), TRUE, TRUE, GNOME_PAD_SMALL); + capplet_set_icon (dialog_win, "background-capplet.png"); gtk_widget_show (dialog_win); gtk_main (); diff --git a/capplets/background/main.c b/capplets/background/main.c deleted file mode 100644 index 21af05a57..000000000 --- a/capplets/background/main.c +++ /dev/null @@ -1,314 +0,0 @@ -/* -*- mode: c; style: linux -*- */ - -/* main.c - * Copyright (C) 2000 Helix Code, Inc. - * - * Written by Bradford Hovinen (hovinen@helixcode.com) - * - * 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, 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., 59 Temple Place - Suite 330, Boston, MA - * 02111-1307, USA. - */ - -#ifdef HAVE_CONFIG_H -# include -#endif - -#include -#include -#include -#include -#include -#include - -#include - -#include - -#ifdef HAVE_XIMIAN_ARCHIVER -# include -# include -#endif /* HAVE_XIMIAN_ARCHIVER */ - -#include "preferences.h" -#include "prefs-widget.h" - -static Preferences *prefs; -static Preferences *old_prefs; -static PrefsWidget *prefs_widget; - -static guint ok_handler_id; -static guint cancel_handler_id; - -#ifdef HAVE_XIMIAN_ARCHIVER - -static Archive *archive; -static gboolean outside_location; - -static void -store_archive_data (void) -{ - Location *location; - xmlDocPtr xml_doc; - - if (capplet_get_location () == NULL) - location = archive_get_current_location (archive); - else - location = archive_get_location (archive, - capplet_get_location ()); - - xml_doc = preferences_write_xml (prefs); - location_store_xml (location, "background-properties-capplet", - xml_doc, STORE_MASK_PREVIOUS); - xmlFreeDoc (xml_doc); - archive_close (archive); -} - -#endif /* HAVE_XIMIAN_ARCHIVER */ - -static void -ok_cb (GtkWidget *widget) -{ -#ifdef HAVE_XIMIAN_ARCHIVER - if (!outside_location) { - preferences_save (prefs); - preferences_apply_now (prefs); - } -#else /* !HAVE_XIMIAN_ARCHIVER */ - preferences_save (prefs); - preferences_apply_now (prefs); -#endif /* HAVE_XIMIAN_ARCHIVER */ - - gtk_signal_disconnect (GTK_OBJECT (prefs_widget), ok_handler_id); - gtk_signal_disconnect (GTK_OBJECT (prefs_widget), cancel_handler_id); - gtk_object_destroy (GTK_OBJECT (prefs_widget)); -#ifdef HAVE_XIMIAN_ARCHIVER - store_archive_data (); -#endif /* HAVE_XIMIAN_ARCHIVER */ -} - -static void -cancel_cb (GtkWidget *widget) -{ -#ifdef HAVE_XIMIAN_ARCHIVER - if (!outside_location) { - preferences_save (old_prefs); - preferences_apply_now (old_prefs); - } -#else /* !HAVE_XIMIAN_ARCHIVER */ - preferences_save (prefs); - preferences_apply_now (prefs); -#endif /* HAVE_XIMIAN_ARCHIVER */ - - gtk_signal_disconnect (GTK_OBJECT (prefs_widget), ok_handler_id); - gtk_signal_disconnect (GTK_OBJECT (prefs_widget), cancel_handler_id); - gtk_object_destroy (GTK_OBJECT (prefs_widget)); -} - -static void -setup_capplet_widget (void) -{ - preferences_freeze (prefs); - - prefs_widget = PREFS_WIDGET (prefs_widget_new (prefs)); - - ok_handler_id = - gtk_signal_connect (GTK_OBJECT (prefs_widget), "ok", - GTK_SIGNAL_FUNC (ok_cb), NULL); - cancel_handler_id = - gtk_signal_connect (GTK_OBJECT (prefs_widget), "cancel", - GTK_SIGNAL_FUNC (cancel_cb), NULL); - - gtk_widget_show_all (GTK_WIDGET (prefs_widget)); - - preferences_thaw (prefs); -} - -#ifdef HAVE_XIMIAN_ARCHIVER - -static void -do_get_xml (void) -{ - Preferences *prefs; - xmlDocPtr doc; - - prefs = PREFERENCES (preferences_new ()); - preferences_load (prefs); - doc = preferences_write_xml (prefs); - xmlDocDump (stdout, doc); - gtk_object_destroy (GTK_OBJECT (prefs)); -} - -static void -do_set_xml (gboolean apply_settings) -{ - xmlDocPtr doc; - char buffer[16384]; - GString *doc_str; - int t = 0; - - fflush (stdin); - - fcntl (fileno (stdin), F_SETFL, 0); - - doc_str = g_string_new (""); - - while ((t = read (fileno (stdin), buffer, sizeof (buffer) - 1)) != 0) { - buffer[t] = '\0'; - g_string_append (doc_str, buffer); - } - - if (doc_str->len > 0) { - doc = xmlParseDoc (doc_str->str); - g_string_free (doc_str, TRUE); - - if (doc != NULL) { - prefs = preferences_read_xml (doc); - - if (prefs != NULL) { - if (apply_settings) { - preferences_save (prefs); - preferences_apply_now (prefs); - } - - return; - } - else if (prefs != NULL) { - return; - } - - xmlFreeDoc (doc); - } - } else { - g_critical ("No data to apply"); - } - - return; -} - -#endif /* HAVE_XIMIAN_ARCHIVER */ - -static void -do_restore_from_defaults (void) -{ - prefs = PREFERENCES (preferences_new ()); - preferences_save (prefs); - preferences_apply_now (prefs); -} - -int -main (int argc, char **argv) -{ - GnomeClient *client; - GnomeClientFlags flags; - gint token, res; - gchar *restart_args[3]; - - bindtextdomain (GETTEXT_PACKAGE, GNOMELOCALEDIR); - bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8"); - textdomain (GETTEXT_PACKAGE); - - glade_gnome_init (); - res = gnome_capplet_init ("background-properties-capplet", - VERSION, argc, argv, NULL, - 0, NULL); - - if (res < 0) { - g_error ("Could not initialize the capplet."); - } - else if (res == 3) { -#ifdef HAVE_XIMIAN_ARCHIVER - do_get_xml (); -#endif /* HAVE_XIMIAN_ARCHIVER */ - return 0; - } - else if (res == 4) { -#ifdef HAVE_XIMIAN_ARCHIVER - do_set_xml (TRUE); -#endif /* HAVE_XIMIAN_ARCHIVER */ - return 0; - } - else if (res == 5) { - do_restore_from_defaults (); - return 0; - } - - client = gnome_master_client (); - flags = gnome_client_get_flags (client); - - if (flags & GNOME_CLIENT_IS_CONNECTED) { - token = gnome_startup_acquire_token - ("GNOME_BACKGROUND_PROPERTIES", - gnome_client_get_id (client)); - - if (token) { - gnome_client_set_priority (client, 20); - gnome_client_set_restart_style (client, - GNOME_RESTART_ANYWAY); - restart_args[0] = argv[0]; - restart_args[1] = "--init-session-settings"; - restart_args[2] = NULL; - gnome_client_set_restart_command (client, 2, - restart_args); - } else { - gnome_client_set_restart_style (client, - GNOME_RESTART_NEVER); - } - } else { - token = 1; - } - - gnome_window_icon_set_default_from_file - (GNOMECC_ICONS_DIR"/gnome-ccbackground.png"); - -#ifdef HAVE_XIMIAN_ARCHIVER - archive = ARCHIVE (archive_load (FALSE)); - - if (capplet_get_location () != NULL && - strcmp (capplet_get_location (), - archive_get_current_location_id (archive))) - { - outside_location = TRUE; - do_set_xml (FALSE); - if (prefs == NULL) return -1; - preferences_freeze (prefs); - } else { - outside_location = FALSE; - prefs = PREFERENCES (preferences_new ()); - preferences_load (prefs); - } - - if (!outside_location && (token || res == 1)) { - preferences_apply_now (prefs); - } - -#else /* !HAVE_XIMIAN_ARCHIVER */ - - prefs = PREFERENCES (preferences_new ()); - preferences_load (prefs); - - if (token || res == 1) - preferences_apply_now (prefs); - -#endif /* HAVE_XIMIAN_ARCHIVER */ - - if (!res) { - old_prefs = PREFERENCES (preferences_clone (prefs)); - setup_capplet_widget (); - - capplet_gtk_main (); - } - - return 0; -}