aboutsummaryrefslogtreecommitdiffstats
path: root/src/window-commands.c
diff options
context:
space:
mode:
authorChristian Persch <chpe@cvs.gnome.org>2003-10-26 18:45:56 +0800
committerChristian Persch <chpe@src.gnome.org>2003-10-26 18:45:56 +0800
commiteb6b2cdb2e89e41759cf3b1cd136cfca42e6e42b (patch)
tree9c1ae176d61be345a8d3295aa9e43e48a43464da /src/window-commands.c
parenta34a545dbe35d250c5f5743634909ad2a45f423b (diff)
downloadgsoc2013-epiphany-eb6b2cdb2e89e41759cf3b1cd136cfca42e6e42b.tar.gz
gsoc2013-epiphany-eb6b2cdb2e89e41759cf3b1cd136cfca42e6e42b.tar.zst
gsoc2013-epiphany-eb6b2cdb2e89e41759cf3b1cd136cfca42e6e42b.zip
Port to new gtk+ file chooser.
2003-10-26 Christian Persch <chpe@cvs.gnome.org> Port to new gtk+ file chooser. * data/epiphany.schemas.in: * lib/ephy-prefs.h: Add key for remembering upload path. * embed /Makefile.am: * embed/downloader-view.c: * embed/ephy-embed-persist.c: (ephy_embed_persist_get_type), (ephy_embed_persist_set_dest), (ephy_embed_persist_set_embed), (ephy_embed_persist_set_fc_title), (ephy_embed_persist_set_fc_parent), (ephy_embed_persist_set_flags), (ephy_embed_persist_set_max_size), (ephy_embed_persist_set_persist_key), (ephy_embed_persist_set_source), (ephy_embed_persist_get_dest), (ephy_embed_persist_get_embed), (ephy_embed_persist_get_fc_title), (ephy_embed_persist_get_fc_parent), (ephy_embed_persist_get_flags), (ephy_embed_persist_get_max_size), (ephy_embed_persist_get_persist_key), (ephy_embed_persist_get_source), (ephy_embed_persist_set_property), (ephy_embed_persist_get_property), (ephy_embed_persist_init), (ephy_embed_persist_finalize), (ephy_embed_persist_class_init), (ephy_embed_persist_cancel), (ephy_embed_persist_save), (ephy_embed_persist_new): * embed/ephy-embed-persist.h: * embed/ephy-embed-popup-control.c: (save_url), (save_property_url), (background_download_completed), (embed_popup_set_image_as_background_cmd), (embed_popup_copy_image_location_cmd): * src/popup-commands.c: (save_property_url), (background_download_completed), (popup_cmd_set_image_as_background): * src/window-commands.c: (open_response_cb), (window_cmd_file_open), (window_cmd_file_save_as): * src/window-commands.h: * embed/ephy-favicon-cache.c: (ephy_favicon_cache_get_type), (ephy_favicon_cache_new), (icon_is_obsolete), (icons_added_cb), (remove_obsolete_icons), (ephy_favicon_cache_init), (favicon_download_completed_cb), (ephy_favicon_cache_download), (ephy_favicon_cache_get): * embed/mozilla/MozDownload.cpp: * embed/mozilla/EphyHeaderSniffer.cpp: * embed/mozilla/mozilla-embed-persist.cpp: * embed/mozilla/mozilla-embed-single.cpp: * src/popup-commands.c: (save_property_url), (background_download_completed), (popup_cmd_set_image_as_background): * src/window-commands.c: (open_response_cb), (window_cmd_file_open), (window_cmd_file_save_as): * src/window-commands.h: Simplify EphyEmbedPersist implementation. Augment it with properties for showing a file chooser to select persist destination. Port all callers to new interfaces. * embed/ephy-embed-single.c: (ephy_embed_single_remove_passwords): * embed/ephy-embed-single.h: * embed/ephy-embed-utils.c: * embed/ephy-embed-utils.h: Obsolete and removed. * embed/mozilla/ContentHandler.cpp: * embed/mozilla/ContentHandler.h: Misc cleanups. * embed/mozilla/FilePicker.cpp: * embed/mozilla/FilePicker.h: Port to new file chooser class. * embed/mozilla/Makefile.am: * lib/Makefile.am: * lib/ephy-file-chooser.c: (ephy_file_chooser_get_type), (current_folder_changed_cb), (ephy_file_chooser_init), (ephy_file_chooser_finalize), (ephy_file_chooser_set_persist_key), (ephy_file_chooser_set_property), (ephy_file_chooser_get_property), (ephy_file_chooser_class_init), (ephy_file_chooser_new): * lib/ephy-file-chooser.h: * src/bookmarks/ephy-bookmarks-editor.c: (import_from_file_response_cb), (import_dialog_response_cb): New file chooser wrapper class; ported file chooser callers to it.
Diffstat (limited to 'src/window-commands.c')
-rw-r--r--src/window-commands.c88
1 files changed, 42 insertions, 46 deletions
diff --git a/src/window-commands.c b/src/window-commands.c
index a4793df79..364d326e6 100644
--- a/src/window-commands.c
+++ b/src/window-commands.c
@@ -18,19 +18,22 @@
* $Id$
*/
-#include <config.h>
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
#include "ephy-shell.h"
+#include "ephy-embed-persist.h"
#include "ephy-debug.h"
#include "ephy-command-manager.h"
#include "window-commands.h"
#include "print-dialog.h"
#include "eel-gconf-extensions.h"
#include "ephy-prefs.h"
-#include "ephy-embed-utils.h"
#include "pdm-dialog.h"
#include "ephy-bookmarks-editor.h"
#include "ephy-new-bookmark.h"
+#include "ephy-file-chooser.h"
#include "ephy-file-helpers.h"
#include "toolbar.h"
#include "ephy-state.h"
@@ -41,6 +44,7 @@
#include "egg-editable-toolbar.h"
#include "egg-toolbar-editor.h"
+#include <glib.h>
#include <string.h>
#include <libgnomevfs/gnome-vfs-uri.h>
#include <libgnomevfs/gnome-vfs-utils.h>
@@ -318,53 +322,43 @@ window_cmd_file_bookmark_page (GtkAction *action,
g_free (location);
}
-void
-window_cmd_file_open (GtkAction *action,
- EphyWindow *window)
+static void
+open_response_cb (GtkDialog *dialog, gint response, EphyWindow *window)
{
- char *dir, *ret_dir, *file;
- EphyEmbedShell *embed_shell;
- gresult result;
- EphyEmbedSingle *single;
+ if (response == EPHY_RESPONSE_OPEN)
+ {
+ char *uri, *converted;
- single = ephy_embed_shell_get_embed_single
- (EPHY_EMBED_SHELL (ephy_shell));
+ uri = gtk_file_chooser_get_uri (GTK_FILE_CHOOSER (dialog));
+ converted = g_filename_to_utf8 (uri, -1, NULL, NULL, NULL);
- embed_shell = EPHY_EMBED_SHELL (ephy_shell);
+ if (converted != NULL)
+ {
+ ephy_window_load_url(window, uri);
+ }
- dir = eel_gconf_get_string (CONF_STATE_OPEN_DIR);
+ g_free (converted);
+ g_free (uri);
+ }
- result = ephy_embed_single_show_file_picker
- (single, GTK_WIDGET (window),
- _("Open"),
- dir, NULL, modeOpen,
- &file, NULL, NULL);
+ gtk_widget_destroy (GTK_WIDGET (dialog));
+}
- /* persist directory choice */
- /* Fix for bug 122780:
- * if the user selected a directory, or aborted with no filename typed,
- * g_path_get_dirname and gnome_vfs_uri_extract_dirname strip the last
- * path component, so test if the returned file is actually a directory.
- */
- if (g_file_test (file, G_FILE_TEST_IS_DIR))
- {
- ret_dir = g_strdup (file);
- }
- else
- {
- ret_dir = g_path_get_dirname (file);
- }
+void
+window_cmd_file_open (GtkAction *action,
+ EphyWindow *window)
+{
+ EphyFileChooser *dialog;
- eel_gconf_set_string (CONF_STATE_OPEN_DIR, ret_dir);
+ dialog = ephy_file_chooser_new (_("Open"),
+ GTK_WIDGET (window),
+ GTK_FILE_CHOOSER_ACTION_OPEN,
+ CONF_STATE_OPEN_DIR);
- if (result == G_OK)
- {
- ephy_window_load_url(window, file);
- }
+ g_signal_connect (dialog, "response",
+ G_CALLBACK (open_response_cb), window);
- g_free (ret_dir);
- g_free (file);
- g_free (dir);
+ gtk_widget_show (GTK_WIDGET (dialog));
}
void
@@ -378,13 +372,15 @@ window_cmd_file_save_as (GtkAction *action,
g_return_if_fail (embed != NULL);
persist = ephy_embed_persist_new (embed);
- ephy_embed_persist_set_flags (persist,
- EMBED_PERSIST_MAINDOC);
- ephy_embed_utils_save (GTK_WIDGET(window),
- _("Save As"),
- CONF_STATE_SAVE_DIR,
- TRUE, persist);
+ ephy_embed_persist_set_fc_title (persist, _("Save As"));
+ ephy_embed_persist_set_fc_parent (persist,GTK_WINDOW (window));
+ ephy_embed_persist_set_flags
+ (persist, EMBED_PERSIST_MAINDOC | EMBED_PERSIST_ASK_DESTINATION);
+ ephy_embed_persist_set_persist_key
+ (persist, CONF_STATE_SAVE_DIR);
+
+ ephy_embed_persist_save (persist);
g_object_unref (G_OBJECT(persist));
}