X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;ds=sidebyside;f=synfig-studio%2Ftrunk%2Fsrc%2Fgtkmm%2Fapp.cpp;h=18cab60718d31006cd071894dbf9832b66f466df;hb=955793a73eff1191da57a4e3b3446f761c39e7e1;hp=ec2697e8731d0b231cba0d7bb8e0e0e9a45384ed;hpb=4b9ecaaa0023322d30f489ed1b328f2bfb99adcb;p=synfig.git
diff --git a/synfig-studio/trunk/src/gtkmm/app.cpp b/synfig-studio/trunk/src/gtkmm/app.cpp
index ec2697e..18cab60 100644
--- a/synfig-studio/trunk/src/gtkmm/app.cpp
+++ b/synfig-studio/trunk/src/gtkmm/app.cpp
@@ -8,6 +8,7 @@
** Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley
** Copyright (c) 2007, 2008 Chris Moore
** Copyright (c) 2008 Gerald Young
+** Copyright (c) 2008 Carlos López
**
** This package is free software; you can redistribute it and/or
** modify it under the terms of the GNU General Public License as
@@ -89,6 +90,7 @@
#include "state_rectangle.h"
#include "state_smoothmove.h"
#include "state_scale.h"
+#include "state_star.h"
#include "state_text.h"
#include "state_width.h"
#include "state_rotate.h"
@@ -273,6 +275,11 @@ bool studio::App::use_colorspace_gamma=true;
bool studio::App::single_threaded=false;
#endif
bool studio::App::restrict_radius_ducks=false;
+bool studio::App::resize_imported_images=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);
#ifdef USE_OPEN_FOR_URLS
String studio::App::browser_command("open"); // MacOS only
#else
@@ -505,12 +512,37 @@ public:
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=="browser_command")
{
value=App::browser_command;
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;
+ }
+
return synfigapp::Settings::get_value(key,value);
}
@@ -574,12 +606,39 @@ public:
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=="browser_command")
{
App::browser_command=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;
+ }
return synfigapp::Settings::set_value(key,value);
}
@@ -596,7 +655,12 @@ public:
#endif
ret.push_back("auto_recover_backup_interval");
ret.push_back("restrict_radius_ducks");
+ ret.push_back("resize_imported_images");
ret.push_back("browser_command");
+ ret.push_back("custom_filename_prefix");
+ ret.push_back("preferred_x_size");
+ ret.push_back("preferred_y_size");
+ ret.push_back("predefined_size");
return ret;
}
};
@@ -669,6 +733,8 @@ init_ui_manager()
DEFINE_ACTION("copy", Gtk::StockID("gtk-copy"));
DEFINE_ACTION("paste", Gtk::StockID("gtk-paste"));
DEFINE_ACTION("select-all-ducks", _("Select All Ducks"));
+ DEFINE_ACTION("unselect-all-ducks", _("Unselect All Ducks"));
+ DEFINE_ACTION("select-all-layers", _("Select All Layers"));
DEFINE_ACTION("unselect-all-layers", _("Unselect All Layers"));
DEFINE_ACTION("properties", _("Properties"));
@@ -797,8 +863,10 @@ init_ui_manager()
" "
" "
" "
-" "
+" "
" "
+" "
+" "
" "
" "
" "
@@ -937,7 +1005,9 @@ init_ui_manager()
}
ACCEL("//select-all-ducks","a");
- ACCEL("//unselect-all-layers","d");
+ ACCEL("//unselect-all-ducks","d");
+ ACCEL("//select-all-layers","a");
+ ACCEL("//unselect-all-layers","d");
ACCEL("//render","F9");
ACCEL("//preview","F11");
ACCEL("//properties","F8");
@@ -1001,25 +1071,25 @@ init_ui_manager()
ACCEL("//state-normal", "a");
ACCEL("//state-smooth_move", "v");
- ACCEL("//state-scale", "d");
- ACCEL("//state-rotate", "s");
+ ACCEL("//state-scale", "s");
+ ACCEL("//state-rotate", "t");
+ ACCEL("//state-mirror", "m");
- ACCEL("//state-bline", "b");
ACCEL("//state-circle", "c");
ACCEL("//state-rectangle", "r");
+ ACCEL("//state-star", "q");
ACCEL("//state-gradient", "g");
+ ACCEL("//state-polygon", "p");
- ACCEL("//state-eyedrop", "e");
+ ACCEL("//state-bline", "b");
+ ACCEL("//state-text", "x");
ACCEL("//state-fill", "f");
+ ACCEL("//state-eyedrop", "e");
ACCEL("//state-zoom", "z");
- ACCEL("//state-polygon", "p");
- ACCEL("//state-draw", "w");
+ ACCEL("//state-draw", "d");
ACCEL("//state-sketch", "k");
- ACCEL("//state-width", "t");
- ACCEL("//state-mirror", "m");
-
- ACCEL("//state-text", "x");
+ ACCEL("//state-width", "w");
ACCEL("//canvas-zoom-fit","z");
@@ -1086,6 +1156,11 @@ App::App(int *argc, char ***argv):
// Initialize the Synfig library
try { synfigapp_main=etl::smart_ptr(new synfigapp::Main(etl::dirname((*argv)[0]),&synfig_init_cb)); }
+ catch(std::runtime_error x)
+ {
+ get_ui_interface()->error(strprintf("%s\n\n%s", _("Failed to initialize synfig!"), x.what()));
+ throw;
+ }
catch(...)
{
get_ui_interface()->error(_("Failed to initialize synfig!"));
@@ -1185,23 +1260,22 @@ App::App(int *argc, char ***argv):
studio_init_cb.task(_("Init ModMirror...")); module_list_.push_back(new ModMirror()); module_list_.back()->start();
/* row 2 */
- state_manager->add_state(&state_bline);
state_manager->add_state(&state_circle);
state_manager->add_state(&state_rectangle);
+ state_manager->add_state(&state_star);
state_manager->add_state(&state_gradient);
if(!getenv("SYNFIG_DISABLE_POLYGON")) state_manager->add_state(&state_polygon); // Enabled - for working without ducks
/* row 3 */
- if(!getenv("SYNFIG_DISABLE_DRAW" )) state_manager->add_state(&state_draw); // Enabled for now. Let's see whether they're good enough yet.
- if(!getenv("SYNFIG_DISABLE_SKETCH" )) state_manager->add_state(&state_sketch);
+ state_manager->add_state(&state_bline);
+ state_manager->add_state(&state_text);
state_manager->add_state(&state_fill);
state_manager->add_state(&state_eyedrop);
state_manager->add_state(&state_zoom);
- state_manager->add_state(&state_text);
-
- // Disabled by default - it doesn't work properly?
- if(getenv("SYNFIG_ENABLE_WIDTH" )) state_manager->add_state(&state_width);
+ if(!getenv("SYNFIG_DISABLE_DRAW" )) state_manager->add_state(&state_draw); // Enabled for now. Let's see whether they're good enough yet.
+ if(!getenv("SYNFIG_DISABLE_SKETCH" )) state_manager->add_state(&state_sketch);
+ if(!getenv("SYNFIG_DISABLE_WIDTH" )) state_manager->add_state(&state_width); // Enabled since 0.61.09
studio_init_cb.task(_("Init ModPalette..."));
module_list_.push_back(new ModPalette()); module_list_.back()->start();
@@ -1376,7 +1450,8 @@ App::set_recent_file_window_size(etl::handle instance)
// find the canvas
synfig::Canvas::Handle canvas;
try {
- canvas = instance->get_canvas()->find_canvas(String(canvas_window_size, current, separator-current));
+ String warnings;
+ canvas = instance->get_canvas()->find_canvas(String(canvas_window_size, current, separator-current), warnings);
}
catch(Exception::IDNotFound) {
// can't find the canvas; skip to the next canvas or return
@@ -1616,10 +1691,13 @@ App::load_settings()
{
if(!window_size_broken && !file_window_size)
window_size_broken = true;
- if(!window_size_broken)
- add_recent_file(recent_file,recent_file_window_size);
- else
- add_recent_file(recent_file);
+ if (std::ifstream(recent_file.c_str()))
+ {
+ if(!window_size_broken)
+ add_recent_file(recent_file,recent_file_window_size);
+ else
+ add_recent_file(recent_file);
+ }
}
}
if(!window_size_broken && file_window_size)
@@ -1668,6 +1746,11 @@ App::reset_initial_window_configuration()
synfigapp::Main::settings().set_value("pref.single_threaded","0");
#endif
synfigapp::Main::settings().set_value("pref.restrict_radius_ducks","0");
+ synfigapp::Main::settings().set_value("pref.resize_imported_images","0");
+ synfigapp::Main::settings().set_value("pref.custom_filename_prefix",DEFAULT_FILENAME_PREFIX);
+ synfigapp::Main::settings().set_value("pref.preferred_x_size","480");
+ synfigapp::Main::settings().set_value("pref.preferred_y_size","270");
+ synfigapp::Main::settings().set_value("pref.predefined_size",DEFAULT_PREDEFINED_SIZE);
synfigapp::Main::settings().set_value("window.toolbox.pos","4 4");
}
@@ -1851,7 +1934,7 @@ App::dialog_open_file(const std::string &title, std::string &filename, std::stri
if(dialog->run() == GTK_RESPONSE_ACCEPT) {
filename = dialog->get_filename();
- info("Saving preference %s = '%s' in App::dialog_open_file()", preference.c_str(), dirname(filename).c_str());
+ // info("Saving preference %s = '%s' in App::dialog_open_file()", preference.c_str(), dirname(filename).c_str());
_preferences.set_value(preference, dirname(filename));
delete dialog;
return true;
@@ -2010,7 +2093,7 @@ App::dialog_save_file(const std::string &title, std::string &filename, std::stri
if (preference == ANIMATION_DIR_PREFERENCE)
set_file_version(synfig::ReleaseVersion(file_type_enum->get_value()));
filename = dialog->get_filename();
- info("Saving preference %s = '%s' in App::dialog_save_file()", preference.c_str(), dirname(filename).c_str());
+ // info("Saving preference %s = '%s' in App::dialog_save_file()", preference.c_str(), dirname(filename).c_str());
_preferences.set_value(preference, dirname(filename));
delete dialog;
return true;
@@ -2276,8 +2359,9 @@ App::open_as(std::string filename,std::string as)
try
{
OneMoment one_moment;
+ String errors, warnings;
- etl::handle canvas(open_canvas_as(filename,as));
+ etl::handle canvas(open_canvas_as(filename,as,errors,warnings));
if(canvas && get_instance(canvas))
{
get_instance(canvas)->find_canvas_view(canvas)->present();
@@ -2287,9 +2371,12 @@ App::open_as(std::string filename,std::string as)
else
{
if(!canvas)
- throw (String)strprintf(_("Unable to open file \"%s\""),filename.c_str());
+ throw (String)strprintf(_("Unable to load \"%s\":\n\n"),filename.c_str()) + errors;
- if (as.find(DEFAULT_FILENAME_PREFIX) != 0)
+ if (warnings != "")
+ dialog_warning_blocking(_("Warnings"), strprintf("%s:\n\n%s", _("Warnings"), warnings.c_str()));
+
+ if (as.find(custom_filename_prefix.c_str()) != 0)
add_recent_file(as);
handle instance(Instance::create(canvas));
@@ -2310,6 +2397,11 @@ App::open_as(std::string filename,std::string as)
dialog_error_blocking(_("Error"), x);
return false;
}
+ catch(runtime_error x)
+ {
+ dialog_error_blocking(_("Error"), x.what());
+ return false;
+ }
catch(...)
{
dialog_error_blocking(_("Error"), _("Uncaught error on file open (BUG)"));
@@ -2325,7 +2417,7 @@ App::new_instance()
{
handle canvas=synfig::Canvas::create();
- String file_name(strprintf("%s%d", DEFAULT_FILENAME_PREFIX, Instance::get_count()+1));
+ String file_name(strprintf("%s%d", App::custom_filename_prefix.c_str(), Instance::get_count()+1));
canvas->set_name(file_name);
file_name += ".sifz";
@@ -2334,10 +2426,12 @@ App::new_instance()
canvas->rend_desc().set_time_end(5.0);
canvas->rend_desc().set_x_res(DPI2DPM(72.0f));
canvas->rend_desc().set_y_res(DPI2DPM(72.0f));
- canvas->rend_desc().set_tl(Vector(-4,2.25));
- canvas->rend_desc().set_br(Vector(4,-2.25));
- canvas->rend_desc().set_w(480);
- canvas->rend_desc().set_h(270);
+ // The top left and botton right positions are expressed in units
+ // Original convention is that 1 unit = 60 pixels
+ canvas->rend_desc().set_tl(Vector(-(preferred_x_size/60.0)/2.0,(preferred_y_size/60.0)/2.0));
+ canvas->rend_desc().set_br(Vector((preferred_x_size/60.0)/2.0,-(preferred_y_size/60.0)/2.0));
+ canvas->rend_desc().set_w(preferred_x_size);
+ canvas->rend_desc().set_h(preferred_y_size);
canvas->rend_desc().set_antialias(1);
canvas->rend_desc().set_flags(RendDesc::PX_ASPECT|RendDesc::IM_SPAN);
canvas->set_file_name(file_name);