[beryl-commits] A scheme interpreter embedded in a compiz plugin with wrappings for making useful scripts.: Changes to 'master' (63633b2e46f8f13e6c9d725d854b98a8a7ba907f)

maniac at server.beryl-project.org maniac at server.beryl-project.org
Tue Jun 5 09:39:48 CEST 2007


New commits:
commit 63633b2e46f8f13e6c9d725d854b98a8a7ba907f
Author: Danny Baumann <dannybaumann at web.de>
Date:   Tue Jun 5 09:39:36 2007 +0200

    Make schemep use the metadata system.


 scheme.c    |  100 ++++++++++++++++++++++++++++------------------------------
 schemep.xml |   17 ++++++++++
 2 files changed, 65 insertions(+), 52 deletions(-)
 create mode 100644 schemep.xml


Modified: compcomm/plugins/compiz-scheme/scheme.c
===================================================================
--- compcomm/plugins/compiz-scheme/scheme.c
+++ compcomm/plugins/compiz-scheme/scheme.c
@@ -40,7 +40,6 @@ SCM errorPort;
 #define SCHEME_DISPLAY_OPTION_PROMPT 0
 #define SCHEME_DISPLAY_OPTION_NUM 1
 
-
 // TODO:
 //      Implement place hook.
 //      Make interface more betteris.
@@ -66,9 +65,7 @@ typedef struct _SchemeScreen {
 } SchemeScreen;
 
 static int displayPrivateIndex;
-
-
-
+static CompMetadata schemeMetadata;
 
 #define GET_SCHEME_DISPLAY(d)				     \
     ((SchemeDisplay *) (d)->privates[displayPrivateIndex].ptr)
@@ -124,32 +121,6 @@ addOptionToSchemeDisplay(CompOption *o)
 	sd->numOptions++;
 }
 
-static void
-schemeDisplayInitOptions (SchemeDisplay *sd)
-{
-    CompOption *o;
-
-    o = &sd->opt[SCHEME_DISPLAY_OPTION_PROMPT];
-    o->name			     = "prompt-toggle";
-    //o->shortDesc		     = N_("Toggle prompt visible.");
-    //o->longDesc			     = N_("Toggle prompt visible.");
-    o->type			     = CompOptionTypeAction;
-    o->value.action.initiate	     = schemePromptToggle;
-    o->value.action.terminate	     = 0;
-    o->value.action.bell	     = FALSE;
-    o->value.action.type	  = CompBindingTypeKey;
-    o->value.action.state	 |= CompActionStateInitKey;
-    o->value.action.state	 |= CompActionStateInitButton;
-    o->value.action.key.modifiers = (CompSuperMask);
-    o->value.action.key.keycode   =
-	XKeysymToKeycode (compDisplays->display,
-			  XStringToKeysym ("o"));
-	
-   sd->numOptions = 1;
-   sd->realOptions = malloc(sizeof(CompOption));
-   memcpy(sd->realOptions, o, sizeof(CompOption));
-}
-
 //Used for new window hook.
 static Bool
 schemeDamageWindowRect (CompWindow *w, Bool initial, BoxPtr rect)
@@ -270,6 +241,10 @@ schemeMatchPropertyChanged(CompDisplay *d, CompWindow *w)
 	WRAP (sd, d, matchPropertyChanged, schemeMatchPropertyChanged);
 }
 
+static const CompMetadataOptionInfo schemeDisplayOptionInfo[] = {
+    { "toggle_prompt", "action", 0, schemePromptToggle, 0 }
+};
+
 // Nothing interesting here.
 static Bool
 schemeInitDisplay (CompPlugin  *p,
@@ -281,6 +256,16 @@ schemeInitDisplay (CompPlugin  *p,
     if (!sd)
 	return FALSE;
 
+    if (!compInitDisplayOptionsFromMetadata (d,
+					     &schemeMetadata,
+					     schemeDisplayOptionInfo,
+					     sd->opt,
+					     SCHEME_DISPLAY_OPTION_NUM))
+    {
+	free (sd);
+	return FALSE;
+    }
+
     sd->screenPrivateIndex = allocateScreenPrivateIndex (d);
     if (sd->screenPrivateIndex < 0)
     {
@@ -292,8 +277,9 @@ schemeInitDisplay (CompPlugin  *p,
 
      sd->showingPrompt = 1;
  
-    schemeDisplayInitOptions(sd);
-
+     sd->numOptions = SCHEME_DISPLAY_OPTION_NUM;
+     sd->realOptions = malloc(sizeof(CompOption) * sd->numOptions);
+     memcpy(sd->realOptions, sd->opt, sizeof(CompOption) * sd->numOptions);
 
     d->privates[displayPrivateIndex].ptr = sd;
 
@@ -308,8 +294,13 @@ schemeFiniDisplay (CompPlugin  *p,
     SCHEME_DISPLAY (d);
     UNWRAP (sd, d, matchPropertyChanged);
 
+    if (sd->realOptions)
+	free (sd->realOptions);
+
     freeScreenPrivateIndex (d, sd->screenPrivateIndex);
 
+    compFiniDisplayOptions (d, sd->opt, SCHEME_DISPLAY_OPTION_NUM);
+
     free (sd);
 }
 
@@ -335,8 +326,6 @@ schemeInitScreen (CompPlugin *p,
      WRAP (ss, s, windowUngrabNotify, schemeWindowUngrabNotify);
      WRAP (ss, s, preparePaintScreen, schemePreparePaintScreen);
 
-    addScreenAction (s, &sd->opt[SCHEME_DISPLAY_OPTION_PROMPT].value.action);
-
     char * path = NULL;
     char * homeDir = getenv("HOME");
     if (asprintf(&path,"%s/%s",homeDir,".compiz/scheme/startup.scm")==-1)
@@ -372,11 +361,21 @@ schemeFiniScreen (CompPlugin *p,
 static Bool
 schemeInit (CompPlugin *p)
 {
+    if (!compInitPluginMetadataFromInfo (&schemeMetadata,
+					 p->vTable->name,
+					 schemeDisplayOptionInfo,
+					 SCHEME_DISPLAY_OPTION_NUM,
+					 0, 0))
+	return FALSE;
+
     displayPrivateIndex = allocateDisplayPrivateIndex ();
     if (displayPrivateIndex < 0)
+    {
+	compFiniMetadata (&schemeMetadata);
 	return FALSE;
+    }
 
-
+    compAddMetadataFromFile (&schemeMetadata, p->vTable->name);
 
     scm_init_guile();
     scm_init_hooks();
@@ -410,9 +409,11 @@ schemeInit (CompPlugin *p)
 static void
 schemeFini (CompPlugin *p)
 {
-    if (displayPrivateIndex >= 0)
-	freeDisplayPrivateIndex (displayPrivateIndex);
+    freeDisplayPrivateIndex (displayPrivateIndex);
+
+    compFiniMetadata (&schemeMetadata);
 }
+
 // compatible-p?
 static int
 schemeGetVersion (CompPlugin *plugin,
@@ -421,6 +422,12 @@ schemeGetVersion (CompPlugin *plugin,
     return ABIVERSION;
 }
 
+static CompMetadata *
+schemeGetMetadata (CompPlugin *plugin)
+{
+    return &schemeMetadata;
+}
+
 // I commented this file from top to bottom. My comments become progressively 
 // more useless as I reach the bottom. Maybe I should try a new approach
 static CompOption *
@@ -430,7 +437,7 @@ schemeGetDisplayOptions (CompPlugin  *plugin,
 {
     SCHEME_DISPLAY (display);
 
-	*count = sd->numOptions;
+    *count = sd->numOptions;
     return sd->realOptions;
 }
 
@@ -441,32 +448,21 @@ schemeSetDisplayOption (CompPlugin  *plugin,
 		       CompOptionValue *value)
 {
     CompOption *o;
-    int	       index;
 
     SCHEME_DISPLAY (display);
 
-    o = compFindOption (sd->opt, 1, name, &index);
+    o = compFindOption (sd->opt, 1, name, NULL);
 
     if (!o)
 	return FALSE;
 
-    switch (index) {
-    case SCHEME_DISPLAY_OPTION_PROMPT:
-	if (setDisplayAction (display, o, value))
-	    return TRUE;
-    default:
-	break;
-    }
-
-    return FALSE;
+    return compSetDisplayOption (display, o, value);
 }
 
 static CompPluginVTable schemeVTable = {
     "schemep",
-    //N_("Scheme Interpreter."),
-    //N_("Embeds a Guile scheme interpreter and provides bindings for meaningful Compiz integration."),
     schemeGetVersion,
-    0, /* GetMetadata */
+    schemeGetMetadata,
     schemeInit,
     schemeFini,
     schemeInitDisplay,

Modified: compcomm/plugins/compiz-scheme/schemep.xml
new file mode 100644
===================================================================
--- /dev/null
+++ compcomm/plugins/compiz-scheme/schemep.xml
@@ -0,0 +1,17 @@
+<compiz>
+	<plugin name="schemep">
+		<short>Scheme Interpreter</short>
+		<long>Embeds a Guile scheme interpreter and provides bindings for meaningful Compiz integration.</long>
+		<category>Extras</category>
+		<display>
+			<option name="prompt_toggle" type="action">
+				<short>Toggle Prompt Visible</short>
+				<long>Toggle prompt visible.</long>
+				<allowed key="true" button="true"/>
+				<default>
+					<key>&lt;Super&gt;o</key>
+				</default>
+			</option>
+		</display>
+	</plugin>
+</compiz>



More information about the commits mailing list