Add a "New folder" button to the bookmark panel
This commit is contained in:
parent
f022a72a42
commit
cbe3e75e80
3 changed files with 56 additions and 18 deletions
|
@ -511,12 +511,14 @@ midori_view_notify_statusbar_text_cb (MidoriView* view,
|
|||
g_free (text);
|
||||
}
|
||||
|
||||
/* Private function, used by MidoriBookmarks */
|
||||
/* Private function, used by MidoriBookmarks and MidoriHistory */
|
||||
/* static */ void
|
||||
midori_browser_edit_bookmark_dialog_new (MidoriBrowser* browser,
|
||||
KatzeItem* bookmark,
|
||||
gboolean new_bookmark)
|
||||
gboolean new_bookmark,
|
||||
gboolean is_folder)
|
||||
{
|
||||
const gchar* title;
|
||||
GtkWidget* dialog;
|
||||
GtkSizeGroup* sizegroup;
|
||||
GtkWidget* view;
|
||||
|
@ -528,9 +530,12 @@ midori_browser_edit_bookmark_dialog_new (MidoriBrowser* browser,
|
|||
GtkWidget* entry_uri;
|
||||
GtkWidget* combo_folder;
|
||||
|
||||
if (is_folder)
|
||||
title = new_bookmark ? _("New folder") : _("Edit folder");
|
||||
else
|
||||
title = new_bookmark ? _("New bookmark") : _("Edit bookmark");
|
||||
dialog = gtk_dialog_new_with_buttons (
|
||||
new_bookmark ? _("New bookmark") : _("Edit bookmark"),
|
||||
GTK_WINDOW (browser),
|
||||
title, GTK_WINDOW (browser),
|
||||
GTK_DIALOG_DESTROY_WITH_PARENT | GTK_DIALOG_NO_SEPARATOR,
|
||||
GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
|
||||
new_bookmark ? GTK_STOCK_ADD : GTK_STOCK_SAVE, GTK_RESPONSE_ACCEPT,
|
||||
|
@ -544,6 +549,13 @@ midori_browser_edit_bookmark_dialog_new (MidoriBrowser* browser,
|
|||
if (!bookmark)
|
||||
{
|
||||
view = midori_browser_get_current_tab (browser);
|
||||
if (is_folder)
|
||||
{
|
||||
bookmark = katze_array_new (KATZE_TYPE_ARRAY);
|
||||
katze_item_set_name (bookmark,
|
||||
midori_view_get_display_title (MIDORI_VIEW (view)));
|
||||
}
|
||||
else
|
||||
bookmark = g_object_new (KATZE_TYPE_ITEM,
|
||||
"uri", midori_view_get_display_uri (MIDORI_VIEW (view)),
|
||||
"name", midori_view_get_display_title (MIDORI_VIEW (view)), NULL);
|
||||
|
@ -677,7 +689,7 @@ midori_view_add_bookmark_cb (GtkWidget* menuitem,
|
|||
item = katze_item_new ();
|
||||
katze_item_set_uri (item, uri);
|
||||
browser = (MidoriBrowser*)gtk_widget_get_toplevel (menuitem);
|
||||
midori_browser_edit_bookmark_dialog_new (browser, item, FALSE);
|
||||
midori_browser_edit_bookmark_dialog_new (browser, item, FALSE, FALSE);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -2464,8 +2476,10 @@ midori_browser_bookmark_edit_activate_cb (GtkWidget* menuitem,
|
|||
item = (KatzeItem*)g_object_get_data (G_OBJECT (menuitem), "KatzeItem");
|
||||
uri = katze_item_get_uri (item);
|
||||
|
||||
if (KATZE_IS_ARRAY (item) || (uri && *uri))
|
||||
midori_browser_edit_bookmark_dialog_new (browser, item, FALSE);
|
||||
if (KATZE_IS_ARRAY (item))
|
||||
midori_browser_edit_bookmark_dialog_new (browser, item, FALSE, TRUE);
|
||||
else if (uri && *uri)
|
||||
midori_browser_edit_bookmark_dialog_new (browser, item, FALSE, FALSE);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -2560,7 +2574,7 @@ static void
|
|||
_action_bookmark_add_activate (GtkAction* action,
|
||||
MidoriBrowser* browser)
|
||||
{
|
||||
midori_browser_edit_bookmark_dialog_new (browser, NULL, TRUE);
|
||||
midori_browser_edit_bookmark_dialog_new (browser, NULL, TRUE, FALSE);
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
|
@ -28,7 +28,8 @@
|
|||
void
|
||||
midori_browser_edit_bookmark_dialog_new (MidoriBrowser* browser,
|
||||
KatzeItem* bookmark,
|
||||
gboolean new_bookmark);
|
||||
gboolean new_bookmark,
|
||||
gboolean is_folder);
|
||||
|
||||
struct _MidoriBookmarks
|
||||
{
|
||||
|
@ -114,7 +115,7 @@ midori_bookmarks_add_clicked_cb (GtkWidget* toolitem)
|
|||
GtkWidget* browser = gtk_widget_get_toplevel (toolitem);
|
||||
/* FIXME: Take selected folder into account */
|
||||
midori_browser_edit_bookmark_dialog_new (MIDORI_BROWSER (browser),
|
||||
NULL, TRUE);
|
||||
NULL, TRUE, FALSE);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -137,7 +138,7 @@ midori_bookmarks_edit_clicked_cb (GtkWidget* toolitem,
|
|||
{
|
||||
GtkWidget* browser = gtk_widget_get_toplevel (toolitem);
|
||||
midori_browser_edit_bookmark_dialog_new (MIDORI_BROWSER (browser),
|
||||
item, FALSE);
|
||||
item, FALSE, FALSE);
|
||||
}
|
||||
|
||||
g_object_unref (item);
|
||||
|
@ -169,6 +170,15 @@ midori_bookmarks_delete_clicked_cb (GtkWidget* toolitem,
|
|||
}
|
||||
}
|
||||
|
||||
static void
|
||||
midori_bookmarks_folder_clicked_cb (GtkWidget* toolitem)
|
||||
{
|
||||
GtkWidget* browser = gtk_widget_get_toplevel (toolitem);
|
||||
/* FIXME: Take selected folder into account */
|
||||
midori_browser_edit_bookmark_dialog_new (MIDORI_BROWSER (browser),
|
||||
NULL, TRUE, TRUE);
|
||||
}
|
||||
|
||||
static void
|
||||
midori_bookmarks_cursor_or_row_changed_cb (GtkTreeView* treeview,
|
||||
MidoriBookmarks* bookmarks)
|
||||
|
@ -237,6 +247,19 @@ midori_bookmarks_get_toolbar (MidoriViewable* viewable)
|
|||
gtk_toolbar_insert (GTK_TOOLBAR (toolbar), toolitem, -1);
|
||||
gtk_widget_show (GTK_WIDGET (toolitem));
|
||||
bookmarks->delete = GTK_WIDGET (toolitem);
|
||||
toolitem = gtk_separator_tool_item_new ();
|
||||
gtk_separator_tool_item_set_draw (GTK_SEPARATOR_TOOL_ITEM (toolitem), FALSE);
|
||||
gtk_tool_item_set_expand (toolitem, TRUE);
|
||||
gtk_toolbar_insert (GTK_TOOLBAR (toolbar), toolitem, -1);
|
||||
gtk_widget_show (GTK_WIDGET (toolitem));
|
||||
toolitem = gtk_tool_button_new_from_stock (GTK_STOCK_DIRECTORY);
|
||||
gtk_widget_set_tooltip_text (GTK_WIDGET (toolitem),
|
||||
_("Add a new folder"));
|
||||
g_signal_connect (toolitem, "clicked",
|
||||
G_CALLBACK (midori_bookmarks_folder_clicked_cb), bookmarks);
|
||||
gtk_toolbar_insert (GTK_TOOLBAR (toolbar), toolitem, -1);
|
||||
gtk_widget_show (GTK_WIDGET (toolitem));
|
||||
|
||||
midori_bookmarks_cursor_or_row_changed_cb (
|
||||
GTK_TREE_VIEW (bookmarks->treeview), bookmarks);
|
||||
g_signal_connect (bookmarks->edit, "destroy",
|
||||
|
@ -696,7 +719,7 @@ midori_bookmarks_edit_activate_cb (GtkWidget* menuitem,
|
|||
if (!is_separator)
|
||||
{
|
||||
GtkWidget* browser = gtk_widget_get_toplevel (GTK_WIDGET (bookmarks));
|
||||
midori_browser_edit_bookmark_dialog_new (MIDORI_BROWSER (browser), item, FALSE);
|
||||
midori_browser_edit_bookmark_dialog_new (MIDORI_BROWSER (browser), item, FALSE, FALSE);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -28,7 +28,8 @@
|
|||
void
|
||||
midori_browser_edit_bookmark_dialog_new (MidoriBrowser* browser,
|
||||
KatzeItem* bookmark,
|
||||
gboolean new_bookmark);
|
||||
gboolean new_bookmark,
|
||||
gboolean is_folder);
|
||||
|
||||
struct _MidoriHistory
|
||||
{
|
||||
|
@ -115,7 +116,7 @@ midori_history_add_clicked_cb (GtkWidget* toolitem)
|
|||
GtkWidget* browser = gtk_widget_get_toplevel (toolitem);
|
||||
/* FIXME: Take selected folder into account */
|
||||
midori_browser_edit_bookmark_dialog_new (MIDORI_BROWSER (browser),
|
||||
NULL, TRUE);
|
||||
NULL, TRUE, FALSE);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -752,7 +753,7 @@ midori_history_bookmark_activate_cb (GtkWidget* menuitem,
|
|||
if (uri && *uri)
|
||||
{
|
||||
GtkWidget* browser = gtk_widget_get_toplevel (GTK_WIDGET (history));
|
||||
midori_browser_edit_bookmark_dialog_new (MIDORI_BROWSER (browser), item, TRUE);
|
||||
midori_browser_edit_bookmark_dialog_new (MIDORI_BROWSER (browser), item, TRUE, FALSE);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue