From 33df6e9231ee1e7082ee756fd1b010cb02c31bea Mon Sep 17 00:00:00 2001 From: Sanel Zukan Date: Wed, 12 Aug 2009 15:26:38 +0000 Subject: [PATCH] Removed incomplete edialog. Imported new and functional ede-dialog. ede-help uses ede-dialog for error reports; xmessage is not used since some OS-es to not install it by default, e.g. OpenSolaris. Removed obsolete ede-tip.conf. Fixed background issue in ede-tip; background will now always be white so it can nicely blend with the image. Commit fixed ede.desktop.in; previous commit was only renaming without content change. Reduce some debug output in ede-autostart. --- Jamfile | 1 + data/ede.desktop.in | 9 +- ede-desktop/fl/icon_create.fl | 42 ++++++ ede-dialog/Jamfile | 17 +++ ede-dialog/ede-dialog.cpp | 227 ++++++++++++++++++++++++++++++++ ede-dialog/ede-dialog.txt | 76 +++++++++++ ede-help/ede-help.in | 27 ++-- ede-tip/ede-tip.conf | 2 - ede-tip/ede-tip.cpp | 2 +- edialog/Jamfile | 14 -- edialog/edialog.cpp | 237 ---------------------------------- evoke/ede-autostart.cpp | 1 - 12 files changed, 382 insertions(+), 273 deletions(-) create mode 100644 ede-desktop/fl/icon_create.fl create mode 100644 ede-dialog/Jamfile create mode 100644 ede-dialog/ede-dialog.cpp create mode 100644 ede-dialog/ede-dialog.txt delete mode 100644 ede-tip/ede-tip.conf delete mode 100644 edialog/Jamfile delete mode 100644 edialog/edialog.cpp diff --git a/Jamfile b/Jamfile index d09968a..e618f15 100644 --- a/Jamfile +++ b/Jamfile @@ -22,6 +22,7 @@ SubInclude TOP ede-calc ; SubInclude TOP ede-conf ; SubInclude TOP ede-desktop ; SubInclude TOP ede-desktop-conf ; +SubInclude TOP ede-dialog ; SubInclude TOP ede-screensaver-conf ; SubInclude TOP ede-help ; SubInclude TOP ede-image-view ; diff --git a/data/ede.desktop.in b/data/ede.desktop.in index 3234f22..9e7819f 100644 --- a/data/ede.desktop.in +++ b/data/ede.desktop.in @@ -1,6 +1,7 @@ [Desktop Entry] -Encoding=UTF-8 -Exec=startede -TryExec=startede Name=EDE -Comment=This session logs you into EDE +Exec=@prefix@/bin/startede +TryExec=@prefix@/bin/startede +Comment=This session logs you into EDE Desktop +Type=Application +Encoding=UTF-8 diff --git a/ede-desktop/fl/icon_create.fl b/ede-desktop/fl/icon_create.fl new file mode 100644 index 0000000..13e3316 --- /dev/null +++ b/ede-desktop/fl/icon_create.fl @@ -0,0 +1,42 @@ +# data file for the Fltk User Interface Designer (fluid) +version 1.0108 +header_name {.h} +code_name {.cxx} +Function {} {open +} { + Fl_Window {} {open selected + xywh {393 364 390 170} type Double visible + } { + Fl_Button {} { + label {&OK} + xywh {195 135 90 25} + } + Fl_Button {} { + label {&Cancel} + xywh {290 135 90 25} + } + Fl_Button {} { + xywh {10 10 75 75} labelsize 14 + } + Fl_Input {} { + label {Name:} + xywh {165 10 215 25} + } + Fl_Input {} { + label {Comment:} + xywh {165 40 215 25} + } + Fl_Input {} { + label {Execute:} + xywh {165 70 185 25} + } + Fl_Button {} { + label {...} + xywh {355 70 25 25} + } + Fl_Choice {} { + label {Type:} open + xywh {165 100 215 25} down_box BORDER_BOX + } {} + } +} diff --git a/ede-dialog/Jamfile b/ede-dialog/Jamfile new file mode 100644 index 0000000..4ffb1e7 --- /dev/null +++ b/ede-dialog/Jamfile @@ -0,0 +1,17 @@ +# +# $Id$ +# +# Part of Equinox Desktop Environment (EDE). +# Copyright (c) 2009 EDE Authors. +# +# This program is licensed under the terms of the +# GNU General Public License version 2 or later. +# See COPYING for the details. + +SubDir TOP ede-dialog ; + +SOURCE = ede-dialog.cpp ; + +EdeProgram ede-dialog : $(SOURCE) ; +TranslationStrings locale : $(SOURCE) ; +EdeManual ede-dialog.txt ; diff --git a/ede-dialog/ede-dialog.cpp b/ede-dialog/ede-dialog.cpp new file mode 100644 index 0000000..928b0e5 --- /dev/null +++ b/ede-dialog/ede-dialog.cpp @@ -0,0 +1,227 @@ +/* + * $Id$ + * + * ede-dialog, a dialog displayer + * Part of Equinox Desktop Environment (EDE). + * Copyright (c) 2005-2009 EDE Authors. + * + * This program is licensed under terms of the + * GNU General Public License version 2 or newer. + * See COPYING for details. + */ + +#ifndef HAVE_CONFIG_H +#include +#endif + +#include +#include + +#include +#include +#include +#include + +EDELIB_NS_USING(MessageBox) +EDELIB_NS_USING(MessageBoxType) +EDELIB_NS_USING(MessageBoxIconType) +EDELIB_NS_USING(MSGBOX_PLAIN) +EDELIB_NS_USING(MSGBOX_INPUT) +EDELIB_NS_USING(MSGBOX_INPUT_SECRET) +EDELIB_NS_USING(MSGBOX_ICON_TYPE_INFO) +EDELIB_NS_USING(MSGBOX_ICON_TYPE_ALERT) +EDELIB_NS_USING(MSGBOX_ICON_TYPE_QUESTION) +EDELIB_NS_USING(MSGBOX_ICON_TYPE_INPUT) +EDELIB_NS_USING(MSGBOX_ICON_TYPE_PASSWORD) + +EDELIB_NS_USING_AS(Window, EdelibWindow) + +#define CHECK_ARGV(argv, pshort, plong) ((strcmp(argv, pshort) == 0) || (strcmp(argv, plong) == 0)) +#define CHECK_ARGV_LONG(argv, plong) (strcmp(argv, plong) == 0) + +/* kdialog returns this in the case of error and I'm using it too */ +#define EDE_DIALOG_ERROR_RET 254 + +static MessageBox *mbox; + +enum { + OPT_NONE, + OPT_YESNO, + OPT_YESNOCANCEL, + OPT_ERROR, + OPT_SORRY, + OPT_MSGBOX, + OPT_INPUTBOX, + OPT_PASSWORD +}; + +static const char* next_param(int curr, char **argv, int argc) { + int j = curr + 1; + if(j >= argc) + return NULL; + if(argv[j][0] == '-') + return NULL; + return argv[j]; +} + +static void help(void) { + puts("Usage: ede-dialog [OPTIONS]"); + puts("Display a message in a window from shell scripts"); + puts(""); + puts("Options:"); + puts(" -h, --help this help"); + puts(" --yesno [TEXT] question message with yes/no buttons"); + puts(" --yesnocancel [TEXT] question message with yes/no/cancel buttons"); + puts(" --error [TEXT] error message dialog"); + puts(" --sorry [TEXT] sorry message dialog"); + puts(" --msgbox [TEXT] message dialog"); + puts(" --inputbox [TEXT] dialog with input box"); + puts(" --password [TEXT] dialog with input box for password input (text will be hidden)"); + puts(" --title [TEXT] set dialog title"); +} + +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; + } + + /* + * 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; +} diff --git a/ede-dialog/ede-dialog.txt b/ede-dialog/ede-dialog.txt new file mode 100644 index 0000000..5637d27 --- /dev/null +++ b/ede-dialog/ede-dialog.txt @@ -0,0 +1,76 @@ +ede-dialog(1) +============= +:man version: 0.1 +:man manual: ede-dialog manual + +Sanel Zukan + + +NAME +---- +ede-dialog - display GUI dialogs from the shell + + +SYNOPSIS +-------- +*ede-dialog* ['OPTIONS'] + + +DESCRIPTION +----------- +ede-dialog(1) is dialog displaying utility, very similar to xmessage, kdialog and such tools and +it's main purpose it to display messages or query inputs primarily from shell scripts. + +This will enable interaction with shell scripts to look very similar to interaction with any +compiled EDE application. + +OPTIONS +------- + +-h, --help:: + Show help content. + +--yesno 'text':: + Display a question dialog with yes/no buttons. + +--yesnocancel 'text':: + Display a question dialog with yes/no/cancel buttons. + +--error 'text':: + Display error message dialog. + +--sorry 'text':: + Display sorry message dialog. + +--msgbox 'text':: + Display message box dialog. + +--inputbox 'text':: + Dialog with input box. + +--password 'text':: + Dialog with input box for password input (text will be hidden). + +--title 'text':: + Set dialog title. + + +DETAILS +------- +ede-dialog started as 'edialog', initially written by Vedran Ljubovic in 2005 and had been planned to support +'kdialog' (similar dialog tool from KDE) options. 'edialog' was never finished so I (Sanel) took it and rewrote +it, using subset of 'kdialog' options, mostly as inspiration for command line names. + +Knowing this, ede-dialog does not support additional GUI elements like menus, checkboxes and such: it is meant to +be used for quick handling from shell scripts; anything advanced from that should use straight C++ and FLTK/edelib +combination. + +Also, return values will emulate those from 'kdialog'. For example, if you use '--yesnocancel' option, ede-dialog +will show text with three buttons: 'Yes', 'No' and 'Cancel'. Clicking on 'Yes' will return 0 so it can be picked +by shell script. Similar, pressing on 'No' will return 1 and on 'Cancel' will return 2. + +On other hand, using '--yesno' will show two buttons, 'Yes' and 'No' and pressing on 'Yes' yields 0 and on 'No' +yields 1. Dialogs with only one button (those with '--error', '--sorry' and '--msgbox') always returns 0. + +Input dialogs ('--inputbox' and '--password') prints inserted value to stdout, allowing easy redirection from +shell. Both dialogs provides 'OK' and 'Cancel' buttons, returning 0 if 'OK' was pressed or 1 if 'Cancel' was pressed. diff --git a/ede-help/ede-help.in b/ede-help/ede-help.in index 17db274..d1bdf6a 100644 --- a/ede-help/ede-help.in +++ b/ede-help/ede-help.in @@ -1,7 +1,7 @@ #!/bin/sh help_dir="@ededocdir@/manual" -browser_list="firefox mozilla konqueror opera navigator dillo" +browser_list="firefox mozilla chromium-browser konqueror opera navigator dillo" program="ede-help" url="" @@ -10,9 +10,10 @@ if [ "$1" = "--help" ]; then cat <begin(); Fl_Group* main_group = new Fl_Group(10, 10, 515, 205); main_group->box(FL_DOWN_BOX); - main_group->color(FL_BACKGROUND2_COLOR); + main_group->color(FL_WHITE); main_group->begin(); Fl_Box* image_box = new Fl_Box(11, 13, 121, 201); image_box->image(image_hint); diff --git a/edialog/Jamfile b/edialog/Jamfile deleted file mode 100644 index b41df6a..0000000 --- a/edialog/Jamfile +++ /dev/null @@ -1,14 +0,0 @@ -# -# $Id$ -# -# Part of Equinox Desktop Environment (EDE). -# Copyright (c) 2000-2007 EDE Authors. -# -# This program is licenced under terms of the -# GNU General Public Licence version 2 or newer. -# See COPYING for details. - -SubDir TOP edialog ; - -MakeProgram edialog : edialog.cpp ; -ExtractStrings locale : edialog.cpp ; diff --git a/edialog/edialog.cpp b/edialog/edialog.cpp deleted file mode 100644 index 1514e2e..0000000 --- a/edialog/edialog.cpp +++ /dev/null @@ -1,237 +0,0 @@ -// EDialog - copyleft (c) Vedran Ljubovic 2005 -// This program is licenced under GNU General Public License v2 or greater - - -#include -#include -#include -#include - -using namespace fltk; - - -// --- compat. modes enum - -enum { - KDIALOGMODE = 0 -}; - - -// Common functions - -void errormsg(char* msg) { - fprintf (stderr, "edialog: %s\n", msg); - exit(1); -} - - -void showhelp() { - printf ("edialog - Show dialogs using FLTK2\n"); - printf ("Copyright (c) Vedran Ljubovic 2005\n"); - printf ("This program is licensed under GNU General Public License v2 or greater\n\n"); - printf ("Displays a dialog box. Return value corresponds to button pressed (e.g 0 = Ok, 1 = Cancel...)\n\n"); - printf ("Options:\n"); - printf (" --kdialog - kdialog compatibility mode (default)\n"); - printf (" (see kdialog --help for list)\n"); - exit(0); -} - - -// Functions for dialogs - -void YesNo(char* param) { - if (param[0] == '\0') errormsg ("Required parameter missing."); - exit(ask(param)); -} - -void YesNoCancel(char* param) { - if (param[0] == '\0') errormsg ("Required parameter missing."); - exit(choice(param,yes,no,cancel)); -} - -void WarningYesNo(char* param) { - if (param[0] == '\0') errormsg ("Required parameter missing."); - exit(choice_alert(param,yes,no,"")); -} - -void WarningContinueCancel(char* param) { - if (param[0] == '\0') errormsg ("Required parameter missing."); - exit(choice_alert(param,"Continue",cancel,0)); -} - -void WarningYesNoCancel(char* param) { - if (param[0] == '\0') errormsg ("Required parameter missing."); - exit(choice_alert(param,yes,no,cancel)); -} - -void Sorry(char* param) { - if (param[0] == '\0') errormsg ("Required parameter missing."); - alert(param); - exit(0); -} - -void Error(char* param) { - errormsg("Not implemented yet."); - // Displays a red X and plays "error" sound - -// if (param[0] == '\0') errormsg ("Required parameter missing."); -// alert(param); -// exit(0); -} - -void MsgBox(char* param) { - if (param[0] == '\0') errormsg ("Required parameter missing."); - message(param); - exit(0); -} - -void InputBox(char* param) { - if (param[0] == '\0') errormsg ("Required parameter missing."); - char *title = strtok(param," "); - char *defval = strtok(NULL," "); - printf ("%s\n",input(title,defval)); - exit(0); -} - -void Password(char* param) { - // NOTE: kdialog doesn't support default value for password - // possibly for security reasons? - if (param[0] == '\0') errormsg ("Required parameter missing."); - char *title = strtok(param," "); - char *defval = strtok(NULL," "); - printf ("%s\n",password(title,defval)); - exit(0); -} - -void TextBox(char* param) { - errormsg("Not implemented yet."); -} - -void ComboBox(char* param) { - errormsg("Not implemented yet."); -} - -void Menu(char* param) { - errormsg("Not implemented yet."); -} - -void CheckList(char* param) { - errormsg("Not implemented yet."); -} - -void RadioList(char* param) { - errormsg("Not implemented yet."); -} - -void PassivePopup(char* param) { - errormsg("Not implemented yet."); -} - -void GetOpenFilename(char* param) { - errormsg("Not implemented yet."); -} - -void GetSaveFilename(char* param) { - errormsg("Not implemented yet."); -} - -void GetExistingDirectory(char* param) { - errormsg("Not implemented yet."); -} - -void GetOpenUrl(char* param) { - errormsg("Not implemented yet."); -} - -void GetSaveUrl(char* param) { - errormsg("Not implemented yet."); -} - -void GetIcon(char* param) { - errormsg("Not implemented yet."); -} - -void ProgressBar(char* param) { - errormsg("Not implemented yet."); -} - - - -// ----------- These are charts for various compatibility modes - -struct paramslist { - char* option; - void (*func)(char*); -}; - -// kdialog - KDE dialog -paramslist kdialogopts[] = { - {"--yesno", YesNo}, - {"--yesnocancel", YesNoCancel}, - {"--warningyesno", WarningYesNo}, - {"--warningcontinuecancel", WarningContinueCancel}, - {"--warningyesnocancel", WarningYesNoCancel}, - {"--sorry", Sorry}, - {"--error", Error}, - {"--msgbox", MsgBox}, - {"--inputbox", InputBox}, - {"--password", Password}, - {"--textbox", TextBox}, - {"--combobox", ComboBox}, - {"--menu", Menu}, - {"--checklist", CheckList}, - {"--radiolist", RadioList}, - {"--passivepopup", PassivePopup}, - {"--getopenfilename", GetOpenFilename}, - {"--getsavefilename", GetSaveFilename}, - {"--getexistingdirectory", GetExistingDirectory}, - {"--getopenurl", GetOpenUrl}, - {"--getsaveurl", GetSaveUrl}, - {"--geticon", GetIcon}, - {"--progressbar", ProgressBar}, - {""} -}; - - -// parse command line parameters -int main (int argc, char **argv) { - int compat_mode = KDIALOGMODE; - bool param_recognized[100]; - for (int i=0;i<100;i++) param_recognized[i]=false; - - // Switches and modifiers - for (int i=1; ioption[0] != '\0') { - if (strcmp(argv[i],ptr->option) == 0) { - char *params = strdup(""); - i++; - while ((ifunc(params); - } - ptr++; - } - // function should exit() - // so we can get here only if parameter isn't recognized - if (param_recognized[i] == false) { - showhelp(); - } - } - - // No parameters passed or just modifiers - showhelp(); -} diff --git a/evoke/ede-autostart.cpp b/evoke/ede-autostart.cpp index ea11aed..e1c4068 100644 --- a/evoke/ede-autostart.cpp +++ b/evoke/ede-autostart.cpp @@ -158,7 +158,6 @@ static void dialog_runsel_cb(Fl_Widget*, void* e) { static void dialog_runall_cb(Fl_Widget*, void* e) { DialogEntryList* lst = (DialogEntryList*)e; - E_DEBUG("%i != %i\n", lst->size(), cbrowser->nitems()); E_ASSERT(lst->size() == (unsigned int)cbrowser->nitems() && "Size mismatch in local list and browser widget"); dialog_win->hide();