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);
|
g_free (text);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Private function, used by MidoriBookmarks */
|
/* Private function, used by MidoriBookmarks and MidoriHistory */
|
||||||
/* static */ void
|
/* static */ void
|
||||||
midori_browser_edit_bookmark_dialog_new (MidoriBrowser* browser,
|
midori_browser_edit_bookmark_dialog_new (MidoriBrowser* browser,
|
||||||
KatzeItem* bookmark,
|
KatzeItem* bookmark,
|
||||||
gboolean new_bookmark)
|
gboolean new_bookmark,
|
||||||
|
gboolean is_folder)
|
||||||
{
|
{
|
||||||
|
const gchar* title;
|
||||||
GtkWidget* dialog;
|
GtkWidget* dialog;
|
||||||
GtkSizeGroup* sizegroup;
|
GtkSizeGroup* sizegroup;
|
||||||
GtkWidget* view;
|
GtkWidget* view;
|
||||||
|
@ -528,9 +530,12 @@ midori_browser_edit_bookmark_dialog_new (MidoriBrowser* browser,
|
||||||
GtkWidget* entry_uri;
|
GtkWidget* entry_uri;
|
||||||
GtkWidget* combo_folder;
|
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 (
|
dialog = gtk_dialog_new_with_buttons (
|
||||||
new_bookmark ? _("New bookmark") : _("Edit bookmark"),
|
title, GTK_WINDOW (browser),
|
||||||
GTK_WINDOW (browser),
|
|
||||||
GTK_DIALOG_DESTROY_WITH_PARENT | GTK_DIALOG_NO_SEPARATOR,
|
GTK_DIALOG_DESTROY_WITH_PARENT | GTK_DIALOG_NO_SEPARATOR,
|
||||||
GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
|
GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
|
||||||
new_bookmark ? GTK_STOCK_ADD : GTK_STOCK_SAVE, GTK_RESPONSE_ACCEPT,
|
new_bookmark ? GTK_STOCK_ADD : GTK_STOCK_SAVE, GTK_RESPONSE_ACCEPT,
|
||||||
|
@ -544,9 +549,16 @@ midori_browser_edit_bookmark_dialog_new (MidoriBrowser* browser,
|
||||||
if (!bookmark)
|
if (!bookmark)
|
||||||
{
|
{
|
||||||
view = midori_browser_get_current_tab (browser);
|
view = midori_browser_get_current_tab (browser);
|
||||||
bookmark = g_object_new (KATZE_TYPE_ITEM,
|
if (is_folder)
|
||||||
"uri", midori_view_get_display_uri (MIDORI_VIEW (view)),
|
{
|
||||||
"name", midori_view_get_display_title (MIDORI_VIEW (view)), NULL);
|
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);
|
||||||
}
|
}
|
||||||
|
|
||||||
hbox = gtk_hbox_new (FALSE, 8);
|
hbox = gtk_hbox_new (FALSE, 8);
|
||||||
|
@ -677,7 +689,7 @@ midori_view_add_bookmark_cb (GtkWidget* menuitem,
|
||||||
item = katze_item_new ();
|
item = katze_item_new ();
|
||||||
katze_item_set_uri (item, uri);
|
katze_item_set_uri (item, uri);
|
||||||
browser = (MidoriBrowser*)gtk_widget_get_toplevel (menuitem);
|
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
|
static void
|
||||||
|
@ -2464,8 +2476,10 @@ midori_browser_bookmark_edit_activate_cb (GtkWidget* menuitem,
|
||||||
item = (KatzeItem*)g_object_get_data (G_OBJECT (menuitem), "KatzeItem");
|
item = (KatzeItem*)g_object_get_data (G_OBJECT (menuitem), "KatzeItem");
|
||||||
uri = katze_item_get_uri (item);
|
uri = katze_item_get_uri (item);
|
||||||
|
|
||||||
if (KATZE_IS_ARRAY (item) || (uri && *uri))
|
if (KATZE_IS_ARRAY (item))
|
||||||
midori_browser_edit_bookmark_dialog_new (browser, item, FALSE);
|
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
|
static void
|
||||||
|
@ -2560,7 +2574,7 @@ static void
|
||||||
_action_bookmark_add_activate (GtkAction* action,
|
_action_bookmark_add_activate (GtkAction* action,
|
||||||
MidoriBrowser* browser)
|
MidoriBrowser* browser)
|
||||||
{
|
{
|
||||||
midori_browser_edit_bookmark_dialog_new (browser, NULL, TRUE);
|
midori_browser_edit_bookmark_dialog_new (browser, NULL, TRUE, FALSE);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
|
|
@ -28,7 +28,8 @@
|
||||||
void
|
void
|
||||||
midori_browser_edit_bookmark_dialog_new (MidoriBrowser* browser,
|
midori_browser_edit_bookmark_dialog_new (MidoriBrowser* browser,
|
||||||
KatzeItem* bookmark,
|
KatzeItem* bookmark,
|
||||||
gboolean new_bookmark);
|
gboolean new_bookmark,
|
||||||
|
gboolean is_folder);
|
||||||
|
|
||||||
struct _MidoriBookmarks
|
struct _MidoriBookmarks
|
||||||
{
|
{
|
||||||
|
@ -114,7 +115,7 @@ midori_bookmarks_add_clicked_cb (GtkWidget* toolitem)
|
||||||
GtkWidget* browser = gtk_widget_get_toplevel (toolitem);
|
GtkWidget* browser = gtk_widget_get_toplevel (toolitem);
|
||||||
/* FIXME: Take selected folder into account */
|
/* FIXME: Take selected folder into account */
|
||||||
midori_browser_edit_bookmark_dialog_new (MIDORI_BROWSER (browser),
|
midori_browser_edit_bookmark_dialog_new (MIDORI_BROWSER (browser),
|
||||||
NULL, TRUE);
|
NULL, TRUE, FALSE);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -137,7 +138,7 @@ midori_bookmarks_edit_clicked_cb (GtkWidget* toolitem,
|
||||||
{
|
{
|
||||||
GtkWidget* browser = gtk_widget_get_toplevel (toolitem);
|
GtkWidget* browser = gtk_widget_get_toplevel (toolitem);
|
||||||
midori_browser_edit_bookmark_dialog_new (MIDORI_BROWSER (browser),
|
midori_browser_edit_bookmark_dialog_new (MIDORI_BROWSER (browser),
|
||||||
item, FALSE);
|
item, FALSE, FALSE);
|
||||||
}
|
}
|
||||||
|
|
||||||
g_object_unref (item);
|
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
|
static void
|
||||||
midori_bookmarks_cursor_or_row_changed_cb (GtkTreeView* treeview,
|
midori_bookmarks_cursor_or_row_changed_cb (GtkTreeView* treeview,
|
||||||
MidoriBookmarks* bookmarks)
|
MidoriBookmarks* bookmarks)
|
||||||
|
@ -237,6 +247,19 @@ midori_bookmarks_get_toolbar (MidoriViewable* viewable)
|
||||||
gtk_toolbar_insert (GTK_TOOLBAR (toolbar), toolitem, -1);
|
gtk_toolbar_insert (GTK_TOOLBAR (toolbar), toolitem, -1);
|
||||||
gtk_widget_show (GTK_WIDGET (toolitem));
|
gtk_widget_show (GTK_WIDGET (toolitem));
|
||||||
bookmarks->delete = 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 (
|
midori_bookmarks_cursor_or_row_changed_cb (
|
||||||
GTK_TREE_VIEW (bookmarks->treeview), bookmarks);
|
GTK_TREE_VIEW (bookmarks->treeview), bookmarks);
|
||||||
g_signal_connect (bookmarks->edit, "destroy",
|
g_signal_connect (bookmarks->edit, "destroy",
|
||||||
|
@ -696,7 +719,7 @@ midori_bookmarks_edit_activate_cb (GtkWidget* menuitem,
|
||||||
if (!is_separator)
|
if (!is_separator)
|
||||||
{
|
{
|
||||||
GtkWidget* browser = gtk_widget_get_toplevel (GTK_WIDGET (bookmarks));
|
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
|
void
|
||||||
midori_browser_edit_bookmark_dialog_new (MidoriBrowser* browser,
|
midori_browser_edit_bookmark_dialog_new (MidoriBrowser* browser,
|
||||||
KatzeItem* bookmark,
|
KatzeItem* bookmark,
|
||||||
gboolean new_bookmark);
|
gboolean new_bookmark,
|
||||||
|
gboolean is_folder);
|
||||||
|
|
||||||
struct _MidoriHistory
|
struct _MidoriHistory
|
||||||
{
|
{
|
||||||
|
@ -115,7 +116,7 @@ midori_history_add_clicked_cb (GtkWidget* toolitem)
|
||||||
GtkWidget* browser = gtk_widget_get_toplevel (toolitem);
|
GtkWidget* browser = gtk_widget_get_toplevel (toolitem);
|
||||||
/* FIXME: Take selected folder into account */
|
/* FIXME: Take selected folder into account */
|
||||||
midori_browser_edit_bookmark_dialog_new (MIDORI_BROWSER (browser),
|
midori_browser_edit_bookmark_dialog_new (MIDORI_BROWSER (browser),
|
||||||
NULL, TRUE);
|
NULL, TRUE, FALSE);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -752,7 +753,7 @@ midori_history_bookmark_activate_cb (GtkWidget* menuitem,
|
||||||
if (uri && *uri)
|
if (uri && *uri)
|
||||||
{
|
{
|
||||||
GtkWidget* browser = gtk_widget_get_toplevel (GTK_WIDGET (history));
|
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