Refactoring of bookmarks add functions
This commit is contained in:
parent
3eea7c933d
commit
08dab16bc2
4 changed files with 38 additions and 62 deletions
|
@ -956,20 +956,6 @@ midori_browser_edit_bookmark_dialog_new (MidoriBrowser* browser,
|
||||||
gtk_widget_destroy (dialog);
|
gtk_widget_destroy (dialog);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
|
||||||
midori_view_add_bookmark_cb (GtkWidget* menuitem,
|
|
||||||
const gchar* uri,
|
|
||||||
GtkWidget* view)
|
|
||||||
{
|
|
||||||
KatzeItem* item;
|
|
||||||
MidoriBrowser* browser;
|
|
||||||
|
|
||||||
item = katze_item_new ();
|
|
||||||
katze_item_set_uri (item, uri);
|
|
||||||
browser = midori_browser_get_for_widget (menuitem);
|
|
||||||
midori_browser_edit_bookmark_dialog_new (browser, item, TRUE, FALSE);
|
|
||||||
}
|
|
||||||
|
|
||||||
#if WEBKIT_CHECK_VERSION (1, 1, 3)
|
#if WEBKIT_CHECK_VERSION (1, 1, 3)
|
||||||
static gboolean
|
static gboolean
|
||||||
midori_browser_prepare_download (MidoriBrowser* browser,
|
midori_browser_prepare_download (MidoriBrowser* browser,
|
||||||
|
@ -1601,8 +1587,6 @@ _midori_browser_add_tab (MidoriBrowser* browser,
|
||||||
#endif
|
#endif
|
||||||
"signal::search-text",
|
"signal::search-text",
|
||||||
midori_view_search_text_cb, browser,
|
midori_view_search_text_cb, browser,
|
||||||
"signal::add-bookmark",
|
|
||||||
midori_view_add_bookmark_cb, browser,
|
|
||||||
"signal::save-as",
|
"signal::save-as",
|
||||||
midori_view_save_as_cb, browser,
|
midori_view_save_as_cb, browser,
|
||||||
"signal::add-speed-dial",
|
"signal::add-speed-dial",
|
||||||
|
@ -4269,14 +4253,10 @@ 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, FALSE);
|
if (g_str_equal (gtk_action_get_name (action), "BookmarkFolderAdd"))
|
||||||
}
|
midori_browser_edit_bookmark_dialog_new (browser, NULL, TRUE, TRUE);
|
||||||
|
else
|
||||||
static void
|
midori_browser_edit_bookmark_dialog_new (browser, NULL, TRUE, FALSE);
|
||||||
_action_bookmark_folder_add_activate (GtkAction* action,
|
|
||||||
MidoriBrowser* browser)
|
|
||||||
{
|
|
||||||
midori_browser_edit_bookmark_dialog_new (browser, NULL, TRUE, TRUE);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -5276,7 +5256,7 @@ static const GtkActionEntry entries[] =
|
||||||
N_("Add a new bookmark"), G_CALLBACK (_action_bookmark_add_activate) },
|
N_("Add a new bookmark"), G_CALLBACK (_action_bookmark_add_activate) },
|
||||||
{ "BookmarkFolderAdd", NULL,
|
{ "BookmarkFolderAdd", NULL,
|
||||||
N_("Add a new _folder"), "",
|
N_("Add a new _folder"), "",
|
||||||
N_("Add a new bookmark folder"), G_CALLBACK (_action_bookmark_folder_add_activate) },
|
N_("Add a new bookmark folder"), G_CALLBACK (_action_bookmark_add_activate) },
|
||||||
{ "BookmarksImport", NULL,
|
{ "BookmarksImport", NULL,
|
||||||
N_("_Import bookmarks"), "",
|
N_("_Import bookmarks"), "",
|
||||||
NULL, G_CALLBACK (_action_bookmarks_import_activate) },
|
NULL, G_CALLBACK (_action_bookmarks_import_activate) },
|
||||||
|
|
|
@ -397,6 +397,15 @@ midori_view_class_init (MidoriViewClass* class)
|
||||||
G_TYPE_BOOLEAN,
|
G_TYPE_BOOLEAN,
|
||||||
G_TYPE_STRING);
|
G_TYPE_STRING);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* MidoriView::add-bookmark:
|
||||||
|
* @view: the object on which the signal is emitted
|
||||||
|
* @uri: the bookmark URI
|
||||||
|
*
|
||||||
|
* Emitted when a bookmark is added.
|
||||||
|
*
|
||||||
|
* Deprecated: 0.2.7
|
||||||
|
*/
|
||||||
signals[ADD_BOOKMARK] = g_signal_new (
|
signals[ADD_BOOKMARK] = g_signal_new (
|
||||||
"add-bookmark",
|
"add-bookmark",
|
||||||
G_TYPE_FROM_CLASS (class),
|
G_TYPE_FROM_CLASS (class),
|
||||||
|
|
|
@ -309,7 +309,10 @@ midori_bookmarks_add_clicked_cb (GtkWidget* toolitem)
|
||||||
{
|
{
|
||||||
MidoriBrowser* browser = midori_browser_get_for_widget (toolitem);
|
MidoriBrowser* browser = midori_browser_get_for_widget (toolitem);
|
||||||
/* FIXME: Take selected folder into account */
|
/* FIXME: Take selected folder into account */
|
||||||
midori_browser_edit_bookmark_dialog_new (browser, NULL, TRUE, FALSE);
|
if (g_str_equal (gtk_widget_get_name (toolitem), "BookmarkFolderAdd"))
|
||||||
|
midori_browser_edit_bookmark_dialog_new (browser, NULL, TRUE, TRUE);
|
||||||
|
else
|
||||||
|
midori_browser_edit_bookmark_dialog_new (browser, NULL, TRUE, FALSE);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -365,15 +368,6 @@ midori_bookmarks_delete_clicked_cb (GtkWidget* toolitem,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
|
||||||
midori_bookmarks_folder_clicked_cb (GtkWidget* toolitem)
|
|
||||||
{
|
|
||||||
MidoriBrowser* browser = midori_browser_get_for_widget (GTK_WIDGET (toolitem));
|
|
||||||
/* FIXME: Take selected folder into account */
|
|
||||||
midori_browser_edit_bookmark_dialog_new (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)
|
||||||
|
@ -419,6 +413,7 @@ midori_bookmarks_get_toolbar (MidoriViewable* viewable)
|
||||||
gtk_toolbar_set_icon_size (GTK_TOOLBAR (toolbar), GTK_ICON_SIZE_BUTTON);
|
gtk_toolbar_set_icon_size (GTK_TOOLBAR (toolbar), GTK_ICON_SIZE_BUTTON);
|
||||||
bookmarks->toolbar = toolbar;
|
bookmarks->toolbar = toolbar;
|
||||||
toolitem = gtk_tool_button_new_from_stock (GTK_STOCK_ADD);
|
toolitem = gtk_tool_button_new_from_stock (GTK_STOCK_ADD);
|
||||||
|
gtk_widget_set_name (GTK_WIDGET (toolitem), "BookmarkAdd");
|
||||||
gtk_widget_set_tooltip_text (GTK_WIDGET (toolitem),
|
gtk_widget_set_tooltip_text (GTK_WIDGET (toolitem),
|
||||||
_("Add a new bookmark"));
|
_("Add a new bookmark"));
|
||||||
gtk_tool_item_set_is_important (toolitem, TRUE);
|
gtk_tool_item_set_is_important (toolitem, TRUE);
|
||||||
|
@ -448,10 +443,11 @@ 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));
|
||||||
toolitem = gtk_tool_button_new_from_stock (GTK_STOCK_DIRECTORY);
|
toolitem = gtk_tool_button_new_from_stock (GTK_STOCK_DIRECTORY);
|
||||||
|
gtk_widget_set_name (GTK_WIDGET (toolitem), "BookmarkFolderAdd");
|
||||||
gtk_widget_set_tooltip_text (GTK_WIDGET (toolitem),
|
gtk_widget_set_tooltip_text (GTK_WIDGET (toolitem),
|
||||||
_("Add a new folder"));
|
_("Add a new folder"));
|
||||||
g_signal_connect (toolitem, "clicked",
|
g_signal_connect (toolitem, "clicked",
|
||||||
G_CALLBACK (midori_bookmarks_folder_clicked_cb), bookmarks);
|
G_CALLBACK (midori_bookmarks_add_clicked_cb), bookmarks);
|
||||||
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));
|
||||||
|
|
||||||
|
|
|
@ -336,14 +336,6 @@ midori_history_read_from_db (MidoriHistory* history,
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
|
||||||
midori_history_add_clicked_cb (GtkWidget* toolitem)
|
|
||||||
{
|
|
||||||
MidoriBrowser* browser = midori_browser_get_for_widget (toolitem);
|
|
||||||
/* FIXME: Take selected folder into account */
|
|
||||||
midori_browser_edit_bookmark_dialog_new (browser, NULL, TRUE, FALSE);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
midori_history_delete_clicked_cb (GtkWidget* toolitem,
|
midori_history_delete_clicked_cb (GtkWidget* toolitem,
|
||||||
MidoriHistory* history)
|
MidoriHistory* history)
|
||||||
|
@ -416,6 +408,21 @@ midori_history_cursor_or_row_changed_cb (GtkTreeView* treeview,
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
static void
|
||||||
|
midori_history_bookmark_add_cb (GtkWidget* menuitem,
|
||||||
|
MidoriHistory* history)
|
||||||
|
{
|
||||||
|
KatzeItem* item;
|
||||||
|
|
||||||
|
MidoriBrowser* browser = midori_browser_get_for_widget (GTK_WIDGET (history));
|
||||||
|
item = (KatzeItem*)g_object_get_data (G_OBJECT (menuitem), "KatzeItem");
|
||||||
|
|
||||||
|
if (KATZE_IS_ITEM (item) && katze_item_get_uri (item))
|
||||||
|
midori_browser_edit_bookmark_dialog_new (browser, item, TRUE, FALSE);
|
||||||
|
else
|
||||||
|
midori_browser_edit_bookmark_dialog_new (browser, NULL, TRUE, FALSE);
|
||||||
|
}
|
||||||
|
|
||||||
static GtkWidget*
|
static GtkWidget*
|
||||||
midori_history_get_toolbar (MidoriViewable* viewable)
|
midori_history_get_toolbar (MidoriViewable* viewable)
|
||||||
{
|
{
|
||||||
|
@ -437,7 +444,7 @@ midori_history_get_toolbar (MidoriViewable* viewable)
|
||||||
_("Bookmark the selected history item"));
|
_("Bookmark the selected history item"));
|
||||||
gtk_tool_item_set_is_important (toolitem, TRUE);
|
gtk_tool_item_set_is_important (toolitem, TRUE);
|
||||||
g_signal_connect (toolitem, "clicked",
|
g_signal_connect (toolitem, "clicked",
|
||||||
G_CALLBACK (midori_history_add_clicked_cb), history);
|
G_CALLBACK (midori_history_bookmark_add_cb), history);
|
||||||
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));
|
||||||
history->bookmark = GTK_WIDGET (toolitem);
|
history->bookmark = GTK_WIDGET (toolitem);
|
||||||
|
@ -718,22 +725,6 @@ midori_history_open_in_window_activate_cb (GtkWidget* menuitem,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
|
||||||
midori_history_bookmark_activate_cb (GtkWidget* menuitem,
|
|
||||||
MidoriHistory* history)
|
|
||||||
{
|
|
||||||
KatzeItem* item;
|
|
||||||
const gchar* uri;
|
|
||||||
|
|
||||||
item = (KatzeItem*)g_object_get_data (G_OBJECT (menuitem), "KatzeItem");
|
|
||||||
uri = katze_item_get_uri (item);
|
|
||||||
|
|
||||||
if (uri && *uri)
|
|
||||||
{
|
|
||||||
MidoriBrowser* browser = midori_browser_get_for_widget (GTK_WIDGET (history));
|
|
||||||
midori_browser_edit_bookmark_dialog_new (browser, item, TRUE, FALSE);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
midori_history_popup (GtkWidget* widget,
|
midori_history_popup (GtkWidget* widget,
|
||||||
|
@ -758,7 +749,7 @@ midori_history_popup (GtkWidget* widget,
|
||||||
midori_history_popup_item (menu, STOCK_WINDOW_NEW, _("Open in New _Window"),
|
midori_history_popup_item (menu, STOCK_WINDOW_NEW, _("Open in New _Window"),
|
||||||
item, midori_history_open_in_window_activate_cb, history);
|
item, midori_history_open_in_window_activate_cb, history);
|
||||||
midori_history_popup_item (menu, STOCK_BOOKMARK_ADD, NULL,
|
midori_history_popup_item (menu, STOCK_BOOKMARK_ADD, NULL,
|
||||||
item, midori_history_bookmark_activate_cb, history);
|
item, midori_history_bookmark_add_cb, history);
|
||||||
}
|
}
|
||||||
menuitem = gtk_separator_menu_item_new ();
|
menuitem = gtk_separator_menu_item_new ();
|
||||||
gtk_menu_shell_append (GTK_MENU_SHELL (menu), menuitem);
|
gtk_menu_shell_append (GTK_MENU_SHELL (menu), menuitem);
|
||||||
|
|
Loading…
Reference in a new issue