X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=synfig-studio%2Ftrunk%2Fsrc%2Fgtkmm%2Fapp.cpp;h=26f2f30494fb387b0cae113bcea71eb80f28c849;hb=6560846b17d7898c6c98398c7dda55ec1cbcaa74;hp=7295b3eabb764313223988baa862240a464a2068;hpb=02252941b29de64037116f4d37991a38d9ff0d94;p=synfig.git diff --git a/synfig-studio/trunk/src/gtkmm/app.cpp b/synfig-studio/trunk/src/gtkmm/app.cpp index 7295b3e..26f2f30 100644 --- a/synfig-studio/trunk/src/gtkmm/app.cpp +++ b/synfig-studio/trunk/src/gtkmm/app.cpp @@ -5,16 +5,17 @@ ** $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 */ /* ========================================================================= */ @@ -30,7 +31,11 @@ #include #include +#include +#ifdef HAVE_SYS_ERRNO_H +#include +#endif #include #include #include @@ -109,9 +114,12 @@ #endif #ifdef WIN32 +#define _WIN32_WINNT 0x0500 #include #endif #include +#include +#include #endif @@ -124,6 +132,14 @@ 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) @@ -450,6 +466,7 @@ 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; @@ -488,6 +505,9 @@ int check_license(String basedir) } synfig::info("License Authenticated -- Serial #%05d",serial); return serial; +#else + return 1; +#endif } /* @@ -650,7 +670,7 @@ public: } }; -static Preferences _preferences; +static ::Preferences _preferences; void init_ui_manager() @@ -666,7 +686,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") ); @@ -717,12 +737,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")); @@ -1192,21 +1212,29 @@ App::App(int *argc, char ***argv): state_manager->add_state(&state_rotate); state_manager->add_state(&state_bline); - state_manager->add_state(&state_polygon); + + state_manager->add_state(&state_circle); state_manager->add_state(&state_rectangle); - state_manager->add_state(&state_draw); - state_manager->add_state(&state_sketch); - + state_manager->add_state(&state_gradient); state_manager->add_state(&state_eyedrop); state_manager->add_state(&state_fill); - state_manager->add_state(&state_width); - state_manager->add_state(&state_gradient); - state_manager->add_state(&state_zoom); + if(false) { + // Disabled this tool because it should be + // considered deprecated. Use the bline tool instead. + state_manager->add_state(&state_polygon); + + // These tools are disabled for now, + // because they tend to confuse users. + state_manager->add_state(&state_draw); + state_manager->add_state(&state_sketch); + state_manager->add_state(&state_width); + } + studio_init_cb.task("Init ModPalette..."); module_list_.push_back(new ModPalette()); module_list_.back()->start(); @@ -1329,11 +1357,7 @@ App::~App() String App::get_user_app_directory() { -#ifdef __APPLE__ - return Glib::build_filename(Glib::get_home_dir(),"Library/Synfig"); -#else - return Glib::build_filename(Glib::get_home_dir(),"Synfig"); -#endif + return Glib::build_filename(Glib::get_home_dir(),SYNFIG_USER_APP_DIR); } synfig::String @@ -1401,8 +1425,11 @@ App::set_time_format(synfig::Time::Format x) void App::save_settings() { + char * old_locale; try { + old_locale=strdup(setlocale(LC_NUMERIC, NULL)); + setlocale(LC_NUMERIC, "C"); { std::string filename=get_config_file("accelrc"); Gtk::AccelMap::save(filename); @@ -1426,6 +1453,7 @@ App::save_settings() std::string filename=get_config_file("settings"); synfigapp::Main::settings().save_to_file(filename); + setlocale(LC_NUMERIC,old_locale); } catch(...) { @@ -1436,8 +1464,11 @@ App::save_settings() void App::load_settings() { + char * old_locale; try { + old_locale=strdup(setlocale(LC_NUMERIC, NULL)); + setlocale(LC_NUMERIC, "C"); { std::string filename=get_config_file("accelrc"); Gtk::AccelMap::load(filename); @@ -1477,7 +1508,7 @@ App::load_settings() synfigapp::Main::settings().set_value("window.toolbox.pos","4 4"); } } - + setlocale(LC_NUMERIC,old_locale); } catch(...) { @@ -1645,6 +1676,21 @@ App::dialog_open_file(const std::string &title, std::string &filename) 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; @@ -1686,6 +1732,7 @@ App::dialog_open_file(const std::string &title, std::string &filename) } gtk_widget_destroy(fileselection); return true; + */ #endif } @@ -1734,7 +1781,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 } @@ -1783,7 +1847,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 } @@ -1919,6 +2000,12 @@ 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;