** \legal
** Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley
** Copyright (c) 2007, 2008 Chris Moore
+** Copyright (c) 2008 Gerald Young
**
** This package is free software; you can redistribute it and/or
** modify it under the terms of the GNU General Public License as
# include <config.h>
#endif
+#ifdef WIN32
+#define WINVER 0x0500
+#include <windows.h>
+#endif
+
#include <fstream>
#include <iostream>
#include <locale>
#include <fmod.h>
#endif
-#ifdef WIN32
-#define _WIN32_WINNT 0x0500
-#include <windows.h>
-#endif
#include <gtkmm/accelmap.h>
#include <gtkmm/filechooser.h>
#include <gtkmm/filechooserdialog.h>
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_; }
Glib::set_application_name(_("Synfig Studio"));
Splash splash_screen;
- splash_screen.set_can_self_destruct(false);
splash_screen.show();
shutdown_in_progress=false;
String
App::get_user_app_directory()
{
+//! \todo do we need locale_from_utf8() on non-Windows boxes too? (bug #1837445)
+#ifdef WIN32
+ return Glib::locale_from_utf8(Glib::build_filename(Glib::get_home_dir(),SYNFIG_USER_APP_DIR));
+#else
return Glib::build_filename(Glib::get_home_dir(),SYNFIG_USER_APP_DIR);
+#endif
}
synfig::String
return;
synfig::String::size_type current=0;
+ bool seen_root(false), shown_non_root(false);
while(current != synfig::String::npos)
{
// find end of first field (canvas) or return
synfig::String::size_type separator = canvas_window_size.find_first_of(' ', current);
- if(separator == synfig::String::npos) return;
+ if(separator == synfig::String::npos) break;
// find the canvas
synfig::Canvas::Handle canvas;
continue;
}
- CanvasView::Handle canvasview = instance->find_canvas_view(canvas);
- canvasview->present();
+ if (canvas->is_root())
+ seen_root = true;
+ else
+ shown_non_root = true;
// check that we have the tab character the ends this canvas' data or return
current = separator+1;
x += atoi(getenv("SYNFIG_WINDOW_POSITION_X_OFFSET"));
if(getenv("SYNFIG_WINDOW_POSITION_Y_OFFSET"))
y += atoi(getenv("SYNFIG_WINDOW_POSITION_Y_OFFSET"));
- canvasview->move(x,y);
if (w > SCALE_FACTOR) w = 150; if (w < 0) w = 0;
if (h > SCALE_FACTOR) h = 150; if (h < 0) h = 0;
- w=w*screen_w/SCALE_FACTOR;
- h=h*screen_h/SCALE_FACTOR;
- canvasview->set_default_size(w,h);
- canvasview->set_size_request(w,h);
+
+ CanvasView::Handle canvasview = instance->find_canvas_view(canvas);
+ canvasview->move(x,y);
+ canvasview->resize(w*screen_w/SCALE_FACTOR,h*screen_h/SCALE_FACTOR);
+ canvasview->present();
current = separator+1;
}
+
+ if (shown_non_root && !seen_root)
+ instance->find_canvas_view(instance->get_canvas())->hide();
}
void
std::string filename=get_config_file("settings");
if(!synfigapp::Main::settings().load_from_file(filename))
{
- //std::string filename=Glib::build_filename(Glib::get_home_dir(),".synfigrc");
+ //std::string filename=Glib::locale_from_utf8(Glib::build_filename(Glib::get_home_dir(),".synfigrc"));
//if(!synfigapp::Main::settings().load_from_file(filename))
{
gamma.set_gamma(1.0/2.2);
{
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
{
#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<std::string> command_line;
+ std::vector<std::string> 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
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
#ifdef WIN32
char long_name[1024];
if(GetLongPathName(as.c_str(),long_name,sizeof(long_name)));
- as=long_name;
+ // when called from autorecover.cpp, filename doesn't exist, and so long_name is empty
+ // don't use it if that's the case
+ if (long_name[0] != '\0')
+ as=long_name;
#endif
try
if(!canvas)
throw (String)strprintf(_("Unable to open file \"%s\""),filename.c_str());
- add_recent_file(as);
+ if (as.find(DEFAULT_FILENAME_PREFIX) != 0)
+ add_recent_file(as);
handle<Instance> instance(Instance::create(canvas));