diff options
author | JP Rosevear <jpr@ximian.com> | 2004-04-08 00:12:22 +0800 |
---|---|---|
committer | JP Rosevear <jpr@src.gnome.org> | 2004-04-08 00:12:22 +0800 |
commit | 3d47eb28221963adcef3a9c8502d6815353af1d9 (patch) | |
tree | b2615874c61ebdbc0964a6f53f99a1918ddca4c8 /calendar/gui | |
parent | 5861eb8e7b1ae59b5e5cf600b36c6bf947b806bc (diff) | |
download | gsoc2013-evolution-3d47eb28221963adcef3a9c8502d6815353af1d9.tar.gz gsoc2013-evolution-3d47eb28221963adcef3a9c8502d6815353af1d9.tar.zst gsoc2013-evolution-3d47eb28221963adcef3a9c8502d6815353af1d9.zip |
remove extra set view params (gnome_calendar_set_view): simplify, just set
2004-04-07 JP Rosevear <jpr@ximian.com>
* gui/gnome-cal.c (gnome_calendar_dayjump): remove extra set view
params
(gnome_calendar_set_view): simplify, just set the current view id
and let the gal view stuff do the rest
(display_view): modify from set_view, don't set the view id here
or update the default view config setting
(display_view_cb): update the date navigator
(gnome_calendar_construct): kill the default view stuff, gal view
handles that
(gnome_calendar_on_date_navigator_selection_changed): use display_view
* gui/e-week-view.c (time_range_changed_cb): ditto
(e_week_view_set_selected_time_range): just set the selection,
don't fool with the base date
(e_week_view_on_button_press): do a full day event if double
clicked on
* gui/e-day-view.c (time_range_changed_cb): only set the selection
if we can't preserve an existing selection
* gui/control-factory.c (set_prop):
* gui/calendar-config.h: remove protos
* gui/calendar-config.c: remove default view calls
* gui/calendar-commands.c (show_day_view_clicked): remove extra
params to gnome_calendar_set_view
(show_work_week_view_clicked): ditto
(show_week_view_clicked): ditto
(show_month_view_clicked): ditto
(show_list_view_clicked): ditto
* gui/apps_evolution_calendar.schemas.in.in: remove default view
setting, gal view remembers this for us
svn path=/trunk/; revision=25353
Diffstat (limited to 'calendar/gui')
-rw-r--r-- | calendar/gui/apps_evolution_calendar.schemas.in.in | 11 | ||||
-rw-r--r-- | calendar/gui/calendar-commands.c | 10 | ||||
-rw-r--r-- | calendar/gui/calendar-config.c | 15 | ||||
-rw-r--r-- | calendar/gui/calendar-config.h | 4 | ||||
-rw-r--r-- | calendar/gui/control-factory.c | 6 | ||||
-rw-r--r-- | calendar/gui/e-day-view.c | 4 | ||||
-rw-r--r-- | calendar/gui/e-week-view.c | 74 | ||||
-rw-r--r-- | calendar/gui/gnome-cal.c | 128 | ||||
-rw-r--r-- | calendar/gui/gnome-cal.h | 3 |
9 files changed, 85 insertions, 170 deletions
diff --git a/calendar/gui/apps_evolution_calendar.schemas.in.in b/calendar/gui/apps_evolution_calendar.schemas.in.in index b42d3f8498..03dbe29296 100644 --- a/calendar/gui/apps_evolution_calendar.schemas.in.in +++ b/calendar/gui/apps_evolution_calendar.schemas.in.in @@ -92,17 +92,6 @@ </schema> <schema> - <key>/schemas/apps/evolution/calendar/display/default_view</key> - <applyto>/apps/evolution/calendar/display/default_view</applyto> - <owner>evolution-calendar</owner> - <type>int</type> - <default>0</default> - <locale name="C"> - <short>The view showing when the calendar starts</short> - </locale> - </schema> - - <schema> <key>/schemas/apps/evolution/calendar/display/hpane_position</key> <applyto>/apps/evolution/calendar/display/hpane_position</applyto> <owner>evolution-calendar</owner> diff --git a/calendar/gui/calendar-commands.c b/calendar/gui/calendar-commands.c index 29ddda03d4..d26230ce47 100644 --- a/calendar/gui/calendar-commands.c +++ b/calendar/gui/calendar-commands.c @@ -222,7 +222,7 @@ show_day_view_clicked (BonoboUIComponent *uic, gpointer data, const char *path) gcal = GNOME_CALENDAR (data); - gnome_calendar_set_view (gcal, GNOME_CAL_DAY_VIEW, FALSE, TRUE); + gnome_calendar_set_view (gcal, GNOME_CAL_DAY_VIEW); } static void @@ -232,7 +232,7 @@ show_work_week_view_clicked (BonoboUIComponent *uic, gpointer data, const char * gcal = GNOME_CALENDAR (data); - gnome_calendar_set_view (gcal, GNOME_CAL_WORK_WEEK_VIEW, FALSE, TRUE); + gnome_calendar_set_view (gcal, GNOME_CAL_WORK_WEEK_VIEW); } static void @@ -242,7 +242,7 @@ show_week_view_clicked (BonoboUIComponent *uic, gpointer data, const char *path) gcal = GNOME_CALENDAR (data); - gnome_calendar_set_view (gcal, GNOME_CAL_WEEK_VIEW, FALSE, TRUE); + gnome_calendar_set_view (gcal, GNOME_CAL_WEEK_VIEW); } static void @@ -252,7 +252,7 @@ show_month_view_clicked (BonoboUIComponent *uic, gpointer data, const char *path gcal = GNOME_CALENDAR (data); - gnome_calendar_set_view (gcal, GNOME_CAL_MONTH_VIEW, FALSE, TRUE); + gnome_calendar_set_view (gcal, GNOME_CAL_MONTH_VIEW); } @@ -263,7 +263,7 @@ show_list_view_clicked (BonoboUIComponent *uic, gpointer data, const char *path) gcal = GNOME_CALENDAR (data); - gnome_calendar_set_view (gcal, GNOME_CAL_LIST_VIEW, FALSE, TRUE); + gnome_calendar_set_view (gcal, GNOME_CAL_LIST_VIEW); } diff --git a/calendar/gui/calendar-config.c b/calendar/gui/calendar-config.c index 9280996d4a..4f8b7c59e8 100644 --- a/calendar/gui/calendar-config.c +++ b/calendar/gui/calendar-config.c @@ -410,21 +410,6 @@ calendar_config_add_notification_dnav_show_week_no (GConfClientNotifyFunc func, return id; } -/* The view to show on start-up, 0 = Day, 1 = WorkWeek, 2 = Week, 3 = Month. */ -gint -calendar_config_get_default_view (void) -{ - return gconf_client_get_int (config, CALENDAR_CONFIG_DEFAULT_VIEW, NULL); -} - - -void -calendar_config_set_default_view (gint view) -{ - gconf_client_set_int (config, CALENDAR_CONFIG_DEFAULT_VIEW, view, NULL); -} - - /* The positions of the panes in the normal and month views. */ gint calendar_config_get_hpane_pos (void) diff --git a/calendar/gui/calendar-config.h b/calendar/gui/calendar-config.h index 847cba98ef..238ba55a83 100644 --- a/calendar/gui/calendar-config.h +++ b/calendar/gui/calendar-config.h @@ -136,10 +136,6 @@ gboolean calendar_config_get_dnav_show_week_no (void); void calendar_config_set_dnav_show_week_no (gboolean show_week_no); guint calendar_config_add_notification_dnav_show_week_no (GConfClientNotifyFunc func, gpointer data); -/* The view to show on start-up, 0 = Day, 1 = WorkWeek, 2 = Week, 3 = Month. */ -gint calendar_config_get_default_view (void); -void calendar_config_set_default_view (gint view); - /* The positions of the panes in the normal and month views. */ gint calendar_config_get_hpane_pos (void); void calendar_config_set_hpane_pos (gint hpane_pos); diff --git a/calendar/gui/control-factory.c b/calendar/gui/control-factory.c index ac04829ee9..71c918fb14 100644 --- a/calendar/gui/control-factory.c +++ b/calendar/gui/control-factory.c @@ -159,15 +159,17 @@ set_prop (BonoboPropertyBag *bag, view = GNOME_CAL_WORK_WEEK_VIEW; else if (!strcmp (string, "month")) view = GNOME_CAL_MONTH_VIEW; + else if (!strcmp (string, "list")) + view = GNOME_CAL_LIST_VIEW; else if (!strcmp (string, "day")) view = GNOME_CAL_DAY_VIEW; else - view = calendar_config_get_default_view (); + view = GNOME_CAL_DAY_VIEW; /* This doesn't actually work, because the GalView * comes along and resets the view. FIXME. */ - gnome_calendar_set_view (gcal, view, FALSE, TRUE); + gnome_calendar_set_view (gcal, view); break; default: diff --git a/calendar/gui/e-day-view.c b/calendar/gui/e-day-view.c index f79f1d9ddd..bc256e288b 100644 --- a/calendar/gui/e-day-view.c +++ b/calendar/gui/e-day-view.c @@ -507,7 +507,9 @@ time_range_changed_cb (ECalModel *model, time_t start_time, time_t end_time, gpo if (lower != day_view->lower) e_day_view_recalc_day_starts (day_view, lower); - e_day_view_set_selected_time_range (E_CALENDAR_VIEW (day_view), start_time, end_time); + /* If we don't show the new selection, don't preserve it */ + if (day_view->selection_start_day == -1 || day_view->days_shown <= day_view->selection_start_day) + e_day_view_set_selected_time_range (E_CALENDAR_VIEW (day_view), start_time, end_time); } diff --git a/calendar/gui/e-week-view.c b/calendar/gui/e-week-view.c index e9cd2d284e..bc61ff6bb8 100644 --- a/calendar/gui/e-week-view.c +++ b/calendar/gui/e-week-view.c @@ -27,7 +27,9 @@ * EWeekView - displays the Week & Month views of the calendar. */ +#ifdef HAVE_CONFIG_H #include <config.h> +#endif #include "e-week-view.h" #include "ea-calendar.h" @@ -253,8 +255,8 @@ static void time_range_changed_cb (ECalModel *model, time_t start_time, time_t end_time, gpointer user_data) { EWeekView *week_view = E_WEEK_VIEW (user_data); - GDate date, base_date, end_date; - gint day_offset, weekday, week_start_offset, num_days; + GDate date, base_date; + gint day_offset, weekday, week_start_offset; gboolean update_adjustment_value = FALSE; g_return_if_fail (E_IS_WEEK_VIEW (week_view)); @@ -323,7 +325,9 @@ time_range_changed_cb (ECalModel *model, time_t start_time, time_t end_time, gpo gtk_widget_queue_draw (week_view->main_canvas); /* FIXME Preserve selection if possible */ - e_week_view_set_selected_time_range (E_CALENDAR_VIEW (week_view), start_time, start_time); + if (week_view->selection_start_day == -1 || + (week_view->multi_week_view ? week_view->weeks_shown * 7 : 7) <= week_view->selection_start_day) + e_week_view_set_selected_time_range (E_CALENDAR_VIEW (week_view), start_time, start_time); } @@ -1424,8 +1428,8 @@ e_week_view_set_selected_time_range (ECalendarView *cal_view, time_t start_time, time_t end_time) { - GDate date, base_date, end_date; - gint day_offset, weekday, week_start_offset, num_days; + GDate date, end_date; + gint num_days; gboolean update_adjustment_value = FALSE; EWeekView *week_view = E_WEEK_VIEW (cal_view); @@ -1433,63 +1437,9 @@ e_week_view_set_selected_time_range (ECalendarView *cal_view, time_to_gdate_with_zone (&date, start_time, e_calendar_view_get_timezone (E_CALENDAR_VIEW (week_view))); - if (week_view->multi_week_view) { - /* Find the number of days since the start of the month. */ - day_offset = g_date_day (&date) - 1; - - /* Find the 1st week which starts at or before the start of - the month. */ - base_date = date; - g_date_set_day (&base_date, 1); - - /* Calculate the weekday of the 1st of the month, 0 = Mon. */ - weekday = g_date_weekday (&base_date) - 1; - - /* Convert it to an offset from the start of the display. */ - week_start_offset = (weekday + 7 - week_view->display_start_day) % 7; - - /* Add it to the day offset so we go back to the 1st week at - or before the start of the month. */ - day_offset += week_start_offset; - } else { - /* Calculate the weekday of the given date, 0 = Mon. */ - weekday = g_date_weekday (&date) - 1; - - /* Convert it to an offset from the start of the display. */ - week_start_offset = (weekday + 7 - week_view->display_start_day) % 7; - - /* Set the day_offset to the result, so we move back to the - start of the week. */ - day_offset = week_start_offset; - } - - /* Calculate the base date, i.e. the first day shown when the - scrollbar adjustment value is 0. */ - base_date = date; - g_date_subtract_days (&base_date, day_offset); - - /* See if we need to update the base date. */ - if (!g_date_valid (&week_view->base_date) - || g_date_compare (&week_view->base_date, &base_date)) { - week_view->base_date = base_date; - update_adjustment_value = TRUE; - } - - /* See if we need to update the first day shown. */ - if (!g_date_valid (&week_view->first_day_shown) - || g_date_compare (&week_view->first_day_shown, &base_date)) { - week_view->first_day_shown = base_date; - start_time = time_add_day_with_zone (start_time, -day_offset, - e_calendar_view_get_timezone (E_CALENDAR_VIEW (week_view))); - start_time = time_day_begin_with_zone (start_time, - e_calendar_view_get_timezone (E_CALENDAR_VIEW (week_view))); - e_week_view_recalc_day_starts (week_view, start_time); - e_week_view_update_query (week_view); - } - /* Set the selection to the given days. */ week_view->selection_start_day = g_date_julian (&date) - - g_date_julian (&base_date); + - g_date_julian (&week_view->base_date); if (end_time == start_time || end_time <= time_add_day_with_zone (start_time, 1, e_calendar_view_get_timezone (E_CALENDAR_VIEW (week_view)))) @@ -1497,7 +1447,7 @@ e_week_view_set_selected_time_range (ECalendarView *cal_view, else { time_to_gdate_with_zone (&end_date, end_time - 60, e_calendar_view_get_timezone (E_CALENDAR_VIEW (week_view))); week_view->selection_end_day = g_date_julian (&end_date) - - g_date_julian (&base_date); + - g_date_julian (&week_view->base_date); } /* Make sure the selection is valid. */ @@ -2181,7 +2131,7 @@ e_week_view_on_button_press (GtkWidget *widget, return FALSE; if (event->button == 1 && event->type == GDK_2BUTTON_PRESS) { - e_calendar_view_new_appointment (E_CALENDAR_VIEW (week_view)); + e_calendar_view_new_appointment_full (E_CALENDAR_VIEW (week_view), TRUE, FALSE); return TRUE; } diff --git a/calendar/gui/gnome-cal.c b/calendar/gui/gnome-cal.c index d22c9ee6cb..617d01c11c 100644 --- a/calendar/gui/gnome-cal.c +++ b/calendar/gui/gnome-cal.c @@ -1369,7 +1369,7 @@ gnome_calendar_dayjump (GnomeCalendar *gcal, time_t time) priv->base_view_time = time_day_begin_with_zone (time, priv->zone); update_view_times (gcal, priv->base_view_time); - gnome_calendar_set_view (gcal, GNOME_CAL_DAY_VIEW, FALSE, TRUE); + gnome_calendar_set_view (gcal, GNOME_CAL_DAY_VIEW); } static void @@ -1412,22 +1412,67 @@ gnome_calendar_get_view (GnomeCalendar *gcal) return priv->current_view_type; } + +/** + * gnome_calendar_set_view: + * @gcal: A calendar. + * @view_type: Type of view to show. + * + * Sets the view that should be shown in a calendar. If @reset_range is true, + * this function will automatically set the number of days or weeks shown in + * the view; otherwise the last configuration will be kept. + **/ +void +gnome_calendar_set_view (GnomeCalendar *gcal, GnomeCalendarViewType view_type) +{ + GnomeCalendarPrivate *priv; + const char *view_id; + + g_return_if_fail (gcal != NULL); + g_return_if_fail (GNOME_IS_CALENDAR (gcal)); + + priv = gcal->priv; + + switch (view_type) { + case GNOME_CAL_DAY_VIEW: + view_id = "Day_View"; + break; + + case GNOME_CAL_WORK_WEEK_VIEW: + view_id = "Work_Week_View"; + break; + + case GNOME_CAL_WEEK_VIEW: + view_id = "Week_View"; + break; + + case GNOME_CAL_MONTH_VIEW: + view_id = "Month_View"; + break; + + case GNOME_CAL_LIST_VIEW: + view_id = "List_View"; + break; + + default: + g_assert_not_reached (); + return; + } + + gal_view_instance_set_current_view_id (priv->view_instance, view_id); +} + /* Sets the view without changing the selection or updating the date * navigator. If a range of dates isn't selected it will also reset the number * of days/weeks shown to the default (i.e. 1 day for the day view or 5 weeks * for the month view). */ static void -set_view (GnomeCalendar *gcal, GnomeCalendarViewType view_type, - gboolean range_selected, gboolean grab_focus) +display_view (GnomeCalendar *gcal, GnomeCalendarViewType view_type, + gboolean range_selected, gboolean grab_focus) { GnomeCalendarPrivate *priv; gboolean preserve_day; - const char *view_id; - static gboolean updating = FALSE; - - if (updating) - return; priv = gcal->priv; @@ -1435,26 +1480,20 @@ set_view (GnomeCalendar *gcal, GnomeCalendarViewType view_type, switch (view_type) { case GNOME_CAL_DAY_VIEW: - view_id = "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"; preserve_day = TRUE; break; case GNOME_CAL_WEEK_VIEW: - view_id = "Week_View"; preserve_day = TRUE; break; case GNOME_CAL_MONTH_VIEW: - view_id = "Month_View"; - if (!range_selected) e_week_view_set_weeks_shown (E_WEEK_VIEW (priv->month_view), 5); @@ -1462,7 +1501,6 @@ set_view (GnomeCalendar *gcal, GnomeCalendarViewType view_type, break; case GNOME_CAL_LIST_VIEW: - view_id = "List_View"; break; default: @@ -1473,22 +1511,7 @@ set_view (GnomeCalendar *gcal, GnomeCalendarViewType view_type, priv->current_view_type = view_type; priv->range_selected = range_selected; - calendar_config_set_default_view (view_type); - - updating = TRUE; gtk_notebook_set_page (GTK_NOTEBOOK (priv->notebook), (int) view_type); - if (priv->view_instance) { - char *current_id; - - /* If the list view is actually in "custom" mode, preserve that */ - current_id = gal_view_instance_get_current_view_id (priv->view_instance); - - if (current_id || view_type != GNOME_CAL_LIST_VIEW) - gal_view_instance_set_current_view_id (priv->view_instance, view_id); - - g_free (current_id); - } - updating = FALSE; if (grab_focus) focus_current_view (gcal); @@ -1503,31 +1526,6 @@ set_view (GnomeCalendar *gcal, GnomeCalendarViewType view_type, NULL); } -/** - * gnome_calendar_set_view: - * @gcal: A calendar. - * @view_type: Type of view to show. - * @range_selected: If false, the range of days/weeks shown will be reset to the - * default value (1 for day view, 5 for week view, respectively). If true, the - * currently displayed range will be kept. - * @grab_focus: Whether the view widget should grab the focus. - * - * Sets the view that should be shown in a calendar. If @reset_range is true, - * this function will automatically set the number of days or weeks shown in - * the view; otherwise the last configuration will be kept. - **/ -void -gnome_calendar_set_view (GnomeCalendar *gcal, GnomeCalendarViewType view_type, - gboolean range_selected, gboolean grab_focus) -{ - g_return_if_fail (gcal != NULL); - g_return_if_fail (GNOME_IS_CALENDAR (gcal)); - - set_view (gcal, view_type, range_selected, grab_focus); - gnome_calendar_update_date_navigator (gcal); - gnome_calendar_notify_dates_shown_changed (gcal); -} - /* Callback used when the view collection asks us to display a particular view */ static void display_view_cb (GalViewInstance *view_instance, GalView *view, gpointer data) @@ -1555,8 +1553,11 @@ display_view_cb (GalViewInstance *view_instance, GalView *view, gpointer data) g_error (G_STRLOC ": Unknown type of view for GnomeCalendar"); return; } + - gnome_calendar_set_view (gcal, view_type, FALSE, TRUE); + display_view (gcal, view_type, FALSE, TRUE); + gnome_calendar_update_date_navigator (gcal); + gnome_calendar_notify_dates_shown_changed (gcal); } /** @@ -1958,20 +1959,12 @@ GtkWidget * gnome_calendar_construct (GnomeCalendar *gcal) { GnomeCalendarPrivate *priv; - GnomeCalendarViewType view_type; g_return_val_if_fail (gcal != NULL, NULL); g_return_val_if_fail (GNOME_IS_CALENDAR (gcal), NULL); priv = gcal->priv; - /* Get the default view to show. */ - view_type = calendar_config_get_default_view (); - if (view_type < GNOME_CAL_DAY_VIEW || view_type > GNOME_CAL_LIST_VIEW) - view_type = GNOME_CAL_DAY_VIEW; - - gnome_calendar_set_view (gcal, view_type, FALSE, FALSE); - return GTK_WIDGET (gcal); } @@ -2353,7 +2346,6 @@ get_days_shown (GnomeCalendar *gcal, GDate *start_date, gint *days_shown) E_WEEK_VIEW (priv->month_view)) * 7; else *days_shown = 7; - break; case GNOME_CAL_LIST_VIEW: @@ -2393,7 +2385,7 @@ gnome_calendar_update_date_navigator (GnomeCalendar *gcal) end_date = start_date; g_date_add_days (&end_date, days_shown - 1); - + e_calendar_item_set_selection (priv->date_navigator->calitem, &start_date, &end_date); } @@ -2410,7 +2402,7 @@ gnome_calendar_on_date_navigator_selection_changed (ECalendarItem *calitem, Gnom struct icaltimetype tt; priv = gcal->priv; - + starts_on_week_start_day = FALSE; get_days_shown (gcal, &start_date, &days_shown); @@ -2464,7 +2456,7 @@ gnome_calendar_on_date_navigator_selection_changed (ECalendarItem *calitem, Gnom /* Make the views display things properly */ update_view_times (gcal, new_time); - set_view (gcal, view_type, TRUE, TRUE); + display_view (gcal, view_type, TRUE, TRUE); gnome_calendar_notify_dates_shown_changed (gcal); } diff --git a/calendar/gui/gnome-cal.h b/calendar/gui/gnome-cal.h index 3ea56b2068..edb9405b1f 100644 --- a/calendar/gui/gnome-cal.h +++ b/calendar/gui/gnome-cal.h @@ -121,8 +121,7 @@ void gnome_calendar_dayjump (GnomeCalendar *gcal, void gnome_calendar_goto_today (GnomeCalendar *gcal); GnomeCalendarViewType gnome_calendar_get_view (GnomeCalendar *gcal); -void gnome_calendar_set_view (GnomeCalendar *gcal, GnomeCalendarViewType view_type, - gboolean range_selected, gboolean grab_focus); +void gnome_calendar_set_view (GnomeCalendar *gcal, GnomeCalendarViewType view_type); GtkWidget *gnome_calendar_get_current_view_widget (GnomeCalendar *gcal); |