File: launcher_button_callback.C

package info (click to toggle)
peruser 4b33-10
  • links: PTS
  • area: main
  • in suites: woody
  • size: 2,944 kB
  • ctags: 1,064
  • sloc: cpp: 22,397; perl: 2,733; makefile: 345; sh: 335
file content (52 lines) | stat: -rw-r--r-- 1,136 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <errno.h>
#include <unistd.h>
#include <signal.h>
#include <ctype.h>

#include <X11/Xlib.h>
#include <gdk/gdkx.h>
#include <gtk/gtk.h>

#include "npfile.h"
#include "npstringarray.h"
#include "npgroup.h"
#include "npnode.h"
#include "nptree.h"
#include "npcollections.h"

void launcher_button_callback( GtkWidget *widget, gpointer data )
{
   NP_Collections *collections = ( NP_Collections *)data;

   if ( collections->launcher_pid )
   {
      kill( collections->launcher_pid, SIGUSR1 ); 
      return;
   }

   switch( collections->launcher_pid = fork() )
   {
      case -1:
         perror( "fork" );
         break;

      case 0:
         close( ConnectionNumber( gdk_display ));
         execlp( "nplauncher", "nplauncher", NULL );
         perror( "execlp" );
         exit( 1 );
         break;

      default:
         char buffer[ 1024 ];
         snprintf( buffer, sizeof buffer, "%d", collections->launcher_pid );
         if ( collections->children.add_item( buffer ))
            collections->children.print_error();
         break;
   }

   return;
}