Tweak themes for more color consistency.
[ntk.git] / test / connect.cxx
blob86e1e55173be2507c2d7d20c93a9b40bd8e904da
1 //
2 // "$Id: connect.cxx 7913 2010-11-29 18:18:27Z greg.ercolano $"
3 //
4 // PPP example program for the Fast Light Tool Kit (FLTK).
5 //
6 // Program to make a button to turn a ppp connection on/off.
7 // You must chmod +s /usr/sbin/pppd, and put all the options
8 // into /etc/ppp/options.
9 //
10 // Copyright 1998-2010 by Bill Spitzak and others.
12 // This library is free software; you can redistribute it and/or
13 // modify it under the terms of the GNU Library General Public
14 // License as published by the Free Software Foundation; either
15 // version 2 of the License, or (at your option) any later version.
17 // This library is distributed in the hope that it will be useful,
18 // but WITHOUT ANY WARRANTY; without even the implied warranty of
19 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20 // Library General Public License for more details.
22 // You should have received a copy of the GNU Library General Public
23 // License along with this library; if not, write to the Free Software
24 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
25 // USA.
27 // Please report all bugs and problems on the following page:
29 // http://www.fltk.org/str.php
32 #include <stdlib.h>
33 #include <stdio.h>
34 #include <unistd.h>
35 #include <signal.h>
36 #include <sys/wait.h>
38 #include <FL/Fl.H>
39 #include <FL/Fl_Window.H>
40 #include <FL/Fl_Toggle_Button.H>
42 int running; // actually the pid
43 Fl_Toggle_Button *Button;
45 void sigchld(int) {
46 waitpid(running, 0, 0);
47 running = 0;
48 Button->value(0);
51 void cb(Fl_Widget *o, void *) {
52 if (((Fl_Toggle_Button*)o)->value()) {
53 if (running) return;
54 running = fork();
55 if (!running) execl("/usr/sbin/pppd","pppd","-detach",0);
56 else signal(SIGCHLD, sigchld);
57 } else {
58 if (!running) return;
59 kill(running, SIGINT);
60 waitpid(running, 0, 0);
61 running = 0;
65 int main(int argc, char ** argv) {
66 Fl_Window window(100,50);
67 Fl_Toggle_Button button(0,0,100,50,"Connect");
68 Button = &button;
69 button.color(1,2);
70 button.callback(cb,0);
71 window.show(argc,argv);
72 return Fl::run();
76 // End of "$Id: connect.cxx 7913 2010-11-29 18:18:27Z greg.ercolano $".