Implement MidoriBrowser::populate-tool-menu and adjust extensions
Extensions used to look for the menu and append items manually. In order to show Tools in the Compact menu a proper signal is needed. Adblock, Shortcuts and Toolbar Editor are ported to the new API.
This commit is contained in:
parent
356f3f20be
commit
43e6542702
5 changed files with 207 additions and 97 deletions
|
@ -52,6 +52,11 @@ adblock_fixup_regexp (gchar* src)
|
||||||
return dst;
|
return dst;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
adblock_browser_populate_tool_menu_cb (MidoriBrowser* browser,
|
||||||
|
GtkWidget* menu,
|
||||||
|
MidoriExtension* extension);
|
||||||
|
|
||||||
static void
|
static void
|
||||||
adblock_app_add_browser_cb (MidoriApp* app,
|
adblock_app_add_browser_cb (MidoriApp* app,
|
||||||
MidoriBrowser* browser,
|
MidoriBrowser* browser,
|
||||||
|
@ -59,13 +64,14 @@ adblock_app_add_browser_cb (MidoriApp* app,
|
||||||
|
|
||||||
static void
|
static void
|
||||||
adblock_deactivate_cb (MidoriExtension* extension,
|
adblock_deactivate_cb (MidoriExtension* extension,
|
||||||
GtkWidget* menuitem)
|
MidoriBrowser* browser)
|
||||||
{
|
{
|
||||||
MidoriApp* app = midori_extension_get_app (extension);
|
MidoriApp* app = midori_extension_get_app (extension);
|
||||||
|
|
||||||
gtk_widget_destroy (menuitem);
|
|
||||||
g_signal_handlers_disconnect_by_func (
|
g_signal_handlers_disconnect_by_func (
|
||||||
extension, adblock_deactivate_cb, menuitem);
|
browser, adblock_browser_populate_tool_menu_cb, extension);
|
||||||
|
g_signal_handlers_disconnect_by_func (
|
||||||
|
extension, adblock_deactivate_cb, browser);
|
||||||
g_signal_handlers_disconnect_by_func (
|
g_signal_handlers_disconnect_by_func (
|
||||||
app, adblock_app_add_browser_cb, extension);
|
app, adblock_app_add_browser_cb, extension);
|
||||||
/* FIXME: Disconnect session callbacks */
|
/* FIXME: Disconnect session callbacks */
|
||||||
|
@ -289,26 +295,28 @@ adblock_menu_configure_filters_activate_cb (GtkWidget* menuitem,
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
adblock_app_add_browser_cb (MidoriApp* app,
|
adblock_browser_populate_tool_menu_cb (MidoriBrowser* browser,
|
||||||
MidoriBrowser* browser,
|
GtkWidget* menu,
|
||||||
MidoriExtension* extension)
|
MidoriExtension* extension)
|
||||||
{
|
{
|
||||||
GtkWidget* panel;
|
|
||||||
GtkWidget* menu;
|
|
||||||
GtkWidget* menuitem;
|
GtkWidget* menuitem;
|
||||||
|
|
||||||
panel = katze_object_get_object (browser, "panel");
|
|
||||||
menu = katze_object_get_object (panel, "menu");
|
|
||||||
menuitem = gtk_menu_item_new_with_mnemonic (_("Configure _Advertisement filters..."));
|
menuitem = gtk_menu_item_new_with_mnemonic (_("Configure _Advertisement filters..."));
|
||||||
g_signal_connect (menuitem, "activate",
|
g_signal_connect (menuitem, "activate",
|
||||||
G_CALLBACK (adblock_menu_configure_filters_activate_cb), extension);
|
G_CALLBACK (adblock_menu_configure_filters_activate_cb), extension);
|
||||||
gtk_widget_show (menuitem);
|
gtk_widget_show (menuitem);
|
||||||
gtk_menu_shell_insert (GTK_MENU_SHELL (menu), menuitem, 3);
|
gtk_menu_shell_append (GTK_MENU_SHELL (menu), menuitem);
|
||||||
g_object_unref (menu);
|
}
|
||||||
g_object_unref (panel);
|
|
||||||
|
|
||||||
|
static void
|
||||||
|
adblock_app_add_browser_cb (MidoriApp* app,
|
||||||
|
MidoriBrowser* browser,
|
||||||
|
MidoriExtension* extension)
|
||||||
|
{
|
||||||
|
g_signal_connect (browser, "populate-tool-menu",
|
||||||
|
G_CALLBACK (adblock_browser_populate_tool_menu_cb), extension);
|
||||||
g_signal_connect (extension, "deactivate",
|
g_signal_connect (extension, "deactivate",
|
||||||
G_CALLBACK (adblock_deactivate_cb), menuitem);
|
G_CALLBACK (adblock_deactivate_cb), browser);
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
|
|
|
@ -14,6 +14,11 @@
|
||||||
#include <midori/sokoke.h>
|
#include <midori/sokoke.h>
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
|
static void
|
||||||
|
shortcuts_browser_populate_tool_menu_cb (MidoriBrowser* browser,
|
||||||
|
GtkWidget* menu,
|
||||||
|
MidoriExtension* extension);
|
||||||
|
|
||||||
static void
|
static void
|
||||||
shortcuts_app_add_browser_cb (MidoriApp* app,
|
shortcuts_app_add_browser_cb (MidoriApp* app,
|
||||||
MidoriBrowser* browser,
|
MidoriBrowser* browser,
|
||||||
|
@ -21,13 +26,14 @@ shortcuts_app_add_browser_cb (MidoriApp* app,
|
||||||
|
|
||||||
static void
|
static void
|
||||||
shortcuts_deactivate_cb (MidoriExtension* extension,
|
shortcuts_deactivate_cb (MidoriExtension* extension,
|
||||||
GtkWidget* menuitem)
|
MidoriBrowser* browser)
|
||||||
{
|
{
|
||||||
MidoriApp* app = midori_extension_get_app (extension);
|
MidoriApp* app = midori_extension_get_app (extension);
|
||||||
|
|
||||||
gtk_widget_destroy (menuitem);
|
|
||||||
g_signal_handlers_disconnect_by_func (
|
g_signal_handlers_disconnect_by_func (
|
||||||
extension, shortcuts_deactivate_cb, menuitem);
|
browser, shortcuts_browser_populate_tool_menu_cb, extension);
|
||||||
|
g_signal_handlers_disconnect_by_func (
|
||||||
|
extension, shortcuts_deactivate_cb, browser);
|
||||||
g_signal_handlers_disconnect_by_func (
|
g_signal_handlers_disconnect_by_func (
|
||||||
app, shortcuts_app_add_browser_cb, extension);
|
app, shortcuts_app_add_browser_cb, extension);
|
||||||
}
|
}
|
||||||
|
@ -249,26 +255,28 @@ shortcuts_menu_configure_shortcuts_activate_cb (GtkWidget* menuitem,
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
shortcuts_app_add_browser_cb (MidoriApp* app,
|
shortcuts_browser_populate_tool_menu_cb (MidoriBrowser* browser,
|
||||||
MidoriBrowser* browser,
|
GtkWidget* menu,
|
||||||
MidoriExtension* extension)
|
MidoriExtension* extension)
|
||||||
{
|
{
|
||||||
GtkWidget* panel;
|
|
||||||
GtkWidget* menu;
|
|
||||||
GtkWidget* menuitem;
|
GtkWidget* menuitem;
|
||||||
|
|
||||||
panel = katze_object_get_object (browser, "panel");
|
|
||||||
menu = katze_object_get_object (panel, "menu");
|
|
||||||
g_object_unref (panel);
|
|
||||||
menuitem = gtk_menu_item_new_with_mnemonic (_("Customize Sh_ortcuts..."));
|
menuitem = gtk_menu_item_new_with_mnemonic (_("Customize Sh_ortcuts..."));
|
||||||
g_signal_connect (menuitem, "activate",
|
g_signal_connect (menuitem, "activate",
|
||||||
G_CALLBACK (shortcuts_menu_configure_shortcuts_activate_cb), extension);
|
G_CALLBACK (shortcuts_menu_configure_shortcuts_activate_cb), extension);
|
||||||
gtk_widget_show (menuitem);
|
gtk_widget_show (menuitem);
|
||||||
gtk_menu_shell_insert (GTK_MENU_SHELL (menu), menuitem, 3);
|
gtk_menu_shell_append (GTK_MENU_SHELL (menu), menuitem);
|
||||||
g_object_unref (menu);
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
shortcuts_app_add_browser_cb (MidoriApp* app,
|
||||||
|
MidoriBrowser* browser,
|
||||||
|
MidoriExtension* extension)
|
||||||
|
{
|
||||||
|
g_signal_connect (browser, "populate-tool-menu",
|
||||||
|
G_CALLBACK (shortcuts_browser_populate_tool_menu_cb), extension);
|
||||||
g_signal_connect (extension, "deactivate",
|
g_signal_connect (extension, "deactivate",
|
||||||
G_CALLBACK (shortcuts_deactivate_cb), menuitem);
|
G_CALLBACK (shortcuts_deactivate_cb), browser);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
|
|
@ -48,16 +48,17 @@ static const GtkTargetEntry tb_editor_dnd_targets[] =
|
||||||
};
|
};
|
||||||
static const gint tb_editor_dnd_targets_len = G_N_ELEMENTS(tb_editor_dnd_targets);
|
static const gint tb_editor_dnd_targets_len = G_N_ELEMENTS(tb_editor_dnd_targets);
|
||||||
|
|
||||||
|
static void tb_editor_browser_populate_tool_menu_cb(MidoriBrowser *browser, GtkWidget *menu, MidoriExtension *ext);
|
||||||
|
|
||||||
static void tb_editor_app_add_browser_cb(MidoriApp *app, MidoriBrowser *browser, MidoriExtension *ext);
|
static void tb_editor_app_add_browser_cb(MidoriApp *app, MidoriBrowser *browser, MidoriExtension *ext);
|
||||||
|
|
||||||
|
|
||||||
static void tb_editor_deactivate_cb(MidoriExtension *extension, GtkWidget *menuitem)
|
static void tb_editor_deactivate_cb(MidoriExtension *extension, MidoriBrowser *browser)
|
||||||
{
|
{
|
||||||
MidoriApp *app = midori_extension_get_app(extension);
|
MidoriApp *app = midori_extension_get_app(extension);
|
||||||
|
|
||||||
gtk_widget_destroy(menuitem);
|
g_signal_handlers_disconnect_by_func(browser, tb_editor_browser_populate_tool_menu_cb, extension);
|
||||||
g_signal_handlers_disconnect_by_func(extension, tb_editor_deactivate_cb, menuitem);
|
g_signal_handlers_disconnect_by_func(extension, tb_editor_deactivate_cb, browser);
|
||||||
g_signal_handlers_disconnect_by_func(app, tb_editor_app_add_browser_cb, extension);
|
g_signal_handlers_disconnect_by_func(app, tb_editor_app_add_browser_cb, extension);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -571,24 +572,21 @@ static void tb_editor_menu_configure_toolbar_activate_cb(GtkWidget *menuitem, Mi
|
||||||
g_free(tbw);
|
g_free(tbw);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void tb_editor_browser_populate_tool_menu_cb(MidoriBrowser *browser, GtkWidget *menu, MidoriExtension *ext)
|
||||||
static void tb_editor_app_add_browser_cb(MidoriApp *app, MidoriBrowser *browser, MidoriExtension *ext)
|
|
||||||
{
|
{
|
||||||
GtkWidget *panel;
|
|
||||||
GtkWidget *menu;
|
|
||||||
GtkWidget *menuitem;
|
GtkWidget *menuitem;
|
||||||
|
|
||||||
panel = katze_object_get_object(browser, "panel");
|
|
||||||
menu = katze_object_get_object(panel, "menu");
|
|
||||||
g_object_unref(panel);
|
|
||||||
menuitem = gtk_menu_item_new_with_mnemonic (_("Customize _Toolbar..."));
|
menuitem = gtk_menu_item_new_with_mnemonic (_("Customize _Toolbar..."));
|
||||||
g_signal_connect (menuitem, "activate",
|
g_signal_connect (menuitem, "activate",
|
||||||
G_CALLBACK (tb_editor_menu_configure_toolbar_activate_cb), browser);
|
G_CALLBACK (tb_editor_menu_configure_toolbar_activate_cb), browser);
|
||||||
gtk_widget_show (menuitem);
|
gtk_widget_show (menuitem);
|
||||||
gtk_menu_shell_insert(GTK_MENU_SHELL (menu), menuitem, 3);
|
gtk_menu_shell_append (GTK_MENU_SHELL (menu), menuitem);
|
||||||
g_object_unref(menu);
|
}
|
||||||
|
|
||||||
g_signal_connect(ext, "deactivate", G_CALLBACK(tb_editor_deactivate_cb), menuitem);
|
static void tb_editor_app_add_browser_cb(MidoriApp *app, MidoriBrowser *browser, MidoriExtension *ext)
|
||||||
|
{
|
||||||
|
g_signal_connect(browser, "populate-tool-menu", G_CALLBACK(tb_editor_browser_populate_tool_menu_cb), ext);
|
||||||
|
g_signal_connect(ext, "deactivate", G_CALLBACK(tb_editor_deactivate_cb), browser);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -132,6 +132,7 @@ enum
|
||||||
CONTEXT_READY,
|
CONTEXT_READY,
|
||||||
ADD_DOWNLOAD,
|
ADD_DOWNLOAD,
|
||||||
SEND_NOTIFICATION,
|
SEND_NOTIFICATION,
|
||||||
|
POPULATE_TOOL_MENU,
|
||||||
QUIT,
|
QUIT,
|
||||||
|
|
||||||
LAST_SIGNAL
|
LAST_SIGNAL
|
||||||
|
@ -175,6 +176,10 @@ static void
|
||||||
_midori_browser_set_toolbar_style (MidoriBrowser* browser,
|
_midori_browser_set_toolbar_style (MidoriBrowser* browser,
|
||||||
MidoriToolbarStyle toolbar_style);
|
MidoriToolbarStyle toolbar_style);
|
||||||
|
|
||||||
|
GtkWidget*
|
||||||
|
midori_panel_construct_menu_item (MidoriPanel* panel,
|
||||||
|
MidoriViewable* viewable);
|
||||||
|
|
||||||
static GtkAction*
|
static GtkAction*
|
||||||
_action_by_name (MidoriBrowser* browser,
|
_action_by_name (MidoriBrowser* browser,
|
||||||
const gchar* name)
|
const gchar* name)
|
||||||
|
@ -1695,6 +1700,27 @@ midori_browser_class_init (MidoriBrowserClass* class)
|
||||||
G_TYPE_STRING,
|
G_TYPE_STRING,
|
||||||
G_TYPE_STRING);
|
G_TYPE_STRING);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* MidoriBrowser::populate-tool-menu:
|
||||||
|
* @browser: the object on which the signal is emitted
|
||||||
|
* @menu: the #GtkMenu to populate
|
||||||
|
*
|
||||||
|
* Emitted when a Tool menu is displayed, such as the
|
||||||
|
* toplevel Tools in the menubar or the compact menu.
|
||||||
|
*
|
||||||
|
* Since: 0.1.9
|
||||||
|
*/
|
||||||
|
signals[POPULATE_TOOL_MENU] = g_signal_new (
|
||||||
|
"populate-tool-menu",
|
||||||
|
G_TYPE_FROM_CLASS (class),
|
||||||
|
(GSignalFlags)(G_SIGNAL_RUN_LAST),
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
NULL,
|
||||||
|
g_cclosure_marshal_VOID__OBJECT,
|
||||||
|
G_TYPE_NONE, 1,
|
||||||
|
GTK_TYPE_MENU);
|
||||||
|
|
||||||
signals[QUIT] = g_signal_new (
|
signals[QUIT] = g_signal_new (
|
||||||
"quit",
|
"quit",
|
||||||
G_TYPE_FROM_CLASS (class),
|
G_TYPE_FROM_CLASS (class),
|
||||||
|
@ -2481,6 +2507,59 @@ _action_bookmarks_activate_item (GtkAction* action,
|
||||||
gtk_widget_grab_focus (midori_browser_get_current_tab (browser));
|
gtk_widget_grab_focus (midori_browser_get_current_tab (browser));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
_action_tools_populate_popup (GtkAction* action,
|
||||||
|
GtkMenu* menu,
|
||||||
|
MidoriBrowser* browser)
|
||||||
|
{
|
||||||
|
static const GtkActionEntry actions[] = {
|
||||||
|
{ "ManageSearchEngines" },
|
||||||
|
{ "ClearPrivateData" },
|
||||||
|
{ "-" },
|
||||||
|
{ NULL },
|
||||||
|
{ "p" },
|
||||||
|
#ifdef G_OS_WIN32
|
||||||
|
{ NULL },
|
||||||
|
{ "Preferences" },
|
||||||
|
#endif
|
||||||
|
};
|
||||||
|
guint i;
|
||||||
|
|
||||||
|
for (i = 0; i < G_N_ELEMENTS (actions); i++)
|
||||||
|
{
|
||||||
|
GtkWidget* menuitem;
|
||||||
|
if (actions[i].name != NULL)
|
||||||
|
{
|
||||||
|
if (actions[i].name[0] == '-')
|
||||||
|
{
|
||||||
|
g_signal_emit (browser, signals[POPULATE_TOOL_MENU], 0, menu);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
else if (actions[i].name[0] == 'p')
|
||||||
|
{
|
||||||
|
MidoriPanel* panel;
|
||||||
|
gsize j;
|
||||||
|
GtkWidget* widget;
|
||||||
|
|
||||||
|
panel = MIDORI_PANEL (browser->panel);
|
||||||
|
j = 0;
|
||||||
|
while ((widget = midori_panel_get_nth_page (panel, j++)))
|
||||||
|
{
|
||||||
|
menuitem = midori_panel_construct_menu_item (panel, MIDORI_VIEWABLE (widget));
|
||||||
|
gtk_menu_shell_append (GTK_MENU_SHELL (menu), menuitem);
|
||||||
|
}
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
menuitem = sokoke_action_create_popup_menu_item (
|
||||||
|
_action_by_name (browser, actions[i].name));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
menuitem = gtk_separator_menu_item_new ();
|
||||||
|
gtk_menu_shell_append (GTK_MENU_SHELL (menu), menuitem);
|
||||||
|
gtk_widget_show (menuitem);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
_action_menus_activate_item_alt (GtkAction* action,
|
_action_menus_activate_item_alt (GtkAction* action,
|
||||||
KatzeItem* item,
|
KatzeItem* item,
|
||||||
|
@ -2542,13 +2621,14 @@ _action_compact_menu_populate_popup (GtkAction* action,
|
||||||
{ "TabNew" },
|
{ "TabNew" },
|
||||||
{ "WindowNew" },
|
{ "WindowNew" },
|
||||||
{ "Open" },
|
{ "Open" },
|
||||||
{ "PrivateBrowsing" },
|
|
||||||
{ "Print" },
|
{ "Print" },
|
||||||
|
{ "PrivateBrowsing" },
|
||||||
{ NULL },
|
{ NULL },
|
||||||
{ "Bookmarkbar" },
|
{ "Bookmarkbar" },
|
||||||
{ "Panel" },
|
{ "Panel" },
|
||||||
{ "Statusbar" },
|
{ "Statusbar" },
|
||||||
{ NULL },
|
{ NULL },
|
||||||
|
{ "-" },
|
||||||
{ "ClearPrivateData" },
|
{ "ClearPrivateData" },
|
||||||
{ "Fullscreen" },
|
{ "Fullscreen" },
|
||||||
{ "Preferences" },
|
{ "Preferences" },
|
||||||
|
@ -2559,14 +2639,20 @@ _action_compact_menu_populate_popup (GtkAction* action,
|
||||||
{
|
{
|
||||||
GtkWidget* menuitem;
|
GtkWidget* menuitem;
|
||||||
if (actions[i].name != NULL)
|
if (actions[i].name != NULL)
|
||||||
|
{
|
||||||
|
if (actions[i].name[0] == '-')
|
||||||
|
{
|
||||||
|
g_signal_emit (browser, signals[POPULATE_TOOL_MENU], 0, menu);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
menuitem = sokoke_action_create_popup_menu_item (
|
menuitem = sokoke_action_create_popup_menu_item (
|
||||||
_action_by_name (browser, actions[i].name));
|
_action_by_name (browser, actions[i].name));
|
||||||
|
}
|
||||||
else
|
else
|
||||||
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);
|
||||||
|
gtk_widget_show (menuitem);
|
||||||
}
|
}
|
||||||
|
|
||||||
gtk_widget_show_all (GTK_WIDGET (menu));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -4145,7 +4231,6 @@ static const GtkActionEntry entries[] = {
|
||||||
{ "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_folder_add_activate) },
|
||||||
{ "Tools", NULL, N_("_Tools") },
|
|
||||||
{ "ManageSearchEngines", GTK_STOCK_PROPERTIES,
|
{ "ManageSearchEngines", GTK_STOCK_PROPERTIES,
|
||||||
N_("_Manage Search Engines"), "<Ctrl><Alt>s",
|
N_("_Manage Search Engines"), "<Ctrl><Alt>s",
|
||||||
N_("Add, edit and remove search engines..."),
|
N_("Add, edit and remove search engines..."),
|
||||||
|
@ -4399,15 +4484,7 @@ static const gchar* ui_markup =
|
||||||
"<menuitem action='RecentlyVisited'/>"
|
"<menuitem action='RecentlyVisited'/>"
|
||||||
"</menu>"
|
"</menu>"
|
||||||
"<menuitem action='Bookmarks'/>"
|
"<menuitem action='Bookmarks'/>"
|
||||||
"<menu action='Tools'>"
|
"<menuitem action='Tools'/>"
|
||||||
"<menuitem action='ManageSearchEngines'/>"
|
|
||||||
"<menuitem action='ClearPrivateData'/>"
|
|
||||||
/* Panel items shall be appended here */
|
|
||||||
#ifdef G_OS_WIN32
|
|
||||||
"<separator/>"
|
|
||||||
"<menuitem action='Preferences'/>"
|
|
||||||
#endif
|
|
||||||
"</menu>"
|
|
||||||
"<menuitem action='Window'/>"
|
"<menuitem action='Window'/>"
|
||||||
"<menu action='Help'>"
|
"<menu action='Help'>"
|
||||||
"<menuitem action='HelpContents'/>"
|
"<menuitem action='HelpContents'/>"
|
||||||
|
@ -4422,10 +4499,13 @@ static const gchar* ui_markup =
|
||||||
"<menuitem action='FindPrevious'/>"
|
"<menuitem action='FindPrevious'/>"
|
||||||
"<menuitem action='BookmarkAdd'/>"
|
"<menuitem action='BookmarkAdd'/>"
|
||||||
"<menuitem action='BookmarkFolderAdd'/>"
|
"<menuitem action='BookmarkFolderAdd'/>"
|
||||||
|
"<menuitem action='ManageSearchEngines'/>"
|
||||||
|
"<menuitem action='ClearPrivateData'/>"
|
||||||
"<menuitem action='TabPrevious'/>"
|
"<menuitem action='TabPrevious'/>"
|
||||||
"<menuitem action='TabNext'/>"
|
"<menuitem action='TabNext'/>"
|
||||||
"<menuitem action='UndoTabClose'/>"
|
"<menuitem action='UndoTabClose'/>"
|
||||||
"<menuitem action='TrashEmpty'/>"
|
"<menuitem action='TrashEmpty'/>"
|
||||||
|
"<menuitem action='Preferences'/>"
|
||||||
"</menu>"
|
"</menu>"
|
||||||
"</menubar>"
|
"</menubar>"
|
||||||
"<toolbar name='toolbar_navigation'>"
|
"<toolbar name='toolbar_navigation'>"
|
||||||
|
@ -4780,6 +4860,18 @@ midori_browser_init (MidoriBrowser* browser)
|
||||||
gtk_action_group_add_action_with_accel (browser->action_group, action, "");
|
gtk_action_group_add_action_with_accel (browser->action_group, action, "");
|
||||||
g_object_unref (action);
|
g_object_unref (action);
|
||||||
|
|
||||||
|
action = g_object_new (KATZE_TYPE_ARRAY_ACTION,
|
||||||
|
"name", "Tools",
|
||||||
|
"label", _("_Tools"),
|
||||||
|
"array", katze_array_new (KATZE_TYPE_ITEM),
|
||||||
|
NULL);
|
||||||
|
g_object_connect (action,
|
||||||
|
"signal::populate-popup",
|
||||||
|
_action_tools_populate_popup, browser,
|
||||||
|
NULL);
|
||||||
|
gtk_action_group_add_action (browser->action_group, action);
|
||||||
|
g_object_unref (action);
|
||||||
|
|
||||||
action = g_object_new (KATZE_TYPE_ARRAY_ACTION,
|
action = g_object_new (KATZE_TYPE_ARRAY_ACTION,
|
||||||
"name", "Window",
|
"name", "Window",
|
||||||
"label", _("_Window"),
|
"label", _("_Window"),
|
||||||
|
@ -4841,11 +4933,7 @@ midori_browser_init (MidoriBrowser* browser)
|
||||||
gtk_widget_set_sensitive (menuitem, FALSE);
|
gtk_widget_set_sensitive (menuitem, FALSE);
|
||||||
gtk_menu_item_set_right_justified (GTK_MENU_ITEM (menuitem), TRUE);
|
gtk_menu_item_set_right_justified (GTK_MENU_ITEM (menuitem), TRUE);
|
||||||
gtk_menu_shell_append (GTK_MENU_SHELL (browser->menubar), menuitem);
|
gtk_menu_shell_append (GTK_MENU_SHELL (browser->menubar), menuitem);
|
||||||
browser->menu_tools = gtk_menu_item_get_submenu (GTK_MENU_ITEM (
|
browser->menu_tools = gtk_menu_new ();
|
||||||
gtk_ui_manager_get_widget (ui_manager, "/menubar/Tools")));
|
|
||||||
menuitem = gtk_separator_menu_item_new ();
|
|
||||||
gtk_widget_show (menuitem);
|
|
||||||
gtk_menu_shell_insert (GTK_MENU_SHELL (browser->menu_tools), menuitem, 3);
|
|
||||||
|
|
||||||
homepage = gtk_ui_manager_get_widget (ui_manager, "/menubar/Go/Homepage");
|
homepage = gtk_ui_manager_get_widget (ui_manager, "/menubar/Go/Homepage");
|
||||||
g_signal_connect (homepage, "button-press-event",
|
g_signal_connect (homepage, "button-press-event",
|
||||||
|
|
|
@ -133,6 +133,15 @@ midori_panel_class_init (MidoriPanelClass* class)
|
||||||
GTK_SHADOW_NONE,
|
GTK_SHADOW_NONE,
|
||||||
flags));
|
flags));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* MidoriWebSettings:menu:
|
||||||
|
*
|
||||||
|
* This is the menu that holds the panel menu items.
|
||||||
|
*
|
||||||
|
* You shouldn't use this menu or add items.
|
||||||
|
*
|
||||||
|
* Deprecated: 0.1.9
|
||||||
|
*/
|
||||||
g_object_class_install_property (gobject_class,
|
g_object_class_install_property (gobject_class,
|
||||||
PROP_MENU,
|
PROP_MENU,
|
||||||
g_param_spec_object (
|
g_param_spec_object (
|
||||||
|
@ -404,7 +413,6 @@ midori_panel_set_property (GObject* object,
|
||||||
break;
|
break;
|
||||||
case PROP_MENU:
|
case PROP_MENU:
|
||||||
katze_object_assign (panel->menu, g_value_dup_object (value));
|
katze_object_assign (panel->menu, g_value_dup_object (value));
|
||||||
/* FIXME: Move existing items to the new menu */
|
|
||||||
break;
|
break;
|
||||||
case PROP_PAGE:
|
case PROP_PAGE:
|
||||||
midori_panel_set_current_page (panel, g_value_get_int (value));
|
midori_panel_set_current_page (panel, g_value_get_int (value));
|
||||||
|
@ -515,26 +523,46 @@ midori_panel_menu_item_activate_cb (GtkWidget* widget,
|
||||||
MidoriPanel* panel)
|
MidoriPanel* panel)
|
||||||
{
|
{
|
||||||
GtkWidget* child;
|
GtkWidget* child;
|
||||||
GtkToggleToolButton* toolitem;
|
GtkToolItem* toolitem;
|
||||||
guint n;
|
guint n;
|
||||||
|
|
||||||
child = g_object_get_data (G_OBJECT (widget), "page");
|
child = g_object_get_data (G_OBJECT (widget), "page");
|
||||||
toolitem = g_object_get_data (G_OBJECT (widget), "toolitem");
|
n = midori_panel_page_num (panel, child);
|
||||||
|
toolitem = gtk_toolbar_get_nth_item (GTK_TOOLBAR (panel->toolbar), n);
|
||||||
|
|
||||||
if (toolitem)
|
if (toolitem)
|
||||||
{
|
{
|
||||||
/* Unsetting the button before setting it ensures that
|
/* Unsetting the button before setting it ensures that
|
||||||
it will emit signals even if it was active before */
|
it will emit signals even if it was active before */
|
||||||
gtk_toggle_tool_button_set_active (toolitem, FALSE);
|
GtkToggleToolButton* button = GTK_TOGGLE_TOOL_BUTTON (toolitem);
|
||||||
gtk_toggle_tool_button_set_active (toolitem, TRUE);
|
g_signal_handlers_block_by_func (widget,
|
||||||
|
midori_panel_menu_item_activate_cb, panel);
|
||||||
|
gtk_toggle_tool_button_set_active (button, FALSE);
|
||||||
|
gtk_toggle_tool_button_set_active (button, TRUE);
|
||||||
|
g_signal_handlers_unblock_by_func (widget,
|
||||||
|
midori_panel_menu_item_activate_cb, panel);
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
n = midori_panel_page_num (panel, child);
|
|
||||||
midori_panel_set_current_page (panel, n);
|
midori_panel_set_current_page (panel, n);
|
||||||
g_signal_emit (panel, signals[SWITCH_PAGE], 0, n);
|
g_signal_emit (panel, signals[SWITCH_PAGE], 0, n);
|
||||||
gtk_widget_show (GTK_WIDGET (panel));
|
gtk_widget_show (GTK_WIDGET (panel));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Private function, used by MidoriBrowser */
|
||||||
|
/* static */ GtkWidget*
|
||||||
|
midori_panel_construct_menu_item (MidoriPanel* panel,
|
||||||
|
MidoriViewable* viewable)
|
||||||
|
{
|
||||||
|
const gchar* stock_id;
|
||||||
|
GtkWidget* menuitem;
|
||||||
|
|
||||||
|
stock_id = midori_viewable_get_stock_id (viewable);
|
||||||
|
menuitem = gtk_image_menu_item_new_from_stock (stock_id, NULL);
|
||||||
|
gtk_widget_show (menuitem);
|
||||||
|
g_object_set_data (G_OBJECT (menuitem), "page", viewable);
|
||||||
|
g_signal_connect (menuitem, "activate",
|
||||||
|
G_CALLBACK (midori_panel_menu_item_activate_cb), panel);
|
||||||
|
return menuitem;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -609,9 +637,6 @@ midori_panel_append_page (MidoriPanel* panel,
|
||||||
GtkWidget* widget;
|
GtkWidget* widget;
|
||||||
GtkWidget* toolbar;
|
GtkWidget* toolbar;
|
||||||
const gchar* label;
|
const gchar* label;
|
||||||
const gchar* stock_id;
|
|
||||||
GtkToolItem* toolitem;
|
|
||||||
GtkWidget* menuitem;
|
|
||||||
guint n;
|
guint n;
|
||||||
|
|
||||||
g_return_val_if_fail (MIDORI_IS_PANEL (panel), -1);
|
g_return_val_if_fail (MIDORI_IS_PANEL (panel), -1);
|
||||||
|
@ -648,26 +673,9 @@ midori_panel_append_page (MidoriPanel* panel,
|
||||||
|
|
||||||
n = midori_panel_page_num (panel, scrolled);
|
n = midori_panel_page_num (panel, scrolled);
|
||||||
label = midori_viewable_get_label (viewable);
|
label = midori_viewable_get_label (viewable);
|
||||||
stock_id = midori_viewable_get_stock_id (viewable);
|
|
||||||
|
|
||||||
toolitem = midori_panel_construct_tool_item (panel, viewable);
|
|
||||||
|
|
||||||
if (panel->menu)
|
|
||||||
{
|
|
||||||
menuitem = gtk_image_menu_item_new_from_stock (stock_id, NULL);
|
|
||||||
gtk_widget_show (menuitem);
|
|
||||||
g_object_set_data (G_OBJECT (menuitem), "page", viewable);
|
|
||||||
g_object_set_data (G_OBJECT (menuitem), "toolitem", toolitem);
|
|
||||||
g_signal_connect (menuitem, "activate",
|
|
||||||
G_CALLBACK (midori_panel_menu_item_activate_cb),
|
|
||||||
panel);
|
|
||||||
gtk_menu_shell_insert (GTK_MENU_SHELL (panel->menu), menuitem, 4);
|
|
||||||
g_object_set_data (G_OBJECT (scrolled), "panel-menuitem", menuitem);
|
|
||||||
g_signal_connect (viewable, "destroy",
|
|
||||||
G_CALLBACK (midori_panel_widget_destroy_cb), menuitem);
|
|
||||||
}
|
|
||||||
|
|
||||||
g_object_set_data (G_OBJECT (viewable), "parent", scrolled);
|
g_object_set_data (G_OBJECT (viewable), "parent", scrolled);
|
||||||
|
midori_panel_construct_tool_item (panel, viewable);
|
||||||
g_signal_connect (viewable, "destroy",
|
g_signal_connect (viewable, "destroy",
|
||||||
G_CALLBACK (midori_panel_viewable_destroy_cb), panel);
|
G_CALLBACK (midori_panel_viewable_destroy_cb), panel);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue