aboutsummaryrefslogtreecommitdiffstats
path: root/src/bookmarks/ephy-bookmarks.c
diff options
context:
space:
mode:
authorChristian Persch <chpe@cvs.gnome.org>2004-12-14 03:04:01 +0800
committerChristian Persch <chpe@src.gnome.org>2004-12-14 03:04:01 +0800
commitcacc504b9a60460fc312220ba7461f23e196fd83 (patch)
tree70786e56d7163a160701a36001076a4acf5d4b88 /src/bookmarks/ephy-bookmarks.c
parent08a1289e48356e9da66ca2a16afa8355d8929cf3 (diff)
downloadgsoc2013-epiphany-cacc504b9a60460fc312220ba7461f23e196fd83.tar
gsoc2013-epiphany-cacc504b9a60460fc312220ba7461f23e196fd83.tar.gz
gsoc2013-epiphany-cacc504b9a60460fc312220ba7461f23e196fd83.tar.bz2
gsoc2013-epiphany-cacc504b9a60460fc312220ba7461f23e196fd83.tar.lz
gsoc2013-epiphany-cacc504b9a60460fc312220ba7461f23e196fd83.tar.xz
gsoc2013-epiphany-cacc504b9a60460fc312220ba7461f23e196fd83.tar.zst
gsoc2013-epiphany-cacc504b9a60460fc312220ba7461f23e196fd83.zip
Prompt for bookmark update.
2004-12-13 Christian Persch <chpe@cvs.gnome.org> * src/bookmarks/ephy-bookmarks.c: (update_bookmark_response_cb), (update_bookmark_destroy_cb), (redirect_cb): Prompt for bookmark update. * src/prefs-dialog.c: (get_download_button_label): Use gtk domain for Home and Desktop strings to get the same as the filechooser.
Diffstat (limited to 'src/bookmarks/ephy-bookmarks.c')
-rw-r--r--src/bookmarks/ephy-bookmarks.c85
1 files changed, 74 insertions, 11 deletions
diff --git a/src/bookmarks/ephy-bookmarks.c b/src/bookmarks/ephy-bookmarks.c
index 0d520f2ac..f8e9fe428 100644
--- a/src/bookmarks/ephy-bookmarks.c
+++ b/src/bookmarks/ephy-bookmarks.c
@@ -40,11 +40,14 @@
#include <string.h>
#include <glib/gi18n.h>
#include <libgnomevfs/gnome-vfs-utils.h>
+#include <gtk/gtkmessagedialog.h>
+#include <gtk/gtkdialog.h>
#define EPHY_BOOKMARKS_XML_ROOT "ephy_bookmarks"
#define EPHY_BOOKMARKS_XML_VERSION "1.03"
#define BOOKMARKS_SAVE_DELAY (3 * 1000)
#define MAX_FAVORITES_NUM 10
+#define UPDATE_URI_DATA_KEY "updated-uri"
#define EPHY_BOOKMARKS_GET_PRIVATE(object)(G_TYPE_INSTANCE_GET_PRIVATE ((object), EPHY_TYPE_BOOKMARKS, EphyBookmarksPrivate))
@@ -476,27 +479,87 @@ history_cleared_cb (EphyHistory *history, EphyBookmarks *bookmarks)
clear_favorites (bookmarks);
}
-#include <gtk/gtkmessagedialog.h>
-#include <gtk/gtkdialog.h>
-
static void
-redirect_cb (EphyHistory *history,
- const char *from_uri,
- const char *to_uri,
- EphyBookmarks *eb)
+update_bookmark_response_cb (GtkWidget *dialog,
+ int response,
+ EphyNode *bookmark)
{
- EphyNode *bookmark;
GValue value = { 0, };
+ char *to_uri;
- bookmark = ephy_bookmarks_find_bookmark (eb, from_uri);
- if (bookmark != NULL)
+ if (response == GTK_RESPONSE_ACCEPT)
{
+ to_uri = (char *) g_object_steal_data (G_OBJECT (dialog),
+ UPDATE_URI_DATA_KEY);
+
g_value_init (&value, G_TYPE_STRING);
- g_value_set_string (&value, to_uri);
+ g_value_take_string (&value, to_uri);
ephy_node_set_property (bookmark, EPHY_NODE_BMK_PROP_LOCATION,
&value);
g_value_unset (&value);
}
+
+ gtk_widget_destroy (dialog);
+}
+
+static void
+update_bookmark_destroy_cb (EphyNode *zombie,
+ GtkWidget *dialog)
+{
+ gtk_widget_destroy (dialog);
+}
+
+static void
+redirect_cb (EphyHistory *history,
+ const char *from_uri,
+ const char *to_uri,
+ EphyBookmarks *eb)
+{
+ EphyNode *bookmark;
+ GtkWidget *dialog;
+ const char *title;
+
+ bookmark = ephy_bookmarks_find_bookmark (eb, from_uri);
+
+ /* FIXME check if there's another update-bookmark dialog up
+ * for from_uri' -> from_uri and update it accordingly
+ */
+ if (bookmark == NULL) return;
+
+ title = ephy_node_get_property_string (bookmark, EPHY_NODE_BMK_PROP_TITLE);
+
+ dialog = gtk_message_dialog_new
+ (NULL, GTK_DIALOG_DESTROY_WITH_PARENT,
+ GTK_MESSAGE_QUESTION,
+ GTK_BUTTONS_NONE,
+ /* translators: the %s is the title of the bookmark */
+ _("Update bookmark \"%s\"?"),
+ title);
+ gtk_message_dialog_format_secondary_markup
+ (GTK_MESSAGE_DIALOG (dialog),
+ /* translators: the %s is a URL */
+ _("The bookmarked page has moved to <tt>%s</tt>."),
+ to_uri);
+
+ gtk_dialog_add_button (GTK_DIALOG (dialog),
+ _("_Don't update bookmark"), GTK_RESPONSE_REJECT);
+ gtk_dialog_add_button (GTK_DIALOG (dialog),
+ _("_Update bookmark"), GTK_RESPONSE_ACCEPT);
+ gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_REJECT);
+
+ gtk_window_set_title (GTK_WINDOW (dialog), _("Update bookmark?"));
+ gtk_window_set_icon_name (GTK_WINDOW (dialog), "web-browser");
+
+ g_object_set_data_full (G_OBJECT (dialog), UPDATE_URI_DATA_KEY,
+ g_strdup (to_uri), (GDestroyNotify) g_free);
+ g_signal_connect (dialog, "response",
+ G_CALLBACK (update_bookmark_response_cb), bookmark);
+ ephy_node_signal_connect_object (bookmark,
+ EPHY_NODE_DESTROY,
+ (EphyNodeCallback) update_bookmark_destroy_cb,
+ G_OBJECT (dialog));
+
+ gtk_window_present (GTK_WINDOW (dialog));
}
static void