aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--shell/ChangeLog15
-rw-r--r--shell/e-shell-marshal.list1
-rw-r--r--shell/e-shell-window.c52
-rw-r--r--shell/e-sidebar.c45
-rw-r--r--shell/e-sidebar.h2
5 files changed, 101 insertions, 14 deletions
diff --git a/shell/ChangeLog b/shell/ChangeLog
index a24d62a802..256c6f7ceb 100644
--- a/shell/ChangeLog
+++ b/shell/ChangeLog
@@ -1,3 +1,18 @@
+2007-04-20 Srinivasa Ragavan <sragavan@novell.com>
+
+ ** Fix for bug #259606 from Michael Meeks
+
+ * e-shell-marshal.list:
+ * e-shell-window.c: (get_component_view),
+ (sidebar_button_selected_callback),
+ (sidebar_button_pressed_callback), (setup_widgets): Added support for
+ middle click to open the component in new window.
+ * e-shell.c:
+ * e-sidebar.c: (button_pressed_callback),
+ (boolean_handled_accumulator), (e_sidebar_class_init),
+ (e_sidebar_add_button):
+ * e-sidebar.h:
+
2007-04-19 Matthew Barnes <mbarnes@redhat.com>
** Fixes part of bug #429422
diff --git a/shell/e-shell-marshal.list b/shell/e-shell-marshal.list
index fd4274f310..f18d290c80 100644
--- a/shell/e-shell-marshal.list
+++ b/shell/e-shell-marshal.list
@@ -1,3 +1,4 @@
+BOOL:POINTER,INT
NONE:BOOL
NONE:BOOL,INT
NONE:INT
diff --git a/shell/e-shell-window.c b/shell/e-shell-window.c
index 541ddbcc26..a5475b078f 100644
--- a/shell/e-shell-window.c
+++ b/shell/e-shell-window.c
@@ -428,28 +428,50 @@ update_send_receive_sensitivity (EShellWindow *window)
/* Callbacks. */
+static ComponentView *
+get_component_view (EShellWindow *window, int id)
+{
+ GSList *p;
+
+ for (p = window->priv->component_views; p; p = p->next) {
+ if (((ComponentView *) p->data)->button_id == id)
+ return p->data;
+ }
+
+ g_warning ("Unknown component button id %d", id);
+ return NULL;
+}
+
static void
sidebar_button_selected_callback (ESidebar *sidebar,
int button_id,
EShellWindow *window)
{
- EShellWindowPrivate *priv = window->priv;
- ComponentView *component_view = NULL;
- GSList *p;
+ ComponentView *component_view;
- for (p = priv->component_views; p != NULL; p = p->next) {
- if (((ComponentView *) p->data)->button_id == button_id) {
- component_view = p->data;
- break;
- }
- }
+ if ((component_view = get_component_view (window, button_id)))
+ switch_view (window, component_view);
+}
- if (component_view == NULL) {
- g_warning ("Unknown component button id %d", button_id);
- return;
+static gboolean
+sidebar_button_pressed_callback (ESidebar *sidebar,
+ GdkEventButton *event,
+ int button_id,
+ EShellWindow *window)
+{
+ if (event->type == GDK_BUTTON_PRESS &&
+ event->button == 2) {
+ /* open it in a new window */
+ ComponentView *component_view;
+
+ if ((component_view = get_component_view (window, button_id))) {
+ e_shell_create_window (window->priv->shell,
+ component_view->component_id,
+ window);
+ }
+ return TRUE;
}
-
- switch_view (window, component_view);
+ return FALSE;
}
static void
@@ -668,6 +690,8 @@ setup_widgets (EShellWindow *window)
priv->sidebar = e_sidebar_new ();
g_signal_connect (priv->sidebar, "button_selected",
G_CALLBACK (sidebar_button_selected_callback), window);
+ g_signal_connect (priv->sidebar, "button_pressed",
+ G_CALLBACK (sidebar_button_pressed_callback), window);
gtk_paned_pack1 (GTK_PANED (priv->paned), priv->sidebar, FALSE, FALSE);
gtk_widget_show (priv->sidebar);
diff --git a/shell/e-sidebar.c b/shell/e-sidebar.c
index 32c25d748e..0dc8b7eb2c 100644
--- a/shell/e-sidebar.c
+++ b/shell/e-sidebar.c
@@ -63,6 +63,7 @@ struct _ESidebarPrivate {
enum {
BUTTON_SELECTED,
+ BUTTON_PRESSED,
NUM_SIGNALS
};
@@ -164,6 +165,25 @@ button_toggled_callback (GtkToggleButton *toggle_button,
g_signal_emit (sidebar, signals[BUTTON_SELECTED], 0, id);
}
+static gboolean
+button_pressed_callback (GtkToggleButton *toggle_button,
+ GdkEventButton *event,
+ ESidebar *sidebar)
+{
+ gboolean return_val = FALSE;
+ GSList *p;
+
+ for (p = sidebar->priv->buttons; p != NULL; p = p->next) {
+ Button *button = p->data;
+
+ if (button->button_widget == GTK_WIDGET (toggle_button))
+ g_signal_emit (sidebar, signals [BUTTON_PRESSED],
+ 0, event, button->id, &return_val);
+ }
+
+ return return_val;
+}
+
/* Layout. */
@@ -400,6 +420,20 @@ impl_dispose (GObject *object)
(* G_OBJECT_CLASS (e_sidebar_parent_class)->dispose) (object);
}
+static gboolean
+boolean_handled_accumulator (GSignalInvocationHint *ihint,
+ GValue *return_accu,
+ const GValue *handler_return,
+ gpointer dummy)
+{
+ gboolean handled;
+
+ handled = g_value_get_boolean (handler_return);
+ g_value_set_boolean (return_accu, handled);
+
+ return !handled;
+}
+
static void
impl_finalize (GObject *object)
{
@@ -438,6 +472,15 @@ e_sidebar_class_init (ESidebarClass *klass)
e_shell_marshal_NONE__INT,
G_TYPE_NONE, 1,
G_TYPE_INT);
+ signals[BUTTON_PRESSED]
+ = g_signal_new ("button_pressed",
+ G_OBJECT_CLASS_TYPE (object_class),
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (ESidebarClass, button_pressed),
+ boolean_handled_accumulator, NULL,
+ e_shell_marshal_NONE__POINTER_INT,
+ G_TYPE_BOOLEAN, 2,
+ G_TYPE_POINTER, G_TYPE_INT);
}
static void
@@ -494,6 +537,8 @@ e_sidebar_add_button (ESidebar *sidebar,
if (sidebar->priv->show)
gtk_widget_show (button_widget);
g_signal_connect (button_widget, "toggled", G_CALLBACK (button_toggled_callback), sidebar);
+ g_signal_connect (button_widget, "button_press_event",
+ G_CALLBACK (button_pressed_callback), sidebar);
hbox = gtk_hbox_new (FALSE, 3);
gtk_container_set_border_width (GTK_CONTAINER (hbox), 2);
diff --git a/shell/e-sidebar.h b/shell/e-sidebar.h
index c93300c53f..8bf6eeb51f 100644
--- a/shell/e-sidebar.h
+++ b/shell/e-sidebar.h
@@ -52,7 +52,9 @@ struct _ESidebar {
struct _ESidebarClass {
GtkContainerClass parent_class;
+ /* signals */
void (* button_selected) (ESidebar *sidebar, int id);
+ void (* button_pressed) (ESidebar *sidebar, GdkEventButton *event, int id);
};