[evolution-patches] [Fwd: Re: [Evolution-hackers] Marcus Bains Line in calendar]




-- 
Philip Van Hoof, Software Developer @ Cronos
home: me at freax dot org
gnome: pvanhoof at gnome dot org
work: philip dot vanhoof at cronos dot be
junk: philip dot vanhoof at gmail dot com
http://www.freax.be, http://www.freax.eu.org
--- Begin Message --- On Fri, 2005-03-04 at 11:06 +0100, Anders Näslund wrote:
YES, finally! Have ben waiting for that to come. Unfortunately I'm not
programmer enough to make it happen and not frustrated enough to file a
bug...but it's very welcome addition to the calendar.

Please let that make it into main release!

tor 2005-03-03 klockan 21:45 -0500 skrev Thouis (Ray) Jones:
> I've modified evolution calendar to have a Marcus Bains Line 
> http://people.csail.mit.edu/u/r/rahimi/public_html/marcus-bains-line/
> 
> It looks like this:
> http://people.csail.mit.edu/u/t/thouis/public_html/gnome-mb.png

I have upgraded this patch to HEAD. Check attachment.


-- 
Philip Van Hoof, Software Developer @ Cronos
home: me at freax dot org
gnome: pvanhoof at gnome dot org
work: philip dot vanhoof at cronos dot be
junk: philip dot vanhoof at gmail dot com
http://www.freax.be, http://www.freax.eu.org
Index: calendar/gui/calendar-config-keys.h
===================================================================
RCS file: /cvs/gnome/evolution/calendar/gui/calendar-config-keys.h,v
retrieving revision 1.6
diff -u -r1.6 calendar-config-keys.h
--- calendar/gui/calendar-config-keys.h	18 Dec 2004 13:01:17 -0000	1.6
+++ calendar/gui/calendar-config-keys.h	4 Mar 2005 10:53:54 -0000
@@ -39,6 +39,7 @@
 #define CALENDAR_CONFIG_DAY_END_MINUTE CALENDAR_CONFIG_PREFIX "/display/day_end_minute"
 #define CALENDAR_CONFIG_TIME_DIVISIONS CALENDAR_CONFIG_PREFIX "/display/time_divisions"
 #define CALENDAR_CONFIG_TIME_DIVISIONS CALENDAR_CONFIG_PREFIX "/display/time_divisions"
+#define CALENDAR_CONFIG_SHOW_MARCUS_BAINS_LINE CALENDAR_CONFIG_PREFIX "/display/show_marcus_bains_line"
 #define CALENDAR_CONFIG_DEFAULT_VIEW CALENDAR_CONFIG_PREFIX "/display/default_view"
 #define CALENDAR_CONFIG_HPANE_POS CALENDAR_CONFIG_PREFIX "/display/hpane_position"
 #define CALENDAR_CONFIG_VPANE_POS CALENDAR_CONFIG_PREFIX "/display/vpane_position"
Index: calendar/gui/calendar-config.c
===================================================================
RCS file: /cvs/gnome/evolution/calendar/gui/calendar-config.c,v
retrieving revision 1.72
diff -u -r1.72 calendar-config.c
--- calendar/gui/calendar-config.c	31 Dec 2004 16:59:18 -0000	1.72
+++ calendar/gui/calendar-config.c	4 Mar 2005 10:53:54 -0000
@@ -444,6 +444,30 @@
 	return id;
 }
 
+/* Whehter we show the Marcus Bains Line (current time) */
+gint
+calendar_config_get_show_marcus_bains_line	(void)
+{
+	return gconf_client_get_int (config, CALENDAR_CONFIG_SHOW_MARCUS_BAINS_LINE, NULL);
+}
+
+
+void
+calendar_config_set_show_marcus_bains_line	(gint	      divisions)
+{
+	gconf_client_set_int (config, CALENDAR_CONFIG_SHOW_MARCUS_BAINS_LINE, divisions, NULL);
+}
+
+guint
+calendar_config_add_notification_show_marcus_bains_line (GConfClientNotifyFunc func, gpointer data)
+{
+	guint id;
+	
+	id = gconf_client_notify_add (config, CALENDAR_CONFIG_SHOW_MARCUS_BAINS_LINE, func, data, NULL, NULL);
+	
+	return id;
+}
+
 /* Whether we show week numbers in the Date Navigator. */
 gboolean
 calendar_config_get_dnav_show_week_no	(void)
Index: calendar/gui/calendar-config.h
===================================================================
RCS file: /cvs/gnome/evolution/calendar/gui/calendar-config.h,v
retrieving revision 1.36
diff -u -r1.36 calendar-config.h
--- calendar/gui/calendar-config.h	31 Dec 2004 16:59:18 -0000	1.36
+++ calendar/gui/calendar-config.h	4 Mar 2005 10:53:55 -0000
@@ -117,6 +117,11 @@
 void	  calendar_config_set_time_divisions	(gint	      divisions);
 guint calendar_config_add_notification_time_divisions (GConfClientNotifyFunc func, gpointer data);
 
+/* Whether we show the Marcus Bains Line. */
+gboolean  calendar_config_get_show_marcus_bains_line	(void);
+void	  calendar_config_set_show_marcus_bains_line	(gboolean     show_end);
+guint calendar_config_add_notification_show_marcus_bains_line (GConfClientNotifyFunc func, gpointer data);
+
 /* Whether we show event end times. */
 gboolean  calendar_config_get_show_event_end	(void);
 void	  calendar_config_set_show_event_end	(gboolean     show_end);
Index: calendar/gui/e-day-view-config.c
===================================================================
RCS file: /cvs/gnome/evolution/calendar/gui/e-day-view-config.c,v
retrieving revision 1.7
diff -u -r1.7 e-day-view-config.c
--- calendar/gui/e-day-view-config.c	2 Nov 2004 19:25:47 -0000	1.7
+++ calendar/gui/e-day-view-config.c	4 Mar 2005 10:53:55 -0000
@@ -355,6 +355,27 @@
 }
 
 static void
+set_show_marcus_bains_line (EDayView *day_view) 
+{
+	gboolean show_marcus_bains_line;
+
+	show_marcus_bains_line = calendar_config_get_show_marcus_bains_line ();
+
+	e_day_view_set_show_marcus_bains_line (day_view, show_marcus_bains_line);
+}
+
+static void
+show_marcus_bains_line_changed_cb (GConfClient *client, guint id, GConfEntry *entry, gpointer data)
+{
+	EDayViewConfig *view_config = data;
+	EDayViewConfigPrivate *priv;
+	
+	priv = view_config->priv;
+	
+	set_show_marcus_bains_line (priv->view);
+}
+
+static void
 set_show_event_end (EDayView *day_view) 
 {
 	gboolean show_event_end;
@@ -457,6 +478,13 @@
 
 	not = calendar_config_add_notification_time_divisions (time_divisions_changed_cb, view_config);
 	priv->notifications = g_list_prepend (priv->notifications, GUINT_TO_POINTER (not));
+
+	/* Showing Marcus Bains Line */
+	set_show_marcus_bains_line(day_view);
+
+	not = calendar_config_add_notification_show_marcus_bains_line (show_marcus_bains_line_changed_cb, view_config);
+	priv->notifications = g_list_prepend (priv->notifications, GUINT_TO_POINTER (not));
+
 
 	/* Showing event end */
 	set_show_event_end (day_view);
Index: calendar/gui/e-day-view-main-item.c
===================================================================
RCS file: /cvs/gnome/evolution/calendar/gui/e-day-view-main-item.c,v
retrieving revision 1.40
diff -u -r1.40 e-day-view-main-item.c
--- calendar/gui/e-day-view-main-item.c	8 Jan 2005 10:53:52 -0000	1.40
+++ calendar/gui/e-day-view-main-item.c	4 Mar 2005 10:53:56 -0000
@@ -299,6 +299,42 @@
 						      x, y, width, height,
 						      day);
 	}
+
+
+	grid_x1 = day_view->day_offsets[0] - x;
+	grid_x2 = day_view->day_offsets[day_view->days_shown] - x;
+
+	if (e_day_view_get_show_marcus_bains_line(day_view)) {
+		struct tm ltime, day_start = { 0 };
+		time_t time_now;
+		int marcus_bains_y;
+
+		time(&time_now);
+		localtime_r(&time_now, &ltime);
+		
+		for (day = 0; day < day_view->days_shown; day++) {
+			day_start_tt = icaltime_from_timet_with_zone (day_view->day_starts[day], FALSE,
+								      e_calendar_view_get_timezone (E_CALENDAR_VIEW (day_view)));
+			day_start.tm_year = day_start_tt.year - 1900;
+			day_start.tm_mon = day_start_tt.month - 1;
+			day_start.tm_mday = day_start_tt.day;
+			day_start.tm_isdst = -1;
+
+			if ((day_start.tm_year == ltime.tm_year) &&
+			    (day_start.tm_mon == ltime.tm_mon) &&
+			    (day_start.tm_mday == ltime.tm_mday)) {
+
+				grid_x1 = day_view->day_offsets[day] - x + E_DAY_VIEW_BAR_WIDTH;
+				grid_x2 = day_view->day_offsets[day + 1] - x;
+				marcus_bains_y = (ltime.tm_hour * 60 + ltime.tm_min) * day_view->row_height / day_view->mins_per_row - y;
+				
+				gdk_gc_set_foreground (gc, &day_view->colors[E_DAY_VIEW_COLOR_MARCUS_BAINS_LINE]);
+				gdk_draw_line(drawable, gc, grid_x1, marcus_bains_y, grid_x2, marcus_bains_y);
+			}
+		}
+	}
+
+
 }
 
 
Index: calendar/gui/e-day-view-time-item.c
===================================================================
RCS file: /cvs/gnome/evolution/calendar/gui/e-day-view-time-item.c,v
retrieving revision 1.29
diff -u -r1.29 e-day-view-time-item.c
--- calendar/gui/e-day-view-time-item.c	14 Oct 2004 14:44:41 -0000	1.29
+++ calendar/gui/e-day-view-time-item.c	4 Mar 2005 10:53:57 -0000
@@ -40,6 +40,8 @@
 #include <gal/widgets/e-gui-utils.h>
 #include "e-day-view-time-item.h"
 #include "calendar-config.h"
+#include <time.h>
+
 
 
 /* The spacing between items in the time column. GRID_X_PAD is the space down
@@ -331,6 +333,19 @@
 			    pango_font_metrics_get_descent (large_font_metrics)) / PANGO_SCALE +
 			   E_DVTMI_LARGE_HOUR_Y_PAD);
 
+	if (e_day_view_get_show_marcus_bains_line(day_view)) {
+		struct tm ltime;
+		time_t time_now;
+		int marcus_bains_y;
+	
+		time(&time_now);
+		localtime_r(&time_now, &ltime);
+		marcus_bains_y = (ltime.tm_hour * 60 + ltime.tm_min) * day_view->row_height / day_view->mins_per_row - y;
+		gdk_draw_line (drawable, style->white_gc,
+				long_line_x1, marcus_bains_y,
+				long_line_x2, marcus_bains_y);
+	}
+
 	/* Step through each row, drawing the times and the horizontal lines
 	   between them. */
 	for (row = 0, row_y = 0 - y;
@@ -614,6 +629,12 @@
 	dvtmitem->dragging_selection = FALSE;
 }
 
+void
+e_day_view_update_marcus_bains(EDayView *day_view)
+{
+	gtk_widget_queue_draw(day_view->main_canvas);
+	gtk_widget_queue_draw(day_view->time_canvas);
+}
 
 static void
 e_day_view_time_item_on_motion_notify (EDayViewTimeItem *dvtmitem,
Index: calendar/gui/e-day-view.c
===================================================================
RCS file: /cvs/gnome/evolution/calendar/gui/e-day-view.c,v
retrieving revision 1.268
diff -u -r1.268 e-day-view.c
--- calendar/gui/e-day-view.c	4 Feb 2005 11:22:52 -0000	1.268
+++ calendar/gui/e-day-view.c	4 Mar 2005 10:54:05 -0000
@@ -1161,6 +1161,11 @@
 	day_view->colors[E_DAY_VIEW_COLOR_EVENT_BORDER] = widget->style->dark[GTK_STATE_NORMAL];
 	day_view->colors[E_DAY_VIEW_COLOR_LONG_EVENT_BACKGROUND] = widget->style->bg[GTK_STATE_ACTIVE];
 	day_view->colors[E_DAY_VIEW_COLOR_LONG_EVENT_BORDER] = widget->style->dark[GTK_STATE_NORMAL];
+
+	/* Shouldn't this use some standard GTK colors? */
+	day_view->colors[E_DAY_VIEW_COLOR_MARCUS_BAINS_LINE].red   = 65535;
+	day_view->colors[E_DAY_VIEW_COLOR_MARCUS_BAINS_LINE].green = 0;
+	day_view->colors[E_DAY_VIEW_COLOR_MARCUS_BAINS_LINE].blue  = 0;
 }
 
 static void
@@ -2467,6 +2472,28 @@
 
 	gtk_widget_queue_draw (day_view->main_canvas);
 }
+
+
+/* Whether we display the Marcus Bains Line in the main canvas and time canvas. */
+gboolean
+e_day_view_get_show_marcus_bains_line	(EDayView       *day_view)
+{
+	g_return_val_if_fail (E_IS_DAY_VIEW (day_view), TRUE);
+	return day_view->show_marcus_bains_line;
+}
+
+void
+e_day_view_set_show_marcus_bains_line	(EDayView       *day_view,
+					 gboolean        show)
+{
+	g_return_if_fail (E_IS_DAY_VIEW (day_view));
+
+	if (day_view->show_marcus_bains_line != show) {
+		day_view->show_marcus_bains_line = show;
+		e_day_view_update_marcus_bains(day_view);
+	}
+}
+
 
 /* Whether we display event end times in the main canvas. */
 gboolean
Index: calendar/gui/e-day-view.h
===================================================================
RCS file: /cvs/gnome/evolution/calendar/gui/e-day-view.h,v
retrieving revision 1.63
diff -u -r1.63 e-day-view.h
--- calendar/gui/e-day-view.h	8 Jan 2005 10:53:53 -0000	1.63
+++ calendar/gui/e-day-view.h	4 Mar 2005 10:54:05 -0000
@@ -153,6 +153,8 @@
 	E_DAY_VIEW_COLOR_LONG_EVENT_BACKGROUND,
 	E_DAY_VIEW_COLOR_LONG_EVENT_BORDER,
 
+	E_DAY_VIEW_COLOR_MARCUS_BAINS_LINE,
+
 	E_DAY_VIEW_COLOR_LAST
 } EDayViewColors;
 
@@ -278,6 +280,9 @@
 	gint work_day_end_hour;
 	gint work_day_end_minute;
 
+	/* Whether we show the Marcus Bains Line in the main canvas and time canvas. */
+	gboolean show_marcus_bains_line;
+
 	/* Whether we use show event end times in the main canvas. */
 	gboolean show_event_end_times;
 
@@ -493,6 +498,11 @@
 						 gint		 end_hour,
 						 gint		 end_minute);
 
+/* Whether we display the Marcus Bains Line in the main canvas and time canvas. */
+gboolean   e_day_view_get_show_marcus_bains_line	(EDayView	*day_view);
+void	   e_day_view_set_show_marcus_bains_line	(EDayView	*day_view,
+							 gboolean	 show);
+
 /* Whether we display event end times in the main canvas. */
 gboolean   e_day_view_get_show_event_end_times	(EDayView	*day_view);
 void	   e_day_view_set_show_event_end_times	(EDayView	*day_view,
@@ -572,6 +582,8 @@
 				     gint start_row,
 				     gint end_row);
 
+
+void e_day_view_update_marcus_bains(EDayView *day_view);
 
 G_END_DECLS
 
Index: calendar/gui/gnome-cal.c
===================================================================
RCS file: /cvs/gnome/evolution/calendar/gui/gnome-cal.c,v
retrieving revision 1.368
diff -u -r1.368 gnome-cal.c
--- calendar/gui/gnome-cal.c	28 Feb 2005 22:12:30 -0000	1.368
+++ calendar/gui/gnome-cal.c	4 Mar 2005 10:54:09 -0000
@@ -138,6 +138,7 @@
 	char        *sexp;
 	char        *todo_sexp;
 	guint        update_timeout;
+	guint        update_marcus_bains_line_timeout;
 	
 	/* This is the view currently shown. We use it to keep track of the
 	   positions of the panes. range_selected is TRUE if a range of dates
@@ -1080,6 +1081,21 @@
 	return TRUE;
 }
 
+static gboolean
+update_marcus_bains_line_cb (GnomeCalendar *gcal)
+{	
+	GnomeCalendarPrivate *priv;
+
+	priv = gcal->priv;
+
+	if ((priv->current_view_type == GNOME_CAL_DAY_VIEW) ||
+	    (priv->current_view_type == GNOME_CAL_WORK_WEEK_VIEW)) {
+		e_day_view_update_marcus_bains(E_DAY_VIEW (gnome_calendar_get_current_view_widget(gcal)));
+	}
+
+	return TRUE;
+}
+
 static void
 config_hide_completed_tasks_changed_cb (GConfClient *client, guint id, GConfEntry *entry, gpointer data)
 {
@@ -1312,6 +1328,9 @@
 	e_calendar_view_set_timezone (E_CALENDAR_VIEW (priv->work_week_view), priv->zone);
 	connect_day_view_focus (gcal, E_DAY_VIEW (priv->work_week_view));
 
+	/* The Marcus Bains line */
+	priv->update_marcus_bains_line_timeout = g_timeout_add_full (G_PRIORITY_LOW, 60000, (GSourceFunc) update_marcus_bains_line_cb, gcal, NULL);	
+
 	/* The Week View. */
 	priv->week_view = e_week_view_new ();
 	e_calendar_view_set_calendar (E_CALENDAR_VIEW (priv->week_view), gcal);
@@ -1510,6 +1529,11 @@
 		if (priv->view_instance) {
 			g_object_unref (priv->view_instance);
 			priv->view_instance = NULL;
+		}
+
+		if (priv->update_marcus_bains_line_timeout) {
+			g_source_remove (priv->update_marcus_bains_line_timeout);
+			priv->update_marcus_bains_line_timeout = 0;
 		}
 
 		if (priv->view_menus) {
Index: calendar/gui/dialogs/cal-prefs-dialog.c
===================================================================
RCS file: /cvs/gnome/evolution/calendar/gui/dialogs/cal-prefs-dialog.c,v
retrieving revision 1.41
diff -u -r1.41 cal-prefs-dialog.c
--- calendar/gui/dialogs/cal-prefs-dialog.c	31 Dec 2004 16:59:18 -0000	1.41
+++ calendar/gui/dialogs/cal-prefs-dialog.c	4 Mar 2005 10:54:10 -0000
@@ -263,6 +263,12 @@
 }
 
 static void
+show_marcus_bains_line_toggled (GtkToggleButton *toggle, DialogData *dialog_data)
+{
+	calendar_config_set_show_marcus_bains_line (gtk_toggle_button_get_active (toggle));
+}
+
+static void
 compress_weekend_toggled (GtkToggleButton *toggle, DialogData *dialog_data)
 {
 	calendar_config_set_compress_weekend (gtk_toggle_button_get_active (toggle));
@@ -397,6 +403,8 @@
 	g_signal_connect (GTK_OPTION_MENU (dialog_data->time_divisions)->menu, "selection-done",
 			  G_CALLBACK (time_divisions_changed), dialog_data);
 	
+	g_signal_connect (dialog_data->show_marcus_bains_line, "toggled", G_CALLBACK (show_marcus_bains_line_toggled), dialog_data);
+
 	g_signal_connect (dialog_data->show_end_times, "toggled", G_CALLBACK (show_end_times_toggled), dialog_data);
 	g_signal_connect (dialog_data->compress_weekend, "toggled", G_CALLBACK (compress_weekend_toggled), dialog_data);
 	g_signal_connect (dialog_data->dnav_show_week_no, "toggled", G_CALLBACK (dnav_show_week_no_toggled), dialog_data);
@@ -449,6 +457,7 @@
 	data->use_12_hour = GW ("use_12_hour");
 	data->use_24_hour = GW ("use_24_hour");
 	data->time_divisions = GW ("time_divisions");
+	data->show_marcus_bains_line = GW ("show_marcus_bains_line");
 	data->show_end_times = GW ("show_end_times");
 	data->compress_weekend = GW ("compress_weekend");
 	data->dnav_show_week_no = GW ("dnav_show_week_no");
@@ -490,6 +499,7 @@
 		&& data->use_12_hour
 		&& data->use_24_hour
 		&& data->time_divisions
+		&& data->show_marcus_bains_line
 		&& data->show_end_times
 		&& data->compress_weekend
 		&& data->dnav_show_week_no
@@ -1010,6 +1020,9 @@
 	time_divisions = calendar_config_get_time_divisions ();
 	e_dialog_option_menu_set (dialog_data->time_divisions, time_divisions,
 				  time_division_map);
+
+	/* Show Marcus Bains Line. */
+	e_dialog_toggle_set (dialog_data->show_marcus_bains_line, calendar_config_get_show_marcus_bains_line ());
 
 	/* Show Appointment End Times. */
 	e_dialog_toggle_set (dialog_data->show_end_times, calendar_config_get_show_event_end ());
Index: calendar/gui/dialogs/cal-prefs-dialog.glade
===================================================================
RCS file: /cvs/gnome/evolution/calendar/gui/dialogs/cal-prefs-dialog.glade,v
retrieving revision 1.31
diff -u -r1.31 cal-prefs-dialog.glade
--- calendar/gui/dialogs/cal-prefs-dialog.glade	26 Jan 2005 11:48:21 -0000	1.31
+++ calendar/gui/dialogs/cal-prefs-dialog.glade	4 Mar 2005 10:54:13 -0000
@@ -1176,6 +1176,25 @@
 		      </child>
 
 		      <child>
+			<widget class="GtkCheckButton" id="show_marcus_bains_line">
+			  <property name="visible">True</property>
+			  <property name="can_focus">True</property>
+			  <property name="label" translatable="yes">Show Marcus Bains Line (current time) on calendar</property>
+			  <property name="use_underline">True</property>
+			  <property name="relief">GTK_RELIEF_NORMAL</property>
+			  <property name="focus_on_click">True</property>
+			  <property name="active">True</property>
+			  <property name="inconsistent">False</property>
+			  <property name="draw_indicator">True</property>
+			</widget>
+			<packing>
+			  <property name="padding">0</property>
+			  <property name="expand">False</property>
+			  <property name="fill">False</property>
+			</packing>
+		      </child>
+
+		      <child>
 			<widget class="GtkCheckButton" id="show_end_times">
 			  <property name="visible">True</property>
 			  <property name="can_focus">True</property>
Index: calendar/gui/dialogs/cal-prefs-dialog.h
===================================================================
RCS file: /cvs/gnome/evolution/calendar/gui/dialogs/cal-prefs-dialog.h,v
retrieving revision 1.11
diff -u -r1.11 cal-prefs-dialog.h
--- calendar/gui/dialogs/cal-prefs-dialog.h	18 Dec 2004 13:01:17 -0000	1.11
+++ calendar/gui/dialogs/cal-prefs-dialog.h	4 Mar 2005 10:54:13 -0000
@@ -62,6 +62,7 @@
 	GtkWidget *use_12_hour;
 	GtkWidget *use_24_hour;
 	GtkWidget *time_divisions;
+	GtkWidget *show_marcus_bains_line;
 	GtkWidget *show_end_times;
 	GtkWidget *compress_weekend;
 	GtkWidget *dnav_show_week_no;

--- End Message ---


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]