Function to execute a program

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



 

Hi all,

I'm a newbie gtk-programmer and wanna ask something. Which function in gtk-library is use to run a program such as "xterm" or "xclock"? I design myself a simple program with a simple button and want to run an execute program after button click. Here i want to pack it in my "xclock" function. Please help.. 

My simple code..  

/* Begin test1.c */

#include<gtk/gtk.h>

/* Function: xclock
 *
 * Abstract: This is a callback function for hello
 *
 * Return: NN
 */
static void xclock ( GtkWidget *widget,
      gpointer data)
{

// HERE i find a function to run a simple program like xclock!!
// i should ! be "run(xclock);" or something like that..  have somebody an idea?

}

/* Function: delete_event
 *
 * Abstract: This is a function for delete event.
 *
 * Return: TRUE  - you don't want the window to be destroyed.
 *         FALSE - GTK will emit the destroy signal.
 */
static gboolean delete_event( GtkWidget *widget,
         GdkEvent *event,
         gpointer data)
{
  g_print ("delete evernt occured ");

  return TRUE;
}

/* Function: destroy
 *
 * Abstract: This a callback function for destroy.
 *
 * Return: NN
 */
static void destroy( GtkWidget *widget,
       gpointer data)
{
  gtk_main_quit();
}

int main( int argc, char *argv[])
{
  Gtk! Widget *window;
  GtkWidget *button1;

  gtk_init (& amp;argc, &argv);

  /* create a new window */
  window = gtk_window_new (GTK_WINDOW_TOPLEVEL);

  g_signal_connect (G_OBJECT (window), "delete_event",
      G_CALLBACK (delete_event), NULL);

  gtk_container_set_border_width (GTK_CONTAINER (window), 10);

  button1 = gtk_button_new_with_label ("XCLOCK");

  /* When the button receives the "clicked" signal, it will call
   * the function xclock() passing NULL as its argument. The xclock()
   * signal could come from here, or the window manager.
   */
  g_signal_connect (G_OBJECT (button1), "clicked",
      G_CALLBACK (xclock), NULL);

  /* This will cause the window to be destroyed by calling
   * gtk_widget_destroy(window) when "clicked". Again, the destroy
   * signal could come from here, or the window manager. */
 ! ; g_signal_connect_swapped (G_OBJECT (button1), "clicked",
       G_CALLBACK (gtk_widget_destroy),
       G_OBJECT (window));

  gtk_container_add (GTK_CONTAINER (window), button1);

  gtk_widget_show (button1);

  gtk_widget_show (window);

  gtk_main ();
 
  return 0;
}

/* END OF FILE test1.c */

-- 
Pisanu Prasertnopakun
Bienroder Weg 54/1810
38108 Braunschweig, Germany
Tel. +49-(0)531-221 7133
Cell. +49-(0)176-2007 1885
Email:
P.Prasertnopakun@xxxxxxxx
P.Prasertnopakun@xxxxxx
pissanup@xxxxxxxxx

______________________________________________________________________________
38xTestsieger - WEB.DE FreeMail - Deutschlands beste E-Mail! Jetzt das
neue FreeMail-Handbuch http://f.web.de/extern/handbuch.htm/?mc=021131 _______________________________________________ gtk-list@xxxxxxxxx http://mail.gnome.org/mailman/listinfo/gtk-list

[Index of Archives]     [Touch Screen Library]     [GIMP Users]     [Gnome]     [KDE]     [Yosemite News]     [Steve's Art]

  Powered by Linux