summaryrefslogtreecommitdiffstats
path: root/src/inkscape.cpp
diff options
context:
space:
mode:
authorMichael Soegtrop <MSoegtrop@yahoo.de>2017-06-05 13:01:17 +0000
committerMichael Soegtrop <MSoegtrop@yahoo.de>2017-06-05 13:01:17 +0000
commit509ca3687330fea576ea67ae6c7f31d16e66b800 (patch)
tree9097520c54e355ded9bd0b4d6618af4e8dacdd91 /src/inkscape.cpp
parentupdated to latest trunk (diff)
parent[Bug #1695016] Xaml export misses some radialGradients. (diff)
downloadinkscape-509ca3687330fea576ea67ae6c7f31d16e66b800.tar.gz
inkscape-509ca3687330fea576ea67ae6c7f31d16e66b800.zip
updated to latest trunk
(bzr r14876.2.4)
Diffstat (limited to 'src/inkscape.cpp')
-rw-r--r--src/inkscape.cpp122
1 files changed, 109 insertions, 13 deletions
diff --git a/src/inkscape.cpp b/src/inkscape.cpp
index 888a64430..bf694ada7 100644
--- a/src/inkscape.cpp
+++ b/src/inkscape.cpp
@@ -15,13 +15,17 @@
*/
#ifdef HAVE_CONFIG_H
-# include "config.h"
+#include <config.h>
#endif
#include <errno.h>
#include <map>
+#include <glibmm/fileutils.h>
+
+#include <gtkmm/cssprovider.h>
+#include <gtkmm/icontheme.h>
#include <gtkmm/messagedialog.h>
#include "debug/simple-event.h"
#include "debug/event-tracker.h"
@@ -40,14 +44,10 @@
# include <shlobj.h>
#endif
-#include <cstring>
#include <glib/gstdio.h>
#include <glibmm/i18n.h>
#include <glibmm/miscutils.h>
#include <glibmm/convert.h>
-#include <gtk/gtk.h>
-#include <signal.h>
-#include <string>
#include "desktop.h"
@@ -58,17 +58,13 @@
#include "extension/output.h"
#include "extension/system.h"
#include "helper/action-context.h"
-#include "helper/sp-marshal.h"
#include "inkscape.h"
#include "io/sys.h"
-#include "layer-model.h"
#include "message-stack.h"
-#include "preferences.h"
+#include "path-prefix.h"
#include "resource-manager.h"
-#include "selection.h"
#include "ui/tools/tool-base.h"
#include "ui/dialog/debug.h"
-#include "xml/repr.h"
/* Backbones of configuration xml data */
#include "menus-skeleton.h"
@@ -278,7 +274,7 @@ int Application::autosave()
if (doc->isModifiedSinceSave()) {
gchar *oldest_autosave = 0;
const gchar *filename = 0;
- struct stat sb;
+ GStatBuf sb;
time_t min_time = 0;
gint count = 0;
@@ -388,6 +384,103 @@ void Application::argv0(char const* argv)
_argv0 = g_strdup(argv);
}
+/**
+ * \brief Add our icon theme to the search path
+ */
+void
+Application::add_icon_theme()
+{
+ // Get list of the possible folders containing the theme
+ auto dataDirs = Glib::get_system_data_dirs();
+ dataDirs.insert(dataDirs.begin(), Glib::get_user_data_dir());
+
+ auto icon_theme = Gtk::IconTheme::get_default();
+
+ for (auto it : dataDirs)
+ {
+ std::vector<Glib::ustring> listing;
+ listing.push_back(it);
+ listing.push_back("inkscape");
+ listing.push_back("icons");
+ auto dir = Glib::build_filename(listing);
+ icon_theme->append_search_path(dir);
+ }
+
+ // Add our icon directory to the search path for icon theme lookups.
+ auto const usericondir = Inkscape::Application::profile_path("icons");
+ icon_theme->append_search_path(usericondir);
+ icon_theme->append_search_path(INKSCAPE_PIXMAPDIR);
+#ifdef INKSCAPE_THEMEDIR
+ icon_theme->append_search_path(INKSCAPE_THEMEDIR);
+ icon_theme->rescan_if_needed();
+#endif
+ g_free(usericondir);
+}
+
+/**
+ * \brief Add our CSS style sheets
+ */
+void
+Application::add_style_sheet()
+{
+ // Add style sheet (GTK3)
+ auto const 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 (Glib::file_test(inkscape_style, Glib::FILE_TEST_EXISTS)) {
+ auto 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 (Glib::file_test(user_style, Glib::FILE_TEST_EXISTS)) {
+ auto 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);
+ }
+
+}
/* \brief Constructor for the application.
* Creates a new Inkscape::Application.
*
@@ -432,9 +525,12 @@ Application::Application(const char* argv, bool use_gui) :
}
if (use_gui) {
+ add_icon_theme();
+ add_style_sheet();
load_menus();
Inkscape::DeviceManager::getManager().loadConfig();
}
+
Inkscape::ResourceManager::getManager();
/* set language for user interface according setting in preferences */
@@ -453,7 +549,7 @@ Application::Application(const char* argv, bool use_gui) :
#define DEFAULT_LOG_REDIRECT false
#endif
- if (use_gui == TRUE && prefs->getBool("/dialogs/debug/redirect", DEFAULT_LOG_REDIRECT))
+ if (use_gui && prefs->getBool("/dialogs/debug/redirect", DEFAULT_LOG_REDIRECT))
{
Inkscape::UI::Dialog::DebugDialog::getInstance()->captureLogMessages();
}
@@ -560,6 +656,7 @@ Application::crash_handler (int /*signum*/)
repr = doc->getReprRoot();
if (doc->isModifiedSinceSave()) {
const gchar *docname;
+ char n[64];
/* originally, the document name was retrieved from
* the sodipod:docname attribute */
@@ -575,7 +672,6 @@ Application::crash_handler (int /*signum*/)
if (*d=='.') dots++;
}
if (*d=='.' && d>docname && dots==2) {
- char n[64];
size_t len = MIN (d - docname, 63);
memcpy (n, docname, len);
n[len] = '\0';