aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--widgets/misc/ChangeLog9
-rw-r--r--widgets/misc/e-source-selector.c32
-rw-r--r--widgets/misc/e-source-selector.h2
3 files changed, 42 insertions, 1 deletions
diff --git a/widgets/misc/ChangeLog b/widgets/misc/ChangeLog
index 839887d079..74e1a753cf 100644
--- a/widgets/misc/ChangeLog
+++ b/widgets/misc/ChangeLog
@@ -1,3 +1,12 @@
+2003-10-28 Rodrigo Moya <rodrigo@ximian.com>
+
+ * e-source-selector.[ch]: added "fill_popup_menu" signal, to
+ allow the addition of new items to the popup menu.
+ (class_init): create new signal.
+ (init): connect to "button_press_event" for the tree view.
+ (selector_button_press_event): callback for "button_press_event".
+ (e_source_selector_selection_shown): use g_return_val_if_fail.
+
2003-10-22 Dan Winship <danw@ximian.com>
* e-bonobo-widget.[ch]: Remove these (unused since 1.2)
diff --git a/widgets/misc/e-source-selector.c b/widgets/misc/e-source-selector.c
index 5bc12bcd39..f7814ad99b 100644
--- a/widgets/misc/e-source-selector.c
+++ b/widgets/misc/e-source-selector.c
@@ -55,6 +55,7 @@ struct _ESourceSelectorPrivate {
enum {
SELECTION_CHANGED,
PRIMARY_SELECTION_CHANGED,
+ FILL_POPUP_MENU,
NUM_SIGNALS
};
static unsigned int signals[NUM_SIGNALS] = { 0 };
@@ -315,6 +316,24 @@ selection_changed_callback (GtkTreeSelection *selection,
g_signal_emit (selector, signals[PRIMARY_SELECTION_CHANGED], 0);
}
+static gboolean
+selector_button_press_event (GtkWidget *widget, GdkEventButton *event, ESourceSelector *selector)
+{
+ GtkWidget *menu;
+
+ /* only process right-clicks */
+ if (event->button != 3)
+ return FALSE;
+
+ /* create the menu */
+ menu = gtk_menu_new ();
+ g_signal_emit (G_OBJECT (selector), signals[FILL_POPUP_MENU], 0, GTK_MENU (menu));
+
+ /* popup the menu */
+ gtk_menu_popup (GTK_MENU (menu), NULL, NULL, NULL, NULL, event->button, event->time);
+
+ return TRUE;
+}
/* GObject methods. */
@@ -386,6 +405,14 @@ class_init (ESourceSelectorClass *class)
NULL, NULL,
e_util_marshal_VOID__VOID,
G_TYPE_NONE, 0);
+ signals[FILL_POPUP_MENU] =
+ g_signal_new ("fill_popup_menu",
+ G_OBJECT_CLASS_TYPE (object_class),
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (ESourceSelectorClass, fill_popup_menu),
+ NULL, NULL,
+ g_cclosure_marshal_VOID__OBJECT,
+ G_TYPE_OBJECT, 0);
}
static void
@@ -399,6 +426,9 @@ init (ESourceSelector *selector)
priv = g_new0 (ESourceSelectorPrivate, 1);
selector->priv = priv;
+ g_signal_connect (G_OBJECT (selector), "button_press_event",
+ G_CALLBACK (selector_button_press_event), selector);
+
priv->checkboxes_shown = TRUE;
priv->selected_sources = create_selected_sources_hash ();
@@ -546,7 +576,7 @@ e_source_selector_show_selection (ESourceSelector *selector,
gboolean
e_source_selector_selection_shown (ESourceSelector *selector)
{
- g_return_if_fail (E_IS_SOURCE_SELECTOR (selector));
+ g_return_val_if_fail (E_IS_SOURCE_SELECTOR (selector), FALSE);
return selector->priv->checkboxes_shown;
}
diff --git a/widgets/misc/e-source-selector.h b/widgets/misc/e-source-selector.h
index 02b1356e08..3880d86ac5 100644
--- a/widgets/misc/e-source-selector.h
+++ b/widgets/misc/e-source-selector.h
@@ -26,6 +26,7 @@
#include "e-util/e-source-list.h"
+#include <gtk/gtkmenu.h>
#include <gtk/gtktreeview.h>
@@ -51,6 +52,7 @@ struct _ESourceSelectorClass {
void (* selection_changed) (ESourceSelector *selector);
void (* primary_selection_changed) (ESourceSelector *selector);
+ void (* fill_popup_menu) (ESourceSelector *selector, GtkMenu *menu);
};