int main(int argc, char **argv) { EDE_APPLICATION(EDE_DESKTOP_APP); desktop = NULL; signal(SIGTERM, exit_signal); signal(SIGKILL, exit_signal); signal(SIGINT, exit_signal); /* initialize random number generator */ srand(time(NULL)); desktop = new Desktop(); desktop->show(); return Fl::run(); }
static void window_create(int argc, char** argv) { EDE_APPLICATION("ede-bell-conf"); win = new edelib::Window(330, 210, _("System bell configuration"), edelib::WIN_INIT_NONE); win->begin(); vol_slide = new Fl_Value_Slider(10, 30, 310, 25, _("Volume")); vol_slide->type(5); vol_slide->step(1); vol_slide->maximum(100); vol_slide->align(FL_ALIGN_TOP); pitch_slide = new Fl_Value_Slider(10, 80, 310, 25, _("Pitch")); pitch_slide->type(5); pitch_slide->step(1); pitch_slide->minimum(100); pitch_slide->maximum(1000); pitch_slide->align(FL_ALIGN_TOP); dur_slide = new Fl_Value_Slider(10, 130, 310, 25, _("Duration")); dur_slide->type(5); dur_slide->step(1); dur_slide->minimum(0); dur_slide->maximum(1000); dur_slide->align(FL_ALIGN_TOP); Fl_Button* ok = new Fl_Button(135, 175, 90, 25, _("&OK")); ok->callback(ok_cb); Fl_Button* cancel = new Fl_Button(230, 175, 90, 25, _("&Cancel")); cancel->callback(cancel_cb); Fl_Button* test = new Fl_Button(10, 175, 90, 25, _("&Test")); test->callback(test_cb); win->end(); window_center_on_screen(win); win->show(argc, argv); }
int main(int argc, char **argv) { #ifdef HAVE_XKBRULES /* must be opened first */ fl_open_display(); /* only apply what was written in config */ if(argc > 1 && strcmp(argv[1], "--apply") == 0) { String layout; read_config(&layout); apply_changes_on_x(layout.c_str(), NULL); return 0; } else { read_config(NULL); } EDE_APPLICATION("ede-keyboard-conf"); String cl; dialog_canceled = false; /* get layout X holds */ fetch_current_layout(cl); /* construct GUI */ win = new AppWindow(340, 320, _("Keyboard configuration tool")); win->begin(); Fl_Tabs *tabs = new Fl_Tabs(10, 10, 320, 265); tabs->begin(); Fl_Group *layout_group = new Fl_Group(15, 30, 310, 240, _("Layout")); layout_group->begin(); layout_browser = new Fl_Hold_Browser(20, 40, 300, 190); /* so things can be nicely aligned per column */ int cwidths [] = {100, 0}; layout_browser->column_widths(cwidths); layout_browser->column_char('\t'); layout_group->resizable(layout_browser); show_flag = new Fl_Check_Button(20, 240, 300, 25, _("Show country flag")); show_flag->tooltip(_("Display country flag in panel keyboard applet")); show_flag->down_box(FL_DOWN_BOX); show_flag->value(show_flag_value); show_flag->callback(show_flag_cb); layout_group->end(); Fl_Group::current()->resizable(layout_group); Fl_Group *details_group = new Fl_Group(15, 30, 310, 240, _("Details")); details_group->hide(); details_group->begin(); repeat_press = new Fl_Check_Button(20, 45, 300, 25, _("Repeat pressed key")); repeat_press->tooltip(_("Allow pressed key to be repeated")); repeat_press->down_box(FL_DOWN_BOX); repeat_press->value(repeat_press_value); repeat_press->callback(repeat_press_cb); details_group->end(); tabs->end(); /* resizable box */ Fl_Box *rbox = new Fl_Box(30, 163, 65, 52); Fl_Group::current()->resizable(rbox); Fl_Button *ok_button = new Fl_Button(145, 285, 90, 25, _("&OK")); ok_button->callback(ok_cb); Fl_Button *cancel_button = new Fl_Button(240, 285, 90, 25, _("&Cancel")); cancel_button->callback(cancel_cb); win->end(); /* read all XKB layouts */ XkbRF_RulesPtr xkb_rules = fetch_all_layouts(cl); window_center_on_screen(win); win->show(argc, argv); Fl::run(); /* do not save configuration if was canceled */ if(!dialog_canceled && xkb_rules && layout_browser->value()) { int i = layout_browser->value(); /* get the layout that matches browser row */ char *n = xkb_rules->layouts.desc[i - 1].name; save_config(n); apply_changes_on_x(n, &cl); } if(xkb_rules) XkbRF_Free(xkb_rules, True); #else alert(_("ede-keyboard-conf was compiled without XKB extension. Please recompile it again")); #endif /* HAVE_XKBRULES */ return 0; }
int main(int argc, char** argv) { bool do_startup = false; bool do_dryrun = false; bool show_splash = true; if(argc > 1) { const char* a; for(int i = 1; i < argc; i++) { a = argv[i]; if(CHECK_ARGV(a, "-h", "--help")) { help(); return 0; } else if(CHECK_ARGV(a, "-s", "--startup")) do_startup = true; else if(CHECK_ARGV(a, "-d", "--dry-run")) do_dryrun = true; else if(CHECK_ARGV(a, "-n", "--no-splash")) show_splash = false; else { printf("Unknown parameter '%s'. Run 'evoke -h' for options\n", a); return 1; } } } EDE_APPLICATION("evoke"); /* make sure X11 is running before rest of code is called */ fl_open_display(); /* initialize main service object */ EvokeService* service = EvokeService::instance(); /* * Main loop is not initialized before startup (and splash) are finished; * this is intentional so we could use 'dryrun' to test a splash theme and startup items * without interfering with already running evoke instance (and getting lock error) * * TODO: dryrun option is pretty dummy; better to use "test-splash" or similar */ if(do_startup) { service->read_startup(); service->run_startup(show_splash, do_dryrun); } /* only testing, quit nicely */ if(do_dryrun) return 0; if(!service->setup_lock(LOCK_FILE)) { printf("*** Either another evoke instance is running or I can't create lock file.\n"); printf("*** If program abnormaly crashed before, just remove '%s' and start it again.\n", LOCK_FILE); return 1; } signal(SIGINT, quit_signal); signal(SIGTERM, quit_signal); signal(SIGKILL, quit_signal); signal(SIGQUIT, quit_signal); #ifdef USE_SIGHUP /* * This is mostly used when we get request to shutdown session and close/kill all windows. * If evoke is started from gui console (xterm, rxvt), closing that window we will get * SIGHUP since terminal will disconnect all controlling processes. On other hand, if evoke * is started as session carrier (eg. run from xinitrc), this is not needed. */ signal(SIGHUP, quit_signal); #endif service->start_xsettings_manager(); /* set stuff so xsettings manager can receive events */ XSelectInput(fl_display, RootWindow(fl_display, fl_screen), PropertyChangeMask | SubstructureNotifyMask | ClientMessage); Fl::add_handler(xmessage_handler); /* run applicator for settings; it must be done after manager is fully on */ if(do_startup) run_async("ede-settings-apply"); service->start(); while(service->running()) { /* * FLTK will not report SelectionClear needed for XSETTINGS manager * so we must catch it first before FLTK discards it (if we can :P) * This can be missed greatly due a large number of XDamage events * and using this method is not quite safe. */ if(fl_xevent && fl_xevent->type == SelectionClear) service->handle(fl_xevent); Fl::wait(FOREVER); } return 0; }
int main(int argc, char **argv) { const char *title, *txt; int opt = OPT_NONE; int ret = EDE_DIALOG_ERROR_RET; int nbuttons = 0; MessageBoxType mtype = MSGBOX_PLAIN; MessageBoxIconType itype = MSGBOX_ICON_TYPE_INFO; title = txt = NULL; if(argc <= 1) { help(); return EDE_DIALOG_ERROR_RET; } for(int i = 1; i < argc; i++) { if(CHECK_ARGV(argv[i], "-h", "--help")) { help(); return EDE_DIALOG_ERROR_RET; } /* optional flags */ if(CHECK_ARGV_LONG(argv[i], "--title")) { title = next_param(i, argv, argc); if(!title) { puts("'title' option requires a parameter"); return EDE_DIALOG_ERROR_RET; } i++; continue; } /* mandatory flags */ if(CHECK_ARGV_LONG(argv[i], "--yesno")) { itype = MSGBOX_ICON_TYPE_QUESTION; opt = OPT_YESNO; } else if(CHECK_ARGV_LONG(argv[i], "--yesnocancel")) { itype = MSGBOX_ICON_TYPE_QUESTION; opt = OPT_YESNOCANCEL; } else if(CHECK_ARGV_LONG(argv[i], "--error")) { itype = MSGBOX_ICON_TYPE_ALERT; opt = OPT_ERROR; } else if(CHECK_ARGV_LONG(argv[i], "--sorry")) { itype = MSGBOX_ICON_TYPE_ALERT; opt = OPT_SORRY; } else if(CHECK_ARGV_LONG(argv[i], "--msgbox")) { opt = OPT_MSGBOX; /* for else do nothing; use default values */ } else if(CHECK_ARGV_LONG(argv[i], "--inputbox")) { itype = MSGBOX_ICON_TYPE_INPUT; mtype = MSGBOX_INPUT; opt = OPT_INPUTBOX; } else if(CHECK_ARGV_LONG(argv[i], "--password")) { itype = MSGBOX_ICON_TYPE_PASSWORD; mtype = MSGBOX_INPUT_SECRET; opt = OPT_PASSWORD; } else { printf("Unknown '%s' parameter\n", argv[i]); return EDE_DIALOG_ERROR_RET; } /* every above option requres additional parameter */ txt = next_param(i, argv, argc); if(!txt) { printf("'%s' option requires a parameter\n", argv[i]); return EDE_DIALOG_ERROR_RET; } /* skip parameter */ i++; } if(opt == OPT_NONE) { puts("Missing one of the flags that will describe the dialog. Run program with '--help' for the details"); return EDE_DIALOG_ERROR_RET; } EDE_APPLICATION("ede-dialog"); /* * Use a trick to load icon theme and colors using xsettings stuff. edelib::Window will load them * and fill static FLTK values; every further window will use those values, including our will use them * * TODO: this hack needs appropriate solution in edelib. */ EdelibWindow *win = new EdelibWindow(-100, -100, 0, 0); win->show(); Fl::wait(0.2); win->hide(); mbox = new MessageBox(mtype); mbox->set_icon_from_type(itype); mbox->set_text(txt); mbox->label(title); /* determine buttons */ switch(opt) { case OPT_YESNO: mbox->add_button(_("&No")); mbox->add_button(_("&Yes")); nbuttons = 2; break; case OPT_YESNOCANCEL: mbox->add_button(_("&Cancel")); mbox->add_button(_("&No")); mbox->add_button(_("&Yes")); nbuttons = 3; break; case OPT_ERROR: case OPT_MSGBOX: case OPT_SORRY: mbox->add_button(_("&Close")); nbuttons = 1; break; case OPT_INPUTBOX: case OPT_PASSWORD: mbox->add_button(_("&Cancel")); mbox->add_button(_("&OK")); nbuttons = 2; break; } ret = mbox->run(); /* check box type and 'Cancel' wasn't present */ if((opt == OPT_INPUTBOX || opt == OPT_PASSWORD) && ret != 0) printf("%s\n", mbox->get_input()); /* * Now emulate kdialog return values; e.g. 'OK' will be 0 and 'Cancel' will be 1 if two buttons * are exists. Because MessageBox already do this in reversed way, here value is just re-reversed again if * we have more that one button. */ if(nbuttons > 1) { /* xor-ing with 2 is different so button number can't be decreased */ if(nbuttons == 3) { ret ^= nbuttons; ret -= 1; } else { ret ^= (nbuttons - 1); } } return ret; }
int main(int argc, char **argv) { EDE_APPLICATION("ede-screensaver-conf"); fl_open_display(); /* start daemon if not started */ xscreensaver_run_daemon(fl_display); SaverPrefs* sp = xscreensaver_read_config(); main_win = new Fl_Double_Window(340, 445, _("Screensaver options")); /* so ESC does not interrupt running process */ main_win->callback(close_cb); main_win->begin(); /* monitor */ Fl_Box* b1 = new Fl_Box(120, 163, 100, 15); b1->box(FL_BORDER_BOX); Fl_Box* b2 = new Fl_Box(65, 10, 210, 158); b2->box(FL_THIN_UP_BOX); Fl_Box* b3 = new Fl_Box(78, 20, 184, 138); b3->color(FL_BLACK); b3->box(FL_DOWN_BOX); /* preview window in 'b3' box */ preview_win = new Fl_Double_Window(80, 22, 180, 134); preview_win->color(FL_BLACK); preview_win->begin(); /* if failed to load any screensaver */ if(!sp) { Fl_Box* b4 = new Fl_Box(0, 0, 180, 134, _("No screensavers found")); b4->labelcolor(FL_GRAY); b4->align(FL_ALIGN_INSIDE | FL_ALIGN_WRAP); } preview_win->end(); Fl_Box* b4 = new Fl_Box(95, 173, 146, 14); b4->box(FL_THIN_UP_BOX); Fl_Group* g1 = new Fl_Group(10, 215, 320, 45, _("Screensaver")); g1->box(FL_ENGRAVED_BOX); g1->align(FL_ALIGN_TOP_LEFT); g1->begin(); Fl_Choice* saver_list = new Fl_Choice(19, 225, 180, 25); saver_list->down_box(FL_BORDER_BOX); saver_list->add("(None)", 0, 0); if(sp) { int sel = 0; saver_list->callback((Fl_Callback*)choice_cb, sp); /* fix possible error */ if(sp->curr_hack >= sp->hacks.size()) sp->curr_hack = 0; HackListIter it = sp->hacks.begin(), it_end = sp->hacks.end(); for(int i = 1; it != it_end; ++it, i++) { saver_list->add((*it)->name.c_str(), 0, 0); /* * Check real hack index number against current one and let it match * position in our Fl_Choice list. Note that first item is '(None)' * so 'i' starts from 1 */ if(sp->mode != SAVER_OFF && (*it)->sindex == sp->curr_hack) sel = i; } saver_list->value(sel); } timeout_val = new Fl_Spinner(275, 226, 45, 25, _("Timeout:")); timeout_val->tooltip(_("Idle time in minutes after screensaver is started")); timeout_val->range(1, 500); if(sp) timeout_val->value(sp->timeout); else timeout_val->value(1); g1->end(); Fl_Group* g2 = new Fl_Group(10, 290, 320, 110, _("Power management")); g2->box(FL_ENGRAVED_BOX); g2->align(FL_ALIGN_TOP_LEFT); g2->begin(); Fl_Check_Button* denabled = new Fl_Check_Button(20, 299, 180, 26, _("Enabled")); denabled->down_box(FL_DOWN_BOX); denabled->tooltip(_("Enable or disable Display Power Management Signaling support")); if(sp) { denabled->callback((Fl_Callback*)dpms_enable_cb, sp); denabled->value(sp->dpms_enabled); } else { denabled->value(1); } Fl_Box* energy_image = new Fl_Box(20, 341, 75, 49); energy_image->image(image_energy); standby_val = new Fl_Spinner(275, 301, 45, 24, _("Standby:")); standby_val->tooltip(_("Minutes for standby")); standby_val->range(1, 500); if(sp) standby_val->value(sp->dpms_standby); else standby_val->value(1); suspend_val = new Fl_Spinner(275, 331, 45, 24, _("Suspend:")); suspend_val->tooltip(_("Minutes for suspend")); suspend_val->range(1, 500); if(sp) suspend_val->value(sp->dpms_suspend); else suspend_val->value(1); off_val = new Fl_Spinner(275, 360, 45, 24, _("Off:")); off_val->tooltip(_("Minutes to turn off the screen")); off_val->range(1, 500); if(sp) off_val->value(sp->dpms_off); else off_val->value(1); /* execute callback to apply changes before main_window is shown */ denabled->do_callback(); g2->end(); Fl_Button* ok_button = new Fl_Button(145, 410, 90, 25, _("&OK")); ok_button->callback(ok_cb, sp); Fl_Button* close_button = new Fl_Button(240, 410, 90, 25, _("&Cancel")); close_button->callback(close_cb); main_win->end(); window_center_on_screen(main_win); main_win->show(argc, argv); /* run preview immediately */ saver_list->do_callback(); int ret = Fl::run(); if(sp) { HackListIter it = sp->hacks.begin(), it_end = sp->hacks.end(); for(; it != it_end; ++it) delete *it; delete sp; } return ret; }