# HG changeset patch # User Stu Tomlinson # Date 1156096198 0 # Node ID c18bdf510325c5080cf25c51d0ec73fdddb8d7f6 # Parent f306918687a4de4264095c6b9b873a2a56a5475f [gaim-migrate @ 16910] Fix autogen.sh to run glib-gettextize Fix CFLAGS when gstreamer is not installed Make things work with gtk < 2.6, in part by borrowing some code from gdk Don't link gntgaim with gstreamer, xss or sm committer: Tailor Script diff -r f306918687a4 -r c18bdf510325 autogen.sh --- a/autogen.sh Sun Aug 20 17:34:21 2006 +0000 +++ b/autogen.sh Sun Aug 20 17:49:58 2006 +0000 @@ -1,5 +1,12 @@ #!/bin/sh +(glib-gettextize --version) < /dev/null > /dev/null 2>&1 || { + echo; + echo "You must have glib-gettextize installed to compile Gaim"; + echo; + exit; +} + (intltoolize --version) < /dev/null > /dev/null 2>&1 || { echo; echo "You must have intltool installed to compile Gaim"; @@ -46,6 +53,7 @@ done libtoolize -c -f --automake +glib-gettextize --force --copy intltoolize --force --copy aclocal $ACLOCAL_FLAGS || exit; autoheader || exit; diff -r f306918687a4 -r c18bdf510325 configure.ac --- a/configure.ac Sun Aug 20 17:34:21 2006 +0000 +++ b/configure.ac Sun Aug 20 17:49:58 2006 +0000 @@ -635,28 +635,20 @@ fi AC_SUBST(CFLAGS) -PKG_CHECK_MODULES(GLIB, [glib-2.0 >= 2.0.0 gobject-2.0 gmodule-2.0 gthread-2.0], - [ - AC_SUBST(GLIB_CFLAGS) - AC_SUBST(GLIB_LIBS) - echo "GLib 2.0 check OK!" - ], +PKG_CHECK_MODULES(GLIB, [glib-2.0 >= 2.0.0 gobject-2.0 gmodule-2.0 gthread-2.0],, [ AC_MSG_ERROR([ *** GLib 2.0 is required to build Gaim; please make sure you have the GLib *** development headers installed. The latest version of GLib is *** always available at http://www.gtk.org/.]) ]) +AC_SUBST(GLIB_CFLAGS) +AC_SUBST(GLIB_LIBS) AC_PATH_PROG(gaimpath, gaim) -if test "$enable_gtk" = yes ; then - PKG_CHECK_MODULES(GTK, [gtk+-2.0 >= 2.0.0], - [ - AC_SUBST(GTK_CFLAGS) - AC_SUBST(GTK_LIBS) - echo "GTK+ 2.0 check OK!" - ], +if test "x$enable_gtk" = "xyes" ; then + PKG_CHECK_MODULES(GTK, [gtk+-2.0 >= 2.0.0],, [ AC_MSG_ERROR([ *** GTK+ 2.0 is required to build Gaim. please make sure you have the GTK+ @@ -666,6 +658,8 @@ *** If you wish to build just gntgaim or libgaim, *** configure with --disable-gtkgaim]) ]) +AC_SUBST(GTK_CFLAGS) +AC_SUBST(GTK_LIBS) fi AC_PATH_XTRA diff -r f306918687a4 -r c18bdf510325 console/Makefile.am --- a/console/Makefile.am Sun Aug 20 17:34:21 2006 +0000 +++ b/console/Makefile.am Sun Aug 20 17:49:58 2006 +0000 @@ -35,18 +35,16 @@ gntgaiminclude_HEADERS = \ $(gntgaim_headers) -gntgaim_DEPENDENCIES = @LIBOBJS@ $(STATIC_LINK_LIBS) $(MS_LIBS) +gntgaim_DEPENDENCIES = @LIBOBJS@ $(STATIC_LINK_LIBS) gntgaim_LDFLAGS = -export-dynamic gntgaim_LDADD = \ @LIBOBJS@ \ $(DBUS_LIBS) \ - $(GSTREAMER_LIBS) \ $(STATIC_LINK_LIBS) \ - $(XSS_LIBS) \ - $(SM_LIBS) \ $(INTLLIBS) \ $(GLIB_LIBS) \ $(LIBXML_LIBS) \ + $(GNT_LIBS) \ -L./libgnt/ -lgnt \ -L$(top_srcdir)/libgaim -lgaim @@ -59,7 +57,6 @@ -DSYSCONFDIR=\"$(sysconfdir)\" \ -I$(top_srcdir)/libgaim/ \ -I ./libgnt/ \ - $(GSTREAMER_CFLAGS) \ $(DEBUG_CFLAGS) \ $(GLIB_CFLAGS) \ $(DBUS_CFLAGS) \ diff -r f306918687a4 -r c18bdf510325 console/libgnt/Makefile.am --- a/console/libgnt/Makefile.am Sun Aug 20 17:34:21 2006 +0000 +++ b/console/libgnt/Makefile.am Sun Aug 20 17:49:58 2006 +0000 @@ -43,7 +43,7 @@ libgnt_lainclude_HEADERS = \ $(libgnt_la_headers) -libgnt_la_DEPENDENCIES = @LIBOBJS@ $(STATIC_LINK_LIBS) $(MS_LIBS) +libgnt_la_DEPENDENCIES = @LIBOBJS@ $(STATIC_LINK_LIBS) libgnt_la_LDFLAGS = -export-dynamic libgnt_la_LIBADD = \ $(GLIB_LIBS) \ diff -r f306918687a4 -r c18bdf510325 console/libgnt/configure.ac --- a/console/libgnt/configure.ac Sun Aug 20 17:34:21 2006 +0000 +++ b/console/libgnt/configure.ac Sun Aug 20 17:49:58 2006 +0000 @@ -216,17 +216,15 @@ fi AC_SUBST(CFLAGS) -PKG_CHECK_MODULES(GLIB, [glib-2.0 >= 2.0.0 gobject-2.0 gmodule-2.0], - [ - AC_SUBST(GLIB_CFLAGS) - AC_SUBST(GLIB_LIBS) - ], +PKG_CHECK_MODULES(GLIB, [glib-2.0 >= 2.0.0 gobject-2.0 gmodule-2.0],, [ AC_MSG_ERROR([ *** GLib 2.0 is required to build Gaim; please make sure you have the GLib *** development headers installed. The latest version of GLib is *** always available at http://www.gtk.org/.]) ]) +AC_SUBST(GLIB_CFLAGS) +AC_SUBST(GLIB_LIBS) AC_MSG_CHECKING(for me pot o' gold) diff -r f306918687a4 -r c18bdf510325 gtk/Makefile.am --- a/gtk/Makefile.am Sun Aug 20 17:34:21 2006 +0000 +++ b/gtk/Makefile.am Sun Aug 20 17:49:58 2006 +0000 @@ -149,7 +149,7 @@ $(gaim_headers) -gaim_DEPENDENCIES = @LIBOBJS@ $(STATIC_LINK_LIBS) $(MS_LIBS) +gaim_DEPENDENCIES = @LIBOBJS@ $(STATIC_LINK_LIBS) gaim_LDFLAGS = -export-dynamic gaim_LDADD = \ @LIBOBJS@ \ @@ -172,6 +172,7 @@ -DLOCALEDIR=\"$(datadir)/locale\" \ -DSYSCONFDIR=\"$(sysconfdir)\" \ -I$(top_srcdir)/libgaim/ \ + $(GLIB_CFLAGS) \ $(GSTREAMER_CFLAGS) \ $(DEBUG_CFLAGS) \ $(GTK_CFLAGS) \ diff -r f306918687a4 -r c18bdf510325 gtk/gtkconv.c --- a/gtk/gtkconv.c Sun Aug 20 17:34:21 2006 +0000 +++ b/gtk/gtkconv.c Sun Aug 20 17:49:58 2006 +0000 @@ -4984,9 +4984,11 @@ gtk_label_set_text(GTK_LABEL(gtkchat->count), tmp); ls = GTK_LIST_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW(gtkchat->list))); - + +#if GTK_CHECK_VERSION(2,6,0) gtk_tree_sortable_set_sort_column_id(GTK_TREE_SORTABLE(ls), GTK_TREE_SORTABLE_UNSORTED_SORT_COLUMN_ID, GTK_TREE_SORTABLE_UNSORTED_SORT_COLUMN_ID); +#endif l = cbuddies; while (l != NULL) { diff -r f306918687a4 -r c18bdf510325 gtk/gtkgaim.h --- a/gtk/gtkgaim.h Sun Aug 20 17:34:21 2006 +0000 +++ b/gtk/gtkgaim.h Sun Aug 20 17:49:58 2006 +0000 @@ -66,7 +66,7 @@ # include "gtkcellviewmenuitem.h" # if !GTK_CHECK_VERSION(2,4,0) # include "gtkcelllayout.h" -# include "gtkcombobox.h" +# include "gaimcombobox.h" # endif /* Gtk 2.4 */ #endif /* Gtk 2.6 */ diff -r f306918687a4 -r c18bdf510325 gtk/gtkutils.c --- a/gtk/gtkutils.c Sun Aug 20 17:34:21 2006 +0000 +++ b/gtk/gtkutils.c Sun Aug 20 17:49:58 2006 +0000 @@ -2228,7 +2228,7 @@ gtk_widget_destroy(dialog->icon_filesel); if (dialog->callback) - dialog->callback(NULL, data); + dialog->callback(NULL, dialog->data); g_free(dialog); } @@ -2262,7 +2262,7 @@ #else /* FILECHOOSER */ static void -icon_filesel_choose_cb(GtkWidget *w, AccountPrefsDialog *dialog) +icon_filesel_choose_cb(GtkWidget *w, struct _icon_chooser *dialog) { char *filename, *current_folder; @@ -2647,3 +2647,140 @@ return NULL; #endif } + +#if !GTK_CHECK_VERSION(2,6,0) +static void +_gdk_file_scale_size_prepared_cb (GdkPixbufLoader *loader, + int width, + int height, + gpointer data) +{ + struct { + gint width; + gint height; + gboolean preserve_aspect_ratio; + } *info = data; + + g_return_if_fail (width > 0 && height > 0); + + if (info->preserve_aspect_ratio && + (info->width > 0 || info->height > 0)) { + if (info->width < 0) + { + width = width * (double)info->height/(double)height; + height = info->height; + } + else if (info->height < 0) + { + height = height * (double)info->width/(double)width; + width = info->width; + } + else if ((double)height * (double)info->width > + (double)width * (double)info->height) { + width = 0.5 + (double)width * (double)info->height / (double)height; + height = info->height; + } else { + height = 0.5 + (double)height * (double)info->width / (double)width; + width = info->width; + } + } else { + if (info->width > 0) + width = info->width; + if (info->height > 0) + height = info->height; + } + + gdk_pixbuf_loader_set_size (loader, width, height); +} + +GdkPixbuf * +gdk_pixbuf_new_from_file_at_scale(const char *filename, int width, int height, + gboolean preserve_aspect_ratio, + GError **error) +{ + GdkPixbufLoader *loader; + GdkPixbuf *pixbuf; + guchar buffer [4096]; + int length; + FILE *f; + struct { + gint width; + gint height; + gboolean preserve_aspect_ratio; + } info; + GdkPixbufAnimation *animation; + GdkPixbufAnimationIter *iter; + gboolean has_frame; + + g_return_val_if_fail (filename != NULL, NULL); + g_return_val_if_fail (width > 0 || width == -1, NULL); + g_return_val_if_fail (height > 0 || height == -1, NULL); + + f = g_fopen (filename, "rb"); + if (!f) { + gint save_errno = errno; + gchar *display_name = g_filename_to_utf8 (filename, -1, NULL, NULL, NULL); + g_set_error (error, G_FILE_ERROR, g_file_error_from_errno (save_errno), + _("Failed to open file '%s': %s"), + display_name ? display_name : "(unknown)", + g_strerror (save_errno)); + g_free (display_name); + return NULL; + } + + loader = gdk_pixbuf_loader_new (); + + info.width = width; + info.height = height; + info.preserve_aspect_ratio = preserve_aspect_ratio; + + g_signal_connect (loader, "size-prepared", G_CALLBACK (_gdk_file_scale_size_prepared_cb), &info); + + has_frame = FALSE; + while (!has_frame && !feof (f) && !ferror (f)) { + length = fread (buffer, 1, sizeof (buffer), f); + if (length > 0) + if (!gdk_pixbuf_loader_write (loader, buffer, length, error)) { + gdk_pixbuf_loader_close (loader, NULL); + fclose (f); + g_object_unref (loader); + return NULL; + } + + animation = gdk_pixbuf_loader_get_animation (loader); + if (animation) { + iter = gdk_pixbuf_animation_get_iter (animation, 0); + if (!gdk_pixbuf_animation_iter_on_currently_loading_frame (iter)) { + has_frame = TRUE; + } + g_object_unref (iter); + } + } + + fclose (f); + + if (!gdk_pixbuf_loader_close (loader, error) && !has_frame) { + g_object_unref (loader); + return NULL; + } + + pixbuf = gdk_pixbuf_loader_get_pixbuf (loader); + + if (!pixbuf) { + gchar *display_name = g_filename_to_utf8 (filename, -1, NULL, NULL, NULL); + g_object_unref (loader); + g_set_error (error, GDK_PIXBUF_ERROR, GDK_PIXBUF_ERROR_FAILED, + _("Failed to load image '%s': reason not known, probably a corrupt image file"), + display_name ? display_name : "(unknown)"); + g_free (display_name); + return NULL; + } + + g_object_ref (pixbuf); + + g_object_unref (loader); + + return pixbuf; +} +#endif + diff -r f306918687a4 -r c18bdf510325 gtk/gtkutils.h --- a/gtk/gtkutils.h Sun Aug 20 17:34:21 2006 +0000 +++ b/gtk/gtkutils.h Sun Aug 20 17:49:58 2006 +0000 @@ -479,4 +479,15 @@ */ char* gaim_gtk_convert_buddy_icon(GaimPlugin *plugin, const char *path); +#if !GTK_CHECK_VERSION(2,6,0) +/** + * Creates a new pixbuf by loading an image from a file. The image will + * be scaled to fit in the requested size, optionally preserving the image's + * aspect ratio. + */ +GdkPixbuf *gdk_pixbuf_new_from_file_at_scale(const char *filename, int width, int height, + gboolean preserve_aspect_ratio, + GError **error); +#endif + #endif /* _GAIM_GTKUTILS_H_ */ diff -r f306918687a4 -r c18bdf510325 libgaim/Makefile.am --- a/libgaim/Makefile.am Sun Aug 20 17:34:21 2006 +0000 +++ b/libgaim/Makefile.am Sun Aug 20 17:49:58 2006 +0000 @@ -250,7 +250,7 @@ $(gaim_coreheaders) \ $(dbus_headers) -libgaim_la_DEPENDENCIES = @LIBOBJS@ $(STATIC_LINK_LIBS) $(MS_LIBS) +libgaim_la_DEPENDENCIES = @LIBOBJS@ $(STATIC_LINK_LIBS) libgaim_la_LDFLAGS = -export-dynamic libgaim_la_LIBADD = \ @LIBOBJS@ \ @@ -267,7 +267,6 @@ -DLIBDIR=\"$(libdir)/gaim/\" \ -DLOCALEDIR=\"$(datadir)/locale\" \ -DSYSCONFDIR=\"$(sysconfdir)\" \ - -I$(top_srcdir)/plugins \ $(GLIB_CFLAGS) \ $(DEBUG_CFLAGS) \ $(DBUS_CFLAGS) \ diff -r f306918687a4 -r c18bdf510325 libgaim/xmlnode.c --- a/libgaim/xmlnode.c Sun Aug 20 17:34:21 2006 +0000 +++ b/libgaim/xmlnode.c Sun Aug 20 17:49:58 2006 +0000 @@ -403,12 +403,15 @@ xmlnode_set_namespace(node, namespace); for(i=0; i < nb_attributes * 5; i+=5) { +#ifdef HAVE_LIBXML + char *txt; +#endif int attrib_len = attributes[i+4] - attributes[i+3]; char *attrib = g_malloc(attrib_len + 1); memcpy(attrib, attributes[i+3], attrib_len); attrib[attrib_len] = '\0'; #ifdef HAVE_LIBXML - char *txt = attrib; + txt = attrib; attrib = gaim_unescape_html(txt); g_free(txt); #endif