gimp r26370 - in trunk: . app/gui



Author: neo
Date: Tue Aug  5 09:02:04 2008
New Revision: 26370
URL: http://svn.gnome.org/viewvc/gimp?rev=26370&view=rev

Log:
2008-08-05  Sven Neumann  <sven gimp org>

	* app/gui/gimpdbusservice.c: open the files from an idle 
handler.
	Opening a file may take a while (in particular if it involves
	asking the user for input) and we need to respond to the D-Bus
	call before it times out.



Modified:
   trunk/ChangeLog
   trunk/app/gui/gimpdbusservice.c

Modified: trunk/app/gui/gimpdbusservice.c
==============================================================================
--- trunk/app/gui/gimpdbusservice.c	(original)
+++ trunk/app/gui/gimpdbusservice.c	Tue Aug  5 09:02:04 2008
@@ -71,6 +71,44 @@
   return G_OBJECT (service);
 }
 
+typedef struct
+{
+  Gimp     *gimp;
+  gchar    *uri;
+  gboolean  as_new;
+} IdleData;
+
+static IdleData *
+gimp_dbus_service_open_idle_new (GimpDBusService *service,
+                                 const gchar     *uri,
+                                 gboolean         as_new)
+{
+  IdleData *data = g_slice_new (IdleData);
+
+  data->gimp   = g_object_ref (service->gimp);
+  data->uri    = g_strdup (uri);
+  data->as_new = as_new;
+
+  return data;
+}
+
+static void
+gimp_dbus_service_open_idle_free (IdleData *data)
+{
+  g_object_unref (data->gimp);
+  g_free (data->uri);
+
+  g_slice_free (IdleData, data);
+}
+
+static gboolean
+gimp_dbus_service_open_idle (IdleData *data)
+{
+  file_open_from_command_line (data->gimp, data->uri, data->as_new);
+
+  return FALSE;
+}
+
 gboolean
 gimp_dbus_service_open (GimpDBusService  *service,
                         const gchar      *uri,
@@ -81,7 +119,15 @@
   g_return_val_if_fail (uri != NULL, FALSE);
   g_return_val_if_fail (success != NULL, FALSE);
 
-  *success = file_open_from_command_line (service->gimp, uri, FALSE);
+  g_idle_add_full (G_PRIORITY_DEFAULT_IDLE,
+                   (GSourceFunc) gimp_dbus_service_open_idle,
+                   gimp_dbus_service_open_idle_new (service, uri, FALSE),
+                   (GDestroyNotify) gimp_dbus_service_open_idle_free);
+
+  /*  The call always succeeds as it is handled in one way or another.
+   *  Even presenting an error message is considered success ;-)
+   */
+  *success = TRUE;
 
   return TRUE;
 }
@@ -96,7 +142,15 @@
   g_return_val_if_fail (uri != NULL, FALSE);
   g_return_val_if_fail (success != NULL, FALSE);
 
-  *success = file_open_from_command_line (service->gimp, uri, TRUE);
+  g_idle_add_full (G_PRIORITY_DEFAULT_IDLE,
+                   (GSourceFunc) gimp_dbus_service_open_idle,
+                   gimp_dbus_service_open_idle_new (service, uri, TRUE),
+                   (GDestroyNotify) gimp_dbus_service_open_idle_free);
+
+  /*  The call always succeeds as it is handled in one way or another.
+   *  Even presenting an error message is considered success ;-)
+   */
+  *success = TRUE;
 
   return TRUE;
 }
@@ -116,4 +170,5 @@
   return TRUE;
 }
 
+
 #endif /* HAVE_DBUS_GLIB */



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