[nautilus-sendto] Make plugin capabilities an enumeration



commit bd2e4f1cc1843e1edb500c693fb5d4f0b596968f
Author: Bastien Nocera <hadess hadess net>
Date:   Fri Sep 11 17:34:04 2009 +0100

    Make plugin capabilities an enumeration
    
    Instead of continually adding new members to the struct.

 src/nautilus-sendto-command.c                     |    4 +-
 src/nautilus-sendto-plugin.h                      |   30 ++++++++++++--------
 src/plugins/bluetooth/bluetooth.c                 |    2 +-
 src/plugins/empathy/empathy.c                     |    2 +-
 src/plugins/evolution/evolution.c                 |    2 +-
 src/plugins/gajim/gajim.c                         |    2 +-
 src/plugins/nautilus-burn/nautilus-burn.c         |    2 +-
 src/plugins/pidgin/pidgin.c                       |    2 +-
 src/plugins/removable-devices/removable-devices.c |    2 +-
 src/plugins/upnp/upnp.c                           |    2 +-
 10 files changed, 28 insertions(+), 22 deletions(-)
---
diff --git a/src/nautilus-sendto-command.c b/src/nautilus-sendto-command.c
index 1cdda8b..84f120f 100644
--- a/src/nautilus-sendto-command.c
+++ b/src/nautilus-sendto-command.c
@@ -381,7 +381,7 @@ option_changed (GtkComboBox *cb, NS_ui *ui)
 	gtk_label_set_mnemonic_widget (GTK_LABEL (ui->send_to_label), aux->data);
 
 	p = (NstPlugin *) g_list_nth_data (plugin_list, option);
-	supports_dirs = p->info->can_send_directories;
+	supports_dirs = (p->info->capabilities & NAUTILUS_CAPS_SEND_DIRECTORIES);
 
 	if (has_dirs == FALSE || supports_dirs != FALSE) {
 		gboolean toggle;
@@ -450,7 +450,7 @@ set_model_for_options_combobox (NS_ui *ui)
 					-1);
 		if (last_used != NULL && !strcmp(last_used, p->info->id)) {
 			option = i;
-			last_used_support_dirs = p->info->can_send_directories;
+			last_used_support_dirs = (p->info->capabilities & NAUTILUS_CAPS_SEND_DIRECTORIES);
 		}
 		i++;
 	}
diff --git a/src/nautilus-sendto-plugin.h b/src/nautilus-sendto-plugin.h
index 7593544..89407d0 100644
--- a/src/nautilus-sendto-plugin.h
+++ b/src/nautilus-sendto-plugin.h
@@ -30,19 +30,26 @@
 typedef struct _NstPluginInfo NstPluginInfo;
 typedef struct _NstPlugin NstPlugin;
 
+typedef enum {
+	NAUTILUS_CAPS_NONE = 0,
+	NAUTILUS_CAPS_SEND_DIRECTORIES = 1 << 0,
+	NAUTILUS_CAPS_SEND_IMAGES = 1 << 1,
+} NstPluginCapabilities;
+
 struct _NstPluginInfo 
 {
 	gchar *icon;
 	gchar *id;
 	gchar *description;
 	gboolean never_unload;
-	gboolean can_send_directories;
-	gboolean (*init)(NstPlugin *plugin);
-	GtkWidget* (*get_contacts_widget)(NstPlugin *plugin);
-	gboolean (*validate_destination)(NstPlugin *plugin, GtkWidget *contact_widget, char **error);
-	gboolean (*send_files)(NstPlugin *plugin, GtkWidget *contact_widget,
+	NstPluginCapabilities capabilities;
+	gboolean (*init) (NstPlugin *plugin);
+	GtkWidget* (*get_contacts_widget) (NstPlugin *plugin);
+	gboolean (*validate_destination) (NstPlugin *plugin, GtkWidget *contact_widget, char **error);
+	gboolean (*send_files) (NstPlugin *plugin,
+				GtkWidget *contact_widget,
 				GList *file_list);
-    	gboolean (*destroy)(NstPlugin *plugin) ;
+	gboolean (*destroy) (NstPlugin *plugin) ;
 };
 
 struct _NstPlugin
@@ -51,11 +58,11 @@ struct _NstPlugin
 	NstPluginInfo *info;
 };
 
-# define NST_INIT_PLUGIN(plugininfo) \
-	gboolean nst_init_plugin(NstPlugin *plugin); \
-        G_MODULE_EXPORT gboolean nst_init_plugin(NstPlugin *plugin) { \
-		plugin->info = &(plugininfo);\
-                return TRUE;\
+# define NST_INIT_PLUGIN(plugininfo)					\
+	gboolean nst_init_plugin(NstPlugin *plugin);			\
+        G_MODULE_EXPORT gboolean nst_init_plugin(NstPlugin *plugin) {	\
+		plugin->info = &(plugininfo);				\
+                return TRUE;						\
         }	
 
 #define SOEXT           ("." G_MODULE_SUFFIX)
@@ -64,4 +71,3 @@ struct _NstPlugin
 
 #endif /* _NAUTILUS_SENDTO_PLUGIN_H_ */
 
-
diff --git a/src/plugins/bluetooth/bluetooth.c b/src/plugins/bluetooth/bluetooth.c
index 91df6c3..9cf36a2 100644
--- a/src/plugins/bluetooth/bluetooth.c
+++ b/src/plugins/bluetooth/bluetooth.c
@@ -546,7 +546,7 @@ NstPluginInfo plugin_info = {
 	"bluetooth",
 	N_("Bluetooth (OBEX Push)"),
 	FALSE,
-	FALSE,
+	NAUTILUS_CAPS_NONE,
 	init,
 	get_contacts_widget,
 	validate_destination,
diff --git a/src/plugins/empathy/empathy.c b/src/plugins/empathy/empathy.c
index d45bb4f..70f9a8f 100644
--- a/src/plugins/empathy/empathy.c
+++ b/src/plugins/empathy/empathy.c
@@ -280,7 +280,7 @@ NstPluginInfo plugin_info = {
   "empathy",
   N_("Instant Message (Empathy)"),
   TRUE,
-  FALSE,
+  NAUTILUS_CAPS_NONE,
   init,
   get_contacts_widget,
   validate_destination,
diff --git a/src/plugins/evolution/evolution.c b/src/plugins/evolution/evolution.c
index 52ab6de..abb4cb1 100644
--- a/src/plugins/evolution/evolution.c
+++ b/src/plugins/evolution/evolution.c
@@ -365,7 +365,7 @@ NstPluginInfo plugin_info = {
 	"evolution",
 	N_("Email"),
 	FALSE,
-	FALSE,
+	NAUTILUS_CAPS_NONE,
 	init,
 	get_contacts_widget,
 	NULL,
diff --git a/src/plugins/gajim/gajim.c b/src/plugins/gajim/gajim.c
index d6f08b2..8635d0a 100644
--- a/src/plugins/gajim/gajim.c
+++ b/src/plugins/gajim/gajim.c
@@ -488,7 +488,7 @@ NstPluginInfo plugin_info = {
 	"gajim",
 	N_("Instant Message (Gajim)"),
 	TRUE,
-	FALSE,
+	NAUTILUS_CAPS_NONE,
 	init,
 	get_contacts_widget,
 	NULL,
diff --git a/src/plugins/nautilus-burn/nautilus-burn.c b/src/plugins/nautilus-burn/nautilus-burn.c
index 05714c2..8d5e265 100644
--- a/src/plugins/nautilus-burn/nautilus-burn.c
+++ b/src/plugins/nautilus-burn/nautilus-burn.c
@@ -164,7 +164,7 @@ NstPluginInfo plugin_info = {
 	"nautilus-burn",
 	N_("CD/DVD Creator"),
 	FALSE,
-	TRUE,
+	NAUTILUS_CAPS_SEND_DIRECTORIES,
 	init,
 	get_contacts_widget,
 	NULL,
diff --git a/src/plugins/pidgin/pidgin.c b/src/plugins/pidgin/pidgin.c
index a7a5d73..6a2187c 100644
--- a/src/plugins/pidgin/pidgin.c
+++ b/src/plugins/pidgin/pidgin.c
@@ -352,7 +352,7 @@ NstPluginInfo plugin_info = {
 	"pidgin",
 	N_("Instant Message (Pidgin)"),
 	FALSE,
-	FALSE,
+	NAUTILUS_CAPS_NONE,
 	init,
 	get_contacts_widget,
 	NULL,
diff --git a/src/plugins/removable-devices/removable-devices.c b/src/plugins/removable-devices/removable-devices.c
index a302081..6c5aa5c 100644
--- a/src/plugins/removable-devices/removable-devices.c
+++ b/src/plugins/removable-devices/removable-devices.c
@@ -223,7 +223,7 @@ NstPluginInfo plugin_info = {
 	"folder-remote",
 	N_("Removable disks and shares"),
 	FALSE,
-	TRUE,
+	NAUTILUS_CAPS_SEND_DIRECTORIES,
 	init,
 	get_contacts_widget,
 	NULL,
diff --git a/src/plugins/upnp/upnp.c b/src/plugins/upnp/upnp.c
index 5f0c8b1..1307a91 100644
--- a/src/plugins/upnp/upnp.c
+++ b/src/plugins/upnp/upnp.c
@@ -300,7 +300,7 @@ NstPluginInfo plugin_info = {
 	"upnp",
 	N_("UPnP Media Server"),
 	FALSE,
-	FALSE,
+	NAUTILUS_CAPS_NONE,
 	init,
 	get_contacts_widget,
 	NULL,



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