[nautilus-sendto] Change the return value of the send_files method



commit ac0cc3bcb97eb1b93a7efa95b8a2cd1cd0f825da
Author: Bastien Nocera <hadess hadess net>
Date:   Fri Aug 20 19:08:03 2010 +0100

    Change the return value of the send_files method
    
    Now an enum, so we can get status reports from plugins some
    other way when the process of sending will be long.

 src/nautilus-sendto-command.c                     |    6 +++---
 src/plugins/evolution/evolution.c                 |    4 ++--
 src/plugins/nautilus-sendto-plugin.c              |   10 ++++++----
 src/plugins/nautilus-sendto-plugin.h              |   14 +++++++++++---
 src/plugins/removable-devices/removable-devices.c |    4 ++--
 5 files changed, 24 insertions(+), 14 deletions(-)
---
diff --git a/src/nautilus-sendto-command.c b/src/nautilus-sendto-command.c
index 70dd67d..b59b4a3 100644
--- a/src/nautilus-sendto-command.c
+++ b/src/nautilus-sendto-command.c
@@ -105,7 +105,7 @@ send_button_cb (GtkWidget *widget, NS_ui *ui)
 	char *id;
 	PeasPluginInfo *info;
 	PeasExtension *ext;
-	gboolean success;
+	NautilusSendtoSendStatus status;
 
 	treeselection = gtk_tree_view_get_selection (GTK_TREE_VIEW (ui->options_treeview));
 	if (gtk_tree_selection_get_selected (treeselection, &model, &iter) == FALSE)
@@ -124,8 +124,8 @@ send_button_cb (GtkWidget *widget, NS_ui *ui)
 	info = peas_engine_get_plugin_info (engine, id);
 	ext = peas_extension_set_get_extension (exten_set, info);
 
-	if (peas_extension_call (ext, "send_files", file_list, &success) == FALSE ||
-	    success == FALSE) {
+	if (peas_extension_call (ext, "send_files", file_list, &status) == FALSE ||
+	    status != NST_SEND_STATUS_SUCCESS) {
 		/* FIXME report the error in the UI */
 		g_warning ("Failed to send files");
 		make_sensitive_for_send (ui, TRUE);
diff --git a/src/plugins/evolution/evolution.c b/src/plugins/evolution/evolution.c
index 34cda98..83b74b6 100644
--- a/src/plugins/evolution/evolution.c
+++ b/src/plugins/evolution/evolution.c
@@ -413,7 +413,7 @@ get_sylpheed_mailto (EvolutionPlugin *p,
 	}
 }
 
-static gboolean
+static NautilusSendtoSendStatus
 evolution_plugin_send_files (NautilusSendtoPlugin *plugin,
 			     GList                *file_list)
 {
@@ -462,7 +462,7 @@ evolution_plugin_send_files (NautilusSendtoPlugin *plugin,
 	g_spawn_command_line_async (cmd, NULL);
 	g_free (cmd);
 
-	return TRUE;
+	return NST_SEND_STATUS_SUCCESS;
 }
 
 static void
diff --git a/src/plugins/nautilus-sendto-plugin.c b/src/plugins/nautilus-sendto-plugin.c
index fd586bd..a2b85b7 100644
--- a/src/plugins/nautilus-sendto-plugin.c
+++ b/src/plugins/nautilus-sendto-plugin.c
@@ -90,11 +90,13 @@ nautilus_sendto_plugin_supports_mime_types (NautilusSendtoPlugin  *plugin,
  * @plugin: a #NautilusSendtoPlugin instance
  * @file_list: (element-type utf8): a #GList of strings representing the files to send
  *
- * Returns a #gboolean representing failure or success
+ * Returns a #NautilusSendtoSendStatus representing failure or success
  *
- * Return value: %FALSE on failure.
+ * Return value: %NST_SEND_STATUS_SUCCESS on success,
+ * %NST_SEND_STATUS_IN_PROGRESS if the send will take a while,
+ * %NST_SEND_STATUS_FAILED if it failed.
  */
-gboolean
+NautilusSendtoSendStatus
 nautilus_sendto_plugin_send_files (NautilusSendtoPlugin *plugin,
 				   GList                *file_list)
 {
@@ -107,5 +109,5 @@ nautilus_sendto_plugin_send_files (NautilusSendtoPlugin *plugin,
 	if (G_LIKELY (iface->send_files != NULL))
 		return iface->send_files (plugin, file_list);
 
-	return FALSE;
+	return NST_SEND_STATUS_FAILED;
 }
diff --git a/src/plugins/nautilus-sendto-plugin.h b/src/plugins/nautilus-sendto-plugin.h
index ec640f1..8300fe0 100644
--- a/src/plugins/nautilus-sendto-plugin.h
+++ b/src/plugins/nautilus-sendto-plugin.h
@@ -36,13 +36,20 @@ G_BEGIN_DECLS
 typedef struct _NautilusSendtoPlugin           NautilusSendtoPlugin; /* dummy typedef */
 typedef struct _NautilusSendtoPluginInterface  NautilusSendtoPluginInterface;
 
+typedef enum {
+	NST_SEND_STATUS_SUCCESS,
+	NST_SEND_STATUS_IN_PROGRESS,
+	NST_SEND_STATUS_FAILED
+} NautilusSendtoSendStatus;
+
 struct _NautilusSendtoPluginInterface
 {
 	GTypeInterface g_iface;
 
 	gboolean    (*supports_mime_types) (NautilusSendtoPlugin *plugin,
 					    const char          **mime_types);
-	gboolean    (*send_files)  (NautilusSendtoPlugin *plugin,
+	NautilusSendtoSendStatus
+		    (*send_files)  (NautilusSendtoPlugin *plugin,
 				    GList                *file_list);
 	GtkWidget  *(*get_widget)  (NautilusSendtoPlugin *plugin,
 				    GList                *file_list);
@@ -53,14 +60,15 @@ GtkWidget  *nautilus_sendto_plugin_get_widget (NautilusSendtoPlugin  *plugin,
 					       GList                 *file_list);
 gboolean    nautilus_sendto_plugin_supports_mime_types (NautilusSendtoPlugin *plugin,
 							const char          **mime_types);
-gboolean    nautilus_sendto_plugin_send_files (NautilusSendtoPlugin *plugin,
+NautilusSendtoSendStatus
+	    nautilus_sendto_plugin_send_files (NautilusSendtoPlugin *plugin,
 					       GList                *file_list);
 
 #define NAUTILUS_PLUGIN_REGISTER(TYPE_NAME, TypeName, type_name)					\
 	GType type_name##_get_type (void) G_GNUC_CONST;							\
 	G_MODULE_EXPORT void  peas_register_types (PeasObjectModule *module);				\
 	static GtkWidget *type_name##_get_widget (NautilusSendtoPlugin *plugin, GList *file_list);	\
-	static gboolean type_name##_send_files (NautilusSendtoPlugin *plugin, GList *file_list);	\
+	static NautilusSendtoSendStatus type_name##_send_files (NautilusSendtoPlugin *plugin, GList *file_list); \
 	static gboolean type_name##_supports_mime_types (NautilusSendtoPlugin *plugin, const char **mime_types); \
 	static void nautilus_sendto_plugin_iface_init (NautilusSendtoPluginInterface *iface);		\
 	static void type_name##_finalize (GObject *object);						\
diff --git a/src/plugins/removable-devices/removable-devices.c b/src/plugins/removable-devices/removable-devices.c
index 8a81f4a..01723fa 100644
--- a/src/plugins/removable-devices/removable-devices.c
+++ b/src/plugins/removable-devices/removable-devices.c
@@ -161,7 +161,7 @@ cb_mount_added (GVolumeMonitor         *volume_monitor,
 
 }
 
-static gboolean
+static NautilusSendtoSendStatus
 removable_devices_plugin_send_files (NautilusSendtoPlugin *plugin,
 				     GList                *file_list)
 {
@@ -182,7 +182,7 @@ removable_devices_plugin_send_files (NautilusSendtoPlugin *plugin,
 
 	g_object_unref (mount_root);
 
-	return TRUE;
+	return NST_SEND_STATUS_SUCCESS;
 }
 
 static gboolean



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