[epiphany] e-file-chooser: remove persist-key



commit 27a5272d09d5623f480258bfee593384d26956ee
Author: Diego Escalante Urrelo <descalante igalia com>
Date:   Fri Jul 29 23:28:32 2011 -0500

    e-file-chooser: remove persist-key
    
    GTK+ has changed the UX of the GtkFileChooser. This has (pragmatically)
    deprecated "last save dir" stored by applications themselves.
    
    For Epiphany this means we no longer need a "persist-key" in our file
    chooser, and that we have to clean up some GtkFileChooser API use in
    followup patches.
    
    This commit removes the property and uses of it.
    
    Bug #655508

 lib/ephy-file-chooser.c               |  172 ---------------------------------
 lib/ephy-file-chooser.h               |   10 --
 src/bookmarks/ephy-bookmarks-editor.c |    3 +-
 src/popup-commands.c                  |    1 -
 src/prefs-dialog.c                    |    2 +-
 src/window-commands.c                 |    2 -
 6 files changed, 2 insertions(+), 188 deletions(-)
---
diff --git a/lib/ephy-file-chooser.c b/lib/ephy-file-chooser.c
index 285d602..a570246 100644
--- a/lib/ephy-file-chooser.c
+++ b/lib/ephy-file-chooser.c
@@ -31,76 +31,19 @@
 #include <gtk/gtk.h>
 #include <glib/gi18n.h>
 
-#define EPHY_FILE_CHOOSER_GET_PRIVATE(object)(G_TYPE_INSTANCE_GET_PRIVATE ((object), EPHY_TYPE_FILE_CHOOSER, EphyFileChooserPrivate))
-
-struct _EphyFileChooserPrivate
-{
-	char *persist_key;
-};
-
 static void ephy_file_chooser_class_init	(EphyFileChooserClass *klass);
 static void ephy_file_chooser_init		(EphyFileChooser *dialog);
 static void ephy_file_chooser_image_preview	(GtkFileChooser *file_chooser, 
 				 		 gpointer user_data);
 
-enum
-{
-	PROP_0,
-	PROP_PERSIST_KEY
-};
-
 #define PREVIEW_WIDTH 150
 #define PREVIEW_HEIGHT 150
 
 G_DEFINE_TYPE (EphyFileChooser, ephy_file_chooser, GTK_TYPE_FILE_CHOOSER_DIALOG)
 
 static void
-current_folder_changed_cb (GtkFileChooser *chooser, EphyFileChooser *dialog)
-{
-	if (dialog->priv->persist_key != NULL)
-	{
-		char *dir;
-
-		dir = gtk_file_chooser_get_current_folder (chooser);
-
-		g_settings_set_string (EPHY_SETTINGS_STATE,
-				       dialog->priv->persist_key, dir);
-
-		g_free (dir);
-	}
-}
-
-static void
-file_chooser_response_cb (GtkWidget *widget,
-			  gint response,
-			  EphyFileChooser *dialog)
-{
-	if (response == GTK_RESPONSE_ACCEPT)
-	{
-		if (dialog->priv->persist_key != NULL)
-		{
-			char *dir, *filename;
-		    
-			filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (dialog));
-                        if (filename == NULL) return;
-
-			dir = g_path_get_dirname (filename);
-                        if (dir != NULL)
-				g_settings_set_string
-					(EPHY_SETTINGS_STATE,
-					 dialog->priv->persist_key,
-					 dir);
-
-			g_free (dir);
-			g_free (filename);
-		}
-	}
-}
-
-static void
 ephy_file_chooser_init (EphyFileChooser *dialog)
 {
-	dialog->priv = EPHY_FILE_CHOOSER_GET_PRIVATE (dialog);
 }
 
 static GObject *
@@ -123,64 +66,6 @@ ephy_file_chooser_constructor (GType type,
 	return object;
 }
 
-static void
-ephy_file_chooser_finalize (GObject *object)
-{
-	EphyFileChooser *dialog = EPHY_FILE_CHOOSER (object);
-
-	g_free (dialog->priv->persist_key);
-
-	LOG ("EphyFileChooser finalised");
-
-	G_OBJECT_CLASS (ephy_file_chooser_parent_class)->finalize (object);
-}
-
-void
-ephy_file_chooser_set_persist_key (EphyFileChooser *dialog, const char *key)
-{
-	char *dir, *expanded, *converted;
-
-	g_return_if_fail (key != NULL && key[0] != '\0');
-
-	dialog->priv->persist_key = g_strdup (key);
-
-	dir = g_settings_get_string (EPHY_SETTINGS_STATE, key);
-	if (dir != NULL)
-	{
-		/* FIXME: Maybe we will find a better way to do this when the
-		 * gio-filechooser will be in GTK+ */
-		converted = g_filename_from_utf8
-			(dir, -1, NULL, NULL, NULL);
-
-		if (converted != NULL)
-		{
-			expanded = ephy_string_expand_initial_tilde (converted);
-
-			gtk_file_chooser_set_current_folder
-				(GTK_FILE_CHOOSER (dialog), expanded);
-
-			g_free (expanded);
-			g_free (converted);
-		}
-
-		g_free (dir);
-	}
-
-	g_signal_connect (dialog, "current-folder-changed",
-			  G_CALLBACK (current_folder_changed_cb), dialog);
-    
-	g_signal_connect (dialog, "response",
-			  G_CALLBACK (file_chooser_response_cb), dialog);
-}
-
-const char *
-ephy_file_chooser_get_persist_key (EphyFileChooser *dialog)
-{
-	g_return_val_if_fail (EPHY_IS_FILE_CHOOSER (dialog), NULL);
-
-	return dialog->priv->persist_key;
-}
-
 GtkFileFilter *
 ephy_file_chooser_add_pattern_filter (EphyFileChooser *dialog,
 				      const char *title,
@@ -240,56 +125,11 @@ ephy_file_chooser_add_mime_filter (EphyFileChooser *dialog,
 }
 
 static void
-ephy_file_chooser_set_property (GObject *object,
-				guint prop_id,
-				const GValue *value,
-				GParamSpec *pspec)
-{
-	EphyFileChooser *dialog = EPHY_FILE_CHOOSER (object);
-	
-	switch (prop_id)
-	{
-		case PROP_PERSIST_KEY:
-			ephy_file_chooser_set_persist_key (dialog, g_value_get_string (value));
-			break;
-	}
-}
-
-static void
-ephy_file_chooser_get_property (GObject *object,
-				guint prop_id,
-				GValue *value,
-				GParamSpec *pspec)
-{
-	EphyFileChooser *dialog = EPHY_FILE_CHOOSER (object);
-
-	switch (prop_id)
-	{
-		case PROP_PERSIST_KEY:
-			g_value_set_string (value, ephy_file_chooser_get_persist_key (dialog));
-			break;
-	}
-}
-
-static void
 ephy_file_chooser_class_init (EphyFileChooserClass *klass)
 {
 	GObjectClass *object_class = G_OBJECT_CLASS (klass);
 
 	object_class->constructor = ephy_file_chooser_constructor;
-	object_class->finalize = ephy_file_chooser_finalize;
-	object_class->get_property = ephy_file_chooser_get_property;
-	object_class->set_property = ephy_file_chooser_set_property;
-
-	g_object_class_install_property (object_class,
-					 PROP_PERSIST_KEY,
-					 g_param_spec_string ("persist-key",
-							      "Persist Key",
-							      "The gconf key to which to persist the selected directory",
-							      NULL,
-							      G_PARAM_READWRITE | G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB));
-
-	g_type_class_add_private (object_class, sizeof (EphyFileChooserPrivate));
 }
 
 static void
@@ -324,7 +164,6 @@ EphyFileChooser	*
 ephy_file_chooser_new (const char *title,
 		       GtkWidget *parent,
 		       GtkFileChooserAction action,
-		       const char *persist_key,
 		       EphyFileFilterDefault default_filter)
 {
 	EphyFileChooser *dialog;
@@ -338,17 +177,6 @@ ephy_file_chooser_new (const char *title,
 						  "action", action,
 						  NULL));
 
-	/* NOTE: We cannot set this property on object construction time.
-	 * This is because GtkFileChooserDialog overrides the gobject
-	 * constructor; the GtkFileChooser delegate will only be set
-	 * _after_ our instance_init and construct-param setters will have
-	 * run.
-	 */
-	if (persist_key != NULL)
-	{
-		ephy_file_chooser_set_persist_key (dialog, persist_key);
-	}
-
 	if (action == GTK_FILE_CHOOSER_ACTION_OPEN	    ||
 	    action == GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER ||
 	    action == GTK_FILE_CHOOSER_ACTION_CREATE_FOLDER)
diff --git a/lib/ephy-file-chooser.h b/lib/ephy-file-chooser.h
index a31f684..bdf0b82 100644
--- a/lib/ephy-file-chooser.h
+++ b/lib/ephy-file-chooser.h
@@ -38,7 +38,6 @@ G_BEGIN_DECLS
 #define EPHY_FILE_CHOOSER_GET_CLASS(o)	(G_TYPE_INSTANCE_GET_CLASS ((o), EPHY_TYPE_FILE_CHOOSER, EphyFileChooserClass))
 
 typedef struct _EphyFileChooser		EphyFileChooser;
-typedef struct _EphyFileChooserPrivate	EphyFileChooserPrivate;
 typedef struct _EphyFileChooserClass	EphyFileChooserClass;
 
 typedef enum
@@ -54,9 +53,6 @@ typedef enum
 struct _EphyFileChooser
 {
 	GtkFileChooserDialog parent;
-
-	/*< private >*/
-	EphyFileChooserPrivate *priv;
 };
 
 struct _EphyFileChooserClass
@@ -69,14 +65,8 @@ GType		 ephy_file_chooser_get_type		(void);
 EphyFileChooser	*ephy_file_chooser_new			(const char *title,
 							 GtkWidget *parent,
 							 GtkFileChooserAction action,
-							 const char *persist_key,
 							 EphyFileFilterDefault default_filter);
 
-void		 ephy_file_chooser_set_persist_key	(EphyFileChooser *dialog,
-							 const char *key);
-
-const char	*ephy_file_chooser_get_persist_key	(EphyFileChooser *dialog);
-
 GtkFileFilter	*ephy_file_chooser_add_pattern_filter	(EphyFileChooser *dialog,
 							 const char *title,
 							 const char *first_pattern,
diff --git a/src/bookmarks/ephy-bookmarks-editor.c b/src/bookmarks/ephy-bookmarks-editor.c
index 2dcee58..eeeecac 100644
--- a/src/bookmarks/ephy-bookmarks-editor.c
+++ b/src/bookmarks/ephy-bookmarks-editor.c
@@ -616,7 +616,7 @@ import_dialog_response_cb (GtkDialog *dialog,
 			dialog = ephy_file_chooser_new (_("Import Bookmarks from File"),
 							GTK_WIDGET (editor),
 							GTK_FILE_CHOOSER_ACTION_OPEN,
-							NULL, EPHY_FILE_FILTER_NONE);
+							EPHY_FILE_FILTER_NONE);
 
 			ephy_file_chooser_add_mime_filter
 				(dialog,
@@ -755,7 +755,6 @@ cmd_bookmarks_export (GtkAction *action,
 	dialog = GTK_WIDGET (ephy_file_chooser_new (_("Export Bookmarks"),
 		GTK_WIDGET (editor),
 		GTK_FILE_CHOOSER_ACTION_SAVE,
-		NULL,
 		EPHY_FILE_FILTER_NONE));
 
 	gtk_file_chooser_set_do_overwrite_confirmation (GTK_FILE_CHOOSER (dialog), TRUE);
diff --git a/src/popup-commands.c b/src/popup-commands.c
index 939d6e3..bc2a4fb 100644
--- a/src/popup-commands.c
+++ b/src/popup-commands.c
@@ -238,7 +238,6 @@ save_property_url (GtkAction *action,
 		base = g_path_get_basename (location);
 		dialog = ephy_file_chooser_new (title, GTK_WIDGET (window),
 						GTK_FILE_CHOOSER_ACTION_SAVE,
-						EPHY_PREFS_STATE_SAVE_DIR,
 						EPHY_FILE_FILTER_NONE);
 
 		gtk_file_chooser_set_do_overwrite_confirmation
diff --git a/src/prefs-dialog.c b/src/prefs-dialog.c
index f956200..748b065 100644
--- a/src/prefs-dialog.c
+++ b/src/prefs-dialog.c
@@ -869,7 +869,7 @@ create_download_path_button (EphyDialog *dialog)
 	fc = ephy_file_chooser_new (_("Select a Directory"),
 				    parent,
 				    GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER,
-				    NULL, EPHY_FILE_FILTER_NONE);
+				    EPHY_FILE_FILTER_NONE);
 
 	/* Unset the destroy-with-parent, since gtkfilechooserbutton doesn't
 	 * expect this */
diff --git a/src/window-commands.c b/src/window-commands.c
index 762a6c7..da8a2f9 100644
--- a/src/window-commands.c
+++ b/src/window-commands.c
@@ -268,7 +268,6 @@ window_cmd_file_open (GtkAction *action,
 	dialog = ephy_file_chooser_new (_("Open"),
 					GTK_WIDGET (window),
 					GTK_FILE_CHOOSER_ACTION_OPEN,
-					EPHY_PREFS_STATE_OPEN_DIR,
 					EPHY_FILE_FILTER_ALL_SUPPORTED);
 
 	g_signal_connect (dialog, "response",
@@ -331,7 +330,6 @@ window_cmd_file_save_as (GtkAction *action,
 	dialog = ephy_file_chooser_new (_("Save"),
 					GTK_WIDGET (window),
 					GTK_FILE_CHOOSER_ACTION_SAVE,
-					EPHY_PREFS_STATE_SAVE_DIR,
 					EPHY_FILE_FILTER_NONE);
 
 	gtk_file_chooser_set_do_overwrite_confirmation (GTK_FILE_CHOOSER (dialog), TRUE);



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