diff options
Diffstat (limited to 'calendar')
-rw-r--r-- | calendar/ChangeLog | 20 | ||||
-rw-r--r-- | calendar/gui/e-day-view.c | 44 | ||||
-rw-r--r-- | calendar/gui/e-day-view.h | 4 | ||||
-rw-r--r-- | calendar/gui/e-week-view.c | 26 | ||||
-rw-r--r-- | calendar/gui/e-week-view.h | 2 | ||||
-rw-r--r-- | calendar/gui/gnome-cal.c | 42 | ||||
-rw-r--r-- | calendar/gui/gnome-cal.h | 4 |
7 files changed, 112 insertions, 30 deletions
diff --git a/calendar/ChangeLog b/calendar/ChangeLog index f77b8b1bd7..8096477015 100644 --- a/calendar/ChangeLog +++ b/calendar/ChangeLog @@ -1,3 +1,23 @@ +2002-04-24 JP Rosevear <jpr@ximian.com> + + * gui/e-week-view.c (free_view_popup): free the view popup + (e_week_view_show_popup_menu): add the view popup to the + "main_item" menu and listen for destruction + + * gui/e-day-view.c (free_view_popup): as above + (e_day_view_on_event_right_click): as above + + * gui/e-week-view.h: add class member + + * gui/e-day-view.h: add a class member + + * gui/gnome-cal.h: new protos + + * gui/gnome-cal.c (set_view): set the instance view id properly + when switching views + (gnome_calendar_setup_view_popup): generate a view popup + (gnome_calendar_discard_view_popup): destroy a view popup + 2002-04-22 Rodrigo Moya <rodrigo@ximian.com> * pcs/cal.c (impl_Cal_get_alarms_in_range): raise an exception if the diff --git a/calendar/gui/e-day-view.c b/calendar/gui/e-day-view.c index 4f73dccd55..01b9022e2f 100644 --- a/calendar/gui/e-day-view.c +++ b/calendar/gui/e-day-view.c @@ -41,8 +41,8 @@ #include <gtk/gtkvscrollbar.h> #include <gtk/gtkwindow.h> #include <gal/e-text/e-text.h> -#include <gal/widgets/e-popup-menu.h> #include <gal/widgets/e-canvas-utils.h> +#include <gal/widgets/e-gui-utils.h> #include <gal/widgets/e-unicode.h> #include <libgnomeui/gnome-canvas-rect-ellipse.h> #include <libgnome/gnome-i18n.h> @@ -3541,17 +3541,6 @@ enum { MASK_EDITING = 8 }; -#if 0 -static EPopupMenu view_items [] = { - E_POPUP_RADIO_ITEM (N_("Day View"), e_day_view_on_goto_date, 0, 0), - E_POPUP_RADIO_ITEM (N_("Work Week View"), e_day_view_on_goto_date, 0, 0), - E_POPUP_RADIO_ITEM (N_("Week View"), e_day_view_on_goto_date, 0, 0), - E_POPUP_RADIO_ITEM (N_("Month View"), e_day_view_on_goto_date, 0, 0), - - E_POPUP_TERMINATOR -}; -#endif - static EPopupMenu main_items [] = { E_POPUP_ITEM (N_("New _Appointment"), e_day_view_on_new_appointment, 0), @@ -3574,10 +3563,7 @@ static EPopupMenu main_items [] = { E_POPUP_SEPARATOR, -#if 0 - E_POPUP_SUBMENU (N_("Current View"), - view_items, 0), -#endif + E_POPUP_SUBMENU (N_("Current View"), NULL, 0), E_POPUP_ITEM (N_("Go to _Today"), e_day_view_on_goto_today, 0), @@ -3612,8 +3598,8 @@ static EPopupMenu child_items [] = { E_POPUP_SEPARATOR, - E_POPUP_ITEM (N_("_Schedule Meeting..."), e_day_view_on_meeting, MASK_EDITABLE | MASK_SINGLE | MASK_EDITING), - E_POPUP_ITEM (N_("_Forward as iCalendar..."), e_day_view_on_forward, MASK_EDITABLE | MASK_SINGLE | MASK_EDITING), + E_POPUP_ITEM (N_("_Schedule Meeting..."), e_day_view_on_meeting, MASK_EDITABLE | MASK_EDITING), + E_POPUP_ITEM (N_("_Forward as iCalendar..."), e_day_view_on_forward, MASK_EDITABLE | MASK_EDITING), E_POPUP_SEPARATOR, @@ -3626,6 +3612,14 @@ static EPopupMenu child_items [] = { }; static void +free_view_popup (GtkWidget *widget, gpointer data) +{ + EDayView *day_view = E_DAY_VIEW (data); + + gnome_calendar_discard_view_popup (day_view->calendar, day_view->view_menu); +} + +static void e_day_view_on_event_right_click (EDayView *day_view, GdkEventButton *bevent, gint day, @@ -3635,6 +3629,7 @@ e_day_view_on_event_right_click (EDayView *day_view, int have_selection; gboolean being_edited; EPopupMenu *context_menu; + GtkMenu *popup; int hide_mask = 0; int disable_mask = 0; @@ -3650,9 +3645,11 @@ e_day_view_on_event_right_click (EDayView *day_view, have_selection = GTK_WIDGET_HAS_FOCUS (day_view) && day_view->selection_start_day != -1; - if (event_num == -1) + if (event_num == -1) { + day_view->view_menu = gnome_calendar_setup_view_popup (day_view->calendar); + main_items[9].submenu = day_view->view_menu; context_menu = main_items; - else { + } else { context_menu = child_items; if (day == E_DAY_VIEW_LONG_EVENT) @@ -3673,8 +3670,11 @@ e_day_view_on_event_right_click (EDayView *day_view, day_view->popup_event_day = day; day_view->popup_event_num = event_num; - - e_popup_menu_run (context_menu, (GdkEvent *) bevent, disable_mask, hide_mask, day_view); + + popup = e_popup_menu_create (context_menu, disable_mask, hide_mask, day_view); + gtk_signal_connect (GTK_OBJECT (popup), "selection-done", + GTK_SIGNAL_FUNC (free_view_popup), day_view); + e_popup_menu (popup, (GdkEvent *) bevent); } static void diff --git a/calendar/gui/e-day-view.h b/calendar/gui/e-day-view.h index 1c72a3a78b..25f9181218 100644 --- a/calendar/gui/e-day-view.h +++ b/calendar/gui/e-day-view.h @@ -27,6 +27,7 @@ #include <time.h> #include <gtk/gtktable.h> #include <libgnomeui/gnome-canvas.h> +#include <gal/widgets/e-popup-menu.h> #include "gnome-cal.h" #include "evolution-activity-client.h" @@ -408,7 +409,8 @@ struct _EDayView /* The event for which a popup menu is being displayed, as above. */ gint popup_event_day; gint popup_event_num; - + EPopupMenu *view_menu; + /* The currently selected region. If selection_start_day is -1 there is no current selection. If start_row or end_row is -1 then the selection is in the top canvas. */ diff --git a/calendar/gui/e-week-view.c b/calendar/gui/e-week-view.c index 3ebc5f9ac0..4fb09c5961 100644 --- a/calendar/gui/e-week-view.c +++ b/calendar/gui/e-week-view.c @@ -44,8 +44,8 @@ #include <gdk-pixbuf/gdk-pixbuf.h> #include <gdk-pixbuf/gnome-canvas-pixbuf.h> #include <gal/e-text/e-text.h> -#include <gal/widgets/e-popup-menu.h> #include <gal/widgets/e-canvas-utils.h> +#include <gal/widgets/e-gui-utils.h> #include <gal/widgets/e-unicode.h> #include <e-util/e-dialog-utils.h> #include "dialogs/delete-comp.h" @@ -3444,6 +3444,8 @@ static EPopupMenu main_items [] = { E_POPUP_ITEM (N_("_Paste"), e_week_view_on_paste, 0), E_POPUP_SEPARATOR, + + E_POPUP_SUBMENU (N_("Current View"), NULL, 0), E_POPUP_ITEM (N_("Go to _Today"), e_week_view_on_goto_today, 0), E_POPUP_ITEM (N_("_Go to Date..."), e_week_view_on_goto_date, 0), @@ -3473,8 +3475,8 @@ static EPopupMenu child_items [] = { E_POPUP_SEPARATOR, - E_POPUP_ITEM (N_("_Schedule Meeting..."), e_week_view_on_meeting, MASK_EDITABLE | MASK_SINGLE | MASK_EDITING), - E_POPUP_ITEM (N_("_Forward as iCalendar..."), e_week_view_on_forward, MASK_EDITABLE | MASK_SINGLE | MASK_EDITING), + E_POPUP_ITEM (N_("_Schedule Meeting..."), e_week_view_on_meeting, MASK_EDITABLE | MASK_EDITING), + E_POPUP_ITEM (N_("_Forward as iCalendar..."), e_week_view_on_forward, MASK_EDITABLE | MASK_EDITING), E_POPUP_SEPARATOR, @@ -3486,6 +3488,14 @@ static EPopupMenu child_items [] = { E_POPUP_TERMINATOR }; +static void +free_view_popup (GtkWidget *widget, gpointer data) +{ + EWeekView *week_view = E_WEEK_VIEW (data); + + gnome_calendar_discard_view_popup (week_view->calendar, week_view->view_menu); +} + void e_week_view_show_popup_menu (EWeekView *week_view, GdkEventButton *bevent, @@ -3496,7 +3506,8 @@ e_week_view_show_popup_menu (EWeekView *week_view, gboolean being_edited; guint32 disable_mask = 0, hide_mask = 0; EPopupMenu *context_menu; - + GtkMenu *popup; + have_selection = GTK_WIDGET_HAS_FOCUS (week_view) && week_view->selection_start_day != -1; @@ -3508,6 +3519,8 @@ e_week_view_show_popup_menu (EWeekView *week_view, being_edited = FALSE; if (event_num == -1) { + week_view->view_menu = gnome_calendar_setup_view_popup (week_view->calendar); + main_items[9].submenu = week_view->view_menu; context_menu = main_items; } else { context_menu = child_items; @@ -3523,7 +3536,10 @@ e_week_view_show_popup_menu (EWeekView *week_view, disable_mask |= MASK_EDITING; week_view->popup_event_num = event_num; - e_popup_menu_run (context_menu, (GdkEvent *) bevent, disable_mask, hide_mask, week_view); + popup = e_popup_menu_create (context_menu, disable_mask, hide_mask, week_view); + gtk_signal_connect (GTK_OBJECT (popup), "selection-done", + GTK_SIGNAL_FUNC (free_view_popup), week_view); + e_popup_menu (popup, (GdkEvent *) bevent); } static void diff --git a/calendar/gui/e-week-view.h b/calendar/gui/e-week-view.h index ed14796414..689874cc25 100644 --- a/calendar/gui/e-week-view.h +++ b/calendar/gui/e-week-view.h @@ -26,6 +26,7 @@ #include <gtk/gtktable.h> #include <libgnomeui/gnome-canvas.h> +#include <gal/widgets/e-popup-menu.h> #include "gnome-cal.h" #include "evolution-activity-client.h" @@ -347,6 +348,7 @@ struct _EWeekView /* The event that the context menu is for. */ gint popup_event_num; + EPopupMenu *view_menu; /* The last mouse position when dragging, in the entire canvas. */ gint drag_event_x; diff --git a/calendar/gui/gnome-cal.c b/calendar/gui/gnome-cal.c index 809e3588e3..fdbbce9769 100644 --- a/calendar/gui/gnome-cal.c +++ b/calendar/gui/gnome-cal.c @@ -1236,7 +1236,8 @@ set_view (GnomeCalendar *gcal, GnomeCalendarViewType view_type, GnomeCalendarPrivate *priv; gboolean round_selection; GtkWidget *focus_widget; - + const char *view_id; + priv = gcal->priv; round_selection = FALSE; @@ -1244,23 +1245,27 @@ set_view (GnomeCalendar *gcal, GnomeCalendarViewType view_type, switch (view_type) { case GNOME_CAL_DAY_VIEW: + view_id = "Day_View"; focus_widget = priv->day_view; - + if (!range_selected) e_day_view_set_days_shown (E_DAY_VIEW (priv->day_view), 1); break; case GNOME_CAL_WORK_WEEK_VIEW: + view_id = "Work_Week_View"; focus_widget = priv->work_week_view; break; case GNOME_CAL_WEEK_VIEW: + view_id = "Week_View"; focus_widget = priv->week_view; round_selection = TRUE; break; case GNOME_CAL_MONTH_VIEW: + view_id = "Month_View"; focus_widget = priv->month_view; if (!range_selected) @@ -1283,6 +1288,7 @@ set_view (GnomeCalendar *gcal, GnomeCalendarViewType view_type, calendar_config_set_default_view (view_type); gtk_notebook_set_page (GTK_NOTEBOOK (priv->notebook), (int) view_type); + gal_view_instance_set_current_view_id (priv->view_instance, view_id); if (grab_focus) gtk_widget_grab_focus (focus_widget); @@ -1441,6 +1447,38 @@ gnome_calendar_discard_view_menus (GnomeCalendar *gcal) priv->view_menus = NULL; } +EPopupMenu * +gnome_calendar_setup_view_popup (GnomeCalendar *gcal) +{ + GnomeCalendarPrivate *priv; + + g_return_val_if_fail (gcal != NULL, NULL); + g_return_val_if_fail (GNOME_IS_CALENDAR (gcal), NULL); + + priv = gcal->priv; + + g_return_val_if_fail (priv->view_instance != NULL, NULL); + + return gal_view_instance_get_popup_menu (priv->view_instance); +} + +void +gnome_calendar_discard_view_popup (GnomeCalendar *gcal, EPopupMenu *popup) +{ + + + GnomeCalendarPrivate *priv; + + g_return_if_fail (gcal != NULL); + g_return_if_fail (GNOME_IS_CALENDAR (gcal)); + + priv = gcal->priv; + + g_return_if_fail (priv->view_instance != NULL); + + gal_view_instance_free_popup_menu (priv->view_instance, popup); +} + static void gnome_calendar_set_pane_positions (GnomeCalendar *gcal) { diff --git a/calendar/gui/gnome-cal.h b/calendar/gui/gnome-cal.h index 8a888420dc..ebad45c99f 100644 --- a/calendar/gui/gnome-cal.h +++ b/calendar/gui/gnome-cal.h @@ -29,6 +29,7 @@ #include <libgnome/gnome-defs.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 <cal-client/cal-client.h> @@ -111,6 +112,9 @@ void gnome_calendar_set_view (GnomeCalendar *gcal, GnomeCalendarViewType view_ty 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_set_selected_time_range (GnomeCalendar *gcal, time_t start_time, time_t end_time); |