From 5198e76ee434bd68985181d26900d71c1675cc63 Mon Sep 17 00:00:00 2001 From: Alex Valavanis Date: Tue, 9 Aug 2016 12:32:55 +0100 Subject: Move some main functions to Application class (bzr r15048) --- src/main.cpp | 104 +++++------------------------------------------------------ 1 file changed, 8 insertions(+), 96 deletions(-) (limited to 'src/main.cpp') diff --git a/src/main.cpp b/src/main.cpp index 28bdf8359..28ae6992f 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -46,7 +46,6 @@ #include -#include #include #include "inkgc/gc-core.h" @@ -101,9 +100,12 @@ #endif // WITH_DBUS #include +#include +#include #include #include #include +#include #ifndef HAVE_BIND_TEXTDOMAIN_CODESET #define bind_textdomain_codeset(p,c) @@ -851,8 +853,8 @@ static int sp_common_main( int argc, char const **argv, GSList **flDest ) // temporarily switch gettext encoding to locale, so that help messages can be output properly - gchar const *charset; - g_get_charset(&charset); + std::string charset; + Glib::get_charset(charset); bind_textdomain_codeset(GETTEXT_PACKAGE, charset); @@ -998,16 +1000,6 @@ snooper(GdkEvent *event, gpointer /*data*/) { gtk_main_do_event (event); } -static std::vector getDirectorySet(const gchar* userDir, const gchar* const * systemDirs) { - std::vector listing; - listing.push_back(userDir); - for ( const char* const* cur = systemDirs; *cur; cur++ ) - { - listing.push_back(*cur); - } - return listing; -} - int sp_main_gui(int argc, char const **argv) { @@ -1017,103 +1009,23 @@ sp_main_gui(int argc, char const **argv) int retVal = sp_common_main( argc, argv, &fl ); g_return_val_if_fail(retVal == 0, 1); - // Add possible icon entry directories - std::vector dataDirs = getDirectorySet( g_get_user_data_dir(), - g_get_system_data_dirs() ); - for (std::vector::iterator it = dataDirs.begin(); it != dataDirs.end(); ++it) - { - std::vector listing; - listing.push_back(*it); - listing.push_back("inkscape"); - listing.push_back("icons"); - Glib::ustring dir = Glib::build_filename(listing); - gtk_icon_theme_append_search_path(gtk_icon_theme_get_default(), dir.c_str()); - } - - // Add our icon directory to the search path for icon theme lookups. - gchar *usericondir = Inkscape::Application::profile_path("icons"); - gtk_icon_theme_append_search_path(gtk_icon_theme_get_default(), usericondir); - gtk_icon_theme_append_search_path(gtk_icon_theme_get_default(), INKSCAPE_PIXMAPDIR); -#ifdef INKSCAPE_THEMEDIR - gtk_icon_theme_append_search_path(gtk_icon_theme_get_default(), INKSCAPE_THEMEDIR); - gtk_icon_theme_rescan_if_needed (gtk_icon_theme_get_default()); -#endif - g_free(usericondir); - - // Add style sheet (GTK3) - Glib::RefPtr screen = Gdk::Screen::get_default(); - - Glib::ustring inkscape_style = INKSCAPE_UIDIR; - inkscape_style += "/style.css"; - // std::cout << "CSS Stylesheet Inkscape: " << inkscape_style << std::endl; - - if (g_file_test (inkscape_style.c_str(), G_FILE_TEST_EXISTS)) { - Glib::RefPtr provider = Gtk::CssProvider::create(); - - // From 3.16, throws an error which we must catch. - try { - provider->load_from_path (inkscape_style); - } -#if GTK_CHECK_VERSION(3,16,0) - // Gtk::CssProviderError not defined until 3.16. - catch (const Gtk::CssProviderError& ex) - { - std::cerr << "CSSProviderError::load_from_path(): failed to load: " << inkscape_style - << "\n (" << ex.what() << ")" << std::endl; - } -#else - catch (...) - {} -#endif - - Gtk::StyleContext::add_provider_for_screen (screen, provider, GTK_STYLE_PROVIDER_PRIORITY_APPLICATION); - } else { - std::cerr << "sp_main_gui: Cannot find default style file:\n (" << inkscape_style - << ")" << std::endl; - } - - Glib::ustring user_style = Inkscape::Application::profile_path("ui/style.css"); - // std::cout << "CSS Stylesheet User: " << user_style << std::endl; - - if (g_file_test (user_style.c_str(), G_FILE_TEST_EXISTS)) { - Glib::RefPtr provider2 = Gtk::CssProvider::create(); - - // From 3.16, throws an error which we must catch. - try { - provider2->load_from_path (user_style); - } -#if GTK_CHECK_VERSION(3,16,0) - // Gtk::CssProviderError not defined until 3.16. - catch (const Gtk::CssProviderError& ex) - { - std::cerr << "CSSProviderError::load_from_path(): failed to load: " << user_style - << "\n (" << ex.what() << ")" << std::endl; - } -#else - catch (...) - {} -#endif - - Gtk::StyleContext::add_provider_for_screen (screen, provider2, GTK_STYLE_PROVIDER_PRIORITY_APPLICATION); - } - gdk_event_handler_set((GdkEventFunc)snooper, NULL, NULL); Inkscape::Debug::log_display_config(); // Set default window icon. Obeys the theme. - gtk_window_set_default_icon_name("inkscape"); + Gtk::Window::set_default_icon_name("inkscape"); // Do things that were previously in inkscape_gtk_stock_init(). sp_icon_get_phys_size(GTK_ICON_SIZE_MENU); Inkscape::UI::Widget::Panel::prep(); - gboolean create_new = TRUE; + bool create_new = true; /// \todo FIXME BROKEN - non-UTF-8 sneaks in here. Inkscape::Application::create(argv[0], true); while (fl) { if (sp_file_open((gchar *)fl->data,NULL)) { - create_new=FALSE; + create_new=false; } fl = g_slist_remove(fl, fl->data); } -- cgit v1.2.3