[evolution/express] re-enable middle-click to open in new window with new actions
- From: Michael Meeks <michael src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution/express] re-enable middle-click to open in new window with new actions
- Date: Thu, 4 Mar 2010 10:30:00 +0000 (UTC)
commit e83b2a9b6625b2962a4dcb907d0b6c75d2c67939
Author: Michael Meeks <michael meeks novell com>
Date: Thu Mar 4 10:26:31 2010 +0000
re-enable middle-click to open in new window with new actions
shell/e-shell-switcher.c | 56 +++++++++++++++++++++++++++++++++++-----
shell/e-shell-switcher.h | 3 +-
shell/e-shell-window-actions.c | 3 +-
3 files changed, 53 insertions(+), 9 deletions(-)
---
diff --git a/shell/e-shell-switcher.c b/shell/e-shell-switcher.c
index 226279e..7e82e55 100644
--- a/shell/e-shell-switcher.c
+++ b/shell/e-shell-switcher.c
@@ -551,31 +551,73 @@ e_shell_switcher_new (void)
return g_object_new (E_TYPE_SHELL_SWITCHER, NULL);
}
+/*
+ * gtk+ doesn't give us what we want - a middle click,
+ * option on toolbar items, so we have to get it by force.
+ */
+static GtkButton *
+tool_item_get_button (GtkWidget *widget)
+{
+ GtkWidget *child;
+
+ g_return_val_if_fail (GTK_IS_TOOL_ITEM (widget), NULL);
+
+ child = GTK_BIN (widget)->child;
+ if (child != NULL && GTK_IS_BUTTON (child))
+ return GTK_BUTTON (child);
+ else
+ return NULL;
+}
+
+static gboolean
+tool_item_button_cb (GtkWidget *internal_widget,
+ GdkEventButton *event,
+ GtkAction *action)
+{
+ g_return_val_if_fail (GTK_IS_ACTION (action), FALSE);
+
+ if (event->button == 2) {
+ gtk_action_activate (action);
+ return TRUE;
+ }
+ return FALSE;
+}
+
/**
* e_shell_switcher_add_action:
* @switcher: an #EShellSwitcher
- * @action: a #GtkAction
+ * @switch_action: a #GtkAction
+ * @new_window_action: a #GtkAction
*
- * Adds a button to @switcher that proxies for @action. Switcher buttons
- * appear in the order they were added.
+ * Adds a button to @switcher that proxies for @switcher_action.
+ * Switcher buttons appear in the order they were added. A middle
+ * click opens a new window of this type.
*
* #EShellWindow adds switcher actions in the order given by the
* <structfield>sort_order</structfield> field in #EShellBackendClass.
**/
void
e_shell_switcher_add_action (EShellSwitcher *switcher,
- GtkAction *action)
+ GtkAction *switch_action,
+ GtkAction *new_window_action)
{
GtkWidget *widget;
+ GtkButton *button;
g_return_if_fail (E_IS_SHELL_SWITCHER (switcher));
- g_return_if_fail (GTK_IS_ACTION (action));
+ g_return_if_fail (GTK_IS_ACTION (switch_action));
+ g_return_if_fail (GTK_IS_ACTION (new_window_action));
- g_object_ref (action);
- widget = gtk_action_create_tool_item (action);
+ g_object_ref (switch_action);
+ widget = gtk_action_create_tool_item (switch_action);
gtk_tool_item_set_is_important (GTK_TOOL_ITEM (widget), TRUE);
gtk_widget_show (widget);
+ if ((button = tool_item_get_button (widget)) != NULL)
+ g_signal_connect (button, "button-release-event",
+ G_CALLBACK (tool_item_button_cb),
+ new_window_action);
+
switcher->priv->proxies = g_list_append (
switcher->priv->proxies, widget);
diff --git a/shell/e-shell-switcher.h b/shell/e-shell-switcher.h
index 1cc6445..dd3eddf 100644
--- a/shell/e-shell-switcher.h
+++ b/shell/e-shell-switcher.h
@@ -78,7 +78,8 @@ struct _EShellSwitcherClass {
GType e_shell_switcher_get_type (void);
GtkWidget * e_shell_switcher_new (void);
void e_shell_switcher_add_action (EShellSwitcher *switcher,
- GtkAction *action);
+ GtkAction *switch_action,
+ GtkAction *new_window_action);
GtkToolbarStyle e_shell_switcher_get_style (EShellSwitcher *switcher);
void e_shell_switcher_set_style (EShellSwitcher *switcher,
GtkToolbarStyle style);
diff --git a/shell/e-shell-window-actions.c b/shell/e-shell-window-actions.c
index 7a091a1..c2c5aea 100644
--- a/shell/e-shell-window-actions.c
+++ b/shell/e-shell-window-actions.c
@@ -2216,7 +2216,6 @@ e_shell_window_create_switcher_actions (EShellWindow *shell_window)
gtk_action_group_add_action_with_accel (
s_action_group, GTK_ACTION (s_action), accelerator);
- e_shell_switcher_add_action (switcher, GTK_ACTION (s_action));
g_free (accelerator);
@@ -2237,6 +2236,8 @@ e_shell_window_create_switcher_actions (EShellWindow *shell_window)
shell_window);
gtk_action_group_add_action (n_action_group, n_action);
+ e_shell_switcher_add_action (switcher, GTK_ACTION (s_action), n_action);
+
g_free (n_action_name);
g_free (tooltip);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]