klavaro  3.13
About: Klavaro is a touch typing tutor program.
  Fossies Dox: klavaro-3.13.tar.bz2  ("unofficial" and yet experimental doxygen-generated source code documentation)  

callbacks.c
Go to the documentation of this file.
1 /**************************************************************************/
2 /* Klavaro - a flexible touch typing tutor */
3 /* Copyright (C) 2005-2021 Felipe Emmanuel Ferreira de Castro */
4 /* */
5 /* This file is part of Klavaro, which is a free software: you can */
6 /* redistribute it and/or modify it under the terms of the GNU General */
7 /* Public License as published by the Free Software Foundation, either */
8 /* version 3 of the License, or (at your option) any later version. */
9 /* */
10 /* Klavaro is distributed in the hope that it will be useful, */
11 /* but WITHOUT ANY WARRANTY; without even the implied warranty of */
12 /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
13 /* GNU General Public License for more details (in the file COPYING). */
14 /* You should have received a copy of the GNU General Public License */
15 /* along with Klavaro. If not, see <https://www.gnu.org/licenses/> */
16 /**************************************************************************/
17 
18 /*
19  * Callbacks for widgets events
20  */
21 #include <string.h>
22 #include <stdlib.h>
23 #include <glib.h>
24 #include <glib/gstdio.h>
25 #include <gtk/gtk.h>
26 #include <gtkdatabox.h>
27 
28 #include "auxiliar.h"
29 #include "main.h"
30 #include "translation.h"
31 #include "keyboard.h"
32 #include "tutor.h"
33 #include "cursor.h"
34 #include "plot.h"
35 #include "basic.h"
36 #include "velocity.h"
37 #include "fluidness.h"
38 #include "accuracy.h"
39 #include "top10.h"
40 #include "callbacks.h"
41 
42 /*
43  * Variables
44  */
45 GtkClipboard *clipboard = NULL;
46 GtkClipboard *clipboard_2 = NULL;
47 
48 extern gchar *KEYB_CUSTOM;
49 extern gchar *KEYB_EDIT;
50 extern gchar *OTHER_DEFAULT;
51 
52 static gboolean callbacks_shield = FALSE;
53 static gboolean mesg_drag_drop = FALSE;
54 static gchar *other_renaming_undo = NULL;
55 
56 void
57 callbacks_shield_set (gboolean state)
58 {
59  callbacks_shield = state;
60 }
61 
62 /**********************************************************************
63  * 1 - Main menu commands
64  **********************************************************************/
65 G_MODULE_EXPORT void
66 on_button_intro_clicked (GtkButton *button, gpointer user_data)
67 {
68  keyb_mode_intro ();
69 }
70 
71 G_MODULE_EXPORT void
72 on_button_basic_clicked (GtkButton *button, gpointer user_data)
73 {
74  window_save ("main");
76 }
77 
78 G_MODULE_EXPORT void
79 on_button_adapt_clicked (GtkButton *button, gpointer user_data)
80 {
81  window_save ("main");
83 }
84 
85 G_MODULE_EXPORT void
86 on_button_velo_clicked (GtkButton *button, gpointer user_data)
87 {
88  window_save ("main");
90 }
91 
92 G_MODULE_EXPORT void
93 on_button_fluid_clicked (GtkButton *button, gpointer user_data)
94 {
95  window_save ("main");
97 }
98 
99 G_MODULE_EXPORT void
100 on_button_about_clicked (GtkButton *button, gpointer user_data)
101 {
102  gtk_widget_show (get_wg ("aboutdialog"));
103 }
104 
105 G_MODULE_EXPORT void
106 on_checkbutton_speech_toggled (GtkToggleButton * togglebutton, gpointer user_data)
107 {
108  if (callbacks_shield)
109  return;
110  main_preferences_set_boolean ("interface", "speech",
111  gtk_toggle_button_get_active (togglebutton));
112 }
113 
114 G_MODULE_EXPORT void
115 on_combobox_language_changed (GtkComboBox *cmb, gpointer user_data)
116 {
117  gchar *tmp;
118  gint active;
119 
120  if (callbacks_shield)
121  return;
122  tmp = gtk_combo_box_text_get_active_text (GTK_COMBO_BOX_TEXT (cmb));
123  trans_change_language (tmp);
124  g_free (tmp);
125 
126  callbacks_shield_set (TRUE);
127  active = gtk_combo_box_get_active (cmb);
128  gtk_combo_box_set_active (GTK_COMBO_BOX (get_wg ("combobox_top10_language")), active);
129  callbacks_shield_set (FALSE);
130 
131  on_combobox_stat_module_changed (GTK_COMBO_BOX (get_wg ("combobox_stat_module")), (gpointer) -1);
132 }
133 
134 G_MODULE_EXPORT void
135 on_combobox_kbd_country_changed (GtkComboBox *cmb, gpointer user_data)
136 {
137  if (callbacks_shield)
138  return;
139  if (keyb_get_name ()) accur_close ();
140  keyb_set_combo_kbd_variant ("combobox_kbd_country", "combobox_kbd_variant");
141  accur_init ();
142  main_preferences_set_string ("tutor", "keyboard", keyb_get_name ());
143 
144  on_combobox_stat_module_changed (GTK_COMBO_BOX (get_wg ("combobox_stat_module")), (gpointer) -1);
145 
146  //g_message ("kbd_country_changed: %s", keyb_get_name ());
147 }
148 
149 G_MODULE_EXPORT void
150 on_combobox_kbd_variant_changed (GtkComboBox *cmb, gpointer user_data)
151 {
152  gchar *tmp;
153 
154  if (callbacks_shield)
155  return;
156 
157  tmp = gtk_combo_box_text_get_active_text (GTK_COMBO_BOX_TEXT (cmb));
158  if (g_str_equal (tmp, KEYB_EDIT))
159  keyb_mode_edit ();
160  else
161  {
162  if (keyb_get_name ()) accur_close ();
163  keyb_update_from_variant ("combobox_kbd_country", "combobox_kbd_variant");
164  accur_init ();
165  main_preferences_set_string ("tutor", "keyboard", keyb_get_name ());
166  }
167  g_free (tmp);
168 
169  on_combobox_stat_module_changed (GTK_COMBO_BOX (get_wg ("combobox_stat_module")), (gpointer) -1);
170 
171  //g_message ("kbd_variant_changed: %s", keyb_get_name ());
172 }
173 
174 G_MODULE_EXPORT void
175 on_window_main_destroy (GtkWidget *obj, gpointer data)
176 {
177  if (callbacks_shield)
178  return;
179 
180  window_save ("main");
181  main_preferences_set_boolean ("interface", "autostart", FALSE);
182 
184 }
185 
186 /**********************************************************************
187  * 2 - Tutor window
188  **********************************************************************/
189 
190 static void
191 cb_color_tag(gchar *tag, gchar *fgcolor, gchar *bgcolor, GtkTextBuffer *tbuf)
192 {
193  gchar *tmp;
194  gchar *color_fg;
195  gchar *color_bg;
196 
197  tmp = g_strconcat (tag, "_fg", NULL);
198  if (main_preferences_exist ("colors", tmp))
199  color_fg = main_preferences_get_string ("colors", tmp);
200  else
201  {
202  color_fg = g_strdup (fgcolor);
203  main_preferences_set_string ("colors", tmp, color_fg);
204  }
205  if (main_altcolor_get_boolean ("colors", "altcolor"))
206  {
207  g_free (color_fg);
208  color_fg = main_altcolor_get_string ("colors", tmp);
209  }
210  g_free (tmp);
211 
212  tmp = g_strconcat (tag, "_bg", NULL);
213  if (main_preferences_exist ("colors", tmp))
214  color_bg = main_preferences_get_string ("colors", tmp);
215  else
216  {
217  color_bg = g_strdup (bgcolor);
218  main_preferences_set_string ("colors", tmp, color_bg);
219  }
220  if (main_altcolor_get_boolean ("colors", "altcolor"))
221  {
222  g_free (color_bg);
223  color_bg = main_altcolor_get_string ("colors", tmp);
224  }
225  g_free (tmp);
226 
227  gtk_text_buffer_create_tag (tbuf, tag,
228  "foreground", color_fg,
229  "background", color_bg,
230  "underline", PANGO_UNDERLINE_NONE, NULL);
231  g_free (color_fg);
232  g_free (color_bg);
233 }
234 
235 G_MODULE_EXPORT void
236 on_text_tutor_realize (GtkWidget * widget, gpointer user_data)
237 {
238  gboolean beep;
239  gchar *tmp;
240  gchar *tmp_font;
241  gchar *search;
242  gchar *color_main_fg;
243  gchar *color_main_bg;
244  GtkWidget *wg;
245  GtkTextBuffer *buf;
246  PangoFontDescription *font_desc;
247  PangoStyle pg_style;
248  PangoWeight pg_weight;
249  gint pg_size;
250  gchar *pg_family;
251  GdkRGBA color;
252  GtkStyleContext *sc;
253  static GtkCssProvider *css;
254 
255  buf = gtk_text_view_get_buffer (GTK_TEXT_VIEW (widget));
256 
257  /* Set main color for tutor text (char_untouched & CIA)
258  */
259  if (main_preferences_exist ("colors", "char_untouched_bg"))
260  color_main_bg = main_preferences_get_string ("colors", "char_untouched_bg");
261  else
262  color_main_bg = g_strdup (TUTOR_CREAM);
263  if (main_preferences_exist ("colors", "char_untouched_fg"))
264  color_main_fg = main_preferences_get_string ("colors", "char_untouched_fg");
265  else
266  color_main_fg = g_strdup (TUTOR_BLACK);
267  /* Check if altcolor applies */
268  if (main_altcolor_get_boolean ("colors", "altcolor") == TRUE)
269  {
270  g_free (color_main_fg);
271  g_free (color_main_bg);
272  color_main_fg = main_altcolor_get_string ("colors", "char_untouched_fg");
273  color_main_bg = main_altcolor_get_string ("colors", "char_untouched_bg");
274  }
275 
276  /* Colors of text on the tutor window (note: ordering here matters, the first tag created is in the bottom!)
277  */
278  gtk_text_buffer_create_tag (buf, "char_keep_wrap",
279  "background", color_main_bg,
280  "foreground", color_main_fg,
281  "underline", PANGO_UNDERLINE_NONE, NULL);
282 
283  /* This second one seems to not be needed. FIXME ?
284  gtk_text_buffer_create_tag (buf, "char_keep_wrap2",
285  "background", color_main_bg,
286  "foreground", color_main_fg,
287  "underline", PANGO_UNDERLINE_NONE, NULL);
288  */
289 
290  cb_color_tag ("char_untouched", TUTOR_BLACK, TUTOR_CREAM, buf);
291  cb_color_tag ("char_wrong", TUTOR_RED, TUTOR_RED_LITE, buf);
292  cb_color_tag ("char_correct", TUTOR_GREEN, TUTOR_CREAM, buf);
293  cb_color_tag ("char_retouched", TUTOR_BROWN, TUTOR_GRAY, buf);
294  cb_color_tag ("cursor_blink", TUTOR_BLUE, TUTOR_YELLOW, buf);
295  cb_color_tag ("cursor_unblink", TUTOR_BLUE_LITE,TUTOR_CREAM, buf);
296  cb_color_tag ("text_intro", TUTOR_BLACK, TUTOR_WHITE, buf);
297 
298  /* Tutor font */
299  tmp_font = main_preferences_get_string ("tutor", "lesson_font");
300  if (tmp_font == NULL)
301  {
302  if (tutor_is_tibetan() || g_str_has_prefix (main_preferences_get_string ("interface", "language"), "bo"))
303  tmp_font = g_strdup (LESSON_FONT_BO);
304  else
305  tmp_font = g_strdup (LESSON_FONT);
306  main_preferences_set_string ("tutor", "lesson_font", tmp_font);
307  }
308  gtk_text_buffer_create_tag (buf, "lesson_font", "font", tmp_font, NULL);
309  gtk_font_chooser_set_font (GTK_FONT_CHOOSER (get_wg ("fontbutton_tutor")), tmp_font);
310 
311  /* Change default font throughout the widget
312  */
313  font_desc = pango_font_description_from_string (tmp_font);
314  g_free (tmp_font);
315  pg_style = pango_font_description_get_style (font_desc);
316  pg_weight = pango_font_description_get_weight (font_desc);
317  pg_size = pango_font_description_get_size (font_desc) / PANGO_SCALE;
318  pg_family = (gchar *) pango_font_description_get_family (font_desc);
319  tmp = g_strdup_printf (".tutor-font {color: %s; font: %s %s %ipt %s;}", color_main_fg,
320  pg_style==PANGO_STYLE_NORMAL?"":"italic",
321  pg_weight>PANGO_WEIGHT_MEDIUM?"bold":"",
322  pg_size, pg_family);
323  css = gtk_css_provider_new ();
324  gtk_css_provider_load_from_data (css, tmp, -1, NULL);
325  sc = gtk_widget_get_style_context (widget);
326  gtk_style_context_add_provider (sc, GTK_STYLE_PROVIDER (css), GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
327  gtk_style_context_add_class (sc, "tutor-font");
328  pango_font_description_free (font_desc);
329  g_free (tmp);
330 
331  g_free (color_main_bg);
332  g_free (color_main_fg);
333 
334  /* Turns on/off the beeps according to preferences
335  */
336  if (main_preferences_exist ("tutor", "tutor_beep"))
337  beep = main_preferences_get_boolean ("tutor", "tutor_beep");
338  else
339  beep = TRUE;
340 
341  tutor_init_goals ();
342 }
343 
344 static void
346 {
347  if (tutor_get_query () == QUERY_END)
348  return;
349 
351  tutor_process_touch (L'\0');
352 }
353 
354 G_MODULE_EXPORT void
355 on_button_tutor_other_clicked (GtkButton * button, gpointer user_data)
356 {
357  GtkWidget *wg;
358  GtkListStore *list;
359 
360  gtk_widget_show (get_wg ("popup_other"));
361 
362  wg = get_wg ("treeview_other");
363  list = GTK_LIST_STORE ( gtk_tree_view_get_model (GTK_TREE_VIEW (wg)) );
364  if (tutor_get_type () == TT_VELO)
365  {
366  if (main_velo_txt ())
367  tutor_load_list_other (".paragraphs", list);
368  else
369  tutor_load_list_other (".words", list);
370  }
371  else if (tutor_get_type () == TT_FLUID)
372  tutor_load_list_other (".paragraphs", list);
373 
374  g_free (other_renaming_undo);
375  other_renaming_undo = g_strdup ("*");
376 }
377 
378 G_MODULE_EXPORT void
379 on_spinbutton_lesson_value_changed (GtkSpinButton * spinbutton, gpointer user_data)
380 {
381  gint tmp_int;
382 
383  if (callbacks_shield)
384  return;
385 
386  if (tutor_get_type () == TT_BASIC)
387  {
389  basic_set_lesson (gtk_spin_button_get_value_as_int (spinbutton));
391  }
392  else if (tutor_get_type () == TT_FLUID)
393  {
394  tmp_int = gtk_spin_button_get_value_as_int (spinbutton);
395  main_preferences_set_int ("tutor", "fluid_paragraphs", tmp_int);
396  }
398  tutor_process_touch (L'\0');
399 }
400 
401 G_MODULE_EXPORT void
402 on_eventbox_lesson_plus (GtkWidget * widget, gpointer user_data)
403 {
404  gint tmp_int;
405  GtkSpinButton *spb;
406 
407  spb = GTK_SPIN_BUTTON (get_wg ("spinbutton_lesson"));
408  tmp_int = gtk_spin_button_get_value_as_int (spb);
409  gtk_spin_button_set_value (spb, tmp_int + 1);
410 }
411 
412 G_MODULE_EXPORT void
413 on_eventbox_lesson_minus (GtkWidget * widget, gpointer user_data)
414 {
415  gint tmp_int;
416  GtkSpinButton *spb;
417 
418  spb = GTK_SPIN_BUTTON (get_wg ("spinbutton_lesson"));
419  tmp_int = gtk_spin_button_get_value_as_int (spb);
420  if (tmp_int > 0)
421  gtk_spin_button_set_value (spb, tmp_int - 1);
422 }
423 
424 G_MODULE_EXPORT void
425 on_eventbox_stat_plus (GtkWidget * widget, gpointer user_data)
426 {
427  gint tmp_int;
428  GtkSpinButton *spb;
429 
430  spb = GTK_SPIN_BUTTON (get_wg ("spinbutton_stat_lesson"));
431  tmp_int = gtk_spin_button_get_value_as_int (spb);
432  gtk_spin_button_set_value (spb, tmp_int + 1);
433 }
434 
435 G_MODULE_EXPORT void
436 on_eventbox_stat_minus (GtkWidget * widget, gpointer user_data)
437 {
438  gint tmp_int;
439  GtkSpinButton *spb;
440 
441  spb = GTK_SPIN_BUTTON (get_wg ("spinbutton_stat_lesson"));
442  tmp_int = gtk_spin_button_get_value_as_int (spb);
443  if (tmp_int > 0)
444  gtk_spin_button_set_value (spb, tmp_int - 1);
445 }
446 
447 G_MODULE_EXPORT void
448 on_button_tutor_stat_clicked (GtkButton * button, gpointer user_data)
449 {
450  gint aux;
451 
452  gtk_combo_box_set_active (GTK_COMBO_BOX (get_wg ("combobox_stat_module")), tutor_get_type ());
453  if (tutor_get_type () == TT_BASIC)
454  {
455  callbacks_shield_set (TRUE);
456  aux = basic_get_lesson () - (basic_get_lesson_increased () ? 1 : 0);
457  aux += (aux == 0) ? 1 : 0;
458  gtk_spin_button_set_value (GTK_SPIN_BUTTON (get_wg ("spinbutton_stat_lesson")), aux);
459  callbacks_shield_set (FALSE);
460  }
461 
462  plot_draw_chart (gtk_combo_box_get_active (GTK_COMBO_BOX (get_wg ("combobox_stat_type"))) + 1);
463  gtk_widget_show (get_wg ("window_stat"));
464 }
465 
466 G_MODULE_EXPORT void
467 on_togglebutton_edit_basic_lesson_toggled (GtkToggleButton * togglebutton, gpointer user_data)
468 {
469  gchar *tmp_name;
470  GtkWidget *wg;
471 
472  wg = get_wg ("entry_custom_basic_lesson");
473  if (gtk_toggle_button_get_active (togglebutton))
474  {
475  callbacks_shield_set (TRUE);
476  gtk_widget_show (wg);
477  gtk_widget_grab_focus (wg);
478 
479  tmp_name = g_ucs4_to_utf8 (basic_get_char_set (), -1, NULL, NULL, NULL);
480  gtk_entry_set_text (GTK_ENTRY (wg), g_strstrip (tmp_name));
481  gtk_editable_set_position (GTK_EDITABLE (wg), -1);
482  g_free (tmp_name);
483 
484  gtk_widget_set_sensitive (get_wg ("spinbutton_lesson"), FALSE);
485  gtk_label_set_text (GTK_LABEL (get_wg ("label_heading")), _("Keys:"));
486  }
487  else
488  {
489  gtk_widget_hide (wg);
490 
491  tmp_name = g_strdup (gtk_entry_get_text (GTK_ENTRY (wg)));
492  if (tutor_get_type () == TT_BASIC)
493  {
494  basic_save_lesson (tmp_name);
495 
498  tutor_process_touch (L'\0');
499 
500  gtk_widget_set_sensitive (get_wg ("spinbutton_lesson"), TRUE);
501  }
502  g_free (tmp_name);
503 
504  callbacks_shield_set (FALSE);
505  gtk_widget_grab_focus (get_wg ("entry_mesg"));
506  }
507 }
508 
509 G_MODULE_EXPORT void
510 on_togglebutton_toomuch_errors_toggled (GtkToggleButton * togglebutton, gpointer user_data)
511 {
512  cb_quick_restart ();
513 }
514 
515 G_MODULE_EXPORT void
516 on_entry_custom_basic_lesson_activate (GtkEntry * entry, gpointer user_data)
517 {
518  GtkWidget *wg;
519 
520  wg = get_wg ("togglebutton_edit_basic_lesson");
521  gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (wg), FALSE);
522 }
523 
524 G_MODULE_EXPORT void
525 on_button_tutor_top10_clicked (GtkButton * button, gpointer user_data)
526 {
527  GtkComboBox *cmb;
528 
529  cmb = GTK_COMBO_BOX (get_wg ("combobox_top10"));
530 
531  if (gtk_combo_box_get_active (cmb) == -1)
532  gtk_combo_box_set_active (cmb, 0);
533 
534  top10_message (NULL);
535 
536  if (gtk_combo_box_get_active (GTK_COMBO_BOX (get_wg ("combobox_top10"))) == 0)
538  else
540 
541  gtk_widget_show (get_wg ("window_top10"));
542 }
543 
544 G_MODULE_EXPORT void
545 on_button_tutor_show_keyb_clicked (GtkButton * button, gpointer user_data)
546 {
547  if (gtk_widget_get_visible (get_wg ("window_hints")))
548  window_save ("hints");
549  keyb_mode_hint ();
550 }
551 
552 G_MODULE_EXPORT void
553 on_fontbutton_tutor_font_set (GtkFontButton * fbut, gpointer user_data)
554 {
555  GtkWidget *wg;
556  GtkTextBuffer *buf;
557  GtkTextTagTable *ttab;
558  GtkTextIter start;
559  GtkTextIter end;
560  gchar *tmp_font;
561 
562  tmp_font = gtk_font_chooser_get_font (GTK_FONT_CHOOSER (fbut));
563  if (tmp_font == NULL)
564  tmp_font = g_strdup (LESSON_FONT);
565  if (strlen (tmp_font) == 0)
566  {
567  g_free (tmp_font);
568  tmp_font = g_strdup (LESSON_FONT);
569  }
570  main_preferences_set_string ("tutor", "lesson_font", tmp_font);
571 
572  wg = get_wg ("text_tutor");
573  buf = gtk_text_view_get_buffer (GTK_TEXT_VIEW (wg));
574  ttab = gtk_text_buffer_get_tag_table (buf);
575  gtk_text_buffer_get_bounds (buf, &start, &end);
576 
577  gtk_text_tag_table_remove (ttab, gtk_text_tag_table_lookup (ttab, "lesson_font"));
578  gtk_text_buffer_create_tag (buf, "lesson_font", "font", tmp_font, NULL);
579  gtk_text_buffer_apply_tag_by_name (buf, "lesson_font", &start, &end);
580 
581  g_free (tmp_font);
582 }
583 
584 G_MODULE_EXPORT void
585 on_togglebutton_altcolor_toggled (GtkToggleButton * togglebutton, gpointer user_data)
586 {
587  gboolean acol;
588 
589  if (callbacks_shield)
590  return;
591 
592  acol = gtk_toggle_button_get_active (togglebutton);
593  main_altcolor_set_boolean ("colors", "altcolor", acol);
594 }
595 
596 G_MODULE_EXPORT void
597 on_togglebutton_tutor_intro_toggled (GtkToggleButton *button, gpointer user_data)
598 {
599  if (callbacks_shield)
600  return;
601 
603  if (gtk_toggle_button_get_active (button))
604  tutor_update ();
605  else
607 }
608 
609 G_MODULE_EXPORT void
610 on_button_tutor_back_clicked (GtkButton *button, gpointer user_data)
611 {
612  window_save ("tutor");
613  if (gtk_widget_get_visible (get_wg ("window_hints")))
614  window_save ("hints");
615  if (gtk_widget_get_visible (get_wg ("window_top10")))
616  window_save ("top10");
617  if (gtk_widget_get_visible (get_wg ("window_stat")))
618  window_save ("stat");
619  gtk_widget_hide (get_wg ("window_tutor"));
620  gtk_widget_hide (get_wg ("window_hints"));
621  gtk_widget_hide (get_wg ("window_top10"));
622  gtk_widget_hide (get_wg ("window_stat"));
623  gtk_widget_hide (get_wg ("filechooser_tutor"));
624  gtk_widget_show (get_wg ("window_main"));
625 }
626 
627 G_MODULE_EXPORT void
628 on_window_tutor_destroy (GtkWidget * object, gpointer user_data)
629 {
630  if (callbacks_shield)
631  return;
632  window_save ("tutor");
633  main_preferences_set_boolean ("interface", "autostart", TRUE);
634  main_preferences_set_int ("interface", "exercise", tutor_get_type ());
635  callbacks_shield_set (TRUE);
637 }
638 
639 G_MODULE_EXPORT void
640 on_button_tutor_close_clicked (GtkButton *button, gpointer user_data)
641 {
642  on_window_tutor_destroy (NULL, NULL);
643 }
644 
645 G_MODULE_EXPORT void
646 on_eventbox_tutor_restart_grab_focus (GtkWidget * widget, gpointer user_data)
647 {
648  cb_quick_restart ();
649 }
650 
651 G_MODULE_EXPORT void
652 on_entry_mesg_icon_release (GtkEntry *entry, GtkEntryIconPosition pos, GdkEvent *event, gpointer user_data)
653 {
654  cb_quick_restart ();
655 }
656 
657 /* Managing the keyboard/messages entry of the tutor window
658  */
659 
660 G_MODULE_EXPORT gboolean
661 on_entry_mesg_focus_out_event (GtkWidget * widget, GdkEventFocus * event, gpointer user_data)
662 {
663  if (callbacks_shield)
664  return (FALSE);
665 
666  gtk_widget_grab_focus (widget);
667  return (FALSE);
668 }
669 
670 
671 G_MODULE_EXPORT void
672 on_entry_mesg_grab_focus (GtkWidget * widget, gpointer user_data)
673 {
674  if (callbacks_shield)
675  return;
676 
677  gtk_editable_select_region (GTK_EDITABLE (widget), 0, 0);
678  gtk_editable_set_position (GTK_EDITABLE (widget), -1);
679 }
680 
681 
682 G_MODULE_EXPORT void
683 on_entry_mesg_activate (GtkEntry * entry, gpointer user_data)
684 {
685  gchar *tmp1;
686  gchar *tmp2;
687 
688  if (callbacks_shield)
689  return;
690 
691  tmp1 = g_strdup (gtk_entry_get_text (entry));
692  tmp2 = g_strconcat (tmp1, keyb_get_utf8_paragraph_symbol (), NULL);
693  callbacks_shield_set (TRUE);
694  gtk_entry_set_text (entry, tmp2);
695  callbacks_shield_set (FALSE);
696  g_free (tmp1);
697  g_free (tmp2);
698 
699  gtk_editable_set_position (GTK_EDITABLE (entry), -1);
700 
702 }
703 
704 
705 G_MODULE_EXPORT void
706 on_entry_mesg_delete_text (GtkEditable * editable, gint start_pos, gint end_pos, gpointer user_data)
707 {
708  if (callbacks_shield)
709  return;
710 
711  if (end_pos - start_pos == 1)
712  tutor_process_touch (L'\b');
713  else
714  tutor_process_touch (L'\t');
715 }
716 
717 G_MODULE_EXPORT void
718 on_entry_mesg_insert_text (GtkEditable * editable,
719  gchar * new_text, gint new_text_length, gpointer position,
720  gpointer user_data)
721 {
722  gchar *test;
723  gchar *text;
724 
725  if (callbacks_shield)
726  return;
727 
728  if (mesg_drag_drop)
729  {
730  mesg_drag_drop = FALSE;
731 
732  callbacks_shield_set (TRUE);
733  gtk_editable_delete_text (editable, 0, -1);
734  callbacks_shield_set (FALSE);
735 
736  if (g_str_has_prefix (new_text, "file://"))
737  test = new_text + 7;
738  else
739  test = new_text;
740 
741  if (g_file_test (test, G_FILE_TEST_IS_REGULAR))
742  g_file_get_contents (test, &text, NULL, NULL);
743  else
744  text = g_strdup (new_text);
745 
746  if (tutor_get_type () == TT_VELO)
747  velo_text_write_to_file (text, TRUE);
748  else if (tutor_get_type () == TT_FLUID)
750 
751  g_free (text);
752  return;
753  }
754 
755  tutor_process_touch (g_utf8_get_char_validated (new_text, new_text_length));
756 }
757 
758 /* For languages using input method - by Hodong Kim */
759 G_MODULE_EXPORT void
761  gchar * preedit,
762  gpointer user_data)
763 {
764  gunichar real_char = cursor_get_char ();
765  gunichar preedit_char = g_utf8_get_char (preedit);
766 
767  if (real_char == preedit_char)
768  {
769  /* This trick sends 'focus change' to GtkEntry.
770  gtk_entry_focus_in() sets priv->need_im_reset = TRUE,
771  therefore gtk_entry_reset_im_context always executes gtk_im_context_reset,
772  as a result, pre-edit text is committed
773  */
774  GdkEvent *event = gdk_event_new (GDK_FOCUS_CHANGE);
775 
776  event->focus_change.type = GDK_FOCUS_CHANGE;
777  event->focus_change.in = TRUE;
778  event->focus_change.window = gtk_widget_get_window (GTK_WIDGET (entry));
779  if (event->focus_change.window != NULL)
780  g_object_ref (event->focus_change.window);
781 
782  gtk_widget_send_focus_change (GTK_WIDGET (entry), event);
783  gdk_event_free (event);
784 
785  gtk_entry_reset_im_context (entry);
786  }
787 }
788 
789 /* Tutor drag and drop handling
790  */
791 G_MODULE_EXPORT gboolean
792 on_entry_mesg_drag_drop (GtkWidget * widget, GdkDragContext * drag_context,
793  gint x, gint y, guint time, gpointer user_data)
794 {
795  callbacks_shield_set (TRUE);
796  gtk_entry_set_text (GTK_ENTRY (widget), "");
797  callbacks_shield_set (FALSE);
798  mesg_drag_drop = TRUE;
799  return FALSE;
800 }
801 
802 G_MODULE_EXPORT void
803 on_entry_mesg_realize (GtkWidget * widget, gpointer user_data)
804 {
805  GtkBindingSet *bs;
806  GdkModifierType modmask = GDK_CONTROL_MASK;
807 
808  bs = gtk_binding_set_by_class (G_OBJECT_GET_CLASS ( G_OBJECT (GTK_ENTRY (widget))));
809  gtk_binding_entry_add_signal (bs, GDK_KEY_w, modmask,
810  "delete-from-cursor", 2,
811  G_TYPE_INT, GTK_DELETE_WORDS,
812  G_TYPE_INT, -1); /* Delete -1 word: Ctrl+w */
813  gtk_binding_entry_add_signal (bs, GDK_KEY_h, modmask,
814  "delete-from-cursor", 2,
815  G_TYPE_INT, GTK_DELETE_CHARS,
816  G_TYPE_INT, -1); /* Delete -1 char: Ctrl+h */
817 }
818 
819 /**********************************************************************
820  * 3 - Top 10 management
821  **********************************************************************/
822 G_MODULE_EXPORT void
823 on_combobox_top10_changed (GtkComboBox *cmb, gpointer user_data)
824 {
825  if (callbacks_shield)
826  return;
827 
828  top10_message (NULL);
829 
830  if (gtk_combo_box_get_active (cmb) == 0)
832  else
834 }
835 
836 G_MODULE_EXPORT void
837 on_combobox_top10_language_changed (GtkComboBox *cmb, gpointer user_data)
838 {
839  gchar *tmp;
840  gint active;
841 
842  if (callbacks_shield)
843  return;
844  tmp = gtk_combo_box_text_get_active_text (GTK_COMBO_BOX_TEXT (cmb));
845  trans_change_language (tmp);
846  g_free (tmp);
847 
848  callbacks_shield_set (TRUE);
849  active = gtk_combo_box_get_active (cmb);
850  gtk_combo_box_set_active (GTK_COMBO_BOX (get_wg ("combobox_language")), active);
851  callbacks_shield_set (FALSE);
852 
853  if (tutor_get_type () == TT_FLUID)
855 
856  on_combobox_top10_changed (GTK_COMBO_BOX (get_wg ("combobox_top10")), NULL);
857 }
858 
859 G_MODULE_EXPORT void
861  gpointer user_data)
862 {
863  gchar *url;
864  url = gtk_widget_get_tooltip_text (get_wg ("button_top10_go_www"));
865  gtk_show_uri_on_window (get_win ("window_top10") , url, GDK_CURRENT_TIME, NULL);
866  g_free (url);
867 }
868 
869 G_MODULE_EXPORT void
870 on_button_top10_publish_clicked (GtkButton * button, gpointer user_data)
871 {
872  GtkWidget *wg;
873 
874  top10_message (NULL);
875 
877  wg = get_wg ("image_top10_publish");
878  gtk_image_set_from_icon_name (GTK_IMAGE (wg), "gtk-yes", GTK_ICON_SIZE_BUTTON);
879 
880  top10_message (_("Connecting..."));
881 
882  g_idle_add ((GSourceFunc) top10_global_publish, NULL);
883 }
884 
885 G_MODULE_EXPORT void
886 on_button_top10_update_clicked (GtkButton * button, gpointer user_data)
887 {
888  GtkWidget *wg;
889 
890  top10_message (NULL);
891 
893  wg = get_wg ("image_top10_update");
894  gtk_image_set_from_icon_name (GTK_IMAGE (wg), "gtk-yes", GTK_ICON_SIZE_BUTTON);
895 
896  top10_message (_("Connecting..."));
897 
898  g_idle_add ((GSourceFunc) top10_global_update, NULL);
899 }
900 
901 G_MODULE_EXPORT void
902 on_button_top10_expand_clicked (GtkButton * button, gpointer user_data)
903 {
904  gtk_widget_hide (GTK_WIDGET (button));
905  gtk_widget_show (get_wg ("button_top10_noexpand"));
906  gtk_widget_show (get_wg ("scrolledwindow_top10_2"));
907  gtk_widget_set_size_request (get_wg ("window_top10"), 630, 400);
908 }
909 
910 G_MODULE_EXPORT void
911 on_button_top10_noexpand_clicked (GtkButton * button, gpointer user_data)
912 {
913  gtk_widget_hide (get_wg ("scrolledwindow_top10_2"));
914  gtk_widget_show (get_wg ("button_top10_expand"));
915  gtk_widget_hide (GTK_WIDGET (button));
916  gtk_widget_set_size_request (get_wg ("window_top10"), 350, 400);
917 }
918 
919 G_MODULE_EXPORT void
920 on_button_top10_close_clicked (GtkButton * button, gpointer user_data)
921 {
922  top10_message (NULL);
923  window_save ("top10");
924  gtk_widget_hide (get_wg ("window_top10"));
925 }
926 
927 /**********************************************************************
928  * 4 - Keyboard window
929  **********************************************************************/
930 
931 G_MODULE_EXPORT void
932 on_combobox_keyboard_country_changed (GtkComboBox *cmb, gpointer user_data)
933 {
934  gchar *tmp;
935 
936  if (callbacks_shield)
937  return;
938 
939  keyb_set_combo_kbd_variant ("combobox_keyboard_country", "combobox_keyboard_variant");
940  tmp = gtk_combo_box_text_get_active_text (GTK_COMBO_BOX_TEXT (cmb));
941  if (g_str_equal (tmp, KEYB_CUSTOM) &&
942  gtk_combo_box_get_active ( GTK_COMBO_BOX (get_wg ("combobox_keyboard_variant")) ) > -1 )
943  {
944  gtk_widget_set_sensitive (get_wg ("button_kb_remove"), TRUE);
945  }
946  else
947  gtk_widget_set_sensitive (get_wg ("button_kb_remove"), FALSE);
948  g_free (tmp);
949 }
950 
951 G_MODULE_EXPORT void
952 on_combobox_keyboard_variant_changed (GtkComboBox *cmb, gpointer user_data)
953 {
954  gchar *tmp;
955 
956  if (callbacks_shield)
957  return;
958 
959  keyb_update_from_variant ("combobox_keyboard_country", "combobox_keyboard_variant");
960 
961  tmp = gtk_combo_box_text_get_active_text (GTK_COMBO_BOX_TEXT (get_wg ("combobox_keyboard_country")));
962  if (g_str_equal (tmp, KEYB_CUSTOM) &&
963  gtk_combo_box_get_active (cmb) > -1 )
964 
965  gtk_widget_set_sensitive (get_wg ("button_kb_remove"), TRUE);
966  else
967  gtk_widget_set_sensitive (get_wg ("button_kb_remove"), FALSE);
968  g_free (tmp);
969 }
970 
971 G_MODULE_EXPORT void
972 on_button_kb_remove_clicked (GtkButton * button, gpointer user_data)
973 {
974  gchar *tmp_path = NULL;
975 
976  tmp_path = g_strconcat (main_path_user (), G_DIR_SEPARATOR_S, keyb_get_name (), ".kbd", NULL);
977  if (! g_file_test (tmp_path, G_FILE_TEST_IS_REGULAR))
978  {
979  gdk_display_beep (gdk_display_get_default());
980  g_message ("no valid keyboard to remove...");
981  g_free (tmp_path);
982  return;
983  }
984  g_free (tmp_path);
985 
986  gtk_label_set_text (GTK_LABEL (get_wg ("label_confirm_action")), "REMOVE");
987  gtk_widget_show (get_wg ("dialog_confirm"));
988 }
989 
990 G_MODULE_EXPORT void
991 on_button_kb_save_clicked (GtkButton * button, gpointer user_data)
992 {
993  gchar *tmp;
994  gchar *tmp_path;
995 
996  tmp = gtk_editable_get_chars (GTK_EDITABLE (get_wg ("entry_keyboard")), 0, -1);
997  if (strlen (tmp) == 0)
998  {
999  g_free (tmp);
1000  tmp = g_strdup (KEYB_AUTO_SAVE);
1001  }
1002  tmp_path = g_strconcat (main_path_user (), G_DIR_SEPARATOR_S, tmp, ".kbd", NULL);
1003  keyb_set_name (tmp);
1004  g_free (tmp);
1005 
1006  gtk_label_set_text (GTK_LABEL (get_wg ("label_confirm_action")), "OVERWRITE");
1007  if (g_file_test (tmp_path, G_FILE_TEST_IS_REGULAR))
1008  gtk_widget_show (get_wg ("dialog_confirm"));
1009  else
1010  on_button_confirm_yes_clicked (GTK_BUTTON (get_wg ("button_confirm_yes")), NULL);
1011  g_free (tmp_path);
1012 }
1013 
1014 G_MODULE_EXPORT void
1015 on_button_keyboard_previous_clicked (GtkButton *but, gpointer user_data)
1016 {
1018 }
1019 
1020 G_MODULE_EXPORT void
1021 on_button_keyboard_next_clicked (GtkButton *but, gpointer user_data)
1022 {
1024 }
1025 
1026 G_MODULE_EXPORT void
1027 on_button_keyboard_close_clicked (GtkButton *but, gpointer user_data)
1028 {
1029  hints_demo_fingers (0);
1030  gtk_widget_hide (get_wg ("window_keyboard"));
1031 }
1032 
1033 G_MODULE_EXPORT void
1034 on_button_keyboard_hands_clicked (GtkButton *but, gpointer user_data)
1035 {
1036  if (gtk_widget_get_visible (get_wg ("window_tutor")))
1037  if (gtk_widget_get_visible (get_wg ("hbox_keyboard_hints")))
1038  {
1039  gtk_widget_show (get_wg ("window_hints"));
1041  }
1042 
1043  hints_demo_fingers (0);
1044  gtk_widget_hide (get_wg ("window_keyboard"));
1045 }
1046 
1047 G_MODULE_EXPORT void
1048 on_button_keyboard_cancel_clicked (GtkButton * button, gpointer user_data)
1049 {
1050  gchar *tmp;
1051 
1052  tmp = main_preferences_get_string ("tutor", "keyboard");
1053  keyb_set_name (tmp);
1054  keyb_set_chars ();
1055  keyb_update_combos ("combobox_kbd_country", "combobox_kbd_variant");
1056  gtk_widget_hide (get_wg ("window_keyboard"));
1057  g_free (tmp);
1058 }
1059 
1060 /* Editing the keyboard.
1061  */
1062 G_MODULE_EXPORT void
1063 on_toggle_shift1_toggled (GtkToggleButton * togglebutton, gpointer user_data)
1064 {
1065  gboolean tog_state;
1066  GtkWidget *tog;
1067 
1068  tog = get_wg ("toggle_shift2");
1069  tog_state = gtk_toggle_button_get_active (togglebutton);
1070  gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (tog), tog_state);
1072  keyb_edit_none ();
1073 
1074  if (gtk_widget_get_visible (get_wg ("hbox_keyboard_hints")))
1075  hints_update_from_button (GTK_BUTTON (togglebutton));
1076 }
1077 
1078 G_MODULE_EXPORT void
1079 on_toggle_shift2_toggled (GtkToggleButton * togglebutton, gpointer user_data)
1080 {
1081  gboolean tog_state;
1082  GtkWidget *tog;
1083 
1084  tog = get_wg ("toggle_shift1");
1085  tog_state = gtk_toggle_button_get_active (togglebutton);
1086  gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (tog), tog_state);
1088  keyb_edit_none ();
1089 
1090  if (gtk_widget_get_visible (get_wg ("hbox_keyboard_hints")))
1091  hints_update_from_button (GTK_BUTTON (togglebutton));
1092 }
1093 
1094 G_MODULE_EXPORT void
1095 on_toggle_shift1_grab_focus (GtkToggleButton *tg, gpointer user_data)
1096 {
1097  if (callbacks_shield)
1098  return;
1099  keyb_edit_none ();
1100 }
1101 
1102 G_MODULE_EXPORT void
1103 on_toggle_shift2_grab_focus (GtkToggleButton *tg, gpointer user_data)
1104 {
1105  if (callbacks_shield)
1106  return;
1107  keyb_edit_none ();
1108 }
1109 
1110 /* All the other keys
1111  */
1112 G_MODULE_EXPORT void
1113 on_virtual_key_grab_focus (GtkWidget *wg, gpointer user_data)
1114 {
1115  if (callbacks_shield)
1116  return;
1117 
1118  if ( gtk_widget_get_visible (get_wg ("hbox_keyboard_hints")) )
1119  hints_update_from_button (GTK_BUTTON (wg));
1120  else
1121  keyb_edit_button (GTK_BUTTON (wg));
1122 }
1123 
1124 G_MODULE_EXPORT void
1125 on_virtual_key_clicked (GtkButton * button, gpointer user_data)
1126 {
1127  if (callbacks_shield)
1128  return;
1129 
1130  if ( gtk_widget_get_visible (get_wg ("hbox_keyboard_hints")) )
1131  hints_update_from_button (button);
1132  else
1133  keyb_edit_button (button);
1134 }
1135 
1136 G_MODULE_EXPORT void
1137 on_virtual_key_changed (GtkEditable *edit, gpointer user_data)
1138 {
1139  gunichar ch;
1140 
1141  if (callbacks_shield)
1142  return;
1143 
1144  ch = g_utf8_get_char_validated (gtk_entry_get_text (GTK_ENTRY (edit)), -1);
1145  if (ch == (gunichar)-2 || ch == (gunichar)-1 || ch == 0)
1146  ch = L' ';
1147 
1148  keyb_change_key (ch);
1149 }
1150 
1151 /* Confirm-dialog shared tasks
1152  */
1153 G_MODULE_EXPORT void
1154 on_dialog_confirm_show (GtkWidget * widget, gpointer user_data)
1155 {
1156  gchar *action;
1157  gchar *msg;
1158  gchar *tmp;
1159  gint len;
1160  GtkLabel *wg_label;
1161 
1162  wg_label = GTK_LABEL (get_wg ("label_confirm_action"));
1163  action = (gchar *) gtk_label_get_text (wg_label);
1164 
1165  wg_label = GTK_LABEL (get_wg ("label_confirm"));
1166 
1167  if (g_str_equal (action, "OVERWRITE"))
1168  {
1169  gtk_window_set_title (GTK_WINDOW (widget), _("Overwrite user layout"));
1170  msg = g_strdup_printf ("%s\n\n %s",
1171  _("This will OVERWRITE an existent keyboard layout."),
1172  keyb_get_name ());
1173  gtk_label_set_text (wg_label, msg);
1174  g_free (msg);
1175  }
1176  else if (g_str_equal (action, "REMOVE"))
1177  {
1178  gtk_window_set_title (GTK_WINDOW (widget), _("Remove user layout"));
1179  msg = g_strdup_printf ("%s\n\n %s",
1180  _("This will REMOVE an existent keyboard layout."),
1181  keyb_get_name ());
1182  gtk_label_set_text (wg_label, msg);
1183  g_free (msg);
1184  }
1185  else if (g_str_equal (action, "RESET_ALL"))
1186  {
1187  gtk_window_set_title (GTK_WINDOW (widget), _("Reset progress data"));
1188  gtk_label_set_text (wg_label, _("This will DELETE all the progress data of all modules."));
1189  }
1190  else if (g_str_equal (action, "RESET"))
1191  {
1192  gtk_window_set_title (GTK_WINDOW (widget), _("Reset progress data"));
1193  tmp = g_strdup (tutor_get_type_name ());
1194  for (msg = tmp; tmp[0] != '\0'; tmp++) tmp[0] = g_ascii_toupper (tmp[0]);
1195  tmp = msg;
1196  if (g_str_equal (tmp, "ADAPT") && gtk_combo_box_get_active (GTK_COMBO_BOX (get_wg ("combobox_stat_type"))) > 1)
1197  {
1198  g_free (tmp);
1199  tmp = gtk_combo_box_text_get_active_text (GTK_COMBO_BOX_TEXT (get_wg ("combobox_stat_type")));
1200  msg = g_strdup_printf (_("This will delete the data of this chart. <%s>"), tmp);
1201  }
1202  else
1203  msg = g_strdup_printf (_("This will delete the progress data of the module. (%s)"), tmp);
1204  gtk_label_set_text (wg_label, msg);
1205  g_free (tmp);
1206  g_free (msg);
1207  }
1208  else
1209  {
1210  g_warning ("No valid action for this confirm-dialog: %s", action);
1211  gtk_widget_hide (widget);
1212  }
1213 }
1214 
1215 G_MODULE_EXPORT void
1216 on_button_confirm_yes_clicked (GtkButton * button, gpointer user_data)
1217 {
1218  gchar *file;
1219  gchar *action;
1220  gchar *msg;
1221  gchar *tmp;
1222  GtkWidget *wg;
1223 
1224  wg = get_wg ("label_confirm_action");
1225  action = (gchar *) gtk_label_get_text (GTK_LABEL (wg));
1226 
1227  if (g_str_equal (action, "OVERWRITE"))
1228  {
1231  keyb_update_combos ("combobox_kbd_country", "combobox_kbd_variant");
1232  gtk_widget_hide (get_wg ("window_keyboard"));
1233  }
1234 
1235  else if (g_str_equal (action, "REMOVE"))
1236  {
1238  }
1239 
1240  else if (g_str_equal (action, "RESET_ALL"))
1241  {
1242  file = g_build_filename (main_path_stats (), "stat_basic.txt", NULL);
1243  g_unlink (file);
1244  g_free (file);
1245  basic_set_lesson (1);
1246  file = g_build_filename (main_path_stats (), "stat_adapt.txt", NULL);
1247  g_unlink (file);
1248  g_free (file);
1249  file = g_build_filename (main_path_stats (), "stat_velo.txt", NULL);
1250  g_unlink (file);
1251  g_free (file);
1252  file = g_build_filename (main_path_stats (), "stat_fluid.txt", NULL);
1253  g_unlink (file);
1254  g_free (file);
1255  file = g_build_filename (main_path_stats (), "scores_fluid.txt", NULL);
1256  g_unlink (file);
1257  g_free (file);
1258 
1259  accur_reset ();
1260  accur_close ();
1261  accur_init ();
1262 
1263  on_combobox_stat_type_changed (NULL, NULL);
1264  }
1265  else if (g_str_equal (action, "RESET"))
1266  {
1267  tmp = g_strdup (tutor_get_type_name ());
1268  for (msg = tmp; tmp[0] != '\0'; tmp++) tmp[0] = g_ascii_toupper (tmp[0]);
1269  tmp = msg;
1270 
1271  if (g_str_equal (tmp, "BASIC"))
1272  {
1273  file = g_build_filename (main_path_stats (), "stat_basic.txt", NULL);
1274  g_unlink (file);
1275  g_free (file);
1276  basic_set_lesson (1);
1277  }
1278  else if (g_str_equal (tmp, "ADAPT"))
1279  {
1280  if (gtk_combo_box_get_active (GTK_COMBO_BOX (get_wg ("combobox_stat_type"))) == 2)
1281  {
1282  accur_terror_reset ();
1283  accur_close ();
1284  accur_init ();
1285  }
1286  else if (gtk_combo_box_get_active (GTK_COMBO_BOX (get_wg ("combobox_stat_type"))) == 3)
1287  {
1288  accur_ttime_reset ();
1289  accur_close ();
1290  accur_init ();
1291  }
1292  else
1293  {
1294  file = g_build_filename (main_path_stats (), "stat_adapt.txt", NULL);
1295  g_unlink (file);
1296  g_free (file);
1297  }
1298  }
1299  else if (g_str_equal (tmp, "VELO"))
1300  {
1301  file = g_build_filename (main_path_stats (), "stat_velo.txt", NULL);
1302  g_unlink (file);
1303  g_free (file);
1304  }
1305  else if (g_str_equal (tmp, "FLUID"))
1306  {
1307  file = g_build_filename (main_path_stats (), "stat_fluid.txt", NULL);
1308  g_unlink (file);
1309  g_free (file);
1310  file = g_build_filename (main_path_stats (), "scores_fluid.txt", NULL);
1311  g_unlink (file);
1312  g_free (file);
1313  }
1314  on_combobox_stat_type_changed (NULL, NULL);
1315  }
1316  else
1317  g_warning ("No valid action selected for 'yes' confirm-button: %s", action);
1318 
1319  gtk_widget_hide (gtk_widget_get_toplevel (GTK_WIDGET (button)));
1320 }
1321 
1322 G_MODULE_EXPORT void
1323 on_button_confirm_no_clicked (GtkButton * button, gpointer user_data)
1324 {
1325  gchar *action;
1326  GtkWidget *wg;
1327 
1328  wg = get_wg ("label_confirm_action");
1329  action = (gchar *) gtk_label_get_text (GTK_LABEL (wg));
1330 
1331  if (g_str_equal (action, "OVERWRITE"))
1332  g_printf ("Not overwriting file %s.kbd\n", keyb_get_name ());
1333 
1334  else if (g_str_equal (action, "REMOVE"))
1335  g_printf ("Not removing file %s.kbd\n", keyb_get_name ());
1336 
1337  gtk_widget_hide (gtk_widget_get_toplevel (GTK_WIDGET (button)));
1338 }
1339 
1340 /*******************************************************************************
1341  * Window hints management
1342  */
1343 G_MODULE_EXPORT void
1344 on_window_hints_check_resize (GtkContainer *cont, gpointer user_data)
1345 {
1346  static int i;
1347  static GTimer *wait = NULL;
1348  gint dx, dy;
1349 
1350  //if (callbacks_shield)
1351  return;
1352 
1353  if (wait == NULL)
1354  wait = g_timer_new ();
1355 
1356  if (g_timer_elapsed (wait, NULL) > 0.2)
1357  {
1358  g_timer_start (wait);
1359  gtk_window_get_size (get_win ("window_hints"), &dx, &dy);
1360  g_printf ("hints_check_resize: %04i x %04i (%i)\n", dx, dy, i++);
1361  }
1362 }
1363 
1364 G_MODULE_EXPORT void
1365 on_button_hints_close_clicked (GtkButton *but, gpointer user_data)
1366 {
1367  window_save ("hints");
1368  gtk_widget_hide (get_wg ("window_hints"));
1369 }
1370 
1371 /**********************************************************************
1372  * 5 - Charts window
1373  **********************************************************************/
1374 
1375 G_MODULE_EXPORT void
1376 on_combobox_stat_module_changed (GtkComboBox *cmb, gpointer user_data)
1377 {
1378  static gchar *stat_title = NULL;
1379  gchar *win_title;
1380  gint i;
1381  gchar *tmp;
1382  GtkWindow *win;
1383 
1384  if (callbacks_shield == TRUE)
1385  return;
1386 
1387  if (gtk_combo_box_get_active (cmb) < 0)
1388  return;
1389 
1390  win = GTK_WINDOW (get_wg ("window_stat"));
1391  if (stat_title == NULL)
1392  {
1393  plot_initialize ();
1394  stat_title = g_strdup (gtk_window_get_title (win));
1395  }
1396 
1397  if (user_data == NULL)
1398  tutor_init (gtk_combo_box_get_active (cmb));
1399 
1400  callbacks_shield_set (TRUE);
1401  for (i = 0; i < 4; i++)
1402  gtk_combo_box_text_remove (GTK_COMBO_BOX_TEXT (get_wg ("combobox_stat_type")), 0);
1403  tmp = g_strdup_printf ("%s (%%)", _("Accuracy"));
1404  gtk_combo_box_text_insert_text (GTK_COMBO_BOX_TEXT (get_wg ("combobox_stat_type")), 0, tmp);
1405  g_free (tmp);
1406  tmp = g_strdup_printf ("%s %s", _("Speed"), _("(WPM)"));
1407  gtk_combo_box_text_insert_text (GTK_COMBO_BOX_TEXT (get_wg ("combobox_stat_type")), 1, tmp);
1408  g_free (tmp);
1409 
1410  switch (gtk_combo_box_get_active (cmb))
1411  {
1412  case 0:
1413  win_title = g_strdup_printf ("%s (%s)", stat_title, keyb_mode_get_name ());
1414  break;
1415  case 1:
1416  win_title = g_strdup_printf ("%s (%s)", stat_title, keyb_mode_get_name ());
1417  tmp = g_strdup_printf ("%s", _("Errors"));
1418  gtk_combo_box_text_insert_text (GTK_COMBO_BOX_TEXT (get_wg ("combobox_stat_type")), 2, tmp);
1419  g_free (tmp);
1420  tmp = g_strdup_printf ("%s", _("Touch times (s)"));
1421  gtk_combo_box_text_insert_text (GTK_COMBO_BOX_TEXT (get_wg ("combobox_stat_type")), 3, tmp);
1422  g_free (tmp);
1423  break;
1424  case 2:
1425  win_title = g_strdup_printf ("%s (%s)", stat_title, trans_get_current_language ());
1426  break;
1427  case 3:
1428  win_title = g_strdup_printf ("%s (%s)", stat_title, trans_get_current_language ());
1429  tmp = g_strdup_printf ("%s (%%)", _("Fluidity"));
1430  gtk_combo_box_text_insert_text (GTK_COMBO_BOX_TEXT (get_wg ("combobox_stat_type")), 2, tmp);
1431  g_free (tmp);
1432  tmp = g_strdup_printf ("%s (0-10)", _("Score"));
1433  gtk_combo_box_text_insert_text (GTK_COMBO_BOX_TEXT (get_wg ("combobox_stat_type")), 3, tmp);
1434  g_free (tmp);
1435  break;
1436  default:
1437  win_title = g_strdup (stat_title);
1438  }
1439 
1440  gtk_combo_box_set_active (GTK_COMBO_BOX (get_wg ("combobox_stat_type")), 0);
1441  callbacks_shield_set (FALSE);
1442 
1443  gtk_window_set_title (win, win_title);
1444  g_free (win_title);
1445  plot_draw_chart (1);
1446 }
1447 
1448 G_MODULE_EXPORT void
1449 on_combobox_stat_type_changed (GtkComboBox *cmb, gpointer user_data)
1450 {
1451  static gboolean init = TRUE;
1452  gint active;
1453 
1454  if (callbacks_shield == TRUE)
1455  return;
1456 
1457  if (init)
1458  {
1459  plot_initialize ();
1460  init = FALSE;
1461  }
1462 
1463  active = gtk_combo_box_get_active ( GTK_COMBO_BOX (get_wg ("combobox_stat_type")) );
1464  if (active < 0)
1465  return;
1466 
1467  /* Adapt module (1) has special charts
1468  */
1469  if (gtk_combo_box_get_active (GTK_COMBO_BOX (get_wg ("combobox_stat_module"))) == 1)
1470  plot_draw_chart (active + (active < 2 ? 1 : 4));
1471  else
1472  plot_draw_chart (active + 1);
1473 }
1474 
1475 G_MODULE_EXPORT void
1476 on_spinbutton_stat_lesson_value_changed (GtkSpinButton * spinbutton, gpointer user_data)
1477 {
1478  if (callbacks_shield)
1479  return;
1480 
1481  plot_draw_chart (gtk_combo_box_get_active (GTK_COMBO_BOX (get_wg ("combobox_stat_type"))) + 1);
1482 }
1483 
1484 G_MODULE_EXPORT void
1485 on_button_stat_reset_clicked (GtkButton * button, gpointer check)
1486 {
1487  if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (check)))
1488  gtk_label_set_text (GTK_LABEL (get_wg ("label_confirm_action")), "RESET_ALL");
1489  else
1490  gtk_label_set_text (GTK_LABEL (get_wg ("label_confirm_action")), "RESET");
1491  gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (check), FALSE);
1492 
1493  gtk_widget_show (get_wg ("dialog_confirm"));
1494 }
1495 
1496 G_MODULE_EXPORT void
1497 on_button_stat_close_clicked (GtkButton * button, gpointer user_data)
1498 {
1499  callbacks_shield_set (TRUE);
1500  gtk_combo_box_set_active (GTK_COMBO_BOX ( get_wg ("combobox_stat_type")), 0 );
1501  callbacks_shield_set (FALSE);
1502  window_save ("stat");
1503  gtk_widget_hide (gtk_widget_get_toplevel (GTK_WIDGET (button)));
1504 }
1505 
1506 G_MODULE_EXPORT void
1507 on_databox_hovered (GtkDatabox *dbox, GdkEventMotion *event, gpointer user_data)
1508 {
1509  plot_pointer_update (event->x);
1510 }
1511 
1512 /**********************************************************************
1513  * 6 - Other texts popup
1514  **********************************************************************/
1515 
1516 G_MODULE_EXPORT void
1517 on_treeview_other_realize (GtkWidget * widget, gpointer user_data)
1518 {
1519  GtkListStore *list;
1520  GtkCellRenderer *renderer;
1521  GtkTreeViewColumn *column;
1522 
1523  list = gtk_list_store_new (1, G_TYPE_STRING);
1524  gtk_tree_view_set_model (GTK_TREE_VIEW (widget), GTK_TREE_MODEL (list));
1525  renderer = gtk_cell_renderer_text_new ();
1526  column = gtk_tree_view_column_new_with_attributes (":-)", renderer, "text", 0, NULL);
1527  gtk_tree_view_append_column (GTK_TREE_VIEW (widget), column);
1528 }
1529 
1530 G_MODULE_EXPORT void
1531 on_button_other_new_clicked (GtkButton * button, gpointer user_data)
1532 {
1533  gtk_widget_show (GTK_WIDGET (get_wg ("filechooser_tutor")));
1534 }
1535 
1536 G_MODULE_EXPORT void
1537 on_button_other_cancel_clicked (GtkButton * button, gpointer user_data)
1538 {
1539  g_free (other_renaming_undo);
1540  other_renaming_undo = g_strdup ("*");
1541  gtk_widget_hide (get_wg ("popup_other"));
1542 }
1543 
1544 G_MODULE_EXPORT void
1545 on_button_other_apply_clicked (GtkButton *button, gpointer user_data)
1546 {
1547  gchar *tmp_name;
1548  GtkTreeSelection *sel;
1549  GtkTreeModel *store;
1550  GtkTreeIter iter;
1551 
1552  gtk_widget_hide (get_wg ("popup_other"));
1553 
1554  sel = gtk_tree_view_get_selection (GTK_TREE_VIEW (get_wg ("treeview_other")));
1555  if (gtk_tree_selection_get_selected (sel, &store, &iter) == FALSE)
1556  {
1558  tutor_process_touch ('\0');
1559  return;
1560  }
1561 
1562  tutor_other_rename (gtk_entry_get_text (GTK_ENTRY (get_wg ("entry_other_rename"))), other_renaming_undo);
1563  g_free (other_renaming_undo);
1564  other_renaming_undo = g_strdup ("*");
1565 
1566  gtk_tree_model_get (store, &iter, 0, &tmp_name, -1);
1567 
1568  if (tutor_get_type () == TT_VELO)
1569  {
1570  if (main_velo_txt ())
1571  fluid_init_paragraph_list (tmp_name);
1572  else
1573  velo_init_dict (tmp_name);
1574  }
1575  else if (tutor_get_type () == TT_FLUID)
1576  fluid_init_paragraph_list (tmp_name);
1577 
1579  tutor_process_touch ('\0');
1580 }
1581 
1582 G_MODULE_EXPORT void
1583 on_button_other_paste_clicked (GtkButton * button, gpointer user_data)
1584 {
1585  gchar *text;
1586  GtkWidget *wg;
1587  GtkListStore *list;
1588 
1589  if (clipboard == NULL)
1590  clipboard = gtk_clipboard_get (GDK_SELECTION_CLIPBOARD);
1591  if (clipboard_2 == NULL)
1592  clipboard_2 = gtk_clipboard_get (GDK_SELECTION_PRIMARY);
1593 
1594  text = gtk_clipboard_wait_for_text (clipboard);
1595  if (text == NULL)
1596  text = gtk_clipboard_wait_for_text (clipboard_2);
1597  if (text == NULL)
1598  {
1599  gdk_display_beep (gdk_display_get_default());
1600  g_message ("No text in the Clipboard");
1601  return;
1602  }
1603 
1604  wg = get_wg ("treeview_other");
1605  list = GTK_LIST_STORE ( gtk_tree_view_get_model (GTK_TREE_VIEW (wg)) );
1606  if (tutor_get_type () == TT_VELO)
1607  {
1608  if (main_velo_txt ())
1609  {
1610  fluid_text_write_to_file (text);
1611  tutor_load_list_other (".paragraphs", list);
1612  }
1613  else
1614  {
1615  velo_text_write_to_file (text, TRUE);
1616  tutor_load_list_other (".words", list);
1617  }
1618  }
1619  else if (tutor_get_type () == TT_FLUID)
1620  {
1621  fluid_text_write_to_file (text);
1622  tutor_load_list_other (".paragraphs", list);
1623  }
1624  g_free (text);
1625 
1626  g_free (other_renaming_undo);
1627  other_renaming_undo = g_strdup ("*");
1628  gtk_widget_hide (get_wg ("popup_other"));
1629 }
1630 
1631 G_MODULE_EXPORT void
1632 on_button_other_remove_clicked (GtkButton * button, gpointer user_data)
1633 {
1634  gchar *tmp_str;
1635  gchar *tmp_name;
1636  GtkTreeSelection *sel;
1637  GtkTreeModel *store;
1638  GtkTreeIter iter;
1639 
1640  sel = gtk_tree_view_get_selection (GTK_TREE_VIEW (get_wg ("treeview_other")));
1641  if (gtk_tree_selection_get_selected (sel, &store, &iter) == FALSE)
1642  {
1643  gdk_display_beep (gdk_display_get_default());
1644  return;
1645  }
1646 
1647  gtk_tree_model_get (store, &iter, 0, &tmp_str, -1);
1648 
1649  if (g_str_equal (tmp_str, OTHER_DEFAULT))
1650  {
1651  gdk_display_beep (gdk_display_get_default());
1652  g_free (tmp_str);
1653  return;
1654  }
1655 
1656  tmp_name = g_build_filename (main_path_user (), tmp_str, NULL);
1657  g_free (tmp_str);
1658 
1659  if (tutor_get_type () == TT_VELO)
1660  if (main_velo_txt ())
1661  tmp_str = g_strconcat (tmp_name, ".paragraphs", NULL);
1662  else
1663  tmp_str = g_strconcat (tmp_name, ".words", NULL);
1664  else if (tutor_get_type () == TT_FLUID)
1665  tmp_str = g_strconcat (tmp_name, ".paragraphs", NULL);
1666  g_unlink (tmp_str);
1667  g_free (tmp_str);
1668  g_free (tmp_name);
1669 
1670  gtk_list_store_remove (GTK_LIST_STORE (store), &iter);
1671  gtk_widget_set_sensitive (get_wg ("button_other_remove"), FALSE);
1672  gtk_widget_set_sensitive (get_wg ("label_other_rename"), FALSE);
1673  gtk_widget_set_sensitive (get_wg ("entry_other_rename"), FALSE);
1674 }
1675 
1676 G_MODULE_EXPORT void
1677 on_entry_other_rename_changed (GtkEditable *editable, gint start_pos, gint end_pos, gpointer user_data)
1678 {
1679  gchar *str;
1680  GtkTreeSelection *sel;
1681  GtkTreeModel *store;
1682  GtkTreeIter iter;
1683 
1684  if (callbacks_shield)
1685  return;
1686 
1687  sel = gtk_tree_view_get_selection (GTK_TREE_VIEW (get_wg ("treeview_other")));
1688  if (gtk_tree_selection_get_selected (sel, &store, &iter) == FALSE)
1689  {
1690  gtk_widget_set_sensitive (get_wg ("label_other_rename"), FALSE);
1691  gtk_widget_set_sensitive (get_wg ("entry_other_rename"), FALSE);
1692  return;
1693  }
1694  str = (gchar*) gtk_entry_get_text (GTK_ENTRY (get_wg ("entry_other_rename")));
1695  if (strlen (str) > 0)
1696  gtk_list_store_set (GTK_LIST_STORE (store), &iter, 0, str, -1);
1697  else
1698  gtk_list_store_set (GTK_LIST_STORE (store), &iter, 0, other_renaming_undo, -1);
1699 }
1700 
1701 G_MODULE_EXPORT void
1702 on_entry_other_rename_activate (GtkEntry *entry, gpointer user_data)
1703 {
1704  on_button_other_apply_clicked (NULL, NULL);
1705 }
1706 
1707 G_MODULE_EXPORT void
1708 on_treeview_other_cursor_changed (GtkTreeView *treeview, gpointer user_data)
1709 {
1710  gchar *tmp_str;
1711  GtkTreeSelection *sel;
1712  GtkTreeModel *store;
1713  GtkTreeIter iter;
1714  GtkEntry *entry;
1715 
1716  sel = gtk_tree_view_get_selection (GTK_TREE_VIEW (get_wg ("treeview_other")));
1717  if (gtk_tree_selection_get_selected (sel, &store, &iter) == FALSE)
1718  {
1719  gtk_widget_set_sensitive (get_wg ("button_other_apply"), FALSE);
1720  return;
1721  }
1722  gtk_widget_set_sensitive (get_wg ("button_other_apply"), TRUE);
1723 
1724  entry = GTK_ENTRY (get_wg ("entry_other_rename"));
1725 
1726  if (other_renaming_undo == NULL)
1727  other_renaming_undo = g_strdup ("*");
1728  else
1729  tutor_other_rename (gtk_entry_get_text (entry), other_renaming_undo);
1730 
1731  callbacks_shield_set (TRUE);
1732  g_free (other_renaming_undo);
1733  gtk_tree_model_get (store, &iter, 0, &tmp_str, -1);
1734  if (g_str_equal (tmp_str, OTHER_DEFAULT))
1735  {
1736  gtk_entry_set_text (entry, "");
1737  gtk_widget_set_sensitive (get_wg ("button_other_remove"), FALSE);
1738  gtk_widget_set_sensitive (get_wg ("label_other_rename"), FALSE);
1739  gtk_widget_set_sensitive (get_wg ("entry_other_rename"), FALSE);
1740  other_renaming_undo = g_strdup ("*");
1741  }
1742  else
1743  {
1744  gtk_widget_set_sensitive (get_wg ("button_other_remove"), TRUE);
1745  gtk_widget_set_sensitive (get_wg ("label_other_rename"), TRUE);
1746  gtk_widget_set_sensitive (get_wg ("entry_other_rename"), TRUE);
1747  gtk_entry_set_text (entry, tmp_str);
1748  other_renaming_undo = g_strdup (tmp_str);
1749  }
1750  callbacks_shield_set (FALSE);
1751 
1752 }
1753 
1754 G_MODULE_EXPORT void
1755 on_treeview_other_row_activated (GtkTreeView *treeview, GtkTreePath *path, GtkTreeViewColumn *column, gpointer user_data)
1756 {
1757  on_button_other_apply_clicked (NULL, NULL);
1758 }
1759 
1760 G_MODULE_EXPORT void
1761 on_button_filechooser_open_clicked (GtkButton *button, gpointer user_data)
1762 {
1763  gchar *tmp_path;
1764  GtkWidget *wg;
1765  GtkListStore *list;
1766 
1767  tmp_path = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (get_wg ("filechooser_tutor")));
1768  if (tutor_get_type () == TT_VELO)
1769  velo_create_dict (tmp_path, TRUE);
1770  else if (tutor_get_type () == TT_FLUID)
1771  fluid_copy_text_file (tmp_path);
1772  g_free (tmp_path);
1773 
1774  wg = get_wg ("treeview_other");
1775  list = GTK_LIST_STORE ( gtk_tree_view_get_model (GTK_TREE_VIEW (wg)) );
1776  if (tutor_get_type () == TT_VELO)
1777  if (main_velo_txt ())
1778  tutor_load_list_other (".paragraphs", list);
1779  else
1780  tutor_load_list_other (".words", list);
1781  else if (tutor_get_type () == TT_FLUID)
1782  tutor_load_list_other (".paragraphs", list);
1783 
1784  g_free (other_renaming_undo);
1785  other_renaming_undo = g_strdup ("*");
1786  gtk_widget_hide (get_wg ("popup_other"));
1787  gtk_widget_hide (get_wg ("filechooser_tutor"));
1788 }
1789 
1790 G_MODULE_EXPORT void
1791 on_button_filechooser_cancel_clicked (GtkButton *button, gpointer user_data)
1792 {
1793  gtk_widget_hide (get_wg ("filechooser_tutor"));
1794 }
1795 
1796 /**********************************************************************
1797  * 7 - Mangling with the windows positions
1798  **********************************************************************/
1799 
1800 G_MODULE_EXPORT void
1801 on_window_main_show (GtkWidget *wg, gpointer user_data)
1802 {
1803  window_restore ("main");
1804 }
1805 
1806 G_MODULE_EXPORT void
1807 on_window_tutor_show (GtkWidget *wg, gpointer user_data)
1808 {
1809  window_restore ("tutor");
1810 }
1811 
1812 G_MODULE_EXPORT void
1813 on_window_hints_show (GtkWidget *wg, gpointer user_data)
1814 {
1815  window_restore ("hints");
1816 }
1817 
1818 G_MODULE_EXPORT void
1819 on_window_top10_show (GtkWidget *wg, gpointer user_data)
1820 {
1821  window_restore ("top10");
1822 }
1823 
1824 G_MODULE_EXPORT void
1825 on_window_stat_show (GtkWidget *wg, gpointer user_data)
1826 {
1827  window_restore ("stat");
1828 }
1829 
1830 void
1831 window_restore (gchar *who)
1832 {
1833  gint x, y;
1834  gchar *str;
1835 
1836  str = g_strconcat (who, "_X", NULL);
1837  if (main_preferences_exist ("windows", str))
1838  x = main_preferences_get_int ("windows", str);
1839  else
1840  {
1841  g_free (str);
1842  return;
1843  }
1844  g_free (str);
1845 
1846  str = g_strconcat (who, "_Y", NULL);
1847  if (main_preferences_exist ("windows", str))
1848  y = main_preferences_get_int ("windows", str);
1849  else
1850  {
1851  g_free (str);
1852  return;
1853  }
1854  g_free (str);
1855 
1856  str = g_strconcat ("window_", who, NULL);
1857  gtk_window_move (get_win (str), x, y);
1858  g_free (str);
1859 }
1860 
1861 void
1862 window_save (gchar *who)
1863 {
1864  gint x, y;
1865  gchar *str;
1866 
1867  str = g_strconcat ("window_", who, NULL);
1868  gtk_window_get_position (get_win (str), &x, &y);
1869  g_free (str);
1870 
1871  str = g_strconcat (who, "_X", NULL);
1872  main_preferences_set_int ("windows", str, x);
1873  g_free (str);
1874 
1875  str = g_strconcat (who, "_Y", NULL);
1876  main_preferences_set_int ("windows", str, y);
1877  g_free (str);
1878 }
void accur_reset()
Definition: accuracy.c:69
void accur_close()
Definition: accuracy.c:619
void accur_terror_reset()
Definition: accuracy.c:55
void accur_ttime_reset()
Definition: accuracy.c:62
void accur_init()
Definition: accuracy.c:151
GtkWidget * get_wg(gchar *name)
Definition: auxiliar.c:40
GtkWindow * get_win(gchar *name)
Definition: auxiliar.c:50
#define _(String)
Definition: auxiliar.h:45
void basic_set_lesson_increased(gboolean state)
Definition: basic.c:76
gboolean basic_get_lesson_increased()
Definition: basic.c:70
void basic_set_lesson(gint lesson)
Definition: basic.c:54
gint basic_init_char_set()
Definition: basic.c:102
gint basic_get_lesson()
Definition: basic.c:48
gunichar * basic_get_char_set()
Definition: basic.c:64
void basic_save_lesson(gchar *charset)
Definition: basic.c:233
G_MODULE_EXPORT void on_entry_custom_basic_lesson_activate(GtkEntry *entry, gpointer user_data)
Definition: callbacks.c:516
G_MODULE_EXPORT void on_button_velo_clicked(GtkButton *button, gpointer user_data)
Definition: callbacks.c:86
G_MODULE_EXPORT void on_button_basic_clicked(GtkButton *button, gpointer user_data)
Definition: callbacks.c:72
G_MODULE_EXPORT void on_button_confirm_no_clicked(GtkButton *button, gpointer user_data)
Definition: callbacks.c:1323
G_MODULE_EXPORT void on_toggle_shift2_toggled(GtkToggleButton *togglebutton, gpointer user_data)
Definition: callbacks.c:1079
static void cb_quick_restart()
Definition: callbacks.c:345
G_MODULE_EXPORT void on_treeview_other_row_activated(GtkTreeView *treeview, GtkTreePath *path, GtkTreeViewColumn *column, gpointer user_data)
Definition: callbacks.c:1755
G_MODULE_EXPORT void on_entry_mesg_grab_focus(GtkWidget *widget, gpointer user_data)
Definition: callbacks.c:672
G_MODULE_EXPORT void on_combobox_top10_changed(GtkComboBox *cmb, gpointer user_data)
Definition: callbacks.c:823
G_MODULE_EXPORT void on_togglebutton_tutor_intro_toggled(GtkToggleButton *button, gpointer user_data)
Definition: callbacks.c:597
G_MODULE_EXPORT void on_button_keyboard_previous_clicked(GtkButton *but, gpointer user_data)
Definition: callbacks.c:1015
G_MODULE_EXPORT void on_button_keyboard_close_clicked(GtkButton *but, gpointer user_data)
Definition: callbacks.c:1027
G_MODULE_EXPORT void on_virtual_key_changed(GtkEditable *edit, gpointer user_data)
Definition: callbacks.c:1137
G_MODULE_EXPORT void on_button_keyboard_next_clicked(GtkButton *but, gpointer user_data)
Definition: callbacks.c:1021
G_MODULE_EXPORT void on_toggle_shift2_grab_focus(GtkToggleButton *tg, gpointer user_data)
Definition: callbacks.c:1103
G_MODULE_EXPORT void on_button_tutor_back_clicked(GtkButton *button, gpointer user_data)
Definition: callbacks.c:610
G_MODULE_EXPORT void on_window_main_destroy(GtkWidget *obj, gpointer data)
Definition: callbacks.c:175
G_MODULE_EXPORT void on_combobox_stat_type_changed(GtkComboBox *cmb, gpointer user_data)
Definition: callbacks.c:1449
G_MODULE_EXPORT void on_button_tutor_top10_clicked(GtkButton *button, gpointer user_data)
Definition: callbacks.c:525
G_MODULE_EXPORT void on_entry_mesg_delete_text(GtkEditable *editable, gint start_pos, gint end_pos, gpointer user_data)
Definition: callbacks.c:706
G_MODULE_EXPORT void on_button_kb_save_clicked(GtkButton *button, gpointer user_data)
Definition: callbacks.c:991
G_MODULE_EXPORT void on_button_top10_publish_clicked(GtkButton *button, gpointer user_data)
Definition: callbacks.c:870
G_MODULE_EXPORT void on_button_intro_clicked(GtkButton *button, gpointer user_data)
Definition: callbacks.c:66
G_MODULE_EXPORT void on_entry_mesg_realize(GtkWidget *widget, gpointer user_data)
Definition: callbacks.c:803
G_MODULE_EXPORT void on_button_tutor_show_keyb_clicked(GtkButton *button, gpointer user_data)
Definition: callbacks.c:545
G_MODULE_EXPORT gboolean on_entry_mesg_drag_drop(GtkWidget *widget, GdkDragContext *drag_context, gint x, gint y, guint time, gpointer user_data)
Definition: callbacks.c:792
G_MODULE_EXPORT void on_button_tutor_close_clicked(GtkButton *button, gpointer user_data)
Definition: callbacks.c:640
static gchar * other_renaming_undo
Definition: callbacks.c:54
G_MODULE_EXPORT void on_entry_mesg_activate(GtkEntry *entry, gpointer user_data)
Definition: callbacks.c:683
G_MODULE_EXPORT void on_button_confirm_yes_clicked(GtkButton *button, gpointer user_data)
Definition: callbacks.c:1216
G_MODULE_EXPORT void on_togglebutton_toomuch_errors_toggled(GtkToggleButton *togglebutton, gpointer user_data)
Definition: callbacks.c:510
G_MODULE_EXPORT void on_databox_hovered(GtkDatabox *dbox, GdkEventMotion *event, gpointer user_data)
Definition: callbacks.c:1507
G_MODULE_EXPORT void on_window_stat_show(GtkWidget *wg, gpointer user_data)
Definition: callbacks.c:1825
G_MODULE_EXPORT void on_button_top10_noexpand_clicked(GtkButton *button, gpointer user_data)
Definition: callbacks.c:911
gchar * KEYB_EDIT
Definition: main.c:42
gchar * OTHER_DEFAULT
Definition: main.c:43
G_MODULE_EXPORT void on_button_stat_close_clicked(GtkButton *button, gpointer user_data)
Definition: callbacks.c:1497
G_MODULE_EXPORT void on_eventbox_stat_plus(GtkWidget *widget, gpointer user_data)
Definition: callbacks.c:425
G_MODULE_EXPORT void on_combobox_language_changed(GtkComboBox *cmb, gpointer user_data)
Definition: callbacks.c:115
G_MODULE_EXPORT void on_spinbutton_stat_lesson_value_changed(GtkSpinButton *spinbutton, gpointer user_data)
Definition: callbacks.c:1476
G_MODULE_EXPORT void on_dialog_confirm_show(GtkWidget *widget, gpointer user_data)
Definition: callbacks.c:1154
G_MODULE_EXPORT void on_entry_mesg_preedit_changed(GtkEntry *entry, gchar *preedit, gpointer user_data)
Definition: callbacks.c:760
G_MODULE_EXPORT void on_text_tutor_realize(GtkWidget *widget, gpointer user_data)
Definition: callbacks.c:236
G_MODULE_EXPORT void on_combobox_stat_module_changed(GtkComboBox *cmb, gpointer user_data)
Definition: callbacks.c:1376
G_MODULE_EXPORT void on_entry_other_rename_activate(GtkEntry *entry, gpointer user_data)
Definition: callbacks.c:1702
G_MODULE_EXPORT void on_spinbutton_lesson_value_changed(GtkSpinButton *spinbutton, gpointer user_data)
Definition: callbacks.c:379
G_MODULE_EXPORT void on_button_tutor_other_clicked(GtkButton *button, gpointer user_data)
Definition: callbacks.c:355
G_MODULE_EXPORT void on_button_top10_close_clicked(GtkButton *button, gpointer user_data)
Definition: callbacks.c:920
G_MODULE_EXPORT void on_button_hints_close_clicked(GtkButton *but, gpointer user_data)
Definition: callbacks.c:1365
G_MODULE_EXPORT void on_button_filechooser_open_clicked(GtkButton *button, gpointer user_data)
Definition: callbacks.c:1761
G_MODULE_EXPORT void on_toggle_shift1_toggled(GtkToggleButton *togglebutton, gpointer user_data)
Definition: callbacks.c:1063
G_MODULE_EXPORT void on_button_keyboard_cancel_clicked(GtkButton *button, gpointer user_data)
Definition: callbacks.c:1048
gchar * KEYB_CUSTOM
Definition: main.c:41
G_MODULE_EXPORT void on_checkbutton_speech_toggled(GtkToggleButton *togglebutton, gpointer user_data)
Definition: callbacks.c:106
G_MODULE_EXPORT void on_combobox_kbd_variant_changed(GtkComboBox *cmb, gpointer user_data)
Definition: callbacks.c:150
G_MODULE_EXPORT void on_button_other_cancel_clicked(GtkButton *button, gpointer user_data)
Definition: callbacks.c:1537
G_MODULE_EXPORT void on_eventbox_lesson_plus(GtkWidget *widget, gpointer user_data)
Definition: callbacks.c:402
G_MODULE_EXPORT void on_button_fluid_clicked(GtkButton *button, gpointer user_data)
Definition: callbacks.c:93
G_MODULE_EXPORT void on_button_top10_go_www_clicked(GtkButton *button, gpointer user_data)
Definition: callbacks.c:860
G_MODULE_EXPORT void on_button_tutor_stat_clicked(GtkButton *button, gpointer user_data)
Definition: callbacks.c:448
G_MODULE_EXPORT void on_window_tutor_show(GtkWidget *wg, gpointer user_data)
Definition: callbacks.c:1807
G_MODULE_EXPORT void on_button_keyboard_hands_clicked(GtkButton *but, gpointer user_data)
Definition: callbacks.c:1034
G_MODULE_EXPORT void on_button_top10_update_clicked(GtkButton *button, gpointer user_data)
Definition: callbacks.c:886
G_MODULE_EXPORT void on_togglebutton_edit_basic_lesson_toggled(GtkToggleButton *togglebutton, gpointer user_data)
Definition: callbacks.c:467
G_MODULE_EXPORT void on_virtual_key_grab_focus(GtkWidget *wg, gpointer user_data)
Definition: callbacks.c:1113
G_MODULE_EXPORT void on_button_adapt_clicked(GtkButton *button, gpointer user_data)
Definition: callbacks.c:79
G_MODULE_EXPORT void on_window_hints_show(GtkWidget *wg, gpointer user_data)
Definition: callbacks.c:1813
G_MODULE_EXPORT void on_button_filechooser_cancel_clicked(GtkButton *button, gpointer user_data)
Definition: callbacks.c:1791
G_MODULE_EXPORT void on_entry_other_rename_changed(GtkEditable *editable, gint start_pos, gint end_pos, gpointer user_data)
Definition: callbacks.c:1677
void callbacks_shield_set(gboolean state)
Definition: callbacks.c:57
G_MODULE_EXPORT void on_combobox_keyboard_country_changed(GtkComboBox *cmb, gpointer user_data)
Definition: callbacks.c:932
GtkClipboard * clipboard_2
Definition: callbacks.c:46
G_MODULE_EXPORT void on_treeview_other_cursor_changed(GtkTreeView *treeview, gpointer user_data)
Definition: callbacks.c:1708
G_MODULE_EXPORT void on_button_kb_remove_clicked(GtkButton *button, gpointer user_data)
Definition: callbacks.c:972
G_MODULE_EXPORT void on_button_other_new_clicked(GtkButton *button, gpointer user_data)
Definition: callbacks.c:1531
G_MODULE_EXPORT void on_combobox_kbd_country_changed(GtkComboBox *cmb, gpointer user_data)
Definition: callbacks.c:135
G_MODULE_EXPORT void on_virtual_key_clicked(GtkButton *button, gpointer user_data)
Definition: callbacks.c:1125
void window_restore(gchar *who)
Definition: callbacks.c:1831
G_MODULE_EXPORT void on_window_hints_check_resize(GtkContainer *cont, gpointer user_data)
Definition: callbacks.c:1344
GtkClipboard * clipboard
Definition: callbacks.c:45
G_MODULE_EXPORT void on_toggle_shift1_grab_focus(GtkToggleButton *tg, gpointer user_data)
Definition: callbacks.c:1095
G_MODULE_EXPORT void on_eventbox_stat_minus(GtkWidget *widget, gpointer user_data)
Definition: callbacks.c:436
G_MODULE_EXPORT void on_treeview_other_realize(GtkWidget *widget, gpointer user_data)
Definition: callbacks.c:1517
G_MODULE_EXPORT void on_entry_mesg_icon_release(GtkEntry *entry, GtkEntryIconPosition pos, GdkEvent *event, gpointer user_data)
Definition: callbacks.c:652
G_MODULE_EXPORT void on_button_top10_expand_clicked(GtkButton *button, gpointer user_data)
Definition: callbacks.c:902
G_MODULE_EXPORT void on_fontbutton_tutor_font_set(GtkFontButton *fbut, gpointer user_data)
Definition: callbacks.c:553
G_MODULE_EXPORT gboolean on_entry_mesg_focus_out_event(GtkWidget *widget, GdkEventFocus *event, gpointer user_data)
Definition: callbacks.c:661
G_MODULE_EXPORT void on_button_other_apply_clicked(GtkButton *button, gpointer user_data)
Definition: callbacks.c:1545
static gboolean mesg_drag_drop
Definition: callbacks.c:53
G_MODULE_EXPORT void on_combobox_top10_language_changed(GtkComboBox *cmb, gpointer user_data)
Definition: callbacks.c:837
void window_save(gchar *who)
Definition: callbacks.c:1862
static gboolean callbacks_shield
Definition: callbacks.c:52
G_MODULE_EXPORT void on_button_other_paste_clicked(GtkButton *button, gpointer user_data)
Definition: callbacks.c:1583
G_MODULE_EXPORT void on_togglebutton_altcolor_toggled(GtkToggleButton *togglebutton, gpointer user_data)
Definition: callbacks.c:585
G_MODULE_EXPORT void on_button_other_remove_clicked(GtkButton *button, gpointer user_data)
Definition: callbacks.c:1632
static void cb_color_tag(gchar *tag, gchar *fgcolor, gchar *bgcolor, GtkTextBuffer *tbuf)
Definition: callbacks.c:191
G_MODULE_EXPORT void on_window_top10_show(GtkWidget *wg, gpointer user_data)
Definition: callbacks.c:1819
G_MODULE_EXPORT void on_eventbox_lesson_minus(GtkWidget *widget, gpointer user_data)
Definition: callbacks.c:413
G_MODULE_EXPORT void on_button_stat_reset_clicked(GtkButton *button, gpointer check)
Definition: callbacks.c:1485
G_MODULE_EXPORT void on_window_tutor_destroy(GtkWidget *object, gpointer user_data)
Definition: callbacks.c:628
G_MODULE_EXPORT void on_eventbox_tutor_restart_grab_focus(GtkWidget *widget, gpointer user_data)
Definition: callbacks.c:646
G_MODULE_EXPORT void on_button_about_clicked(GtkButton *button, gpointer user_data)
Definition: callbacks.c:100
G_MODULE_EXPORT void on_combobox_keyboard_variant_changed(GtkComboBox *cmb, gpointer user_data)
Definition: callbacks.c:952
G_MODULE_EXPORT void on_window_main_show(GtkWidget *wg, gpointer user_data)
Definition: callbacks.c:1801
G_MODULE_EXPORT void on_entry_mesg_insert_text(GtkEditable *editable, gchar *new_text, gint new_text_length, gpointer position, gpointer user_data)
Definition: callbacks.c:718
gunichar cursor_get_char()
Definition: cursor.c:131
void fluid_text_write_to_file(gchar *text_raw)
Definition: fluidness.c:433
void fluid_init_paragraph_list(gchar *list_name)
Definition: fluidness.c:174
void fluid_copy_text_file(gchar *file_name)
Definition: fluidness.c:474
guint i
Definition: keyboard.c:55
gchar * keyb_get_name()
Definition: keyboard.c:204
GtkWidget * entry
Definition: keyboard.c:52
void keyb_intro_step_previous()
Definition: keyboard.c:1155
void hints_demo_fingers(guint msec)
Definition: keyboard.c:1969
GtkWidget * but[4][(14+1) - 1]
Definition: keyboard.c:50
void keyb_set_chars()
Definition: keyboard.c:361
void keyb_remove_user_layout()
Definition: keyboard.c:640
void keyb_set_keyboard_layouts()
Definition: keyboard.c:797
void keyb_update_virtual_layout()
Definition: keyboard.c:671
void keyb_mode_hint()
Definition: keyboard.c:1411
void keyb_update_combos(gchar *cmb_country, gchar *cmb_variant)
Definition: keyboard.c:1101
gchar * keyb_get_utf8_paragraph_symbol()
Definition: keyboard.c:1649
void keyb_edit_button(GtkButton *button)
Definition: keyboard.c:1532
void keyb_set_name(const gchar *name)
Definition: keyboard.c:216
void hints_update_from_char(gunichar character)
Definition: keyboard.c:1911
gchar * keyb_mode_get_name()
Definition: keyboard.c:1358
void keyb_mode_intro()
Definition: keyboard.c:1377
void keyb_mode_edit()
Definition: keyboard.c:1446
void keyb_intro_step_next()
Definition: keyboard.c:1148
struct @4::@6 pos
void keyb_update_from_variant(gchar *cmb_country, gchar *cmb_variant)
Definition: keyboard.c:853
void keyb_set_combo_kbd_variant(gchar *cmb_country, gchar *cmb_variant)
Definition: keyboard.c:914
void keyb_save_new_layout()
Definition: keyboard.c:608
void hints_update_from_button(GtkButton *button)
Definition: keyboard.c:1880
void keyb_edit_none(void)
Definition: keyboard.c:1557
void keyb_change_key(gunichar real_key)
Definition: keyboard.c:1609
#define KEYB_AUTO_SAVE
Definition: keyboard.h:18
#define UPSYM
Definition: keyboard.h:23
gboolean main_velo_txt()
Definition: main.c:91
gint main_preferences_get_int(gchar *group, gchar *key)
Definition: main.c:121
void main_window_pass_away()
Definition: main.c:572
gchar * main_preferences_get_string(gchar *group, gchar *key)
Definition: main.c:109
static struct @7 path
void main_preferences_set_boolean(gchar *group, gchar *key, gboolean value)
Definition: main.c:139
void main_preferences_set_int(gchar *group, gchar *key, gint value)
Definition: main.c:127
gchar * main_path_user()
Definition: main.c:61
gboolean main_preferences_exist(gchar *group, gchar *key)
Definition: main.c:97
void main_preferences_set_string(gchar *group, gchar *key, gchar *value)
Definition: main.c:115
void main_altcolor_set_boolean(gchar *group, gchar *key, gboolean value)
Definition: main.c:164
gboolean main_altcolor_get_boolean(gchar *group, gchar *key)
Definition: main.c:158
gchar * main_altcolor_get_string(gchar *group, gchar *key)
Definition: main.c:151
gchar * main_path_stats()
Definition: main.c:67
gchar * data
Definition: main.c:53
gboolean main_preferences_get_boolean(gchar *group, gchar *key)
Definition: main.c:133
void main_preferences_save()
Definition: main.c:170
#define LESSON_FONT
Definition: main.h:27
#define LOCAL
Definition: main.h:38
#define GLOBAL
Definition: main.h:39
#define LESSON_FONT_BO
Definition: main.h:36
gfloat x[50+1]
Definition: plot.c:52
void plot_draw_chart(gint pltype)
Definition: plot.c:292
void plot_pointer_update(gdouble x)
Definition: plot.c:660
void plot_initialize()
Definition: plot.c:248
gfloat y[50+1]
Definition: plot.c:53
void top10_message(gchar *msg)
Definition: top10.c:134
gboolean top10_global_update(gpointer data)
Definition: top10.c:798
gboolean top10_global_publish(gpointer data)
Definition: top10.c:884
void top10_show_stats(gboolean locally)
Definition: top10.c:690
gchar * trans_get_current_language()
Definition: translation.c:471
void trans_change_language(gchar *language)
Definition: translation.c:498
gboolean tutor_is_tibetan()
Definition: tutor.c:121
void tutor_load_list_other(gchar *file_name_end, GtkListStore *list)
Definition: tutor.c:1611
void tutor_other_rename(const gchar *new_tx, const gchar *old_tx)
Definition: tutor.c:1660
void tutor_update()
Definition: tutor.c:434
void tutor_init_goals()
Definition: tutor.c:182
void tutor_set_query(TutorQuery query)
Definition: tutor.c:146
void tutor_process_touch(gunichar user_chr)
Definition: tutor.c:631
TutorType tutor_get_type()
Definition: tutor.c:107
gchar * tutor_get_type_name()
Definition: tutor.c:113
TutorQuery tutor_get_query()
Definition: tutor.c:140
void tutor_init(TutorType tt_type)
Definition: tutor.c:294
#define TUTOR_GREEN
Definition: tutor.h:26
#define TUTOR_BLUE_LITE
Definition: tutor.h:28
#define TUTOR_RED_LITE
Definition: tutor.h:25
#define TUTOR_CREAM
Definition: tutor.h:34
#define TUTOR_WHITE
Definition: tutor.h:35
#define TUTOR_BROWN
Definition: tutor.h:30
#define TUTOR_YELLOW
Definition: tutor.h:29
#define TUTOR_BLACK
Definition: tutor.h:31
#define TUTOR_RED
Definition: tutor.h:24
#define TUTOR_BLUE
Definition: tutor.h:27
@ TT_VELO
Definition: tutor.h:41
@ TT_FLUID
Definition: tutor.h:42
@ TT_BASIC
Definition: tutor.h:39
@ TT_ADAPT
Definition: tutor.h:40
@ QUERY_INTRO
Definition: tutor.h:47
@ QUERY_END
Definition: tutor.h:50
#define TUTOR_GRAY
Definition: tutor.h:32
GList * list
Definition: velocity.c:39
gint len
Definition: velocity.c:40
void velo_text_write_to_file(gchar *text_raw, gboolean overwrite)
Definition: velocity.c:330
void velo_init_dict(gchar *list_name)
Definition: velocity.c:91
void velo_create_dict(gchar *file_name, gboolean overwrite)
Definition: velocity.c:376