Make KatzeArrayAction::activate-item-alt fully autonomous
Implementing the signal and returning TRUE makes it unneeded to implement activate-item as well now.
This commit is contained in:
parent
dd585da0b0
commit
b66902ef7a
2 changed files with 50 additions and 50 deletions
|
@ -133,6 +133,15 @@ katze_array_action_class_init (KatzeArrayActionClass* class)
|
||||||
G_TYPE_BOOLEAN, 2,
|
G_TYPE_BOOLEAN, 2,
|
||||||
GTK_TYPE_MENU_SHELL, KATZE_TYPE_ITEM);
|
GTK_TYPE_MENU_SHELL, KATZE_TYPE_ITEM);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* KatzeArrayAction::activate-item:
|
||||||
|
* @array: the object on which the signal is emitted
|
||||||
|
* @item: the item being activated
|
||||||
|
*
|
||||||
|
* An item was clicked with the first button.
|
||||||
|
*
|
||||||
|
* Deprecated: 0.2.8: Use "activate-item-alt" instead.
|
||||||
|
**/
|
||||||
signals[ACTIVATE_ITEM] = g_signal_new ("activate-item",
|
signals[ACTIVATE_ITEM] = g_signal_new ("activate-item",
|
||||||
G_TYPE_FROM_CLASS (class),
|
G_TYPE_FROM_CLASS (class),
|
||||||
(GSignalFlags) (G_SIGNAL_RUN_LAST),
|
(GSignalFlags) (G_SIGNAL_RUN_LAST),
|
||||||
|
@ -149,8 +158,7 @@ katze_array_action_class_init (KatzeArrayActionClass* class)
|
||||||
* @item: the item being activated
|
* @item: the item being activated
|
||||||
* @button: the mouse button pressed
|
* @button: the mouse button pressed
|
||||||
*
|
*
|
||||||
* An item was clicked with a particular button. Use this if you need
|
* An item was clicked, with the specified @button.
|
||||||
* to handle middle or right clicks specially.
|
|
||||||
*
|
*
|
||||||
* Return value: %TRUE if the event was handled. If %FALSE is returned,
|
* Return value: %TRUE if the event was handled. If %FALSE is returned,
|
||||||
* the default "activate-item" signal is emitted.
|
* the default "activate-item" signal is emitted.
|
||||||
|
@ -286,12 +294,24 @@ katze_array_action_activate (GtkAction* action)
|
||||||
GTK_ACTION_CLASS (katze_array_action_parent_class)->activate (action);
|
GTK_ACTION_CLASS (katze_array_action_parent_class)->activate (action);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
katze_array_action_activate_item (KatzeArrayAction* action,
|
||||||
|
KatzeItem* item,
|
||||||
|
gint button)
|
||||||
|
{
|
||||||
|
gboolean handled = FALSE;
|
||||||
|
g_signal_emit (action, signals[ACTIVATE_ITEM_ALT], 0, item,
|
||||||
|
button, &handled);
|
||||||
|
if (!handled)
|
||||||
|
g_signal_emit (action, signals[ACTIVATE_ITEM], 0, item);
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
katze_array_action_menu_activate_cb (GtkWidget* proxy,
|
katze_array_action_menu_activate_cb (GtkWidget* proxy,
|
||||||
KatzeArrayAction* array_action)
|
KatzeArrayAction* array_action)
|
||||||
{
|
{
|
||||||
KatzeItem* item = g_object_get_data (G_OBJECT (proxy), "KatzeItem");
|
KatzeItem* item = g_object_get_data (G_OBJECT (proxy), "KatzeItem");
|
||||||
g_signal_emit (array_action, signals[ACTIVATE_ITEM], 0, item);
|
katze_array_action_activate_item (array_action, item, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
|
@ -300,13 +320,8 @@ katze_array_action_menu_button_press_cb (GtkWidget* proxy,
|
||||||
KatzeArrayAction* array_action)
|
KatzeArrayAction* array_action)
|
||||||
{
|
{
|
||||||
KatzeItem* item = g_object_get_data (G_OBJECT (proxy), "KatzeItem");
|
KatzeItem* item = g_object_get_data (G_OBJECT (proxy), "KatzeItem");
|
||||||
gboolean handled;
|
|
||||||
|
|
||||||
g_signal_emit (array_action, signals[ACTIVATE_ITEM_ALT], 0, item,
|
katze_array_action_activate_item (array_action, item, event->button);
|
||||||
event->button, &handled);
|
|
||||||
|
|
||||||
if (!handled)
|
|
||||||
g_signal_emit (array_action, signals[ACTIVATE_ITEM], 0, item);
|
|
||||||
|
|
||||||
/* we need to block the 'activate' handler which would be called
|
/* we need to block the 'activate' handler which would be called
|
||||||
* otherwise as well */
|
* otherwise as well */
|
||||||
|
@ -458,7 +473,7 @@ katze_array_action_proxy_clicked_cb (GtkWidget* proxy,
|
||||||
array = (KatzeArray*)g_object_get_data (G_OBJECT (proxy), "KatzeArray");
|
array = (KatzeArray*)g_object_get_data (G_OBJECT (proxy), "KatzeArray");
|
||||||
if (KATZE_IS_ITEM (array) && katze_item_get_uri ((KatzeItem*)array))
|
if (KATZE_IS_ITEM (array) && katze_item_get_uri ((KatzeItem*)array))
|
||||||
{
|
{
|
||||||
g_signal_emit (array_action, signals[ACTIVATE_ITEM], 0, array);
|
katze_array_action_activate_item (array_action, KATZE_ITEM (array), 1);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2652,28 +2652,23 @@ midori_browser_menu_item_deselect_cb (GtkWidget* menuitem,
|
||||||
_midori_browser_set_statusbar_text (browser, NULL);
|
_midori_browser_set_statusbar_text (browser, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
|
||||||
midori_bookmarkbar_activate_item (GtkAction* action,
|
|
||||||
KatzeItem* item,
|
|
||||||
MidoriBrowser* browser)
|
|
||||||
{
|
|
||||||
midori_browser_open_bookmark (browser, item);
|
|
||||||
}
|
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
midori_bookmarkbar_activate_item_alt (GtkAction* action,
|
midori_bookmarkbar_activate_item_alt (GtkAction* action,
|
||||||
KatzeItem* item,
|
KatzeItem* item,
|
||||||
guint button,
|
guint button,
|
||||||
MidoriBrowser* browser)
|
MidoriBrowser* browser)
|
||||||
{
|
{
|
||||||
if (button == 2)
|
if (button == 1)
|
||||||
|
{
|
||||||
|
midori_browser_open_bookmark (browser, item);
|
||||||
|
}
|
||||||
|
else if (button == 2)
|
||||||
{
|
{
|
||||||
gint n = midori_browser_add_uri (browser, katze_item_get_uri (item));
|
gint n = midori_browser_add_uri (browser, katze_item_get_uri (item));
|
||||||
midori_browser_set_current_page_smartly (browser, n);
|
midori_browser_set_current_page_smartly (browser, n);
|
||||||
return TRUE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return FALSE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -2703,33 +2698,28 @@ _action_trash_populate_popup (GtkAction* action,
|
||||||
gtk_widget_show (menuitem);
|
gtk_widget_show (menuitem);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
|
||||||
_action_trash_activate_item (GtkAction* action,
|
|
||||||
KatzeItem* item,
|
|
||||||
MidoriBrowser* browser)
|
|
||||||
{
|
|
||||||
guint n = midori_browser_add_item (browser, item);
|
|
||||||
midori_browser_set_current_page (browser, n);
|
|
||||||
katze_array_remove_item (browser->trash, item);
|
|
||||||
_midori_browser_update_actions (browser);
|
|
||||||
}
|
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
_action_trash_activate_item_alt (GtkAction* action,
|
_action_trash_activate_item_alt (GtkAction* action,
|
||||||
KatzeItem* item,
|
KatzeItem* item,
|
||||||
guint button,
|
guint button,
|
||||||
MidoriBrowser* browser)
|
MidoriBrowser* browser)
|
||||||
{
|
{
|
||||||
if (button == 2)
|
if (button == 1)
|
||||||
{
|
{
|
||||||
gint n = midori_browser_add_uri (browser, katze_item_get_uri (item));
|
guint n = midori_browser_add_item (browser, item);
|
||||||
|
midori_browser_set_current_page (browser, n);
|
||||||
|
katze_array_remove_item (browser->trash, item);
|
||||||
|
_midori_browser_update_actions (browser);
|
||||||
|
}
|
||||||
|
else if (button == 2)
|
||||||
|
{
|
||||||
|
gint n = midori_browser_add_item (browser, item);
|
||||||
midori_browser_set_current_page_smartly (browser, n);
|
midori_browser_set_current_page_smartly (browser, n);
|
||||||
katze_array_remove_item (browser->trash, item);
|
katze_array_remove_item (browser->trash, item);
|
||||||
_midori_browser_update_actions (browser);
|
_midori_browser_update_actions (browser);
|
||||||
return TRUE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return FALSE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* static */ void
|
/* static */ void
|
||||||
|
@ -2899,16 +2889,17 @@ _action_window_populate_popup (GtkAction* action,
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
_action_window_activate_item (GtkAction* action,
|
_action_window_activate_item_alt (GtkAction* action,
|
||||||
KatzeItem* item,
|
KatzeItem* item,
|
||||||
|
gint button,
|
||||||
MidoriBrowser* browser)
|
MidoriBrowser* browser)
|
||||||
{
|
{
|
||||||
guint i, n;
|
guint i;
|
||||||
GtkWidget* view;
|
guint n = katze_array_get_length (browser->proxy_array);
|
||||||
|
|
||||||
n = katze_array_get_length (browser->proxy_array);
|
|
||||||
for (i = 0; i < n; i++)
|
for (i = 0; i < n; i++)
|
||||||
{
|
{
|
||||||
|
GtkWidget* view;
|
||||||
view = gtk_notebook_get_nth_page (GTK_NOTEBOOK (browser->notebook), i);
|
view = gtk_notebook_get_nth_page (GTK_NOTEBOOK (browser->notebook), i);
|
||||||
if (midori_view_get_proxy_item (MIDORI_VIEW (view)) == item)
|
if (midori_view_get_proxy_item (MIDORI_VIEW (view)) == item)
|
||||||
gtk_notebook_set_current_page (GTK_NOTEBOOK (browser->notebook), i);
|
gtk_notebook_set_current_page (GTK_NOTEBOOK (browser->notebook), i);
|
||||||
|
@ -5683,8 +5674,6 @@ midori_browser_init (MidoriBrowser* browser)
|
||||||
g_object_connect (action,
|
g_object_connect (action,
|
||||||
"signal::populate-popup",
|
"signal::populate-popup",
|
||||||
_action_trash_populate_popup, browser,
|
_action_trash_populate_popup, browser,
|
||||||
"signal::activate-item",
|
|
||||||
_action_trash_activate_item, browser,
|
|
||||||
"signal::activate-item-alt",
|
"signal::activate-item-alt",
|
||||||
_action_trash_activate_item_alt, browser,
|
_action_trash_activate_item_alt, browser,
|
||||||
NULL);
|
NULL);
|
||||||
|
@ -5701,8 +5690,6 @@ midori_browser_init (MidoriBrowser* browser)
|
||||||
g_object_connect (action,
|
g_object_connect (action,
|
||||||
"signal::populate-folder",
|
"signal::populate-folder",
|
||||||
_action_bookmarks_populate_folder, browser,
|
_action_bookmarks_populate_folder, browser,
|
||||||
"signal::activate-item",
|
|
||||||
midori_bookmarkbar_activate_item, browser,
|
|
||||||
"signal::activate-item-alt",
|
"signal::activate-item-alt",
|
||||||
midori_bookmarkbar_activate_item_alt, browser,
|
midori_bookmarkbar_activate_item_alt, browser,
|
||||||
NULL);
|
NULL);
|
||||||
|
@ -5718,8 +5705,6 @@ midori_browser_init (MidoriBrowser* browser)
|
||||||
g_object_connect (action,
|
g_object_connect (action,
|
||||||
"signal::populate-popup",
|
"signal::populate-popup",
|
||||||
_action_tools_populate_popup, browser,
|
_action_tools_populate_popup, browser,
|
||||||
"signal::activate-item",
|
|
||||||
midori_bookmarkbar_activate_item, browser,
|
|
||||||
"signal::activate-item-alt",
|
"signal::activate-item-alt",
|
||||||
midori_bookmarkbar_activate_item_alt, browser,
|
midori_bookmarkbar_activate_item_alt, browser,
|
||||||
NULL);
|
NULL);
|
||||||
|
@ -5736,8 +5721,8 @@ midori_browser_init (MidoriBrowser* browser)
|
||||||
g_object_connect (action,
|
g_object_connect (action,
|
||||||
"signal::populate-popup",
|
"signal::populate-popup",
|
||||||
_action_window_populate_popup, browser,
|
_action_window_populate_popup, browser,
|
||||||
"signal::activate-item",
|
"signal::activate-item-alt",
|
||||||
_action_window_activate_item, browser,
|
_action_window_activate_item_alt, browser,
|
||||||
NULL);
|
NULL);
|
||||||
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);
|
||||||
|
|
Loading…
Reference in a new issue