2
* @brief The top level class for managing the application
5
* Bryce W. Harrington <bryce@bryceharrington.org>
6
* Ralf Stephan <ralf@ark.in-berlin.de>
8
* Copyright (C) 2005 Authors
10
* Released under GNU GPL. Read the file 'COPYING' for more information.
17
#include <gtkmm/main.h>
19
#include "preferences.h"
20
#include "application.h"
23
int sp_main_gui(int argc, char const **argv);
24
int sp_main_console(int argc, char const **argv);
26
static Gtk::Main *_gtk_main;
27
static bool _use_gui, _new_gui;
30
namespace NSApplication {
32
Application::Application(int argc, char **argv, bool use_gui, bool new_gui)
42
_argv = argv; // TODO: Is this correct?
46
_gtk_main = new Gtk::Main(argc, argv, true);
48
// TODO: Determine class by arguments
49
g_warning("Creating new Editor");
50
_app_impl = (AppPrototype*) Editor::create(_argc, _argv);
53
// No op - we'll use the old interface
55
_app_impl = NULL; // = Cmdline(_argc, _argv);
58
/// \todo Install segv handler here?
60
// Inkscape::Extension::init();
63
Application::~Application()
69
/** Returns the current home directory location */
71
Application::homedir() const
74
_path_home = g_strdup(g_get_home_dir());
75
gchar* utf8Path = g_filename_to_utf8( _path_home, -1, NULL, NULL, NULL );
77
_path_home = utf8Path;
78
if ( !g_utf8_validate(_path_home, -1, NULL) ) {
79
g_warning( "Home directory is non-UTF-8" );
83
if ( !_path_home && _argv != NULL) {
84
gchar * path = g_path_get_dirname(_argv[0]);
85
gchar * utf8Path = g_filename_to_utf8( path, -1, NULL, NULL, NULL );
88
_path_home = utf8Path;
89
if ( !g_utf8_validate(_path_home, -1, NULL) ) {
90
g_warning( "Application run directory is non-UTF-8" );
102
/* Note: This if loop should be replaced by calls to the
103
* various subclasses of I::A::AppPrototype.
105
if (_gtk_main != NULL) {
106
g_assert(_app_impl != NULL);
107
g_warning("Running main window");
108
Gtk::Window *win = static_cast<Gtk::Window*>(_app_impl->getWindow());
109
g_assert(win != NULL);
110
_gtk_main->run(*win);
113
} else if (_use_gui) {
114
result = sp_main_gui(_argc, (const char**)_argv);
117
result = sp_main_console(_argc, (const char**)_argv);
126
Inkscape::Preferences::unload();
128
if (_gtk_main != NULL) {
135
Application::getUseGui()
141
Application::getNewGui()
147
} // namespace NSApplication
148
} // namespace Inkscape
154
c-file-style:"stroustrup"
155
c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
160
// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :