[Xfce4-commits] <midori:master> Re-implement 'Bookmarks' menubar and toolbar button

Christian Dywan noreply at xfce.org
Wed Sep 15 04:12:03 CEST 2010


Updating branch refs/heads/master
         to d39148f230630389cc63abec5de3aa4af2b32933 (commit)
       from 34ddb8c2f099ffd8e1add44e0c098de5f9cc4cbe (commit)

commit d39148f230630389cc63abec5de3aa4af2b32933
Author: Christian Dywan <christian at twotoasts.de>
Date:   Tue Sep 14 22:12:55 2010 +0200

    Re-implement 'Bookmarks' menubar and toolbar button

 midori/midori-browser.c |   60 ++++++++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 59 insertions(+), 1 deletions(-)

diff --git a/midori/midori-browser.c b/midori/midori-browser.c
index a2bf527..2edca99 100644
--- a/midori/midori-browser.c
+++ b/midori/midori-browser.c
@@ -2561,7 +2561,7 @@ midori_browser_get_toolbar_actions (MidoriBrowser* browser)
 {
     static const gchar* actions[] = {
             "WindowNew", "TabNew", "Open", "SaveAs", "Print", "Find",
-            "Fullscreen", "Preferences", "Window",
+            "Fullscreen", "Preferences", "Window", "Bookmarks",
             "ReloadStop", "ZoomIn", "TabClose",
             "ZoomOut", "Separator", "Back", "Forward", "Homepage",
             "Panel", "Trash", "Search", "BookmarkAdd", "Previous", "Next", NULL };
@@ -2820,6 +2820,45 @@ midori_browser_bookmark_popup (GtkWidget*      widget,
                                KatzeItem*      item,
                                MidoriBrowser*  browser);
 
+static gboolean
+_action_bookmarks_populate_folder (GtkAction*     action,
+                                   GtkMenuShell*  menu,
+                                   KatzeArray*    folder,
+                                   MidoriBrowser* browser)
+{
+    const char* sqlcmd = "SELECT uri, title, app, folder "
+                         "FROM bookmarks WHERE folder = '%q' ORDER BY uri ASC";
+    sqlite3* db = g_object_get_data (G_OBJECT (browser->bookmarks), "db");
+    const gchar* folder_name;
+    char* sqlcmd_folder;
+    KatzeArray* bookmarks;
+    GtkWidget* menuitem;
+
+    if (!db)
+        return;
+
+    /* Clear items from dummy array here */
+    gtk_container_foreach (GTK_CONTAINER (menu),
+        (GtkCallback)(gtk_widget_destroy), NULL);
+
+    folder_name = katze_item_get_name (KATZE_ITEM (folder));
+    sqlcmd_folder = sqlite3_mprintf (sqlcmd, folder_name ? folder_name : "");
+    bookmarks = katze_array_from_sqlite (db, sqlcmd_folder);
+    sqlite3_free (sqlcmd_folder);
+    if (!bookmarks || katze_array_is_empty (bookmarks))
+    {
+        menuitem = gtk_image_menu_item_new_with_label (_("Empty"));
+        gtk_widget_set_sensitive (menuitem, FALSE);
+        gtk_menu_shell_append (menu, menuitem);
+        gtk_widget_show (menuitem);
+        return TRUE;
+    }
+
+    katze_array_action_generate_menu (KATZE_ARRAY_ACTION (action), bookmarks,
+                                      menu, GTK_WIDGET (browser));
+    return TRUE;
+}
+
 static void
 _action_window_populate_popup (GtkAction*     action,
                                GtkMenu*       menu,
@@ -5246,6 +5285,7 @@ static const gchar* ui_markup =
                 "<menuitem action='Search'/>"
                 "<menuitem action='Trash'/>"
             "</menu>"
+            "<menuitem action='Bookmarks'/>"
             "<menuitem action='Tools'/>"
             "<menuitem action='Window'/>"
             "<menu action='Help'>"
@@ -5652,6 +5692,24 @@ midori_browser_init (MidoriBrowser* browser)
     g_object_unref (action);
 
     action = g_object_new (KATZE_TYPE_ARRAY_ACTION,
+        "name", "Bookmarks",
+        "label", _("_Bookmarks"),
+        "stock-id", STOCK_BOOKMARKS,
+        "tooltip", _("Show the saved bookmarks"),
+        "array", browser->proxy_array, /* Use a non-empty array here */
+        NULL);
+    g_object_connect (action,
+                      "signal::populate-folder",
+                      _action_bookmarks_populate_folder, browser,
+                      "signal::activate-item",
+                      midori_bookmarkbar_activate_item, browser,
+                      "signal::activate-item-alt",
+                      midori_bookmarkbar_activate_item_alt, browser,
+                      NULL);
+    gtk_action_group_add_action_with_accel (browser->action_group, action, "");
+    g_object_unref (action);
+
+    action = g_object_new (KATZE_TYPE_ARRAY_ACTION,
         "name", "Tools",
         "label", _("_Tools"),
         "stock-id", GTK_STOCK_PREFERENCES,



More information about the Xfce4-commits mailing list