Adding command to nicely shutdown EDE

This commit is contained in:
Sanel Zukan 2009-02-25 15:12:26 +00:00
parent 377538f2e3
commit 69173c766a
4 changed files with 33 additions and 92 deletions

View File

@ -27,7 +27,8 @@ CONFIG = ede-settings.conf
#ObjectC++Flags $(SOURCE) : -DUSE_LOCAL_CONFIG ;
EdeProgram evoke : $(SOURCE) ;
FltkProgramBare test/evoke_test : test/evoke_test.cpp : "noinstall" ;
ProgramBare ede-shutdown : ede-shutdown.cpp ;
LinkAgainst ede-shutdown : -lX11 ;
EdeManualWithToc [ FFileName doc evoke.txt ] ;
TranslationStrings locale : $(SOURCE) ;

31
evoke/ede-shutdown.cpp Normal file
View File

@ -0,0 +1,31 @@
/*
* $Id$
*
* ede-shutdown, a command to quit EDE
* Part of Equinox Desktop Environment (EDE).
* Copyright (c) 2009 EDE Authors.
*
* This program is licensed under terms of the
* GNU General Public License version 2 or newer.
* See COPYING for details.
*/
#include <stdio.h>
#include <X11/Xlib.h>
#include <X11/Xatom.h>
int main(int argc, char** argv) {
Display* dpy = XOpenDisplay(0);
if(!dpy) {
puts("Unabel to open default display");
return 1;
}
int scr = DefaultScreen(dpy);
Atom ede_quit = XInternAtom(dpy, "_EDE_EVOKE_QUIT", False);
int dummy = 1;
XChangeProperty(dpy, RootWindow(dpy, scr),
ede_quit, XA_CARDINAL, 32, PropModeReplace, (unsigned char*)&dummy, sizeof(int));
return 0;
}

View File

@ -1,63 +0,0 @@
#include <FL/Fl.H>
#include <FL/Fl_Double_Window.H>
#include <FL/Fl_Input.H>
#include <FL/Fl_Button.H>
#include <FL/x.H>
#include <string.h>
Fl_Input* inp;
Fl_Double_Window* win;
void run_cb(Fl_Widget*, void*) {
Atom _XA_EDE_EVOKE_SPAWN = XInternAtom(fl_display, "_EDE_EVOKE_SPAWN", False);
// max size
unsigned char txt_send[8192];
int i;
const char* txt_val = inp->value() ? inp->value() : "(none)";
int len = strlen(txt_val);
for(i = 0; i < 8192-2 && i < len; i++)
txt_send[i] = txt_val[i];
txt_send[i] = '\0';
// send text
XChangeProperty(fl_display, RootWindow(fl_display, fl_screen),
_XA_EDE_EVOKE_SPAWN, XA_STRING, 8, PropModeReplace,
txt_send, i + 1);
}
void evoke_quit_cb(Fl_Widget*, void*) {
Atom _XA_EDE_EVOKE_QUIT = XInternAtom(fl_display, "_EDE_EVOKE_QUIT", False);
int dummy = 1;
XChangeProperty(fl_display, RootWindow(fl_display, fl_screen),
_XA_EDE_EVOKE_QUIT, XA_CARDINAL, 32, PropModeReplace,
(unsigned char*)&dummy, sizeof(int));
}
void quit_all_cb(Fl_Widget*, void*) {
Atom _XA_EDE_EVOKE_SHUTDOWN_ALL = XInternAtom(fl_display, "_EDE_EVOKE_SHUTDOWN_ALL", False);
int dummy = 1;
XChangeProperty(fl_display, RootWindow(fl_display, fl_screen),
_XA_EDE_EVOKE_SHUTDOWN_ALL, XA_CARDINAL, 32, PropModeReplace,
(unsigned char*)&dummy, sizeof(int));
}
int main(int argc, char **argv) {
win = new Fl_Double_Window(355, 94, "Evoke test");
win->begin();
inp = new Fl_Input(10, 25, 335, 25, "Program to run:");
inp->align(FL_ALIGN_TOP_LEFT);
Fl_Button* b1 = new Fl_Button(255, 60, 90, 25, "&Run");
b1->callback(run_cb);
Fl_Button* b2 = new Fl_Button(150, 60, 90, 25, "&Quit evoke");
b2->callback(evoke_quit_cb);
Fl_Button* b3 = new Fl_Button(55, 60, 90, 25, "&Quit all");
b3->callback(quit_all_cb);
win->end();
win->show(argc, argv);
return Fl::run();
}

View File

@ -1,28 +0,0 @@
# data file for the Fltk User Interface Designer (fluid)
version 1.0108
header_name {.h}
code_name {.cxx}
Function {} {open
} {
Fl_Window {} {
label {Evoke test} open
xywh {493 478 355 94} type Double visible
} {
Fl_Input {} {
label {Program to run:} selected
xywh {10 25 335 25} labelsize 14 align 5 textsize 14
}
Fl_Button {} {
label {&Run}
xywh {255 60 90 25} labelsize 14
}
Fl_Button {} {
label {&Quit evoke}
xywh {150 60 90 25} labelsize 14
}
Fl_Button {} {
label {&Quit all}
xywh {55 60 90 25} labelsize 14
}
}
}