mirror of
https://github.com/edeproject/ede.git
synced 2023-08-10 21:13:03 +03:00
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.
This commit is contained in:
parent
ddd508903f
commit
33df6e9231
1
Jamfile
1
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 ;
|
||||
|
@ -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
|
||||
|
42
ede-desktop/fl/icon_create.fl
Normal file
42
ede-desktop/fl/icon_create.fl
Normal file
@ -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
|
||||
} {}
|
||||
}
|
||||
}
|
17
ede-dialog/Jamfile
Normal file
17
ede-dialog/Jamfile
Normal file
@ -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 ;
|
227
ede-dialog/ede-dialog.cpp
Normal file
227
ede-dialog/ede-dialog.cpp
Normal file
@ -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 <config.h>
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <FL/Fl.h>
|
||||
#include <edelib/MessageBox.h>
|
||||
#include <edelib/Window.h>
|
||||
#include <edelib/Nls.h>
|
||||
|
||||
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;
|
||||
}
|
76
ede-dialog/ede-dialog.txt
Normal file
76
ede-dialog/ede-dialog.txt
Normal file
@ -0,0 +1,76 @@
|
||||
ede-dialog(1)
|
||||
=============
|
||||
:man version: 0.1
|
||||
:man manual: ede-dialog manual
|
||||
|
||||
Sanel Zukan <karijes@users.sourceforge.net>
|
||||
|
||||
|
||||
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.
|
@ -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 <<EOF
|
||||
Usage: $program [OPTIONS] [TITLE]
|
||||
Display EDE Manual in the web browser
|
||||
|
||||
Options:
|
||||
--help Show this help
|
||||
--titles Show known titles
|
||||
--help this help
|
||||
--titles show known titles
|
||||
|
||||
Example:
|
||||
$program evoke - display evoke help
|
||||
@ -55,13 +56,12 @@ if [ "x$BROWSER" = "x" ]; then
|
||||
fi
|
||||
|
||||
if [ "x$BROWSER" = "x" ]; then
|
||||
xmessage -title "$program error" -center -buttons "Close" -file - <<EOF
|
||||
ede-dialog --title "$program error" --error "
|
||||
Failed to find any of known browsers!
|
||||
|
||||
If you thing that I made mistake, please try to set
|
||||
BROWSER environment variable with full path pointing
|
||||
to the browser binary
|
||||
EOF
|
||||
If you think how this is mistake, please try to set \
|
||||
BROWSER environment variable with the full path pointing to the browser binary and run $program again"
|
||||
|
||||
exit 1
|
||||
fi
|
||||
|
||||
@ -69,13 +69,12 @@ fi
|
||||
$BROWSER $url
|
||||
|
||||
if [ $? -ne 0 ]; then
|
||||
xmessage -title "$program error" -center -buttons "Close" -file - <<EOF
|
||||
Unable to run '$BROWSER'!
|
||||
ede-dialog --title "$program error" --error "
|
||||
Unable to run $BROWSER browser!
|
||||
|
||||
Please check if program path is correct or \
|
||||
adjust BROWSER environment variable pointing to the correct binary file"
|
||||
|
||||
Please check if program path is correct or
|
||||
adjust BROWSER environment variable pointing
|
||||
to the correct binary
|
||||
EOF
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
@ -1,2 +0,0 @@
|
||||
[etip]
|
||||
Path = tips/ede
|
@ -174,7 +174,7 @@ int main(int argc, char **argv) {
|
||||
win->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);
|
||||
|
@ -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 ;
|
@ -1,237 +0,0 @@
|
||||
// EDialog - copyleft (c) Vedran Ljubovic 2005
|
||||
// This program is licenced under GNU General Public License v2 or greater
|
||||
|
||||
|
||||
#include <fltk/ask.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
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; i<argc; i++) {
|
||||
if (strcmp(argv[i],"--kdialog") == 0) {
|
||||
compat_mode = KDIALOGMODE;
|
||||
param_recognized[i]=true;
|
||||
}
|
||||
}
|
||||
|
||||
// Dialogs - only one dialog can be shown, so as soon as
|
||||
// we recognize parameter, we exit()
|
||||
paramslist* ptr;
|
||||
if (compat_mode == KDIALOGMODE) ptr = kdialogopts;
|
||||
for (int i=1; i<argc; i++) {
|
||||
while (ptr->option[0] != '\0') {
|
||||
if (strcmp(argv[i],ptr->option) == 0) {
|
||||
char *params = strdup("");
|
||||
i++;
|
||||
while ((i<argc) && (argv[i][0] != '-') && (argv[i][1] != '-')) {
|
||||
params = (char*) realloc(params, strlen(params)+strlen(argv[i])+2);
|
||||
params = strcat(params,argv[i++]);
|
||||
params = strcat(params," ");
|
||||
}
|
||||
ptr->func(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();
|
||||
}
|
@ -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();
|
||||
|
Loading…
Reference in New Issue
Block a user