~alanbell/dasher/ircfix-lp579181

« back to all changes in this revision

Viewing changes to Src/Gtk2/dasher_editor.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Daniel Holbach
  • Date: 2006-11-14 12:03:42 UTC
  • mfrom: (1.2.14 upstream)
  • Revision ID: james.westby@ubuntu.com-20061114120342-pebcosas78lczcgz
Tags: 4.3.1-0ubuntu1
* New upstream release:
  - 4.3.1:
    - Bugfixes
    - Translation updates
  - 4.3.0:
    - Mainly work on two button dynamic mode to provide a platform for 
      user tests
* debian/patches/10_remove-extra-qualifier.patch:
  - fix FTBFS.

Show diffs side-by-side

added added

removed removed

Lines of Context:
5
5
#ifndef WITH_MAEMO
6
6
#include "dasher_action_copy.h"
7
7
#endif
8
 
#ifdef GNOME_A11Y
9
8
#include "dasher_action_keyboard.h"
10
 
#endif 
11
9
#ifdef WITH_MAEMO
12
10
#include "dasher_action_keyboard_maemo.h"
13
11
#else
24
22
#include "game_mode_helper.h"
25
23
#include "FontDialogues.h"
26
24
#include "GtkDasherControl.h"
 
25
#include "Menu.h"
27
26
#include "Preferences.h"
28
27
 
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);
151
150
 
152
151
  EditorAction *pCurrentAction = pPrivate->pActionRing;
153
 
  bool bStarted = false;
154
 
  
155
 
  while(!bStarted || (pCurrentAction != pPrivate->pActionRing)) {
156
 
    bStarted = true;
157
 
    dasher_action_deactivate(pCurrentAction->pAction);
158
 
    g_object_unref(G_OBJECT(pCurrentAction->pAction));
159
 
    pCurrentAction = pCurrentAction->pNext;
 
152
 
 
153
  if(pCurrentAction) {
 
154
    bool bStarted = false;
 
155
    
 
156
    while(!bStarted || (pCurrentAction != pPrivate->pActionRing)) {
 
157
      bStarted = true;
 
158
      dasher_action_deactivate(pCurrentAction->pAction);
 
159
      g_object_unref(G_OBJECT(pCurrentAction->pAction));
 
160
      pCurrentAction = pCurrentAction->pNext;
 
161
    }
160
162
  }
161
163
 
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);
172
 
 
173
 
  g_pDasherAppSettings = dasher_app_settings_new(argc, argv);
174
 
 
175
 
  g_pDasherMain = dasher_main_new();
176
 
  //  g_signal_connect(G_OBJECT(g_pDasherMain), "realized", G_CALLBACK(main_window_realized), pDasherControl);
 
173
 
 
174
  return pDasherControl;
 
175
}
 
176
 
 
177
void dasher_editor_initialise(DasherEditor *pSelf) {
 
178
  DasherEditorPrivate *pPrivate = (DasherEditorPrivate *)(pSelf->private_data);
177
179
 
178
180
  GladeXML *pGladeXML = dasher_main_get_glade(g_pDasherMain);
179
 
  pDasherWidget = glade_xml_get_widget(pGladeXML, "DasherControl");
180
 
  
181
 
  dasher_main_set_app_settings(g_pDasherMain, g_pDasherAppSettings);
182
 
 
183
 
  // TODO: Make lock diaogue a full method
184
 
#ifndef WITH_MAEMO
185
 
  dasher_lock_dialogue_new(pGladeXML, GTK_WINDOW(dasher_main_get_window(g_pDasherMain)));
186
 
#else
187
 
  dasher_lock_dialogue_new(pGladeXML, 0);
188
 
#endif
189
 
  // TODO: Bring into object framework
190
 
  InitialiseFontDialogues(pGladeXML);
191
 
  
192
 
  g_pPreferencesDialogue = dasher_preferences_dialogue_new(pGladeXML, pDasherControl);
193
 
 
 
181
  
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"));
196
184
 
203
191
  pPrivate->iNextActionID = 0;
204
192
  pPrivate->pGameModeHelper = 0;
205
193
 
206
 
  dasher_editor_create_buffer(pDasherControl);
207
 
  dasher_editor_setup_actions(pDasherControl);
208
 
  dasher_preferences_dialogue_populate_actions(g_pPreferencesDialogue);
209
 
 
210
 
  return pDasherControl;
 
194
  dasher_editor_create_buffer(pSelf);
 
195
  dasher_editor_setup_actions(pSelf);
 
196
  //
211
197
}
212
198
 
213
199
IDasherBufferSet *dasher_editor_get_buffer_set(DasherEditor *pSelf) {
280
266
  
281
267
  // See if anything is set to auto:
282
268
  EditorAction *pCurrentAction = pPrivate->pActionRing;
283
 
  bool bStarted = false;
284
 
  
285
 
  while(!bStarted || (pCurrentAction != pPrivate->pActionRing)) {
286
 
    bStarted = true;
287
 
    if(pCurrentAction->bAuto)
288
 
      dasher_action_execute(pCurrentAction->pAction, dasher_editor_get_all_text(pSelf)); 
289
 
    pCurrentAction = pCurrentAction->pNext;
 
269
 
 
270
  if(pCurrentAction) {
 
271
    bool bStarted = false;
 
272
    
 
273
    while(!bStarted || (pCurrentAction != pPrivate->pActionRing)) {
 
274
      bStarted = true;
 
275
      if(pCurrentAction->bAuto)
 
276
        dasher_action_execute(pCurrentAction->pAction, dasher_editor_get_all_text(pSelf)); 
 
277
      pCurrentAction = pCurrentAction->pNext;
 
278
    }
290
279
  }
291
280
}
292
281
 
346
335
  };    
347
336
 
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);
358
347
}
359
348
 
360
349
void dasher_editor_handle_parameter_change(DasherEditor *pSelf, int iParameter) {
361
 
  switch(iParameter) {
362
 
  case APP_LP_STYLE:
363
 
    dasher_editor_create_buffer(pSelf);
364
 
    break;
365
 
  }
 
350
//   switch(iParameter) {
 
351
//   case APP_LP_STYLE:
 
352
//     dasher_editor_create_buffer(pSelf);
 
353
//     break;
 
354
//   }
366
355
 
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));
386
375
 
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] = '_';
390
379
 
417
406
  }
418
407
 
419
408
  pPrivate->pActionRing = pNewEditorAction;
 
409
  
 
410
  if(iState & ACTION_STATE_SHOW)
 
411
        gtk_dasher_control_add_action_button(GTK_DASHER_CONTROL(pDasherWidget), dasher_action_get_name(pNewEditorAction->pAction));
420
412
}
421
413
 
422
414
void dasher_editor_setup_actions(DasherEditor *pSelf) {
429
421
  dasher_editor_add_action(pSelf, DASHER_ACTION(dasher_action_speech_new()));
430
422
#endif
431
423
 
432
 
#ifdef GNOME_A11Y
433
424
  dasher_editor_add_action(pSelf, DASHER_ACTION(dasher_action_keyboard_new(pPrivate->pExternalBuffer)));
434
 
#endif
435
425
 
436
426
#ifdef WITH_MAEMO
437
427
  dasher_editor_add_action(pSelf, DASHER_ACTION(dasher_action_keyboard_maemo_new()));
499
489
  }
500
490
 
501
491
#ifndef WITH_MAEMOFULLSCREEN
502
 
  dasher_editor_rebuild_action_pane(pSelf);
 
492
  //  dasher_editor_rebuild_action_pane(pSelf);
503
493
#endif
504
494
}
505
495
 
664
654
  strncpy(szRegistryName, "Action_", 256);
665
655
  strncat(szRegistryName, dasher_action_get_name(pAction->pAction), 255 - strlen(szRegistryName));
666
656
 
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] = '_';
670
660
 
735
725
void dasher_editor_create_buffer(DasherEditor *pSelf) {
736
726
  DasherEditorPrivate *pPrivate = (DasherEditorPrivate *)(pSelf->private_data);
737
727
 
738
 
#ifdef GNOME_A11Y
739
728
  if(!(pPrivate->pExternalBuffer))
740
729
    pPrivate->pExternalBuffer = IDASHER_BUFFER_SET(dasher_external_buffer_new());
741
 
#endif
742
730
 
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)));
835
823
}
836
824
 
 
825
void dasher_editor_command(DasherEditor *pSelf, const gchar *szCommand) {
 
826
  DasherEditorPrivate *pPrivate = (DasherEditorPrivate *)(pSelf->private_data);
 
827
 
 
828
  if(!strcmp(szCommand, "Preferences")) {
 
829
    dasher_preferences_dialogue_show(g_pPreferencesDialogue);
 
830
  }
 
831
  else if(!strcmp(szCommand, "Exit")) {
 
832
    ask_save_before_exit(NULL, NULL);
 
833
  }
 
834
  else if(!strcmp(szCommand, "Help")) {
 
835
    show_help(NULL, NULL);
 
836
  }
 
837
  else if(!strcmp(szCommand, "About")) {
 
838
    about_dasher(NULL, NULL);
 
839
  }
 
840
  else {
 
841
    bool bActionIterStarted = false;
 
842
    EditorAction *pActionIter = pPrivate->pActionRing;
 
843
    
 
844
    while((pActionIter != pPrivate->pActionRing) || !bActionIterStarted) {
 
845
      bActionIterStarted = true;
 
846
 
 
847
      if(!strcmp(dasher_action_get_name(pActionIter->pAction), szCommand)) {
 
848
        dasher_action_execute(pActionIter->pAction, dasher_editor_get_all_text(pSelf));
 
849
        return;
 
850
      }
 
851
 
 
852
      pActionIter = pActionIter->pNext;
 
853
    }
 
854
  }
 
855
}
 
856
 
837
857
// Callbacks
838
858
 
839
859
extern "C" void action_button_callback(GtkWidget *pWidget, gpointer pUserData) { 
877
897
   dasher_editor_display_message(g_pEditor, (DasherMessageInfo *)pMessageInfo);
878
898
}
879
899
 
 
900
 
 
901
extern "C" void on_command(GtkDasherControl *pDasherControl, gchar *szCommand, gpointer pUserData) {
 
902
 if(g_pEditor)
 
903
   dasher_editor_command(g_pEditor, szCommand);
 
904
}
 
905
 
 
906
 
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);