aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ChangeLog16
-rw-r--r--embed/mozilla/ContentHandler.cpp3
-rw-r--r--embed/mozilla/EphyHeaderSniffer.cpp3
-rw-r--r--embed/mozilla/FilePicker.cpp6
-rw-r--r--lib/ephy-gui.c39
-rw-r--r--lib/ephy-gui.h2
-rw-r--r--src/bookmarks/ephy-bookmarks-editor.c9
7 files changed, 36 insertions, 42 deletions
diff --git a/ChangeLog b/ChangeLog
index 84f459668..d6d02277a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,19 @@
+2005-09-21 Christian Persch <chpe@cvs.gnome.org>
+
+ * lib/ephy-gui.c: (ephy_gui_check_location_writable):
+ * lib/ephy-gui.h:
+
+ New function to check the filename/directory for writability,
+ derived from the now removed ephy_gui_confirm_overwrite_file.
+
+ * src/bookmarks/ephy-bookmarks-editor.c:
+ * embed/mozilla/FilePicker.cpp:
+ * embed/mozilla/ContentHandler.cpp:
+ * embed/mozilla/EphyHeaderSniffer.cpp:
+
+ Use the filechooser's stock confirm-overwrite checking, but
+ we still need our own writability check.
+
2005-09-19 Christian Persch <chpe@cvs.gnome.org>
* embed/ephy-embed.h:
diff --git a/embed/mozilla/ContentHandler.cpp b/embed/mozilla/ContentHandler.cpp
index 2c8e0e93d..ead2ea138 100644
--- a/embed/mozilla/ContentHandler.cpp
+++ b/embed/mozilla/ContentHandler.cpp
@@ -173,6 +173,7 @@ NS_IMETHODIMP GContentHandler::PromptForSaveToFile(
GTK_FILE_CHOOSER_ACTION_SAVE,
CONF_STATE_SAVE_DIR,
EPHY_FILE_FILTER_ALL);
+ gtk_file_chooser_set_do_overwrite_confirmation (GTK_FILE_CHOOSER (dialog), TRUE);
gtk_file_chooser_set_current_name (GTK_FILE_CHOOSER (dialog), defaultFile.get());
if (parentWindow)
@@ -191,7 +192,7 @@ NS_IMETHODIMP GContentHandler::PromptForSaveToFile(
response = gtk_dialog_run (GTK_DIALOG (dialog));
filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (dialog));
} while (response == GTK_RESPONSE_ACCEPT
- && !ephy_gui_confirm_overwrite_file (GTK_WIDGET (dialog), filename));
+ && !ephy_gui_check_location_writable (GTK_WIDGET (dialog), filename));
if (response == GTK_RESPONSE_ACCEPT)
{
diff --git a/embed/mozilla/EphyHeaderSniffer.cpp b/embed/mozilla/EphyHeaderSniffer.cpp
index 7676c245f..8eaac238b 100644
--- a/embed/mozilla/EphyHeaderSniffer.cpp
+++ b/embed/mozilla/EphyHeaderSniffer.cpp
@@ -213,7 +213,7 @@ filechooser_response_cb (GtkWidget *dialog,
filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (dialog));
- if (ephy_gui_confirm_overwrite_file (dialog, filename) == FALSE)
+ if (ephy_gui_check_location_writable (dialog, filename) == FALSE)
{
g_free (filename);
return;
@@ -367,6 +367,7 @@ nsresult EphyHeaderSniffer::PerformSave (nsIURI* inOriginalURI)
GTK_FILE_CHOOSER_ACTION_SAVE,
key ? key : CONF_STATE_SAVE_DIR,
EPHY_FILE_FILTER_ALL_SUPPORTED);
+ gtk_file_chooser_set_do_overwrite_confirmation (GTK_FILE_CHOOSER (dialog), TRUE);
gtk_file_chooser_set_current_name (GTK_FILE_CHOOSER (dialog),
filename);
diff --git a/embed/mozilla/FilePicker.cpp b/embed/mozilla/FilePicker.cpp
index 58559bc0d..261318515 100644
--- a/embed/mozilla/FilePicker.cpp
+++ b/embed/mozilla/FilePicker.cpp
@@ -127,6 +127,10 @@ NS_IMETHODIMP GFilePicker::Init(nsIDOMWindowInternal *parent, const PRUnichar *t
{
gtk_file_chooser_set_select_multiple (GTK_FILE_CHOOSER (mDialog), TRUE);
}
+ if (mMode == nsIFilePicker::modeSave)
+ {
+ gtk_file_chooser_set_do_overwrite_confirmation (GTK_FILE_CHOOSER (mDialog), TRUE);
+ }
g_object_add_weak_pointer (G_OBJECT (mDialog), (gpointer *) &mDialog);
@@ -447,7 +451,7 @@ NS_IMETHODIMP GFilePicker::Show(PRInt16 *_retval)
}
while (response == GTK_RESPONSE_ACCEPT &&
mMode == nsIFilePicker::modeSave &&
- !ephy_gui_confirm_overwrite_file (GTK_WIDGET (mDialog), filename));
+ !ephy_gui_check_location_writable (GTK_WIDGET (mDialog), filename));
gtk_widget_hide (GTK_WIDGET (mDialog));
diff --git a/lib/ephy-gui.c b/lib/ephy-gui.c
index cb80b89c5..47a5544a5 100644
--- a/lib/ephy-gui.c
+++ b/lib/ephy-gui.c
@@ -304,8 +304,8 @@ ephy_gui_ensure_window_group (GtkWindow *window)
}
gboolean
-ephy_gui_confirm_overwrite_file (GtkWidget *parent,
- const char *filename)
+ephy_gui_check_location_writable (GtkWidget *parent,
+ const char *filename)
{
GtkWidget *dialog;
char *display_name;
@@ -331,7 +331,7 @@ ephy_gui_confirm_overwrite_file (GtkWidget *parent,
gtk_message_dialog_format_secondary_text (
GTK_MESSAGE_DIALOG (dialog),
_("You do not have permission to "
- "create files in this directory."));
+ "create files in this directory."));
gtk_window_set_title (GTK_WINDOW (dialog), _("Directory not writable"));
gtk_window_set_icon_name (GTK_WINDOW (dialog), "web-browser");
@@ -386,39 +386,8 @@ ephy_gui_confirm_overwrite_file (GtkWidget *parent,
return FALSE;
}
- dialog = gtk_message_dialog_new
- (parent ? GTK_WINDOW (parent) : NULL,
- GTK_DIALOG_DESTROY_WITH_PARENT,
- GTK_MESSAGE_QUESTION,
- GTK_BUTTONS_CANCEL,
- _("Overwrite \"%s\"?"), display_name);
- gtk_message_dialog_format_secondary_text
- (GTK_MESSAGE_DIALOG (dialog),
- _("A file with this name already exists. If you choose to "
- "overwrite this file, the contents will be lost."));
-
- gtk_dialog_add_button (GTK_DIALOG (dialog),
- _("_Overwrite"), GTK_RESPONSE_ACCEPT);
-
- gtk_window_set_title (GTK_WINDOW (dialog), _("Overwrite File?"));
- gtk_window_set_icon_name (GTK_WINDOW (dialog), "web-browser");
-
- gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_CANCEL);
-
- if (parent != NULL)
- {
- gtk_window_group_add_window (ephy_gui_ensure_window_group (GTK_WINDOW (parent)),
- GTK_WINDOW (dialog));
- }
-
- retval = (gtk_dialog_run (GTK_DIALOG (dialog)) == GTK_RESPONSE_ACCEPT);
-
- gtk_widget_destroy (dialog);
-
- g_free (display_name);
-
- return retval;
+ return TRUE;
}
void
diff --git a/lib/ephy-gui.h b/lib/ephy-gui.h
index 6a7e6ab30..3dc1eb18d 100644
--- a/lib/ephy-gui.h
+++ b/lib/ephy-gui.h
@@ -63,7 +63,7 @@ GtkWindowGroup *ephy_gui_ensure_window_group (GtkWindow *window);
gboolean ephy_gui_is_middle_click (void);
-gboolean ephy_gui_confirm_overwrite_file (GtkWidget *parent,
+gboolean ephy_gui_check_location_writable (GtkWidget *parent,
const char *filename);
void ephy_gui_help (GtkWindow *parent,
diff --git a/src/bookmarks/ephy-bookmarks-editor.c b/src/bookmarks/ephy-bookmarks-editor.c
index 26f9e7af5..068e9723b 100644
--- a/src/bookmarks/ephy-bookmarks-editor.c
+++ b/src/bookmarks/ephy-bookmarks-editor.c
@@ -752,6 +752,8 @@ cmd_bookmarks_export (GtkAction *action,
NULL,
EPHY_FILE_FILTER_NONE));
+ gtk_file_chooser_set_do_overwrite_confirmation (GTK_FILE_CHOOSER (dialog), TRUE);
+
gtk_file_chooser_set_current_folder
(GTK_FILE_CHOOSER (dialog), g_get_home_dir ());
@@ -777,7 +779,7 @@ cmd_bookmarks_export (GtkAction *action,
do
{
- char *basename, *strtmp;
+ char *basename, *strtmp = NULL;
g_free (filename);
@@ -788,13 +790,14 @@ cmd_bookmarks_export (GtkAction *action,
basename = g_path_get_basename (filename);
if (basename != NULL && strchr (basename, '.') == NULL)
{
- strtmp = filename;
if (format == 0)
{
+ strtmp = filename;
filename = g_strconcat (filename, ".rdf", NULL);
}
else if (format == 1)
{
+ strtmp = filename;
filename = g_strconcat (filename, ".html", NULL);
}
g_free (strtmp);
@@ -802,7 +805,7 @@ cmd_bookmarks_export (GtkAction *action,
g_free (basename);
}
while (response == GTK_RESPONSE_ACCEPT
- && !ephy_gui_confirm_overwrite_file (GTK_WIDGET (dialog), filename));
+ && !ephy_gui_check_location_writable (GTK_WIDGET (dialog), filename));
gtk_widget_destroy (dialog);