Laurent Monin wrote:
> in recent versions this doesn't seem to be needed (though i may be
> wrong here).
Well, I just wanted to ask myself "what did pango devs smoke, not using
that by default".
FWIW, I'm on debian oldstable/etch, with prehistoric pango 1.14.10 ;-)
> /Since 1.20, pango_attribute_init() was added.
> It would be better to test for Pango versions and provide the fix only
> for versions that need it.
Not sure.
1) No sense to change it only here. And adding ifdefs everywhere will
clutter code. Make helper macro? Eww.
2) Not perfectly good as compile-time check (imagine someone build
binary with 1.20 and run with 1.18? that won't be catched by runtime
linker), and making that runtime check is complete waste.
I think better would be add note somewhere to TODO "remove all
->{start,end}_index after we will be incompatible with pango < 1.20 for
other reasons".
> Also note that indexes are of unsigned type (so G_MAXINT -> G_MAXUINT).
It was G_MAXINT in all other places, so for sake of consistency I've
preferred to use G_MAXINT too (and that would be really bug only other
way round).
> Please provide an improved patch so we can apply it to trunk asap.
Anyway, some fugly attempt at that attached.
Only checked on 1.14, may misbehave on 1.16 or 1.20+, someone should check.
--- geeqie-20090616/src/compat.h.orig 2009-05-15 04:45:45.000000000 +0400
+++ geeqie-20090616/src/compat.h 2009-06-16 18:39:21.000000000 +0400
@@ -13,6 +13,10 @@
#ifndef COMPAT_H
#define COMPAT_H
+#include <gtk/gtkversion.h>
+#include <gtk/gtkradioaction.h>
+#include <pango/pango.h>
+
void radio_action_set_current_value(GtkRadioAction *action, gint current_value);
GList* hash_table_get_keys(GHashTable *hash_table);
@@ -20,6 +24,20 @@
#define gtk_widget_set_tooltip_text(widget, text) /* ignored */
#endif
+#if !defined(PANGO_CHECK_VERSION) /* introduced in pango 1.16.x */
+#define PANGO_CHECK_VERSION(X,Y,Z) 0
+#endif
+
+#if PANGO_CHECK_VERSION(2,20,0)
+#define compat_pango_attr_prepare(ATTR) (ATTR)
+#else
+static inline PangoAttribute* compat_pango_attr_prepare(PangoAttribute *attr)
+{
+ attr->start_index = 0;
+ attr->end_index = G_MAXUINT;
+ return attr;
+}
+#endif
#endif /* COMPAT_H */
/* vim: set shiftwidth=8 softtabstop=0 cindent cinoptions={1s: */
--- geeqie-20090616/src/layout_image.c.orig 2009-06-16 00:32:50.000000000 +0400
+++ geeqie-20090616/src/layout_image.c 2009-06-16 18:23:18.000000000 +0400
@@ -1563,7 +1563,8 @@
}
attrs = pango_attr_list_new();
- pango_attr_list_insert(attrs, pango_attr_family_new("Monospace"));
+ pango_attr_list_insert(attrs, compat_pango_attr_prepare(pango_attr_family_new("Monospace")));
+
gtk_label_set_text(GTK_LABEL(lw->info_pixel), text);
gtk_label_set_attributes(GTK_LABEL(lw->info_pixel), attrs);
pango_attr_list_unref(attrs);
--- geeqie-20090616/src/pan-item.c.orig 2009-05-15 04:45:44.000000000 +0400
+++ geeqie-20090616/src/pan-item.c 2009-06-16 18:20:20.000000000 +0400
@@ -358,23 +358,12 @@
pi->text_attr & PAN_TEXT_ATTR_HEADING)
{
PangoAttrList *pal;
- PangoAttribute *pa;
pal = pango_attr_list_new();
if (pi->text_attr & PAN_TEXT_ATTR_BOLD)
- {
- pa = pango_attr_weight_new(PANGO_WEIGHT_BOLD);
- pa->start_index = 0;
- pa->end_index = G_MAXINT;
- pango_attr_list_insert(pal, pa);
- }
+ pango_attr_list_insert(pal, compat_pango_attr_prepare(pango_attr_weight_new(PANGO_WEIGHT_BOLD)));
if (pi->text_attr & PAN_TEXT_ATTR_HEADING)
- {
- pa = pango_attr_scale_new(PANGO_SCALE_LARGE);
- pa->start_index = 0;
- pa->end_index = G_MAXINT;
- pango_attr_list_insert(pal, pa);
- }
+ pango_attr_list_insert(pal, compat_pango_attr_prepare(pango_attr_scale_new(PANGO_SCALE_LARGE)));
pango_layout_set_attributes(layout, pal);
pango_attr_list_unref(pal);
}
--- geeqie-20090616/src/ui_misc.c.orig 2009-05-15 04:45:47.000000000 +0400
+++ geeqie-20090616/src/ui_misc.c 2009-06-16 18:22:15.000000000 +0400
@@ -203,27 +203,16 @@
void pref_label_bold(GtkWidget *label, gboolean bold, gboolean increase_size)
{
PangoAttrList *pal;
- PangoAttribute *pa;
if (!bold && !increase_size) return;
pal = pango_attr_list_new();
if (bold)
- {
- pa = pango_attr_weight_new(PANGO_WEIGHT_BOLD);
- pa->start_index = 0;
- pa->end_index = G_MAXINT;
- pango_attr_list_insert(pal, pa);
- }
+ pango_attr_list_insert(pal, compat_pango_attr_prepare(pango_attr_weight_new(PANGO_WEIGHT_BOLD)));
if (increase_size)
- {
- pa = pango_attr_scale_new(PANGO_SCALE_LARGE);
- pa->start_index = 0;
- pa->end_index = G_MAXINT;
- pango_attr_list_insert(pal, pa);
- }
+ pango_attr_list_insert(pal, compat_pango_attr_prepare(pango_attr_scale_new(PANGO_SCALE_LARGE)));
gtk_label_set_attributes(GTK_LABEL(label), pal);
pango_attr_list_unref(pal);
--- geeqie-20090616/src/cellrenderericon.c.orig 2009-05-15 04:45:46.000000000 +0400
+++ geeqie-20090616/src/cellrenderericon.c 2009-06-16 18:35:58.000000000 +0400
@@ -22,6 +22,7 @@
#include <stdlib.h>
#include "cellrenderericon.h"
#include "intl.h"
+#include "compat.h"
#define FIXED_ICON_SIZE_MAX 512
@@ -503,15 +504,10 @@
if (cellicon->foreground_set)
{
PangoColor color;
- PangoAttribute *attr;
color = cellicon->foreground;
- attr = pango_attr_foreground_new(color.red, color.green, color.blue);
-
- attr->start_index = 0;
- attr->end_index = G_MAXINT;
- pango_attr_list_insert(attr_list, attr);
+ pango_attr_list_insert(attr_list, compat_pango_attr_prepare(pango_attr_foreground_new(color.red, color.green, color.blue)));
}
pango_layout_set_attributes(layout, attr_list);
------------------------------------------------------------------------------
Crystal Reports - New Free Runtime and 30 Day Trial
Check out the new simplified licensing option that enables unlimited
royalty-free distribution of the report engine for externally facing
server and web deployment.
http://p.sf.net/sfu/businessobjects
_______________________________________________
Geeqie-devel mailing list
Geeqie-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/geeqie-devel