summaryrefslogtreecommitdiff
path: root/openbox
diff options
context:
space:
mode:
authorDana Jansens <danakj@orodu.net>2003-09-15 19:20:05 +0000
committerDana Jansens <danakj@orodu.net>2003-09-15 19:20:05 +0000
commitc1b2fc5324522f74a14a5cfa210c95e1509a6e7f (patch)
tree7024fd9c49d64e29d3f622250199c5d6a382b721 /openbox
parent3a607fad9df628ab16e0f7436dfbfc9b22634003 (diff)
make openbox base-dir spec compliant, and change the theme dir structure, so that themes go in $XDG_DATA_DIRS/themes/ with gtk/metacity/whateverelse themes
Diffstat (limited to 'openbox')
-rw-r--r--openbox/action.c2
-rw-r--r--openbox/config.c4
-rw-r--r--openbox/menu.c35
-rw-r--r--openbox/openbox.c48
-rw-r--r--openbox/openbox.h2
-rw-r--r--openbox/session.c9
6 files changed, 23 insertions, 77 deletions
diff --git a/openbox/action.c b/openbox/action.c
index 0a969a86..adfa2d9e 100644
--- a/openbox/action.c
+++ b/openbox/action.c
@@ -723,7 +723,7 @@ ObAction *action_parse(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node,
if (act->func == action_execute || act->func == action_restart) {
if ((n = parse_find_node("execute", node->xmlChildrenNode))) {
gchar *s = parse_string(doc, n);
- act->data.execute.path = ob_expand_tilde(s);
+ act->data.execute.path = parse_expand_tilde(s);
g_free(s);
}
} else if (act->func == action_showmenu) {
diff --git a/openbox/config.c b/openbox/config.c
index 4251390c..b6ec290b 100644
--- a/openbox/config.c
+++ b/openbox/config.c
@@ -189,7 +189,7 @@ static void parse_theme(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node,
g_free(config_theme);
c = parse_string(doc, n);
- config_theme = ob_expand_tilde(c);
+ config_theme = parse_expand_tilde(c);
g_free(c);
}
if ((n = parse_find_node("titleLayout", node))) {
@@ -304,7 +304,7 @@ static void parse_menu(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node, void *d)
c = parse_string(doc, node);
config_menu_files = g_slist_append(config_menu_files,
- ob_expand_tilde(c));
+ parse_expand_tilde(c));
g_free(c);
}
}
diff --git a/openbox/menu.c b/openbox/menu.c
index 231777f2..39dd60d6 100644
--- a/openbox/menu.c
+++ b/openbox/menu.c
@@ -34,35 +34,6 @@ static void parse_menu_separator(ObParseInst *i,
static void parse_menu(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node,
gpointer data);
-static gboolean menu_open(gchar *file, xmlDocPtr *doc, xmlNodePtr *node)
-{
- gboolean loaded = TRUE;
- gchar *p;
-
- if (file[0] == '/') {
- if (!parse_load(file, "openbox_menu", doc, node)) {
- g_warning("Failed to load menu from '%s'", file);
- loaded = FALSE;
- }
- } else {
- p = g_build_filename(g_get_home_dir(), ".openbox", file, NULL);
- if (!parse_load(p, "openbox_menu", doc, node)) {
- g_free(p);
- p = g_build_filename(RCDIR, file, NULL);
- if (!parse_load(p, "openbox_menu", doc, node)) {
- g_free(p);
- p = g_strdup(file);
- if (!parse_load(p, "openbox_menu", doc, node)) {
- g_warning("Failed to load menu from '%s'", file);
- loaded = FALSE;
- }
- }
- }
- g_free(p);
- }
- return loaded;
-}
-
static void client_dest(gpointer client)
{
/* menus can be associated with a client, so close any that are since
@@ -94,14 +65,14 @@ void menu_startup(gboolean reconfig)
parse_menu_separator, &menu_parse_state);
for (it = config_menu_files; it; it = g_slist_next(it)) {
- if (menu_open(it->data, &doc, &node)) {
+ if (parse_load_menu(it->data, &doc, &node)) {
loaded = TRUE;
parse_tree(menu_parse_inst, doc, node->children);
xmlFreeDoc(doc);
}
}
if (!loaded) {
- if (menu_open("menu.xml", &doc, &node)) {
+ if (parse_load_menu("menu.xml", &doc, &node)) {
parse_tree(menu_parse_inst, doc, node->children);
xmlFreeDoc(doc);
}
@@ -225,7 +196,7 @@ static void parse_menu(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node,
if ((menu = menu_new(name, title, NULL))) {
menu->pipe_creator = state->pipe_creator;
if (parse_attr_string("execute", node, &script)) {
- menu->execute = ob_expand_tilde(script);
+ menu->execute = parse_expand_tilde(script);
} else {
ObMenu *old;
diff --git a/openbox/openbox.c b/openbox/openbox.c
index a3adb102..a8102c3a 100644
--- a/openbox/openbox.c
+++ b/openbox/openbox.c
@@ -29,7 +29,6 @@
# include <fcntl.h>
#endif
#ifdef HAVE_SIGNAL_H
-#define __USE_UNIX98
# include <signal.h>
#endif
#ifdef HAVE_STDLIB_H
@@ -68,8 +67,6 @@ static void parse_args(int argc, char **argv);
int main(int argc, char **argv)
{
- char *path;
-
#ifdef DEBUG
ob_debug_show_output(TRUE);
#endif
@@ -83,24 +80,10 @@ int main(int argc, char **argv)
bind_textdomain_codeset(PACKAGE_NAME, "UTF-8");
textdomain(PACKAGE_NAME);
- /* create the ~/.openbox dir */
- path = g_build_filename(g_get_home_dir(), ".openbox", NULL);
- mkdir(path, (S_IRUSR | S_IWUSR | S_IXUSR | S_IRGRP | S_IWGRP | S_IXGRP |
- S_IROTH | S_IWOTH | S_IXOTH));
- g_free(path);
- /* create the ~/.openbox/themes dir */
- path = g_build_filename(g_get_home_dir(), ".openbox", "themes", NULL);
- mkdir(path, (S_IRUSR | S_IWUSR | S_IXUSR | S_IRGRP | S_IWGRP | S_IXGRP |
- S_IROTH | S_IWOTH | S_IXOTH));
- g_free(path);
- /* create the ~/.openbox/sessions dir */
- path = g_build_filename(g_get_home_dir(), ".openbox", "sessions", NULL);
- mkdir(path, (S_IRUSR | S_IWUSR | S_IXUSR | S_IRGRP | S_IWGRP | S_IXGRP |
- S_IROTH | S_IWOTH | S_IXOTH));
- g_free(path);
-
g_set_prgname(argv[0]);
+ parse_paths_startup();
+
session_startup(&argc, &argv);
/* parse out command line args */
@@ -291,6 +274,8 @@ int main(int argc, char **argv)
XCloseDisplay(ob_display);
+ parse_paths_shutdown();
+
if (restart) {
if (restart_path != NULL) {
int argcp;
@@ -404,6 +389,12 @@ void ob_restart()
ob_exit();
}
+void ob_reconfigure()
+{
+ reconfigure = TRUE;
+ ob_exit();
+}
+
void ob_exit()
{
ob_main_loop_exit(ob_main_loop);
@@ -425,22 +416,3 @@ ObState ob_state()
{
return state;
}
-
-gchar *ob_expand_tilde(const gchar *f)
-{
- gchar **spl;
- gchar *ret;
-
- if (!f)
- return NULL;
- spl = g_strsplit(f, "~", 0);
- ret = g_strjoinv(g_get_home_dir(), spl);
- g_strfreev(spl);
- return ret;
-}
-
-void ob_reconfigure()
-{
- reconfigure = TRUE;
- ob_exit();
-}
diff --git a/openbox/openbox.h b/openbox/openbox.h
index 9d7551b9..a4e87a3a 100644
--- a/openbox/openbox.h
+++ b/openbox/openbox.h
@@ -41,6 +41,4 @@ Cursor ob_cursor(ObCursor cursor);
KeyCode ob_keycode(ObKey key);
-gchar *ob_expand_tilde(const gchar *f);
-
#endif
diff --git a/openbox/session.c b/openbox/session.c
index 181dfe8d..9ce04674 100644
--- a/openbox/session.c
+++ b/openbox/session.c
@@ -42,6 +42,7 @@ static gchar *save_file;
static gchar *sm_id;
static gint sm_argc;
static gchar **sm_argv;
+static gchar *sm_sessions_path;
static void session_load(char *path);
static gboolean session_save();
@@ -141,6 +142,10 @@ void session_startup(int *argc, char ***argv)
if (sm_disable)
return;
+ sm_sessions_path = g_build_filename(parse_xdg_data_home_path(),
+ "openbox", "sessions", NULL);
+ parse_mkdir_path(sm_sessions_path, 0700);
+
if (save_file)
session_load(save_file);
@@ -224,6 +229,7 @@ void session_startup(int *argc, char ***argv)
void session_shutdown()
{
+ g_free(sm_sessions_path);
g_free(save_file);
g_free(sm_id);
@@ -298,8 +304,7 @@ static gboolean session_save()
(int) time(NULL),
(int) getpid(),
g_random_int());
- save_file = g_build_filename(g_get_home_dir(), ".openbox", "sessions",
- filename, NULL);
+ save_file = g_build_filename(sm_sessions_path, filename, NULL);
g_free(filename);
f = fopen(save_file, "w");