24
22
#include "game_mode_helper.h"
25
23
#include "FontDialogues.h"
26
24
#include "GtkDasherControl.h"
27
26
#include "Preferences.h"
29
28
// TODO: Maybe reimplement something along the lines of the following, which used to be in edit.cc
150
149
DasherEditorPrivate *pPrivate = (DasherEditorPrivate *)(((DasherEditor *)pObject)->private_data);
152
151
EditorAction *pCurrentAction = pPrivate->pActionRing;
153
bool bStarted = false;
155
while(!bStarted || (pCurrentAction != pPrivate->pActionRing)) {
157
dasher_action_deactivate(pCurrentAction->pAction);
158
g_object_unref(G_OBJECT(pCurrentAction->pAction));
159
pCurrentAction = pCurrentAction->pNext;
154
bool bStarted = false;
156
while(!bStarted || (pCurrentAction != pPrivate->pActionRing)) {
158
dasher_action_deactivate(pCurrentAction->pAction);
159
g_object_unref(G_OBJECT(pCurrentAction->pAction));
160
pCurrentAction = pCurrentAction->pNext;
162
164
if(pPrivate->pBufferSet)
168
170
DasherEditor *dasher_editor_new(int argc, char **argv) {
169
171
DasherEditor *pDasherControl;
170
172
pDasherControl = (DasherEditor *)(g_object_new(dasher_editor_get_type(), NULL));
171
DasherEditorPrivate *pPrivate = (DasherEditorPrivate *)(pDasherControl->private_data);
173
g_pDasherAppSettings = dasher_app_settings_new(argc, argv);
175
g_pDasherMain = dasher_main_new();
176
// g_signal_connect(G_OBJECT(g_pDasherMain), "realized", G_CALLBACK(main_window_realized), pDasherControl);
174
return pDasherControl;
177
void dasher_editor_initialise(DasherEditor *pSelf) {
178
DasherEditorPrivate *pPrivate = (DasherEditorPrivate *)(pSelf->private_data);
178
180
GladeXML *pGladeXML = dasher_main_get_glade(g_pDasherMain);
179
pDasherWidget = glade_xml_get_widget(pGladeXML, "DasherControl");
181
dasher_main_set_app_settings(g_pDasherMain, g_pDasherAppSettings);
183
// TODO: Make lock diaogue a full method
185
dasher_lock_dialogue_new(pGladeXML, GTK_WINDOW(dasher_main_get_window(g_pDasherMain)));
187
dasher_lock_dialogue_new(pGladeXML, 0);
189
// TODO: Bring into object framework
190
InitialiseFontDialogues(pGladeXML);
192
g_pPreferencesDialogue = dasher_preferences_dialogue_new(pGladeXML, pDasherControl);
194
182
GtkTextView *pTextView = GTK_TEXT_VIEW(glade_xml_get_widget(pGladeXML, "the_text_view"));
195
183
GtkVBox *pActionPane = GTK_VBOX(glade_xml_get_widget(pGladeXML, "vbox39"));
203
191
pPrivate->iNextActionID = 0;
204
192
pPrivate->pGameModeHelper = 0;
206
dasher_editor_create_buffer(pDasherControl);
207
dasher_editor_setup_actions(pDasherControl);
208
dasher_preferences_dialogue_populate_actions(g_pPreferencesDialogue);
210
return pDasherControl;
194
dasher_editor_create_buffer(pSelf);
195
dasher_editor_setup_actions(pSelf);
213
199
IDasherBufferSet *dasher_editor_get_buffer_set(DasherEditor *pSelf) {
281
267
// See if anything is set to auto:
282
268
EditorAction *pCurrentAction = pPrivate->pActionRing;
283
bool bStarted = false;
285
while(!bStarted || (pCurrentAction != pPrivate->pActionRing)) {
287
if(pCurrentAction->bAuto)
288
dasher_action_execute(pCurrentAction->pAction, dasher_editor_get_all_text(pSelf));
289
pCurrentAction = pCurrentAction->pNext;
271
bool bStarted = false;
273
while(!bStarted || (pCurrentAction != pPrivate->pActionRing)) {
275
if(pCurrentAction->bAuto)
276
dasher_action_execute(pCurrentAction->pAction, dasher_editor_get_all_text(pSelf));
277
pCurrentAction = pCurrentAction->pNext;
348
337
if(pPrivate->pBufferSet) {
349
for(int i(0); i < sizeof(sMap)/sizeof(struct SControlMap); ++i) {
338
for(unsigned int i(0); i < sizeof(sMap)/sizeof(struct SControlMap); ++i) {
350
339
if(sMap[i].iEvent == iNodeID) {
351
340
if(sMap[i].bDelete)
352
341
idasher_buffer_set_edit_delete(pPrivate->pBufferSet, sMap[i].iDir, sMap[i].iDist);
360
349
void dasher_editor_handle_parameter_change(DasherEditor *pSelf, int iParameter) {
363
dasher_editor_create_buffer(pSelf);
350
// switch(iParameter) {
351
// case APP_LP_STYLE:
352
// dasher_editor_create_buffer(pSelf);
367
356
dasher_preferences_dialogue_handle_parameter_change(g_pPreferencesDialogue, iParameter);
368
357
dasher_main_handle_parameter_change(g_pDasherMain, iParameter);
384
373
strncpy(szRegistryName, "Action_", 256);
385
374
strncat(szRegistryName, dasher_action_get_name(pNewEditorAction->pAction), 255 - strlen(szRegistryName));
387
for(int i(0); i < strlen(szRegistryName); ++i)
376
for(unsigned int i(0); i < strlen(szRegistryName); ++i)
388
377
if(szRegistryName[i] == ' ')
389
378
szRegistryName[i] = '_';
419
408
pPrivate->pActionRing = pNewEditorAction;
410
if(iState & ACTION_STATE_SHOW)
411
gtk_dasher_control_add_action_button(GTK_DASHER_CONTROL(pDasherWidget), dasher_action_get_name(pNewEditorAction->pAction));
422
414
void dasher_editor_setup_actions(DasherEditor *pSelf) {
429
421
dasher_editor_add_action(pSelf, DASHER_ACTION(dasher_action_speech_new()));
433
424
dasher_editor_add_action(pSelf, DASHER_ACTION(dasher_action_keyboard_new(pPrivate->pExternalBuffer)));
436
426
#ifdef WITH_MAEMO
437
427
dasher_editor_add_action(pSelf, DASHER_ACTION(dasher_action_keyboard_maemo_new()));
664
654
strncpy(szRegistryName, "Action_", 256);
665
655
strncat(szRegistryName, dasher_action_get_name(pAction->pAction), 255 - strlen(szRegistryName));
667
for(int i(0); i < strlen(szRegistryName); ++i)
657
for(unsigned int i(0); i < strlen(szRegistryName); ++i)
668
658
if(szRegistryName[i] == ' ')
669
659
szRegistryName[i] = '_';
735
725
void dasher_editor_create_buffer(DasherEditor *pSelf) {
736
726
DasherEditorPrivate *pPrivate = (DasherEditorPrivate *)(pSelf->private_data);
739
728
if(!(pPrivate->pExternalBuffer))
740
729
pPrivate->pExternalBuffer = IDASHER_BUFFER_SET(dasher_external_buffer_new());
743
731
if(!(pPrivate->pInternalBuffer)) {
744
732
pPrivate->pInternalBuffer = dasher_editor_get_buffer_set(pSelf);
834
822
pPrivate->pGameModeHelper = GAME_MODE_HELPER(game_mode_helper_new(GTK_DASHER_CONTROL(pDasherWidget)));
825
void dasher_editor_command(DasherEditor *pSelf, const gchar *szCommand) {
826
DasherEditorPrivate *pPrivate = (DasherEditorPrivate *)(pSelf->private_data);
828
if(!strcmp(szCommand, "Preferences")) {
829
dasher_preferences_dialogue_show(g_pPreferencesDialogue);
831
else if(!strcmp(szCommand, "Exit")) {
832
ask_save_before_exit(NULL, NULL);
834
else if(!strcmp(szCommand, "Help")) {
835
show_help(NULL, NULL);
837
else if(!strcmp(szCommand, "About")) {
838
about_dasher(NULL, NULL);
841
bool bActionIterStarted = false;
842
EditorAction *pActionIter = pPrivate->pActionRing;
844
while((pActionIter != pPrivate->pActionRing) || !bActionIterStarted) {
845
bActionIterStarted = true;
847
if(!strcmp(dasher_action_get_name(pActionIter->pAction), szCommand)) {
848
dasher_action_execute(pActionIter->pAction, dasher_editor_get_all_text(pSelf));
852
pActionIter = pActionIter->pNext;
839
859
extern "C" void action_button_callback(GtkWidget *pWidget, gpointer pUserData) {
877
897
dasher_editor_display_message(g_pEditor, (DasherMessageInfo *)pMessageInfo);
901
extern "C" void on_command(GtkDasherControl *pDasherControl, gchar *szCommand, gpointer pUserData) {
903
dasher_editor_command(g_pEditor, szCommand);
880
907
// TODO: The following two should probably be made the same
881
908
extern "C" void handle_request_settings(GtkDasherControl * pDasherControl, gpointer data) {
882
909
dasher_preferences_dialogue_show(g_pPreferencesDialogue);