PATCH: foobar clock widget



I would like to submit a patch for the foobar clock to enhance the menu layout.

The patch makes these notable modifications.

1.    It converts the menu items of the Format submenu into 
      gtk radio menu items.
2.    It adds support for icons and tool tips to many of the menu items.
3.    It adds the missing ellipses to the gnome-cal menu items.

Below is the URL of a screenshot to illustrate the modifications.

	 http://www.slip.net/~dcransto/gnome-core/panel/foobar-clock-new.png

Diff files can be obtained from these URLs.

	http://www.slip.net/~dcransto/gnome-core/diffs/Makefile.am.diff
	http://www.slip.net/~dcransto/gnome-core/diffs/foobar-widget.c.diff

These four graphic files should be copied to the gnome-core/pixmaps directory.

	http://www.slip.net/~dcransto/gnome-core/pixmaps/gnome-day.png
	http://www.slip.net/~dcransto/gnome-core/pixmaps/gnome-week.png
	http://www.slip.net/~dcransto/gnome-core/pixmaps/gnome-month.png
	http://www.slip.net/~dcransto/gnome-core/pixmaps/gnome-set-time.png

(A copy of this email has been submitted to Gnome Bugzilla as bug report 
#66900.)

Thanks,
Dennis

Index: Makefile.am
===================================================================
RCS file: /cvs/gnome/gnome-core/pixmaps/Makefile.am,v
retrieving revision 1.75
diff -u -u -p -r1.75 Makefile.am
--- Makefile.am	2001/10/19 12:43:04	1.75
+++ Makefile.am	2001/12/13 07:51:09
@@ -110,7 +110,11 @@ pixmap_DATA =					\
 	gnome-debian.png			\
 	gnome-suse.png				\
 	gtkvim.png				\
-	gnome-computer.png	
+	gnome-computer.png			\
+	gnome-day.png				\
+	gnome-week.png				\
+	gnome-month.png				\
+	gnome-set-time.png
 
 # tilesdir = $(datadir)/pixmaps/tiles
 # tiles_DATA =					\

Index: foobar-widget.c
===================================================================
RCS file: /cvs/gnome/gnome-core/panel/foobar-widget.c,v
retrieving revision 1.105
diff -u -u -p -r1.105 foobar-widget.c
--- foobar-widget.c	2001/12/12 01:21:20	1.105
+++ foobar-widget.c	2001/12/13 08:20:16
@@ -35,6 +35,7 @@
 #include "drawer-widget.h"
 #include "gnome-run.h"
 #include "multiscreen-stuff.h"
+#include "panel-gconf.h"
 
 #define ICON_SIZE 20
 
@@ -314,13 +315,29 @@ append_folder_menu (GtkWidget *menu_bar,
 #endif
 
 static void
-append_gnomecal_item (GtkWidget *menu, const char *label, const char *flag)
+append_gnomecal_items (GtkWidget *menu)
 {
-	GtkWidget *item = gtk_image_menu_item_new_with_label (label);
-	gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
-	g_signal_connect (G_OBJECT (item), "activate",
-			  G_CALLBACK (gnomecal_client),
-			  (char *)flag);
+	GtkWidget *item;
+	int i;
+	
+	const char *cals[] = { 
+		N_("Today..."),      N_("View the calendar for today."),     
"gnome-day.png",   "dayview",
+		N_("This Week..."),  N_("View the calendar for this week."), 
"gnome-week.png",  "weekview",
+		N_("This Month..."), N_("View the calendar for this month."),
"gnome-month.png", "monthview",
+		NULL
+	};
+	
+	for (i=0; cals[i]; i+=4) {
+		item = pixmap_menu_item_new (cals[i], cals[i+2]);
+		gtk_tooltips_set_tip (panel_tooltips, item,
+			      	      cals[i+1],
+			      	      NULL);
+	
+		gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
+		g_signal_connect (G_OBJECT (item), "activate",
+				  G_CALLBACK (gnomecal_client),
+				  (char *)cals[i+3]);
+	}
 }
 
 static void
@@ -390,27 +407,48 @@ set_fooclock_format (GtkWidget *w, char 
 }
 
 static void
-append_format_item (GtkWidget *menu, const char *format)
+append_format_items (GtkWidget *menu)
 {
 	char hour[256];
 	GtkWidget *item;
+	GSList *group = NULL;
 	struct tm *das_tm;
 	time_t das_time = 0;
-
-	das_tm = localtime (&das_time);
-	if (strftime (hour, sizeof(hour), _(format), das_tm) == 0) {
-		/* according to docs, if the string does not fit, the
-		 * contents of tmp2 are undefined, thus just use
-		 * ??? */
-		strcpy(hour, "???");
-	}
-	hour[sizeof(hour)-1] = '\0'; /* just for sanity */
+	char *s = panel_gconf_global_config_get_string ("clock-format");
+	int i;
+	
+	const char *formats[] = {
+		N_("%H:%M"),
+		N_("%H:%M:%S"),
+		N_("%l:%M %p"),
+		N_("%l:%M:%S %p"),
+		NULL
+	};
+	
+	for (i = 0; formats[i]; i++)
+	{
+		das_tm = localtime (&das_time);
+		if (strftime (hour, sizeof(hour), _(formats[i]), das_tm) == 0) {
+ 			/* according to docs, if the string does not fit, the
+ 		 	 * contents of tmp2 are undefined, thus just use
+ 		 	 * ??? */
+			strcpy(hour, "???");
+		}
+		hour[sizeof(hour)-1] = '\0'; /* just for sanity */
 
-	item = gtk_image_menu_item_new_with_label (hour);
-	gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
-	g_signal_connect (G_OBJECT (item), "activate",
+		item = gtk_radio_menu_item_new_with_label (group, hour);
+		group = gtk_radio_menu_item_group (GTK_RADIO_MENU_ITEM (item));
+	
+		gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);	
+		g_signal_connect (G_OBJECT (item), "activate",
 			  G_CALLBACK (set_fooclock_format),
-			  (char *)format);
+			  (char *)formats[i]);
+
+		if (s && !strcmp (s, formats[i])) {
+			gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (item), TRUE);
+		}
+	}
+	g_free (s);
 }
 
 static void
@@ -429,50 +467,33 @@ append_clock_menu (FoobarWidget *foo, Gt
 {
 	GtkWidget *item, *menu, *menu2;
 	gchar *time_admin_path;
-	int i;
-	const char *cals[] = { 
-		N_("Today"),      "dayview",
-		N_("This Week"),  "weekview",
-		N_("This Month"), "monthview",
-		NULL
-	};
-
-	const char *formats[] = {
-		N_("%H:%M"),
-		N_("%H:%M:%S"),
-		N_("%l:%M %p"),
-		N_("%l:%M:%S %p"),
-		NULL
-	};
 
 	menu = gtk_menu_new ();
-	
+	append_gnomecal_items (menu);
+
 #if 0 /* put back when evolution can do this */
-	item = gtk_image_menu_item_new_with_label (_("Add appointement..."));
+	item = gtk_image_menu_item_new_with_label (_("Add Appointment..."));
 	gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
+#endif
 
 	add_menu_separator (menu);
-#endif
 
-	/* FIXME: wtf is time-admin???? */
+	/* check for time-admin (part of ximian-setup-tools) */
 	time_admin_path = g_find_program_in_path  ("time-admin");
 	if (time_admin_path != NULL) {
-		item = gtk_image_menu_item_new_with_label (_("Set Time"));
+		item = pixmap_menu_item_new (_("Set Time..."), "gnome-set-time.png");
+		gtk_tooltips_set_tip (panel_tooltips, item,
+			      	      _("Adjust the date and time."),
+			      	      NULL);	
+		
+		gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
 		g_signal_connect (G_OBJECT (item), "activate",
 				  G_CALLBACK (set_time_cb),
-				  time_admin_path);
-		gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
-		add_menu_separator (menu);
+				  time_admin_path);			
 	}
 
-	for (i=0; cals[i]; i+=2)
-		append_gnomecal_item (menu, _(cals[i]), cals[i+1]);
-
-	add_menu_separator (menu);
-
 	menu2 = gtk_menu_new ();
-	for (i=0; formats[i]; i++)
-		append_format_item (menu2, formats[i]);
+	append_format_items (menu2); 
 
 	add_tearoff (GTK_MENU_SHELL (menu2));
 



__________________________________________________
Do You Yahoo!?
Check out Yahoo! Shopping and Yahoo! Auctions for all of
your unique holiday gifts! Buy at http://shopping.yahoo.com
or bid at http://auctions.yahoo.com



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