moved menu from a rc file option to a command line option

This commit is contained in:
Dana Jansens 2002-05-15 22:23:35 +00:00
parent 4f50d11704
commit a3a23c28f0
20 changed files with 189 additions and 114 deletions

View file

@ -1,6 +1,14 @@
Changelog for Openbox: Changelog for Openbox:
1.2.0: 1.2.0:
* changed the menu from an rcfile option to a command-
line option. use 'openbox -menu <file>' to select an
alternate menu. The default menu used is
~/.openbox/menu. If the default, or the file you
specify does not exist, the global menu is tried.
And if the global menu also does not exist, a
simple, internal menu is used instead. (Ben Jansens)
* new version of bsetroot ported from blackbox cvs * new version of bsetroot ported from blackbox cvs
with intent to support Eterm/Esetroot. (Sean Perry) with intent to support Eterm/Esetroot. (Sean Perry)

View file

@ -2,6 +2,8 @@ $set 14 #main
$ #RCRequiresArg $ #RCRequiresArg
# error: '-rc' requires an argument\n # error: '-rc' requires an argument\n
$ #MENURequiresArg
# error: '-menu' requires an argument\n
$ #DISPLAYRequiresArg $ #DISPLAYRequiresArg
# error: '-display' requires an argument\n # error: '-display' requires an argument\n
$ #WarnDisplaySet $ #WarnDisplaySet
@ -12,6 +14,7 @@ $ #Usage
\t\t\t 1997 - 2000 Brad Hughes\n\n\ \t\t\t 1997 - 2000 Brad Hughes\n\n\
-display <string>\t\tuse display connection.\n\ -display <string>\t\tuse display connection.\n\
-rc <string>\t\t\tuse alternate resource file.\n\ -rc <string>\t\t\tuse alternate resource file.\n\
-menu <string>\t\t\tuse alternate menu file.\n\
-version\t\t\tdisplay version and exit.\n\ -version\t\t\tdisplay version and exit.\n\
-help\t\t\t\tdisplay this help text and exit.\n\n -help\t\t\t\tdisplay this help text and exit.\n\n
$ #CompileOptions $ #CompileOptions

View file

@ -2,6 +2,8 @@ $set 14 #main
$ #RCRequiresArg $ #RCRequiresArg
# fejl: '-rc' kræver et argument\n # fejl: '-rc' kræver et argument\n
$ #MENURequiresArg
# fejl: '-menu' kræver et argument\n
$ #DISPLAYRequiresArg $ #DISPLAYRequiresArg
# fjel: '-display' kræver et argument\n # fjel: '-display' kræver et argument\n
$ #WarnDisplaySet $ #WarnDisplaySet
@ -12,6 +14,7 @@ $ #Usage
\t\t\t 1997 - 2000 Brad Hughes\n\n\ \t\t\t 1997 - 2000 Brad Hughes\n\n\
-display <string>\t\tbrug skærm tilslutning.\n\ -display <string>\t\tbrug skærm tilslutning.\n\
-rc <string>\t\t\tbrug alternativ resource fil.\n\ -rc <string>\t\t\tbrug alternativ resource fil.\n\
-menu <string>\t\t\tbrug alternativ menu fil.\n\
-version\t\t\tvis versionsnummer og afslut.\n\ -version\t\t\tvis versionsnummer og afslut.\n\
-help\t\t\t\tvis denne hjælp og afslut.\n\n -help\t\t\t\tvis denne hjælp og afslut.\n\n
$ #CompileOptions $ #CompileOptions

View file

@ -2,6 +2,8 @@ $set 14 #main
$ #RCRequiresArg $ #RCRequiresArg
# Fehler: '-rc' benötigt einen Parameter\n # Fehler: '-rc' benötigt einen Parameter\n
$ #MENURequiresArg
# Fehler: '-menu' benötigt einen Parameter\n
$ #DISPLAYRequiresArg $ #DISPLAYRequiresArg
# Fehler: '-display' benötigt einen Parameter\n # Fehler: '-display' benötigt einen Parameter\n
$ #WarnDisplaySet $ #WarnDisplaySet
@ -12,6 +14,7 @@ $ #Usage
\t\t\t 1997 - 2000 Brad Hughes\n\n\ \t\t\t 1997 - 2000 Brad Hughes\n\n\
-display <string>\t\tDisplay Verbindung.\n\ -display <string>\t\tDisplay Verbindung.\n\
-rc <string>\t\t\talternative Konfigurationsdatei.\n\ -rc <string>\t\t\talternative Konfigurationsdatei.\n\
-menu <string>\t\t\talternative menu.\n\
-version\t\t\tzeige Versionsnummer und Beendung.\n\ -version\t\t\tzeige Versionsnummer und Beendung.\n\
-help\t\t\t\tzeige diesen Hilfstext und Beendung.\n\n -help\t\t\t\tzeige diesen Hilfstext und Beendung.\n\n
$ #CompileOptions $ #CompileOptions

View file

@ -2,6 +2,8 @@ $set 14 #main
$ #RCRequiresArg $ #RCRequiresArg
# error: '-rc' requiere un argumento # error: '-rc' requiere un argumento
$ #MENURequiresArg
# error: '-menu' requiere un argumento
$ #DISPLAYRequiresArg $ #DISPLAYRequiresArg
# error: '-display' requiere un argumento # error: '-display' requiere un argumento
$ #WarnDisplaySet $ #WarnDisplaySet
@ -12,6 +14,7 @@ $ #Usage
\t\t\t 1997 - 2000 Brad Hughes\n\n\ \t\t\t 1997 - 2000 Brad Hughes\n\n\
-display <string> conexión de despliegue.\n\ -display <string> conexión de despliegue.\n\
-rc <string> archivo alternativo de recuros.\n\ -rc <string> archivo alternativo de recuros.\n\
-menu <string> archivo alternativo de menu.\n\
-version mostrar la versión y cerrar.\n\ -version mostrar la versión y cerrar.\n\
-help mostrar este texto de ayuda y cerrar.\n\n -help mostrar este texto de ayuda y cerrar.\n\n
$ #CompileOptions $ #CompileOptions

View file

@ -2,6 +2,8 @@ $set 14 #main
$ #RCRequiresArg $ #RCRequiresArg
# viga: '-rc' vajab argumenti\n # viga: '-rc' vajab argumenti\n
$ #MENURequiresArg
# viga: '-menu' vajab argumenti\n
$ #DISPLAYRequiresArg $ #DISPLAYRequiresArg
# viga: '-display' vajab argumenti\n # viga: '-display' vajab argumenti\n
$ #WarnDisplaySet $ #WarnDisplaySet
@ -12,6 +14,7 @@ $ #Usage
\t\t\t 1997 - 2000 Brad Hughes\n\n\ \t\t\t 1997 - 2000 Brad Hughes\n\n\
-display <string>\t\tkasuta displei ühendust.\n\ -display <string>\t\tkasuta displei ühendust.\n\
-rc <string>\t\t\tkasuta alternatiivseid resursse.\n\ -rc <string>\t\t\tkasuta alternatiivseid resursse.\n\
-menu <string>\t\t\tkasuta alternatiivseid menu.\n\
-version\t\t\tnäita versiooninumber ja välju.\n\ -version\t\t\tnäita versiooninumber ja välju.\n\
-help\t\t\t\tnäita seda abiteksti ja välju.\n\n -help\t\t\t\tnäita seda abiteksti ja välju.\n\n
$ #CompileOptions $ #CompileOptions

View file

@ -2,6 +2,8 @@ $set 14 #main
$ #RCRequiresArg $ #RCRequiresArg
# Erreur: '-rc' nécessite un argument\n # Erreur: '-rc' nécessite un argument\n
$ #MENURequiresArg
# Erreur: '-menu' nécessite un argument\n
$ #DISPLAYRequiresArg $ #DISPLAYRequiresArg
# Erreur: '-display' nécessite un argument\n # Erreur: '-display' nécessite un argument\n
$ #WarnDisplaySet $ #WarnDisplaySet
@ -12,6 +14,7 @@ $ #Usage
\t\t\t 1997 - 2000 Brad Hughes\n\n\ \t\t\t 1997 - 2000 Brad Hughes\n\n\
-display <chaîne>\t\tutilise la connexion à l'affichage.\n\ -display <chaîne>\t\tutilise la connexion à l'affichage.\n\
-rc <chaîne>\t\t\tutilise un autre fichier de configuration.\n\ -rc <chaîne>\t\t\tutilise un autre fichier de configuration.\n\
-menu <chaîne>\t\t\tutilise un autre fichier de menu.\n\
-version\t\t\taffiche la version et quitte.\n\ -version\t\t\taffiche la version et quitte.\n\
-help\t\t\t\taffiche ce texte d'aide et quitte.\n\n -help\t\t\t\taffiche ce texte d'aide et quitte.\n\n
$ #CompileOptions $ #CompileOptions

View file

@ -2,6 +2,8 @@ $set 14 #main
$ #RCRequiresArg $ #RCRequiresArg
# errore: '-rc' richiede un argomento\n # errore: '-rc' richiede un argomento\n
$ #MENURequiresArg
# errore: '-menu' richiede un argomento\n
$ #DISPLAYRequiresArg $ #DISPLAYRequiresArg
# errore: '-display' richiede an argomento\n # errore: '-display' richiede an argomento\n
$ #WarnDisplaySet $ #WarnDisplaySet
@ -12,6 +14,7 @@ $ #Usage
\t\t\t 1997 - 2000 Brad Hughes\n\n\ \t\t\t 1997 - 2000 Brad Hughes\n\n\
-display <string>\t\tusa connessione display.\n\ -display <string>\t\tusa connessione display.\n\
-rc <string>\t\t\tusa un file risorsa alternativo.\n\ -rc <string>\t\t\tusa un file risorsa alternativo.\n\
-menu <string>\t\t\tusa un file menu alternativo.\n\
-version\t\t\tmostra la versione e esci.\n\ -version\t\t\tmostra la versione e esci.\n\
-help\t\t\t\tmostra questo aiuto e esci.\n\n -help\t\t\t\tmostra questo aiuto e esci.\n\n
$ #CompileOptions $ #CompileOptions

View file

@ -2,6 +2,8 @@ $set 14 #main
$ #RCRequiresArg $ #RCRequiresArg
# : '-rc' \n # : '-rc' \n
$ #MENURequiresArg
# : '-menu' \n
$ #DISPLAYRequiresArg $ #DISPLAYRequiresArg
# : '-display' \n # : '-display' \n
$ #WarnDisplaySet $ #WarnDisplaySet
@ -12,6 +14,7 @@ $ #Usage
\t\t\t 1997 - 2000 Brad Hughes\n\n\ \t\t\t 1997 - 2000 Brad Hughes\n\n\
-display <string>\t\t\n\ -display <string>\t\t\n\
-rc <string>\t\t\t使\n\ -rc <string>\t\t\t使\n\
-menu <string>\t\t\tuse alternate menu file\n\
-version\t\t\t\n\ -version\t\t\t\n\
-help\t\t\t\t\n\n -help\t\t\t\t\n\n
$ #CompileOptions $ #CompileOptions

View file

@ -2,6 +2,8 @@ $set 14 #main
$ #RCRequiresArg $ #RCRequiresArg
# fout: '-rc' heeft een argument nodig (bestandsnaam)\n # fout: '-rc' heeft een argument nodig (bestandsnaam)\n
$ #MENURequiresArg
# fout: '-menu' heeft een argument nodig (bestandsnaam)\n
$ #DISPLAYRequiresArg $ #DISPLAYRequiresArg
# fout: '-display' heeft een argument nodig (displaynaam)\n # fout: '-display' heeft een argument nodig (displaynaam)\n
$ #WarnDisplaySet $ #WarnDisplaySet
@ -12,6 +14,7 @@ $ #Usage
\t\t\t 1997 - 2000 Brad Hughes\n\n\ \t\t\t 1997 - 2000 Brad Hughes\n\n\
-display <displaynaam> gebruik aangegeven display.\n\ -display <displaynaam> gebruik aangegeven display.\n\
-rc <bestandsnaam> gebruik alternatief resource bestand.\n\ -rc <bestandsnaam> gebruik alternatief resource bestand.\n\
-menu <bestandsnaam> gebruik alternatief menu bestand.\n\
-version toon versie en stop.\n\ -version toon versie en stop.\n\
-help toon deze hulp tekst en stop.\n\n -help toon deze hulp tekst en stop.\n\n
$ #CompileOptions $ #CompileOptions

View file

@ -2,6 +2,8 @@ $set 14 #main
$ #RCRequiresArg $ #RCRequiresArg
# erro: '-rc' requer um argumento\n # erro: '-rc' requer um argumento\n
$ #MENURequiresArg
# erro: '-menu' requer um argumento\n
$ #DISPLAYRequiresArg $ #DISPLAYRequiresArg
# erro: '-display' requer um argumento\n # erro: '-display' requer um argumento\n
$ #WarnDisplaySet $ #WarnDisplaySet
@ -12,6 +14,7 @@ $ #Usage
\t\t\t 1997 - 2000 Brad Hughes\n\n\ \t\t\t 1997 - 2000 Brad Hughes\n\n\
-display <string>\t\tusar conexão com o display.\n\ -display <string>\t\tusar conexão com o display.\n\
-rc <string>\t\t\tusar arquivo alternativo de recursos.\n\ -rc <string>\t\t\tusar arquivo alternativo de recursos.\n\
-menu <string>\t\t\tusar arquivo alternativo de menu.\n\
-version\t\t\tmostrar versao e sair.\n\ -version\t\t\tmostrar versao e sair.\n\
-help\t\t\t\tmostrar esta ajuda e sair.\n\n -help\t\t\t\tmostrar esta ajuda e sair.\n\n
$ #CompileOptions $ #CompileOptions

View file

@ -2,6 +2,8 @@ $set 14 #main
$ #RCRequiresArg $ #RCRequiresArg
# ошибка: '-rc' требует наличие аргумента\n # ошибка: '-rc' требует наличие аргумента\n
$ #MENURequiresArg
# ÏÛÉÂËÁ: '-menu' ÔÒÅÂÕÅÔ ÎÁÌÉÞÉÅ ÁÒÇÕÍÅÎÔÁ\n
$ #DISPLAYRequiresArg $ #DISPLAYRequiresArg
# ошибка: '-display' требует наличие аргумента\n # ошибка: '-display' требует наличие аргумента\n
$ #WarnDisplaySet $ #WarnDisplaySet
@ -12,6 +14,7 @@ $ #Usage
\t\t\t 1997 - 2000 Brad Hughes\n\n\ \t\t\t 1997 - 2000 Brad Hughes\n\n\
-display <string>\t\tиспользовать заданный дисплей.\n\ -display <string>\t\tиспользовать заданный дисплей.\n\
-rc <string>\t\t\tиспользовать альтернативный файл ресурсов.\n\ -rc <string>\t\t\tиспользовать альтернативный файл ресурсов.\n\
-menu <string>\t\t\tuse alternate menu file.\n\
-version\t\t\tвывести номер версии и выйти.\n\ -version\t\t\tвывести номер версии и выйти.\n\
-help\t\t\t\tвывести эту подсказку и выйти.\n\n -help\t\t\t\tвывести эту подсказку и выйти.\n\n
$ #CompileOptions $ #CompileOptions

View file

@ -2,6 +2,8 @@ $set 14 #main
$ #RCRequiresArg $ #RCRequiresArg
# napaka: '-rc' zahteva argument\n # napaka: '-rc' zahteva argument\n
$ #MENURequiresArg
# napaka: '-menu' zahteva argument\n
$ #DISPLAYRequiresArg $ #DISPLAYRequiresArg
# napaka: '-display' zahteva argument\n # napaka: '-display' zahteva argument\n
$ #WarnDisplaySet $ #WarnDisplaySet
@ -12,6 +14,7 @@ $ #Usage
\t\t\t 1997 - 2000 Brad Hughes\n\n\ \t\t\t 1997 - 2000 Brad Hughes\n\n\
-display <string>\t\tuporabi prikazovalnik.\n\ -display <string>\t\tuporabi prikazovalnik.\n\
-rc <string>\t\t\tuporabi nadomestno datoteko z viri.\n\ -rc <string>\t\t\tuporabi nadomestno datoteko z viri.\n\
-menu <string>\t\t\tuse alternate menu file.\n\
-version\t\t\tprika¾i oznako razlièice in konèaj.\n\ -version\t\t\tprika¾i oznako razlièice in konèaj.\n\
-help\t\t\t\prika¾i ta navodila in konèaj.\n\n -help\t\t\t\prika¾i ta navodila in konèaj.\n\n
$ #CompileOptions $ #CompileOptions

View file

@ -2,6 +2,8 @@ $set 14 #main
$ #RCRequiresArg $ #RCRequiresArg
# fel: '-rc' kräver ett argument\n # fel: '-rc' kräver ett argument\n
$ #MENURequiresArg
# fel: '-menu' kräver ett argument\n
$ #DISPLAYRequiresArg $ #DISPLAYRequiresArg
# fel: '-display' kräver ett argument\n # fel: '-display' kräver ett argument\n
$ #WarnDisplaySet $ #WarnDisplaySet
@ -12,6 +14,7 @@ $ #Usage
\t\t\t 1997 - 2000 Brad Hughes\n\n\ \t\t\t 1997 - 2000 Brad Hughes\n\n\
-display <string>\t\tanvänd skärmanslutning.\n\ -display <string>\t\tanvänd skärmanslutning.\n\
-rc <string>\t\t\tanvänd alternativ resursfil.\n\ -rc <string>\t\t\tanvänd alternativ resursfil.\n\
-menu <string>\t\t\tanvänd alternativ menu.\n\
-version\t\t\tvisa version och avsluta.\n\ -version\t\t\tvisa version och avsluta.\n\
-help\t\t\t\tvisa denna hjälptext och avsluta.\n\n -help\t\t\t\tvisa denna hjälptext och avsluta.\n\n
$ #CompileOptions $ #CompileOptions

View file

@ -2,6 +2,8 @@ $set 14 #main
$ #RCRequiresArg $ #RCRequiresArg
# hata : '-rc' bir argüman bekler\n # hata : '-rc' bir argüman bekler\n
$ #MENURequiresArg
# hata : '-menu' bir argüman bekler\n
$ #DISPLAYRequiresArg $ #DISPLAYRequiresArg
# hata : '-display' bir argüman bekler\n # hata : '-display' bir argüman bekler\n
$ #WarnDisplaySet $ #WarnDisplaySet
@ -12,6 +14,7 @@ $ #Usage
\t\t\t 1997 - 2000 Brad Hughes\n\n\ \t\t\t 1997 - 2000 Brad Hughes\n\n\
-display <metin>\t\tekranı kullan.\n\ -display <metin>\t\tekranı kullan.\n\
-rc <metin>\t\t\tbaşka bir ayarlama dosyasını kullan.\n\ -rc <metin>\t\t\tbaşka bir ayarlama dosyasını kullan.\n\
-menu <metin>\t\t\tuse alternate menu file.\n\
-version\t\t\tnesil bilgisini gösterir ve çıkar.\n\ -version\t\t\tnesil bilgisini gösterir ve çıkar.\n\
-help\t\t\t\tbu yardım iletisini gösterir ve çıkar.\n\n -help\t\t\t\tbu yardım iletisini gösterir ve çıkar.\n\n
$ #CompileOptions $ #CompileOptions

View file

@ -2,6 +2,8 @@ $set 14 #main
$ #RCRequiresArg $ #RCRequiresArg
# : '-rc' \n # : '-rc' \n
$ #MENURequiresArg
# : '-menu' \n
$ #DISPLAYRequiresArg $ #DISPLAYRequiresArg
# : '-display' \n # : '-display' \n
$ #WarnDisplaySet $ #WarnDisplaySet
@ -12,6 +14,7 @@ $ #Usage
\t\t\t 1997 - 2000 Brad Hughes\n\n\ \t\t\t 1997 - 2000 Brad Hughes\n\n\
-display <string>\t\t使.\n\ -display <string>\t\t使.\n\
-rc <string>\t\t\t使.\n\ -rc <string>\t\t\t使.\n\
-menu <string>\t\t\tuse alternate menu file.\n\
-version\t\t\t.\n\ -version\t\t\t.\n\
-help\t\t\t\t.\n\n -help\t\t\t\t.\n\n
$ #CompileOptions $ #CompileOptions

View file

@ -2265,60 +2265,73 @@ void BScreen::InitMenu(void) {
} else { } else {
rootmenu = new Rootmenu(*this); rootmenu = new Rootmenu(*this);
} }
Bool defaultMenu = True; bool defaultMenu = true;
if (openbox.getMenuFilename()) { FILE *menu_file;
FILE *menu_file = fopen(openbox.getMenuFilename(), "r"); const char *menu_filename = openbox.getMenuFilename();
if (!menu_file) { if (!(menu_file = fopen(menu_filename, "r"))) {
perror(openbox.getMenuFilename()); perror(menu_filename);
} else { menu_filename = (char *) 0;
if (feof(menu_file)) { }
fprintf(stderr, i18n->getMessage(ScreenSet, ScreenEmptyMenuFile, if (menu_filename == (char *) 0) {
"%s: Empty menu file"), // opening the menu file failed, try the DEFAULTMENU
openbox.getMenuFilename()); menu_filename = DEFAULTMENU;
} else { if (!(menu_file = fopen(menu_filename, "r"))) {
char line[1024], label[1024]; perror(menu_filename);
memset(line, 0, 1024); menu_filename = (char *) 0;
memset(label, 0, 1024);
while (fgets(line, 1024, menu_file) && ! feof(menu_file)) {
if (line[0] != '#') {
int i, key = 0, index = -1, len = strlen(line);
key = 0;
for (i = 0; i < len; i++) {
if (line[i] == '[') index = 0;
else if (line[i] == ']') break;
else if (line[i] != ' ')
if (index++ >= 0)
key += tolower(line[i]);
}
if (key == 517) {
index = -1;
for (i = index; i < len; i++) {
if (line[i] == '(') index = 0;
else if (line[i] == ')') break;
else if (index++ >= 0) {
if (line[i] == '\\' && i < len - 1) i++;
label[index - 1] = line[i];
}
}
if (index == -1) index = 0;
label[index] = '\0';
rootmenu->setLabel(label);
defaultMenu = parseMenuFile(menu_file, rootmenu);
break;
}
}
}
}
fclose(menu_file);
} }
} }
if (menu_filename) {
if (feof(menu_file)) {
fprintf(stderr, i18n->getMessage(ScreenSet, ScreenEmptyMenuFile,
"%s: Empty menu file"), menu_filename);
menu_filename = (char *) 0;
} else {
// successsfully opened a menu file
char line[1024], label[1024];
memset(line, 0, 1024);
memset(label, 0, 1024);
while (fgets(line, 1024, menu_file) && ! feof(menu_file)) {
if (line[0] != '#') {
int i, key = 0, index = -1, len = strlen(line);
key = 0;
for (i = 0; i < len; i++) {
if (line[i] == '[') index = 0;
else if (line[i] == ']') break;
else if (line[i] != ' ')
if (index++ >= 0)
key += tolower(line[i]);
}
if (key == 517) {
index = -1;
for (i = index; i < len; i++) {
if (line[i] == '(') index = 0;
else if (line[i] == ')') break;
else if (index++ >= 0) {
if (line[i] == '\\' && i < len - 1) i++;
label[index - 1] = line[i];
}
}
if (index == -1) index = 0;
label[index] = '\0';
rootmenu->setLabel(label);
defaultMenu = parseMenuFile(menu_file, rootmenu);
if (!defaultMenu)
openbox.addMenuTimestamp(menu_filename);
break;
}
}
}
}
fclose(menu_file);
}
if (defaultMenu) { if (defaultMenu) {
rootmenu->setInternalMenu(); rootmenu->setInternalMenu();
@ -2329,8 +2342,6 @@ void BScreen::InitMenu(void) {
BScreen::Restart); BScreen::Restart);
rootmenu->insert(i18n->getMessage(ScreenSet, ScreenExit, "Exit"), rootmenu->insert(i18n->getMessage(ScreenSet, ScreenExit, "Exit"),
BScreen::Exit); BScreen::Exit);
} else {
openbox.setMenuFilename(openbox.getMenuFilename());
} }
} }
@ -2530,10 +2541,9 @@ Bool BScreen::parseMenuFile(FILE *file, Rootmenu *menu) {
} }
if (! feof(submenufile)) { if (! feof(submenufile)) {
if (! parseMenuFile(submenufile, menu)) if (!parseMenuFile(submenufile, menu))
openbox.setMenuFilename(newfile); openbox.addMenuTimestamp(newfile);
fclose(submenufile);
fclose(submenufile);
} }
} else } else
perror(newfile); perror(newfile);
@ -2689,8 +2699,7 @@ Bool BScreen::parseMenuFile(FILE *file, Rootmenu *menu) {
menu->insert(label, stylesmenu); menu->insert(label, stylesmenu);
rootmenuList.push_back(stylesmenu); rootmenuList.push_back(stylesmenu);
} }
openbox.addMenuTimestamp(stylesdir);
openbox.setMenuFilename(stylesdir);
} else { } else {
fprintf(stderr, i18n->getMessage(ScreenSet, fprintf(stderr, i18n->getMessage(ScreenSet,
ScreenSTYLESDIRErrorNotDir, ScreenSTYLESDIRErrorNotDir,

View file

@ -68,6 +68,7 @@ static void showHelp(int exitval) {
"\t\t\t 1997 - 2000 Brad Hughes\n\n" "\t\t\t 1997 - 2000 Brad Hughes\n\n"
" -display <string>\t\tuse display connection.\n" " -display <string>\t\tuse display connection.\n"
" -rc <string>\t\t\tuse alternate resource file.\n" " -rc <string>\t\t\tuse alternate resource file.\n"
" -menu <string>\t\t\tuse alternate menu file.\n"
" -version\t\t\tdisplay version and exit.\n" " -version\t\t\tdisplay version and exit.\n"
" -help\t\t\t\tdisplay this help text and exit.\n\n"), " -help\t\t\t\tdisplay this help text and exit.\n\n"),
__openbox_version); __openbox_version);
@ -125,6 +126,7 @@ static void showHelp(int exitval) {
int main(int argc, char **argv) { int main(int argc, char **argv) {
char *session_display = (char *) 0; char *session_display = (char *) 0;
char *rc_file = (char *) 0; char *rc_file = (char *) 0;
char *menu_file = (char *) 0;
NLSInit("openbox.cat"); NLSInit("openbox.cat");
@ -134,13 +136,25 @@ int main(int argc, char **argv) {
if ((++i) >= argc) { if ((++i) >= argc) {
fprintf(stderr, fprintf(stderr,
i18n->getMessage(mainSet, mainRCRequiresArg, i18n->getMessage(mainSet, mainRCRequiresArg,
"error: '-rc' requires and argument\n")); "error: '-rc' requires and argument\n"));
::exit(1); ::exit(1);
} }
rc_file = argv[i]; rc_file = argv[i];
} else if (! strcmp(argv[i], "-menu")) {
// look for alternative menu file to use
if ((++i) >= argc) {
fprintf(stderr,
i18n->getMessage(mainSet, mainMENURequiresArg,
"error: '-menu' requires and argument\n"));
::exit(1);
}
menu_file = argv[i];
} else if (! strcmp(argv[i], "-display")) { } else if (! strcmp(argv[i], "-display")) {
// check for -display option... to run on a display other than the one // check for -display option... to run on a display other than the one
// set by the environment variable DISPLAY // set by the environment variable DISPLAY
@ -182,7 +196,7 @@ int main(int argc, char **argv) {
_chdir2(getenv("X11ROOT")); _chdir2(getenv("X11ROOT"));
#endif // __EMX__ #endif // __EMX__
Openbox openbox(argc, argv, session_display, rc_file); Openbox openbox(argc, argv, session_display, rc_file, menu_file);
openbox.eventLoop(); openbox.eventLoop();
return(0); return(0);

View file

@ -151,8 +151,8 @@ static Bool queueScanner(Display *, XEvent *e, char *args) {
Openbox *openbox; Openbox *openbox;
Openbox::Openbox(int m_argc, char **m_argv, char *dpy_name, char *rc) Openbox::Openbox(int m_argc, char **m_argv, char *dpy_name, char *rc,
: BaseDisplay(m_argv[0], dpy_name) { char *menu) : BaseDisplay(m_argv[0], dpy_name) {
grab(); grab();
if (! XSupportsLocale()) if (! XSupportsLocale())
@ -164,25 +164,35 @@ Openbox::Openbox(int m_argc, char **m_argv, char *dpy_name, char *rc)
::openbox = this; ::openbox = this;
argc = m_argc; argc = m_argc;
argv = m_argv; argv = m_argv;
if (rc == NULL) { if (rc == NULL || menu == NULL) {
char *homedir = getenv("HOME"); char *homedir = getenv("HOME");
char *configdir = new char[strlen(homedir) + strlen("/.openbox") + 1];
rc_file = new char[strlen(homedir) + strlen("/.openbox/rc") + 1]; sprintf(configdir, "%s/.openbox", homedir);
sprintf(rc_file, "%s/.openbox", homedir);
// try to make sure the ~/.openbox directory exists // try to make sure the ~/.openbox directory exists
mkdir(rc_file, S_IREAD | S_IWRITE | S_IEXEC | S_IRGRP | S_IWGRP | S_IXGRP | mkdir(configdir, S_IREAD | S_IWRITE | S_IEXEC |
S_IRGRP | S_IWGRP | S_IXGRP |
S_IROTH | S_IWOTH | S_IXOTH); S_IROTH | S_IWOTH | S_IXOTH);
sprintf(rc_file, "%s/.openbox/rc", homedir);
} else { if (rc == NULL) {
rc_file = bstrdup(rc); rc_file = new char[strlen(configdir) + strlen("/rc") + 1];
sprintf(rc_file, "%s/rc", configdir);
} else
rc_file = bstrdup(rc);
if (menu == NULL) {
menu_file = new char[strlen(configdir) + strlen("/menu") + 1];
sprintf(menu_file, "%s/menu", configdir);
} else
menu_file = bstrdup(menu);
delete [] configdir;
} }
config.setFile(rc_file); config.setFile(rc_file);
no_focus = False; no_focus = False;
resource.menu_file = resource.style_file = NULL; resource.style_file = NULL;
resource.titlebar_layout = NULL; resource.titlebar_layout = NULL;
resource.auto_raise_delay.tv_sec = resource.auto_raise_delay.tv_usec = 0; resource.auto_raise_delay.tv_sec = resource.auto_raise_delay.tv_usec = 0;
@ -240,9 +250,6 @@ Openbox::~Openbox() {
for_each(menuTimestamps.begin(), menuTimestamps.end(), for_each(menuTimestamps.begin(), menuTimestamps.end(),
PointerAssassin()); PointerAssassin());
if (resource.menu_file)
delete [] resource.menu_file;
if (resource.style_file) if (resource.style_file)
delete [] resource.style_file; delete [] resource.style_file;
@ -252,6 +259,7 @@ Openbox::~Openbox() {
delete timer; delete timer;
delete [] rc_file; delete [] rc_file;
delete [] menu_file;
} }
@ -883,7 +891,6 @@ void Openbox::save() {
// save all values as they are so that the defaults will be written to the rc // save all values as they are so that the defaults will be written to the rc
// file // file
config.setValue("session.menuFile", getMenuFilename());
config.setValue("session.colorsPerChannel", config.setValue("session.colorsPerChannel",
resource.colors_per_channel); resource.colors_per_channel);
config.setValue("session.styleFile", resource.style_file); config.setValue("session.styleFile", resource.style_file);
@ -910,13 +917,6 @@ void Openbox::load() {
std::string s; std::string s;
long l; long l;
if (resource.menu_file)
delete [] resource.menu_file;
if (config.getValue("session.menuFile", "Session.MenuFile", s))
resource.menu_file = bstrdup(s.c_str());
else
resource.menu_file = bstrdup(DEFAULTMENU);
if (config.getValue("session.colorsPerChannel", "Session.ColorsPerChannel", if (config.getValue("session.colorsPerChannel", "Session.ColorsPerChannel",
l)) l))
resource.colors_per_channel = (l < 2 ? 2 : (l > 6 ? 6 : l)); // >= 2, <= 6 resource.colors_per_channel = (l < 2 ? 2 : (l > 6 ? 6 : l)); // >= 2, <= 6
@ -1001,6 +1001,29 @@ void Openbox::checkMenu() {
} }
void Openbox::addMenuTimestamp(const char *filename) {
bool found = false;
MenuTimestampList::iterator it;
for (it = menuTimestamps.begin(); it != menuTimestamps.end(); ++it)
if (! strcmp((*it)->filename, filename)) {
found = true;
break;
}
if (!found) {
struct stat buf;
if (! stat(filename, &buf)) {
MenuTimestamp *ts = new MenuTimestamp;
ts->filename = bstrdup(filename);
ts->timestamp = buf.st_ctime;
menuTimestamps.push_back(ts);
}
}
}
void Openbox::rereadMenu() { void Openbox::rereadMenu() {
reread_menu_wait = True; reread_menu_wait = True;
@ -1027,30 +1050,6 @@ void Openbox::setStyleFilename(const char *filename) {
} }
void Openbox::setMenuFilename(const char *filename) {
bool found = false;
MenuTimestampList::iterator it;
for (it = menuTimestamps.begin(); it != menuTimestamps.end(); ++it)
if (! strcmp((*it)->filename, filename)) {
found = true;
break;
}
if (!found) {
struct stat buf;
if (! stat(filename, &buf)) {
MenuTimestamp *ts = new MenuTimestamp;
ts->filename = bstrdup(filename);
ts->timestamp = buf.st_ctime;
menuTimestamps.push_back(ts);
}
}
}
void Openbox::timeout() { void Openbox::timeout() {
if (reconfigure_wait) if (reconfigure_wait)
real_reconfigure(); real_reconfigure();

View file

@ -87,7 +87,7 @@ private:
struct resource { struct resource {
Time double_click_interval; Time double_click_interval;
char *menu_file, *style_file; char *style_file;
char *titlebar_layout; char *titlebar_layout;
int colors_per_channel; int colors_per_channel;
timeval auto_raise_delay; timeval auto_raise_delay;
@ -129,7 +129,7 @@ private:
Bool no_focus, reconfigure_wait, reread_menu_wait; Bool no_focus, reconfigure_wait, reread_menu_wait;
Time last_time; Time last_time;
Window masked; Window masked;
char *rc_file, **argv; char *menu_file, *rc_file, **argv;
int argc; int argc;
Resource config; Resource config;
@ -144,7 +144,7 @@ protected:
public: public:
Openbox(int, char **, char * = 0, char * = 0); Openbox(int, char **, char * = 0, char * = 0, char * = 0);
virtual ~Openbox(); virtual ~Openbox();
#ifdef HAVE_GETPID #ifdef HAVE_GETPID
@ -173,7 +173,8 @@ public:
inline const char *getStyleFilename() const inline const char *getStyleFilename() const
{ return resource.style_file; } { return resource.style_file; }
inline const char *getMenuFilename() const inline const char *getMenuFilename() const
{ return resource.menu_file; } { return menu_file; }
void addMenuTimestamp(const char *filename);
inline const int &getColorsPerChannel() const inline const int &getColorsPerChannel() const
{ return resource.colors_per_channel; } { return resource.colors_per_channel; }
@ -197,7 +198,6 @@ public:
void shutdown(); void shutdown();
void setStyleFilename(const char *); void setStyleFilename(const char *);
void setMenuFilename(const char *);
void saveMenuSearch(Window, Basemenu *); void saveMenuSearch(Window, Basemenu *);
void saveWindowSearch(Window, OpenboxWindow *); void saveWindowSearch(Window, OpenboxWindow *);
void saveToolbarSearch(Window, Toolbar *); void saveToolbarSearch(Window, Toolbar *);