]> spindle.queued.net Git - midori/commitdiff
Render bookmark dialog as a pop-over on buttons
authorChristian Dywan <christian@twotoasts.de>
Thu, 15 Mar 2012 18:57:01 +0000 (19:57 +0100)
committerChristian Dywan <christian@twotoasts.de>
Thu, 15 Mar 2012 18:57:57 +0000 (19:57 +0100)
midori/midori-browser.c
panels/midori-bookmarks.c
panels/midori-history.c

index c9acb8fcdac8b83f031c0604084c275ec5f0c62e..b28c39c489cf970f33e7506830084932f0c2b8da 100644 (file)
@@ -742,7 +742,8 @@ midori_browser_edit_bookmark_add_speed_dial_cb (GtkWidget* button,
 midori_browser_edit_bookmark_dialog_new (MidoriBrowser* browser,
                                          KatzeItem*     bookmark,
                                          gboolean       new_bookmark,
-                                         gboolean       is_folder)
+                                         gboolean       is_folder,
+                                         GtkWidget*     proxy)
 {
     const gchar* title;
     GtkWidget* dialog;
@@ -772,12 +773,23 @@ midori_browser_edit_bookmark_dialog_new (MidoriBrowser* browser,
         title = new_bookmark ? _("New folder") : _("Edit folder");
     else
         title = new_bookmark ? _("New bookmark") : _("Edit bookmark");
-    dialog = gtk_dialog_new_with_buttons (
-        title, GTK_WINDOW (browser),
-        GTK_DIALOG_DESTROY_WITH_PARENT | GTK_DIALOG_NO_SEPARATOR,
+    #ifdef HAVE_GRANITE
+    if (proxy != NULL)
+    {
+        /* FIXME: granite: should return GtkWidget* like GTK+ */
+        dialog = (GtkWidget*)granite_widgets_pop_over_new ();
+        granite_widgets_pop_over_move_to_widget (
+            GRANITE_WIDGETS_POP_OVER (dialog), proxy);
+    }
+    else
+    #endif
+    {
+        dialog = gtk_dialog_new_with_buttons (title, GTK_WINDOW (browser),
+            GTK_DIALOG_DESTROY_WITH_PARENT | GTK_DIALOG_NO_SEPARATOR, NULL);
+    }
+    gtk_dialog_add_buttons (GTK_DIALOG (dialog),
         GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
-        new_bookmark ? GTK_STOCK_ADD : GTK_STOCK_SAVE, GTK_RESPONSE_ACCEPT,
-        NULL);
+        new_bookmark ? GTK_STOCK_ADD : GTK_STOCK_SAVE, GTK_RESPONSE_ACCEPT, NULL);
     content_area = gtk_dialog_get_content_area (GTK_DIALOG (dialog));
     gtk_window_set_icon_name (GTK_WINDOW (dialog),
         new_bookmark ? GTK_STOCK_ADD : GTK_STOCK_REMOVE);
@@ -3877,13 +3889,11 @@ _action_search_activate (GtkAction*     action,
                          MidoriBrowser* browser)
 {
     GSList* proxies = gtk_action_get_proxies (action);
-    guint i = 0;
-    GtkWidget* proxy;
     const gchar* uri;
     gchar* search;
 
-    while (((proxy = g_slist_nth_data (proxies, i++))))
-        if (GTK_IS_TOOL_ITEM (proxy))
+    for (; proxies != NULL; proxies = g_slist_next (proxies))
+        if (GTK_IS_TOOL_ITEM (proxies->data))
         {
             if (!gtk_widget_get_visible (browser->navigationbar))
                 gtk_widget_show (browser->navigationbar);
@@ -4040,9 +4050,9 @@ midori_browser_bookmark_edit_activate_cb (GtkWidget*     menuitem,
     item = (KatzeItem*)g_object_get_data (G_OBJECT (menuitem), "KatzeItem");
 
     if (KATZE_ITEM_IS_BOOKMARK (item))
-        midori_browser_edit_bookmark_dialog_new (browser, item, FALSE, FALSE);
+        midori_browser_edit_bookmark_dialog_new (browser, item, FALSE, FALSE, NULL);
     else
-        midori_browser_edit_bookmark_dialog_new (browser, item, FALSE, TRUE);
+        midori_browser_edit_bookmark_dialog_new (browser, item, FALSE, TRUE, NULL);
 }
 
 static void
@@ -4140,10 +4150,19 @@ static void
 _action_bookmark_add_activate (GtkAction*     action,
                                MidoriBrowser* browser)
 {
+    GtkWidget* proxy = NULL;
+    GSList* proxies = gtk_action_get_proxies (action);
+    for (; proxies != NULL; proxies = g_slist_next (proxies))
+    if (GTK_IS_TOOL_ITEM (proxies->data))
+    {
+        proxy = proxies->data;
+        break;
+    }
+
     if (g_str_equal (gtk_action_get_name (action), "BookmarkFolderAdd"))
-        midori_browser_edit_bookmark_dialog_new (browser, NULL, TRUE, TRUE);
+        midori_browser_edit_bookmark_dialog_new (browser, NULL, TRUE, TRUE, proxy);
     else
-        midori_browser_edit_bookmark_dialog_new (browser, NULL, TRUE, FALSE);
+        midori_browser_edit_bookmark_dialog_new (browser, NULL, TRUE, FALSE, proxy);
 }
 
 static void
index 8c9714701a5a1cf102e523038ec355f5709efb7f..d6dfa29cbc2186a99c95ffabf5394b13253eafee 100644 (file)
@@ -29,7 +29,8 @@ gboolean
 midori_browser_edit_bookmark_dialog_new (MidoriBrowser* browser,
                                          KatzeItem*     bookmark,
                                          gboolean       new_bookmark,
-                                         gboolean       is_folder);
+                                         gboolean       is_folder,
+                                         GtkWidget*     proxy);
 
 void
 midori_browser_open_bookmark (MidoriBrowser* browser,
@@ -341,9 +342,9 @@ midori_bookmarks_add_clicked_cb (GtkWidget* toolitem)
     MidoriBrowser* browser = midori_browser_get_for_widget (toolitem);
     /* FIXME: Take selected folder into account */
     if (g_str_equal (gtk_widget_get_name (toolitem), "BookmarkFolderAdd"))
-        midori_browser_edit_bookmark_dialog_new (browser, NULL, TRUE, TRUE);
+        midori_browser_edit_bookmark_dialog_new (browser, NULL, TRUE, TRUE, toolitem);
     else
-        midori_browser_edit_bookmark_dialog_new (browser, NULL, TRUE, FALSE);
+        midori_browser_edit_bookmark_dialog_new (browser, NULL, TRUE, FALSE, toolitem);
 }
 
 static void
@@ -365,7 +366,7 @@ midori_bookmarks_edit_clicked_cb (GtkWidget*       toolitem,
 
         browser = midori_browser_get_for_widget (bookmarks->treeview);
         midori_browser_edit_bookmark_dialog_new (
-            browser, item, FALSE, KATZE_ITEM_IS_FOLDER (item));
+            browser, item, FALSE, KATZE_ITEM_IS_FOLDER (item), NULL);
         g_object_unref (item);
     }
 }
index 90cc1c393bea43a59a07656f619fb461091b707c..f54a2b82c5c2a32fba134b86607637e1062beb11 100644 (file)
@@ -28,7 +28,8 @@ void
 midori_browser_edit_bookmark_dialog_new (MidoriBrowser* browser,
                                          KatzeItem*     bookmark,
                                          gboolean       new_bookmark,
-                                         gboolean       is_folder);
+                                         gboolean       is_folder,
+                                         GtkWidget*     proxy);
 
 
 struct _MidoriHistory
@@ -373,6 +374,7 @@ midori_history_bookmark_add_cb (GtkWidget*     menuitem,
     GtkTreeIter iter;
     KatzeItem* item = NULL;
 
+    GtkWidget* proxy = GTK_IS_TOOL_ITEM (menuitem) ? menuitem : NULL;
     MidoriBrowser* browser = midori_browser_get_for_widget (GTK_WIDGET (history));
     if (katze_tree_view_get_selected_iter (GTK_TREE_VIEW (history->treeview),
                                            &model, &iter))
@@ -380,11 +382,11 @@ midori_history_bookmark_add_cb (GtkWidget*     menuitem,
 
     if (KATZE_IS_ITEM (item) && katze_item_get_uri (item))
     {
-        midori_browser_edit_bookmark_dialog_new (browser, item, TRUE, FALSE);
+        midori_browser_edit_bookmark_dialog_new (browser, item, TRUE, FALSE, proxy);
         g_object_unref (item);
     }
     else
-        midori_browser_edit_bookmark_dialog_new (browser, NULL, TRUE, FALSE);
+        midori_browser_edit_bookmark_dialog_new (browser, NULL, TRUE, FALSE, proxy);
 }
 
 static GtkWidget*