[cairo-compmgr] wrong plugin dependencies

[ Thread Index | Date Index | More lists.tuxfamily.org/cairo-compmgr Archives ]


Hi,

In the actual code the plugin dependence is not done right. For
example, suppose that we have a plugin called "Swellow" that depends
upon (loads after) the "Magnifier" plugin, so if we have the following
plugins entering the system, the other will be wrong:

1. Magnifier
2. Menu Animation
3 .Swellow

Since the load order will be: Swellow, Menu Animation and Magnifier,
instead of Menu Animation, Magnifier and Swellow.

The attached patch correct the problem.

Best regards,
Carlos.
diff --git a/plugins/magnifier/ccm-magnifier.c b/plugins/magnifier/ccm-magnifier.c
diff --git a/plugins/magnifier/ccm-magnifier.plugin.desktop.in b/plugins/magnifier/ccm-magnifier.plugin.desktop.in
index adf9ea0..bb2bf62 100644
--- a/plugins/magnifier/ccm-magnifier.plugin.desktop.in
+++ b/plugins/magnifier/ccm-magnifier.plugin.desktop.in
@@ -3,4 +3,4 @@ Plugin=ccm-magnifier
 _Name=Magnifier
 _Description=Cairo Composite Manager Magnifier
 Backends=xrender;glitz
-Depends=
+Depends=Shadow
diff --git a/plugins/shadow/ccm-shadow.c b/plugins/shadow/ccm-shadow.c
diff --git a/plugins/shadow/ccm-shadow.plugin.desktop.in b/plugins/shadow/ccm-shadow.plugin.desktop.in
diff --git a/po/Makefile.in.in b/po/Makefile.in.in
diff --git a/src/ccm-extension-loader.c b/src/ccm-extension-loader.c
index e325200..564b462 100644
--- a/src/ccm-extension-loader.c
+++ b/src/ccm-extension-loader.c
@@ -94,9 +94,8 @@ ccm_extension_loader_new ()
 					
 					if ((plugin = ccm_extension_new(file)) != NULL)
 					{
-						self->priv->plugins = g_slist_insert_sorted (
-										self->priv->plugins, plugin,
-										(GCompareFunc)_ccm_extension_compare);
+						_ccm_extension_insert_sorted (&self->priv->plugins,
+													  plugin);
 					}
 					g_free(file);
 				}
diff --git a/src/ccm-extension.c b/src/ccm-extension.c
index 852fed1..1524f9f 100644
--- a/src/ccm-extension.c
+++ b/src/ccm-extension.c
@@ -239,6 +239,30 @@ ccm_extension_get_type_object (CCMExtension* self)
 	return self->priv->type;
 }
 
+void
+_ccm_extension_insert_sorted (GSList** self, CCMExtension* in)
+
+{
+	gint most_far = -1;
+	int cpt;
+	GSList *tmp;
+
+	tmp = *self;
+
+	while (tmp) {
+		CCMExtension *on = CCM_EXTENSION (tmp->data);
+		for (cpt = 0; in->priv->depends[cpt]; cpt++) {
+			if (!g_ascii_strcasecmp (in->priv->depends[cpt],
+									 on->priv->label)) {
+				most_far = g_slist_index (*self, on);
+			}
+		}
+		tmp = tmp->next;
+	}
+
+	*self = g_slist_insert (*self, in, most_far + 1);
+}
+
 gint
 _ccm_extension_compare(CCMExtension* self, CCMExtension* other)
 {
diff --git a/src/ccm-extension.h b/src/ccm-extension.h
index ee363d5..de402da 100644
--- a/src/ccm-extension.h
+++ b/src/ccm-extension.h
@@ -58,6 +58,8 @@ GType 			ccm_extension_get_type_object 	(CCMExtension* self);
 const gchar*	ccm_extension_get_label			(CCMExtension* self);
 gint			_ccm_extension_compare			(CCMExtension* self, 
 												 CCMExtension* other);
+void            _ccm_extension_insert_sorted    (GSList** self,
+												 CCMExtension* in);
 
 G_END_DECLS
 


Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/