1 #include "../../config.h"
3 #include <glib/gi18n.h>
6 #include "../Common/Common.h"
7 #include "DasherTypes.h"
8 //#include "FontDialogues.h"
9 #include "Preferences.h"
10 #include "Parameters.h"
11 #include "module_settings_window.h"
13 #define DASHER_PREFERENCES_DIALOGUE_PRIVATE(pSelf) (DasherPreferencesDialoguePrivate *)(pSelf->private_data);
15 /* Static global member - use to deal with callbacks */
16 static DasherPreferencesDialogue
*g_pPreferencesDialogue
= NULL
;
18 // TODO: Reintroduce advanced settings and start on mouse position offset
20 typedef struct _BoolTranslation BoolTranslation
;
22 struct _BoolTranslation
{
28 // Checkbox widgets which map directly to boolean parameters
32 BoolTranslation sBoolTranslationTable
[] = {
33 {BP_DRAW_MOUSE_LINE
, "showmouselinebutton", NULL
},
34 {BP_DRAW_MOUSE
, "showmousebutton", NULL
},
35 {BP_SHOW_SLIDER
, "speedsliderbutton", NULL
},
36 {APP_BP_SHOW_TOOLBAR
, "toolbarbutton", NULL
},
37 {BP_OUTLINE_MODE
, "outlinebutton", NULL
},
38 {BP_CONTROL_MODE
, "control_controlmode", NULL
},
39 {APP_BP_TIME_STAMP
, "timestampbutton", NULL
},
40 {APP_BP_DOCK
, "dockbutton", NULL
},
41 {BP_START_MOUSE
, "leftbutton", NULL
},
42 {BP_START_SPACE
, "spacebutton", NULL
},
43 {BP_PAUSE_OUTSIDE
, "winpausebutton", NULL
},
44 {BP_AUTO_SPEEDCONTROL
, "adaptivebutton", NULL
},
45 {BP_LM_ADAPTIVE
, "cb_adaptive", NULL
}
50 // List widgets which map directly to string parameters
52 typedef struct _StringTranslation StringTranslation
;
54 struct _StringTranslation
{
64 StringTranslation sStringTranslationTable
[] = {
65 {SP_ALPHABET_ID
, "AlphabetTree", NULL
, NULL
, NULL
},
66 {SP_COLOUR_ID
, "ColorTree", NULL
, NULL
, NULL
},
71 StringTranslation sStringTranslationTable
[] = {
72 {SP_ALPHABET_ID
, "AlphabetTree", NULL
, NULL
, NULL
},
73 {SP_COLOUR_ID
, "ColorTree", NULL
, NULL
, NULL
},
74 {SP_INPUT_FILTER
, "input_filter_tree_view", NULL
, "button13", NULL
},
75 {SP_INPUT_DEVICE
, "input_tree_view", NULL
, "button25", NULL
}
84 ACTIONS_CONTROL_COLUMN
,
89 // TODO: Look at coding convention stuff for gobjets
91 /// Newer, object based stuff
93 struct _DasherPreferencesDialoguePrivate
{
94 GtkWidget
*pPreferencesWindow
;
95 DasherEditorInternal
*pEditor
;
96 DasherAppSettings
*pAppSettings
;
97 GtkWindow
*pMainWindow
;
99 // TODO: it really would be nice not to have to keep this arround
102 // TODO: check all of these are really needed
103 GtkListStore
*pListStore
;
104 GtkWidget
*pLRButton
;
105 GtkWidget
*pRLButton
;
106 GtkWidget
*pTBButton
;
107 GtkWidget
*pBTButton
;
108 GtkWidget
*pSpeedSlider
;
109 GtkWidget
*pMousePosButton
;
110 GtkWidget
*pMousePosStyle
;
111 GtkWidget
*pActionTreeView
;
112 GtkWidget
*pNotebook
;
114 // Set this to ignore signals (ie loops coming back from setting widgets in response to parameters having changed)
118 typedef struct _DasherPreferencesDialoguePrivate DasherPreferencesDialoguePrivate
;
120 // Private member functions
121 static void dasher_preferences_dialogue_class_init(DasherPreferencesDialogueClass
*pClass
);
122 static void dasher_preferences_dialogue_init(DasherPreferencesDialogue
*pMain
);
123 static void dasher_preferences_dialogue_destroy(GObject
*pObject
);
125 static GtkWidget
*dasher_preferences_dialogue_get_helper(DasherPreferencesDialogue
*pSelf
, int iParameter
, const gchar
*szValue
);
126 static void dasher_preferences_dialogue_initialise_tables(DasherPreferencesDialogue
*pSelf
);
127 static void dasher_preferences_dialogue_refresh_widget(DasherPreferencesDialogue
*pSelf
, gint iParameter
);
128 static void dasher_preferences_dialogue_populate_list(DasherPreferencesDialogue
*pSelf
, GtkTreeView
*pView
, int iParameter
, GtkWidget
*pHelper
);
129 static void dasher_preferences_dialogue_update_special(DasherPreferencesDialogue
*pSelf
, int iID
);
130 static void dasher_preferences_dialogue_refresh_parameter(DasherPreferencesDialogue
*pSelf
, GtkWidget
*pWidget
, gpointer pUserData
);
132 /* Special privalte members called via table (see below) */
133 static void dasher_preferences_dialogue_populate_special_speed(DasherPreferencesDialogue
*pSelf
);
134 static void dasher_preferences_dialogue_populate_special_mouse_start(DasherPreferencesDialogue
*pSelf
);
135 static void dasher_preferences_dialogue_populate_special_orientation(DasherPreferencesDialogue
*pSelf
);
136 static void dasher_preferences_dialogue_populate_special_appstyle(DasherPreferencesDialogue
*pSelf
);
137 static void dasher_preferences_dialogue_populate_special_linewidth(DasherPreferencesDialogue
*pSelf
);
138 static void dasher_preferences_dialogue_populate_special_lm(DasherPreferencesDialogue
*pSelf
);
139 static void dasher_preferences_dialogue_populate_special_uniform(DasherPreferencesDialogue
*pSelf
);
140 static void dasher_preferences_dialogue_populate_special_colour(DasherPreferencesDialogue
*pSelf
);
141 static void dasher_preferences_dialogue_populate_special_dasher_font(DasherPreferencesDialogue
*pSelf
);
142 static void dasher_preferences_dialogue_populate_special_edit_font(DasherPreferencesDialogue
*pSelf
);
143 static void dasher_preferences_dialogue_populate_special_fontsize(DasherPreferencesDialogue
*pSelf
);
145 static void dasher_preferences_dialogue_populate_actions(DasherPreferencesDialogue
*pSelf
);
147 typedef struct _SpecialControl SpecialControl
;
149 struct _SpecialControl
{
151 void (*pPopulate
)(DasherPreferencesDialogue
*);
155 SpecialControl sSpecialControlTable
[] = {
156 {LP_MAX_BITRATE
, dasher_preferences_dialogue_populate_special_speed
, true},
157 {BP_MOUSEPOS_MODE
, dasher_preferences_dialogue_populate_special_mouse_start
, true},
158 {BP_CIRCLE_START
, dasher_preferences_dialogue_populate_special_mouse_start
, false},
159 {LP_ORIENTATION
, dasher_preferences_dialogue_populate_special_orientation
, true},
160 {LP_REAL_ORIENTATION
, dasher_preferences_dialogue_populate_special_orientation
, false},
161 {APP_LP_STYLE
, dasher_preferences_dialogue_populate_special_appstyle
, true},
162 {LP_LINE_WIDTH
, dasher_preferences_dialogue_populate_special_linewidth
, true},
163 {LP_LANGUAGE_MODEL_ID
, dasher_preferences_dialogue_populate_special_lm
, true},
164 {LP_UNIFORM
, dasher_preferences_dialogue_populate_special_uniform
, true},
165 {BP_PALETTE_CHANGE
, dasher_preferences_dialogue_populate_special_colour
, true},
166 {SP_DASHER_FONT
, dasher_preferences_dialogue_populate_special_dasher_font
, true},
167 {APP_SP_EDIT_FONT
, dasher_preferences_dialogue_populate_special_edit_font
, true},
168 {LP_DASHER_FONTSIZE
, dasher_preferences_dialogue_populate_special_fontsize
, true}
171 // Callback functions
172 extern "C" void on_action_toggle(GtkCellRendererToggle
*pRenderer
, gchar
*szPath
, gpointer pUserData
);
173 extern "C" void on_list_selection(GtkTreeSelection
*pSelection
, gpointer pUserData
);
174 extern "C" void on_widget_realize(GtkWidget
*pWidget
, gpointer pUserData
);
175 extern "C" gboolean
show_helper_window(GtkWidget
*pWidget
, gpointer
*pUserData
);
176 extern "C" gboolean
dasher_preferences_refresh_foreach_function(GtkTreeModel
*pModel
, GtkTreePath
*pPath
, GtkTreeIter
*pIter
, gpointer pUserData
);
179 /* Start definitions */
182 GType
dasher_preferences_dialogue_get_type() {
184 static GType dasher_preferences_dialogue_type
= 0;
186 if(!dasher_preferences_dialogue_type
) {
187 static const GTypeInfo dasher_preferences_dialogue_info
= {
188 sizeof(DasherPreferencesDialogueClass
),
191 (GClassInitFunc
) dasher_preferences_dialogue_class_init
,
194 sizeof(DasherPreferencesDialogue
),
196 (GInstanceInitFunc
) dasher_preferences_dialogue_init
,
200 dasher_preferences_dialogue_type
= g_type_register_static(G_TYPE_OBJECT
, "DasherPreferencesDialogue", &dasher_preferences_dialogue_info
, static_cast < GTypeFlags
> (0));
203 return dasher_preferences_dialogue_type
;
206 static void dasher_preferences_dialogue_class_init(DasherPreferencesDialogueClass
*pClass
) {
207 GObjectClass
*pObjectClass
= (GObjectClass
*) pClass
;
208 pObjectClass
->finalize
= dasher_preferences_dialogue_destroy
;
211 static void dasher_preferences_dialogue_init(DasherPreferencesDialogue
*pDasherControl
) {
212 pDasherControl
->private_data
= new DasherPreferencesDialoguePrivate
;
215 static void dasher_preferences_dialogue_destroy(GObject
*pObject
) {
216 // FIXME - I think we need to chain up through the finalize methods
217 // of the parent classes here...
222 DasherPreferencesDialogue
*dasher_preferences_dialogue_new(GladeXML
*pGladeWidgets
, DasherEditorInternal
*pEditor
, DasherAppSettings
*pAppSettings
, GtkWindow
*pMainWindow
) {
223 DasherPreferencesDialogue
*pDasherControl
;
224 pDasherControl
= (DasherPreferencesDialogue
*)(g_object_new(dasher_preferences_dialogue_get_type(), NULL
));
226 g_pPreferencesDialogue
= pDasherControl
;
228 DasherPreferencesDialoguePrivate
*pPrivate
= (DasherPreferencesDialoguePrivate
*)(pDasherControl
->private_data
);
230 pPrivate
->bIgnoreSignals
= false;
232 pPrivate
->pEditor
= pEditor
;
233 pPrivate
->pAppSettings
= pAppSettings
;
235 pPrivate
->pGladeXML
= pGladeWidgets
;
237 pPrivate
->pPreferencesWindow
= glade_xml_get_widget(pGladeWidgets
, "preferences");
239 pPrivate
->pActionTreeView
=glade_xml_get_widget(pGladeWidgets
, "action_tree_view");
240 pPrivate
->pNotebook
= glade_xml_get_widget(pGladeWidgets
, "notebook1");
242 gtk_window_set_transient_for(GTK_WINDOW(pPrivate
->pPreferencesWindow
), pMainWindow
);
244 pPrivate
->pMainWindow
= pMainWindow
;
246 pPrivate
->pSpeedSlider
= glade_xml_get_widget(pGladeWidgets
, "hscale1");
247 dasher_preferences_dialogue_initialise_tables(pDasherControl
);
248 dasher_preferences_dialogue_refresh_widget(pDasherControl
, -1);
249 dasher_preferences_dialogue_update_special(pDasherControl
, -1);
252 gtk_widget_hide(glade_xml_get_widget(pGladeWidgets
, "radiobutton9"));
255 dasher_preferences_dialogue_populate_actions(pDasherControl
);
257 // InitialiseFontDialogues(pGladeWidgets, pAppSettings);
259 return pDasherControl
;
262 void dasher_preferences_dialogue_show(DasherPreferencesDialogue
*pSelf
, gint iPage
) {
263 DasherPreferencesDialoguePrivate
*pPrivate
= (DasherPreferencesDialoguePrivate
*)(pSelf
->private_data
);
264 // FIXME - REIMPLEMENT
266 // Keep the preferences window in the correct position relative to the
267 // main Dasher window
269 // gtk_window_set_transient_for(GTK_WINDOW(pPrivate->pPreferencesWindow),pPrivate->pMainWindow);
271 #ifndef WITH_MAEMOFULLSCREEN
272 // gtk_window_set_keep_above((pPrivate->pPreferencesWindow), true);
276 // gtk_window_set_keep_above(GTK_WINDOW(pPrivate->pPreferencesWindow), dasher_main_topmost(g_pDasherMain));
279 gtk_notebook_set_current_page(GTK_NOTEBOOK(pPrivate
->pNotebook
), iPage
- 1);
282 gtk_window_present(GTK_WINDOW(pPrivate
->pPreferencesWindow
));
286 void dasher_preferences_dialogue_handle_parameter_change(DasherPreferencesDialogue
*pSelf
, int iParameter
) {
287 dasher_preferences_dialogue_refresh_widget(pSelf
, iParameter
);
288 dasher_preferences_dialogue_update_special(pSelf
, iParameter
);
292 // --- Generic Options ---
294 void dasher_preferences_dialogue_initialise_tables(DasherPreferencesDialogue
*pSelf
) {
295 DasherPreferencesDialoguePrivate
*pPrivate
= DASHER_PREFERENCES_DIALOGUE_PRIVATE(pSelf
);
299 int iNumBoolEntries
= sizeof(sBoolTranslationTable
) / sizeof(BoolTranslation
);
300 for(int i(0); i
< iNumBoolEntries
; ++i
) {
301 sBoolTranslationTable
[i
].pWidget
= glade_xml_get_widget(pPrivate
->pGladeXML
, sBoolTranslationTable
[i
].szWidgetName
);
305 int iNumStringEntries
= sizeof(sStringTranslationTable
) / sizeof(StringTranslation
);
306 for(int i(0); i
< iNumStringEntries
; ++i
) {
307 sStringTranslationTable
[i
].pWidget
= glade_xml_get_widget(pPrivate
->pGladeXML
, sStringTranslationTable
[i
].szWidgetName
);
308 if(sStringTranslationTable
[i
].szHelperName
)
309 sStringTranslationTable
[i
].pHelper
= glade_xml_get_widget(pPrivate
->pGladeXML
, sStringTranslationTable
[i
].szHelperName
);
311 dasher_preferences_dialogue_populate_list(pSelf
, GTK_TREE_VIEW(sStringTranslationTable
[i
].pWidget
), sStringTranslationTable
[i
].iParameter
, sStringTranslationTable
[i
].pHelper
);
312 g_signal_connect(sStringTranslationTable
[i
].pWidget
, "realize", (GCallback
)on_widget_realize
, &sStringTranslationTable
[i
].iParameter
);
316 extern "C" gboolean
dasher_preferences_refresh_foreach_function(GtkTreeModel
*pModel
, GtkTreePath
*pPath
, GtkTreeIter
*pIter
, gpointer pUserData
) {
317 gpointer
*pPointers
= (gpointer
*)pUserData
;
319 gchar
*szTarget
= (gchar
*)pPointers
[0];
322 gtk_tree_model_get(pModel
, pIter
, 2, &szComparison
, -1);
324 if(!strcmp(szTarget
, szComparison
)) {
325 // Todo: set selection here?
326 gtk_tree_view_set_cursor((GtkTreeView
*)pPointers
[1], pPath
, NULL
, false);
328 gtk_tree_view_scroll_to_cell((GtkTreeView
*)pPointers
[1], pPath
, NULL
, true, 0.5, 0.0);
337 void dasher_preferences_dialogue_refresh_widget(DasherPreferencesDialogue
*pSelf
, gint iParameter
) {
338 DasherPreferencesDialoguePrivate
*pPrivate
= DASHER_PREFERENCES_DIALOGUE_PRIVATE(pSelf
);
341 int iNumBoolEntries
= sizeof(sBoolTranslationTable
) / sizeof(BoolTranslation
);
342 for(int i(0); i
< iNumBoolEntries
; ++i
) {
343 if((iParameter
== -1) || (sBoolTranslationTable
[i
].iParameter
== iParameter
)) {
344 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(sBoolTranslationTable
[i
].pWidget
), dasher_app_settings_get_bool(pPrivate
->pAppSettings
, sBoolTranslationTable
[i
].iParameter
));
349 // TODO: I believe that this is being called initially before the
350 // widgets are realised, so the selection isn't being correctly
352 int iNumStringEntries
= sizeof(sStringTranslationTable
) / sizeof(StringTranslation
);
353 for(int i(0); i
< iNumStringEntries
; ++i
) {
354 if((iParameter
== -1) || (sStringTranslationTable
[i
].iParameter
== iParameter
)) {
355 GtkTreeModel
*pModel
= gtk_tree_view_get_model(GTK_TREE_VIEW(sStringTranslationTable
[i
].pWidget
));
357 // TODO: tidy up in a struct
358 const void *pUserData
[3];
359 pUserData
[0] = dasher_app_settings_get_string(pPrivate
->pAppSettings
, sStringTranslationTable
[i
].iParameter
);
360 pUserData
[1] = GTK_TREE_VIEW(sStringTranslationTable
[i
].pWidget
);
361 pUserData
[2] = pSelf
;
363 if(sStringTranslationTable
[i
].pWidget
&& GTK_WIDGET_REALIZED(sStringTranslationTable
[i
].pWidget
))
364 gtk_tree_model_foreach(pModel
, dasher_preferences_refresh_foreach_function
, pUserData
);
369 static void dasher_preferences_dialogue_refresh_parameter(DasherPreferencesDialogue
*pSelf
, GtkWidget
*pWidget
, gpointer pUserData
) {
371 DasherPreferencesDialoguePrivate
*pPrivate
= DASHER_PREFERENCES_DIALOGUE_PRIVATE(pSelf
);
373 int iNumBoolEntries
= sizeof(sBoolTranslationTable
) / sizeof(BoolTranslation
);
375 for(int i(0); i
< iNumBoolEntries
; ++i
) {
376 if((pWidget
== NULL
) || (sBoolTranslationTable
[i
].pWidget
== pWidget
)) {
378 if(GTK_TOGGLE_BUTTON(sBoolTranslationTable
[i
].pWidget
)->active
!= dasher_app_settings_get_bool(pPrivate
->pAppSettings
, sBoolTranslationTable
[i
].iParameter
)) {
380 dasher_app_settings_set_bool(pPrivate
->pAppSettings
, sBoolTranslationTable
[i
].iParameter
, GTK_TOGGLE_BUTTON(sBoolTranslationTable
[i
].pWidget
)->active
);
387 // TODO: Is this function actually useful? (conversely, is the other call to RefreshFoo elsewhere any use?)
388 extern "C" void on_widget_realize(GtkWidget
*pWidget
, gpointer pUserData
) {
389 gint
*pParameter
= (gint
*)pUserData
;
390 dasher_preferences_dialogue_refresh_widget(g_pPreferencesDialogue
, *pParameter
); // TODO: Fix NULL pointer
393 // --- Generic boolean options ---
395 extern "C" void generic_bool_changed(GtkWidget
*widget
, gpointer user_data
) {
396 dasher_preferences_dialogue_refresh_parameter(g_pPreferencesDialogue
, widget
, user_data
);// TODO: fix NULL
399 // --- Generic string options ---
401 void dasher_preferences_dialogue_populate_list(DasherPreferencesDialogue
*pSelf
, GtkTreeView
*pView
, int iParameter
, GtkWidget
*pHelper
) {
402 DasherPreferencesDialoguePrivate
*pPrivate
= DASHER_PREFERENCES_DIALOGUE_PRIVATE(pSelf
);
404 // TODO: Need to kill helpers on list depopulation
406 const gchar
*szCurrentValue(dasher_app_settings_get_string(pPrivate
->pAppSettings
, iParameter
));
408 GArray
*pFilterArray
= dasher_app_settings_get_allowed_values(pPrivate
->pAppSettings
, iParameter
);
410 GtkListStore
*pStore
= gtk_list_store_new(6, G_TYPE_INT
, G_TYPE_POINTER
, G_TYPE_STRING
, G_TYPE_STRING
, G_TYPE_POINTER
, G_TYPE_POINTER
);
411 gtk_tree_view_set_model(pView
, GTK_TREE_MODEL(pStore
));
413 GtkCellRenderer
*pRenderer
;
414 GtkTreeViewColumn
*pColumn
;
416 pRenderer
= gtk_cell_renderer_text_new();
417 pColumn
= gtk_tree_view_column_new_with_attributes("Action", pRenderer
, "text", 2, NULL
);
418 gtk_tree_view_append_column(pView
, pColumn
);
421 // GtkTreeIter oSelectedIter;
422 GtkTreeSelection
*pSelection
= gtk_tree_view_get_selection(pView
);
424 GtkWidget
**pHelperWindowRef
= new GtkWidget
*;
426 for(unsigned int i(0); i
< pFilterArray
->len
; ++i
) {
427 const gchar
*szCurrentFilter
= g_array_index(pFilterArray
, gchar
*, i
);
428 gchar
*szName
= new gchar
[strlen(szCurrentFilter
) + 1];
429 strcpy(szName
, szCurrentFilter
);
431 gtk_list_store_append(pStore
, &oIter
);
432 GtkWidget
*pHelperWindow
;
435 pHelperWindow
= dasher_preferences_dialogue_get_helper(pSelf
, iParameter
, szName
);
436 g_signal_connect(G_OBJECT(pHelper
), "clicked", G_CALLBACK(show_helper_window
), pHelperWindowRef
);
439 pHelperWindow
= NULL
;
441 // This is potentially horrible - maybe rethink in the future;
442 gtk_list_store_set(pStore
, &oIter
, 0, iParameter
, 1, pHelper
, 2, szName
, 3, szName
, 4, pHelperWindow
, 5, pHelperWindowRef
, -1);
444 if(!strcmp(szCurrentFilter
, szCurrentValue
)) {
445 gtk_tree_selection_select_iter(pSelection
, &oIter
);
447 gtk_widget_set_sensitive(GTK_WIDGET(pHelper
), pHelperWindow
!= NULL
);
448 *pHelperWindowRef
= pHelperWindow
;
453 g_signal_connect(pSelection
, "changed", (GCallback
)on_list_selection
, 0);
457 extern "C" void on_list_selection(GtkTreeSelection
*pSelection
, gpointer pUserData
) {
458 // DasherPreferencesDialoguePrivate *pPrivate = DASHER_PREFERENCES_DIALOGUE_PRIVATE(pSelf);
459 DasherPreferencesDialoguePrivate
*pPrivate
= DASHER_PREFERENCES_DIALOGUE_PRIVATE(g_pPreferencesDialogue
); // TODO: Fix null
462 GtkTreeModel
*pModel
;
464 if(gtk_tree_selection_get_selected(pSelection
, &pModel
, &oIter
)) {
467 gpointer pHelperWindow
;
468 gpointer pHelperWindowRef
;
470 gtk_tree_model_get(pModel
, &oIter
, 0, &iParameter
, 1, &pHelper
, 2, &szValue
, 4, &pHelperWindow
, 5, &pHelperWindowRef
, -1);
472 dasher_app_settings_set_string(pPrivate
->pAppSettings
, iParameter
, szValue
);
475 gtk_widget_set_sensitive(GTK_WIDGET(pHelper
), pHelperWindow
!= NULL
);
476 *((GtkWidget
**)pHelperWindowRef
) = (GtkWidget
*)pHelperWindow
;
481 GtkWidget
*dasher_preferences_dialogue_get_helper(DasherPreferencesDialogue
*pSelf
, int iParameter
, const gchar
*szValue
) {
482 DasherPreferencesDialoguePrivate
*pPrivate
= DASHER_PREFERENCES_DIALOGUE_PRIVATE(pSelf
);
484 SModuleSettings
*pSettings
;
487 if(!dasher_app_settings_get_module_settings(pPrivate
->pAppSettings
, szValue
, &pSettings
, &iCount
))
490 return module_settings_window_new(pPrivate
->pAppSettings
, szValue
, pSettings
, iCount
);
493 // --- Special Cases ---
495 static void dasher_preferences_dialogue_populate_special_speed(DasherPreferencesDialogue
*pSelf
) {
496 DasherPreferencesDialoguePrivate
*pPrivate
= DASHER_PREFERENCES_DIALOGUE_PRIVATE(pSelf
);
498 double dNewValue
= dasher_app_settings_get_long(pPrivate
->pAppSettings
, LP_MAX_BITRATE
) / 100.0;
499 gtk_range_set_value(GTK_RANGE(pPrivate
->pSpeedSlider
), dNewValue
);
502 static void dasher_preferences_dialogue_populate_special_mouse_start(DasherPreferencesDialogue
*pSelf
) {
504 DasherPreferencesDialoguePrivate
*pPrivate
= DASHER_PREFERENCES_DIALOGUE_PRIVATE(pSelf
);
506 pPrivate
->pMousePosButton
= glade_xml_get_widget(pPrivate
->pGladeXML
, "mouseposbutton");
507 pPrivate
->pMousePosStyle
= glade_xml_get_widget(pPrivate
->pGladeXML
, "MousePosStyle");
509 if(dasher_app_settings_get_bool(pPrivate
->pAppSettings
, BP_MOUSEPOS_MODE
)) {
510 gtk_combo_box_set_active(GTK_COMBO_BOX(pPrivate
->pMousePosStyle
), 1);
511 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(glade_xml_get_widget(pPrivate
->pGladeXML
, "mouseposbutton")), true);
513 else if(dasher_app_settings_get_bool(pPrivate
->pAppSettings
, BP_CIRCLE_START
)) {
514 gtk_combo_box_set_active(GTK_COMBO_BOX(pPrivate
->pMousePosStyle
), 0);
515 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(glade_xml_get_widget(pPrivate
->pGladeXML
, "mouseposbutton")), true);
518 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(glade_xml_get_widget(pPrivate
->pGladeXML
, "mouseposbutton")), false);
523 static void dasher_preferences_dialogue_populate_special_orientation(DasherPreferencesDialogue
*pSelf
) {
524 DasherPreferencesDialoguePrivate
*pPrivate
= DASHER_PREFERENCES_DIALOGUE_PRIVATE(pSelf
);
526 pPrivate
->pLRButton
= glade_xml_get_widget(pPrivate
->pGladeXML
, "radiobutton2");
527 pPrivate
->pRLButton
= glade_xml_get_widget(pPrivate
->pGladeXML
, "radiobutton3");
528 pPrivate
->pTBButton
= glade_xml_get_widget(pPrivate
->pGladeXML
, "radiobutton4");
529 pPrivate
->pBTButton
= glade_xml_get_widget(pPrivate
->pGladeXML
, "radiobutton5");
531 switch (dasher_app_settings_get_long(pPrivate
->pAppSettings
, LP_ORIENTATION
)) {
532 case Dasher::Opts::Alphabet
:
533 if(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(glade_xml_get_widget(pPrivate
->pGladeXML
, "radiobutton1"))) != TRUE
)
534 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(glade_xml_get_widget(pPrivate
->pGladeXML
, "radiobutton1")), TRUE
);
536 pPrivate
->bIgnoreSignals
= true;
538 switch (dasher_app_settings_get_long(pPrivate
->pAppSettings
, LP_REAL_ORIENTATION
)) {
539 case Dasher::Opts::LeftToRight
:
540 if(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(pPrivate
->pLRButton
)) != TRUE
)
541 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(pPrivate
->pLRButton
), TRUE
);
543 case Dasher::Opts::RightToLeft
:
544 if(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(pPrivate
->pRLButton
)) != TRUE
)
545 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(pPrivate
->pRLButton
), TRUE
);
547 case Dasher::Opts::TopToBottom
:
548 if(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(pPrivate
->pTBButton
)) != TRUE
)
549 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(pPrivate
->pTBButton
), TRUE
);
551 case Dasher::Opts::BottomToTop
:
552 if(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(pPrivate
->pTBButton
)) != TRUE
)
553 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(pPrivate
->pTBButton
), TRUE
);
557 pPrivate
->bIgnoreSignals
= false;
559 gtk_widget_set_sensitive(pPrivate
->pLRButton
, FALSE
);
560 gtk_widget_set_sensitive(pPrivate
->pRLButton
, FALSE
);
561 gtk_widget_set_sensitive(pPrivate
->pTBButton
, FALSE
);
562 gtk_widget_set_sensitive(pPrivate
->pBTButton
, FALSE
);
566 case Dasher::Opts::LeftToRight
:
567 if(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(glade_xml_get_widget(pPrivate
->pGladeXML
, "radiobutton2"))) != TRUE
)
568 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(glade_xml_get_widget(pPrivate
->pGladeXML
, "radiobutton2")), TRUE
);
569 if(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(glade_xml_get_widget(pPrivate
->pGladeXML
, "radiobutton12"))) != TRUE
)
570 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(glade_xml_get_widget(pPrivate
->pGladeXML
, "radiobutton12")), TRUE
);
572 gtk_widget_set_sensitive(pPrivate
->pLRButton
, TRUE
);
573 gtk_widget_set_sensitive(pPrivate
->pRLButton
, TRUE
);
574 gtk_widget_set_sensitive(pPrivate
->pTBButton
, TRUE
);
575 gtk_widget_set_sensitive(pPrivate
->pBTButton
, TRUE
);
577 case Dasher::Opts::RightToLeft
:
578 if(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(glade_xml_get_widget(pPrivate
->pGladeXML
, "radiobutton3"))) != TRUE
)
579 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(glade_xml_get_widget(pPrivate
->pGladeXML
, "radiobutton3")), TRUE
);
580 if(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(glade_xml_get_widget(pPrivate
->pGladeXML
, "radiobutton12"))) != TRUE
)
581 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(glade_xml_get_widget(pPrivate
->pGladeXML
, "radiobutton12")), TRUE
);
583 gtk_widget_set_sensitive(pPrivate
->pLRButton
, TRUE
);
584 gtk_widget_set_sensitive(pPrivate
->pRLButton
, TRUE
);
585 gtk_widget_set_sensitive(pPrivate
->pTBButton
, TRUE
);
586 gtk_widget_set_sensitive(pPrivate
->pBTButton
, TRUE
);
588 case Dasher::Opts::TopToBottom
:
589 if(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(glade_xml_get_widget(pPrivate
->pGladeXML
, "radiobutton4"))) != TRUE
)
590 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(glade_xml_get_widget(pPrivate
->pGladeXML
, "radiobutton4")), TRUE
);
591 if(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(glade_xml_get_widget(pPrivate
->pGladeXML
, "radiobutton12"))) != TRUE
)
592 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(glade_xml_get_widget(pPrivate
->pGladeXML
, "radiobutton12")), TRUE
);
594 gtk_widget_set_sensitive(pPrivate
->pLRButton
, TRUE
);
595 gtk_widget_set_sensitive(pPrivate
->pRLButton
, TRUE
);
596 gtk_widget_set_sensitive(pPrivate
->pTBButton
, TRUE
);
597 gtk_widget_set_sensitive(pPrivate
->pBTButton
, TRUE
);
599 case Dasher::Opts::BottomToTop
:
600 if(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(glade_xml_get_widget(pPrivate
->pGladeXML
, "radiobutton5"))) != TRUE
)
601 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(glade_xml_get_widget(pPrivate
->pGladeXML
, "radiobutton5")), TRUE
);
602 if(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(glade_xml_get_widget(pPrivate
->pGladeXML
, "radiobutton12"))) != TRUE
)
603 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(glade_xml_get_widget(pPrivate
->pGladeXML
, "radiobutton12")), TRUE
);
605 gtk_widget_set_sensitive(pPrivate
->pLRButton
, TRUE
);
606 gtk_widget_set_sensitive(pPrivate
->pRLButton
, TRUE
);
607 gtk_widget_set_sensitive(pPrivate
->pTBButton
, TRUE
);
608 gtk_widget_set_sensitive(pPrivate
->pBTButton
, TRUE
);
613 static void dasher_preferences_dialogue_populate_special_appstyle(DasherPreferencesDialogue
*pSelf
) {
615 DasherPreferencesDialoguePrivate
*pPrivate
= DASHER_PREFERENCES_DIALOGUE_PRIVATE(pSelf
);
617 switch(dasher_app_settings_get_long(pPrivate
->pAppSettings
, APP_LP_STYLE
)) {
619 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(glade_xml_get_widget(pPrivate
->pGladeXML
, "appstyle_classic")), TRUE
);
622 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(glade_xml_get_widget(pPrivate
->pGladeXML
, "appstyle_compose")), TRUE
);
625 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(glade_xml_get_widget(pPrivate
->pGladeXML
, "appstyle_direct")), TRUE
);
628 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(glade_xml_get_widget(pPrivate
->pGladeXML
, "appstyle_fullscreen")), TRUE
);
634 static void dasher_preferences_dialogue_populate_special_linewidth(DasherPreferencesDialogue
*pSelf
) {
636 DasherPreferencesDialoguePrivate
*pPrivate
= DASHER_PREFERENCES_DIALOGUE_PRIVATE(pSelf
);
638 if(dasher_app_settings_get_long(pPrivate
->pAppSettings
, LP_LINE_WIDTH
) > 1)
639 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(glade_xml_get_widget(pPrivate
->pGladeXML
, "thicklinebutton")), true);
641 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(glade_xml_get_widget(pPrivate
->pGladeXML
, "thicklinebutton")), false);
646 static void dasher_preferences_dialogue_populate_special_lm(DasherPreferencesDialogue
*pSelf
) {
647 DasherPreferencesDialoguePrivate
*pPrivate
= DASHER_PREFERENCES_DIALOGUE_PRIVATE(pSelf
);
649 switch( dasher_app_settings_get_long(pPrivate
->pAppSettings
, LP_LANGUAGE_MODEL_ID
)) {
651 if(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(glade_xml_get_widget(pPrivate
->pGladeXML
, "radiobutton6"))) != TRUE
)
652 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(glade_xml_get_widget(pPrivate
->pGladeXML
, "radiobutton6")), TRUE
);
655 if(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(glade_xml_get_widget(pPrivate
->pGladeXML
, "radiobutton7"))) != TRUE
)
656 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(glade_xml_get_widget(pPrivate
->pGladeXML
, "radiobutton7")), TRUE
);
659 if(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(glade_xml_get_widget(pPrivate
->pGladeXML
, "radiobutton8"))) != TRUE
)
660 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(glade_xml_get_widget(pPrivate
->pGladeXML
, "radiobutton8")), TRUE
);
663 if(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(glade_xml_get_widget(pPrivate
->pGladeXML
, "radiobutton9"))) != TRUE
)
664 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(glade_xml_get_widget(pPrivate
->pGladeXML
, "radiobutton9")), TRUE
);
671 static void dasher_preferences_dialogue_populate_special_uniform(DasherPreferencesDialogue
*pSelf
) {
672 DasherPreferencesDialoguePrivate
*pPrivate
= DASHER_PREFERENCES_DIALOGUE_PRIVATE(pSelf
);
674 gtk_range_set_value( GTK_RANGE(glade_xml_get_widget(pPrivate
->pGladeXML
, "uniformhscale")), dasher_app_settings_get_long(pPrivate
->pAppSettings
, LP_UNIFORM
)/10.0);
677 static void dasher_preferences_dialogue_populate_special_colour(DasherPreferencesDialogue
*pSelf
) {
678 DasherPreferencesDialoguePrivate
*pPrivate
= DASHER_PREFERENCES_DIALOGUE_PRIVATE(pSelf
);
680 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(glade_xml_get_widget(pPrivate
->pGladeXML
, "manual_colour")), !dasher_app_settings_get_bool(pPrivate
->pAppSettings
, BP_PALETTE_CHANGE
));
681 gtk_widget_set_sensitive(glade_xml_get_widget(pPrivate
->pGladeXML
, "ColorTree"), !dasher_app_settings_get_bool(pPrivate
->pAppSettings
, BP_PALETTE_CHANGE
));
684 static void dasher_preferences_dialogue_populate_special_dasher_font(DasherPreferencesDialogue
*pSelf
) {
685 DasherPreferencesDialoguePrivate
*pPrivate
= DASHER_PREFERENCES_DIALOGUE_PRIVATE(pSelf
);
687 GtkWidget
*pDasherFontButton
= glade_xml_get_widget(pPrivate
->pGladeXML
, "dasher_fontbutton");
689 gtk_font_button_set_font_name(GTK_FONT_BUTTON(pDasherFontButton
),
690 dasher_app_settings_get_string(pPrivate
->pAppSettings
, SP_DASHER_FONT
));
693 static void dasher_preferences_dialogue_populate_special_edit_font(DasherPreferencesDialogue
*pSelf
) {
694 DasherPreferencesDialoguePrivate
*pPrivate
= DASHER_PREFERENCES_DIALOGUE_PRIVATE(pSelf
);
696 GtkWidget
*pEditFontButton
= glade_xml_get_widget(pPrivate
->pGladeXML
, "edit_fontbutton");
698 gtk_font_button_set_font_name(GTK_FONT_BUTTON(pEditFontButton
),
699 dasher_app_settings_get_string(pPrivate
->pAppSettings
, APP_SP_EDIT_FONT
));
702 static void dasher_preferences_dialogue_populate_special_fontsize(DasherPreferencesDialogue
*pSelf
) {
703 DasherPreferencesDialoguePrivate
*pPrivate
= DASHER_PREFERENCES_DIALOGUE_PRIVATE(pSelf
);
705 int iValue
= dasher_app_settings_get_long(pPrivate
->pAppSettings
, LP_DASHER_FONTSIZE
);
706 gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON(glade_xml_get_widget(pPrivate
->pGladeXML
, "fontsizenormal")), iValue
== Opts::Normal
);
707 gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON(glade_xml_get_widget(pPrivate
->pGladeXML
, "fontsizelarge")), iValue
== Opts::Big
);
708 gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON(glade_xml_get_widget(pPrivate
->pGladeXML
, "fontsizevlarge")), iValue
== Opts::VBig
);
711 static void dasher_preferences_dialogue_update_special(DasherPreferencesDialogue
*pSelf
, int iID
) {
712 for(unsigned int i(0); i
< (sizeof(sSpecialControlTable
) / sizeof(SpecialControl
)); ++i
) {
713 if(((iID
== -1) && sSpecialControlTable
[i
].bPrimary
) || (sSpecialControlTable
[i
].iID
== iID
)) {
714 (sSpecialControlTable
[i
].pPopulate
)(pSelf
);
719 // --- Callbacks for 'special case' controls ---
721 // TODO: Give these a systematic naming convention
722 // TODO: Think about trying to combine OnMousePosStyleChanged and startonmousepos
724 extern "C" void OnMousePosStyleChanged(GtkWidget
*widget
, gpointer user_data
) {
725 // DasherPreferencesDialoguePrivate *pPrivate = DASHER_PREFERENCES_DIALOGUE_PRIVATE(pSelf);
726 DasherPreferencesDialoguePrivate
*pPrivate
= DASHER_PREFERENCES_DIALOGUE_PRIVATE(g_pPreferencesDialogue
); // TODO: Fix NULL
728 // FIXME - duplicate code from extern "C" void startonmousepos
729 if(GTK_TOGGLE_BUTTON(pPrivate
->pMousePosButton
)->active
) {
731 iIndex
= gtk_combo_box_get_active(GTK_COMBO_BOX(pPrivate
->pMousePosStyle
));
734 dasher_app_settings_set_bool(pPrivate
->pAppSettings
, BP_MOUSEPOS_MODE
, true);
735 dasher_app_settings_set_bool(pPrivate
->pAppSettings
, BP_CIRCLE_START
, false);
738 dasher_app_settings_set_bool(pPrivate
->pAppSettings
, BP_MOUSEPOS_MODE
, false);
739 dasher_app_settings_set_bool(pPrivate
->pAppSettings
, BP_CIRCLE_START
, true);
744 extern "C" void startonmousepos(GtkWidget
*widget
, gpointer user_data
) {
745 // DasherPreferencesDialoguePrivate *pPrivate = DASHER_PREFERENCES_DIALOGUE_PRIVATE(pSelf);
746 DasherPreferencesDialoguePrivate
*pPrivate
= DASHER_PREFERENCES_DIALOGUE_PRIVATE(g_pPreferencesDialogue
); // TODO: Fix NULL
748 if(GTK_TOGGLE_BUTTON(widget
)->active
) {
750 iIndex
= gtk_combo_box_get_active(GTK_COMBO_BOX(pPrivate
->pMousePosStyle
));
753 dasher_app_settings_set_bool(pPrivate
->pAppSettings
, BP_MOUSEPOS_MODE
, true);
754 dasher_app_settings_set_bool(pPrivate
->pAppSettings
, BP_CIRCLE_START
, false);
757 dasher_app_settings_set_bool(pPrivate
->pAppSettings
, BP_MOUSEPOS_MODE
, false);
758 dasher_app_settings_set_bool(pPrivate
->pAppSettings
, BP_CIRCLE_START
, true);
762 dasher_app_settings_set_bool(pPrivate
->pAppSettings
, BP_MOUSEPOS_MODE
, false);
763 dasher_app_settings_set_bool(pPrivate
->pAppSettings
, BP_CIRCLE_START
, false);
767 extern "C" void PrefsSpeedSliderChanged(GtkHScale
*hscale
, gpointer user_data
) {
768 // DasherPreferencesDialoguePrivate *pPrivate = DASHER_PREFERENCES_DIALOGUE_PRIVATE(pSelf);
769 DasherPreferencesDialoguePrivate
*pPrivate
= DASHER_PREFERENCES_DIALOGUE_PRIVATE(g_pPreferencesDialogue
); // TODO: Fix NULL
771 long iNewValue
= long(round(gtk_range_get_value(GTK_RANGE(hscale
)) * 100));
772 dasher_app_settings_set_long(pPrivate
->pAppSettings
, LP_MAX_BITRATE
, iNewValue
);
775 extern "C" void orientation(GtkRadioButton
*widget
, gpointer user_data
) {
776 // DasherPreferencesDialoguePrivate *pPrivate = DASHER_PREFERENCES_DIALOGUE_PRIVATE(pSelf);
777 DasherPreferencesDialoguePrivate
*pPrivate
= DASHER_PREFERENCES_DIALOGUE_PRIVATE(g_pPreferencesDialogue
); // TODO: Fix NULL
779 if(pPrivate
->bIgnoreSignals
)
782 // Again, this could be neater.
783 if(GTK_TOGGLE_BUTTON(widget
)->active
== TRUE
) {
784 if(!strcmp(gtk_widget_get_name(GTK_WIDGET(widget
)), "radiobutton1")) {
785 dasher_app_settings_set_long(pPrivate
->pAppSettings
, LP_ORIENTATION
, Dasher::Opts::Alphabet
);
787 // FIXME - get rid of global variables here.
789 gtk_widget_set_sensitive(pPrivate
->pLRButton
, FALSE
);
790 gtk_widget_set_sensitive(pPrivate
->pRLButton
, FALSE
);
791 gtk_widget_set_sensitive(pPrivate
->pTBButton
, FALSE
);
792 gtk_widget_set_sensitive(pPrivate
->pBTButton
, FALSE
);
795 pPrivate
->bIgnoreSignals
= true;
797 switch (dasher_app_settings_get_long(pPrivate
->pAppSettings
, LP_REAL_ORIENTATION
)) {
798 case Dasher::Opts::LeftToRight
:
799 if(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(pPrivate
->pLRButton
)) != TRUE
)
800 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(pPrivate
->pLRButton
), TRUE
);
802 case Dasher::Opts::RightToLeft
:
803 if(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(pPrivate
->pRLButton
)) != TRUE
)
804 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(pPrivate
->pRLButton
), TRUE
);
806 case Dasher::Opts::TopToBottom
:
807 if(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(pPrivate
->pTBButton
)) != TRUE
)
808 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(pPrivate
->pTBButton
), TRUE
);
810 case Dasher::Opts::BottomToTop
:
811 if(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(pPrivate
->pTBButton
)) != TRUE
)
812 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(pPrivate
->pTBButton
), TRUE
);
816 pPrivate
->bIgnoreSignals
= false;
818 else if(!strcmp(gtk_widget_get_name(GTK_WIDGET(widget
)), "radiobutton12")) {
819 gtk_widget_set_sensitive(pPrivate
->pLRButton
, TRUE
);
820 gtk_widget_set_sensitive(pPrivate
->pRLButton
, TRUE
);
821 gtk_widget_set_sensitive(pPrivate
->pTBButton
, TRUE
);
822 gtk_widget_set_sensitive(pPrivate
->pBTButton
, TRUE
);
824 dasher_app_settings_set_long(pPrivate
->pAppSettings
, LP_ORIENTATION
, dasher_app_settings_get_long(pPrivate
->pAppSettings
, LP_REAL_ORIENTATION
));
826 else if(!strcmp(gtk_widget_get_name(GTK_WIDGET(widget
)), "radiobutton2")) {
827 dasher_app_settings_set_long(pPrivate
->pAppSettings
, LP_ORIENTATION
, Dasher::Opts::LeftToRight
);
829 else if(!strcmp(gtk_widget_get_name(GTK_WIDGET(widget
)), "radiobutton3")) {
830 dasher_app_settings_set_long(pPrivate
->pAppSettings
, LP_ORIENTATION
, Dasher::Opts::RightToLeft
);
832 else if(!strcmp(gtk_widget_get_name(GTK_WIDGET(widget
)), "radiobutton4")) {
833 dasher_app_settings_set_long(pPrivate
->pAppSettings
, LP_ORIENTATION
, Dasher::Opts::TopToBottom
);
835 else if(!strcmp(gtk_widget_get_name(GTK_WIDGET(widget
)), "radiobutton5")) {
836 dasher_app_settings_set_long(pPrivate
->pAppSettings
, LP_ORIENTATION
, Dasher::Opts::BottomToTop
);
841 extern "C" void ThickLineClicked(GtkWidget
*widget
, gpointer user_data
) {
842 // DasherPreferencesDialoguePrivate *pPrivate = DASHER_PREFERENCES_DIALOGUE_PRIVATE(pSelf);
843 DasherPreferencesDialoguePrivate
*pPrivate
= DASHER_PREFERENCES_DIALOGUE_PRIVATE(g_pPreferencesDialogue
); // TODO: Fix NULL
845 if(GTK_TOGGLE_BUTTON(widget
)->active
)
846 dasher_app_settings_set_long(pPrivate
->pAppSettings
, LP_LINE_WIDTH
, 3);
848 dasher_app_settings_set_long(pPrivate
->pAppSettings
, LP_LINE_WIDTH
, 1);
851 extern "C" void autocolour_clicked(GtkWidget
*widget
, gpointer user_data
) {
852 // DasherPreferencesDialoguePrivate *pPrivate = DASHER_PREFERENCES_DIALOGUE_PRIVATE(pSelf);
853 DasherPreferencesDialoguePrivate
*pPrivate
= DASHER_PREFERENCES_DIALOGUE_PRIVATE(g_pPreferencesDialogue
); // TODO: Fix NULL
855 dasher_app_settings_set_bool(pPrivate
->pAppSettings
, BP_PALETTE_CHANGE
, !GTK_TOGGLE_BUTTON(widget
)->active
);
858 extern "C" void mouseposstart_y_changed(GtkRange
*widget
, gpointer user_data
) {
859 // DasherPreferencesDialoguePrivate *pPrivate = DASHER_PREFERENCES_DIALOGUE_PRIVATE(pSelf);
860 DasherPreferencesDialoguePrivate
*pPrivate
= DASHER_PREFERENCES_DIALOGUE_PRIVATE(g_pPreferencesDialogue
); // TODO: Fix NULL
862 int mouseposstartdist
=int(widget
->adjustment
->value
);
863 dasher_app_settings_set_long(pPrivate
->pAppSettings
, LP_MOUSEPOSDIST
, mouseposstartdist
);
866 extern "C" void languagemodel(GtkRadioButton
*widget
, gpointer user_data
) {
867 // DasherPreferencesDialoguePrivate *pPrivate = DASHER_PREFERENCES_DIALOGUE_PRIVATE(pSelf);
868 DasherPreferencesDialoguePrivate
*pPrivate
= DASHER_PREFERENCES_DIALOGUE_PRIVATE(g_pPreferencesDialogue
); // TODO: Fix NULL
870 if (GTK_TOGGLE_BUTTON(widget
)->active
==TRUE
) {
871 if( !strcmp( gtk_widget_get_name( GTK_WIDGET(widget
) ), "radiobutton6" ) ) {
872 dasher_app_settings_set_long(pPrivate
->pAppSettings
, LP_LANGUAGE_MODEL_ID
, 0 );
873 } else if (!strcmp( gtk_widget_get_name( GTK_WIDGET(widget
) ), "radiobutton7" )) {
874 dasher_app_settings_set_long(pPrivate
->pAppSettings
, LP_LANGUAGE_MODEL_ID
, 2 );
875 } else if (!strcmp( gtk_widget_get_name( GTK_WIDGET(widget
) ), "radiobutton8" )) {
876 dasher_app_settings_set_long(pPrivate
->pAppSettings
, LP_LANGUAGE_MODEL_ID
, 3 );
877 } else if (!strcmp( gtk_widget_get_name( GTK_WIDGET(widget
) ), "radiobutton9" )) {
878 dasher_app_settings_set_long(pPrivate
->pAppSettings
, LP_LANGUAGE_MODEL_ID
, 4 );
883 extern "C" void uniform_changed(GtkHScale
*hscale
) {
884 // DasherPreferencesDialoguePrivate *pPrivate = DASHER_PREFERENCES_DIALOGUE_PRIVATE(pSelf);
885 DasherPreferencesDialoguePrivate
*pPrivate
= DASHER_PREFERENCES_DIALOGUE_PRIVATE(g_pPreferencesDialogue
); // TODO: Fix NULL
887 dasher_app_settings_set_long(pPrivate
->pAppSettings
, LP_UNIFORM
, int (GTK_RANGE(hscale
)->adjustment
->value
* 10));
890 extern "C" gboolean
show_helper_window(GtkWidget
*pWidget
, gpointer
*pUserData
) {
891 gtk_window_present(GTK_WINDOW(*pUserData
));
895 extern "C" void on_appstyle_changed(GtkWidget
*widget
, gpointer user_data
) {
896 // DasherPreferencesDialoguePrivate *pPrivate = DASHER_PREFERENCES_DIALOGUE_PRIVATE(pSelf);
897 DasherPreferencesDialoguePrivate
*pPrivate
= DASHER_PREFERENCES_DIALOGUE_PRIVATE(g_pPreferencesDialogue
); // TODO: Fix NULL
899 if(GTK_TOGGLE_BUTTON(widget
)->active
) {
900 if(!strcmp(gtk_widget_get_name(GTK_WIDGET(widget
)), "appstyle_classic"))
901 dasher_app_settings_set_long(pPrivate
->pAppSettings
, APP_LP_STYLE
, 0);
902 else if(!strcmp(gtk_widget_get_name(GTK_WIDGET(widget
)), "appstyle_compose"))
903 dasher_app_settings_set_long(pPrivate
->pAppSettings
, APP_LP_STYLE
, 1);
904 else if(!strcmp(gtk_widget_get_name(GTK_WIDGET(widget
)), "appstyle_direct"))
905 dasher_app_settings_set_long(pPrivate
->pAppSettings
, APP_LP_STYLE
, 2);
906 else if(!strcmp(gtk_widget_get_name(GTK_WIDGET(widget
)), "appstyle_fullscreen"))
907 dasher_app_settings_set_long(pPrivate
->pAppSettings
, APP_LP_STYLE
, 3);
911 extern "C" void on_dasher_font_changed(GtkFontButton
*pButton
, gpointer pUserData
) {
912 DasherPreferencesDialoguePrivate
*pPrivate
= DASHER_PREFERENCES_DIALOGUE_PRIVATE(g_pPreferencesDialogue
);
914 dasher_app_settings_set_string(pPrivate
->pAppSettings
,
916 gtk_font_button_get_font_name(pButton
));
919 extern "C" void on_edit_font_changed(GtkFontButton
*pButton
, gpointer pUserData
) {
920 DasherPreferencesDialoguePrivate
*pPrivate
= DASHER_PREFERENCES_DIALOGUE_PRIVATE(g_pPreferencesDialogue
);
922 dasher_app_settings_set_string(pPrivate
->pAppSettings
,
924 gtk_font_button_get_font_name(pButton
));
927 // --- Actions Selection ---
929 // Note - for now consider the actions configuration to be *really* a
930 // special case (more so than the systematic special cases), as it
931 // doesn't even make use of the integer IDs for parameters.
933 void dasher_preferences_dialogue_populate_actions(DasherPreferencesDialogue
*pSelf
) {
935 DasherPreferencesDialoguePrivate
*pPrivate
= (DasherPreferencesDialoguePrivate
*)(pSelf
->private_data
);
937 pPrivate
->pListStore
= gtk_list_store_new(ACTIONS_N_COLUMNS
, G_TYPE_INT
, G_TYPE_STRING
, G_TYPE_BOOLEAN
, G_TYPE_BOOLEAN
, G_TYPE_BOOLEAN
);
941 dasher_editor_internal_actions_start(pPrivate
->pEditor
);
943 while(dasher_editor_internal_actions_more(pPrivate
->pEditor
)) {
944 gtk_list_store_append(pPrivate
->pListStore
, &oIter
);
952 dasher_editor_internal_actions_get_next(pPrivate
->pEditor
, &szName
, &iID
, &bShow
, &bControl
, &bAuto
),
954 gtk_list_store_set(pPrivate
->pListStore
, &oIter
,
955 ACTIONS_ID_COLUMN
, iID
,
956 ACTIONS_NAME_COLUMN
, szName
,
957 ACTIONS_SHOW_COLUMN
, bShow
,
958 ACTIONS_CONTROL_COLUMN
, bControl
,
959 ACTIONS_AUTO_COLUMN
, bAuto
,
963 GtkCellRenderer
*pRenderer
;
964 GtkTreeViewColumn
*pColumn
;
966 // TODO: (small) memory leak here at the moment
967 gint
*pColumnIndex
= new gint
[3];
968 pColumnIndex
[0] = ACTIONS_SHOW_COLUMN
;
969 pColumnIndex
[1] = ACTIONS_CONTROL_COLUMN
;
970 pColumnIndex
[2] = ACTIONS_AUTO_COLUMN
;
972 pRenderer
= gtk_cell_renderer_text_new();
973 pColumn
= gtk_tree_view_column_new_with_attributes("Action", pRenderer
, "text", ACTIONS_NAME_COLUMN
, NULL
);
974 g_object_set(G_OBJECT(pColumn
), "expand", true, NULL
);
975 gtk_tree_view_append_column(GTK_TREE_VIEW(pPrivate
->pActionTreeView
), pColumn
);
977 pRenderer
= gtk_cell_renderer_toggle_new();
978 g_signal_connect(pRenderer
, "toggled", (GCallback
)on_action_toggle
, pColumnIndex
);
979 pColumn
= gtk_tree_view_column_new_with_attributes("Show Button", pRenderer
, "active", ACTIONS_SHOW_COLUMN
, NULL
);
980 gtk_tree_view_append_column(GTK_TREE_VIEW(pPrivate
->pActionTreeView
), pColumn
);
982 pRenderer
= gtk_cell_renderer_toggle_new();
983 g_signal_connect(pRenderer
, "toggled", (GCallback
)on_action_toggle
, pColumnIndex
+ 1);
984 pColumn
= gtk_tree_view_column_new_with_attributes("Control Mode", pRenderer
, "active", ACTIONS_CONTROL_COLUMN
, NULL
);
985 gtk_tree_view_append_column(GTK_TREE_VIEW(pPrivate
->pActionTreeView
), pColumn
);
987 pRenderer
= gtk_cell_renderer_toggle_new();
988 g_signal_connect(pRenderer
, "toggled", (GCallback
)on_action_toggle
, pColumnIndex
+ 2);
989 pColumn
= gtk_tree_view_column_new_with_attributes("Auto On Stop", pRenderer
, "active", ACTIONS_AUTO_COLUMN
, NULL
);
990 gtk_tree_view_append_column(GTK_TREE_VIEW(pPrivate
->pActionTreeView
), pColumn
);
992 gtk_tree_view_set_model(GTK_TREE_VIEW(pPrivate
->pActionTreeView
), GTK_TREE_MODEL(pPrivate
->pListStore
));
996 extern "C" void on_action_toggle(GtkCellRendererToggle
*pRenderer
, gchar
*szPath
, gpointer pUserData
) {
997 // DasherPreferencesDialoguePrivate *pPrivate = DASHER_PREFERENCES_DIALOGUE_PRIVATE(pSelf);
998 DasherPreferencesDialoguePrivate
*pPrivate
= DASHER_PREFERENCES_DIALOGUE_PRIVATE(g_pPreferencesDialogue
); // TODO: Fix NULL
1000 gint
*pColumnIndex
= (gint
*)pUserData
;
1003 gtk_tree_model_get_iter_from_string(GTK_TREE_MODEL(pPrivate
->pListStore
), &oIter
, szPath
);
1007 gtk_tree_model_get(GTK_TREE_MODEL(pPrivate
->pListStore
), &oIter
, ACTIONS_ID_COLUMN
, &iID
, *pColumnIndex
, &bSelected
, -1);
1009 gtk_list_store_set(pPrivate
->pListStore
, &oIter
, *pColumnIndex
, !bSelected
, -1);
1011 // TODO: reimplement
1013 // switch(*pColumnIndex) {
1014 // case ACTIONS_SHOW_COLUMN:
1015 // dasher_editor_internal_action_set_show(g_pEditor, iID, !bSelected);
1017 // case ACTIONS_CONTROL_COLUMN:
1018 // dasher_editor_internal_action_set_control(g_pEditor, iID, !bSelected);
1020 // case ACTIONS_AUTO_COLUMN:
1021 // dasher_editor_internal_action_set_auto(g_pEditor, iID, !bSelected);
1026 extern "C" void set_dasher_fontsize(GtkWidget
*pWidget
, gboolean pUserData
) {
1027 DasherPreferencesDialoguePrivate
*pPrivate
= DASHER_PREFERENCES_DIALOGUE_PRIVATE(g_pPreferencesDialogue
);
1029 int iValue
= dasher_app_settings_get_long(pPrivate
->pAppSettings
, LP_DASHER_FONTSIZE
);
1031 if((iValue
!= Opts::Normal
) && gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON(glade_xml_get_widget(pPrivate
->pGladeXML
, "fontsizenormal"))))
1032 dasher_app_settings_set_long(pPrivate
->pAppSettings
, LP_DASHER_FONTSIZE
, Opts::Normal
);
1033 else if((iValue
!= Opts::Big
) && gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON(glade_xml_get_widget(pPrivate
->pGladeXML
, "fontsizelarge"))))
1034 dasher_app_settings_set_long(pPrivate
->pAppSettings
, LP_DASHER_FONTSIZE
, Opts::Big
);
1035 else if((iValue
!= Opts::VBig
) && gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON(glade_xml_get_widget(pPrivate
->pGladeXML
, "fontsizevlarge"))))
1036 dasher_app_settings_set_long(pPrivate
->pAppSettings
, LP_DASHER_FONTSIZE
, Opts::VBig
);
1040 // --- General Callbacks ---
1042 // For general purpose operation of the dialogue, rather than dealing
1043 // with changing specific options
1045 extern "C" gboolean
preferences_hide(GtkWidget
*widget
, gpointer user_data
) {
1046 // DasherPreferencesDialoguePrivate *pPrivate = DASHER_PREFERENCES_DIALOGUE_PRIVATE(pSelf);
1047 DasherPreferencesDialoguePrivate
*pPrivate
= DASHER_PREFERENCES_DIALOGUE_PRIVATE(g_pPreferencesDialogue
); // TODO: Fix NULL
1049 gtk_widget_hide(pPrivate
->pPreferencesWindow
);
1057 extern "C" void on_window_size_changed(GtkWidget
*widget
, gpointer user_data
) {
1058 if(GTK_TOGGLE_BUTTON(widget
)->active
)
1059 dasher_app_settings_set_long(pPrivate
->pAppSettings
, APP_LP_MAEMO_SIZE
, 1);
1061 dasher_app_settings_set_long(pPrivate
->pAppSettings
, APP_LP_MAEMO_SIZE
, 0);