1 /*****
2  *       Xnee's Not an Event Emulator
3  *
4  * Xnee enables recording and replaying of X protocol data
5  *
6  *  Copyright (C) 2002, 2003, 2004, 2005, 2007, 2011, 2013
7  *                    Henrik Sandklef
8  *
9  * This program is free software; you can redistribute it and/or
10  * modify it under the terms of the GNU General Public License
11  * as published by the Free Software Foundation; either version 3
12  * of the License, or any later version.
13  *
14  *
15  * This program is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU General Public License for more details.
19  *
20  * You should have received a copy of the GNU General Public License
21  * along with this program; if not, write to the Free Software
22  * Foundation, Inc., 51 Franklin Street, Boston,
23  * MA  02110-1301, USA.
24  ****/
25 
26 #ifdef HAVE_CONFIG_H
27 #  include <config.h>
28 #endif
29 
30 #include <gtk/gtk.h>
31 
32 #include "callbacks.h"
33 #include "interface.h"
34 #include "support.h"
35 #include "recordables.h"
36 #include "gnee_xnee.h"
37 
38 #include <stdio.h>
39 #include <libxnee/xnee.h>
40 #include <libxnee/xnee_setget.h>
41 
42 
43 
44 static int          use_delay = 0;
45 static gint         delay = 0 ;
46 extern xnee_data   *ext_xd;
47 extern gnee_xnee   *ext_gx;
48 extern GtkWidget   *ext_gnee_window;
49 
50 static int x_offset   = 0;
51 static int y_offset   = 0;
52 static int use_offset = 0;
53 
54 const char *predef_string   = "Predefined";
55 const char *events_string   = "Events";
56 const char *replies_string  = "Replies";
57 const char *requests_string = "Requests";
58 const char *errors_string   = "Errors";
59 const char *exclude_list_string = "exclude_list";
60 const char *include_list_string = "include_list";
61 const char *combo_label1_string = "combo_label1";
62 
63 const char *stop_k_combo_string   = "stop_k_combo";
64 const char *pause_k_combo_string  = "pause_k_combo";
65 const char *resume_k_combo_string = "resume_k_combo";
66 const char *mark_k_combo_string   = "mark_k_combo";
67 const char *exec_k_combo_string   = "exec_k_combo";
68 
69 const char *stop_m_combo_string   = "stop_m_combo";
70 const char *pause_m_combo_string  = "pause_m_combo";
71 const char *resume_m_combo_string = "resume_m_combo";
72 const char *mark_m_combo_string   = "mark_m_combo";
73 const char *exec_m_combo_string   = "exec_m_combo";
74 
75 const char *exclude_predef_store_string = "exclude_predef_store";
76 const char *include_predef_store_string = "include_predef_store";
77 
78 const char *exclude_event_store_string = "exclude_event_store";
79 const char *include_event_store_string = "include_event_store";
80 
81 const char *exclude_reply_store_string = "exclude_reply_store";
82 const char *include_reply_store_string = "include_reply_store";
83 
84 const char *exclude_request_store_string = "exclude_request_store";
85 const char *include_request_store_string = "include_request_store";
86 
87 const char *exclude_error_store_string = "exclude_error_store";
88 const char *include_error_store_string = "include_error_store";
89 
90 const char *rec_file_text_string = "rec_file_text";
91 const char *rep_file_text_string = "rep_file_text";
92 
93 
94 GtkWidget* fs;
95 gchar *filename;
96 #define  CHOOSE_XNEE_PROJECT_FILE 1
97 #define  CHOOSE_XNEE_SESSION_FILE 2
98 #define  FILE_TO_SAVE             1
99 #define  FILE_TO_OPEN             2
100 static int          file_choosen = 0;
101 static int          file_action  = 0;
102 
103 
104 int err_continue_clicked=0;
105 int err_quit_clicked=0;
106 
107 
108 
109 int
read_session_file()110 read_session_file()
111 {
112   GNEE_DEBUG(("read_session_file()\n"));
113   if (fs==NULL)
114     {
115       fs = create_fileselection1 ();
116     }
117   file_choosen = CHOOSE_XNEE_SESSION_FILE;
118   file_action=FILE_TO_OPEN;
119 
120   gtk_widget_show (fs);
121   return GNEE_OK;
122 }
123 
124 int
write_session_file()125 write_session_file()
126 {
127   GNEE_DEBUG(("write_session_file()\n"));
128   if (fs==NULL)
129     {
130       fs = create_fileselection1 ();
131     }
132   file_choosen = CHOOSE_XNEE_SESSION_FILE;
133   file_action=FILE_TO_SAVE;
134 
135   gtk_widget_show (fs);
136   return GNEE_OK;
137 }
138 
139 int
read_project_file()140 read_project_file()
141 {
142   GNEE_DEBUG(("read_project_file()\n"));
143   if (fs==NULL)
144     {
145       fs = create_fileselection1 ();
146     }
147   file_choosen = CHOOSE_XNEE_PROJECT_FILE;
148   file_action=FILE_TO_OPEN;
149 
150   gtk_widget_show (fs);
151   return GNEE_OK;
152 }
153 
154 int
write_project_file()155 write_project_file()
156 {
157   GNEE_DEBUG(("write_project_file()\n"));
158   if (fs==NULL)
159     {
160       fs = create_fileselection1 ();
161     }
162   file_choosen = CHOOSE_XNEE_PROJECT_FILE;
163   file_action=FILE_TO_SAVE;
164 
165   gtk_widget_show (fs);
166   return GNEE_OK;
167 }
168 
169 
170 int
get_type(GtkWidget * combo_label)171 get_type(GtkWidget* combo_label)
172 {
173   int   type = 0 ;
174   gchar *selection;
175 
176   GNEE_DEBUG(("int get_type(GtkWidget* combo_label)\n"));
177   selection = gtk_editable_get_chars
178     (GTK_EDITABLE(combo_label), 0, -1);
179 
180   if (selection != 0)
181     {
182       if (strncmp(selection,
183 		  predef_string,
184 		  strlen(predef_string) ) == 0)
185         {
186 	  type = XNEE_PREDEF_EVENTS;
187         }
188       else if (strncmp(selection,
189 		  events_string,
190 		  strlen(events_string) ) == 0)
191         {
192 	  type = XNEE_EVENT;
193         }
194       else if (strncmp(selection,
195 		       replies_string,
196 		       strlen(replies_string)) == 0)
197         {
198 	  type = XNEE_REPLY;
199         }
200       else if (strncmp(selection,
201 		       requests_string,
202 		       strlen(requests_string)) == 0)
203         {
204 	  type = XNEE_REQUEST;
205         }
206       else if (strncmp(selection,
207 		       errors_string,
208 		       strlen(errors_string) ) == 0)
209         {
210 	  type = XNEE_ERROR;
211         }
212     }
213 
214   g_free(selection);
215 
216   return type;
217 }
218 
219 void
on_record_include_button_clicked(GtkButton * button,gpointer user_data)220 on_record_include_button_clicked       (GtkButton       *button,
221                                         gpointer         user_data)
222 {
223   GtkWidget          *source_list;
224     GtkWidget          *destination_list;
225     GtkWidget          *combo_label;
226 
227     GNEE_DEBUG(("on_record_include_button_clicked\n"));
228     source_list      = lookup_widget(GTK_WIDGET(user_data),
229                                      exclude_list_string);
230     destination_list = lookup_widget(GTK_WIDGET(user_data),
231                                      include_list_string);
232     combo_label      = lookup_widget(GTK_WIDGET(user_data),
233                                      combo_label1_string);
234 
235     gnee_recordables_exclude(GTK_TREE_VIEW(source_list),
236                              GTK_TREE_VIEW(destination_list),
237                              ext_xd,
238                              get_type(combo_label));
239 }
240 
241 
242 void
on_record_exclude_button_clicked(GtkButton * button,gpointer user_data)243 on_record_exclude_button_clicked       (GtkButton       *button,
244                                         gpointer         user_data)
245 {
246     GtkWidget          *source_list;
247     GtkWidget          *destination_list;
248     GtkWidget          *combo_label;
249 
250     GNEE_DEBUG(("on_record_exclude_button_clicked\n"));
251     source_list      = lookup_widget(GTK_WIDGET(user_data),
252                                      include_list_string);
253     destination_list = lookup_widget(GTK_WIDGET(user_data),
254                                      exclude_list_string);
255     combo_label      = lookup_widget(GTK_WIDGET(user_data),
256                                      combo_label1_string);
257 
258     gnee_recordables_include(GTK_TREE_VIEW(source_list),
259                              GTK_TREE_VIEW(destination_list),
260                              ext_xd,
261                              get_type(combo_label));
262 }
263 
264 
265 void
on_exclude_list_row_activated(GtkTreeView * treeview,GtkTreePath * path,GtkTreeViewColumn * column,gpointer user_data)266 on_exclude_list_row_activated          (GtkTreeView     *treeview,
267                                         GtkTreePath     *path,
268                                         GtkTreeViewColumn *column,
269                                         gpointer         user_data)
270 {
271     GtkWidget          *source_list;
272     GtkWidget          *destination_list;
273     GtkWidget          *combo_label;
274 
275     GNEE_DEBUG(("on_exclude_list_row_activated\n"));
276     source_list      = lookup_widget(GTK_WIDGET(user_data),
277                                      exclude_list_string);
278     destination_list = lookup_widget(GTK_WIDGET(user_data),
279                                      include_list_string);
280     combo_label      = lookup_widget(GTK_WIDGET(user_data),
281                                      combo_label1_string);
282 
283     gnee_recordables_include(GTK_TREE_VIEW(source_list),
284                              GTK_TREE_VIEW(destination_list),
285                              ext_xd,
286                              get_type(combo_label));
287 }
288 
289 
290 void
on_include_list_row_activated(GtkTreeView * treeview,GtkTreePath * path,GtkTreeViewColumn * column,gpointer user_data)291 on_include_list_row_activated          (GtkTreeView     *treeview,
292                                         GtkTreePath     *path,
293                                         GtkTreeViewColumn *column,
294                                         gpointer         user_data)
295 {
296     GtkWidget          *source_list;
297     GtkWidget          *destination_list;
298     GtkWidget          *combo_label;
299 
300     GNEE_DEBUG(("on_include_list_row_activated\n"));
301     source_list      = lookup_widget(GTK_WIDGET(user_data),
302                                      include_list_string);
303     destination_list = lookup_widget(GTK_WIDGET(user_data),
304                                      exclude_list_string);
305     combo_label      = lookup_widget(GTK_WIDGET(user_data),
306                                      combo_label1_string);
307 
308     gnee_recordables_exclude(GTK_TREE_VIEW(source_list),
309                              GTK_TREE_VIEW(destination_list),
310                              ext_xd,
311                              get_type(combo_label));
312 }
313 
314 void
fake_on_include_list_row_activated(gpointer user_data,int type)315 fake_on_include_list_row_activated (gpointer user_data, int type)
316 {
317     GNEE_DEBUG(("fake_on_include_list_row_activated\n"));
318 }
319 
320 void
on_combo_label1_changed(GtkEditable * editable,gpointer user_data)321 on_combo_label1_changed                (GtkEditable     *editable,
322                                         gpointer         user_data)
323 {
324     GtkWidget          *exclude_list;
325     GtkWidget          *include_list;
326 
327     GtkTreeStore       *exclude_store = 0;
328     GtkTreeStore       *include_store = 0;
329 
330     gchar              *selection;
331     GtkWidget          *combo_label;
332 
333     GNEE_DEBUG(("on_combo_label1_changed\n"));
334     exclude_list = lookup_widget(GTK_WIDGET(user_data),
335                                  exclude_list_string);
336     include_list = lookup_widget(GTK_WIDGET(user_data),
337                                  include_list_string);
338 
339     combo_label = lookup_widget(GTK_WIDGET(user_data),
340                                 combo_label1_string);
341     selection = gtk_editable_get_chars
342       (GTK_EDITABLE(combo_label), 0, -1);
343 
344     if (selection != 0)
345     {
346 
347 
348         if (strcmp(selection, predef_string) == 0)
349         {
350             exclude_store = GTK_TREE_STORE
351                 (lookup_widget(GTK_WIDGET(user_data), exclude_predef_store_string));
352             include_store = GTK_TREE_STORE
353                 (lookup_widget(GTK_WIDGET(user_data), include_predef_store_string));
354 
355         }
356         else if (strcmp(selection, events_string) == 0)
357         {
358             exclude_store = GTK_TREE_STORE
359                 (lookup_widget(GTK_WIDGET(user_data), exclude_event_store_string));
360             include_store = GTK_TREE_STORE
361                 (lookup_widget(GTK_WIDGET(user_data), include_event_store_string));
362 
363         }
364         else if (strcmp(selection, replies_string) == 0)
365         {
366             exclude_store = GTK_TREE_STORE
367                 (lookup_widget(GTK_WIDGET(user_data), exclude_reply_store_string));
368             include_store = GTK_TREE_STORE
369                 (lookup_widget(GTK_WIDGET(user_data), include_reply_store_string));
370 
371         }
372         else if (strcmp(selection, requests_string) == 0)
373         {
374             exclude_store = GTK_TREE_STORE
375                 (lookup_widget(GTK_WIDGET(user_data), exclude_request_store_string));
376             include_store = GTK_TREE_STORE
377                 (lookup_widget(GTK_WIDGET(user_data), include_request_store_string));
378 
379         }
380         else if (strcmp(selection, errors_string) == 0)
381         {
382             exclude_store = GTK_TREE_STORE
383                 (lookup_widget(GTK_WIDGET(user_data), exclude_error_store_string));
384             include_store = GTK_TREE_STORE
385                 (lookup_widget(GTK_WIDGET(user_data), include_error_store_string));
386 
387         }
388 
389         if (exclude_store != NULL && include_store != NULL)
390         {
391             gtk_tree_view_set_model(GTK_TREE_VIEW(exclude_list),
392                                     GTK_TREE_MODEL(exclude_store));
393             gtk_tree_view_set_model(GTK_TREE_VIEW(include_list),
394                                     GTK_TREE_MODEL(include_store));
395         }
396 
397         g_free(selection);
398     }
399 }
400 
401 void
on_new1_activate(GtkMenuItem * menuitem,gpointer user_data)402 on_new1_activate                       (GtkMenuItem     *menuitem,
403                                         gpointer         user_data)
404 {
405   GNEE_DEBUG(("on_new1_activate\n"));
406   write_project_file();
407 }
408 
409 
410 void
on_open1_activate(GtkMenuItem * menuitem,gpointer user_data)411 on_open1_activate                      (GtkMenuItem     *menuitem,
412                                         gpointer         user_data)
413 {
414   GNEE_DEBUG(("on_open1_activate\n"));
415   read_project_file();
416 }
417 
418 
419 void
on_save1_activate(GtkMenuItem * menuitem,gpointer user_data)420 on_save1_activate                      (GtkMenuItem     *menuitem,
421                                         gpointer         user_data)
422 {
423   GNEE_DEBUG(("on_save1_activate\n"));
424   gx_save();
425 }
426 
427 
428 void
on_save_as1_activate(GtkMenuItem * menuitem,gpointer user_data)429 on_save_as1_activate                   (GtkMenuItem     *menuitem,
430                                         gpointer         user_data)
431 {
432   GNEE_DEBUG(("on_save_as1\n"));
433   write_project_file();
434 }
435 
436 
437 void
on_quit1_activate(GtkMenuItem * menuitem,gpointer user_data)438 on_quit1_activate                      (GtkMenuItem     *menuitem,
439                                         gpointer         user_data)
440 {
441   GNEE_DEBUG(("on_quit1_activate\n"));
442   gnee_close_down();
443 }
444 
445 
446 void
on_cut1_activate(GtkMenuItem * menuitem,gpointer user_data)447 on_cut1_activate                       (GtkMenuItem     *menuitem,
448                                         gpointer         user_data)
449 {
450   GNEE_DEBUG(("on_cut1_activate\n"));
451 }
452 
453 
454 void
on_copy1_activate(GtkMenuItem * menuitem,gpointer user_data)455 on_copy1_activate                      (GtkMenuItem     *menuitem,
456                                         gpointer         user_data)
457 {
458   GNEE_DEBUG(("on_copy1_activate\n"));
459 }
460 
461 
462 void
on_paste1_activate(GtkMenuItem * menuitem,gpointer user_data)463 on_paste1_activate                     (GtkMenuItem     *menuitem,
464                                         gpointer         user_data)
465 {
466   GNEE_DEBUG(("on_paste1_activate\n"));
467 }
468 
469 
470 void
on_delete1_activate(GtkMenuItem * menuitem,gpointer user_data)471 on_delete1_activate                    (GtkMenuItem     *menuitem,
472                                         gpointer         user_data)
473 {
474   GNEE_DEBUG(("on_delete1_activate\n"));
475 }
476 
477 
478 void
on_about1_activate(GtkMenuItem * menuitem,gpointer user_data)479 on_about1_activate                     (GtkMenuItem     *menuitem,
480                                         gpointer         user_data)
481 {
482   GtkWidget          *about_box;
483   GtkWidget          *about_label_1;
484   char buf[256];
485   GNEE_DEBUG(("on_about1_activate\n"));
486 
487   about_box      = lookup_widget(GTK_WIDGET(user_data),
488 				 "gnee_about");
489 
490   if (about_box == NULL)
491     {
492       about_box = create_gnee_about();
493     }
494 
495   about_label_1 = lookup_widget(GTK_WIDGET(about_box),
496 				"gnee_label");
497   if (about_label_1!=NULL)
498     {
499       sprintf(buf,"<b>%s %s</b>\n\n",
500 	      XNEE_GUI,
501 	      VERSION);
502       strcat(buf, "is the graphical frontend to " PACKAGE "\n\n");
503       strcat(buf, PACKAGE " is Free Software released under GPL version 3\n");
504 
505       gtk_label_set_markup((GtkLabel*)about_label_1, (gchar*)buf);
506     }
507 
508   if (about_box!=NULL)
509     {
510       gtk_widget_show (about_box);
511     }
512 }
513 
514 
515 void
on_log_window_activate(GtkMenuItem * menuitem,gpointer user_data)516 on_log_window_activate                 (GtkMenuItem     *menuitem,
517                                         gpointer         user_data)
518 {
519   GNEE_DEBUG(("on_log_window\n"));
520 }
521 
522 
523 void
on_record(GtkButton * button,gpointer user_data)524 on_record                              (GtkButton       *button,
525                                         gpointer         user_data)
526 {
527     GtkWidget   *window;
528 
529     window = lookup_widget(user_data, "gnee_window");
530 
531 /*     xnee_set_verbose(ext_xd); */
532     xnee_verbose((ext_xd, "verbose: %d", ext_xd->verbose)); usleep(1000*1000);
533 
534     if (window != NULL)
535       {
536 	gtk_widget_hide(window);
537 	while (gtk_events_pending ())
538 	  {
539 	    gtk_main_iteration ();
540 	  }
541 
542 	if (ext_xd != NULL)
543 	  {
544 	    gnee_recordable2xd(ext_gnee_window,
545 			       "include_event_store" ,
546 			       XNEE_EVENT);
547 
548 	    gx_start_recording(ext_xd);
549 	  }
550 
551       }
552     gtk_widget_show_all(window);
553     fflush(stdout);
554 }
555 
556 
557 void
on_replay(GtkButton * button,gpointer user_data)558 on_replay                              (GtkButton       *button,
559                                         gpointer         user_data)
560 {
561     GtkWidget   *window;
562 
563     window = lookup_widget(user_data, "gnee_window");
564 
565     xnee_verbose((ext_xd, "verbose: %d", ext_xd->verbose)); usleep(1000*1000);
566 /*     xnee_set_verbose(ext_xd); */
567 
568     if (window != NULL)
569     {
570       gtk_widget_hide(window);
571       while (gtk_events_pending ())
572 	{
573 	  gtk_main_iteration ();
574 	}
575 
576       if (ext_xd != NULL)
577         {
578 	  /* This usleep is to prevent the
579 	   * window iconification to disturbe
580 	   * replay.....
581 	   */
582 	  usleep(50*1000);
583 
584 	  gx_start_replaying(ext_xd);
585         }
586     }
587 
588     gtk_widget_show_all(window);
589 }
590 
591 
592 void
on_spinbutton3_change_value(GtkSpinButton * spinbutton,gpointer user_data)593 on_spinbutton3_change_value            (GtkSpinButton   *spinbutton,
594                                         gpointer         user_data)
595 {
596     gint speed = 0 ;
597 
598     speed = gtk_spin_button_get_value_as_int(spinbutton);
599 
600     if (ext_xd != NULL)
601       {
602 	gx_set_speed (speed);
603       }
604 }
605 
606 
607 void
on_wait_spinbutton_value_changed(GtkEditable * editable,gpointer user_data)608 on_wait_spinbutton_value_changed       (GtkEditable     *editable,
609                                         gpointer         user_data)
610 {
611   GNEE_DEBUG(("on_wait_spinbutton\n"));
612 }
613 
614 
615 void
on_wait_checkbox_toggled(GtkToggleButton * togglebutton,gpointer user_data)616 on_wait_checkbox_toggled               (GtkToggleButton *togglebutton,
617                                         gpointer         user_data)
618 {
619   GNEE_DEBUG(("on_wait_checkbox\n"));
620 
621   use_delay = gtk_toggle_button_get_active(togglebutton);
622 
623   if (ext_xd != NULL)
624     {
625       if (use_delay)
626 	{
627 	  gx_set_interval (ext_xd, delay);
628 	}
629       else
630 	{
631 	  gx_set_interval (ext_xd, 0);
632 	}
633     }
634 }
635 
636 
637 void
on_wait_button_value_change(GtkEditable * editable,gpointer user_data)638 on_wait_button_value_change            (GtkEditable     *editable,
639                                         gpointer         user_data)
640 {
641   GNEE_DEBUG(("on_wait_button\n"));
642 }
643 
644 
645 void
on_wait_spinbutton_value_change(GtkEditable * editable,gpointer user_data)646 on_wait_spinbutton_value_change        (GtkEditable     *editable,
647                                         gpointer         user_data)
648 {
649   GNEE_DEBUG(("on_wait_spinbutton\n"));
650 
651 }
652 
653 
654 void
on_wait_spinbutto_change_value(GtkEditable * editable,gpointer user_data)655 on_wait_spinbutto_change_value         (GtkEditable     *editable,
656                                         gpointer         user_data)
657 {
658   GNEE_DEBUG(("on_wait_spinbutto\n"));
659 
660 }
661 
662 
663 void
on_wait_spinbutton_change_value(GtkSpinButton * spinbutton,gpointer user_data)664 on_wait_spinbutton_change_value        (GtkSpinButton   *spinbutton,
665                                         gpointer         user_data)
666 {
667   GNEE_DEBUG(("on_wait_spinbutton\n"));
668   delay = gtk_spin_button_get_value_as_int(spinbutton);
669 
670   if (ext_xd != NULL)
671     {
672       if (use_delay)
673 	{
674 	  gx_set_interval (ext_xd, delay);
675 	}
676       else
677 	{
678 	  gx_set_interval (ext_xd, 0);
679 	}
680     }
681 }
682 
683 void
on_verbose_logging_checkbox_toggled(GtkToggleButton * togglebutton,gpointer user_data)684 on_verbose_logging_checkbox_toggled    (GtkToggleButton *togglebutton,
685                                         gpointer         user_data)
686 {
687   GNEE_DEBUG(("on_verbose_logging_checkbox_toggled\n"));
688   if (ext_xd != NULL)
689     {
690       if (gtk_toggle_button_get_active(togglebutton))
691 	{
692 	  gx_set_verbose(ext_xd);
693 	}
694       else
695 	{
696 	  gx_unset_verbose(ext_xd);
697 	}
698     }
699 
700 }
701 
702 
703 
704 
705 void
on_spinbutton5_change_value(GtkSpinButton * spinbutton,gpointer user_data)706 on_spinbutton5_change_value            (GtkSpinButton   *spinbutton,
707                                         gpointer         user_data)
708 {
709   GNEE_DEBUG(("on_spinbutton5_change\n"));
710   if (ext_xd != NULL)
711     {
712       gx_set_events_max(ext_xd,gtk_spin_button_get_value_as_int(spinbutton));
713     }
714 }
715 
716 
717 void
on_spinbutton4_change_value(GtkSpinButton * spinbutton,gpointer user_data)718 on_spinbutton4_change_value            (GtkSpinButton   *spinbutton,
719                                         gpointer         user_data)
720 {
721   GNEE_DEBUG(("on_spinbutton4_change\n"));
722   if (ext_xd != NULL)
723     {
724       gx_set_data_max(ext_xd,gtk_spin_button_get_value_as_int(spinbutton));
725     }
726 
727 }
728 
729 
730 void
on_spinbutton6_change_value(GtkSpinButton * spinbutton,gpointer user_data)731 on_spinbutton6_change_value            (GtkSpinButton   *spinbutton,
732                                         gpointer         user_data)
733 {
734   GNEE_DEBUG(("on_spinbutton6_change\n"));
735   if (ext_xd != NULL)
736     {
737       gx_set_time_max(ext_xd,gtk_spin_button_get_value_as_int(spinbutton));
738     }
739 
740 }
741 
742 
743 
744 void
on_ok_button1_clicked(GtkButton * button,gpointer user_data)745 on_ok_button1_clicked                  (GtkButton       *button,
746                                         gpointer         user_data)
747 {
748   FILE *file;
749   GtkEntry *file_text ;
750 
751   GNEE_DEBUG(("on_ok_button1_clicked\n"));
752   if (filename!=NULL)
753     {
754       free (filename);
755     }
756 
757   filename = strdup(gtk_file_selection_get_filename(GTK_FILE_SELECTION(fs)));
758 
759   switch (file_choosen)
760     {
761     case CHOOSE_XNEE_PROJECT_FILE:
762       if ( file_action  == FILE_TO_SAVE )
763 	{
764 	  gx_set_rc_byname (ext_xd, filename);
765 	  file = fopen (filename, "w");
766 	  gx_write_settings_to_file (ext_xd, file) ;
767 	  fclose (file);
768 	  file_choosen = 0;
769 	  file_action  = 0;
770 	}
771       else if ( file_action  == FILE_TO_OPEN)
772 	{
773 	  file = fopen (filename, "rw");
774 	  xnee_refresh_ranges(ext_xd);
775 	  gnee_remove_all_recordables();
776 	  gx_set_rc_byname (ext_xd, filename);
777 
778 	  if ( gx_get_rc_file (ext_xd) != NULL)
779 	    {
780  	      gx_add_resource (ext_xd );
781 	    }
782 	  else
783 	  {
784 	      g_print (" Could not open project file %s\n", filename);
785 	  }
786 
787 
788 	  fclose (file);
789 	  file_choosen = 0;
790 	  file_action  = 0;
791 
792           /* Make the GUI reflect all settings as read from file */
793  	  gx_set_xd_settings();
794 	}
795       else
796 	{
797 	  ;
798 	}
799       break;
800     case CHOOSE_XNEE_SESSION_FILE:
801       if ( file_action  == FILE_TO_SAVE )
802 	{
803 	  file_text = (GtkEntry*) lookup_widget(GTK_WIDGET(ext_gnee_window),
804 						    rec_file_text_string);
805 
806 	  gtk_entry_set_text (file_text,
807 			      filename);
808 	  xnee_set_out_name (ext_xd, filename);
809 	}
810       else if ( file_action  == FILE_TO_OPEN)
811 	{
812 
813 	  file_text = (GtkEntry*) lookup_widget(GTK_WIDGET(ext_gnee_window),
814 						    rep_file_text_string);
815 
816 	  gtk_entry_set_text (file_text,
817 			      filename);
818 
819 	  xnee_set_data_name(ext_xd, filename);
820 
821           /* Make the GUI reflect all settings as read from file */
822  	  gx_set_xd_settings();
823 
824 
825 	}
826 
827       file_choosen=0;
828       break;
829     case 0:
830     default:
831       break;
832     }
833   gtk_widget_hide(fs);
834 }
835 
836 
837 void
on_open_button_clicked(GtkButton * button,gpointer user_data)838 on_open_button_clicked                 (GtkButton       *button,
839                                         gpointer         user_data)
840 {
841   GNEE_DEBUG(("on_open_button\n"));
842   read_project_file();
843 }
844 
845 
846 void
on_cancel_button1_clicked(GtkButton * button,gpointer user_data)847 on_cancel_button1_clicked              (GtkButton       *button,
848                                         gpointer         user_data)
849 {
850   GNEE_DEBUG(("on_cancel_button1\n"));
851   gtk_widget_hide(fs);
852 }
853 
854 
855 void
on_sfile_activate(GtkMenuItem * menuitem,gpointer user_data)856 on_sfile_activate                      (GtkMenuItem     *menuitem,
857                                         gpointer         user_data)
858 {
859   GNEE_DEBUG(("on_sfile_activate\n"));
860 }
861 
862 
863 void
on_save_button_clicked(GtkButton * button,gpointer user_data)864 on_save_button_clicked                 (GtkButton       *button,
865                                         gpointer         user_data)
866 {
867   GNEE_DEBUG(("on_save_button\n"));
868   if (ext_xd != NULL)
869     {
870       FILE *file;
871       char *fname = gx_get_rc_name(ext_xd);
872 
873       if (fname == NULL)
874 	{
875 	  write_project_file();
876 	}
877       else
878 	{
879 	  file = fopen (fname, "w");
880 	  gx_write_settings_to_file (ext_xd, file) ;
881 	  fclose (file);
882 	}
883     }
884 }
885 
886 
887 void
on_about_ok_button_clicked(GtkButton * button,gpointer user_data)888 on_about_ok_button_clicked             (GtkButton       *button,
889                                         gpointer         user_data)
890 {
891   GtkWidget          *about_box;
892 
893   GNEE_DEBUG(("on_about_ok\n"));
894   about_box      = lookup_widget(GTK_WIDGET(user_data),
895 				 "gnee_about");
896 
897   if (about_box==NULL)
898     {
899       about_box = create_gnee_about();
900     }
901 
902   if (about_box!=NULL)
903     {
904       gtk_widget_hide (about_box);
905     }
906 }
907 
908 
909 
910 static void
combo_change_helper(gpointer gw,const char * combo_name,int mod_or_key,int grab_action)911 combo_change_helper(gpointer gw,
912 		    const char *combo_name,
913 		    int mod_or_key,
914 		    int grab_action)
915 {
916   gchar *k_selection = NULL;
917   GtkWidget          *k_combo = NULL;
918   #define MOD_KEY_SIZE    128
919   #define COMBO_NAME_SIZE 50
920 
921   char mod_key[MOD_KEY_SIZE];
922   char k_combo_name[COMBO_NAME_SIZE] ;
923 
924   GNEE_DEBUG(("combo_change_helper\n"));
925 
926 
927 
928   GNEE_DEBUG((" combo .............. \n"));
929 
930   switch (grab_action)
931     {
932     case XNEE_GRAB_STOP:
933       GNEE_DEBUG((" stop \n"));
934       strncpy (k_combo_name, stop_k_combo_string, COMBO_NAME_SIZE);
935       break;
936     case XNEE_GRAB_PAUSE:
937       GNEE_DEBUG((" pause \n"));
938       strncpy (k_combo_name, pause_k_combo_string, COMBO_NAME_SIZE);
939       break;
940     case XNEE_GRAB_RESUME:
941       GNEE_DEBUG((" resume \n"));
942       strncpy (k_combo_name, resume_k_combo_string, COMBO_NAME_SIZE);
943       break;
944     case XNEE_GRAB_INSERT:
945       GNEE_DEBUG((" insert \n"));
946       strncpy (k_combo_name, mark_k_combo_string, COMBO_NAME_SIZE);
947       break;
948     case XNEE_GRAB_EXEC:
949       GNEE_DEBUG((" exec \n"));
950       strncpy (k_combo_name, exec_k_combo_string, COMBO_NAME_SIZE);
951       break;
952     default:
953       GNEE_DEBUG(("NO action choosen\n"));
954       strncpy (k_combo_name, "", COMBO_NAME_SIZE);
955     }
956 
957   if (strlen (k_combo_name) != 0)
958     {
959       k_combo      = lookup_widget(GTK_WIDGET(gw),
960 				   k_combo_name);
961       k_selection = gtk_editable_get_chars
962 	(GTK_EDITABLE(k_combo), 0, -1);
963     }
964 
965 
966   if (strlen(k_selection)!=0)
967     {
968       if (strcmp (k_selection, "None")==0)
969 	{
970 	  GNEE_DEBUG((" combo no 1 \n"));
971 	}
972       else
973 	{
974 	  strncpy (mod_key, k_selection, MOD_KEY_SIZE);
975 
976 	  GNEE_DEBUG(("combo_change_helper: mod/key=%d   type=%.2d  %s \n",
977 		      mod_or_key,
978 		      grab_action,
979 		      mod_key));
980 
981 
982  	  gx_set_key (ext_xd, grab_action, mod_key);
983 	}
984     }
985 }
986 
987 void
on_stop_m_combo_changed(GtkEditable * editable,gpointer user_data)988 on_stop_m_combo_changed                (GtkEditable     *editable,
989                                         gpointer         user_data)
990 {
991   GNEE_DEBUG(("on_stop_m_combo_changed\n"));
992   combo_change_helper(user_data,
993 		      stop_m_combo_string,
994 		      XNEE_GRAB_MODIFIER,
995 		      XNEE_GRAB_STOP );
996 }
997 
998 
999 void
on_stop_k_combo_changed(GtkEditable * editable,gpointer user_data)1000 on_stop_k_combo_changed                (GtkEditable     *editable,
1001                                         gpointer         user_data)
1002 {
1003   GNEE_DEBUG(("on_stop_k\n"));
1004   combo_change_helper(user_data,
1005 		      stop_k_combo_string,
1006 		      XNEE_GRAB_KEY, 		      XNEE_GRAB_STOP );
1007 }
1008 
1009 
1010 
1011 
1012 void
on_pause_m_combo_changed(GtkEditable * editable,gpointer user_data)1013 on_pause_m_combo_changed               (GtkEditable     *editable,
1014                                         gpointer         user_data)
1015 {
1016   GNEE_DEBUG(("on_pause_m\n"));
1017   combo_change_helper(user_data,
1018 		      pause_m_combo_string,
1019 		      XNEE_GRAB_MODIFIER,
1020 		      XNEE_GRAB_PAUSE );
1021 
1022 }
1023 
1024 
1025 void
on_resume_m_combo_changed(GtkEditable * editable,gpointer user_data)1026 on_resume_m_combo_changed              (GtkEditable     *editable,
1027                                         gpointer         user_data)
1028 {
1029   GNEE_DEBUG(("on_resume_m\n"));
1030   combo_change_helper(user_data,
1031 		      resume_m_combo_string,
1032 		      XNEE_GRAB_MODIFIER,
1033 		      XNEE_GRAB_RESUME );
1034 
1035 }
1036 
1037 
1038 void
on_mark_m_combo_changed(GtkEditable * editable,gpointer user_data)1039 on_mark_m_combo_changed                (GtkEditable     *editable,
1040                                         gpointer         user_data)
1041 {
1042   GNEE_DEBUG(("on_mark_m\n"));
1043   combo_change_helper(user_data,
1044 		      mark_m_combo_string,
1045 		      XNEE_GRAB_MODIFIER,
1046 		      XNEE_GRAB_INSERT );
1047 
1048 }
1049 
1050 
1051 void
on_exec_m_combo_changed(GtkEditable * editable,gpointer user_data)1052 on_exec_m_combo_changed                (GtkEditable     *editable,
1053                                         gpointer         user_data)
1054 {
1055   GNEE_DEBUG(("on_exec_m\n"));
1056   combo_change_helper(user_data,
1057 		      exec_m_combo_string,
1058 		      XNEE_GRAB_MODIFIER,
1059 		      XNEE_GRAB_EXEC );
1060 
1061 }
1062 
1063 
1064 void
on_pause_k_combo_changed(GtkEditable * editable,gpointer user_data)1065 on_pause_k_combo_changed               (GtkEditable     *editable,
1066                                         gpointer         user_data)
1067 {
1068   GNEE_DEBUG(("on_pause_k\n"));
1069   combo_change_helper(user_data,
1070 		      pause_k_combo_string,
1071 		      XNEE_GRAB_KEY,
1072 		      XNEE_GRAB_PAUSE );
1073 
1074 }
1075 
1076 
1077 void
on_resume_k_combo_changed(GtkEditable * editable,gpointer user_data)1078 on_resume_k_combo_changed              (GtkEditable     *editable,
1079                                         gpointer         user_data)
1080 {
1081   GNEE_DEBUG(("on_resume_k\n"));
1082   combo_change_helper(user_data,
1083 		      resume_k_combo_string,
1084 		      XNEE_GRAB_KEY,
1085 		      XNEE_GRAB_RESUME );
1086 
1087 }
1088 
1089 
1090 void
on_mark_k_combo_changed(GtkEditable * editable,gpointer user_data)1091 on_mark_k_combo_changed                (GtkEditable     *editable,
1092                                         gpointer         user_data)
1093 {
1094   GNEE_DEBUG(("on_mark_k\n"));
1095   combo_change_helper(user_data,
1096 		      mark_k_combo_string,
1097 		      XNEE_GRAB_KEY,
1098 		      XNEE_GRAB_INSERT );
1099 
1100 }
1101 
1102 
1103 void
on_exec_k_combo_changed(GtkEditable * editable,gpointer user_data)1104 on_exec_k_combo_changed                (GtkEditable     *editable,
1105                                         gpointer         user_data)
1106 {
1107   GNEE_DEBUG(("on_exec_k\n"));
1108   combo_change_helper(user_data,
1109 		      exec_k_combo_string,
1110 		      XNEE_GRAB_KEY,
1111 		      XNEE_GRAB_EXEC );
1112 }
1113 
1114 
1115 void
on_err_cont_button_clicked(GtkButton * button,gpointer user_data)1116 on_err_cont_button_clicked             (GtkButton       *button,
1117                                         gpointer         user_data)
1118 {
1119   GNEE_DEBUG(("on_err_cont\n"));
1120 }
1121 
1122 
1123 void
on_err_quit_button_clicked(GtkButton * button,gpointer user_data)1124 on_err_quit_button_clicked             (GtkButton       *button,
1125                                         gpointer         user_data)
1126 {
1127   GNEE_DEBUG(("on_err_quit\n"));
1128 }
1129 
1130 
1131 void
on_cancelbutton1_clicked(GtkButton * button,gpointer user_data)1132 on_cancelbutton1_clicked               (GtkButton       *button,
1133                                         gpointer         user_data)
1134 {
1135   GNEE_DEBUG(("on_cancelbutton1_clicked\n"));
1136   err_continue_clicked=1;
1137   err_quit_clicked=0;
1138   gx_undisplay_errror();
1139 }
1140 
1141 
1142 void
on_okbutton1_clicked(GtkButton * button,gpointer user_data)1143 on_okbutton1_clicked                   (GtkButton       *button,
1144                                         gpointer         user_data)
1145 {
1146   GNEE_DEBUG(("on_okbutton1_clicked\n"));
1147 }
1148 
1149 
1150 void
on_rep_menu_open_activate(GtkMenuItem * menuitem,gpointer user_data)1151 on_rep_menu_open_activate              (GtkMenuItem     *menuitem,
1152                                         gpointer         user_data)
1153 {
1154     GNEE_DEBUG(("on_rep_menu\n"));
1155   read_session_file();
1156 }
1157 
1158 
1159 
1160 
1161 void
on_open_project_file2_activate(GtkMenuItem * menuitem,gpointer user_data)1162 on_open_project_file2_activate         (GtkMenuItem     *menuitem,
1163                                         gpointer         user_data)
1164 {
1165   GNEE_DEBUG(("on_open_project\n"));
1166   read_project_file();
1167 }
1168 
1169 
1170 void
on_set_session_file1_activate(GtkMenuItem * menuitem,gpointer user_data)1171 on_set_session_file1_activate          (GtkMenuItem     *menuitem,
1172                                         gpointer         user_data)
1173 {
1174   GNEE_DEBUG(("on_set_session\n"));
1175   write_session_file();
1176 }
1177 
1178 
1179 void
on_checkbutton10_toggled(GtkToggleButton * togglebutton,gpointer user_data)1180 on_checkbutton10_toggled               (GtkToggleButton *togglebutton,
1181                                         gpointer         user_data)
1182 {
1183   GNEE_DEBUG(("on_checkbutton10_toggled\n"));
1184 
1185   if (gtk_toggle_button_get_active(togglebutton))
1186     {
1187       gx_set_using_rec_display(ext_gx);
1188     }
1189   else
1190     {
1191       gx_unset_using_rec_display(ext_gx);
1192     }
1193 }
1194 
1195 
1196 
1197 void
on_rec_file_sel_clicked(GtkButton * button,gpointer user_data)1198 on_rec_file_sel_clicked                (GtkButton       *button,
1199                                         gpointer         user_data)
1200 {
1201   GNEE_DEBUG(("on_rec_file\n"));
1202   write_session_file();
1203 }
1204 
1205 
1206 void
on_rep_disp_cb_toggled(GtkToggleButton * togglebutton,gpointer user_data)1207 on_rep_disp_cb_toggled                 (GtkToggleButton *togglebutton,
1208                                         gpointer         user_data)
1209 {
1210   GNEE_DEBUG(("on_rep_disp\n"));
1211   if (gtk_toggle_button_get_active(togglebutton))
1212     {
1213       gx_set_using_rep_display(ext_gx);
1214     }
1215   else
1216     {
1217       gx_unset_using_rep_display(ext_gx);
1218     }
1219 }
1220 
1221 
1222 void
on_rep_disp_text_changed(GtkEditable * editable,gpointer user_data)1223 on_rep_disp_text_changed               (GtkEditable     *editable,
1224                                         gpointer         user_data)
1225 {
1226 
1227   GNEE_DEBUG(("on_rep_disp\n"));
1228 }
1229 
1230 
1231 void
on_button11_clicked(GtkButton * button,gpointer user_data)1232 on_button11_clicked                    (GtkButton       *button,
1233                                         gpointer         user_data)
1234 {
1235   GNEE_DEBUG(("on_button11_clicked\n"));
1236   read_session_file();
1237 }
1238 
1239 
1240 void
on_max_thresh_sb_value_changed(GtkSpinButton * spinbutton,gpointer user_data)1241 on_max_thresh_sb_value_changed         (GtkSpinButton   *spinbutton,
1242                                         gpointer         user_data)
1243 {
1244   GNEE_DEBUG(("on_max_thresh\n"));
1245   if (ext_xd != NULL)
1246     {
1247       gx_set_max_threshold(ext_xd,
1248 			   gtk_spin_button_get_value_as_int(spinbutton));
1249     }
1250 }
1251 
1252 
1253 void
on_min_thresh_sb_value_changed(GtkSpinButton * spinbutton,gpointer user_data)1254 on_min_thresh_sb_value_changed         (GtkSpinButton   *spinbutton,
1255                                         gpointer         user_data)
1256 {
1257   GNEE_DEBUG(("on_min_thresh\n"));
1258   if (ext_xd != NULL)
1259     {
1260       gx_set_min_threshold(ext_xd,
1261 			   gtk_spin_button_get_value_as_int(spinbutton));
1262     }
1263 }
1264 
1265 
1266 void
on_tot_thresh_sb_value_changed(GtkSpinButton * spinbutton,gpointer user_data)1267 on_tot_thresh_sb_value_changed         (GtkSpinButton   *spinbutton,
1268                                         gpointer         user_data)
1269 {
1270   GNEE_DEBUG(("on_tot_thresh\n"));
1271   if (ext_xd != NULL)
1272     {
1273       gx_set_tot_threshold(ext_xd,
1274 			   gtk_spin_button_get_value_as_int(spinbutton));
1275     }
1276 }
1277 
1278 
1279 void
on_spinbutton11_change_value(GtkSpinButton * spinbutton,gpointer user_data)1280 on_spinbutton11_change_value           (GtkSpinButton   *spinbutton,
1281                                         gpointer         user_data)
1282 {
1283   GNEE_DEBUG(("on_spinbutton11_change\n"));
1284   if (ext_xd != NULL)
1285     {
1286       gx_set_events_max(ext_xd,gtk_spin_button_get_value_as_int(spinbutton));
1287     }
1288 }
1289 
1290 
1291 void
on_spinbutton12_change_value(GtkSpinButton * spinbutton,gpointer user_data)1292 on_spinbutton12_change_value           (GtkSpinButton   *spinbutton,
1293                                         gpointer         user_data)
1294 {
1295   GNEE_DEBUG(("on_spinbutton12_change\n"));
1296   if (ext_xd != NULL)
1297     {
1298       gx_set_data_max(ext_xd,gtk_spin_button_get_value_as_int(spinbutton));
1299     }
1300 }
1301 
1302 
1303 void
on_spinbutton13_change_value(GtkSpinButton * spinbutton,gpointer user_data)1304 on_spinbutton13_change_value           (GtkSpinButton   *spinbutton,
1305                                         gpointer         user_data)
1306 {
1307   GNEE_DEBUG(("on_spinbutton13_change\n"));
1308   if (ext_xd != NULL)
1309     {
1310       gx_set_time_max(ext_xd,gtk_spin_button_get_value_as_int(spinbutton));
1311     }
1312 }
1313 
1314 
1315 void
on_spinbutton7_change_value(GtkSpinButton * spinbutton,gpointer user_data)1316 on_spinbutton7_change_value            (GtkSpinButton   *spinbutton,
1317                                         gpointer         user_data)
1318 {
1319   GNEE_DEBUG(("on_spinbutton7_change\n"));
1320 
1321 }
1322 
1323 
1324 void
on_speed_spin_change_value(GtkSpinButton * spinbutton,gpointer user_data)1325 on_speed_spin_change_value             (GtkSpinButton   *spinbutton,
1326                                         gpointer         user_data)
1327 {
1328   gint speed = 0 ;
1329 
1330   GNEE_DEBUG(("on_speed_spin\n"));
1331   speed = gtk_spin_button_get_value_as_int(spinbutton);
1332 
1333   if (ext_xd != NULL)
1334   {
1335       gx_set_speed (speed);
1336   }
1337 }
1338 
1339 
1340 
1341 
1342 void
on_rec_disp_text_changed(GtkEditable * editable,gpointer user_data)1343 on_rec_disp_text_changed               (GtkEditable     *editable,
1344                                         gpointer         user_data)
1345 {
1346   GNEE_DEBUG(("on_rec_disp\n"));
1347 }
1348 
1349 
1350 void
on_skip_sync_cb_toggled(GtkToggleButton * togglebutton,gpointer user_data)1351 on_skip_sync_cb_toggled                (GtkToggleButton *togglebutton,
1352                                         gpointer         user_data)
1353 {
1354   GNEE_DEBUG(("on_skip_sync "));
1355   if (ext_xd != NULL)
1356     {
1357       if (gtk_toggle_button_get_active(togglebutton))
1358       {
1359 	  GNEE_DEBUG(("  SYNC ON"));
1360 	  gx_set_sync (ext_xd);
1361 	}
1362       else
1363 	{
1364 	  GNEE_DEBUG(("  SYNC OFF "));
1365 	  gx_unset_sync (ext_xd);
1366 	}
1367     }
1368   GNEE_DEBUG(("     xd says=%d\n",
1369 	      xnee_get_sync(ext_xd)));
1370 }
1371 
1372 
1373 
1374 void
on_force_rep_cb_toggled(GtkToggleButton * togglebutton,gpointer user_data)1375 on_force_rep_cb_toggled                (GtkToggleButton *togglebutton,
1376                                         gpointer         user_data)
1377 {
1378   GNEE_DEBUG(("on_force_rep\n"));
1379   if (ext_xd != NULL)
1380     {
1381       if (gtk_toggle_button_get_active(togglebutton))
1382 	{
1383 	  gx_set_force_replay (ext_xd);
1384 	}
1385       else
1386 	{
1387 	  gx_unset_force_replay (ext_xd);
1388 	}
1389     }
1390 }
1391 
1392 
1393 void
on_okbutton2_clicked(GtkButton * button,gpointer user_data)1394 on_okbutton2_clicked                   (GtkButton       *button,
1395                                         gpointer         user_data)
1396 {
1397   GNEE_DEBUG(("on_okbutton2_clicked\n"));
1398   err_continue_clicked=0;
1399   err_quit_clicked=1;
1400   gx_undisplay_errror();
1401 }
1402 
1403 
1404 void
on_speed_toggle_toggled(GtkToggleButton * togglebutton,gpointer user_data)1405 on_speed_toggle_toggled                (GtkToggleButton *togglebutton,
1406                                         gpointer         user_data)
1407 {
1408   GNEE_DEBUG(("on_speed_toggle\n"));
1409   if (ext_xd != NULL)
1410     {
1411       if (gtk_toggle_button_get_active(togglebutton))
1412 	{
1413 	  gx_set_use_speed(1);
1414 	}
1415       else
1416 	{
1417 	  gx_set_use_speed(0);
1418 	}
1419     }
1420 
1421 }
1422 
1423 
1424 void
on_radiobutton1_toggled(GtkToggleButton * togglebutton,gpointer user_data)1425 on_radiobutton1_toggled                (GtkToggleButton *togglebutton,
1426                                         gpointer         user_data)
1427 {
1428   GNEE_DEBUG(("on_radiobutton1_toggled\n"));
1429   if (ext_xd != NULL)
1430     {
1431       if (gtk_toggle_button_get_active(togglebutton))
1432 	{
1433 	  gx_set_all_clients();
1434 	}
1435     }
1436 }
1437 
1438 
1439 void
on_radiobutton2_toggled(GtkToggleButton * togglebutton,gpointer user_data)1440 on_radiobutton2_toggled                (GtkToggleButton *togglebutton,
1441                                         gpointer         user_data)
1442 {
1443   GNEE_DEBUG(("on_radiobutton2_toggled\n"));
1444   if (ext_xd != NULL)
1445     {
1446       if (gtk_toggle_button_get_active(togglebutton))
1447 	{
1448 	  gx_unset_all_clients();
1449 	}
1450     }
1451 }
1452 
1453 
1454 void
on_xnee_format_rb_toggled(GtkToggleButton * togglebutton,gpointer user_data)1455 on_xnee_format_rb_toggled              (GtkToggleButton *togglebutton,
1456                                         gpointer         user_data)
1457 {
1458   GNEE_DEBUG(("on_xnee_format\n"));
1459   if (ext_xd != NULL)
1460     {
1461       if (gtk_toggle_button_get_active(togglebutton))
1462 	{
1463 	  gx_set_xnee_printout();
1464 	}
1465     }
1466 }
1467 
1468 
1469 void
on_human_format_rb_toggled(GtkToggleButton * togglebutton,gpointer user_data)1470 on_human_format_rb_toggled             (GtkToggleButton *togglebutton,
1471                                         gpointer         user_data)
1472 {
1473   GNEE_DEBUG(("on_human_format\n"));
1474   if (ext_xd != NULL)
1475     {
1476       if (gtk_toggle_button_get_active(togglebutton))
1477 	{
1478 	  gx_set_human_printout();
1479 	}
1480     }
1481 }
1482 
1483 
1484 void
on_gnee_window_destroy(GtkObject * object,gpointer user_data)1485 on_gnee_window_destroy                 (GtkObject       *object,
1486                                         gpointer         user_data)
1487 {
1488   GNEE_DEBUG(("on_gnee_window\n"));
1489   gnee_close_down();
1490 }
1491 
1492 
1493 void
on_stderr_fb_b_toggled(GtkToggleButton * togglebutton,gpointer user_data)1494 on_stderr_fb_b_toggled                 (GtkToggleButton *togglebutton,
1495                                         gpointer         user_data)
1496 {
1497   GNEE_DEBUG(("on_stderr_fb\n"));
1498   if (ext_xd != NULL)
1499     {
1500       if (gtk_toggle_button_get_active(togglebutton))
1501 	{
1502 	  gx_set_stderr_feedback();
1503 	}
1504     }
1505 }
1506 
1507 
1508 void
on_no_fb_b_toggled(GtkToggleButton * togglebutton,gpointer user_data)1509 on_no_fb_b_toggled                     (GtkToggleButton *togglebutton,
1510                                         gpointer         user_data)
1511 {
1512   GNEE_DEBUG(("on_no_fb\n"));
1513   if (ext_xd != NULL)
1514     {
1515       if (gtk_toggle_button_get_active(togglebutton))
1516 	{
1517 	  gx_set_no_feedback();
1518 	}
1519     }
1520 }
1521 
1522 
1523 
1524 void
on_xosd_fb_b_toggled(GtkToggleButton * togglebutton,gpointer user_data)1525 on_xosd_fb_b_toggled                   (GtkToggleButton *togglebutton,
1526                                         gpointer         user_data)
1527 {
1528   GNEE_DEBUG(("on_xosd_fb\n"));
1529   if (ext_xd != NULL)
1530     {
1531       if (gtk_toggle_button_get_active(togglebutton))
1532 	{
1533 	  gx_set_xosd_feedback();
1534 	}
1535     }
1536 
1537 }
1538 
1539 
1540 void
on_replay_settings_box_map(GtkWidget * widget,gpointer user_data)1541 on_replay_settings_box_map             (GtkWidget       *widget,
1542                                         gpointer         user_data)
1543 {
1544 /*   printf ("map\n"); */
1545   ;
1546 }
1547 
1548 
1549 void
on_record_settings_box_map(GtkWidget * widget,gpointer user_data)1550 on_record_settings_box_map             (GtkWidget       *widget,
1551                                         gpointer         user_data)
1552 {
1553   ;
1554 }
1555 
1556 
1557 void
on_button5_clicked(GtkButton * button,gpointer user_data)1558 on_button5_clicked                     (GtkButton       *button,
1559                                         gpointer         user_data)
1560 {
1561   GtkWidget   *window;
1562 
1563   if (user_data)
1564     {
1565       window = lookup_widget(user_data, "gnee_about");
1566     }
1567   else
1568     {
1569       return;
1570     }
1571 
1572   if (window)
1573     {
1574       gtk_widget_hide (window);
1575     }
1576 }
1577 
1578 
1579 
1580 void
on_new_win_check_toggled(GtkToggleButton * togglebutton,gpointer user_data)1581 on_new_win_check_toggled               (GtkToggleButton *togglebutton,
1582                                         gpointer         user_data)
1583 {
1584   int use_recall;
1585   GNEE_DEBUG(("on_new_win_checkbox\n"));
1586 
1587   use_recall = gtk_toggle_button_get_active(togglebutton);
1588 
1589   if (ext_xd != NULL)
1590     {
1591       if (use_recall)
1592 	{
1593 	  gx_set_recall_window_pos(ext_xd);
1594 	}
1595       else
1596 	{
1597 	  gx_unset_recall_window_pos(ext_xd);
1598 	}
1599     }
1600 }
1601 
1602 
1603 
1604 void
on_x_offs_spin_changed(GtkSpinButton * spinbutton,gpointer user_data)1605 on_x_offs_spin_changed                 (GtkSpinButton   *spinbutton,
1606                                         gpointer         user_data)
1607 {
1608   x_offset = gtk_spin_button_get_value_as_int(spinbutton);
1609 
1610   if (ext_xd != NULL)
1611     {
1612       if (use_offset)
1613 	{
1614 	  gx_set_replay_offset_x (ext_xd, x_offset);
1615 	}
1616     }
1617 }
1618 
1619 
1620 void
on_y_offs_spin_changed(GtkSpinButton * spinbutton,gpointer user_data)1621 on_y_offs_spin_changed                 (GtkSpinButton   *spinbutton,
1622                                         gpointer         user_data)
1623 {
1624   y_offset = gtk_spin_button_get_value_as_int(spinbutton);
1625 
1626   if (ext_xd != NULL)
1627     {
1628       if (use_offset)
1629 	{
1630 	  gx_set_replay_offset_y (ext_xd, y_offset);
1631 	}
1632     }
1633 }
1634 
1635 
1636 void
on_offset_toggle_toggled(GtkToggleButton * togglebutton,gpointer user_data)1637 on_offset_toggle_toggled               (GtkToggleButton *togglebutton,
1638                                         gpointer         user_data)
1639 {
1640   GNEE_DEBUG(("%s\n", __func__));
1641 
1642   use_offset = gtk_toggle_button_get_active(togglebutton);
1643 
1644   if (ext_xd != NULL)
1645     {
1646       if (use_offset)
1647 	{
1648 	  gx_set_replay_offset_x(ext_xd, x_offset);
1649 	  gx_set_replay_offset_y(ext_xd, y_offset);
1650 	}
1651       else
1652 	{
1653 	  gx_set_replay_offset_x(ext_xd, 0);
1654 	  gx_set_replay_offset_y(ext_xd, 0);
1655 	}
1656     }
1657 }
1658 
1659 
1660 
1661 
1662 
1663 gboolean
on_gnee_about_close(GtkWidget * widget,GdkEventButton * event,gpointer user_data)1664 on_gnee_about_close                    (GtkWidget       *widget,
1665                                         GdkEventButton  *event,
1666                                         gpointer         user_data)
1667 {
1668   printf ("Close\n");
1669 
1670   return FALSE;
1671 }
1672 
1673 
1674 void
on_gnee_about_response(GtkDialog * dialog,gint response_id,gpointer user_data)1675 on_gnee_about_response                 (GtkDialog       *dialog,
1676                                         gint             response_id,
1677                                         gpointer         user_data)
1678 {
1679 
1680   GtkWidget   *window = user_data;
1681 
1682   if (window != NULL )
1683     {
1684       gtk_widget_hide (window);
1685     }
1686 }
1687 
1688