Provide midori_browser_(un)block_action for extensions
So extensions can override individual actions without hacks.
This commit is contained in:
parent
7dec022471
commit
34da7c8090
3 changed files with 73 additions and 0 deletions
|
@ -7057,6 +7057,69 @@ midori_browser_set_action_visible (MidoriBrowser* browser,
|
||||||
_action_set_sensitive (browser, name, visible);
|
_action_set_sensitive (browser, name, visible);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* midori_browser_block_action:
|
||||||
|
* @browser: a #MidoriBrowser
|
||||||
|
* @name: the action to be blocked
|
||||||
|
*
|
||||||
|
* Blocks built-in behavior of the specified action without
|
||||||
|
* disabling it, which gives you a chance to connect your
|
||||||
|
* own signal handling.
|
||||||
|
* Call midori_browser_unblock_action() to undo the effect.
|
||||||
|
*
|
||||||
|
* Since: 0.3.4
|
||||||
|
**/
|
||||||
|
void
|
||||||
|
midori_browser_block_action (MidoriBrowser* browser,
|
||||||
|
GtkAction* action)
|
||||||
|
{
|
||||||
|
const gchar* name;
|
||||||
|
guint i;
|
||||||
|
|
||||||
|
g_return_if_fail (MIDORI_IS_BROWSER (browser));
|
||||||
|
g_return_if_fail (GTK_IS_ACTION (action));
|
||||||
|
|
||||||
|
name = gtk_action_get_name (action);
|
||||||
|
for (i = 0; i < entries_n; i++)
|
||||||
|
if (g_str_equal (entries[i].name, name))
|
||||||
|
{
|
||||||
|
g_signal_handlers_block_by_func (action, entries[i].callback, browser);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
g_critical ("%s: Action \"%s\" can't be blocked.", G_STRFUNC, name);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* midori_browser_unblock_action:
|
||||||
|
* @browser: a #MidoriBrowser
|
||||||
|
* @name: the action to be unblocked
|
||||||
|
*
|
||||||
|
* Restores built-in behavior of the specified action after
|
||||||
|
* previously blocking it with midori_browser_block_action().
|
||||||
|
*
|
||||||
|
* Since: 0.3.4
|
||||||
|
**/
|
||||||
|
void
|
||||||
|
midori_browser_unblock_action (MidoriBrowser* browser,
|
||||||
|
GtkAction* action)
|
||||||
|
{
|
||||||
|
const gchar* name;
|
||||||
|
guint i;
|
||||||
|
|
||||||
|
g_return_if_fail (MIDORI_IS_BROWSER (browser));
|
||||||
|
g_return_if_fail (GTK_IS_ACTION (action));
|
||||||
|
|
||||||
|
name = gtk_action_get_name (action);
|
||||||
|
for (i = 0; i < entries_n; i++)
|
||||||
|
if (g_str_equal (entries[i].name, name))
|
||||||
|
{
|
||||||
|
g_signal_handlers_unblock_by_func (action, entries[i].callback, browser);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
g_critical ("%s: Action \"%s\" can't be unblocked.", G_STRFUNC, name);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* midori_browser_get_action_group:
|
* midori_browser_get_action_group:
|
||||||
* @browser: a #MidoriBrowser
|
* @browser: a #MidoriBrowser
|
||||||
|
|
|
@ -106,6 +106,14 @@ void
|
||||||
midori_browser_activate_action (MidoriBrowser* browser,
|
midori_browser_activate_action (MidoriBrowser* browser,
|
||||||
const gchar* name);
|
const gchar* name);
|
||||||
|
|
||||||
|
void
|
||||||
|
midori_browser_block_action (MidoriBrowser* browser,
|
||||||
|
GtkAction* action);
|
||||||
|
|
||||||
|
void
|
||||||
|
midori_browser_unblock_action (MidoriBrowser* browser,
|
||||||
|
GtkAction* action);
|
||||||
|
|
||||||
void
|
void
|
||||||
midori_browser_set_action_visible (MidoriBrowser* browser,
|
midori_browser_set_action_visible (MidoriBrowser* browser,
|
||||||
const gchar* name,
|
const gchar* name,
|
||||||
|
|
|
@ -39,6 +39,8 @@ namespace Midori {
|
||||||
public int add_uri (string uri);
|
public int add_uri (string uri);
|
||||||
public unowned View get_nth_tab (int n);
|
public unowned View get_nth_tab (int n);
|
||||||
public GLib.List<weak View> get_tabs ();
|
public GLib.List<weak View> get_tabs ();
|
||||||
|
public void block_action (Gtk.Action action);
|
||||||
|
public void unblock_action (Gtk.Action action);
|
||||||
public unowned Gtk.ActionGroup get_action_group ();
|
public unowned Gtk.ActionGroup get_action_group ();
|
||||||
public unowned Browser get_for_widget (Gtk.Widget widget);
|
public unowned Browser get_for_widget (Gtk.Widget widget);
|
||||||
public unowned string[] get_toolbar_actions ();
|
public unowned string[] get_toolbar_actions ();
|
||||||
|
|
Loading…
Reference in a new issue