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 
26 #include <pnee_impl.h>
27 #include <interface.h>
28 #include <support.h>
29 #include <callbacks.h>
30 #include "pnee_types.h"
31 
32 xnee_data *xd;
33 extern pnee_panel_applet *pnee_applet;
34 
35 #define PNEE_DELAY_RECORD 0
36 #define PNEE_DELAY_REPLAY 1
37 
38 GtkWidget *my_delay;
39 GtkWidget *my_del_progr_win;
40 GtkWidget *my_delay_progr;
41 GtkWidget *my_delay_label;
42 GtkWidget *my_err_dial;
43 
44 static int
pnee_handle_err(xnee_data * xd,int error)45 pnee_handle_err(xnee_data *xd, int error)
46 {
47   const char *err;
48   const char *descr;
49 
50   if ( ( error != XNEE_OK ) &&
51        ( error != XNEE_OK_LEAVE ) )
52     {
53       err   = xnee_get_err_description(error);
54       descr = xnee_get_err_solution(error);
55 
56       fprintf (stderr, "Error number: %d\n", error);
57       fprintf (stderr, "  Error:      %s\n", err);
58       fprintf (stderr, "  Solution:   %s\n", descr);
59     }
60   return XNEE_OK;
61 }
62 
63 GtkWidget *
create_delay_splash_impl(void)64 create_delay_splash_impl (void)
65 {
66 
67   _IN;
68   my_delay = gtk_window_new (GTK_WINDOW_POPUP);
69   gtk_container_set_border_width (GTK_CONTAINER (my_delay), 3);
70   gtk_window_set_title (GTK_WINDOW (my_delay), "pnee delay");
71   gtk_window_set_position (GTK_WINDOW (my_delay), GTK_WIN_POS_CENTER);
72   _OUT;
73 
74   _IN;
75   my_del_progr_win = gtk_vbox_new (FALSE, 0);
76   gtk_widget_show (my_del_progr_win);
77   gtk_container_add (GTK_CONTAINER (my_delay), my_del_progr_win);
78   _OUT;
79 
80   _IN;
81   my_delay_label = gtk_label_new ("Pnee - a GNU Xnee Applet");
82   gtk_widget_show (my_delay_label);
83   gtk_box_pack_start (GTK_BOX (my_del_progr_win), my_delay_label, FALSE,
84 		      FALSE, 0);
85   /*   gtk_label_set_text (GTK_LABEL (my_delay_progr), "Delayd start of pnee"); */
86   _OUT;
87 
88   _IN;
89   my_delay_progr = gtk_progress_bar_new ();
90   gtk_widget_show (my_delay_progr);
91   gtk_box_pack_start (GTK_BOX (my_del_progr_win), my_delay_progr, FALSE,
92 		      FALSE, 0);
93   gtk_progress_bar_set_text (GTK_PROGRESS_BAR (my_delay_progr),
94 			     "Delayd start of pnee");
95   _OUT;
96 
97 
98   /* Store pointers to all widgets, for use by lookup_widget(). */
99   /*
100      GLADE_HOOKUP_OBJECT_NO_REF (my_delay, my_delay, "delay");
101      GLADE_HOOKUP_OBJECT (my_delay, my_del_progr_win, "del_progr_win");
102      GLADE_HOOKUP_OBJECT (my_delay, my_delay_progr, "delay_progr");
103    */
104   return my_delay;
105 }
106 
107 void
create_delay_splash(void)108 create_delay_splash (void)
109 {
110   if (my_delay == NULL)
111     {
112       create_delay_splash_impl ();
113     }
114 }
115 
116 
117 void
delay_start(int mode)118 delay_start (int mode)
119 {
120   gdouble perc;
121   char buf[100];
122   int delay_time ;
123   int delay_time_start;
124 
125   pnee_set_interval(NULL, pnee_applet->pnee_pref);
126 
127   delay_time = xnee_get_interval (xd) ;
128   delay_time_start = delay_time;
129 
130   xnee_verbose((xd, " ============================================================ delay: %d\n",
131 	  delay_time));
132 
133   xnee_verbose((xd, "  ****** %s:%d       delay %d  \n", __FILE__, __LINE__, xnee_get_interval(pnee_applet->xd)));
134   create_delay_splash ();
135   _IN;
136   gtk_widget_show_all (my_delay);
137   _OUT;
138 
139   while (delay_time != 0)
140     {
141       if (!pnee_is_recording (pnee_applet) &&
142 	  !pnee_is_replaying (pnee_applet))
143 	{
144 	  xnee_verbose((xd, "Action interrupted ...., leaving start\n"));
145 	  _IN;
146 	  gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR (my_delay_progr),
147 					 0.0);
148 	  _OUT;
149 
150 	  xnee_verbose((xd, "  ****** %s:%d       delay %d  \n", __FILE__, __LINE__, xnee_get_interval(pnee_applet->xd)));
151 	  return;
152 	}
153 
154       perc = (gdouble) delay_time / (gdouble) delay_time_start;
155       if (mode == PNEE_DELAY_RECORD)
156 	{
157 	  sprintf (buf, "Starting to record in %d seconds", delay_time);
158 	}
159       else
160 	{
161 	  sprintf (buf, "Starting to replay in %d seconds", delay_time);
162 	}
163 
164 
165 
166       xnee_verbose((xd, "  delay_start->\n"));
167       sem_wait (&pnee_applet->update_mutex);
168       xnee_verbose((xd, "  delay_start -- %u\n", (int) my_delay_progr));
169       _IN;
170       gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR (my_delay_progr), perc);
171       gtk_progress_bar_set_text (GTK_PROGRESS_BAR (my_delay_progr), buf);
172       _OUT;
173       xnee_verbose((xd, "  delay_start -- \n"));
174       sem_post (&pnee_applet->update_mutex);
175       xnee_verbose((xd, "  <-delay_start\n"));
176 
177       usleep (1000 * 1000);
178       delay_time--;
179     }
180 
181   _IN;
182   gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR (my_delay_progr), 0.0);
183   _OUT;
184 
185   _IN;
186   gtk_widget_hide_all (my_delay);
187   _OUT;
188   xnee_verbose((xd, "  ****** %s:%d       delay %d  \n", __FILE__, __LINE__, xnee_get_interval(pnee_applet->xd)));
189   xnee_set_interval(xd, 0);
190   return;
191 }
192 
193 
194 
195 
196 PTHREAD_RETURN_VAL
pnee_start_recording(void * pnee_applet_in)197 pnee_start_recording (void *pnee_applet_in)
198 {
199   int ret;
200 
201   pnee_panel_applet *pa = (pnee_panel_applet *) pnee_applet_in;
202 
203   create_delay_splash ();
204 
205   DEBUG_MARK();
206 
207   pnee_set_recording (pa);
208   pnee_set_update_no_action (pa);
209 
210   pnee_set_events_to_record(NULL, pnee_applet_in);
211   xnee_set_events_recorded(pa->xd,0);
212   pnee_prepare_record ();
213 
214   xnee_verbose((xd, "\n\n\n ********** RECORDING SETTINGS ******** \n\n\n"));
215   xnee_print_ranges(pa->xd, stderr);
216   xnee_print_xnee_settings(pa->xd, stderr);
217 
218   pnee_set_interval(NULL, pa->pnee_pref);
219   delay_start (PNEE_DELAY_RECORD);
220 
221   xnee_verbose((xd, "\n\n\n ********** SET RECORDER ******** \n\n\n"));
222 
223   ret = xnee_set_recorder (pa->xd);
224   if ( ( ret != XNEE_OK) &&  ( ret != XNEE_OK_LEAVE) )
225     {
226       pnee_handle_err(xd, ret);
227     }
228   xnee_verbose((xd, "\n\n\n ********** START RECORDING ******** \n\n\n"));
229 
230   ret = xnee_start (pa->xd);
231 
232 
233   xnee_verbose((xd, "\n\n\n ********** FINISHED RECORDING ******** \n\n\n"));
234 
235   if ( ( ret != XNEE_OK) &&  ( ret != XNEE_OK_LEAVE) )
236     {
237       pnee_handle_err(xd, ret);
238     }
239   xnee_verbose((xd, "\n\n\n ********** STOPED RECORDING  (%d) ******** \n\n\n", ret));
240   DEBUG_MARK();
241 
242   pnee_set_no_action (pa);
243   PTHREAD_RETURN;
244 }
245 
246 
247 void
pnee_display_error(int err_nr)248 pnee_display_error(int err_nr)
249 {
250   GtkLabel   *my_text;
251 #define GNEE_BUF_SIZE 8
252   gchar buf[GNEE_BUF_SIZE];
253   const char *str_ptr = NULL;
254 
255   if (my_err_dial==NULL)
256     {
257       my_err_dial = create_error_dialog();
258     }
259 
260   /* number field */
261   my_text = (GtkLabel *)
262     lookup_widget (my_err_dial, "err_nr_label");
263   snprintf (buf, GNEE_BUF_SIZE, "%d", err_nr);
264   gtk_label_set_text(my_text,buf);
265 
266   /* description field */
267   my_text = (GtkLabel *)
268     lookup_widget (my_err_dial, "err_descr_label");
269   if (my_text!=NULL)
270     {
271       str_ptr = xnee_get_err_description(err_nr);
272       if (str_ptr!=NULL)
273 	{
274 	  gtk_label_set_text(my_text,str_ptr);
275 	}
276     }
277 
278   /* solution field */
279   my_text = (GtkLabel *)
280     lookup_widget (my_err_dial, "err_sol_label");
281   if (my_text!=NULL)
282     {
283       str_ptr = xnee_get_err_solution(err_nr);
284       if (str_ptr!=NULL)
285 	{
286 	  gtk_label_set_text(my_text,str_ptr);
287 	}
288     }
289 
290   gtk_widget_show (my_err_dial);
291 }
292 
293 PTHREAD_RETURN_VAL
pnee_start_replaying(void * pnee_applet_in)294 pnee_start_replaying (void *pnee_applet_in)
295 {
296   int ret;
297 
298   pnee_panel_applet *pa = (pnee_panel_applet *) pnee_applet_in;
299 
300   create_delay_splash ();
301 
302 
303   pnee_set_replaying (pa);
304   pnee_set_update_no_action (pa);
305 
306   pnee_prepare_replay ();
307 
308   delay_start (PNEE_DELAY_REPLAY);
309 
310   ret = xnee_start (pa->xd);
311 
312   if (ret!=XNEE_OK)
313     {
314       xnee_verbose((xd, "xnee_start failed :(\n"));
315       pnee_display_error(ret);
316     }
317 
318   pnee_set_no_action (pa);
319 
320   PTHREAD_RETURN;
321 }
322 
323 
324 PTHREAD_RETURN_VAL
pnee_progress_updater(void * pnee_applet_in)325 pnee_progress_updater (void *pnee_applet_in)
326 {
327   gint max;
328   gint curr;
329   gdouble perc;
330   pnee_panel_applet *pa = (pnee_panel_applet *) pnee_applet_in;
331   static unsigned char do_reset_ctr=0;
332 
333   /*
334      GtkWidget *wid;
335      GdkWindow *win;
336    */
337 
338   while (1)
339     {
340       /* Multiple quick presses on stop button
341        * means reset everything */
342       if (pnee_reset_need_reset(pa))
343 	{
344 	  xnee_verbose((xd, "\tRESETing xnee structure!!!!!\n"));
345 
346 	  /* Dealloc xnee structures */
347 	  xnee_close_down(pa->xd);
348 
349 	  /* Alloc/init new xnee structures */
350 	  pnee_xnee_init(pa);
351 
352 	  /* Zero reset ctr */
353 	  pnee_reset_zero_ctr(pa);
354 	}
355       if (do_reset_ctr++==1)
356 	{
357 	  /* Zero reset ctr */
358 	  pnee_reset_zero_ctr(pa);
359 
360 	  do_reset_ctr=0;
361 	}
362 
363 
364       while (pnee_is_replaying (pa) || pnee_is_recording (pa))
365 	{
366 	  if (pnee_is_replaying (pa))
367 	    {
368 	      pnee_set_update_replaying (pa);
369 	    }
370 	  else if (pnee_is_recording (pa))
371 	    {
372 	      pnee_set_update_recording (pa);
373 	    }
374 
375 	  max = xnee_get_events_max (pa->xd);
376 	  if (pnee_is_replaying (pa))
377 	    {
378 	      curr = xnee_get_events_replayed (pa->xd);
379 	    }
380 	  else
381 	    {
382 	      curr = xnee_get_events_recorded (pa->xd);
383 	    }
384 
385 	  perc = (gdouble) curr / (gdouble) max;
386 
387 	  pnee_update_progress (pa, perc);
388 	  usleep (1000 * 200);
389 
390 
391 	}
392 
393       pnee_set_update_no_action (pa);
394       pnee_update_progress (pa, 0.0);
395       usleep (1000 * 1000);
396     }
397 }
398 
399 int
pnee_update_progress(pnee_panel_applet * pnee_applet_in,double perc)400 pnee_update_progress (pnee_panel_applet * pnee_applet_in, double perc)
401 {
402   if ((pnee_applet_in != 0) && (pnee_applet_in->progress != 0))
403     {
404       sem_wait (&pnee_applet->update_mutex);
405       _IN;
406       gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR
407 				     (pnee_applet_in->progress), perc);
408       _OUT;
409       sem_post (&pnee_applet->update_mutex);
410     }
411   return 0;
412 }
413 
414 
415 
416 
417 
418 
419 
420 
421 
422 
423 
424 
425 
426 
427 
428 
429 void
pnee_create_button(pnee_panel_applet * pnee_applet_in,const gchar * tooltip_str,const gchar * id,GCallback press_callback,pnee_button_type mode)430 pnee_create_button (pnee_panel_applet * pnee_applet_in,
431 		    const gchar * tooltip_str,
432 		    const gchar * id,
433 		    GCallback press_callback, pnee_button_type mode)
434 {
435   GtkWidget *button;
436   GtkWidget *image;
437   GtkTooltips *tooltip;
438 
439   /* Button */
440   button = gtk_button_new ();
441   _IN;
442   gtk_button_set_relief (GTK_BUTTON (button), GTK_RELIEF_HALF);
443   gtk_container_set_border_width (GTK_CONTAINER (button), 0);
444   _OUT;
445 
446   /* Image */
447   _IN;
448   image = gtk_image_new_from_stock (id, pnee_applet->icon_size);
449   tooltip = gtk_tooltips_new ();
450   gtk_widget_show (image);
451   _OUT;
452 
453   /* Tooltip */
454   _IN;
455   gtk_container_add (GTK_CONTAINER (button), image);
456   gtk_tooltips_set_tip (tooltip, button, tooltip_str, NULL);
457   _OUT;
458 
459   /* callback */
460   g_signal_connect (button, "button_press_event",
461 		    G_CALLBACK (cb_button_press), pnee_applet->applet);
462   g_signal_connect (button, "clicked",
463 		    G_CALLBACK (press_callback), pnee_applet);
464 
465   _IN;
466   gtk_widget_show (button);
467   _OUT;
468 
469   if (mode == PNEE_BUTTON_RECORD)
470     {
471       pnee_applet->rec_button = button;
472       pnee_applet->rec_image = image;
473       pnee_applet->rec_tooltip = tooltip;
474     }
475   else if (mode == PNEE_BUTTON_REPLAY)
476     {
477       pnee_applet->rep_button = button;
478       pnee_applet->rep_image = image;
479       pnee_applet->rep_tooltip = tooltip;
480     }
481   else if (mode == PNEE_BUTTON_STOP)
482     {
483       pnee_applet->stop_button = button;
484       pnee_applet->stop_image = image;
485       pnee_applet->stop_tooltip = tooltip;
486     }
487 }
488 
489 
490 int
pnee_handle_xerr(Display * dpy,XErrorEvent * errevent)491 pnee_handle_xerr (Display * dpy, XErrorEvent * errevent)
492 {
493   int ret;
494   /*@out@ */ char tmp[100] = "";
495 
496   if (errevent->type == 0)
497     {
498       return XNEE_OK;
499     }
500   else if (errevent->type == 161)
501     {
502       return XNEE_OK;
503     }
504 
505   fprintf (stderr, "Error received:\n");
506   fprintf (stderr, "\terror type       %u (0x%x)\n",
507 	   errevent->type, errevent->type);
508   fprintf (stderr, "\terror code       %u (0x%x)\n",
509 	   errevent->error_code, errevent->error_code);
510   fprintf (stderr, "\terror code major %u (0x%x)\n",
511 	   errevent->request_code, errevent->request_code);
512   fprintf (stderr, "\terror code minor %u (0x%x)\n",
513 	   errevent->minor_code, errevent->minor_code);
514   fprintf (stderr, "\tdisplay          %d (0x%x)\n",
515 	   (int) dpy, (unsigned int) dpy);
516 
517   ret = XGetErrorText (dpy, (int) errevent->error_code, tmp, 100);
518   fprintf (stderr, " %s\n", (char *) tmp);
519   fprintf (stderr, "This error can be ignored\n");
520 
521   usleep (1000 * 1000);
522 
523   return XNEE_OK;
524 }
525 
526 
527 int
pnee_xnee_init(pnee_panel_applet * pnee_panel_in)528 pnee_xnee_init (pnee_panel_applet * pnee_panel_in)
529 {
530 
531   char *default_tmp_file;
532 /*   char *default_err_file; */
533 
534   default_tmp_file = pnee_get_default_filename ();
535 /*   default_err_file = pnee_get_default_err_name (); */
536 
537   /*  Get a new xnee_data structure  */
538   xd = xnee_new_xnee_data ();
539   pnee_panel_in->xd = xd;
540 
541   (void) XSetErrorHandler (pnee_handle_xerr);
542 
543 /*   xnee_set_verbose (pnee_panel_in->xd); */
544 /*   pnee_set_err_file (default_err_file); */
545   xnee_open_files (pnee_panel_in->xd);
546   xnee_unset_recall_window_pos (pnee_panel_in->xd);
547   xnee_set_events_max (pnee_panel_in->xd, 600);
548   xnee_set_data_max (pnee_panel_in->xd, -1);
549   xnee_set_key (pnee_panel_in->xd, XNEE_GRAB_STOP, "F5");
550 
551 
552   pnee_panel_in->reset=0;
553 
554   /* Set the program name */
555   xnee_set_program_name (pnee_panel_in->xd, "pnee");
556 
557   /* Set the cli parameters */
558   xnee_set_application_parameters (pnee_panel_in->xd, NULL);
559 
560   pnee_set_rec_file (default_tmp_file);
561 
562   pnee_set_rep_file(default_tmp_file);
563 
564   free (default_tmp_file);
565 /*   free (default_err_file); */
566 
567   xnee_verbose((xd, "  ****** %s:%d       delay %d  \n", __FILE__, __LINE__, xnee_get_interval(pnee_applet->xd)));
568   pnee_set_interval(NULL, pnee_panel_in->pnee_pref);
569   xnee_verbose((xd, "  ****** %s:%d       delay %d  \n", __FILE__, __LINE__, xnee_get_interval(pnee_applet->xd)));
570 
571   return XNEE_OK;
572 }
573 
574 
575 
576 
577 int
pnee_setup(pnee_panel_applet * pnee_panel_in)578 pnee_setup (pnee_panel_applet * pnee_panel_in)
579 {
580   static int already_setup = 0;
581 
582   if (already_setup)
583     {
584       return 0;
585     }
586   already_setup = 1;
587 
588   fs = create_filechooserdialog1 ();
589 
590 
591   if (pnee_panel_in->pnee_pref == NULL)
592     {
593       pnee_panel_in->pnee_pref = create_pnee_pref ();
594     }
595 
596   pnee_xnee_init (pnee_panel_in);
597 
598   /* init threads   */
599   gdk_threads_init ();
600   gdk_threads_leave ();
601 
602   return 0;
603 }
604 
605 int
pnee_prepare_record(void)606 pnee_prepare_record (void)
607 {
608   pnee_setup (pnee_applet);
609 
610   pnee_2xnee_update_all();
611 
612   xnee_parse_range (pnee_applet->xd, XNEE_DEVICE_EVENT,
613 		    "KeyPress-MotionNotify");
614   xnee_set_recorder (pnee_applet->xd);
615   pnee_set_interval(NULL, pnee_applet->pnee_pref);
616 
617   return 0;
618 }
619 
620 int
pnee_prepare_replay(void)621 pnee_prepare_replay (void)
622 {
623 /*   gchar *my_file; */
624 
625   pnee_setup (pnee_applet);
626 
627   pnee_2xnee_update_all();
628 
629   xnee_set_replayer (pnee_applet->xd);
630   xnee_unset_sync (pnee_applet->xd);
631   pnee_set_interval(NULL, pnee_applet->pnee_pref);
632 
633   return 0;
634 }
635 
636 
637 
638 
639 
640 
641 
642 PTHREAD_RETURN_VAL
pnee_stop_pressed_impl(void * pnee_applet_in)643 pnee_stop_pressed_impl (void *pnee_applet_in)
644 {
645 /*   gint ev_max; */
646   pnee_panel_applet *pa = (pnee_panel_applet *) pnee_applet_in;
647 
648   pnee_setup (pa);
649 
650   /*
651    * Make sure we are in action,
652    * otherwise we will prevent next cation (only once though)
653    */
654   if (pnee_is_replaying (pa) || pnee_is_recording (pa))
655     {
656       xnee_set_interrupt_action (xd);
657     }
658 
659   pnee_set_no_action (pa);
660   pnee_set_no_action_no_thread (pa);
661   pnee_set_update_no_action (pa);
662 
663   pnee_reset_inc_ctr(pa);
664 
665   _IN;
666   gtk_widget_hide_all (my_delay);
667   _OUT
668 ;
669   PTHREAD_RETURN;
670 }
671 
672 gboolean
cb_button_press(GtkWidget * w,GdkEventButton * event,GtkWidget * applet)673 cb_button_press (GtkWidget * w, GdkEventButton * event, GtkWidget * applet)
674 {
675   if ((event->button == 3) || (event->button == 2))
676     {
677       gtk_propagate_event (applet, (GdkEvent *) event);
678       return TRUE;
679     }
680 
681   return FALSE;
682 }
683 
684 
685 void
register_stock_icons(pnee_panel_applet * pnee_applet_in,GtkIconFactory * factory)686 register_stock_icons (pnee_panel_applet * pnee_applet_in,
687 		      GtkIconFactory * factory)
688 {
689   gint i;
690   static gchar file_name[1024];
691   const gchar *items[] =
692     { "pnee-record.png", "pnee-replay.png", "pnee-stop.png" };
693 
694   for (i = 0; i < sizeof (items) / sizeof (items[0]); ++i)
695     {
696       GdkPixbuf *pixbuf;
697       GtkIconSet *icon_set;
698       GError *error = NULL;
699 
700       sprintf (file_name, "%s/%s", PNEE_PIXDIR, items[i]);
701       pixbuf = gdk_pixbuf_new_from_file (file_name, &error);
702 
703       icon_set = gtk_icon_set_new_from_pixbuf (pixbuf);
704       gtk_icon_factory_add (factory, items[i], icon_set);
705 
706       gtk_icon_set_unref (icon_set);
707       g_object_unref (G_OBJECT (pixbuf));
708     }
709 }
710 
711 
712 void
init_stock_icons(pnee_panel_applet * pnee_applet_in)713 init_stock_icons (pnee_panel_applet * pnee_applet_in)
714 {
715   GtkIconFactory *factory;
716 
717   factory = gtk_icon_factory_new ();
718   gtk_icon_factory_add_default (factory);
719 
720   register_stock_icons (pnee_applet, factory);
721 
722   pnee_applet->icon_size = gtk_icon_size_register ("pnee_icon_size", 5, 5);
723 
724   g_object_unref (factory);
725 }
726 
727 
728 void
display_about_dialog(BonoboUIComponent * component,gpointer user_data,const char * cname)729 display_about_dialog (BonoboUIComponent * component,
730 		      gpointer user_data, const char *cname)
731 {
732   static GtkWidget *pnee_about = NULL;
733 
734   /*
735    * Prevent about to showwhile in action
736    */
737   if (pnee_is_replaying (pnee_applet) || pnee_is_recording (pnee_applet))
738     {
739       xnee_verbose((xd, "************** about blocked "));
740       return;
741     }
742 
743   if (pnee_about == NULL)
744     {
745       pnee_about = create_pnee_about ();
746     }
747 
748   gtk_widget_show (pnee_about);
749 
750 
751   return;
752 }
753 
754 
755 void
display_properties_dialog(BonoboUIComponent * component,gpointer user_data,const char * cname)756 display_properties_dialog (BonoboUIComponent * component,
757 			   gpointer user_data, const char *cname)
758 {
759   /*
760    * Prevent properties to showwhile in action
761    */
762   if (pnee_is_replaying (pnee_applet) || pnee_is_recording (pnee_applet))
763     {
764       xnee_verbose((xd, "*****************  properties blocked "));
765       return;
766     }
767 
768   if (pnee_applet->pnee_pref == NULL)
769     {
770       pnee_applet->pnee_pref = create_pnee_pref ();
771     }
772   gtk_widget_show (pnee_applet->pnee_pref);
773   return;
774 }
775 
776 void
pnee_2xnee_update_err_name(void)777 pnee_2xnee_update_err_name(void)
778 {
779   GtkFileChooserButton *file_text;
780   char *my_file ;
781 
782   file_text =
783     (GtkFileChooserButton *)
784     lookup_widget (GTK_WIDGET (pnee_applet->pnee_pref), "rep_choose_but");
785 
786   my_file = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (file_text));
787   if (my_file != NULL)
788     {
789       xnee_set_data_name (pnee_applet->xd, my_file);
790     }
791 
792 }
793 
794 void
pnee_2xnee_update_out_name(void)795 pnee_2xnee_update_out_name(void)
796 {
797   GtkFileChooserButton *file_text;
798   char *my_file ;
799 
800   file_text =
801     (GtkFileChooserButton *)
802     lookup_widget (GTK_WIDGET (pnee_applet->pnee_pref), "rec_chooser_but");
803 
804   my_file = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (file_text));
805   if (my_file != NULL)
806     {
807       xnee_set_out_name (pnee_applet->xd, my_file);
808     }
809 
810 }
811 
812 void
pnee_2xnee_update_stop_key(void)813 pnee_2xnee_update_stop_key(void)
814 {
815   GtkEntry *entry;
816   char * my_key = NULL;
817 
818   entry =  (GtkEntry *)
819 	lookup_widget (GTK_WIDGET (pnee_applet->pnee_pref), "entry5");
820   if ( entry != NULL)
821     {
822       my_key = GCHAR_TO_CHAR(gtk_entry_get_text (GTK_ENTRY(entry)));
823     }
824   if (my_key!=NULL)
825     {
826       xnee_set_key (xd, XNEE_GRAB_STOP, my_key);
827     }
828 }
829 
830 void
pnee_2xnee_update_all(void)831 pnee_2xnee_update_all(void)
832 {
833 
834 
835   if (xnee_is_replayer(pnee_applet->xd))
836     {
837       /*
838        *    update err file name
839        */
840       pnee_2xnee_update_err_name();
841     }
842   else if (xnee_is_recorder(pnee_applet->xd))
843     {
844       /*
845        *    update out file name
846        */
847       pnee_2xnee_update_err_name();
848     }
849 
850 
851 
852   /*
853    *   update stop key
854    */
855   pnee_2xnee_update_stop_key();
856 
857 }
858 
859 #ifdef PNEE_DEBUGGER
860 PTHREAD_RETURN_VAL
pnee_debugger(void * pnee_applet_in)861 pnee_debugger (void *pnee_applet_in)
862 {
863   pnee_panel_applet *pa = (pnee_panel_applet *) pnee_applet_in;
864 
865   while (1)
866     {
867       xnee_verbose((xd, "  debugger thread:: "));
868       pnee_show_states (pa);
869       usleep (1000 * 1000);
870 
871     }
872   PTHREAD_RETURN;
873 }
874 #endif /* PNEE_DEBUGGER */
875