X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=synfig-studio%2Ftrunk%2Fsrc%2Fgtkmm%2Fapp.cpp;h=a22bae00834eb5ed84d48c9a44f742d1feb42795;hb=0c2b7e48750351e8f3d39885dd1e2c2b73551523;hp=b63b37d8ec3de983389e385254234391eb5ce573;hpb=3a3c4bca3a17137bec5d7960560934b91ef4146e;p=synfig.git diff --git a/synfig-studio/trunk/src/gtkmm/app.cpp b/synfig-studio/trunk/src/gtkmm/app.cpp index b63b37d..a22bae0 100644 --- a/synfig-studio/trunk/src/gtkmm/app.cpp +++ b/synfig-studio/trunk/src/gtkmm/app.cpp @@ -1,20 +1,21 @@ -/* === S I N F G =========================================================== */ +/* === S Y N F I G ========================================================= */ /*! \file app.cpp ** \brief writeme ** -** $Id: app.cpp,v 1.10 2005/01/17 06:31:12 darco Exp $ +** $Id: app.cpp,v 1.11 2005/03/24 21:47:28 darco Exp $ ** ** \legal -** Copyright (c) 2002 Robert B. Quattlebaum Jr. +** Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley ** -** This software and associated documentation -** are CONFIDENTIAL and PROPRIETARY property of -** the above-mentioned copyright holder. +** 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. ** -** You may not copy, print, publish, or in any -** other way distribute this software without -** a prior written agreement with -** the copyright holder. +** 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 */ /* ========================================================================= */ @@ -31,6 +32,9 @@ #include #include +#ifdef HAVE_SYS_ERRNO_H +#include +#endif #include #include #include @@ -43,7 +47,7 @@ #include -#include +#include #include "app.h" #include "about.h" @@ -79,7 +83,7 @@ #include "autorecover.h" -#include +#include #include "dock_history.h" #include "dock_canvases.h" #include "dock_keyframes.h" @@ -109,9 +113,12 @@ #endif #ifdef WIN32 +#define _WIN32_WINNT 0x0500 #include #endif #include +#include +#include #endif @@ -119,11 +126,19 @@ using namespace std; using namespace etl; -using namespace sinfg; +using namespace synfig; using namespace studio; /* === M A C R O S ========================================================= */ +#ifndef SYNFIG_USER_APP_DIR +#ifdef __APPLE__ +#define SYNFIG_USER_APP_DIR "Library/Synfig" +#else +#define SYNFIG_USER_APP_DIR "Synfig" +#endif +#endif + #ifndef DPM2DPI #define DPM2DPI(x) (float(x)/39.3700787402f) #define DPI2DPM(x) (float(x)*39.3700787402f) @@ -144,7 +159,7 @@ using namespace studio; # define IMAGE_EXT "tif" #endif -#include +#include /* === S I G N A L S ======================================================= */ @@ -180,11 +195,11 @@ const std::list& App::get_recent_files() { return recent_files; } int App::Busy::count; bool App::shutdown_in_progress; -sinfg::Gamma App::gamma; +synfig::Gamma App::gamma; Glib::RefPtr App::ui_manager_; -sinfg::Distance::System App::distance_system; +synfig::Distance::System App::distance_system; studio::Dialog_Setup* App::dialog_setup; @@ -193,8 +208,8 @@ etl::handle< studio::ModPalette > mod_palette_; std::list > App::instance_list; -static etl::handle ui_interface_; -const etl::handle& App::get_ui_interface() { return ui_interface_; } +static etl::handle ui_interface_; +const etl::handle& App::get_ui_interface() { return ui_interface_; } etl::handle App::selected_instance; etl::handle App::selected_canvas_view; @@ -238,7 +253,7 @@ 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 sinfg::String app_base_path_; +static synfig::String app_base_path_; namespace studio { }; // END of namespace studio @@ -247,7 +262,7 @@ studio::StateManager* state_manager; -class GlobalUIInterface : public sinfgapp::UIInterface +class GlobalUIInterface : public synfigapp::UIInterface { public: @@ -371,7 +386,14 @@ static inline U32 hash_U32(U32 i) return i; } -inline int v_unwind_key(V_KeyUnwound* unwound, const char* key) +#ifdef BIG_ENDIAN +static const int endian_fix_table[8] = { 3, 2, 1, 0, 7, 6, 5, 4 } ; +#define endian_fix(x) (endian_fix_table[x]) +#else +#define endian_fix(x) (x) +#endif + +int v_unwind_key(V_KeyUnwound* unwound, const char* key) { int i; unwound->element.serial=0; @@ -408,7 +430,7 @@ inline int v_unwind_key(V_KeyUnwound* unwound, const char* key) return 1; } -inline int v_key_check(const char* key, U32* serial, U32 appid) +int v_key_check(const char* key, U32* serial, U32 appid) { V_KeyUnwound unwound_key; U32 appid_mask_a=hash_U32(appid); @@ -423,12 +445,12 @@ inline int v_key_check(const char* key, U32* serial, U32 appid) // Undo obfuscation pass { - U32 next=hash_U32(unwound_key.raw[7]); + U32 next=hash_U32(unwound_key.raw[endian_fix(7)]); int i; for(i=0;i<7;i++) { next=hash_U32(next); - unwound_key.raw[i]^=(next>>24); + unwound_key.raw[endian_fix(i)]^=(next>>24); } } @@ -443,6 +465,7 @@ inline int v_key_check(const char* key, U32* serial, U32 appid) int check_license(String basedir) { +#ifdef LICENSE_KEY_REQUIRED String key; String license_file; @@ -477,10 +500,13 @@ int check_license(String basedir) fclose(file); } else - sinfg::error("Unable to save license key!"); + synfig::error("Unable to save license key!"); } - sinfg::info("License Authenticated -- Serial #%05d",serial); + synfig::info("License Authenticated -- Serial #%05d",serial); return serial; +#else + return 1; +#endif } /* @@ -502,7 +528,7 @@ studio::UIManager::remove_action_group (const Glib::RefPtr& ac Gtk::UIManager::remove_action_group(action_group); return; } - sinfg::error("Unable to find action group"); + synfig::error("Unable to find action group"); } void @@ -520,7 +546,7 @@ studio::add_action_group_to_top(Glib::RefPtr ui_manager, Glib DEBUGPOINT(); if(*iter && (*iter)->get_name()!="menus") { - sinfg::info("Removing action group "+(*iter)->get_name()); + synfig::info("Removing action group "+(*iter)->get_name()); ui_manager->remove_action_group(*iter); } } @@ -536,10 +562,10 @@ studio::add_action_group_to_top(Glib::RefPtr ui_manager, Glib DEBUGPOINT(); } */ -class Preferences : public sinfgapp::Settings +class Preferences : public synfigapp::Settings { public: - virtual bool get_value(const sinfg::String& key, sinfg::String& value)const + virtual bool get_value(const synfig::String& key, synfig::String& value)const { if(key=="gamma") { @@ -577,10 +603,10 @@ public: return true; } - return sinfgapp::Settings::get_value(key,value); + return synfigapp::Settings::get_value(key,value); } - virtual bool set_value(const sinfg::String& key,const sinfg::String& value) + virtual bool set_value(const synfig::String& key,const synfig::String& value) { if(key=="gamma") { @@ -600,7 +626,7 @@ public: if(key=="time_format") { int i(atoi(value.c_str())); - App::set_time_format(static_cast(i)); + App::set_time_format(static_cast(i)); return true; } if(key=="auto_recover_backup_interval") @@ -627,12 +653,12 @@ public: return true; } - return sinfgapp::Settings::set_value(key,value); + return synfigapp::Settings::set_value(key,value); } virtual KeyList get_key_list()const { - KeyList ret(sinfgapp::Settings::get_key_list()); + KeyList ret(synfigapp::Settings::get_key_list()); ret.push_back("gamma"); ret.push_back("time_format"); ret.push_back("distance_system"); @@ -643,7 +669,7 @@ public: } }; -static Preferences _preferences; +static ::Preferences _preferences; void init_ui_manager() @@ -659,7 +685,7 @@ init_ui_manager() menus_action_group->add( Gtk::Action::create("menu-view", "_View") ); 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-duck-mask", "Mask Ducks") ); + menus_action_group->add( Gtk::Action::create("menu-duck-mask", "Show/Hide Ducks") ); menus_action_group->add( Gtk::Action::create("menu-preview-quality", "Preview Quality") ); menus_action_group->add( Gtk::Action::create("menu-layer-new", "New Layer") ); menus_action_group->add( Gtk::Action::create("menu-keyframe", "Keyframe") ); @@ -667,9 +693,9 @@ init_ui_manager() menus_action_group->add( Gtk::Action::create("menu-state", "State") ); menus_action_group->add( Gtk::Action::create("menu-toolbox", "Toolbox") ); - // Add the sinfgapp actions... - sinfgapp::Action::Book::iterator iter; - for(iter=sinfgapp::Action::book().begin();iter!=sinfgapp::Action::book().end();++iter) + // Add the synfigapp actions... + 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, @@ -683,15 +709,15 @@ init_ui_manager() #define DEFINE_ACTION_SIG(group,x,stock,sig) { Glib::RefPtr action( Gtk::Action::create(x, stock) ); /*action->set_sensitive(false);*/ group->add(action,sig); } DEFINE_ACTION2("keyframe-properties", Gtk::StockID("gtk-properties"), _("Keyframe Properties")); - DEFINE_ACTION("about", Gtk::StockID("sinfg-about")); + DEFINE_ACTION("about", Gtk::StockID("synfig-about")); DEFINE_ACTION("open", Gtk::Stock::OPEN); DEFINE_ACTION("save", Gtk::Stock::SAVE); DEFINE_ACTION("save-as", Gtk::Stock::SAVE_AS); DEFINE_ACTION("revert", Gtk::Stock::REVERT_TO_SAVED); - DEFINE_ACTION("cvs-add", Gtk::StockID("sinfg-cvs_add")); - DEFINE_ACTION("cvs-update", Gtk::StockID("sinfg-cvs_update")); - DEFINE_ACTION("cvs-commit", Gtk::StockID("sinfg-cvs_commit")); - DEFINE_ACTION("cvs-revert", Gtk::StockID("sinfg-cvs_revert")); + 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")); @@ -710,12 +736,12 @@ init_ui_manager() DEFINE_ACTION("unselect-all-layers", _("Unselect All Layers")); DEFINE_ACTION("properties", _("Properties")); - DEFINE_ACTION("mask-position-ducks", _("Mask Position Ducks")); - DEFINE_ACTION("mask-vertex-ducks", _("Mask Vertex Ducks")); - DEFINE_ACTION("mask-tangent-ducks", _("Mask Tangent Ducks")); - DEFINE_ACTION("mask-radius-ducks", _("Mask Radius Ducks")); - DEFINE_ACTION("mask-width-ducks", _("Mask Width Ducks")); - DEFINE_ACTION("mask-angle-ducks", _("Mask Angle Ducks")); + DEFINE_ACTION("mask-position-ducks", _("Show Position Ducks")); + DEFINE_ACTION("mask-vertex-ducks", _("Show Vertex Ducks")); + DEFINE_ACTION("mask-tangent-ducks", _("Show Tangent Ducks")); + DEFINE_ACTION("mask-radius-ducks", _("Show Radius Ducks")); + DEFINE_ACTION("mask-width-ducks", _("Show Width Ducks")); + DEFINE_ACTION("mask-angle-ducks", _("Show Angle Ducks")); DEFINE_ACTION("quality-00", _("Use Parametric Renderer")); DEFINE_ACTION("quality-01", _("Use Quality Level 1")); DEFINE_ACTION("quality-02", _("Use Quality Level 2")); @@ -760,15 +786,15 @@ init_ui_manager() #undef DEFINE_ACTION -// Set up sinfgapp actions +// Set up synfigapp actions /*{ - sinfgapp::Action::Book::iterator iter; + synfigapp::Action::Book::iterator iter; - for(iter=sinfgapp::Action::book().begin();iter!=sinfgapp::Action::book().end();++iter) + for(iter=synfigapp::Action::book().begin();iter!=synfigapp::Action::book().end();++iter) { Gtk::StockID stock_id; - if(!(iter->second.category&sinfgapp::Action::CATEGORY_HIDDEN)) + if(!(iter->second.category&synfigapp::Action::CATEGORY_HIDDEN)) { //Gtk::Image* image(manage(new Gtk::Image())); if(iter->second.task=="raise") stock_id=Gtk::Stock::GO_UP; @@ -780,7 +806,7 @@ init_ui_manager() else if(iter->second.task=="set_off") stock_id=Gtk::Stock::NO; //else if(iter->second.task=="duplicate") stock_id=Gtk::Stock::COPY; else if(iter->second.task=="remove") stock_id=Gtk::Stock::DELETE; - else stock_id=Gtk::StockID("sinfg-"+iter->second.task); + else stock_id=Gtk::StockID("synfig-"+iter->second.task); actions_action_group->add(Gtk::Action::create( "action-"+iter->second.name, @@ -939,7 +965,7 @@ init_ui_manager() } catch(const Glib::Error& ex) { - sinfg::error("building menus and toolbars failed: " + ex.what()); + synfig::error("building menus and toolbars failed: " + ex.what()); } // Add default keyboard accelerators @@ -1044,11 +1070,11 @@ App::App(int *argc, char ***argv): if(mkdir(get_user_app_directory().c_str(),ACCESSPERMS)<0) { if(errno!=EEXIST) - sinfg::error("UNABLE TO CREATE \"%s\"",get_user_app_directory().c_str()); + synfig::error("UNABLE TO CREATE \"%s\"",get_user_app_directory().c_str()); } else { - sinfg::info("Created directory \"%s\"",get_user_app_directory().c_str()); + synfig::info("Created directory \"%s\"",get_user_app_directory().c_str()); } @@ -1056,50 +1082,50 @@ App::App(int *argc, char ***argv): try { - if(!SINFG_CHECK_VERSION()) + if(!SYNFIG_CHECK_VERSION()) { - cerr<<"FATAL: Sinfg Version Mismatch"<(new sinfgapp::Main(etl::dirname((*argv)[0]),&sinfg_init_cb)); } + // Initialize the Synfig library + try { synfigapp_main=etl::smart_ptr(new synfigapp::Main(etl::dirname((*argv)[0]),&synfig_init_cb)); } catch(...) { - get_ui_interface()->error("Failed to initialize sinfg!"); + get_ui_interface()->error("Failed to initialize synfig!"); throw; } // add the preferences to the settings - sinfgapp::Main::settings().add_domain(&_preferences,"pref"); + synfigapp::Main::settings().add_domain(&_preferences,"pref"); try { @@ -1229,11 +1255,11 @@ App::App(int *argc, char ***argv): if( get_ui_interface()->yes_no( "Auto Recovery", - "SINFG Studio seems to have crashed\n" + "SYNFIG Studio seems to have crashed\n" "before you could save all your files.\n" "Would you like to re-open those files\n" "and recover your unsaved changes?" - )==sinfgapp::UIInterface::RESPONSE_YES + )==synfigapp::UIInterface::RESPONSE_YES ) { if(!auto_recover->recover()) @@ -1242,7 +1268,7 @@ App::App(int *argc, char ***argv): } else get_ui_interface()->error( - _("SINFG Studio has attempted to recover\n" + _("SYNFIG Studio has attempted to recover\n" "from a previous crash. The files that it has\n" "recovered are NOT YET SAVED. It would be a good\n" "idea to review them and save them now.") @@ -1281,7 +1307,7 @@ App::~App() save_settings(); - sinfgapp::Main::settings().remove_domain("pref"); + synfigapp::Main::settings().remove_domain("pref"); selected_instance=0; @@ -1322,11 +1348,11 @@ App::~App() String App::get_user_app_directory() { - return Glib::build_filename(Glib::get_home_dir(),"sinfg"); + return Glib::build_filename(Glib::get_home_dir(),SYNFIG_USER_APP_DIR); } -sinfg::String -App::get_config_file(const sinfg::String& file) +synfig::String +App::get_config_file(const synfig::String& file) { return Glib::build_filename(get_user_app_directory(),file); } @@ -1381,7 +1407,7 @@ App::get_time_format() } void -App::set_time_format(sinfg::Time::Format x) +App::set_time_format(synfig::Time::Format x) { _App_time_format=x; } @@ -1403,7 +1429,7 @@ App::save_settings() if(!file) { - sinfg::warning("Unable to save %s",filename.c_str()); + synfig::warning("Unable to save %s",filename.c_str()); break; } @@ -1414,11 +1440,11 @@ App::save_settings() }while(0); std::string filename=get_config_file("settings"); - sinfgapp::Main::settings().save_to_file(filename); + synfigapp::Main::settings().save_to_file(filename); } catch(...) { - sinfg::warning("Caught exception when attempting to save settings."); + synfig::warning("Caught exception when attempting to save settings."); } } @@ -1445,32 +1471,32 @@ App::load_settings() } } std::string filename=get_config_file("settings"); - if(!sinfgapp::Main::settings().load_from_file(filename)) + if(!synfigapp::Main::settings().load_from_file(filename)) { - //std::string filename=Glib::build_filename(Glib::get_home_dir(),".sinfgrc"); - //if(!sinfgapp::Main::settings().load_from_file(filename)) + //std::string filename=Glib::build_filename(Glib::get_home_dir(),".synfigrc"); + //if(!synfigapp::Main::settings().load_from_file(filename)) { gamma.set_gamma(1.0/2.2); - sinfgapp::Main::settings().set_value("dock.dialog.1.comp_selector","1"); - sinfgapp::Main::settings().set_value("dock.dialog.1.contents","navigator - info pal_edit pal_browse - tool_options history canvases - layers groups"); - sinfgapp::Main::settings().set_value("dock.dialog.1.contents_size","225 167 207"); - sinfgapp::Main::settings().set_value("dock.dialog.1.pos","1057 32"); - sinfgapp::Main::settings().set_value("dock.dialog.1.size","208 1174"); - sinfgapp::Main::settings().set_value("dock.dialog.2.comp_selector","0"); - sinfgapp::Main::settings().set_value("dock.dialog.2.contents","params children keyframes | timetrack curves meta_data"); - sinfgapp::Main::settings().set_value("dock.dialog.2.contents_size","263"); - sinfgapp::Main::settings().set_value("dock.dialog.2.pos","0 973"); - sinfgapp::Main::settings().set_value("dock.dialog.2.size","1045 235"); - sinfgapp::Main::settings().set_value("pref.distance_system","pt"); - sinfgapp::Main::settings().set_value("pref.use_colorspace_gamma","1"); - sinfgapp::Main::settings().set_value("window.toolbox.pos","4 4"); + synfigapp::Main::settings().set_value("dock.dialog.1.comp_selector","1"); + synfigapp::Main::settings().set_value("dock.dialog.1.contents","navigator - info pal_edit pal_browse - tool_options history canvases - layers groups"); + synfigapp::Main::settings().set_value("dock.dialog.1.contents_size","225 167 207"); + synfigapp::Main::settings().set_value("dock.dialog.1.pos","1057 32"); + synfigapp::Main::settings().set_value("dock.dialog.1.size","208 1174"); + synfigapp::Main::settings().set_value("dock.dialog.2.comp_selector","0"); + synfigapp::Main::settings().set_value("dock.dialog.2.contents","params children keyframes | timetrack curves meta_data"); + synfigapp::Main::settings().set_value("dock.dialog.2.contents_size","263"); + synfigapp::Main::settings().set_value("dock.dialog.2.pos","0 973"); + synfigapp::Main::settings().set_value("dock.dialog.2.size","1045 235"); + synfigapp::Main::settings().set_value("pref.distance_system","pt"); + synfigapp::Main::settings().set_value("pref.use_colorspace_gamma","1"); + synfigapp::Main::settings().set_value("window.toolbox.pos","4 4"); } } } catch(...) { - sinfg::warning("Caught exception when attempting to load settings."); + synfig::warning("Caught exception when attempting to load settings."); } } @@ -1502,20 +1528,20 @@ App::quit() return; /* - if((*iter)->sinfgapp::Instance::get_action_count()) + if((*iter)->synfigapp::Instance::get_action_count()) { - handle uim; + handle uim; uim=(*iter)->find_canvas_view((*iter)->get_canvas())->get_ui_interface(); assert(uim); string str=strprintf(_("Would you like to save your changes to %s?"),(*iter)->get_file_name().c_str() ); - switch(uim->yes_no_cancel((*iter)->get_canvas()->get_name(),str,sinfgapp::UIInterface::RESPONSE_YES)) + switch(uim->yes_no_cancel((*iter)->get_canvas()->get_name(),str,synfigapp::UIInterface::RESPONSE_YES)) { - case sinfgapp::UIInterface::RESPONSE_NO: + case synfigapp::UIInterface::RESPONSE_NO: break; - case sinfgapp::UIInterface::RESPONSE_YES: + case synfigapp::UIInterface::RESPONSE_YES: (*iter)->save(); break; - case sinfgapp::UIInterface::RESPONSE_CANCEL: + case synfigapp::UIInterface::RESPONSE_CANCEL: return; default: assert(0); @@ -1524,20 +1550,20 @@ App::quit() } - if((*iter)->sinfgapp::Instance::is_modified()) + if((*iter)->synfigapp::Instance::is_modified()) { - handle uim; + handle uim; uim=(*iter)->find_canvas_view((*iter)->get_canvas())->get_ui_interface(); assert(uim); string str=strprintf(_("%s has changes not yet on the CVS repository.\nWould you like to commit these changes?"),(*iter)->get_file_name().c_str() ); - switch(uim->yes_no_cancel((*iter)->get_canvas()->get_name(),str,sinfgapp::UIInterface::RESPONSE_YES)) + switch(uim->yes_no_cancel((*iter)->get_canvas()->get_name(),str,synfigapp::UIInterface::RESPONSE_YES)) { - case sinfgapp::UIInterface::RESPONSE_NO: + case synfigapp::UIInterface::RESPONSE_NO: break; - case sinfgapp::UIInterface::RESPONSE_YES: + case synfigapp::UIInterface::RESPONSE_YES: (*iter)->dialog_cvs_commit(); break; - case sinfgapp::UIInterface::RESPONSE_CANCEL: + case synfigapp::UIInterface::RESPONSE_CANCEL: return; default: assert(0); @@ -1630,10 +1656,25 @@ App::dialog_open_file(const std::string &title, std::string &filename) return false; #else - sinfg::String prev_path; + synfig::String prev_path; if(!_preferences.get_value("curr_path",prev_path)) prev_path="."; + Gtk::FileChooserDialog *dialog=new Gtk::FileChooserDialog(title,Gtk::FILE_CHOOSER_ACTION_OPEN); + dialog->set_current_folder(prev_path); + dialog->add_button(Gtk::StockID("gtk-ok"),GTK_RESPONSE_ACCEPT); + dialog->add_button(Gtk::StockID("gtk-cancel"),GTK_RESPONSE_CANCEL); + if(!filename.empty()) + dialog->set_filename(filename); + if(dialog->run()==GTK_RESPONSE_ACCEPT) { + filename=dialog->get_filename(); + delete dialog; + return true; + } + delete dialog; + return false; + /* + GtkWidget *ok; GtkWidget *cancel; int val=0; @@ -1675,6 +1716,7 @@ App::dialog_open_file(const std::string &title, std::string &filename) } gtk_widget_destroy(fileselection); return true; + */ #endif } @@ -1723,7 +1765,24 @@ App::dialog_save_file(const std::string &title, std::string &filename) } return false; #else - return dialog_open_file(title, filename); + synfig::String prev_path; + if(!_preferences.get_value("curr_path",prev_path)) + prev_path="."; + + Gtk::FileChooserDialog *dialog=new Gtk::FileChooserDialog(title,Gtk::FILE_CHOOSER_ACTION_SAVE); + dialog->set_current_folder(prev_path); + dialog->add_button(Gtk::StockID("gtk-ok"),GTK_RESPONSE_ACCEPT); + dialog->add_button(Gtk::StockID("gtk-cancel"),GTK_RESPONSE_CANCEL); + if(!filename.empty()) + dialog->set_filename(filename); + if(dialog->run()==GTK_RESPONSE_ACCEPT) { + filename=dialog->get_filename(); + delete dialog; + return true; + } + delete dialog; + return false; +// return dialog_open_file(title, filename); #endif } @@ -1772,7 +1831,24 @@ App::dialog_saveas_file(const std::string &title, std::string &filename) } return false; #else - return dialog_open_file(title, filename); + synfig::String prev_path; + if(!_preferences.get_value("curr_path",prev_path)) + prev_path="."; + + Gtk::FileChooserDialog *dialog=new Gtk::FileChooserDialog(title,Gtk::FILE_CHOOSER_ACTION_SAVE); + dialog->set_current_folder(prev_path); + dialog->add_button(Gtk::StockID("gtk-ok"),GTK_RESPONSE_ACCEPT); + dialog->add_button(Gtk::StockID("gtk-cancel"),GTK_RESPONSE_CANCEL); + if(!filename.empty()) + dialog->set_filename(filename); + if(dialog->run()==GTK_RESPONSE_ACCEPT) { + filename=dialog->get_filename(); + delete dialog; + return true; + } + delete dialog; + return false; +// return dialog_open_file(title, filename); #endif } @@ -1908,11 +1984,17 @@ App::open(std::string filename) bool App::open_as(std::string filename,std::string as) { +#ifdef WIN32 + char long_name[1024]; + if(GetLongPathName(as.c_str(),long_name,sizeof(long_name))); + as=long_name; +#endif + try { OneMoment one_moment; - etl::handle canvas(open_canvas_as(filename,as)); + etl::handle canvas(open_canvas_as(filename,as)); if(canvas && get_instance(canvas)) { get_instance(canvas)->find_canvas_view(canvas)->present(); @@ -1953,7 +2035,7 @@ App::open_as(std::string filename,std::string as) void App::new_instance() { - handle canvas=sinfg::Canvas::create(); + handle canvas=synfig::Canvas::create(); canvas->set_name(strprintf("Untitled%d",Instance::get_count())); String file_name(strprintf("untitled%d.sif",Instance::get_count())); @@ -2077,7 +2159,7 @@ studio::App::redo() selected_instance->redo(); } -sinfg::String +synfig::String studio::App::get_base_path() { return app_base_path_;