gedit r6986 - in trunk: . gedit plugin-loaders/c



Author: pborelli
Date: Sat Apr 11 14:33:04 2009
New Revision: 6986
URL: http://svn.gnome.org/viewvc/gedit?rev=6986&view=rev

Log:
2009-04-11  Paolo Borelli  <pborelli katamail com>

	* plugin-loaders/c/gedit-plugin-loader-c.c:
	* gedit/gedit-object-module.c:
	* gedit/gedit-object-module.h:
	* gedit/gedit-plugins-engine.c:
	Make all C plugin resident since they may use libraries that
	do not deal well with reload. Python plugins are already
	resident.



Modified:
   trunk/ChangeLog
   trunk/gedit/gedit-object-module.c
   trunk/gedit/gedit-object-module.h
   trunk/gedit/gedit-plugins-engine.c
   trunk/plugin-loaders/c/gedit-plugin-loader-c.c

Modified: trunk/gedit/gedit-object-module.c
==============================================================================
--- trunk/gedit/gedit-object-module.c	(original)
+++ trunk/gedit/gedit-object-module.c	Sat Apr 11 14:33:04 2009
@@ -48,7 +48,8 @@
 	PROP_0,
 	PROP_MODULE_NAME,
 	PROP_PATH,
-	PROP_TYPE_REGISTRATION
+	PROP_TYPE_REGISTRATION,
+	PROP_RESIDENT
 };
 
 struct _GeditObjectModulePrivate
@@ -59,6 +60,8 @@
 	gchar *path;
 	gchar *module_name;
 	gchar *type_registration;
+
+	gboolean resident;
 };
 
 G_DEFINE_TYPE (GeditObjectModule, gedit_object_module, G_TYPE_TYPE_MODULE);
@@ -116,6 +119,11 @@
 		return FALSE;
 	}
 
+	if (module->priv->resident)
+	{
+		g_module_make_resident (module->priv->library);
+	}
+
 	return TRUE;
 }
 
@@ -174,6 +182,10 @@
 			break;
 		case PROP_TYPE_REGISTRATION:
 			g_value_set_string (value, module->priv->type_registration);
+			break;
+		case PROP_RESIDENT:
+			g_value_set_boolean (value, module->priv->resident);
+			break;
 		default:
 			g_return_if_reached ();
 	}
@@ -181,9 +193,9 @@
 
 static void
 gedit_object_module_set_property (GObject      *object,
-			   guint         prop_id,
-			   const GValue *value,
-			   GParamSpec   *pspec)
+				  guint         prop_id,
+				  const GValue *value,
+				  GParamSpec   *pspec)
 {
 	GeditObjectModule *module = GEDIT_OBJECT_MODULE (object);
 
@@ -200,6 +212,9 @@
 		case PROP_TYPE_REGISTRATION:
 			module->priv->type_registration = g_value_dup_string (value);
 			break;
+		case PROP_RESIDENT:
+			module->priv->resident = g_value_get_boolean (value);
+			break;
 		default:
 			g_return_if_reached ();
 	}
@@ -245,13 +260,23 @@
 							      G_PARAM_READWRITE |
 							      G_PARAM_CONSTRUCT_ONLY));
 
+	g_object_class_install_property (object_class,
+					 PROP_RESIDENT,
+					 g_param_spec_boolean ("resident",
+							       "Resident",
+							       "Whether the module is resident",
+							       FALSE,
+							       G_PARAM_READWRITE |
+							       G_PARAM_CONSTRUCT_ONLY));
+
 	g_type_class_add_private (klass, sizeof (GeditObjectModulePrivate));
 }
 
 GeditObjectModule *
 gedit_object_module_new (const gchar *module_name,
 			 const gchar *path,
-			 const gchar *type_registration)
+			 const gchar *type_registration,
+			 gboolean     resident)
 {
 	return (GeditObjectModule *)g_object_new (GEDIT_TYPE_OBJECT_MODULE,
 						  "module-name",
@@ -260,6 +285,8 @@
 						  path,
 						  "type-registration",
 						  type_registration,
+						  "resident",
+						  resident,
 						  NULL);
 }
 

Modified: trunk/gedit/gedit-object-module.h
==============================================================================
--- trunk/gedit/gedit-object-module.h	(original)
+++ trunk/gedit/gedit-object-module.h	Sat Apr 11 14:33:04 2009
@@ -74,9 +74,11 @@
 };
 
 GType		 gedit_object_module_get_type			(void) G_GNUC_CONST;
+
 GeditObjectModule *gedit_object_module_new			(const gchar *module_name,
 								 const gchar *path,
-								 const gchar *type_registration);
+								 const gchar *type_registration,
+								 gboolean     resident);
 
 GObject		*gedit_object_module_new_object			(GeditObjectModule *module, 
 								 const gchar	   *first_property_name,

Modified: trunk/gedit/gedit-plugins-engine.c
==============================================================================
--- trunk/gedit/gedit-plugins-engine.c	(original)
+++ trunk/gedit/gedit-plugins-engine.c	Sat Apr 11 14:33:04 2009
@@ -393,8 +393,12 @@
 	path = g_path_get_dirname (filename);
 	base = g_path_get_basename (filename);
 
-	module = gedit_object_module_new (base, path, "register_gedit_plugin_loader");
-	
+	/* for now they are all resident */
+	module = gedit_object_module_new (base,
+					  path,
+					  "register_gedit_plugin_loader",
+					  TRUE);
+
 	g_free (base);
 	g_free (path);
 

Modified: trunk/plugin-loaders/c/gedit-plugin-loader-c.c
==============================================================================
--- trunk/plugin-loaders/c/gedit-plugin-loader-c.c	(original)
+++ trunk/plugin-loaders/c/gedit-plugin-loader-c.c	Sat Apr 11 14:33:04 2009
@@ -56,9 +56,11 @@
 
 	if (module == NULL)
 	{
+		/* For now we force all modules to be resident */
 		module = gedit_object_module_new (module_name,
 						  path,
-						  "register_gedit_plugin");
+						  "register_gedit_plugin",
+						  TRUE);
 
 		/* Infos are available for all the lifetime of the loader.
 		 * If this changes, we should use weak refs or something */



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