X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=synfig-studio%2Ftrunk%2Fsrc%2Fgtkmm%2Fapp.cpp;h=ec2697e8731d0b231cba0d7bb8e0e0e9a45384ed;hb=62136261cc9eed43f117b46c61361dda07dfce97;hp=b59d5ef1b8f046406e8122eab854a1a137dbccba;hpb=b26c2401611fca2d36486151a9168865b0cafbb1;p=synfig.git diff --git a/synfig-studio/trunk/src/gtkmm/app.cpp b/synfig-studio/trunk/src/gtkmm/app.cpp index b59d5ef..ec2697e 100644 --- a/synfig-studio/trunk/src/gtkmm/app.cpp +++ b/synfig-studio/trunk/src/gtkmm/app.cpp @@ -54,6 +54,7 @@ #include #include #include +#include #include @@ -88,6 +89,7 @@ #include "state_rectangle.h" #include "state_smoothmove.h" #include "state_scale.h" +#include "state_text.h" #include "state_width.h" #include "state_rotate.h" #include "state_zoom.h" @@ -271,7 +273,11 @@ bool studio::App::use_colorspace_gamma=true; bool studio::App::single_threaded=false; #endif bool studio::App::restrict_radius_ducks=false; -String studio::App::browser_command("firefox"); +#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 static int max_recent_files_=25; int studio::App::get_max_recent_files() { return max_recent_files_; } @@ -1013,6 +1019,8 @@ init_ui_manager() ACCEL("//state-width", "t"); ACCEL("//state-mirror", "m"); + ACCEL("//state-text", "x"); + ACCEL("//canvas-zoom-fit","z"); #undef ACCEL @@ -1070,7 +1078,6 @@ App::App(int *argc, char ***argv): Glib::set_application_name(_("Synfig Studio")); Splash splash_screen; - splash_screen.set_can_self_destruct(false); splash_screen.show(); shutdown_in_progress=false; @@ -1191,6 +1198,8 @@ App::App(int *argc, char ***argv): 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); @@ -1775,7 +1784,7 @@ static OPENFILENAME ofn={}; bool App::dialog_open_file(const std::string &title, std::string &filename, std::string preference) { - info("App::dialog_open_file('%s', '%s', '%s')", title.c_str(), filename.c_str(), preference.c_str()); + // info("App::dialog_open_file('%s', '%s', '%s')", title.c_str(), filename.c_str(), preference.c_str()); #ifdef USE_WIN32_FILE_DIALOGS static TCHAR szFilter[] = TEXT ("All Files (*.*)\0*.*\0\0") ; @@ -1901,7 +1910,7 @@ App::dialog_open_file(const std::string &title, std::string &filename, std::stri bool App::dialog_save_file(const std::string &title, std::string &filename, std::string preference) { - info("App::dialog_save_file('%s', '%s', '%s')", title.c_str(), filename.c_str(), preference.c_str()); + // info("App::dialog_save_file('%s', '%s', '%s')", title.c_str(), filename.c_str(), preference.c_str()); #if USE_WIN32_FILE_DIALOGS static TCHAR szFilter[] = TEXT ("All Files (*.*)\0*.*\0\0") ; @@ -1964,7 +1973,8 @@ App::dialog_save_file(const std::string &title, std::string &filename, std::stri { file_type_enum = manage(new Widget_Enum()); file_type_enum->set_param_desc(ParamDesc().set_hint("enum") - .add_enum_value(synfig::RELEASE_VERSION_0_61_08, "0.61.08", strprintf("0.61.08 (%s)", _("current"))) + .add_enum_value(synfig::RELEASE_VERSION_0_61_09, "0.61.09", strprintf("0.61.09 (%s)", _("current"))) + .add_enum_value(synfig::RELEASE_VERSION_0_61_08, "0.61.08", "0.61.08") .add_enum_value(synfig::RELEASE_VERSION_0_61_07, "0.61.07", "0.61.07") .add_enum_value(synfig::RELEASE_VERSION_0_61_06, "0.61.06", strprintf("0.61.06 %s", _("and older")))); file_type_enum->set_value(RELEASE_VERSION_END-1); // default to the most recent version @@ -2079,24 +2089,75 @@ try_open_url(const std::string &url) { #ifdef WIN32 return ShellExecute(GetDesktopWindow(), "open", url.c_str(), NULL, NULL, SW_SHOW); -#else // WIN32 - gchar* argv[3] = {strdup(App::browser_command.c_str()), strdup(url.c_str()), NULL}; - - GError* gerror = NULL; - gboolean retval; - retval = g_spawn_async(NULL, argv, NULL, G_SPAWN_SEARCH_PATH, NULL, NULL, NULL, &gerror); - free(argv[0]); - free(argv[1]); - - if (!retval) - { - error(_("Could not execute specified web browser: %s"), gerror->message); - g_error_free(gerror); - return false; - } +#else // !WIN32 + std::vector command_line; + std::vector browsers; + browsers.reserve(23); + + // Browser wrapper scripts +#ifdef USE_OPEN_FOR_URLS + browsers.push_back("open"); // Apple MacOS X wrapper, on Linux it opens a virtual console +#endif + browsers.push_back("xdg-open"); // XDG wrapper + browsers.push_back("sensible-browser"); // Debian wrapper + browsers.push_back("gnome-open"); // GNOME wrapper + browsers.push_back("kfmclient"); // KDE wrapper + browsers.push_back("exo-open"); // XFCE wrapper + + // Alternatives system + browsers.push_back("gnome-www-browser"); // Debian GNOME alternative + browsers.push_back("x-www-browser"); // Debian GUI alternative + + // Individual browsers + browsers.push_back("firefox"); + browsers.push_back("epiphany-browser"); + browsers.push_back("epiphany"); + browsers.push_back("konqueror"); + browsers.push_back("iceweasel"); + browsers.push_back("mozilla"); + browsers.push_back("netscape"); + browsers.push_back("icecat"); + browsers.push_back("galeon"); + browsers.push_back("midori"); + browsers.push_back("safari"); + browsers.push_back("opera"); + browsers.push_back("amaya"); + browsers.push_back("netsurf"); + browsers.push_back("dillo"); + + // Try the user-specified browser first + command_line.push_back(App::browser_command); + if( command_line[0] == "kfmclient" ) command_line.push_back("openURL"); + command_line.push_back(url); + + try { Glib::spawn_async(".", command_line, Glib::SPAWN_SEARCH_PATH); return true; } + catch( Glib::SpawnError& exception ){ + + while ( !browsers.empty() ) + { + // Skip the browser if we already tried it + if( browsers[0] == App::browser_command ) + continue; + + // Construct the command line + command_line.clear(); + command_line.push_back(browsers[0]); + if( command_line[0] == "kfmclient" ) command_line.push_back("openURL"); + command_line.push_back(url); + + // Remove the browser from the list + browsers.erase(browsers.begin()); + + // Try to spawn the browser + try { Glib::spawn_async(".", command_line, Glib::SPAWN_SEARCH_PATH); } + // Failed, move on to the next one + catch(Glib::SpawnError& exception){ continue; } + return true; // No exception means we succeeded! + } + } - return true; -#endif // WIN32 + return false; +#endif // !WIN32 } void @@ -2114,7 +2175,13 @@ App::dialog_help() void App::open_url(const std::string &url) { - try_open_url(url); + if(!try_open_url(url)) + { + Gtk::MessageDialog dialog(_("No browser was found. Please load this website manually:"), false, Gtk::MESSAGE_ERROR, Gtk::BUTTONS_CLOSE, true); + dialog.set_secondary_text(url); + dialog.set_title(_("No browser found")); + dialog.run(); + } } bool @@ -2123,8 +2190,8 @@ App::dialog_entry(const std::string &title, const std::string &message,std::stri Gtk::Dialog dialog( title, // Title true, // Modal - true // use_separator - ); + true); // use_separator + Gtk::Label label(message); label.show(); dialog.get_vbox()->pack_start(label); @@ -2133,11 +2200,13 @@ App::dialog_entry(const std::string &title, const std::string &message,std::stri entry.set_text(text); entry.show(); entry.set_activates_default(true); + dialog.get_vbox()->pack_start(entry); dialog.add_button(Gtk::StockID("gtk-ok"),Gtk::RESPONSE_OK); dialog.add_button(Gtk::StockID("gtk-cancel"),Gtk::RESPONSE_CANCEL); dialog.set_default_response(Gtk::RESPONSE_OK); + entry.signal_activate().connect(sigc::bind(sigc::mem_fun(dialog,&Gtk::Dialog::response),Gtk::RESPONSE_OK)); dialog.show(); @@ -2149,8 +2218,39 @@ App::dialog_entry(const std::string &title, const std::string &message,std::stri return true; } +bool +App::dialog_paragraph(const std::string &title, const std::string &message,std::string &text) +{ + Gtk::Dialog dialog( + title, // Title + true, // Modal + true); // use_separator + + Gtk::Label label(message); + label.show(); + dialog.get_vbox()->pack_start(label); + + Glib::RefPtr text_buffer(Gtk::TextBuffer::create()); + text_buffer->set_text(text); + Gtk::TextView text_view(text_buffer); + text_view.show(); + dialog.get_vbox()->pack_start(text_view); + dialog.add_button(Gtk::StockID("gtk-ok"),Gtk::RESPONSE_OK); + dialog.add_button(Gtk::StockID("gtk-cancel"),Gtk::RESPONSE_CANCEL); + dialog.set_default_response(Gtk::RESPONSE_OK); + + //text_entry.signal_activate().connect(sigc::bind(sigc::mem_fun(dialog,&Gtk::Dialog::response),Gtk::RESPONSE_OK)); + dialog.show(); + + if(dialog.run()!=Gtk::RESPONSE_OK) + return false; + + text=text_buffer->get_text(); + + return true; +} bool App::open(std::string filename)