gnome-control-center r8827 - trunk/capplets/appearance



Author: jensg
Date: Tue Jul 29 21:10:04 2008
New Revision: 8827
URL: http://svn.gnome.org/viewvc/gnome-control-center?rev=8827&view=rev

Log:
2008-07-29  Jens Granseuer  <jensgr gmx net>

	* appearance-main.c: (main):
	* appearance-themes.c: (theme_drag_data_received_cb):
	* theme-installer.c: (gnome_theme_install),
	(gnome_theme_installer_run):
	* theme-installer.h: make theme installation from GIO-supported
	sources work (including drag and drop) (bug #545335)


Modified:
   trunk/capplets/appearance/ChangeLog
   trunk/capplets/appearance/appearance-main.c
   trunk/capplets/appearance/appearance-themes.c
   trunk/capplets/appearance/theme-installer.c
   trunk/capplets/appearance/theme-installer.h

Modified: trunk/capplets/appearance/appearance-main.c
==============================================================================
--- trunk/capplets/appearance/appearance-main.c	(original)
+++ trunk/capplets/appearance/appearance-main.c	Tue Jul 29 21:10:04 2008
@@ -142,9 +142,12 @@
         GNOME_PARAM_GOPTION_CONTEXT, option_context,
         NULL);
 
-  if (install_filename != NULL)
-     gnome_theme_install_from_uri (install_filename, NULL);
-  g_free (install_filename);
+  if (install_filename != NULL) {
+    GFile *inst = g_file_new_for_commandline_arg (install_filename);
+    g_free (install_filename);
+    gnome_theme_install (inst, NULL);
+    g_object_unref (inst);
+  }
 
   /* init tabs */
   themes_init (data);

Modified: trunk/capplets/appearance/appearance-themes.c
==============================================================================
--- trunk/capplets/appearance/appearance-themes.c	(original)
+++ trunk/capplets/appearance/appearance-themes.c	Tue Jul 29 21:10:04 2008
@@ -989,12 +989,10 @@
 
   if (uris != NULL && uris[0] != NULL) {
     GFile *f = g_file_new_for_uri (uris[0]);
-    gchar *filename = g_file_get_path (f);
-    g_object_unref (f);
 
-    gnome_theme_install_from_uri (filename,
+    gnome_theme_install (f,
         GTK_WINDOW (glade_xml_get_widget (data->xml, "appearance_window")));
-    g_free (filename);
+    g_object_unref (f);
   }
 
   g_strfreev (uris);

Modified: trunk/capplets/appearance/theme-installer.c
==============================================================================
--- trunk/capplets/appearance/theme-installer.c	(original)
+++ trunk/capplets/appearance/theme-installer.c	Tue Jul 29 21:10:04 2008
@@ -579,16 +579,14 @@
 }
 
 void
-gnome_theme_install_from_uri (const gchar *filename, GtkWindow *parent)
+gnome_theme_install (GFile *file, GtkWindow *parent)
 {
 	GtkWidget *dialog;
 	gchar *path, *base;
 	GList *src, *target;
-	gchar *temppath;
 	const gchar *template;
-	int cmp;
 
-	if (filename == NULL || strcmp (filename, "") == 0) {
+	if (file == NULL) {
 		dialog = gtk_message_dialog_new (NULL,
 						 GTK_DIALOG_MODAL,
 						 GTK_MESSAGE_ERROR,
@@ -599,9 +597,10 @@
 		return;
 	}
 
-	/* see if someone dropped a directory */
-	if (g_file_test (filename, G_FILE_TEST_IS_DIR))	{
-		transfer_done_cb (NULL, g_strdup (filename));
+	/* see if someone dropped a local directory */
+	if (g_file_is_native (file) &&
+	    g_file_query_file_type (file, G_FILE_QUERY_INFO_NONE, NULL) == G_FILE_TYPE_DIRECTORY) {
+		transfer_done_cb (NULL, g_file_get_path (file));
 		return;
 	}
 
@@ -620,28 +619,7 @@
 		return;
 	}
 
-	/* To avoid the copy of /root/.themes to /root/.themes/.themes
-	 * which causes an infinite loop. The user asks to transfer the all
-	 * contents of a folder, to a folder under itself. So ignore the
-	 * situation.
-	 */
-	temppath = g_build_filename (filename, ".themes", NULL);
-	cmp = strcmp (temppath, path);
-	g_free (path);
-	g_free (temppath);
-
-	if (cmp == 0) {
-		dialog = gtk_message_dialog_new (NULL,
-						 GTK_DIALOG_MODAL,
-						 GTK_MESSAGE_ERROR,
-						 GTK_BUTTONS_OK,
-						 _("%s is the path where the theme files will be installed. This can not be selected as the source location"), filename);
-		gtk_dialog_run (GTK_DIALOG (dialog));
-		gtk_widget_destroy (dialog);
-		return;
-	}
-
-	base = g_path_get_basename (filename);
+	base = g_file_get_basename (file);
 
 	if (g_str_has_suffix (base, ".tar.gz") || g_str_has_suffix (base, ".tgz") || g_str_has_suffix (base, ".gtp"))
 		template = "gnome-theme-%d.gtp";
@@ -654,7 +632,7 @@
 	}
 	g_free (base);
 
-	src = g_list_append (NULL, g_file_new_for_path (filename));
+	src = g_list_append (NULL, g_object_ref (file));
 
 	path = NULL;
 	do {
@@ -694,7 +672,6 @@
 	static gboolean running_theme_install = FALSE;
 	static gchar old_folder[512] = "";
 	GtkWidget *dialog;
-	gchar *filename_selected, *folder;
 	GtkFileFilter *filter;
 
 	if (running_theme_install)
@@ -725,7 +702,9 @@
 
 	if (gtk_dialog_run (GTK_DIALOG (dialog)) == GTK_RESPONSE_ACCEPT)
 	{
-		filename_selected = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (dialog));
+		gchar *uri_selected, *folder;
+
+		uri_selected = gtk_file_chooser_get_uri (GTK_FILE_CHOOSER (dialog));
 
 		folder = gtk_file_chooser_get_current_folder (GTK_FILE_CHOOSER (dialog));
 		g_strlcpy (old_folder, folder, 255);
@@ -733,8 +712,13 @@
 
 		gtk_widget_destroy (dialog);
 
-		gnome_theme_install_from_uri (filename_selected, parent);
-		g_free (filename_selected);
+		if (uri_selected != NULL) {
+			GFile *file = g_file_new_for_uri (uri_selected);
+			g_free (uri_selected);
+
+			gnome_theme_install (file, parent);
+			g_object_unref (file);
+		}
 	}
 	else
 		gtk_widget_destroy (dialog);

Modified: trunk/capplets/appearance/theme-installer.h
==============================================================================
--- trunk/capplets/appearance/theme-installer.h	(original)
+++ trunk/capplets/appearance/theme-installer.h	Tue Jul 29 21:10:04 2008
@@ -22,7 +22,7 @@
 #ifndef THEME_INSTALLER_H
 #define THEME_INSTALLER_H
 
-void gnome_theme_install_from_uri (const gchar *filename, GtkWindow *parent);
+void gnome_theme_install (GFile *file, GtkWindow *parent);
 void gnome_theme_installer_run (GtkWindow *parent, const gchar *filename);
 
 #endif /* THEME_INSTALLER_H */



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]