mirror of
https://github.com/edeproject/ede.git
synced 2023-08-10 21:13:03 +03:00
find_index() exists only in fltk 1.3.x
This commit is contained in:
parent
2e4fc39aa2
commit
4c94bcd899
@ -73,7 +73,7 @@ void AppChoice::select_by_cmd(const char *cmd) {
|
|||||||
|
|
||||||
if(!user_val.empty()) {
|
if(!user_val.empty()) {
|
||||||
const char *b = get_basename(user_val.c_str());
|
const char *b = get_basename(user_val.c_str());
|
||||||
pos = find_index(b);
|
pos = find_item_index(b);
|
||||||
if(pos >= 0) {
|
if(pos >= 0) {
|
||||||
value(pos);
|
value(pos);
|
||||||
pvalue = pos;
|
pvalue = pos;
|
||||||
@ -84,7 +84,7 @@ void AppChoice::select_by_cmd(const char *cmd) {
|
|||||||
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 */
|
||||||
pos = find_index(known_apps[i].name);
|
pos = find_item_index(known_apps[i].name);
|
||||||
if(pos >= 0) {
|
if(pos >= 0) {
|
||||||
value(pos);
|
value(pos);
|
||||||
pvalue = pos;
|
pvalue = pos;
|
||||||
@ -135,3 +135,21 @@ void AppChoice::on_select(void) {
|
|||||||
|
|
||||||
pvalue = value();
|
pvalue = value();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int AppChoice::find_item_index(const char *p) {
|
||||||
|
E_RETURN_VAL_IF_FAIL(p != NULL, -1);
|
||||||
|
|
||||||
|
const Fl_Menu_Item *m;
|
||||||
|
for(int i = 0; i < size(); i++) {
|
||||||
|
m = menu() + i;
|
||||||
|
if(m->flags & FL_SUBMENU) {
|
||||||
|
E_WARNING(E_STRLOC ": Submenus are not supported\n");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!m->label()) continue;
|
||||||
|
if(strcmp(m->label(), p) == 0) return i;
|
||||||
|
}
|
||||||
|
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
@ -22,6 +22,12 @@ public:
|
|||||||
void select_by_cmd(const char *cmd);
|
void select_by_cmd(const char *cmd);
|
||||||
const char *selected(void);
|
const char *selected(void);
|
||||||
void on_select(void);
|
void on_select(void);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* FLTK 1.3 has this function, but not previous one versions.
|
||||||
|
* Here, we are not traversing submenus, e.g. Edit/Copy, but only top level ones
|
||||||
|
*/
|
||||||
|
int find_item_index(const char *p);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user