aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJP Rosevear <jpr@ximian.com>2002-09-07 05:40:38 +0800
committerJP Rosevear <jpr@src.gnome.org>2002-09-07 05:40:38 +0800
commite1a2491881b488a87dc2374ce459ead0b443ae84 (patch)
treeca8df6b91eca169edde395ebf7943553b2d4a575
parent9e0e4a3fbf5218ad2e764bd2816070a2eb94e91a (diff)
downloadgsoc2013-evolution-e1a2491881b488a87dc2374ce459ead0b443ae84.tar
gsoc2013-evolution-e1a2491881b488a87dc2374ce459ead0b443ae84.tar.gz
gsoc2013-evolution-e1a2491881b488a87dc2374ce459ead0b443ae84.tar.bz2
gsoc2013-evolution-e1a2491881b488a87dc2374ce459ead0b443ae84.tar.lz
gsoc2013-evolution-e1a2491881b488a87dc2374ce459ead0b443ae84.tar.xz
gsoc2013-evolution-e1a2491881b488a87dc2374ce459ead0b443ae84.tar.zst
gsoc2013-evolution-e1a2491881b488a87dc2374ce459ead0b443ae84.zip
kill warning
2002-09-06 JP Rosevear <jpr@ximian.com> * gui/gnome-cal.c (gnome_calendar_edit_object): kill warning * gui/e-week-view.h: new proto * gui/e-week-view.c (e_week_view_set_selected_time_range_visible): select a range of time in the currently visible area, if out side the visible area, select as much as possible (e_week_view_on_text_item_event): call above * gui/e-week-view-event-item.c (e_week_view_event_item_button_press): call above * gui/e-day-view.c (e_day_view_set_selected_time_range_in_top_visible): select a range of time in the currently visible area, if out side the visible area, select as much as possible (e_day_view_set_selected_time_range_visible): the same for the main canvas (e_day_view_on_long_event_button_press): call above (e_day_view_on_event_button_press): ditto svn path=/trunk/; revision=18010
-rw-r--r--calendar/ChangeLog23
-rw-r--r--calendar/gui/e-day-view.c88
-rw-r--r--calendar/gui/e-week-view-event-item.c2
-rw-r--r--calendar/gui/e-week-view.c41
-rw-r--r--calendar/gui/e-week-view.h4
-rw-r--r--calendar/gui/gnome-cal.c19
6 files changed, 143 insertions, 34 deletions
diff --git a/calendar/ChangeLog b/calendar/ChangeLog
index ad958f220c..001d5dd8bb 100644
--- a/calendar/ChangeLog
+++ b/calendar/ChangeLog
@@ -1,3 +1,26 @@
+2002-09-06 JP Rosevear <jpr@ximian.com>
+
+ * gui/gnome-cal.c (gnome_calendar_edit_object): kill warning
+
+ * gui/e-week-view.h: new proto
+
+ * gui/e-week-view.c (e_week_view_set_selected_time_range_visible):
+ select a range of time in the currently visible area, if out side
+ the visible area, select as much as possible
+ (e_week_view_on_text_item_event): call above
+
+ * gui/e-week-view-event-item.c
+ (e_week_view_event_item_button_press): call above
+
+ * gui/e-day-view.c
+ (e_day_view_set_selected_time_range_in_top_visible): select a
+ range of time in the currently visible area, if out side the
+ visible area, select as much as possible
+ (e_day_view_set_selected_time_range_visible): the same for the
+ main canvas
+ (e_day_view_on_long_event_button_press): call above
+ (e_day_view_on_event_button_press): ditto
+
2002-09-05 JP Rosevear <jpr@ximian.com>
* gui/itip-utils.c (itip_send_comp): don't try to send via the
diff --git a/calendar/gui/e-day-view.c b/calendar/gui/e-day-view.c
index 9965707db4..31b71e473c 100644
--- a/calendar/gui/e-day-view.c
+++ b/calendar/gui/e-day-view.c
@@ -2220,7 +2220,7 @@ e_day_view_set_selected_time_range (EDayView *day_view,
} else {
lower = e_day_view_find_work_week_start (day_view, start_time);
}
-
+
/* See if we need to change the days shown. */
if (lower != day_view->lower) {
e_day_view_recalc_day_starts (day_view, lower);
@@ -2272,32 +2272,15 @@ e_day_view_set_selected_time_range (EDayView *day_view,
}
static void
-e_day_view_set_selected_time_range_in_top (EDayView *day_view,
- time_t start_time,
- time_t end_time)
+e_day_view_set_selected_time_range_in_top_visible (EDayView *day_view,
+ time_t start_time,
+ time_t end_time)
{
- time_t lower;
gint start_row, start_col, end_row, end_col;
gboolean need_redraw = FALSE, start_in_grid, end_in_grid;
g_return_if_fail (E_IS_DAY_VIEW (day_view));
- /* Calculate the first day that should be shown, based on start_time
- and the days_shown setting. If we are showing 1 day it is just the
- start of the day given by start_time, otherwise it is the previous
- work-week start day. */
- if (!day_view->work_week_view) {
- lower = time_day_begin_with_zone (start_time, day_view->zone);
- } else {
- lower = e_day_view_find_work_week_start (day_view, start_time);
- }
-
- /* See if we need to change the days shown. */
- if (lower != day_view->lower) {
- e_day_view_recalc_day_starts (day_view, lower);
- update_query (day_view);
- }
-
/* Set the selection. */
start_in_grid = e_day_view_convert_time_to_grid_position (day_view,
start_time,
@@ -2308,6 +2291,11 @@ e_day_view_set_selected_time_range_in_top (EDayView *day_view,
&end_col,
&end_row);
+ if (!start_in_grid)
+ start_col = 0;
+ if (!end_in_grid)
+ end_col = day_view->days_shown - 1;
+
if (start_row != day_view->selection_start_row
|| start_col != day_view->selection_start_day) {
need_redraw = TRUE;
@@ -2330,6 +2318,60 @@ e_day_view_set_selected_time_range_in_top (EDayView *day_view,
}
}
+static void
+e_day_view_set_selected_time_range_visible (EDayView *day_view,
+ time_t start_time,
+ time_t end_time)
+{
+ gint start_row, start_col, end_row, end_col;
+ gboolean need_redraw = FALSE, start_in_grid, end_in_grid;
+
+ g_return_if_fail (E_IS_DAY_VIEW (day_view));
+
+ /* Set the selection. */
+ start_in_grid = e_day_view_convert_time_to_grid_position (day_view,
+ start_time,
+ &start_col,
+ &start_row);
+ end_in_grid = e_day_view_convert_time_to_grid_position (day_view,
+ end_time - 60,
+ &end_col,
+ &end_row);
+
+ /* If either of the times isn't in the grid, or the selection covers
+ an entire day, we set the selection to 1 row from the start of the
+ working day, in the day corresponding to the start time. */
+ if (!start_in_grid || !end_in_grid
+ || (start_row == 0 && end_row == day_view->rows - 1)) {
+ end_col = start_col;
+
+ start_row = e_day_view_convert_time_to_row (day_view, day_view->work_day_start_hour, day_view->work_day_start_minute);
+ start_row = CLAMP (start_row, 0, day_view->rows - 1);
+ end_row = start_row;
+ }
+
+ if (start_row != day_view->selection_start_row
+ || start_col != day_view->selection_start_day) {
+ need_redraw = TRUE;
+ day_view->selection_in_top_canvas = FALSE;
+ day_view->selection_start_row = start_row;
+ day_view->selection_start_day = start_col;
+ }
+
+ if (end_row != day_view->selection_end_row
+ || end_col != day_view->selection_end_day) {
+ need_redraw = TRUE;
+ day_view->selection_in_top_canvas = FALSE;
+ day_view->selection_end_row = end_row;
+ day_view->selection_end_day = end_col;
+ }
+
+ if (need_redraw) {
+ gtk_widget_queue_draw (day_view->top_canvas);
+ gtk_widget_queue_draw (day_view->main_canvas);
+ }
+}
+
/* Finds the start of the working week which includes the given time. */
static time_t
@@ -3269,7 +3311,7 @@ e_day_view_on_long_event_button_press (EDayView *day_view,
if (!destroyed) {
gtk_signal_disconnect (GTK_OBJECT (e->comp), id);
- e_day_view_set_selected_time_range_in_top (day_view, e->start, e->end);
+ e_day_view_set_selected_time_range_in_top_visible (day_view, e->start, e->end);
e_day_view_on_event_right_click (day_view, event,
E_DAY_VIEW_LONG_EVENT,
@@ -3321,7 +3363,7 @@ e_day_view_on_event_button_press (EDayView *day_view,
if (!destroyed) {
gtk_signal_disconnect (GTK_OBJECT (e->comp), id);
- e_day_view_set_selected_time_range (day_view, e->start, e->end);
+ e_day_view_set_selected_time_range_visible (day_view, e->start, e->end);
e_day_view_on_event_right_click (day_view, event,
day, event_num);
diff --git a/calendar/gui/e-week-view-event-item.c b/calendar/gui/e-week-view-event-item.c
index eb102a9b97..4006afb3f7 100644
--- a/calendar/gui/e-week-view-event-item.c
+++ b/calendar/gui/e-week-view-event-item.c
@@ -798,7 +798,7 @@ e_week_view_event_item_button_press (EWeekViewEventItem *wveitem,
if (!GTK_WIDGET_HAS_FOCUS (week_view))
gtk_widget_grab_focus (GTK_WIDGET (week_view));
- e_week_view_set_selected_time_range (week_view, event->start, event->end);
+ e_week_view_set_selected_time_range_visible (week_view, event->start, event->end);
e_week_view_show_popup_menu (week_view,
(GdkEventButton*) bevent,
diff --git a/calendar/gui/e-week-view.c b/calendar/gui/e-week-view.c
index dee9b03540..500701306e 100644
--- a/calendar/gui/e-week-view.c
+++ b/calendar/gui/e-week-view.c
@@ -1430,6 +1430,43 @@ e_week_view_set_selected_time_range (EWeekView *week_view,
gtk_widget_queue_draw (week_view->main_canvas);
}
+void
+e_week_view_set_selected_time_range_visible (EWeekView *week_view,
+ time_t start_time,
+ time_t end_time)
+{
+ GDate date, end_date;
+ gint num_days;
+
+ g_return_if_fail (E_IS_WEEK_VIEW (week_view));
+
+ time_to_gdate_with_zone (&date, start_time, week_view->zone);
+
+ /* Set the selection to the given days. */
+ week_view->selection_start_day = g_date_julian (&date)
+ - g_date_julian (&week_view->first_day_shown);
+ if (end_time == start_time
+ || end_time <= time_add_day_with_zone (start_time, 1,
+ week_view->zone))
+ week_view->selection_end_day = week_view->selection_start_day;
+ else {
+ time_to_gdate_with_zone (&end_date, end_time - 60, week_view->zone);
+ week_view->selection_end_day = g_date_julian (&end_date)
+ - g_date_julian (&week_view->first_day_shown);
+ }
+
+ /* Make sure the selection is valid. */
+ num_days = week_view->multi_week_view ? week_view->weeks_shown * 7 : 7;
+ num_days--;
+ week_view->selection_start_day = CLAMP (week_view->selection_start_day,
+ 0, num_days);
+ week_view->selection_end_day = CLAMP (week_view->selection_end_day,
+ week_view->selection_start_day,
+ num_days);
+
+ gtk_widget_queue_draw (week_view->main_canvas);
+}
+
/* Returns the selected time range. */
void
@@ -3055,8 +3092,8 @@ e_week_view_on_text_item_event (GnomeCanvasItem *item,
if (!destroyed) {
gtk_signal_disconnect (GTK_OBJECT (e->comp), id);
-
- e_week_view_set_selected_time_range (week_view, e->start, e->end);
+
+ e_week_view_set_selected_time_range_visible (week_view, e->start, e->end);
e_week_view_show_popup_menu (week_view,
(GdkEventButton*) gdkevent,
diff --git a/calendar/gui/e-week-view.h b/calendar/gui/e-week-view.h
index 689874cc25..696c8e6ac2 100644
--- a/calendar/gui/e-week-view.h
+++ b/calendar/gui/e-week-view.h
@@ -413,6 +413,10 @@ void e_week_view_set_selected_time_range (EWeekView *week_view,
time_t start_time,
time_t end_time);
+void e_week_view_set_selected_time_range_visible (EWeekView *week_view,
+ time_t start_time,
+ time_t end_time);
+
/* Gets the visible time range. Returns FALSE if no time range has been set. */
gboolean e_week_view_get_visible_time_range (EWeekView *week_view,
time_t *start_time,
diff --git a/calendar/gui/gnome-cal.c b/calendar/gui/gnome-cal.c
index bbc85bf983..cdcb323e4a 100644
--- a/calendar/gui/gnome-cal.c
+++ b/calendar/gui/gnome-cal.c
@@ -2182,7 +2182,7 @@ gnome_calendar_edit_object (GnomeCalendar *gcal, CalComponent *comp,
gboolean meeting)
{
GnomeCalendarPrivate *priv;
- EventEditor *ee;
+ CompEditor *ce;
const char *uid;
g_return_if_fail (gcal != NULL);
@@ -2193,23 +2193,26 @@ gnome_calendar_edit_object (GnomeCalendar *gcal, CalComponent *comp,
cal_component_get_uid (comp, &uid);
- ee = EVENT_EDITOR (e_comp_editor_registry_find (comp_editor_registry, uid));
- if (!ee) {
+ ce = e_comp_editor_registry_find (comp_editor_registry, uid);
+ if (!ce) {
+ EventEditor *ee;
+
ee = event_editor_new ();
if (!ee) {
g_message ("gnome_calendar_edit_object(): Could not create the event editor");
return;
}
-
- comp_editor_set_cal_client (COMP_EDITOR (ee), priv->client);
- comp_editor_edit_comp (COMP_EDITOR (ee), comp);
+ ce = COMP_EDITOR (ee);
+
+ comp_editor_set_cal_client (ce, priv->client);
+ comp_editor_edit_comp (ce, comp);
if (meeting)
event_editor_show_meeting (ee);
- e_comp_editor_registry_add (comp_editor_registry, COMP_EDITOR (ee), FALSE);
+ e_comp_editor_registry_add (comp_editor_registry, ce, FALSE);
}
- comp_editor_focus (COMP_EDITOR (ee));
+ comp_editor_focus (ce);
}
/**