1 /*****
2 * Xnee's Not an Event Emulator
3 *
4 * Xnee enables recording and replaying of X protocol data
5 *
6 * Copyright (C) 2005, 2006, 2007, 2011 Henrik Sandklef
7 *
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License
10 * as published by the Free Software Foundation; either version 3
11 * of the License, or any later version.
12 *
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 51 Franklin Street, Boston,
22 * MA 02110-1301, USA.
23 ****/
24
25 #ifdef HAVE_CONFIG_H
26 # include <config.h>
27 #endif
28
29 #include <gtk/gtk.h>
30
31 #include "callbacks.h"
32 #include "interface.h"
33 #include "support.h"
34
35 #include "libxnee/xnee.h"
36 #include "libxnee/print_varargs.h"
37 #include "libxnee/print.h"
38 #include "libxnee/xnee_setget.h"
39
40 #include "pnee_impl.h"
41
42 extern xnee_data *xd;
43 extern GtkWidget *pnee_pref;
44
45 static int use_delay = 1 ;
46 static int use_display = 0 ;
47 static int use_speed = 0 ;
48
49
50 GtkWidget* fs = NULL ;
51 gchar *global_filename;
52 gchar *display_string ;
53 extern xnee_data *xd ;
54
55 enum {
56 PNEE_FILE_NONE ,
57 PNEE_FILE_RECORD ,
58 PNEE_FILE_REPLAY ,
59 PNEE_FILE_VERBOSE
60 } pnee_files;
61
62
63 int file_choosen = PNEE_FILE_NONE;
64 extern GtkWidget *my_err_dial;
65
66
67 char *
pnee_get_default_filename(void)68 pnee_get_default_filename(void)
69 {
70 char *tmp_dir = NULL;
71 char *user_name = NULL;
72
73 const char *default_tmp_dir = "/tmp/";
74 const char *default_user_name = "user";
75 const char *file_prefix = "pnee_";
76 const char *file_suffix = ".xns";
77
78 char *ret_str;
79 int size = 0 ;
80
81 XNEE_VERBOSE_ENTER_FUNCTION();
82
83 /* set the dir */
84 tmp_dir = getenv("TMPIR");
85 if (tmp_dir==NULL)
86 {
87 tmp_dir= (char *) default_tmp_dir;
88 }
89
90 /* set the user name */
91 user_name = getlogin();
92 if (user_name==NULL)
93 {
94 user_name= getenv("USER");
95 }
96 if (user_name==NULL)
97 {
98 user_name = (char *) default_user_name;
99 }
100
101 #define PNEE_CHECK_CHAR_PTR(a) { if ( a==NULL) { fprintf(stderr, "Couldn't put together default file name\n") ; return NULL; } }
102 PNEE_CHECK_CHAR_PTR(tmp_dir);
103 PNEE_CHECK_CHAR_PTR(user_name);
104 PNEE_CHECK_CHAR_PTR(file_prefix);
105 PNEE_CHECK_CHAR_PTR(file_suffix);
106
107 size = strlen (tmp_dir) +
108 strlen (user_name) +
109 strlen (file_prefix) +
110 strlen (file_suffix) ;
111
112 if (size <= 0 )
113 {
114 fprintf (stderr, "Trying to allocate size %d\n", size);
115 return NULL;
116 }
117 ret_str = (char*) malloc (size*sizeof(char));
118 if (ret_str==NULL)
119 {
120 return NULL;
121 }
122
123 strncpy (ret_str, tmp_dir, size);
124 strncat (ret_str, file_prefix, size - strlen(ret_str));
125 strncat (ret_str, user_name, size - strlen(ret_str));
126 strncat (ret_str, file_suffix, size - strlen(ret_str));
127 return ret_str;
128 }
129
130
131 char *
pnee_get_default_err_name(void)132 pnee_get_default_err_name(void)
133 {
134 char *tmp_dir = NULL;
135 char *user_name = NULL;
136
137 const char *default_tmp_dir = "/tmp/";
138 const char *default_user_name = "user";
139 const char *file_prefix = "pnee_";
140 const char *file_suffix = ".err";
141
142 char *ret_str;
143 int size = 0 ;
144
145 XNEE_VERBOSE_ENTER_FUNCTION();
146
147 /* set the dir */
148 tmp_dir = getenv("TMPIR");
149 if (tmp_dir==NULL)
150 {
151 tmp_dir= (char *) default_tmp_dir;
152 }
153
154 /* set the user name */
155 user_name = getlogin();
156 if (user_name==NULL)
157 {
158 user_name= getenv("USER");
159 }
160 if (user_name==NULL)
161 {
162 user_name = (char *) default_user_name;
163 }
164
165 size = strlen (tmp_dir) +
166 strlen (user_name) +
167 strlen (file_prefix) +
168 strlen (file_suffix) ;
169
170 ret_str = (char*) malloc (size*sizeof(char));
171 if (ret_str==NULL)
172 {
173 return NULL;
174 }
175
176 strncpy (ret_str, tmp_dir, size);
177 strncat (ret_str, file_prefix, size - strlen(ret_str));
178 strncat (ret_str, user_name, size - strlen(ret_str));
179 strncat (ret_str, file_suffix, size - strlen(ret_str));
180 return ret_str;
181 }
182
183
184 void
pnee_set_rec_file(char * filename)185 pnee_set_rec_file(char *filename)
186 {
187 GtkEntry *file_text ;
188
189 XNEE_VERBOSE_ENTER_FUNCTION();
190
191 file_text = (GtkEntry*) lookup_widget(GTK_WIDGET(pnee_applet->pnee_pref),
192 "entry3");
193 xnee_verbose((xd, " setting filename to gui: %s\n", filename));
194 gtk_entry_set_text (file_text,
195 filename);
196
197 xnee_verbose((xd, " setting filename in xd: %s\n", filename));
198 xnee_set_out_name (xd, filename);
199
200 XNEE_VERBOSE_LEAVE_FUNCTION();
201 }
202
203 void
pnee_set_rep_file(char * filename)204 pnee_set_rep_file(char *filename)
205 {
206 GtkFileChooserButton *file_text ;
207 XNEE_VERBOSE_ENTER_FUNCTION();
208
209
210 if (filename!=NULL)
211 {
212 _IN;
213 file_text = (GtkFileChooserButton*) lookup_widget(GTK_WIDGET(pnee_applet->pnee_pref),
214 "rep_choose_but");
215 _OUT;
216 _IN;
217 gtk_file_chooser_set_filename(GTK_FILE_CHOOSER(file_text),
218 filename);
219 _OUT;
220
221 xnee_verbose((xd, " setting date name to:%s\n", filename));
222 xnee_set_data_name (xd, filename);
223 }
224
225 XNEE_VERBOSE_LEAVE_FUNCTION();
226 }
227
228
229
230 void
pnee_set_err_file(char * filename)231 pnee_set_err_file(char *filename)
232 {
233 GtkFileChooserButton *file_text ;
234
235
236 XNEE_VERBOSE_ENTER_FUNCTION();
237
238 file_text = (GtkEntry*) lookup_widget(GTK_WIDGET(pnee_applet->pnee_pref),
239 "log_entry");
240
241 if (file_text!=NULL)
242 {
243 xnee_verbose((xd, " setting filename to gui: %s\n", filename));
244 gtk_entry_set_text (file_text,
245 filename);
246
247 xnee_verbose((xd, " setting (err) filename in xd: %s\n", filename));
248 xnee_set_err_name (xd, filename);
249 }
250 else
251 {
252 xnee_verbose((xd, "Failed to get text entry for ERROR\n"));
253 }
254
255 XNEE_VERBOSE_LEAVE_FUNCTION();
256 }
257
258
259
260 void
on_setting_ok_clicked(GtkButton * button,gpointer user_data)261 on_setting_ok_clicked (GtkButton *button,
262 gpointer user_data)
263 {
264 XNEE_VERBOSE_ENTER_FUNCTION();
265 gtk_widget_hide (pnee_applet->pnee_pref);
266 XNEE_VERBOSE_LEAVE_FUNCTION();
267 }
268
269
270 void
on_verbose_check_toggled(GtkToggleButton * togglebutton,gpointer user_data)271 on_verbose_check_toggled (GtkToggleButton *togglebutton,
272 gpointer user_data)
273 {
274 XNEE_VERBOSE_ENTER_FUNCTION();
275 if (gtk_toggle_button_get_active(togglebutton))
276 {
277 xnee_set_verbose(xd);
278 XNEE_VERBOSE_IN_FUNCTION("Setting verbose");
279 }
280 else
281 {
282 XNEE_VERBOSE_IN_FUNCTION("Unsetting verbose");
283
284 xnee_unset_verbose(xd);
285 }
286 XNEE_VERBOSE_LEAVE_FUNCTION();
287 }
288
289
290 void
on_display_check_toggled(GtkToggleButton * togglebutton,gpointer user_data)291 on_display_check_toggled (GtkToggleButton *togglebutton,
292 gpointer user_data)
293 {
294 XNEE_VERBOSE_ENTER_FUNCTION();
295
296 if (gtk_toggle_button_get_active(togglebutton))
297 {
298 xnee_set_display_name(xd, display_string);
299 XNEE_VERBOSE_IN_FUNCTION("Setting display");
300 use_display = 1 ;
301 }
302 else
303 {
304 xnee_set_display_name(xd, NULL);
305 XNEE_VERBOSE_IN_FUNCTION("Unsetting display (usiong NULL)");
306 use_display = 0 ;
307 }
308
309 XNEE_VERBOSE_LEAVE_FUNCTION();
310 }
311
312
313
314
315 void
pnee_set_interval(GtkToggleButton * togglebutton,gpointer user_data)316 pnee_set_interval (GtkToggleButton *togglebutton,
317 gpointer user_data)
318 {
319 gint delay = 0 ;
320 GtkWidget *window=NULL;
321
322 XNEE_VERBOSE_ENTER_FUNCTION();
323 if ( use_delay )
324 {
325 if (user_data)
326 {
327 window = lookup_widget(user_data, "spinbutton2");
328 }
329 if (window!=NULL)
330 {
331 delay = gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(window));
332 }
333 }
334 else
335 {
336 delay = 0 ;
337 }
338
339 xnee_set_interval (xd, (int)delay) ;
340 xnee_verbose((xd, " -- : setting delay %d\n", delay));
341 xnee_verbose((xd, "=================== Setting delay=%d\n", delay));
342 XNEE_VERBOSE_LEAVE_FUNCTION();
343 return ;
344 }
345
346
347 void
pnee_set_events_to_record(GtkToggleButton * togglebutton,gpointer user_data)348 pnee_set_events_to_record (GtkToggleButton *togglebutton,
349 gpointer user_data)
350 {
351 gint nr = 0 ;
352 GtkWidget *window=NULL;
353
354 XNEE_VERBOSE_ENTER_FUNCTION();
355 if (user_data)
356 {
357 window = lookup_widget(user_data, "spinbutton3");
358 }
359 if (window)
360 {
361 nr = gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(window));
362 xnee_set_events_max (xd, nr) ;
363 xnee_verbose((xd, " -- : setting events to record: %d\n", nr));
364 }
365 XNEE_VERBOSE_LEAVE_FUNCTION();
366 return ;
367 }
368
369 void
pnee_set_speed(GtkToggleButton * togglebutton,gpointer user_data)370 pnee_set_speed (GtkToggleButton *togglebutton,
371 gpointer user_data)
372 {
373 gint speed = 0 ;
374 GtkWidget *window=NULL;
375
376 XNEE_VERBOSE_ENTER_FUNCTION();
377 if (user_data)
378 {
379 window = lookup_widget(user_data, "spinbutton1");
380 }
381 if (window)
382 {
383 speed = gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(window));
384 xnee_set_replay_speed (xd, speed) ;
385 xnee_verbose((xd, " -- : setting replay speed: %d\n", speed));
386 }
387 XNEE_VERBOSE_LEAVE_FUNCTION();
388 return ;
389 }
390
391
392 void
on_delay_check_toggled(GtkToggleButton * togglebutton,gpointer user_data)393 on_delay_check_toggled (GtkToggleButton *togglebutton,
394 gpointer user_data)
395 {
396 XNEE_VERBOSE_ENTER_FUNCTION();
397
398 if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(togglebutton)))
399 {
400 use_delay = 1;
401 pnee_set_interval(NULL, user_data);
402 }
403 else
404 {
405 xnee_verbose((xd, " --on_delay_check_toggled: setting default 0\n"));
406 use_delay = 0;
407 xnee_verbose((xd, "***** 346 delay=%d", 0));
408 xnee_set_interval (xd, 0) ;
409 }
410
411 XNEE_VERBOSE_LEAVE_FUNCTION();
412 return;
413 }
414
415 void
on_speed_check_toggled(GtkToggleButton * togglebutton,gpointer user_data)416 on_speed_check_toggled (GtkToggleButton *togglebutton,
417 gpointer user_data)
418 {
419 XNEE_VERBOSE_ENTER_FUNCTION();
420
421 if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(togglebutton)))
422 {
423 use_speed = 1;
424 pnee_set_speed(togglebutton, user_data);
425 }
426 else
427 {
428 xnee_verbose((xd, " --on_delay_check_toggled: setting default speed 100 \n"));
429 use_speed = 0;
430 xnee_set_replay_speed (xd, 100) ;
431 }
432
433 XNEE_VERBOSE_LEAVE_FUNCTION();
434 }
435
436
437 void
on_feedback_button_toggled(GtkToggleButton * togglebutton,gpointer user_data)438 on_feedback_button_toggled (GtkToggleButton *togglebutton,
439 gpointer user_data)
440 {
441 XNEE_VERBOSE_ENTER_FUNCTION();
442 XNEE_VERBOSE_LEAVE_FUNCTION();
443
444 }
445
446
447 void
on_faked_rec_clicked(GtkButton * button,gpointer user_data)448 on_faked_rec_clicked (GtkButton *button,
449 gpointer user_data)
450 {
451 XNEE_VERBOSE_ENTER_FUNCTION();
452 pnee_rec_pressed();
453 XNEE_VERBOSE_LEAVE_FUNCTION();
454 }
455
456
457 void
on_faked_rep_clicked(GtkButton * button,gpointer user_data)458 on_faked_rep_clicked (GtkButton *button,
459 gpointer user_data)
460 {
461 XNEE_VERBOSE_ENTER_FUNCTION();
462 pnee_rep_pressed();
463 XNEE_VERBOSE_LEAVE_FUNCTION();
464 }
465
466
467 void
on_spinbutton2_change_value(GtkSpinButton * spinbutton,gpointer user_data)468 on_spinbutton2_change_value (GtkSpinButton *spinbutton,
469 gpointer user_data)
470 {
471 XNEE_VERBOSE_ENTER_FUNCTION();
472 pnee_set_interval(NULL, user_data);
473 XNEE_VERBOSE_LEAVE_FUNCTION();
474
475 }
476
477
478 void
on_spinbutton3_value_changed(GtkSpinButton * spinbutton,gpointer user_data)479 on_spinbutton3_value_changed (GtkSpinButton *spinbutton,
480 gpointer user_data)
481 {
482 XNEE_VERBOSE_ENTER_FUNCTION();
483 pnee_set_events_to_record(NULL, user_data);
484 XNEE_VERBOSE_LEAVE_FUNCTION();
485 }
486
487
488 void
on_spinbutton1_value_changed(GtkSpinButton * spinbutton,gpointer user_data)489 on_spinbutton1_value_changed (GtkSpinButton *spinbutton,
490 gpointer user_data)
491 {
492 XNEE_VERBOSE_ENTER_FUNCTION();
493 pnee_set_speed(NULL, user_data);
494 XNEE_VERBOSE_LEAVE_FUNCTION();
495 }
496
497
498 void
on_rec_file_button_clicked(GtkButton * button,gpointer user_data)499 on_rec_file_button_clicked (GtkButton *button,
500 gpointer user_data)
501 {
502 XNEE_VERBOSE_ENTER_FUNCTION();
503 gtk_file_chooser_set_action (GTK_FILE_CHOOSER(fs),GTK_FILE_CHOOSER_ACTION_SAVE);
504 gtk_widget_show (fs);
505 file_choosen=PNEE_FILE_RECORD;
506 XNEE_VERBOSE_LEAVE_FUNCTION();
507 }
508
509
510 void
on_rep_file_button_clicked(GtkButton * button,gpointer user_data)511 on_rep_file_button_clicked (GtkButton *button,
512 gpointer user_data)
513 {
514 XNEE_VERBOSE_ENTER_FUNCTION();
515 gtk_file_chooser_set_action (GTK_FILE_CHOOSER(fs),GTK_FILE_CHOOSER_ACTION_OPEN);
516 gtk_widget_show (fs);
517 file_choosen=PNEE_FILE_REPLAY;
518 XNEE_VERBOSE_LEAVE_FUNCTION();
519 }
520
521
522 void
on_f_cancel_button_clicked(GtkButton * button,gpointer user_data)523 on_f_cancel_button_clicked (GtkButton *button,
524 gpointer user_data)
525 {
526 XNEE_VERBOSE_ENTER_FUNCTION();
527 gtk_widget_hide (fs);
528 XNEE_VERBOSE_LEAVE_FUNCTION();
529 file_choosen=PNEE_FILE_NONE;
530 }
531
532
533 void
on_f_ok_button_clicked(GtkButton * button,gpointer user_data)534 on_f_ok_button_clicked (GtkButton *button,
535 gpointer user_data)
536 {
537 XNEE_VERBOSE_ENTER_FUNCTION();
538 gtk_widget_hide (fs);
539
540 global_filename = strdup(gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(fs)));
541 if ( file_choosen == PNEE_FILE_RECORD )
542 {
543 XNEE_VERBOSE_IN_FUNCTION("got rec file ");
544 xnee_verbose((xd, "rec file: %s\n", GCHAR_TO_CHAR(global_filename)));
545 xnee_set_out_name (xd, GCHAR_TO_CHAR(global_filename));
546 pnee_set_rec_file (GCHAR_TO_CHAR(global_filename));
547 }
548 else if ( file_choosen == PNEE_FILE_REPLAY )
549 {
550 XNEE_VERBOSE_IN_FUNCTION("got rep file ");
551 xnee_set_data_name(xd, GCHAR_TO_CHAR(global_filename));
552 pnee_set_rep_file (GCHAR_TO_CHAR(global_filename));
553 }
554 else if ( file_choosen == PNEE_FILE_VERBOSE )
555 {
556 XNEE_VERBOSE_IN_FUNCTION("got verbose file ");
557 xnee_set_err_name(xd, GCHAR_TO_CHAR(global_filename));
558
559 pnee_set_err_file (GCHAR_TO_CHAR(global_filename));
560 xnee_open_err_file(xd);
561 }
562 else
563 {
564 XNEE_VERBOSE_IN_FUNCTION("que?? ");
565 }
566
567 XNEE_VERBOSE_LEAVE_FUNCTION();
568 }
569
570
571 void
on_entry2_editing_done(GtkEditable * editable,gpointer user_data)572 on_entry2_editing_done (GtkEditable *editable,
573 gpointer user_data)
574 {
575 /* replay */
576 XNEE_VERBOSE_ENTER_FUNCTION();
577
578 global_filename = GCHAR_TO_CHAR(gtk_entry_get_text (GTK_ENTRY(user_data)));
579 xnee_verbose((xd, "replay file changed to: %s\n", global_filename));
580 xnee_set_data_name (xd, global_filename);
581
582 XNEE_VERBOSE_LEAVE_FUNCTION();
583
584 }
585
586
587 void
on_entry3_editing_done(GtkEditable * editable,gpointer user_data)588 on_entry3_editing_done (GtkEditable *editable,
589 gpointer user_data)
590 {
591 /* record */
592 XNEE_VERBOSE_ENTER_FUNCTION();
593
594 global_filename = GCHAR_TO_CHAR(gtk_entry_get_text (GTK_ENTRY(user_data)));
595 xnee_verbose((xd, "record file changed to: %s\n", global_filename));
596 xnee_set_out_name (xd, global_filename);
597
598 XNEE_VERBOSE_LEAVE_FUNCTION();
599
600 }
601
602
603 void
on_entry4_changed(GtkEditable * editable,gpointer user_data)604 on_entry4_changed (GtkEditable *editable,
605 gpointer user_data)
606 {
607 XNEE_VERBOSE_ENTER_FUNCTION();
608 display_string = GCHAR_TO_CHAR(gtk_entry_get_text (GTK_ENTRY(user_data)));
609 xnee_verbose((xd, "display: %s\n", display_string));
610
611 xnee_set_display_name(xd, display_string);
612
613 XNEE_VERBOSE_LEAVE_FUNCTION();
614 }
615
616
617 void
on_verbose_f_sel_clicked(GtkButton * button,gpointer user_data)618 on_verbose_f_sel_clicked (GtkButton *button,
619 gpointer user_data)
620 {
621 XNEE_VERBOSE_ENTER_FUNCTION();
622 file_choosen=PNEE_FILE_VERBOSE;
623 gtk_widget_show (fs);
624 XNEE_VERBOSE_LEAVE_FUNCTION();
625 }
626
627
628 void
on_use_display_ok_clicked(GtkButton * button,gpointer user_data)629 on_use_display_ok_clicked (GtkButton *button,
630 gpointer user_data)
631 {
632
633 }
634
635
636 void
on_entry1_changed(GtkEditable * editable,gpointer user_data)637 on_entry1_changed (GtkEditable *editable,
638 gpointer user_data)
639 {
640 char * my_string;
641 XNEE_VERBOSE_ENTER_FUNCTION();
642
643 my_string = GCHAR_TO_CHAR(gtk_entry_get_text (GTK_ENTRY(user_data)));
644 xnee_verbose((xd, "verbose file: %s\n", my_string));
645
646 xnee_set_err_name(xd, my_string);
647
648 XNEE_VERBOSE_LEAVE_FUNCTION();
649
650 }
651
652
653 void
on_entry5_changed(GtkEditable * editable,gpointer user_data)654 on_entry5_changed (GtkEditable *editable,
655 gpointer user_data)
656 {
657 char * my_key;
658 XNEE_VERBOSE_ENTER_FUNCTION();
659 my_key = GCHAR_TO_CHAR(gtk_entry_get_text (GTK_ENTRY(user_data)));
660 xnee_verbose((xd, "stop file: %s\n", my_key));
661
662 xnee_set_key (xd, XNEE_GRAB_STOP, my_key);
663
664 XNEE_VERBOSE_LEAVE_FUNCTION();
665
666 }
667
668
669 void
on_f_c_button_clicked(GtkButton * button,gpointer user_data)670 on_f_c_button_clicked (GtkButton *button,
671 gpointer user_data)
672 {
673 XNEE_VERBOSE_ENTER_FUNCTION();
674 gtk_widget_hide (fs);
675 XNEE_VERBOSE_LEAVE_FUNCTION();
676 }
677
678
679 void
on_f_open_button_clicked(GtkButton * button,gpointer user_data)680 on_f_open_button_clicked (GtkButton *button,
681 gpointer user_data)
682 {
683 gchar * my_file;
684 XNEE_VERBOSE_ENTER_FUNCTION();
685
686 gtk_widget_hide (fs);
687 my_file = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER(fs));
688
689 XNEE_VERBOSE_IN_FUNCTION(my_file);
690
691 on_f_ok_button_clicked(NULL,NULL);
692
693 XNEE_VERBOSE_LEAVE_FUNCTION();
694 }
695
696
697 void
on_rec_chooser_but_file_activated(GtkFileChooser * filechooser,gpointer user_data)698 on_rec_chooser_but_file_activated (GtkFileChooser *filechooser,
699 gpointer user_data)
700 {
701 XNEE_VERBOSE_ENTER_FUNCTION();
702 gtk_widget_hide (fs);
703 XNEE_VERBOSE_LEAVE_FUNCTION();
704 }
705
706
707 void
on_rep_choose_but_file_activated(GtkFileChooser * filechooser,gpointer user_data)708 on_rep_choose_but_file_activated (GtkFileChooser *filechooser,
709 gpointer user_data)
710 {
711 gchar * my_file;
712 XNEE_VERBOSE_ENTER_FUNCTION();
713
714 my_file = gtk_file_chooser_get_filename (user_data);
715
716 if (my_file!=NULL)
717 {
718 xnee_set_data_name (xd, my_file);
719 }
720
721 XNEE_VERBOSE_LEAVE_FUNCTION();
722 }
723
724
725
726 void
pnee_stop_pressed(void)727 pnee_stop_pressed(void)
728 {
729 pthread_create (&pnee_applet->xnee_thread,
730 NULL,
731 pnee_stop_pressed_impl,
732 pnee_applet);
733 return;
734 }
735
736
737
738 void
pnee_rec_pressed(void)739 pnee_rec_pressed(void)
740 {
741
742 sem_wait (&pnee_applet->action_mutex);
743
744 if (!pnee_is_ready(pnee_applet))
745 {
746
747 sem_post (&pnee_applet->action_mutex);
748 return;
749 }
750
751
752 pnee_set_recording(pnee_applet);
753
754 pnee_2xnee_update_all();
755
756 sem_post (&pnee_applet->action_mutex);
757
758 pthread_create (&pnee_applet->xnee_thread,
759 NULL,
760 pnee_start_recording,
761 pnee_applet);
762 return;
763 }
764
765 void
pnee_rep_pressed(void)766 pnee_rep_pressed(void)
767 {
768 sem_wait (&pnee_applet->action_mutex);
769
770 if (!pnee_is_ready(pnee_applet))
771 {
772
773 sem_post (&pnee_applet->action_mutex);
774 return;
775 }
776
777 pnee_set_replaying(pnee_applet);
778
779 pnee_2xnee_update_all();
780
781 sem_post (&pnee_applet->action_mutex);
782
783 pthread_create (&pnee_applet->xnee_thread,
784 NULL,
785 pnee_start_replaying,
786 pnee_applet);
787 return;
788 }
789
790
791 void
on_log_file_button_clicked(GtkButton * button,gpointer user_data)792 on_log_file_button_clicked (GtkButton *button,
793 gpointer user_data)
794 {
795 XNEE_VERBOSE_ENTER_FUNCTION();
796
797 gtk_file_chooser_set_action (GTK_FILE_CHOOSER(fs),
798 GTK_FILE_CHOOSER_ACTION_SAVE);
799 gtk_widget_show (fs);
800 file_choosen=PNEE_FILE_VERBOSE;
801
802 XNEE_VERBOSE_LEAVE_FUNCTION();
803 }
804
805
806 void
on_error_ok_clicked(GtkButton * button,gpointer user_data)807 on_error_ok_clicked (GtkButton *button,
808 gpointer user_data)
809 {
810 gtk_widget_hide (my_err_dial);
811 }
812
813
814 void
on_pnee_about_response(GtkDialog * dialog,gint response_id,gpointer user_data)815 on_pnee_about_response (GtkDialog *dialog,
816 gint response_id,
817 gpointer user_data)
818 {
819 GtkWidget *window = user_data;
820
821 if (window != NULL )
822 {
823 gtk_widget_hide (window);
824 }
825
826 }
827
828