[Xfce4-commits] <midori:master> Render bookmark dialog as a pop-over on buttons
Christian Dywan
noreply at xfce.org
Thu Mar 15 19:58:01 CET 2012
Updating branch refs/heads/master
to 2fa5059cc4d03dc4c914fe10c22e494744484911 (commit)
from 7d4cdfe4623d0debe6da2d3453d19193a5cf45c2 (commit)
commit 2fa5059cc4d03dc4c914fe10c22e494744484911
Author: Christian Dywan <christian at twotoasts.de>
Date: Thu Mar 15 19:57:01 2012 +0100
Render bookmark dialog as a pop-over on buttons
midori/midori-browser.c | 47 +++++++++++++++++++++++++++++++-------------
panels/midori-bookmarks.c | 9 ++++---
panels/midori-history.c | 8 ++++--
3 files changed, 43 insertions(+), 21 deletions(-)
diff --git a/midori/midori-browser.c b/midori/midori-browser.c
index c9acb8f..b28c39c 100644
--- a/midori/midori-browser.c
+++ b/midori/midori-browser.c
@@ -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
diff --git a/panels/midori-bookmarks.c b/panels/midori-bookmarks.c
index 8c97147..d6dfa29 100644
--- a/panels/midori-bookmarks.c
+++ b/panels/midori-bookmarks.c
@@ -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);
}
}
diff --git a/panels/midori-history.c b/panels/midori-history.c
index 90cc1c3..f54a2b8 100644
--- a/panels/midori-history.c
+++ b/panels/midori-history.c
@@ -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*
More information about the Xfce4-commits
mailing list