File: configure_button_callback.C

package info (click to toggle)
peruser 4b33-6
  • links: PTS
  • area: main
  • in suites: potato
  • size: 2,952 kB
  • ctags: 1,064
  • sloc: cpp: 22,367; perl: 2,733; makefile: 345; sh: 335
file content (48 lines) | stat: -rw-r--r-- 977 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
#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
#include <signal.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 configure_button_callback( GtkWidget *widget, gpointer data )
{
   NP_Collections *collections = ( NP_Collections *)data;

   if ( collections->summary_pid )
      kill( collections->summary_pid, SIGUSR2 );

   pid_t pid;
   switch( pid = fork() )
   {
   case -1:
      perror( "fork" );
      break;

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

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