]> Dogcows Code - chaz/openbox/blobdiff - openbox/actions/showmenu.c
more using g_slice_new() instead of g_new()
[chaz/openbox] / openbox / actions / showmenu.c
index 4b12548f6dd4bf9d070ec07a654c2e1d917d6f82..485a31d5a7e06880eee48d0f1f6aef512db13911 100644 (file)
@@ -6,39 +6,32 @@ typedef struct {
     gchar   *name;
 } Options;
 
-static gpointer setup_func(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node);
+static gpointer setup_func(xmlNodePtr node);
 static void     free_func(gpointer options);
 static gboolean run_func(ObActionsData *data, gpointer options);
 
-void action_showmenu_startup()
+void action_showmenu_startup(void)
 {
-    actions_register("ShowMenu",
-                     setup_func,
-                     free_func,
-                     run_func,
-                     NULL, NULL);
+    actions_register("ShowMenu", setup_func, free_func, run_func);
 }
 
-static gpointer setup_func(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node)
+static gpointer setup_func(xmlNodePtr node)
 {
     xmlNodePtr n;
     Options *o;
 
-    o = g_new0(Options, 1);
+    o = g_slice_new0(Options);
 
-    if ((n = parse_find_node("menu", node)))
-        o->name = parse_string(doc, n);
+    if ((n = obt_xml_find_node(node, "menu")))
+        o->name = obt_xml_node_string(n);
     return o;
 }
 
 static void free_func(gpointer options)
 {
     Options *o = options;
-
-    if (o) {
-        g_free(o->name);
-        g_free(o);
-    }
+    g_free(o->name);
+    g_slice_free(Options, o);
 }
 
 /* Always return FALSE because its not interactive */
@@ -47,11 +40,8 @@ static gboolean run_func(ObActionsData *data, gpointer options)
     Options *o = options;
 
     /* you cannot call ShowMenu from inside a menu */
-    if (data->uact == OB_USER_ACTION_MENU_SELECTION) return FALSE;
-
-    if (o->name) {
+    if (data->uact != OB_USER_ACTION_MENU_SELECTION && o->name)
         menu_show(o->name, data->x, data->y, data->button != 0, data->client);
-    }
 
     return FALSE;
 }
This page took 0.021316 seconds and 4 git commands to generate.