gossip r2865 - in trunk: . libgossip src



Author: mr
Date: Tue Dec 30 02:31:45 2008
New Revision: 2865
URL: http://svn.gnome.org/viewvc/gossip?rev=2865&view=rev

Log:
	* configure.ac:
	* libgossip/gossip-ft.c: 
	* libgossip/gossip-jabber-ft.c:
	* libgossip/gossip-log.c: 
	* src/gossip-accounts-dialog.c:
	* src/gossip-app.c:
	* src/gossip-image-chooser.c:
	* src/gossip-main.c:
	* src/gossip-sound.c:
	* src/gossip-ui-utils.c:
	* src/gossip-vcard-dialog.c: Removed libgnomeui and libgnomevfs
	deps from Gossip. Now we use libcanberra-gtk for Sound support,
	the rest is done with GTK+ and GIO. This patch was provided by
	Christian Dywan and fixes bug #565498.


Modified:
   trunk/ChangeLog
   trunk/configure.ac
   trunk/libgossip/gossip-ft.c
   trunk/libgossip/gossip-jabber-ft.c
   trunk/libgossip/gossip-log.c
   trunk/src/gossip-accounts-dialog.c
   trunk/src/gossip-app.c
   trunk/src/gossip-image-chooser.c
   trunk/src/gossip-main.c
   trunk/src/gossip-sound.c
   trunk/src/gossip-ui-utils.c
   trunk/src/gossip-vcard-dialog.c

Modified: trunk/configure.ac
==============================================================================
--- trunk/configure.ac	(original)
+++ trunk/configure.ac	Tue Dec 30 02:31:45 2008
@@ -28,7 +28,7 @@
 
 LIBXML_REQUIRED=2.6.16
 GLIB_REQUIRED=2.12.0
-GTK_REQUIRED=2.10.0
+GTK_REQUIRED=2.14.0
 LIBGLADE_REQUIRED=2.0.0
 LOUDMOUTH_REQUIRED=1.4.1
 GCONF_REQUIRED=1.2.0
@@ -45,29 +45,21 @@
 IGE_PLATFORM_CHECK
 if test "x$IGE_PLATFORM" = xx11; then
    gconf_pkgconfig=gconf-2.0
-   gnome_vfs_pkgconfig=gnome-vfs-2.0
-   libgnomeui_pkgconfig=libgnomeui-2.0
    platform_pkgconfig=
    PLATFORM_CFLAGS=
    PLATFORM_LDFLAGS=
 elif test "x$IGE_PLATFORM" = xosx; then
    gconf_pkgconfig=
-   gnome_vfs_pkgconfig=
-   libgnomeui_pkgconfig=
    platform_pkgconfig="ige-mac-integration >= 0.8.2"
    PLATFORM_CFLAGS="-xobjective-c"
    PLATFORM_LDFLAGS="-framework Carbon -framework AppKit -framework IOKit -lobjc"
 elif test "x$IGE_PLATFORM" = xwin32; then
    gconf_pkgconfig=
-   gnome_vfs_pkgconfig=
-   libgnomeui_pkgconfig=
    platform_pkgconfig=
    PLATFORM_CFLAGS="-mms-bitfields"
    PLATFORM_LDFLAGS="-no-undefined -mwindows"
 else
    gconf_pkgconfig=
-   gnome_vfs_pkgconfig=
-   libgnomeui_pkgconfig=
    PLATFORM_CFLAGS=
    PLATFORM_LDFLAGS=
 fi
@@ -238,6 +230,20 @@
 
 AC_DEFINE_UNQUOTED([ISO_CODES_PREFIX],["$iso_codes_prefix"],[ISO codes prefix])
 
+gio_pkgconfig_tmp="gio-2.0 >= 2.16"
+PKG_CHECK_MODULES(GIO, $gio_pkgconfig_tmp, have_gio=yes, have_gio=no)
+if test x$have_gio = xyes; then
+  AC_DEFINE(HAVE_GIO, 1, [GIO support])
+  gio_pkgconfig=$gio_pkgconfig_tmp
+fi
+
+libcanberra_gtk_pkgconfig_tmp="libcanberra-gtk >= 0.3"
+PKG_CHECK_MODULES(LIBCANBERRA_GTK, $libcanberra_gtk_pkgconfig_tmp, have_libcanberra_gtk=yes, have_libcanberra_gtk=no)
+if test x$have_libcanberra_gtk = xyes; then
+  AC_DEFINE(HAVE_LIBCANBERRA_GTK, 1, [libCanberraGtk support])
+  libcanberra_gtk_pkgconfig=$libcanberra_gtk_pkgconfig_tmp
+fi
+
 dnl -----------------------------------------------------------
 dnl Pkg-Config dependency checks
 dnl -----------------------------------------------------------
@@ -249,7 +255,8 @@
    gobject-2.0
    $gconf_pkgconfig
    $dbus_pkgconfig
-   $gnome_vfs_pkgconfig
+   $gio_pkgconfig
+   $libcanberra_gtk_pkgconfig
    $gnome_keyring_pkgconfig
    $ebook_pkgconfig
 ])
@@ -274,8 +281,6 @@
    $dbus_pkgconfig
    $galago_pkgconfig
    $libnotify_pkgconfig
-   $libgnomeui_pkgconfig
-   $gnome_vfs_pkgconfig
    $platform_pkgconfig
 ])
 
@@ -285,13 +290,12 @@
    gobject-2.0
    loudmouth-1.0 >= $LOUDMOUTH_REQUIRED
    libxml-2.0 >= $LIBXML_REQUIRED
-   $gnome_vfs_pkgconfig
 ])
 
 if test x$have_dbus = xyes; then
    PKG_CHECK_MODULES(PEEKABOO, 
    [
-      libgnomeui-2.0 
+      libgnomeui-2.0
       libpanelapplet-2.0 >= $LIBPANELAPPLET_REQUIRED
       gconf-2.0 >= $GCONF_REQUIRED
       glib-2.0 >= $GLIB_REQUIRED
@@ -447,6 +451,7 @@
 echo
 echo "Extras:"
 echo "  DBUS:          $have_dbus"
+echo "  Sound:         $have_libcanberra_gtk (libcanberra-gtk)"
 echo "  Galago:        $have_galago"
 echo "  Notify:        $have_libnotify"
 echo "  GNOME Keyring: $have_gnome_keyring (only with GNOME)"

Modified: trunk/libgossip/gossip-ft.c
==============================================================================
--- trunk/libgossip/gossip-ft.c	(original)
+++ trunk/libgossip/gossip-ft.c	Tue Dec 30 02:31:45 2008
@@ -22,8 +22,8 @@
 
 #include <config.h>
 
-#ifdef HAVE_PLATFORM_X11
-#include <libgnomevfs/gnome-vfs.h>
+#ifdef HAVE_GIO
+#include <gio/gio.h>
 #endif
 
 #include "gossip-ft.h"
@@ -452,8 +452,8 @@
 
 	priv = GOSSIP_FT_GET_PRIVATE (ft);
 
-#ifdef HAVE_PLATFORM_X11
-	return gnome_vfs_format_file_size_for_display (priv->file_size);
+#ifdef HAVE_GIO
+	return g_format_size_for_display (priv->file_size);
 #else
 	return g_strdup_printf ("%d kB", priv->file_size / 1024);
 #endif

Modified: trunk/libgossip/gossip-jabber-ft.c
==============================================================================
--- trunk/libgossip/gossip-jabber-ft.c	(original)
+++ trunk/libgossip/gossip-jabber-ft.c	Tue Dec 30 02:31:45 2008
@@ -29,10 +29,6 @@
 
 #include <libloudermouth/loudermouth.h>
 
-#ifdef HAVE_PLATFORM_X11
-#include <libgnomevfs/gnome-vfs.h>
-#endif
-
 #include <libgossip/gossip-contact.h>
 #include <libgossip/gossip-debug.h>
 #include <libgossip/gossip-presence.h>
@@ -42,6 +38,10 @@
 #include "gossip-jabber-private.h"
 #include "gossip-jid.h"
 
+#ifdef HAVE_GIO
+#include <gio/gio.h>
+#endif
+
 #define DEBUG_DOMAIN "JabberFT"
 
 #define XMPP_FILE_TRANSFER_XMLNS   "http://jabber.org/protocol/si";
@@ -832,43 +832,54 @@
 			    gchar       **file_size,
 			    gchar       **mime_type)
 {
-#ifdef HAVE_PLATFORM_X11
-	GnomeVFSFileInfo *file_info;
-	GnomeVFSResult    result;
+#ifdef HAVE_GIO
+	GFile       *file;
+	GFileInfo   *file_info;
+	const gchar *attributes;
 
 	gossip_debug (DEBUG_DOMAIN, "Getting file info for URI:'%s'", uri);
+	
+	file = g_file_new_for_uri (uri);
 
-	file_info = gnome_vfs_file_info_new ();
-
-	result = gnome_vfs_get_file_info (uri,
-					  file_info,
-					  GNOME_VFS_FILE_INFO_DEFAULT);
+	attributes = 
+		G_FILE_ATTRIBUTE_STANDARD_NAME ","
+		G_FILE_ATTRIBUTE_STANDARD_SIZE ","
+		G_FILE_ATTRIBUTE_STANDARD_CONTENT_TYPE;
+
+	file_info = g_file_query_info (file, 
+				       attributes,
+				       G_FILE_QUERY_INFO_NONE, 
+				       NULL, 
+				       NULL);
 
-	if (result != GNOME_VFS_OK) {
-		g_warning ("Could not get file info for URI:'%s'", uri);
+	if (file_info == NULL) {
+		g_warning ("Could not obtain file info for URI:'%s'", uri);
 		return FALSE;
 	}
 
 	if (file_name) {
-		*file_name = g_strdup (file_info->name);
+		*file_name = g_strdup (g_file_info_get_name (file_info));
 	}
 
 	if (file_size) {
-		*file_size = g_strdup_printf ("%d", (guint) file_info->size);
+		*file_size = g_strdup_printf ("%u",
+					      (guint) g_file_info_get_size (file_info));
 	}
 
 	if (mime_type) {
-		gchar *s;
+		const gchar *content_type;
 
-		s = gnome_vfs_get_mime_type (uri);
-		*mime_type = s;
+		/* FIXME: Does this return a MIME type on Win32 and OSX? */
+		content_type = g_file_info_get_content_type (file_info);
+		*mime_type = g_strdup (content_type);
 
-		if (!s) {
-			*mime_type = g_strdup (GNOME_VFS_MIME_TYPE_UNKNOWN);
+		if (!content_type) {
+			*mime_type = g_strdup ("application/octet-stream");
 		}
 	}
 
-	gnome_vfs_file_info_unref (file_info);
+	g_object_unref (file_info);
+	g_object_unref (file);
 
 	return TRUE;
 #else
@@ -876,7 +887,7 @@
 		struct stat buf;
 
 		/* This is not that nice but at least makes
-		 * filetransfer work without GnomeVFS.
+		 * filetransfer work without GIO.
 		 */
 		if (!g_str_has_prefix (uri, "file://")) {
 			return FALSE;

Modified: trunk/libgossip/gossip-log.c
==============================================================================
--- trunk/libgossip/gossip-log.c	(original)
+++ trunk/libgossip/gossip-log.c	Tue Dec 30 02:31:45 2008
@@ -68,8 +68,8 @@
 #include "gossip-private.h"
 #include "gossip-utils.h"
 
-#ifdef HAVE_PLATFORM_X11
-#include <libgnomevfs/gnome-vfs.h>
+#ifdef HAVE_GIO
+#include <gio/gio.h>
 #endif
 
 #define DEBUG_DOMAIN "Log"
@@ -154,7 +154,7 @@
 static void            gossip_log_manager_class_init           (GossipLogManagerClass *klass);
 static void            gossip_log_manager_init                 (GossipLogManager      *manager);
 static void            log_manager_finalize                    (GObject               *object);
-#ifdef HAVE_PLATFORM_X11
+#ifdef HAVE_GIO
 static void            log_move_contact_dirs                   (GossipLogManager      *manager,
 								const gchar           *log_directory,
 								const gchar           *filename,
@@ -181,7 +181,7 @@
 								GossipChatroom        *chatroom,
 								GossipMessage         *message);
 static gboolean        log_check_dir                           (gchar                **directory);
-#ifdef HAVE_PLATFORM_X11
+#ifdef HAVE_GIO
 static LogVersion      log_check_version                       (void);
 #endif
 static gboolean        log_check_dir                           (gchar **directory);
@@ -278,7 +278,7 @@
 	GossipLogManagerPrivate *priv;
 	GossipLogManager     *manager;
 	GossipAccountManager *account_manager;
-#ifdef HAVE_PLATFORM_X11
+#ifdef HAVE_GIO
 	LogVersion            version;
 #endif
 	GList                *accounts, *l;
@@ -307,7 +307,7 @@
 			  NULL);
 
 	/* We only support this when running GNOME. */
-#ifdef HAVE_PLATFORM_X11
+#ifdef HAVE_GIO
 
 	/* Check for new log protocol version, and if so we fix the
 	 * differences here.
@@ -376,12 +376,12 @@
 		g_dir_close (dir);
 		g_free (log_directory);
 	}
-#endif /* HAVE_PLATFORM_X11 */
+#endif /* HAVE_GIO */
 
 	return manager;
 }
 
-#ifdef HAVE_PLATFORM_X11
+#ifdef HAVE_GIO
 static void
 log_move_contact_dirs (GossipLogManager *manager,
 		       const gchar      *log_directory,
@@ -389,24 +389,25 @@
 		       const gchar      *type_str)
 {
 	GossipLogManagerPrivate *priv;
-	GnomeVFSResult        result = GNOME_VFS_OK;
-	GnomeVFSURI          *new_uri, *old_uri;
-	GnomeVFSURI          *new_uri_unknown;
-	GossipAccount        *account;
-	gchar                *basename;
+	
+	gchar         *new_uri, *old_uri;
+	gchar         *new_uri_unknown;
+	gint           result;
+	GossipAccount *account;
+	gchar         *basename;
 
 	priv = GOSSIP_LOG_GET_PRIVATE (manager);
 
-	new_uri_unknown = gnome_vfs_uri_new (log_directory);
-	new_uri_unknown = gnome_vfs_uri_append_path (new_uri_unknown, "Unknown");
+	new_uri_unknown = g_build_filename (log_directory, "Unknown", NULL);
 	basename = g_path_get_basename (filename);
 
 	if (strcmp (basename, LOG_DIR_CHATROOMS) == 0) {
 		/* Special case */
-		old_uri = gnome_vfs_uri_new (filename);
-		new_uri = gnome_vfs_uri_ref (new_uri_unknown);
-		g_mkdir_with_parents (gnome_vfs_uri_get_path (new_uri), LOG_DIR_CREATE_MODE);
-		new_uri = gnome_vfs_uri_append_path (new_uri, basename);
+		old_uri = g_strdup (filename);
+		new_uri = g_strdup (new_uri_unknown);
+		g_mkdir_with_parents (new_uri, LOG_DIR_CREATE_MODE);
+		g_free (new_uri);
+		new_uri = g_build_filename (new_uri_unknown, basename, NULL);
 	} else if (strcmp (basename, LOG_KEY_FILENAME) == 0) {
 		/* Remove this file since it can't be
 		 * placed anywhere and it will be
@@ -417,7 +418,7 @@
 			      filename);
 		g_remove (filename);
 		g_free (basename);
-		gnome_vfs_uri_unref (new_uri_unknown);
+		g_free (new_uri_unknown);
 		return;
 	} else {
 		GossipAccountManager *account_manager;
@@ -433,35 +434,35 @@
 			gossip_debug (DEBUG_DOMAIN, 
 				      "No account related to filename:'%s'",
 				      filename);
-			old_uri = gnome_vfs_uri_new (filename);
-			new_uri = gnome_vfs_uri_dup (new_uri_unknown);
-			g_mkdir_with_parents (gnome_vfs_uri_get_path (new_uri), LOG_DIR_CREATE_MODE);
-			new_uri = gnome_vfs_uri_append_path (new_uri, basename);
+			old_uri = g_strdup (filename);
+			new_uri = g_strdup (new_uri_unknown);
+			g_mkdir_with_parents (new_uri, LOG_DIR_CREATE_MODE);
+			g_free (new_uri);
+			new_uri = g_build_filename (new_uri_unknown, basename, NULL);
 		} else {
 			const gchar *account_name;
 
-			old_uri = gnome_vfs_uri_new (filename);
-			new_uri = gnome_vfs_uri_new (log_directory);
+			old_uri = g_strdup (filename);
 
 			account_name = gossip_account_get_name (account);
-			new_uri = gnome_vfs_uri_append_path (new_uri, account_name);
-			g_mkdir_with_parents (gnome_vfs_uri_get_path (new_uri), LOG_DIR_CREATE_MODE);
+			new_uri = g_build_filename (log_directory, account_name, NULL);
+			g_mkdir_with_parents (new_uri, LOG_DIR_CREATE_MODE);
 		}
 	}
 
-	result = gnome_vfs_move_uri (old_uri, new_uri, TRUE);
+	result = g_rename (old_uri, new_uri);
 			
 	gossip_debug (DEBUG_DOMAIN,
 		      "Transfering old URI:'%s' to new URI:'%s' returned:%d->'%s'",
-		      gnome_vfs_uri_get_path (old_uri),
-		      gnome_vfs_uri_get_path (new_uri),
-		      result, 
-		      gnome_vfs_result_to_string (result));
+		      old_uri,
+		      new_uri,
+		      result,
+		      result == -1 ? "Failed" : "Succeeded");
 			
 	g_free (basename);
-	gnome_vfs_uri_unref (old_uri);
-	gnome_vfs_uri_unref (new_uri);
-	gnome_vfs_uri_unref (new_uri_unknown);
+	g_free (old_uri);
+	g_free (new_uri);
+	g_free (new_uri_unknown);
 }
 #endif
 
@@ -493,13 +494,13 @@
 			GParamSpec    *param,
 			gpointer       user_data)
 {
-#ifdef HAVE_PLATFORM_X11
+#ifdef HAVE_GIO
 	const gchar    *old_name;
 	const gchar    *new_name;
 	gchar          *log_directory;
 	gchar          *new_uri;
 	gchar          *old_uri;
-	GnomeVFSResult  result;
+	gint            result;
 
 	old_name = g_object_get_data (G_OBJECT (account), "log-name");
 	new_name = gossip_account_get_name (account);
@@ -516,12 +517,12 @@
 
 	old_uri = g_build_filename (log_directory, old_name, NULL);
 	new_uri = g_build_filename (log_directory, new_name, NULL);
-	result = gnome_vfs_move (old_uri, new_uri, TRUE);
+	result = g_rename (old_uri, new_uri);
 
 	gossip_debug (DEBUG_DOMAIN,
 		      "Transfering logs from:'%s' to:'%s' returned:%d->'%s'",
 		      old_uri, new_uri, result, 
-		      gnome_vfs_result_to_string (result));
+		      result == -1 ? "Failed" : "Succeeded");
 
 	g_object_set_data_full (G_OBJECT (account), "log-name",
 				g_strdup (new_name),
@@ -536,8 +537,8 @@
 static gchar *
 log_escape (const gchar *str)
 {
-#ifdef HAVE_PLATFORM_X11
-	return gnome_vfs_escape_host_and_path_string (str);
+#ifdef HAVE_GIO
+	return g_uri_escape_string (str, NULL, FALSE);
 #else
 	return g_strdup (str);
 #endif
@@ -546,8 +547,8 @@
 static gchar *
 log_unescape (const gchar *str)
 {
-#ifdef HAVE_PLATFORM_X11
-	return gnome_vfs_unescape_string_for_display (str);
+#ifdef HAVE_GIO
+	return g_uri_unescape_string (str, NULL);
 #else
 	return g_strdup (str);
 #endif
@@ -687,7 +688,7 @@
 	g_list_free (handlers);
 }
 
-#ifdef HAVE_PLATFORM_X11
+#ifdef HAVE_GIO
 static LogVersion
 log_check_version (void)
 {
@@ -780,7 +781,7 @@
 	
 	return LOG_VERSION_LAST;
 }
-#endif /* HAVE_PLATFORM_X11 */
+#endif /* HAVE_GIO */
 
 static gboolean
 log_check_dir (gchar **directory)

Modified: trunk/src/gossip-accounts-dialog.c
==============================================================================
--- trunk/src/gossip-accounts-dialog.c	(original)
+++ trunk/src/gossip-accounts-dialog.c	Tue Dec 30 02:31:45 2008
@@ -541,7 +541,10 @@
 		      NULL);
 
 	g_object_unref (account);
-	g_object_unref (pixbuf);
+
+	if (pixbuf) {
+		g_object_unref (pixbuf);
+	}
 }
 
 static GossipAccount *

Modified: trunk/src/gossip-app.c
==============================================================================
--- trunk/src/gossip-app.c	(original)
+++ trunk/src/gossip-app.c	Tue Dec 30 02:31:45 2008
@@ -875,9 +875,9 @@
 	gtk_widget_hide (priv->chat_context);
 	gtk_widget_hide (priv->chat_context_separator);
 
-#ifndef HAVE_HELP
-	gtk_widget_hide (help_contents);
-#endif
+/* #ifndef HAVE_HELP */
+	/* gtk_widget_hide (help_contents); */
+/* #endif */
 
 	/* Set up connection related widgets. */
 	app_connection_items_setup (glade);

Modified: trunk/src/gossip-image-chooser.c
==============================================================================
--- trunk/src/gossip-image-chooser.c	(original)
+++ trunk/src/gossip-image-chooser.c	Tue Dec 30 02:31:45 2008
@@ -25,8 +25,8 @@
 
 #include <glib/gi18n.h>
 
-#ifdef HAVE_PLATFORM_X11
-#include <libgnomevfs/gnome-vfs-ops.h>
+#ifdef HAVE_GIO
+#include <gio/gio.h>
 #endif
 
 #include <libgossip/gossip.h>
@@ -140,7 +140,7 @@
 	priv->image_min_height = -1;
 	priv->image_max_width = -1;
 	priv->image_max_height = -1;
-	priv->image_max_size = 8*1024;
+	priv->image_max_size = 8 * 1024;
 	priv->image_format = g_strdup ("image/png");
 
 	gtk_box_set_homogeneous (GTK_BOX (chooser), FALSE);
@@ -460,13 +460,11 @@
 	target_type = gdk_atom_name (selection_data->target);
 
 	if (!strcmp (target_type, URI_LIST_TYPE)) {
-#ifdef HAVE_PLATFORM_X11
-		GnomeVFSHandle   *handle;
-		GnomeVFSResult    result;
-		GnomeVFSFileInfo  info;
-		gchar            *uri;
-		gchar            *nl;
-		gchar            *data = NULL;
+		GError *error = NULL;
+		gchar  *uri;
+		gchar  *nl;
+		gchar  *data = NULL;
+		gsize   data_size;
 
 		nl = strstr (selection_data->data, "\r\n");
 		if (nl) {
@@ -476,35 +474,23 @@
 			uri = g_strdup (selection_data->data);
 		}
 
-		result = gnome_vfs_open (&handle, uri, GNOME_VFS_OPEN_READ);
-		if (result == GNOME_VFS_OK) {
-			result = gnome_vfs_get_file_info_from_handle (handle,
-								      &info,
-								      GNOME_VFS_FILE_INFO_DEFAULT);
-			if (result == GNOME_VFS_OK) {
-				GnomeVFSFileSize data_size;
-
-				data = g_malloc (info.size);
-
-				result = gnome_vfs_read (handle, data, info.size, &data_size);
-				if (result == GNOME_VFS_OK) {
-					if (image_chooser_set_image_from_data (chooser,
-									       data,
-									       data_size)) {
-						handled = TRUE;
-					} else {
-						g_free (data);
-					}
-				} else {
-					g_free (data);
-				}
+		if (g_file_get_contents (uri, &data, &data_size, &error)) {
+			if (image_chooser_set_image_from_data (chooser,
+							       data,
+							       data_size)) {
+				/* FIXME: Why don't we free data? */
+				handled = TRUE;
+			} else {
+				g_free (data);
 			}
-
-			gnome_vfs_close (handle);
+		} else {
+			g_warning ("Could not obtain file contents for URI:'%s', %s", 
+				   uri,
+				   error->message);
 		}
-
+		
+		g_clear_error (&error);
 		g_free (uri);
-#endif
 	}
 
 	gtk_drag_finish (context, handled, FALSE, time);

Modified: trunk/src/gossip-main.c
==============================================================================
--- trunk/src/gossip-main.c	(original)
+++ trunk/src/gossip-main.c	Tue Dec 30 02:31:45 2008
@@ -32,11 +32,6 @@
 #include <gtk/gtk.h>
 #include <glade/glade.h>
 
-#ifdef HAVE_PLATFORM_X11
-#include <libgnome/gnome-program.h>
-#include <libgnomeui/gnome-ui-init.h>
-#endif
-
 #include <libgossip/gossip.h>
 
 #ifdef HAVE_DBUS
@@ -60,11 +55,7 @@
 main (int argc, char *argv[])
 {
 	gchar                *localedir;
-#ifdef HAVE_PLATFORM_X11
-	GnomeProgram         *program;
-#else
 	GError               *error = NULL;
-#endif
 	gboolean              init_galago;
 	GossipSession        *session;
 	GossipAccountManager *account_manager;
@@ -109,17 +100,9 @@
 	 * GNOME_PROGRAM_STANDARD_PROPERTIES which needs it. So we simply add
 	 * this hack below to keep everyone happy.
 	 */
-#define DATADIR SHAREDIR
+// #define DATADIR SHAREDIR
+#endif
 
-	program = gnome_program_init (PACKAGE_TARNAME, 
-				      PACKAGE_VERSION,
-				      LIBGNOMEUI_MODULE,
-				      argc, argv,
-				      GNOME_PROGRAM_STANDARD_PROPERTIES,
-				      "goption-context", context,
-				      GNOME_PARAM_HUMAN_READABLE_NAME, PACKAGE_NAME,
-				      NULL);
-#else
 	if (!gtk_init_with_args (&argc, &argv,
 				 _("- Gossip Instant Messenger"),
 				 options,
@@ -128,7 +111,6 @@
 		g_printerr ("%s\n", error->message);
 		return 1;
 	}
-#endif
 
 	gossip_window_set_default_icon_name (PACKAGE_TARNAME);
 
@@ -219,10 +201,6 @@
 
 	gossip_stock_finalize ();
 
-#ifdef HAVE_PLATFORM_X11
-	g_object_unref (program);
-#endif
-
 	return EXIT_SUCCESS;
 }
 

Modified: trunk/src/gossip-sound.c
==============================================================================
--- trunk/src/gossip-sound.c	(original)
+++ trunk/src/gossip-sound.c	Tue Dec 30 02:31:45 2008
@@ -24,9 +24,9 @@
 
 #include "config.h"
 
-#ifdef HAVE_PLATFORM_X11
-#include <libgnome/gnome-sound.h>
-#include <libgnome/gnome-triggers.h>
+#ifdef HAVE_LIBCANBERRA_GTK
+#include <canberra-gtk.h>
+#include <glib/gi18n.h>
 #elif  HAVE_PLATFORM_WIN32
 #ifdef HAVE_WINDOWS_H
 #include <windows.h>
@@ -34,7 +34,7 @@
 #ifdef HAVE_MMSYSTEM_H
 #include <mmsystem.h>
 #endif /* HAVE_MMSYSTEM_H */
-#endif /* HAVE_PLATFORM_X11 */
+#endif /* HAVE_LIBCANBERRA_GTK */
 
 #include <libgossip/gossip.h>
 
@@ -201,6 +201,25 @@
 	g_hash_table_remove (contact_states, contact);
 }
 
+#ifdef HAVE_LIBCANBERRA_GTK
+
+#if 0
+
+static void 
+callback (ca_context *c, 
+	  uint32_t    id, 
+	  int         error, 
+	  void       *userdata)
+{
+        gossip_debug (DEBUG_DOMAIN,
+		      "Callback called, error '%s'\n", 
+		      ca_strerror (error));
+}
+
+#endif
+
+#endif /* HAVE_LIBCANBERRA_GTK */
+
 gboolean
 gossip_sound_play (GossipSound sound)
 {
@@ -244,23 +263,44 @@
 		return FALSE;
 	}
 
-#ifdef HAVE_PLATFORM_X11
+#ifdef HAVE_LIBCANBERRA_GTK
+	{
+	int result;
+	
 	switch (sound) {
 	case GOSSIP_SOUND_CHAT:
-		gossip_debug (DEBUG_DOMAIN, "Triggering 'Chat' sound.");
-		gnome_triggers_do (NULL, NULL, PACKAGE_TARNAME, "Chat", NULL);
+		gossip_debug (DEBUG_DOMAIN, "Triggering 'Chat' sound...");
+		result = ca_context_play (ca_gtk_context_get (), 0,
+					  CA_PROP_APPLICATION_NAME, _("Gossip Instant Messenger"),
+					  CA_PROP_EVENT_ID, PACKAGE_TARNAME G_DIR_SEPARATOR_S "chat1", 
+					  CA_PROP_EVENT_DESCRIPTION, _("Chat"), 
+					  NULL); 
 		break;
 	case GOSSIP_SOUND_ONLINE:
-		gossip_debug (DEBUG_DOMAIN, "Triggering 'Online' sound.");
-		gnome_triggers_do (NULL, NULL, PACKAGE_TARNAME, "Online", NULL);
+		gossip_debug (DEBUG_DOMAIN, "Triggering 'Online' sound...");
+		result = ca_context_play (ca_gtk_context_get (), 0,
+					  CA_PROP_APPLICATION_NAME, _("Gossip Instant Messenger"),
+					  CA_PROP_EVENT_ID, PACKAGE_TARNAME G_DIR_SEPARATOR_S "online",
+					  CA_PROP_EVENT_DESCRIPTION, _("Online"),
+					  NULL);
 		break;
 	case GOSSIP_SOUND_OFFLINE:
-		gossip_debug (DEBUG_DOMAIN, "Triggering 'Offline' sound.");
-		gnome_triggers_do (NULL, NULL, PACKAGE_TARNAME, "Offline", NULL);
+		gossip_debug (DEBUG_DOMAIN, "Triggering 'Offline' sound...");
+		result = ca_context_play (ca_gtk_context_get (), 0,
+					  CA_PROP_APPLICATION_NAME, _("Gossip Instant Messenger"),
+					  CA_PROP_EVENT_ID, PACKAGE_TARNAME G_DIR_SEPARATOR_S "offline",
+					  CA_PROP_EVENT_DESCRIPTION, _("Offline"),
+					  NULL);
 		break;
 	}
 
-	success = TRUE;
+	gossip_debug (DEBUG_DOMAIN,
+		      "Trigger result: %d->%s\n", 
+		      result,
+		      ca_strerror (result));
+	
+	success = result == 0;
+	}
 #elif HAVE_PLATFORM_WIN32
 	switch (sound) {
 	case GOSSIP_SOUND_CHAT:
@@ -291,30 +331,10 @@
 void
 gossip_sound_init (GossipSession *session)
 {
-#ifdef HAVE_PLATFORM_X11
-	gchar *filename;
-#endif /* HAVE_PLATFORM_X11 */
-
 	g_return_if_fail (GOSSIP_IS_SESSION (session));
 
 	g_assert (saved_session == NULL);
 
-#ifdef HAVE_PLATFORM_X11
-	gnome_sound_init (NULL);
-
-	filename = gossip_paths_get_sound_path ("chat1.wav");
-	gnome_sound_sample_load ("gossip/Chat", filename);
-	g_free (filename);
-
-	filename = gossip_paths_get_sound_path ("online.wav");
-	gnome_sound_sample_load ("gossip/Online", filename);
-	g_free (filename);
-
-	filename = gossip_paths_get_sound_path ("offline.wav");
-	gnome_sound_sample_load ("gossip/Offline", filename);
-	g_free (filename);
-#endif
-
 	saved_session = g_object_ref (session);
 
 	account_states = g_hash_table_new_full (gossip_account_hash,
@@ -346,10 +366,6 @@
 {
 	g_assert (saved_session != NULL);
 
-#ifdef HAVE_PLATFORM_X11
-	gnome_sound_shutdown ();
-#endif
-
 	g_signal_handlers_disconnect_by_func (saved_session,
 					      sound_protocol_connected_cb,
 					      NULL);

Modified: trunk/src/gossip-ui-utils.c
==============================================================================
--- trunk/src/gossip-ui-utils.c	(original)
+++ trunk/src/gossip-ui-utils.c	Tue Dec 30 02:31:45 2008
@@ -31,8 +31,7 @@
 
 #ifdef HAVE_PLATFORM_X11
 #include <gdk/gdkx.h>
-#include <libgnome/gnome-url.h>
-#include <libgnomeui/libgnomeui.h>
+#include <gtk/gtk.h>
 #elif defined (HAVE_PLATFORM_OSX)
 #include <Cocoa/Cocoa.h>
 #elif defined (HAVE_PLATFORM_WIN32)
@@ -249,7 +248,8 @@
 	return real_url;
 }
 
-#ifdef HAVE_PLATFORM_X11
+#if GTK_CHECK_VERSION (2, 14, 0)
+
 gboolean
 gossip_url_show (const char *url)
 {
@@ -259,7 +259,7 @@
 	gossip_debug (DEBUG_DOMAIN, "Opening URL:'%s'...", url);
 
 	real_url = url_fixup (url);
-	gnome_url_show (real_url, &error);
+	gtk_show_uri (NULL, real_url, GDK_CURRENT_TIME, &error);
 
 	if (error) {
 		g_warning ("Couldn't show URL:'%s'", real_url);
@@ -273,7 +273,9 @@
 
 	return TRUE;
 }
+
 #elif defined(HAVE_PLATFORM_OSX)
+
 gboolean
 gossip_url_show (const char *url)
 {
@@ -294,8 +296,11 @@
 
 	return TRUE;
 }
+
 #elif defined(HAVE_PLATFORM_WIN32)
+
 #ifdef HAVE_SHELLAPI_H
+
 static const char *
 url_show_error_string (gint error)
 {
@@ -381,36 +386,72 @@
 
 	return success;
 }
-#else
+
+#else /* GTK 2.14.0|HAVE_PLATFORM_{OSX|WIN32) */ 
+
 void
-gossip_url_show (const char *url)
+gossip_url_show (const gchar *url)
 {
 	gchar *real_url;
+	gchar *command;
+
 	real_url = url_fixup (url);
+
+	command = g_strconcat ("xdg-open ", real_url, NULL);
+        if (!g_spawn_command_line_async (command, NULL)) {
+		g_free (command);
+
+		if (!command = g_strconcat ("gnome-open ", real_url, NULL)) {
+			g_free (command);
+
+			if (!command = g_strconcat ("exo-open ", real_url, NULL)) {
+				g_warning ("Failed to open url:'%s'", real_url);
+			}
+		}
+	}
+
+        g_free (command);
 	g_free (real_url);
 }
-#endif
+
+#endif /* GTK 2.14.0|HAVE_PLATFORM_{OSX|WIN32) */ 
 
 void
 gossip_help_show (void)
 {
-#ifdef HAVE_PLATFORM_X11
-	gboolean   ok;
 	GtkWidget *dialog;
+	gchar *message;
+#if GTK_CHECK_VERSION (2, 14, 0)
+	GError    *err = NULL;
+
+	if (gtk_show_uri (NULL, "ghelp:gossip", GDK_CURRENT_TIME, &err)) {
+		return;
+	}
+
+	message = g_strdup (err->message);
+	g_error_free (err);
+#else  /* GTK_CHECK_VERSION (2, 14, 0) */
+	gchar     *command;
 	GError    *err = NULL;
 
-	ok = gnome_help_display ("gossip.xml", NULL, &err);
-	if (ok) {
+	command = g_strconcat ("gnome-open ", "ghelp:gossip", NULL);
+        if (g_spawn_command_line_async (command, &error)) {
+		g_free (command);
 		return;
 	}
 
+	g_free (command);
+
+	message = g_strdup (_("Online help is not supported on this platform."));
+#endif  /* GTK_CHECK_VERSION (2, 14, 0) */
+
 	dialog = gtk_message_dialog_new_with_markup (GTK_WINDOW (gossip_app_get_window ()),
 						     GTK_DIALOG_DESTROY_WITH_PARENT,
 						     GTK_MESSAGE_ERROR,
 						     GTK_BUTTONS_CLOSE,
 						     "<b>%s</b>\n\n%s",
 						     _("Could not display the help contents."),
-						     err->message);
+						     message);
 
 	g_signal_connect_swapped (dialog, "response",
 				  G_CALLBACK (gtk_widget_destroy),
@@ -418,10 +459,7 @@
 
 	gtk_widget_show (dialog);
 
-	g_error_free (err);
-#elif defined(HAVE_PLATFORM_OSX)
-	/* Nothing for now. */
-#endif
+	g_free (message);
 }
 
 static void

Modified: trunk/src/gossip-vcard-dialog.c
==============================================================================
--- trunk/src/gossip-vcard-dialog.c	(original)
+++ trunk/src/gossip-vcard-dialog.c	Tue Dec 30 02:31:45 2008
@@ -1,6 +1,7 @@
 /* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
 /*
  * Copyright (C) 2004-2007 Imendio AB
+ * Copyright (C) 2002 Red Hat, Inc.
  *
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License as
@@ -27,9 +28,8 @@
 #include <gtk/gtk.h>
 #include <glade/glade.h>
 
-#ifdef HAVE_PLATFORM_X11
-#include <libgnomeui/libgnomeui.h>
-#include <libgnomevfs/gnome-vfs-mime-utils.h>
+#if HAVE_PLATFORM_X11 && HAVE_GIO
+#include <gio/gio.h>
 #endif
 
 #include <libgossip/gossip.h>
@@ -45,11 +45,13 @@
 
 #define DEBUG_DOMAIN "VCardDialog"
 
-#define VCARD_TIMEOUT     20000
-#define SAVED_TIMEOUT     10000
+#define VCARD_TIMEOUT       20000
+#define SAVED_TIMEOUT       10000
 
-#define AVATAR_MAX_HEIGHT 96
-#define AVATAR_MAX_WIDTH  96
+#define AVATAR_MAX_HEIGHT   96
+#define AVATAR_MAX_WIDTH    96
+
+#define AVATAR_PREVIEW_SIZE 128
 
 #define RESPONSE_IMPORT   1
 
@@ -91,10 +93,6 @@
 	gboolean   requesting_vcard;
 	gint       last_account_selected;
 	gchar     *avatar_format;
-
-#ifdef HAVE_PLATFORM_X11
-	GnomeThumbnailFactory *thumbs;
-#endif
 } GossipVCardDialog;
 
 static void       vcard_dialog_create_avatar_chooser       (GossipVCardDialog *dialog);
@@ -311,79 +309,49 @@
 						     (gchar*) avatar->data, avatar->len);
 		gossip_avatar_unref (avatar);
 	}
-#endif
+#endif /* HAVE_EBOOK */
 }
 
-#ifdef HAVE_PLATFORM_X11
-
-static GdkPixbuf *
-vcard_dialog_scale_down_to_width (GdkPixbuf *pixbuf, gint wanted_width)
-{
-	gint      width, height;
-	gdouble   factor;
-
-	width = gdk_pixbuf_get_width (pixbuf);
-	height = gdk_pixbuf_get_height (pixbuf);
-
-	if (width > wanted_width) {
-		factor = (gdouble) wanted_width / MAX (width, height);
-
-		width = width * factor;
-		height = height * factor;
-
-		return gdk_pixbuf_scale_simple (pixbuf,
-						width, height,
-						GDK_INTERP_BILINEAR);
-	}
-
-	return g_object_ref (pixbuf);
-}
-
-#endif
-
 static void
 vcard_dialog_avatar_update_preview_cb (GtkFileChooser    *chooser,
 				       GossipVCardDialog *dialog)
 {
-#ifdef HAVE_PLATFORM_X11
-	gchar *uri;
+#if HAVE_PLATFORM_X11 && HAVE_GIO
+	gchar *filename;
 
-	uri = gtk_file_chooser_get_preview_uri (chooser);
-
-	if (uri) {
+	/* We are only interested in local filenames */
+	filename = gtk_file_chooser_get_preview_filename (chooser);
+	
+	if (filename) {
 		GtkWidget *image;
 		GdkPixbuf *pixbuf;
-		GdkPixbuf *scaled_pixbuf;
-		gchar     *mime_type;
+		GError    *error = NULL;
 
-		if (!dialog->thumbs) {
-			dialog->thumbs =
-				gnome_thumbnail_factory_new (GNOME_THUMBNAIL_SIZE_NORMAL);
-		}
+		pixbuf = gdk_pixbuf_new_from_file_at_scale (filename,
+							    AVATAR_PREVIEW_SIZE, 
+							    AVATAR_PREVIEW_SIZE,
+							    TRUE,
+							    &error);
 
-		mime_type = gnome_vfs_get_mime_type (uri);
-		pixbuf = gnome_thumbnail_factory_generate_thumbnail (dialog->thumbs,
-								     uri,
-								     mime_type);
 		image = gtk_file_chooser_get_preview_widget (chooser);
 
 		if (pixbuf) {
-			scaled_pixbuf = vcard_dialog_scale_down_to_width (
-				pixbuf, AVATAR_MAX_WIDTH);
-			gtk_image_set_from_pixbuf (GTK_IMAGE (image), scaled_pixbuf);
-			g_object_unref (scaled_pixbuf);
+			gtk_image_set_from_pixbuf (GTK_IMAGE (image), pixbuf);
 			g_object_unref (pixbuf);
 		} else {
+			gossip_debug (DEBUG_DOMAIN, 
+				      "Couldn't load GdkPixbuf from file scaled (%dÂ), %s",
+				      AVATAR_PREVIEW_SIZE, 
+				      error ? error->message : "no error given");
+ 
 			gtk_image_set_from_stock (GTK_IMAGE (image),
 						  "gtk-dialog-question",
 						  GTK_ICON_SIZE_DIALOG);
 		}
-
-		g_free (mime_type);
 	}
 
 	gtk_file_chooser_set_preview_widget_active (chooser, TRUE);
-#endif
+#endif /* HAVE_PLATFORM_X11 && HAVE_GIO */
 }
 
 static void



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