diff --git a/midori/midori-browser.c b/midori/midori-browser.c index 9041d3dd..759e1ec6 100644 --- a/midori/midori-browser.c +++ b/midori/midori-browser.c @@ -3000,10 +3000,15 @@ _action_bookmarks_populate_popup (GtkAction* action, gtk_menu_shell_append (GTK_MENU_SHELL (menu), menuitem); gtk_widget_show (menuitem); } + menuitem = gtk_action_create_menu_item ( + _action_by_name (browser, "BookmarksExport")); + gtk_menu_shell_prepend (GTK_MENU_SHELL (menu), menuitem); + gtk_widget_show (menuitem); menuitem = gtk_action_create_menu_item ( _action_by_name (browser, "BookmarksImport")); gtk_menu_shell_prepend (GTK_MENU_SHELL (menu), menuitem); gtk_widget_show (menuitem); + menuitem = gtk_action_create_menu_item ( _action_by_name (browser, "BookmarkFolderAdd")); gtk_menu_shell_prepend (GTK_MENU_SHELL (menu), menuitem); @@ -4635,6 +4640,36 @@ _action_bookmarks_import_activate (GtkAction* action, gtk_widget_destroy (dialog); } +static void +_action_bookmarks_export_activate (GtkAction* action, + MidoriBrowser* browser) +{ + GtkWidget* file_dialog; + gchar* path = NULL; + GError* error; + + file_dialog = sokoke_file_chooser_dialog_new (_("Save file as"), + GTK_WINDOW (browser), GTK_FILE_CHOOSER_ACTION_SAVE); + gtk_file_chooser_set_current_name (GTK_FILE_CHOOSER (file_dialog), + "bookmarks.xbel"); + if (gtk_dialog_run (GTK_DIALOG (file_dialog)) == GTK_RESPONSE_OK) + path = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (file_dialog)); + gtk_widget_destroy (file_dialog); + + if (path == NULL) + return; + + error = NULL; + if (!midori_array_to_file (browser->bookmarks, path, "xbel", &error)) + { + sokoke_message_dialog (GTK_MESSAGE_ERROR, + _("Failed to export bookmarks"), error ? error->message : ""); + if (error) + g_error_free (error); + } + g_free (path); +} + static void _action_manage_search_engines_activate (GtkAction* action, MidoriBrowser* browser) @@ -5441,6 +5476,9 @@ static const GtkActionEntry entries[] = { { "BookmarksImport", NULL, N_("_Import bookmarks"), "", NULL, G_CALLBACK (_action_bookmarks_import_activate) }, + { "BookmarksExport", NULL, + N_("_Export bookmarks"), "", + NULL, G_CALLBACK (_action_bookmarks_export_activate) }, { "ManageSearchEngines", GTK_STOCK_PROPERTIES, N_("_Manage Search Engines"), "s", N_("Add, edit and remove search engines..."), @@ -5740,6 +5778,7 @@ static const gchar* ui_markup = "" "" "" + "" "" "" ""