mirror of
https://github.com/edeproject/ede.git
synced 2023-08-10 21:13:03 +03:00
Correctly write/read user supplied programs.
This commit is contained in:
parent
09b60c67c8
commit
46cb6110b7
@ -60,6 +60,7 @@ void AppChoice::add_if_user_program(const char *cmd) {
|
|||||||
|
|
||||||
if(found) return;
|
if(found) return;
|
||||||
|
|
||||||
|
user_val = cmd;
|
||||||
replace(size() - 2, get_basename(cmd));
|
replace(size() - 2, get_basename(cmd));
|
||||||
add(_("Browse..."));
|
add(_("Browse..."));
|
||||||
}
|
}
|
||||||
@ -70,6 +71,16 @@ void AppChoice::select_by_cmd(const char *cmd) {
|
|||||||
|
|
||||||
int pos;
|
int pos;
|
||||||
|
|
||||||
|
if(!user_val.empty()) {
|
||||||
|
const char *b = get_basename(user_val.c_str());
|
||||||
|
pos = find_index(b);
|
||||||
|
if(pos >= 0) {
|
||||||
|
value(pos);
|
||||||
|
pvalue = pos;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
for(int i = 0; known_apps[i].name; i++) {
|
for(int i = 0; known_apps[i].name; i++) {
|
||||||
if(STR_CMP(cmd, known_apps[i].cmd)) {
|
if(STR_CMP(cmd, known_apps[i].cmd)) {
|
||||||
/* now find menu entry with this name */
|
/* now find menu entry with this name */
|
||||||
@ -94,7 +105,7 @@ const char *AppChoice::selected(void) {
|
|||||||
const char *n = text();
|
const char *n = text();
|
||||||
|
|
||||||
/* first check if user one was selected */
|
/* first check if user one was selected */
|
||||||
if(!user_val.empty() && STR_CMP(get_basename(user_val.c_str()), n));
|
if(!user_val.empty() && STR_CMP(get_basename(user_val.c_str()), n))
|
||||||
return user_val.c_str();
|
return user_val.c_str();
|
||||||
|
|
||||||
for(int i = 0; known_apps[i].name; i++) {
|
for(int i = 0; known_apps[i].name; i++) {
|
||||||
|
@ -16,6 +16,8 @@
|
|||||||
|
|
||||||
#include "AppChoice.h"
|
#include "AppChoice.h"
|
||||||
|
|
||||||
|
#define EMPTY_STR(s) (s[0] == '\0' || (strlen(s) == 0))
|
||||||
|
|
||||||
EDELIB_NS_USING_AS(Window, EdeWindow)
|
EDELIB_NS_USING_AS(Window, EdeWindow)
|
||||||
EDELIB_NS_USING(Resource)
|
EDELIB_NS_USING(Resource)
|
||||||
|
|
||||||
@ -33,7 +35,7 @@ static void check_and_store(AppChoice *c, const char *n, Resource &rc) {
|
|||||||
/* load separate item */
|
/* load separate item */
|
||||||
static void check_and_load(AppChoice *c, const char *n, Resource &rc) {
|
static void check_and_load(AppChoice *c, const char *n, Resource &rc) {
|
||||||
static char buf[128];
|
static char buf[128];
|
||||||
if(rc.get("Preferred", n, buf, sizeof(buf)) && strlen(buf) > 0) {
|
if(rc.get("Preferred", n, buf, sizeof(buf)) && !EMPTY_STR(buf)) {
|
||||||
c->add_if_user_program(buf);
|
c->add_if_user_program(buf);
|
||||||
c->select_by_cmd(buf);
|
c->select_by_cmd(buf);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user