aboutsummaryrefslogtreecommitdiffstats
path: root/src/bookmarks/ephy-bookmarks-editor.c
diff options
context:
space:
mode:
authorChristian Persch <chpe@cvs.gnome.org>2004-12-07 07:00:08 +0800
committerChristian Persch <chpe@src.gnome.org>2004-12-07 07:00:08 +0800
commit258fa23beaa5c6096dcd2081ccc5f3fa1e6e6f1e (patch)
tree0501dae900c657a595512dcfbaeeb452f55fb020 /src/bookmarks/ephy-bookmarks-editor.c
parent7d41f0ac49c67d18ff6852f92f730c0929852790 (diff)
downloadgsoc2013-epiphany-258fa23beaa5c6096dcd2081ccc5f3fa1e6e6f1e.tar
gsoc2013-epiphany-258fa23beaa5c6096dcd2081ccc5f3fa1e6e6f1e.tar.gz
gsoc2013-epiphany-258fa23beaa5c6096dcd2081ccc5f3fa1e6e6f1e.tar.bz2
gsoc2013-epiphany-258fa23beaa5c6096dcd2081ccc5f3fa1e6e6f1e.tar.lz
gsoc2013-epiphany-258fa23beaa5c6096dcd2081ccc5f3fa1e6e6f1e.tar.xz
gsoc2013-epiphany-258fa23beaa5c6096dcd2081ccc5f3fa1e6e6f1e.tar.zst
gsoc2013-epiphany-258fa23beaa5c6096dcd2081ccc5f3fa1e6e6f1e.zip
A data/epiphany-bookmarks-html.xsl:
2004-12-06 Christian Persch <chpe@cvs.gnome.org> * configure.ac: * data/Makefile.am: A data/epiphany-bookmarks-html.xsl: * data/ui/epiphany-bookmark-editor-ui.xml: * src/bookmarks/ephy-bookmarks-editor.c: (cmd_bookmarks_export), (ephy_bookmarks_editor_construct): * src/bookmarks/ephy-bookmarks-export.c: (write_rdf), (ephy_bookmarks_export_rdf), (ephy_bookmarks_export_mozilla): * src/bookmarks/ephy-bookmarks-export.h: * src/ephy-main.c: (main): Add bookmarks export to bookmarks editor. Fixes bug #157745.
Diffstat (limited to 'src/bookmarks/ephy-bookmarks-editor.c')
-rw-r--r--src/bookmarks/ephy-bookmarks-editor.c98
1 files changed, 98 insertions, 0 deletions
diff --git a/src/bookmarks/ephy-bookmarks-editor.c b/src/bookmarks/ephy-bookmarks-editor.c
index babb883e7..556984c5a 100644
--- a/src/bookmarks/ephy-bookmarks-editor.c
+++ b/src/bookmarks/ephy-bookmarks-editor.c
@@ -47,6 +47,7 @@
#include "ephy-bookmarks-editor.h"
#include "ephy-bookmarks-import.h"
+#include "ephy-bookmarks-export.h"
#include "ephy-node-common.h"
#include "ephy-node-view.h"
#include "ephy-window.h"
@@ -113,6 +114,8 @@ static void cmd_bookmark_properties (GtkAction *action,
EphyBookmarksEditor *editor);
static void cmd_bookmarks_import (GtkAction *action,
EphyBookmarksEditor *editor);
+static void cmd_bookmarks_export (GtkAction *action,
+ EphyBookmarksEditor *editor);
static void cmd_add_topic (GtkAction *action,
EphyBookmarksEditor *editor);
static void cmd_rename (GtkAction *action,
@@ -189,6 +192,9 @@ static GtkActionEntry ephy_bookmark_popup_entries [] = {
{ "Import", NULL, N_("_Import Bookmarks..."), NULL,
N_("Import bookmarks from another browser or a bookmarks file"),
G_CALLBACK (cmd_bookmarks_import) },
+ { "Export", NULL, N_("_Export Bookmarks..."), NULL,
+ N_("Export bookmarks to a file"),
+ G_CALLBACK (cmd_bookmarks_export) },
{ "Close", GTK_STOCK_CLOSE, N_("_Close"), "<control>W",
N_("Close the bookmarks window"),
G_CALLBACK (cmd_close) },
@@ -661,6 +667,88 @@ import_dialog_response_cb (GtkDialog *dialog, gint response,
}
static void
+cmd_bookmarks_export (GtkAction *action,
+ EphyBookmarksEditor *editor)
+{
+ GtkWidget *dialog, *hbox, *label, *combo;
+ char *filename = NULL;
+ int response, format;
+
+ 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_current_folder
+ (GTK_FILE_CHOOSER (dialog), g_get_home_dir ());
+
+ gtk_file_chooser_set_current_name
+ (GTK_FILE_CHOOSER (dialog), _("Bookmarks"));
+
+ /* Make a format selection combo & label */
+ label = gtk_label_new (_("File format:"));
+
+ combo = gtk_combo_box_new_text ();
+ gtk_combo_box_append_text (GTK_COMBO_BOX (combo), _("Epiphany (RDF)"));
+ gtk_combo_box_append_text (GTK_COMBO_BOX (combo), _("Mozilla (HTML)"));
+ gtk_combo_box_set_active (GTK_COMBO_BOX (combo), 1);
+
+ hbox = gtk_hbox_new (FALSE, 12);
+ gtk_box_pack_end (GTK_BOX (hbox), combo, TRUE, TRUE, 0);
+ gtk_box_pack_end (GTK_BOX (hbox), label, FALSE, FALSE, 0);
+ gtk_widget_show_all (hbox);
+
+ gtk_file_chooser_set_extra_widget (GTK_FILE_CHOOSER (dialog), hbox);
+
+ gtk_window_group_add_window (GTK_WINDOW (editor)->group, GTK_WINDOW (dialog));
+
+ do
+ {
+ char *basename, *strtmp;
+
+ g_free (filename);
+
+ response = gtk_dialog_run (GTK_DIALOG (dialog));
+
+ format = gtk_combo_box_get_active (GTK_COMBO_BOX (combo));
+ filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (dialog));
+ basename = g_path_get_basename (filename);
+ if (basename != NULL && strchr (basename, '.') == NULL)
+ {
+ strtmp = filename;
+ if (format == 0)
+ {
+ filename = g_strconcat (filename, ".rdf", NULL);
+ }
+ else if (format == 1)
+ {
+ filename = g_strconcat (filename, ".html", NULL);
+ }
+ g_free (strtmp);
+ }
+ g_free (basename);
+ }
+ while (response == GTK_RESPONSE_ACCEPT
+ && !ephy_gui_confirm_overwrite_file (GTK_WIDGET (dialog), filename));
+
+ gtk_widget_destroy (dialog);
+
+ /* 0 for ephy RDF format, 1 for mozilla HTML format */
+
+ if (format == 0)
+ {
+ ephy_bookmarks_export_rdf (editor->priv->bookmarks, filename);
+ }
+ else if (format == 1)
+ {
+ ephy_bookmarks_export_mozilla (editor->priv->bookmarks, filename);
+ }
+
+ g_free (filename);
+}
+
+static void
cmd_bookmarks_import (GtkAction *action,
EphyBookmarksEditor *editor)
{
@@ -1454,8 +1542,18 @@ ephy_bookmarks_editor_construct (EphyBookmarksEditor *editor)
EphyNode *node;
GtkUIManager *ui_merge;
GtkActionGroup *action_group;
+ GtkWindowGroup *group;
int col_id, details_value;
+ /* ensure window group */
+ group = GTK_WINDOW (editor)->group;
+ if (group == NULL)
+ {
+ group = gtk_window_group_new ();
+ gtk_window_group_add_window (group, GTK_WINDOW (editor));
+ g_object_unref (group);
+ }
+
gtk_window_set_title (GTK_WINDOW (editor), _("Bookmarks"));
gtk_window_set_icon_name (GTK_WINDOW (editor), EPHY_STOCK_BOOKMARKS);