aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/bookmarks/ephy-bookmarks-editor.c47
-rw-r--r--src/ephy-window.c21
-rw-r--r--src/popup-commands.c40
-rw-r--r--src/window-commands.c88
-rw-r--r--src/window-commands.h1
5 files changed, 111 insertions, 86 deletions
diff --git a/src/bookmarks/ephy-bookmarks-editor.c b/src/bookmarks/ephy-bookmarks-editor.c
index e902f3bdf..0236b825b 100644
--- a/src/bookmarks/ephy-bookmarks-editor.c
+++ b/src/bookmarks/ephy-bookmarks-editor.c
@@ -49,6 +49,7 @@
#include "ephy-prefs.h"
#include "ephy-shell.h"
#include "ephy-file-helpers.h"
+#include "ephy-file-chooser.h"
#include "popup-commands.h"
#include "ephy-state.h"
#include "window-commands.h"
@@ -494,6 +495,27 @@ add_bookmarks_source (GtkListStore *store,
}
static void
+import_from_file_response_cb (GtkDialog *dialog, gint response,
+ EphyBookmarksEditor *editor)
+{
+ char *filename;
+
+ if (response == EPHY_RESPONSE_OPEN)
+ {
+ filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (dialog));
+
+ if (filename != NULL)
+ {
+ ephy_bookmarks_import (editor->priv->bookmarks, filename);
+
+ g_free (filename);
+ }
+ }
+
+ gtk_widget_destroy (GTK_WIDGET (dialog));
+}
+
+static void
import_dialog_response_cb (GtkDialog *dialog, gint response,
EphyBookmarksEditor *editor)
{
@@ -516,15 +538,22 @@ import_dialog_response_cb (GtkDialog *dialog, gint response,
if (filename == NULL)
{
- const char *title;
- EphyEmbedSingle *single;
-
- title = _("Import bookmarks from file");
- single = ephy_embed_shell_get_embed_single
- (EPHY_EMBED_SHELL (ephy_shell));
- ephy_embed_single_show_file_picker
- (single, GTK_WIDGET (editor), title, NULL,
- NULL, modeOpen, &filename, NULL, NULL);
+ EphyFileChooser *dialog;
+
+ dialog = ephy_file_chooser_new (_("Import bookmarks from file"),
+ GTK_WIDGET (editor),
+ GTK_FILE_CHOOSER_ACTION_OPEN,
+ NULL);
+ /* FIXME: set up some filters perhaps ? */
+ g_signal_connect (dialog, "response",
+ G_CALLBACK (import_from_file_response_cb), editor);
+
+ gtk_dialog_add_buttons (GTK_DIALOG (dialog),
+ GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
+ GTK_STOCK_OPEN, GTK_RESPONSE_OK,
+ NULL);
+
+ gtk_widget_show (GTK_WIDGET (dialog));
}
else
{
diff --git a/src/ephy-window.c b/src/ephy-window.c
index 3cf31c15e..4ec9a3a92 100644
--- a/src/ephy-window.c
+++ b/src/ephy-window.c
@@ -969,7 +969,6 @@ show_embed_popup (EphyWindow *window, EphyTab *tab, EphyEmbedEvent *event)
GtkAction *action;
EmbedEventContext context;
const char *popup;
- char *path;
const GValue *value;
gboolean framed, has_background;
GtkWidget *widget;
@@ -991,24 +990,24 @@ show_embed_popup (EphyWindow *window, EphyTab *tab, EphyEmbedEvent *event)
if ((context & EMBED_CONTEXT_LINK) &&
(context & EMBED_CONTEXT_IMAGE))
{
- popup = "EphyImageLinkPopup";
+ popup = "/EphyImageLinkPopup";
}
else if (context & EMBED_CONTEXT_LINK)
{
- popup = "EphyLinkPopup";
+ popup = "/EphyLinkPopup";
}
else if (context & EMBED_CONTEXT_IMAGE)
{
- popup = "EphyImagePopup";
+ popup = "/EphyImagePopup";
}
-/* else if (context & EMBED_CONTEXT_INPUT)
+ /* else if (context & EMBED_CONTEXT_INPUT)
{
- popup = "EphyInputPopup";
- }*/
+ popup = "/EphyInputPopup";
+ } */
else
{
- popup = framed ? "EphyFramedDocumentPopup" :
- "EphyDocumentPopup";
+ popup = framed ? "/EphyFramedDocumentPopup" :
+ "/EphyDocumentPopup";
}
action_group = window->priv->popups_action_group;
@@ -1016,10 +1015,8 @@ show_embed_popup (EphyWindow *window, EphyTab *tab, EphyEmbedEvent *event)
g_object_set (action, "sensitive", has_background,
"visible", has_background, NULL);
- path = g_strconcat ("/", popup, NULL);
widget = gtk_ui_manager_get_widget (GTK_UI_MANAGER (window->ui_merge),
- path);
- g_free (path);
+ popup);
g_return_if_fail (widget != NULL);
diff --git a/src/popup-commands.c b/src/popup-commands.c
index e1d2a046e..02bfbea2a 100644
--- a/src/popup-commands.c
+++ b/src/popup-commands.c
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2000, 2001, 2002 Marco Pesenti Gritti
+ * Copyright (C) 2000-2003 Marco Pesenti Gritti
*
* 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
@@ -14,14 +14,19 @@
* 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.
+ *
+ * $Id$
*/
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
#include "popup-commands.h"
#include "ephy-shell.h"
#include "ephy-new-bookmark.h"
#include "ephy-embed-persist.h"
#include "ephy-prefs.h"
-#include "ephy-embed-utils.h"
#include "eel-gconf-extensions.h"
#include "ephy-file-helpers.h"
@@ -267,7 +272,6 @@ save_property_url (GtkAction *action,
EphyEmbedEvent *info;
const char *location;
const GValue *value;
- GtkWidget *widget;
EphyEmbedPersist *persist;
EphyEmbed *embed;
@@ -278,15 +282,17 @@ save_property_url (GtkAction *action,
ephy_embed_event_get_property (info, property, &value);
location = g_value_get_string (value);
- widget = GTK_WIDGET (embed);
-
persist = ephy_embed_persist_new (embed);
+ ephy_embed_persist_set_fc_title (persist, title);
+ ephy_embed_persist_set_fc_parent (persist,GTK_WINDOW (window));
+ ephy_embed_persist_set_flags
+ (persist, ask_dest ? EMBED_PERSIST_ASK_DESTINATION : 0);
+ ephy_embed_persist_set_persist_key
+ (persist, CONF_STATE_DOWNLOADING_DIR);
ephy_embed_persist_set_source (persist, location);
- ephy_embed_utils_save (GTK_WIDGET (window), title,
- CONF_STATE_DOWNLOADING_DIR,
- ask_dest, persist);
+ ephy_embed_persist_save (persist);
g_object_unref (G_OBJECT(persist));
}
@@ -338,16 +344,14 @@ background_download_completed (EphyEmbedPersist *persist,
const char *bg;
char *type;
- ephy_embed_persist_get_dest (persist, &bg);
+ bg = ephy_embed_persist_get_dest (persist);
eel_gconf_set_string (CONF_DESKTOP_BG_PICTURE, bg);
type = eel_gconf_get_string (CONF_DESKTOP_BG_TYPE);
- if (type || strcmp (type, "none") == 0)
+ if (type == NULL || strcmp (type, "none") == 0)
{
- eel_gconf_set_string (CONF_DESKTOP_BG_TYPE,
- "wallpaper");
+ eel_gconf_set_string (CONF_DESKTOP_BG_TYPE, "wallpaper");
}
-
g_free (type);
g_object_unref (persist);
@@ -374,18 +378,18 @@ popup_cmd_set_image_as_background (GtkAction *action,
persist = ephy_embed_persist_new (embed);
base = g_path_get_basename (location);
- dest = g_build_filename (ephy_dot_dir (),
- base, NULL);
+ dest = g_build_filename (ephy_dot_dir (), base, NULL);
- ephy_embed_persist_set_source (persist, location);
ephy_embed_persist_set_dest (persist, dest);
-
- ephy_embed_persist_save (persist);
+ ephy_embed_persist_set_flags (persist, EMBED_PERSIST_NO_VIEW);
+ ephy_embed_persist_set_source (persist, location);
g_signal_connect (persist, "completed",
G_CALLBACK (background_download_completed),
NULL);
+ ephy_embed_persist_save (persist);
+
g_free (dest);
g_free (base);
}
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));
}
diff --git a/src/window-commands.h b/src/window-commands.h
index 2fbbd540b..2f0f8bc14 100644
--- a/src/window-commands.h
+++ b/src/window-commands.h
@@ -19,7 +19,6 @@
#include <gtk/gtkaction.h>
#include "ephy-window.h"
-#include "ephy-embed-utils.h"
void window_cmd_edit_find (GtkAction *action,
EphyWindow *window);