Add a new clock type, which shows both the time and date in the panel. Although the date can be seen in the tooltip, it would be nice to see it all the time. Specially since there is place for it.
I coded this for 4.2 beta 2. 3 files need to be modified: xfce4-panel-4.1.91/plugins/clock/clock.c libxfcegui4-4.1.91/libxfcegui4/xfce_clock.c libxfcegui4-4.1.91/libxfcegui4/xfce_clock.h This is the diff -Nur of these changes: diff -Nur xfce-4.1.91/src/libxfcegui4-4.1.91/libxfcegui4/xfce_clock.c xcfe/src/libxfcegui4-4.1.91/libxfcegui4/xfce_clock.c --- xfce-4.1.91/src/libxfcegui4-4.1.91/libxfcegui4/xfce_clock.c 2004-11-01 07:44:45.000000000 +0200 +++ xcfe/src/libxfcegui4-4.1.91/libxfcegui4/xfce_clock.c 2004-10-31 19:08:01.000000000 +0200 @@ -676,6 +676,7 @@ clock->mode = XFCE_CLOCK_LEDS; break; case XFCE_CLOCK_LEDS: + case XFCE_CLOCK_TIMEDATE: default: clock->mode = XFCE_CLOCK_ANALOG; } @@ -696,7 +697,7 @@ static void xfce_clock_size_request (GtkWidget * widget, GtkRequisition * requisition) { - gchar buffer[16]; + gchar buffer[32]; XfceClock *clock; guint ln = 0; guint width = 0; @@ -712,6 +713,7 @@ switch (clock->mode) { case XFCE_CLOCK_DIGITAL: + case XFCE_CLOCK_TIMEDATE: if (clock->military_time) { if (clock->display_secs) @@ -745,6 +747,10 @@ strcpy (buffer, "88:88"); } } + if (clock->mode==XFCE_CLOCK_TIMEDATE) + { + strcat (buffer, "\n88:88:8888"); + } layout = gtk_widget_create_pango_layout (widget, buffer); pango_layout_get_pixel_extents (layout, NULL, &logical_rect); requisition->width = logical_rect.width + 6; @@ -1008,10 +1014,10 @@ XfceClock *clock; time_t ticks; struct tm *tm; - gint h, m, s; + gint h, m, s, dd, mm, yy; gint x, y; gchar ampm[3] = "AM"; - gchar time_buf[24]; + gchar time_buf[32], date_buf[16]; gint width, height; /* to measure out string. */ PangoLayout *layout = NULL; @@ -1025,6 +1031,9 @@ h = tm->tm_hour; m = tm->tm_min; s = tm->tm_sec; + dd = tm->tm_mday; + mm = tm->tm_mon + 1; + yy = tm->tm_year + 1900; if (h >= 12) ampm[0] = 'P'; @@ -1058,6 +1067,11 @@ else sprintf (time_buf, "%d:%02d", h, m); } + if (clock->mode==XFCE_CLOCK_TIMEDATE) + { + sprintf (date_buf, "\n%02d.%02d.%d", dd, mm, yy); + strcat (time_buf, date_buf); + } layout = gtk_widget_create_pango_layout (widget, time_buf); pango_layout_set_alignment (layout, PANGO_ALIGN_CENTER); @@ -1344,6 +1358,7 @@ xfce_clock_draw_leds (widget, area); break; case XFCE_CLOCK_DIGITAL: + case XFCE_CLOCK_TIMEDATE: default: xfce_clock_draw_digital (widget, area); break; diff -Nur xfce-4.1.91/src/libxfcegui4-4.1.91/libxfcegui4/xfce_clock.h xcfe/src/libxfcegui4-4.1.91/libxfcegui4/xfce_clock.h --- xfce-4.1.91/src/libxfcegui4-4.1.91/libxfcegui4/xfce_clock.h 2004-11-01 07:44:54.000000000 +0200 +++ xcfe/src/libxfcegui4-4.1.91/libxfcegui4/xfce_clock.h 2004-10-31 19:07:50.000000000 +0200 @@ -45,7 +45,8 @@ { XFCE_CLOCK_ANALOG, XFCE_CLOCK_DIGITAL, - XFCE_CLOCK_LEDS + XFCE_CLOCK_LEDS, + XFCE_CLOCK_TIMEDATE } XfceClockMode; diff -Nur xfce-4.1.91/src/xfce4-panel-4.1.91/plugins/clock/clock.c xcfe/src/xfce4-panel-4.1.91/plugins/clock/clock.c --- xfce-4.1.91/src/xfce4-panel-4.1.91/plugins/clock/clock.c 2004-11-01 07:45:46.000000000 +0200 +++ xcfe/src/xfce4-panel-4.1.91/plugins/clock/clock.c 2004-11-01 08:05:47.000000000 +0200 @@ -198,8 +198,9 @@ * %d : day of the month * %B : full month name * %Y : four digit year + * %V : ISO week number */ - strftime (date_s, 255, _("%A, %d %B %Y"), tm); + strftime (date_s, 255, _("%A, %d %B %V/%Y"), tm); /* Conversion to utf8 * patch by Oliver M. Bolzer <oliver@fakeroot.net> @@ -275,7 +276,8 @@ update_clock_size (XfceClock * clock, int size) { if ((xfce_clock_get_mode (clock) == XFCE_CLOCK_LEDS) || - (xfce_clock_get_mode (clock) == XFCE_CLOCK_DIGITAL)) + (xfce_clock_get_mode (clock) == XFCE_CLOCK_DIGITAL) || + (xfce_clock_get_mode (clock) == XFCE_CLOCK_TIMEDATE)) { gtk_widget_set_size_request (GTK_WIDGET (clock), -1, -1); } @@ -451,6 +453,10 @@ gtk_widget_show (mi); gtk_menu_shell_append (GTK_MENU_SHELL (menu), mi); + mi = gtk_menu_item_new_with_label (_("Time&Date")); + gtk_widget_show (mi); + gtk_menu_shell_append (GTK_MENU_SHELL (menu), mi); + gtk_option_menu_set_history (GTK_OPTION_MENU (om), XFCE_CLOCK (cd->clock->clock)->mode);
Created attachment 86 patch in safe gzip format patch in gzip format
note that the patch also changes slighlty the tooltip hint by adding week number (which is very important in my work...)
feature freeze is in place for 4.2, so this isn't going to get accepted. at any rate, there's the datetime plugin, available from http://xfce-goodies.berlios.de/ that will do what you want.
sorry for the spam, but, for future reference, please don't compress patches, especially such small ones. there's plenty of room to store the full text in bugzilla, and it makes it much easier to view (without having to do a download). thanks!
datetime plugin is not good for me since: 1) it shows date after the time and wastes too much space 2) it is not integrated with xfcalendar. I concidered very much if I should enhance clock or datetime and decided it is easier to modify clock, but apparently I choosed wrongly. Of course I understand that this enhancement can not be included in 4.2 since it includes new strings etc...but is nit not possible to file enhancements against 4.3 or 4.4 ? Or is there reasons to deny this also from those ?
No, it's a good request. We'll have to decide what we want to do with these after 4.2. At first glance I don't think it should be in the clock widget, but in the panel plugin. I think I'd prefer the clock widget to include only the LED and the analog clock types. Anyway, I'd like to keep this open and think about it at a later time. Thanks, Jasper
as this suggestion was not approved, I coded this as orage-clock.
appears in 4.4