From be2cb085b9fe63907db811dfd7b0ba0ec4bcdcef Mon Sep 17 00:00:00 2001 From: Sanel Zukan Date: Tue, 7 Jul 2009 11:57:45 +0000 Subject: [PATCH] A small documentation update for evoke. Do not compile running code for ede-launch-sn in ede-launch when startup-notification was not found. Allow report button only for ede applications. --- ede-launch/ede-launch-sn.cpp | 11 +++++ ede-launch/ede-launch.cpp | 93 +++++++++++++++++++++++++++++------- evoke/EvokeService.cpp | 2 +- evoke/doc/evoke.txt | 8 ---- 4 files changed, 87 insertions(+), 27 deletions(-) diff --git a/ede-launch/ede-launch-sn.cpp b/ede-launch/ede-launch-sn.cpp index 4fee154..a6d4eee 100644 --- a/ede-launch/ede-launch-sn.cpp +++ b/ede-launch/ede-launch-sn.cpp @@ -1,8 +1,19 @@ /* + * $Id$ + * + * ede-launch, launch external application + * Part of Equinox Desktop Environment (EDE). + * Copyright (c) 2008-2009 EDE Authors. + * + * This program is licensed under terms of the + * GNU General Public License version 2 or newer. + * See COPYING for details. + * * This is an helper program for startup notification system, and * is run from ede-launch. To simplify things, it was written as separate * program, but it does not mean that will stay ;) (Sanel) */ + #ifdef HAVE_CONFIG_H #include #endif diff --git a/ede-launch/ede-launch.cpp b/ede-launch/ede-launch.cpp index 299c3cf..98ce05c 100644 --- a/ede-launch/ede-launch.cpp +++ b/ede-launch/ede-launch.cpp @@ -1,3 +1,15 @@ +/* + * $Id$ + * + * ede-launch, launch external application + * Part of Equinox Desktop Environment (EDE). + * Copyright (c) 2008-2009 EDE Authors. + * + * This program is licensed under terms of the + * GNU General Public License version 2 or newer. + * See COPYING for details. + */ + #ifdef HAVE_CONFIG_H #include #endif @@ -19,7 +31,9 @@ #include #include #include + #include +#include #include #include #include @@ -29,11 +43,13 @@ #include "icons/run.xpm" /* - * Window from X11 is alread included with Fl.H so we can't use - * EDELIB_NS_USING(Window) here. Stupid C++ namespaces + * Window from X11 is alread included with Fl.H so we can't use EDELIB_NS_USING(Window) here. + * Stupid C++ namespaces */ #define LaunchWindow edelib::Window +EDELIB_NS_USING(Resource) +EDELIB_NS_USING(RES_USER_ONLY) EDELIB_NS_USING(run_sync) EDELIB_NS_USING(run_async) EDELIB_NS_USING(alert) @@ -42,11 +58,19 @@ static Fl_Pixmap image_run((const char**)run_xpm); static Fl_Input* dialog_input; static Fl_Check_Button* in_term; -void help(void) { - puts("Usage: ede-launch [OPTIONS] program"); +static void help(void) { + puts("Usage: ede-launch program"); puts("EDE program launcher"); } +static char* get_basename(const char* path) { + char *p = strrchr(path, '/'); + if(p) + return (p + 1); + + return (char*)p; +} + static char** cmd_split(const char* cmd) { int sz = 10; int i = 0; @@ -69,11 +93,22 @@ static char** cmd_split(const char* cmd) { } static void start_crasher(const char* cmd, int sig) { + const char* base = get_basename(cmd); + const char* ede_app_flag = ""; + + /* this means the app was called without full path */ + if(!base) + base = cmd; + /* - * call edelib implementation instead start_child_process() - * to prevents loops if 'ede-crasher' crashes + * determine is our app by checking the prefix; we don't want user to send bug reports about crashes + * of foreign applications */ - run_sync("ede-crasher --apppath %s --signal %i", cmd, sig); + if(strncmp(base, "ede-", 4) == 0) + ede_app_flag = "--edeapp"; + + /* call edelib implementation instead start_child_process() to prevents loops if 'ede-crasher' crashes */ + run_sync("ede-crasher %s --appname %s --apppath %s --signal %i", ede_app_flag, base, cmd, sig); } static int start_child_process(const char* cmd) { @@ -183,12 +218,17 @@ static int start_child_process_with_core(const char* cmd) { } static bool start_child(const char* cmd) { +#ifdef HAVE_LIBSTARTUP_NOTIFICATION run_async("ede-launch-sn --program %s --icon applications-order", cmd); +#endif int ret = start_child_process_with_core(cmd); if(ret == 199) { - alert(_("Program '%s' not found.\n\nPlease check if given path to the executable was correct or adjust $PATH environment variable to point to the directory where target executable exists"), cmd); + alert(_("Program '%s' not found.\n\nPlease check if given path to the " + "executable was correct or adjust $PATH environment variable to " + "point to the directory where target executable exists"), cmd); + return false; } @@ -236,20 +276,38 @@ static void ok_cb(Fl_Widget*, void* w) { if(!started) { /* show dialog again */ win->show(); + + if(cmd) + dialog_input->position(0, dialog_input->size()); + } else { + Resource rc; + rc.set("History", "open", cmd); + rc.save("ede-launch-history"); } } -static void start_dialog(int argc, char** argv) { +static int start_dialog(int argc, char** argv) { LaunchWindow* win = new LaunchWindow(370, 195, _("Run Command")); win->begin(); Fl_Box* icon = new Fl_Box(10, 10, 55, 55); icon->image(image_run); - Fl_Box* txt = new Fl_Box(70, 10, 290, 69, _("Enter the name of the application you would like to run or the URL you would like to view")); + Fl_Box* txt = new Fl_Box(70, 10, 290, 69, _("Enter the name of the application " + "you would like to run or the URL you would like to view")); txt->align(132|FL_ALIGN_INSIDE); dialog_input = new Fl_Input(70, 90, 290, 25, _("Open:")); + Resource rc; + char buf[128]; + + if(rc.load("ede-launch-history") && rc.get("History", "open", buf, sizeof(buf))) { + dialog_input->value(buf); + + /* make text appear selected */ + dialog_input->position(0, dialog_input->size()); + } + in_term = new Fl_Check_Button(70, 125, 290, 25, _("Run in terminal")); in_term->down_box(FL_DOWN_BOX); @@ -258,21 +316,20 @@ static void start_dialog(int argc, char** argv) { Fl_Button* cancel = new Fl_Button(270, 160, 90, 25, _("&Cancel")); cancel->callback(cancel_cb, win); win->end(); + win->window_icon(run_xpm); win->show(argc, argv); - while(win->shown()) - Fl::wait(); + return Fl::run(); } int main(int argc, char** argv) { if(argc == 1) - start_dialog(argc, argv); - else if(argc != 2) { - help(); - return 0; - } else { + return start_dialog(argc, argv); + + if(argc == 2) start_child(argv[1]); - } + else + help(); return 0; } diff --git a/evoke/EvokeService.cpp b/evoke/EvokeService.cpp index 13f8e3b..268ddfd 100644 --- a/evoke/EvokeService.cpp +++ b/evoke/EvokeService.cpp @@ -73,8 +73,8 @@ static void send_dbus_ede_quit(void) { E_RETURN_IF_FAIL(c.connect(EDBUS_SESSION)); EdbusMessage msg; - msg.create_signal("/org/equinoxproject/Shutdown", "org.equinoxproject.Shutdown", "Shutdown"); + msg.create_signal("/org/equinoxproject/Shutdown", "org.equinoxproject.Shutdown", "Shutdown"); c.send(msg); } diff --git a/evoke/doc/evoke.txt b/evoke/doc/evoke.txt index 3bc1295..695a66b 100644 --- a/evoke/doc/evoke.txt +++ b/evoke/doc/evoke.txt @@ -28,14 +28,6 @@ Options Only useful in startup mode (if '-s' or '--startup' are given). Mainly to test splash screen themes --a, --autostart:: - Run in autostart mode. It will check 'autostart' directory and run .desktop - files from it. This will be done according to freedesktop.org autostart specification. - --u, --autostart-safe:: - Same as '-a' or '--autostart' option, but display dialog with items that should - be run. - -h, --help:: This help.