Foobar patch



This is a patch to fix two things...
1. foobar clock constantly resizes on default font with AA on.
2. pixmaps were not properly scaled from wnck_window_get_mini_icon

Are these changes ok to commit?

#2 should be fine, but there might be some balking on #1 due to its
usage of usize (since it is deprecated and all...), and the possibility
of the label needing to change size if the font is changed.

Later,
Chris

-- 

http://glimmer.sourceforge.net - My pet project
http://uberhackers.dhs.org - My personal website

./configure --prefix=/dev/mocha --enable-caffeine
--- foobar-widget.c	Tue Dec 11 14:57:14 2001
+++ foobar-widget-hacked.c	Tue Dec 11 15:11:08 2001
@@ -520,4 +520,17 @@
 	foo->clock_format = g_strdup (clock_format);
 
+	if(foo->clock_label && foo->clock_label->style && foo->clock_label->style->private_font) {
+		time_t das_time;
+		struct tm *das_tm;
+		char hour[256];
+		int width;
+
+		das_time = 0;
+		das_tm = localtime (&das_time);
+		strftime(hour, sizeof(hour), _(clock_format), das_tm);
+		width = gdk_string_width(foo->clock_label->style->private_font, hour);
+		width += 12; /* For char width changes on non-fixed fonts */
+		gtk_widget_set_usize(foo->clock_label, width, 0);
+	}
 	update_clock (foo);
 }
@@ -672,4 +685,16 @@
 		pb = get_default_image ();
 	if (pb != NULL) {
+		double pix_x, pix_y;
+		pix_x = gdk_pixbuf_get_width (pb);
+		pix_y = gdk_pixbuf_get_height (pb);
+		if (pix_x > ICON_SIZE || pix_y > ICON_SIZE) {
+			double greatest;
+
+			greatest = pix_x > pix_y ? pix_x : pix_y;
+			pb = gdk_pixbuf_scale_simple (pb,
+						     (ICON_SIZE / greatest) * pix_x,
+						     (ICON_SIZE / greatest) * pix_y,
+						      GDK_INTERP_BILINEAR);
+		}
 		image = gtk_image_new_from_pixbuf (pb);
 		gtk_widget_show (image);
@@ -772,4 +797,16 @@
 
 	if (pb != NULL) {
+		double pix_x, pix_y;
+		pix_x = gdk_pixbuf_get_width (pb);
+		pix_y = gdk_pixbuf_get_height (pb);
+		if (pix_x > ICON_SIZE || pix_y > ICON_SIZE) {
+			double greatest;
+
+			greatest = pix_x > pix_y ? pix_x : pix_y;
+			pb = gdk_pixbuf_scale_simple (pb,
+						     (ICON_SIZE / greatest) * pix_x,
+						     (ICON_SIZE / greatest) * pix_y,
+						      GDK_INTERP_BILINEAR);
+		}
 		foo->task_image = gtk_image_new_from_pixbuf (pb);
 		gtk_widget_show (foo->task_image);


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