? 317891-year-panel-and-tooltip.patch
Index: clock.c
===================================================================
RCS file: /cvs/gnome/gnome-panel/applets/clock/clock.c,v
retrieving revision 1.172
diff -u -r1.172 clock.c
--- clock.c	15 Sep 2005 20:20:39 -0000	1.172
+++ clock.c	12 Oct 2005 20:39:29 -0000
@@ -67,13 +67,14 @@
 #define INTERNETSECOND (864)
 #define INTERNETBEAT   (86400)
 
-#define N_GCONF_PREFS 7
+#define N_GCONF_PREFS 8
 
 #define NEVER_SENSITIVE "never_sensitive"
 
 static const char* KEY_FORMAT        = "format";
 static const char* KEY_SHOW_SECONDS  = "show_seconds";
 static const char* KEY_SHOW_DATE     = "show_date";
+static const char* KEY_SHOW_YEAR     = "show_year";
 static const char* KEY_GMT_TIME      = "gmt_time";
 static const char* KEY_CONFIG_TOOL   = "config_tool";
 static const char* KEY_CUSTOM_FORMAT = "custom_format";
@@ -133,6 +134,7 @@
 	char        *custom_format;
 	gboolean     showseconds;
 	gboolean     showdate;
+	gboolean     showyear;
 	gboolean     gmt_time;
 	gboolean     showweek;
 
@@ -150,6 +152,7 @@
 
         GtkWidget *showseconds_check;
         GtkWidget *showdate_check;
+        GtkWidget *showyear_check;
         GtkWidget *gmt_time_check;
         GtkWidget *custom_hbox;
         GtkWidget *custom_label;
@@ -319,7 +322,11 @@
 		 *              should begin with a 0 in your locale (e.g. "May
 		 *              01" instead of "May  1").
 		 */
-		date_format = _("%a %b %e");
+		
+		if (!cd->showyear)
+			date_format = _("%a %b %e");
+		else
+			date_format = _("%a %b %e %y");
 
 		if (use_two_line_format (cd))
 			/* translators: reverse the order of these arguments
@@ -414,7 +421,10 @@
 
         if (!cd->showdate) {
                 /* Show date in tooltip */
-                loc = g_locale_from_utf8 (_("%A %B %d"), -1, NULL, NULL, NULL);
+		if (!cd->showyear)
+                	loc = g_locale_from_utf8 (_("%A %B %d"), -1, NULL, NULL, NULL);
+		else
+                	loc = g_locale_from_utf8 (_("%A %B %d %y"), -1, NULL, NULL, NULL);			
                 if (!loc)
                         strcpy (date, "???");
                 else if (strftime (date, sizeof (date), loc, tm) <= 0)
@@ -1992,6 +2002,24 @@
 }
 
 static void
+show_year_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->showyear = (value != 0);
+	update_timeformat (clock);
+	refresh_clock (clock);
+}
+
+static void
 gmt_time_changed (GConfClient  *client,
                   guint         cnxn_id,
                   GConfEntry   *entry,
@@ -2177,6 +2205,15 @@
 				clock, NULL, NULL);
 	g_free (key);
 
+	key = panel_applet_gconf_get_full_key (PANEL_APPLET (clock->applet),
+					       KEY_SHOW_YEAR);
+	clock->listeners [7] =
+			gconf_client_notify_add (
+				client, key,
+				(GConfClientNotifyFunc) show_year_changed,
+				clock, NULL, NULL);
+	g_free (key);
+
 	g_object_unref (G_OBJECT (client));
 }
 
@@ -2249,6 +2286,7 @@
 
 	cd->custom_format = panel_applet_gconf_get_string (applet, KEY_CUSTOM_FORMAT, NULL);
 	cd->showseconds = panel_applet_gconf_get_bool (applet, KEY_SHOW_SECONDS, NULL);
+	cd->showyear = panel_applet_gconf_get_bool (applet, KEY_SHOW_YEAR, NULL);
 	
 	error = NULL;
 	cd->showdate = panel_applet_gconf_get_bool (applet, KEY_SHOW_DATE, &error);
@@ -2394,6 +2432,7 @@
         case CLOCK_FORMAT_24:
                 gtk_widget_set_sensitive (cd->showseconds_check, TRUE);
                 gtk_widget_set_sensitive (cd->showdate_check, TRUE);
+		gtk_widget_set_sensitive (cd->showyear_check, TRUE);
                 gtk_widget_set_sensitive (cd->gmt_time_check, TRUE);
 		gtk_widget_set_sensitive (cd->custom_entry, FALSE);
 		gtk_widget_set_sensitive (cd->custom_label, FALSE);
@@ -2401,6 +2440,7 @@
         case CLOCK_FORMAT_UNIX:
                 gtk_widget_set_sensitive (cd->showseconds_check, FALSE);
                 gtk_widget_set_sensitive (cd->showdate_check, FALSE);
+		gtk_widget_set_sensitive (cd->showyear_check, FALSE);
                 gtk_widget_set_sensitive (cd->gmt_time_check, FALSE);
                 gtk_widget_set_sensitive (cd->custom_entry, FALSE);
                 gtk_widget_set_sensitive (cd->custom_label, FALSE);
@@ -2408,6 +2448,7 @@
         case CLOCK_FORMAT_INTERNET:
                 gtk_widget_set_sensitive (cd->showseconds_check, TRUE);
                 gtk_widget_set_sensitive (cd->showdate_check, FALSE);
+		gtk_widget_set_sensitive (cd->showyear_check, FALSE);
 		gtk_widget_set_sensitive (cd->gmt_time_check, FALSE);
 		gtk_widget_set_sensitive (cd->custom_entry, FALSE);
 		gtk_widget_set_sensitive (cd->custom_label, FALSE);
@@ -2415,6 +2456,7 @@
 	case CLOCK_FORMAT_CUSTOM:
 		gtk_widget_set_sensitive (cd->showseconds_check, FALSE);
 		gtk_widget_set_sensitive (cd->showdate_check, FALSE);
+		gtk_widget_set_sensitive (cd->showyear_check, FALSE);
 		gtk_widget_set_sensitive (cd->gmt_time_check, TRUE);
 		gtk_widget_set_sensitive (cd->custom_entry, TRUE);
 		gtk_widget_set_sensitive (cd->custom_label, TRUE);
@@ -2464,6 +2506,16 @@
 }
 
 static void
+set_show_year_cb (GtkWidget *w,
+		  ClockData *clock)
+{
+	panel_applet_gconf_set_bool (PANEL_APPLET (clock->applet),
+				     KEY_SHOW_YEAR,
+				     GTK_TOGGLE_BUTTON (w)->active,
+				     NULL);
+}
+
+static void
 set_gmt_time_cb (GtkWidget *w,
 		 ClockData *clock)
 {
@@ -2621,6 +2673,15 @@
 			  cd);
   	gtk_widget_show (cd->showdate_check);
 
+	cd->showyear_check = gtk_check_button_new_with_mnemonic (_("Show _year"));
+	gtk_box_pack_start (GTK_BOX (vbox), cd->showyear_check, FALSE, FALSE, 0);
+	gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (cd->showyear_check),
+	                              cd->showyear);
+	g_signal_connect (cd->showyear_check, "toggled",
+			  G_CALLBACK (set_show_year_cb),
+			  cd);
+  	gtk_widget_show (cd->showyear_check);
+
 	cd->gmt_time_check = gtk_check_button_new_with_mnemonic (_("Use _UTC"));
 	gtk_box_pack_start (GTK_BOX (vbox), cd->gmt_time_check, FALSE, FALSE, 0);
 	gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (cd->gmt_time_check),
@@ -2650,6 +2711,7 @@
 				       KEY_CUSTOM_FORMAT);
 	setup_writability_sensitivity (cd, cd->showseconds_check, NULL, KEY_SHOW_SECONDS);
 	setup_writability_sensitivity (cd, cd->showdate_check, NULL, KEY_SHOW_DATE);
+	setup_writability_sensitivity (cd, cd->showyear_check, NULL, KEY_SHOW_YEAR);
 	setup_writability_sensitivity (cd, cd->gmt_time_check, NULL, KEY_GMT_TIME);
 
 	gtk_widget_show (cd->props);
Index: clock.schemas.in
===================================================================
RCS file: /cvs/gnome/gnome-panel/applets/clock/clock.schemas.in,v
retrieving revision 1.21
diff -u -r1.21 clock.schemas.in
--- clock.schemas.in	3 Oct 2005 06:38:46 -0000	1.21
+++ clock.schemas.in	12 Oct 2005 20:39:30 -0000
@@ -77,6 +77,17 @@
       </schema>
 
       <schema>
+        <key>/schemas/apps/clock_applet/prefs/show_year</key>
+        <owner>clock-applet</owner>
+        <type>bool</type>
+        <default>true</default>
+        <locale name="C">
+          <short>Show year in clock</short>
+          <long>If true, display year in the clock, in addition to time.</long>
+        </locale>
+      </schema>
+
+      <schema>
         <key>/schemas/apps/clock_applet/prefs/show_tooltip</key>
         <owner>clock-applet</owner>
         <type>bool</type>
