? .clock.c.swp
Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/gnome-panel/applets/clock/ChangeLog,v
retrieving revision 1.483
diff -u -p -u -r1.483 ChangeLog
--- ChangeLog	15 Sep 2003 22:11:42 -0000	1.483
+++ ChangeLog	16 Sep 2003 10:42:00 -0000
@@ -1,3 +1,9 @@
+2003-09-16  Robin Ericsson  <robin.ericsson@profecta.se>
+
+	* clock.c, clock.schemas.in: Added 2 new options. Display
+	  weeknumber in calendar, and let calendar weeks start on
+	  monday.
+
 Mon Sep 15 15:09:46 2003  George Lebl <jirka@5z.com>
 
 	* clock.c: when started with the locked_down flag, hide the
Index: clock.c
===================================================================
RCS file: /cvs/gnome/gnome-panel/applets/clock/clock.c,v
retrieving revision 1.114
diff -u -p -u -r1.114 clock.c
--- clock.c	15 Sep 2003 22:11:42 -0000	1.114
+++ clock.c	16 Sep 2003 10:42:00 -0000
@@ -53,13 +53,15 @@
 #define INTERNETSECOND (864)
 #define INTERNETBEAT   (86400)
 
-#define N_GCONF_PREFS 7
+#define N_GCONF_PREFS 9
 
 #define NEVER_SENSITIVE "never_sensitive"
 
 static const char* KEY_HOUR_FORMAT   = "hour_format";
 static const char* KEY_SHOW_SECONDS  = "show_seconds";
 static const char* KEY_SHOW_DATE     = "show_date";
+static const char* KEY_SHOW_WEEKS    = "show_weeks";
+static const char* KEY_WEEK_MONDAY   = "week_start_monday";
 static const char* KEY_GMT_TIME      = "gmt_time";
 static const char* KEY_UNIX_TIME     = "unix_time";
 static const char* KEY_INTERNET_TIME = "internet_time";
@@ -79,6 +81,8 @@ struct _ClockData {
 	int hourformat;
 	gboolean showseconds;
 	gboolean showdate;
+	gboolean showweeks;
+	gboolean weekmonday;
 	gboolean unixtime;
 	gboolean internettime;
 	gboolean gmt_time;
@@ -456,12 +460,29 @@ delete_event (GtkWidget   *widget,
 	return TRUE;
 }
 
+static GtkCalendarDisplayOptions
+calendar_display_options (ClockData *cd)
+{
+	GtkCalendarDisplayOptions options = GTK_CALENDAR_SHOW_HEADING;
+
+	if (cd->showweeks) {
+		options |= GTK_CALENDAR_SHOW_WEEK_NUMBERS;
+	}
+
+	if (cd->weekmonday) {
+		options |= GTK_CALENDAR_WEEK_START_MONDAY;
+	}
+
+	return options;
+}
+
 static GtkWidget *
 create_calendar (ClockData *cd,
 		 GdkScreen *screen)
 {
 	GtkWindow *window;
 	GtkWidget *calendar;
+	GtkCalendarDisplayOptions options;
 
 	window = GTK_WINDOW (gtk_window_new (GTK_WINDOW_TOPLEVEL));
 
@@ -479,7 +500,12 @@ create_calendar (ClockData *cd,
 			
 	calendar = gtk_calendar_new ();
 
+	options = calendar_display_options(cd);	
+	gtk_calendar_display_options (GTK_CALENDAR (calendar), options);
+
 	gtk_container_add (GTK_CONTAINER (window), calendar);
+	g_object_set_data_full (G_OBJECT (window), "calendar",
+				calendar, NULL);
 
 	gtk_widget_show (calendar);
 
@@ -487,6 +513,27 @@ create_calendar (ClockData *cd,
 }
 
 static void
+refresh_calendar (ClockData *cd)
+{
+	GtkWidget *window;
+	GtkWidget *button;
+	GtkWidget *calendar;
+
+	button = cd->toggle;
+	window = g_object_get_data (G_OBJECT (button), "calendar");
+
+	if (window) {
+		calendar = g_object_get_data (G_OBJECT (window), "calendar");
+		
+		if (calendar) {
+			GtkCalendarDisplayOptions options = calendar_display_options(cd);
+
+			gtk_calendar_display_options (GTK_CALENDAR (calendar), options);
+		}
+	}
+}
+
+static void
 present_calendar_popup (ClockData *cd,
 			GtkWidget *window,
 			GtkWidget *button)
@@ -968,6 +1015,40 @@ show_date_changed (GConfClient  *client,
 }
 
 static void
+show_weeks_changed (GConfClient  *client,
+                    guint         cnxn_id,
+                    GConfEntry   *entry,
+                    ClockData    *clock)
+{
+	gboolean value;
+
+	if (!entry->value || entry->value->type != GCONF_VALUE_BOOL)
+		return;
+
+	value = gconf_value_get_bool (entry->value);
+
+	clock->showweeks = (value != 0);
+	refresh_calendar (clock);
+}
+
+static void
+show_week_monday_changed (GConfClient  *client,
+                         guint         cnxn_id,
+                         GConfEntry   *entry,
+                         ClockData    *clock)
+{
+	gboolean value;
+
+	if (!entry->value || entry->value->type != GCONF_VALUE_BOOL)
+		return;
+
+	value = gconf_value_get_bool (entry->value);
+
+	clock->weekmonday = (value != 0);
+	refresh_calendar (clock);
+}
+
+static void
 internet_time_changed (GConfClient *client,
                        guint        cnxn_id,
                        GConfEntry  *entry,
@@ -1106,6 +1187,24 @@ setup_gconf (ClockData *clock)
 				clock, NULL, NULL);
 	g_free (key);
 
+	key = panel_applet_gconf_get_full_key (PANEL_APPLET (clock->applet),
+					       KEY_SHOW_WEEKS);	
+	clock->listeners [7] =
+		gconf_client_notify_add (
+				client, key,
+				(GConfClientNotifyFunc) show_weeks_changed,
+				clock, NULL, NULL);
+	g_free (key);
+
+	key = panel_applet_gconf_get_full_key (PANEL_APPLET (clock->applet),
+					       KEY_WEEK_MONDAY);
+	clock->listeners [8] =
+		gconf_client_notify_add (
+				client, key,
+				(GConfClientNotifyFunc) show_week_monday_changed,
+				clock, NULL, NULL);
+	g_free (key);
+
 	g_object_unref (G_OBJECT (client));
 }
 
@@ -1150,6 +1249,7 @@ fill_clock_applet (PanelApplet *applet)
 			cd->showdate = TRUE;
 	}
 
+	cd->showweeks = panel_applet_gconf_get_bool (applet, KEY_SHOW_WEEKS, NULL);
 	cd->gmt_time = panel_applet_gconf_get_bool (applet, KEY_GMT_TIME, NULL);
 	cd->unixtime = panel_applet_gconf_get_bool (applet, KEY_UNIX_TIME, NULL);
 	cd->internettime = panel_applet_gconf_get_bool (applet, KEY_INTERNET_TIME, NULL);
@@ -1293,6 +1393,26 @@ set_show_date_cb (GtkWidget *w,
 }
 
 static void
+set_show_weeks_cb (GtkWidget *w,
+		   ClockData *clock)
+{
+	panel_applet_gconf_set_bool (PANEL_APPLET (clock->applet),
+				     KEY_SHOW_WEEKS,
+				     GTK_TOGGLE_BUTTON (w)->active,
+				     NULL);
+}
+
+static void
+set_week_monday_cb (GtkWidget *w,
+                    ClockData *clock)
+{
+	panel_applet_gconf_set_bool (PANEL_APPLET (clock->applet),
+				     KEY_WEEK_MONDAY,
+				     GTK_TOGGLE_BUTTON (w)->active,
+				     NULL);
+}
+
+static void
 set_internettime_cb (GtkWidget *w,
 		     ClockData *clock)
 {
@@ -1379,6 +1499,8 @@ display_properties_dialog (BonoboUICompo
 	GtkWidget *twentyfourhour;
 	GtkWidget *showseconds;
 	GtkWidget *showdate;
+	GtkWidget *showweeks;
+	GtkWidget *weekmonday;
 	GtkWidget *unixtime;
 	GtkWidget *internettime;
 	GtkWidget *use_gmt_time;
@@ -1495,6 +1617,24 @@ display_properties_dialog (BonoboUICompo
 			  G_CALLBACK (set_show_date_cb),
 			  cd);
   	gtk_widget_show (showdate);
+
+	showweeks = gtk_check_button_new_with_mnemonic (_("Show _weeks"));
+	gtk_box_pack_start (GTK_BOX (vbox), showweeks, FALSE, FALSE, 0);
+	gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (showweeks),
+				      cd->showweeks);
+	g_signal_connect (G_OBJECT (showweeks), "toggled",
+			  G_CALLBACK (set_show_weeks_cb),
+			  cd);
+	gtk_widget_show (showweeks);
+
+	weekmonday = gtk_check_button_new_with_mnemonic (_("Week starts on _monday"));
+	gtk_box_pack_start (GTK_BOX (vbox), weekmonday, FALSE, FALSE, 0);
+	gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (weekmonday),
+				      cd->weekmonday);
+	g_signal_connect (G_OBJECT (weekmonday), "toggled",
+			  G_CALLBACK (set_week_monday_cb),
+			  cd);
+	gtk_widget_show (weekmonday);
 
 	use_gmt_time = gtk_check_button_new_with_mnemonic (_("Use _UTC"));
 	gtk_box_pack_start (GTK_BOX (vbox), use_gmt_time, FALSE, FALSE, 0);
Index: clock.schemas.in
===================================================================
RCS file: /cvs/gnome/gnome-panel/applets/clock/clock.schemas.in,v
retrieving revision 1.11
diff -u -p -u -r1.11 clock.schemas.in
--- clock.schemas.in	9 Jul 2003 10:36:53 -0000	1.11
+++ clock.schemas.in	16 Sep 2003 10:42:00 -0000
@@ -41,6 +41,28 @@
       </schema>
 
       <schema>
+        <key>/schemas/apps/clock_applet/prefs/show_weeks</key>
+        <owner>clock-applet</owner>
+        <type>bool</type>
+        <default>false</default>
+        <locale name="C">
+         <short>Display weeks in calendar</short>
+         <long>If true, display week numbers in the calendar popup.</long>
+        </locale>
+      </schema>
+
+      <schema>
+        <key>/schemas/apps/clock_applet/prefs/week_start_monday</key>
+        <owner>clock-applet></owner>
+        <type>bool</type>
+        <default>false</default>
+        <locale name="C">
+         <short>Whether week starts on monday</short>
+         <long>If true, week starts monday in the calendar.</long>
+        </locale>
+      </schema>
+
+      <schema>
         <key>/schemas/apps/clock_applet/prefs/show_tooltip</key>
         <owner>clock-applet</owner>
         <type>bool</type>
