mirror of
https://github.com/edeproject/ede.git
synced 2023-08-10 21:13:03 +03:00
Handle 'Browse...' click.
This commit is contained in:
parent
688f5e07de
commit
796a43cda5
@ -82,3 +82,15 @@ bool app_is_magic_cmd(const char *cmd) {
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
bool app_is_browse_item(KnownApp *lst, const char *name) {
|
||||
E_RETURN_VAL_IF_FAIL(lst != 0, false);
|
||||
E_RETURN_VAL_IF_FAIL(name != 0, false);
|
||||
|
||||
for(int i = 0; lst[i].name; i++) {
|
||||
if(strcmp(lst[i].name, name) == 0 && app_is_magic_cmd(lst[i].cmd) && lst[i].cmd[1] == 'b')
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
@ -28,4 +28,6 @@ void app_populate_menu(KnownApp *lst, Fl_Choice *c);
|
||||
|
||||
bool app_is_magic_cmd(const char *cmd);
|
||||
inline bool app_is_magic_cmd(const KnownApp &a) { return app_is_magic_cmd(a.cmd); }
|
||||
|
||||
bool app_is_browse_item(KnownApp *lst, const char *name);
|
||||
#endif
|
||||
|
@ -8,10 +8,12 @@
|
||||
#include <FL/Fl_Group.H>
|
||||
#include <FL/Fl_Choice.H>
|
||||
#include <FL/Fl_Tabs.H>
|
||||
#include <FL/Fl_File_Chooser.H>
|
||||
#include <edelib/Window.h>
|
||||
#include <edelib/Nls.h>
|
||||
#include <edelib/Ede.h>
|
||||
#include <edelib/Resource.h>
|
||||
#include <edelib/Debug.h>
|
||||
|
||||
#include "PredefApps.h"
|
||||
|
||||
@ -58,6 +60,18 @@ static void load_settings(void) {
|
||||
check_and_load(term_choice, app_terminals, "terminal", rc);
|
||||
}
|
||||
|
||||
static void menu_cb(Fl_Widget *widget, void *ww) {
|
||||
Fl_Choice *c = (Fl_Choice*)widget;
|
||||
const char *name = c->text();
|
||||
KnownApp *lst = (KnownApp*)ww;
|
||||
|
||||
if(!name || !app_is_browse_item(lst, name)) return;
|
||||
const char *path = fl_file_chooser(_("Choose program"), "*", 0);
|
||||
|
||||
/* go to first, as it will be None */
|
||||
if(!path) c->value(0);
|
||||
}
|
||||
|
||||
static void close_cb(Fl_Widget *widget, void *ww) {
|
||||
EdeWindow *win = (EdeWindow*)ww;
|
||||
win->hide();
|
||||
@ -87,11 +101,13 @@ int main(int argc, char** argv) {
|
||||
browser_choice->align(FL_ALIGN_TOP_LEFT);
|
||||
app_populate_menu(app_browsers, browser_choice);
|
||||
browser_choice->value(0);
|
||||
browser_choice->callback(menu_cb, app_browsers);
|
||||
|
||||
mail_choice = new Fl_Choice(20, 120, 320, 25, _("Mail reader"));
|
||||
mail_choice->align(FL_ALIGN_TOP_LEFT);
|
||||
app_populate_menu(app_mails, mail_choice);
|
||||
mail_choice->value(0);
|
||||
mail_choice->callback(menu_cb, app_mails);
|
||||
gint->end();
|
||||
|
||||
Fl_Group *gutil = new Fl_Group(15, 30, 335, 140, _("Utilities"));
|
||||
@ -101,11 +117,13 @@ int main(int argc, char** argv) {
|
||||
filemgr_choice->align(FL_ALIGN_TOP_LEFT);
|
||||
app_populate_menu(app_filemanagers, filemgr_choice);
|
||||
filemgr_choice->value(0);
|
||||
filemgr_choice->callback(menu_cb, app_filemanagers);
|
||||
|
||||
term_choice = new Fl_Choice(20, 120, 320, 25, _("Terminal"));
|
||||
term_choice->align(FL_ALIGN_TOP_LEFT);
|
||||
app_populate_menu(app_terminals, term_choice);
|
||||
term_choice->value(0);
|
||||
term_choice->callback(menu_cb, app_terminals);
|
||||
gutil->end();
|
||||
tabs->end();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user