I noticed Christian's comment in the source that Gtk+2 >= 2.5.0 contains an implementation of pbarcellrenderer.c. The only difference between the cellrenderer that is part of GTK2 and the one implemented in pbarcellrenderer.c is that GTK2's expects an int in the range 1 -> 100 where pbarcellrender.c expects a double in the range of 0.0 -> 1.0.
The following patch modifies the bundled pbarcellrender.c file to behave as a drop in replacement for the cellrender bundled with GTK2 >= 2.5.0
Conditional compilation of pbarcellrender.c where (GTK2 < 2.5.0) should probably also be added to completely address the issue.
Thanks, Russ
Index: src/ui/gtk/gtk2/downloads.c =================================================================== RCS file: /cvsroot/gtk-gnutella/gtk-gnutella-current/src/ui/gtk/gtk2/downloads.c,v retrieving revision 1.21 diff -u -r1.21 downloads.c --- src/ui/gtk/gtk2/downloads.c 3 Jan 2005 11:02:07 -0000 1.21 +++ src/ui/gtk/gtk2/downloads.c 4 Jan 2005 02:40:29 -0000 @@ -27,7 +27,10 @@
RCSID("$Id: downloads.c,v 1.21 2005/01/03 11:02:07 cbiere Exp $");
+#if (GTK_MINOR_VERSION <= (5))
#include "pbarcellrenderer.h"
+#endif
+
#include "downloads_cb.h"
#include "gtk/downloads.h"
Index: src/ui/gtk/gtk2/interface-glade.c
===================================================================
RCS file:
/cvsroot/gtk-gnutella/gtk-gnutella-current/src/ui/gtk/gtk2/interface-glade.c,v
retrieving revision 1.40
diff -u -r1.40 interface-glade.c
--- src/ui/gtk/gtk2/interface-glade.c 31 Dec 2004 07:53:44 -0000 1.40
+++ src/ui/gtk/gtk2/interface-glade.c 4 Jan 2005 02:40:46 -0000
@@ -1654,7 +1654,7 @@
gtk_container_set_border_width (GTK_CONTAINER (button_about_close), 6);
GTK_WIDGET_SET_FLAGS (button_about_close, GTK_CAN_DEFAULT);
- label538 = gtk_label_new ("@(#) $Id: interface-glade.c,v 1.40 2004/12/31
07:53:44 cbiere Exp $");
+ label538 = gtk_label_new ("@(#) $Id: gtk-gnutella.glade,v 1.43 2004/12/31
07:53:42 cbiere Exp $");
gtk_widget_set_name (label538, "label538");
gtk_box_pack_start (GTK_BOX (vbox67), label538, FALSE, FALSE, 0);
gtk_widget_set_sensitive (label538, FALSE);
Index: src/ui/gtk/gtk2/pbarcellrenderer.c
===================================================================
RCS file:
/cvsroot/gtk-gnutella/gtk-gnutella-current/src/ui/gtk/gtk2/pbarcellrenderer.c,v
retrieving revision 1.6
diff -u -r1.6 pbarcellrenderer.c
--- src/ui/gtk/gtk2/pbarcellrenderer.c 28 Dec 2004 00:01:22 -0000 1.6
+++ src/ui/gtk/gtk2/pbarcellrenderer.c 4 Jan 2005 02:40:46 -0000
@@ -107,11 +107,11 @@
*/
enum {
PROP_0, /* Placeholder, empty property */
- PROP_VALUE /* The position of the progress bar [0:1] */
+ PROP_VALUE /* The position of the progress bar [0:100] */
};
struct _GtkCellRendererProgressPriv {
- double value;
+ gint value;
};
static gpointer parent_class;
@@ -382,10 +382,10 @@
gdk_gc_set_rgb_fg_color(gc, &widget->style->bg[GTK_STATE_NORMAL]);
gdk_draw_rectangle(window, gc, TRUE, x + 1, y + 1, w - 2, h - 2);
gdk_gc_set_rgb_fg_color(gc, &widget->style->bg[GTK_STATE_SELECTED]);
- perc_w = (int)((w - 4) * cellprogress->priv->value);
+ perc_w = (int)((w - 4) * (cellprogress->priv->value / 100.0));
gdk_draw_rectangle(window, gc, TRUE, x + 2, y + 2, perc_w, h - 4);
- val = cellprogress->priv->value * 100;
+ val = cellprogress->priv->value;
gm_snprintf(text, sizeof text, "%d", val);
layout = gtk_widget_create_pango_layout(widget, text);
pango_layout_get_pixel_extents(layout, NULL, &logical_rect);
Index: src/ui/gtk/gtk2/uploads.c
===================================================================
RCS file: /cvsroot/gtk-gnutella/gtk-gnutella-current/src/ui/gtk/gtk2/uploads.c,v
retrieving revision 1.7
diff -u -r1.7 uploads.c
--- src/ui/gtk/gtk2/uploads.c 28 Dec 2004 00:01:22 -0000 1.7
+++ src/ui/gtk/gtk2/uploads.c 4 Jan 2005 02:40:47 -0000
@@ -26,7 +26,9 @@
#include "gtk/gui.h"
#include "interface-glade.h"
+#if (GTK_MINOR_VERSION <= (5))
#include "pbarcellrenderer.h"
+#endif
#include "gtk/uploads.h"
#include "gtk/uploads_common.h"
signature.asc
Description: OpenPGP digital signature
