aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNot Zed <NotZed@Ximian.com>2004-10-07 09:42:50 +0800
committerMichael Zucci <zucchi@src.gnome.org>2004-10-07 09:42:50 +0800
commiteb114d32c827f54d0c752ee022f78fb35d5ee4ef (patch)
treee237e128549b5ad2cce8be3c481ab32ba886ddf4
parentbfaace723bb0199325f79ac52c32260df9e524fb (diff)
downloadgsoc2013-evolution-eb114d32c827f54d0c752ee022f78fb35d5ee4ef.tar
gsoc2013-evolution-eb114d32c827f54d0c752ee022f78fb35d5ee4ef.tar.gz
gsoc2013-evolution-eb114d32c827f54d0c752ee022f78fb35d5ee4ef.tar.bz2
gsoc2013-evolution-eb114d32c827f54d0c752ee022f78fb35d5ee4ef.tar.lz
gsoc2013-evolution-eb114d32c827f54d0c752ee022f78fb35d5ee4ef.tar.xz
gsoc2013-evolution-eb114d32c827f54d0c752ee022f78fb35d5ee4ef.tar.zst
gsoc2013-evolution-eb114d32c827f54d0c752ee022f78fb35d5ee4ef.zip
rename to view_popup_factory. Make it build an epopup item list directly.
2004-10-06 Not Zed <NotZed@Ximian.com> * gui/gnome-cal.c (gnome_calendar_setup_view_popup): rename to view_popup_factory. Make it build an epopup item list directly. Can't re-use the galview cruft :-/ (gnome_calendar_discard_view_popup): no longer needed. (gc_set_view, gc_save_custom_view, gc_define_views_response) (gc_define_views): implement the gal-view popup menu items. * gui/gnome-cal.h: * gui/e-week-view.h: * gui/e-day-view.h: * gui/e-cal-list-view.h: removed old e-popup-menu header. * gui/e-calendar-view.c (setup_popup_icons): removed. (e_calendar_view_create_popup_menu): converted to use e-popup. (on_paste, on_copy, on_cut, on_delete_occurrence) (on_unrecur_appointment, on_delete_appointment, on_publish) (on_forward, on_meeting, on_move_to, on_copy_to, on_print_event) (on_save_as, on_print, on_edit_appointment, on_goto_today) (on_goto_date, on_new_task, on_new_meeting, on_new_event) (on_new_appointment): convert to use e-popup stuff. * gui/tasks-component.c (popup_event_cb): e-popup api changes. * gui/e-cal-popup.c (e_cal_popup_target_new_select): implement the selection target. (ecalp_target_free): and free it. * gui/e-cal-model.h: Make the ECalModel struct non-anonymous so it can be forward-declared. * gui/calendar-component.c (popup_event_cb): e-popup api changes. svn path=/trunk/; revision=27489
-rw-r--r--calendar/ChangeLog34
-rw-r--r--calendar/gui/calendar-component.c11
-rw-r--r--calendar/gui/e-cal-list-view.c6
-rw-r--r--calendar/gui/e-cal-list-view.h1
-rw-r--r--calendar/gui/e-cal-model.h2
-rw-r--r--calendar/gui/e-cal-popup.c80
-rw-r--r--calendar/gui/e-cal-popup.h33
-rw-r--r--calendar/gui/e-calendar-view.c351
-rw-r--r--calendar/gui/e-day-view.c2
-rw-r--r--calendar/gui/e-day-view.h1
-rw-r--r--calendar/gui/e-week-view.c2
-rw-r--r--calendar/gui/e-week-view.h1
-rw-r--r--calendar/gui/gnome-cal.c125
-rw-r--r--calendar/gui/gnome-cal.h6
-rw-r--r--calendar/gui/tasks-component.c11
15 files changed, 372 insertions, 294 deletions
diff --git a/calendar/ChangeLog b/calendar/ChangeLog
index 8405c54a0c..9187fe5cf9 100644
--- a/calendar/ChangeLog
+++ b/calendar/ChangeLog
@@ -1,3 +1,37 @@
+2004-10-06 Not Zed <NotZed@Ximian.com>
+
+ * gui/gnome-cal.c (gnome_calendar_setup_view_popup): rename to
+ view_popup_factory. Make it build an epopup item list directly.
+ Can't re-use the galview cruft :-/
+ (gnome_calendar_discard_view_popup): no longer needed.
+ (gc_set_view, gc_save_custom_view, gc_define_views_response)
+ (gc_define_views): implement the gal-view popup menu items.
+
+ * gui/gnome-cal.h:
+ * gui/e-week-view.h:
+ * gui/e-day-view.h:
+ * gui/e-cal-list-view.h: removed old e-popup-menu header.
+
+ * gui/e-calendar-view.c (setup_popup_icons): removed.
+ (e_calendar_view_create_popup_menu): converted to use e-popup.
+ (on_paste, on_copy, on_cut, on_delete_occurrence)
+ (on_unrecur_appointment, on_delete_appointment, on_publish)
+ (on_forward, on_meeting, on_move_to, on_copy_to, on_print_event)
+ (on_save_as, on_print, on_edit_appointment, on_goto_today)
+ (on_goto_date, on_new_task, on_new_meeting, on_new_event)
+ (on_new_appointment): convert to use e-popup stuff.
+
+ * gui/tasks-component.c (popup_event_cb): e-popup api changes.
+
+ * gui/e-cal-popup.c (e_cal_popup_target_new_select): implement the
+ selection target.
+ (ecalp_target_free): and free it.
+
+ * gui/e-cal-model.h: Make the ECalModel struct non-anonymous so it
+ can be forward-declared.
+
+ * gui/calendar-component.c (popup_event_cb): e-popup api changes.
+
2004-10-06 Rodrigo Moya <rodrigo@novell.com>
Revert fix for #60551
diff --git a/calendar/gui/calendar-component.c b/calendar/gui/calendar-component.c
index 14f7aff23a..b1d63987bd 100644
--- a/calendar/gui/calendar-component.c
+++ b/calendar/gui/calendar-component.c
@@ -379,10 +379,10 @@ edit_calendar_cb (EPopup *ep, EPopupItem *pitem, void *data)
}
static EPopupItem ecc_source_popups[] = {
- { E_POPUP_ITEM, "10.new", N_("New Calendar"), new_calendar_cb, NULL, "stock_calendar", 0 },
- { E_POPUP_ITEM, "15.copy", N_("Copy"), copy_calendar_cb, NULL, "stock_folder-copy", E_CAL_POPUP_SOURCE_PRIMARY },
- { E_POPUP_ITEM, "20.delete", N_("Delete"), delete_calendar_cb, NULL, "stock_delete", E_CAL_POPUP_SOURCE_USER|E_CAL_POPUP_SOURCE_PRIMARY },
- { E_POPUP_ITEM, "30.properties", N_("Properties..."), edit_calendar_cb, NULL, NULL, E_CAL_POPUP_SOURCE_PRIMARY },
+ { E_POPUP_ITEM, "10.new", N_("New Calendar"), new_calendar_cb, NULL, "stock_calendar", 0, 0 },
+ { E_POPUP_ITEM, "15.copy", N_("Copy"), copy_calendar_cb, NULL, "stock_folder-copy", 0, E_CAL_POPUP_SOURCE_PRIMARY },
+ { E_POPUP_ITEM, "20.delete", N_("Delete"), delete_calendar_cb, NULL, "stock_delete", 0, E_CAL_POPUP_SOURCE_USER|E_CAL_POPUP_SOURCE_PRIMARY },
+ { E_POPUP_ITEM, "30.properties", N_("Properties..."), edit_calendar_cb, NULL, NULL, 0, E_CAL_POPUP_SOURCE_PRIMARY },
};
static void
@@ -409,8 +409,7 @@ popup_event_cb(ESourceSelector *selector, ESource *insource, GdkEventButton *eve
e_popup_add_items((EPopup *)ep, menus, ecc_source_popup_free, component_view);
- /* visibility is disabled, we only disable menu items */
- menu = e_popup_create_menu_once((EPopup *)ep, (EPopupTarget *)t, 0, t->target.mask);
+ menu = e_popup_create_menu_once((EPopup *)ep, (EPopupTarget *)t, 0);
gtk_menu_popup(menu, NULL, NULL, NULL, NULL, event?event->button:0, event?event->time:gtk_get_current_event_time());
return TRUE;
diff --git a/calendar/gui/e-cal-list-view.c b/calendar/gui/e-cal-list-view.c
index db194895fd..69f4c85aa9 100644
--- a/calendar/gui/e-cal-list-view.c
+++ b/calendar/gui/e-cal-list-view.c
@@ -367,10 +367,10 @@ e_cal_list_view_destroy (GtkObject *object)
static void
e_cal_list_view_show_popup_menu (ECalListView *cal_list_view, gint row, GdkEvent *gdk_event)
{
- GtkMenu *popup;
+ GtkMenu *menu;
- popup = e_calendar_view_create_popup_menu (E_CALENDAR_VIEW (cal_list_view));
- e_popup_menu (popup, gdk_event);
+ menu = e_calendar_view_create_popup_menu (E_CALENDAR_VIEW (cal_list_view));
+ gtk_menu_popup(menu, NULL, NULL, NULL, NULL, gdk_event?gdk_event->button.button:0, gdk_event?gdk_event->button.time:gtk_get_current_event_time());
}
static gboolean
diff --git a/calendar/gui/e-cal-list-view.h b/calendar/gui/e-cal-list-view.h
index 6b700c7b8a..eb7732625f 100644
--- a/calendar/gui/e-cal-list-view.h
+++ b/calendar/gui/e-cal-list-view.h
@@ -26,7 +26,6 @@
#include <time.h>
#include <gtk/gtktable.h>
#include <gtk/gtktooltips.h>
-#include <gal/widgets/e-popup-menu.h>
#include "e-calendar-view.h"
#include "gnome-cal.h"
diff --git a/calendar/gui/e-cal-model.h b/calendar/gui/e-cal-model.h
index 69feef8842..d5e2fc4960 100644
--- a/calendar/gui/e-cal-model.h
+++ b/calendar/gui/e-cal-model.h
@@ -76,7 +76,7 @@ typedef struct {
gpointer cb_data;
} ECalModelGenerateInstancesData;
-typedef struct {
+typedef struct _ECalModel {
ETableModel model;
ECalModelPrivate *priv;
} ECalModel;
diff --git a/calendar/gui/e-cal-popup.c b/calendar/gui/e-cal-popup.c
index d0a751fce1..55bd7bccbf 100644
--- a/calendar/gui/e-cal-popup.c
+++ b/calendar/gui/e-cal-popup.c
@@ -31,6 +31,10 @@
#include "e-cal-popup.h"
#include "widgets/misc/e-source-selector.h"
+#include "gui/e-calendar-view.h"
+#include "gui/e-cal-model.h"
+#include "itip-utils.h"
+
static GObjectClass *ecalp_parent;
static void
@@ -51,9 +55,12 @@ ecalp_target_free(EPopup *ep, EPopupTarget *t)
switch (t->type) {
case E_CAL_POPUP_TARGET_SELECT: {
ECalPopupTargetSelect *s = (ECalPopupTargetSelect *)t;
+ int i;
- /* FIXME: implement */
- s = s;
+ for (i=0;i<s->events->len;i++)
+ e_cal_model_free_component_data(s->events->pdata[i]);
+ g_ptr_array_free(s->events, TRUE);
+ g_object_unref(s->model);
break; }
case E_CAL_POPUP_TARGET_SOURCE: {
ECalPopupTargetSource *s = (ECalPopupTargetSource *)t;
@@ -110,12 +117,69 @@ ECalPopup *e_cal_popup_new(const char *menuid)
* Return value:
**/
ECalPopupTargetSelect *
-e_cal_popup_target_new_select(ECalPopup *eabp)
+e_cal_popup_target_new_select(ECalPopup *eabp, ECalendarView *view)
{
ECalPopupTargetSelect *t = e_popup_target_new(&eabp->popup, E_CAL_POPUP_TARGET_SELECT, sizeof(*t));
guint32 mask = ~0;
+ GList *events, *l;
+ ECal *client;
+ gboolean read_only;
+
+ t->model = e_calendar_view_get_model(view);
+ g_object_ref(t->model);
+ t->events = g_ptr_array_new();
+ l = events = e_calendar_view_get_selected_events(view);
+ for (l=events;l;l=g_list_next(l)) {
+ ECalendarViewEvent *event = l->data;
+
+ if (event)
+ g_ptr_array_add(t->events, e_cal_model_copy_component_data(event->comp_data));
+ }
+
+ /* In reality this is only ever called with a single event or none */
+
+ if (t->events->len == 0) {
+ client = e_cal_model_get_default_client(t->model);
+ } else {
+ ECalendarViewEvent *event = (ECalendarViewEvent *)events->data;
+
+ mask &= ~E_CAL_POPUP_SELECT_MANY;
+ if (events->next == NULL)
+ mask &= ~E_CAL_POPUP_SELECT_ONE;
+
+ if (e_cal_util_component_has_recurrences (event->comp_data->icalcomp))
+ mask &= ~E_CAL_POPUP_SELECT_RECURRING;
+ else
+ mask &= ~E_CAL_POPUP_SELECT_NONRECURRING;
+
+ if (e_cal_util_component_is_instance (event->comp_data->icalcomp))
+ mask &= ~E_CAL_POPUP_SELECT_INSTANCE;
+
+ if (e_cal_util_component_has_organizer (event->comp_data->icalcomp)) {
+ ECalComponent *comp;
+
+ comp = e_cal_component_new ();
+ e_cal_component_set_icalcomponent (comp, icalcomponent_new_clone (event->comp_data->icalcomp));
+ if (!itip_organizer_is_user (comp, event->comp_data->client))
+ mask &= ~E_CAL_POPUP_SELECT_ORGANIZER;
+
+ g_object_unref (comp);
+ } else {
+ /* organiser is synonym for owner in this case */
+ mask &= ~(E_CAL_POPUP_SELECT_ORGANIZER|E_CAL_POPUP_SELECT_NOTMEETING);
+ }
+
+ client = event->comp_data->client;
+ }
+
+ g_list_free(events);
+
+ e_cal_is_read_only(client, &read_only, NULL);
+ if (!read_only)
+ mask &= ~E_CAL_POPUP_SELECT_EDITABLE;
- /* FIXME: impelement */
+ /* This bit isn't implemented ... */
+ mask &= ~E_CAL_POPUP_SELECT_NOTEDITING;
t->target.mask = mask;
@@ -185,12 +249,20 @@ static void *ecalph_parent_class;
static const EPopupHookTargetMask ecalph_select_masks[] = {
{ "one", E_CAL_POPUP_SELECT_ONE },
{ "many", E_CAL_POPUP_SELECT_MANY },
+ { "editable", E_CAL_POPUP_SELECT_EDITABLE },
+ { "recurring", E_CAL_POPUP_SELECT_RECURRING },
+ { "non-recurring", E_CAL_POPUP_SELECT_NONRECURRING },
+ { "instance", E_CAL_POPUP_SELECT_INSTANCE },
+ { "organizer", E_CAL_POPUP_SELECT_ORGANIZER },
+ { "not-editing", E_CAL_POPUP_SELECT_NOTEDITING },
+ { "not-meeting", E_CAL_POPUP_SELECT_NOTMEETING },
{ 0 }
};
static const EPopupHookTargetMask ecalph_source_masks[] = {
{ "primary", E_CAL_POPUP_SOURCE_PRIMARY },
{ "system", E_CAL_POPUP_SOURCE_SYSTEM },
+ { "user", E_CAL_POPUP_SOURCE_USER },
{ 0 }
};
diff --git a/calendar/gui/e-cal-popup.h b/calendar/gui/e-cal-popup.h
index 81d2d51976..1e6c84d1b9 100644
--- a/calendar/gui/e-cal-popup.h
+++ b/calendar/gui/e-cal-popup.h
@@ -34,6 +34,8 @@ extern "C" {
typedef struct _ECalPopup ECalPopup;
typedef struct _ECalPopupClass ECalPopupClass;
+struct _ECalendarView;
+
/**
* enum _e_cal_popup_target_t - A list of mail popup target types.
*
@@ -52,11 +54,26 @@ enum _e_cal_popup_target_t {
*
* @E_CAL_POPUP_SELECT_ONE: Only one item is selected.
* @E_CAL_POPUP_SELECT_MANY: One ore more items are selected.
+ * @E_CAL_POPUP_SELECT_EDITABLE: The selection is editable.
+ * @E_CAL_POPUP_SELECT_RECURRING: Is a recurring event.
+ * @E_CAL_POPUP_SELECT_NONRECURRING: Is not a recurring event.
+ * @E_CAL_POPUP_SELECT_INSTANCE: This is an instance event.
+ * @E_CAL_POPUP_SELECT_ORGANIZER: The user is the organiser of the event.
+ * @E_CAL_POPUP_SELECT_NOTEDITING: The event is not being edited already. Not implemented.
+ * @E_CAL_POPUP_SELECT_NOTMEETING: The event is not a meeting.
*
**/
enum _e_cal_popup_target_select_t {
- E_CAL_POPUP_SELECT_ONE = 1<<1,
- E_CAL_POPUP_SELECT_MANY = 1<<2,
+ E_CAL_POPUP_SELECT_ONE = 1<<0,
+ E_CAL_POPUP_SELECT_MANY = 1<<1,
+ E_CAL_POPUP_SELECT_EDITABLE = 1<<2,
+ E_CAL_POPUP_SELECT_RECURRING = 1<<3,
+ E_CAL_POPUP_SELECT_NONRECURRING = 1<<4,
+ E_CAL_POPUP_SELECT_INSTANCE = 1<<5,
+
+ E_CAL_POPUP_SELECT_ORGANIZER = 1<<6,
+ E_CAL_POPUP_SELECT_NOTEDITING = 1<<7,
+ E_CAL_POPUP_SELECT_NOTMEETING = 1<<8,
};
/**
@@ -78,15 +95,21 @@ typedef struct _ECalPopupTargetSource ECalPopupTargetSource;
/**
* struct _ECalPopupTargetSelect - A list of address cards.
*
- * @target: Superclass.
+ * @target: Superclass. target.widget is an ECalendarView.
+ * @model: The ECalModel.
+ * @events: The selected events. These are ECalModelComponent's.
*
* Used to represent a selection of appointments as context for a popup
* menu.
*
- * FIXME: impelemnt me
+ * TODO: For maximum re-usability references to the view could be removed
+ * from this structure.
**/
struct _ECalPopupTargetSelect {
EPopupTarget target;
+
+ struct _ECalModel *model;
+ GPtrArray *events;
};
/**
@@ -120,7 +143,7 @@ GType e_cal_popup_get_type(void);
ECalPopup *e_cal_popup_new(const char *menuid);
-ECalPopupTargetSelect *e_cal_popup_target_new_select(ECalPopup *eabp);
+ECalPopupTargetSelect *e_cal_popup_target_new_select(ECalPopup *eabp, struct _ECalendarView *view);
ECalPopupTargetSource *e_cal_popup_target_new_source(ECalPopup *eabp, struct _ESourceSelector *selector);
/* ********************************************************************** */
diff --git a/calendar/gui/e-calendar-view.c b/calendar/gui/e-calendar-view.c
index c22a4125d4..e9cb63b8ab 100644
--- a/calendar/gui/e-calendar-view.c
+++ b/calendar/gui/e-calendar-view.c
@@ -56,6 +56,7 @@
#include "print.h"
#include "goto.h"
#include "ea-calendar.h"
+#include "e-cal-popup.h"
/* Used for the status bar messages */
#define EVOLUTION_CALENDAR_PROGRESS_IMAGE "stock_calendar"
@@ -72,9 +73,6 @@ struct _ECalendarViewPrivate {
EActivityHandler *activity_handler;
guint activity_id;
- /* The popup menu */
- EPopupMenu *view_menu;
-
/* The default category */
char *default_category;
};
@@ -942,57 +940,58 @@ e_calendar_view_delete_selected_occurrence (ECalendarView *cal_view)
}
static void
-on_new_appointment (GtkWidget *widget, gpointer user_data)
+on_new_appointment (EPopup *ep, EPopupItem *pitem, void *data)
{
- ECalendarView *cal_view = (ECalendarView *) user_data;
+ ECalendarView *cal_view = data;
e_calendar_view_new_appointment (cal_view);
}
static void
-on_new_event (GtkWidget *widget, gpointer user_data)
+on_new_event (EPopup *ep, EPopupItem *pitem, void *data)
{
- ECalendarView *cal_view = (ECalendarView *) user_data;
+ ECalendarView *cal_view = data;
e_calendar_view_new_appointment_full (cal_view, TRUE, FALSE);
}
static void
-on_new_meeting (GtkWidget *widget, gpointer user_data)
+on_new_meeting (EPopup *ep, EPopupItem *pitem, void *data)
{
- ECalendarView *cal_view = (ECalendarView *) user_data;
+ ECalendarView *cal_view = data;
e_calendar_view_new_appointment_full (cal_view, FALSE, TRUE);
}
static void
-on_new_task (GtkWidget *widget, gpointer user_data)
+on_new_task (EPopup *ep, EPopupItem *pitem, void *data)
{
- ECalendarView *cal_view = (ECalendarView *) user_data;
+ ECalendarView *cal_view = data;
+
gnome_calendar_new_task (cal_view->priv->calendar);
}
static void
-on_goto_date (GtkWidget *widget, gpointer user_data)
+on_goto_date (EPopup *ep, EPopupItem *pitem, void *data)
{
- ECalendarView *cal_view = E_CALENDAR_VIEW (user_data);
+ ECalendarView *cal_view = data;
goto_dialog (cal_view->priv->calendar);
}
static void
-on_goto_today (GtkWidget *widget, gpointer user_data)
+on_goto_today (EPopup *ep, EPopupItem *pitem, void *data)
{
- ECalendarView *cal_view = E_CALENDAR_VIEW (user_data);
+ ECalendarView *cal_view = data;
calendar_goto_today (cal_view->priv->calendar);
}
static void
-on_edit_appointment (GtkWidget *widget, gpointer user_data)
+on_edit_appointment (EPopup *ep, EPopupItem *pitem, void *data)
{
+ ECalendarView *cal_view = data;
GList *selected;
- ECalendarView *cal_view = E_CALENDAR_VIEW (user_data);
selected = e_calendar_view_get_selected_events (cal_view);
if (selected) {
@@ -1007,15 +1006,13 @@ on_edit_appointment (GtkWidget *widget, gpointer user_data)
}
static void
-on_print (GtkWidget *widget, gpointer user_data)
+on_print (EPopup *ep, EPopupItem *pitem, void *data)
{
- ECalendarView *cal_view;
+ ECalendarView *cal_view = data;
time_t start, end;
GnomeCalendarViewType view_type;
PrintView print_view;
- cal_view = E_CALENDAR_VIEW (user_data);
-
e_calendar_view_get_visible_time_range (cal_view, &start, &end);
view_type = gnome_calendar_get_view (cal_view->priv->calendar);
@@ -1042,17 +1039,15 @@ on_print (GtkWidget *widget, gpointer user_data)
}
static void
-on_save_as (GtkWidget *widget, gpointer user_data)
+on_save_as (EPopup *ep, EPopupItem *pitem, void *data)
{
- ECalendarView *cal_view;
+ ECalendarView *cal_view = data;
GList *selected;
char *filename;
char *ical_string;
FILE *file;
ECalendarViewEvent *event;
- cal_view = E_CALENDAR_VIEW (user_data);
-
selected = e_calendar_view_get_selected_events (cal_view);
if (!selected)
return;
@@ -1082,14 +1077,13 @@ on_save_as (GtkWidget *widget, gpointer user_data)
}
static void
-on_print_event (GtkWidget *widget, gpointer user_data)
+on_print_event (EPopup *ep, EPopupItem *pitem, void *data)
{
- ECalendarView *cal_view;
+ ECalendarView *cal_view = data;
GList *selected;
ECalendarViewEvent *event;
ECalComponent *comp;
- cal_view = E_CALENDAR_VIEW (user_data);
selected = e_calendar_view_get_selected_events (cal_view);
if (!selected)
return;
@@ -1189,26 +1183,26 @@ transfer_selected_items (ECalendarView *cal_view, gboolean remove_item)
}
static void
-on_copy_to (GtkWidget *widget, gpointer user_data)
+on_copy_to (EPopup *ep, EPopupItem *pitem, void *data)
{
- ECalendarView *cal_view = E_CALENDAR_VIEW (user_data);
+ ECalendarView *cal_view = data;
transfer_selected_items (cal_view, FALSE);
}
static void
-on_move_to (GtkWidget *widget, gpointer user_data)
+on_move_to (EPopup *ep, EPopupItem *pitem, void *data)
{
- ECalendarView *cal_view = E_CALENDAR_VIEW (user_data);
+ ECalendarView *cal_view = data;
transfer_selected_items (cal_view, TRUE);
}
static void
-on_meeting (GtkWidget *widget, gpointer user_data)
+on_meeting (EPopup *ep, EPopupItem *pitem, void *data)
{
+ ECalendarView *cal_view = data;
GList *selected;
- ECalendarView *cal_view = E_CALENDAR_VIEW (user_data);
selected = e_calendar_view_get_selected_events (cal_view);
if (selected) {
@@ -1220,10 +1214,10 @@ on_meeting (GtkWidget *widget, gpointer user_data)
}
static void
-on_forward (GtkWidget *widget, gpointer user_data)
+on_forward (EPopup *ep, EPopupItem *pitem, void *data)
{
+ ECalendarView *cal_view = data;
GList *selected;
- ECalendarView *cal_view = E_CALENDAR_VIEW (user_data);
selected = e_calendar_view_get_selected_events (cal_view);
if (selected) {
@@ -1240,24 +1234,23 @@ on_forward (GtkWidget *widget, gpointer user_data)
}
static void
-on_publish (GtkWidget *widget, gpointer user_data)
+on_publish (EPopup *ep, EPopupItem *pitem, void *data)
{
e_pub_publish (TRUE);
}
static void
-on_delete_appointment (GtkWidget *widget, gpointer user_data)
+on_delete_appointment (EPopup *ep, EPopupItem *pitem, void *data)
{
- ECalendarView *cal_view;
+ ECalendarView *cal_view = data;
- cal_view = E_CALENDAR_VIEW (user_data);
e_calendar_view_delete_selected_event (cal_view);
}
static void
-on_unrecur_appointment (GtkWidget *widget, gpointer user_data)
+on_unrecur_appointment (EPopup *ep, EPopupItem *pitem, void *data)
{
- ECalendarView *cal_view;
+ ECalendarView *cal_view = data;
ECalendarViewEvent *event;
ECalComponent *comp, *new_comp;
ECalComponentDateTime date;
@@ -1265,8 +1258,6 @@ on_unrecur_appointment (GtkWidget *widget, gpointer user_data)
GList *selected;
char *new_uid;
- cal_view = E_CALENDAR_VIEW (user_data);
-
selected = e_calendar_view_get_selected_events (cal_view);
if (!selected)
return;
@@ -1326,266 +1317,126 @@ on_unrecur_appointment (GtkWidget *widget, gpointer user_data)
}
static void
-on_delete_occurrence (GtkWidget *widget, gpointer user_data)
+on_delete_occurrence (EPopup *ep, EPopupItem *pitem, void *data)
{
- ECalendarView *cal_view;
+ ECalendarView *cal_view = data;
- cal_view = E_CALENDAR_VIEW (user_data);
e_calendar_view_delete_selected_occurrence (cal_view);
}
static void
-on_cut (GtkWidget *widget, gpointer user_data)
+on_cut (EPopup *ep, EPopupItem *pitem, void *data)
{
- ECalendarView *cal_view = E_CALENDAR_VIEW (user_data);
+ ECalendarView *cal_view = data;
e_calendar_view_cut_clipboard (cal_view);
}
static void
-on_copy (GtkWidget *widget, gpointer user_data)
+on_copy (EPopup *ep, EPopupItem *pitem, void *data)
{
- ECalendarView *cal_view = E_CALENDAR_VIEW (user_data);
+ ECalendarView *cal_view = data;
e_calendar_view_copy_clipboard (cal_view);
}
static void
-on_paste (GtkWidget *widget, gpointer user_data)
+on_paste (EPopup *ep, EPopupItem *pitem, void *data)
{
- ECalendarView *cal_view = E_CALENDAR_VIEW (user_data);
+ ECalendarView *cal_view = data;
e_calendar_view_paste_clipboard (cal_view);
}
-enum {
- /*
- * This is used to "flag" events that can not be editted
- */
- MASK_EDITABLE = 1,
+static EPopupItem ecv_main_items [] = {
+ { E_POPUP_ITEM, "00.new", N_("New _Appointment..."), on_new_appointment, NULL, "stock_new-appointment", 0, 0 },
+ { E_POPUP_ITEM, "10.newallday", N_("New All Day _Event"), on_new_event, NULL, "stock_new-24h-appointment", 0, 0},
+ { E_POPUP_ITEM, "20.meeting", N_("New Meeting"), on_new_meeting, NULL, "stock_new-meeting", 0, 0},
+ { E_POPUP_ITEM, "30.task", N_("New Task"), on_new_task, NULL, "stock_task", 0, 0},
- /*
- * To disable recurring actions to be displayed
- */
- MASK_RECURRING = 2,
+ { E_POPUP_BAR, "40."},
+ { E_POPUP_ITEM, "40.print", N_("_Print..."), on_print, NULL, GTK_STOCK_PRINT, 0, 0 },
- /*
- * To disable actions for non-recurring items to be displayed
- */
- MASK_SINGLE = 4,
+ { E_POPUP_BAR, "50." },
+ { E_POPUP_ITEM, "50.paste", N_("_Paste"), on_paste, NULL, GTK_STOCK_PASTE, 0, E_CAL_POPUP_SELECT_EDITABLE },
- /*
- * This is used to when an event is currently being edited
- * in another window and we want to disable the event
- * from being edited twice
- */
- MASK_EDITING = 8,
-
- /*
- * This is used to when an event is already a meeting and
- * we want to disable the schedule meeting command
- */
- MASK_MEETING = 16,
-
- /*
- * To disable cut and copy for meetings the user is not the
- * organizer of
- */
- MASK_MEETING_ORGANIZER = 32,
-
- /*
- * To disable things not valid for instances
- */
- MASK_INSTANCE = 64
-};
-
-static EPopupMenu main_items [] = {
- E_POPUP_ITEM (N_("New _Appointment..."), GTK_SIGNAL_FUNC (on_new_appointment), 0),
- E_POPUP_ITEM (N_("New All Day _Event"), GTK_SIGNAL_FUNC (on_new_event), 0),
- E_POPUP_ITEM (N_("New Meeting"), GTK_SIGNAL_FUNC (on_new_meeting), 0),
- E_POPUP_ITEM (N_("New Task"), GTK_SIGNAL_FUNC (on_new_task), 0),
-
- E_POPUP_SEPARATOR,
-
- E_POPUP_ITEM (N_("_Print..."), GTK_SIGNAL_FUNC (on_print), 0),
-
- E_POPUP_SEPARATOR,
-
- E_POPUP_ITEM (N_("_Paste"), GTK_SIGNAL_FUNC (on_paste), MASK_EDITABLE),
-
- E_POPUP_SEPARATOR,
-
- E_POPUP_SUBMENU (N_("Current View"), NULL, 0),
+ { E_POPUP_BAR, "60." },
+ /* FIXME: hook in this somehow */
+ { E_POPUP_SUBMENU, "60.view", N_("Current View") },
- E_POPUP_ITEM (N_("Select _Today"), GTK_SIGNAL_FUNC (on_goto_today), 0),
- E_POPUP_ITEM (N_("_Select Date..."), GTK_SIGNAL_FUNC (on_goto_date), 0),
-
- E_POPUP_SEPARATOR,
+ { E_POPUP_ITEM, "61.today", N_("Select _Today"), on_goto_today, NULL, GTK_STOCK_HOME },
+ { E_POPUP_ITEM, "62.todate", N_("_Select Date..."), on_goto_date, NULL, GTK_STOCK_JUMP_TO },
- E_POPUP_ITEM (N_("_Publish Free/Busy Information"), GTK_SIGNAL_FUNC (on_publish), 0),
+ { E_POPUP_BAR, "70." },
- E_POPUP_TERMINATOR
+ /* TODO: Why is this in a context menu when it applies globally? */
+ { E_POPUP_ITEM, "70.publish", N_("_Publish Free/Busy Information"), on_publish, },
};
-static EPopupMenu child_items [] = {
- E_POPUP_ITEM (N_("_Open"), GTK_SIGNAL_FUNC (on_edit_appointment), MASK_EDITING),
- E_POPUP_ITEM (N_("_Save As..."), GTK_SIGNAL_FUNC (on_save_as), MASK_EDITING),
- E_POPUP_ITEM (N_("_Print..."), GTK_SIGNAL_FUNC (on_print_event), MASK_EDITING),
+static EPopupItem ecv_child_items [] = {
+ { E_POPUP_ITEM, "00.open", N_("_Open"), on_edit_appointment, NULL, GTK_STOCK_OPEN, 0, E_CAL_POPUP_SELECT_NOTEDITING },
+ { E_POPUP_ITEM, "10.saveas", N_("_Save As..."), on_save_as, NULL, GTK_STOCK_SAVE_AS, 0, E_CAL_POPUP_SELECT_NOTEDITING },
+ { E_POPUP_ITEM, "20.print", N_("_Print..."), on_print_event, NULL, GTK_STOCK_PRINT, 0, E_CAL_POPUP_SELECT_NOTEDITING },
- /* Only show this separator if one of the above is shown. */
- E_POPUP_SEPARATOR,
+ { E_POPUP_BAR, "30." },
- E_POPUP_ITEM (N_("C_ut"), GTK_SIGNAL_FUNC (on_cut), MASK_EDITING | MASK_EDITABLE | MASK_MEETING_ORGANIZER),
- E_POPUP_ITEM (N_("_Copy"), GTK_SIGNAL_FUNC (on_copy), MASK_EDITING | MASK_MEETING_ORGANIZER),
- E_POPUP_ITEM (N_("_Paste"), GTK_SIGNAL_FUNC (on_paste), MASK_EDITABLE),
+ { E_POPUP_ITEM, "31.cut", N_("C_ut"), on_cut, NULL, GTK_STOCK_CUT, 0, E_CAL_POPUP_SELECT_NOTEDITING|E_CAL_POPUP_SELECT_EDITABLE|E_CAL_POPUP_SELECT_ORGANIZER },
+ { E_POPUP_ITEM, "32.copy", N_("_Copy"), on_copy, NULL, GTK_STOCK_COPY, 0, E_CAL_POPUP_SELECT_NOTEDITING|E_CAL_POPUP_SELECT_ORGANIZER },
+ { E_POPUP_ITEM, "33.paste", N_("_Paste"), on_paste, NULL, GTK_STOCK_PASTE, 0, E_CAL_POPUP_SELECT_EDITABLE },
- E_POPUP_SEPARATOR,
+ { E_POPUP_BAR, "40." },
- E_POPUP_ITEM (N_("Cop_y to Calendar..."), GTK_SIGNAL_FUNC (on_copy_to), MASK_EDITING),
- E_POPUP_ITEM (N_("Mo_ve to Calendar..."), GTK_SIGNAL_FUNC (on_move_to), MASK_EDITING | MASK_EDITABLE),
- E_POPUP_ITEM (N_("_Schedule Meeting..."), GTK_SIGNAL_FUNC (on_meeting), MASK_EDITABLE | MASK_EDITING | MASK_MEETING),
- E_POPUP_ITEM (N_("_Forward as iCalendar..."), GTK_SIGNAL_FUNC (on_forward), MASK_EDITING),
+ { E_POPUP_ITEM, "41.copyto", N_("Cop_y to Calendar..."), on_copy_to, NULL, NULL, 0, E_CAL_POPUP_SELECT_NOTEDITING },
+ { E_POPUP_ITEM, "42.moveto", N_("Mo_ve to Calendar..."), on_move_to, NULL, NULL, 0, E_CAL_POPUP_SELECT_NOTEDITING | E_CAL_POPUP_SELECT_EDITABLE },
+ { E_POPUP_ITEM, "43.schedule", N_("_Schedule Meeting..."), on_meeting, NULL, NULL, 0, E_CAL_POPUP_SELECT_NOTEDITING | E_CAL_POPUP_SELECT_EDITABLE | E_CAL_POPUP_SELECT_NOTMEETING },
+ { E_POPUP_ITEM, "44.forward", N_("_Forward as iCalendar..."), on_forward, NULL, "stock_mail-forward", 0, E_CAL_POPUP_SELECT_NOTEDITING },
- E_POPUP_SEPARATOR,
+ { E_POPUP_BAR, "50." },
- E_POPUP_ITEM (N_("_Delete"), GTK_SIGNAL_FUNC (on_delete_appointment), MASK_EDITABLE | MASK_SINGLE | MASK_EDITING),
- E_POPUP_ITEM (N_("Make this Occurrence _Movable"), GTK_SIGNAL_FUNC (on_unrecur_appointment), MASK_EDITABLE | MASK_RECURRING | MASK_EDITING | MASK_INSTANCE),
- E_POPUP_ITEM (N_("Delete this _Occurrence"), GTK_SIGNAL_FUNC (on_delete_occurrence), MASK_RECURRING | MASK_EDITING | MASK_EDITABLE),
- E_POPUP_ITEM (N_("Delete _All Occurrences"), GTK_SIGNAL_FUNC (on_delete_appointment), MASK_RECURRING | MASK_EDITING | MASK_EDITABLE),
-
- E_POPUP_TERMINATOR
+ { E_POPUP_ITEM, "51.delete", N_("_Delete"), on_delete_appointment, NULL, GTK_STOCK_DELETE, E_CAL_POPUP_SELECT_NONRECURRING, E_CAL_POPUP_SELECT_NOTEDITING | E_CAL_POPUP_SELECT_EDITABLE },
+ { E_POPUP_ITEM, "52.move", N_("Make this Occurrence _Movable"), on_unrecur_appointment, NULL, NULL, E_CAL_POPUP_SELECT_RECURRING | E_CAL_POPUP_SELECT_INSTANCE, E_CAL_POPUP_SELECT_NOTEDITING | E_CAL_POPUP_SELECT_EDITABLE },
+ { E_POPUP_ITEM, "53.delete", N_("Delete this _Occurrence"), on_delete_occurrence, NULL, GTK_STOCK_DELETE, E_CAL_POPUP_SELECT_RECURRING, E_CAL_POPUP_SELECT_NOTEDITING | E_CAL_POPUP_SELECT_EDITABLE },
+ { E_POPUP_ITEM, "54.delete", N_("Delete _All Occurrences"), on_delete_appointment, NULL, GTK_STOCK_DELETE, E_CAL_POPUP_SELECT_RECURRING, E_CAL_POPUP_SELECT_NOTEDITING | E_CAL_POPUP_SELECT_EDITABLE },
};
static void
-free_view_popup (GtkWidget *widget, gpointer data)
-{
- ECalendarView *cal_view = E_CALENDAR_VIEW (data);
-
- if (cal_view->priv->view_menu == NULL)
- return;
-
- gnome_calendar_discard_view_popup (cal_view->priv->calendar, cal_view->priv->view_menu);
- cal_view->priv->view_menu = NULL;
-}
-
-static void
-setup_popup_icons (EPopupMenu *context_menu)
+ecv_popup_free (EPopup *ep, GSList *list, void *data)
{
- gint i;
-
- for (i = 0; context_menu[i].name; i++) {
- GtkWidget *pixmap_widget = NULL;
- GdkPixbuf *pixbuf;
-
- if (!strcmp (context_menu[i].name, _("_Copy")))
- pixmap_widget = gtk_image_new_from_stock (GTK_STOCK_COPY, GTK_ICON_SIZE_MENU);
- else if (!strcmp (context_menu[i].name, _("C_ut")))
- pixmap_widget = gtk_image_new_from_stock (GTK_STOCK_CUT, GTK_ICON_SIZE_MENU);
- else if (!strcmp (context_menu[i].name, _("_Delete")) ||
- !strcmp (context_menu[i].name, _("Delete this _Occurrence")) ||
- !strcmp (context_menu[i].name, _("Delete _All Occurrences")))
- pixmap_widget = gtk_image_new_from_stock (GTK_STOCK_DELETE, GTK_ICON_SIZE_MENU);
- else if (!strcmp (context_menu[i].name, _("Go to _Today")))
- pixmap_widget = gtk_image_new_from_stock (GTK_STOCK_HOME, GTK_ICON_SIZE_MENU);
- else if (!strcmp (context_menu[i].name, _("_Go to Date...")))
- pixmap_widget = gtk_image_new_from_stock (GTK_STOCK_JUMP_TO, GTK_ICON_SIZE_MENU);
- else if (!strcmp (context_menu[i].name, _("New _Appointment..."))) {
- pixbuf = e_icon_factory_get_icon ("stock_new-appointment", E_ICON_SIZE_MENU);
- pixmap_widget = gtk_image_new_from_pixbuf (pixbuf);
- gdk_pixbuf_unref (pixbuf);
- }
- else if (!strcmp (context_menu[i].name, _("New All Day _Event"))) {
- pixbuf = e_icon_factory_get_icon ("stock_new-24h-appointment", E_ICON_SIZE_MENU);
- pixmap_widget = gtk_image_new_from_pixbuf (pixbuf);
- gdk_pixbuf_unref (pixbuf);
- }
- else if (!strcmp (context_menu[i].name, _("New Meeting"))) {
- pixbuf = e_icon_factory_get_icon ("stock_new-meeting", E_ICON_SIZE_MENU);
- pixmap_widget = gtk_image_new_from_pixbuf (pixbuf);
- gdk_pixbuf_unref (pixbuf);
- }
- else if (!strcmp (context_menu[i].name, _("New Task"))) {
- pixbuf = e_icon_factory_get_icon ("stock_task", E_ICON_SIZE_MENU);
- pixmap_widget = gtk_image_new_from_pixbuf (pixbuf);
- gdk_pixbuf_unref (pixbuf);
- }
- else if (!strcmp (context_menu[i].name, _("_Open")))
- pixmap_widget = gtk_image_new_from_stock (GTK_STOCK_OPEN, GTK_ICON_SIZE_MENU);
- else if (!strcmp (context_menu[i].name, _("_Paste")))
- pixmap_widget = gtk_image_new_from_stock (GTK_STOCK_PASTE, GTK_ICON_SIZE_MENU);
- else if (!strcmp (context_menu[i].name, _("_Print...")))
- pixmap_widget = gtk_image_new_from_stock (GTK_STOCK_PRINT, GTK_ICON_SIZE_MENU);
- else if (!strcmp (context_menu[i].name, _("_Save As...")))
- pixmap_widget = gtk_image_new_from_stock (GTK_STOCK_SAVE_AS, GTK_ICON_SIZE_MENU);
- else if (!strcmp (context_menu[i].name, _("_Settings...")))
- pixmap_widget = gtk_image_new_from_stock (GTK_STOCK_PREFERENCES, GTK_ICON_SIZE_MENU);
-
- if (pixmap_widget)
- gtk_widget_show (pixmap_widget);
- context_menu[i].pixmap_widget = pixmap_widget;
- }
+ g_slist_free(list);
}
GtkMenu *
e_calendar_view_create_popup_menu (ECalendarView *cal_view)
{
- GList *selected;
- EPopupMenu *context_menu;
- guint32 disable_mask = 0, hide_mask = 0;
- GtkMenu *popup;
- ECal *client = NULL;
- gboolean read_only = TRUE;
-
- g_return_val_if_fail (E_IS_CALENDAR_VIEW (cal_view), NULL);
-
- /* get the selection */
- selected = e_calendar_view_get_selected_events (cal_view);
-
- if (selected == NULL) {
- cal_view->priv->view_menu = gnome_calendar_setup_view_popup (cal_view->priv->calendar);
- main_items[9].submenu = cal_view->priv->view_menu;
- context_menu = main_items;
-
- client = e_cal_model_get_default_client (cal_view->priv->model);
- } else {
- ECalendarViewEvent *event;
-
- context_menu = child_items;
+ ECalPopup *ep;
+ GSList *menus = NULL;
+ int i;
+ ECalPopupTargetSelect *t;
- event = (ECalendarViewEvent *) selected->data;
- if (e_cal_util_component_has_recurrences (event->comp_data->icalcomp))
- hide_mask |= MASK_SINGLE;
- else
- hide_mask |= MASK_RECURRING;
-
- if (e_cal_util_component_is_instance (event->comp_data->icalcomp))
- hide_mask |= MASK_INSTANCE;
+ g_return_val_if_fail (E_IS_CALENDAR_VIEW (cal_view), NULL);
- if (e_cal_util_component_has_organizer (event->comp_data->icalcomp)) {
- ECalComponent *comp;
+ /* We could do this using a factory on the ECalPopup class,
+ * that way we would get called implicitly whenever a popup
+ * menu was created rather than everyone having to call us.
+ * We could also have a different menu id for each view */
- disable_mask |= MASK_MEETING;
+ ep = e_cal_popup_new("com.novell.evolution.calendar.view.popup");
+ t = e_cal_popup_target_new_select(ep, cal_view);
+ t->target.widget = (GtkWidget *)cal_view;
- comp = e_cal_component_new ();
- e_cal_component_set_icalcomponent (comp, icalcomponent_new_clone (event->comp_data->icalcomp));
- if (!itip_organizer_is_user (comp, event->comp_data->client))
- disable_mask |= MASK_MEETING_ORGANIZER;
+ if (t->events->len == 0) {
+ for (i=0;i<sizeof(ecv_main_items)/sizeof(ecv_main_items[0]);i++)
+ menus = g_slist_prepend(menus, &ecv_main_items[i]);
- g_object_unref (comp);
- }
-
- client = event->comp_data->client;
+ gnome_calendar_view_popup_factory(cal_view->priv->calendar, (EPopup *)ep, "60.view");
+ } else {
+ for (i=0;i<sizeof(ecv_child_items)/sizeof(ecv_child_items[0]);i++)
+ menus = g_slist_prepend(menus, &ecv_child_items[i]);
}
- e_cal_is_read_only (client, &read_only, NULL);
- if (read_only)
- disable_mask |= MASK_EDITABLE;
-
- setup_popup_icons (context_menu);
- popup = e_popup_menu_create (context_menu, disable_mask, hide_mask, cal_view);
- g_signal_connect (popup, "selection-done", G_CALLBACK (free_view_popup), cal_view);
+ e_popup_add_items((EPopup *)ep, menus, ecv_popup_free, cal_view);
- return popup;
+ return e_popup_create_menu_once((EPopup *)ep, (EPopupTarget *)t, 0);
}
void
diff --git a/calendar/gui/e-day-view.c b/calendar/gui/e-day-view.c
index 4830bbda89..49ed340dc5 100644
--- a/calendar/gui/e-day-view.c
+++ b/calendar/gui/e-day-view.c
@@ -3289,7 +3289,7 @@ e_day_view_show_popup_menu (EDayView *day_view,
popup = e_calendar_view_create_popup_menu (E_CALENDAR_VIEW (day_view));
g_object_weak_ref (G_OBJECT (popup), popup_destroyed_cb, day_view);
- e_popup_menu (popup, gdk_event);
+ gtk_menu_popup (popup, NULL, NULL, NULL, NULL, gdk_event?gdk_event->button.button:0, gdk_event?gdk_event->button.time:gtk_get_current_event_time());
}
static gboolean
diff --git a/calendar/gui/e-day-view.h b/calendar/gui/e-day-view.h
index b37960f6db..1d87d57211 100644
--- a/calendar/gui/e-day-view.h
+++ b/calendar/gui/e-day-view.h
@@ -28,7 +28,6 @@
#include <gtk/gtktable.h>
#include <gtk/gtktooltips.h>
#include <libgnomecanvas/gnome-canvas.h>
-#include <gal/widgets/e-popup-menu.h>
#include "e-calendar-view.h"
#include "gnome-cal.h"
diff --git a/calendar/gui/e-week-view.c b/calendar/gui/e-week-view.c
index cfb0f208f1..7802fa5da1 100644
--- a/calendar/gui/e-week-view.c
+++ b/calendar/gui/e-week-view.c
@@ -3935,7 +3935,7 @@ e_week_view_show_popup_menu (EWeekView *week_view,
popup = e_calendar_view_create_popup_menu (E_CALENDAR_VIEW (week_view));
g_object_weak_ref (G_OBJECT (popup), popup_destroyed_cb, week_view);
- e_popup_menu (popup, (GdkEvent *) bevent);
+ gtk_menu_popup (popup, NULL, NULL, NULL, NULL, bevent?bevent->button:0, bevent?bevent->time:gtk_get_current_event_time());
}
static gboolean
diff --git a/calendar/gui/e-week-view.h b/calendar/gui/e-week-view.h
index 90ab82eb08..2b63748704 100644
--- a/calendar/gui/e-week-view.h
+++ b/calendar/gui/e-week-view.h
@@ -26,7 +26,6 @@
#include <gtk/gtktable.h>
#include <libgnomecanvas/gnome-canvas.h>
-#include <gal/widgets/e-popup-menu.h>
#include "e-calendar-view.h"
#include "gnome-cal.h"
diff --git a/calendar/gui/gnome-cal.c b/calendar/gui/gnome-cal.c
index b8c97d5040..f5ac1895d7 100644
--- a/calendar/gui/gnome-cal.c
+++ b/calendar/gui/gnome-cal.c
@@ -47,6 +47,7 @@
#include <libecal/e-cal-time-util.h>
#include <gal/menus/gal-view-factory-etable.h>
#include <gal/menus/gal-view-etable.h>
+#include <gal/menus/gal-define-views-dialog.h>
#include "widgets/menus/gal-view-menus.h"
#include "widgets/misc/e-error.h"
#include "e-comp-editor-registry.h"
@@ -77,6 +78,7 @@
#include "misc.h"
#include "ea-calendar.h"
#include "common/authentication.h"
+#include "e-cal-popup.h"
/* FIXME glib 2.4 and above has this */
#ifndef G_MAXINT32
@@ -1982,36 +1984,137 @@ gnome_calendar_discard_view_menus (GnomeCalendar *gcal)
priv->view_menus = NULL;
}
-EPopupMenu *
-gnome_calendar_setup_view_popup (GnomeCalendar *gcal)
+/* This is copied/moved from gal-view-instance, only the calendar uses this for a popup menu */
+static void
+gc_set_view(EPopup *ep, EPopupItem *pitem, void *data)
{
- GnomeCalendarPrivate *priv;
+ GnomeCalendar *gcal = data;
- g_return_val_if_fail (gcal != NULL, NULL);
- g_return_val_if_fail (GNOME_IS_CALENDAR (gcal), NULL);
+ if (pitem->type & E_POPUP_ACTIVE)
+ gal_view_instance_set_current_view_id(gcal->priv->view_instance, (char *)pitem->user_data);
+}
- priv = gcal->priv;
+static void
+gc_save_custom_view(EPopup *ep, EPopupItem *pitem, void *data)
+{
+ GnomeCalendar *gcal = data;
- g_return_val_if_fail (priv->view_instance != NULL, NULL);
+ gal_view_instance_save_as(gcal->priv->view_instance);
+}
- return gal_view_instance_get_popup_menu (priv->view_instance);
+static void
+gc_define_views_response(GtkWidget *d, int id, GnomeCalendar *gcal)
+{
+ if (id == GTK_RESPONSE_OK)
+ gal_view_collection_save(gcal->priv->view_instance->collection);
+
+ gtk_widget_destroy(d);
}
-void
-gnome_calendar_discard_view_popup (GnomeCalendar *gcal, EPopupMenu *popup)
+static void
+gc_define_views(EPopup *ep, EPopupItem *pitem, void *data)
+{
+ GnomeCalendar *gcal = data;
+ GtkWidget *dialog = gal_define_views_dialog_new(gcal->priv->view_instance->collection);
+
+ g_signal_connect(dialog, "response", G_CALLBACK(gc_define_views_response), data);
+ gtk_widget_show(dialog);
+}
+
+static EPopupItem gc_popups[] = {
+ /* Code generates the path to fit */
+ { E_POPUP_BAR, NULL },
+ { E_POPUP_RADIO|E_POPUP_ACTIVE, NULL, N_("Custom View"), },
+ { E_POPUP_ITEM, NULL, N_("Save Custom View"), gc_save_custom_view },
+
+ /* index == 3, when we have non-custom view */
+
+ { E_POPUP_BAR, NULL },
+ { E_POPUP_ITEM, NULL, N_("Define Views..."), gc_define_views },
+};
+
+static void
+gc_popup_free (EPopup *ep, GSList *list, void *data)
+{
+ while (list) {
+ GSList *n = list->next;
+ EPopupItem *pitem = list->data;
+
+ g_free(pitem->path);
+ g_free(pitem->label);
+ g_free(pitem->user_data);
+ g_free(pitem);
+ g_slist_free_1(list);
+ list = n;
+ }
+}
+
+static void
+gc_popup_free_static (EPopup *ep, GSList *list, void *data)
{
+ while (list) {
+ GSList *n = list->next;
+ EPopupItem *pitem = list->data;
+ g_free(pitem->path);
+ g_free(pitem);
+ g_slist_free_1(list);
+ list = n;
+ }
+}
+void
+gnome_calendar_view_popup_factory (GnomeCalendar *gcal, EPopup *ep, const char *prefix)
+{
GnomeCalendarPrivate *priv;
+ int length;
+ int i;
+ gboolean found = FALSE;
+ char *id;
+ GSList *menus = NULL;
+ EPopupItem *pitem;
g_return_if_fail (gcal != NULL);
g_return_if_fail (GNOME_IS_CALENDAR (gcal));
+ g_return_if_fail (prefix != NULL);
priv = gcal->priv;
g_return_if_fail (priv->view_instance != NULL);
- gal_view_instance_free_popup_menu (priv->view_instance, popup);
+ length = gal_view_collection_get_count(priv->view_instance->collection);
+ id = gal_view_instance_get_current_view_id (priv->view_instance);
+
+ for (i = 0; i < length; i++) {
+ GalViewCollectionItem *item = gal_view_collection_get_view_item(priv->view_instance->collection, i);
+
+ pitem = g_malloc0(sizeof(*pitem));
+ pitem->type = E_POPUP_RADIO;
+ pitem->path = g_strdup_printf("%s/%02d.item", prefix, i);
+ pitem->label = g_strdup(item->title);
+ pitem->activate = gc_set_view;
+ pitem->user_data = g_strdup(item->id);
+
+ if (!found && id && !strcmp (id, item->id)) {
+ found = TRUE;
+ pitem->type |= E_POPUP_ACTIVE;
+ }
+
+ menus = g_slist_prepend(menus, pitem);
+ }
+
+ if (menus)
+ e_popup_add_items(ep, menus, gc_popup_free, gcal);
+
+ menus = NULL;
+ for (i = found?3:0; i<sizeof(gc_popups)/sizeof(gc_popups[0]);i++) {
+ pitem = g_malloc0(sizeof(*pitem));
+ memcpy(pitem, &gc_popups[i], sizeof(*pitem));
+ pitem->path = g_strdup_printf("%s/%02d.item", prefix, i+length);
+ menus = g_slist_prepend(menus, pitem);
+ }
+
+ e_popup_add_items(ep, menus, gc_popup_free_static, gcal);
}
static void
diff --git a/calendar/gui/gnome-cal.h b/calendar/gui/gnome-cal.h
index 2e41529b33..ee08c98700 100644
--- a/calendar/gui/gnome-cal.h
+++ b/calendar/gui/gnome-cal.h
@@ -28,7 +28,6 @@
#include <time.h>
#include <gtk/gtkvbox.h>
#include <bonobo/bonobo-ui-component.h>
-#include <gal/widgets/e-popup-menu.h>
#include <widgets/misc/e-calendar.h>
#include <libecal/e-cal.h>
@@ -38,6 +37,8 @@ G_BEGIN_DECLS
+struct _EPopup;
+
#define GNOME_TYPE_CALENDAR (gnome_calendar_get_type ())
#define GNOME_CALENDAR(obj) (GTK_CHECK_CAST ((obj), GNOME_TYPE_CALENDAR, GnomeCalendar))
#define GNOME_CALENDAR_CLASS(klass) (GTK_CHECK_CAST_CLASS ((klass), GNOME_TYPE_CALENDAR, \
@@ -137,8 +138,7 @@ GtkWidget *gnome_calendar_get_view_notebook_widget (GnomeCalendar *gcal);
void gnome_calendar_setup_view_menus (GnomeCalendar *gcal, BonoboUIComponent *uic);
void gnome_calendar_discard_view_menus (GnomeCalendar *gcal);
-EPopupMenu *gnome_calendar_setup_view_popup (GnomeCalendar *gcal);
-void gnome_calendar_discard_view_popup (GnomeCalendar *gcal, EPopupMenu *popup);
+void gnome_calendar_view_popup_factory (GnomeCalendar *gcal, struct _EPopup *ep, const char *prefix);
void gnome_calendar_set_selected_time_range (GnomeCalendar *gcal,
time_t start_time,
diff --git a/calendar/gui/tasks-component.c b/calendar/gui/tasks-component.c
index 23482dc33f..d5455468eb 100644
--- a/calendar/gui/tasks-component.c
+++ b/calendar/gui/tasks-component.c
@@ -325,10 +325,10 @@ edit_task_list_cb (EPopup *ep, EPopupItem *pitem, void *data)
}
static EPopupItem etc_source_popups[] = {
- { E_POPUP_ITEM, "10.new", N_("New Task List"), new_task_list_cb, NULL, "stock_todo", 0 },
- { E_POPUP_ITEM, "15.copy", N_("Copy"), copy_task_list_cb, NULL, "stock_folder-copy", E_CAL_POPUP_SOURCE_PRIMARY },
- { E_POPUP_ITEM, "20.delete", N_("Delete"), delete_task_list_cb, NULL, "stock_delete", E_CAL_POPUP_SOURCE_USER|E_CAL_POPUP_SOURCE_PRIMARY },
- { E_POPUP_ITEM, "30.properties", N_("Properties..."), edit_task_list_cb, NULL, NULL, E_CAL_POPUP_SOURCE_PRIMARY },
+ { E_POPUP_ITEM, "10.new", N_("New Task List"), new_task_list_cb, NULL, "stock_todo", 0, 0 },
+ { E_POPUP_ITEM, "15.copy", N_("Copy"), copy_task_list_cb, NULL, "stock_folder-copy", 0, E_CAL_POPUP_SOURCE_PRIMARY },
+ { E_POPUP_ITEM, "20.delete", N_("Delete"), delete_task_list_cb, NULL, "stock_delete", 0, E_CAL_POPUP_SOURCE_USER|E_CAL_POPUP_SOURCE_PRIMARY },
+ { E_POPUP_ITEM, "30.properties", N_("Properties..."), edit_task_list_cb, NULL, NULL, 0, E_CAL_POPUP_SOURCE_PRIMARY },
};
static void
@@ -355,8 +355,7 @@ popup_event_cb(ESourceSelector *selector, ESource *insource, GdkEventButton *eve
e_popup_add_items((EPopup *)ep, menus, etc_source_popup_free, component_view);
- /* visibility is disabled, we only disable menu items */
- menu = e_popup_create_menu_once((EPopup *)ep, (EPopupTarget *)t, 0, t->target.mask);
+ menu = e_popup_create_menu_once((EPopup *)ep, (EPopupTarget *)t, 0);
gtk_menu_popup(menu, NULL, NULL, NULL, NULL, event?event->button:0, event?event->time:gtk_get_current_event_time());
return TRUE;