forked from synfig/synfig
/
app.cpp
3681 lines (3131 loc) · 113 KB
/
app.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/* === S Y N F I G ========================================================= */
/*! \file app.cpp
** \brief writeme
**
** $Id$
**
** \legal
** Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley
** Copyright (c) 2007, 2008 Chris Moore
** Copyright (c) 2008 Gerald Young
** Copyright (c) 2008, 2010-2013 Carlos López
** Copyright (c) 2009, 2011 Nikita Kitaev
** Copyright (c) 2012 Konstantin Dmitriev
**
** This package is free software; you can redistribute it and/or
** modify it under the terms of the GNU General Public License as
** published by the Free Software Foundation; either version 2 of
** the License, or (at your option) any later version.
**
** This package is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
** General Public License for more details.
** \endlegal
*/
/* ========================================================================= */
/* === H E A D E R S ======================================================= */
#ifdef USING_PCH
# include "pch.h"
#else
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include <fstream>
#include <iostream>
#include <locale>
#include <cstring>
#ifdef __OpenBSD__
#include <errno.h>
#elif defined(HAVE_SYS_ERRNO_H)
#include <sys/errno.h>
#endif
#include <gtkmm/filechooserdialog.h>
#include <gtkmm/dialog.h>
#include <gtkmm/messagedialog.h>
#include <gtkmm/label.h>
#include <gtkmm/stock.h>
#include <gtkmm/stockitem.h>
#include <gtkmm/iconsource.h>
#include <gtkmm/accelmap.h>
#include <gtkmm/uimanager.h>
#include <gtkmm/textview.h>
#include <gtkmm/filefilter.h>
#include <gtkmm/cssprovider.h>
#include <glibmm/main.h>
#include <glibmm/thread.h>
#include <glibmm/miscutils.h>
#include <glibmm/spawn.h>
#include <gtk/gtk.h>
#include <gdkmm/general.h>
#ifdef WIN32
#define WINVER 0x0500
#include <windows.h>
#endif
#include <synfig/loadcanvas.h>
#include <synfig/savecanvas.h>
#include <synfig/importer.h>
#include <synfig/filesystemnative.h>
#include <synfig/filesystemgroup.h>
#include <synfig/filecontainertemporary.h>
#include "app.h"
#include "dialogs/about.h"
#include "splash.h"
#include "instance.h"
#include "canvasview.h"
#include "dialogs/dialog_setup.h"
#include "dialogs/dialog_gradient.h"
#include "dialogs/dialog_input.h"
#include "dialogs/dialog_color.h"
#include "mainwindow.h"
#include "docks/dock_toolbox.h"
#include "onemoment.h"
#include "docks/dockmanager.h"
#include "states/state_eyedrop.h"
#include "states/state_normal.h"
#include "states/state_mirror.h"
#include "states/state_draw.h"
#include "states/state_lasso.h"
#include "states/state_fill.h"
#include "states/state_bline.h"
#include "states/state_brush.h"
#include "states/state_polygon.h"
#include "states/state_sketch.h"
#include "states/state_gradient.h"
#include "states/state_circle.h"
#include "states/state_rectangle.h"
#include "states/state_smoothmove.h"
#include "states/state_scale.h"
#include "states/state_star.h"
#include "states/state_text.h"
#include "states/state_width.h"
#include "states/state_rotate.h"
#include "states/state_zoom.h"
#include "devicetracker.h"
#include "docks/dialog_tooloptions.h"
#include "widgets/widget_enum.h"
#include "autorecover.h"
#include <synfigapp/settings.h>
#include "docks/dock_history.h"
#include "docks/dock_canvases.h"
#include "docks/dock_keyframes.h"
#include "docks/dock_layers.h"
#include "docks/dock_params.h"
#include "docks/dock_metadata.h"
#include "docks/dock_children.h"
#include "docks/dock_info.h"
#include "docks/dock_navigator.h"
#include "docks/dock_layergroups.h"
#include "docks/dock_timetrack.h"
#include "docks/dock_curves.h"
#include "modules/module.h"
#include "modules/mod_palette/mod_palette.h"
#include "ipc.h"
#include "statemanager.h"
#ifdef WITH_FMOD
#include <fmod.h>
#endif
#include <gtkmm/accelmap.h>
#include <gtkmm/filechooser.h>
#include <gtkmm/filechooserdialog.h>
#include "general.h"
#endif
/* === U S I N G =========================================================== */
using namespace std;
using namespace etl;
using namespace synfig;
using namespace studio;
/* === M A C R O S ========================================================= */
#ifndef DPM2DPI
#define DPM2DPI(x) (float(x)/39.3700787402f)
#define DPI2DPM(x) (float(x)*39.3700787402f)
#endif
#ifdef WIN32
# ifdef IMAGE_DIR
# undef IMAGE_DIR
# define IMAGE_DIR "share\\pixmaps"
# endif
#endif
#ifndef IMAGE_DIR
# define IMAGE_DIR "/usr/local/share/pixmaps"
#endif
#ifndef IMAGE_EXT
# define IMAGE_EXT "tif"
#endif
#ifdef WIN32
# ifdef PLUGIN_DIR
# undef PLUGIN_DIR
# define PLUGIN_DIR "share\\synfig\\plugins"
# endif
#endif
#ifndef PLUGIN_DIR
# define PLUGIN_DIR "/usr/local/share/synfig/plugins"
#endif
#include <synfigapp/main.h>
/* === S I G N A L S ======================================================= */
static sigc::signal<void> signal_present_all_;
sigc::signal<void>&
App::signal_present_all() { return signal_present_all_; }
static sigc::signal<void> signal_recent_files_changed_;
sigc::signal<void>&
App::signal_recent_files_changed() { return signal_recent_files_changed_; }
static sigc::signal<void,etl::loose_handle<CanvasView> > signal_canvas_view_focus_;
sigc::signal<void,etl::loose_handle<CanvasView> >&
App::signal_canvas_view_focus() { return signal_canvas_view_focus_; }
static sigc::signal<void,etl::handle<Instance> > signal_instance_selected_;
sigc::signal<void,etl::handle<Instance> >&
App::signal_instance_selected() { return signal_instance_selected_; }
static sigc::signal<void,etl::handle<Instance> > signal_instance_created_;
sigc::signal<void,etl::handle<Instance> >&
App::signal_instance_created() { return signal_instance_created_; }
static sigc::signal<void,etl::handle<Instance> > signal_instance_deleted_;
sigc::signal<void,etl::handle<Instance> >&
App::signal_instance_deleted() { return signal_instance_deleted_; }
/* === G L O B A L S ======================================================= */
static std::list<std::string> recent_files;
const std::list<std::string>& App::get_recent_files() { return recent_files; }
int App::Busy::count;
bool App::shutdown_in_progress;
synfig::Gamma App::gamma;
Glib::RefPtr<studio::UIManager> App::ui_manager_;
synfig::Distance::System App::distance_system;
studio::Dialog_Setup* App::dialog_setup;
etl::handle< studio::ModPalette > mod_palette_;
//studio::Dialog_Palette* App::dialog_palette;
std::list<etl::handle<Instance> > App::instance_list;
static etl::handle<synfigapp::UIInterface> ui_interface_;
const etl::handle<synfigapp::UIInterface>& App::get_ui_interface() { return ui_interface_; }
etl::handle<Instance> App::selected_instance;
etl::handle<CanvasView> App::selected_canvas_view;
studio::About *studio::App::about=NULL;
studio::MainWindow *studio::App::main_window=NULL;
studio::Dock_Toolbox *studio::App::dock_toolbox=NULL;
studio::AutoRecover *studio::App::auto_recover=NULL;
studio::IPC *ipc=NULL;
studio::DockManager* studio::App::dock_manager=0;
studio::DeviceTracker* studio::App::device_tracker=0;
studio::Dialog_Gradient* studio::App::dialog_gradient;
studio::Dialog_Color* studio::App::dialog_color;
studio::Dialog_Input* studio::App::dialog_input;
studio::Dialog_ToolOptions* studio::App::dialog_tool_options;
studio::Dock_History* dock_history;
studio::Dock_Canvases* dock_canvases;
studio::Dock_Keyframes* dock_keyframes;
studio::Dock_Layers* dock_layers;
studio::Dock_Params* dock_params;
studio::Dock_MetaData* dock_meta_data;
studio::Dock_Children* dock_children;
studio::Dock_Info* dock_info;
studio::Dock_LayerGroups* dock_layer_groups;
studio::Dock_Navigator* dock_navigator;
studio::Dock_Timetrack* dock_timetrack;
studio::Dock_Curves* dock_curves;
std::list< etl::handle< studio::Module > > module_list_;
bool studio::App::use_colorspace_gamma=true;
#ifdef SINGLE_THREADED
bool studio::App::single_threaded=false;
#endif // SINGLE THREADED
bool studio::App::restrict_radius_ducks=true;
bool studio::App::resize_imported_images=false;
bool studio::App::enable_experimental_features=false;
bool studio::App::use_dark_theme=false;
String studio::App::custom_filename_prefix(DEFAULT_FILENAME_PREFIX);
int studio::App::preferred_x_size=480;
int studio::App::preferred_y_size=270;
String studio::App::predefined_size(DEFAULT_PREDEFINED_SIZE);
String studio::App::predefined_fps(DEFAULT_PREDEFINED_FPS);
float studio::App::preferred_fps=24.0;
synfigapp::PluginManager studio::App::plugin_manager;
#ifdef USE_OPEN_FOR_URLS
String studio::App::browser_command("open"); // MacOS only
#else
String studio::App::browser_command("xdg-open"); // Linux XDG standard
#endif
String studio::App::brushes_path("");
String studio::App::sequence_separator(".");
bool studio::App::navigator_uses_cairo=false;
bool studio::App::workarea_uses_cairo=false;
bool studio::App::enable_mainwin_menubar = true;
String studio::App::ui_language ("os_LANG");
static int max_recent_files_=25;
int studio::App::get_max_recent_files() { return max_recent_files_; }
void studio::App::set_max_recent_files(int x) { max_recent_files_=x; }
static synfig::String app_base_path_;
namespace studio {
bool
really_delete_widget(Gtk::Widget *widget)
{
// synfig::info("really delete %p", (void*)widget);
delete widget;
return false;
}
// nasty workaround - when we've finished with a popup menu, we want to delete it
// attaching to the signal_hide() signal gets us here before the action on the menu has run,
// so schedule the real delete to happen in 50ms, giving the action a chance to run
void
delete_widget(Gtk::Widget *widget)
{
// synfig::info("delete %p", (void*)widget);
Glib::signal_timeout().connect(sigc::bind(sigc::ptr_fun(&really_delete_widget), widget), 50);
}
}; // END of namespace studio
studio::StateManager* state_manager;
class GlobalUIInterface : public synfigapp::UIInterface
{
public:
virtual Response confirmation(
const std::string &message,
const std::string &details,
const std::string &cancel,
const std::string &confirm,
Response dflt
)
{
Gtk::MessageDialog dialog(
message,
false,
Gtk::MESSAGE_WARNING,
Gtk::BUTTONS_NONE,
true
);
if (! details.empty())
dialog.set_secondary_text(details);
dialog.add_button(cancel, RESPONSE_CANCEL);
dialog.add_button(confirm, RESPONSE_OK);
dialog.set_default_response(dflt);
dialog.show_all();
return (Response) dialog.run();
}
virtual Response yes_no_cancel(
const std::string &message,
const std::string &details,
const std::string &button1,
const std::string &button2,
const std::string &button3,
Response dflt=RESPONSE_YES
)
{
Gtk::MessageDialog dialog(
message,
false,
Gtk::MESSAGE_QUESTION,
Gtk::BUTTONS_NONE,
true
);
dialog.set_secondary_text(details);
dialog.add_button(button1, RESPONSE_NO);
dialog.add_button(button2, RESPONSE_CANCEL);
dialog.add_button(button3, RESPONSE_YES);
dialog.set_default_response(dflt);
dialog.show();
return (Response)dialog.run();
}
virtual bool
task(const std::string &task)
{
std::cerr<<task.c_str()<<std::endl;
while(studio::App::events_pending())studio::App::iteration(false);
return true;
}
virtual bool
error(const std::string &err)
{
Gtk::MessageDialog dialog(err, false, Gtk::MESSAGE_ERROR, Gtk::BUTTONS_CLOSE, true);
dialog.show();
dialog.run();
return true;
}
virtual bool
warning(const std::string &err)
{
std::cerr<<"warning: "<<err.c_str()<<std::endl;
while(studio::App::events_pending())studio::App::iteration(false);
return true;
}
virtual bool
amount_complete(int /*current*/, int /*total*/)
{
while(studio::App::events_pending())studio::App::iteration(false);
return true;
}
};
/* === P R O C E D U R E S ================================================= */
/*
void
studio::UIManager::insert_action_group (const Glib::RefPtr<Gtk::ActionGroup>& action_group, int pos)
{
action_group_list.push_back(action_group);
Gtk::UIManager::insert_action_group(action_group, pos);
}
void
studio::UIManager::remove_action_group (const Glib::RefPtr<Gtk::ActionGroup>& action_group)
{
std::list<Glib::RefPtr<Gtk::ActionGroup> >::iterator iter;
for(iter=action_group_list.begin();iter!=action_group_list.end();++iter)
if(*iter==action_group)
{
action_group_list.erase(iter);
Gtk::UIManager::remove_action_group(action_group);
return;
}
synfig::error("Unable to find action group");
}
void
studio::add_action_group_to_top(Glib::RefPtr<studio::UIManager> ui_manager, Glib::RefPtr<Gtk::ActionGroup> group)
{
ui_manager->insert_action_group(group,0);
return;
std::list<Glib::RefPtr<Gtk::ActionGroup> > prev_groups(ui_manager->get_action_groups());
std::list<Glib::RefPtr<Gtk::ActionGroup> >::reverse_iterator iter;
for(iter=prev_groups.rbegin();iter!=prev_groups.rend();++iter)
{
if(*iter && (*iter)->get_name()!="menus")
{
synfig::info("Removing action group "+(*iter)->get_name());
ui_manager->remove_action_group(*iter);
}
}
ui_manager->insert_action_group(group,0);
for(;!prev_groups.empty();prev_groups.pop_front())
{
if(prev_groups.front() && prev_groups.front()!=group && prev_groups.front()->get_name()!="menus")
ui_manager->insert_action_group(prev_groups.front(),1);
}
}
*/
class Preferences : public synfigapp::Settings
{
public:
virtual bool get_value(const synfig::String& key, synfig::String& value)const
{
try
{
synfig::ChangeLocale change_locale(LC_NUMERIC, "C");
if(key=="gamma")
{
value=strprintf("%f %f %f %f",
App::gamma.get_gamma_r(),
App::gamma.get_gamma_g(),
App::gamma.get_gamma_b(),
App::gamma.get_black_level()
);
return true;
}
if(key=="time_format")
{
value=strprintf("%i",App::get_time_format());
return true;
}
if(key=="file_history.size")
{
value=strprintf("%i",App::get_max_recent_files());
return true;
}
if(key=="use_colorspace_gamma")
{
value=strprintf("%i",(int)App::use_colorspace_gamma);
return true;
}
if(key=="distance_system")
{
value=strprintf("%s",Distance::system_name(App::distance_system).c_str());
return true;
}
#ifdef SINGLE_THREADED
if(key=="single_threaded")
{
value=strprintf("%i",(int)App::single_threaded);
return true;
}
#endif
if(key=="auto_recover_backup_interval")
{
value=strprintf("%i",App::auto_recover->get_timeout());
return true;
}
if(key=="restrict_radius_ducks")
{
value=strprintf("%i",(int)App::restrict_radius_ducks);
return true;
}
if(key=="resize_imported_images")
{
value=strprintf("%i",(int)App::resize_imported_images);
return true;
}
if(key=="enable_experimental_features")
{
value=strprintf("%i",(int)App::enable_experimental_features);
return true;
}
if(key=="use_dark_theme")
{
value=strprintf("%i",(int)App::use_dark_theme);
return true;
}
if(key=="browser_command")
{
value=App::browser_command;
return true;
}
if(key=="brushes_path")
{
value=App::brushes_path;
return true;
}
if(key=="custom_filename_prefix")
{
value=App::custom_filename_prefix;
return true;
}
if(key=="preferred_x_size")
{
value=strprintf("%i",App::preferred_x_size);
return true;
}
if(key=="preferred_y_size")
{
value=strprintf("%i",App::preferred_y_size);
return true;
}
if(key=="predefined_size")
{
value=strprintf("%s",App::predefined_size.c_str());
return true;
}
if(key=="preferred_fps")
{
value=strprintf("%f",App::preferred_fps);
return true;
}
if(key=="predefined_fps")
{
value=strprintf("%s",App::predefined_fps.c_str());
return true;
}
if(key=="sequence_separator")
{
value=App::sequence_separator;
return true;
}
if(key=="navigator_uses_cairo")
{
value=strprintf("%i",(int)App::navigator_uses_cairo);
return true;
}
if(key=="workarea_uses_cairo")
{
value=strprintf("%i",(int)App::workarea_uses_cairo);
return true;
}
if(key=="enable_mainwin_menubar")
{
value=strprintf("%i", (int)App::enable_mainwin_menubar);
return true;
}
if(key == "ui_language")
{
value = strprintf ("%s", App::ui_language.c_str());
return true;
}
}
catch(...)
{
synfig::warning("Preferences: Caught exception when attempting to get value.");
}
return synfigapp::Settings::get_value(key,value);
}
virtual bool set_value(const synfig::String& key,const synfig::String& value)
{
try
{
synfig::ChangeLocale change_locale(LC_NUMERIC, "C");
if(key=="gamma")
{
float r,g,b,blk;
strscanf(value,"%f %f %f %f",
&r,
&g,
&b,
&blk
);
App::gamma.set_all(r,g,b,blk);
return true;
}
if(key=="time_format")
{
int i(atoi(value.c_str()));
App::set_time_format(static_cast<synfig::Time::Format>(i));
return true;
}
if(key=="auto_recover_backup_interval")
{
int i(atoi(value.c_str()));
App::auto_recover->set_timeout(i);
return true;
}
if(key=="file_history.size")
{
int i(atoi(value.c_str()));
App::set_max_recent_files(i);
return true;
}
if(key=="use_colorspace_gamma")
{
int i(atoi(value.c_str()));
App::use_colorspace_gamma=i;
return true;
}
if(key=="distance_system")
{
App::distance_system=Distance::ident_system(value);;
return true;
}
#ifdef SINGLE_THREADED
if(key=="single_threaded")
{
int i(atoi(value.c_str()));
App::single_threaded=i;
return true;
}
#endif
if(key=="restrict_radius_ducks")
{
int i(atoi(value.c_str()));
App::restrict_radius_ducks=i;
return true;
}
if(key=="resize_imported_images")
{
int i(atoi(value.c_str()));
App::resize_imported_images=i;
return true;
}
if(key=="enable_experimental_features")
{
int i(atoi(value.c_str()));
App::enable_experimental_features=i;
return true;
}
if(key=="use_dark_theme")
{
int i(atoi(value.c_str()));
App::use_dark_theme=i;
return true;
}
if(key=="browser_command")
{
App::browser_command=value;
return true;
}
if(key=="brushes_path")
{
App::brushes_path=value;
return true;
}
if(key=="custom_filename_prefix")
{
App::custom_filename_prefix=value;
return true;
}
if(key=="preferred_x_size")
{
int i(atoi(value.c_str()));
App::preferred_x_size=i;
return true;
}
if(key=="preferred_y_size")
{
int i(atoi(value.c_str()));
App::preferred_y_size=i;
return true;
}
if(key=="predefined_size")
{
App::predefined_size=value;
return true;
}
if(key=="preferred_fps")
{
float i(atof(value.c_str()));
App::preferred_fps=i;
return true;
}
if(key=="predefined_fps")
{
App::predefined_fps=value;
return true;
}
if(key=="sequence_separator")
{
App::sequence_separator=value;
return true;
}
if(key=="navigator_uses_cairo")
{
int i(atoi(value.c_str()));
App::navigator_uses_cairo=i;
return true;
}
if(key=="workarea_uses_cairo")
{
int i(atoi(value.c_str()));
App::workarea_uses_cairo=i;
return true;
}
if(key=="enable_mainwin_menubar")
{
int i(atoi(value.c_str()));
App::enable_mainwin_menubar = i;
return true;
}
if(key == "ui_language")
{
App::ui_language = value;
return true;
}
}
catch(...)
{
synfig::warning("Preferences: Caught exception when attempting to set value.");
}
return synfigapp::Settings::set_value(key,value);
}
virtual KeyList get_key_list()const
{
KeyList ret(synfigapp::Settings::get_key_list());
ret.push_back("gamma");
ret.push_back("time_format");
ret.push_back("distance_system");
ret.push_back("file_history.size");
ret.push_back("use_colorspace_gamma");
#ifdef SINGLE_THREADED
ret.push_back("single_threaded");
#endif
ret.push_back("auto_recover_backup_interval");
ret.push_back("restrict_radius_ducks");
ret.push_back("resize_imported_images");
ret.push_back("enable_experimental_features");
ret.push_back("use_dark_theme");
ret.push_back("browser_command");
ret.push_back("brushes_path");
ret.push_back("custom_filename_prefix");
ret.push_back("ui_language");
ret.push_back("preferred_x_size");
ret.push_back("preferred_y_size");
ret.push_back("predefined_size");
ret.push_back("preferred_fps");
ret.push_back("predefined_fps");
ret.push_back("sequence_separator");
ret.push_back("navigator_uses_cairo");
ret.push_back("workarea_uses_cairo");
ret.push_back("enable_mainwin_menubar");
return ret;
}
};
static ::Preferences _preferences;
void
init_ui_manager()
{
Glib::RefPtr<Gtk::ActionGroup> menus_action_group = Gtk::ActionGroup::create("menus");
Glib::RefPtr<Gtk::ActionGroup> actions_action_group = Gtk::ActionGroup::create("actions");
menus_action_group->add( Gtk::Action::create("menu-file", _("_File")));
menus_action_group->add( Gtk::Action::create("menu-open-recent", _("Open Recent")));
menus_action_group->add( Gtk::Action::create("menu-edit", _("_Edit")));
menus_action_group->add( Gtk::Action::create("menu-view", _("_View")));
menus_action_group->add( Gtk::Action::create("menu-duck-mask", _("Show/Hide Handles")));
menus_action_group->add( Gtk::Action::create("menu-preview-quality", _("Preview Quality")));
menus_action_group->add( Gtk::Action::create("menu-lowres-pixel", _("Low-Res Pixel Size")));
menus_action_group->add( Gtk::Action::create("menu-canvas", _("_Canvas")));
menus_action_group->add( Gtk::Action::create("menu-layer", _("_Layer")));
menus_action_group->add( Gtk::Action::create("menu-layer-new", _("New Layer")));
menus_action_group->add( Gtk::Action::create("menu-toolbox", _("Toolbox")));
menus_action_group->add( Gtk::Action::create("menu-plugins", _("Plug-Ins")));
menus_action_group->add( Gtk::Action::create("menu-window", _("_Window")));
menus_action_group->add( Gtk::Action::create("menu-arrange", _("_Arrange")));
menus_action_group->add( Gtk::Action::create("menu-workspace", _("Work_space")));
menus_action_group->add( Gtk::Action::create("menu-help", _("_Help")) );
menus_action_group->add(Gtk::Action::create("menu-keyframe","Keyframe"));
// Add the synfigapp actions (layer panel toolbar items, etc...)
synfigapp::Action::Book::iterator iter;
for(iter=synfigapp::Action::book().begin();iter!=synfigapp::Action::book().end();++iter)
{
actions_action_group->add(Gtk::Action::create(
"action-"+iter->second.name,
get_action_stock_id(iter->second),
iter->second.local_name,iter->second.local_name
));
}
// predefined actions to initial menu items, so that there is all menu items listing
// even there is no any canvas instance existed, for example, when app just opened.
// the menu items (action names) should be named consistently with those in canvasview.cpp and others.
#define DEFINE_ACTION(x,stock) { Glib::RefPtr<Gtk::Action> action( Gtk::Action::create(x, stock) ); actions_action_group->add(action); }
// actions in File menu
DEFINE_ACTION("new", Gtk::Stock::NEW);
DEFINE_ACTION("open", Gtk::Stock::OPEN);
DEFINE_ACTION("save", Gtk::Stock::SAVE);
DEFINE_ACTION("save-as", _("Save As..."));
DEFINE_ACTION("save-all", Gtk::StockID("synfig-saveall"));
DEFINE_ACTION("revert", Gtk::Stock::REVERT_TO_SAVED);
DEFINE_ACTION("cvs-add", Gtk::StockID("synfig-cvs_add"));
DEFINE_ACTION("cvs-update", Gtk::StockID("synfig-cvs_update"));
DEFINE_ACTION("cvs-commit", Gtk::StockID("synfig-cvs_commit"));
DEFINE_ACTION("cvs-revert", Gtk::StockID("synfig-cvs_revert"));
DEFINE_ACTION("import", _("Import..."));
DEFINE_ACTION("render", _("Render..."));
DEFINE_ACTION("preview", _("Preview..."));
DEFINE_ACTION("close-document", _("Close Document"));
DEFINE_ACTION("quit", Gtk::Stock::QUIT);
// actions in Edit menu
DEFINE_ACTION("undo", Gtk::Stock::UNDO);
DEFINE_ACTION("redo", Gtk::Stock::REDO);
DEFINE_ACTION("copy", Gtk::Stock::COPY);
DEFINE_ACTION("cut", Gtk::Stock::CUT);
DEFINE_ACTION("paste", Gtk::Stock::PASTE);
DEFINE_ACTION("select-all-ducks", _("Select All Handles"));
DEFINE_ACTION("unselect-all-ducks", _("Unselect All Handles"));
DEFINE_ACTION("select-all-layers", _("Select All Layers"));
DEFINE_ACTION("unselect-all-layers", _("Unselect All Layers"));
DEFINE_ACTION("input-devices", _("Input Devices..."));
DEFINE_ACTION("setup", _("Preferences..."));
DEFINE_ACTION("restore-default-settings", _("Restore Defaults"));
// actions in View menu
DEFINE_ACTION("toggle-mainwin-menubar", _("Menubar"));
DEFINE_ACTION("toggle-mainwin-toolbar", _("Toolbar"));
DEFINE_ACTION("mask-position-ducks", _("Show Position Handles"));
DEFINE_ACTION("mask-vertex-ducks", _("Show Vertex Handles"));
DEFINE_ACTION("mask-tangent-ducks", _("Show Tangent Handles"));
DEFINE_ACTION("mask-radius-ducks", _("Show Radius Handles"));
DEFINE_ACTION("mask-width-ducks", _("Show Width Handles"));
DEFINE_ACTION("mask-angle-ducks", _("Show Angle Handles"));
DEFINE_ACTION("mask-bone-setup-ducks", _("Show Bone Setup Handles"));
DEFINE_ACTION("mask-bone-recursive-ducks", _("Show Recursive Scale Bone Handles"));
DEFINE_ACTION("mask-bone-ducks", _("Next Bone Handles"));
DEFINE_ACTION("mask-widthpoint-position-ducks", _("Show WidthPoints Position Handles"));
DEFINE_ACTION("quality-00", _("Use Parametric Renderer"));
DEFINE_ACTION("quality-01", _("Use Quality Level 1"));
DEFINE_ACTION("quality-02", _("Use Quality Level 2"));
DEFINE_ACTION("quality-03", _("Use Quality Level 3"));
DEFINE_ACTION("quality-04", _("Use Quality Level 4"));
DEFINE_ACTION("quality-05", _("Use Quality Level 5"));
DEFINE_ACTION("quality-06", _("Use Quality Level 6"));
DEFINE_ACTION("quality-07", _("Use Quality Level 7"));
DEFINE_ACTION("quality-08", _("Use Quality Level 8"));
DEFINE_ACTION("quality-09", _("Use Quality Level 9"));
DEFINE_ACTION("quality-10", _("Use Quality Level 10"));
for(list<int>::iterator iter = CanvasView::get_pixel_sizes().begin(); iter != CanvasView::get_pixel_sizes().end(); iter++)
DEFINE_ACTION(strprintf("lowres-pixel-%d", *iter), strprintf(_("Set Low-Res pixel size to %d"), *iter));
DEFINE_ACTION("play", _("Play"));
// the stop is not a normal stop but a pause. So use "Pause" in UI, including TEXT and
// icon. the internal code is still using stop.
DEFINE_ACTION("stop", _("Pause"));
DEFINE_ACTION("toggle-grid-show", _("Toggle Grid Show"));
DEFINE_ACTION("toggle-grid-snap", _("Toggle Grid Snap"));
DEFINE_ACTION("toggle-guide-show", _("Toggle Guide Show"));
DEFINE_ACTION("toggle-guide-snap", _("Toggle Guide Snap"));
DEFINE_ACTION("toggle-low-res", _("Toggle Low-Res"));
DEFINE_ACTION("decrease-low-res-pixel-size", _("Decrease Low-Res Pixel Size"));
DEFINE_ACTION("increase-low-res-pixel-size", _("Increase Low-Res Pixel Size"));
DEFINE_ACTION("toggle-onion-skin", _("Toggle Onion Skin"));
DEFINE_ACTION("canvas-zoom-in", Gtk::StockID("gtk-zoom-in"));
DEFINE_ACTION("canvas-zoom-out", Gtk::StockID("gtk-zoom-out"));
DEFINE_ACTION("canvas-zoom-fit", Gtk::StockID("gtk-zoom-fit"));
DEFINE_ACTION("canvas-zoom-100", Gtk::StockID("gtk-zoom-100"));
DEFINE_ACTION("time-zoom-in", Gtk::StockID("gtk-zoom-in"));
DEFINE_ACTION("time-zoom-out", Gtk::StockID("gtk-zoom-out"));
DEFINE_ACTION("jump-next-keyframe", _("Seek to Next Keyframe"));
DEFINE_ACTION("jump-prev-keyframe", _("Seek to previous Keyframe"));
DEFINE_ACTION("seek-next-frame", _("Seek to Next Frame"));
DEFINE_ACTION("seek-prev-frame", _("Seek to Previous Frame"));
DEFINE_ACTION("seek-next-second", _("Seek Forward"));
DEFINE_ACTION("seek-prev-second", _("Seek Backward"));
DEFINE_ACTION("seek-begin", _("Seek to Begin"));
DEFINE_ACTION("seek-end", _("Seek to End"));
// actions in Canvas menu
DEFINE_ACTION("properties", _("Properties..."));
DEFINE_ACTION("options", _("Options..."));
// actions in Layer menu
DEFINE_ACTION("amount-inc", _("Increase Layer Amount"))
DEFINE_ACTION("amount-dec", _("Decrease Layer Amount"))
// actions in Window menu
DEFINE_ACTION("workspace-compositing", _("Compositing"));
DEFINE_ACTION("workspace-default", _("Default"));
DEFINE_ACTION("workspace-animating", _("Animating"));
DEFINE_ACTION("dialog-flipbook", _("Preview Dialog"));
DEFINE_ACTION("panel-toolbox","Toolbox");
DEFINE_ACTION("panel-tool_options",_("Tool Options"));
DEFINE_ACTION("panel-history", "History");
DEFINE_ACTION("panel-canvases",_("Canvas Browser"));
DEFINE_ACTION("panel-keyframes",_("Keyframes"));
DEFINE_ACTION("panel-layers",_("Layers"));
DEFINE_ACTION("panel-params",_("Parameters"));
DEFINE_ACTION("panel-meta_data",_("Canvas MetaData"));
DEFINE_ACTION("panel-children",_("Library"));
DEFINE_ACTION("panel-info",_("Info"));
DEFINE_ACTION("panel-navigator",_("Navigator"));
DEFINE_ACTION("panel-timetrack",_("Timetrack"));
DEFINE_ACTION("panel-curves",_("Graphs"));
DEFINE_ACTION("panel-groups",_("Sets"));
DEFINE_ACTION("panel-pal_edit",_("Palette Editor"));
// actions in Help menu
DEFINE_ACTION("help", Gtk::Stock::HELP);
DEFINE_ACTION("help-tutorials", Gtk::Stock::HELP);
DEFINE_ACTION("help-reference", Gtk::Stock::HELP);
DEFINE_ACTION("help-faq", Gtk::Stock::HELP);
DEFINE_ACTION("help-support", Gtk::Stock::HELP);
DEFINE_ACTION("help-about", Gtk::StockID("synfig-about"));