[fusion-commits] Compiz configuration system library: Changes to 'master' (bf0669318f93a5049a0466379e7f4c4b6155fb70)

guillaume at server.beryl-project.org guillaume at server.beryl-project.org
Mon Jul 9 16:30:51 CEST 2007


New commits:
commit bf0669318f93a5049a0466379e7f4c4b6155fb70
Author: Guillaume Seguin <guillaume at segu.in>
Date:   Mon Jul 9 16:30:51 2007 +0200

    * Add ccsEmptyContextNew to create a context without any plugin
    * Add ccsLoadPlugin to attempt to load a single plugin


 include/ccs.h |    5 +++++
 src/compiz.c  |   47 ++++++++++++++++++++++++++++++++++++-----------
 src/main.c    |   14 +++++++++++---
 3 files changed, 52 insertions(+), 14 deletions(-)


Modified: fusion/compizconfig/libcompizconfig/include/ccs.h
===================================================================
--- fusion/compizconfig/libcompizconfig/include/ccs.h
+++ fusion/compizconfig/libcompizconfig/include/ccs.h
@@ -403,9 +403,14 @@ struct _CCSPluginCategory
 void ccsSetBasicMetadata (Bool value);
 CCSContext* ccsContextNew (unsigned int *screens,
 			   unsigned int numScreens);
+CCSContext* ccsEmptyContextNew (unsigned int *screens,
+				unsigned int numScreens);
 void ccsContextDestroy (CCSContext * context);
 CCSBackendVTable* getBackendInfo (void);
 
+Bool ccsLoadPlugin (CCSContext *context,
+		    char       *name);
+
 CCSPlugin* ccsFindPlugin (CCSContext *context,
 			  char       *name);
 

Modified: fusion/compizconfig/libcompizconfig/src/compiz.c
===================================================================
--- fusion/compizconfig/libcompizconfig/src/compiz.c
+++ fusion/compizconfig/libcompizconfig/src/compiz.c
@@ -1512,14 +1512,28 @@ pluginXMLFilter (const struct dirent *name)
 }
 
 static void
+loadPluginsFromXMLFile (CCSContext * context, char *name)
+{
+    xmlDoc *doc = NULL;
+    FILE *fp = fopen (name, "r");
+
+    if (fp)
+    {
+	fclose (fp);
+	doc = xmlReadFile (name, NULL, 0);
+	if (doc)
+	    loadPluginsFromXML (context, doc, name);
+	xmlFreeDoc (doc);
+    }
+}
+
+static void
 loadPluginsFromXMLFiles (CCSContext * context, char *path)
 {
 
     struct dirent **nameList;
     char *name;
     int nFile, i;
-    FILE *fp;
-    xmlDoc *doc = NULL;
 
     if (!path)
 	return;
@@ -1534,16 +1548,8 @@ loadPluginsFromXMLFiles (CCSContext * context, char *path)
 	asprintf (&name, "%s/%s", path, nameList[i]->d_name);
 	free (nameList[i]);
 
-	fp = fopen (name, "r");
+	loadPluginsFromXMLFile (context, name);
 
-	if (fp)
-	{
-	    fclose (fp);
-	    doc = xmlReadFile (name, NULL, 0);
-	    if (doc)
-		loadPluginsFromXML (context, doc, name);
-	    xmlFreeDoc (doc);
-	}
 	free (name);
     }
     free (nameList);
@@ -1642,6 +1648,25 @@ loadPluginsFromName (CCSContext * context, char *path)
     free (nameList);
 }
 
+Bool
+ccsLoadPlugin (CCSContext * context, char *name)
+{
+    char *path = NULL;
+    char *home = getenv ("HOME");
+    if (home && strlen (home))
+    {
+	asprintf (&path, "%s/.compiz/metadata/%s.xml", home, name);
+	loadPluginsFromXMLFile (context, path);
+	free (path);
+    }
+
+    asprintf (&path, "%s/%s.xml", METADATADIR, name);
+    loadPluginsFromXMLFile (context, path);
+    free (path);
+
+    return (ccsFindPlugin (context, name) != NULL);
+}
+
 void
 ccsLoadPlugins (CCSContext * context)
 {

Modified: fusion/compizconfig/libcompizconfig/src/main.c
===================================================================
--- fusion/compizconfig/libcompizconfig/src/main.c
+++ fusion/compizconfig/libcompizconfig/src/main.c
@@ -81,7 +81,7 @@ configChangeNotify (unsigned int watchId, void *closure)
 }
 
 CCSContext *
-ccsContextNew (unsigned int *screens, unsigned int numScreens)
+ccsEmptyContextNew (unsigned int *screens, unsigned int numScreens)
 {
     NEW (CCSContext, context);
 
@@ -102,8 +102,6 @@ ccsContextNew (unsigned int *screens, unsigned int numScreens)
 	context->numScreens = 1;
     }
 
-    ccsLoadPlugins (context);
-
     initGeneralOptions (context);
     context->configWatchId = ccsAddConfigWatch (context, configChangeNotify);
 
@@ -117,6 +115,16 @@ ccsContextNew (unsigned int *screens, unsigned int numScreens)
     return context;
 }
 
+CCSContext *
+ccsContextNew (unsigned int *screens, unsigned int numScreens)
+{
+    CCSContext *context = ccsEmptyContextNew (screens, numScreens);
+
+    ccsLoadPlugins (context);
+
+    return context;
+}
+
 CCSPlugin *
 ccsFindPlugin (CCSContext * context, char *name)
 {


More information about the commits mailing list