adjust for changes to the parsing api.
split the menu into its own file.
This commit is contained in:
parent
9ea78a4eb0
commit
1045079482
17 changed files with 230 additions and 124 deletions
|
@ -414,7 +414,8 @@ dist_om4ob_theme_DATA = \
|
||||||
## data ##
|
## data ##
|
||||||
|
|
||||||
dist_rc_DATA = \
|
dist_rc_DATA = \
|
||||||
data/rc3
|
data/rc3 \
|
||||||
|
data/menu
|
||||||
|
|
||||||
dist_desktopfiles_DATA = \
|
dist_desktopfiles_DATA = \
|
||||||
data/openbox.desktop
|
data/openbox.desktop
|
||||||
|
|
38
data/menu
Normal file
38
data/menu
Normal file
|
@ -0,0 +1,38 @@
|
||||||
|
<openbox_menu>
|
||||||
|
|
||||||
|
<menu id="root" label="Openbox 3">
|
||||||
|
<menu id="apps" label="Applications">
|
||||||
|
<item label="Xterm">
|
||||||
|
<action name="execute"><execute>xterm</execute></action>
|
||||||
|
</item>
|
||||||
|
<item label="Mozilla">
|
||||||
|
<action name="execute"><execute>mozilla</execute></action>
|
||||||
|
</item>
|
||||||
|
<item label="Gaim">
|
||||||
|
<action name="execute"><execute>gaim</execute></action>
|
||||||
|
</item>
|
||||||
|
<item label="Quark">
|
||||||
|
<action name="execute"><execute>strange-quark</execute></action>
|
||||||
|
</item>
|
||||||
|
</menu>
|
||||||
|
<menu id="games" label="Games">
|
||||||
|
<item label="Crack-Attack">
|
||||||
|
<action name="execute"><execute>crack-attack</execute></action>
|
||||||
|
</item>
|
||||||
|
<item label="XFRisk">
|
||||||
|
<action name="execute"><execute>xfrisk</execute></action>
|
||||||
|
</item>
|
||||||
|
<item label="Quake III">
|
||||||
|
<action name="execute"><execute>quake3</execute></action>
|
||||||
|
</item>
|
||||||
|
</menu>
|
||||||
|
<item label="--" /> <!-- separator -->
|
||||||
|
<item label="Restart">
|
||||||
|
<action name="restart" />
|
||||||
|
</item>
|
||||||
|
<item label="Exit">
|
||||||
|
<action name="exit" />
|
||||||
|
</item>
|
||||||
|
</menu>
|
||||||
|
|
||||||
|
</openbox_menu>
|
35
data/rc3
35
data/rc3
|
@ -310,39 +310,8 @@
|
||||||
</context>
|
</context>
|
||||||
</mouse>
|
</mouse>
|
||||||
|
|
||||||
<menu id="root" label="Openbox 3">
|
<menu>
|
||||||
<menu id="apps" label="Applications">
|
<location>~/.openbox/menu</location>
|
||||||
<item label="Xterm">
|
|
||||||
<action name="execute"><execute>xterm</execute></action>
|
|
||||||
</item>
|
|
||||||
<item label="Mozilla">
|
|
||||||
<action name="execute"><execute>mozilla</execute></action>
|
|
||||||
</item>
|
|
||||||
<item label="Gaim">
|
|
||||||
<action name="execute"><execute>gaim</execute></action>
|
|
||||||
</item>
|
|
||||||
<item label="Quark">
|
|
||||||
<action name="execute"><execute>strange-quark</execute></action>
|
|
||||||
</item>
|
|
||||||
</menu>
|
|
||||||
<menu id="games" label="Games">
|
|
||||||
<item label="Crack-Attack">
|
|
||||||
<action name="execute"><execute>crack-attack</execute></action>
|
|
||||||
</item>
|
|
||||||
<item label="XFRisk">
|
|
||||||
<action name="execute"><execute>xfrisk</execute></action>
|
|
||||||
</item>
|
|
||||||
<item label="Quake III">
|
|
||||||
<action name="execute"><execute>quake3</execute></action>
|
|
||||||
</item>
|
|
||||||
</menu>
|
|
||||||
<item label="--" /> <!-- separator -->
|
|
||||||
<item label="Restart">
|
|
||||||
<action name="restart" />
|
|
||||||
</item>
|
|
||||||
<item label="Exit">
|
|
||||||
<action name="exit" />
|
|
||||||
</item>
|
|
||||||
</menu>
|
</menu>
|
||||||
|
|
||||||
</openbox_config>
|
</openbox_config>
|
||||||
|
|
|
@ -36,6 +36,18 @@ guint config_keyboard_reset_state;
|
||||||
gint config_mouse_threshold;
|
gint config_mouse_threshold;
|
||||||
gint config_mouse_dclicktime;
|
gint config_mouse_dclicktime;
|
||||||
|
|
||||||
|
gchar *config_menu_path;
|
||||||
|
|
||||||
|
gchar *expand_tilde(const gchar *f)
|
||||||
|
{
|
||||||
|
if (!f)
|
||||||
|
return NULL;
|
||||||
|
else if (f[0] != '~')
|
||||||
|
return g_strdup(f);
|
||||||
|
else
|
||||||
|
return g_strconcat(g_get_home_dir(), f+1, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
||||||
<keybind key="C-x">
|
<keybind key="C-x">
|
||||||
|
@ -46,7 +58,8 @@ gint config_mouse_dclicktime;
|
||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static void parse_key(xmlDocPtr doc, xmlNodePtr node, GList *keylist)
|
static void parse_key(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node,
|
||||||
|
GList *keylist)
|
||||||
{
|
{
|
||||||
char *key;
|
char *key;
|
||||||
ObAction *action;
|
ObAction *action;
|
||||||
|
@ -57,6 +70,7 @@ static void parse_key(xmlDocPtr doc, xmlNodePtr node, GList *keylist)
|
||||||
key = parse_string(doc, n);
|
key = parse_string(doc, n);
|
||||||
translate_key(key, &config_keyboard_reset_state,
|
translate_key(key, &config_keyboard_reset_state,
|
||||||
&config_keyboard_reset_keycode);
|
&config_keyboard_reset_keycode);
|
||||||
|
g_free(key);
|
||||||
}
|
}
|
||||||
|
|
||||||
n = parse_find_node("keybind", node);
|
n = parse_find_node("keybind", node);
|
||||||
|
@ -64,7 +78,7 @@ static void parse_key(xmlDocPtr doc, xmlNodePtr node, GList *keylist)
|
||||||
if (parse_attr_string("key", n, &key)) {
|
if (parse_attr_string("key", n, &key)) {
|
||||||
keylist = g_list_append(keylist, key);
|
keylist = g_list_append(keylist, key);
|
||||||
|
|
||||||
parse_key(doc, n->xmlChildrenNode, keylist);
|
parse_key(i, doc, n->xmlChildrenNode, keylist);
|
||||||
|
|
||||||
it = g_list_last(keylist);
|
it = g_list_last(keylist);
|
||||||
g_free(it->data);
|
g_free(it->data);
|
||||||
|
@ -94,9 +108,10 @@ static void parse_key(xmlDocPtr doc, xmlNodePtr node, GList *keylist)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void parse_keyboard(xmlDocPtr doc, xmlNodePtr node, void *d)
|
static void parse_keyboard(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node,
|
||||||
|
void *d)
|
||||||
{
|
{
|
||||||
parse_key(doc, node->xmlChildrenNode, NULL);
|
parse_key(i, doc, node->xmlChildrenNode, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -109,7 +124,8 @@ static void parse_keyboard(xmlDocPtr doc, xmlNodePtr node, void *d)
|
||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static void parse_mouse(xmlDocPtr doc, xmlNodePtr node, void *d)
|
static void parse_mouse(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node,
|
||||||
|
void *d)
|
||||||
{
|
{
|
||||||
xmlNodePtr n, nbut, nact;
|
xmlNodePtr n, nbut, nact;
|
||||||
char *buttonstr;
|
char *buttonstr;
|
||||||
|
@ -182,7 +198,8 @@ static void parse_mouse(xmlDocPtr doc, xmlNodePtr node, void *d)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void parse_focus(xmlDocPtr doc, xmlNodePtr node, void *d)
|
static void parse_focus(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node,
|
||||||
|
void *d)
|
||||||
{
|
{
|
||||||
xmlNodePtr n;
|
xmlNodePtr n;
|
||||||
|
|
||||||
|
@ -200,7 +217,8 @@ static void parse_focus(xmlDocPtr doc, xmlNodePtr node, void *d)
|
||||||
config_focus_popup = parse_bool(doc, n);
|
config_focus_popup = parse_bool(doc, n);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void parse_theme(xmlDocPtr doc, xmlNodePtr node, void *d)
|
static void parse_theme(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node,
|
||||||
|
void *d)
|
||||||
{
|
{
|
||||||
xmlNodePtr n;
|
xmlNodePtr n;
|
||||||
|
|
||||||
|
@ -216,7 +234,8 @@ static void parse_theme(xmlDocPtr doc, xmlNodePtr node, void *d)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void parse_desktops(xmlDocPtr doc, xmlNodePtr node, void *d)
|
static void parse_desktops(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node,
|
||||||
|
void *d)
|
||||||
{
|
{
|
||||||
xmlNodePtr n;
|
xmlNodePtr n;
|
||||||
|
|
||||||
|
@ -244,7 +263,8 @@ static void parse_desktops(xmlDocPtr doc, xmlNodePtr node, void *d)
|
||||||
config_desktop_popup = parse_bool(doc, n);
|
config_desktop_popup = parse_bool(doc, n);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void parse_resize(xmlDocPtr doc, xmlNodePtr node, void *d)
|
static void parse_resize(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node,
|
||||||
|
void *d)
|
||||||
{
|
{
|
||||||
xmlNodePtr n;
|
xmlNodePtr n;
|
||||||
|
|
||||||
|
@ -254,7 +274,7 @@ static void parse_resize(xmlDocPtr doc, xmlNodePtr node, void *d)
|
||||||
config_redraw_resize = parse_bool(doc, n);
|
config_redraw_resize = parse_bool(doc, n);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void parse_dock(xmlDocPtr doc, xmlNodePtr node, void *d)
|
static void parse_dock(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node, void *d)
|
||||||
{
|
{
|
||||||
xmlNodePtr n;
|
xmlNodePtr n;
|
||||||
|
|
||||||
|
@ -314,7 +334,21 @@ static void parse_dock(xmlDocPtr doc, xmlNodePtr node, void *d)
|
||||||
config_dock_hide_timeout = parse_int(doc, n);
|
config_dock_hide_timeout = parse_int(doc, n);
|
||||||
}
|
}
|
||||||
|
|
||||||
void config_startup()
|
static void parse_menu(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node, void *d)
|
||||||
|
{
|
||||||
|
xmlNodePtr n;
|
||||||
|
|
||||||
|
node = node->xmlChildrenNode;
|
||||||
|
if ((n = parse_find_node("location", node))) {
|
||||||
|
gchar *c;
|
||||||
|
|
||||||
|
c = parse_string(doc, n);
|
||||||
|
config_menu_path = expand_tilde(c);
|
||||||
|
g_free(c);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void config_startup(ObParseInst *i)
|
||||||
{
|
{
|
||||||
config_focus_new = TRUE;
|
config_focus_new = TRUE;
|
||||||
config_focus_follow = FALSE;
|
config_focus_follow = FALSE;
|
||||||
|
@ -322,23 +356,23 @@ void config_startup()
|
||||||
config_focus_last_on_desktop = TRUE;
|
config_focus_last_on_desktop = TRUE;
|
||||||
config_focus_popup = TRUE;
|
config_focus_popup = TRUE;
|
||||||
|
|
||||||
parse_register("focus", parse_focus, NULL);
|
parse_register(i, "focus", parse_focus, NULL);
|
||||||
|
|
||||||
config_theme = NULL;
|
config_theme = NULL;
|
||||||
|
|
||||||
config_title_layout = g_strdup("NLIMC");
|
config_title_layout = g_strdup("NLIMC");
|
||||||
|
|
||||||
parse_register("theme", parse_theme, NULL);
|
parse_register(i, "theme", parse_theme, NULL);
|
||||||
|
|
||||||
config_desktops_num = 4;
|
config_desktops_num = 4;
|
||||||
config_desktops_names = NULL;
|
config_desktops_names = NULL;
|
||||||
config_desktop_popup = TRUE;
|
config_desktop_popup = TRUE;
|
||||||
|
|
||||||
parse_register("desktops", parse_desktops, NULL);
|
parse_register(i, "desktops", parse_desktops, NULL);
|
||||||
|
|
||||||
config_redraw_resize = TRUE;
|
config_redraw_resize = TRUE;
|
||||||
|
|
||||||
parse_register("resize", parse_resize, NULL);
|
parse_register(i, "resize", parse_resize, NULL);
|
||||||
|
|
||||||
config_dock_layer = OB_STACKING_LAYER_TOP;
|
config_dock_layer = OB_STACKING_LAYER_TOP;
|
||||||
config_dock_pos = OB_DIRECTION_NORTHEAST;
|
config_dock_pos = OB_DIRECTION_NORTHEAST;
|
||||||
|
@ -349,17 +383,21 @@ void config_startup()
|
||||||
config_dock_hide = FALSE;
|
config_dock_hide = FALSE;
|
||||||
config_dock_hide_timeout = 3000;
|
config_dock_hide_timeout = 3000;
|
||||||
|
|
||||||
parse_register("dock", parse_dock, NULL);
|
parse_register(i, "dock", parse_dock, NULL);
|
||||||
|
|
||||||
translate_key("C-g", &config_keyboard_reset_state,
|
translate_key("C-g", &config_keyboard_reset_state,
|
||||||
&config_keyboard_reset_keycode);
|
&config_keyboard_reset_keycode);
|
||||||
|
|
||||||
parse_register("keyboard", parse_keyboard, NULL);
|
parse_register(i, "keyboard", parse_keyboard, NULL);
|
||||||
|
|
||||||
config_mouse_threshold = 3;
|
config_mouse_threshold = 3;
|
||||||
config_mouse_dclicktime = 200;
|
config_mouse_dclicktime = 200;
|
||||||
|
|
||||||
parse_register("mouse", parse_mouse, NULL);
|
parse_register(i, "mouse", parse_mouse, NULL);
|
||||||
|
|
||||||
|
config_menu_path = NULL;
|
||||||
|
|
||||||
|
parse_register(i, "menu", parse_menu, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
void config_shutdown()
|
void config_shutdown()
|
||||||
|
|
|
@ -6,6 +6,8 @@
|
||||||
|
|
||||||
#include <glib.h>
|
#include <glib.h>
|
||||||
|
|
||||||
|
struct _ObParseInst;
|
||||||
|
|
||||||
/*! Should new windows be focused */
|
/*! Should new windows be focused */
|
||||||
extern gboolean config_focus_new;
|
extern gboolean config_focus_new;
|
||||||
/*! Focus windows when the mouse enters them */
|
/*! Focus windows when the mouse enters them */
|
||||||
|
@ -65,7 +67,10 @@ extern gint config_mouse_threshold;
|
||||||
double-click */
|
double-click */
|
||||||
extern gint config_mouse_dclicktime;
|
extern gint config_mouse_dclicktime;
|
||||||
|
|
||||||
void config_startup();
|
/*! User-specified path to the menu file */
|
||||||
|
extern gchar *config_menu_path;
|
||||||
|
|
||||||
|
void config_startup(struct _ObParseInst *i);
|
||||||
void config_shutdown();
|
void config_shutdown();
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -4,10 +4,12 @@
|
||||||
#include "stacking.h"
|
#include "stacking.h"
|
||||||
#include "client.h"
|
#include "client.h"
|
||||||
#include "grab.h"
|
#include "grab.h"
|
||||||
|
#include "config.h"
|
||||||
#include "screen.h"
|
#include "screen.h"
|
||||||
#include "geom.h"
|
#include "geom.h"
|
||||||
#include "plugin.h"
|
#include "plugin.h"
|
||||||
#include "misc.h"
|
#include "misc.h"
|
||||||
|
#include "parser/parse.h"
|
||||||
|
|
||||||
GHashTable *menu_hash = NULL;
|
GHashTable *menu_hash = NULL;
|
||||||
GList *menu_visible = NULL;
|
GList *menu_visible = NULL;
|
||||||
|
@ -18,14 +20,16 @@ GList *menu_visible = NULL;
|
||||||
#define ENTRY_EVENTMASK (EnterWindowMask | LeaveWindowMask | \
|
#define ENTRY_EVENTMASK (EnterWindowMask | LeaveWindowMask | \
|
||||||
ButtonPressMask | ButtonReleaseMask)
|
ButtonPressMask | ButtonReleaseMask)
|
||||||
|
|
||||||
static void parse_menu(xmlDocPtr doc, xmlNodePtr node, void *data)
|
static void parse_menu(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node,
|
||||||
|
gpointer data)
|
||||||
{
|
{
|
||||||
parse_menu_full(doc, node, data, TRUE);
|
g_message("%s", __FUNCTION__);
|
||||||
|
parse_menu_full(i, doc, node, data, TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void parse_menu_full(xmlDocPtr doc, xmlNodePtr node, void *data,
|
void parse_menu_full(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node,
|
||||||
gboolean newmenu)
|
gpointer data, gboolean newmenu)
|
||||||
{
|
{
|
||||||
ObAction *act;
|
ObAction *act;
|
||||||
xmlNodePtr nact;
|
xmlNodePtr nact;
|
||||||
|
@ -42,11 +46,12 @@ void parse_menu_full(xmlDocPtr doc, xmlNodePtr node, void *data,
|
||||||
|
|
||||||
if (parse_attr_string("plugin", node, &plugin)) {
|
if (parse_attr_string("plugin", node, &plugin)) {
|
||||||
PluginMenuCreateData data;
|
PluginMenuCreateData data;
|
||||||
|
data.parse_inst = i;
|
||||||
data.doc = doc;
|
data.doc = doc;
|
||||||
data.node = node;
|
data.node = node;
|
||||||
data.parent = menu;
|
data.parent = menu;
|
||||||
|
|
||||||
if (plugin_open_reopen(plugin))
|
if (plugin_open_reopen(plugin, i))
|
||||||
parent = plugin_create(plugin, &data);
|
parent = plugin_create(plugin, &data);
|
||||||
g_free(plugin);
|
g_free(plugin);
|
||||||
} else
|
} else
|
||||||
|
@ -67,12 +72,12 @@ void parse_menu_full(xmlDocPtr doc, xmlNodePtr node, void *data,
|
||||||
data.doc = doc;
|
data.doc = doc;
|
||||||
data.node = node;
|
data.node = node;
|
||||||
data.parent = menu;
|
data.parent = menu;
|
||||||
if (plugin_open_reopen(plugin))
|
if (plugin_open_reopen(plugin, i))
|
||||||
parent = plugin_create(plugin, &data);
|
parent = plugin_create(plugin, &data);
|
||||||
g_free(plugin);
|
g_free(plugin);
|
||||||
} else {
|
} else {
|
||||||
parent = menu;
|
parent = menu;
|
||||||
parse_menu(doc, node, &parent);
|
parse_menu(i, doc, node, &parent);
|
||||||
menu_add_entry(menu, menu_entry_new_submenu(parent->label,
|
menu_add_entry(menu, menu_entry_new_submenu(parent->label,
|
||||||
parent));
|
parent));
|
||||||
}
|
}
|
||||||
|
@ -148,14 +153,11 @@ void menu_entry_free(ObMenuEntry *self)
|
||||||
g_free(self);
|
g_free(self);
|
||||||
}
|
}
|
||||||
|
|
||||||
void menu_startup()
|
void menu_startup(ObParseInst *i)
|
||||||
{
|
{
|
||||||
menu_hash = g_hash_table_new_full(g_str_hash, g_str_equal,
|
menu_hash = g_hash_table_new_full(g_str_hash, g_str_equal,
|
||||||
(GDestroyNotify)menu_destroy_hash_key,
|
(GDestroyNotify)menu_destroy_hash_key,
|
||||||
(GDestroyNotify)menu_destroy_hash_value);
|
(GDestroyNotify)menu_destroy_hash_value);
|
||||||
|
|
||||||
parse_register("menu", parse_menu, NULL);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void menu_shutdown()
|
void menu_shutdown()
|
||||||
|
@ -163,6 +165,43 @@ void menu_shutdown()
|
||||||
g_hash_table_destroy(menu_hash);
|
g_hash_table_destroy(menu_hash);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void menu_parse()
|
||||||
|
{
|
||||||
|
ObParseInst *i;
|
||||||
|
xmlDocPtr doc;
|
||||||
|
xmlNodePtr node;
|
||||||
|
gchar *p;
|
||||||
|
gboolean loaded = FALSE;
|
||||||
|
|
||||||
|
i = parse_startup();
|
||||||
|
|
||||||
|
if (config_menu_path)
|
||||||
|
if (!(loaded =
|
||||||
|
parse_load(config_menu_path, "openbox_menu", &doc, &node)))
|
||||||
|
g_warning("Failed to load menu from '%s'", config_menu_path);
|
||||||
|
if (!loaded) {
|
||||||
|
p = g_build_filename(g_get_home_dir(), ".openbox", "menu", NULL);
|
||||||
|
if (!(loaded =
|
||||||
|
parse_load(p, "openbox_menu", &doc, &node)))
|
||||||
|
g_warning("Failed to load menu from '%s'", p);
|
||||||
|
g_free(p);
|
||||||
|
}
|
||||||
|
if (!loaded) {
|
||||||
|
p = g_build_filename(RCDIR, "menu", NULL);
|
||||||
|
if (!(loaded =
|
||||||
|
parse_load(p, "openbox_menu", &doc, &node)))
|
||||||
|
g_warning("Failed to load menu from '%s'", p);
|
||||||
|
g_free(p);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (loaded) {
|
||||||
|
parse_register(i, "menu", parse_menu, NULL);
|
||||||
|
parse_tree(i, doc, node->xmlChildrenNode);
|
||||||
|
}
|
||||||
|
|
||||||
|
parse_shutdown(i);
|
||||||
|
}
|
||||||
|
|
||||||
static Window createWindow(Window parent, unsigned long mask,
|
static Window createWindow(Window parent, unsigned long mask,
|
||||||
XSetWindowAttributes *attrib)
|
XSetWindowAttributes *attrib)
|
||||||
{
|
{
|
||||||
|
|
|
@ -9,6 +9,7 @@
|
||||||
#include <glib.h>
|
#include <glib.h>
|
||||||
|
|
||||||
struct _ObClient;
|
struct _ObClient;
|
||||||
|
struct _ObParseInst;
|
||||||
|
|
||||||
typedef struct _ObMenu ObMenu;
|
typedef struct _ObMenu ObMenu;
|
||||||
typedef struct _ObMenuEntry ObMenuEntry;
|
typedef struct _ObMenuEntry ObMenuEntry;
|
||||||
|
@ -125,6 +126,7 @@ struct _ObMenuEntry
|
||||||
} MenuEntry;
|
} MenuEntry;
|
||||||
|
|
||||||
typedef struct PluginMenuCreateData{
|
typedef struct PluginMenuCreateData{
|
||||||
|
struct _ObParseInst *parse_inst;
|
||||||
xmlDocPtr doc;
|
xmlDocPtr doc;
|
||||||
xmlNodePtr node;
|
xmlNodePtr node;
|
||||||
ObMenu *parent;
|
ObMenu *parent;
|
||||||
|
@ -134,6 +136,8 @@ typedef struct PluginMenuCreateData{
|
||||||
void menu_startup();
|
void menu_startup();
|
||||||
void menu_shutdown();
|
void menu_shutdown();
|
||||||
|
|
||||||
|
void menu_parse();
|
||||||
|
|
||||||
void menu_noop();
|
void menu_noop();
|
||||||
|
|
||||||
#define menu_new(l, n, p) \
|
#define menu_new(l, n, p) \
|
||||||
|
@ -190,7 +194,8 @@ void menu_render(ObMenu *self);
|
||||||
void menu_render_full(ObMenu *self);
|
void menu_render_full(ObMenu *self);
|
||||||
|
|
||||||
/*so plugins can call it? */
|
/*so plugins can call it? */
|
||||||
void parse_menu_full(xmlDocPtr doc, xmlNodePtr node, void *data, gboolean new);
|
void parse_menu_full(struct _ObParseInst *i, xmlDocPtr doc, xmlNodePtr node,
|
||||||
|
void *data, gboolean new);
|
||||||
void menu_control_mouseover(ObMenuEntry *entry, gboolean enter);
|
void menu_control_mouseover(ObMenuEntry *entry, gboolean enter);
|
||||||
void menu_control_keyboard_nav(unsigned int key);
|
void menu_control_keyboard_nav(unsigned int key);
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -83,9 +83,9 @@ static void clearall()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void fire_button(ObMouseAction a, ObFrameContext context,
|
static gboolean fire_button(ObMouseAction a, ObFrameContext context,
|
||||||
ObClient *c, guint state,
|
ObClient *c, guint state,
|
||||||
guint button, int x, int y)
|
guint button, int x, int y)
|
||||||
{
|
{
|
||||||
GSList *it;
|
GSList *it;
|
||||||
ObMouseBinding *b;
|
ObMouseBinding *b;
|
||||||
|
@ -96,7 +96,7 @@ static void fire_button(ObMouseAction a, ObFrameContext context,
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
/* if not bound, then nothing to do! */
|
/* if not bound, then nothing to do! */
|
||||||
if (it == NULL) return;
|
if (it == NULL) return FALSE;
|
||||||
|
|
||||||
for (it = b->actions[a]; it; it = it->next) {
|
for (it = b->actions[a]; it; it = it->next) {
|
||||||
ObAction *act = it->data;
|
ObAction *act = it->data;
|
||||||
|
@ -131,11 +131,12 @@ static void fire_button(ObMouseAction a, ObFrameContext context,
|
||||||
act->func(&act->data);
|
act->func(&act->data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void fire_motion(ObMouseAction a, ObFrameContext context, ObClient *c,
|
static gboolean fire_motion(ObMouseAction a, ObFrameContext context,
|
||||||
guint state, guint button, int x_root, int y_root,
|
ObClient *c, guint state, guint button,
|
||||||
guint32 corner)
|
int x_root, int y_root, guint32 corner)
|
||||||
{
|
{
|
||||||
GSList *it;
|
GSList *it;
|
||||||
ObMouseBinding *b;
|
ObMouseBinding *b;
|
||||||
|
@ -146,7 +147,7 @@ static void fire_motion(ObMouseAction a, ObFrameContext context, ObClient *c,
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
/* if not bound, then nothing to do! */
|
/* if not bound, then nothing to do! */
|
||||||
if (it == NULL) return;
|
if (it == NULL) return FALSE;
|
||||||
|
|
||||||
for (it = b->actions[a]; it; it = it->next) {
|
for (it = b->actions[a]; it; it = it->next) {
|
||||||
ObAction *act = it->data;
|
ObAction *act = it->data;
|
||||||
|
@ -170,6 +171,7 @@ static void fire_motion(ObMouseAction a, ObFrameContext context, ObClient *c,
|
||||||
act->func(&act->data);
|
act->func(&act->data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static guint32 pick_corner(int x, int y, int cx, int cy, int cw, int ch)
|
static guint32 pick_corner(int x, int y, int cx, int cy, int cw, int ch)
|
||||||
|
|
|
@ -210,8 +210,10 @@ int main(int argc, char **argv)
|
||||||
startup_save();
|
startup_save();
|
||||||
|
|
||||||
if (screen_annex()) { /* it will be ours! */
|
if (screen_annex()) { /* it will be ours! */
|
||||||
|
ObParseInst *i;
|
||||||
|
|
||||||
/* startup the parsing so everything can register sections of the rc */
|
/* startup the parsing so everything can register sections of the rc */
|
||||||
parse_startup();
|
i = parse_startup();
|
||||||
|
|
||||||
/* anything that is going to read data from the rc file needs to be
|
/* anything that is going to read data from the rc file needs to be
|
||||||
in this group */
|
in this group */
|
||||||
|
@ -224,16 +226,18 @@ int main(int argc, char **argv)
|
||||||
window_startup();
|
window_startup();
|
||||||
plugin_startup();
|
plugin_startup();
|
||||||
/* load the plugins specified in the pluginrc */
|
/* load the plugins specified in the pluginrc */
|
||||||
plugin_loadall();
|
plugin_loadall(i);
|
||||||
|
|
||||||
/* set up the kernel config shit */
|
/* set up the kernel config shit */
|
||||||
config_startup();
|
config_startup(i);
|
||||||
menu_startup();
|
menu_startup(i);
|
||||||
/* parse/load user options */
|
/* parse/load user options */
|
||||||
if (parse_load_rc(&doc, &node))
|
if (parse_load_rc(&doc, &node))
|
||||||
parse_tree(doc, node->xmlChildrenNode, NULL);
|
parse_tree(i, doc, node->xmlChildrenNode);
|
||||||
/* we're done with parsing now, kill it */
|
/* we're done with parsing now, kill it */
|
||||||
parse_shutdown();
|
parse_shutdown(i);
|
||||||
|
|
||||||
|
menu_parse();
|
||||||
|
|
||||||
/* load the theme specified in the rc file */
|
/* load the theme specified in the rc file */
|
||||||
ob_rr_theme = RrThemeNew(ob_rr_inst, config_theme);
|
ob_rr_theme = RrThemeNew(ob_rr_inst, config_theme);
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
#include "plugins/interface.h"
|
#include "plugins/interface.h"
|
||||||
|
#include "parser/parse.h"
|
||||||
|
|
||||||
#include <glib.h>
|
#include <glib.h>
|
||||||
#include <gmodule.h>
|
#include <gmodule.h>
|
||||||
|
@ -92,7 +93,7 @@ void plugin_shutdown()
|
||||||
g_datalist_clear(&plugins);
|
g_datalist_clear(&plugins);
|
||||||
}
|
}
|
||||||
|
|
||||||
gboolean plugin_open_full(char *name, gboolean reopen)
|
gboolean plugin_open_full(char *name, gboolean reopen, ObParseInst *i)
|
||||||
{
|
{
|
||||||
Plugin *p;
|
Plugin *p;
|
||||||
|
|
||||||
|
@ -107,18 +108,18 @@ gboolean plugin_open_full(char *name, gboolean reopen)
|
||||||
g_warning("failed to load plugin '%s'", name);
|
g_warning("failed to load plugin '%s'", name);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
p->config();
|
p->config(i);
|
||||||
|
|
||||||
g_datalist_set_data_full(&plugins, name, p, (GDestroyNotify) plugin_free);
|
g_datalist_set_data_full(&plugins, name, p, (GDestroyNotify) plugin_free);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
gboolean plugin_open(char *name) {
|
gboolean plugin_open(char *name, ObParseInst *i) {
|
||||||
return plugin_open_full(name, FALSE);
|
return plugin_open_full(name, FALSE, i);
|
||||||
}
|
}
|
||||||
|
|
||||||
gboolean plugin_open_reopen(char *name) {
|
gboolean plugin_open_reopen(char *name, ObParseInst *i) {
|
||||||
return plugin_open_full(name, TRUE);
|
return plugin_open_full(name, TRUE, i);
|
||||||
}
|
}
|
||||||
|
|
||||||
void plugin_close(char *name)
|
void plugin_close(char *name)
|
||||||
|
@ -136,7 +137,7 @@ void plugin_startall()
|
||||||
g_datalist_foreach(&plugins, (GDataForeachFunc)foreach_start, NULL);
|
g_datalist_foreach(&plugins, (GDataForeachFunc)foreach_start, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
void plugin_loadall()
|
void plugin_loadall(ObParseInst *i)
|
||||||
{
|
{
|
||||||
GIOChannel *io;
|
GIOChannel *io;
|
||||||
GError *err;
|
GError *err;
|
||||||
|
@ -156,18 +157,18 @@ void plugin_loadall()
|
||||||
|
|
||||||
if (io == NULL) {
|
if (io == NULL) {
|
||||||
/* load the default plugins */
|
/* load the default plugins */
|
||||||
plugin_open("placement");
|
plugin_open("placement", i);
|
||||||
plugin_open("resistance");
|
plugin_open("resistance", i);
|
||||||
|
|
||||||
/* XXX rm me when the parser loads me magically */
|
/* XXX rm me when the parser loads me magically */
|
||||||
plugin_open("client_menu");
|
plugin_open("client_menu", i);
|
||||||
} else {
|
} else {
|
||||||
/* load the plugins in the rc file */
|
/* load the plugins in the rc file */
|
||||||
while (g_io_channel_read_line(io, &name, NULL, NULL, &err) ==
|
while (g_io_channel_read_line(io, &name, NULL, NULL, &err) ==
|
||||||
G_IO_STATUS_NORMAL) {
|
G_IO_STATUS_NORMAL) {
|
||||||
g_strstrip(name);
|
g_strstrip(name);
|
||||||
if (name[0] != '\0' && name[0] != '#')
|
if (name[0] != '\0' && name[0] != '#')
|
||||||
plugin_open(name);
|
plugin_open(name, i);
|
||||||
g_free(name);
|
g_free(name);
|
||||||
}
|
}
|
||||||
g_io_channel_unref(io);
|
g_io_channel_unref(io);
|
||||||
|
|
|
@ -1,16 +1,18 @@
|
||||||
#ifndef __plugin_h
|
#ifndef __plugin_h
|
||||||
#define __plugin_h
|
#define __plugin_h
|
||||||
|
|
||||||
|
struct _ObParseInst;
|
||||||
|
|
||||||
void plugin_startup();
|
void plugin_startup();
|
||||||
void plugin_shutdown();
|
void plugin_shutdown();
|
||||||
|
|
||||||
void plugin_loadall();
|
void plugin_loadall(struct _ObParseInst *i);
|
||||||
void plugin_startall();
|
void plugin_startall();
|
||||||
|
|
||||||
/* default plugin */
|
/* default plugin */
|
||||||
gboolean plugin_open(char *name);
|
gboolean plugin_open(char *name, struct _ObParseInst *i);
|
||||||
/* load a plugin, but don't warn about reopens. for menus */
|
/* load a plugin, but don't warn about reopens. for menus */
|
||||||
gboolean plugin_open_reopen(char *name);
|
gboolean plugin_open_reopen(char *name, struct _ObParseInst *i);
|
||||||
void plugin_close(char *name);
|
void plugin_close(char *name);
|
||||||
|
|
||||||
/* call plugin's generic constructor */
|
/* call plugin's generic constructor */
|
||||||
|
|
|
@ -1,8 +1,10 @@
|
||||||
#ifndef __plugins_interface_h
|
#ifndef __plugins_interface_h
|
||||||
#define __plugins_interface_h
|
#define __plugins_interface_h
|
||||||
|
|
||||||
|
struct _ObParseInst;
|
||||||
|
|
||||||
/* plugin_setup_config() */
|
/* plugin_setup_config() */
|
||||||
typedef void (*PluginSetupConfig)(void);
|
typedef void (*PluginSetupConfig)(struct _ObParseInst *i);
|
||||||
|
|
||||||
/* plugin_startup() */
|
/* plugin_startup() */
|
||||||
typedef void (*PluginStartup)(void);
|
typedef void (*PluginStartup)(void);
|
||||||
|
|
|
@ -101,6 +101,7 @@ void fifo_menu_handler(int fd, void *d) {
|
||||||
num_realloc);
|
num_realloc);
|
||||||
|
|
||||||
if (num_read == 0) { /* eof */
|
if (num_read == 0) { /* eof */
|
||||||
|
ObParseInst *i;
|
||||||
xmlDocPtr doc;
|
xmlDocPtr doc;
|
||||||
xmlNodePtr node;
|
xmlNodePtr node;
|
||||||
|
|
||||||
|
@ -109,15 +110,14 @@ void fifo_menu_handler(int fd, void *d) {
|
||||||
|
|
||||||
FIFO_MENU_DATA(menu)->buf[FIFO_MENU_DATA(menu)->buflen] = '\0';
|
FIFO_MENU_DATA(menu)->buf[FIFO_MENU_DATA(menu)->buflen] = '\0';
|
||||||
|
|
||||||
doc = xmlParseMemory(FIFO_MENU_DATA(menu)->buf,
|
i = parse_startup();
|
||||||
FIFO_MENU_DATA(menu)->buflen);
|
|
||||||
|
|
||||||
node = xmlDocGetRootElement(doc);
|
if (parse_load_mem(FIFO_MENU_DATA(menu)->buf,
|
||||||
|
FIFO_MENU_DATA(menu)->buflen,
|
||||||
|
"fifo_menu", &doc, &node))
|
||||||
|
parse_menu_full(i, doc, node, menu, FALSE);
|
||||||
|
|
||||||
if (node &&
|
parse_shutdown(i);
|
||||||
!xmlStrcasecmp(node->name, (const xmlChar*) "fifo_menu")) {
|
|
||||||
parse_menu_full(doc, node, menu, FALSE);
|
|
||||||
}
|
|
||||||
|
|
||||||
fifo_menu_clean_up(menu);
|
fifo_menu_clean_up(menu);
|
||||||
|
|
||||||
|
|
|
@ -46,7 +46,7 @@ void *plugin_create(PluginMenuCreateData *data)
|
||||||
if (doc) {
|
if (doc) {
|
||||||
xmlNodePtr node = xmlDocGetRootElement(doc);
|
xmlNodePtr node = xmlDocGetRootElement(doc);
|
||||||
if (node) {
|
if (node) {
|
||||||
parse_menu_full(doc, node, m, FALSE);
|
parse_menu_full(data->parse_inst, doc, node, m, FALSE);
|
||||||
}
|
}
|
||||||
xmlFreeDoc(doc);
|
xmlFreeDoc(doc);
|
||||||
}
|
}
|
||||||
|
|
|
@ -125,6 +125,7 @@ void timed_menu_read_pipe(int fd, void *d)
|
||||||
TIMED_MENU_DATA(menu)->buf + TIMED_MENU_DATA(menu)->buflen,
|
TIMED_MENU_DATA(menu)->buf + TIMED_MENU_DATA(menu)->buflen,
|
||||||
num_realloc);
|
num_realloc);
|
||||||
if (num_read == 0) {
|
if (num_read == 0) {
|
||||||
|
ObParseInst *i;
|
||||||
xmlDocPtr doc;
|
xmlDocPtr doc;
|
||||||
xmlNodePtr node;
|
xmlNodePtr node;
|
||||||
|
|
||||||
|
@ -133,15 +134,14 @@ void timed_menu_read_pipe(int fd, void *d)
|
||||||
|
|
||||||
TIMED_MENU_DATA(menu)->buf[TIMED_MENU_DATA(menu)->buflen] = '\0';
|
TIMED_MENU_DATA(menu)->buf[TIMED_MENU_DATA(menu)->buflen] = '\0';
|
||||||
|
|
||||||
doc = xmlParseMemory(TIMED_MENU_DATA(menu)->buf,
|
i = parse_startup();
|
||||||
TIMED_MENU_DATA(menu)->buflen);
|
|
||||||
|
|
||||||
node = xmlDocGetRootElement(doc);
|
if (parse_load_mem(TIMED_MENU_DATA(menu)->buf,
|
||||||
|
TIMED_MENU_DATA(menu)->buflen,
|
||||||
|
"timed_menu", &doc, &node))
|
||||||
|
parse_menu_full(i, doc, node, menu, FALSE);
|
||||||
|
|
||||||
if (node &&
|
parse_shutdown(i);
|
||||||
!xmlStrcasecmp(node->name, (const xmlChar*) "timed_menu")) {
|
|
||||||
parse_menu_full(doc, node, menu, FALSE);
|
|
||||||
}
|
|
||||||
|
|
||||||
timed_menu_clean_up(menu);
|
timed_menu_clean_up(menu);
|
||||||
} else if (num_read > 0) {
|
} else if (num_read > 0) {
|
||||||
|
@ -205,6 +205,7 @@ void timed_menu_timeout_handler(ObTimer *t, void *d)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (stat_buf.st_mtime > TIMED_MENU_DATA(data)->mtime) {
|
if (stat_buf.st_mtime > TIMED_MENU_DATA(data)->mtime) {
|
||||||
|
ObParseInst *i;
|
||||||
xmlDocPtr doc;
|
xmlDocPtr doc;
|
||||||
xmlNodePtr node;
|
xmlNodePtr node;
|
||||||
|
|
||||||
|
@ -214,14 +215,13 @@ void timed_menu_timeout_handler(ObTimer *t, void *d)
|
||||||
data->invalid = TRUE;
|
data->invalid = TRUE;
|
||||||
menu_clear(data);
|
menu_clear(data);
|
||||||
|
|
||||||
doc = xmlParseFile(TIMED_MENU_DATA(data)->command);
|
i = parse_startup();
|
||||||
|
|
||||||
node = xmlDocGetRootElement(doc);
|
if (parse_load(TIMED_MENU_DATA(data)->command,
|
||||||
|
"timed_menu", &doc, &node))
|
||||||
|
parse_menu_full(i, doc, node, data, FALSE);
|
||||||
|
|
||||||
if (node &&
|
parse_shutdown(i);
|
||||||
!xmlStrcasecmp(node->name, (const xmlChar*) "timed_menu")) {
|
|
||||||
parse_menu_full(doc, node, data, FALSE);
|
|
||||||
}
|
|
||||||
|
|
||||||
timed_menu_clean_up(data);
|
timed_menu_clean_up(data);
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,7 +10,7 @@
|
||||||
|
|
||||||
static gboolean history;
|
static gboolean history;
|
||||||
|
|
||||||
static void parse_xml(xmlDocPtr doc, xmlNodePtr node, void *d)
|
static void parse_xml(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node, void *d)
|
||||||
{
|
{
|
||||||
xmlNodePtr n;
|
xmlNodePtr n;
|
||||||
|
|
||||||
|
@ -19,11 +19,11 @@ static void parse_xml(xmlDocPtr doc, xmlNodePtr node, void *d)
|
||||||
history = parse_bool(doc, n);
|
history = parse_bool(doc, n);
|
||||||
}
|
}
|
||||||
|
|
||||||
void plugin_setup_config()
|
void plugin_setup_config(ObParseInst *i)
|
||||||
{
|
{
|
||||||
history = TRUE;
|
history = TRUE;
|
||||||
|
|
||||||
parse_register("placement", parse_xml, NULL);
|
parse_register(i, "placement", parse_xml, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
static Rect* pick_head(ObClient *c)
|
static Rect* pick_head(ObClient *c)
|
||||||
|
|
|
@ -10,7 +10,7 @@
|
||||||
static int win_resistance;
|
static int win_resistance;
|
||||||
static int edge_resistance;
|
static int edge_resistance;
|
||||||
|
|
||||||
static void parse_xml(xmlDocPtr doc, xmlNodePtr node, void *d)
|
static void parse_xml(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node, void *d)
|
||||||
{
|
{
|
||||||
xmlNodePtr n;
|
xmlNodePtr n;
|
||||||
|
|
||||||
|
@ -21,11 +21,11 @@ static void parse_xml(xmlDocPtr doc, xmlNodePtr node, void *d)
|
||||||
edge_resistance = parse_int(doc, n);
|
edge_resistance = parse_int(doc, n);
|
||||||
}
|
}
|
||||||
|
|
||||||
void plugin_setup_config()
|
void plugin_setup_config(ObParseInst *i)
|
||||||
{
|
{
|
||||||
win_resistance = edge_resistance = DEFAULT_RESISTANCE;
|
win_resistance = edge_resistance = DEFAULT_RESISTANCE;
|
||||||
|
|
||||||
parse_register("resistance", parse_xml, NULL);
|
parse_register(i, "resistance", parse_xml, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void resist_move(ObClient *c, int *x, int *y)
|
static void resist_move(ObClient *c, int *x, int *y)
|
||||||
|
|
Loading…
Reference in a new issue