summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJabier Arraiza <jabier.arraiza@marker.es>2017-07-01 02:03:38 +0000
committerJabier Arraiza <jabier.arraiza@marker.es>2017-07-01 02:03:38 +0000
commit0d5bb885dee83f041830dc950d3be6f21a37f08b (patch)
tree88a0ae7a15ed496ddad1f83f43547783b88843ac /src
parentBug fixes (diff)
parentAdd Mac CI build config (diff)
downloadinkscape-0d5bb885dee83f041830dc950d3be6f21a37f08b.tar.gz
inkscape-0d5bb885dee83f041830dc950d3be6f21a37f08b.zip
update to trunk
Diffstat (limited to 'src')
-rw-r--r--src/color.h1
-rw-r--r--src/desktop-events.cpp2
-rw-r--r--src/extension/error-file.cpp3
-rw-r--r--src/extension/extension.cpp3
-rw-r--r--src/extension/init.cpp31
-rw-r--r--src/extension/internal/filter/filter-file.cpp21
-rw-r--r--src/extension/internal/filter/filter.h1
-rw-r--r--src/file.cpp45
-rw-r--r--src/helper/pixbuf-ops.cpp2
-rw-r--r--src/helper/png-write.h2
-rw-r--r--src/helper/window.cpp6
-rw-r--r--src/icon-size.h2
-rw-r--r--src/inkscape.cpp209
-rw-r--r--src/inkscape.h3
-rw-r--r--src/io/resource.cpp193
-rw-r--r--src/io/resource.h24
-rw-r--r--src/live_effects/parameter/bool.cpp1
-rw-r--r--src/live_effects/parameter/item.cpp4
-rw-r--r--src/live_effects/parameter/originalitem.cpp7
-rw-r--r--src/live_effects/parameter/originalpath.cpp7
-rw-r--r--src/live_effects/parameter/originalpatharray.cpp13
-rw-r--r--src/live_effects/parameter/path.cpp15
-rw-r--r--src/live_effects/parameter/point.cpp1
-rw-r--r--src/live_effects/parameter/text.cpp1
-rw-r--r--src/live_effects/parameter/togglebutton.cpp12
-rw-r--r--src/live_effects/parameter/togglebutton.h4
-rw-r--r--src/main.cpp3
-rw-r--r--src/menus-skeleton.h28
-rw-r--r--src/path-prefix.h2
-rw-r--r--src/pixmaps/cursor-3dbox.xpm2
-rw-r--r--src/pixmaps/cursor-arc.xpm38
-rw-r--r--src/pixmaps/cursor-arrow.xpm38
-rw-r--r--src/pixmaps/cursor-calligraphy.xpm2
-rw-r--r--src/pixmaps/cursor-connector.xpm2
-rw-r--r--src/pixmaps/cursor-crosshairs.xpm2
-rw-r--r--src/pixmaps/cursor-dropper-f.xpm19
-rw-r--r--src/pixmaps/cursor-dropper-s.xpm33
-rw-r--r--src/pixmaps/cursor-dropping-f.xpm39
-rw-r--r--src/pixmaps/cursor-dropping-s.xpm39
-rw-r--r--src/pixmaps/cursor-ellipse.xpm2
-rw-r--r--src/pixmaps/cursor-eraser.xpm2
-rw-r--r--src/pixmaps/cursor-gradient-add.xpm2
-rw-r--r--src/pixmaps/cursor-gradient.xpm2
-rw-r--r--src/pixmaps/cursor-measure.xpm2
-rw-r--r--src/pixmaps/cursor-node-d.xpm2
-rw-r--r--src/pixmaps/cursor-node-m.xpm38
-rw-r--r--src/pixmaps/cursor-node.xpm2
-rw-r--r--src/pixmaps/cursor-paintbucket.xpm2
-rw-r--r--src/pixmaps/cursor-pen.xpm2
-rw-r--r--src/pixmaps/cursor-pencil.xpm2
-rw-r--r--src/pixmaps/cursor-rect.xpm2
-rw-r--r--src/pixmaps/cursor-select-d.xpm2
-rw-r--r--src/pixmaps/cursor-select-m.xpm2
-rw-r--r--src/pixmaps/cursor-select.xpm2
-rw-r--r--src/pixmaps/cursor-spiral.xpm2
-rw-r--r--src/pixmaps/cursor-spray-move.xpm2
-rw-r--r--src/pixmaps/cursor-spray.xpm2
-rw-r--r--src/pixmaps/cursor-star.xpm2
-rw-r--r--src/pixmaps/cursor-text-insert.xpm2
-rw-r--r--src/pixmaps/cursor-text.xpm2
-rw-r--r--src/pixmaps/cursor-tweak-attract.xpm (renamed from src/pixmaps/cursor-attract.xpm)2
-rw-r--r--src/pixmaps/cursor-tweak-color.xpm (renamed from src/pixmaps/cursor-color.xpm)2
-rw-r--r--src/pixmaps/cursor-tweak-less.xpm2
-rw-r--r--src/pixmaps/cursor-tweak-more.xpm2
-rw-r--r--src/pixmaps/cursor-tweak-move-in.xpm2
-rw-r--r--src/pixmaps/cursor-tweak-move-jitter.xpm2
-rw-r--r--src/pixmaps/cursor-tweak-move-out.xpm2
-rw-r--r--src/pixmaps/cursor-tweak-move.xpm2
-rw-r--r--src/pixmaps/cursor-tweak-push.xpm (renamed from src/pixmaps/cursor-push.xpm)2
-rw-r--r--src/pixmaps/cursor-tweak-repel.xpm (renamed from src/pixmaps/cursor-repel.xpm)2
-rw-r--r--src/pixmaps/cursor-tweak-rotate-clockwise.xpm2
-rw-r--r--src/pixmaps/cursor-tweak-rotate-counterclockwise.xpm2
-rw-r--r--src/pixmaps/cursor-tweak-roughen.xpm (renamed from src/pixmaps/cursor-roughen.xpm)2
-rw-r--r--src/pixmaps/cursor-tweak-scale-down.xpm2
-rw-r--r--src/pixmaps/cursor-tweak-scale-up.xpm2
-rw-r--r--src/pixmaps/cursor-tweak-thicken.xpm (renamed from src/pixmaps/cursor-thicken.xpm)2
-rw-r--r--src/pixmaps/cursor-tweak-thin.xpm (renamed from src/pixmaps/cursor-thin.xpm)2
-rw-r--r--src/pixmaps/cursor-zoom-out.xpm2
-rw-r--r--src/pixmaps/cursor-zoom.xpm2
-rw-r--r--src/preferences.cpp28
-rw-r--r--src/preferences.h2
-rw-r--r--src/selection-chemistry.cpp3
-rw-r--r--src/shortcuts.cpp49
-rw-r--r--src/shortcuts.h13
-rw-r--r--src/sp-cursor.cpp106
-rw-r--r--src/sp-cursor.h3
-rw-r--r--src/sp-namedview.cpp46
-rw-r--r--src/ui/CMakeLists.txt4
-rw-r--r--src/ui/contextmenu.cpp914
-rw-r--r--src/ui/contextmenu.h218
-rw-r--r--src/ui/dialog/aboutbox.cpp27
-rw-r--r--src/ui/dialog/align-and-distribute.cpp4
-rw-r--r--src/ui/dialog/clonetiler.cpp5
-rw-r--r--src/ui/dialog/cssdialog.cpp3
-rw-r--r--src/ui/dialog/dialog-manager.cpp3
-rw-r--r--src/ui/dialog/dialog.cpp20
-rw-r--r--src/ui/dialog/dock-behavior.cpp5
-rw-r--r--src/ui/dialog/document-properties.cpp9
-rw-r--r--src/ui/dialog/export.cpp3
-rw-r--r--src/ui/dialog/filedialogimpl-gtkmm.cpp6
-rw-r--r--src/ui/dialog/fill-and-stroke.cpp7
-rw-r--r--src/ui/dialog/filter-editor.cpp128
-rw-r--r--src/ui/dialog/filter-editor.h53
-rw-r--r--src/ui/dialog/filter-effects-dialog.h8
-rw-r--r--src/ui/dialog/grid-arrange-tab.cpp5
-rw-r--r--src/ui/dialog/grid-arrange-tab.h20
-rw-r--r--src/ui/dialog/icon-preview.cpp188
-rw-r--r--src/ui/dialog/inkscape-preferences.cpp2
-rw-r--r--src/ui/dialog/knot-properties.cpp18
-rw-r--r--src/ui/dialog/knot-properties.h4
-rw-r--r--src/ui/dialog/layers.cpp40
-rw-r--r--src/ui/dialog/livepatheffect-editor.cpp3
-rw-r--r--src/ui/dialog/objects.cpp41
-rw-r--r--src/ui/dialog/polar-arrange-tab.cpp1
-rw-r--r--src/ui/dialog/spellcheck.cpp1
-rw-r--r--src/ui/dialog/styledialog.cpp5
-rw-r--r--src/ui/dialog/styledialog.h6
-rw-r--r--src/ui/dialog/swatches.cpp7
-rw-r--r--src/ui/dialog/symbols.cpp61
-rw-r--r--src/ui/dialog/tags.cpp11
-rw-r--r--src/ui/dialog/template-load-tab.cpp17
-rw-r--r--src/ui/dialog/template-load-tab.h4
-rw-r--r--src/ui/dialog/text-edit.cpp26
-rw-r--r--src/ui/dialog/transformation.cpp13
-rw-r--r--src/ui/dialog/undo-history.cpp9
-rw-r--r--src/ui/dialog/undo-history.h1
-rw-r--r--src/ui/dialog/xml-tree.cpp55
-rw-r--r--src/ui/interface.cpp1019
-rw-r--r--src/ui/interface.h189
-rw-r--r--src/ui/previewholder.cpp1
-rw-r--r--src/ui/tools/arc-tool.cpp2
-rw-r--r--src/ui/tools/box3d-tool.cpp2
-rw-r--r--src/ui/tools/calligraphic-tool.cpp2
-rw-r--r--src/ui/tools/connector-tool.cpp2
-rw-r--r--src/ui/tools/dropper-tool.cpp153
-rw-r--r--src/ui/tools/dropper-tool.h5
-rw-r--r--src/ui/tools/dynamic-base.cpp4
-rw-r--r--src/ui/tools/dynamic-base.h2
-rw-r--r--src/ui/tools/eraser-tool.cpp2
-rw-r--r--src/ui/tools/flood-tool.cpp2
-rw-r--r--src/ui/tools/freehand-base.cpp4
-rw-r--r--src/ui/tools/freehand-base.h2
-rw-r--r--src/ui/tools/gradient-tool.cpp2
-rw-r--r--src/ui/tools/lpe-tool.cpp2
-rw-r--r--src/ui/tools/measure-tool.cpp2
-rw-r--r--src/ui/tools/mesh-tool.cpp2
-rw-r--r--src/ui/tools/node-tool.cpp6
-rw-r--r--src/ui/tools/pen-tool.cpp6
-rw-r--r--src/ui/tools/pen-tool.h2
-rw-r--r--src/ui/tools/pencil-tool.cpp2
-rw-r--r--src/ui/tools/rect-tool.cpp2
-rw-r--r--src/ui/tools/select-tool.cpp10
-rw-r--r--src/ui/tools/spiral-tool.cpp2
-rw-r--r--src/ui/tools/spray-tool.cpp2
-rw-r--r--src/ui/tools/star-tool.cpp2
-rw-r--r--src/ui/tools/text-tool.cpp6
-rw-r--r--src/ui/tools/tool-base.cpp56
-rw-r--r--src/ui/tools/tool-base.h5
-rw-r--r--src/ui/tools/tweak-tool.cpp16
-rw-r--r--src/ui/tools/zoom-tool.cpp2
-rw-r--r--src/ui/widget/addtoicon.cpp14
-rw-r--r--src/ui/widget/addtoicon.h2
-rw-r--r--src/ui/widget/anchor-selector.cpp6
-rw-r--r--src/ui/widget/clipmaskicon.cpp17
-rw-r--r--src/ui/widget/color-notebook.cpp1
-rw-r--r--src/ui/widget/dock-item.cpp16
-rw-r--r--src/ui/widget/dock-item.h14
-rw-r--r--src/ui/widget/dock.cpp5
-rw-r--r--src/ui/widget/dock.h2
-rw-r--r--src/ui/widget/highlight-picker.cpp1
-rw-r--r--src/ui/widget/imagetoggler.cpp14
-rw-r--r--src/ui/widget/insertordericon.cpp14
-rw-r--r--src/ui/widget/labelled.cpp8
-rw-r--r--src/ui/widget/labelled.h3
-rw-r--r--src/ui/widget/layer-selector.cpp21
-rw-r--r--src/ui/widget/layertypeicon.cpp15
-rw-r--r--src/ui/widget/object-composite-settings.cpp1
-rw-r--r--src/ui/widget/panel.cpp4
-rw-r--r--src/ui/widget/random.cpp5
-rw-r--r--src/widgets/CMakeLists.txt2
-rw-r--r--src/widgets/arc-toolbar.cpp2
-rw-r--r--src/widgets/box3d-toolbar.cpp6
-rw-r--r--src/widgets/button.cpp12
-rw-r--r--src/widgets/button.h6
-rw-r--r--src/widgets/calligraphy-toolbar.cpp8
-rw-r--r--src/widgets/connector-toolbar.cpp8
-rw-r--r--src/widgets/desktop-widget.cpp7
-rw-r--r--src/widgets/dropper-toolbar.cpp4
-rw-r--r--src/widgets/ege-adjustment-action.cpp15
-rw-r--r--src/widgets/eraser-toolbar.cpp4
-rw-r--r--src/widgets/gradient-selector.cpp3
-rw-r--r--src/widgets/gradient-toolbar.cpp4
-rw-r--r--src/widgets/icon.cpp1651
-rw-r--r--src/widgets/icon.h71
-rw-r--r--src/widgets/ink-action.cpp45
-rw-r--r--src/widgets/ink-action.h2
-rw-r--r--src/widgets/ink-radio-action.cpp18
-rw-r--r--src/widgets/ink-radio-action.h4
-rw-r--r--src/widgets/ink-toggle-action.cpp15
-rw-r--r--src/widgets/ink-toggle-action.h2
-rw-r--r--src/widgets/ink-tool-menu-action.cpp2
-rw-r--r--src/widgets/ink-tool-menu-action.h2
-rw-r--r--src/widgets/lpe-toolbar.cpp8
-rw-r--r--src/widgets/measure-toolbar.cpp2
-rw-r--r--src/widgets/mesh-toolbar.cpp2
-rw-r--r--src/widgets/node-toolbar.cpp2
-rw-r--r--src/widgets/paint-selector.cpp7
-rw-r--r--src/widgets/paintbucket-toolbar.cpp2
-rw-r--r--src/widgets/pencil-toolbar.cpp8
-rw-r--r--src/widgets/rect-toolbar.cpp2
-rw-r--r--src/widgets/select-toolbar.cpp9
-rw-r--r--src/widgets/spiral-toolbar.cpp2
-rw-r--r--src/widgets/spray-toolbar.cpp8
-rw-r--r--src/widgets/star-toolbar.cpp4
-rw-r--r--src/widgets/stroke-marker-selector.cpp9
-rw-r--r--src/widgets/stroke-style.cpp5
-rw-r--r--src/widgets/stroke-style.h1
-rw-r--r--src/widgets/text-toolbar.cpp2
-rw-r--r--src/widgets/toolbox.cpp48
-rw-r--r--src/widgets/toolbox.h2
-rw-r--r--src/widgets/tweak-toolbar.cpp12
221 files changed, 2808 insertions, 4082 deletions
diff --git a/src/color.h b/src/color.h
index 887daf66b..02a4fc90f 100644
--- a/src/color.h
+++ b/src/color.h
@@ -30,6 +30,7 @@ typedef unsigned int guint32; // uint is guaranteed to hold up to 2^32 − 1
#define SP_RGBA32_A_F(v) SP_COLOR_U_TO_F (SP_RGBA32_A_U (v))
#define SP_RGBA32_U_COMPOSE(r,g,b,a) ((((r) & 0xff) << 24) | (((g) & 0xff) << 16) | (((b) & 0xff) << 8) | ((a) & 0xff))
#define SP_RGBA32_F_COMPOSE(r,g,b,a) SP_RGBA32_U_COMPOSE (SP_COLOR_F_TO_U (r), SP_COLOR_F_TO_U (g), SP_COLOR_F_TO_U (b), SP_COLOR_F_TO_U (a))
+#define SP_RGBA32_C_COMPOSE(c,o) SP_RGBA32_U_COMPOSE(SP_RGBA32_R_U(c),SP_RGBA32_G_U(c),SP_RGBA32_B_U(c),SP_COLOR_F_TO_U(o))
struct SVGICCColor;
diff --git a/src/desktop-events.cpp b/src/desktop-events.cpp
index 5fef8cbfc..894087c8c 100644
--- a/src/desktop-events.cpp
+++ b/src/desktop-events.cpp
@@ -521,7 +521,7 @@ gint sp_dt_guide_event(SPCanvasItem *item, GdkEvent *event, gpointer data)
GdkCursor *guide_cursor = gdk_cursor_new_for_display(display, cursor_type);
if(guide->getLocked()){
- guide_cursor = sp_cursor_new_from_xpm(cursor_select_xpm , 1, 1);
+ guide_cursor = sp_cursor_from_xpm(cursor_select_xpm);
}
gdk_window_set_cursor(gtk_widget_get_window (GTK_WIDGET(desktop->getCanvas())), guide_cursor);
g_object_unref(guide_cursor);
diff --git a/src/extension/error-file.cpp b/src/extension/error-file.cpp
index 342511ec9..063e43f42 100644
--- a/src/extension/error-file.cpp
+++ b/src/extension/error-file.cpp
@@ -18,6 +18,7 @@
#include "inkscape.h"
#include "preferences.h"
#include "extension/extension.h"
+#include "io/resource.h"
#include "error-file.h"
@@ -51,7 +52,7 @@ ErrorFileNotice::ErrorFileNotice (void) :
// \FIXME change this
/* This is some filler text, needs to change before relase */
Glib::ustring dialog_text(_("<span weight=\"bold\" size=\"larger\">One or more extensions failed to load</span>\n\nThe failed extensions have been skipped. Inkscape will continue to run normally but those extensions will be unavailable. For details to troubleshoot this problem, please refer to the error log located at: "));
- gchar * ext_error_file = Inkscape::Application::profile_path(EXTENSION_ERROR_LOG_FILENAME);
+ gchar * ext_error_file = Inkscape::IO::Resource::log_path(EXTENSION_ERROR_LOG_FILENAME);
dialog_text += ext_error_file;
g_free(ext_error_file);
set_message(dialog_text, true);
diff --git a/src/extension/extension.cpp b/src/extension/extension.cpp
index 497f98431..9c0221521 100644
--- a/src/extension/extension.cpp
+++ b/src/extension/extension.cpp
@@ -33,6 +33,7 @@
#include "dependency.h"
#include "timer.h"
#include "param/parameter.h"
+#include "io/resource.h"
namespace Inkscape {
namespace Extension {
@@ -658,7 +659,7 @@ Extension::set_param_color (const gchar * name, guint32 color, SPDocument * doc,
void
Extension::error_file_open (void)
{
- gchar * ext_error_file = Inkscape::Application::profile_path(EXTENSION_ERROR_LOG_FILENAME);
+ gchar * ext_error_file = Inkscape::IO::Resource::log_path(EXTENSION_ERROR_LOG_FILENAME);
gchar * filename = g_filename_from_utf8( ext_error_file, -1, NULL, NULL, NULL );
error_file.open(filename);
if (!error_file.is_open()) {
diff --git a/src/extension/init.cpp b/src/extension/init.cpp
index af7af2cb1..a40196a74 100644
--- a/src/extension/init.cpp
+++ b/src/extension/init.cpp
@@ -60,11 +60,13 @@
#endif
#include "preferences.h"
#include "io/sys.h"
+#include "io/resource.h"
#ifdef WITH_DBUS
#include "dbus/dbus-init.h"
#endif
#ifdef WITH_IMAGE_MAGICK
+#include <Magick++.h>
#include "internal/bitmap/adaptiveThreshold.h"
#include "internal/bitmap/addNoise.h"
#include "internal/bitmap/blur.h"
@@ -106,6 +108,8 @@
#include "init.h"
+using namespace Inkscape::IO::Resource;
+
namespace Inkscape {
namespace Extension {
@@ -113,7 +117,7 @@ namespace Extension {
the extension directory and parsed */
#define SP_MODULE_EXTENSION "inx"
-static void build_module_from_dir(gchar const *dirname);
+static void build_module_from_domain(Domain domain);
static void check_extensions();
/**
@@ -150,7 +154,7 @@ update_pref(Glib::ustring const &pref_path,
* Invokes the init routines for internal modules.
*
* This should be a list of all the internal modules that need to initialized. This is just a
- * convinent place to put them. Also, this function calls build_module_from_dir to parse the
+ * convinent place to put them. Also, this function calls build_module_from_domain to parse the
* Inkscape extensions directory.
*/
void
@@ -201,6 +205,8 @@ init()
/* Raster Effects */
#ifdef WITH_IMAGE_MAGICK
+ Magick::InitializeMagick(NULL);
+
Internal::Bitmap::AdaptiveThreshold::init();
Internal::Bitmap::AddNoise::init();
Internal::Bitmap::Blur::init();
@@ -240,18 +246,8 @@ init()
Internal::Filter::Filter::filters_all();
- /* Load search path for extensions */
- if (Inkscape::Extension::Extension::search_path.size() == 0)
- {
- Inkscape::Extension::Extension::search_path.push_back(Inkscape::Application::profile_path("extensions"));
-
- Inkscape::Extension::Extension::search_path.push_back(g_strdup(INKSCAPE_EXTENSIONDIR));
-
- }
-
- for (unsigned int i=0; i<Inkscape::Extension::Extension::search_path.size(); i++) {
- build_module_from_dir(Inkscape::Extension::Extension::search_path[i]);
- }
+ build_module_from_domain(USER);
+ build_module_from_domain(SYSTEM);
/* this is at the very end because it has several catch-alls
* that are possibly over-ridden by other extensions (such as
@@ -282,8 +278,10 @@ init()
* with their filenames.
*/
static void
-build_module_from_dir(gchar const *dirname)
+build_module_from_domain(Domain domain)
{
+ char const *dirname = get_path(domain, EXTENSIONS);
+
if (!dirname) {
g_warning("%s", _("Null external module directory name. Modules will not be loaded."));
return;
@@ -293,7 +291,8 @@ build_module_from_dir(gchar const *dirname)
return;
}
- //# Hopefully doing this the Glib way is portable
+ // TODO: We may have to get to why this is needed, since it seems redundent.
+ Inkscape::Extension::Extension::search_path.push_back(dirname);
GError *err;
GDir *directory = g_dir_open(dirname, 0, &err);
diff --git a/src/extension/internal/filter/filter-file.cpp b/src/extension/internal/filter/filter-file.cpp
index b1993057d..dfe889ddf 100644
--- a/src/extension/internal/filter/filter-file.cpp
+++ b/src/extension/internal/filter/filter-file.cpp
@@ -8,6 +8,7 @@
#include "filter.h"
#include "io/sys.h"
+#include "io/resource.h"
#include "io/inkscapestream.h"
/* Directory includes */
@@ -22,27 +23,27 @@
#include <glibmm/i18n.h>
#include <glibmm/fileutils.h>
+using namespace Inkscape::IO::Resource;
+
namespace Inkscape {
namespace Extension {
namespace Internal {
namespace Filter {
+void filters_load_domain(Domain domain, gchar *menuname);
+
void Filter::filters_all_files(void)
{
- gchar *filtersProfilePath = Inkscape::Application::profile_path("filters");
-
- filters_load_dir(INKSCAPE_FILTERDIR, _("Bundled"));
- filters_load_dir(filtersProfilePath, _("Personal"));
-
- g_free(filtersProfilePath);
- filtersProfilePath = 0;
+ filters_load_domain(SYSTEM, _("Bundled"));
+ filters_load_domain(USER, _("Personal"));
}
#define INKSCAPE_FILTER_FILE ".svg"
-void
-Filter::filters_load_dir (gchar const * dirname, gchar * menuname)
+void filters_load_domain(Domain domain, gchar *menuname)
{
+ char const *dirname = get_path(domain, FILTERS);
+
if (!dirname) {
g_warning("%s", _("Null external module directory name. Filters will not be loaded."));
return;
@@ -72,7 +73,7 @@ Filter::filters_load_dir (gchar const * dirname, gchar * menuname)
}
gchar *pathname = g_build_filename(dirname, filename, NULL);
- filters_load_file(pathname, menuname);
+ Filter::filters_load_file(pathname, menuname);
g_free(pathname);
}
diff --git a/src/extension/internal/filter/filter.h b/src/extension/internal/filter/filter.h
index 9aaa84aec..d4728b69c 100644
--- a/src/extension/internal/filter/filter.h
+++ b/src/extension/internal/filter/filter.h
@@ -53,7 +53,6 @@ public:
/* File loader related */
static void filters_all_files(void);
- static void filters_load_dir(gchar const * filename, gchar * menuname);
static void filters_load_file(gchar * filename, gchar * menuname);
static void filters_load_node(Inkscape::XML::Node * node, gchar * menuname);
diff --git a/src/file.cpp b/src/file.cpp
index 43a9c6f5b..b9d896de0 100644
--- a/src/file.cpp
+++ b/src/file.cpp
@@ -50,6 +50,7 @@
#include "inkscape-version.h"
#include "ui/interface.h"
#include "io/sys.h"
+#include "io/resource.h"
#include "message-stack.h"
#include "path-prefix.h"
#include "print.h"
@@ -67,6 +68,7 @@
using Inkscape::DocumentUndo;
+using Inkscape::IO::Resource::TEMPLATES;
#ifdef WITH_GNOME_VFS
# include <libgnomevfs/gnome-vfs.h>
@@ -159,48 +161,7 @@ SPDesktop *sp_file_new(const std::string &templ)
Glib::ustring sp_file_default_template_uri()
{
- std::list<gchar *> sources;
- sources.push_back( Inkscape::Application::profile_path("templates") ); // first try user's local dir
- sources.push_back( g_strdup(INKSCAPE_TEMPLATESDIR) ); // then the system templates dir
- std::list<gchar const*> baseNames;
- gchar const* localized = _("default.svg");
- if (strcmp("default.svg", localized) != 0) {
- baseNames.push_back(localized);
- }
- baseNames.push_back("default.svg");
- gchar *foundTemplate = 0;
-
- for (std::list<gchar *>::iterator it = sources.begin(); (it != sources.end()) && !foundTemplate; ++it) {
- for (std::list<gchar const*>::iterator nameIt = baseNames.begin(); (nameIt != baseNames.end()) && !foundTemplate; ++nameIt) {
- gchar *dirname = *it;
- if ( Inkscape::IO::file_test( dirname, (GFileTest)(G_FILE_TEST_EXISTS | G_FILE_TEST_IS_DIR) ) ) {
-
- // TRANSLATORS: default.svg is localizable - this is the name of the default document
- // template. This way you can localize the default pagesize, translate the name of
- // the default layer, etc. If you wish to localize this file, please create a
- // localized share/templates/default.xx.svg file, where xx is your language code.
- char *tmp = g_build_filename(dirname, *nameIt, NULL);
- if (Inkscape::IO::file_test(tmp, G_FILE_TEST_IS_REGULAR)) {
- foundTemplate = tmp;
- } else {
- g_free(tmp);
- }
- }
- }
- }
-
- for (std::list<gchar *>::iterator it = sources.begin(); it != sources.end(); ++it) {
- g_free(*it);
- }
-
- Glib::ustring templateUri = foundTemplate ? foundTemplate : "";
-
- if (foundTemplate) {
- g_free(foundTemplate);
- foundTemplate = 0;
- }
-
- return templateUri;
+ return Inkscape::IO::Resource::get_filename(TEMPLATES, "default.svg", _("default.svg"));
}
SPDesktop* sp_file_new_default()
diff --git a/src/helper/pixbuf-ops.cpp b/src/helper/pixbuf-ops.cpp
index bab998fdb..bb33f7b15 100644
--- a/src/helper/pixbuf-ops.cpp
+++ b/src/helper/pixbuf-ops.cpp
@@ -30,6 +30,8 @@
#include "helper/pixbuf-ops.h"
+#include <gdk/gdk.h>
+
// TODO look for copy-n-paste duplication of this function:
/**
* Hide all items that are not listed in list, recursively, skipping groups and defs.
diff --git a/src/helper/png-write.h b/src/helper/png-write.h
index 06498f46e..b886158c9 100644
--- a/src/helper/png-write.h
+++ b/src/helper/png-write.h
@@ -16,8 +16,8 @@
#include <2geom/forward.h>
-
class SPDocument;
+class SPItem;
enum ExportResult {
EXPORT_ERROR = 0,
diff --git a/src/helper/window.cpp b/src/helper/window.cpp
index 98e886a38..270f9a3c8 100644
--- a/src/helper/window.cpp
+++ b/src/helper/window.cpp
@@ -23,6 +23,12 @@ static bool on_window_key_press(GdkEventKey* event)
shortcut = Inkscape::UI::Tools::get_group0_keyval (event) |
( event->state & GDK_SHIFT_MASK ?
SP_SHORTCUT_SHIFT_MASK : 0 ) |
+ ( event->state & GDK_SUPER_MASK ?
+ SP_SHORTCUT_SUPER_MASK : 0 ) |
+ ( event->state & GDK_HYPER_MASK ?
+ SP_SHORTCUT_HYPER_MASK : 0 ) |
+ ( event->state & GDK_META_MASK ?
+ SP_SHORTCUT_META_MASK : 0 ) |
( event->state & GDK_CONTROL_MASK ?
SP_SHORTCUT_CONTROL_MASK : 0 ) |
( event->state & GDK_MOD1_MASK ?
diff --git a/src/icon-size.h b/src/icon-size.h
index d7a9c9b0b..8058e8da8 100644
--- a/src/icon-size.h
+++ b/src/icon-size.h
@@ -26,8 +26,6 @@ namespace Inkscape {
ICON_SIZE_DIALOG = ::GTK_ICON_SIZE_DIALOG,
ICON_SIZE_DECORATION
};
-
- GtkIconSize getRegisteredIconSize( IconSize size );
} // namespace Inkscape
#endif // SEEN_ICON_SIZE_H
diff --git a/src/inkscape.cpp b/src/inkscape.cpp
index bf694ada7..b0d2a7f6b 100644
--- a/src/inkscape.cpp
+++ b/src/inkscape.cpp
@@ -60,6 +60,7 @@
#include "helper/action-context.h"
#include "inkscape.h"
#include "io/sys.h"
+#include "io/resource.h"
#include "message-stack.h"
#include "path-prefix.h"
#include "resource-manager.h"
@@ -83,9 +84,6 @@ static void (* ill_handler) (int) = SIG_DFL;
static void (* bus_handler) (int) = SIG_DFL;
#endif
-#define INKSCAPE_PROFILE_DIR "inkscape"
-#define INKSCAPE_PROFILE_DIR_047DEV "Inkscape"
-#define INKSCAPE_LEGACY_PROFILE_DIR ".inkscape"
#define MENUS_FILE "menus.xml"
#define SP_INDENT 8
@@ -390,31 +388,17 @@ void Application::argv0(char const* argv)
void
Application::add_icon_theme()
{
+ using namespace Inkscape::IO::Resource;
// 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);
+ // We used to add get_system_data_dirs and get_user_data_dir, but these
+ // folders didn't seem to make much sense for Linux. More testing needed.
+ icon_theme->append_search_path(get_path_ustring(SYSTEM, ICONS));
+ icon_theme->append_search_path(get_path_ustring(USER, ICONS));
#ifdef INKSCAPE_THEMEDIR
- icon_theme->append_search_path(INKSCAPE_THEMEDIR);
- icon_theme->rescan_if_needed();
+ icon_theme->append_search_path(get_path_ustring(SYSTEM, THEMES));
+ icon_theme->append_search_path(get_path_ustring(USER, THEMES));
#endif
- g_free(usericondir);
}
/**
@@ -423,63 +407,33 @@ Application::add_icon_theme()
void
Application::add_style_sheet()
{
+ using namespace Inkscape::IO::Resource;
// 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)) {
+ // Calling get_filename always returns a real filename OR
+ // if no file exists, then it will have warned already and returns empty.
+ Glib::ustring style = get_filename(UIS, "style.css");
+ if (!style.empty()) {
auto provider = Gtk::CssProvider::create();
// From 3.16, throws an error which we must catch.
try {
- provider->load_from_path (inkscape_style);
+ provider->load_from_path (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;
+ g_error("CSSProviderError::load_from_path(): %s\n(%s)",
+ style.c_str(), ex.what().c_str());
}
#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.
@@ -813,7 +767,7 @@ Application::crash_handler (int /*signum*/)
*/
bool Application::load_menus()
{
- gchar *fn = profile_path(MENUS_FILE);
+ gchar *fn = Inkscape::IO::Resource::profile_path(MENUS_FILE);
gchar *menus_xml = 0;
gsize len = 0;
@@ -1302,137 +1256,8 @@ Application::exit ()
gtk_main_quit ();
}
-char *
-Application::homedir_path(const char *filename)
-{
- static const gchar *homedir = NULL;
- if (!homedir) {
- homedir = g_get_home_dir();
- }
- if (!homedir) {
- if (Application::exists()) {
- homedir = g_path_get_dirname(Application::instance()._argv0);
- }
- }
- return g_build_filename(homedir, filename, NULL);
-}
-
-
-/**
- * Get, or guess, or decide the location where the preferences.xml
- * file should be located.
- */
-gchar *
-Application::profile_path(const char *filename)
-{
- static const gchar *prefdir = NULL;
-
-
- if (!prefdir) {
- // First check for a custom environment variable for a "portable app"
- gchar const *val = g_getenv("INKSCAPE_PORTABLE_PROFILE_DIR");
- if (val) {
- prefdir = g_strdup(val);
- }
- // Then check for a custom user environment variable
- gchar const *userenv = g_getenv("INKSCAPE_PROFILE_DIR");
- if (userenv) {
- prefdir = g_strdup(userenv);
- }
-
-#ifdef HAS_SHGetSpecialFolderLocation
- // prefer c:\Documents and Settings\UserName\Application Data\ to
- // c:\Documents and Settings\userName\;
- if (!prefdir) {
- ITEMIDLIST *pidl = 0;
- if ( SHGetSpecialFolderLocation( NULL, CSIDL_APPDATA, &pidl ) == NOERROR ) {
- gchar * utf8Path = NULL;
-
- {
- wchar_t pathBuf[MAX_PATH+1];
- g_assert(sizeof(wchar_t) == sizeof(gunichar2));
-
- if ( SHGetPathFromIDListW( pidl, pathBuf ) ) {
- utf8Path = g_utf16_to_utf8( (gunichar2*)(&pathBuf[0]), -1, NULL, NULL, NULL );
- }
- }
-
- if ( utf8Path ) {
- if (!g_utf8_validate(utf8Path, -1, NULL)) {
- g_warning( "SHGetPathFromIDListW() resulted in invalid UTF-8");
- g_free( utf8Path );
- utf8Path = 0;
- } else {
- prefdir = utf8Path;
- }
- }
-
-
- /* not compiling yet...
-
- // Remember to free the list pointer
- IMalloc * imalloc = 0;
- if ( SHGetMalloc(&imalloc) == NOERROR) {
- imalloc->lpVtbl->Free( imalloc, pidl );
- imalloc->lpVtbl->Release( imalloc );
- }
- */
- }
- if (prefdir) {
- const char *prefdir_profile = g_build_filename(prefdir, INKSCAPE_PROFILE_DIR, NULL);
- g_free((void *)prefdir);
- prefdir = prefdir_profile;
- }
- }
-#endif
- if (!prefdir) {
- prefdir = g_build_filename(g_get_user_config_dir(), INKSCAPE_PROFILE_DIR, NULL);
- gchar * legacyDir = homedir_path(INKSCAPE_LEGACY_PROFILE_DIR);
- gchar * dev47Dir = g_build_filename(g_get_user_config_dir(), INKSCAPE_PROFILE_DIR_047DEV, NULL);
-
- bool needsMigration = ( !Inkscape::IO::file_test( prefdir, G_FILE_TEST_EXISTS ) && Inkscape::IO::file_test( legacyDir, G_FILE_TEST_EXISTS ) );
- if (needsMigration) {
- // TODO here is a point to hook in preference migration
- g_warning("Preferences need to be migrated from 0.46 or older %s to %s", legacyDir, prefdir);
- Inkscape::Preferences::migrate( legacyDir, prefdir );
- }
-
- bool needsRenameWarning = ( !Inkscape::IO::file_test( prefdir, G_FILE_TEST_EXISTS ) && Inkscape::IO::file_test( dev47Dir, G_FILE_TEST_EXISTS ) );
- if (needsRenameWarning) {
- g_warning("Preferences need to be copied from %s to %s", legacyDir, prefdir);
- }
- g_free(legacyDir);
- legacyDir = 0;
- g_free(dev47Dir);
- dev47Dir = 0;
- // In case the XDG user config dir of the moment does not yet exist...
- int mode = S_IRWXU;
-#ifdef S_IRGRP
- mode |= S_IRGRP;
-#endif
-#ifdef S_IXGRP
- mode |= S_IXGRP;
-#endif
-#ifdef S_IXOTH
- mode |= S_IXOTH;
-#endif
- if ( g_mkdir_with_parents(prefdir, mode) == -1 ) {
- int problem = errno;
- g_warning("Unable to create profile directory (%s) (%d)", g_strerror(problem), problem);
- } else {
- gchar const *userDirs[] = {"keys", "templates", "icons", "extensions", "palettes", NULL};
- for (gchar const** name = userDirs; *name; ++name) {
- gchar *dir = g_build_filename(prefdir, *name, NULL);
- g_mkdir_with_parents(dir, mode);
- g_free(dir);
- }
- }
- }
- }
- return g_build_filename(prefdir, filename, NULL);
-}
Inkscape::XML::Node *
Application::get_menus()
diff --git a/src/inkscape.h b/src/inkscape.h
index 3f4416f2f..e66201b25 100644
--- a/src/inkscape.h
+++ b/src/inkscape.h
@@ -147,9 +147,6 @@ public:
void add_document (SPDocument *document);
bool remove_document (SPDocument *document);
- static char *homedir_path(const char *filename);
- static char *profile_path(const char *filename);
-
// fixme: This has to be rethought
void refresh_display ();
diff --git a/src/io/resource.cpp b/src/io/resource.cpp
index 52ac884b1..73dc7117e 100644
--- a/src/io/resource.cpp
+++ b/src/io/resource.cpp
@@ -1,7 +1,11 @@
/*
* Inkscape::IO::Resource - simple resource API
*
- * Copyright 2006 MenTaLguY <mental@rydia.net>
+ * Authors:
+ * MenTaLguY <mental@rydia.net>
+ * Martin Owens <doctormo@gmail.com>
+ *
+ * Copyright (C) 2006-2017 Authors
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@@ -16,9 +20,7 @@
#include "config.h"
#endif
-#include <glib.h> // g_assert()
#include "path-prefix.h"
-#include "inkscape.h"
#include "io/sys.h"
#include "io/resource.h"
@@ -30,6 +32,8 @@ namespace IO {
namespace Resource {
+#define INKSCAPE_PROFILE_DIR "inkscape"
+
gchar *_get_path(Domain domain, Type type, char const *filename)
{
gchar *path=NULL;
@@ -39,16 +43,20 @@ gchar *_get_path(Domain domain, Type type, char const *filename)
switch (type) {
case APPICONS: temp = INKSCAPE_APPICONDIR; break;
case EXTENSIONS: temp = INKSCAPE_EXTENSIONDIR; break;
+ case FILTERS: temp = INKSCAPE_FILTERDIR; break;
case GRADIENTS: temp = INKSCAPE_GRADIENTSDIR; break;
case ICONS: temp = INKSCAPE_PIXMAPDIR; break;
case KEYS: temp = INKSCAPE_KEYSDIR; break;
case MARKERS: temp = INKSCAPE_MARKERSDIR; break;
+ case NONE: g_assert_not_reached(); break;
case PALETTES: temp = INKSCAPE_PALETTESDIR; break;
case PATTERNS: temp = INKSCAPE_PATTERNSDIR; break;
case SCREENS: temp = INKSCAPE_SCREENSDIR; break;
+ case SYMBOLS: temp = INKSCAPE_SYMBOLSDIR; break;
case TEMPLATES: temp = INKSCAPE_TEMPLATESDIR; break;
+ case THEMES: temp = INKSCAPE_THEMEDIR; break;
case TUTORIALS: temp = INKSCAPE_TUTORIALSDIR; break;
- case UI: temp = INKSCAPE_UIDIR; break;
+ case UIS: temp = INKSCAPE_UIDIR; break;
default: g_assert_not_reached();
}
path = g_strdup(temp);
@@ -63,21 +71,28 @@ gchar *_get_path(Domain domain, Type type, char const *filename)
}
path = g_strdup(temp);
} break;
+ case CACHE: {
+ path = g_build_filename(g_get_user_cache_dir(), "inkscape", NULL);
+ } break;
case USER: {
char const *name=NULL;
switch (type) {
case EXTENSIONS: name = "extensions"; break;
+ case FILTERS: name = "filters"; break;
case GRADIENTS: name = "gradients"; break;
case ICONS: name = "icons"; break;
case KEYS: name = "keys"; break;
case MARKERS: name = "markers"; break;
+ case NONE: name = ""; break;
case PALETTES: name = "palettes"; break;
case PATTERNS: name = "patterns"; break;
+ case SYMBOLS: name = "symbols"; break;
case TEMPLATES: name = "templates"; break;
- case UI: name = "ui"; break;
+ case THEMES: name = "icons"; break;
+ case UIS: name = "ui"; break;
default: return _get_path(SYSTEM, type, filename);
}
- path = Inkscape::Application::profile_path(name);
+ path = profile_path(name);
} break;
}
@@ -97,29 +112,185 @@ Util::ptr_shared<char> get_path(Domain domain, Type type, char const *filename)
g_free(path);
return result;
}
+Glib::ustring get_path_ustring(Domain domain, Type type, char const *filename)
+{
+ Glib::ustring result;
+ char *path = _get_path(domain, type, filename);
+ if(path) {
+ result = Glib::ustring(path);
+ g_free(path);
+ }
+ return result;
+}
/*
* Same as get_path, but checks for file's existance and falls back
* from USER to SYSTEM modes.
+ *
+ * type - The type of file to get, such as extension, template, ui etc
+ * filename - The filename to get, i.e. preferences.xml
+ * locale - The local language version of the file (if needed)
*/
-Util::ptr_shared<char> get_filename(Type type, char const *filename)
+Glib::ustring get_filename(Type type, char const *filename, char const *locale)
{
- Util::ptr_shared<char> result;
+ Glib::ustring result;
+
+ if(locale != NULL) {
+ char *user_locale = _get_path(USER, type, filename);
+ char *sys_locale = _get_path(SYSTEM, type, filename);
+
+ if (file_test(user_locale, G_FILE_TEST_EXISTS)) {
+ result = Glib::ustring(user_locale);
+ } else if(file_test(sys_locale, G_FILE_TEST_EXISTS)) {
+ result = Glib::ustring(sys_locale);
+ }
+ g_free(user_locale);
+ g_free(sys_locale);
+
+ if(!result.empty()) {
+ g_info("Using translated resource file: %s", result.c_str());
+ return result;
+ }
+ }
+
char *user_filename = _get_path(USER, type, filename);
char *sys_filename = _get_path(SYSTEM, type, filename);
if (file_test(user_filename, G_FILE_TEST_EXISTS)) {
- result = Util::share_string(user_filename);
+ result = Glib::ustring(user_filename);
} else if(file_test(sys_filename, G_FILE_TEST_EXISTS)) {
- result = Util::share_string(sys_filename);
+ result = Glib::ustring(sys_filename);
} else {
- g_warning("Failed to load resource: %s", filename);
+ g_warning("Failed to load resource: %s from %s or %s", filename, user_filename, sys_filename);
+ }
+
+ if(!result.empty()) {
+ g_info("Using resource file: %s", result.c_str());
}
+
g_free(user_filename);
g_free(sys_filename);
return result;
}
+/**
+ * Get, or guess, or decide the location where the preferences.xml
+ * file should be located. This also indicates where all other inkscape
+ * shared files may optionally exist.
+ */
+char *profile_path(const char *filename)
+{
+ static const gchar *prefdir = NULL;
+
+
+ if (!prefdir) {
+ // First check for a custom environment variable for a "portable app"
+ gchar const *val = g_getenv("INKSCAPE_PORTABLE_PROFILE_DIR");
+ if (val) {
+ prefdir = g_strdup(val);
+ }
+ // Then check for a custom user environment variable
+ gchar const *userenv = g_getenv("INKSCAPE_PROFILE_DIR");
+ if (userenv) {
+ prefdir = g_strdup(userenv);
+ }
+
+#ifdef HAS_SHGetSpecialFolderLocation
+ // prefer c:\Documents and Settings\UserName\Application Data\ to
+ // c:\Documents and Settings\userName\;
+ if (!prefdir) {
+ ITEMIDLIST *pidl = 0;
+ if ( SHGetSpecialFolderLocation( NULL, CSIDL_APPDATA, &pidl ) == NOERROR ) {
+ gchar * utf8Path = NULL;
+
+ {
+ wchar_t pathBuf[MAX_PATH+1];
+ g_assert(sizeof(wchar_t) == sizeof(gunichar2));
+
+ if ( SHGetPathFromIDListW( pidl, pathBuf ) ) {
+ utf8Path = g_utf16_to_utf8( (gunichar2*)(&pathBuf[0]), -1, NULL, NULL, NULL );
+ }
+ }
+
+ if ( utf8Path ) {
+ if (!g_utf8_validate(utf8Path, -1, NULL)) {
+ g_warning( "SHGetPathFromIDListW() resulted in invalid UTF-8");
+ g_free( utf8Path );
+ utf8Path = 0;
+ } else {
+ prefdir = utf8Path;
+ }
+ }
+
+
+ /* not compiling yet...
+
+ // Remember to free the list pointer
+ IMalloc * imalloc = 0;
+ if ( SHGetMalloc(&imalloc) == NOERROR) {
+ imalloc->lpVtbl->Free( imalloc, pidl );
+ imalloc->lpVtbl->Release( imalloc );
+ }
+ */
+ }
+
+ if (prefdir) {
+ const char *prefdir_profile = g_build_filename(prefdir, INKSCAPE_PROFILE_DIR, NULL);
+ g_free((void *)prefdir);
+ prefdir = prefdir_profile;
+ }
+ }
+#endif
+ if (!prefdir) {
+ prefdir = g_build_filename(g_get_user_config_dir(), INKSCAPE_PROFILE_DIR, NULL);
+ // In case the XDG user config dir of the moment does not yet exist...
+ int mode = S_IRWXU;
+#ifdef S_IRGRP
+ mode |= S_IRGRP;
+#endif
+#ifdef S_IXGRP
+ mode |= S_IXGRP;
+#endif
+#ifdef S_IXOTH
+ mode |= S_IXOTH;
+#endif
+ if ( g_mkdir_with_parents(prefdir, mode) == -1 ) {
+ int problem = errno;
+ g_warning("Unable to create profile directory (%s) (%d)", g_strerror(problem), problem);
+ } else {
+ gchar const *userDirs[] = {"keys", "templates", "icons", "extensions", "palettes", NULL};
+ for (gchar const** name = userDirs; *name; ++name) {
+ gchar *dir = g_build_filename(prefdir, *name, NULL);
+ g_mkdir_with_parents(dir, mode);
+ g_free(dir);
+ }
+ }
+ }
+ }
+ return g_build_filename(prefdir, filename, NULL);
+}
+
+/*
+ * We return the profile_path because that is where most documentation
+ * days log files will be generated in inkscape 0.92
+ */
+char *log_path(const char *filename)
+{
+ return profile_path(filename);
+}
+
+char *homedir_path(const char *filename)
+{
+ static const gchar *homedir = NULL;
+ homedir = g_get_home_dir();
+
+ // I suspect this is for handling inkscape app packages
+ /*if (!homedir && Application::exists()) {
+ homedir = g_path_get_dirname(Application::instance()._argv0);
+ }*/
+ return g_build_filename(homedir, filename, NULL);
+}
+
}
}
diff --git a/src/io/resource.h b/src/io/resource.h
index fbf2111f4..0ea5ab4f0 100644
--- a/src/io/resource.h
+++ b/src/io/resource.h
@@ -1,5 +1,9 @@
/*
- * Copyright 2006 MenTaLguY <mental@rydia.net>
+ * Authors:
+ * MenTaLguY <mental@rydia.net>
+ * Martin Owens <doctormo@gmail.com>
+ *
+ * Copyright (C) 2006-2017 Authors
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@@ -13,6 +17,7 @@
#ifndef SEEN_INKSCAPE_IO_RESOURCE_H
#define SEEN_INKSCAPE_IO_RESOURCE_H
+#include <glibmm/ustring.h>
#include "util/share.h"
namespace Inkscape {
@@ -31,24 +36,37 @@ enum Type {
ICONS,
KEYS,
MARKERS,
+ NONE,
PALETTES,
PATTERNS,
SCREENS,
TEMPLATES,
TUTORIALS,
- UI
+ SYMBOLS,
+ FILTERS,
+ THEMES,
+ UIS
};
enum Domain {
SYSTEM,
CREATE,
+ CACHE,
USER
};
Util::ptr_shared<char> get_path(Domain domain, Type type,
char const *filename=NULL);
-Util::ptr_shared<char> get_filename(Type type, char const *filename=NULL);
+Glib::ustring get_path_ustring(Domain domain, Type type,
+ char const *filename=NULL);
+
+Glib::ustring get_filename(Type type, char const *filename,
+ char const *locale=NULL);
+
+char *profile_path(const char *filename);
+char *homedir_path(const char *filename);
+char *log_path(const char *filename);
}
diff --git a/src/live_effects/parameter/bool.cpp b/src/live_effects/parameter/bool.cpp
index 954947cf4..f291a8104 100644
--- a/src/live_effects/parameter/bool.cpp
+++ b/src/live_effects/parameter/bool.cpp
@@ -9,7 +9,6 @@
#include "live_effects/effect.h"
#include "svg/svg.h"
#include "svg/stringstream.h"
-#include "widgets/icon.h"
#include "inkscape.h"
#include "verbs.h"
#include "helper-fns.h"
diff --git a/src/live_effects/parameter/item.cpp b/src/live_effects/parameter/item.cpp
index 7b40f4540..71134b118 100644
--- a/src/live_effects/parameter/item.cpp
+++ b/src/live_effects/parameter/item.cpp
@@ -18,7 +18,6 @@
#include "live_effects/effect.h"
#include "svg/svg.h"
-#include "widgets/icon.h"
#include "selection-chemistry.h"
#include "xml/repr.h"
#include "desktop.h"
@@ -109,7 +108,8 @@ Gtk::Widget *
ItemParam::param_newWidget()
{
Gtk::HBox * _widget = Gtk::manage(new Gtk::HBox());
- Gtk::Widget* pIcon = Gtk::manage( sp_icon_get_icon( INKSCAPE_ICON("edit-clone"), Inkscape::ICON_SIZE_BUTTON) );
+ Gtk::Image* pIcon = Gtk::manage(new Gtk::Image());
+ pIcon->set_from_icon_name("edit-clone", Gtk::ICON_SIZE_BUTTON);
Gtk::Button * pButton = Gtk::manage(new Gtk::Button());
Gtk::Label* pLabel = Gtk::manage(new Gtk::Label(param_label));
static_cast<Gtk::HBox*>(_widget)->pack_start(*pLabel, true, true);
diff --git a/src/live_effects/parameter/originalitem.cpp b/src/live_effects/parameter/originalitem.cpp
index 053062128..81ab41c56 100644
--- a/src/live_effects/parameter/originalitem.cpp
+++ b/src/live_effects/parameter/originalitem.cpp
@@ -11,7 +11,6 @@
#include <gtkmm/box.h>
#include "live_effects/parameter/originalitem.h"
-#include "widgets/icon.h"
#include <glibmm/i18n.h>
#include <gtkmm/button.h>
#include <gtkmm/label.h>
@@ -55,7 +54,8 @@ OriginalItemParam::param_newWidget()
}
{ // Paste item to link button
- Gtk::Widget *pIcon = Gtk::manage( sp_icon_get_icon( INKSCAPE_ICON("edit-paste"), Inkscape::ICON_SIZE_BUTTON) );
+ Gtk::Image *pIcon = Gtk::manage(new Gtk::Image());
+ pIcon->set_from_icon_name("edit-paste", Gtk::ICON_SIZE_BUTTON);
Gtk::Button *pButton = Gtk::manage(new Gtk::Button());
pButton->set_relief(Gtk::RELIEF_NONE);
pIcon->show();
@@ -67,7 +67,8 @@ OriginalItemParam::param_newWidget()
}
{ // Select original button
- Gtk::Widget *pIcon = Gtk::manage( sp_icon_get_icon("edit-select-original", Inkscape::ICON_SIZE_BUTTON) );
+ Gtk::Image *pIcon = Gtk::manage(new Gtk::Image());
+ pIcon->set_from_icon_name("edit-select-original", Gtk::ICON_SIZE_BUTTON);
Gtk::Button *pButton = Gtk::manage(new Gtk::Button());
pButton->set_relief(Gtk::RELIEF_NONE);
pIcon->show();
diff --git a/src/live_effects/parameter/originalpath.cpp b/src/live_effects/parameter/originalpath.cpp
index 1e78f7fe1..62483d7fb 100644
--- a/src/live_effects/parameter/originalpath.cpp
+++ b/src/live_effects/parameter/originalpath.cpp
@@ -11,7 +11,6 @@
#include <gtkmm/box.h>
#include "live_effects/parameter/originalpath.h"
-#include "widgets/icon.h"
#include <glibmm/i18n.h>
#include <gtkmm/button.h>
#include <gtkmm/label.h>
@@ -56,7 +55,8 @@ OriginalPathParam::param_newWidget()
}
{ // Paste path to link button
- Gtk::Widget *pIcon = Gtk::manage( sp_icon_get_icon( INKSCAPE_ICON("edit-clone"), Inkscape::ICON_SIZE_BUTTON) );
+ Gtk::Image *pIcon = Gtk::manage(new Gtk::Image());
+ pIcon->set_from_icon_name("edit-clone", Gtk::ICON_SIZE_BUTTON);
Gtk::Button *pButton = Gtk::manage(new Gtk::Button());
pButton->set_relief(Gtk::RELIEF_NONE);
pIcon->show();
@@ -68,7 +68,8 @@ OriginalPathParam::param_newWidget()
}
{ // Select original button
- Gtk::Widget *pIcon = Gtk::manage( sp_icon_get_icon("edit-select-original", Inkscape::ICON_SIZE_BUTTON) );
+ Gtk::Image *pIcon = Gtk::manage(new Gtk::Image());
+ pIcon->set_from_icon_name("edit-select-original", Gtk::ICON_SIZE_BUTTON);
Gtk::Button *pButton = Gtk::manage(new Gtk::Button());
pButton->set_relief(Gtk::RELIEF_NONE);
pIcon->show();
diff --git a/src/live_effects/parameter/originalpatharray.cpp b/src/live_effects/parameter/originalpatharray.cpp
index 693821ed2..92859de05 100644
--- a/src/live_effects/parameter/originalpatharray.cpp
+++ b/src/live_effects/parameter/originalpatharray.cpp
@@ -20,7 +20,6 @@
#include "inkscape.h"
#include "icon-size.h"
-#include "widgets/icon.h"
#include "ui/clipboard.h"
#include "svg/svg.h"
#include "svg/stringstream.h"
@@ -144,7 +143,8 @@ Gtk::Widget* OriginalPathArrayParam::param_newWidget()
{ // Paste path to link button
- Gtk::Widget *pIcon = Gtk::manage( sp_icon_get_icon("edit-clone", Inkscape::ICON_SIZE_BUTTON) );
+ Gtk::Image *pIcon = Gtk::manage(new Gtk::Image());
+ pIcon->set_from_icon_name("edit-clone", Gtk::ICON_SIZE_BUTTON);
Gtk::Button *pButton = Gtk::manage(new Gtk::Button());
pButton->set_relief(Gtk::RELIEF_NONE);
pIcon->show();
@@ -156,7 +156,8 @@ Gtk::Widget* OriginalPathArrayParam::param_newWidget()
}
{ // Remove linked path
- Gtk::Widget *pIcon = Gtk::manage( sp_icon_get_icon("gtk-remove", Inkscape::ICON_SIZE_BUTTON) );
+ Gtk::Image *pIcon = Gtk::manage(new Gtk::Image());
+ pIcon->set_from_icon_name("gtk-remove", Gtk::ICON_SIZE_BUTTON);
Gtk::Button *pButton = Gtk::manage(new Gtk::Button());
pButton->set_relief(Gtk::RELIEF_NONE);
pIcon->show();
@@ -168,7 +169,8 @@ Gtk::Widget* OriginalPathArrayParam::param_newWidget()
}
{ // Move Down
- Gtk::Widget *pIcon = Gtk::manage( sp_icon_get_icon( "gtk-go-down", Inkscape::ICON_SIZE_BUTTON) );
+ Gtk::Image *pIcon = Gtk::manage(new Gtk::Image());
+ pIcon->set_from_icon_name( "gtk-go-down", Gtk::ICON_SIZE_BUTTON);
Gtk::Button *pButton = Gtk::manage(new Gtk::Button());
pButton->set_relief(Gtk::RELIEF_NONE);
pIcon->show();
@@ -180,7 +182,8 @@ Gtk::Widget* OriginalPathArrayParam::param_newWidget()
}
{ // Move Down
- Gtk::Widget *pIcon = Gtk::manage( sp_icon_get_icon( "gtk-go-up", Inkscape::ICON_SIZE_BUTTON) );
+ Gtk::Image *pIcon = Gtk::manage(new Gtk::Image());
+ pIcon->set_from_icon_name( "gtk-go-up", Gtk::ICON_SIZE_BUTTON);
Gtk::Button *pButton = Gtk::manage(new Gtk::Button());
pButton->set_relief(Gtk::RELIEF_NONE);
pIcon->show();
diff --git a/src/live_effects/parameter/path.cpp b/src/live_effects/parameter/path.cpp
index 54f5d93e8..ec011b855 100644
--- a/src/live_effects/parameter/path.cpp
+++ b/src/live_effects/parameter/path.cpp
@@ -22,7 +22,6 @@
#include <2geom/pathvector.h>
#include <2geom/d2.h>
-#include "widgets/icon.h"
#include "selection-chemistry.h"
#include "xml/repr.h"
#include "desktop.h"
@@ -187,10 +186,11 @@ PathParam::param_newWidget()
Gtk::Label* pLabel = Gtk::manage(new Gtk::Label(param_label));
static_cast<Gtk::HBox*>(_widget)->pack_start(*pLabel, true, true);
pLabel->set_tooltip_text(param_tooltip);
- Gtk::Widget * pIcon = NULL;
+ Gtk::Image * pIcon = NULL;
Gtk::Button * pButton = NULL;
if (_edit_button) {
- pIcon = Gtk::manage( sp_icon_get_icon( INKSCAPE_ICON("tool-node-editor"), Inkscape::ICON_SIZE_BUTTON) );
+ pIcon = Gtk::manage(new Gtk::Image());
+ pIcon->set_from_icon_name( INKSCAPE_ICON("tool-node-editor"), Gtk::ICON_SIZE_BUTTON);
pButton = Gtk::manage(new Gtk::Button());
pButton->set_relief(Gtk::RELIEF_NONE);
pIcon->show();
@@ -202,7 +202,8 @@ PathParam::param_newWidget()
}
if (_copy_button) {
- pIcon = Gtk::manage( sp_icon_get_icon( INKSCAPE_ICON("edit-copy"), Inkscape::ICON_SIZE_BUTTON) );
+ pIcon = Gtk::manage(new Gtk::Image());
+ pIcon->set_from_icon_name( INKSCAPE_ICON("edit-copy"), Gtk::ICON_SIZE_BUTTON);
pButton = Gtk::manage(new Gtk::Button());
pButton->set_relief(Gtk::RELIEF_NONE);
pIcon->show();
@@ -214,7 +215,8 @@ PathParam::param_newWidget()
}
if (_paste_button) {
- pIcon = Gtk::manage( sp_icon_get_icon( INKSCAPE_ICON("edit-paste"), Inkscape::ICON_SIZE_BUTTON) );
+ pIcon = Gtk::manage(new Gtk::Image());
+ pIcon->set_from_icon_name( INKSCAPE_ICON("edit-paste"), Gtk::ICON_SIZE_BUTTON);
pButton = Gtk::manage(new Gtk::Button());
pButton->set_relief(Gtk::RELIEF_NONE);
pIcon->show();
@@ -225,7 +227,8 @@ PathParam::param_newWidget()
pButton->set_tooltip_text(_("Paste path"));
}
if (_link_button) {
- pIcon = Gtk::manage( sp_icon_get_icon( INKSCAPE_ICON("edit-clone"), Inkscape::ICON_SIZE_BUTTON) );
+ pIcon = Gtk::manage(new Gtk::Image());
+ pIcon->set_from_icon_name( INKSCAPE_ICON("edit-clone"), Gtk::ICON_SIZE_BUTTON);
pButton = Gtk::manage(new Gtk::Button());
pButton->set_relief(Gtk::RELIEF_NONE);
pIcon->show();
diff --git a/src/live_effects/parameter/point.cpp b/src/live_effects/parameter/point.cpp
index 4ca88a6b8..331a86f81 100644
--- a/src/live_effects/parameter/point.cpp
+++ b/src/live_effects/parameter/point.cpp
@@ -9,7 +9,6 @@
#include "svg/svg.h"
#include "svg/stringstream.h"
#include "ui/widget/point.h"
-#include "widgets/icon.h"
#include "inkscape.h"
#include "verbs.h"
#include "knotholder.h"
diff --git a/src/live_effects/parameter/text.cpp b/src/live_effects/parameter/text.cpp
index d633666aa..f40708917 100644
--- a/src/live_effects/parameter/text.cpp
+++ b/src/live_effects/parameter/text.cpp
@@ -15,7 +15,6 @@
#include "live_effects/effect.h"
#include "svg/svg.h"
#include "svg/stringstream.h"
-#include "widgets/icon.h"
#include "inkscape.h"
#include "verbs.h"
#include "display/canvas-text.h"
diff --git a/src/live_effects/parameter/togglebutton.cpp b/src/live_effects/parameter/togglebutton.cpp
index eb40a7e41..6aad8b3a6 100644
--- a/src/live_effects/parameter/togglebutton.cpp
+++ b/src/live_effects/parameter/togglebutton.cpp
@@ -13,7 +13,6 @@
#include "svg/svg.h"
#include "svg/stringstream.h"
#include "selection.h"
-#include "widgets/icon.h"
#include "inkscape.h"
#include "verbs.h"
#include "helper-fns.h"
@@ -26,7 +25,7 @@ ToggleButtonParam::ToggleButtonParam( const Glib::ustring& label, const Glib::us
const Glib::ustring& key, Inkscape::UI::Widget::Registry* wr,
Effect* effect, bool default_value, const Glib::ustring& inactive_label,
char const * _icon_active, char const * _icon_inactive,
- Inkscape::IconSize _icon_size)
+ GtkIconSize _icon_size)
: Parameter(label, tip, key, wr, effect), value(default_value), defvalue(default_value),
inactive_label(inactive_label), _icon_active(_icon_active), _icon_inactive(_icon_inactive), _icon_size(_icon_size)
{
@@ -105,9 +104,9 @@ ToggleButtonParam::param_newWidget()
gtk_widget_show(box_button);
GtkWidget *icon_button = NULL;
if(!value){
- icon_button = sp_icon_new(_icon_size, _icon_inactive);
+ icon_button = gtk_image_new_from_icon_name(_icon_inactive, _icon_size);
} else {
- icon_button = sp_icon_new(_icon_size, _icon_active);
+ icon_button = gtk_image_new_from_icon_name(_icon_active, _icon_size);
}
gtk_widget_show(icon_button);
gtk_box_pack_start (GTK_BOX(box_button), icon_button, false, false, 1);
@@ -153,11 +152,10 @@ ToggleButtonParam::refresh_button()
if ( _icon_active ) {
GdkPixbuf * icon_pixbuf = NULL;
if(!value){
- icon_pixbuf = sp_pixbuf_new( _icon_size, _icon_inactive );
+ gtk_image_set_from_icon_name (GTK_IMAGE(g_list_nth_data(childs, 0)), _icon_inactive, _icon_size);
} else {
- icon_pixbuf = sp_pixbuf_new( _icon_size, _icon_active );
+ gtk_image_set_from_icon_name (GTK_IMAGE(g_list_nth_data(childs, 0)), _icon_active, _icon_size);
}
- gtk_image_set_from_pixbuf (GTK_IMAGE(g_list_nth_data(childs, 0)), icon_pixbuf);
}
}
diff --git a/src/live_effects/parameter/togglebutton.h b/src/live_effects/parameter/togglebutton.h
index d6ca15e75..02b9d5127 100644
--- a/src/live_effects/parameter/togglebutton.h
+++ b/src/live_effects/parameter/togglebutton.h
@@ -34,7 +34,7 @@ public:
const Glib::ustring& inactive_label = "",
char const * icon_active = NULL,
char const * icon_inactive = NULL,
- Inkscape::IconSize icon_size = Inkscape::ICON_SIZE_SMALL_TOOLBAR);
+ GtkIconSize icon_size = GTK_ICON_SIZE_SMALL_TOOLBAR);
virtual ~ToggleButtonParam();
virtual Gtk::Widget * param_newWidget();
@@ -64,7 +64,7 @@ private:
const Glib::ustring inactive_label;
const char * _icon_active;
const char * _icon_inactive;
- Inkscape::IconSize _icon_size;
+ GtkIconSize _icon_size;
Inkscape::UI::Widget::RegisteredToggleButton * checkwdg;
sigc::signal<void> _signal_toggled;
diff --git a/src/main.cpp b/src/main.cpp
index 7a786234e..6f7624cf7 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -113,7 +113,6 @@
#include "main-cmdlineact.h"
#include "main-cmdlinexact.h"
-#include "widgets/icon.h"
#include <errno.h>
#include "verbs.h"
@@ -1030,8 +1029,6 @@ sp_main_gui(int argc, char const **argv)
// Set default window icon. Obeys the theme.
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();
bool create_new = true;
diff --git a/src/menus-skeleton.h b/src/menus-skeleton.h
index 7d00ffa86..65c497da4 100644
--- a/src/menus-skeleton.h
+++ b/src/menus-skeleton.h
@@ -237,20 +237,20 @@ static char const menus_skeleton[] =
" <verb verb-id=\"SelectionPixelArt\" />\n"
" <separator/>\n"
-" <verb verb-id=\"SelectionUnion\" />\n"
-" <verb verb-id=\"SelectionDiff\" />\n"
-" <verb verb-id=\"SelectionIntersect\" />\n"
-" <verb verb-id=\"SelectionSymDiff\" />\n"
-" <verb verb-id=\"SelectionDivide\" />\n"
-" <verb verb-id=\"SelectionCutPath\" />\n"
-" <separator/>\n"
-" <verb verb-id=\"SelectionCombine\" />\n"
-" <verb verb-id=\"SelectionBreakApart\" />\n"
-" <separator/>\n"
-" <verb verb-id=\"SelectionInset\" />\n"
-" <verb verb-id=\"SelectionOffset\" />\n"
-" <verb verb-id=\"SelectionDynOffset\" />\n"
-" <verb verb-id=\"SelectionLinkedOffset\" />\n"
+" <verb verb-id=\"SelectionUnion\" show-icon=\"yes\" />\n"
+" <verb verb-id=\"SelectionDiff\" show-icon=\"yes\" />\n"
+" <verb verb-id=\"SelectionIntersect\" show-icon=\"yes\" />\n"
+" <verb verb-id=\"SelectionSymDiff\" show-icon=\"yes\"/>\n"
+" <verb verb-id=\"SelectionDivide\" show-icon=\"yes\"/>\n"
+" <verb verb-id=\"SelectionCutPath\" show-icon=\"yes\"/>\n"
+" <separator/>\n"
+" <verb verb-id=\"SelectionCombine\" show-icon=\"yes\"/>\n"
+" <verb verb-id=\"SelectionBreakApart\" show-icon=\"yes\"/>\n"
+" <separator/>\n"
+" <verb verb-id=\"SelectionInset\" show-icon=\"yes\"/>\n"
+" <verb verb-id=\"SelectionOffset\" show-icon=\"yes\"/>\n"
+" <verb verb-id=\"SelectionDynOffset\" show-icon=\"yes\"/>\n"
+" <verb verb-id=\"SelectionLinkedOffset\" show-icon=\"yes\"/>\n"
" <separator/>\n"
" <verb verb-id=\"SelectionSimplify\" />\n"
" <verb verb-id=\"SelectionReverse\" />\n"
diff --git a/src/path-prefix.h b/src/path-prefix.h
index e54a80f28..77fd90da5 100644
--- a/src/path-prefix.h
+++ b/src/path-prefix.h
@@ -64,6 +64,7 @@
# define INKSCAPE_PATTERNSDIR WIN32_DATADIR("patterns")
# define INKSCAPE_SCREENSDIR WIN32_DATADIR("screens")
# define INKSCAPE_SYMBOLSDIR WIN32_DATADIR("symbols")
+# define INKSCAPE_THEMEDIR INKSCAPE_PIXMAPDIR
# define INKSCAPE_TUTORIALSDIR WIN32_DATADIR("tutorials")
# define INKSCAPE_TEMPLATESDIR WIN32_DATADIR("templates")
# define INKSCAPE_UIDIR WIN32_DATADIR("ui")
@@ -86,6 +87,7 @@
# define INKSCAPE_PATTERNSDIR "Contents/Resources/share/inkscape/patterns"
# define INKSCAPE_SCREENSDIR "Contents/Resources/share/inkscape/screens"
# define INKSCAPE_SYMBOLSDIR "Contents/Resources/share/inkscape/symbols"
+# define INKSCAPE_THEMEDIR INKSCAPE_PIXMAPDIR
# define INKSCAPE_TUTORIALSDIR "Contents/Resources/share/inkscape/tutorials"
# define INKSCAPE_TEMPLATESDIR "Contents/Resources/share/inkscape/templates"
# define INKSCAPE_UIDIR "Contents/Resources/share/inkscape/ui"
diff --git a/src/pixmaps/cursor-3dbox.xpm b/src/pixmaps/cursor-3dbox.xpm
index 3fda78ef1..c7fcb9248 100644
--- a/src/pixmaps/cursor-3dbox.xpm
+++ b/src/pixmaps/cursor-3dbox.xpm
@@ -1,6 +1,6 @@
/* XPM */
static const char * cursor_3dbox_xpm[] = {
-"32 32 3 1",
+"32 32 3 1 4 4",
" c None",
". c #FFFFFF",
"+ c #000000",
diff --git a/src/pixmaps/cursor-arc.xpm b/src/pixmaps/cursor-arc.xpm
deleted file mode 100644
index cbf6a9e30..000000000
--- a/src/pixmaps/cursor-arc.xpm
+++ /dev/null
@@ -1,38 +0,0 @@
-/* XPM */
-static char const *cursor_arc_xpm[] = {
-"32 32 3 1",
-" c None",
-". c #FFFFFF",
-"+ c #000000",
-" ... ",
-" .+. ",
-" .+. ",
-"....+.... ",
-".+++ +++. ",
-"....+.... ",
-" .+. ",
-" .+. ..... ",
-" ... .+++.... ",
-" .+..+++.. ",
-" .+.....+.. ",
-" .+......+.. ",
-" ..+.......+. ",
-" ...++.......+. ",
-" ...++.........+. ",
-" ...++..........+.. ",
-" .++...........+.. ",
-" ...++......+++.. ",
-" ...++++++.... ",
-" ........ ",
-" ",
-" ",
-" ",
-" ",
-" ",
-" ",
-" ",
-" ",
-" ",
-" ",
-" ",
-" "};
diff --git a/src/pixmaps/cursor-arrow.xpm b/src/pixmaps/cursor-arrow.xpm
deleted file mode 100644
index 963656a92..000000000
--- a/src/pixmaps/cursor-arrow.xpm
+++ /dev/null
@@ -1,38 +0,0 @@
-/* XPM */
-static char const *cursor_arrow_xpm[] = {
-"32 32 3 1",
-" c None",
-". c #FFFFFF",
-"+ c #000000",
-" .. ",
-".++.. ",
-".+ ++.. ",
-" .+ ++.. ",
-" .+ ++.. ",
-" .+ ++. ",
-" .+ +. ",
-" .+ +. ",
-" .+ +. ",
-" .+ +. ",
-" .+ + +. ",
-" .++.+ +. ",
-" .. .+ +. ",
-" .+ +. ",
-" .+ +. ",
-" .+ +. ",
-" .+ +. ",
-" .+ +. ",
-" .+. ",
-" . ",
-" ",
-" ",
-" ",
-" ",
-" ",
-" ",
-" ",
-" ",
-" ",
-" ",
-" ",
-" "};
diff --git a/src/pixmaps/cursor-calligraphy.xpm b/src/pixmaps/cursor-calligraphy.xpm
index 52c4f76cb..193bd6196 100644
--- a/src/pixmaps/cursor-calligraphy.xpm
+++ b/src/pixmaps/cursor-calligraphy.xpm
@@ -1,6 +1,6 @@
/* XPM */
static char const *cursor_calligraphy_xpm[] = {
-"32 32 3 1",
+"32 32 3 1 4 4",
" c None",
". c #FFFFFF",
"+ c #000000",
diff --git a/src/pixmaps/cursor-connector.xpm b/src/pixmaps/cursor-connector.xpm
index ddff5cdf5..86e8d1753 100644
--- a/src/pixmaps/cursor-connector.xpm
+++ b/src/pixmaps/cursor-connector.xpm
@@ -1,6 +1,6 @@
/* XPM */
static const char * cursor_connector_xpm[] = {
-"32 32 3 1",
+"32 32 3 1 1 1",
" c None",
". c #FFFFFF",
"+ c #000000",
diff --git a/src/pixmaps/cursor-crosshairs.xpm b/src/pixmaps/cursor-crosshairs.xpm
index 8c7554523..407b76048 100644
--- a/src/pixmaps/cursor-crosshairs.xpm
+++ b/src/pixmaps/cursor-crosshairs.xpm
@@ -1,6 +1,6 @@
/* XPM */
static char const *cursor_crosshairs_xpm[] = {
-"32 32 3 1",
+"32 32 3 1 7 7",
" c None",
". c #FFFFFF",
"+ c #000000",
diff --git a/src/pixmaps/cursor-dropper-f.xpm b/src/pixmaps/cursor-dropper-f.xpm
index 3bf1e80e1..2804f6614 100644
--- a/src/pixmaps/cursor-dropper-f.xpm
+++ b/src/pixmaps/cursor-dropper-f.xpm
@@ -1,19 +1,20 @@
/* XPM */
static const char * cursor_dropper_f_xpm[] = {
-"32 32 3 1",
+"32 32 4 1 5 5",
" c None",
+"@ c Fill",
". c #FFFFFF",
"+ c #000000",
" ... ............",
" .+. .++++++++++.",
-" .+. .+........+.",
-" .+. .+........+.",
-".... .... .+........+.",
-".+++ +++. .+........+.",
-".... .... .+........+.",
-" .+. .+........+.",
-" .+. .... .+........+.",
-" .+. .+++. .+........+.",
+" .+. .+@@@@@@@@+.",
+" .+. .+@@@@@@@@+.",
+".... .... .+@@@@@@@@+.",
+".+++ +++. .+@@@@@@@@+.",
+".... .... .+@@@@@@@@+.",
+" .+. .+@@@@@@@@+.",
+" .+. .... .+@@@@@@@@+.",
+" .+. .+++. .+@@@@@@@@+.",
" ... .+..+. .++++++++++.",
" .++..+. ............",
" .++..+. ",
diff --git a/src/pixmaps/cursor-dropper-s.xpm b/src/pixmaps/cursor-dropper-s.xpm
index 1a12934d8..c7cb9cc7e 100644
--- a/src/pixmaps/cursor-dropper-s.xpm
+++ b/src/pixmaps/cursor-dropper-s.xpm
@@ -1,24 +1,25 @@
/* XPM */
static const char * cursor_dropper_s_xpm[] = {
-"32 32 3 1",
+"32 32 4 1 5 5",
" c None",
+"@ s Fill",
". c #FFFFFF",
"+ c #000000",
-" ... ............",
-" .+. .+++.++.+++.",
-" .+. .+........+.",
-" .+. .+. .+.",
-".... .... ... ...",
-".+++ +++. .+. .+.",
-".... .... .+. .+.",
-" .+. ... ...",
-" .+. .... .+. .+.",
-" .+. .+++. .+........+.",
-" ... .+..+. .+++.++.+++.",
-" .++..+. ............",
-" .++..+. ",
-" .++..+. ",
-" .++..+. . ",
+" ... ...............",
+" .+. .+++++++++++++.",
+" .+. .+@@@@@@@@@@@+.",
+" .+. .+@@@@@@@@@@@+.",
+".... .... .+@@+++++++@@+.",
+".+++ +++. .+@@+.....+@@+.",
+".... .... .+@@+. .+@@+.",
+" .+. .+@@+. .+@@+.",
+" .+. .... .+@@+. .+@@+.",
+" .+. .+++. .+@@+.....+@@+.",
+" ... .+..+. .+@@+++++++@@+.",
+" .++..+. .+@@@@@@@@@@@+.",
+" .++..+. .+@@@@@@@@@@@+.",
+" .++..+..+++++++++++++.",
+" .++..+...............",
" .++..+.+. ",
" .++..+++. ",
" .++++.+. ",
diff --git a/src/pixmaps/cursor-dropping-f.xpm b/src/pixmaps/cursor-dropping-f.xpm
new file mode 100644
index 000000000..8490ba795
--- /dev/null
+++ b/src/pixmaps/cursor-dropping-f.xpm
@@ -0,0 +1,39 @@
+/* XPM */
+static const char * cursor_dropping_f_xpm[] = {
+"32 32 4 1 5 5",
+" c None",
+". c #FFFFFF",
+"+ c #000000",
+"@ s Fill",
+" ... ............",
+" .+. .++++++++++.",
+" .+. .+@@@@@@@@+.",
+" .+. .+@@@@@@@@+.",
+".... .... .+@@@@@@@@+.",
+".+++ +++. .+@@@@@@@@+.",
+".... .... .+@@@@@@@@+.",
+" .+. ... .+@@@@@@@@+.",
+" .+. .+++. .+@@@@@@@@+.",
+" .+. .+..++. .+@@@@@@@@+.",
+" ... .+.++++. .++++++++++.",
+" ..+.+++++. ............",
+" .++.++++++. ",
+" .++.++++++. ",
+" .++++++.. ",
+" .+.++++. ",
+" .+..++++. ",
+" .+..++.+. ",
+" .+..++. . ",
+" .+++++. ",
+" .+++++. ",
+" .+++++. ",
+" .++++. ",
+" .+++. ",
+" .... ",
+" .+. ",
+" .+++. ",
+".++..+. ",
+".+++.+. ",
+".+++++. ",
+" .+++. ",
+" ... "};
diff --git a/src/pixmaps/cursor-dropping-s.xpm b/src/pixmaps/cursor-dropping-s.xpm
new file mode 100644
index 000000000..8efd4e04c
--- /dev/null
+++ b/src/pixmaps/cursor-dropping-s.xpm
@@ -0,0 +1,39 @@
+/* XPM */
+static const char * cursor_dropping_s_xpm[] = {
+"32 32 4 1 5 5",
+" c None",
+". c #FFFFFF",
+"+ c #000000",
+"@ s Fill",
+" ... ...............",
+" .+. .+++++++++++++.",
+" .+. .+@@@@@@@@@@@+.",
+" .+. .+@@@@@@@@@@@+.",
+".... .... .+@@+++++++@@+.",
+".+++ +++. .+@@+.....+@@+.",
+".... .... .+@@+. .+@@+.",
+" .+. ... .+@@+. .+@@+.",
+" .+. .+++. .+@@+. .+@@+.",
+" .+. .+..++..+@@+.....+@@+.",
+" ... .+.++++.+@@+++++++@@+.",
+" ..+.+++++.+@@@@@@@@@@@+.",
+" .++.++++++.+@@@@@@@@@@@+.",
+" .++.++++++..+++++++++++++.",
+" .++++++.. ...............",
+" .+.++++. ",
+" .+..++++. ",
+" .+..++.+. ",
+" .+..++. . ",
+" .+++++. ",
+" .+++++. ",
+".+++++. ",
+".++++. ",
+".+++. ",
+".... ",
+" .+. ",
+" .+++. ",
+".++..+. ",
+".+++.+. ",
+".+++++. ",
+" .+++. ",
+" ... "};
diff --git a/src/pixmaps/cursor-ellipse.xpm b/src/pixmaps/cursor-ellipse.xpm
index b0f20d18c..83a820f49 100644
--- a/src/pixmaps/cursor-ellipse.xpm
+++ b/src/pixmaps/cursor-ellipse.xpm
@@ -1,6 +1,6 @@
/* XPM */
static char const *cursor_ellipse_xpm[] = {
-"32 32 5 1",
+"32 32 5 1 4 4",
" c None",
". c #FFFFFF",
"% c Stroke",
diff --git a/src/pixmaps/cursor-eraser.xpm b/src/pixmaps/cursor-eraser.xpm
index dbe730291..b3f8f2d84 100644
--- a/src/pixmaps/cursor-eraser.xpm
+++ b/src/pixmaps/cursor-eraser.xpm
@@ -1,6 +1,6 @@
/* XPM */
static const char * cursor_eraser_xpm[] = {
-"32 32 3 1",
+"32 32 3 1 4 4",
" c None",
". c #FFFFFF",
"+ c #000000",
diff --git a/src/pixmaps/cursor-gradient-add.xpm b/src/pixmaps/cursor-gradient-add.xpm
index d1fe8ed95..ea8341bb2 100644
--- a/src/pixmaps/cursor-gradient-add.xpm
+++ b/src/pixmaps/cursor-gradient-add.xpm
@@ -1,6 +1,6 @@
/* XPM */
static char const *cursor_gradient_add_xpm[] = {
-"32 32 3 1",
+"32 32 3 1 4 4",
" c None",
". c #FFFFFF",
"+ c #000000",
diff --git a/src/pixmaps/cursor-gradient.xpm b/src/pixmaps/cursor-gradient.xpm
index a7be769f5..92c9a9a15 100644
--- a/src/pixmaps/cursor-gradient.xpm
+++ b/src/pixmaps/cursor-gradient.xpm
@@ -1,6 +1,6 @@
/* XPM */
static char const *cursor_gradient_xpm[] = {
-"32 32 3 1",
+"32 32 3 1 4 4",
" c None",
". c #FFFFFF",
"+ c #000000",
diff --git a/src/pixmaps/cursor-measure.xpm b/src/pixmaps/cursor-measure.xpm
index 2a28579c6..9f6497c65 100644
--- a/src/pixmaps/cursor-measure.xpm
+++ b/src/pixmaps/cursor-measure.xpm
@@ -1,6 +1,6 @@
/* XPM */
static char const *cursor_measure_xpm[] = {
-"32 32 3 1",
+"32 32 3 1 4 4",
" c None",
". c #FFFFFF",
"+ c #000000",
diff --git a/src/pixmaps/cursor-node-d.xpm b/src/pixmaps/cursor-node-d.xpm
index 7e177bff4..e28bc73d3 100644
--- a/src/pixmaps/cursor-node-d.xpm
+++ b/src/pixmaps/cursor-node-d.xpm
@@ -1,6 +1,6 @@
/* XPM */
static char const *cursor_node_d_xpm[] = {
-"32 32 3 1",
+"32 32 3 1 1 1",
" c None",
". c #FFFFFF",
"+ c #000000",
diff --git a/src/pixmaps/cursor-node-m.xpm b/src/pixmaps/cursor-node-m.xpm
deleted file mode 100644
index 08574bfb0..000000000
--- a/src/pixmaps/cursor-node-m.xpm
+++ /dev/null
@@ -1,38 +0,0 @@
-/* XPM */
-static char const *cursor_node_m_xpm[] = {
-"32 32 3 1",
-" g None",
-". g #FFFFFF",
-"+ g #000000",
-" . ",
-".+. ",
-" .+. ",
-" .++. ",
-" .++. ",
-" .+++. ",
-" .+++. ",
-" .++++. ",
-" .++++. ",
-" .+++++. ",
-" .+++++. ",
-" .++++++. +++ ",
-" .+++++. +.+..+ ",
-" .+++.. +..+..++++ ",
-" .+. +..+..+..+ ",
-" . +..+..+..++ ",
-" +++..+..+..+.+ ",
-" +..+..+..+..+.+ ",
-" +..+..+..+..+.+ ",
-" +..+..+..+..+.+ ",
-" +.............+ ",
-" +............+ ",
-" +...........+ ",
-" +..........+ ",
-" +.........+ ",
-" +........+ ",
-" +.......+ ",
-" +.......+ ",
-" +++++++++ ",
-" ",
-" ",
-" "};
diff --git a/src/pixmaps/cursor-node.xpm b/src/pixmaps/cursor-node.xpm
index 6daae6bda..4d3bd9407 100644
--- a/src/pixmaps/cursor-node.xpm
+++ b/src/pixmaps/cursor-node.xpm
@@ -1,6 +1,6 @@
/* XPM */
static char const *cursor_node_xpm[] = {
-"32 32 3 1",
+"32 32 3 1 1 1",
" c None",
". c #FFFFFF",
"+ c #000000",
diff --git a/src/pixmaps/cursor-paintbucket.xpm b/src/pixmaps/cursor-paintbucket.xpm
index 11ffd6ed1..0c6767f75 100644
--- a/src/pixmaps/cursor-paintbucket.xpm
+++ b/src/pixmaps/cursor-paintbucket.xpm
@@ -1,6 +1,6 @@
/* XPM */
static char const *cursor_paintbucket_xpm[] = {
-"32 32 3 1",
+"32 32 3 1 11 30",
" c None",
". c #000000",
"+ c #FFFFFF",
diff --git a/src/pixmaps/cursor-pen.xpm b/src/pixmaps/cursor-pen.xpm
index 11512e03f..79b68e9ba 100644
--- a/src/pixmaps/cursor-pen.xpm
+++ b/src/pixmaps/cursor-pen.xpm
@@ -1,6 +1,6 @@
/* XPM */
static const char * cursor_pen_xpm[] = {
-"32 32 3 1",
+"32 32 3 1 4 4",
" c None",
". c #FFFFFF",
"+ c #000000",
diff --git a/src/pixmaps/cursor-pencil.xpm b/src/pixmaps/cursor-pencil.xpm
index 4e7b03776..92c6331ab 100644
--- a/src/pixmaps/cursor-pencil.xpm
+++ b/src/pixmaps/cursor-pencil.xpm
@@ -1,6 +1,6 @@
/* XPM */
static const char * cursor_pencil_xpm[] = {
-"32 32 3 1",
+"32 32 3 1 4 4",
" c None",
". c #FFFFFF",
"+ c #000000",
diff --git a/src/pixmaps/cursor-rect.xpm b/src/pixmaps/cursor-rect.xpm
index 69007bc77..e54b7ce4f 100644
--- a/src/pixmaps/cursor-rect.xpm
+++ b/src/pixmaps/cursor-rect.xpm
@@ -1,6 +1,6 @@
/* XPM */
static char const *cursor_rect_xpm[] = {
-"32 32 5 1",
+"32 32 5 1 4 4",
" c None",
". c #FFFFFF",
"% c Stroke",
diff --git a/src/pixmaps/cursor-select-d.xpm b/src/pixmaps/cursor-select-d.xpm
index 501816da0..e84e4de9f 100644
--- a/src/pixmaps/cursor-select-d.xpm
+++ b/src/pixmaps/cursor-select-d.xpm
@@ -1,6 +1,6 @@
/* XPM */
static char const *cursor_select_d_xpm[] = {
-"32 32 3 1",
+"32 32 3 1 1 1",
" c None",
". c #000000",
"+ c #FFFFFF",
diff --git a/src/pixmaps/cursor-select-m.xpm b/src/pixmaps/cursor-select-m.xpm
index 439639c8f..8dd8fb076 100644
--- a/src/pixmaps/cursor-select-m.xpm
+++ b/src/pixmaps/cursor-select-m.xpm
@@ -1,6 +1,6 @@
/* XPM */
static char const *cursor_select_m_xpm[] = {
-"32 32 3 1",
+"32 32 3 1 1 1",
" c None",
". c #000000",
"+ c #FFFFFF",
diff --git a/src/pixmaps/cursor-select.xpm b/src/pixmaps/cursor-select.xpm
index 569573618..36b40c6c5 100644
--- a/src/pixmaps/cursor-select.xpm
+++ b/src/pixmaps/cursor-select.xpm
@@ -1,6 +1,6 @@
/* XPM */
static char const *cursor_select_xpm[] = {
-"32 32 3 1",
+"32 32 3 1 1 1",
" c None",
". c #000000",
"+ c #FFFFFF",
diff --git a/src/pixmaps/cursor-spiral.xpm b/src/pixmaps/cursor-spiral.xpm
index db6f9d2ec..1eaef1e8c 100644
--- a/src/pixmaps/cursor-spiral.xpm
+++ b/src/pixmaps/cursor-spiral.xpm
@@ -1,6 +1,6 @@
/* XPM */
static char const *cursor_spiral_xpm[] = {
-"32 32 3 1",
+"32 32 3 1 4 4",
" c None",
". c #FFFFFF",
"+ c #000000",
diff --git a/src/pixmaps/cursor-spray-move.xpm b/src/pixmaps/cursor-spray-move.xpm
index ad898b3a5..0c918392a 100644
--- a/src/pixmaps/cursor-spray-move.xpm
+++ b/src/pixmaps/cursor-spray-move.xpm
@@ -1,6 +1,6 @@
/* XPM */
static char const * cursor_spray_move_xpm[] = {
-"32 32 3 1",
+"32 32 3 1 4 4",
" c None",
". c #FFFFFF",
"+ c #000000",
diff --git a/src/pixmaps/cursor-spray.xpm b/src/pixmaps/cursor-spray.xpm
index 9ccefee4f..19a40997c 100644
--- a/src/pixmaps/cursor-spray.xpm
+++ b/src/pixmaps/cursor-spray.xpm
@@ -1,6 +1,6 @@
/* XPM */
static char const * cursor_spray_xpm[] = {
-"32 32 3 1",
+"32 32 3 1 4 4",
" c None",
". c #FFFFFF",
"+ c #000000",
diff --git a/src/pixmaps/cursor-star.xpm b/src/pixmaps/cursor-star.xpm
index eedf448e4..c9f2e85e7 100644
--- a/src/pixmaps/cursor-star.xpm
+++ b/src/pixmaps/cursor-star.xpm
@@ -1,6 +1,6 @@
/* XPM */
static char const *cursor_star_xpm[] = {
-"32 32 5 1",
+"32 32 5 1 4 4",
" c None",
". c #FFFFFF",
"% c Stroke",
diff --git a/src/pixmaps/cursor-text-insert.xpm b/src/pixmaps/cursor-text-insert.xpm
index d72c59686..488791e2e 100644
--- a/src/pixmaps/cursor-text-insert.xpm
+++ b/src/pixmaps/cursor-text-insert.xpm
@@ -1,6 +1,6 @@
/* XPM */
static char const *cursor_text_insert_xpm[] = {
-"32 32 3 1",
+"32 32 3 1 7 10",
" c None",
". c #FFFFFF",
"+ c #000000",
diff --git a/src/pixmaps/cursor-text.xpm b/src/pixmaps/cursor-text.xpm
index 46098db30..6d74ae305 100644
--- a/src/pixmaps/cursor-text.xpm
+++ b/src/pixmaps/cursor-text.xpm
@@ -1,6 +1,6 @@
/* XPM */
static char const *cursor_text_xpm[] = {
-"32 32 3 1",
+"32 32 3 1 7 7",
" c None",
". c #FFFFFF",
"+ c #000000",
diff --git a/src/pixmaps/cursor-attract.xpm b/src/pixmaps/cursor-tweak-attract.xpm
index 56033b287..264360b2e 100644
--- a/src/pixmaps/cursor-attract.xpm
+++ b/src/pixmaps/cursor-tweak-attract.xpm
@@ -1,6 +1,6 @@
/* XPM */
static char const *cursor_attract_xpm[] = {
-"32 32 3 1",
+"32 32 3 1 4 4",
" c None",
". c #FFFFFF",
"+ c #000000",
diff --git a/src/pixmaps/cursor-color.xpm b/src/pixmaps/cursor-tweak-color.xpm
index 327028ba8..4bce642d6 100644
--- a/src/pixmaps/cursor-color.xpm
+++ b/src/pixmaps/cursor-tweak-color.xpm
@@ -1,6 +1,6 @@
/* XPM */
static char const *cursor_color_xpm[] = {
-"32 32 3 1",
+"32 32 3 1 4 4",
" c None",
". c #FFFFFF",
"+ c #000000",
diff --git a/src/pixmaps/cursor-tweak-less.xpm b/src/pixmaps/cursor-tweak-less.xpm
index 6c065ba62..c669bca77 100644
--- a/src/pixmaps/cursor-tweak-less.xpm
+++ b/src/pixmaps/cursor-tweak-less.xpm
@@ -1,6 +1,6 @@
/* XPM */
static char const * cursor_tweak_less_xpm[] = {
-"32 32 3 1",
+"32 32 3 1 4 4",
" c None",
". c #FFFFFF",
"+ c #000000",
diff --git a/src/pixmaps/cursor-tweak-more.xpm b/src/pixmaps/cursor-tweak-more.xpm
index 0e80bb9c5..6321ce940 100644
--- a/src/pixmaps/cursor-tweak-more.xpm
+++ b/src/pixmaps/cursor-tweak-more.xpm
@@ -1,6 +1,6 @@
/* XPM */
static char const * cursor_tweak_more_xpm[] = {
-"32 32 3 1",
+"32 32 3 1 4 4",
" c None",
". c #FFFFFF",
"+ c #000000",
diff --git a/src/pixmaps/cursor-tweak-move-in.xpm b/src/pixmaps/cursor-tweak-move-in.xpm
index 11ee4c3e1..d80fa03c6 100644
--- a/src/pixmaps/cursor-tweak-move-in.xpm
+++ b/src/pixmaps/cursor-tweak-move-in.xpm
@@ -1,6 +1,6 @@
/* XPM */
static char const * cursor_tweak_move_in_xpm[] = {
-"32 32 3 1",
+"32 32 3 1 4 4",
" c None",
". c #FFFFFF",
"+ c #000000",
diff --git a/src/pixmaps/cursor-tweak-move-jitter.xpm b/src/pixmaps/cursor-tweak-move-jitter.xpm
index 1f2b1d26a..7f0f8114d 100644
--- a/src/pixmaps/cursor-tweak-move-jitter.xpm
+++ b/src/pixmaps/cursor-tweak-move-jitter.xpm
@@ -1,6 +1,6 @@
/* XPM */
static char const * cursor_tweak_move_jitter_xpm[] = {
-"32 32 3 1",
+"32 32 3 1 4 4",
" c None",
". c #FFFFFF",
"+ c #000000",
diff --git a/src/pixmaps/cursor-tweak-move-out.xpm b/src/pixmaps/cursor-tweak-move-out.xpm
index 7d4569dfe..1fa0293bb 100644
--- a/src/pixmaps/cursor-tweak-move-out.xpm
+++ b/src/pixmaps/cursor-tweak-move-out.xpm
@@ -1,6 +1,6 @@
/* XPM */
static char const * cursor_tweak_move_out_xpm[] = {
-"32 32 3 1",
+"32 32 3 1 4 4",
" c None",
". c #FFFFFF",
"+ c #000000",
diff --git a/src/pixmaps/cursor-tweak-move.xpm b/src/pixmaps/cursor-tweak-move.xpm
index e44028f6c..67b10980b 100644
--- a/src/pixmaps/cursor-tweak-move.xpm
+++ b/src/pixmaps/cursor-tweak-move.xpm
@@ -1,6 +1,6 @@
/* XPM */
static char const * cursor_tweak_move_xpm[] = {
-"32 32 3 1",
+"32 32 3 1 4 4",
" c None",
". c #FFFFFF",
"+ c #000000",
diff --git a/src/pixmaps/cursor-push.xpm b/src/pixmaps/cursor-tweak-push.xpm
index ba05369a8..bf331e58d 100644
--- a/src/pixmaps/cursor-push.xpm
+++ b/src/pixmaps/cursor-tweak-push.xpm
@@ -1,6 +1,6 @@
/* XPM */
static char const *cursor_push_xpm[] = {
-"32 32 3 1",
+"32 32 3 1 4 4",
" c None",
". c #FFFFFF",
"+ c #000000",
diff --git a/src/pixmaps/cursor-repel.xpm b/src/pixmaps/cursor-tweak-repel.xpm
index d365cddc3..5dccefdb8 100644
--- a/src/pixmaps/cursor-repel.xpm
+++ b/src/pixmaps/cursor-tweak-repel.xpm
@@ -1,6 +1,6 @@
/* XPM */
static char const *cursor_repel_xpm[] = {
-"32 32 3 1",
+"32 32 3 1 4 4",
" c None",
". c #FFFFFF",
"+ c #000000",
diff --git a/src/pixmaps/cursor-tweak-rotate-clockwise.xpm b/src/pixmaps/cursor-tweak-rotate-clockwise.xpm
index 20bad59af..ecbbde820 100644
--- a/src/pixmaps/cursor-tweak-rotate-clockwise.xpm
+++ b/src/pixmaps/cursor-tweak-rotate-clockwise.xpm
@@ -1,6 +1,6 @@
/* XPM */
static char const * cursor_tweak_rotate_clockwise_xpm[] = {
-"32 32 3 1",
+"32 32 3 1 4 4",
" c None",
". c #FFFFFF",
"+ c #000000",
diff --git a/src/pixmaps/cursor-tweak-rotate-counterclockwise.xpm b/src/pixmaps/cursor-tweak-rotate-counterclockwise.xpm
index c5fcc70e8..a3c220842 100644
--- a/src/pixmaps/cursor-tweak-rotate-counterclockwise.xpm
+++ b/src/pixmaps/cursor-tweak-rotate-counterclockwise.xpm
@@ -1,6 +1,6 @@
/* XPM */
static char const * cursor_tweak_rotate_counterclockwise_xpm[] = {
-"32 32 3 1",
+"32 32 3 1 4 4",
" c None",
". c #FFFFFF",
"+ c #000000",
diff --git a/src/pixmaps/cursor-roughen.xpm b/src/pixmaps/cursor-tweak-roughen.xpm
index 5adafbbd2..1581b95fa 100644
--- a/src/pixmaps/cursor-roughen.xpm
+++ b/src/pixmaps/cursor-tweak-roughen.xpm
@@ -1,6 +1,6 @@
/* XPM */
static char const *cursor_roughen_xpm[] = {
-"32 32 3 1",
+"32 32 3 1 4 4",
" c None",
". c #FFFFFF",
"+ c #000000",
diff --git a/src/pixmaps/cursor-tweak-scale-down.xpm b/src/pixmaps/cursor-tweak-scale-down.xpm
index cfd804aab..b1b15af17 100644
--- a/src/pixmaps/cursor-tweak-scale-down.xpm
+++ b/src/pixmaps/cursor-tweak-scale-down.xpm
@@ -1,6 +1,6 @@
/* XPM */
static char const * cursor_tweak_scale_down_xpm[] = {
-"32 32 3 1",
+"32 32 3 1 4 4",
" c None",
". c #FFFFFF",
"+ c #000000",
diff --git a/src/pixmaps/cursor-tweak-scale-up.xpm b/src/pixmaps/cursor-tweak-scale-up.xpm
index 547346f4c..dcc73c122 100644
--- a/src/pixmaps/cursor-tweak-scale-up.xpm
+++ b/src/pixmaps/cursor-tweak-scale-up.xpm
@@ -1,6 +1,6 @@
/* XPM */
static char const * cursor_tweak_scale_up_xpm[] = {
-"32 32 3 1",
+"32 32 3 1 4 4",
" c None",
". c #FFFFFF",
"+ c #000000",
diff --git a/src/pixmaps/cursor-thicken.xpm b/src/pixmaps/cursor-tweak-thicken.xpm
index ab76c6c8c..ba7a2dfb8 100644
--- a/src/pixmaps/cursor-thicken.xpm
+++ b/src/pixmaps/cursor-tweak-thicken.xpm
@@ -1,6 +1,6 @@
/* XPM */
static char const *cursor_thicken_xpm[] = {
-"32 32 3 1",
+"32 32 3 1 4 4",
" c None",
". c #FFFFFF",
"+ c #000000",
diff --git a/src/pixmaps/cursor-thin.xpm b/src/pixmaps/cursor-tweak-thin.xpm
index 16a32311d..7d10fe7e9 100644
--- a/src/pixmaps/cursor-thin.xpm
+++ b/src/pixmaps/cursor-tweak-thin.xpm
@@ -1,6 +1,6 @@
/* XPM */
static char const *cursor_thin_xpm[] = {
-"32 32 3 1",
+"32 32 3 1 4 4",
" c None",
". c #FFFFFF",
"+ c #000000",
diff --git a/src/pixmaps/cursor-zoom-out.xpm b/src/pixmaps/cursor-zoom-out.xpm
index c8ddf48a2..8f35ad049 100644
--- a/src/pixmaps/cursor-zoom-out.xpm
+++ b/src/pixmaps/cursor-zoom-out.xpm
@@ -1,6 +1,6 @@
/* XPM */
static char const *cursor_zoom_out_xpm[] = {
-"32 32 3 1",
+"32 32 3 1 6 6",
" c None",
". c #FFFFFF",
"+ c #000000",
diff --git a/src/pixmaps/cursor-zoom.xpm b/src/pixmaps/cursor-zoom.xpm
index 0def57427..e869239d6 100644
--- a/src/pixmaps/cursor-zoom.xpm
+++ b/src/pixmaps/cursor-zoom.xpm
@@ -1,6 +1,6 @@
/* XPM */
static char const *cursor_zoom_xpm[] = {
-"32 32 3 1",
+"32 32 3 1 6 6",
" c None",
". c #FFFFFF",
"+ c #000000",
diff --git a/src/preferences.cpp b/src/preferences.cpp
index 2849fe068..4d14afa93 100644
--- a/src/preferences.cpp
+++ b/src/preferences.cpp
@@ -25,6 +25,7 @@
#include "xml/attribute-record.h"
#include "util/units.h"
#include "attribute-rel-util.h"
+#include "io/resource.h"
#define PREFERENCES_FILE_NAME "preferences.xml"
@@ -82,22 +83,13 @@ private:
};
Preferences::Preferences() :
- _prefs_basename(PREFERENCES_FILE_NAME),
- _prefs_dir(""),
_prefs_filename(""),
_prefs_doc(0),
_errorHandler(0),
_writable(false),
_hasError(false)
{
- // profile_path essentailly returns the argument prefixed by the profile directory.
- // \TODO this is kinda hackish, but the alternative (strrchr) is worse
-
- gchar *path = Inkscape::Application::profile_path(NULL);
- _prefs_dir = path;
- g_free(path);
-
- path = Inkscape::Application::profile_path(_prefs_basename.c_str());
+ char *path = Inkscape::IO::Resource::profile_path(PREFERENCES_FILE_NAME);
_prefs_filename = path;
g_free(path);
@@ -140,16 +132,16 @@ void Preferences::_load()
// 1. Does the file exist?
if (!g_file_test(_prefs_filename.c_str(), G_FILE_TEST_EXISTS)) {
+ char *_prefs_dir = Inkscape::IO::Resource::profile_path(NULL);
// No - we need to create one.
// Does the profile directory exist?
- if (!g_file_test(_prefs_dir.c_str(), G_FILE_TEST_EXISTS)) {
+ if (!g_file_test(_prefs_dir, G_FILE_TEST_EXISTS)) {
// No - create the profile directory
- if (g_mkdir(_prefs_dir.c_str(), 0755)) {
+ if (g_mkdir(_prefs_dir, 0755)) {
// the creation failed
//_reportError(Glib::ustring::compose(_("Cannot create profile directory %1."),
// Glib::filename_to_utf8(_prefs_dir)), not_saved);
- gchar *msg = g_strdup_printf(_("Cannot create profile directory %s."),
- Glib::filename_to_utf8(_prefs_dir).c_str());
+ gchar *msg = g_strdup_printf(_("Cannot create profile directory %s."), _prefs_dir);
_reportError(msg, not_saved);
g_free(msg);
return;
@@ -157,17 +149,17 @@ void Preferences::_load()
// create some subdirectories for user stuff
char const *user_dirs[] = {"keys", "templates", "icons", "extensions", "palettes", NULL};
for (int i=0; user_dirs[i]; ++i) {
- char *dir = Inkscape::Application::profile_path(user_dirs[i]);
+ // XXX Why are we doing this here? shouldn't this be an IO load item?
+ char *dir = Inkscape::IO::Resource::profile_path(user_dirs[i]);
g_mkdir(dir, 0755);
g_free(dir);
}
- } else if (!g_file_test(_prefs_dir.c_str(), G_FILE_TEST_IS_DIR)) {
+ } else if (!g_file_test(_prefs_dir, G_FILE_TEST_IS_DIR)) {
// The profile dir is not actually a directory
//_reportError(Glib::ustring::compose(_("%1 is not a valid directory."),
// Glib::filename_to_utf8(_prefs_dir)), not_saved);
- gchar *msg = g_strdup_printf(_("%s is not a valid directory."),
- Glib::filename_to_utf8(_prefs_dir).c_str());
+ gchar *msg = g_strdup_printf(_("%s is not a valid directory."), _prefs_dir);
_reportError(msg, not_saved);
g_free(msg);
return;
diff --git a/src/preferences.h b/src/preferences.h
index d5ae40e56..2a9818c63 100644
--- a/src/preferences.h
+++ b/src/preferences.h
@@ -544,8 +544,6 @@ private:
Preferences(Preferences const &);
Preferences operator=(Preferences const &);
- std::string _prefs_basename; ///< Basename of the prefs file
- std::string _prefs_dir; ///< Directory in which to look for the prefs file
std::string _prefs_filename; ///< Full filename (with directory) of the prefs file
Glib::ustring _lastErrPrimary; ///< Last primary error message, if any.
Glib::ustring _lastErrSecondary; ///< Last secondary error message, if any.
diff --git a/src/selection-chemistry.cpp b/src/selection-chemistry.cpp
index b3d910700..bac924980 100644
--- a/src/selection-chemistry.cpp
+++ b/src/selection-chemistry.cpp
@@ -39,6 +39,7 @@ SPCycleType SP_CYCLING = SP_CYCLE_FOCUS;
#include "layer-model.h"
#include "selection.h"
#include "ui/tools-switch.h"
+#include "io/resource.h"
#include "message-stack.h"
#include "sp-item-transform.h"
@@ -3628,7 +3629,7 @@ void ObjectSet::createBitmapCopy()
directory = g_path_get_dirname( doc->getURI() );
}
if (directory == NULL) {
- directory = INKSCAPE.homedir_path(NULL);
+ directory = Inkscape::IO::Resource::homedir_path(NULL);
}
gchar *filepath = g_build_filename(directory, basename, NULL);
g_free(directory);
diff --git a/src/shortcuts.cpp b/src/shortcuts.cpp
index e74d60abc..8a8d36d5a 100644
--- a/src/shortcuts.cpp
+++ b/src/shortcuts.cpp
@@ -48,11 +48,7 @@
#include "ui/dialog/filedialog.h"
using namespace Inkscape;
-
-using Inkscape::IO::Resource::get_path;
-using Inkscape::IO::Resource::SYSTEM;
-using Inkscape::IO::Resource::USER;
-using Inkscape::IO::Resource::KEYS;
+using namespace Inkscape::IO::Resource;
static void try_shortcuts_file(char const *filename);
static void read_shortcuts_file(char const *filename, bool const is_user_set=false);
@@ -126,6 +122,12 @@ unsigned int sp_gdkmodifier_to_shortcut(guint accel_key, Gdk::ModifierType gdkmo
SP_SHORTCUT_SHIFT_MASK : 0 ) |
( gdkmodifier & GDK_CONTROL_MASK ?
SP_SHORTCUT_CONTROL_MASK : 0 ) |
+ ( gdkmodifier & GDK_SUPER_MASK ?
+ SP_SHORTCUT_SUPER_MASK : 0 ) |
+ ( gdkmodifier & GDK_HYPER_MASK ?
+ SP_SHORTCUT_HYPER_MASK : 0 ) |
+ ( gdkmodifier & GDK_META_MASK ?
+ SP_SHORTCUT_META_MASK : 0 ) |
( gdkmodifier & GDK_MOD1_MASK ?
SP_SHORTCUT_ALT_MASK : 0 );
@@ -142,6 +144,12 @@ Glib::ustring sp_shortcut_to_label(unsigned int const shortcut) {
modifiers += "Shift,";
if (shortcut & SP_SHORTCUT_ALT_MASK)
modifiers += "Alt,";
+ if (shortcut & SP_SHORTCUT_SUPER_MASK)
+ modifiers += "Super,";
+ if (shortcut & SP_SHORTCUT_HYPER_MASK)
+ modifiers += "Hyper,";
+ if (shortcut & SP_SHORTCUT_META_MASK)
+ modifiers += "Meta,";
if(modifiers.length() > 0 &&
modifiers.find(',',modifiers.length()-1)!=modifiers.npos) {
@@ -208,9 +216,11 @@ Inkscape::XML::Document *sp_shortcut_create_template_file(char const *filename)
*/
void sp_shortcut_get_file_names(std::vector<Glib::ustring> *names, std::vector<Glib::ustring> *paths) {
- std::list<gchar *> sources;
- sources.push_back( Inkscape::Application::profile_path("keys") );
- sources.push_back( g_strdup(INKSCAPE_KEYSDIR) );
+ using namespace Inkscape::IO::Resource;
+ std::list<char *> sources;
+
+ sources.push_back(g_strdup(get_path(USER, KEYS)));
+ sources.push_back(g_strdup(get_path(SYSTEM, KEYS)));
// loop through possible keyboard shortcut file locations.
while (!sources.empty()) {
@@ -227,14 +237,12 @@ void sp_shortcut_get_file_names(std::vector<Glib::ustring> *names, std::vector<G
gchar *filename = 0;
while ((filename = (gchar *) g_dir_read_name(directory)) != NULL) {
gchar* lower = g_ascii_strdown(filename, -1);
- if (!strcmp(dirname, Inkscape::Application::profile_path("keys")) &&
- !strcmp(lower, "default.xml")) {
+ if (!strcmp(lower, "default.xml")) {
// Dont add the users custom keys file
continue;
}
- if (!strcmp(dirname, INKSCAPE_KEYSDIR) &&
- !strcmp(lower, "inkscape.xml")) {
- // Dont add system inkscape.xml (since its a duplicate? of dfefault.xml)
+ if (!strcmp(lower, "inkscape.xml")) {
+ // Dont add system inkscape.xml (since its a duplicate? of default.xml)
continue;
}
if (g_str_has_suffix(lower, ".xml")) {
@@ -611,6 +619,18 @@ static void read_shortcuts_file(char const *filename, bool const is_user_set) {
modifiers |= SP_SHORTCUT_SHIFT_MASK;
} else if (!strcmp(mod, "Alt")) {
modifiers |= SP_SHORTCUT_ALT_MASK;
+ } else if (!strcmp(mod, "Super")) {
+ modifiers |= SP_SHORTCUT_SUPER_MASK;
+ } else if (!strcmp(mod, "Hyper")) {
+ modifiers |= SP_SHORTCUT_HYPER_MASK;
+ } else if (!strcmp(mod, "Meta")) {
+ modifiers |= SP_SHORTCUT_META_MASK;
+ } else if (!strcmp(mod, "Primary")) {
+#ifdef __APPLE__
+ modifiers |= SP_SHORTCUT_META_MASK;
+#else
+ modifiers |= SP_SHORTCUT_CONTROL_MASK;
+#endif
} else {
g_warning("Unknown modifier %s for %s", mod, verb_name);
}
@@ -698,6 +718,9 @@ sp_shortcut_get_modifiers(unsigned int const shortcut)
return static_cast<GdkModifierType>(
((shortcut & SP_SHORTCUT_SHIFT_MASK) ? GDK_SHIFT_MASK : 0) |
((shortcut & SP_SHORTCUT_CONTROL_MASK) ? GDK_CONTROL_MASK : 0) |
+ ((shortcut & SP_SHORTCUT_SUPER_MASK) ? GDK_SUPER_MASK : 0) |
+ ((shortcut & SP_SHORTCUT_HYPER_MASK) ? GDK_HYPER_MASK : 0) |
+ ((shortcut & SP_SHORTCUT_META_MASK) ? GDK_META_MASK : 0) |
((shortcut & SP_SHORTCUT_ALT_MASK) ? GDK_MOD1_MASK : 0)
);
}
diff --git a/src/shortcuts.h b/src/shortcuts.h
index f24a82603..fb36dfd11 100644
--- a/src/shortcuts.h
+++ b/src/shortcuts.h
@@ -12,6 +12,8 @@
#include <vector>
#include <gdkmm/types.h>
+#include <gdk/gdktypes.h>
+
typedef struct _GtkAccelGroup GtkAccelGroup;
typedef struct _GtkWidget GtkWidget;
@@ -27,10 +29,13 @@ namespace Inkscape {
/* We define high-bit mask for packing into single int */
-#define SP_SHORTCUT_SHIFT_MASK (1 << 24)
-#define SP_SHORTCUT_CONTROL_MASK (1 << 25)
-#define SP_SHORTCUT_ALT_MASK (1 << 26)
-#define SP_SHORTCUT_MODIFIER_MASK (SP_SHORTCUT_SHIFT_MASK|SP_SHORTCUT_CONTROL_MASK|SP_SHORTCUT_ALT_MASK)
+#define SP_SHORTCUT_SHIFT_MASK GDK_MODIFIER_RESERVED_20_MASK
+#define SP_SHORTCUT_CONTROL_MASK GDK_MODIFIER_RESERVED_21_MASK
+#define SP_SHORTCUT_ALT_MASK GDK_MODIFIER_RESERVED_22_MASK
+#define SP_SHORTCUT_SUPER_MASK GDK_MODIFIER_RESERVED_23_MASK
+#define SP_SHORTCUT_HYPER_MASK GDK_MODIFIER_RESERVED_24_MASK
+#define SP_SHORTCUT_META_MASK GDK_MODIFIER_RESERVED_25_MASK
+#define SP_SHORTCUT_MODIFIER_MASK (SP_SHORTCUT_SHIFT_MASK|SP_SHORTCUT_CONTROL_MASK|SP_SHORTCUT_ALT_MASK|SP_SHORTCUT_SUPER_MASK|SP_SHORTCUT_HYPER_MASK|SP_SHORTCUT_META_MASK)
/* Returns true if action was performed */
diff --git a/src/sp-cursor.cpp b/src/sp-cursor.cpp
index 4b9f1cc2d..78bfc9075 100644
--- a/src/sp-cursor.cpp
+++ b/src/sp-cursor.cpp
@@ -54,82 +54,92 @@ struct RGBA {
}
};
-GdkPixbuf *sp_cursor_pixbuf_from_xpm(char const *const *xpm, GdkColor const& black, GdkColor const& white, guint32 fill, guint32 stroke)
+GdkCursor *sp_cursor_from_xpm(char const *const *xpm, GdkColor *black, GdkColor *white, guint32 fill, guint32 stroke)
{
+ GdkPixbuf *pixbuf;
+ GdkCursor *cursor;
+ GdkDisplay *display = gdk_display_get_default();
+
int height = 0;
int width = 0;
int colors = 0;
int pix = 0;
+ int hot_x = 0;
+ int hot_y = 0;
std::stringstream ss (std::stringstream::in | std::stringstream::out);
ss << xpm[0];
ss >> height;
ss >> width;
ss >> colors;
ss >> pix;
+ ss >> hot_x;
+ ss >> hot_y;
- std::map<char, RGBA> colorMap;
+ if (gdk_display_supports_cursor_alpha(display) && gdk_display_supports_cursor_color(display)) {
+ std::map<char, RGBA> colorMap;
- for (int i = 0; i < colors; i++) {
+ for (int i = 0; i < colors; i++) {
- char const *p = xpm[1 + i];
- g_assert(*p >=0);
- unsigned char const ccode = (guchar) *p;
+ char const *p = xpm[1 + i];
+ g_assert(*p >=0);
+ unsigned char const ccode = (guchar) *p;
- p++;
- while (isspace(*p)) {
p++;
- }
- p++;
- while (isspace(*p)) {
+ while (isspace(*p)) {
+ p++;
+ }
p++;
+ while (isspace(*p)) {
+ p++;
+ }
+
+ if (strcmp(p, "Fill") == 0) {
+ colorMap[ccode] = RGBA(SP_RGBA32_R_U(fill), SP_RGBA32_G_U(fill), SP_RGBA32_B_U(fill), SP_RGBA32_A_U(fill));
+ } else if (strcmp(p, "Stroke") == 0) {
+ colorMap[ccode] = RGBA(SP_RGBA32_R_U(stroke), SP_RGBA32_G_U(stroke), SP_RGBA32_B_U(stroke), SP_RGBA32_A_U(stroke));
+ } else if (black && strcmp(p, "#000000") == 0) {
+ colorMap[ccode] = RGBA(black->red, black->green, black->blue, 255);
+ } else if (white && strcmp(p, "#FFFFFF") == 0) {
+ colorMap[ccode] = RGBA(white->red, white->green, white->blue, 255);
+ } else if (p[0] == '#') {
+ GdkRGBA color;
+ if (gdk_rgba_parse(&color, p)) {
+ colorMap[ccode] = RGBA(color.red * 255, color.green * 255, color.blue * 255, color.alpha * 255);
+ } else {
+ colorMap[ccode] = RGBA();
+ }
+ } else { // Catches 'None'
+ colorMap[ccode] = RGBA();
+ }
}
- if (strcmp(p, "None") == 0) {
- colorMap[ccode] = RGBA();
- } else if (strcmp(p, "Fill") == 0) {
- colorMap[ccode] = RGBA(SP_RGBA32_R_U(fill), SP_RGBA32_G_U(fill), SP_RGBA32_B_U(fill), SP_RGBA32_A_U(fill));
- } else if (strcmp(p, "Stroke") == 0) {
- colorMap[ccode] = RGBA(SP_RGBA32_R_U(stroke), SP_RGBA32_G_U(stroke), SP_RGBA32_B_U(stroke), SP_RGBA32_A_U(stroke));
- } else if (strcmp(p, "#000000") == 0) {
- colorMap[ccode] = RGBA(black.red, black.green, black.blue, 255);
- } else if (strcmp(p, "#FFFFFF") == 0) {
- colorMap[ccode] = RGBA(white.red, white.green, white.blue, 255);
- } else {
- colorMap[ccode] = RGBA();
- }
- }
+ guint32 *pixmap_buffer = new guint32[width * height];
- guint32 *pixmap_buffer = new guint32[width * height];
-
- for (int y = 0; y < height; y++) {
- for (int x = 0; x < width; x++) {
- std::map<char, RGBA>::const_iterator it = colorMap.find(xpm[1 + colors + y][x]);
- pixmap_buffer[y * width + x] = (it == colorMap.end()) ? 0u : it->second;
+ for (int y = 0; y < height; y++) {
+ for (int x = 0; x < width; x++) {
+ std::map<char, RGBA>::const_iterator it = colorMap.find(xpm[1 + colors + y][x]);
+ pixmap_buffer[y * width + x] = (it == colorMap.end()) ? 0u : it->second;
+ }
}
- }
#if G_BYTE_ORDER == G_BIG_ENDIAN
- for (int i = 0, n = width * height; i < n; i++) {
- guint32 v = pixmap_buffer[i];
- pixmap_buffer[i] = ((v & 0xFF) << 24) | (((v >> 8) & 0xFF) << 16) | (((v >> 16) & 0xFF) << 8) | ((v >> 24) & 0xFF);
- }
+ for (int i = 0, n = width * height; i < n; i++) {
+ guint32 v = pixmap_buffer[i];
+ pixmap_buffer[i] = ((v & 0xFF) << 24) | (((v >> 8) & 0xFF) << 16) | (((v >> 16) & 0xFF) << 8) | ((v >> 24) & 0xFF);
+ }
#endif
- return gdk_pixbuf_new_from_data(reinterpret_cast<guchar*>(pixmap_buffer), GDK_COLORSPACE_RGB, TRUE, 8, width, height, width * sizeof(guint32), free_cursor_data, NULL);
-}
-
-GdkCursor *sp_cursor_new_from_xpm(char const *const *xpm, int hot_x, int hot_y)
-{
- GdkCursor *cursor = 0;
- GdkPixbuf *pixbuf = gdk_pixbuf_new_from_xpm_data((const gchar **)xpm);
-
- if (pixbuf) {
- cursor = gdk_cursor_new_from_pixbuf(gdk_display_get_default(),
- pixbuf, hot_x, hot_y);
+ pixbuf = gdk_pixbuf_new_from_data(reinterpret_cast<guchar*>(pixmap_buffer), GDK_COLORSPACE_RGB, TRUE, 8, width, height, width * sizeof(guint32), free_cursor_data, NULL);
+ } else {
+ pixbuf = gdk_pixbuf_new_from_xpm_data((const gchar **)xpm);
+ }
+ if (pixbuf != NULL) {
+ cursor = gdk_cursor_new_from_pixbuf(display, pixbuf, hot_x, hot_y);
g_object_unref(pixbuf);
+ } else {
+ g_warning("Failed to load cursor from xpm!");
}
-
return cursor;
}
diff --git a/src/sp-cursor.h b/src/sp-cursor.h
index c0b8b46a3..6579d6a16 100644
--- a/src/sp-cursor.h
+++ b/src/sp-cursor.h
@@ -6,8 +6,7 @@ typedef struct _GdkPixbuf GdkPixbuf;
typedef struct _GdkCursor GdkCursor;
typedef struct _GdkColor GdkColor;
-GdkPixbuf* sp_cursor_pixbuf_from_xpm(char const *const *xpm, GdkColor const& black, GdkColor const& white, guint32 fill, guint32 stroke);
-GdkCursor *sp_cursor_new_from_xpm(char const *const *xpm, int hot_x, int hot_y);
+GdkCursor* sp_cursor_from_xpm(char const *const *xpm, GdkColor *black=NULL, GdkColor *white=NULL, guint32 fill=0, guint32 stroke=0);
#endif
diff --git a/src/sp-namedview.cpp b/src/sp-namedview.cpp
index c40006a92..a3a5617e1 100644
--- a/src/sp-namedview.cpp
+++ b/src/sp-namedview.cpp
@@ -37,6 +37,12 @@
#include "sp-root.h"
#include <gtkmm/window.h>
+#if WITH_GTKMM_3_22
+# include <gdkmm/monitor.h>
+#else
+# include <gdkmm/screen.h>
+#endif
+
using Inkscape::DocumentUndo;
using Inkscape::Util::unit_table;
@@ -742,9 +748,22 @@ gdouble const NEWDOC_Y_SCALE = NEWDOC_X_SCALE;
Geom::Point calcAnchorPoint(gint const x, gint const y,
gint const w, gint const h, gint const minOnscreen)
{
+#if WITH_GTKMM_3_22
+ Gdk::Rectangle screen_geometry;
+
+ auto const display = Gdk::Display::get_default();
+ auto const monitor = display->get_primary_monitor();
+ monitor->get_geometry(screen_geometry);
+ int screen_width = screen_geometry.get_width();
+ int screen_height = screen_geometry.get_height();
+#else
+ int screen_width = gdk_screen_width();
+ int screen_height = gdk_screen_height();
+#endif
+
// prevent the window from moving off the screen to the right or to the bottom
- gint ax = MIN(gdk_screen_width() - minOnscreen, x);
- gint ay = MIN(gdk_screen_height() - minOnscreen, y);
+ gint ax = MIN(screen_width - minOnscreen, x);
+ gint ay = MIN(screen_height - minOnscreen, y);
// prevent the window from moving off the screen to the left or to the top
ax = MAX(minOnscreen - w, ax);
@@ -778,16 +797,23 @@ void sp_namedview_window_from_document(SPDesktop *desktop)
win->maximize();
}
} else {
- // gdk_screen_width() / gdk_screen_height() return the dimensions of all displays combined
- // therefore we have to get the dimensions of one monitor explicitly (currently the primary monitor)
+
// TODO: account for multi-monitor setups (i.e. on which monitor do we want to display Inkscape?)
- gint monitor_number;
- GdkRectangle monitor_geometry;
- monitor_number = gdk_screen_get_primary_monitor(gdk_screen_get_default());
- gdk_screen_get_monitor_geometry(gdk_screen_get_default(), monitor_number, &monitor_geometry);
+ Gdk::Rectangle monitor_geometry;
+
+#if WITH_GTKMM_3_22
+ auto const display = Gdk::Display::get_default();
+ auto const monitor = display->get_primary_monitor();
+ monitor->get_geometry(monitor_geometry);
+#else
+ auto const default_screen = Gdk::Screen::get_default();
+ auto const monitor_number = default_screen->get_primary_monitor();
+ default_screen->get_monitor_geometry(monitor_number, monitor_geometry);
+#endif
+
+ int w = monitor_geometry.get_width();
+ int h = monitor_geometry.get_height();
- gint w = monitor_geometry.width;
- gint h = monitor_geometry.height;
bool move_to_screen = false;
if (geometry_from_file and !new_document) {
w = MIN(w, nv->window_width);
diff --git a/src/ui/CMakeLists.txt b/src/ui/CMakeLists.txt
index 389e8902a..b6b88e50b 100644
--- a/src/ui/CMakeLists.txt
+++ b/src/ui/CMakeLists.txt
@@ -1,5 +1,6 @@
set(ui_SRC
clipboard.cpp
+ contextmenu.cpp
control-manager.cpp
dialog-events.cpp
draw-anchor.cpp
@@ -71,6 +72,7 @@ set(ui_SRC
dialog/filedialog.cpp
dialog/filedialogimpl-gtkmm.cpp
dialog/fill-and-stroke.cpp
+ dialog/filter-editor.cpp
dialog/filter-effects-dialog.cpp
dialog/find.cpp
dialog/floating-behavior.cpp
@@ -173,6 +175,7 @@ set(ui_SRC
# -------
# Headers
clipboard.h
+ contextmenu.h
control-manager.h
control-types.h
dialog-events.h
@@ -214,6 +217,7 @@ set(ui_SRC
dialog/filedialogimpl-gtkmm.h
dialog/filedialogimpl-win32.h
dialog/fill-and-stroke.h
+ dialog/filter-editor.h
dialog/filter-effects-dialog.h
dialog/find.h
dialog/floating-behavior.h
diff --git a/src/ui/contextmenu.cpp b/src/ui/contextmenu.cpp
new file mode 100644
index 000000000..1bc87574e
--- /dev/null
+++ b/src/ui/contextmenu.cpp
@@ -0,0 +1,914 @@
+/**
+ * @file
+ * Context menu
+ */
+/* Authors:
+ * Lauris Kaplinski <lauris@kaplinski.com>
+ * Frank Felfe <innerspace@iname.com>
+ * bulia byak <buliabyak@users.sf.net>
+ * Jon A. Cruz <jon@joncruz.org>
+ * Abhishek Sharma
+ * Kris De Gussem <Kris.DeGussem@gmail.com>
+ *
+ * Copyright (C) 2012 Kris De Gussem
+ * Copyright (C) 2010 authors
+ * Copyright (C) 1999-2005 authors
+ * Copyright (C) 2004 David Turner
+ * Copyright (C) 2001-2002 Ximian, Inc.
+ *
+ * Released under GNU GPL, read the file 'COPYING' for more information
+ */
+
+#include "contextmenu.h"
+
+#include <glibmm/i18n.h>
+#include <glibmm/miscutils.h>
+
+#include <gtkmm/box.h>
+#include <gtkmm/image.h>
+#include <gtkmm/separatormenuitem.h>
+
+#include "desktop.h"
+#include "document.h"
+#include "document-undo.h"
+#include "helper/action.h"
+#include "helper/action-context.h"
+#include "inkscape.h"
+#include "message-context.h"
+#include "message-stack.h"
+#include "selection.h"
+#include "selection-chemistry.h"
+#include "shortcuts.h"
+#include "sp-anchor.h"
+#include "sp-clippath.h"
+#include "sp-image.h"
+#include "sp-item.h"
+#include "sp-mask.h"
+#include "sp-shape.h"
+#include "sp-text.h"
+#include "ui/dialog/dialog-manager.h"
+#include "ui/dialog/layer-properties.h"
+#include "verbs.h"
+
+static bool temporarily_block_actions = false;
+
+ContextMenu::ContextMenu(SPDesktop *desktop, SPItem *item) :
+ _item(item),
+ MIGroup(),
+ MIParent(_("Go to parent"))
+{
+// g_message("ContextMenu");
+ _object = static_cast<SPObject *>(item);
+ _desktop = desktop;
+
+ AppendItemFromVerb(Inkscape::Verb::get(SP_VERB_EDIT_UNDO));
+ AppendItemFromVerb(Inkscape::Verb::get(SP_VERB_EDIT_REDO));
+ AddSeparator();
+ AppendItemFromVerb(Inkscape::Verb::get(SP_VERB_EDIT_CUT));
+ AppendItemFromVerb(Inkscape::Verb::get(SP_VERB_EDIT_COPY));
+ AppendItemFromVerb(Inkscape::Verb::get(SP_VERB_EDIT_PASTE));
+ AddSeparator();
+ AppendItemFromVerb(Inkscape::Verb::get(SP_VERB_EDIT_DUPLICATE));
+ AppendItemFromVerb(Inkscape::Verb::get(SP_VERB_EDIT_DELETE));
+
+ positionOfLastDialog = 10; // 9 in front + 1 for the separator in the next if; used to position the dialog menu entries below each other
+ /* Item menu */
+ if (item!=NULL) {
+ AddSeparator();
+ MakeObjectMenu();
+ }
+ AddSeparator();
+ /* Lock/Unock Hide/Unhide*/
+ Geom::Rect b(_desktop->point(),_desktop->point() + Geom::Point(1,1));
+ std::vector< SPItem * > down_items = _desktop->getDocument()->getItemsPartiallyInBox( _desktop->dkey, b, true, true);
+ bool has_down_hidden = false;
+ bool has_down_locked = false;
+ for(std::vector< SPItem * >::iterator down = down_items.begin(); down != down_items.end(); ++down){
+ if((*down)->isHidden()) {
+ has_down_hidden = true;
+ }
+ if((*down)->isLocked()) {
+ has_down_locked = true;
+ }
+ }
+ Gtk::MenuItem* mi;
+
+ mi = Gtk::manage(new Gtk::MenuItem(_("Hide selected objects"),1));
+ mi->signal_activate().connect(sigc::mem_fun(*this, &ContextMenu::HideSelected));
+ if (_desktop->selection->isEmpty()) {
+ mi->set_sensitive(false);
+ }
+ mi->show();
+ append(*mi);//insert(*mi,positionOfLastDialog++);
+
+ mi = Gtk::manage(new Gtk::MenuItem(_("Unhide objects below"),1));
+ mi->signal_activate().connect(sigc::bind<std::vector< SPItem * > >(sigc::mem_fun(*this, &ContextMenu::UnHideBelow), down_items));
+ if (!has_down_hidden) {
+ mi->set_sensitive(false);
+ }
+ mi->show();
+ append(*mi);//insert(*mi,positionOfLastDialog++);
+
+ mi = Gtk::manage(new Gtk::MenuItem(_("Lock selected objects"),1));
+ mi->signal_activate().connect(sigc::mem_fun(*this, &ContextMenu::LockSelected));
+ if (_desktop->selection->isEmpty()) {
+ mi->set_sensitive(false);
+ }
+ mi->show();
+ append(*mi);//insert(*mi,positionOfLastDialog++);
+
+ mi = Gtk::manage(new Gtk::MenuItem(_("Unlock objects below"),1));
+ mi->signal_activate().connect(sigc::bind<std::vector< SPItem * > >(sigc::mem_fun(*this, &ContextMenu::UnLockBelow), down_items));
+ if (!has_down_locked) {
+ mi->set_sensitive(false);
+ }
+ mi->show();
+ append(*mi);//insert(*mi,positionOfLastDialog++);
+ /* layer menu */
+ SPGroup *group=NULL;
+ if (item) {
+ if (SP_IS_GROUP(item)) {
+ group = SP_GROUP(item);
+ } else if ( item != _desktop->currentRoot() && SP_IS_GROUP(item->parent) ) {
+ group = SP_GROUP(item->parent);
+ }
+ }
+
+ if (( group && group != _desktop->currentLayer() ) ||
+ ( _desktop->currentLayer() != _desktop->currentRoot() && _desktop->currentLayer()->parent != _desktop->currentRoot() ) ) {
+ AddSeparator();
+ }
+
+ if ( group && group != _desktop->currentLayer() ) {
+ /* TRANSLATORS: #%1 is the id of the group e.g. <g id="#g7">, not a number. */
+ MIGroup.set_label (Glib::ustring::compose(_("Enter group #%1"), group->getId()));
+ MIGroup.set_data("group", group);
+ MIGroup.signal_activate().connect(sigc::bind(sigc::mem_fun(*this, &ContextMenu::EnterGroup),&MIGroup));
+ MIGroup.show();
+ append(MIGroup);
+ }
+
+ if ( _desktop->currentLayer() != _desktop->currentRoot() ) {
+ if ( _desktop->currentLayer()->parent != _desktop->currentRoot() ) {
+ MIParent.signal_activate().connect(sigc::mem_fun(*this, &ContextMenu::LeaveGroup));
+ MIParent.show();
+ append(MIParent);
+
+ /* Pop selection out of group */
+ Gtk::MenuItem* miu = Gtk::manage(new Gtk::MenuItem(_("_Pop selection out of group"), 1));
+ miu->signal_activate().connect(sigc::mem_fun(*this, &ContextMenu::ActivateUngroupPopSelection));
+ miu->show();
+ append(*miu);
+ }
+ }
+}
+
+ContextMenu::~ContextMenu(void)
+{
+}
+
+Gtk::SeparatorMenuItem* ContextMenu::AddSeparator(void)
+{
+ Gtk::SeparatorMenuItem* sep = Gtk::manage(new Gtk::SeparatorMenuItem());
+ sep->show();
+ append(*sep);
+ return sep;
+}
+
+void ContextMenu::EnterGroup(Gtk::MenuItem* mi)
+{
+ _desktop->setCurrentLayer(reinterpret_cast<SPObject *>(mi->get_data("group")));
+ _desktop->selection->clear();
+}
+
+void ContextMenu::LeaveGroup(void)
+{
+ _desktop->setCurrentLayer(_desktop->currentLayer()->parent);
+}
+
+void ContextMenu::LockSelected(void)
+{
+ auto itemlist = _desktop->selection->items();
+ for(auto i=itemlist.begin();i!=itemlist.end(); ++i) {
+ (*i)->setLocked(true);
+ }
+}
+
+void ContextMenu::HideSelected(void)
+{
+ auto itemlist =_desktop->selection->items();
+ for(auto i=itemlist.begin();i!=itemlist.end(); ++i) {
+ (*i)->setHidden(true);
+ }
+}
+
+void ContextMenu::UnLockBelow(std::vector<SPItem *> items)
+{
+ _desktop->selection->clear();
+ for(auto i=items.begin();i!=items.end(); ++i) {
+ if ((*i)->isLocked()) {
+ (*i)->setLocked(false);
+ _desktop->selection->add(*i);
+ }
+ }
+}
+
+void ContextMenu::UnHideBelow(std::vector<SPItem *> items)
+{
+ _desktop->selection->clear();
+ for(auto i=items.begin();i!=items.end(); ++i) {
+ if ((*i)->isHidden()) {
+ (*i)->setHidden(false);
+ _desktop->selection->add(*i);
+ }
+ }
+}
+
+/*
+ * Some day when the right-click menus are ready to start working
+ * smarter with the verbs, we'll need to change this NULL being
+ * sent to sp_action_perform to something useful, or set some kind
+ * of global "right-clicked position" variable for actions to
+ * investigate when they're called.
+ */
+static void
+context_menu_item_on_my_activate(void */*object*/, SPAction *action)
+{
+ if (!temporarily_block_actions) {
+ sp_action_perform(action, NULL);
+ }
+}
+
+static void
+context_menu_item_on_my_select(void */*object*/, SPAction *action)
+{
+ sp_action_get_view(action)->tipsMessageContext()->set(Inkscape::NORMAL_MESSAGE, action->tip);
+}
+
+static void
+context_menu_item_on_my_deselect(void */*object*/, SPAction *action)
+{
+ sp_action_get_view(action)->tipsMessageContext()->clear();
+}
+
+
+// TODO: Update this to allow radio items to be used
+void ContextMenu::AppendItemFromVerb(Inkscape::Verb *verb)//, SPDesktop *view)//, bool radio, GSList *group)
+{
+ SPAction *action;
+ SPDesktop *view = _desktop;
+
+ if (verb->get_code() == SP_VERB_NONE) {
+ Gtk::MenuItem *item = AddSeparator();
+ item->show();
+ append(*item);
+ } else {
+ action = verb->get_action(Inkscape::ActionContext(view));
+ if (!action) {
+ return;
+ }
+
+ auto const item = Gtk::manage(new Gtk::MenuItem(action->name, true));
+
+ sp_shortcut_add_accelerator(GTK_WIDGET(item->gobj()), sp_shortcut_get_primary(verb));
+
+ action->signal_set_sensitive.connect(sigc::mem_fun(*this, &ContextMenu::set_sensitive));
+ action->signal_set_name.connect(sigc::mem_fun(*item, &ContextMenu::set_name));
+
+ if (!action->sensitive) {
+ item->set_sensitive(FALSE);
+ }
+
+ item->set_events(Gdk::KEY_PRESS_MASK);
+ item->signal_activate().connect(sigc::bind(sigc::ptr_fun(context_menu_item_on_my_activate),item,action));
+ item->signal_select().connect(sigc::bind(sigc::ptr_fun(context_menu_item_on_my_select),item,action));
+ item->signal_deselect().connect(sigc::bind(sigc::ptr_fun(context_menu_item_on_my_deselect),item,action));
+ item->show_all();
+ append(*item);
+ }
+}
+
+void ContextMenu::MakeObjectMenu(void)
+{
+ if (SP_IS_ITEM(_object)) {
+ MakeItemMenu();
+ }
+
+ if (SP_IS_GROUP(_object)) {
+ MakeGroupMenu();
+ }
+
+ if (SP_IS_ANCHOR(_object)) {
+ MakeAnchorMenu();
+ }
+
+ if (SP_IS_IMAGE(_object)) {
+ MakeImageMenu();
+ }
+
+ if (SP_IS_SHAPE(_object)) {
+ MakeShapeMenu();
+ }
+
+ if (SP_IS_TEXT(_object)) {
+ MakeTextMenu();
+ }
+}
+
+void ContextMenu::MakeItemMenu (void)
+{
+ Gtk::MenuItem* mi;
+
+ /* Item dialog */
+ mi = Gtk::manage(new Gtk::MenuItem(_("_Object Properties..."),1));
+ mi->signal_activate().connect(sigc::mem_fun(*this, &ContextMenu::ItemProperties));
+ mi->show();
+ append(*mi);//insert(*mi,positionOfLastDialog++);
+
+ AddSeparator();
+
+ /* Select item */
+ if (Inkscape::Verb::getbyid( "org.inkscape.followlink" )) {
+ mi = Gtk::manage(new Gtk::MenuItem(_("_Select This"), 1));
+ if (_desktop->selection->includes(_item)) {
+ mi->set_sensitive(FALSE);
+ } else {
+ mi->signal_activate().connect(sigc::mem_fun(*this, &ContextMenu::ItemSelectThis));
+ }
+ mi->show();
+ append(*mi);
+ }
+
+
+ mi = Gtk::manage(new Gtk::MenuItem(_("Select Same")));
+ mi->show();
+ Gtk::Menu *select_same_submenu = Gtk::manage(new Gtk::Menu());
+ if (_desktop->selection->isEmpty()) {
+ mi->set_sensitive(FALSE);
+ }
+ mi->set_submenu(*select_same_submenu);
+ append(*mi);
+
+ /* Select same fill and stroke */
+ mi = Gtk::manage(new Gtk::MenuItem(_("Fill and Stroke"), 1));
+ mi->signal_activate().connect(sigc::mem_fun(*this, &ContextMenu::SelectSameFillStroke));
+ mi->set_sensitive(!SP_IS_ANCHOR(_item));
+ mi->show();
+ select_same_submenu->append(*mi);
+
+ /* Select same fill color */
+ mi = Gtk::manage(new Gtk::MenuItem(_("Fill Color"), 1));
+ mi->signal_activate().connect(sigc::mem_fun(*this, &ContextMenu::SelectSameFillColor));
+ mi->set_sensitive(!SP_IS_ANCHOR(_item));
+ mi->show();
+ select_same_submenu->append(*mi);
+
+ /* Select same stroke color */
+ mi = Gtk::manage(new Gtk::MenuItem(_("Stroke Color"), 1));
+ mi->signal_activate().connect(sigc::mem_fun(*this, &ContextMenu::SelectSameStrokeColor));
+ mi->set_sensitive(!SP_IS_ANCHOR(_item));
+ mi->show();
+ select_same_submenu->append(*mi);
+
+ /* Select same stroke style */
+ mi = Gtk::manage(new Gtk::MenuItem(_("Stroke Style"), 1));
+ mi->signal_activate().connect(sigc::mem_fun(*this, &ContextMenu::SelectSameStrokeStyle));
+ mi->set_sensitive(!SP_IS_ANCHOR(_item));
+ mi->show();
+ select_same_submenu->append(*mi);
+
+ /* Select same stroke style */
+ mi = Gtk::manage(new Gtk::MenuItem(_("Object type"), 1));
+ mi->signal_activate().connect(sigc::mem_fun(*this, &ContextMenu::SelectSameObjectType));
+ mi->set_sensitive(!SP_IS_ANCHOR(_item));
+ mi->show();
+ select_same_submenu->append(*mi);
+
+ /* Move to layer */
+ mi = Gtk::manage(new Gtk::MenuItem(_("_Move to layer ..."), 1));
+ if (_desktop->selection->isEmpty()) {
+ mi->set_sensitive(FALSE);
+ } else {
+ mi->signal_activate().connect(sigc::mem_fun(*this, &ContextMenu::ItemMoveTo));
+ }
+ mi->show();
+ append(*mi);
+
+ /* Create link */
+ mi = Gtk::manage(new Gtk::MenuItem(_("Create _Link"), 1));
+ mi->signal_activate().connect(sigc::mem_fun(*this, &ContextMenu::ItemCreateLink));
+ mi->set_sensitive(!SP_IS_ANCHOR(_item));
+ mi->show();
+ append(*mi);
+
+ bool ClipRefOK=false;
+ bool MaskRefOK=false;
+ if (_item){
+ if (_item->clip_ref){
+ if (_item->clip_ref->getObject()){
+ ClipRefOK=true;
+ }
+ }
+ }
+ if (_item){
+ if (_item->mask_ref){
+ if (_item->mask_ref->getObject()){
+ MaskRefOK=true;
+ }
+ }
+ }
+ /* Set mask */
+ mi = Gtk::manage(new Gtk::MenuItem(_("Set Mask"), 1));
+ mi->signal_activate().connect(sigc::mem_fun(*this, &ContextMenu::SetMask));
+ if (ClipRefOK || MaskRefOK) {
+ mi->set_sensitive(FALSE);
+ } else {
+ mi->set_sensitive(TRUE);
+ }
+ mi->show();
+ append(*mi);
+
+ /* Release mask */
+ mi = Gtk::manage(new Gtk::MenuItem(_("Release Mask"), 1));
+ mi->signal_activate().connect(sigc::mem_fun(*this, &ContextMenu::ReleaseMask));
+ if (MaskRefOK) {
+ mi->set_sensitive(TRUE);
+ } else {
+ mi->set_sensitive(FALSE);
+ }
+ mi->show();
+ append(*mi);
+
+ /*SSet Clip Group */
+ mi = Gtk::manage(new Gtk::MenuItem(_("Create Clip G_roup"),1));
+ mi->signal_activate().connect(sigc::mem_fun(*this, &ContextMenu::CreateGroupClip));
+ mi->set_sensitive(TRUE);
+ mi->show();
+ append(*mi);
+
+ /* Set Clip */
+ mi = Gtk::manage(new Gtk::MenuItem(_("Set Cl_ip"), 1));
+ mi->signal_activate().connect(sigc::mem_fun(*this, &ContextMenu::SetClip));
+ if (ClipRefOK || MaskRefOK) {
+ mi->set_sensitive(FALSE);
+ } else {
+ mi->set_sensitive(TRUE);
+ }
+ mi->show();
+ append(*mi);
+
+ /* Release Clip */
+ mi = Gtk::manage(new Gtk::MenuItem(_("Release C_lip"), 1));
+ mi->signal_activate().connect(sigc::mem_fun(*this, &ContextMenu::ReleaseClip));
+ if (ClipRefOK) {
+ mi->set_sensitive(TRUE);
+ } else {
+ mi->set_sensitive(FALSE);
+ }
+ mi->show();
+ append(*mi);
+
+ /* Group */
+ mi = Gtk::manage(new Gtk::MenuItem(_("_Group"), 1));
+ mi->signal_activate().connect(sigc::mem_fun(*this, &ContextMenu::ActivateGroup));
+ if (_desktop->selection->isEmpty()) {
+ mi->set_sensitive(FALSE);
+ } else {
+ mi->set_sensitive(TRUE);
+ }
+ mi->show();
+ append(*mi);
+}
+
+void ContextMenu::SelectSameFillStroke(void)
+{
+ sp_select_same_fill_stroke_style(_desktop, true, true, true);
+}
+
+void ContextMenu::SelectSameFillColor(void)
+{
+ sp_select_same_fill_stroke_style(_desktop, true, false, false);
+}
+
+void ContextMenu::SelectSameStrokeColor(void)
+{
+ sp_select_same_fill_stroke_style(_desktop, false, true, false);
+}
+
+void ContextMenu::SelectSameStrokeStyle(void)
+{
+ sp_select_same_fill_stroke_style(_desktop, false, false, true);
+}
+
+void ContextMenu::SelectSameObjectType(void)
+{
+ sp_select_same_object_type(_desktop);
+}
+
+void ContextMenu::ItemProperties(void)
+{
+ _desktop->selection->set(_item);
+ _desktop->_dlg_mgr->showDialog("ObjectProperties");
+}
+
+void ContextMenu::ItemSelectThis(void)
+{
+ _desktop->selection->set(_item);
+}
+
+void ContextMenu::ItemMoveTo(void)
+{
+ Inkscape::UI::Dialogs::LayerPropertiesDialog::showMove(_desktop, _desktop->currentLayer());
+}
+
+
+
+void ContextMenu::ItemCreateLink(void)
+{
+ Inkscape::XML::Document *xml_doc = _desktop->doc()->getReprDoc();
+ Inkscape::XML::Node *repr = xml_doc->createElement("svg:a");
+ _item->parent->getRepr()->addChild(repr, _item->getRepr());
+ SPObject *object = _item->document->getObjectByRepr(repr);
+ g_return_if_fail(SP_IS_ANCHOR(object));
+
+ const char *id = _item->getRepr()->attribute("id");
+ Inkscape::XML::Node *child = _item->getRepr()->duplicate(xml_doc);
+ _item->deleteObject(false);
+ repr->addChild(child, NULL);
+ child->setAttribute("id", id);
+
+ Inkscape::GC::release(repr);
+ Inkscape::GC::release(child);
+
+ Inkscape::DocumentUndo::done(object->document, SP_VERB_NONE, _("Create link"));
+
+ _desktop->selection->set(SP_ITEM(object));
+ _desktop->_dlg_mgr->showDialog("ObjectAttributes");
+}
+
+void ContextMenu::SetMask(void)
+{
+ _desktop->selection->setMask(false, false);
+}
+
+void ContextMenu::ReleaseMask(void)
+{
+ _desktop->selection->unsetMask(false);
+}
+
+void ContextMenu::CreateGroupClip(void)
+{
+ _desktop->selection->setClipGroup();
+}
+
+void ContextMenu::SetClip(void)
+{
+ _desktop->selection->setMask(true, false);
+}
+
+
+void ContextMenu::ReleaseClip(void)
+{
+ _desktop->selection->unsetMask(true);
+}
+
+void ContextMenu::MakeGroupMenu(void)
+{
+ /* Ungroup */
+ Gtk::MenuItem* mi = Gtk::manage(new Gtk::MenuItem(_("_Ungroup"), 1));
+ mi->signal_activate().connect(sigc::mem_fun(*this, &ContextMenu::ActivateUngroup));
+ mi->show();
+ append(*mi);
+}
+
+void ContextMenu::ActivateGroup(void)
+{
+ _desktop->selection->group();
+}
+
+void ContextMenu::ActivateUngroup(void)
+{
+ std::vector<SPItem*> children;
+
+ sp_item_group_ungroup(static_cast<SPGroup*>(_item), children);
+ _desktop->selection->setList(children);
+}
+
+void ContextMenu::ActivateUngroupPopSelection(void)
+{
+ _desktop->selection->popFromGroup();
+}
+
+
+void ContextMenu::MakeAnchorMenu(void)
+{
+ Gtk::MenuItem* mi;
+
+ /* Link dialog */
+ mi = Gtk::manage(new Gtk::MenuItem(_("Link _Properties..."), 1));
+ mi->signal_activate().connect(sigc::mem_fun(*this, &ContextMenu::AnchorLinkProperties));
+ mi->show();
+ insert(*mi,positionOfLastDialog++);
+
+ /* Select item */
+ mi = Gtk::manage(new Gtk::MenuItem(_("_Follow Link"), 1));
+ mi->signal_activate().connect(sigc::mem_fun(*this, &ContextMenu::AnchorLinkFollow));
+ mi->show();
+ append(*mi);
+
+ /* Reset transformations */
+ mi = Gtk::manage(new Gtk::MenuItem(_("_Remove Link"), 1));
+ mi->signal_activate().connect(sigc::mem_fun(*this, &ContextMenu::AnchorLinkRemove));
+ mi->show();
+ append(*mi);
+}
+
+void ContextMenu::AnchorLinkProperties(void)
+{
+ _desktop->_dlg_mgr->showDialog("ObjectAttributes");
+}
+
+void ContextMenu::AnchorLinkFollow(void)
+{
+
+ if (_desktop->selection->isEmpty()) {
+ _desktop->selection->set(_item);
+ }
+ // Opening the selected links with a python extension
+ Inkscape::Verb *verb = Inkscape::Verb::getbyid( "org.inkscape.followlink" );
+ if (verb) {
+ SPAction *action = verb->get_action(Inkscape::ActionContext(_desktop));
+ if (action) {
+ sp_action_perform(action, NULL);
+ }
+ }
+}
+
+void ContextMenu::AnchorLinkRemove(void)
+{
+ std::vector<SPItem*> children;
+ sp_item_group_ungroup(static_cast<SPAnchor*>(_item), children, false);
+ Inkscape::DocumentUndo::done(_desktop->doc(), SP_VERB_NONE, _("Remove link"));
+}
+
+void ContextMenu::MakeImageMenu (void)
+{
+ Gtk::MenuItem* mi;
+ Inkscape::XML::Node *ir = _object->getRepr();
+ const gchar *href = ir->attribute("xlink:href");
+
+ /* Image properties */
+ mi = Gtk::manage(new Gtk::MenuItem(_("Image _Properties..."), 1));
+ mi->signal_activate().connect(sigc::mem_fun(*this, &ContextMenu::ImageProperties));
+ mi->show();
+ insert(*mi,positionOfLastDialog++);
+
+ /* Edit externally */
+ mi = Gtk::manage(new Gtk::MenuItem(_("Edit Externally..."), 1));
+ mi->signal_activate().connect(sigc::mem_fun(*this, &ContextMenu::ImageEdit));
+ mi->show();
+ insert(*mi,positionOfLastDialog++);
+ if ( (!href) || ((strncmp(href, "data:", 5) == 0)) ) {
+ mi->set_sensitive( FALSE );
+ }
+
+ /* Trace Bitmap */
+ mi = Gtk::manage(new Gtk::MenuItem(_("_Trace Bitmap..."), 1));
+ mi->signal_activate().connect(sigc::mem_fun(*this, &ContextMenu::ImageTraceBitmap));
+ mi->show();
+ insert(*mi,positionOfLastDialog++);
+ if (_desktop->selection->isEmpty()) {
+ mi->set_sensitive(FALSE);
+ }
+
+ /* Trace Pixel Art */
+ mi = Gtk::manage(new Gtk::MenuItem(_("Trace Pixel Art"), 1));
+ mi->signal_activate().connect(sigc::mem_fun(*this, &ContextMenu::ImageTracePixelArt));
+ mi->show();
+ insert(*mi,positionOfLastDialog++);
+ if (_desktop->selection->isEmpty()) {
+ mi->set_sensitive(FALSE);
+ }
+
+ /* Embed image */
+ if (Inkscape::Verb::getbyid( "org.ekips.filter.embedselectedimages" )) {
+ mi = Gtk::manage(new Gtk::MenuItem(C_("Context menu", "Embed Image")));
+ mi->signal_activate().connect(sigc::mem_fun(*this, &ContextMenu::ImageEmbed));
+ mi->show();
+ insert(*mi,positionOfLastDialog++);
+ if ( (!href) || ((strncmp(href, "data:", 5) == 0)) ) {
+ mi->set_sensitive( FALSE );
+ }
+ }
+
+ /* Extract image */
+ if (Inkscape::Verb::getbyid( "org.ekips.filter.extractimage" )) {
+ mi = Gtk::manage(new Gtk::MenuItem(C_("Context menu", "Extract Image...")));
+ mi->signal_activate().connect(sigc::mem_fun(*this, &ContextMenu::ImageExtract));
+ mi->show();
+ insert(*mi,positionOfLastDialog++);
+ if ( (!href) || ((strncmp(href, "data:", 5) != 0)) ) {
+ mi->set_sensitive( FALSE );
+ }
+ }
+}
+
+void ContextMenu::ImageProperties(void)
+{
+ _desktop->_dlg_mgr->showDialog("ObjectAttributes");
+}
+
+Glib::ustring ContextMenu::getImageEditorName() {
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ Glib::ustring value;
+ Glib::ustring choices = prefs->getString("/options/bitmapeditor/value");
+ if (!choices.empty()) {
+ value = choices;
+ }
+ else {
+ value = "gimp";
+ }
+ return value;
+}
+
+void ContextMenu::ImageEdit(void)
+{
+ if (_desktop->selection->isEmpty()) {
+ _desktop->selection->set(_item);
+ }
+
+ GError* errThing = 0;
+ Glib::ustring cmdline = getImageEditorName();
+ Glib::ustring name;
+ Glib::ustring fullname;
+
+#ifdef WIN32
+ // g_spawn_command_line_sync parsing is done according to Unix shell rules,
+ // not Windows command interpreter rules. Thus we need to enclose the
+ // executable path with single quotes.
+ int index = cmdline.find(".exe");
+ if ( index < 0 ) index = cmdline.find(".bat");
+ if ( index < 0 ) index = cmdline.find(".com");
+ if ( index >= 0 ) {
+ Glib::ustring editorBin = cmdline.substr(0, index + 4).c_str();
+ Glib::ustring args = cmdline.substr(index + 4, cmdline.length()).c_str();
+ editorBin.insert(0, "'");
+ editorBin.append("'");
+ cmdline = editorBin;
+ cmdline.append(args);
+ } else {
+ // Enclose the whole command line if no executable path can be extracted.
+ cmdline.insert(0, "'");
+ cmdline.append("'");
+ }
+#endif
+
+ auto itemlist= _desktop->selection->items();
+ for(auto i=itemlist.begin();i!=itemlist.end();++i){
+ Inkscape::XML::Node *ir = (*i)->getRepr();
+ const gchar *href = ir->attribute("xlink:href");
+
+ if (strncmp (href,"file:",5) == 0) {
+ // URI to filename conversion
+ name = g_filename_from_uri(href, NULL, NULL);
+ } else {
+ name.append(href);
+ }
+
+ if (Glib::path_is_absolute(name)) {
+ fullname = name;
+ } else if (SP_ACTIVE_DOCUMENT->getBase()) {
+ fullname = Glib::build_filename(SP_ACTIVE_DOCUMENT->getBase(), name);
+ } else {
+ fullname = Glib::build_filename(Glib::get_current_dir(), name);
+ }
+
+ cmdline.append(" '");
+ cmdline.append(fullname.c_str());
+ cmdline.append("'");
+ }
+
+ //g_warning("##Command line: %s\n", cmdline.c_str());
+
+ g_spawn_command_line_async(cmdline.c_str(), &errThing);
+
+ if ( errThing ) {
+ g_warning("Problem launching editor (%d). %s", errThing->code, errThing->message);
+ (_desktop->messageStack())->flash(Inkscape::ERROR_MESSAGE, errThing->message);
+ g_error_free(errThing);
+ errThing = 0;
+ }
+}
+
+void ContextMenu::ImageTraceBitmap(void)
+{
+ INKSCAPE.dialogs_unhide();
+ _desktop->_dlg_mgr->showDialog("Trace");
+}
+
+void ContextMenu::ImageTracePixelArt(void)
+{
+ INKSCAPE.dialogs_unhide();
+ _desktop->_dlg_mgr->showDialog("PixelArt");
+}
+
+void ContextMenu::ImageEmbed(void)
+{
+ if (_desktop->selection->isEmpty()) {
+ _desktop->selection->set(_item);
+ }
+
+ Inkscape::Verb *verb = Inkscape::Verb::getbyid( "org.ekips.filter.embedselectedimages" );
+ if (verb) {
+ SPAction *action = verb->get_action(Inkscape::ActionContext(_desktop));
+ if (action) {
+ sp_action_perform(action, NULL);
+ }
+ }
+}
+
+void ContextMenu::ImageExtract(void)
+{
+ if (_desktop->selection->isEmpty()) {
+ _desktop->selection->set(_item);
+ }
+
+ Inkscape::Verb *verb = Inkscape::Verb::getbyid( "org.ekips.filter.extractimage" );
+ if (verb) {
+ SPAction *action = verb->get_action(Inkscape::ActionContext(_desktop));
+ if (action) {
+ sp_action_perform(action, NULL);
+ }
+ }
+}
+
+void ContextMenu::MakeShapeMenu (void)
+{
+ Gtk::MenuItem* mi;
+
+ /* Item dialog */
+ mi = Gtk::manage(new Gtk::MenuItem(_("_Fill and Stroke..."), 1));
+ mi->signal_activate().connect(sigc::mem_fun(*this, &ContextMenu::FillSettings));
+ mi->show();
+ insert(*mi,positionOfLastDialog++);
+}
+
+void ContextMenu::FillSettings(void)
+{
+ if (_desktop->selection->isEmpty()) {
+ _desktop->selection->set(_item);
+ }
+
+ _desktop->_dlg_mgr->showDialog("FillAndStroke");
+}
+
+void ContextMenu::MakeTextMenu (void)
+{
+ Gtk::MenuItem* mi;
+
+ /* Fill and Stroke dialog */
+ mi = Gtk::manage(new Gtk::MenuItem(_("_Fill and Stroke..."), 1));
+ mi->signal_activate().connect(sigc::mem_fun(*this, &ContextMenu::FillSettings));
+ mi->show();
+ insert(*mi,positionOfLastDialog++);
+
+ /* Edit Text dialog */
+ mi = Gtk::manage(new Gtk::MenuItem(_("_Text and Font..."), 1));
+ mi->signal_activate().connect(sigc::mem_fun(*this, &ContextMenu::TextSettings));
+ mi->show();
+ insert(*mi,positionOfLastDialog++);
+
+ /* Spellcheck dialog */
+ mi = Gtk::manage(new Gtk::MenuItem(_("Check Spellin_g..."), 1));
+ mi->signal_activate().connect(sigc::mem_fun(*this, &ContextMenu::SpellcheckSettings));
+ mi->show();
+ insert(*mi,positionOfLastDialog++);
+}
+
+void ContextMenu::TextSettings (void)
+{
+ if (_desktop->selection->isEmpty()) {
+ _desktop->selection->set(_item);
+ }
+
+ _desktop->_dlg_mgr->showDialog("TextFont");
+}
+
+void ContextMenu::SpellcheckSettings (void)
+{
+ if (_desktop->selection->isEmpty()) {
+ _desktop->selection->set(_item);
+ }
+
+ _desktop->_dlg_mgr->showDialog("SpellCheck");
+}
+/*
+ Local Variables:
+ mode:c++
+ c-file-style:"stroustrup"
+ c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
+ indent-tabs-mode:nil
+ fill-column:99
+ End:
+*/
+// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :
diff --git a/src/ui/contextmenu.h b/src/ui/contextmenu.h
new file mode 100644
index 000000000..faae6358f
--- /dev/null
+++ b/src/ui/contextmenu.h
@@ -0,0 +1,218 @@
+#ifndef SEEN_CONTEXTMENU_H
+#define SEEN_CONTEXTMENU_H
+
+/*
+ * Context menu
+ *
+ * Authors:
+ * Lauris Kaplinski <lauris@kaplinski.com>
+ * Frank Felfe <innerspace@iname.com>
+ * Abhishek Sharma
+ * Kris De Gussem <Kris.DeGussem@gmail.com>
+ *
+ * Copyright (C) 2012 Kris De Gussem
+ * Copyright (C) 1999-2002 authors
+ * Copyright (C) 2001-2002 Ximian, Inc.
+ *
+ * Released under GNU GPL, read the file 'COPYING' for more information
+ */
+
+#include <gtkmm/menu.h>
+
+class SPDesktop;
+class SPItem;
+class SPObject;
+
+namespace Gtk {
+class SeparatorMenuItem;
+}
+
+namespace Inkscape {
+class Verb;
+}
+
+/**
+ * Implements the Inkscape context menu.
+ *
+ * For the context menu implementation, the ContextMenu class stores the object
+ * that was selected in a private data member. This should be farely safe to do
+ * and a pointer to the SPItem as well as SPObject class are kept.
+ * All callbacks of the context menu entries are implemented as private
+ * functions.
+ *
+ * @todo add callbacks to destroy the context menu when it is closed (=key or mouse button pressed out of the scope of the context menu)
+ */
+class ContextMenu : public Gtk::Menu
+{
+ public:
+ /**
+ * The ContextMenu constructor contains all code to create and show the
+ * menu entries (aka child widgets).
+ *
+ * @param desktop pointer to the desktop the user is currently working on.
+ * @param item SPItem pointer to the object selected at the time the ContextMenu is created.
+ */
+ ContextMenu(SPDesktop *desktop, SPItem *item);
+ ~ContextMenu(void);
+
+ private:
+ SPItem *_item; // pointer to the object selected at the time the ContextMenu is created
+ SPObject *_object; // pointer to the object selected at the time the ContextMenu is created
+ SPDesktop *_desktop; //pointer to the desktop the user was currently working on at the time the ContextMenu is created
+
+ int positionOfLastDialog;
+
+ Gtk::MenuItem MIGroup; //menu entry to enter a group
+ Gtk::MenuItem MIParent; //menu entry to leave a group
+
+ /**
+ * auxiliary function that adds a separator line in the context menu
+ */
+ Gtk::SeparatorMenuItem* AddSeparator(void);
+
+ /**
+ * c++ified version of sp_ui_menu_append_item.
+ *
+ * @see sp_ui_menu_append_item_from_verb and synchronize/drop that function when c++ifying other code in interface.cpp
+ */
+ void AppendItemFromVerb(Inkscape::Verb *verb);
+
+ /**
+ * main function which is responsible for creating the context sensitive menu items,
+ * calls subfunctions below to create the menu entry widgets.
+ */
+ void MakeObjectMenu (void);
+ /**
+ * creates menu entries for an SP_TYPE_ITEM object
+ */
+ void MakeItemMenu (void);
+ /**
+ * creates menu entries for a grouped object
+ */
+ void MakeGroupMenu (void);
+ /**
+ * creates menu entries for an anchor object
+ */
+ void MakeAnchorMenu (void);
+ /**
+ * creates menu entries for a bitmap image object
+ */
+ void MakeImageMenu (void);
+ /**
+ * creates menu entries for a shape object
+ */
+ void MakeShapeMenu (void);
+ /**
+ * creates menu entries for a text object
+ */
+ void MakeTextMenu (void);
+
+ void EnterGroup(Gtk::MenuItem* mi);
+ void LeaveGroup(void);
+ void LockSelected(void);
+ void HideSelected(void);
+ void UnLockBelow(std::vector<SPItem *> items);
+ void UnHideBelow(std::vector<SPItem *> items);
+ //////////////////////////////////////////
+ //callbacks for the context menu entries of an SP_TYPE_ITEM object
+ void ItemProperties(void);
+ void ItemSelectThis(void);
+ void ItemMoveTo(void);
+ void SelectSameFillStroke(void);
+ void SelectSameFillColor(void);
+ void SelectSameStrokeColor(void);
+ void SelectSameStrokeStyle(void);
+ void SelectSameObjectType(void);
+ void ItemCreateLink(void);
+ void CreateGroupClip(void);
+ void SetMask(void);
+ void ReleaseMask(void);
+ void SetClip(void);
+ void ReleaseClip(void);
+ //////////////////////////////////////////
+
+
+ /**
+ * callback, is executed on clicking the anchor "Group" and "Ungroup" menu entry
+ */
+ void ActivateUngroupPopSelection(void);
+ void ActivateUngroup(void);
+ void ActivateGroup(void);
+
+ void AnchorLinkProperties(void);
+ /**
+ * placeholder for callback to be executed on clicking the anchor "Follow link" context menu entry
+ * @todo add code to follow link externally
+ */
+ void AnchorLinkFollow(void);
+
+ /**
+ * callback, is executed on clicking the anchor "Link remove" menu entry
+ */
+ void AnchorLinkRemove(void);
+
+
+ /**
+ * callback, opens the image properties dialog and is executed on clicking the context menu entry with similar name
+ */
+ void ImageProperties(void);
+
+ /**
+ * callback, is executed on clicking the image "Edit Externally" menu entry
+ */
+ void ImageEdit(void);
+
+ /**
+ * auxiliary function that loads the external image editor name from the settings.
+ */
+ Glib::ustring getImageEditorName();
+
+ /**
+ * callback, is executed on clicking the "Embed Image" menu entry
+ */
+ void ImageEmbed(void);
+
+ /**
+ * callback, is executed on clicking the "Trace Bitmap" menu entry
+ */
+ void ImageTraceBitmap(void);
+
+ /**
+ * callback, is executed on clicking the "Trace Pixel Art" menu entry
+ */
+ void ImageTracePixelArt(void);
+
+ /**
+ * callback, is executed on clicking the "Extract Image" menu entry
+ */
+ void ImageExtract(void);
+
+
+ /**
+ * callback, is executed on clicking the "Fill and Stroke" menu entry
+ */
+ void FillSettings(void);
+
+
+ /**
+ * callback, is executed on clicking the "Text and Font" menu entry
+ */
+ void TextSettings(void);
+
+ /**
+ * callback, is executed on clicking the "Check spelling" menu entry
+ */
+ void SpellcheckSettings(void);
+};
+#endif // SEEN_CONTEXT_MENU_H
+
+/*
+ Local Variables:
+ mode:c++
+ c-file-style:"stroustrup"
+ c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
+ indent-tabs-mode:nil
+ fill-column:99
+ End:
+*/
+// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :
diff --git a/src/ui/dialog/aboutbox.cpp b/src/ui/dialog/aboutbox.cpp
index 805bfb562..9b99dde6b 100644
--- a/src/ui/dialog/aboutbox.cpp
+++ b/src/ui/dialog/aboutbox.cpp
@@ -107,8 +107,21 @@ AboutBox::AboutBox() : Gtk::Dialog(_("About Inkscape")) {
g_strdup_printf("<small>Inkscape %s</small>",
Inkscape::version_string);
label->set_markup(label_text);
+
+#if WITH_GTKMM_3_10
+ label->set_halign(Gtk::ALIGN_END);
+ label->set_valign(Gtk::ALIGN_CENTER);
+#else
label->set_alignment(Gtk::ALIGN_END, Gtk::ALIGN_CENTER);
+#endif
+
+#if WITH_GTKMM_3_12
+ label->set_margin_start(5);
+ label->set_margin_end(5);
+#else
label->set_padding(5,0);
+#endif
+
g_free(label_text);
label->set_selectable(true);
label->show();
@@ -118,8 +131,22 @@ AboutBox::AboutBox() : Gtk::Dialog(_("About Inkscape")) {
"<a href=\"https://www.inkscape.org\">https://www.inkscape.org</a>";
link->set_markup(website_link);
+
+#if WITH_GTKMM_3_10
+ link->set_halign(Gtk::ALIGN_END);
+#else
link->set_alignment(Gtk::ALIGN_END);
+#endif
+
+#if WITH_GTKMM_3_12
+ label->set_margin_start(5);
+ label->set_margin_end(5);
+ label->set_margin_top(5);
+ label->set_margin_bottom(5);
+#else
link->set_padding(5,5);
+#endif
+
link->set_selectable(true);
link->show();
diff --git a/src/ui/dialog/align-and-distribute.cpp b/src/ui/dialog/align-and-distribute.cpp
index 1c88fc849..27bfa681f 100644
--- a/src/ui/dialog/align-and-distribute.cpp
+++ b/src/ui/dialog/align-and-distribute.cpp
@@ -41,7 +41,6 @@
#include "ui/tool/multi-path-manipulator.h"
#include "ui/tool/control-point-selection.h"
#include "verbs.h"
-#include "widgets/icon.h"
#include "sp-root.h"
#include "document-undo.h"
#include "desktop.h"
@@ -64,7 +63,8 @@ Action::Action(const Glib::ustring &id,
_id(id),
_parent(parent)
{
- Gtk::Widget* pIcon = Gtk::manage( sp_icon_get_icon( _id, Inkscape::ICON_SIZE_LARGE_TOOLBAR) );
+ Gtk::Image* pIcon = Gtk::manage(new Gtk::Image());
+ pIcon->set_from_icon_name( _id, Gtk::ICON_SIZE_LARGE_TOOLBAR);
Gtk::Button * pButton = Gtk::manage(new Gtk::Button());
pButton->set_relief(Gtk::RELIEF_NONE);
pIcon->show();
diff --git a/src/ui/dialog/clonetiler.cpp b/src/ui/dialog/clonetiler.cpp
index 3cdcf594a..cef3c0c71 100644
--- a/src/ui/dialog/clonetiler.cpp
+++ b/src/ui/dialog/clonetiler.cpp
@@ -49,7 +49,6 @@
#include "ui/widget/spinbutton.h"
#include "unclump.h"
#include "verbs.h"
-#include "widgets/icon.h"
using Inkscape::DocumentUndo;
using Inkscape::Util::unit_table;
@@ -2678,7 +2677,7 @@ GtkWidget * CloneTiler::table_x_y_rand(int values)
auto hb = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0);
gtk_box_set_homogeneous(GTK_BOX(hb), FALSE);
- GtkWidget *i = sp_icon_new (Inkscape::ICON_SIZE_DECORATION, INKSCAPE_ICON("object-rows"));
+ GtkWidget *i = gtk_image_new_from_icon_name (INKSCAPE_ICON("object-rows"), GTK_ICON_SIZE_MENU);
gtk_box_pack_start (GTK_BOX (hb), i, FALSE, FALSE, 2);
GtkWidget *l = gtk_label_new ("");
@@ -2692,7 +2691,7 @@ GtkWidget * CloneTiler::table_x_y_rand(int values)
auto hb = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0);
gtk_box_set_homogeneous(GTK_BOX(hb), FALSE);
- GtkWidget *i = sp_icon_new (Inkscape::ICON_SIZE_DECORATION, INKSCAPE_ICON("object-columns"));
+ GtkWidget *i = gtk_image_new_from_icon_name (INKSCAPE_ICON("object-columns"), GTK_ICON_SIZE_MENU);
gtk_box_pack_start (GTK_BOX (hb), i, FALSE, FALSE, 2);
GtkWidget *l = gtk_label_new ("");
diff --git a/src/ui/dialog/cssdialog.cpp b/src/ui/dialog/cssdialog.cpp
index 85c804b75..0443d7c44 100644
--- a/src/ui/dialog/cssdialog.cpp
+++ b/src/ui/dialog/cssdialog.cpp
@@ -13,7 +13,6 @@
#include "cssdialog.h"
#include "ui/widget/addtoicon.h"
-#include "widgets/icon.h"
#include "verbs.h"
#include "sp-object.h"
#include "selection.h"
@@ -122,7 +121,7 @@ void CssDialog::setDesktop(SPDesktop* desktop)
void CssDialog::_styleButton(Gtk::Button& btn, char const* iconName,
char const* tooltip)
{
- GtkWidget *child = sp_icon_new(Inkscape::ICON_SIZE_SMALL_TOOLBAR, iconName);
+ GtkWidget *child = gtk_image_new_from_icon_name(iconName, GTK_ICON_SIZE_SMALL_TOOLBAR);
gtk_widget_show(child);
btn.add(*manage(Glib::wrap(child)));
btn.set_relief(Gtk::RELIEF_NONE);
diff --git a/src/ui/dialog/dialog-manager.cpp b/src/ui/dialog/dialog-manager.cpp
index 01cd9dd0f..c5392864d 100644
--- a/src/ui/dialog/dialog-manager.cpp
+++ b/src/ui/dialog/dialog-manager.cpp
@@ -26,6 +26,7 @@
#include "ui/dialog/extension-editor.h"
#include "ui/dialog/fill-and-stroke.h"
#include "ui/dialog/filter-effects-dialog.h"
+#include "ui/dialog/filter-editor.h"
#include "ui/dialog/find.h"
#include "ui/dialog/glyphs.h"
#include "ui/dialog/inkscape-preferences.h"
@@ -113,6 +114,7 @@ DialogManager::DialogManager() {
registerFactory("ExtensionEditor", &create<ExtensionEditor, FloatingBehavior>);
registerFactory("FillAndStroke", &create<FillAndStroke, FloatingBehavior>);
registerFactory("FilterEffectsDialog", &create<FilterEffectsDialog, FloatingBehavior>);
+ registerFactory("FilterEditorDialog", &create<FilterEditorDialog, FloatingBehavior>);
registerFactory("Find", &create<Find, FloatingBehavior>);
registerFactory("Glyphs", &create<GlyphsPanel, FloatingBehavior>);
registerFactory("IconPreviewPanel", &create<IconPreviewPanel, FloatingBehavior>);
@@ -155,6 +157,7 @@ DialogManager::DialogManager() {
registerFactory("ExtensionEditor", &create<ExtensionEditor, DockBehavior>);
registerFactory("FillAndStroke", &create<FillAndStroke, DockBehavior>);
registerFactory("FilterEffectsDialog", &create<FilterEffectsDialog, DockBehavior>);
+ registerFactory("FilterEditorDialog", &create<FilterEditorDialog, DockBehavior>);
registerFactory("Find", &create<Find, DockBehavior>);
registerFactory("Glyphs", &create<GlyphsPanel, DockBehavior>);
registerFactory("IconPreviewPanel", &create<IconPreviewPanel, DockBehavior>);
diff --git a/src/ui/dialog/dialog.cpp b/src/ui/dialog/dialog.cpp
index 27a6e55d9..39c913175 100644
--- a/src/ui/dialog/dialog.cpp
+++ b/src/ui/dialog/dialog.cpp
@@ -19,6 +19,11 @@
#include "dialog-manager.h"
#include <gtkmm/dialog.h>
+
+#if WITH_GTKMM_3_22
+# include <gdkmm/monitor.h>
+#endif
+
#include <gdk/gdkkeysyms.h>
#include "inkscape.h"
@@ -161,10 +166,23 @@ void Dialog::read_geometry()
resize(w, h);
}
+#if WITH_GTKMM_3_22
+ auto const display = Gdk::Display::get_default();
+ auto const monitor = display->get_primary_monitor();
+
+ Gdk::Rectangle screen_geometry;
+ monitor->get_geometry(screen_geometry);
+ auto const screen_width = screen_geometry.get_width();
+ auto const screen_height = screen_geometry.get_height();
+#else
+ auto const screen_width = gdk_screen_width();
+ auto const screen_height = gdk_screen_width();
+#endif
+
// If there are stored values for where the dialog should be
// located, then restore the dialog to that position.
// also check if (x,y) is actually onscreen with the current screen dimensions
- if ( (x >= 0) && (y >= 0) && (x < (gdk_screen_width()-MIN_ONSCREEN_DISTANCE)) && (y < (gdk_screen_height()-MIN_ONSCREEN_DISTANCE)) ) {
+ if ( (x >= 0) && (y >= 0) && (x < (screen_width-MIN_ONSCREEN_DISTANCE)) && (y < (screen_height-MIN_ONSCREEN_DISTANCE)) ) {
move(x, y);
} else {
// ...otherwise just put it in the middle of the screen
diff --git a/src/ui/dialog/dock-behavior.cpp b/src/ui/dialog/dock-behavior.cpp
index 02955b9a8..0c8bb3194 100644
--- a/src/ui/dialog/dock-behavior.cpp
+++ b/src/ui/dialog/dock-behavior.cpp
@@ -19,7 +19,6 @@
#include "inkscape.h"
#include "desktop.h"
#include "ui/interface.h"
-#include "widgets/icon.h"
#include "ui/widget/dock.h"
#include "verbs.h"
#include "dialog.h"
@@ -40,9 +39,9 @@ DockBehavior::DockBehavior(Dialog &dialog) :
static_cast<Widget::DockItem::State>(
Inkscape::Preferences::get()->getInt(_dialog._prefs_path + "/state",
UI::Widget::DockItem::DOCKED_STATE)),
- static_cast<Widget::DockItem::Placement>(
+ static_cast<GdlDockPlacement>(
Inkscape::Preferences::get()->getInt(_dialog._prefs_path + "/placement",
- UI::Widget::DockItem::TOP)))
+ GDL_DOCK_TOP)))
{
// Connect signals
diff --git a/src/ui/dialog/document-properties.cpp b/src/ui/dialog/document-properties.cpp
index 8593223c1..1b074bb0c 100644
--- a/src/ui/dialog/document-properties.cpp
+++ b/src/ui/dialog/document-properties.cpp
@@ -34,7 +34,6 @@
#include "ui/tools-switch.h"
#include "ui/dialog/filedialog.h"
#include "verbs.h"
-#include "widgets/icon.h"
#include "xml/node-event-vector.h"
#include "rdf.h"
@@ -74,7 +73,7 @@ static Inkscape::XML::NodeEventVector const _repr_events = {
static void docprops_style_button(Gtk::Button& btn, char const* iconName)
{
- GtkWidget *child = sp_icon_new(Inkscape::ICON_SIZE_SMALL_TOOLBAR, iconName);
+ GtkWidget *child = gtk_image_new_from_icon_name(iconName, GTK_ICON_SIZE_SMALL_TOOLBAR);
gtk_widget_show( child );
btn.add(*Gtk::manage(Glib::wrap(child)));
btn.set_relief(Gtk::RELIEF_NONE);
@@ -1429,8 +1428,10 @@ DocumentProperties::_createPageTabLabel(const Glib::ustring& label, const char *
{
Gtk::HBox *_tab_label_box = Gtk::manage(new Gtk::HBox(false, 0));
_tab_label_box->set_spacing(4);
- _tab_label_box->pack_start(*Glib::wrap(sp_icon_new(Inkscape::ICON_SIZE_DECORATION,
- label_image)));
+
+ auto img = Gtk::manage(new Gtk::Image());
+ img->set_from_icon_name(label_image, Gtk::ICON_SIZE_MENU);
+ _tab_label_box->pack_start(*img);
Gtk::Label *_tab_label = Gtk::manage(new Gtk::Label(label, true));
_tab_label_box->pack_start(*_tab_label);
diff --git a/src/ui/dialog/export.cpp b/src/ui/dialog/export.cpp
index 1bb952de4..b1b1cc291 100644
--- a/src/ui/dialog/export.cpp
+++ b/src/ui/dialog/export.cpp
@@ -54,6 +54,7 @@
#include "extension/db.h"
#include "io/sys.h"
+#include "io/resource.h"
#include "helper/png-write.h"
@@ -564,7 +565,7 @@ Glib::ustring Export::create_filepath_from_id (Glib::ustring id, const Glib::ust
}
if (directory.empty()) {
- directory = INKSCAPE.homedir_path(NULL);
+ directory = Inkscape::IO::Resource::homedir_path(NULL);
}
Glib::ustring filename = Glib::build_filename(directory, id+".png");
diff --git a/src/ui/dialog/filedialogimpl-gtkmm.cpp b/src/ui/dialog/filedialogimpl-gtkmm.cpp
index 92e9ce834..b69e9ce97 100644
--- a/src/ui/dialog/filedialogimpl-gtkmm.cpp
+++ b/src/ui/dialog/filedialogimpl-gtkmm.cpp
@@ -27,6 +27,7 @@
#include "ui/dialog-events.h"
#include "ui/interface.h"
#include "io/sys.h"
+#include "io/resource.h"
#include "path-prefix.h"
#include "preferences.h"
@@ -1038,13 +1039,12 @@ FileSaveDialogImplGtk::FileSaveDialogImplGtk(Gtk::Window &parentWindow, const Gl
}
// allow easy access to the user's own templates folder
- gchar *templates = Inkscape::Application::profile_path("templates");
+ using namespace Inkscape::IO::Resource;
+ char const *templates = Inkscape::IO::Resource::get_path(USER, TEMPLATES);
if (Inkscape::IO::file_test(templates, G_FILE_TEST_EXISTS) &&
Inkscape::IO::file_test(templates, G_FILE_TEST_IS_DIR) && g_path_is_absolute(templates)) {
add_shortcut_folder(templates);
}
- g_free(templates);
-
// if (extension == NULL)
// checkbox.set_sensitive(FALSE);
diff --git a/src/ui/dialog/fill-and-stroke.cpp b/src/ui/dialog/fill-and-stroke.cpp
index 0b3b468e9..b271c951b 100644
--- a/src/ui/dialog/fill-and-stroke.cpp
+++ b/src/ui/dialog/fill-and-stroke.cpp
@@ -28,7 +28,6 @@
#include "ui/icon-names.h"
#include "verbs.h"
#include "widgets/fill-style.h"
-#include "widgets/icon.h"
#include "widgets/paint-selector.h"
#include "widgets/stroke-style.h"
@@ -173,8 +172,10 @@ Gtk::HBox&
FillAndStroke::_createPageTabLabel(const Glib::ustring& label, const char *label_image)
{
Gtk::HBox *_tab_label_box = Gtk::manage(new Gtk::HBox(false, 4));
- _tab_label_box->pack_start(*Glib::wrap(sp_icon_new(Inkscape::ICON_SIZE_DECORATION,
- label_image)));
+
+ auto img = Gtk::manage(new Gtk::Image());
+ img->set_from_icon_name(label_image, Gtk::ICON_SIZE_MENU);
+ _tab_label_box->pack_start(*img);
Gtk::Label *_tab_label = Gtk::manage(new Gtk::Label(label, true));
_tab_label_box->pack_start(*_tab_label);
diff --git a/src/ui/dialog/filter-editor.cpp b/src/ui/dialog/filter-editor.cpp
new file mode 100644
index 000000000..730f8175c
--- /dev/null
+++ b/src/ui/dialog/filter-editor.cpp
@@ -0,0 +1,128 @@
+/**
+ * @file
+ * Filter Effects dialog.
+ */
+/* Authors:
+ * Marc Jeanmougin
+ *
+ * Copyright (C) 2017 Authors
+ *
+ * Released under GNU GPL. Read the file 'COPYING' for more information.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "dialog-manager.h"
+
+#include <gdkmm/display.h>
+#if GTK_CHECK_VERSION(3, 20, 0)
+# include <gdkmm/seat.h>
+#else
+# include <gdkmm/devicemanager.h>
+#endif
+
+#include "ui/widget/spinbutton.h"
+
+#include <glibmm/i18n.h>
+#include <glibmm/stringutils.h>
+#include <glibmm/main.h>
+#include <glibmm/convert.h>
+#include <glibmm/error.h>
+
+#include "desktop.h"
+
+#include "document.h"
+#include "document-undo.h"
+#include "filter-chemistry.h"
+#include "filter-editor.h"
+#include "filter-enums.h"
+#include "inkscape.h"
+#include "filters/blend.h"
+#include "filters/colormatrix.h"
+#include "filters/componenttransfer.h"
+#include "filters/componenttransfer-funcnode.h"
+#include "filters/convolvematrix.h"
+#include "filters/distantlight.h"
+#include "filters/merge.h"
+#include "filters/mergenode.h"
+#include "filters/pointlight.h"
+#include "filters/spotlight.h"
+
+#include "style.h"
+#include "svg/svg-color.h"
+#include "ui/dialog/filedialog.h"
+#include "verbs.h"
+
+#include "io/sys.h"
+#include "io/resource.h"
+#include "selection-chemistry.h"
+
+#include <string>
+
+#include <gtkmm.h>
+
+using namespace Inkscape::Filters;
+using namespace Inkscape::IO::Resource;
+namespace Inkscape {
+namespace UI {
+namespace Dialog {
+
+FilterEditorDialog::FilterEditorDialog() : UI::Widget::Panel("", "/dialogs/filtereffects", SP_VERB_DIALOG_FILTER_EFFECTS)
+{
+
+ const std::string req_widgets[] = {"FilterEditor", "FilterList", "FilterFERX", "FilterFERY", "FilterFERH", "FilterFERW", "FilterPreview", "FilterPrimitiveDescImage", "FilterPrimitiveList", "FilterPrimitiveDescText", "FilterPrimitiveAdd"};
+ Glib::ustring gladefile = get_filename(UIS, "filter-editor.glade");
+ try {
+ builder = Gtk::Builder::create_from_file(gladefile);
+ } catch(const Glib::Error& ex) {
+ g_warning("Glade file loading failed for filter effect dialog");
+ return;
+ }
+
+ Gtk::Object* test;
+ for(std::string w:req_widgets) {
+ builder->get_widget(w,test);
+ if(!test){
+ g_warning("Required widget %s does not exist", w);
+ return;
+ }
+ }
+
+ builder->get_widget("FilterEditor", FilterEditor);
+ _getContents()->add(*FilterEditor);
+
+//test
+ Gtk::ComboBox *OptionList;
+ builder->get_widget("OptionList",OptionList);
+ FilterStore = builder->get_object("FilterStore");
+ Glib::RefPtr<Gtk::ListStore> fs = Glib::RefPtr<Gtk::ListStore>::cast_static(FilterStore);
+ Gtk::TreeModel::Row row = *(fs->append());
+
+
+
+
+
+}
+FilterEditorDialog::~FilterEditorDialog(){}
+
+
+
+
+
+
+} // Never put these namespaces together unless you are using gcc 6+
+}
+} // P.S. This is for Inkscape::UI::Dialog
+
+/*
+ Local Variables:
+ mode:c++
+ c-file-style:"stroustrup"
+ c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
+ indent-tabs-mode:nil
+ fill-column:99
+ End:
+*/
+// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :
diff --git a/src/ui/dialog/filter-editor.h b/src/ui/dialog/filter-editor.h
new file mode 100644
index 000000000..6acb83f02
--- /dev/null
+++ b/src/ui/dialog/filter-editor.h
@@ -0,0 +1,53 @@
+/** @file
+ * @brief Filter Editor dialog
+ */
+/* Authors:
+ * Marc Jeanmougin
+ *
+ * Copyright (C) 2017 Authors
+ *
+ * Released under GNU GPL. Read the file 'COPYING' for more information.
+ */
+
+#ifndef INKSCAPE_UI_DIALOG_FILTER_EDITOR_H
+#define INKSCAPE_UI_DIALOG_FILTER_EDITOR_H
+
+#include "attributes.h"
+#include "ui/widget/panel.h"
+#include "sp-filter.h"
+
+#include <gtkmm/notebook.h>
+#include <gtkmm/sizegroup.h>
+#include <gtkmm/builder.h>
+#include <gtkmm/comboboxtext.h>
+#include <gtkmm/combobox.h>
+#include <gtkmm/drawingarea.h>
+#include <gtkmm/liststore.h>
+
+#include <gtkmm/paned.h>
+#include <gtkmm/scrolledwindow.h>
+#include <gtkmm/treeview.h>
+
+namespace Inkscape {
+namespace UI {
+namespace Dialog {
+
+class FilterEditorDialog : public UI::Widget::Panel {
+public:
+
+ FilterEditorDialog();
+ ~FilterEditorDialog();
+
+ static FilterEditorDialog &getInstance()
+ { return *new FilterEditorDialog(); }
+
+// void set_attrs_locked(const bool);
+private:
+ Glib::RefPtr<Gtk::Builder> builder;
+ Glib::RefPtr<Glib::Object> FilterStore;
+ Gtk::Box *FilterEditor;
+};
+}
+}
+}
+#endif
diff --git a/src/ui/dialog/filter-effects-dialog.h b/src/ui/dialog/filter-effects-dialog.h
index 32fabb741..e410a88f9 100644
--- a/src/ui/dialog/filter-effects-dialog.h
+++ b/src/ui/dialog/filter-effects-dialog.h
@@ -132,11 +132,7 @@ private:
Gtk::Button _add;
Glib::RefPtr<Gtk::Menu> _menu;
sigc::signal<void> _signal_filter_changed;
-#if __cplusplus <= 199711L
- std::auto_ptr<Inkscape::XML::SignalObserver> _observer;
-#else
std::unique_ptr<Inkscape::XML::SignalObserver> _observer;
-#endif
};
class PrimitiveColumns : public Gtk::TreeModel::ColumnRecord
@@ -244,11 +240,7 @@ private:
sigc::connection _scroll_connection;
int _autoscroll_y;
int _autoscroll_x;
-#if __cplusplus <= 199711L
- std::auto_ptr<Inkscape::XML::SignalObserver> _observer;
-#else
std::unique_ptr<Inkscape::XML::SignalObserver> _observer;
-#endif
int _input_type_width;
int _input_type_height;
};
diff --git a/src/ui/dialog/grid-arrange-tab.cpp b/src/ui/dialog/grid-arrange-tab.cpp
index 9ec8d3148..bb8fc564a 100644
--- a/src/ui/dialog/grid-arrange-tab.cpp
+++ b/src/ui/dialog/grid-arrange-tab.cpp
@@ -28,7 +28,6 @@
#include "document.h"
#include "document-undo.h"
-#include "widgets/icon.h"
#include "desktop.h"
//#include "sp-item-transform.h" FIXME
#include "ui/dialog/tile.h" // for Inkscape::UI::Dialog::ArrangeDialog
@@ -611,6 +610,7 @@ GridArrangeTab::GridArrangeTab(ArrangeDialog *parent)
NoOfRowsLabel.set_text_with_mnemonic(_("_Rows:"));
NoOfRowsLabel.set_mnemonic_widget(NoOfRowsSpinner);
+ NoOfRowsBox.set_orientation(Gtk::ORIENTATION_VERTICAL);
NoOfRowsBox.pack_start(NoOfRowsLabel, false, false, MARGIN);
NoOfRowsSpinner.set_digits(0);
@@ -641,6 +641,7 @@ GridArrangeTab::GridArrangeTab(ArrangeDialog *parent)
/*#### Label for X ####*/
padXByYLabel.set_label(" ");
+ XByYLabelVBox.set_orientation(Gtk::ORIENTATION_VERTICAL);
XByYLabelVBox.pack_start(padXByYLabel, false, false, MARGIN);
XByYLabel.set_markup(" &#215; ");
XByYLabelVBox.pack_start(XByYLabel, false, false, MARGIN);
@@ -651,6 +652,7 @@ GridArrangeTab::GridArrangeTab(ArrangeDialog *parent)
NoOfColsLabel.set_text_with_mnemonic(_("_Columns:"));
NoOfColsLabel.set_mnemonic_widget(NoOfColsSpinner);
+ NoOfColsBox.set_orientation(Gtk::ORIENTATION_VERTICAL);
NoOfColsBox.pack_start(NoOfColsLabel, false, false, MARGIN);
NoOfColsSpinner.set_digits(0);
@@ -677,6 +679,7 @@ GridArrangeTab::GridArrangeTab(ArrangeDialog *parent)
SpinsHBox.pack_start(NoOfColsBox, false, false, MARGIN);
+ TileBox.set_orientation(Gtk::ORIENTATION_VERTICAL);
TileBox.pack_start(SpinsHBox, false, false, MARGIN);
VertAlign = prefs->getInt("/dialogs/gridtiler/VertAlign", 1);
diff --git a/src/ui/dialog/grid-arrange-tab.h b/src/ui/dialog/grid-arrange-tab.h
index 891849f1a..93bc38218 100644
--- a/src/ui/dialog/grid-arrange-tab.h
+++ b/src/ui/dialog/grid-arrange-tab.h
@@ -73,7 +73,7 @@ private:
bool userHidden;
bool updating;
- Gtk::VBox TileBox;
+ Gtk::Box TileBox;
Gtk::Button *TileOkButton;
Gtk::Button *TileCancelButton;
@@ -81,22 +81,22 @@ private:
Gtk::Label SelectionContentsLabel;
- Gtk::HBox AlignHBox;
- Gtk::HBox SpinsHBox;
+ Gtk::Box AlignHBox;
+ Gtk::Box SpinsHBox;
// Number per Row
- Gtk::VBox NoOfColsBox;
+ Gtk::Box NoOfColsBox;
Gtk::Label NoOfColsLabel;
Inkscape::UI::Widget::SpinButton NoOfColsSpinner;
bool AutoRowSize;
Gtk::CheckButton RowHeightButton;
- Gtk::VBox XByYLabelVBox;
+ Gtk::Box XByYLabelVBox;
Gtk::Label padXByYLabel;
Gtk::Label XByYLabel;
// Number per Column
- Gtk::VBox NoOfRowsBox;
+ Gtk::Box NoOfRowsBox;
Gtk::Label NoOfRowsLabel;
Inkscape::UI::Widget::SpinButton NoOfRowsSpinner;
bool AutoColSize;
@@ -121,15 +121,11 @@ private:
bool ManualSpacing;
// Row height
- Gtk::VBox RowHeightVBox;
- Gtk::HBox RowHeightBox;
- Gtk::Label RowHeightLabel;
+ Gtk::Box RowHeightBox;
Inkscape::UI::Widget::SpinButton RowHeightSpinner;
// Column width
- Gtk::VBox ColumnWidthVBox;
- Gtk::HBox ColumnWidthBox;
- Gtk::Label ColumnWidthLabel;
+ Gtk::Box ColumnWidthBox;
Inkscape::UI::Widget::SpinButton ColumnWidthSpinner;
};
diff --git a/src/ui/dialog/icon-preview.cpp b/src/ui/dialog/icon-preview.cpp
index 19050fb1d..7b1e531b4 100644
--- a/src/ui/dialog/icon-preview.cpp
+++ b/src/ui/dialog/icon-preview.cpp
@@ -31,9 +31,12 @@
#include "desktop.h"
+#include "display/cairo-utils.h"
#include "display/drawing.h"
+#include "display/drawing-context.h"
#include "document.h"
#include "inkscape.h"
+#include "sp-namedview.h"
#include "sp-root.h"
#include "verbs.h"
@@ -41,7 +44,6 @@
extern "C" {
// takes doc, drawing, icon, and icon name to produce pixels
-// this is defined in widgets/icon.cpp
guchar *
sp_icon_doc_icon( SPDocument *doc, Inkscape::Drawing &drawing,
const gchar *name, unsigned int psize, unsigned &stride);
@@ -428,6 +430,190 @@ void IconPreviewPanel::modeToggled()
refreshPreview();
}
+void overlayPixels(guchar *px, int width, int height, int stride,
+ unsigned r, unsigned g, unsigned b)
+{
+ int bytesPerPixel = 4;
+ int spacing = 4;
+ for ( int y = 0; y < height; y += spacing ) {
+ guchar *ptr = px + y * stride;
+ for ( int x = 0; x < width; x += spacing ) {
+ *(ptr++) = r;
+ *(ptr++) = g;
+ *(ptr++) = b;
+ *(ptr++) = 0xff;
+
+ ptr += bytesPerPixel * (spacing - 1);
+ }
+ }
+
+ if ( width > 1 && height > 1 ) {
+ // point at the last pixel
+ guchar *ptr = px + ((height-1) * stride) + ((width - 1) * bytesPerPixel);
+
+ if ( width > 2 ) {
+ px[4] = r;
+ px[5] = g;
+ px[6] = b;
+ px[7] = 0xff;
+
+ ptr[-12] = r;
+ ptr[-11] = g;
+ ptr[-10] = b;
+ ptr[-9] = 0xff;
+ }
+
+ ptr[-4] = r;
+ ptr[-3] = g;
+ ptr[-2] = b;
+ ptr[-1] = 0xff;
+
+ px[0 + stride] = r;
+ px[1 + stride] = g;
+ px[2 + stride] = b;
+ px[3 + stride] = 0xff;
+
+ ptr[0 - stride] = r;
+ ptr[1 - stride] = g;
+ ptr[2 - stride] = b;
+ ptr[3 - stride] = 0xff;
+
+ if ( height > 2 ) {
+ ptr[0 - stride * 3] = r;
+ ptr[1 - stride * 3] = g;
+ ptr[2 - stride * 3] = b;
+ ptr[3 - stride * 3] = 0xff;
+ }
+ }
+}
+
+// takes doc, drawing, icon, and icon name to produce pixels
+extern "C" guchar *
+sp_icon_doc_icon( SPDocument *doc, Inkscape::Drawing &drawing,
+ gchar const *name, unsigned psize,
+ unsigned &stride)
+{
+ bool const dump = Inkscape::Preferences::get()->getBool("/debug/icons/dumpSvg");
+ guchar *px = NULL;
+
+ if (doc) {
+ SPObject *object = doc->getObjectById(name);
+ if (object && SP_IS_ITEM(object)) {
+ SPItem *item = SP_ITEM(object);
+ // Find bbox in document
+ Geom::OptRect dbox = item->documentVisualBounds();
+
+ if ( object->parent == NULL )
+ {
+ dbox = Geom::Rect(Geom::Point(0, 0),
+ Geom::Point(doc->getWidth().value("px"), doc->getHeight().value("px")));
+ }
+
+ /* This is in document coordinates, i.e. pixels */
+ if ( dbox ) {
+ /* Update to renderable state */
+ double sf = 1.0;
+ drawing.root()->setTransform(Geom::Scale(sf));
+ drawing.update();
+ /* Item integer bbox in points */
+ // NOTE: previously, each rect coordinate was rounded using floor(c + 0.5)
+ Geom::IntRect ibox = dbox->roundOutwards();
+
+ if ( dump ) {
+ g_message( " box --'%s' (%f,%f)-(%f,%f)", name, (double)ibox.left(), (double)ibox.top(), (double)ibox.right(), (double)ibox.bottom() );
+ }
+
+ /* Find button visible area */
+ int width = ibox.width();
+ int height = ibox.height();
+
+ if ( dump ) {
+ g_message( " vis --'%s' (%d,%d)", name, width, height );
+ }
+
+ {
+ int block = std::max(width, height);
+ if (block != static_cast<int>(psize) ) {
+ if ( dump ) {
+ g_message(" resizing" );
+ }
+ sf = (double)psize / (double)block;
+
+ drawing.root()->setTransform(Geom::Scale(sf));
+ drawing.update();
+
+ auto scaled_box = *dbox * Geom::Scale(sf);
+ ibox = scaled_box.roundOutwards();
+ if ( dump ) {
+ g_message( " box2 --'%s' (%f,%f)-(%f,%f)", name, (double)ibox.left(), (double)ibox.top(), (double)ibox.right(), (double)ibox.bottom() );
+ }
+
+ /* Find button visible area */
+ width = ibox.width();
+ height = ibox.height();
+ if ( dump ) {
+ g_message( " vis2 --'%s' (%d,%d)", name, width, height );
+ }
+ }
+ }
+
+ Geom::IntPoint pdim(psize, psize);
+ int dx, dy;
+ //dx = (psize - width) / 2;
+ //dy = (psize - height) / 2;
+ dx=dy=psize;
+ dx=(dx-width)/2; // watch out for psize, since 'unsigned'-'signed' can cause problems if the result is negative
+ dy=(dy-height)/2;
+ Geom::IntRect area = Geom::IntRect::from_xywh(ibox.min() - Geom::IntPoint(dx,dy), pdim);
+ /* Actual renderable area */
+ Geom::IntRect ua = *Geom::intersect(ibox, area);
+
+ if ( dump ) {
+ g_message( " area --'%s' (%f,%f)-(%f,%f)", name, (double)area.left(), (double)area.top(), (double)area.right(), (double)area.bottom() );
+ g_message( " ua --'%s' (%f,%f)-(%f,%f)", name, (double)ua.left(), (double)ua.top(), (double)ua.right(), (double)ua.bottom() );
+ }
+
+ stride = cairo_format_stride_for_width(CAIRO_FORMAT_ARGB32, psize);
+
+ /* Set up pixblock */
+ px = g_new(guchar, stride * psize);
+ memset(px, 0x00, stride * psize);
+
+ /* Render */
+ cairo_surface_t *s = cairo_image_surface_create_for_data(px,
+ CAIRO_FORMAT_ARGB32, psize, psize, stride);
+ Inkscape::DrawingContext dc(s, ua.min());
+
+ SPNamedView *nv = sp_document_namedview(doc, NULL);
+ float bg_r = SP_RGBA32_R_F(nv->pagecolor);
+ float bg_g = SP_RGBA32_G_F(nv->pagecolor);
+ float bg_b = SP_RGBA32_B_F(nv->pagecolor);
+ float bg_a = SP_RGBA32_A_F(nv->pagecolor);
+
+ cairo_t *cr = cairo_create(s);
+ cairo_set_source_rgba(cr, bg_r, bg_g, bg_b, bg_a);
+ cairo_rectangle(cr, 0, 0, psize, psize);
+ cairo_fill(cr);
+ cairo_save(cr);
+ cairo_destroy(cr);
+
+ drawing.render(dc, ua);
+ cairo_surface_destroy(s);
+
+ // convert to GdkPixbuf format
+ convert_pixels_argb32_to_pixbuf(px, psize, psize, stride);
+
+ if ( Inkscape::Preferences::get()->getBool("/debug/icons/overlaySvg") ) {
+ overlayPixels( px, psize, psize, stride, 0x00, 0x00, 0xff );
+ }
+ }
+ }
+ }
+
+ return px;
+} // end of sp_icon_doc_icon()
+
+
void IconPreviewPanel::renderPreview( SPObject* obj )
{
SPDocument * doc = obj->document;
diff --git a/src/ui/dialog/inkscape-preferences.cpp b/src/ui/dialog/inkscape-preferences.cpp
index 646439613..1ad44941f 100644
--- a/src/ui/dialog/inkscape-preferences.cpp
+++ b/src/ui/dialog/inkscape-preferences.cpp
@@ -1947,7 +1947,7 @@ void InkscapePreferences::initPageSystem()
_page_system.add_group_header( _("System info"));
- _sys_user_config.set_text((char const *)Inkscape::Application::profile_path(""));
+ _sys_user_config.set_text((char const *)Inkscape::IO::Resource::profile_path(""));
_sys_user_config.set_editable(false);
_page_system.add_line(true, _("User config: "), _sys_user_config, "", _("Location of users configuration"), true);
diff --git a/src/ui/dialog/knot-properties.cpp b/src/ui/dialog/knot-properties.cpp
index 954fe2a66..9008d943a 100644
--- a/src/ui/dialog/knot-properties.cpp
+++ b/src/ui/dialog/knot-properties.cpp
@@ -45,14 +45,15 @@ KnotPropertiesDialog::KnotPropertiesDialog()
{
Gtk::Box *mainVBox = get_vbox();
- _layout_table.set_spacings(4);
- _layout_table.resize (2, 2);
+ _layout_table.set_row_spacing(4);
+ _layout_table.set_column_spacing(4);
_unit_name = "";
// Layer name widgets
_knot_x_entry.set_activates_default(true);
_knot_x_entry.set_digits(4);
_knot_x_entry.set_increments(1,1);
_knot_x_entry.set_range(-G_MAXDOUBLE, G_MAXDOUBLE);
+ _knot_x_entry.set_hexpand();
_knot_x_label.set_label(_("Position X:"));
_knot_x_label.set_alignment(1.0, 0.5);
@@ -60,16 +61,15 @@ KnotPropertiesDialog::KnotPropertiesDialog()
_knot_y_entry.set_digits(4);
_knot_y_entry.set_increments(1,1);
_knot_y_entry.set_range(-G_MAXDOUBLE, G_MAXDOUBLE);
- _knot_y_label.set_label(_("Position Y:"));
+ _knot_y_entry.set_hexpand();
+ _knot_y_label.set_label(_("Position Y:"));
_knot_y_label.set_alignment(1.0, 0.5);
- _layout_table.attach(_knot_x_label,
- 0, 1, 0, 1, Gtk::FILL, Gtk::FILL);
- _layout_table.attach(_knot_x_entry,
- 1, 2, 0, 1, Gtk::FILL | Gtk::EXPAND, Gtk::FILL);
+ _layout_table.attach(_knot_x_label, 0, 0, 1, 1);
+ _layout_table.attach(_knot_x_entry, 1, 0, 1, 1);
- _layout_table.attach(_knot_y_label, 0, 1, 1, 2, Gtk::FILL, Gtk::FILL);
- _layout_table.attach(_knot_y_entry, 1, 2, 1, 2, Gtk::FILL | Gtk::EXPAND, Gtk::FILL);
+ _layout_table.attach(_knot_y_label, 0, 1, 1, 1);
+ _layout_table.attach(_knot_y_entry, 1, 1, 1, 1);
mainVBox->pack_start(_layout_table, true, true, 4);
diff --git a/src/ui/dialog/knot-properties.h b/src/ui/dialog/knot-properties.h
index f6157168f..1297eae1f 100644
--- a/src/ui/dialog/knot-properties.h
+++ b/src/ui/dialog/knot-properties.h
@@ -13,9 +13,9 @@
#define INKSCAPE_DIALOG_KNOT_PROPERTIES_H
#include <gtkmm/dialog.h>
+#include <gtkmm/grid.h>
#include <gtkmm/label.h>
#include <gtkmm/spinbutton.h>
-#include <gtkmm/table.h>
#include <2geom/point.h>
#include "knot.h"
#include "ui/tools/measure-tool.h"
@@ -45,7 +45,7 @@ protected:
Gtk::SpinButton _knot_x_entry;
Gtk::Label _knot_y_label;
Gtk::SpinButton _knot_y_entry;
- Gtk::Table _layout_table;
+ Gtk::Grid _layout_table;
bool _position_visible;
Gtk::Button _close_button;
diff --git a/src/ui/dialog/layers.cpp b/src/ui/dialog/layers.cpp
index dd9d7ec25..7a650b034 100644
--- a/src/ui/dialog/layers.cpp
+++ b/src/ui/dialog/layers.cpp
@@ -15,7 +15,6 @@
#include "layers.h"
#include <gtkmm/icontheme.h>
-#include <gtkmm/imagemenuitem.h>
#include <gtkmm/separatormenuitem.h>
#include <glibmm/main.h>
@@ -31,7 +30,6 @@
#include "ui/icon-names.h"
#include "ui/widget/imagetoggler.h"
#include "verbs.h"
-#include "widgets/icon.h"
#include "sp-root.h"
#include "ui/tools/tool-base.h"
#include "selection-chemistry.h"
@@ -82,7 +80,7 @@ void LayersPanel::_styleButton( Gtk::Button& btn, SPDesktop *desktop, unsigned i
bool set = false;
if ( iconName ) {
- GtkWidget *child = sp_icon_new( Inkscape::ICON_SIZE_SMALL_TOOLBAR, iconName );
+ GtkWidget *child = gtk_image_new_from_icon_name( iconName, GTK_ICON_SIZE_SMALL_TOOLBAR );
gtk_widget_show( child );
btn.add( *Gtk::manage(Glib::wrap(child)) );
btn.set_relief(Gtk::RELIEF_NONE);
@@ -94,7 +92,7 @@ void LayersPanel::_styleButton( Gtk::Button& btn, SPDesktop *desktop, unsigned i
if ( verb ) {
SPAction *action = verb->get_action(Inkscape::ActionContext(desktop));
if ( !set && action && action->image ) {
- GtkWidget *child = sp_icon_new( Inkscape::ICON_SIZE_SMALL_TOOLBAR, action->image );
+ GtkWidget *child = gtk_image_new_from_icon_name( action->image, GTK_ICON_SIZE_SMALL_TOOLBAR );
gtk_widget_show( child );
btn.add( *Gtk::manage(Glib::wrap(child)) );
set = true;
@@ -114,11 +112,12 @@ void LayersPanel::_styleButton( Gtk::Button& btn, SPDesktop *desktop, unsigned i
Gtk::MenuItem& LayersPanel::_addPopupItem( SPDesktop *desktop, unsigned int code, char const* iconName, char const* fallback, int id )
{
- GtkWidget* iconWidget = 0;
+ Gtk::Image *iconWidget = nullptr;
const char* label = 0;
if ( iconName ) {
- iconWidget = sp_icon_new( Inkscape::ICON_SIZE_MENU, iconName );
+ iconWidget = Gtk::manage(new Gtk::Image());
+ iconWidget->set_from_icon_name( iconName, Gtk::ICON_SIZE_MENU );
}
if ( desktop ) {
@@ -126,7 +125,8 @@ Gtk::MenuItem& LayersPanel::_addPopupItem( SPDesktop *desktop, unsigned int code
if ( verb ) {
SPAction *action = verb->get_action(Inkscape::ActionContext(desktop));
if ( !iconWidget && action && action->image ) {
- iconWidget = sp_icon_new( Inkscape::ICON_SIZE_MENU, action->image );
+ iconWidget = Gtk::manage(new Gtk::Image());
+ iconWidget->set_from_icon_name( action->image, Gtk::ICON_SIZE_MENU );
}
if ( action ) {
@@ -139,21 +139,23 @@ Gtk::MenuItem& LayersPanel::_addPopupItem( SPDesktop *desktop, unsigned int code
label = fallback;
}
- Gtk::Widget* wrapped = 0;
- if ( iconWidget ) {
- wrapped = Gtk::manage(Glib::wrap(iconWidget));
- wrapped->show();
- }
-
-
- Gtk::MenuItem* item = 0;
+ auto box = Gtk::manage(new Gtk::Box());
+ Gtk::MenuItem* item = Gtk::manage(new Gtk::MenuItem());
- if (wrapped) {
- item = Gtk::manage(new Gtk::ImageMenuItem(*wrapped, label, true));
- } else {
- item = Gtk::manage(new Gtk::MenuItem(label, true));
+ if (iconWidget) {
+ box->pack_start(*iconWidget, false, true, 0);
+ }
+ else {
+ Gtk::Label *fake_icon = Gtk::manage(new Gtk::Label(""));
+ box->pack_start(*fake_icon, false, true, 0);
}
+ Gtk::Label *menu_label = Gtk::manage(new Gtk::Label(label, true));
+ menu_label->set_xalign(0.0);
+ box->pack_start(*menu_label, true, true, 0);
+ item->add(*box);
+ item->show_all();
+
item->signal_activate().connect(sigc::bind(sigc::mem_fun(*this, &LayersPanel::_takeAction), id));
_popupMenu.append(*item);
diff --git a/src/ui/dialog/livepatheffect-editor.cpp b/src/ui/dialog/livepatheffect-editor.cpp
index bb9b61504..98789f7b2 100644
--- a/src/ui/dialog/livepatheffect-editor.cpp
+++ b/src/ui/dialog/livepatheffect-editor.cpp
@@ -36,7 +36,6 @@
#include "ui/icon-names.h"
#include "ui/widget/imagetoggler.h"
#include "verbs.h"
-#include "widgets/icon.h"
#include "livepatheffect-add.h"
namespace Inkscape {
@@ -67,7 +66,7 @@ void lpeeditor_selection_modified (Inkscape::Selection * selection, guint /*flag
static void lpe_style_button(Gtk::Button& btn, char const* iconName)
{
- GtkWidget *child = sp_icon_new(Inkscape::ICON_SIZE_SMALL_TOOLBAR, iconName);
+ GtkWidget *child = gtk_image_new_from_icon_name(iconName, GTK_ICON_SIZE_SMALL_TOOLBAR);
gtk_widget_show( child );
btn.add(*Gtk::manage(Glib::wrap(child)));
btn.set_relief(Gtk::RELIEF_NONE);
diff --git a/src/ui/dialog/objects.cpp b/src/ui/dialog/objects.cpp
index fd78fec90..4b673b8b7 100644
--- a/src/ui/dialog/objects.cpp
+++ b/src/ui/dialog/objects.cpp
@@ -47,7 +47,6 @@
#include "ui/tools/node-tool.h"
#include "verbs.h"
#include "ui/widget/color-notebook.h"
-#include "widgets/icon.h"
#include "xml/node-observer.h"
//#define DUMP_LAYERS 1
@@ -224,7 +223,7 @@ public:
*/
void ObjectsPanel::_styleButton(Gtk::Button& btn, char const* iconName, char const* tooltip)
{
- GtkWidget *child = sp_icon_new( Inkscape::ICON_SIZE_SMALL_TOOLBAR, iconName );
+ GtkWidget *child = gtk_image_new_from_icon_name( iconName, GTK_ICON_SIZE_SMALL_TOOLBAR );
gtk_widget_show( child );
btn.add( *Gtk::manage(Glib::wrap(child)) );
btn.set_relief(Gtk::RELIEF_NONE);
@@ -242,23 +241,25 @@ void ObjectsPanel::_styleButton(Gtk::Button& btn, char const* iconName, char con
*/
Gtk::MenuItem& ObjectsPanel::_addPopupItem( SPDesktop *desktop, unsigned int code, char const* iconName, char const* fallback, int id )
{
- GtkWidget* iconWidget = 0;
+ Gtk::Image *iconWidget = nullptr;
const char* label = 0;
if ( iconName ) {
- iconWidget = sp_icon_new( Inkscape::ICON_SIZE_MENU, iconName );
+ iconWidget = Gtk::manage(new Gtk::Image());
+ iconWidget->set_from_icon_name( iconName, Gtk::ICON_SIZE_MENU );
}
if ( desktop ) {
Verb *verb = Verb::get( code );
if ( verb ) {
- SPAction *action = verb->get_action(desktop);
+ SPAction *action = verb->get_action(Inkscape::ActionContext(desktop));
if ( !iconWidget && action && action->image ) {
- iconWidget = sp_icon_new( Inkscape::ICON_SIZE_MENU, action->image );
+ iconWidget = Gtk::manage(new Gtk::Image());
+ iconWidget->set_from_icon_name( action->image, Gtk::ICON_SIZE_MENU );
}
if ( action ) {
- // label = action->name;
+ label = action->name;
}
}
}
@@ -267,21 +268,23 @@ Gtk::MenuItem& ObjectsPanel::_addPopupItem( SPDesktop *desktop, unsigned int cod
label = fallback;
}
- Gtk::Widget* wrapped = 0;
- if ( iconWidget ) {
- wrapped = Gtk::manage(Glib::wrap(iconWidget));
- wrapped->show();
- }
-
-
- Gtk::MenuItem* item = 0;
+ auto box = Gtk::manage(new Gtk::Box());
+ Gtk::MenuItem* item = Gtk::manage(new Gtk::MenuItem());
- if (wrapped) {
- item = Gtk::manage(new Gtk::ImageMenuItem(*wrapped, label, true));
- } else {
- item = Gtk::manage(new Gtk::MenuItem(label, true));
+ if (iconWidget) {
+ box->pack_start(*iconWidget, false, true, 0);
+ }
+ else {
+ Gtk::Label *fake_icon = Gtk::manage(new Gtk::Label(""));
+ box->pack_start(*fake_icon, false, true, 0);
}
+ Gtk::Label *menu_label = Gtk::manage(new Gtk::Label(label, true));
+ menu_label->set_xalign(0.0);
+ box->pack_start(*menu_label, true, true, 0);
+ item->add(*box);
+ item->show_all();
+
item->signal_activate().connect(sigc::bind(sigc::mem_fun(*this, &ObjectsPanel::_takeAction), id));
_popupMenu.append(*item);
diff --git a/src/ui/dialog/polar-arrange-tab.cpp b/src/ui/dialog/polar-arrange-tab.cpp
index 9485b6ba3..b65a67e06 100644
--- a/src/ui/dialog/polar-arrange-tab.cpp
+++ b/src/ui/dialog/polar-arrange-tab.cpp
@@ -19,7 +19,6 @@
#include "document.h"
#include "document-undo.h"
-#include "widgets/icon.h"
#include "desktop.h"
#include "sp-ellipse.h"
#include "sp-item-transform.h"
diff --git a/src/ui/dialog/spellcheck.cpp b/src/ui/dialog/spellcheck.cpp
index 045ce3459..4f7657f4f 100644
--- a/src/ui/dialog/spellcheck.cpp
+++ b/src/ui/dialog/spellcheck.cpp
@@ -13,7 +13,6 @@
*/
#include "spellcheck.h"
-#include "widgets/icon.h"
#include "message-stack.h"
#include "helper/window.h"
diff --git a/src/ui/dialog/styledialog.cpp b/src/ui/dialog/styledialog.cpp
index 8679659ce..3642c0168 100644
--- a/src/ui/dialog/styledialog.cpp
+++ b/src/ui/dialog/styledialog.cpp
@@ -13,7 +13,6 @@
#include "styledialog.h"
#include "ui/widget/addtoicon.h"
-#include "widgets/icon.h"
#include "verbs.h"
#include "sp-object.h"
#include "selection.h"
@@ -265,7 +264,9 @@ StyleDialog::StyleDialog() :
_treeView.set_expander_column(*(_treeView.get_column(1)));
// Pack widgets
+ _paned.set_orientation(Gtk::ORIENTATION_VERTICAL);
_paned.pack1(_mainBox, Gtk::SHRINK);
+ _mainBox.set_orientation(Gtk::ORIENTATION_VERTICAL);
_mainBox.pack_start(_scrolledWindow, Gtk::PACK_EXPAND_WIDGET);
_scrolledWindow.add(_treeView);
_scrolledWindow.set_policy(Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC);
@@ -1515,7 +1516,7 @@ bool StyleDialog::_delProperty(GdkEventButton *event)
void StyleDialog::_styleButton(Gtk::Button& btn, char const* iconName,
char const* tooltip)
{
- GtkWidget *child = sp_icon_new(Inkscape::ICON_SIZE_SMALL_TOOLBAR, iconName);
+ GtkWidget *child = gtk_image_new_from_icon_name(iconName, GTK_ICON_SIZE_SMALL_TOOLBAR);
gtk_widget_show(child);
btn.add(*manage(Glib::wrap(child)));
btn.set_relief(Gtk::RELIEF_NONE);
diff --git a/src/ui/dialog/styledialog.h b/src/ui/dialog/styledialog.h
index dbbc1e480..03932e3cc 100644
--- a/src/ui/dialog/styledialog.h
+++ b/src/ui/dialog/styledialog.h
@@ -108,9 +108,9 @@ private:
Glib::RefPtr<TreeStore> _store;
// Widgets
- Gtk::VPaned _paned;
- Gtk::VBox _mainBox;
- Gtk::HBox _buttonBox;
+ Gtk::Paned _paned;
+ Gtk::Box _mainBox;
+ Gtk::Box _buttonBox;
Gtk::ScrolledWindow _scrolledWindow;
Gtk::Button* del;
Gtk::Button* create;
diff --git a/src/ui/dialog/swatches.cpp b/src/ui/dialog/swatches.cpp
index 87bfa9252..82b099bd1 100644
--- a/src/ui/dialog/swatches.cpp
+++ b/src/ui/dialog/swatches.cpp
@@ -512,15 +512,16 @@ compare_swatch_names(SwatchPage const *a, SwatchPage const *b) {
static void loadEmUp()
{
+ using namespace Inkscape::IO::Resource;
static bool beenHere = false;
gboolean userPalette = true;
if ( !beenHere ) {
beenHere = true;
std::list<gchar *> sources;
- sources.push_back( Inkscape::Application::profile_path("palettes") );
- sources.push_back( g_strdup(INKSCAPE_PALETTESDIR) );
- sources.push_back( g_strdup(CREATE_PALETTESDIR) );
+ sources.push_back(g_strdup(get_path(USER, PALETTES)));
+ sources.push_back(g_strdup(get_path(SYSTEM, PALETTES)));
+ sources.push_back(g_strdup(get_path(CREATE, PALETTES)));
// Use this loop to iterate through a list of possible document locations.
while (!sources.empty()) {
diff --git a/src/ui/dialog/symbols.cpp b/src/ui/dialog/symbols.cpp
index e9a13620b..aa3d86b00 100644
--- a/src/ui/dialog/symbols.cpp
+++ b/src/ui/dialog/symbols.cpp
@@ -31,6 +31,7 @@
#include <glibmm/i18n.h>
#include "path-prefix.h"
#include "io/sys.h"
+#include "io/resource.h"
#include "ui/cache/svg_preview_cache.h"
#include "ui/clipboard.h"
@@ -47,7 +48,6 @@
#include "sp-use.h"
#include "sp-defs.h"
#include "sp-symbol.h"
-#include "widgets/icon.h"
#ifdef WITH_LIBVISIO
#include <libvisio/libvisio.h>
@@ -174,18 +174,22 @@ SymbolsDialog::SymbolsDialog( gchar const* prefsPath ) :
scroller->set_hexpand();
table->attach(*Gtk::manage(tools),0,row,2,1);
+ auto addSymbolImage = Gtk::manage(new Gtk::Image());
+ addSymbolImage->set_from_icon_name("symbol-add", Gtk::ICON_SIZE_SMALL_TOOLBAR);
+
addSymbol = Gtk::manage(new Gtk::Button());
- addSymbol->add(*Gtk::manage(Glib::wrap(
- sp_icon_new (Inkscape::ICON_SIZE_SMALL_TOOLBAR, INKSCAPE_ICON("symbol-add")))) );
+ addSymbol->add(*addSymbolImage);
addSymbol->set_tooltip_text(_("Add Symbol from the current document."));
addSymbol->set_relief( Gtk::RELIEF_NONE );
addSymbol->set_focus_on_click( false );
addSymbol->signal_clicked().connect(sigc::mem_fun(*this, &SymbolsDialog::insertSymbol));
tools->pack_start(* addSymbol, Gtk::PACK_SHRINK);
+ auto removeSymbolImage = Gtk::manage(new Gtk::Image());
+ removeSymbolImage->set_from_icon_name("symbol-remove", Gtk::ICON_SIZE_SMALL_TOOLBAR);
+
removeSymbol = Gtk::manage(new Gtk::Button());
- removeSymbol->add(*Gtk::manage(Glib::wrap(
- sp_icon_new (Inkscape::ICON_SIZE_SMALL_TOOLBAR, INKSCAPE_ICON("symbol-remove")))) );
+ removeSymbol->add(*removeSymbolImage);
removeSymbol->set_tooltip_text(_("Remove Symbol from the current document."));
removeSymbol->set_relief( Gtk::RELIEF_NONE );
removeSymbol->set_focus_on_click( false );
@@ -197,18 +201,23 @@ SymbolsDialog::SymbolsDialog( gchar const* prefsPath ) :
// Pack size (controls display area)
pack_size = 2; // Default 32px
+
+ auto packMoreImage = Gtk::manage(new Gtk::Image());
+ packMoreImage->set_from_icon_name("pack-more", Gtk::ICON_SIZE_SMALL_TOOLBAR);
+
button = Gtk::manage(new Gtk::Button());
- button->add(*Gtk::manage(Glib::wrap(
- sp_icon_new (Inkscape::ICON_SIZE_SMALL_TOOLBAR, INKSCAPE_ICON("pack-more")))) );
+ button->add(*packMoreImage);
button->set_tooltip_text(_("Display more icons in row."));
button->set_relief( Gtk::RELIEF_NONE );
button->set_focus_on_click( false );
button->signal_clicked().connect(sigc::mem_fun(*this, &SymbolsDialog::packmore));
tools->pack_start(* button, Gtk::PACK_SHRINK);
+ auto packLessImage = Gtk::manage(new Gtk::Image());
+ packLessImage->set_from_icon_name("pack-less", Gtk::ICON_SIZE_SMALL_TOOLBAR);
+
button = Gtk::manage(new Gtk::Button());
- button->add(*Gtk::manage(Glib::wrap(
- sp_icon_new (Inkscape::ICON_SIZE_SMALL_TOOLBAR, INKSCAPE_ICON("pack-less")))) );
+ button->add(*packLessImage);
button->set_tooltip_text(_("Display fewer icons in row."));
button->set_relief( Gtk::RELIEF_NONE );
button->set_focus_on_click( false );
@@ -216,9 +225,11 @@ SymbolsDialog::SymbolsDialog( gchar const* prefsPath ) :
tools->pack_start(* button, Gtk::PACK_SHRINK);
// Toggle scale to fit on/off
+ auto fitSymbolImage = Gtk::manage(new Gtk::Image());
+ fitSymbolImage->set_from_icon_name("symbol-fit", Gtk::ICON_SIZE_SMALL_TOOLBAR);
+
fitSymbol = Gtk::manage(new Gtk::ToggleButton());
- fitSymbol->add(*Gtk::manage(Glib::wrap(
- sp_icon_new (Inkscape::ICON_SIZE_SMALL_TOOLBAR, INKSCAPE_ICON("symbol-fit")))) );
+ fitSymbol->add(*fitSymbolImage);
fitSymbol->set_tooltip_text(_("Toggle 'fit' symbols in icon space."));
fitSymbol->set_relief( Gtk::RELIEF_NONE );
fitSymbol->set_focus_on_click( false );
@@ -228,9 +239,11 @@ SymbolsDialog::SymbolsDialog( gchar const* prefsPath ) :
// Render size (scales symbols within display area)
scale_factor = 0; // Default 1:1 * pack_size/pack_size default
+ auto zoomOutImage = Gtk::manage(new Gtk::Image());
+ zoomOutImage->set_from_icon_name("symbol-smaller", Gtk::ICON_SIZE_SMALL_TOOLBAR);
+
zoomOut = Gtk::manage(new Gtk::Button());
- zoomOut->add(*Gtk::manage(Glib::wrap(
- sp_icon_new (Inkscape::ICON_SIZE_SMALL_TOOLBAR, INKSCAPE_ICON("symbol-smaller")))) );
+ zoomOut->add(*zoomOutImage);
zoomOut->set_tooltip_text(_("Make symbols smaller by zooming out."));
zoomOut->set_relief( Gtk::RELIEF_NONE );
zoomOut->set_focus_on_click( false );
@@ -238,9 +251,11 @@ SymbolsDialog::SymbolsDialog( gchar const* prefsPath ) :
zoomOut->signal_clicked().connect(sigc::mem_fun(*this, &SymbolsDialog::zoomout));
tools->pack_start(* zoomOut, Gtk::PACK_SHRINK);
+ auto zoomInImage = Gtk::manage(new Gtk::Image());
+ zoomInImage->set_from_icon_name("symbol-bigger", Gtk::ICON_SIZE_SMALL_TOOLBAR);
+
zoomIn = Gtk::manage(new Gtk::Button());
- zoomIn->add(*Gtk::manage(Glib::wrap(
- sp_icon_new (Inkscape::ICON_SIZE_SMALL_TOOLBAR, INKSCAPE_ICON("symbol-bigger")))) );
+ zoomIn->add(*zoomInImage);
zoomIn->set_tooltip_text(_("Make symbols bigger by zooming in."));
zoomIn->set_relief( Gtk::RELIEF_NONE );
zoomIn->set_focus_on_click( false );
@@ -577,19 +592,15 @@ void SymbolsDialog::get_symbols() {
std::list<Glib::ustring> directories;
-// \TODO optimize this
-
- if( Inkscape::IO::file_test( INKSCAPE_SYMBOLSDIR, G_FILE_TEST_EXISTS ) &&
- Inkscape::IO::file_test( INKSCAPE_SYMBOLSDIR, G_FILE_TEST_IS_DIR ) ) {
- directories.push_back( INKSCAPE_SYMBOLSDIR );
- }
- if( Inkscape::IO::file_test( Inkscape::Application::profile_path("symbols"), G_FILE_TEST_EXISTS ) &&
- Inkscape::IO::file_test( Inkscape::Application::profile_path("symbols"), G_FILE_TEST_IS_DIR ) ) {
- directories.push_back( Inkscape::Application::profile_path("symbols") );
- }
+ using namespace Inkscape::IO::Resource;
+ directories.push_back(get_path_ustring(USER, SYMBOLS));
+ directories.push_back(get_path_ustring(SYSTEM, SYMBOLS));
std::list<Glib::ustring>::iterator it;
for( it = directories.begin(); it != directories.end(); ++it ) {
+ if(!Inkscape::IO::file_test((*it).c_str(), G_FILE_TEST_IS_DIR)) {
+ continue;
+ }
GError *err = 0;
GDir *dir = g_dir_open( (*it).c_str(), 0, &err );
diff --git a/src/ui/dialog/tags.cpp b/src/ui/dialog/tags.cpp
index dfe71bddb..176719995 100644
--- a/src/ui/dialog/tags.cpp
+++ b/src/ui/dialog/tags.cpp
@@ -31,7 +31,6 @@
#include "ui/widget/layertypeicon.h"
#include "ui/widget/addtoicon.h"
#include "verbs.h"
-#include "widgets/icon.h"
#include "xml/node-observer.h"
#include "sp-root.h"
#include "ui/tools/tool-base.h" //"event-context.h"
@@ -130,7 +129,7 @@ public:
void TagsPanel::_styleButton(Gtk::Button& btn, char const* iconName, char const* tooltip)
{
- GtkWidget *child = sp_icon_new(Inkscape::ICON_SIZE_SMALL_TOOLBAR, iconName);
+ GtkWidget *child = gtk_image_new_from_icon_name(iconName, GTK_ICON_SIZE_SMALL_TOOLBAR);
gtk_widget_show(child);
btn.add(*manage(Glib::wrap(child)));
btn.set_relief(Gtk::RELIEF_NONE);
@@ -144,7 +143,7 @@ Gtk::MenuItem& TagsPanel::_addPopupItem( SPDesktop *desktop, unsigned int code,
const char* label = 0;
if ( iconName ) {
- iconWidget = sp_icon_new( Inkscape::ICON_SIZE_MENU, iconName );
+ iconWidget = gtk_image_new_from_icon_name( iconName, GTK_ICON_SIZE_MENU );
}
if ( desktop ) {
@@ -152,11 +151,11 @@ Gtk::MenuItem& TagsPanel::_addPopupItem( SPDesktop *desktop, unsigned int code,
if ( verb ) {
SPAction *action = verb->get_action(desktop);
if ( !iconWidget && action && action->image ) {
- iconWidget = sp_icon_new( Inkscape::ICON_SIZE_MENU, action->image );
+ iconWidget = gtk_image_new_from_icon_name( action->image, GTK_ICON_SIZE_MENU );
}
if ( action ) {
- label = action->name;
+ // label = action->name;
}
}
}
@@ -167,7 +166,7 @@ Gtk::MenuItem& TagsPanel::_addPopupItem( SPDesktop *desktop, unsigned int code,
Gtk::Widget* wrapped = 0;
if ( iconWidget ) {
- wrapped = manage(Glib::wrap(iconWidget));
+ wrapped = Gtk::manage(Glib::wrap(iconWidget));
wrapped->show();
}
diff --git a/src/ui/dialog/template-load-tab.cpp b/src/ui/dialog/template-load-tab.cpp
index 7b96c2b97..10b4716ff 100644
--- a/src/ui/dialog/template-load-tab.cpp
+++ b/src/ui/dialog/template-load-tab.cpp
@@ -24,6 +24,8 @@
#include "file.h"
#include "path-prefix.h"
+using namespace Inkscape::IO::Resource;
+
namespace Inkscape {
namespace UI {
@@ -57,7 +59,6 @@ TemplateLoadTab::TemplateLoadTab(NewFromTemplate* parent)
sigc::mem_fun(*this, &TemplateLoadTab::_keywordSelected));
this->show_all();
- _loading_path = "";
_loadTemplates();
_initLists();
}
@@ -207,11 +208,8 @@ void TemplateLoadTab::_refreshTemplatesList()
void TemplateLoadTab::_loadTemplates()
{
- // user's local dir
- _getTemplatesFromDir(Inkscape::Application::profile_path("templates") + _loading_path);
-
- // system templates dir
- _getTemplatesFromDir(INKSCAPE_TEMPLATESDIR + _loading_path);
+ _getTemplatesFromDomain(USER);
+ _getTemplatesFromDomain(SYSTEM);
// procedural templates
_getProceduralTemplates();
@@ -252,11 +250,12 @@ TemplateLoadTab::TemplateData TemplateLoadTab::_processTemplateFile(const std::s
}
-void TemplateLoadTab::_getTemplatesFromDir(const std::string &path)
+void TemplateLoadTab::_getTemplatesFromDomain(Domain domain)
{
- if ( !Glib::file_test(path, Glib::FILE_TEST_EXISTS) ||
- !Glib::file_test(path, Glib::FILE_TEST_IS_DIR))
+ Glib::ustring path = get_path_ustring(domain, TEMPLATES);
+ if (!Glib::file_test(path, Glib::FILE_TEST_IS_DIR)) {
return;
+ }
Glib::Dir dir(path);
diff --git a/src/ui/dialog/template-load-tab.h b/src/ui/dialog/template-load-tab.h
index d11c4c77f..0a5521d93 100644
--- a/src/ui/dialog/template-load-tab.h
+++ b/src/ui/dialog/template-load-tab.h
@@ -21,6 +21,7 @@
#include <string>
#include "xml/node.h"
+#include "io/resource.h"
#include "extension/effect.h"
@@ -66,7 +67,6 @@ protected:
Glib::ustring _current_keyword;
Glib::ustring _current_template;
- std::string _loading_path;
std::map<Glib::ustring, TemplateData> _tdata;
std::set<Glib::ustring> _keywords;
@@ -100,7 +100,7 @@ private:
void _getDataFromNode(Inkscape::XML::Node *, TemplateData &);
void _getProceduralTemplates();
- void _getTemplatesFromDir(const std::string &);
+ void _getTemplatesFromDomain(Inkscape::IO::Resource::Domain domain);
void _keywordSelected();
TemplateData _processTemplateFile(const std::string &);
diff --git a/src/ui/dialog/text-edit.cpp b/src/ui/dialog/text-edit.cpp
index 94f307828..c7d899f45 100644
--- a/src/ui/dialog/text-edit.cpp
+++ b/src/ui/dialog/text-edit.cpp
@@ -45,7 +45,6 @@ extern "C" {
#include "verbs.h"
#include "ui/interface.h"
#include "svg/css-ostringstream.h"
-#include "widgets/icon.h"
#include "widgets/font-selector.h"
#include <glibmm/i18n.h>
#include <glibmm/markup.h>
@@ -103,26 +102,6 @@ TextEdit::TextEdit()
layout_hbox.pack_start(text_sep, false, false, 10);
- /* Line Spacing */
- /* Commented out as this does not handle non-percentage values
- GtkWidget *px = sp_icon_new( Inkscape::ICON_SIZE_SMALL_TOOLBAR, INKSCAPE_ICON("text_line_spacing") );
- layout_hbox.pack_start(*Gtk::manage(Glib::wrap(px)), false, false);
-
- spacing_combo = gtk_combo_box_text_new_with_entry ();
- gtk_widget_set_size_request (spacing_combo, 90, -1);
-
- const gchar *spacings[] = {"50%", "80%", "90%", "100%", "110%", "120%", "130%", "140%", "150%", "200%", "300%", NULL};
- for (int i = 0; spacings[i]; i++) {
- gtk_combo_box_text_append_text((GtkComboBoxText *) spacing_combo, spacings[i]);
- }
-
- gtk_widget_set_tooltip_text (px, _("Spacing between baselines (percent of font size)"));
- gtk_widget_set_tooltip_text (spacing_combo, _("Spacing between baselines (percent of font size)"));
- layout_hbox.pack_start(*Gtk::manage(Glib::wrap(spacing_combo)), false, false);
- layout_frame.set_padding(4,4,4,4);
- layout_frame.add(layout_hbox);
- */
-
// Text start Offset
{
startOffset = gtk_combo_box_text_new_with_entry ();
@@ -223,10 +202,7 @@ TextEdit::~TextEdit()
void TextEdit::styleButton(Gtk::RadioButton *button, gchar const *tooltip, gchar const *icon_name, Gtk::RadioButton *group_button )
{
- GtkWidget *icon = sp_icon_new( Inkscape::ICON_SIZE_SMALL_TOOLBAR, icon_name );
- if (!GTK_IS_IMAGE(icon)) {
- icon = gtk_image_new_from_icon_name ( icon_name, GTK_ICON_SIZE_SMALL_TOOLBAR );
- }
+ GtkWidget *icon = gtk_image_new_from_icon_name( icon_name, GTK_ICON_SIZE_SMALL_TOOLBAR );
if (group_button) {
Gtk::RadioButton::Group group = group_button->get_group();
diff --git a/src/ui/dialog/transformation.cpp b/src/ui/dialog/transformation.cpp
index d209a450c..5ad1b9ec5 100644
--- a/src/ui/dialog/transformation.cpp
+++ b/src/ui/dialog/transformation.cpp
@@ -31,7 +31,6 @@
#include "sp-namedview.h"
#include "sp-item-transform.h"
#include "ui/icon-names.h"
-#include "widgets/icon.h"
namespace Inkscape {
@@ -278,14 +277,18 @@ void Transformation::layoutPageRotate()
_scalar_rotate.setDigits(3);
_scalar_rotate.setIncrements(0.1, 1.0);
- _counterclockwise_rotate.add(*manage( Glib::wrap(
- sp_icon_new(Inkscape::ICON_SIZE_SMALL_TOOLBAR, INKSCAPE_ICON("object-rotate-left")))));
+ auto object_rotate_left_icon = Gtk::manage(new Gtk::Image());
+ object_rotate_left_icon->set_from_icon_name("object-rotate-left", Gtk::ICON_SIZE_SMALL_TOOLBAR);
+
+ _counterclockwise_rotate.add(*object_rotate_left_icon);
_counterclockwise_rotate.set_mode(false);
_counterclockwise_rotate.set_relief(Gtk::RELIEF_NONE);
_counterclockwise_rotate.set_tooltip_text(_("Rotate in a counterclockwise direction"));
- _clockwise_rotate.add(*manage( Glib::wrap(
- sp_icon_new(Inkscape::ICON_SIZE_SMALL_TOOLBAR, INKSCAPE_ICON("object-rotate-right")))));
+ auto object_rotate_right_icon = Gtk::manage(new Gtk::Image());
+ object_rotate_right_icon->set_from_icon_name("object-rotate-right", Gtk::ICON_SIZE_SMALL_TOOLBAR);
+
+ _clockwise_rotate.add(*object_rotate_right_icon);
_clockwise_rotate.set_mode(false);
_clockwise_rotate.set_relief(Gtk::RELIEF_NONE);
_clockwise_rotate.set_tooltip_text(_("Rotate in a clockwise direction"));
diff --git a/src/ui/dialog/undo-history.cpp b/src/ui/dialog/undo-history.cpp
index bf5bdc76d..3d6d71e9a 100644
--- a/src/ui/dialog/undo-history.cpp
+++ b/src/ui/dialog/undo-history.cpp
@@ -44,16 +44,13 @@ void CellRendererSPIcon::render_vfunc(const Cairo::RefPtr<Cairo::Context>& cr,
if ( !_icon_cache[_property_event_type] ) {
Glib::ustring image_name = Inkscape::Verb::get(_property_event_type)->get_image();
- Gtk::Widget* icon = sp_icon_get_icon(image_name, Inkscape::ICON_SIZE_MENU);
+ Gtk::Image* icon = Gtk::manage(new Gtk::Image());
+ icon->set_from_icon_name(image_name, Gtk::ICON_SIZE_MENU);
if (icon) {
// check icon type (inkscape, gtk, none)
- if ( SP_IS_ICON(icon->gobj()) ) {
- SPIcon* sp_icon = SP_ICON(icon->gobj());
- sp_icon_fetch_pixbuf(sp_icon);
- _property_icon = Glib::wrap(sp_icon->pb, true);
- } else if ( GTK_IS_IMAGE(icon->gobj()) ) {
+ if ( GTK_IS_IMAGE(icon->gobj()) ) {
auto icon_theme = Gtk::IconTheme::get_default();
_property_icon = icon_theme->load_icon(image_name, 16);
} else {
diff --git a/src/ui/dialog/undo-history.h b/src/ui/dialog/undo-history.h
index 48929a0d0..3efc25f15 100644
--- a/src/ui/dialog/undo-history.h
+++ b/src/ui/dialog/undo-history.h
@@ -24,7 +24,6 @@
#include "event-log.h"
-#include "widgets/icon.h"
#include "ui/dialog/desktop-tracker.h"
class SPDesktop;
diff --git a/src/ui/dialog/xml-tree.cpp b/src/ui/dialog/xml-tree.cpp
index fa35b092a..d9ea73673 100644
--- a/src/ui/dialog/xml-tree.cpp
+++ b/src/ui/dialog/xml-tree.cpp
@@ -17,7 +17,6 @@
*/
#include "xml-tree.h"
-#include "widgets/icon.h"
#include <glibmm/i18n.h>
#include "desktop.h"
@@ -109,57 +108,74 @@ XmlTree::XmlTree (void) :
gtk_widget_set_tooltip_text( GTK_WIDGET(tree), _("Drag to reorder nodes") );
tree_toolbar.set_toolbar_style(Gtk::TOOLBAR_ICONS);
- xml_element_new_button.set_icon_widget(*Gtk::manage(Glib::wrap(
- sp_icon_new (Inkscape::ICON_SIZE_LARGE_TOOLBAR, INKSCAPE_ICON("xml-element-new")))) );
+
+ auto xml_element_new_icon = Gtk::manage(new Gtk::Image());
+ xml_element_new_icon->set_from_icon_name("xml-element-new", Gtk::ICON_SIZE_LARGE_TOOLBAR);
+
+ xml_element_new_button.set_icon_widget(*xml_element_new_icon);
xml_element_new_button.set_tooltip_text(_("New element node"));
xml_element_new_button.set_sensitive(false);
tree_toolbar.add(xml_element_new_button);
- xml_text_new_button.set_icon_widget(*Gtk::manage(Glib::wrap(
- sp_icon_new (Inkscape::ICON_SIZE_LARGE_TOOLBAR, INKSCAPE_ICON("xml-text-new")))));
+ auto xml_text_new_icon = Gtk::manage(new Gtk::Image());
+ xml_text_new_icon->set_from_icon_name("xml-text-new", Gtk::ICON_SIZE_LARGE_TOOLBAR);
+
+ xml_text_new_button.set_icon_widget(*xml_text_new_icon);
xml_text_new_button.set_tooltip_text(_("New text node"));
xml_text_new_button.set_sensitive(false);
tree_toolbar.add(xml_text_new_button);
- xml_node_duplicate_button.set_icon_widget(*Gtk::manage(Glib::wrap(
- sp_icon_new (Inkscape::ICON_SIZE_LARGE_TOOLBAR, INKSCAPE_ICON("xml-node-duplicate")))));
+ auto xml_node_duplicate_icon = Gtk::manage(new Gtk::Image());
+ xml_node_duplicate_icon->set_from_icon_name("xml-node-duplicate", Gtk::ICON_SIZE_LARGE_TOOLBAR);
+
+ xml_node_duplicate_button.set_icon_widget(*xml_node_duplicate_icon);
xml_node_duplicate_button.set_tooltip_text(_("Duplicate node"));
xml_node_duplicate_button.set_sensitive(false);
tree_toolbar.add(xml_node_duplicate_button);
tree_toolbar.add(separator);
- xml_node_delete_button.set_icon_widget(*Gtk::manage(Glib::wrap(
- sp_icon_new (Inkscape::ICON_SIZE_LARGE_TOOLBAR, INKSCAPE_ICON("xml-node-delete")))));
+ auto xml_node_delete_icon = Gtk::manage(new Gtk::Image());
+ xml_node_delete_icon->set_from_icon_name("xml-node-delete", Gtk::ICON_SIZE_LARGE_TOOLBAR);
+
+ xml_node_delete_button.set_icon_widget(*xml_node_delete_icon);
xml_node_delete_button.set_tooltip_text(Q_("nodeAsInXMLdialogTooltip|Delete node"));
xml_node_delete_button.set_sensitive(false);
tree_toolbar.add(xml_node_delete_button);
tree_toolbar.add(separator2);
- unindent_node_button.set_icon_widget(*Gtk::manage(Glib::wrap(
- sp_icon_new (Inkscape::ICON_SIZE_LARGE_TOOLBAR, INKSCAPE_ICON("format-indent-less")))));
+ auto format_indent_less_icon = Gtk::manage(new Gtk::Image());
+ format_indent_less_icon->set_from_icon_name("format-indent-less", Gtk::ICON_SIZE_LARGE_TOOLBAR);
+
+ unindent_node_button.set_icon_widget(*format_indent_less_icon);
unindent_node_button.set_label(_("Unindent node"));
unindent_node_button.set_tooltip_text(_("Unindent node"));
unindent_node_button.set_sensitive(false);
tree_toolbar.add(unindent_node_button);
- indent_node_button.set_icon_widget(*Gtk::manage(Glib::wrap(
- sp_icon_new (Inkscape::ICON_SIZE_LARGE_TOOLBAR, INKSCAPE_ICON("format-indent-more")))));
+ auto format_indent_more_icon = Gtk::manage(new Gtk::Image());
+ format_indent_more_icon->set_from_icon_name("format-indent-more", Gtk::ICON_SIZE_LARGE_TOOLBAR);
+
+ indent_node_button.set_icon_widget(*format_indent_more_icon);
indent_node_button.set_label(_("Indent node"));
indent_node_button.set_tooltip_text(_("Indent node"));
indent_node_button.set_sensitive(false);
tree_toolbar.add(indent_node_button);
- raise_node_button.set_icon_widget(*Gtk::manage(Glib::wrap(
- sp_icon_new (Inkscape::ICON_SIZE_LARGE_TOOLBAR, INKSCAPE_ICON("go-up")))));
+ auto go_up_icon = Gtk::manage(new Gtk::Image());
+ go_up_icon->set_from_icon_name("go-up", Gtk::ICON_SIZE_LARGE_TOOLBAR);
+
+ raise_node_button.set_icon_widget(*go_up_icon);
raise_node_button.set_label(_("Raise node"));
raise_node_button.set_tooltip_text(_("Raise node"));
raise_node_button.set_sensitive(false);
tree_toolbar.add(raise_node_button);
- lower_node_button.set_icon_widget(*Gtk::manage(Glib::wrap(
- sp_icon_new (Inkscape::ICON_SIZE_LARGE_TOOLBAR, INKSCAPE_ICON("go-down")))));
+ auto go_down_icon = Gtk::manage(new Gtk::Image());
+ go_down_icon->set_from_icon_name("go-down", Gtk::ICON_SIZE_LARGE_TOOLBAR);
+
+ lower_node_button.set_icon_widget(*go_down_icon);
lower_node_button.set_label(_("Lower node"));
lower_node_button.set_tooltip_text(_("Lower node"));
lower_node_button.set_sensitive(false);
@@ -183,7 +199,10 @@ XmlTree::XmlTree (void) :
attributes = SP_XMLVIEW_ATTR_LIST(sp_xmlview_attr_list_new(NULL));
attr_toolbar.set_toolbar_style(Gtk::TOOLBAR_ICONS);
- xml_attribute_delete_button.set_icon_widget(*Gtk::manage(Glib::wrap(sp_icon_new (Inkscape::ICON_SIZE_LARGE_TOOLBAR, INKSCAPE_ICON("xml-attribute-delete")))));
+
+ auto xml_attribute_delete_icon = Gtk::manage(new Gtk::Image());
+ xml_attribute_delete_icon->set_from_icon_name("xml-attribute-delete", Gtk::ICON_SIZE_LARGE_TOOLBAR);
+ xml_attribute_delete_button.set_icon_widget(*xml_attribute_delete_icon);
xml_attribute_delete_button.set_tooltip_text(_("Delete attribute"));
xml_attribute_delete_button.set_sensitive(false);
attr_toolbar.add(xml_attribute_delete_button);
diff --git a/src/ui/interface.cpp b/src/ui/interface.cpp
index 7e80c1a2f..a0ee5c72b 100644
--- a/src/ui/interface.cpp
+++ b/src/ui/interface.cpp
@@ -27,14 +27,15 @@
#include <gtkmm/icontheme.h>
#include "file.h"
#include <glibmm/miscutils.h>
-#include <gtkmm/imagemenuitem.h>
-#include <gtkmm/separatormenuitem.h>
+
+#if WITH_GTKMM_3_22
+# include <gdkmm/monitor.h>
+#endif
#include "inkscape.h"
#include "extension/db.h"
#include "extension/effect.h"
#include "extension/input.h"
-#include "widgets/icon.h"
#include "preferences.h"
#include "shortcuts.h"
#include "document.h"
@@ -135,8 +136,6 @@ static void sp_ui_menu_item_set_name(GtkWidget *data,
Glib::ustring const &name);
static void sp_recent_open(GtkRecentChooser *, gpointer);
-static void injectRenamedIcons();
-
static const int MIN_ONSCREEN_DISTANCE = 50;
void
@@ -176,13 +175,26 @@ sp_create_window(SPViewWidget *vw, bool editable)
gint full = prefs->getBool("/desktop/geometry/fullscreen");
gint maxed = prefs->getBool("/desktop/geometry/maximized");
if (pw>0 && ph>0) {
- gint w = MIN(gdk_screen_width(), pw);
- gint h = MIN(gdk_screen_height(), ph);
- gint x = MIN(gdk_screen_width() - MIN_ONSCREEN_DISTANCE, px);
- gint y = MIN(gdk_screen_height() - MIN_ONSCREEN_DISTANCE, py);
+#if WITH_GTKMM_3_22
+ auto const display = Gdk::Display::get_default();
+ auto const monitor = display->get_primary_monitor();
+
+ // A Gdk::Rectangle in "application pixel" units
+ Gdk::Rectangle screen_geometry;
+ monitor->get_geometry(screen_geometry);
+ auto const screen_width = screen_geometry.get_width();
+ auto const screen_height = screen_geometry.get_height();
+#else
+ auto const screen_width = gdk_screen_width();
+ auto const screen_height = gdk_screen_height();
+#endif
+ gint w = MIN(screen_width, pw);
+ gint h = MIN(screen_height, ph);
+ gint x = MIN(screen_width - MIN_ONSCREEN_DISTANCE, px);
+ gint y = MIN(screen_height - MIN_ONSCREEN_DISTANCE, py);
if (w>0 && h>0) {
- x = MIN(gdk_screen_width() - w, x);
- y = MIN(gdk_screen_height() - h, y);
+ x = MIN(screen_width - w, x);
+ y = MIN(screen_height - h, y);
desktop->setWindowSize(w, h);
}
@@ -389,23 +401,6 @@ sp_ui_menu_deselect(gpointer object)
view->tipsMessageContext()->clear();
}
-/**
- * Creates and attaches a scaled icon to the given menu item.
- */
-static void
-sp_ui_menuitem_add_icon( GtkWidget *item, gchar *icon_name )
-{
- static bool iconsInjected = false;
- if ( !iconsInjected ) {
- iconsInjected = true;
- injectRenamedIcons();
- }
- GtkWidget *icon;
-
- icon = sp_icon_new( Inkscape::ICON_SIZE_MENU, icon_name );
- gtk_widget_show(icon);
- gtk_image_menu_item_set_image((GtkImageMenuItem *) item, icon);
-} // end of sp_ui_menu_add_icon
void
sp_ui_dialog_title_string(Inkscape::Verb *verb, gchar *c)
@@ -435,38 +430,82 @@ sp_ui_dialog_title_string(Inkscape::Verb *verb, gchar *c)
}
}
-
/**
* Appends a custom menu UI from a verb.
*
* @see ContextMenu::AppendItemFromVerb for a c++ified alternative. Consider dropping sp_ui_menu_append_item_from_verb when c++ifying interface.cpp.
+ *
+ * @param menu The menu to which the item will be appended
+ * @param verb The verb from which the item's label, action and icon (optionally) will be read
+ * @param view
+ * @param show_icon True if an icon should be displayed before the menu item's label
+ * @param radio True if a radio button should be displayed next to the menu item
+ * @param group The radio button group that the item should belong to
+ *
+ * @details The show_icon flag should be used very sparingly because menu icons are not recommended
+ * any longer under the GNOME HIG. Also, note that the text appears after the icon, and
+ * so will be indented relative to "normal" menu items. As such, menus will look best if
+ * all the items with icons are grouped together between a pair of separators.
*/
-static GtkWidget *sp_ui_menu_append_item_from_verb(GtkMenu *menu, Inkscape::Verb *verb, Inkscape::UI::View::View *view, bool radio = false, GSList *group = NULL)
+static GtkWidget *sp_ui_menu_append_item_from_verb(GtkMenu *menu,
+ Inkscape::Verb *verb,
+ Inkscape::UI::View::View *view,
+ bool show_icon = false,
+ bool radio = false,
+ GSList *group = NULL)
{
- SPAction *action;
GtkWidget *item;
+ // Just create a menu separator if this isn't a real action.
+ // Otherwise, create a real menu item
if (verb->get_code() == SP_VERB_NONE) {
-
item = gtk_separator_menu_item_new();
-
} else {
+ SPAction *action = verb->get_action(Inkscape::ActionContext(view));
- action = verb->get_action(Inkscape::ActionContext(view));
if (!action) return NULL;
+ // Create the menu item itself, either as a radio menu item, or just
+ // a regular menu item depending on whether the "radio" flag is set
if (radio) {
- item = gtk_radio_menu_item_new_with_mnemonic(group, action->name);
+ item = gtk_radio_menu_item_new(group);
} else {
- item = gtk_image_menu_item_new_with_mnemonic(action->name);
+ item = gtk_menu_item_new();
}
- gtk_label_set_markup_with_mnemonic( GTK_LABEL(gtk_bin_get_child(GTK_BIN (item))), action->name);
+ // Create a box to contain all the widgets (icon, label, accelerator)
+ // that will go inside the menu item
+ GtkWidget *box = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0);
- GtkAccelGroup *accel_group = sp_shortcut_get_accel_group();
+ // Now create the label and add it to the menu item
+ GtkWidget *label = gtk_accel_label_new(action->name);
+ gtk_label_set_markup_with_mnemonic( GTK_LABEL(label), action->name);
+ gtk_label_set_use_underline(GTK_LABEL(label), true);
+ gtk_label_set_xalign(GTK_LABEL(label), 0.0);
+
+ GtkAccelGroup *accel_group = sp_shortcut_get_accel_group();
gtk_menu_set_accel_group(menu, accel_group);
sp_shortcut_add_accelerator(item, sp_shortcut_get_primary(verb));
+ gtk_accel_label_set_accel_widget(GTK_ACCEL_LABEL(label), item);
+
+ GtkWidget *icon;
+
+ // If there is an image associated with the action, then we can add it as an
+ // icon for the menu item. If not, give the label a bit more space
+ if(show_icon && action->image) {
+ icon = gtk_image_new_from_icon_name(action->image, GTK_ICON_SIZE_MENU);
+ }
+ else {
+ icon = gtk_label_new(NULL); // A fake icon just to act as a placeholder
+ }
+
+ gtk_box_pack_start(GTK_BOX(box), icon, FALSE, TRUE, 0);
+ gtk_box_pack_start(GTK_BOX(box), label, TRUE, TRUE, 0);
+
+ // Finally, pack all the widgets into the menu item
+ gtk_container_add(GTK_CONTAINER(item), box);
+
action->signal_set_sensitive.connect(
sigc::bind<0>(
@@ -481,9 +520,6 @@ static GtkWidget *sp_ui_menu_append_item_from_verb(GtkMenu *menu, Inkscape::Verb
gtk_widget_set_sensitive(item, FALSE);
}
- if (action->image) {
- sp_ui_menuitem_add_icon(item, action->image);
- }
gtk_widget_set_events(item, GDK_KEY_PRESS_MASK);
g_object_set_data(G_OBJECT(item), "view", (gpointer) view);
g_signal_connect( G_OBJECT(item), "activate", G_CALLBACK(sp_ui_menu_activate), action );
@@ -491,7 +527,7 @@ static GtkWidget *sp_ui_menu_append_item_from_verb(GtkMenu *menu, Inkscape::Verb
g_signal_connect( G_OBJECT(item), "deselect", G_CALLBACK(sp_ui_menu_deselect_action), action );
}
- gtk_widget_show(item);
+ gtk_widget_show_all(item);
gtk_menu_shell_append(GTK_MENU_SHELL(menu), item);
return item;
@@ -806,11 +842,19 @@ static void sp_ui_build_dyn_menus(Inkscape::XML::Node *menus, GtkWidget *menu, I
}
if (!strcmp(menu_pntr->name(), "verb")) {
gchar const *verb_name = menu_pntr->attribute("verb-id");
+
+ // Check if the "show-icon" attribute is set, and set the flag here accordingly
+ bool show_icon = false;
+
+ if(menu_pntr->attribute("show-icon") != NULL) {
+ show_icon = true;
+ }
+
Inkscape::Verb *verb = Inkscape::Verb::getbyid(verb_name);
if (verb != NULL) {
if (menu_pntr->attribute("radio") != NULL) {
- GtkWidget *item = sp_ui_menu_append_item_from_verb (GTK_MENU(menu), verb, view, true, group);
+ GtkWidget *item = sp_ui_menu_append_item_from_verb (GTK_MENU(menu), verb, view, show_icon, true, group);
group = gtk_radio_menu_item_get_group( GTK_RADIO_MENU_ITEM(item));
if (menu_pntr->attribute("default") != NULL) {
gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (item), TRUE);
@@ -826,7 +870,7 @@ static void sp_ui_build_dyn_menus(Inkscape::XML::Node *menus, GtkWidget *menu, I
checkitem_toggled, checkitem_update, verb);
}
} else {
- sp_ui_menu_append_item_from_verb(GTK_MENU(menu), verb, view);
+ sp_ui_menu_append_item_from_verb(GTK_MENU(menu), verb, view, show_icon);
group = NULL;
}
} else {
@@ -1382,894 +1426,19 @@ sp_ui_menu_item_set_name(GtkWidget *data, Glib::ustring const &name)
if (GTK_IS_LABEL(child)) {
gtk_label_set_markup_with_mnemonic(GTK_LABEL (child), name.c_str());
} else if (GTK_IS_BOX(child)) {
+ GList *children = gtk_container_get_children(GTK_CONTAINER(child));
+
+ // Label is second child in list
+ GtkWidget *label = GTK_WIDGET(children->next->data);
+
gtk_label_set_markup_with_mnemonic(
- GTK_LABEL (gtk_container_get_children(GTK_CONTAINER (child))->data),
+ GTK_LABEL (label),
name.c_str());
}//else sp_ui_menu_append_item_from_verb has been modified and can set
//a menu item in yet another way...
}
}
}
-
-void injectRenamedIcons()
-{
- Glib::RefPtr<Gtk::IconTheme> iconTheme = Gtk::IconTheme::get_default();
-
- std::vector< std::pair<Glib::ustring, Glib::ustring> > renamed;
- renamed.push_back(std::make_pair("gtk-file", "document-x-generic"));
- renamed.push_back(std::make_pair("gtk-directory", "folder"));
-
- for ( std::vector< std::pair<Glib::ustring, Glib::ustring> >::iterator it = renamed.begin(); it < renamed.end(); ++it ) {
- bool hasIcon = iconTheme->has_icon(it->first);
- bool hasSecondIcon = iconTheme->has_icon(it->second);
-
- if ( !hasIcon && hasSecondIcon ) {
- Glib::ArrayHandle<int> sizes = iconTheme->get_icon_sizes(it->second);
- for ( Glib::ArrayHandle<int>::iterator it2 = sizes.begin(); it2 < sizes.end(); ++it2 ) {
- Glib::RefPtr<Gdk::Pixbuf> pb = iconTheme->load_icon( it->second, *it2 );
- if ( pb ) {
- // install a private copy of the pixbuf to avoid pinning a theme
- Glib::RefPtr<Gdk::Pixbuf> pbCopy = pb->copy();
- Gtk::IconTheme::add_builtin_icon( it->first, *it2, pbCopy );
- }
- }
- }
- }
-}
-
-
-ContextMenu::ContextMenu(SPDesktop *desktop, SPItem *item) :
- _item(item),
- MIGroup(),
- MIParent(_("Go to parent"))
-{
-// g_message("ContextMenu");
- _object = static_cast<SPObject *>(item);
- _desktop = desktop;
-
- AppendItemFromVerb(Inkscape::Verb::get(SP_VERB_EDIT_UNDO));
- AppendItemFromVerb(Inkscape::Verb::get(SP_VERB_EDIT_REDO));
- AddSeparator();
- AppendItemFromVerb(Inkscape::Verb::get(SP_VERB_EDIT_CUT));
- AppendItemFromVerb(Inkscape::Verb::get(SP_VERB_EDIT_COPY));
- AppendItemFromVerb(Inkscape::Verb::get(SP_VERB_EDIT_PASTE));
- AddSeparator();
- AppendItemFromVerb(Inkscape::Verb::get(SP_VERB_EDIT_DUPLICATE));
- AppendItemFromVerb(Inkscape::Verb::get(SP_VERB_EDIT_DELETE));
-
- positionOfLastDialog = 10; // 9 in front + 1 for the separator in the next if; used to position the dialog menu entries below each other
- /* Item menu */
- if (item!=NULL) {
- AddSeparator();
- MakeObjectMenu();
- }
- AddSeparator();
- /* Lock/Unock Hide/Unhide*/
- Geom::Rect b(_desktop->point(),_desktop->point() + Geom::Point(1,1));
- std::vector< SPItem * > down_items = _desktop->getDocument()->getItemsPartiallyInBox( _desktop->dkey, b, true, true);
- bool has_down_hidden = false;
- bool has_down_locked = false;
- for(std::vector< SPItem * >::iterator down = down_items.begin(); down != down_items.end(); ++down){
- if((*down)->isHidden()) {
- has_down_hidden = true;
- }
- if((*down)->isLocked()) {
- has_down_locked = true;
- }
- }
- Gtk::MenuItem* mi;
-
- mi = Gtk::manage(new Gtk::MenuItem(_("Hide selected objects"),1));
- mi->signal_activate().connect(sigc::mem_fun(*this, &ContextMenu::HideSelected));
- if (_desktop->selection->isEmpty()) {
- mi->set_sensitive(false);
- }
- mi->show();
- append(*mi);//insert(*mi,positionOfLastDialog++);
-
- mi = Gtk::manage(new Gtk::MenuItem(_("Unhide objects below"),1));
- mi->signal_activate().connect(sigc::bind<std::vector< SPItem * > >(sigc::mem_fun(*this, &ContextMenu::UnHideBelow), down_items));
- if (!has_down_hidden) {
- mi->set_sensitive(false);
- }
- mi->show();
- append(*mi);//insert(*mi,positionOfLastDialog++);
-
- mi = Gtk::manage(new Gtk::MenuItem(_("Lock selected objects"),1));
- mi->signal_activate().connect(sigc::mem_fun(*this, &ContextMenu::LockSelected));
- if (_desktop->selection->isEmpty()) {
- mi->set_sensitive(false);
- }
- mi->show();
- append(*mi);//insert(*mi,positionOfLastDialog++);
-
- mi = Gtk::manage(new Gtk::MenuItem(_("Unlock objects below"),1));
- mi->signal_activate().connect(sigc::bind<std::vector< SPItem * > >(sigc::mem_fun(*this, &ContextMenu::UnLockBelow), down_items));
- if (!has_down_locked) {
- mi->set_sensitive(false);
- }
- mi->show();
- append(*mi);//insert(*mi,positionOfLastDialog++);
- /* layer menu */
- SPGroup *group=NULL;
- if (item) {
- if (SP_IS_GROUP(item)) {
- group = SP_GROUP(item);
- } else if ( item != _desktop->currentRoot() && SP_IS_GROUP(item->parent) ) {
- group = SP_GROUP(item->parent);
- }
- }
-
- if (( group && group != _desktop->currentLayer() ) ||
- ( _desktop->currentLayer() != _desktop->currentRoot() && _desktop->currentLayer()->parent != _desktop->currentRoot() ) ) {
- AddSeparator();
- }
-
- if ( group && group != _desktop->currentLayer() ) {
- /* TRANSLATORS: #%1 is the id of the group e.g. <g id="#g7">, not a number. */
- MIGroup.set_label (Glib::ustring::compose(_("Enter group #%1"), group->getId()));
- MIGroup.set_data("group", group);
- MIGroup.signal_activate().connect(sigc::bind(sigc::mem_fun(*this, &ContextMenu::EnterGroup),&MIGroup));
- MIGroup.show();
- append(MIGroup);
- }
-
- if ( _desktop->currentLayer() != _desktop->currentRoot() ) {
- if ( _desktop->currentLayer()->parent != _desktop->currentRoot() ) {
- MIParent.signal_activate().connect(sigc::mem_fun(*this, &ContextMenu::LeaveGroup));
- MIParent.show();
- append(MIParent);
-
- /* Pop selection out of group */
- Gtk::MenuItem* miu = Gtk::manage(new Gtk::MenuItem(_("_Pop selection out of group"), 1));
- miu->signal_activate().connect(sigc::mem_fun(*this, &ContextMenu::ActivateUngroupPopSelection));
- miu->show();
- append(*miu);
- }
- }
-}
-
-ContextMenu::~ContextMenu(void)
-{
-}
-
-Gtk::SeparatorMenuItem* ContextMenu::AddSeparator(void)
-{
- Gtk::SeparatorMenuItem* sep = Gtk::manage(new Gtk::SeparatorMenuItem());
- sep->show();
- append(*sep);
- return sep;
-}
-
-void ContextMenu::EnterGroup(Gtk::MenuItem* mi)
-{
- _desktop->setCurrentLayer(reinterpret_cast<SPObject *>(mi->get_data("group")));
- _desktop->selection->clear();
-}
-
-void ContextMenu::LeaveGroup(void)
-{
- _desktop->setCurrentLayer(_desktop->currentLayer()->parent);
-}
-
-void ContextMenu::LockSelected(void)
-{
- auto itemlist = _desktop->selection->items();
- for(auto i=itemlist.begin();i!=itemlist.end(); ++i) {
- (*i)->setLocked(true);
- }
-}
-
-void ContextMenu::HideSelected(void)
-{
- auto itemlist =_desktop->selection->items();
- for(auto i=itemlist.begin();i!=itemlist.end(); ++i) {
- (*i)->setHidden(true);
- }
-}
-
-void ContextMenu::UnLockBelow(std::vector<SPItem *> items)
-{
- _desktop->selection->clear();
- for(auto i=items.begin();i!=items.end(); ++i) {
- if ((*i)->isLocked()) {
- (*i)->setLocked(false);
- _desktop->selection->add(*i);
- }
- }
-}
-
-void ContextMenu::UnHideBelow(std::vector<SPItem *> items)
-{
- _desktop->selection->clear();
- for(auto i=items.begin();i!=items.end(); ++i) {
- if ((*i)->isHidden()) {
- (*i)->setHidden(false);
- _desktop->selection->add(*i);
- }
- }
-}
-
-void ContextMenu::AppendItemFromVerb(Inkscape::Verb *verb)//, SPDesktop *view)//, bool radio, GSList *group)
-{
- SPAction *action;
- SPDesktop *view = _desktop;
-
- if (verb->get_code() == SP_VERB_NONE) {
- Gtk::MenuItem *item = AddSeparator();
- item->show();
- append(*item);
- } else {
- action = verb->get_action(Inkscape::ActionContext(view));
- if (!action) {
- return;
- }
-
- Gtk::ImageMenuItem *item = Gtk::manage(new Gtk::ImageMenuItem(action->name, true));
-
- sp_shortcut_add_accelerator(GTK_WIDGET(item->gobj()), sp_shortcut_get_primary(verb));
-
- action->signal_set_sensitive.connect(sigc::mem_fun(*this, &ContextMenu::set_sensitive));
- action->signal_set_name.connect(sigc::mem_fun(*item, &ContextMenu::set_name));
-
- if (!action->sensitive) {
- item->set_sensitive(FALSE);
- }
-
- if (action->image) {
- sp_ui_menuitem_add_icon((GtkWidget*)item->gobj(), action->image);
- }
- item->set_events(Gdk::KEY_PRESS_MASK);
- item->signal_activate().connect(sigc::bind(sigc::ptr_fun(sp_ui_menu_activate),item,action));
- item->signal_select().connect(sigc::bind(sigc::ptr_fun(sp_ui_menu_select_action),item,action));
- item->signal_deselect().connect(sigc::bind(sigc::ptr_fun(sp_ui_menu_deselect_action),item,action));
- item->show();
- append(*item);
- }
-}
-
-void ContextMenu::MakeObjectMenu(void)
-{
-// GObjectClass *klass = G_OBJECT_GET_CLASS(_object); //to deduce the object's type from its class
-//
-// if (G_TYPE_CHECK_CLASS_TYPE(klass, SP_TYPE_ITEM))
-// {
-// MakeItemMenu ();
-// }
-// if (G_TYPE_CHECK_CLASS_TYPE(klass, SP_TYPE_GROUP))
-// {
-// MakeGroupMenu();
-// }
-// if (G_TYPE_CHECK_CLASS_TYPE(klass, SP_TYPE_ANCHOR))
-// {
-// MakeAnchorMenu();
-// }
-// if (G_TYPE_CHECK_CLASS_TYPE(klass, SP_TYPE_IMAGE))
-// {
-// MakeImageMenu();
-// }
-// if (G_TYPE_CHECK_CLASS_TYPE(klass, SP_TYPE_SHAPE))
-// {
-// MakeShapeMenu();
-// }
-// if (G_TYPE_CHECK_CLASS_TYPE(klass, SP_TYPE_TEXT))
-// {
-// MakeTextMenu();
-// }
-
- if (SP_IS_ITEM(_object)) {
- MakeItemMenu();
- }
-
- if (SP_IS_GROUP(_object)) {
- MakeGroupMenu();
- }
-
- if (SP_IS_ANCHOR(_object)) {
- MakeAnchorMenu();
- }
-
- if (SP_IS_IMAGE(_object)) {
- MakeImageMenu();
- }
-
- if (SP_IS_SHAPE(_object)) {
- MakeShapeMenu();
- }
-
- if (SP_IS_TEXT(_object)) {
- MakeTextMenu();
- }
-}
-
-void ContextMenu::MakeItemMenu (void)
-{
- Gtk::MenuItem* mi;
-
- /* Item dialog */
- mi = Gtk::manage(new Gtk::MenuItem(_("_Object Properties..."),1));
- mi->signal_activate().connect(sigc::mem_fun(*this, &ContextMenu::ItemProperties));
- mi->show();
- append(*mi);//insert(*mi,positionOfLastDialog++);
-
- AddSeparator();
-
- /* Select item */
- if (Inkscape::Verb::getbyid( "org.inkscape.followlink" )) {
- mi = Gtk::manage(new Gtk::MenuItem(_("_Select This"), 1));
- if (_desktop->selection->includes(_item)) {
- mi->set_sensitive(FALSE);
- } else {
- mi->signal_activate().connect(sigc::mem_fun(*this, &ContextMenu::ItemSelectThis));
- }
- mi->show();
- append(*mi);
- }
-
-
- mi = Gtk::manage(new Gtk::MenuItem(_("Select Same")));
- mi->show();
- Gtk::Menu *select_same_submenu = Gtk::manage(new Gtk::Menu());
- if (_desktop->selection->isEmpty()) {
- mi->set_sensitive(FALSE);
- }
- mi->set_submenu(*select_same_submenu);
- append(*mi);
-
- /* Select same fill and stroke */
- mi = Gtk::manage(new Gtk::MenuItem(_("Fill and Stroke"), 1));
- mi->signal_activate().connect(sigc::mem_fun(*this, &ContextMenu::SelectSameFillStroke));
- mi->set_sensitive(!SP_IS_ANCHOR(_item));
- mi->show();
- select_same_submenu->append(*mi);
-
- /* Select same fill color */
- mi = Gtk::manage(new Gtk::MenuItem(_("Fill Color"), 1));
- mi->signal_activate().connect(sigc::mem_fun(*this, &ContextMenu::SelectSameFillColor));
- mi->set_sensitive(!SP_IS_ANCHOR(_item));
- mi->show();
- select_same_submenu->append(*mi);
-
- /* Select same stroke color */
- mi = Gtk::manage(new Gtk::MenuItem(_("Stroke Color"), 1));
- mi->signal_activate().connect(sigc::mem_fun(*this, &ContextMenu::SelectSameStrokeColor));
- mi->set_sensitive(!SP_IS_ANCHOR(_item));
- mi->show();
- select_same_submenu->append(*mi);
-
- /* Select same stroke style */
- mi = Gtk::manage(new Gtk::MenuItem(_("Stroke Style"), 1));
- mi->signal_activate().connect(sigc::mem_fun(*this, &ContextMenu::SelectSameStrokeStyle));
- mi->set_sensitive(!SP_IS_ANCHOR(_item));
- mi->show();
- select_same_submenu->append(*mi);
-
- /* Select same stroke style */
- mi = Gtk::manage(new Gtk::MenuItem(_("Object type"), 1));
- mi->signal_activate().connect(sigc::mem_fun(*this, &ContextMenu::SelectSameObjectType));
- mi->set_sensitive(!SP_IS_ANCHOR(_item));
- mi->show();
- select_same_submenu->append(*mi);
-
- /* Move to layer */
- mi = Gtk::manage(new Gtk::MenuItem(_("_Move to layer ..."), 1));
- if (_desktop->selection->isEmpty()) {
- mi->set_sensitive(FALSE);
- } else {
- mi->signal_activate().connect(sigc::mem_fun(*this, &ContextMenu::ItemMoveTo));
- }
- mi->show();
- append(*mi);
-
- /* Create link */
- mi = Gtk::manage(new Gtk::MenuItem(_("Create _Link"), 1));
- mi->signal_activate().connect(sigc::mem_fun(*this, &ContextMenu::ItemCreateLink));
- mi->set_sensitive(!SP_IS_ANCHOR(_item));
- mi->show();
- append(*mi);
-
- bool ClipRefOK=false;
- bool MaskRefOK=false;
- if (_item){
- if (_item->clip_ref){
- if (_item->clip_ref->getObject()){
- ClipRefOK=true;
- }
- }
- }
- if (_item){
- if (_item->mask_ref){
- if (_item->mask_ref->getObject()){
- MaskRefOK=true;
- }
- }
- }
- /* Set mask */
- mi = Gtk::manage(new Gtk::MenuItem(_("Set Mask"), 1));
- mi->signal_activate().connect(sigc::mem_fun(*this, &ContextMenu::SetMask));
- if (ClipRefOK || MaskRefOK) {
- mi->set_sensitive(FALSE);
- } else {
- mi->set_sensitive(TRUE);
- }
- mi->show();
- append(*mi);
-
- /* Release mask */
- mi = Gtk::manage(new Gtk::MenuItem(_("Release Mask"), 1));
- mi->signal_activate().connect(sigc::mem_fun(*this, &ContextMenu::ReleaseMask));
- if (MaskRefOK) {
- mi->set_sensitive(TRUE);
- } else {
- mi->set_sensitive(FALSE);
- }
- mi->show();
- append(*mi);
-
- /*SSet Clip Group */
- mi = Gtk::manage(new Gtk::MenuItem(_("Create Clip G_roup"),1));
- mi->signal_activate().connect(sigc::mem_fun(*this, &ContextMenu::CreateGroupClip));
- mi->set_sensitive(TRUE);
- mi->show();
- append(*mi);
-
- /* Set Clip */
- mi = Gtk::manage(new Gtk::MenuItem(_("Set Cl_ip"), 1));
- mi->signal_activate().connect(sigc::mem_fun(*this, &ContextMenu::SetClip));
- if (ClipRefOK || MaskRefOK) {
- mi->set_sensitive(FALSE);
- } else {
- mi->set_sensitive(TRUE);
- }
- mi->show();
- append(*mi);
-
- /* Release Clip */
- mi = Gtk::manage(new Gtk::MenuItem(_("Release C_lip"), 1));
- mi->signal_activate().connect(sigc::mem_fun(*this, &ContextMenu::ReleaseClip));
- if (ClipRefOK) {
- mi->set_sensitive(TRUE);
- } else {
- mi->set_sensitive(FALSE);
- }
- mi->show();
- append(*mi);
-
- /* Group */
- mi = Gtk::manage(new Gtk::MenuItem(_("_Group"), 1));
- mi->signal_activate().connect(sigc::mem_fun(*this, &ContextMenu::ActivateGroup));
- if (_desktop->selection->isEmpty()) {
- mi->set_sensitive(FALSE);
- } else {
- mi->set_sensitive(TRUE);
- }
- mi->show();
- append(*mi);
-}
-
-void ContextMenu::SelectSameFillStroke(void)
-{
- sp_select_same_fill_stroke_style(_desktop, true, true, true);
-}
-
-void ContextMenu::SelectSameFillColor(void)
-{
- sp_select_same_fill_stroke_style(_desktop, true, false, false);
-}
-
-void ContextMenu::SelectSameStrokeColor(void)
-{
- sp_select_same_fill_stroke_style(_desktop, false, true, false);
-}
-
-void ContextMenu::SelectSameStrokeStyle(void)
-{
- sp_select_same_fill_stroke_style(_desktop, false, false, true);
-}
-
-void ContextMenu::SelectSameObjectType(void)
-{
- sp_select_same_object_type(_desktop);
-}
-
-void ContextMenu::ItemProperties(void)
-{
- _desktop->selection->set(_item);
- _desktop->_dlg_mgr->showDialog("ObjectProperties");
-}
-
-void ContextMenu::ItemSelectThis(void)
-{
- _desktop->selection->set(_item);
-}
-
-void ContextMenu::ItemMoveTo(void)
-{
- Inkscape::UI::Dialogs::LayerPropertiesDialog::showMove(_desktop, _desktop->currentLayer());
-}
-
-
-
-void ContextMenu::ItemCreateLink(void)
-{
- Inkscape::XML::Document *xml_doc = _desktop->doc()->getReprDoc();
- Inkscape::XML::Node *repr = xml_doc->createElement("svg:a");
- _item->parent->getRepr()->addChild(repr, _item->getRepr());
- SPObject *object = _item->document->getObjectByRepr(repr);
- g_return_if_fail(SP_IS_ANCHOR(object));
-
- const char *id = _item->getRepr()->attribute("id");
- Inkscape::XML::Node *child = _item->getRepr()->duplicate(xml_doc);
- _item->deleteObject(false);
- repr->addChild(child, NULL);
- child->setAttribute("id", id);
-
- Inkscape::GC::release(repr);
- Inkscape::GC::release(child);
-
- DocumentUndo::done(object->document, SP_VERB_NONE, _("Create link"));
-
- _desktop->selection->set(SP_ITEM(object));
- _desktop->_dlg_mgr->showDialog("ObjectAttributes");
-}
-
-void ContextMenu::SetMask(void)
-{
- _desktop->selection->setMask(false, false);
-}
-
-void ContextMenu::ReleaseMask(void)
-{
- _desktop->selection->unsetMask(false);
-}
-
-void ContextMenu::CreateGroupClip(void)
-{
- _desktop->selection->setClipGroup();
-}
-
-void ContextMenu::SetClip(void)
-{
- _desktop->selection->setMask(true, false);
-}
-
-
-void ContextMenu::ReleaseClip(void)
-{
- _desktop->selection->unsetMask(true);
-}
-
-void ContextMenu::MakeGroupMenu(void)
-{
- /* Ungroup */
- Gtk::MenuItem* mi = Gtk::manage(new Gtk::MenuItem(_("_Ungroup"), 1));
- mi->signal_activate().connect(sigc::mem_fun(*this, &ContextMenu::ActivateUngroup));
- mi->show();
- append(*mi);
-}
-
-void ContextMenu::ActivateGroup(void)
-{
- _desktop->selection->group();
-}
-
-void ContextMenu::ActivateUngroup(void)
-{
- std::vector<SPItem*> children;
-
- sp_item_group_ungroup(static_cast<SPGroup*>(_item), children);
- _desktop->selection->setList(children);
-}
-
-void ContextMenu::ActivateUngroupPopSelection(void)
-{
- _desktop->selection->popFromGroup();
-}
-
-
-void ContextMenu::MakeAnchorMenu(void)
-{
- Gtk::MenuItem* mi;
-
- /* Link dialog */
- mi = Gtk::manage(new Gtk::MenuItem(_("Link _Properties..."), 1));
- mi->signal_activate().connect(sigc::mem_fun(*this, &ContextMenu::AnchorLinkProperties));
- mi->show();
- insert(*mi,positionOfLastDialog++);
-
- /* Select item */
- mi = Gtk::manage(new Gtk::MenuItem(_("_Follow Link"), 1));
- mi->signal_activate().connect(sigc::mem_fun(*this, &ContextMenu::AnchorLinkFollow));
- mi->show();
- append(*mi);
-
- /* Reset transformations */
- mi = Gtk::manage(new Gtk::MenuItem(_("_Remove Link"), 1));
- mi->signal_activate().connect(sigc::mem_fun(*this, &ContextMenu::AnchorLinkRemove));
- mi->show();
- append(*mi);
-}
-
-void ContextMenu::AnchorLinkProperties(void)
-{
- _desktop->_dlg_mgr->showDialog("ObjectAttributes");
-}
-
-void ContextMenu::AnchorLinkFollow(void)
-{
-
- if (_desktop->selection->isEmpty()) {
- _desktop->selection->set(_item);
- }
- // Opening the selected links with a python extension
- Inkscape::Verb *verb = Inkscape::Verb::getbyid( "org.inkscape.followlink" );
- if (verb) {
- SPAction *action = verb->get_action(Inkscape::ActionContext(_desktop));
- if (action) {
- sp_action_perform(action, NULL);
- }
- }
-}
-
-void ContextMenu::AnchorLinkRemove(void)
-{
- std::vector<SPItem*> children;
- sp_item_group_ungroup(static_cast<SPAnchor*>(_item), children, false);
- DocumentUndo::done(_desktop->doc(), SP_VERB_NONE, _("Remove link"));
-}
-
-void ContextMenu::MakeImageMenu (void)
-{
- Gtk::MenuItem* mi;
- Inkscape::XML::Node *ir = _object->getRepr();
- const gchar *href = ir->attribute("xlink:href");
-
- /* Image properties */
- mi = Gtk::manage(new Gtk::MenuItem(_("Image _Properties..."), 1));
- mi->signal_activate().connect(sigc::mem_fun(*this, &ContextMenu::ImageProperties));
- mi->show();
- insert(*mi,positionOfLastDialog++);
-
- /* Edit externally */
- mi = Gtk::manage(new Gtk::MenuItem(_("Edit Externally..."), 1));
- mi->signal_activate().connect(sigc::mem_fun(*this, &ContextMenu::ImageEdit));
- mi->show();
- insert(*mi,positionOfLastDialog++);
- if ( (!href) || ((strncmp(href, "data:", 5) == 0)) ) {
- mi->set_sensitive( FALSE );
- }
-
- /* Trace Bitmap */
- mi = Gtk::manage(new Gtk::MenuItem(_("_Trace Bitmap..."), 1));
- mi->signal_activate().connect(sigc::mem_fun(*this, &ContextMenu::ImageTraceBitmap));
- mi->show();
- insert(*mi,positionOfLastDialog++);
- if (_desktop->selection->isEmpty()) {
- mi->set_sensitive(FALSE);
- }
-
- /* Trace Pixel Art */
- mi = Gtk::manage(new Gtk::MenuItem(_("Trace Pixel Art"), 1));
- mi->signal_activate().connect(sigc::mem_fun(*this, &ContextMenu::ImageTracePixelArt));
- mi->show();
- insert(*mi,positionOfLastDialog++);
- if (_desktop->selection->isEmpty()) {
- mi->set_sensitive(FALSE);
- }
-
- /* Embed image */
- if (Inkscape::Verb::getbyid( "org.ekips.filter.embedselectedimages" )) {
- mi = Gtk::manage(new Gtk::MenuItem(C_("Context menu", "Embed Image")));
- mi->signal_activate().connect(sigc::mem_fun(*this, &ContextMenu::ImageEmbed));
- mi->show();
- insert(*mi,positionOfLastDialog++);
- if ( (!href) || ((strncmp(href, "data:", 5) == 0)) ) {
- mi->set_sensitive( FALSE );
- }
- }
-
- /* Extract image */
- if (Inkscape::Verb::getbyid( "org.ekips.filter.extractimage" )) {
- mi = Gtk::manage(new Gtk::MenuItem(C_("Context menu", "Extract Image...")));
- mi->signal_activate().connect(sigc::mem_fun(*this, &ContextMenu::ImageExtract));
- mi->show();
- insert(*mi,positionOfLastDialog++);
- if ( (!href) || ((strncmp(href, "data:", 5) != 0)) ) {
- mi->set_sensitive( FALSE );
- }
- }
-}
-
-void ContextMenu::ImageProperties(void)
-{
- _desktop->_dlg_mgr->showDialog("ObjectAttributes");
-}
-
-Glib::ustring ContextMenu::getImageEditorName() {
- Inkscape::Preferences *prefs = Inkscape::Preferences::get();
- Glib::ustring value;
- Glib::ustring choices = prefs->getString("/options/bitmapeditor/value");
- if (!choices.empty()) {
- value = choices;
- }
- else {
- value = "gimp";
- }
- return value;
-}
-
-void ContextMenu::ImageEdit(void)
-{
- if (_desktop->selection->isEmpty()) {
- _desktop->selection->set(_item);
- }
-
- GError* errThing = 0;
- Glib::ustring cmdline = getImageEditorName();
- Glib::ustring name;
- Glib::ustring fullname;
-
-#ifdef WIN32
- // g_spawn_command_line_sync parsing is done according to Unix shell rules,
- // not Windows command interpreter rules. Thus we need to enclose the
- // executable path with single quotes.
- int index = cmdline.find(".exe");
- if ( index < 0 ) index = cmdline.find(".bat");
- if ( index < 0 ) index = cmdline.find(".com");
- if ( index >= 0 ) {
- Glib::ustring editorBin = cmdline.substr(0, index + 4).c_str();
- Glib::ustring args = cmdline.substr(index + 4, cmdline.length()).c_str();
- editorBin.insert(0, "'");
- editorBin.append("'");
- cmdline = editorBin;
- cmdline.append(args);
- } else {
- // Enclose the whole command line if no executable path can be extracted.
- cmdline.insert(0, "'");
- cmdline.append("'");
- }
-#endif
-
- auto itemlist= _desktop->selection->items();
- for(auto i=itemlist.begin();i!=itemlist.end();++i){
- Inkscape::XML::Node *ir = (*i)->getRepr();
- const gchar *href = ir->attribute("xlink:href");
-
- if (strncmp (href,"file:",5) == 0) {
- // URI to filename conversion
- name = g_filename_from_uri(href, NULL, NULL);
- } else {
- name.append(href);
- }
-
- if (Glib::path_is_absolute(name)) {
- fullname = name;
- } else if (SP_ACTIVE_DOCUMENT->getBase()) {
- fullname = Glib::build_filename(SP_ACTIVE_DOCUMENT->getBase(), name);
- } else {
- fullname = Glib::build_filename(Glib::get_current_dir(), name);
- }
-
- cmdline.append(" '");
- cmdline.append(fullname.c_str());
- cmdline.append("'");
- }
-
- //g_warning("##Command line: %s\n", cmdline.c_str());
-
- g_spawn_command_line_async(cmdline.c_str(), &errThing);
-
- if ( errThing ) {
- g_warning("Problem launching editor (%d). %s", errThing->code, errThing->message);
- (_desktop->messageStack())->flash(Inkscape::ERROR_MESSAGE, errThing->message);
- g_error_free(errThing);
- errThing = 0;
- }
-}
-
-void ContextMenu::ImageTraceBitmap(void)
-{
- INKSCAPE.dialogs_unhide();
- _desktop->_dlg_mgr->showDialog("Trace");
-}
-
-void ContextMenu::ImageTracePixelArt(void)
-{
- INKSCAPE.dialogs_unhide();
- _desktop->_dlg_mgr->showDialog("PixelArt");
-}
-
-void ContextMenu::ImageEmbed(void)
-{
- if (_desktop->selection->isEmpty()) {
- _desktop->selection->set(_item);
- }
-
- Inkscape::Verb *verb = Inkscape::Verb::getbyid( "org.ekips.filter.embedselectedimages" );
- if (verb) {
- SPAction *action = verb->get_action(Inkscape::ActionContext(_desktop));
- if (action) {
- sp_action_perform(action, NULL);
- }
- }
-}
-
-void ContextMenu::ImageExtract(void)
-{
- if (_desktop->selection->isEmpty()) {
- _desktop->selection->set(_item);
- }
-
- Inkscape::Verb *verb = Inkscape::Verb::getbyid( "org.ekips.filter.extractimage" );
- if (verb) {
- SPAction *action = verb->get_action(Inkscape::ActionContext(_desktop));
- if (action) {
- sp_action_perform(action, NULL);
- }
- }
-}
-
-void ContextMenu::MakeShapeMenu (void)
-{
- Gtk::MenuItem* mi;
-
- /* Item dialog */
- mi = Gtk::manage(new Gtk::MenuItem(_("_Fill and Stroke..."), 1));
- mi->signal_activate().connect(sigc::mem_fun(*this, &ContextMenu::FillSettings));
- mi->show();
- insert(*mi,positionOfLastDialog++);
-}
-
-void ContextMenu::FillSettings(void)
-{
- if (_desktop->selection->isEmpty()) {
- _desktop->selection->set(_item);
- }
-
- _desktop->_dlg_mgr->showDialog("FillAndStroke");
-}
-
-void ContextMenu::MakeTextMenu (void)
-{
- Gtk::MenuItem* mi;
-
- /* Fill and Stroke dialog */
- mi = Gtk::manage(new Gtk::MenuItem(_("_Fill and Stroke..."), 1));
- mi->signal_activate().connect(sigc::mem_fun(*this, &ContextMenu::FillSettings));
- mi->show();
- insert(*mi,positionOfLastDialog++);
-
- /* Edit Text dialog */
- mi = Gtk::manage(new Gtk::MenuItem(_("_Text and Font..."), 1));
- mi->signal_activate().connect(sigc::mem_fun(*this, &ContextMenu::TextSettings));
- mi->show();
- insert(*mi,positionOfLastDialog++);
-
- /* Spellcheck dialog */
- mi = Gtk::manage(new Gtk::MenuItem(_("Check Spellin_g..."), 1));
- mi->signal_activate().connect(sigc::mem_fun(*this, &ContextMenu::SpellcheckSettings));
- mi->show();
- insert(*mi,positionOfLastDialog++);
-}
-
-void ContextMenu::TextSettings (void)
-{
- if (_desktop->selection->isEmpty()) {
- _desktop->selection->set(_item);
- }
-
- _desktop->_dlg_mgr->showDialog("TextFont");
-}
-
-void ContextMenu::SpellcheckSettings (void)
-{
- if (_desktop->selection->isEmpty()) {
- _desktop->selection->set(_item);
- }
-
- _desktop->_dlg_mgr->showDialog("SpellCheck");
-}
-
/*
Local Variables:
mode:c++
diff --git a/src/ui/interface.h b/src/ui/interface.h
index a41c36cc3..6e95c161c 100644
--- a/src/ui/interface.h
+++ b/src/ui/interface.h
@@ -17,23 +17,13 @@
* Released under GNU GPL, read the file 'COPYING' for more information
*/
-//#ifdef HAVE_CONFIG_H
-//# include <config.h>
-//#endif
+#include <glibmm/ustring.h>
-#include <gtkmm/menu.h>
-
-class SPItem;
-class SPObject;
-class SPDesktop;
class SPViewWidget;
-namespace Gtk {
-class SeparatorMenuItem;
-}
+typedef struct _GtkWidget GtkWidget;
namespace Inkscape {
-
class Verb;
namespace UI {
@@ -93,181 +83,6 @@ Glib::ustring getLayoutPrefPath( Inkscape::UI::View::View *view );
void sp_ui_error_dialog (char const* message);
bool sp_ui_overwrite_file (char const* filename);
-
-/**
- * Implements the Inkscape context menu.
- *
- * For the context menu implementation, the ContextMenu class stores the object
- * that was selected in a private data member. This should be farely safe to do
- * and a pointer to the SPItem as well as SPObject class are kept.
- * All callbacks of the context menu entries are implemented as private
- * functions.
- *
- * @todo add callbacks to destroy the context menu when it is closed (=key or mouse button pressed out of the scope of the context menu)
- */
-class ContextMenu : public Gtk::Menu
-{
- public:
- /**
- * The ContextMenu constructor contains all code to create and show the
- * menu entries (aka child widgets).
- *
- * @param desktop pointer to the desktop the user is currently working on.
- * @param item SPItem pointer to the object selected at the time the ContextMenu is created.
- */
- ContextMenu(SPDesktop *desktop, SPItem *item);
- ~ContextMenu(void);
-
- private:
- SPItem *_item; // pointer to the object selected at the time the ContextMenu is created
- SPObject *_object; // pointer to the object selected at the time the ContextMenu is created
- SPDesktop *_desktop; //pointer to the desktop the user was currently working on at the time the ContextMenu is created
-
- int positionOfLastDialog;
-
- Gtk::MenuItem MIGroup; //menu entry to enter a group
- Gtk::MenuItem MIParent; //menu entry to leave a group
-
- /**
- * auxiliary function that adds a separator line in the context menu
- */
- Gtk::SeparatorMenuItem* AddSeparator(void);
-
- /**
- * c++ified version of sp_ui_menu_append_item.
- *
- * @see sp_ui_menu_append_item_from_verb and synchronize/drop that function when c++ifying other code in interface.cpp
- */
- void AppendItemFromVerb(Inkscape::Verb *verb);
-
- /**
- * main function which is responsible for creating the context sensitive menu items,
- * calls subfunctions below to create the menu entry widgets.
- */
- void MakeObjectMenu (void);
- /**
- * creates menu entries for an SP_TYPE_ITEM object
- */
- void MakeItemMenu (void);
- /**
- * creates menu entries for a grouped object
- */
- void MakeGroupMenu (void);
- /**
- * creates menu entries for an anchor object
- */
- void MakeAnchorMenu (void);
- /**
- * creates menu entries for a bitmap image object
- */
- void MakeImageMenu (void);
- /**
- * creates menu entries for a shape object
- */
- void MakeShapeMenu (void);
- /**
- * creates menu entries for a text object
- */
- void MakeTextMenu (void);
-
- void EnterGroup(Gtk::MenuItem* mi);
- void LeaveGroup(void);
- void LockSelected(void);
- void HideSelected(void);
- void UnLockBelow(std::vector<SPItem *> items);
- void UnHideBelow(std::vector<SPItem *> items);
- //////////////////////////////////////////
- //callbacks for the context menu entries of an SP_TYPE_ITEM object
- void ItemProperties(void);
- void ItemSelectThis(void);
- void ItemMoveTo(void);
- void SelectSameFillStroke(void);
- void SelectSameFillColor(void);
- void SelectSameStrokeColor(void);
- void SelectSameStrokeStyle(void);
- void SelectSameObjectType(void);
- void ItemCreateLink(void);
- void CreateGroupClip(void);
- void SetMask(void);
- void ReleaseMask(void);
- void SetClip(void);
- void ReleaseClip(void);
- //////////////////////////////////////////
-
-
- /**
- * callback, is executed on clicking the anchor "Group" and "Ungroup" menu entry
- */
- void ActivateUngroupPopSelection(void);
- void ActivateUngroup(void);
- void ActivateGroup(void);
-
- void AnchorLinkProperties(void);
- /**
- * placeholder for callback to be executed on clicking the anchor "Follow link" context menu entry
- * @todo add code to follow link externally
- */
- void AnchorLinkFollow(void);
-
- /**
- * callback, is executed on clicking the anchor "Link remove" menu entry
- */
- void AnchorLinkRemove(void);
-
-
- /**
- * callback, opens the image properties dialog and is executed on clicking the context menu entry with similar name
- */
- void ImageProperties(void);
-
- /**
- * callback, is executed on clicking the image "Edit Externally" menu entry
- */
- void ImageEdit(void);
-
- /**
- * auxiliary function that loads the external image editor name from the settings.
- */
- Glib::ustring getImageEditorName();
-
- /**
- * callback, is executed on clicking the "Embed Image" menu entry
- */
- void ImageEmbed(void);
-
- /**
- * callback, is executed on clicking the "Trace Bitmap" menu entry
- */
- void ImageTraceBitmap(void);
-
- /**
- * callback, is executed on clicking the "Trace Pixel Art" menu entry
- */
- void ImageTracePixelArt(void);
-
- /**
- * callback, is executed on clicking the "Extract Image" menu entry
- */
- void ImageExtract(void);
-
-
- /**
- * callback, is executed on clicking the "Fill and Stroke" menu entry
- */
- void FillSettings(void);
-
-
- /**
- * callback, is executed on clicking the "Text and Font" menu entry
- */
- void TextSettings(void);
-
- /**
- * callback, is executed on clicking the "Check spelling" menu entry
- */
- void SpellcheckSettings(void);
-};
-
#endif // SEEN_SP_INTERFACE_H
/*
diff --git a/src/ui/previewholder.cpp b/src/ui/previewholder.cpp
index 6fec65124..e294bd408 100644
--- a/src/ui/previewholder.cpp
+++ b/src/ui/previewholder.cpp
@@ -149,7 +149,6 @@ void PreviewHolder::addPreview( Previewable* preview )
auto target = kids[childCount - (j + 1)];
int col2 = j % width;
int row2 = j / width;
- Glib::RefPtr<Gtk::Widget> handle(target);
_insides->remove( *target );
target->set_hexpand();
diff --git a/src/ui/tools/arc-tool.cpp b/src/ui/tools/arc-tool.cpp
index 6652f7ab5..01e0c3e00 100644
--- a/src/ui/tools/arc-tool.cpp
+++ b/src/ui/tools/arc-tool.cpp
@@ -59,7 +59,7 @@ const std::string ArcTool::prefsPath = "/tools/shapes/arc";
ArcTool::ArcTool()
- : ToolBase(cursor_ellipse_xpm, 4, 4)
+ : ToolBase(cursor_ellipse_xpm)
, arc(NULL)
{
}
diff --git a/src/ui/tools/box3d-tool.cpp b/src/ui/tools/box3d-tool.cpp
index 425695a2c..276385335 100644
--- a/src/ui/tools/box3d-tool.cpp
+++ b/src/ui/tools/box3d-tool.cpp
@@ -54,7 +54,7 @@ const std::string& Box3dTool::getPrefsPath() {
const std::string Box3dTool::prefsPath = "/tools/shapes/3dbox";
Box3dTool::Box3dTool()
- : ToolBase(cursor_3dbox_xpm, 4, 4)
+ : ToolBase(cursor_3dbox_xpm)
, _vpdrag(NULL)
, box3d(NULL)
, ctrl_dragged(false)
diff --git a/src/ui/tools/calligraphic-tool.cpp b/src/ui/tools/calligraphic-tool.cpp
index 7228a52bc..266375caa 100644
--- a/src/ui/tools/calligraphic-tool.cpp
+++ b/src/ui/tools/calligraphic-tool.cpp
@@ -88,7 +88,7 @@ const std::string& CalligraphicTool::getPrefsPath() {
const std::string CalligraphicTool::prefsPath = "/tools/calligraphic";
CalligraphicTool::CalligraphicTool()
- : DynamicBase(cursor_calligraphy_xpm, 4, 4)
+ : DynamicBase(cursor_calligraphy_xpm)
, keep_selected(true)
, hatch_spacing(0)
, hatch_spacing_step(0)
diff --git a/src/ui/tools/connector-tool.cpp b/src/ui/tools/connector-tool.cpp
index 7e6fb4b72..29be4831a 100644
--- a/src/ui/tools/connector-tool.cpp
+++ b/src/ui/tools/connector-tool.cpp
@@ -145,7 +145,7 @@ const std::string& ConnectorTool::getPrefsPath() {
const std::string ConnectorTool::prefsPath = "/tools/connector";
ConnectorTool::ConnectorTool()
- : ToolBase(cursor_connector_xpm, 1, 1)
+ : ToolBase(cursor_connector_xpm)
, selection(NULL)
, npoints(0)
, state(SP_CONNECTOR_CONTEXT_IDLE)
diff --git a/src/ui/tools/dropper-tool.cpp b/src/ui/tools/dropper-tool.cpp
index 99177dc75..4524d2445 100644
--- a/src/ui/tools/dropper-tool.cpp
+++ b/src/ui/tools/dropper-tool.cpp
@@ -39,6 +39,8 @@
#include "pixmaps/cursor-dropper-f.xpm"
#include "pixmaps/cursor-dropper-s.xpm"
+#include "pixmaps/cursor-dropping-f.xpm"
+#include "pixmaps/cursor-dropping-s.xpm"
#include "ui/tools/dropper-tool.h"
#include "message-context.h"
@@ -46,9 +48,6 @@
using Inkscape::DocumentUndo;
-static GdkCursor *cursor_dropper_fill = NULL;
-static GdkCursor *cursor_dropper_stroke = NULL;
-
namespace Inkscape {
namespace UI {
namespace Tools {
@@ -60,7 +59,7 @@ const std::string& DropperTool::getPrefsPath() {
const std::string DropperTool::prefsPath = "/tools/dropper";
DropperTool::DropperTool()
- : ToolBase(cursor_dropper_f_xpm, 5, 5)
+ : ToolBase(cursor_dropper_f_xpm)
, R(0)
, G(0)
, B(0)
@@ -70,8 +69,6 @@ DropperTool::DropperTool()
, area(NULL)
, centre(0, 0)
{
- cursor_dropper_fill = sp_cursor_new_from_xpm(cursor_dropper_f_xpm , 5, 5);
- cursor_dropper_stroke = sp_cursor_new_from_xpm(cursor_dropper_s_xpm , 5, 5);
}
DropperTool::~DropperTool() {
@@ -117,16 +114,6 @@ void DropperTool::finish() {
this->area = NULL;
}
- if (cursor_dropper_fill) {
- g_object_unref(cursor_dropper_fill);
- cursor_dropper_fill = NULL;
- }
-
- if (cursor_dropper_stroke) {
- g_object_unref(cursor_dropper_stroke);
- cursor_dropper_fill = NULL;
- }
-
ToolBase::finish();
}
@@ -149,9 +136,29 @@ bool DropperTool::root_handler(GdkEvent* event) {
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
int ret = FALSE;
-
int pick = prefs->getInt("/tools/dropper/pick", SP_DROPPER_PICK_VISIBLE);
bool setalpha = prefs->getBool("/tools/dropper/setalpha", true);
+ bool fill = !(event->button.state & GDK_SHIFT_MASK); // Stroke if Shift key held
+ bool apply = event->button.state & GDK_CONTROL_MASK; // Apply if Ctrl key held
+ int draw_cursor = fill ? DRAW_FILL_CURSOR : DRAW_STROKE_CURSOR;
+
+ // Get color from selected object instead.
+ guint32 apply_color = 0;
+ if(apply) {
+ Inkscape::Selection *selection = desktop->getSelection();
+ g_assert(selection);
+ for (auto& obj: selection->objects()) {
+ if(obj->style) {
+ if(obj->style->fill.set) {
+ double opacity = 1.0;
+ if(obj->style->fill_opacity.set) {
+ opacity = obj->style->fill_opacity.value;
+ }
+ apply_color = obj->style->fill.value.color.toRGBA32(opacity);
+ }
+ }
+ }
+ }
switch (event->type) {
case GDK_BUTTON_PRESS:
@@ -160,11 +167,12 @@ bool DropperTool::root_handler(GdkEvent* event) {
this->dragging = true;
ret = TRUE;
}
-
- sp_canvas_item_grab(SP_CANVAS_ITEM(desktop->acetate),
- GDK_KEY_PRESS_MASK | GDK_KEY_RELEASE_MASK | GDK_BUTTON_RELEASE_MASK | GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK,
- NULL, event->button.time);
- this->grabbed = SP_CANVAS_ITEM(desktop->acetate);
+
+ sp_canvas_item_grab(SP_CANVAS_ITEM(desktop->acetate),
+ GDK_KEY_PRESS_MASK | GDK_KEY_RELEASE_MASK | GDK_BUTTON_RELEASE_MASK |
+ GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK,
+ NULL, event->button.time);
+ this->grabbed = SP_CANVAS_ITEM(desktop->acetate);
break;
case GDK_MOTION_NOTIFY:
@@ -174,14 +182,6 @@ bool DropperTool::root_handler(GdkEvent* event) {
break;
} else if (!this->space_panning) {
// otherwise, constantly calculate color no matter is any button pressed or not
-
- // If one time pick with stroke set the pixmap
- if (prefs->getBool("/tools/dropper/onetimepick", false) && prefs->getInt("/dialogs/fillstroke/page", 0) == 1) {
- //TODO Only set when not set already
- GdkWindow* window = gtk_widget_get_window(GTK_WIDGET(desktop->getCanvas()));
- gdk_window_set_cursor(window, cursor_dropper_stroke);
- }
-
double rw = 0.0;
double R(0), G(0), B(0), A(0);
@@ -242,10 +242,12 @@ bool DropperTool::root_handler(GdkEvent* event) {
}
// remember color
- this->R = R;
- this->G = G;
- this->B = B;
- this->alpha = A;
+ if(R != this->R || G != this->G || B != this->B || A != this->alpha) {
+ this->R = R;
+ this->G = G;
+ this->B = B;
+ this->alpha = A;
+ }
// status message
double alpha_to_set = setalpha? this->alpha : 1.0;
@@ -276,36 +278,47 @@ bool DropperTool::root_handler(GdkEvent* event) {
case GDK_BUTTON_RELEASE:
if (event->button.button == 1 && !this->space_panning) {
- sp_canvas_item_hide(this->area);
- this->dragging = false;
-
- if (this->grabbed) {
- sp_canvas_item_ungrab(this->grabbed, event->button.time);
- this->grabbed = NULL;
- }
-
double alpha_to_set = setalpha? this->alpha : 1.0;
+ sp_canvas_item_hide(this->area);
+ this->dragging = false;
+
+ if (this->grabbed) {
+ sp_canvas_item_ungrab(this->grabbed, event->button.time);
+ this->grabbed = NULL;
+ }
+
+ if(apply) {
+ Geom::Point const button_w(event->button.x, event->button.y);
+ // remember clicked item, disregarding groups, honoring Alt
+ this->item_to_select = sp_event_context_find_item (desktop, button_w, event->button.state & GDK_MOD1_MASK, TRUE);
+
+ // Change selected object to object under cursor
+ if (this->item_to_select) {
+ Inkscape::Selection *selection = desktop->getSelection();
+ g_assert(selection);
+ selection->set(this->item_to_select);
+ }
- bool fill = !(event->button.state & GDK_SHIFT_MASK); // Stroke if Shift key held
+ this->R = SP_RGBA32_R_F(apply_color);
+ this->G = SP_RGBA32_G_F(apply_color);
+ this->B = SP_RGBA32_B_F(apply_color);
+ this->alpha = SP_RGBA32_A_F(apply_color);
+ alpha_to_set = this->alpha;
- if (prefs->getBool("/tools/dropper/onetimepick", false)) {
- // "One time" pick from Fill/Stroke dialog stroke page, always apply fill or stroke (ignore <Shift> key)
- fill = (prefs->getInt("/dialogs/fillstroke/page", 0) == 0) ? true : false;
+ } else {
+ if (prefs->getBool("/tools/dropper/onetimepick", false)) {
+ // "One time" pick from Fill/Stroke dialog stroke page, always apply fill or stroke (ignore <Shift> key)
+ fill = (prefs->getInt("/dialogs/fillstroke/page", 0) == 0) ? true : false;
+ }
}
// do the actual color setting
sp_desktop_set_color(desktop,
- (event->button.state & GDK_MOD1_MASK)?
- ColorRGBA(1 - this->R, 1 - this->G, 1 - this->B, alpha_to_set) : ColorRGBA(this->R, this->G, this->B, alpha_to_set),
- false, fill);
+ (event->button.state & GDK_MOD1_MASK)?
+ ColorRGBA(1 - this->R, 1 - this->G, 1 - this->B, alpha_to_set) : ColorRGBA(this->R, this->G, this->B, alpha_to_set),
+ false, fill);
// REJON: set aux. toolbar input to hex color!
-
- if (event->button.state & GDK_SHIFT_MASK) {
- GdkWindow* window = gtk_widget_get_window(GTK_WIDGET(desktop->getCanvas()));
- gdk_window_set_cursor(window, cursor_dropper_stroke);
- }
-
if (!(desktop->getSelection()->isEmpty())) {
DocumentUndo::done(desktop->getDocument(), SP_VERB_CONTEXT_DROPPER,
_("Set picked color"));
@@ -340,11 +353,7 @@ bool DropperTool::root_handler(GdkEvent* event) {
desktop->getSelection()->clear();
case GDK_KEY_Shift_L:
case GDK_KEY_Shift_R:
- if (!desktop->isWaitingCursor() && !prefs->getBool("/tools/dropper/onetimepick", false)) {
- GdkWindow* window = gtk_widget_get_window(GTK_WIDGET(desktop->getCanvas()));
- gdk_window_set_cursor(window, cursor_dropper_stroke);
- }
-
+ draw_cursor = DRAW_STROKE_CURSOR;
break;
default:
break;
@@ -355,10 +364,7 @@ bool DropperTool::root_handler(GdkEvent* event) {
switch (get_group0_keyval(&event->key)) {
case GDK_KEY_Shift_L:
case GDK_KEY_Shift_R:
- if (!desktop->isWaitingCursor() && !prefs->getBool("/tools/dropper/onetimepick", false)) {
- GdkWindow* window = gtk_widget_get_window(GTK_WIDGET(desktop->getCanvas()));
- gdk_window_set_cursor(window, cursor_dropper_fill);
- }
+ draw_cursor = DRAW_FILL_CURSOR;
break;
default:
@@ -370,6 +376,25 @@ bool DropperTool::root_handler(GdkEvent* event) {
break;
}
+ if(draw_cursor != DONT_REDRAW_CURSOR && !desktop->isWaitingCursor() && !prefs->getBool("/tools/dropper/onetimepick", false)) {
+ GdkCursor *cursor;
+ if(apply) {
+ if(draw_cursor == DRAW_FILL_CURSOR) {
+ cursor = sp_cursor_from_xpm(cursor_dropping_f_xpm, NULL, NULL, apply_color);
+ } else if(draw_cursor == DRAW_STROKE_CURSOR) {
+ cursor = sp_cursor_from_xpm(cursor_dropping_s_xpm, NULL, NULL, apply_color);
+ }
+ } else {
+ if(draw_cursor == DRAW_FILL_CURSOR) {
+ cursor = sp_cursor_from_xpm(cursor_dropper_f_xpm, NULL, NULL, this->get_color());
+ } else if(draw_cursor == DRAW_STROKE_CURSOR) {
+ cursor = sp_cursor_from_xpm(cursor_dropper_s_xpm, NULL, NULL, this->get_color());
+ }
+ }
+ GdkWindow* window = gtk_widget_get_window(GTK_WIDGET(desktop->getCanvas()));
+ gdk_window_set_cursor(window, cursor);
+ }
+
if (!ret) {
ret = ToolBase::root_handler(event);
}
diff --git a/src/ui/tools/dropper-tool.h b/src/ui/tools/dropper-tool.h
index cfeb91dab..85675501c 100644
--- a/src/ui/tools/dropper-tool.h
+++ b/src/ui/tools/dropper-tool.h
@@ -25,6 +25,11 @@ enum {
SP_DROPPER_PICK_VISIBLE,
SP_DROPPER_PICK_ACTUAL
};
+enum {
+ DONT_REDRAW_CURSOR,
+ DRAW_FILL_CURSOR,
+ DRAW_STROKE_CURSOR
+};
namespace Inkscape {
namespace UI {
diff --git a/src/ui/tools/dynamic-base.cpp b/src/ui/tools/dynamic-base.cpp
index 6627a470e..bb4989333 100644
--- a/src/ui/tools/dynamic-base.cpp
+++ b/src/ui/tools/dynamic-base.cpp
@@ -18,8 +18,8 @@ namespace Inkscape {
namespace UI {
namespace Tools {
-DynamicBase::DynamicBase(gchar const *const *cursor_shape, gint hot_x, gint hot_y)
- : ToolBase(cursor_shape, hot_x, hot_y)
+DynamicBase::DynamicBase(gchar const *const *cursor_shape)
+ : ToolBase(cursor_shape)
, accumulated(NULL)
, segments(NULL)
, currentshape(NULL)
diff --git a/src/ui/tools/dynamic-base.h b/src/ui/tools/dynamic-base.h
index 095af8f88..e270052f3 100644
--- a/src/ui/tools/dynamic-base.h
+++ b/src/ui/tools/dynamic-base.h
@@ -38,7 +38,7 @@ namespace Tools {
class DynamicBase : public ToolBase {
public:
- DynamicBase(gchar const *const *cursor_shape, gint hot_x, gint hot_y);
+ DynamicBase(gchar const *const *cursor_shape);
virtual ~DynamicBase();
virtual void set(const Inkscape::Preferences::Entry& val);
diff --git a/src/ui/tools/eraser-tool.cpp b/src/ui/tools/eraser-tool.cpp
index ae312e054..b4246b9cc 100644
--- a/src/ui/tools/eraser-tool.cpp
+++ b/src/ui/tools/eraser-tool.cpp
@@ -93,7 +93,7 @@ const std::string& EraserTool::getPrefsPath() {
const std::string EraserTool::prefsPath = "/tools/eraser";
EraserTool::EraserTool()
- : DynamicBase(cursor_eraser_xpm, 4, 4)
+ : DynamicBase(cursor_eraser_xpm)
, nowidth(false)
{
}
diff --git a/src/ui/tools/flood-tool.cpp b/src/ui/tools/flood-tool.cpp
index 6e1d085aa..f6f9b4355 100644
--- a/src/ui/tools/flood-tool.cpp
+++ b/src/ui/tools/flood-tool.cpp
@@ -98,7 +98,7 @@ Glib::ustring gap_init[4] = {
const std::vector<Glib::ustring> FloodTool::gap_list( gap_init, gap_init+4 );
FloodTool::FloodTool()
- : ToolBase(cursor_paintbucket_xpm, 11, 30)
+ : ToolBase(cursor_paintbucket_xpm)
, item(NULL)
{
// TODO: Why does the flood tool use a hardcoded tolerance instead of a pref?
diff --git a/src/ui/tools/freehand-base.cpp b/src/ui/tools/freehand-base.cpp
index 4af70a816..8a5ef0aad 100644
--- a/src/ui/tools/freehand-base.cpp
+++ b/src/ui/tools/freehand-base.cpp
@@ -63,8 +63,8 @@ static void spdc_flush_white(FreehandBase *dc, SPCurve *gc);
static void spdc_reset_white(FreehandBase *dc);
static void spdc_free_colors(FreehandBase *dc);
-FreehandBase::FreehandBase(gchar const *const *cursor_shape, gint hot_x, gint hot_y)
- : ToolBase(cursor_shape, hot_x, hot_y)
+FreehandBase::FreehandBase(gchar const *const *cursor_shape)
+ : ToolBase(cursor_shape)
, selection(NULL)
, grab(NULL)
, attach(false)
diff --git a/src/ui/tools/freehand-base.h b/src/ui/tools/freehand-base.h
index 3ee4cd7d0..a3069aa09 100644
--- a/src/ui/tools/freehand-base.h
+++ b/src/ui/tools/freehand-base.h
@@ -44,7 +44,7 @@ namespace Tools {
class FreehandBase : public ToolBase {
public:
- FreehandBase(gchar const *const *cursor_shape, gint hot_x, gint hot_y);
+ FreehandBase(gchar const *const *cursor_shape);
virtual ~FreehandBase();
Inkscape::Selection *selection;
diff --git a/src/ui/tools/gradient-tool.cpp b/src/ui/tools/gradient-tool.cpp
index 750596808..95d940bd6 100644
--- a/src/ui/tools/gradient-tool.cpp
+++ b/src/ui/tools/gradient-tool.cpp
@@ -58,7 +58,7 @@ const std::string GradientTool::prefsPath = "/tools/gradient";
GradientTool::GradientTool()
- : ToolBase(cursor_gradient_xpm, 4, 4)
+ : ToolBase(cursor_gradient_xpm)
, cursor_addnode(false)
, node_added(false)
// TODO: Why are these connections stored as pointers?
diff --git a/src/ui/tools/lpe-tool.cpp b/src/ui/tools/lpe-tool.cpp
index 29e4c9e74..35e6d14a0 100644
--- a/src/ui/tools/lpe-tool.cpp
+++ b/src/ui/tools/lpe-tool.cpp
@@ -68,7 +68,7 @@ const std::string& LpeTool::getPrefsPath() {
const std::string LpeTool::prefsPath = "/tools/lpetool";
LpeTool::LpeTool()
- : PenTool(cursor_crosshairs_xpm, 7, 7)
+ : PenTool(cursor_crosshairs_xpm)
, shape_editor(NULL)
, canvas_bbox(NULL)
, mode(Inkscape::LivePathEffect::BEND_PATH)
diff --git a/src/ui/tools/measure-tool.cpp b/src/ui/tools/measure-tool.cpp
index 98b2c7d03..7f3c99716 100644
--- a/src/ui/tools/measure-tool.cpp
+++ b/src/ui/tools/measure-tool.cpp
@@ -322,7 +322,7 @@ void createAngleDisplayCurve(SPDesktop *desktop, Geom::Point const &center, Geom
boost::optional<Geom::Point> explicit_base_tmp = boost::none;
MeasureTool::MeasureTool()
- : ToolBase(cursor_measure_xpm, 4, 4)
+ : ToolBase(cursor_measure_xpm)
, grabbed(NULL)
{
SPDesktop *desktop = SP_ACTIVE_DESKTOP;
diff --git a/src/ui/tools/mesh-tool.cpp b/src/ui/tools/mesh-tool.cpp
index ac43b6c9d..d79741270 100644
--- a/src/ui/tools/mesh-tool.cpp
+++ b/src/ui/tools/mesh-tool.cpp
@@ -72,7 +72,7 @@ const std::string MeshTool::prefsPath = "/tools/mesh";
// TODO: The gradient tool class looks like a 1:1 copy.
MeshTool::MeshTool()
- : ToolBase(cursor_gradient_xpm, 4, 4)
+ : ToolBase(cursor_gradient_xpm)
, cursor_addnode(false)
, node_added(false)
, show_handles(true)
diff --git a/src/ui/tools/node-tool.cpp b/src/ui/tools/node-tool.cpp
index 6004a0de9..d508a16f2 100644
--- a/src/ui/tools/node-tool.cpp
+++ b/src/ui/tools/node-tool.cpp
@@ -118,7 +118,7 @@ const std::string NodeTool::prefsPath = "/tools/nodes";
SPCanvasGroup *create_control_group(SPDesktop *d);
NodeTool::NodeTool()
- : ToolBase(cursor_node_xpm, 1, 1)
+ : ToolBase(cursor_node_xpm)
, _selected_nodes(NULL)
, _multipath(NULL)
, edit_clipping_paths(false)
@@ -776,14 +776,10 @@ void NodeTool::mouseover_changed(Inkscape::UI::ControlPoint *p) {
if (cdp && !this->cursor_drag) {
this->cursor_shape = cursor_node_d_xpm;
- this->hot_x = 1;
- this->hot_y = 1;
this->sp_event_context_update_cursor();
this->cursor_drag = true;
} else if (!cdp && this->cursor_drag) {
this->cursor_shape = cursor_node_xpm;
- this->hot_x = 1;
- this->hot_y = 1;
this->sp_event_context_update_cursor();
this->cursor_drag = false;
}
diff --git a/src/ui/tools/pen-tool.cpp b/src/ui/tools/pen-tool.cpp
index caf6faec2..265ddf2ea 100644
--- a/src/ui/tools/pen-tool.cpp
+++ b/src/ui/tools/pen-tool.cpp
@@ -81,7 +81,7 @@ const std::string& PenTool::getPrefsPath() {
const std::string PenTool::prefsPath = "/tools/freehand/pen";
PenTool::PenTool()
- : FreehandBase(cursor_pen_xpm, 4, 4)
+ : FreehandBase(cursor_pen_xpm)
, p()
, npoints(0)
, mode(MODE_CLICK)
@@ -100,8 +100,8 @@ PenTool::PenTool()
{
}
-PenTool::PenTool(gchar const *const *cursor_shape, gint hot_x, gint hot_y)
- : FreehandBase(cursor_shape, hot_x, hot_y)
+PenTool::PenTool(gchar const *const *cursor_shape)
+ : FreehandBase(cursor_shape)
, p()
, npoints(0)
, mode(MODE_CLICK)
diff --git a/src/ui/tools/pen-tool.h b/src/ui/tools/pen-tool.h
index 5a21e3bac..7e5483358 100644
--- a/src/ui/tools/pen-tool.h
+++ b/src/ui/tools/pen-tool.h
@@ -23,7 +23,7 @@ namespace Tools {
class PenTool : public FreehandBase {
public:
PenTool();
- PenTool(gchar const *const *cursor_shape, gint hot_x, gint hot_y);
+ PenTool(gchar const *const *cursor_shape);
virtual ~PenTool();
enum Mode {
diff --git a/src/ui/tools/pencil-tool.cpp b/src/ui/tools/pencil-tool.cpp
index ec2874823..99b8103c3 100644
--- a/src/ui/tools/pencil-tool.cpp
+++ b/src/ui/tools/pencil-tool.cpp
@@ -57,7 +57,7 @@ const std::string& PencilTool::getPrefsPath() {
const std::string PencilTool::prefsPath = "/tools/freehand/pencil";
PencilTool::PencilTool()
- : FreehandBase(cursor_pencil_xpm, 4, 4)
+ : FreehandBase(cursor_pencil_xpm)
, p()
, npoints(0)
, state(SP_PENCIL_CONTEXT_IDLE)
diff --git a/src/ui/tools/rect-tool.cpp b/src/ui/tools/rect-tool.cpp
index 272531945..8eaae2f7b 100644
--- a/src/ui/tools/rect-tool.cpp
+++ b/src/ui/tools/rect-tool.cpp
@@ -52,7 +52,7 @@ const std::string& RectTool::getPrefsPath() {
const std::string RectTool::prefsPath = "/tools/shapes/rect";
RectTool::RectTool()
- : ToolBase(cursor_rect_xpm, 4, 4)
+ : ToolBase(cursor_rect_xpm)
, rect(NULL)
, rx(0)
, ry(0)
diff --git a/src/ui/tools/select-tool.cpp b/src/ui/tools/select-tool.cpp
index bae1793ed..fca2173ca 100644
--- a/src/ui/tools/select-tool.cpp
+++ b/src/ui/tools/select-tool.cpp
@@ -81,7 +81,7 @@ sp_load_handles(int start, int count, char const **xpm) {
SelectTool::SelectTool()
// Don't load a default cursor
- : ToolBase(NULL, 0, 0)
+ : ToolBase(NULL)
, dragging(false)
, moved(false)
, button_press_shift(false)
@@ -94,8 +94,8 @@ SelectTool::SelectTool()
, _describer(NULL)
{
// cursors in select context
- CursorSelectMouseover = sp_cursor_new_from_xpm(cursor_select_m_xpm , 1, 1);
- CursorSelectDragging = sp_cursor_new_from_xpm(cursor_select_d_xpm , 1, 1);
+ CursorSelectMouseover = sp_cursor_from_xpm(cursor_select_m_xpm);
+ CursorSelectDragging = sp_cursor_from_xpm(cursor_select_d_xpm);
// selection handles
sp_load_handles(0, 2, handle_scale_xpm);
@@ -566,7 +566,9 @@ bool SelectTool::root_handler(GdkEvent* event) {
/* User has dragged fast, so we get events on root (lauris)*/
// not only that; we will end up here when ctrl-dragging as well
// and also when we started within tolerance, but trespassed tolerance outside of item
- Inkscape::Rubberband::get(desktop)->stop();
+ if (Inkscape::Rubberband::get(desktop)->is_started()) {
+ Inkscape::Rubberband::get(desktop)->stop();
+ }
this->defaultMessageContext()->clear();
item_at_point = desktop->getItemAtPoint(Geom::Point(event->button.x, event->button.y), FALSE);
diff --git a/src/ui/tools/spiral-tool.cpp b/src/ui/tools/spiral-tool.cpp
index 0ba08853e..08c35b9b0 100644
--- a/src/ui/tools/spiral-tool.cpp
+++ b/src/ui/tools/spiral-tool.cpp
@@ -51,7 +51,7 @@ const std::string& SpiralTool::getPrefsPath() {
const std::string SpiralTool::prefsPath = "/tools/shapes/spiral";
SpiralTool::SpiralTool()
- : ToolBase(cursor_spiral_xpm, 4, 4)
+ : ToolBase(cursor_spiral_xpm)
, spiral(NULL)
, revo(3)
, exp(1)
diff --git a/src/ui/tools/spray-tool.cpp b/src/ui/tools/spray-tool.cpp
index ad006627c..f3e7e6d3c 100644
--- a/src/ui/tools/spray-tool.cpp
+++ b/src/ui/tools/spray-tool.cpp
@@ -137,7 +137,7 @@ static void sp_spray_scale_rel(Geom::Point c, SPDesktop */*desktop*/, SPItem *it
}
SprayTool::SprayTool()
- : ToolBase(cursor_spray_xpm, 4, 4, false)
+ : ToolBase(cursor_spray_xpm, false)
, pressure(TC_DEFAULT_PRESSURE)
, dragging(false)
, usepressurewidth(false)
diff --git a/src/ui/tools/star-tool.cpp b/src/ui/tools/star-tool.cpp
index ddee08189..18992d87a 100644
--- a/src/ui/tools/star-tool.cpp
+++ b/src/ui/tools/star-tool.cpp
@@ -57,7 +57,7 @@ const std::string& StarTool::getPrefsPath() {
const std::string StarTool::prefsPath = "/tools/shapes/star";
StarTool::StarTool()
- : ToolBase(cursor_star_xpm, 4, 4)
+ : ToolBase(cursor_star_xpm)
, star(NULL)
, magnitude(5)
, proportion(0.5)
diff --git a/src/ui/tools/text-tool.cpp b/src/ui/tools/text-tool.cpp
index 649bbb045..9091b455e 100644
--- a/src/ui/tools/text-tool.cpp
+++ b/src/ui/tools/text-tool.cpp
@@ -76,7 +76,7 @@ const std::string TextTool::prefsPath = "/tools/text";
TextTool::TextTool()
- : ToolBase(cursor_text_xpm, 7, 7)
+ : ToolBase(cursor_text_xpm)
, imc(NULL)
, text(NULL)
, pdoc(0, 0)
@@ -359,8 +359,6 @@ bool TextTool::item_handler(SPItem* item, GdkEvent* event) {
sp_canvas_item_show(this->indicator);
this->cursor_shape = cursor_text_insert_xpm;
- this->hot_x = 7;
- this->hot_y = 10;
this->sp_event_context_update_cursor();
sp_text_context_update_text_selection(this);
@@ -548,8 +546,6 @@ bool TextTool::root_handler(GdkEvent* event) {
this->over_text = 0;
// update cursor and statusbar: we are not over a text object now
this->cursor_shape = cursor_text_xpm;
- this->hot_x = 7;
- this->hot_y = 7;
this->sp_event_context_update_cursor();
desktop->event_context->defaultMessageContext()->clear();
}
diff --git a/src/ui/tools/tool-base.cpp b/src/ui/tools/tool-base.cpp
index 3d755eadc..0467b984e 100644
--- a/src/ui/tools/tool-base.cpp
+++ b/src/ui/tools/tool-base.cpp
@@ -23,6 +23,7 @@
#include "shortcuts.h"
#include "file.h"
+#include "ui/contextmenu.h"
#include "ui/interface.h"
#include "ui/event-debug.h"
#include "ui/tool/control-point.h"
@@ -85,7 +86,7 @@ SPDesktop const& ToolBase::getDesktop() const {
return *desktop;
}
-ToolBase::ToolBase(gchar const *const *cursor_shape, gint hot_x, gint hot_y, bool uses_snap)
+ToolBase::ToolBase(gchar const *const *cursor_shape, bool uses_snap)
: pref_observer(NULL)
, cursor(NULL)
, xp(0)
@@ -103,8 +104,6 @@ ToolBase::ToolBase(gchar const *const *cursor_shape, gint hot_x, gint hot_y, boo
, desktop(NULL)
, _uses_snap(uses_snap)
, cursor_shape(cursor_shape)
- , hot_x(hot_x)
- , hot_y(hot_y)
{
}
@@ -153,44 +152,24 @@ void ToolBase::sp_event_context_set_cursor(GdkCursorType cursor_type) {
void ToolBase::sp_event_context_update_cursor() {
GtkWidget *w = GTK_WIDGET(this->desktop->getCanvas());
if (gtk_widget_get_window (w)) {
-
GtkStyle *style = gtk_widget_get_style(w);
- /* fixme: */
if (this->cursor_shape) {
- GdkDisplay *display = gdk_display_get_default();
- if (gdk_display_supports_cursor_alpha(display) && gdk_display_supports_cursor_color(display)) {
- bool fillHasColor=false, strokeHasColor=false;
- guint32 fillColor = sp_desktop_get_color_tool(this->desktop, this->getPrefsPath(), true, &fillHasColor);
- guint32 strokeColor = sp_desktop_get_color_tool(this->desktop, this->getPrefsPath(), false, &strokeHasColor);
- double fillOpacity = fillHasColor ? sp_desktop_get_opacity_tool(this->desktop, this->getPrefsPath(), true) : 0;
- double strokeOpacity = strokeHasColor ? sp_desktop_get_opacity_tool(this->desktop, this->getPrefsPath(), false) : 0;
-
- GdkPixbuf *pixbuf = sp_cursor_pixbuf_from_xpm(
- this->cursor_shape,
- style->black, style->white,
- SP_RGBA32_U_COMPOSE(SP_RGBA32_R_U(fillColor),SP_RGBA32_G_U(fillColor),SP_RGBA32_B_U(fillColor),SP_COLOR_F_TO_U(fillOpacity)),
- SP_RGBA32_U_COMPOSE(SP_RGBA32_R_U(strokeColor),SP_RGBA32_G_U(strokeColor),SP_RGBA32_B_U(strokeColor),SP_COLOR_F_TO_U(strokeOpacity))
- );
- if (pixbuf != NULL) {
- if (this->cursor) {
- g_object_unref(this->cursor);
- }
- this->cursor = gdk_cursor_new_from_pixbuf(display, pixbuf, this->hot_x, this->hot_y);
- g_object_unref(pixbuf);
- }
- } else {
- GdkPixbuf *pixbuf = gdk_pixbuf_new_from_xpm_data((const gchar **)this->cursor_shape);
-
- if (pixbuf) {
- if (this->cursor) {
- g_object_unref(this->cursor);
- }
- this->cursor = gdk_cursor_new_from_pixbuf(display,
- pixbuf, this->hot_x, this->hot_y);
- g_object_unref(pixbuf);
- }
+ if(this->cursor) {
+ g_object_unref(this->cursor);
}
+
+ bool fillHasColor=false, strokeHasColor=false;
+ guint32 fillColor = sp_desktop_get_color_tool(this->desktop, this->getPrefsPath(), true, &fillHasColor);
+ guint32 strokeColor = sp_desktop_get_color_tool(this->desktop, this->getPrefsPath(), false, &strokeHasColor);
+ double fillOpacity = fillHasColor ? sp_desktop_get_opacity_tool(this->desktop, this->getPrefsPath(), true) : 0;
+ double strokeOpacity = strokeHasColor ? sp_desktop_get_opacity_tool(this->desktop, this->getPrefsPath(), false) : 0;
+
+ this->cursor = sp_cursor_from_xpm(
+ this->cursor_shape, &style->black, &style->white,
+ SP_RGBA32_C_COMPOSE(fillColor, fillOpacity),
+ SP_RGBA32_C_COMPOSE(strokeColor, strokeOpacity)
+ );
}
gdk_window_set_cursor(gtk_widget_get_window (w), this->cursor);
gdk_flush();
@@ -207,8 +186,7 @@ void ToolBase::sp_event_context_update_cursor() {
void ToolBase::setup() {
this->pref_observer = new ToolPrefObserver(this->getPrefsPath(), this);
Inkscape::Preferences::get()->addObserver(*(this->pref_observer));
-
- this->sp_event_context_update_cursor();
+ this->sp_event_context_update_cursor();
}
/**
diff --git a/src/ui/tools/tool-base.h b/src/ui/tools/tool-base.h
index 3d22fc66f..b0140cecb 100644
--- a/src/ui/tools/tool-base.h
+++ b/src/ui/tools/tool-base.h
@@ -144,7 +144,7 @@ public:
void enableGrDrag (bool enable=true);
bool deleteSelectedDrag(bool just_one);
- ToolBase(gchar const *const *cursor_shape, gint hot_x, gint hot_y, bool uses_snap = true);
+ ToolBase(gchar const *const *cursor_shape, bool uses_snap=true);
virtual ~ToolBase();
@@ -224,9 +224,6 @@ protected:
/// An xpm containing the shape of the tool's cursor.
gchar const *const *cursor_shape;
- /// The cursor's hot spot
- gint hot_x, hot_y;
-
bool sp_event_context_knot_mouseover() const;
private:
diff --git a/src/ui/tools/tweak-tool.cpp b/src/ui/tools/tweak-tool.cpp
index ff5d623c2..dcd9413fb 100644
--- a/src/ui/tools/tweak-tool.cpp
+++ b/src/ui/tools/tweak-tool.cpp
@@ -38,13 +38,13 @@
#include "pixmaps/cursor-tweak-rotate-counterclockwise.xpm"
#include "pixmaps/cursor-tweak-more.xpm"
#include "pixmaps/cursor-tweak-less.xpm"
-#include "pixmaps/cursor-thin.xpm"
-#include "pixmaps/cursor-thicken.xpm"
-#include "pixmaps/cursor-attract.xpm"
-#include "pixmaps/cursor-repel.xpm"
-#include "pixmaps/cursor-push.xpm"
-#include "pixmaps/cursor-roughen.xpm"
-#include "pixmaps/cursor-color.xpm"
+#include "pixmaps/cursor-tweak-thin.xpm"
+#include "pixmaps/cursor-tweak-thicken.xpm"
+#include "pixmaps/cursor-tweak-attract.xpm"
+#include "pixmaps/cursor-tweak-repel.xpm"
+#include "pixmaps/cursor-tweak-push.xpm"
+#include "pixmaps/cursor-tweak-roughen.xpm"
+#include "pixmaps/cursor-tweak-color.xpm"
#include "context-fns.h"
#include "inkscape.h"
#include "splivarot.h"
@@ -92,7 +92,7 @@ const std::string& TweakTool::getPrefsPath() {
const std::string TweakTool::prefsPath = "/tools/tweak";
TweakTool::TweakTool()
- : ToolBase(cursor_push_xpm, 4, 4)
+ : ToolBase(cursor_push_xpm)
, pressure(TC_DEFAULT_PRESSURE)
, dragging(false)
, usepressure(false)
diff --git a/src/ui/tools/zoom-tool.cpp b/src/ui/tools/zoom-tool.cpp
index d40d2e969..8ba0c17b3 100644
--- a/src/ui/tools/zoom-tool.cpp
+++ b/src/ui/tools/zoom-tool.cpp
@@ -36,7 +36,7 @@ const std::string& ZoomTool::getPrefsPath() {
const std::string ZoomTool::prefsPath = "/tools/zoom";
ZoomTool::ZoomTool()
- : ToolBase(cursor_zoom_xpm, 6, 6)
+ : ToolBase(cursor_zoom_xpm)
, grabbed(NULL)
, escaped(false)
{
diff --git a/src/ui/widget/addtoicon.cpp b/src/ui/widget/addtoicon.cpp
index 70516ed00..e5119fc60 100644
--- a/src/ui/widget/addtoicon.cpp
+++ b/src/ui/widget/addtoicon.cpp
@@ -16,7 +16,6 @@
#include <gtkmm/icontheme.h>
-#include "widgets/icon.h"
#include "widgets/toolbox.h"
#include "ui/icon-names.h"
#include "layertypeicon.h"
@@ -33,7 +32,10 @@ AddToIcon::AddToIcon() :
// _property_pixbuf_add(*this, "pixbuf_on", Glib::RefPtr<Gdk::Pixbuf>(0))
{
property_mode() = Gtk::CELL_RENDERER_MODE_ACTIVATABLE;
- phys = sp_icon_get_phys_size((int)Inkscape::ICON_SIZE_BUTTON);
+
+ gint width, height;
+ gtk_icon_size_lookup(GTK_ICON_SIZE_BUTTON, &width, &height);
+ phys = width; // Assumes that we have a square icon?
// Glib::RefPtr<Gtk::IconTheme> icon_theme = Gtk::IconTheme::get_default();
//
@@ -43,8 +45,6 @@ AddToIcon::AddToIcon() :
// if (icon_theme->has_icon(_pixAddName)) {
// _property_pixbuf_add = icon_theme->load_icon(_pixAddName, phys, (Gtk::IconLookupFlags)0);
// }
-//
-// _property_pixbuf_add = Gtk::Widget::
set_pixbuf();
}
@@ -104,8 +104,10 @@ void AddToIcon::set_pixbuf()
{
bool active = property_active().get_value();
- GdkPixbuf *pixbuf = sp_pixbuf_new(Inkscape::ICON_SIZE_BUTTON, active ? INKSCAPE_ICON("list-add") : INKSCAPE_ICON("edit-delete"));
- property_pixbuf() = Glib::wrap(pixbuf);
+ auto icon_theme = Gtk::IconTheme::get_default();
+
+ property_pixbuf() = icon_theme->load_icon(active ? "list-add" : "edit-delete",
+ phys);
}
diff --git a/src/ui/widget/addtoicon.h b/src/ui/widget/addtoicon.h
index 3b2228754..93d66c8d5 100644
--- a/src/ui/widget/addtoicon.h
+++ b/src/ui/widget/addtoicon.h
@@ -54,7 +54,7 @@ protected:
private:
- int phys;
+ int phys; ///< Physical size of the icon (px)
// Glib::ustring _pixAddName;
diff --git a/src/ui/widget/anchor-selector.cpp b/src/ui/widget/anchor-selector.cpp
index 087e7375e..ddc25775d 100644
--- a/src/ui/widget/anchor-selector.cpp
+++ b/src/ui/widget/anchor-selector.cpp
@@ -8,15 +8,17 @@
*/
#include "ui/widget/anchor-selector.h"
-#include "widgets/icon.h"
#include "ui/icon-names.h"
+#include <gtkmm/image.h>
+
namespace Inkscape {
namespace UI {
namespace Widget {
void AnchorSelector::setupButton(const Glib::ustring& icon, Gtk::ToggleButton& button) {
- Gtk::Widget* buttonIcon = Gtk::manage(sp_icon_get_icon(icon, Inkscape::ICON_SIZE_SMALL_TOOLBAR));
+ Gtk::Image* buttonIcon = Gtk::manage(new Gtk::Image());
+ buttonIcon->set_from_icon_name(icon, Gtk::ICON_SIZE_SMALL_TOOLBAR);
buttonIcon->show();
button.set_relief(Gtk::RELIEF_NONE);
diff --git a/src/ui/widget/clipmaskicon.cpp b/src/ui/widget/clipmaskicon.cpp
index a1e3eaf82..c284c035c 100644
--- a/src/ui/widget/clipmaskicon.cpp
+++ b/src/ui/widget/clipmaskicon.cpp
@@ -15,7 +15,6 @@
#include <gtkmm/icontheme.h>
-#include "widgets/icon.h"
#include "widgets/toolbox.h"
#include "ui/icon-names.h"
#include "layertypeicon.h"
@@ -37,18 +36,12 @@ ClipMaskIcon::ClipMaskIcon() :
{
property_mode() = Gtk::CELL_RENDERER_MODE_ACTIVATABLE;
- phys = sp_icon_get_phys_size((int)Inkscape::ICON_SIZE_DECORATION);
- Glib::RefPtr<Gtk::IconTheme> icon_theme = Gtk::IconTheme::get_default();
- if (!icon_theme->has_icon(_pixClipName)) {
- Inkscape::queueIconPrerender( INKSCAPE_ICON(_pixClipName.data()), Inkscape::ICON_SIZE_DECORATION );
- }
- if (!icon_theme->has_icon(_pixMaskName)) {
- Inkscape::queueIconPrerender( INKSCAPE_ICON(_pixMaskName.data()), Inkscape::ICON_SIZE_DECORATION );
- }
- if (!icon_theme->has_icon(_pixBothName)) {
- Inkscape::queueIconPrerender( INKSCAPE_ICON(_pixBothName.data()), Inkscape::ICON_SIZE_DECORATION );
- }
+ gint width, height;
+ gtk_icon_size_lookup(GTK_ICON_SIZE_MENU, &width, &height);
+ phys = width;
+
+ Glib::RefPtr<Gtk::IconTheme> icon_theme = Gtk::IconTheme::get_default();
if (icon_theme->has_icon(_pixClipName)) {
_property_pixbuf_clip = icon_theme->load_icon(_pixClipName, phys, (Gtk::IconLookupFlags)0);
diff --git a/src/ui/widget/color-notebook.cpp b/src/ui/widget/color-notebook.cpp
index 33e22b59d..0c9402c99 100644
--- a/src/ui/widget/color-notebook.cpp
+++ b/src/ui/widget/color-notebook.cpp
@@ -19,7 +19,6 @@
#include "config.h"
#endif
-#include "widgets/icon.h"
#include <glibmm/i18n.h>
#include <gtkmm/label.h>
#include <gtkmm/notebook.h>
diff --git a/src/ui/widget/dock-item.cpp b/src/ui/widget/dock-item.cpp
index d124854ae..60ea03fb7 100644
--- a/src/ui/widget/dock-item.cpp
+++ b/src/ui/widget/dock-item.cpp
@@ -12,7 +12,6 @@
#include "desktop.h"
#include "inkscape.h"
#include "ui/icon-names.h"
-#include "widgets/icon.h"
#include <gtkmm/icontheme.h>
#include <glibmm/exceptionhandler.h>
@@ -22,7 +21,7 @@ namespace UI {
namespace Widget {
DockItem::DockItem(Dock& dock, const Glib::ustring& name, const Glib::ustring& long_name,
- const Glib::ustring& icon_name, State state, Placement placement) :
+ const Glib::ustring& icon_name, State state, GdlDockPlacement placement) :
_dock(dock),
_prev_state(state),
_prev_position(0),
@@ -43,9 +42,6 @@ DockItem::DockItem(Dock& dock, const Glib::ustring& name, const Glib::ustring& l
if (!icon_name.empty()) {
Glib::RefPtr<Gtk::IconTheme> iconTheme = Gtk::IconTheme::get_default();
- if (!iconTheme->has_icon(icon_name)) {
- Inkscape::queueIconPrerender( INKSCAPE_ICON(icon_name.data()), Inkscape::ICON_SIZE_MENU );
- }
if ( iconTheme->has_icon(icon_name) ) {
int width = 0;
int height = 0;
@@ -74,7 +70,7 @@ DockItem::DockItem(Dock& dock, const Glib::ustring& name, const Glib::ustring& l
signal_delete_event().connect(sigc::mem_fun(*this, &Inkscape::UI::Widget::DockItem::_onDeleteEvent));
signal_realize().connect(sigc::mem_fun(*this, &Inkscape::UI::Widget::DockItem::_onRealize));
- _dock.addItem(*this, ( _prev_state == FLOATING_STATE || _prev_state == ICONIFIED_FLOATING_STATE ) ? FLOATING : placement);
+ _dock.addItem(*this, ( _prev_state == FLOATING_STATE || _prev_state == ICONIFIED_FLOATING_STATE ) ? GDL_DOCK_FLOATING : placement);
if (_prev_state == ICONIFIED_FLOATING_STATE || _prev_state == ICONIFIED_DOCKED_STATE) {
iconify();
@@ -218,16 +214,16 @@ DockItem::getPrevState() const
return _prev_state;
}
-DockItem::Placement
+GdlDockPlacement
DockItem::getPlacement() const
{
- GdlDockPlacement placement = (GdlDockPlacement)TOP;
+ GdlDockPlacement placement = GDL_DOCK_TOP;
GdlDockObject *parent = gdl_dock_object_get_parent_object (GDL_DOCK_OBJECT(_gdl_dock_item));
if (parent) {
gdl_dock_object_child_placement(parent, GDL_DOCK_OBJECT(_gdl_dock_item), &placement);
}
- return (Placement)placement;
+ return placement;
}
void
@@ -262,7 +258,7 @@ DockItem::present()
show();
}
// tabbed
- else if (getPlacement() == CENTER) {
+ else if (getPlacement() == GDL_DOCK_CENTER) {
int i = gtk_notebook_page_num(GTK_NOTEBOOK(gtk_widget_get_parent(_gdl_dock_item)),
GTK_WIDGET (_gdl_dock_item));
if (i >= 0)
diff --git a/src/ui/widget/dock-item.h b/src/ui/widget/dock-item.h
index 2df45b207..b5f6c13af 100644
--- a/src/ui/widget/dock-item.h
+++ b/src/ui/widget/dock-item.h
@@ -45,18 +45,8 @@ public:
ICONIFIED_DOCKED_STATE, // item iconified in its assigned dock from dock
ICONIFIED_FLOATING_STATE}; // item iconified in its assigned dock from float
- enum Placement {
- NONE = GDL_DOCK_NONE,
- TOP = GDL_DOCK_TOP,
- BOTTOM = GDL_DOCK_BOTTOM,
- RIGHT = GDL_DOCK_RIGHT,
- LEFT = GDL_DOCK_LEFT,
- CENTER = GDL_DOCK_CENTER,
- FLOATING = GDL_DOCK_FLOATING
- };
-
DockItem(Dock& dock, const Glib::ustring& name, const Glib::ustring& long_name,
- const Glib::ustring& icon_name, State state, Placement placement);
+ const Glib::ustring& icon_name, State state, GdlDockPlacement placement);
~DockItem();
@@ -80,7 +70,7 @@ public:
bool isIconified() const;
State getState() const;
State getPrevState() const;
- Placement getPlacement() const;
+ GdlDockPlacement getPlacement() const;
Gtk::Window *getWindow(); //< gives the parent window, if the dock item has one (i.e. it's floating)
diff --git a/src/ui/widget/dock.cpp b/src/ui/widget/dock.cpp
index b2dec401f..7dfad9582 100644
--- a/src/ui/widget/dock.cpp
+++ b/src/ui/widget/dock.cpp
@@ -124,12 +124,13 @@ Dock::~Dock()
g_free(_gdl_dock_bar);
}
-void Dock::addItem(DockItem& item, DockItem::Placement placement)
+void Dock::addItem(DockItem& item, GdlDockPlacement placement)
{
_dock_items.push_back(&item);
+
gdl_dock_add_item(GDL_DOCK(_gdl_dock),
GDL_DOCK_ITEM(item.gobj()),
- (GdlDockPlacement)placement);
+ placement);
// FIXME: This is a hack to prevent the dock from expanding the main window, this can't be done
// initially as the paned doesn't exist.
diff --git a/src/ui/widget/dock.h b/src/ui/widget/dock.h
index 74b072d22..6258a06e3 100644
--- a/src/ui/widget/dock.h
+++ b/src/ui/widget/dock.h
@@ -37,7 +37,7 @@ public:
Dock(Gtk::Orientation orientation=Gtk::ORIENTATION_VERTICAL);
~Dock();
- void addItem(DockItem& item, DockItem::Placement placement);
+ void addItem(DockItem& item, GdlDockPlacement placement);
Gtk::Widget& getWidget(); //< return the top widget
Gtk::Paned *getParentPaned();
diff --git a/src/ui/widget/highlight-picker.cpp b/src/ui/widget/highlight-picker.cpp
index 561c1332a..3d8ab50ea 100644
--- a/src/ui/widget/highlight-picker.cpp
+++ b/src/ui/widget/highlight-picker.cpp
@@ -13,7 +13,6 @@
#include "display/cairo-utils.h"
#include "highlight-picker.h"
-#include "widgets/icon.h"
namespace Inkscape {
namespace UI {
diff --git a/src/ui/widget/imagetoggler.cpp b/src/ui/widget/imagetoggler.cpp
index 987cc67bb..81d0edd47 100644
--- a/src/ui/widget/imagetoggler.cpp
+++ b/src/ui/widget/imagetoggler.cpp
@@ -13,7 +13,6 @@
#include <gtkmm/icontheme.h>
-#include "widgets/icon.h"
#include "widgets/toolbox.h"
#include "ui/icon-names.h"
@@ -32,15 +31,12 @@ ImageToggler::ImageToggler( char const* on, char const* off) :
_property_pixbuf_off(*this, "pixbuf_off", Glib::RefPtr<Gdk::Pixbuf>(0))
{
property_mode() = Gtk::CELL_RENDERER_MODE_ACTIVATABLE;
- int phys = sp_icon_get_phys_size((int)Inkscape::ICON_SIZE_DECORATION);
- Glib::RefPtr<Gtk::IconTheme> icon_theme = Gtk::IconTheme::get_default();
- if (!icon_theme->has_icon(_pixOnName)) {
- Inkscape::queueIconPrerender( INKSCAPE_ICON(_pixOnName.data()), Inkscape::ICON_SIZE_DECORATION );
- }
- if (!icon_theme->has_icon(_pixOffName)) {
- Inkscape::queueIconPrerender( INKSCAPE_ICON(_pixOffName.data()), Inkscape::ICON_SIZE_DECORATION );
- }
+ gint width, height;
+ gtk_icon_size_lookup(GTK_ICON_SIZE_MENU, &width, &height);
+ int phys = width;
+
+ Glib::RefPtr<Gtk::IconTheme> icon_theme = Gtk::IconTheme::get_default();
if (icon_theme->has_icon(_pixOnName)) {
diff --git a/src/ui/widget/insertordericon.cpp b/src/ui/widget/insertordericon.cpp
index 7ed1ed2e2..26913ff98 100644
--- a/src/ui/widget/insertordericon.cpp
+++ b/src/ui/widget/insertordericon.cpp
@@ -11,7 +11,6 @@
#include <gtkmm/icontheme.h>
-#include "widgets/icon.h"
#include "widgets/toolbox.h"
#include "ui/icon-names.h"
#include "layertypeicon.h"
@@ -31,15 +30,12 @@ InsertOrderIcon::InsertOrderIcon() :
{
property_mode() = Gtk::CELL_RENDERER_MODE_ACTIVATABLE;
- phys = sp_icon_get_phys_size((int)Inkscape::ICON_SIZE_DECORATION);
- Glib::RefPtr<Gtk::IconTheme> icon_theme = Gtk::IconTheme::get_default();
- if (!icon_theme->has_icon(_pixTopName)) {
- Inkscape::queueIconPrerender( INKSCAPE_ICON(_pixTopName.data()), Inkscape::ICON_SIZE_DECORATION );
- }
- if (!icon_theme->has_icon(_pixBottomName)) {
- Inkscape::queueIconPrerender( INKSCAPE_ICON(_pixBottomName.data()), Inkscape::ICON_SIZE_DECORATION );
- }
+ gint width, height;
+ gtk_icon_size_lookup(GTK_ICON_SIZE_MENU, &width, &height);
+ phys=width;
+
+ Glib::RefPtr<Gtk::IconTheme> icon_theme = Gtk::IconTheme::get_default();
if (icon_theme->has_icon(_pixTopName)) {
_property_pixbuf_top = icon_theme->load_icon(_pixTopName, phys, (Gtk::IconLookupFlags)0);
diff --git a/src/ui/widget/labelled.cpp b/src/ui/widget/labelled.cpp
index 6e3652830..d3dc6210f 100644
--- a/src/ui/widget/labelled.cpp
+++ b/src/ui/widget/labelled.cpp
@@ -14,8 +14,7 @@
#include "labelled.h"
-/* For getting the Gtkmmified Icon manager */
-#include "widgets/icon.h"
+#include <gtkmm/image.h>
#include <gtkmm/label.h>
namespace Inkscape {
@@ -33,8 +32,9 @@ Labelled::Labelled(Glib::ustring const &label, Glib::ustring const &tooltip,
{
g_assert(g_utf8_validate(icon.c_str(), -1, NULL));
if (icon != "") {
- _icon = sp_icon_get_icon(icon.c_str(), Inkscape::ICON_SIZE_LARGE_TOOLBAR);
- pack_start(*Gtk::manage(_icon), Gtk::PACK_SHRINK);
+ _icon = Gtk::manage(new Gtk::Image());
+ _icon->set_from_icon_name(icon, Gtk::ICON_SIZE_LARGE_TOOLBAR);
+ pack_start(*_icon, Gtk::PACK_SHRINK);
}
pack_start(*Gtk::manage(_label), Gtk::PACK_EXPAND_WIDGET, 6);
pack_start(*Gtk::manage(_widget), Gtk::PACK_SHRINK, 6);
diff --git a/src/ui/widget/labelled.h b/src/ui/widget/labelled.h
index 88eb3ce19..824abf305 100644
--- a/src/ui/widget/labelled.h
+++ b/src/ui/widget/labelled.h
@@ -14,6 +14,7 @@
#include <gtkmm/box.h>
namespace Gtk {
+class Image;
class Label;
}
@@ -64,7 +65,7 @@ protected:
Gtk::Widget *_widget;
Gtk::Label *_label;
Gtk::Label *_suffix;
- Gtk::Widget *_icon;
+ Gtk::Image *_icon;
};
} // namespace Widget
diff --git a/src/ui/widget/layer-selector.cpp b/src/ui/widget/layer-selector.cpp
index 4432a6e09..0332143b5 100644
--- a/src/ui/widget/layer-selector.cpp
+++ b/src/ui/widget/layer-selector.cpp
@@ -31,7 +31,6 @@
#include "util/filter-list.h"
#include "util/reverse-list.h"
#include "verbs.h"
-#include "widgets/icon.h"
#include "xml/node-event-vector.h"
#include "widgets/gradient-vector.h"
@@ -42,17 +41,19 @@ namespace {
class AlternateIcons : public Gtk::HBox {
public:
- AlternateIcons(Inkscape::IconSize size, gchar const *a, gchar const *b)
+ AlternateIcons(Gtk::IconSize size, Glib::ustring const &a, Glib::ustring const &b)
: _a(NULL), _b(NULL)
{
set_name("AlternateIcons");
- if (a) {
- _a = Gtk::manage(sp_icon_get_icon(a, size));
+ if (!a.empty()) {
+ _a = Gtk::manage(new Gtk::Image());
+ _a->set_from_icon_name(a, size);
_a->set_no_show_all(true);
add(*_a);
}
- if (b) {
- _b = Gtk::manage(sp_icon_get_icon(b, size));
+ if (!b.empty()) {
+ _b = Gtk::manage(new Gtk::Image());
+ _b->set_from_icon_name(b, size);
_b->set_no_show_all(true);
add(*_b);
}
@@ -80,8 +81,8 @@ public:
}
private:
- Gtk::Widget *_a;
- Gtk::Widget *_b;
+ Gtk::Image *_a;
+ Gtk::Image *_b;
bool _state;
};
@@ -98,7 +99,7 @@ LayerSelector::LayerSelector(SPDesktop *desktop)
set_name("LayerSelector");
AlternateIcons *label;
- label = Gtk::manage(new AlternateIcons(Inkscape::ICON_SIZE_DECORATION,
+ label = Gtk::manage(new AlternateIcons(Gtk::ICON_SIZE_MENU,
INKSCAPE_ICON("object-visible"), INKSCAPE_ICON("object-hidden")));
_visibility_toggle.add(*label);
_visibility_toggle.signal_toggled().connect(
@@ -118,7 +119,7 @@ LayerSelector::LayerSelector(SPDesktop *desktop)
_visibility_toggle.set_tooltip_text(_("Toggle current layer visibility"));
pack_start(_visibility_toggle, Gtk::PACK_EXPAND_PADDING);
- label = Gtk::manage(new AlternateIcons(Inkscape::ICON_SIZE_DECORATION,
+ label = Gtk::manage(new AlternateIcons(Gtk::ICON_SIZE_MENU,
INKSCAPE_ICON("object-unlocked"), INKSCAPE_ICON("object-locked")));
_lock_toggle.add(*label);
_lock_toggle.signal_toggled().connect(
diff --git a/src/ui/widget/layertypeicon.cpp b/src/ui/widget/layertypeicon.cpp
index df85f271a..679a95cd2 100644
--- a/src/ui/widget/layertypeicon.cpp
+++ b/src/ui/widget/layertypeicon.cpp
@@ -15,7 +15,6 @@
#include <gtkmm/icontheme.h>
-#include "widgets/icon.h"
#include "widgets/toolbox.h"
#include "ui/icon-names.h"
@@ -37,19 +36,11 @@ LayerTypeIcon::LayerTypeIcon() :
{
property_mode() = Gtk::CELL_RENDERER_MODE_ACTIVATABLE;
- int phys = sp_icon_get_phys_size((int)Inkscape::ICON_SIZE_DECORATION);
+ gint width, height;
+ gtk_icon_size_lookup(GTK_ICON_SIZE_MENU, &width, &height);
+ int phys = width;
Glib::RefPtr<Gtk::IconTheme> icon_theme = Gtk::IconTheme::get_default();
- if (!icon_theme->has_icon(_pixLayerName)) {
- Inkscape::queueIconPrerender( INKSCAPE_ICON(_pixLayerName.data()), Inkscape::ICON_SIZE_DECORATION );
- }
- if (!icon_theme->has_icon(_pixGroupName)) {
- Inkscape::queueIconPrerender( INKSCAPE_ICON(_pixGroupName.data()), Inkscape::ICON_SIZE_DECORATION );
- }
- if (!icon_theme->has_icon(_pixPathName)) {
- Inkscape::queueIconPrerender( INKSCAPE_ICON(_pixPathName.data()), Inkscape::ICON_SIZE_DECORATION );
- }
-
if (icon_theme->has_icon(_pixLayerName)) {
_property_pixbuf_layer = icon_theme->load_icon(_pixLayerName, phys, (Gtk::IconLookupFlags)0);
}
diff --git a/src/ui/widget/object-composite-settings.cpp b/src/ui/widget/object-composite-settings.cpp
index 1727660c8..ca33a845c 100644
--- a/src/ui/widget/object-composite-settings.cpp
+++ b/src/ui/widget/object-composite-settings.cpp
@@ -24,7 +24,6 @@
#include "style.h"
#include "svg/css-ostringstream.h"
#include "verbs.h"
-#include "widgets/icon.h"
#include "display/sp-canvas.h"
#include "ui/widget/style-subject.h"
diff --git a/src/ui/widget/panel.cpp b/src/ui/widget/panel.cpp
index dff92594b..9332fe0f9 100644
--- a/src/ui/widget/panel.cpp
+++ b/src/ui/widget/panel.cpp
@@ -46,7 +46,7 @@ static const int PANEL_SETTING_NEXTFREE = 5;
void Panel::prep() {
GtkIconSize sizes[] = {
- Inkscape::getRegisteredIconSize(Inkscape::ICON_SIZE_DECORATION),
+ GTK_ICON_SIZE_MENU,
GTK_ICON_SIZE_MENU,
GTK_ICON_SIZE_SMALL_TOOLBAR,
GTK_ICON_SIZE_BUTTON,
@@ -270,7 +270,7 @@ void Panel::_init()
gint height = 0;
gtk_image_set_from_icon_name(_temp_arrow.gobj(),
"pan-start-symbolic",
- Inkscape::getRegisteredIconSize(Inkscape::ICON_SIZE_SMALL_TOOLBAR));
+ GTK_ICON_SIZE_SMALL_TOOLBAR);
_menu_popper.add(_temp_arrow);
_menu_popper.signal_button_press_event().connect_notify(sigc::mem_fun(*this, &Panel::_popper));
}
diff --git a/src/ui/widget/random.cpp b/src/ui/widget/random.cpp
index ba3b025ba..237144c7c 100644
--- a/src/ui/widget/random.cpp
+++ b/src/ui/widget/random.cpp
@@ -15,11 +15,11 @@
#include "random.h"
-#include "widgets/icon.h"
#include <glibmm/i18n.h>
#include <gtkmm/button.h>
+#include <gtkmm/image.h>
namespace Inkscape {
namespace UI {
@@ -70,7 +70,8 @@ void Random::setStartSeed(long newseed)
void Random::addReseedButton()
{
- Gtk::Widget* pIcon = Gtk::manage( sp_icon_get_icon( "randomize", Inkscape::ICON_SIZE_BUTTON) );
+ Gtk::Image* pIcon = Gtk::manage(new Gtk::Image());
+ pIcon->set_from_icon_name( "randomize", Gtk::ICON_SIZE_BUTTON);
Gtk::Button * pButton = Gtk::manage(new Gtk::Button());
pButton->set_relief(Gtk::RELIEF_NONE);
pIcon->show();
diff --git a/src/widgets/CMakeLists.txt b/src/widgets/CMakeLists.txt
index 1184291f2..089d68b4e 100644
--- a/src/widgets/CMakeLists.txt
+++ b/src/widgets/CMakeLists.txt
@@ -21,7 +21,6 @@ set(widgets_SRC
gradient-selector.cpp
gradient-toolbar.cpp
gradient-vector.cpp
- icon.cpp
ink-action.cpp
ink-comboboxentry-action.cpp
ink-radio-action.cpp
@@ -78,7 +77,6 @@ set(widgets_SRC
gradient-selector.h
gradient-toolbar.h
gradient-vector.h
- icon.h
ink-action.h
ink-comboboxentry-action.h
ink-radio-action.h
diff --git a/src/widgets/arc-toolbar.cpp b/src/widgets/arc-toolbar.cpp
index 56eeb8922..23e1eba1a 100644
--- a/src/widgets/arc-toolbar.cpp
+++ b/src/widgets/arc-toolbar.cpp
@@ -318,7 +318,7 @@ void sp_arc_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions, GObjec
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
EgeAdjustmentAction* eact = 0;
- Inkscape::IconSize secondarySize = ToolboxFactory::prefToSize("/toolbox/secondary", 1);
+ GtkIconSize secondarySize = ToolboxFactory::prefToSize("/toolbox/secondary", 1);
{
diff --git a/src/widgets/box3d-toolbar.cpp b/src/widgets/box3d-toolbar.cpp
index 95de28cf2..29a447afd 100644
--- a/src/widgets/box3d-toolbar.cpp
+++ b/src/widgets/box3d-toolbar.cpp
@@ -325,7 +325,7 @@ void box3d_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions, GObject
_("State of VP in X direction"),
_("Toggle VP in X direction between 'finite' and 'infinite' (=parallel)"),
INKSCAPE_ICON("perspective-parallel"),
- Inkscape::ICON_SIZE_DECORATION );
+ GTK_ICON_SIZE_MENU );
gtk_action_group_add_action( mainActions, GTK_ACTION( act ) );
g_object_set_data( holder, "box3d_vp_x_state_action", act );
g_signal_connect_after( G_OBJECT(act), "toggled", G_CALLBACK(box3d_vp_x_state_changed), box3d_angle_x );
@@ -364,7 +364,7 @@ void box3d_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions, GObject
_("State of VP in Y direction"),
_("Toggle VP in Y direction between 'finite' and 'infinite' (=parallel)"),
INKSCAPE_ICON("perspective-parallel"),
- Inkscape::ICON_SIZE_DECORATION );
+ GTK_ICON_SIZE_MENU );
gtk_action_group_add_action( mainActions, GTK_ACTION( act ) );
g_object_set_data( holder, "box3d_vp_y_state_action", act );
g_signal_connect_after( G_OBJECT(act), "toggled", G_CALLBACK(box3d_vp_y_state_changed), box3d_angle_y );
@@ -403,7 +403,7 @@ void box3d_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions, GObject
_("State of VP in Z direction"),
_("Toggle VP in Z direction between 'finite' and 'infinite' (=parallel)"),
INKSCAPE_ICON("perspective-parallel"),
- Inkscape::ICON_SIZE_DECORATION );
+ GTK_ICON_SIZE_MENU );
gtk_action_group_add_action( mainActions, GTK_ACTION( act ) );
g_object_set_data( holder, "box3d_vp_z_state_action", act );
g_signal_connect_after( G_OBJECT(act), "toggled", G_CALLBACK(box3d_vp_z_state_changed), box3d_angle_z );
diff --git a/src/widgets/button.cpp b/src/widgets/button.cpp
index 485300a25..7dcfc9771 100644
--- a/src/widgets/button.cpp
+++ b/src/widgets/button.cpp
@@ -12,7 +12,6 @@
*/
#include <glibmm.h>
-#include "icon.h"
#include "button.h"
#include "helper/action-context.h"
@@ -155,12 +154,12 @@ static void sp_button_perform_action(SPButton *button, gpointer /*data*/)
}
}
-GtkWidget *sp_button_new(Inkscape::IconSize size, SPButtonType type, SPAction *action, SPAction *doubleclick_action)
+GtkWidget *sp_button_new(GtkIconSize size, SPButtonType type, SPAction *action, SPAction *doubleclick_action)
{
SPButton *button = SP_BUTTON(g_object_new(SP_TYPE_BUTTON, NULL));
button->type = type;
- button->lsize = CLAMP(size, Inkscape::ICON_SIZE_MENU, Inkscape::ICON_SIZE_DECORATION);
+ button->lsize = CLAMP(size, GTK_ICON_SIZE_MENU, GTK_ICON_SIZE_DIALOG);
sp_button_set_action(button, action);
if (doubleclick_action)
@@ -212,7 +211,7 @@ static void sp_button_set_action(SPButton *button, SPAction *action)
button->c_set_sensitive = action->signal_set_sensitive.connect(
sigc::bind<0>(sigc::ptr_fun(&gtk_widget_set_sensitive), GTK_WIDGET(button)));
if (action->image) {
- child = sp_icon_new(button->lsize, action->image);
+ child = gtk_image_new_from_icon_name(action->image, button->lsize);
gtk_widget_show(child);
gtk_container_add(GTK_CONTAINER(button), child);
}
@@ -256,12 +255,11 @@ static void sp_button_set_composed_tooltip(GtkWidget *widget, SPAction *action)
}
}
-GtkWidget *sp_button_new_from_data(Inkscape::IconSize size, SPButtonType type, Inkscape::UI::View::View *view,
+GtkWidget *sp_button_new_from_data(GtkIconSize size, SPButtonType type, Inkscape::UI::View::View *view,
const gchar *name, const gchar *tip)
{
- GtkWidget *button;
SPAction *action = sp_action_new(Inkscape::ActionContext(view), name, name, tip, name, 0);
- button = sp_button_new(size, type, action, NULL);
+ GtkWidget *button = sp_button_new(size, type, action, NULL);
g_object_unref(action);
return button;
}
diff --git a/src/widgets/button.h b/src/widgets/button.h
index 2bceb5e97..94a956de3 100644
--- a/src/widgets/button.h
+++ b/src/widgets/button.h
@@ -42,7 +42,7 @@ struct SPBChoiceData {
struct SPButton {
GtkToggleButton widget;
SPButtonType type;
- Inkscape::IconSize lsize;
+ GtkIconSize lsize;
unsigned int psize;
SPAction *action;
SPAction *doubleclick_action;
@@ -59,11 +59,11 @@ struct SPButtonClass {
GType sp_button_get_type (void);
-GtkWidget *sp_button_new (Inkscape::IconSize size, SPButtonType type, SPAction *action, SPAction *doubleclick_action);
+GtkWidget *sp_button_new (GtkIconSize size, SPButtonType type, SPAction *action, SPAction *doubleclick_action);
void sp_button_toggle_set_down (SPButton *button, gboolean down);
-GtkWidget *sp_button_new_from_data (Inkscape::IconSize size,
+GtkWidget *sp_button_new_from_data (GtkIconSize size,
SPButtonType type,
Inkscape::UI::View::View *view,
const gchar *name,
diff --git a/src/widgets/calligraphy-toolbar.cpp b/src/widgets/calligraphy-toolbar.cpp
index 031295ccd..7dabee11b 100644
--- a/src/widgets/calligraphy-toolbar.cpp
+++ b/src/widgets/calligraphy-toolbar.cpp
@@ -565,7 +565,7 @@ void sp_calligraphy_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions
_("Trace Background"),
_("Trace the lightness of the background by the width of the pen (white - minimum width, black - maximum width)"),
INKSCAPE_ICON("draw-trace-background"),
- Inkscape::ICON_SIZE_DECORATION );
+ GTK_ICON_SIZE_MENU );
gtk_action_group_add_action( mainActions, GTK_ACTION( act ) );
PrefPusher *pusher = new PrefPusher(GTK_TOGGLE_ACTION(act), "/tools/calligraphic/tracebackground", update_presets_list, holder);
g_signal_connect( holder, "destroy", G_CALLBACK(delete_prefspusher), pusher);
@@ -578,7 +578,7 @@ void sp_calligraphy_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions
_("Pressure"),
_("Use the pressure of the input device to alter the width of the pen"),
INKSCAPE_ICON("draw-use-pressure"),
- Inkscape::ICON_SIZE_DECORATION );
+ GTK_ICON_SIZE_MENU );
gtk_action_group_add_action( mainActions, GTK_ACTION( act ) );
PrefPusher *pusher = new PrefPusher(GTK_TOGGLE_ACTION(act), "/tools/calligraphic/usepressure", update_presets_list, holder);
g_signal_connect( holder, "destroy", G_CALLBACK(delete_prefspusher), pusher);
@@ -591,7 +591,7 @@ void sp_calligraphy_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions
_("Tilt"),
_("Use the tilt of the input device to alter the angle of the pen's nib"),
INKSCAPE_ICON("draw-use-tilt"),
- Inkscape::ICON_SIZE_DECORATION );
+ GTK_ICON_SIZE_MENU );
gtk_action_group_add_action( mainActions, GTK_ACTION( act ) );
PrefPusher *pusher = new PrefPusher(GTK_TOGGLE_ACTION(act), "/tools/calligraphic/usetilt", update_presets_list, holder);
g_signal_connect( holder, "destroy", G_CALLBACK(delete_prefspusher), pusher);
@@ -622,7 +622,7 @@ void sp_calligraphy_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions
_("Add/Edit Profile"),
_("Add or edit calligraphic profile"),
INKSCAPE_ICON("document-properties"),
- Inkscape::ICON_SIZE_DECORATION );
+ GTK_ICON_SIZE_MENU );
g_object_set( inky, "short_label", _("Edit"), NULL );
g_signal_connect_after( G_OBJECT(inky), "activate", G_CALLBACK(sp_ddc_edit_profile), (GObject*)holder );
gtk_action_group_add_action( mainActions, GTK_ACTION(inky) );
diff --git a/src/widgets/connector-toolbar.cpp b/src/widgets/connector-toolbar.cpp
index a078ecec4..9c4980f4c 100644
--- a/src/widgets/connector-toolbar.cpp
+++ b/src/widgets/connector-toolbar.cpp
@@ -299,7 +299,7 @@ static void sp_connector_toolbox_selection_changed(Inkscape::Selection *selectio
void sp_connector_toolbox_prep( SPDesktop *desktop, GtkActionGroup* mainActions, GObject* holder )
{
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
- Inkscape::IconSize secondarySize = ToolboxFactory::prefToSize("/toolbox/secondary", 1);
+ GtkIconSize secondarySize = ToolboxFactory::prefToSize("/toolbox/secondary", 1);
{
InkAction* inky = ink_action_new( "ConnectorAvoidAction",
@@ -327,7 +327,7 @@ void sp_connector_toolbox_prep( SPDesktop *desktop, GtkActionGroup* mainActions,
_("Orthogonal"),
_("Make connector orthogonal or polyline"),
INKSCAPE_ICON("connector-orthogonal"),
- Inkscape::ICON_SIZE_DECORATION );
+ GTK_ICON_SIZE_MENU );
gtk_action_group_add_action( mainActions, GTK_ACTION( act ) );
bool tbuttonstate = prefs->getBool("/tools/connector/orthogonal");
@@ -388,7 +388,7 @@ void sp_connector_toolbox_prep( SPDesktop *desktop, GtkActionGroup* mainActions,
_("Downwards"),
_("Make connectors with end-markers (arrows) point downwards"),
INKSCAPE_ICON("distribute-graph-directed"),
- Inkscape::ICON_SIZE_DECORATION );
+ GTK_ICON_SIZE_MENU );
gtk_action_group_add_action( mainActions, GTK_ACTION( act ) );
bool tbuttonstate = prefs->getBool("/tools/connector/directedlayout");
@@ -404,7 +404,7 @@ void sp_connector_toolbox_prep( SPDesktop *desktop, GtkActionGroup* mainActions,
_("Remove overlaps"),
_("Do not allow overlapping shapes"),
INKSCAPE_ICON("distribute-remove-overlaps"),
- Inkscape::ICON_SIZE_DECORATION );
+ GTK_ICON_SIZE_MENU );
gtk_action_group_add_action( mainActions, GTK_ACTION( act ) );
bool tbuttonstate = prefs->getBool("/tools/connector/avoidoverlaplayout");
diff --git a/src/widgets/desktop-widget.cpp b/src/widgets/desktop-widget.cpp
index ce4c5936c..2479fa453 100644
--- a/src/widgets/desktop-widget.cpp
+++ b/src/widgets/desktop-widget.cpp
@@ -351,7 +351,7 @@ void SPDesktopWidget::init( SPDesktopWidget *dtw )
ToolboxFactory::setOrientation( dtw->tool_toolbox, GTK_ORIENTATION_VERTICAL );
gtk_box_pack_start( GTK_BOX(dtw->hbox), dtw->tool_toolbox, FALSE, TRUE, 0 );
// Lock guides button
- dtw->guides_lock = sp_button_new_from_data( Inkscape::ICON_SIZE_DECORATION,
+ dtw->guides_lock = sp_button_new_from_data( GTK_ICON_SIZE_MENU,
SP_BUTTON_TYPE_TOGGLE,
NULL,
INKSCAPE_ICON("object-locked"),
@@ -410,7 +410,7 @@ void SPDesktopWidget::init( SPDesktopWidget *dtw )
dtw->vscrollbar_box = gtk_box_new(GTK_ORIENTATION_VERTICAL, 0);
// Sticky zoom button
- dtw->sticky_zoom = sp_button_new_from_data ( Inkscape::ICON_SIZE_DECORATION,
+ dtw->sticky_zoom = sp_button_new_from_data ( GTK_ICON_SIZE_MENU,
SP_BUTTON_TYPE_TOGGLE,
NULL,
INKSCAPE_ICON("zoom-original"),
@@ -435,7 +435,7 @@ void SPDesktopWidget::init( SPDesktopWidget *dtw )
tip = act->tip;
}
}
- dtw->cms_adjust = sp_button_new_from_data( Inkscape::ICON_SIZE_DECORATION,
+ dtw->cms_adjust = sp_button_new_from_data( GTK_ICON_SIZE_MENU,
SP_BUTTON_TYPE_TOGGLE,
NULL,
INKSCAPE_ICON("color-management"),
@@ -543,7 +543,6 @@ void SPDesktopWidget::init( SPDesktopWidget *dtw )
dtw->layer_selector = new Inkscape::Widgets::LayerSelector(NULL);
// FIXME: need to unreference on container destruction to avoid leak
dtw->layer_selector->reference();
- //dtw->layer_selector->set_size_request(-1, SP_ICON_SIZE_BUTTON);
gtk_box_pack_start(GTK_BOX(dtw->statusbar), GTK_WIDGET(dtw->layer_selector->gobj()), FALSE, FALSE, 1);
// Select Status
diff --git a/src/widgets/dropper-toolbar.cpp b/src/widgets/dropper-toolbar.cpp
index 4e26a99a0..7a9cf1779 100644
--- a/src/widgets/dropper-toolbar.cpp
+++ b/src/widgets/dropper-toolbar.cpp
@@ -90,7 +90,7 @@ void sp_dropper_toolbox_prep(SPDesktop * /*desktop*/, GtkActionGroup* mainAction
_("Pick opacity"),
_("Pick both the color and the alpha (transparency) under cursor; otherwise, pick only the visible color premultiplied by alpha"),
NULL,
- Inkscape::ICON_SIZE_DECORATION );
+ GTK_ICON_SIZE_MENU );
g_object_set( act, "short_label", _("Pick"), NULL );
gtk_action_group_add_action( mainActions, GTK_ACTION( act ) );
g_object_set_data( holder, "pick_action", act );
@@ -103,7 +103,7 @@ void sp_dropper_toolbox_prep(SPDesktop * /*desktop*/, GtkActionGroup* mainAction
_("Assign opacity"),
_("If alpha was picked, assign it to selection as fill or stroke transparency"),
NULL,
- Inkscape::ICON_SIZE_DECORATION );
+ GTK_ICON_SIZE_MENU );
g_object_set( act, "short_label", _("Assign"), NULL );
gtk_action_group_add_action( mainActions, GTK_ACTION( act ) );
g_object_set_data( holder, "set_action", act );
diff --git a/src/widgets/ege-adjustment-action.cpp b/src/widgets/ege-adjustment-action.cpp
index 6678d1e5a..e4f041bd1 100644
--- a/src/widgets/ege-adjustment-action.cpp
+++ b/src/widgets/ege-adjustment-action.cpp
@@ -42,7 +42,6 @@
#include <cmath>
#include <string.h>
-#include "widgets/icon.h"
#include <gdk/gdkkeysyms.h>
#include "icon-size.h"
@@ -115,7 +114,7 @@ struct _EgeAdjustmentActionPrivate
GList* descriptions;
gchar* appearance;
gchar* iconId;
- Inkscape::IconSize iconSize;
+ GtkIconSize iconSize;
Inkscape::UI::Widget::UnitTracker *unitTracker;
};
@@ -232,9 +231,9 @@ static void ege_adjustment_action_class_init( EgeAdjustmentActionClass* klass )
g_param_spec_int( "iconSize",
"Icon Size",
"The size the icon",
- (int)Inkscape::ICON_SIZE_MENU,
- (int)Inkscape::ICON_SIZE_DECORATION,
- (int)Inkscape::ICON_SIZE_SMALL_TOOLBAR,
+ (int)GTK_ICON_SIZE_MENU,
+ (int)GTK_ICON_SIZE_DIALOG,
+ (int)GTK_ICON_SIZE_SMALL_TOOLBAR,
(GParamFlags)(G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT) ) );
g_object_class_install_property( objClass,
@@ -272,7 +271,7 @@ static void ege_adjustment_action_init( EgeAdjustmentAction* action )
action->private_data->descriptions = 0;
action->private_data->appearance = 0;
action->private_data->iconId = 0;
- action->private_data->iconSize = Inkscape::ICON_SIZE_SMALL_TOOLBAR;
+ action->private_data->iconSize = GTK_ICON_SIZE_SMALL_TOOLBAR;
action->private_data->unitTracker = NULL;
}
@@ -463,7 +462,7 @@ void ege_adjustment_action_set_property( GObject* obj, guint propId, const GValu
case PROP_ICON_SIZE:
{
- action->private_data->iconSize = (Inkscape::IconSize)g_value_get_int( value );
+ action->private_data->iconSize = (GtkIconSize)g_value_get_int( value );
}
break;
@@ -857,7 +856,7 @@ static GtkWidget* create_tool_item( GtkAction* action )
/* Use an icon if available or use short-label */
if ( act->private_data->iconId && strcmp( act->private_data->iconId, "" ) != 0 ) {
- GtkWidget* icon = sp_icon_new( act->private_data->iconSize, act->private_data->iconId );
+ GtkWidget* icon = gtk_image_new_from_icon_name( act->private_data->iconId, act->private_data->iconSize );
gtk_box_pack_start( GTK_BOX(hb), icon, FALSE, FALSE, 0 );
} else {
GtkWidget* lbl = gtk_label_new( g_value_get_string( &value ) ? g_value_get_string( &value ) : "wwww" );
diff --git a/src/widgets/eraser-toolbar.cpp b/src/widgets/eraser-toolbar.cpp
index 7377cdc00..b592b8ace 100644
--- a/src/widgets/eraser-toolbar.cpp
+++ b/src/widgets/eraser-toolbar.cpp
@@ -134,7 +134,7 @@ static void sp_toogle_break_apart( GtkToggleAction* act, gpointer data )
void sp_eraser_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions, GObject* holder)
{
- Inkscape::IconSize secondarySize = ToolboxFactory::prefToSize("/toolbox/secondary", 1);
+ GtkIconSize secondarySize = ToolboxFactory::prefToSize("/toolbox/secondary", 1);
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
gint eraser_mode = FALSE;
{
@@ -202,7 +202,7 @@ void sp_eraser_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions, GOb
_("Eraser Pressure"),
_("Use the pressure of the input device to alter the width of the pen"),
INKSCAPE_ICON("draw-use-pressure"),
- Inkscape::ICON_SIZE_DECORATION );
+ GTK_ICON_SIZE_MENU );
gtk_action_group_add_action( mainActions, GTK_ACTION( act ) );
PrefPusher *pusher = new PrefPusher(GTK_TOGGLE_ACTION(act), "/tools/eraser/usepressure", update_presets_list, holder);
g_signal_connect( holder, "destroy", G_CALLBACK(delete_prefspusher), pusher);
diff --git a/src/widgets/gradient-selector.cpp b/src/widgets/gradient-selector.cpp
index 569f66c2b..99ef9f19b 100644
--- a/src/widgets/gradient-selector.cpp
+++ b/src/widgets/gradient-selector.cpp
@@ -29,7 +29,6 @@
#include "verbs.h"
#include "helper/action.h"
#include "preferences.h"
-#include "widgets/icon.h"
#include <glibmm/i18n.h>
@@ -98,7 +97,7 @@ static void sp_gradient_selector_class_init(SPGradientSelectorClass *klass)
static void gradsel_style_button(GtkWidget *gtkbtn, char const *iconName)
{
Gtk::Button *btn = Glib::wrap(GTK_BUTTON(gtkbtn));
- GtkWidget *child = sp_icon_new(Inkscape::ICON_SIZE_SMALL_TOOLBAR, iconName);
+ GtkWidget *child = gtk_image_new_from_icon_name(iconName, GTK_ICON_SIZE_SMALL_TOOLBAR);
gtk_widget_show(child);
btn->add(*manage(Glib::wrap(child)));
btn->set_relief(Gtk::RELIEF_NONE);
diff --git a/src/widgets/gradient-toolbar.cpp b/src/widgets/gradient-toolbar.cpp
index 8474327ca..196264315 100644
--- a/src/widgets/gradient-toolbar.cpp
+++ b/src/widgets/gradient-toolbar.cpp
@@ -1026,7 +1026,7 @@ static void gradient_toolbox_check_ec(SPDesktop* dt, Inkscape::UI::Tools::ToolBa
*/
void sp_gradient_toolbox_prep(SPDesktop * desktop, GtkActionGroup* mainActions, GObject* holder)
{
- Inkscape::IconSize secondarySize = ToolboxFactory::prefToSize("/toolbox/secondary", 1);
+ GtkIconSize secondarySize = ToolboxFactory::prefToSize("/toolbox/secondary", 1);
/* New gradient linear or radial */
{
@@ -1221,7 +1221,7 @@ void sp_gradient_toolbox_prep(SPDesktop * desktop, GtkActionGroup* mainActions,
_("Link gradients"),
_("Link gradients to change all related gradients"),
INKSCAPE_ICON("object-unlocked"),
- Inkscape::ICON_SIZE_DECORATION );
+ GTK_ICON_SIZE_MENU );
g_object_set( itact, "short_label", "Lock", NULL );
g_signal_connect_after( G_OBJECT(itact), "toggled", G_CALLBACK(gr_linked_changed), desktop) ;
gtk_action_group_add_action( mainActions, GTK_ACTION(itact) );
diff --git a/src/widgets/icon.cpp b/src/widgets/icon.cpp
deleted file mode 100644
index 885deaab7..000000000
--- a/src/widgets/icon.cpp
+++ /dev/null
@@ -1,1651 +0,0 @@
-/** \file
- * SPIcon: Generic icon widget
- */
-/*
- * Author:
- * Lauris Kaplinski <lauris@kaplinski.com>
- * Jon A. Cruz <jon@joncruz.org>
- * Abhishek Sharma
- *
- * Copyright (C) 2002 Lauris Kaplinski
- *
- * Released under GNU GPL, read the file 'COPYING' for more information
- */
-
-#ifdef HAVE_CONFIG_H
-# include "config.h"
-#endif
-
-#include <glibmm/fileutils.h>
-#include <glibmm/miscutils.h>
-#include <gtkmm/icontheme.h>
-#include <cstring>
-#include <glib/gstdio.h>
-#include <gtk/gtk.h>
-#include <gtkmm/image.h>
-#include <2geom/transforms.h>
-
-#include "path-prefix.h"
-#include "preferences.h"
-#include "inkscape.h"
-#include "document.h"
-#include "display/cairo-utils.h"
-#include "display/drawing-context.h"
-#include "display/drawing-item.h"
-#include "display/drawing.h"
-#include "io/sys.h"
-#include "sp-root.h"
-#include "sp-namedview.h"
-#include "util/units.h"
-
-#include "icon.h"
-#include "ui/icon-names.h"
-
-struct IconImpl {
- static GtkWidget *newFull( Inkscape::IconSize lsize, gchar const *name );
-
- static void dispose(GObject *object);
-
- static void reset(SPIcon *icon);
- static void clear(SPIcon *icon);
-
- static void sizeRequest(GtkWidget *widget, GtkRequisition *requisition);
-
- static void getPreferredWidth(GtkWidget *widget,
- gint *minimal_width,
- gint *natural_width);
-
- static void getPreferredHeight(GtkWidget *widget,
- gint *minimal_height,
- gint *natural_height);
-
- static void sizeAllocate(GtkWidget *widget, GtkAllocation *allocation);
- static gboolean draw(GtkWidget *widget, cairo_t *cr);
-
- static void screenChanged( GtkWidget *widget, GdkScreen *previous_screen );
- static void styleSet( GtkWidget *widget, GtkStyle *previous_style );
- static void themeChanged( SPIcon *icon );
-
- static int getPhysSize(int size);
- static void fetchPixbuf( SPIcon *icon );
-
- static gboolean prerenderTask(gpointer data);
- static void addPreRender( GtkIconSize lsize, gchar const *name );
- static GdkPixbuf* renderup( gchar const* name, Inkscape::IconSize lsize, unsigned psize );
-
-
- static GdkPixbuf *loadPixmap(gchar const *name, unsigned lsize, unsigned psize);
- static GdkPixbuf *loadSvg(std::list<Glib::ustring> const &names, GtkIconSize lsize, unsigned psize);
-
- static void overlayPixels( guchar *px, int width, int height, int stride,
- unsigned r, unsigned g, unsigned b );
-
- static void injectCustomSize();
-
- static void imageMapCB(GtkWidget* widget, gpointer user_data);
- static void imageMapNamedCB(GtkWidget* widget, gpointer user_data);
- static bool prerenderIcon(gchar const *name, GtkIconSize lsize, unsigned psize);
-
-
- static std::list<gchar*> &icons_svg_paths();
- static guchar *load_svg_pixels(std::list<Glib::ustring> const &names,
- unsigned psize, unsigned &stride);
-
- static std::string fileEscape( std::string const & str );
-
- static void validateCache();
- static void setupLegacyNaming();
-
-private:
- static const std::string magicNumber;
- static std::map<Glib::ustring, Glib::ustring> legacyNames;
-};
-
-const std::string IconImpl::magicNumber = "1.0";
-std::map<Glib::ustring, Glib::ustring> IconImpl::legacyNames;
-
-
-static bool sizeDirty = true;
-
-static bool sizeMapDone = false;
-static GtkIconSize iconSizeLookup[] = {
- GTK_ICON_SIZE_INVALID,
- GTK_ICON_SIZE_MENU,
- GTK_ICON_SIZE_SMALL_TOOLBAR,
- GTK_ICON_SIZE_LARGE_TOOLBAR,
- GTK_ICON_SIZE_BUTTON,
- GTK_ICON_SIZE_DND,
- GTK_ICON_SIZE_DIALOG,
- GTK_ICON_SIZE_MENU, // for Inkscape::ICON_SIZE_DECORATION
-};
-
-class IconCacheItem
-{
-public:
- IconCacheItem( GtkIconSize lsize, GdkPixbuf* pb ) :
- _lsize( lsize ),
- _pb( pb )
- {}
- GtkIconSize _lsize;
- GdkPixbuf* _pb;
-};
-
-static std::map<Glib::ustring, std::vector<IconCacheItem> > iconSetCache;
-static std::set<Glib::ustring> internalNames;
-
-G_DEFINE_TYPE(SPIcon, sp_icon, GTK_TYPE_WIDGET);
-
-static void
-sp_icon_class_init(SPIconClass *klass)
-{
- GObjectClass *object_class = G_OBJECT_CLASS(klass);
- GtkWidgetClass *widget_class = GTK_WIDGET_CLASS(klass);
-
- object_class->dispose = IconImpl::dispose;
-
- widget_class->get_preferred_width = IconImpl::getPreferredWidth;
- widget_class->get_preferred_height = IconImpl::getPreferredHeight;
- widget_class->draw = IconImpl::draw;
- widget_class->size_allocate = IconImpl::sizeAllocate;
- widget_class->screen_changed = IconImpl::screenChanged;
- widget_class->style_set = IconImpl::styleSet;
-}
-
-static void
-sp_icon_init(SPIcon *icon)
-{
- gtk_widget_set_has_window (GTK_WIDGET (icon), FALSE);
- icon->lsize = Inkscape::ICON_SIZE_BUTTON;
- icon->psize = 0;
- icon->name = NULL;
- icon->pb = NULL;
-}
-
-void IconImpl::dispose(GObject *object)
-{
- SPIcon *icon = SP_ICON(object);
- clear(icon);
- if ( icon->name ) {
- g_free( icon->name );
- icon->name = NULL;
- }
-
- (G_OBJECT_CLASS(sp_icon_parent_class))->dispose(object);
-}
-
-void IconImpl::reset( SPIcon *icon )
-{
- icon->psize = 0;
- clear(icon);
-}
-
-void IconImpl::clear( SPIcon *icon )
-{
- if (icon->pb) {
- g_object_unref(G_OBJECT(icon->pb));
- icon->pb = NULL;
- }
-}
-
-void IconImpl::sizeRequest(GtkWidget *widget, GtkRequisition *requisition)
-{
- SPIcon const *icon = SP_ICON(widget);
-
- int const size = ( icon->psize
- ? icon->psize
- : getPhysSize(icon->lsize) );
- requisition->width = size;
- requisition->height = size;
-}
-
-void IconImpl::getPreferredWidth(GtkWidget *widget, gint *minimal_width, gint *natural_width)
-{
- GtkRequisition requisition;
- sizeRequest(widget, &requisition);
- *minimal_width = *natural_width = requisition.width;
-}
-
-void IconImpl::getPreferredHeight(GtkWidget *widget, gint *minimal_height, gint *natural_height)
-{
- GtkRequisition requisition;
- sizeRequest(widget, &requisition);
- *minimal_height = *natural_height = requisition.height;
-}
-
-void IconImpl::sizeAllocate(GtkWidget *widget, GtkAllocation *allocation)
-{
- gtk_widget_set_allocation(widget, allocation);
-
- if (gtk_widget_is_drawable(widget)) {
- gtk_widget_queue_draw(widget);
- }
-}
-
-// GTK3 Only, Doesn't actually seem to be used.
-gboolean IconImpl::draw(GtkWidget *widget, cairo_t* cr)
-{
- SPIcon *icon = SP_ICON(widget);
- if ( !icon->pb ) {
- fetchPixbuf( icon );
- }
-
- GdkPixbuf *image = icon->pb;
- bool unref_image = false;
-
- /* copied from the expose function of GtkImage */
- if (gtk_widget_get_state_flags (GTK_WIDGET(icon)) != GTK_STATE_FLAG_NORMAL && image) {
- std::cerr << "IconImpl::draw: No image, creating fallback" << std::endl;
-
- GtkIconTheme *icon_theme = gtk_icon_theme_get_default();
- image = gtk_icon_theme_load_icon (icon_theme,
- "gtk-image",
- 32,
- (GtkIconLookupFlags)0,
- NULL);
-
- unref_image = true;
- }
-
- if (image) {
- GtkAllocation allocation;
- GtkRequisition requisition;
- gtk_widget_get_allocation(widget, &allocation);
- gtk_widget_get_preferred_size(widget, &requisition, NULL);
-
- int x = floor(allocation.x + ((allocation.width - requisition.width) * 0.5));
- int y = floor(allocation.y + ((allocation.height - requisition.height) * 0.5));
- int width = gdk_pixbuf_get_width(image);
- int height = gdk_pixbuf_get_height(image);
- // Limit drawing to when we actually have something. Avoids some crashes.
- if ( (width > 0) && (height > 0) ) {
- gdk_cairo_set_source_pixbuf(cr, image, x, y);
- cairo_paint(cr);
- }
- }
-
- if (unref_image) {
- g_object_unref(G_OBJECT(image));
- }
-
- return TRUE;
-}
-
-// PUBLIC CALL:
-void sp_icon_fetch_pixbuf( SPIcon *icon )
-{
- return IconImpl::fetchPixbuf(icon);
-}
-
-void IconImpl::fetchPixbuf( SPIcon *icon )
-{
- if ( icon ) {
- if ( !icon->pb ) {
- icon->psize = getPhysSize(icon->lsize);
- icon->pb = renderup(icon->name, icon->lsize, icon->psize);
- }
- }
-}
-
-GdkPixbuf* IconImpl::renderup( gchar const* name, Inkscape::IconSize lsize, unsigned psize ) {
- GtkIconTheme *theme = gtk_icon_theme_get_default();
-
- GdkPixbuf *pb = NULL;
- if (gtk_icon_theme_has_icon(theme, name)) {
- pb = gtk_icon_theme_load_icon(theme, name, psize, (GtkIconLookupFlags) 0, NULL);
- }
- if (!pb) {
- std::list<Glib::ustring> names;
- names.push_back(name);
- if ( legacyNames.find(name) != legacyNames.end() ) {
- if ( Inkscape::Preferences::get()->getBool("/debug/icons/dumpSvg") ) {
- g_message("Checking fallback [%s]->[%s]", name, legacyNames[name].c_str());
- }
- names.push_back(legacyNames[name]);
- }
-
- pb = loadSvg( names, Inkscape::getRegisteredIconSize(lsize), psize );
-
- // if this was loaded from SVG, add it as a builtin icon
- if (pb) {
- gtk_icon_theme_add_builtin_icon(name, psize, pb);
- }
- }
- if (!pb) {
- pb = loadPixmap( name, lsize, psize );
- }
- if ( !pb ) {
- // TODO: We should do something more useful if we can't load the image.
- g_warning ("failed to load icon '%s'", name);
- }
- return pb;
-}
-
-void IconImpl::screenChanged( GtkWidget *widget, GdkScreen *previous_screen )
-{
- if ( GTK_WIDGET_CLASS( sp_icon_parent_class )->screen_changed ) {
- GTK_WIDGET_CLASS( sp_icon_parent_class )->screen_changed( widget, previous_screen );
- }
- SPIcon *icon = SP_ICON(widget);
- themeChanged(icon);
-}
-
-void IconImpl::styleSet( GtkWidget *widget, GtkStyle *previous_style )
-{
- if ( GTK_WIDGET_CLASS( sp_icon_parent_class )->style_set ) {
- GTK_WIDGET_CLASS( sp_icon_parent_class )->style_set( widget, previous_style );
- }
- SPIcon *icon = SP_ICON(widget);
- themeChanged(icon);
-}
-
-void IconImpl::themeChanged( SPIcon *icon )
-{
- bool const dump = Inkscape::Preferences::get()->getBool("/debug/icons/dumpSvg");
- if ( dump ) {
- g_message("Got a change bump for this icon");
- }
- sizeDirty = true;
- reset(icon);
- gtk_widget_queue_draw( GTK_WIDGET(icon) );
-}
-
-std::string IconImpl::fileEscape( std::string const & str )
-{
- std::string result;
- result.reserve(str.size());
- for ( size_t i = 0; i < str.size(); ++i ) {
- char ch = str[i];
- if ( (0x20 <= ch) && !(0x80 & ch) ) {
- result += ch;
- } else {
- result += "\\x";
- gchar *tmp = g_strdup_printf("%02X", (0x0ff & ch));
- result += tmp;
- g_free(tmp);
- }
- }
- return result;
-}
-
-static bool isSizedSubdir( std::string const &name )
-{
- bool isSized = false;
- if ( (name.size() > 2) && (name.size() & 1) ) { // needs to be an odd length 3 or more
- size_t mid = (name.size() - 1) / 2;
- if ( (name[mid] == 'x') && (name.substr(0, mid) == name.substr(mid + 1)) ) {
- isSized = true;
- for ( size_t i = 0; (i < mid) && isSized; ++i ) {
- isSized &= g_ascii_isdigit(name[i]);
- }
- }
- }
- return isSized;
-}
-
-void IconImpl::validateCache()
-{
- std::list<gchar *> &sources = icons_svg_paths();
- std::string iconCacheDir = Glib::build_filename(Glib::build_filename(Glib::get_user_cache_dir(), "inkscape"), "icons");
- std::string iconCacheFile = Glib::build_filename( iconCacheDir, "cache.info" );
-
- std::vector<std::string> filesFound;
-
- for (std::list<gchar*>::iterator i = sources.begin(); i != sources.end(); ++i) {
- gchar const* potentialFile = *i;
- if ( Glib::file_test(potentialFile, Glib::FILE_TEST_EXISTS) && Glib::file_test(potentialFile, Glib::FILE_TEST_IS_REGULAR) ) {
- filesFound.push_back(*i);
- }
- }
-
- unsigned long lastSeen = 0;
- std::ostringstream out;
- out << "Inkscape cache v" << std::hex << magicNumber << std::dec << std::endl;
- out << "Sourcefiles: " << filesFound.size() << std::endl;
- for ( std::vector<std::string>::iterator it = filesFound.begin(); it != filesFound.end(); ++it ) {
- GStatBuf st;
- memset(&st, 0, sizeof(st));
- if ( !g_stat(it->c_str(), &st) ) {
- unsigned long when = st.st_mtime;
- lastSeen = std::max(lastSeen, when);
- out << std::hex << when << std::dec << " " << fileEscape(*it) << std::endl;
- } else {
- out << "0 " << fileEscape(*it) << std::endl;
- }
- }
- std::string wanted = out.str();
-
- std::string present;
- {
- gchar *contents = NULL;
- if ( g_file_get_contents(iconCacheFile.c_str(), &contents, 0, 0) ) {
- if ( contents ) {
- present = contents;
- }
- g_free(contents);
- contents = NULL;
- }
- }
- bool cacheValid = (present == wanted);
-
- if ( cacheValid ) {
- // Check if any cached rasters are out of date
- Glib::Dir dir(iconCacheDir);
- for ( Glib::DirIterator it = dir.begin(); cacheValid && (it != dir.end()); ++it ) {
- if ( isSizedSubdir(*it) ) {
- std::string subdirName = Glib::build_filename( iconCacheDir, *it );
- if ( Glib::file_test(subdirName, Glib::FILE_TEST_IS_DIR) ) {
- Glib::Dir subdir(subdirName);
- for ( Glib::DirIterator subit = subdir.begin(); cacheValid && (subit != subdir.end()); ++subit ) {
- std::string fullpath = Glib::build_filename( subdirName, *subit );
- if ( Glib::file_test(fullpath, Glib::FILE_TEST_EXISTS) && !Glib::file_test(fullpath, Glib::FILE_TEST_IS_DIR) ) {
- GStatBuf st;
- memset(&st, 0, sizeof(st));
- if ( !g_stat(fullpath.c_str(), &st) ) {
- unsigned long when = st.st_mtime;
- if ( when < lastSeen ) {
- cacheValid = false;
- }
- }
- }
- }
- }
- }
- }
- }
-
- if ( !cacheValid ) {
- if ( Glib::file_test(iconCacheDir, Glib::FILE_TEST_EXISTS) ) {
- // Purge existing icons, but not possible future sub-directories.
- if ( Glib::file_test(iconCacheDir, Glib::FILE_TEST_IS_DIR) ) {
- Glib::Dir dir(iconCacheDir);
- for ( Glib::DirIterator it = dir.begin(); it != dir.end(); ++it ) {
- if ( isSizedSubdir(*it) ) {
- std::string subdirName = Glib::build_filename( iconCacheDir, *it );
- if ( Glib::file_test(subdirName, Glib::FILE_TEST_IS_DIR) ) {
- Glib::Dir subdir(subdirName);
- for ( Glib::DirIterator subit = subdir.begin(); subit != subdir.end(); ++subit ) {
- std::string fullpath = Glib::build_filename( subdirName, *subit );
- if ( Glib::file_test(fullpath, Glib::FILE_TEST_EXISTS) && !Glib::file_test(fullpath, Glib::FILE_TEST_IS_DIR) ) {
- g_remove(fullpath.c_str());
- }
- }
- g_rmdir( subdirName.c_str() );
- }
- }
- }
- }
- } else {
- g_mkdir_with_parents( iconCacheDir.c_str(), 0x1ED );
- }
-
- if ( g_file_set_contents(iconCacheFile.c_str(), wanted.c_str(), wanted.size(), 0) ) {
- // Caching may proceed
- } else {
- g_warning("Unable to write cache info file.");
- }
- }
-}
-
-static Glib::ustring icon_cache_key(Glib::ustring const &name, unsigned psize);
-static GdkPixbuf *get_cached_pixbuf(Glib::ustring const &key);
-
-void IconImpl::setupLegacyNaming() {
- legacyNames["document-import"] ="file_import";
- legacyNames["document-export"] ="file_export";
- legacyNames["document-import-ocal"] ="ocal_import";
- legacyNames["document-export-ocal"] ="ocal_export";
- legacyNames["document-metadata"] ="document_metadata";
- legacyNames["dialog-input-devices"] ="input_devices";
- legacyNames["edit-duplicate"] ="edit_duplicate";
- legacyNames["edit-clone"] ="edit_clone";
- legacyNames["edit-clone-unlink"] ="edit_unlink_clone";
- legacyNames["edit-select-original"] ="edit_select_original";
- legacyNames["edit-undo-history"] ="edit_undo_history";
- legacyNames["edit-paste-in-place"] ="selection_paste_in_place";
- legacyNames["edit-paste-style"] ="selection_paste_style";
- legacyNames["selection-make-bitmap-copy"] ="selection_bitmap";
- legacyNames["edit-select-all"] ="selection_select_all";
- legacyNames["edit-select-all-layers"] ="selection_select_all_in_all_layers";
- legacyNames["edit-select-invert"] ="selection_invert";
- legacyNames["edit-select-none"] ="selection_deselect";
- legacyNames["dialog-xml-editor"] ="xml_editor";
- legacyNames["zoom-original"] ="zoom_1_to_1";
- legacyNames["zoom-half-size"] ="zoom_1_to_2";
- legacyNames["zoom-double-size"] ="zoom_2_to_1";
- legacyNames["zoom-fit-selection"] ="zoom_select";
- legacyNames["zoom-fit-drawing"] ="zoom_draw";
- legacyNames["zoom-fit-page"] ="zoom_page";
- legacyNames["zoom-fit-width"] ="zoom_pagewidth";
- legacyNames["zoom-previous"] ="zoom_previous";
- legacyNames["zoom-next"] ="zoom_next";
- legacyNames["zoom-in"] ="zoom_in";
- legacyNames["zoom-out"] ="zoom_out";
- legacyNames["show-grid"] ="grid";
- legacyNames["show-guides"] ="guides";
- legacyNames["color-management"] ="color_management";
- legacyNames["show-dialogs"] ="dialog_toggle";
- legacyNames["dialog-messages"] ="messages";
- legacyNames["dialog-scripts"] ="scripts";
- legacyNames["window-previous"] ="window_previous";
- legacyNames["window-next"] ="window_next";
- legacyNames["dialog-icon-preview"] ="view_icon_preview";
- legacyNames["window-new"] ="view_new";
- legacyNames["view-fullscreen"] ="fullscreen";
- legacyNames["layer-new"] ="new_layer";
- legacyNames["layer-rename"] ="rename_layer";
- legacyNames["layer-previous"] ="switch_to_layer_above";
- legacyNames["layer-next"] ="switch_to_layer_below";
- legacyNames["selection-move-to-layer-above"] ="move_selection_above";
- legacyNames["selection-move-to-layer-below"] ="move_selection_below";
- legacyNames["layer-raise"] ="raise_layer";
- legacyNames["layer-lower"] ="lower_layer";
- legacyNames["layer-top"] ="layer_to_top";
- legacyNames["layer-bottom"] ="layer_to_bottom";
- legacyNames["layer-delete"] ="delete_layer";
- legacyNames["dialog-layers"] ="layers";
- legacyNames["dialog-fill-and-stroke"] ="fill_and_stroke";
- legacyNames["dialog-object-properties"] ="dialog_item_properties";
- legacyNames["object-group"] ="selection_group";
- legacyNames["object-ungroup"] ="selection_ungroup";
- legacyNames["selection-raise"] ="selection_up";
- legacyNames["selection-lower"] ="selection_down";
- legacyNames["selection-top"] ="selection_top";
- legacyNames["selection-bottom"] ="selection_bot";
- legacyNames["object-rotate-left"] ="object_rotate_90_CCW";
- legacyNames["object-rotate-right"] ="object_rotate_90_CW";
- legacyNames["object-flip-horizontal"] ="object_flip_hor";
- legacyNames["object-flip-vertical"] ="object_flip_ver";
- legacyNames["dialog-transform"] ="object_trans";
- legacyNames["dialog-align-and-distribute"] ="object_align";
- legacyNames["dialog-rows-and-columns"] ="grid_arrange";
- legacyNames["object-to-path"] ="object_tocurve";
- legacyNames["stroke-to-path"] ="stroke_tocurve";
- legacyNames["bitmap-trace"] ="selection_trace";
- legacyNames["path-union"] ="union";
- legacyNames["path-difference"] ="difference";
- legacyNames["path-intersection"] ="intersection";
- legacyNames["path-exclusion"] ="exclusion";
- legacyNames["path-division"] ="division";
- legacyNames["path-cut"] ="cut_path";
- legacyNames["path-combine"] ="selection_combine";
- legacyNames["path-break-apart"] ="selection_break";
- legacyNames["path-outset"] ="outset_path";
- legacyNames["path-inset"] ="inset_path";
- legacyNames["path-offset-dynamic"] ="dynamic_offset";
- legacyNames["path-offset-linked"] ="linked_offset";
- legacyNames["path-simplify"] ="simplify";
- legacyNames["path-reverse"] ="selection_reverse";
- legacyNames["dialog-text-and-font"] ="object_font";
- legacyNames["text-put-on-path"] ="put_on_path";
- legacyNames["text-remove-from-path"] ="remove_from_path";
- legacyNames["text-flow-into-frame"] ="flow_into_frame";
- legacyNames["text-unflow"] ="unflow";
- legacyNames["text-convert-to-regular"] ="convert_to_text";
- legacyNames["text-unkern"] ="remove_manual_kerns";
- legacyNames["help-keyboard-shortcuts"] ="help_keys";
- legacyNames["help-contents"] ="help_tutorials";
- legacyNames["inkscape-logo"] ="inkscape_options";
- legacyNames["dialog-memory"] ="about_memory";
- legacyNames["tool-pointer"] ="draw_select";
- legacyNames["tool-node-editor"] ="draw_node";
- legacyNames["tool-tweak"] ="draw_tweak";
- legacyNames["zoom"] ="draw_zoom";
- legacyNames["draw-rectangle"] ="draw_rect";
- legacyNames["draw-cuboid"] ="draw_3dbox";
- legacyNames["draw-ellipse"] ="draw_arc";
- legacyNames["draw-polygon-star"] ="draw_star";
- legacyNames["draw-spiral"] ="draw_spiral";
- legacyNames["draw-freehand"] ="draw_freehand";
- legacyNames["draw-path"] ="draw_pen";
- legacyNames["draw-calligraphic"] ="draw_calligraphic";
- legacyNames["draw-eraser"] ="draw_erase";
- legacyNames["color-fill"] ="draw_paintbucket";
- legacyNames["draw-text"] ="draw_text";
- legacyNames["draw-connector"] ="draw_connector";
- legacyNames["color-gradient"] ="draw_gradient";
- legacyNames["color-picker"] ="draw_dropper";
- legacyNames["transform-affect-stroke"] ="transform_stroke";
- legacyNames["transform-affect-rounded-corners"] ="transform_corners";
- legacyNames["transform-affect-gradient"] ="transform_gradient";
- legacyNames["transform-affect-pattern"] ="transform_pattern";
- legacyNames["node-add"] ="node_insert";
- legacyNames["node-delete"] ="node_delete";
- legacyNames["node-join"] ="node_join";
- legacyNames["node-break"] ="node_break";
- legacyNames["node-join-segment"] ="node_join_segment";
- legacyNames["node-delete-segment"] ="node_delete_segment";
- legacyNames["node-type-cusp"] ="node_cusp";
- legacyNames["node-type-smooth"] ="node_smooth";
- legacyNames["node-type-symmetric"] ="node_symmetric";
- legacyNames["node-type-auto-smooth"] ="node_auto";
- legacyNames["node-segment-curve"] ="node_curve";
- legacyNames["node-segment-line"] ="node_line";
- legacyNames["show-node-handles"] ="nodes_show_handles";
- legacyNames["path-effect-parameter-next"] ="edit_next_parameter";
- legacyNames["show-path-outline"] ="nodes_show_helperpath";
- legacyNames["path-clip-edit"] ="nodeedit-clippath";
- legacyNames["path-mask-edit"] ="nodeedit-mask";
- legacyNames["node-type-cusp"] ="node_cusp";
- legacyNames["object-tweak-push"] ="tweak_move_mode";
- legacyNames["object-tweak-attract"] ="tweak_move_mode_inout";
- legacyNames["object-tweak-randomize"] ="tweak_move_mode_jitter";
- legacyNames["object-tweak-shrink"] ="tweak_scale_mode";
- legacyNames["object-tweak-rotate"] ="tweak_rotate_mode";
- legacyNames["object-tweak-duplicate"] ="tweak_moreless_mode";
- legacyNames["object-tweak-push"] ="tweak_move_mode";
- legacyNames["path-tweak-push"] ="tweak_push_mode";
- legacyNames["path-tweak-shrink"] ="tweak_shrink_mode";
- legacyNames["path-tweak-attract"] ="tweak_attract_mode";
- legacyNames["path-tweak-roughen"] ="tweak_roughen_mode";
- legacyNames["object-tweak-paint"] ="tweak_colorpaint_mode";
- legacyNames["object-tweak-jitter-color"] ="tweak_colorjitter_mode";
- legacyNames["object-tweak-blur"] ="tweak_blur_mode";
- legacyNames["rectangle-make-corners-sharp"] ="squared_corner";
- legacyNames["perspective-parallel"] ="toggle_vp_x";
- legacyNames["draw-ellipse-whole"] ="reset_circle";
- legacyNames["draw-ellipse-segment"] ="circle_closed_arc";
- legacyNames["draw-ellipse-arc"] ="circle_open_arc";
- legacyNames["draw-polygon"] ="star_flat";
- legacyNames["draw-star"] ="star_angled";
- legacyNames["path-mode-bezier"] ="bezier_mode";
- legacyNames["path-mode-spiro"] ="spiro_splines_mode";
- legacyNames["path-mode-bspline"] ="bspline_mode";
- legacyNames["path-mode-polyline"] ="polylines_mode";
- legacyNames["path-mode-polyline-paraxial"] ="paraxial_lines_mode";
- legacyNames["draw-use-tilt"] ="guse_tilt";
- legacyNames["draw-use-pressure"] ="guse_pressure";
- legacyNames["draw-trace-background"] ="trace_background";
- legacyNames["draw-eraser-delete-objects"] ="delete_object";
- legacyNames["format-text-direction-vertical"] ="writing_mode_tb";
- legacyNames["format-text-direction-horizontal"] ="writing_mode_lr";
- legacyNames["connector-avoid"] ="connector_avoid";
- legacyNames["connector-ignore"] ="connector_ignore";
- legacyNames["object-fill"] ="controls_fill";
- legacyNames["object-stroke"] ="controls_stroke";
- legacyNames["snap"] ="toggle_snap_global";
- legacyNames["snap-bounding-box"] ="toggle_snap_bbox";
- legacyNames["snap-bounding-box-edges"] ="toggle_snap_to_bbox_path";
- legacyNames["snap-bounding-box-corners"] ="toggle_snap_to_bbox_node";
- legacyNames["snap-bounding-box-midpoints"] ="toggle_snap_to_bbox_edge_midpoints";
- legacyNames["snap-bounding-box-center"] ="toggle_snap_to_bbox_midpoints";
- legacyNames["snap-nodes"] ="toggle_snap_nodes";
- legacyNames["snap-nodes-path"] ="toggle_snap_to_paths";
- legacyNames["snap-nodes-cusp"] ="toggle_snap_to_nodes";
- legacyNames["snap-nodes-smooth"] ="toggle_snap_to_smooth_nodes";
- legacyNames["snap-nodes-midpoint"] ="toggle_snap_to_midpoints";
- legacyNames["snap-nodes-intersection"] ="toggle_snap_to_path_intersections";
- legacyNames["snap-nodes-center"] ="toggle_snap_to_bbox_midpoints-3";
- legacyNames["snap-nodes-rotation-center"] ="toggle_snap_center";
- legacyNames["snap-page"] ="toggle_snap_page_border";
- legacyNames["snap-grid-guide-intersections"] ="toggle_snap_grid_guide_intersections";
- legacyNames["align-horizontal-right-to-anchor"] ="al_left_out";
- legacyNames["align-horizontal-left"] ="al_left_in";
- legacyNames["align-horizontal-center"] ="al_center_hor";
- legacyNames["align-horizontal-right"] ="al_right_in";
- legacyNames["align-horizontal-left-to-anchor"] ="al_right_out";
- legacyNames["align-horizontal-baseline"] ="al_baselines_vert";
- legacyNames["align-vertical-bottom-to-anchor"] ="al_top_out";
- legacyNames["align-vertical-top"] ="al_top_in";
- legacyNames["align-vertical-center"] ="al_center_ver";
- legacyNames["align-vertical-bottom"] ="al_bottom_in";
- legacyNames["align-vertical-top-to-anchor"] ="al_bottom_out";
- legacyNames["align-vertical-baseline"] ="al_baselines_hor";
- legacyNames["distribute-horizontal-left"] ="distribute_left";
- legacyNames["distribute-horizontal-center"] ="distribute_hcentre";
- legacyNames["distribute-horizontal-right"] ="distribute_right";
- legacyNames["distribute-horizontal-baseline"] ="distribute_baselines_hor";
- legacyNames["distribute-vertical-bottom"] ="distribute_bottom";
- legacyNames["distribute-vertical-center"] ="distribute_vcentre";
- legacyNames["distribute-vertical-top"] ="distribute_top";
- legacyNames["distribute-vertical-baseline"] ="distribute_baselines_vert";
- legacyNames["distribute-randomize"] ="distribute_randomize";
- legacyNames["distribute-unclump"] ="unclump";
- legacyNames["distribute-graph"] ="graph_layout";
- legacyNames["distribute-graph-directed"] ="directed_graph";
- legacyNames["distribute-remove-overlaps"] ="remove_overlaps";
- legacyNames["align-horizontal-node"] ="node_valign";
- legacyNames["align-vertical-node"] ="node_halign";
- legacyNames["distribute-vertical-node"] ="node_vdistribute";
- legacyNames["distribute-horizontal-node"] ="node_hdistribute";
- legacyNames["xml-element-new"] ="add_xml_element_node";
- legacyNames["xml-text-new"] ="add_xml_text_node";
- legacyNames["xml-node-delete"] ="delete_xml_node";
- legacyNames["xml-node-duplicate"] ="duplicate_xml_node";
- legacyNames["xml-attribute-delete"] ="delete_xml_attribute";
- legacyNames["transform-move-horizontal"] ="arrows_hor";
- legacyNames["transform-move-vertical"] ="arrows_ver";
- legacyNames["transform-scale-horizontal"] ="transform_scale_hor";
- legacyNames["transform-scale-vertical"] ="transform_scale_ver";
- legacyNames["transform-skew-horizontal"] ="transform_scew_hor";
- legacyNames["transform-skew-vertical"] ="transform_scew_ver";
- legacyNames["object-fill"] ="properties_fill";
- legacyNames["object-stroke"] ="properties_stroke_paint";
- legacyNames["object-stroke-style"] ="properties_stroke";
- legacyNames["paint-none"] ="fill_none";
- legacyNames["paint-solid"] ="fill_solid";
- legacyNames["paint-gradient-linear"] ="fill_gradient";
- legacyNames["paint-gradient-radial"] ="fill_radial";
- legacyNames["paint-pattern"] ="fill_pattern";
- legacyNames["paint-unknown"] ="fill_unset";
- legacyNames["fill-rule-even-odd"] ="fillrule_evenodd";
- legacyNames["fill-rule-nonzero"] ="fillrule_nonzero";
- legacyNames["stroke-join-miter"] ="join_miter";
- legacyNames["stroke-join-bevel"] ="join_bevel";
- legacyNames["stroke-join-round"] ="join_round";
- legacyNames["stroke-cap-butt"] ="cap_butt";
- legacyNames["stroke-cap-square"] ="cap_square";
- legacyNames["stroke-cap-round"] ="cap_round";
- legacyNames["guides"] ="guide";
- legacyNames["grid-rectangular"] ="grid_xy";
- legacyNames["grid-axonometric"] ="grid_axonom";
- legacyNames["object-visible"] ="visible";
- legacyNames["object-hidden"] ="hidden";
- legacyNames["object-unlocked"] ="lock_unlocked";
- legacyNames["object-locked"] ="width_height_lock";
- legacyNames["zoom"] ="sticky_zoom";
-}
-
-GtkWidget *IconImpl::newFull( Inkscape::IconSize lsize, gchar const *name )
-{
- static bool dump = Inkscape::Preferences::get()->getBool("/debug/icons/dumpGtk");
-
- GtkWidget *widget = NULL;
- gint trySize = CLAMP( static_cast<gint>(lsize), 0, static_cast<gint>(G_N_ELEMENTS(iconSizeLookup) - 1) );
- if (trySize != lsize ) {
- std::cerr << "GtkWidget *IconImple::newFull(): lsize != trySize: lsize: " << lsize
- << " try Size: " << trySize << " " << (name?name:"NULL") << std::endl;
- }
- if ( !sizeMapDone ) {
- injectCustomSize();
- }
- GtkIconSize mappedSize = iconSizeLookup[trySize];
-
- if ( legacyNames.empty() ) {
- setupLegacyNaming();
- }
-
- GtkWidget *img = gtk_image_new_from_icon_name( name, mappedSize );
- if ( dump ) {
- g_message("gtk_image_new_from_icon_name( '%s', %d ) = %p", name, mappedSize, img);
- GtkImageType thing = gtk_image_get_storage_type(GTK_IMAGE(img));
- g_message(" Type is %d %s", (int)thing, (thing == GTK_IMAGE_EMPTY ? "Empty" : "ok"));
- }
-
- if ( img ) {
- GtkImageType type = gtk_image_get_storage_type( GTK_IMAGE(img) );
- if ( type == GTK_IMAGE_ICON_NAME ) {
- widget = GTK_WIDGET(img);
- img = NULL;
-
- // Add a hook to render if set visible before prerender is done.
- g_signal_connect( G_OBJECT(widget), "map", G_CALLBACK(imageMapNamedCB), GINT_TO_POINTER(0) );
-
- if ( Inkscape::Preferences::get()->getBool("/options/iconrender/named_nodelay") ) {
- int psize = getPhysSize(lsize);
- // std::cout << " name: " << name << " size: " << psize << std::endl;
- prerenderIcon(name, mappedSize, psize);
- } else {
- addPreRender( mappedSize, name );
- }
- } else {
- if ( dump ) {
- g_message( "skipped gtk '%s' %d (not GTK_IMAGE_ICON_NAME)", name, lsize );
- }
- //g_object_unref(G_OBJECT(img));
- img = NULL;
- }
- }
-
- if ( !widget ) {
- //g_message("Creating an SPIcon instance for %s:%d", name, (int)lsize);
- SPIcon *icon = SP_ICON(g_object_new(SP_TYPE_ICON, NULL));
- icon->lsize = lsize;
- icon->name = g_strdup(name);
- icon->psize = getPhysSize(lsize);
-
- widget = GTK_WIDGET(icon);
- }
-
- return widget;
-}
-
-// PUBLIC CALL:
-GtkWidget *sp_icon_new( Inkscape::IconSize lsize, gchar const *name )
-{
- return IconImpl::newFull( lsize, name );
-}
-
-// PUBLIC CALL for when you REALLY need a pixbuf
-GdkPixbuf *sp_pixbuf_new( Inkscape::IconSize lsize, gchar const *name )
-{
- int psize = IconImpl::getPhysSize(lsize);
- return IconImpl::renderup(name, lsize, psize);
-}
-
-// PUBLIC CALL:
-Gtk::Widget *sp_icon_get_icon( Glib::ustring const &oid, Inkscape::IconSize size )
-{
- Gtk::Widget *result = NULL;
- GtkWidget *widget = IconImpl::newFull( static_cast<Inkscape::IconSize>(Inkscape::getRegisteredIconSize(size)), oid.c_str() );
-
- if ( widget ) {
- if ( GTK_IS_IMAGE(widget) ) {
- GtkImage *img = GTK_IMAGE(widget);
- result = Glib::wrap( img );
- } else {
- result = Glib::wrap( widget );
- }
- }
-
- return result;
-}
-
-void IconImpl::injectCustomSize()
-{
- // TODO - still need to handle the case of theme changes and resize, especially as we can't re-register a string.
- if ( !sizeMapDone )
- {
- bool dump = Inkscape::Preferences::get()->getBool("/debug/icons/dumpDefault");
- gint width = 0;
- gint height = 0;
- if ( gtk_icon_size_lookup(GTK_ICON_SIZE_MENU, &width, &height ) ) {
- gint newWidth = ((width * 3) / 4);
- gint newHeight = ((height * 3) / 4);
- GtkIconSize newSizeEnum = gtk_icon_size_register( "inkscape-decoration", newWidth, newHeight );
- if ( newSizeEnum ) {
- if ( dump ) {
- g_message("Registered (%d, %d) <= (%d, %d) as index %d", newWidth, newHeight, width, height, newSizeEnum);
- }
- guint index = static_cast<guint>(Inkscape::ICON_SIZE_DECORATION);
- if ( index < G_N_ELEMENTS(iconSizeLookup) ) {
- iconSizeLookup[index] = newSizeEnum;
- } else if ( dump ) {
- g_message("size lookup array too small to store entry");
- }
- }
- }
- sizeMapDone = true;
- }
-}
-
-GtkIconSize Inkscape::getRegisteredIconSize( Inkscape::IconSize size )
-{
- GtkIconSize other = GTK_ICON_SIZE_MENU;
- IconImpl::injectCustomSize();
- size = CLAMP( size, Inkscape::ICON_SIZE_MENU, Inkscape::ICON_SIZE_DECORATION );
- if ( size == Inkscape::ICON_SIZE_DECORATION ) {
- other = gtk_icon_size_from_name("inkscape-decoration");
- } else {
- other = static_cast<GtkIconSize>(size);
- }
-
- return other;
-}
-
-
-// PUBLIC CALL:
-int sp_icon_get_phys_size(int size)
-{
- return IconImpl::getPhysSize(size);
-}
-
-int IconImpl::getPhysSize(int size)
-{
- static bool init = false;
- static int lastSys[Inkscape::ICON_SIZE_DECORATION + 1];
- static int vals[Inkscape::ICON_SIZE_DECORATION + 1];
-
- size = CLAMP( size, static_cast<int>(GTK_ICON_SIZE_MENU), static_cast<int>(Inkscape::ICON_SIZE_DECORATION) );
-
- if ( !sizeMapDone ) {
- injectCustomSize();
- }
-
- if ( sizeDirty && init ) {
- GtkIconSize const gtkSizes[] = {
- GTK_ICON_SIZE_MENU,
- GTK_ICON_SIZE_SMALL_TOOLBAR,
- GTK_ICON_SIZE_LARGE_TOOLBAR,
- GTK_ICON_SIZE_BUTTON,
- GTK_ICON_SIZE_DND,
- GTK_ICON_SIZE_DIALOG,
- static_cast<guint>(Inkscape::ICON_SIZE_DECORATION) < G_N_ELEMENTS(iconSizeLookup) ?
- iconSizeLookup[static_cast<int>(Inkscape::ICON_SIZE_DECORATION)] :
- GTK_ICON_SIZE_MENU
- };
- for (unsigned i = 0; i < G_N_ELEMENTS(gtkSizes) && init; ++i) {
- guint const val_ix = (gtkSizes[i] <= GTK_ICON_SIZE_DIALOG) ? (guint)gtkSizes[i] : (guint)Inkscape::ICON_SIZE_DECORATION;
-
- g_assert( val_ix < G_N_ELEMENTS(vals) );
-
- gint width = 0;
- gint height = 0;
- if ( gtk_icon_size_lookup(gtkSizes[i], &width, &height ) ) {
- init &= (lastSys[val_ix] == std::max(width, height));
- }
- }
- }
-
- if ( !init ) {
- sizeDirty = false;
- bool dump = Inkscape::Preferences::get()->getBool("/debug/icons/dumpDefault");
- if ( dump ) {
- g_message( "Default icon sizes:" );
- }
- memset( vals, 0, sizeof(vals) );
- memset( lastSys, 0, sizeof(lastSys) );
- GtkIconSize const gtkSizes[] = {
- GTK_ICON_SIZE_MENU,
- GTK_ICON_SIZE_SMALL_TOOLBAR,
- GTK_ICON_SIZE_LARGE_TOOLBAR,
- GTK_ICON_SIZE_BUTTON,
- GTK_ICON_SIZE_DND,
- GTK_ICON_SIZE_DIALOG,
- static_cast<guint>(Inkscape::ICON_SIZE_DECORATION) < G_N_ELEMENTS(iconSizeLookup) ?
- iconSizeLookup[static_cast<int>(Inkscape::ICON_SIZE_DECORATION)] :
- GTK_ICON_SIZE_MENU
- };
- gchar const *const names[] = {
- "GTK_ICON_SIZE_MENU",
- "GTK_ICON_SIZE_SMALL_TOOLBAR",
- "GTK_ICON_SIZE_LARGE_TOOLBAR",
- "GTK_ICON_SIZE_BUTTON",
- "GTK_ICON_SIZE_DND",
- "GTK_ICON_SIZE_DIALOG",
- "inkscape-decoration"
- };
-
- for (unsigned i = 0; i < G_N_ELEMENTS(gtkSizes); ++i) {
- guint const val_ix = (gtkSizes[i] <= GTK_ICON_SIZE_DIALOG) ? (guint)gtkSizes[i] : (guint)Inkscape::ICON_SIZE_DECORATION;
-
- g_assert( val_ix < G_N_ELEMENTS(vals) );
-
- gint width = 0;
- gint height = 0;
- bool used = false;
- if ( gtk_icon_size_lookup(gtkSizes[i], &width, &height ) ) {
- vals[val_ix] = std::max(width, height);
- lastSys[val_ix] = vals[val_ix];
- used = true;
- }
- if (dump) {
- g_message(" =-- %u size:%d %c(%d, %d) '%s'",
- i, gtkSizes[i],
- ( used ? ' ' : 'X' ), width, height, names[i]);
- }
-
- // The following is needed due to this documented behavior of gtk_icon_size_lookup:
- // "The rendered pixbuf may not even correspond to the width/height returned by
- // gtk_icon_size_lookup(), because themes are free to render the pixbuf however
- // they like, including changing the usual size."
- gchar const *id = INKSCAPE_ICON("document-open");
- GtkIconTheme *icon_theme = gtk_icon_theme_get_default();
- GdkPixbuf *pb = gtk_icon_theme_load_icon (icon_theme,
- id,
- vals[val_ix],
- (GtkIconLookupFlags)0,
- NULL);
- if (pb) {
- width = gdk_pixbuf_get_width(pb);
- height = gdk_pixbuf_get_height(pb);
- int newSize = std::max( width, height );
- // TODO perhaps check a few more stock icons to get a range on sizes.
- if ( newSize > 0 ) {
- vals[val_ix] = newSize;
- }
- if (dump) {
- g_message(" %u size:%d (%d, %d)", i, gtkSizes[i], width, height);
- }
-
- g_object_unref(G_OBJECT(pb));
- }
- }
- init = true;
- }
-
- return vals[size];
-}
-
-
-
-GdkPixbuf *IconImpl::loadPixmap(gchar const *name, unsigned /*lsize*/, unsigned psize)
-{
- gchar *path = g_strdup_printf("%s/%s.png", INKSCAPE_PIXMAPDIR, name);
- // TODO: bulia, please look over
- gsize bytesRead = 0;
- gsize bytesWritten = 0;
- GError *error = NULL;
- gchar *localFilename = g_filename_from_utf8( path,
- -1,
- &bytesRead,
- &bytesWritten,
- &error);
- GdkPixbuf *pb = gdk_pixbuf_new_from_file(localFilename, NULL);
- g_free(localFilename);
- g_free(path);
- if (!pb) {
- path = g_strdup_printf("%s/%s.xpm", INKSCAPE_PIXMAPDIR, name);
- // TODO: bulia, please look over
- gsize bytesRead = 0;
- gsize bytesWritten = 0;
- GError *error = NULL;
- gchar *localFilename = g_filename_from_utf8( path,
- -1,
- &bytesRead,
- &bytesWritten,
- &error);
- pb = gdk_pixbuf_new_from_file(localFilename, NULL);
- g_free(localFilename);
- g_free(path);
- }
-
- if (pb) {
- if (!gdk_pixbuf_get_has_alpha(pb)) {
- gdk_pixbuf_add_alpha(pb, FALSE, 0, 0, 0);
- }
-
- if ( ( static_cast<unsigned>(gdk_pixbuf_get_width(pb)) != psize )
- || ( static_cast<unsigned>(gdk_pixbuf_get_height(pb)) != psize ) ) {
- GdkPixbuf *spb = gdk_pixbuf_scale_simple(pb, psize, psize, GDK_INTERP_HYPER);
- g_object_unref(G_OBJECT(pb));
- pb = spb;
- }
- }
-
- return pb;
-}
-
-static Geom::IntRect round_rect(Geom::Rect const &r)
-{
- using Geom::X;
- using Geom::Y;
- Geom::IntPoint a, b;
- a[X] = round(r.left());
- a[Y] = round(r.top());
- b[X] = round(r.right());
- b[Y] = round(r.bottom());
- Geom::IntRect ret(a, b);
- return ret;
-}
-
-// takes doc, drawing, icon, and icon name to produce pixels
-extern "C" guchar *
-sp_icon_doc_icon( SPDocument *doc, Inkscape::Drawing &drawing,
- gchar const *name, unsigned psize,
- unsigned &stride)
-{
- bool const dump = Inkscape::Preferences::get()->getBool("/debug/icons/dumpSvg");
- guchar *px = NULL;
-
- if (doc) {
- SPObject *object = doc->getObjectById(name);
- if (object && SP_IS_ITEM(object)) {
- SPItem *item = SP_ITEM(object);
- // Find bbox in document
- Geom::OptRect dbox = item->documentVisualBounds();
-
- if ( object->parent == NULL )
- {
- dbox = Geom::Rect(Geom::Point(0, 0),
- Geom::Point(doc->getWidth().value("px"), doc->getHeight().value("px")));
- }
-
- /* This is in document coordinates, i.e. pixels */
- if ( dbox ) {
- /* Update to renderable state */
- double sf = 1.0;
- drawing.root()->setTransform(Geom::Scale(sf));
- drawing.update();
- /* Item integer bbox in points */
- // NOTE: previously, each rect coordinate was rounded using floor(c + 0.5)
- Geom::IntRect ibox = round_rect(*dbox);
-
- if ( dump ) {
- g_message( " box --'%s' (%f,%f)-(%f,%f)", name, (double)ibox.left(), (double)ibox.top(), (double)ibox.right(), (double)ibox.bottom() );
- }
-
- /* Find button visible area */
- int width = ibox.width();
- int height = ibox.height();
-
- if ( dump ) {
- g_message( " vis --'%s' (%d,%d)", name, width, height );
- }
-
- {
- int block = std::max(width, height);
- if (block != static_cast<int>(psize) ) {
- if ( dump ) {
- g_message(" resizing" );
- }
- sf = (double)psize / (double)block;
-
- drawing.root()->setTransform(Geom::Scale(sf));
- drawing.update();
-
- ibox = round_rect(*dbox * Geom::Scale(sf));
- if ( dump ) {
- g_message( " box2 --'%s' (%f,%f)-(%f,%f)", name, (double)ibox.left(), (double)ibox.top(), (double)ibox.right(), (double)ibox.bottom() );
- }
-
- /* Find button visible area */
- width = ibox.width();
- height = ibox.height();
- if ( dump ) {
- g_message( " vis2 --'%s' (%d,%d)", name, width, height );
- }
- }
- }
-
- Geom::IntPoint pdim(psize, psize);
- int dx, dy;
- //dx = (psize - width) / 2;
- //dy = (psize - height) / 2;
- dx=dy=psize;
- dx=(dx-width)/2; // watch out for psize, since 'unsigned'-'signed' can cause problems if the result is negative
- dy=(dy-height)/2;
- Geom::IntRect area = Geom::IntRect::from_xywh(ibox.min() - Geom::IntPoint(dx,dy), pdim);
- /* Actual renderable area */
- Geom::IntRect ua = *Geom::intersect(ibox, area);
-
- if ( dump ) {
- g_message( " area --'%s' (%f,%f)-(%f,%f)", name, (double)area.left(), (double)area.top(), (double)area.right(), (double)area.bottom() );
- g_message( " ua --'%s' (%f,%f)-(%f,%f)", name, (double)ua.left(), (double)ua.top(), (double)ua.right(), (double)ua.bottom() );
- }
-
- stride = cairo_format_stride_for_width(CAIRO_FORMAT_ARGB32, psize);
-
- /* Set up pixblock */
- px = g_new(guchar, stride * psize);
- memset(px, 0x00, stride * psize);
-
- /* Render */
- cairo_surface_t *s = cairo_image_surface_create_for_data(px,
- CAIRO_FORMAT_ARGB32, psize, psize, stride);
- Inkscape::DrawingContext dc(s, ua.min());
-
- SPNamedView *nv = sp_document_namedview(doc, NULL);
- float bg_r = SP_RGBA32_R_F(nv->pagecolor);
- float bg_g = SP_RGBA32_G_F(nv->pagecolor);
- float bg_b = SP_RGBA32_B_F(nv->pagecolor);
- float bg_a = SP_RGBA32_A_F(nv->pagecolor);
-
- cairo_t *cr = cairo_create(s);
- cairo_set_source_rgba(cr, bg_r, bg_g, bg_b, bg_a);
- cairo_rectangle(cr, 0, 0, psize, psize);
- cairo_fill(cr);
- cairo_save(cr);
- cairo_destroy(cr);
-
- drawing.render(dc, ua);
- cairo_surface_destroy(s);
-
- // convert to GdkPixbuf format
- convert_pixels_argb32_to_pixbuf(px, psize, psize, stride);
-
- if ( Inkscape::Preferences::get()->getBool("/debug/icons/overlaySvg") ) {
- IconImpl::overlayPixels( px, psize, psize, stride, 0x00, 0x00, 0xff );
- }
- }
- }
- }
-
- return px;
-} // end of sp_icon_doc_icon()
-
-
-
-class SVGDocCache
-{
-public:
- SVGDocCache( SPDocument *doc )
- : doc(doc)
- , visionkey(SPItem::display_key_new(1))
- {
- doc->doRef();
- doc->ensureUpToDate();
- drawing.setRoot(doc->getRoot()->invoke_show(drawing, visionkey, SP_ITEM_SHOW_DISPLAY ));
- }
- ~SVGDocCache() {
- doc->getRoot()->invoke_hide(visionkey);
- doc->doUnref();
- }
- SPDocument *doc;
- Inkscape::Drawing drawing;
- unsigned visionkey;
-};
-
-static std::map<Glib::ustring, SVGDocCache *> doc_cache;
-static std::map<Glib::ustring, GdkPixbuf *> pb_cache;
-
-Glib::ustring icon_cache_key(Glib::ustring const & name, unsigned psize)
-{
- Glib::ustring key = name;
- key += ":";
- key += psize;
- return key;
-}
-
-GdkPixbuf *get_cached_pixbuf(Glib::ustring const &key) {
- GdkPixbuf* pb = NULL;
- std::map<Glib::ustring, GdkPixbuf *>::iterator found = pb_cache.find(key);
- if ( found != pb_cache.end() ) {
- pb = found->second;
- }
- return pb;
-}
-
-std::list<gchar*> &IconImpl::icons_svg_paths()
-{
- static std::list<gchar *> sources;
- static bool initialized = false;
- if (!initialized) {
- // Fall back from user prefs dir into system locations.
- gchar *userdir = Inkscape::Application::profile_path("icons");
- sources.push_back(g_build_filename(userdir,"icons.svg", NULL));
- sources.push_back(g_build_filename(INKSCAPE_PIXMAPDIR, "icons.svg", NULL));
- g_free(userdir);
- initialized = true;
- }
- return sources;
-}
-
-// this function renders icons from icons.svg and returns the pixels.
-guchar *IconImpl::load_svg_pixels(std::list<Glib::ustring> const &names,
- unsigned psize, unsigned &stride)
-{
- bool const dump = Inkscape::Preferences::get()->getBool("/debug/icons/dumpSvg");
- std::list<gchar *> &sources = icons_svg_paths();
-
- // Try each document in turn until we successfully load the icon from one
- guchar *px = NULL;
- for (std::list<gchar*>::iterator i = sources.begin(); (i != sources.end()) && !px; ++i) {
- gchar *doc_filename = *i;
- SVGDocCache *info = NULL;
-
- // Did we already load this doc?
- Glib::ustring key(doc_filename);
- {
- std::map<Glib::ustring, SVGDocCache *>::iterator i = doc_cache.find(key);
- if ( i != doc_cache.end() ) {
- info = i->second;
- }
- }
-
- // Try to load from document.
- if (!info && Inkscape::IO::file_test( doc_filename, G_FILE_TEST_IS_REGULAR ) ) {
- SPDocument *doc = SPDocument::createNewDoc( doc_filename, FALSE );
- if ( doc ) {
- if ( dump ) {
- g_message("Loaded icon file %s", doc_filename);
- }
- // store into the cache
- info = new SVGDocCache(doc);
- doc_cache[key] = info;
- }
- }
- if (info) {
- for (std::list<Glib::ustring>::const_iterator it = names.begin(); !px && (it != names.end()); ++it ) {
- px = sp_icon_doc_icon( info->doc, info->drawing, it->c_str(), psize, stride );
- }
- }
- }
-
- return px;
-}
-
-static void addToIconSet(GdkPixbuf* pb, gchar const* name, GtkIconSize lsize, unsigned psize) {
- Glib::RefPtr<Gtk::IconTheme> icon_theme = Gtk::IconTheme::get_default();
- bool icon_found = icon_theme->has_icon(name);
- if ( !icon_found ) {
- Gtk::IconTheme::add_builtin_icon( name, psize, Glib::wrap(pb) );
- static bool dump = Inkscape::Preferences::get()->getBool("/debug/icons/dumpGtk");
- if (dump) {
- g_message(" set in a builtin for %s:%d:%d", name, lsize, psize);
- }
- }
-}
-
-void Inkscape::queueIconPrerender( Glib::ustring const &name, Inkscape::IconSize lsize )
-{
- gboolean themedFound = gtk_icon_theme_has_icon(gtk_icon_theme_get_default(), name.c_str());
- if ( !themedFound ) {
- gint trySize = CLAMP( static_cast<gint>(lsize), 0, static_cast<gint>(G_N_ELEMENTS(iconSizeLookup) - 1) );
- if ( !sizeMapDone ) {
- IconImpl::injectCustomSize();
- }
- GtkIconSize mappedSize = iconSizeLookup[trySize];
-
- int psize = IconImpl::getPhysSize(lsize);
- // TODO place in a queue that is triggered by other map events
- IconImpl::prerenderIcon(name.c_str(), mappedSize, psize);
- }
-}
-
-static std::map<unsigned, Glib::ustring> sizePaths;
-
-static std::string getDestDir( unsigned psize )
-{
- if ( sizePaths.find(psize) == sizePaths.end() ) {
- gchar *tmp = g_strdup_printf("%dx%d", psize, psize);
- sizePaths[psize] = tmp;
- g_free(tmp);
- }
-
- return sizePaths[psize];
-}
-
-// returns true if icon needed preloading, false if nothing was done
-bool IconImpl::prerenderIcon(gchar const *name, GtkIconSize lsize, unsigned psize)
-{
- bool loadNeeded = false;
- static bool useCache = Inkscape::Preferences::get()->getBool("/debug/icons/useCache", true);
- static bool cacheValidated = false;
- if (!cacheValidated) {
- cacheValidated = true;
- if ( useCache ) {
- validateCache();
- }
- }
-
- Glib::ustring key = icon_cache_key(name, psize);
- if ( !get_cached_pixbuf(key) ) {
- static bool dump = Inkscape::Preferences::get()->getBool("/debug/icons/dumpGtk");
- if ((internalNames.find(name) != internalNames.end())
- || (!gtk_icon_theme_has_icon(gtk_icon_theme_get_default(), name))) {
- if (dump) {
- g_message("prerenderIcon [%s] %d:%d", name, lsize, psize);
- }
-
- std::string potentialFile;
- bool dataLoaded = false;
- if ( useCache ) {
- // In file encoding:
- std::string iconCacheDir = Glib::build_filename(Glib::build_filename(Glib::get_user_cache_dir(), "inkscape"), "icons");
- std::string subpart = getDestDir(psize);
- std::string subdir = Glib::build_filename( iconCacheDir, subpart );
- if ( !Glib::file_test(subdir, Glib::FILE_TEST_EXISTS) ) {
- g_mkdir_with_parents( subdir.c_str(), 0x1ED );
- }
- potentialFile = Glib::build_filename( subdir, name );
- potentialFile += ".png";
-
- if ( Glib::file_test(potentialFile, Glib::FILE_TEST_EXISTS) && Glib::file_test(potentialFile, Glib::FILE_TEST_IS_REGULAR) ) {
- bool badFile = false;
- try {
- Glib::RefPtr<Gdk::Pixbuf> pb = Gdk::Pixbuf::create_from_file(potentialFile);
- if (pb) {
- dataLoaded = true;
- GdkPixbuf *obj = pb->gobj();
- g_object_ref(obj);
- pb_cache[key] = obj;
- addToIconSet(obj, name, lsize, psize);
- loadNeeded = true;
- if (internalNames.find(name) == internalNames.end()) {
- internalNames.insert(name);
- }
- }
- } catch ( Glib::FileError &ex ) {
- //g_warning("FileError [%s]", ex.what().c_str());
- badFile = true;
- } catch ( Gdk::PixbufError &ex ) {
- //g_warning("PixbufError [%s]", ex.what().c_str());
- // Invalid contents. Remove cached item
- badFile = true;
- }
- if ( badFile ) {
- g_remove(potentialFile.c_str());
- }
- }
- }
-
- if (!dataLoaded) {
- std::list<Glib::ustring> names;
- names.push_back(name);
- if ( legacyNames.find(name) != legacyNames.end() ) {
- names.push_back(legacyNames[name]);
- if ( dump ) {
- g_message("load_svg_pixels([%s] = %s, %d, %d)", name, legacyNames[name].c_str(), lsize, psize);
- }
- }
- unsigned stride;
- guchar* px = load_svg_pixels(names, psize, stride);
- if (px) {
- GdkPixbuf* pb = gdk_pixbuf_new_from_data( px, GDK_COLORSPACE_RGB, TRUE, 8,
- psize, psize, stride,
- reinterpret_cast<GdkPixbufDestroyNotify>(g_free), NULL );
- pb_cache[key] = pb;
- addToIconSet(pb, name, lsize, psize);
- loadNeeded = true;
- if (internalNames.find(name) == internalNames.end()) {
- internalNames.insert(name);
- }
- if (useCache) {
- g_object_ref(pb);
- Glib::RefPtr<Gdk::Pixbuf> ppp = Glib::wrap(pb);
- try {
- ppp->save( potentialFile, "png" );
- } catch ( Glib::FileError &ex ) {
- //g_warning("FileError [%s]", ex.what().c_str());
- } catch ( Gdk::PixbufError &ex ) {
- //g_warning("PixbufError [%s]", ex.what().c_str());
- }
- }
- } else if (dump) {
- g_message("XXXXXXXXXXXXXXXXXXXXXXXXXXXXX error!!! pixels not found for '%s'", name);
- }
- }
- }
- else if (dump) {
- g_message("prerenderIcon [%s] %d NOT!!!!!!", name, psize);
- }
- }
- return loadNeeded;
-}
-
-GdkPixbuf *IconImpl::loadSvg(std::list<Glib::ustring> const &names, GtkIconSize lsize, unsigned psize)
-{
- Glib::ustring key = icon_cache_key(*names.begin(), psize);
-
- // did we already load this icon at this scale/size?
- GdkPixbuf* pb = get_cached_pixbuf(key);
- if (!pb) {
- unsigned stride;
- guchar *px = load_svg_pixels(names, psize, stride);
- if (px) {
- pb = gdk_pixbuf_new_from_data(px, GDK_COLORSPACE_RGB, TRUE, 8,
- psize, psize, stride,
- (GdkPixbufDestroyNotify)g_free, NULL);
- pb_cache[key] = pb;
- addToIconSet(pb, names.begin()->c_str(), lsize, psize);
- }
- }
-
- if ( pb ) {
- // increase refcount since we're handing out ownership
- g_object_ref(G_OBJECT(pb));
- }
- return pb;
-}
-
-void IconImpl::overlayPixels(guchar *px, int width, int height, int stride,
- unsigned r, unsigned g, unsigned b)
-{
- int bytesPerPixel = 4;
- int spacing = 4;
- for ( int y = 0; y < height; y += spacing ) {
- guchar *ptr = px + y * stride;
- for ( int x = 0; x < width; x += spacing ) {
- *(ptr++) = r;
- *(ptr++) = g;
- *(ptr++) = b;
- *(ptr++) = 0xff;
-
- ptr += bytesPerPixel * (spacing - 1);
- }
- }
-
- if ( width > 1 && height > 1 ) {
- // point at the last pixel
- guchar *ptr = px + ((height-1) * stride) + ((width - 1) * bytesPerPixel);
-
- if ( width > 2 ) {
- px[4] = r;
- px[5] = g;
- px[6] = b;
- px[7] = 0xff;
-
- ptr[-12] = r;
- ptr[-11] = g;
- ptr[-10] = b;
- ptr[-9] = 0xff;
- }
-
- ptr[-4] = r;
- ptr[-3] = g;
- ptr[-2] = b;
- ptr[-1] = 0xff;
-
- px[0 + stride] = r;
- px[1 + stride] = g;
- px[2 + stride] = b;
- px[3 + stride] = 0xff;
-
- ptr[0 - stride] = r;
- ptr[1 - stride] = g;
- ptr[2 - stride] = b;
- ptr[3 - stride] = 0xff;
-
- if ( height > 2 ) {
- ptr[0 - stride * 3] = r;
- ptr[1 - stride * 3] = g;
- ptr[2 - stride * 3] = b;
- ptr[3 - stride * 3] = 0xff;
- }
- }
-}
-
-class preRenderItem
-{
-public:
- preRenderItem( GtkIconSize lsize, gchar const *name ) :
- _lsize( lsize ),
- _name( name )
- {}
- GtkIconSize _lsize;
- Glib::ustring _name;
-};
-
-
-static std::vector<preRenderItem> pendingRenders;
-static bool callbackHooked = false;
-
-void IconImpl::addPreRender( GtkIconSize lsize, gchar const *name )
-{
- if ( !callbackHooked )
- {
- callbackHooked = true;
- g_idle_add_full( G_PRIORITY_LOW, &prerenderTask, NULL, NULL );
- }
-
- pendingRenders.push_back(preRenderItem(lsize, name));
-}
-
-gboolean IconImpl::prerenderTask(gpointer /*data*/) {
- if ( Inkscape::Application::isCrashing() ) {
- // stop
- } else if (!pendingRenders.empty()) {
- bool workDone = false;
- do {
- preRenderItem single = pendingRenders.front();
- pendingRenders.erase(pendingRenders.begin());
- int psize = getPhysSize(single._lsize);
- workDone = prerenderIcon(single._name.c_str(), single._lsize, psize);
- } while (!pendingRenders.empty() && !workDone);
- }
-
- if (!Inkscape::Application::isCrashing() && !pendingRenders.empty()) {
- return TRUE;
- } else {
- callbackHooked = false;
- return FALSE;
- }
-}
-
-
-void IconImpl::imageMapCB(GtkWidget* widget, gpointer user_data)
-{
- gchar const* id = NULL;
- GtkIconSize size = GTK_ICON_SIZE_INVALID;
- gtk_image_get_icon_name(GTK_IMAGE(widget), &id, &size);
- GtkIconSize lsize = static_cast<GtkIconSize>(GPOINTER_TO_INT(user_data));
- if ( id ) {
- int psize = getPhysSize(lsize);
- g_message("imageMapCB(%p) for [%s]:%d:%d", widget, id, lsize, psize);
- for ( std::vector<preRenderItem>::iterator it = pendingRenders.begin(); it != pendingRenders.end(); ++it ) {
- if ( (it->_name == id) && (it->_lsize == lsize) ) {
- prerenderIcon(id, lsize, psize);
- pendingRenders.erase(it);
- g_message(" prerender for %s:%d:%d", id, lsize, psize);
- if (lsize != size) {
- int psize = getPhysSize(size);
- prerenderIcon(id, size, psize);
- }
- break;
- }
- }
- }
-
- g_signal_handlers_disconnect_by_func(widget, (gpointer)imageMapCB, user_data);
-}
-
-void IconImpl::imageMapNamedCB(GtkWidget* widget, gpointer user_data)
-{
- GtkImage* img = GTK_IMAGE(widget);
- gchar const* iconName = NULL;
- GtkIconSize size = GTK_ICON_SIZE_INVALID;
- gtk_image_get_icon_name(img, &iconName, &size);
- if ( iconName ) {
- GtkImageType type = gtk_image_get_storage_type( GTK_IMAGE(img) );
- if ( type == GTK_IMAGE_ICON_NAME ) {
-
- GtkIconSize iconSize = GTK_ICON_SIZE_INVALID;
- gchar const* iconName_two = NULL;
- {
- g_object_get(G_OBJECT(widget),
- "icon-name", &iconName_two,
- "icon-size", &iconSize,
- NULL);
- }
-
- for ( std::vector<preRenderItem>::iterator it = pendingRenders.begin(); it != pendingRenders.end(); ++it ) {
- /// @todo fix pointer string comparison here!!! "it->_name == iconName_two", that seems very bug-prone
- if ( (it->_name == iconName_two) && (it->_lsize == iconSize) ) {
- int psize = getPhysSize(iconSize);
- prerenderIcon(iconName_two, iconSize, psize);
- pendingRenders.erase(it);
- break;
- }
- }
-
- gtk_image_set_from_icon_name(img, "", iconSize);
- gtk_image_set_from_icon_name(img, iconName_two, iconSize);
- } else {
- g_warning("UNEXPECTED TYPE of %d", (int)type);
- }
- }
-
- g_signal_handlers_disconnect_by_func(widget, (gpointer)imageMapNamedCB, user_data);
-}
-
-
-/*
- Local Variables:
- mode:c++
- c-file-style:"stroustrup"
- c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
- indent-tabs-mode:nil
- fill-column:99
- End:
-*/
-// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :
diff --git a/src/widgets/icon.h b/src/widgets/icon.h
deleted file mode 100644
index 5838d8de4..000000000
--- a/src/widgets/icon.h
+++ /dev/null
@@ -1,71 +0,0 @@
-#ifndef SEEN_SP_ICON_H
-#define SEEN_SP_ICON_H
-
-/*
- * Generic icon widget
- *
- * Author:
- * Lauris Kaplinski <lauris@kaplinski.com>
- * Jon A. Cruz <jon@joncruz.org>
- *
- * Copyright (C) 2002 Lauris Kaplinski
- * Copyright (C) 2010 Authors
- *
- * Released under GNU GPL, read the file 'COPYING' for more information
- */
-
-#include <gtkmm/widget.h>
-#include "icon-size.h"
-
-#define SP_TYPE_ICON sp_icon_get_type()
-#define SP_ICON(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), SP_TYPE_ICON, SPIcon))
-#define SP_IS_ICON(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), SP_TYPE_ICON))
-
-namespace Glib {
-class ustring;
-}
-
-struct SPIconClass {
- GtkWidgetClass parent_class;
-};
-
-GType sp_icon_get_type() G_GNUC_CONST;
-
-struct SPIcon {
- GtkWidget widget;
-
- Inkscape::IconSize lsize;
- int psize;
- gchar *name;
-
- GdkPixbuf *pb;
-
- friend class SPIconImpl;
-};
-
-
-GtkWidget *sp_icon_new( Inkscape::IconSize size, const gchar *name );
-GdkPixbuf *sp_pixbuf_new( Inkscape::IconSize size, const gchar *name );
-
-// Might return a wrapped SPIcon, or Gtk::Image
-Gtk::Widget *sp_icon_get_icon( const Glib::ustring &oid, Inkscape::IconSize size = Inkscape::ICON_SIZE_BUTTON );
-
-void sp_icon_fetch_pixbuf( SPIcon *icon );
-int sp_icon_get_phys_size(int size);
-
-namespace Inkscape {
- void queueIconPrerender( Glib::ustring const &oid, Inkscape::IconSize size = Inkscape::ICON_SIZE_BUTTON );
-}
-
-#endif // SEEN_SP_ICON_H
-
-/*
- Local Variables:
- mode:c++
- c-file-style:"stroustrup"
- c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
- indent-tabs-mode:nil
- fill-column:99
- End:
-*/
-// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :
diff --git a/src/widgets/ink-action.cpp b/src/widgets/ink-action.cpp
index 8859306f1..dae214656 100644
--- a/src/widgets/ink-action.cpp
+++ b/src/widgets/ink-action.cpp
@@ -1,5 +1,4 @@
#include "ink-action.h"
-#include "widgets/icon.h"
#include <gtk/gtk.h>
@@ -13,7 +12,7 @@ static GtkWidget* ink_action_create_tool_item( GtkAction* action );
struct _InkActionPrivate
{
gchar* iconId;
- Inkscape::IconSize iconSize;
+ GtkIconSize iconSize;
};
#define INK_ACTION_GET_PRIVATE( o ) ( G_TYPE_INSTANCE_GET_PRIVATE( (o), INK_ACTION_TYPE, InkActionPrivate ) )
@@ -52,9 +51,9 @@ static void ink_action_class_init( InkActionClass* klass )
g_param_spec_int( "iconSize",
"Icon Size",
"The size the icon",
- (int)Inkscape::ICON_SIZE_MENU,
- (int)Inkscape::ICON_SIZE_DECORATION,
- (int)Inkscape::ICON_SIZE_SMALL_TOOLBAR,
+ (int)GTK_ICON_SIZE_MENU,
+ (int)GTK_ICON_SIZE_DIALOG,
+ (int)GTK_ICON_SIZE_SMALL_TOOLBAR,
(GParamFlags)(G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT) ) );
g_type_class_add_private( klass, sizeof(InkActionClass) );
@@ -65,7 +64,7 @@ static void ink_action_init( InkAction* action )
{
action->private_data = INK_ACTION_GET_PRIVATE( action );
action->private_data->iconId = 0;
- action->private_data->iconSize = Inkscape::ICON_SIZE_SMALL_TOOLBAR;
+ action->private_data->iconSize = GTK_ICON_SIZE_SMALL_TOOLBAR;
}
static void ink_action_finalize( GObject* obj )
@@ -82,7 +81,7 @@ InkAction* ink_action_new( const gchar *name,
const gchar *label,
const gchar *tooltip,
const gchar *inkId,
- Inkscape::IconSize size )
+ GtkIconSize size )
{
GObject* obj = (GObject*)g_object_new( INK_ACTION_TYPE,
"name", name,
@@ -134,7 +133,7 @@ void ink_action_set_property( GObject* obj, guint propId, const GValue *value, G
case PROP_INK_SIZE:
{
- action->private_data->iconSize = (Inkscape::IconSize)g_value_get_int( value );
+ action->private_data->iconSize = (GtkIconSize)g_value_get_int( value );
}
break;
@@ -148,33 +147,7 @@ void ink_action_set_property( GObject* obj, guint propId, const GValue *value, G
static GtkWidget* ink_action_create_menu_item( GtkAction* action )
{
InkAction* act = INK_ACTION( action );
- GtkWidget* item = 0;
-
- if ( act->private_data->iconId ) {
- gchar* label = 0;
- g_object_get( G_OBJECT(act), "label", &label, NULL );
- item = gtk_image_menu_item_new_with_mnemonic( label );
-
- GtkWidget* child = sp_icon_new( Inkscape::ICON_SIZE_MENU, act->private_data->iconId );
- // TODO this work-around is until SPIcon will live properly inside of a popup menu
- if ( SP_IS_ICON(child) ) {
- SPIcon* icon = SP_ICON(child);
- sp_icon_fetch_pixbuf( icon );
- GdkPixbuf* target = icon->pb;
- if ( target ) {
- child = gtk_image_new_from_pixbuf( target );
- gtk_widget_set_sensitive(child, gtk_action_is_sensitive(action));
- gtk_widget_destroy( GTK_WIDGET(icon) );
- }
- }
- gtk_widget_show_all( child );
- gtk_image_menu_item_set_image( GTK_IMAGE_MENU_ITEM(item), child );
-
- g_free( label );
- label = 0;
- } else {
- item = GTK_ACTION_CLASS(ink_action_parent_class)->create_menu_item( action );
- }
+ GtkWidget* item = GTK_ACTION_CLASS(ink_action_parent_class)->create_menu_item( action );
return item;
}
@@ -188,7 +161,7 @@ static GtkWidget* ink_action_create_tool_item( GtkAction* action )
if ( GTK_IS_TOOL_BUTTON(item) ) {
GtkToolButton* button = GTK_TOOL_BUTTON(item);
- GtkWidget* child = sp_icon_new( act->private_data->iconSize, act->private_data->iconId );
+ GtkWidget* child = gtk_image_new_from_icon_name( act->private_data->iconId, act->private_data->iconSize );
gtk_tool_button_set_icon_widget( button, child );
} else {
// For now trigger a warning but don't do anything else
diff --git a/src/widgets/ink-action.h b/src/widgets/ink-action.h
index 738212c61..99786c878 100644
--- a/src/widgets/ink-action.h
+++ b/src/widgets/ink-action.h
@@ -37,7 +37,7 @@ InkAction* ink_action_new( const gchar *name,
const gchar *label,
const gchar *tooltip,
const gchar *inkId,
- Inkscape::IconSize size );
+ GtkIconSize size );
G_END_DECLS
diff --git a/src/widgets/ink-radio-action.cpp b/src/widgets/ink-radio-action.cpp
index 2113819c3..e2bf828ce 100644
--- a/src/widgets/ink-radio-action.cpp
+++ b/src/widgets/ink-radio-action.cpp
@@ -10,7 +10,7 @@ static GtkWidget* ink_radio_action_create_tool_item( GtkAction* action );
struct _InkRadioActionPrivate
{
gchar* iconId;
- Inkscape::IconSize iconSize;
+ GtkIconSize iconSize;
};
#define INK_RADIO_ACTION_GET_PRIVATE( o ) ( G_TYPE_INSTANCE_GET_PRIVATE( (o), INK_RADIO_ACTION_TYPE, InkRadioActionPrivate ) )
@@ -49,9 +49,9 @@ static void ink_radio_action_class_init( InkRadioActionClass* klass )
g_param_spec_int( "iconSize",
"Icon Size",
"The size the icon",
- (int)Inkscape::ICON_SIZE_MENU,
- (int)Inkscape::ICON_SIZE_DECORATION,
- (int)Inkscape::ICON_SIZE_SMALL_TOOLBAR,
+ (int)GTK_ICON_SIZE_MENU,
+ (int)GTK_ICON_SIZE_DIALOG,
+ (int)GTK_ICON_SIZE_SMALL_TOOLBAR,
(GParamFlags)(G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT) ) );
g_type_class_add_private( klass, sizeof(InkRadioActionClass) );
@@ -62,7 +62,7 @@ static void ink_radio_action_init( InkRadioAction* action )
{
action->private_data = INK_RADIO_ACTION_GET_PRIVATE( action );
action->private_data->iconId = 0;
- action->private_data->iconSize = Inkscape::ICON_SIZE_SMALL_TOOLBAR;
+ action->private_data->iconSize = GTK_ICON_SIZE_SMALL_TOOLBAR;
}
static void ink_radio_action_finalize( GObject* obj )
@@ -78,14 +78,14 @@ InkRadioAction* ink_radio_action_new( const gchar *name,
const gchar *label,
const gchar *tooltip,
const gchar *inkId,
- Inkscape::IconSize size )
+ GtkIconSize size )
{
GObject* obj = (GObject*)g_object_new( INK_RADIO_ACTION_TYPE,
"name", name,
"label", label,
"tooltip", tooltip,
"iconId", inkId,
- "iconSize", Inkscape::getRegisteredIconSize(size),
+ "iconSize", size,
NULL );
InkRadioAction* action = INK_RADIO_ACTION( obj );
@@ -130,7 +130,7 @@ void ink_radio_action_set_property( GObject* obj, guint propId, const GValue *va
case PROP_INK_SIZE:
{
- action->private_data->iconSize = (Inkscape::IconSize)g_value_get_int( value );
+ action->private_data->iconSize = (GtkIconSize)g_value_get_int( value );
}
break;
@@ -157,7 +157,7 @@ static GtkWidget* ink_radio_action_create_tool_item( GtkAction* action )
if ( GTK_IS_TOOL_BUTTON(item) ) {
GtkToolButton* button = GTK_TOOL_BUTTON(item);
- GtkWidget* child = sp_icon_new( act->private_data->iconSize, act->private_data->iconId );
+ GtkWidget* child = gtk_image_new_from_icon_name( act->private_data->iconId, act->private_data->iconSize );
gtk_widget_set_hexpand(child, FALSE);
gtk_widget_set_vexpand(child, FALSE);
gtk_tool_button_set_icon_widget(button, child);
diff --git a/src/widgets/ink-radio-action.h b/src/widgets/ink-radio-action.h
index c1f059c4f..52afa0cb8 100644
--- a/src/widgets/ink-radio-action.h
+++ b/src/widgets/ink-radio-action.h
@@ -3,8 +3,6 @@
#include <gtk/gtk.h>
-#include "icon.h"
-
G_BEGIN_DECLS
#define INK_RADIO_ACTION_TYPE ( ink_radio_action_get_type() )
@@ -35,7 +33,7 @@ InkRadioAction* ink_radio_action_new( const gchar *name,
const gchar *label,
const gchar *tooltip,
const gchar *inkId,
- Inkscape::IconSize size );
+ GtkIconSize size );
G_END_DECLS
diff --git a/src/widgets/ink-toggle-action.cpp b/src/widgets/ink-toggle-action.cpp
index 3eed974dc..c091a2e0d 100644
--- a/src/widgets/ink-toggle-action.cpp
+++ b/src/widgets/ink-toggle-action.cpp
@@ -1,5 +1,4 @@
#include "ink-toggle-action.h"
-#include "icon.h"
static void ink_toggle_action_finalize( GObject* obj );
static void ink_toggle_action_get_property( GObject* obj, guint propId, GValue* value, GParamSpec * pspec );
@@ -13,7 +12,7 @@ static void ink_toggle_action_update_icon( InkToggleAction* action );
struct _InkToggleActionPrivate
{
gchar* iconId;
- Inkscape::IconSize iconSize;
+ GtkIconSize iconSize;
};
#define INK_TOGGLE_ACTION_GET_PRIVATE( o ) ( G_TYPE_INSTANCE_GET_PRIVATE( (o), INK_TOGGLE_ACTION_TYPE, InkToggleActionPrivate ) )
@@ -65,7 +64,7 @@ static void ink_toggle_action_init( InkToggleAction* action )
{
action->private_data = INK_TOGGLE_ACTION_GET_PRIVATE( action );
action->private_data->iconId = 0;
- action->private_data->iconSize = Inkscape::ICON_SIZE_SMALL_TOOLBAR;
+ action->private_data->iconSize = GTK_ICON_SIZE_SMALL_TOOLBAR;
}
static void ink_toggle_action_finalize( GObject* obj )
@@ -81,7 +80,7 @@ InkToggleAction* ink_toggle_action_new( const gchar *name,
const gchar *label,
const gchar *tooltip,
const gchar *inkId,
- Inkscape::IconSize size,
+ GtkIconSize size,
SPAttributeEnum attr)
{
GObject* obj = (GObject*)g_object_new( INK_TOGGLE_ACTION_TYPE,
@@ -89,7 +88,7 @@ InkToggleAction* ink_toggle_action_new( const gchar *name,
"label", label,
"tooltip", tooltip,
"iconId", inkId,
- "iconSize", Inkscape::getRegisteredIconSize(size),
+ "iconSize", size,
//"SP_ATTR_INKSCAPE", attr, // Why doesn't this work and do I need to use g_object_set_data below?
NULL );
@@ -138,7 +137,7 @@ void ink_toggle_action_set_property( GObject* obj, guint propId, const GValue *v
case PROP_INK_SIZE:
{
- action->private_data->iconSize = (Inkscape::IconSize)g_value_get_int( value );
+ action->private_data->iconSize = (GtkIconSize)g_value_get_int( value );
}
break;
@@ -164,7 +163,7 @@ static GtkWidget* ink_toggle_action_create_tool_item( GtkAction* action )
if ( GTK_IS_TOOL_BUTTON(item) ) {
GtkToolButton* button = GTK_TOOL_BUTTON(item);
if ( act->private_data->iconId ) {
- GtkWidget* child = sp_icon_new( act->private_data->iconSize, act->private_data->iconId );
+ GtkWidget* child = gtk_image_new_from_icon_name( act->private_data->iconId, act->private_data->iconSize );
gtk_widget_set_hexpand(child, FALSE);
gtk_widget_set_vexpand(child, FALSE);
@@ -196,7 +195,7 @@ static void ink_toggle_action_update_icon( InkToggleAction* action )
if ( GTK_IS_TOOL_BUTTON(proxies->data) ) {
GtkToolButton* button = GTK_TOOL_BUTTON(proxies->data);
- GtkWidget* child = sp_icon_new( action->private_data->iconSize, action->private_data->iconId );
+ GtkWidget* child = gtk_image_new_from_icon_name( action->private_data->iconId, action->private_data->iconSize );
gtk_widget_set_hexpand(child, FALSE);
gtk_widget_set_vexpand(child, FALSE);
gtk_widget_show_all(child);
diff --git a/src/widgets/ink-toggle-action.h b/src/widgets/ink-toggle-action.h
index 8e9d5e257..9130b9f9f 100644
--- a/src/widgets/ink-toggle-action.h
+++ b/src/widgets/ink-toggle-action.h
@@ -35,7 +35,7 @@ InkToggleAction* ink_toggle_action_new( const gchar *name,
const gchar *label,
const gchar *tooltip,
const gchar *inkId,
- Inkscape::IconSize size,
+ GtkIconSize size,
SPAttributeEnum attr = SP_ATTR_INVALID);
G_END_DECLS
diff --git a/src/widgets/ink-tool-menu-action.cpp b/src/widgets/ink-tool-menu-action.cpp
index 29d8dc92f..44c09147b 100644
--- a/src/widgets/ink-tool-menu-action.cpp
+++ b/src/widgets/ink-tool-menu-action.cpp
@@ -21,7 +21,7 @@ ink_tool_menu_action_new (const gchar *name,
const gchar *label,
const gchar *tooltip,
const gchar *inkId,
- Inkscape::IconSize size )
+ GtkIconSize size )
{
g_return_val_if_fail (name != NULL, NULL);
diff --git a/src/widgets/ink-tool-menu-action.h b/src/widgets/ink-tool-menu-action.h
index be04489d3..c34aa1322 100644
--- a/src/widgets/ink-tool-menu-action.h
+++ b/src/widgets/ink-tool-menu-action.h
@@ -34,7 +34,7 @@ InkToolMenuAction* ink_tool_menu_action_new( const gchar *name,
const gchar *label,
const gchar *tooltip,
const gchar *inkId,
- Inkscape::IconSize size );
+ GtkIconSize size );
G_END_DECLS
diff --git a/src/widgets/lpe-toolbar.cpp b/src/widgets/lpe-toolbar.cpp
index c714aba10..d03be1b44 100644
--- a/src/widgets/lpe-toolbar.cpp
+++ b/src/widgets/lpe-toolbar.cpp
@@ -328,7 +328,7 @@ void sp_lpetool_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions, GO
_("Show limiting bounding box"),
_("Show bounding box (used to cut infinite lines)"),
"show-bounding-box",
- Inkscape::ICON_SIZE_DECORATION );
+ GTK_ICON_SIZE_MENU );
gtk_action_group_add_action( mainActions, GTK_ACTION( act ) );
g_signal_connect_after( G_OBJECT(act), "toggled", G_CALLBACK(lpetool_toggle_show_bbox), desktop );
gtk_toggle_action_set_active( GTK_TOGGLE_ACTION(act), prefs->getBool( "/tools/lpetool/show_bbox", true ) );
@@ -340,7 +340,7 @@ void sp_lpetool_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions, GO
_("Get limiting bounding box from selection"),
_("Set limiting bounding box (used to cut infinite lines) to the bounding box of current selection"),
"draw-geometry-set-bounding-box",
- Inkscape::ICON_SIZE_DECORATION );
+ GTK_ICON_SIZE_MENU );
gtk_action_group_add_action( mainActions, GTK_ACTION( act ) );
g_signal_connect_after( G_OBJECT(act), "toggled", G_CALLBACK(lpetool_toggle_set_bbox), desktop );
gtk_toggle_action_set_active( GTK_TOGGLE_ACTION(act), FALSE );
@@ -369,7 +369,7 @@ void sp_lpetool_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions, GO
_("Display measuring info"),
_("Display measuring info for selected items"),
"draw-geometry-show-measuring-info",
- Inkscape::ICON_SIZE_DECORATION );
+ GTK_ICON_SIZE_MENU );
gtk_action_group_add_action( mainActions, GTK_ACTION( act ) );
g_signal_connect_after( G_OBJECT(act), "toggled", G_CALLBACK(lpetool_toggle_show_measuring_info), holder );
gtk_toggle_action_set_active( GTK_TOGGLE_ACTION(act), prefs->getBool( "/tools/lpetool/show_measuring_info", true ) );
@@ -390,7 +390,7 @@ void sp_lpetool_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions, GO
_("Open LPE dialog"),
_("Open LPE dialog (to adapt parameters numerically)"),
"dialog-geometry",
- Inkscape::ICON_SIZE_DECORATION );
+ GTK_ICON_SIZE_MENU );
gtk_action_group_add_action( mainActions, GTK_ACTION( act ) );
g_signal_connect_after( G_OBJECT(act), "toggled", G_CALLBACK(lpetool_open_lpe_dialog), desktop );
gtk_toggle_action_set_active( GTK_TOGGLE_ACTION(act), FALSE );
diff --git a/src/widgets/measure-toolbar.cpp b/src/widgets/measure-toolbar.cpp
index 066c3fbfa..fc6cfdb11 100644
--- a/src/widgets/measure-toolbar.cpp
+++ b/src/widgets/measure-toolbar.cpp
@@ -266,7 +266,7 @@ void sp_measure_toolbox_prep(SPDesktop * desktop, GtkActionGroup* mainActions, G
g_object_set_data( holder, "tracker", tracker );
EgeAdjustmentAction *eact = 0;
- Inkscape::IconSize secondarySize = ToolboxFactory::prefToSize("/toolbox/secondary", 1);
+ GtkIconSize secondarySize = ToolboxFactory::prefToSize("/toolbox/secondary", 1);
/* Font Size */
{
diff --git a/src/widgets/mesh-toolbar.cpp b/src/widgets/mesh-toolbar.cpp
index 0ca1cc027..666d29fc4 100644
--- a/src/widgets/mesh-toolbar.cpp
+++ b/src/widgets/mesh-toolbar.cpp
@@ -375,7 +375,7 @@ static void mesh_toolbox_watch_ec(SPDesktop* dt, Inkscape::UI::Tools::ToolBase*
*/
void sp_mesh_toolbox_prep(SPDesktop * desktop, GtkActionGroup* mainActions, GObject* holder)
{
- Inkscape::IconSize secondarySize = ToolboxFactory::prefToSize("/toolbox/secondary", 1);
+ GtkIconSize secondarySize = ToolboxFactory::prefToSize("/toolbox/secondary", 1);
EgeAdjustmentAction* eact = 0;
diff --git a/src/widgets/node-toolbar.cpp b/src/widgets/node-toolbar.cpp
index 31efaa0b4..b1346ed89 100644
--- a/src/widgets/node-toolbar.cpp
+++ b/src/widgets/node-toolbar.cpp
@@ -332,7 +332,7 @@ void sp_node_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions, GObje
tracker->setActiveUnit(&doc_units);
g_object_set_data( holder, "tracker", tracker );
- Inkscape::IconSize secondarySize = ToolboxFactory::prefToSize("/toolbox/secondary", 1);
+ GtkIconSize secondarySize = ToolboxFactory::prefToSize("/toolbox/secondary", 1);
{
InkToolMenuAction* inky = ink_tool_menu_action_new( "NodeInsertAction",
diff --git a/src/widgets/paint-selector.cpp b/src/widgets/paint-selector.cpp
index 855371ddd..27fe4b63a 100644
--- a/src/widgets/paint-selector.cpp
+++ b/src/widgets/paint-selector.cpp
@@ -27,7 +27,6 @@
#include "widgets/swatch-selector.h"
#include "sp-pattern.h"
#include <glibmm/i18n.h>
-#include "widgets/icon.h"
#include "widgets/widget-sizes.h"
#include "xml/repr.h"
@@ -236,7 +235,7 @@ sp_paint_selector_init(SPPaintSelector *psel)
// TRANSLATORS: for info, see http://www.w3.org/TR/2000/CR-SVG-20000802/painting.html#FillRuleProperty
gtk_widget_set_tooltip_text(psel->evenodd, _("Any path self-intersections or subpaths create holes in the fill (fill-rule: evenodd)"));
g_object_set_data(G_OBJECT(psel->evenodd), "mode", GUINT_TO_POINTER(SPPaintSelector::FILLRULE_EVENODD));
- w = sp_icon_new(Inkscape::ICON_SIZE_DECORATION, INKSCAPE_ICON("fill-rule-even-odd"));
+ w = gtk_image_new_from_icon_name("fill-rule-even-odd", GTK_ICON_SIZE_MENU);
gtk_container_add(GTK_CONTAINER(psel->evenodd), w);
gtk_box_pack_start(GTK_BOX(psel->fillrulebox), psel->evenodd, FALSE, FALSE, 0);
g_signal_connect(G_OBJECT(psel->evenodd), "toggled", G_CALLBACK(sp_paint_selector_fillrule_toggled), psel);
@@ -247,7 +246,7 @@ sp_paint_selector_init(SPPaintSelector *psel)
// TRANSLATORS: for info, see http://www.w3.org/TR/2000/CR-SVG-20000802/painting.html#FillRuleProperty
gtk_widget_set_tooltip_text(psel->nonzero, _("Fill is solid unless a subpath is counterdirectional (fill-rule: nonzero)"));
g_object_set_data(G_OBJECT(psel->nonzero), "mode", GUINT_TO_POINTER(SPPaintSelector::FILLRULE_NONZERO));
- w = sp_icon_new(Inkscape::ICON_SIZE_DECORATION, INKSCAPE_ICON("fill-rule-nonzero"));
+ w = gtk_image_new_from_icon_name("fill-rule-nonzero", GTK_ICON_SIZE_MENU);
gtk_container_add(GTK_CONTAINER(psel->nonzero), w);
gtk_box_pack_start(GTK_BOX(psel->fillrulebox), psel->nonzero, FALSE, FALSE, 0);
g_signal_connect(G_OBJECT(psel->nonzero), "toggled", G_CALLBACK(sp_paint_selector_fillrule_toggled), psel);
@@ -316,7 +315,7 @@ static GtkWidget *sp_paint_selector_style_button_add(SPPaintSelector *psel,
gtk_toggle_button_set_mode(GTK_TOGGLE_BUTTON(b), FALSE);
g_object_set_data(G_OBJECT(b), "mode", GUINT_TO_POINTER(mode));
- w = sp_icon_new(Inkscape::ICON_SIZE_BUTTON, pixmap);
+ w = gtk_image_new_from_icon_name(pixmap, GTK_ICON_SIZE_BUTTON);
gtk_widget_show(w);
gtk_container_add(GTK_CONTAINER(b), w);
diff --git a/src/widgets/paintbucket-toolbar.cpp b/src/widgets/paintbucket-toolbar.cpp
index e2212b64f..1d5fb81e1 100644
--- a/src/widgets/paintbucket-toolbar.cpp
+++ b/src/widgets/paintbucket-toolbar.cpp
@@ -210,7 +210,7 @@ void sp_paintbucket_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions
_("Defaults"),
_("Reset paint bucket parameters to defaults (use Inkscape Preferences > Tools to change defaults)"),
INKSCAPE_ICON("edit-clear"),
- Inkscape::ICON_SIZE_SMALL_TOOLBAR);
+ GTK_ICON_SIZE_SMALL_TOOLBAR);
g_signal_connect_after( G_OBJECT(inky), "activate", G_CALLBACK(paintbucket_defaults), holder );
gtk_action_group_add_action( mainActions, GTK_ACTION(inky) );
gtk_action_set_sensitive( GTK_ACTION(inky), TRUE );
diff --git a/src/widgets/pencil-toolbar.cpp b/src/widgets/pencil-toolbar.cpp
index 96733cb22..918a54991 100644
--- a/src/widgets/pencil-toolbar.cpp
+++ b/src/widgets/pencil-toolbar.cpp
@@ -91,7 +91,7 @@ static void sp_add_freehand_mode_toggle(GtkActionGroup* mainActions, GObject* ho
{
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
guint freehandMode = prefs->getInt(( tool_is_pencil ? "/tools/freehand/pencil/freehand-mode" : "/tools/freehand/pen/freehand-mode" ), 0);
- Inkscape::IconSize secondarySize = ToolboxFactory::prefToSize("/toolbox/secondary", 1);
+ GtkIconSize secondarySize = ToolboxFactory::prefToSize("/toolbox/secondary", 1);
{
GtkListStore* model = gtk_list_store_new( 3, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING );
@@ -398,7 +398,7 @@ void sp_pencil_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions, GOb
_("Defaults"),
_("Reset pencil parameters to defaults (use Inkscape Preferences > Tools to change defaults)"),
INKSCAPE_ICON("edit-clear"),
- Inkscape::ICON_SIZE_SMALL_TOOLBAR );
+ GTK_ICON_SIZE_SMALL_TOOLBAR );
g_signal_connect_after( G_OBJECT(inky), "activate", G_CALLBACK(sp_pencil_tb_defaults), holder );
gtk_action_group_add_action( mainActions, GTK_ACTION(inky) );
}
@@ -409,7 +409,7 @@ void sp_pencil_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions, GOb
_("LPE based interactive simplify"),
_("LPE based interactive simplify"),
INKSCAPE_ICON("interactive_simplify"),
- Inkscape::ICON_SIZE_SMALL_TOOLBAR );
+ GTK_ICON_SIZE_SMALL_TOOLBAR );
gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(itact), prefs->getInt("/tools/freehand/pencil/simplify", 0) );
g_signal_connect_after( G_OBJECT(itact), "toggled", G_CALLBACK(freehand_simplify_lpe), holder) ;
gtk_action_group_add_action( mainActions, GTK_ACTION(itact) );
@@ -420,7 +420,7 @@ void sp_pencil_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions, GOb
_("LPE simplify flatten"),
_("LPE simplify flatten"),
INKSCAPE_ICON("flatten_simplify"),
- Inkscape::ICON_SIZE_SMALL_TOOLBAR );
+ GTK_ICON_SIZE_SMALL_TOOLBAR );
g_signal_connect_after( G_OBJECT(inky), "activate", G_CALLBACK(sp_simplify_flatten), holder );
gtk_action_group_add_action( mainActions, GTK_ACTION(inky) );
g_object_set_data( holder, "flatten_simplify", inky );
diff --git a/src/widgets/rect-toolbar.cpp b/src/widgets/rect-toolbar.cpp
index 67947c1fd..de599cbfb 100644
--- a/src/widgets/rect-toolbar.cpp
+++ b/src/widgets/rect-toolbar.cpp
@@ -289,7 +289,7 @@ static void rect_toolbox_watch_ec(SPDesktop* dt, Inkscape::UI::Tools::ToolBase*
void sp_rect_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions, GObject* holder)
{
EgeAdjustmentAction* eact = 0;
- Inkscape::IconSize secondarySize = ToolboxFactory::prefToSize("/toolbox/secondary", 1);
+ GtkIconSize secondarySize = ToolboxFactory::prefToSize("/toolbox/secondary", 1);
{
EgeOutputAction* act = ege_output_action_new( "RectStateAction", _("<b>New:</b>"), "", 0 );
diff --git a/src/widgets/select-toolbar.cpp b/src/widgets/select-toolbar.cpp
index 2ac7447dd..0932589d2 100644
--- a/src/widgets/select-toolbar.cpp
+++ b/src/widgets/select-toolbar.cpp
@@ -40,7 +40,6 @@
#include "ui/icon-names.h"
#include "ui/widget/unit-tracker.h"
#include "verbs.h"
-#include "widgets/icon.h"
#include "widgets/sp-widget.h"
#include "widgets/widget-sizes.h"
@@ -345,7 +344,7 @@ static void trigger_sp_action( GtkAction* /*act*/, gpointer user_data )
}
}
-static GtkAction* create_action_for_verb( Inkscape::Verb* verb, Inkscape::UI::View::View* view, Inkscape::IconSize size )
+static GtkAction* create_action_for_verb( Inkscape::Verb* verb, Inkscape::UI::View::View* view, GtkIconSize size )
{
GtkAction* act = 0;
@@ -355,15 +354,13 @@ static GtkAction* create_action_for_verb( Inkscape::Verb* verb, Inkscape::UI::Vi
g_signal_connect( G_OBJECT(inky), "activate", G_CALLBACK(trigger_sp_action), targetAction );
- Inkscape::queueIconPrerender( verb->get_image(), size );
-
return act;
}
void sp_select_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions, GObject* holder)
{
Inkscape::UI::View::View *view = desktop;
- Inkscape::IconSize secondarySize = Inkscape::UI::ToolboxFactory::prefToSize("/toolbox/secondary", 1);
+ GtkIconSize secondarySize = Inkscape::UI::ToolboxFactory::prefToSize("/toolbox/secondary", 1);
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
GtkAction* act = 0;
@@ -492,7 +489,7 @@ void sp_select_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions, GOb
_("Lock width and height"),
_("When locked, change both width and height by the same proportion"),
INKSCAPE_ICON("object-unlocked"),
- Inkscape::ICON_SIZE_DECORATION );
+ GTK_ICON_SIZE_MENU );
g_object_set( itact, "short_label", "Lock", NULL );
g_object_set_data( G_OBJECT(spw), "lock", itact );
g_signal_connect_after( G_OBJECT(itact), "toggled", G_CALLBACK(toggle_lock), desktop) ;
diff --git a/src/widgets/spiral-toolbar.cpp b/src/widgets/spiral-toolbar.cpp
index 98d21c84d..ef9f5bce8 100644
--- a/src/widgets/spiral-toolbar.cpp
+++ b/src/widgets/spiral-toolbar.cpp
@@ -225,7 +225,7 @@ static void sp_spiral_toolbox_selection_changed(Inkscape::Selection *selection,
void sp_spiral_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions, GObject* holder)
{
EgeAdjustmentAction* eact = 0;
- Inkscape::IconSize secondarySize = ToolboxFactory::prefToSize("/toolbox/secondary", 1);
+ GtkIconSize secondarySize = ToolboxFactory::prefToSize("/toolbox/secondary", 1);
{
EgeOutputAction* act = ege_output_action_new( "SpiralStateAction", _("<b>New:</b>"), "", 0 );
diff --git a/src/widgets/spray-toolbar.cpp b/src/widgets/spray-toolbar.cpp
index f456bc763..2a56d81cb 100644
--- a/src/widgets/spray-toolbar.cpp
+++ b/src/widgets/spray-toolbar.cpp
@@ -287,7 +287,7 @@ static void sp_toggle_pick_inverse_value( GtkToggleAction* act, gpointer data )
void sp_spray_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions, GObject* holder)
{
- Inkscape::IconSize secondarySize = ToolboxFactory::prefToSize("/toolbox/secondary", 1);
+ GtkIconSize secondarySize = ToolboxFactory::prefToSize("/toolbox/secondary", 1);
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
{
/* Width */
@@ -311,7 +311,7 @@ void sp_spray_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions, GObj
_("Pressure"),
_("Use the pressure of the input device to alter the width of spray area"),
INKSCAPE_ICON("draw-use-pressure"),
- Inkscape::ICON_SIZE_DECORATION );
+ GTK_ICON_SIZE_MENU );
gtk_action_group_add_action( mainActions, GTK_ACTION(act) );
PrefPusher *pusher = new PrefPusher(GTK_TOGGLE_ACTION(act), "/tools/spray/usepressurewidth");
g_signal_connect(holder, "destroy", G_CALLBACK(delete_prefspusher), pusher);
@@ -427,7 +427,7 @@ void sp_spray_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions, GObj
_("Pressure"),
_("Use the pressure of the input device to alter the amount of sprayed objects"),
INKSCAPE_ICON("draw-use-pressure"),
- Inkscape::ICON_SIZE_DECORATION );
+ GTK_ICON_SIZE_MENU );
gtk_action_group_add_action( mainActions, GTK_ACTION(act) );
PrefPusher *pusher = new PrefPusher(GTK_TOGGLE_ACTION(act), "/tools/spray/usepressurepopulation");
g_signal_connect(holder, "destroy", G_CALLBACK(delete_prefspusher), pusher);
@@ -476,7 +476,7 @@ void sp_spray_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions, GObj
_("Pressure"),
_("Use the pressure of the input device to alter the scale of new items"),
INKSCAPE_ICON("draw-use-pressure"),
- Inkscape::ICON_SIZE_DECORATION);
+ GTK_ICON_SIZE_MENU);
gtk_toggle_action_set_active( GTK_TOGGLE_ACTION(act), prefs->getBool("/tools/spray/usepressurescale", false) );
g_object_set_data( holder, "usepressurescale", act );
g_signal_connect_after( G_OBJECT(act), "toggled", G_CALLBACK(sp_toggle_pressure_scale), holder) ;
diff --git a/src/widgets/star-toolbar.cpp b/src/widgets/star-toolbar.cpp
index 8f667a656..657b38f18 100644
--- a/src/widgets/star-toolbar.cpp
+++ b/src/widgets/star-toolbar.cpp
@@ -436,7 +436,7 @@ static void star_toolbox_watch_ec(SPDesktop* dt, Inkscape::UI::Tools::ToolBase*
void sp_star_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions, GObject* holder)
{
- Inkscape::IconSize secondarySize = ToolboxFactory::prefToSize("/toolbox/secondary", 1);
+ GtkIconSize secondarySize = ToolboxFactory::prefToSize("/toolbox/secondary", 1);
{
EgeOutputAction* act = ege_output_action_new( "StarStateAction", _("<b>New:</b>"), "", 0 );
@@ -562,7 +562,7 @@ void sp_star_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions, GObje
_("Defaults"),
_("Reset shape parameters to defaults (use Inkscape Preferences > Tools to change defaults)"),
INKSCAPE_ICON("edit-clear"),
- Inkscape::ICON_SIZE_SMALL_TOOLBAR);
+ GTK_ICON_SIZE_SMALL_TOOLBAR);
g_signal_connect_after( G_OBJECT(inky), "activate", G_CALLBACK(sp_stb_defaults), holder );
gtk_action_group_add_action( mainActions, GTK_ACTION(inky) );
gtk_action_set_sensitive( GTK_ACTION(inky), TRUE );
diff --git a/src/widgets/stroke-marker-selector.cpp b/src/widgets/stroke-marker-selector.cpp
index 3f81bef5c..96994741c 100644
--- a/src/widgets/stroke-marker-selector.cpp
+++ b/src/widgets/stroke-marker-selector.cpp
@@ -54,13 +54,8 @@ MarkerComboBox::MarkerComboBox(gchar const *id, int l) :
set_cell_data_func(image_renderer, sigc::mem_fun(*this, &MarkerComboBox::prepareImageRenderer));
gtk_combo_box_set_row_separator_func(GTK_COMBO_BOX(gobj()), MarkerComboBox::separator_cb, NULL, NULL);
- Glib::ustring no_marker("no-marker");
- Glib::RefPtr<Gtk::IconTheme> iconTheme = Gtk::IconTheme::get_default();
- if (!iconTheme->has_icon(no_marker)) {
- Inkscape::queueIconPrerender( INKSCAPE_ICON(no_marker.data()), Inkscape::ICON_SIZE_SMALL_TOOLBAR );
- }
- empty_image = new Gtk::Image( Glib::wrap(
- sp_pixbuf_new( Inkscape::ICON_SIZE_SMALL_TOOLBAR, INKSCAPE_ICON(no_marker.data()) ) ) );
+ empty_image = new Gtk::Image();
+ empty_image->set_from_icon_name("no-marker", Gtk::ICON_SIZE_SMALL_TOOLBAR);
sandbox = ink_markers_preview_doc ();
desktop = SP_ACTIVE_DESKTOP;
diff --git a/src/widgets/stroke-style.cpp b/src/widgets/stroke-style.cpp
index de3e98297..3115a32db 100644
--- a/src/widgets/stroke-style.cpp
+++ b/src/widgets/stroke-style.cpp
@@ -111,8 +111,9 @@ StrokeStyle::StrokeStyleButton::StrokeStyleButton(Gtk::RadioButtonGroup &grp,
{
show();
set_mode(false);
-
- Gtk::Widget *px = Gtk::manage(Glib::wrap(sp_icon_new(Inkscape::ICON_SIZE_LARGE_TOOLBAR, icon)));
+
+ auto px = Gtk::manage(new Gtk::Image());
+ px->set_from_icon_name(icon, Gtk::ICON_SIZE_LARGE_TOOLBAR);
g_assert(px != NULL);
px->show();
add(*px);
diff --git a/src/widgets/stroke-style.h b/src/widgets/stroke-style.h
index cdd825c7d..b8eaec8e8 100644
--- a/src/widgets/stroke-style.h
+++ b/src/widgets/stroke-style.h
@@ -52,7 +52,6 @@
#include "svg/css-ostringstream.h"
#include "ui/cache/svg_preview_cache.h"
#include "ui/icon-names.h"
-#include "widgets/icon.h"
#include "widgets/paint-selector.h"
#include "widgets/sp-widget.h"
#include "widgets/spw-utilities.h"
diff --git a/src/widgets/text-toolbar.cpp b/src/widgets/text-toolbar.cpp
index efa5527e4..bf05448eb 100644
--- a/src/widgets/text-toolbar.cpp
+++ b/src/widgets/text-toolbar.cpp
@@ -1706,7 +1706,7 @@ static void text_toolbox_watch_ec(SPDesktop* dt, Inkscape::UI::Tools::ToolBase*
void sp_text_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions, GObject* holder)
{
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
- Inkscape::IconSize secondarySize = ToolboxFactory::prefToSize("/toolbox/secondary", 1);
+ GtkIconSize secondarySize = ToolboxFactory::prefToSize("/toolbox/secondary", 1);
/* Font family */
{
diff --git a/src/widgets/toolbox.cpp b/src/widgets/toolbox.cpp
index 65c54f0ce..68e38e8ed 100644
--- a/src/widgets/toolbox.cpp
+++ b/src/widgets/toolbox.cpp
@@ -41,7 +41,6 @@
#include "document-undo.h"
#include "widgets/ege-adjustment-action.h"
#include "../helper/action.h"
-#include "icon.h"
#include "ink-action.h"
#include "ink-toggle-action.h"
#include "../inkscape.h"
@@ -102,7 +101,7 @@ using Inkscape::UI::ToolboxFactory;
using Inkscape::UI::Tools::ToolBase;
using Inkscape::IO::Resource::get_filename;
-using Inkscape::IO::Resource::UI;
+using Inkscape::IO::Resource::UIS;
typedef void (*SetupFunction)(GtkWidget *toolbox, SPDesktop *desktop);
typedef void (*UpdateFunction)(SPDesktop *desktop, ToolBase *eventcontext, GtkWidget *toolbox);
@@ -120,12 +119,12 @@ enum BarId {
static GtkWidget *sp_empty_toolbox_new(SPDesktop *desktop);
-Inkscape::IconSize ToolboxFactory::prefToSize( Glib::ustring const &path, int base ) {
- static Inkscape::IconSize sizeChoices[] = {
- Inkscape::ICON_SIZE_LARGE_TOOLBAR,
- Inkscape::ICON_SIZE_SMALL_TOOLBAR,
- Inkscape::ICON_SIZE_MENU,
- Inkscape::ICON_SIZE_DIALOG
+GtkIconSize ToolboxFactory::prefToSize( Glib::ustring const &path, int base ) {
+ static GtkIconSize sizeChoices[] = {
+ GTK_ICON_SIZE_LARGE_TOOLBAR,
+ GTK_ICON_SIZE_SMALL_TOOLBAR,
+ GTK_ICON_SIZE_MENU,
+ GTK_ICON_SIZE_DIALOG
};
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
int index = prefs->getIntLimited( path, base, 0, G_N_ELEMENTS(sizeChoices) );
@@ -244,7 +243,7 @@ static void update_aux_toolbox(SPDesktop *desktop, ToolBase *eventcontext, GtkWi
static void setup_commands_toolbox(GtkWidget *toolbox, SPDesktop *desktop);
static void update_commands_toolbox(SPDesktop *desktop, ToolBase *eventcontext, GtkWidget *toolbox);
-static GtkToolItem * sp_toolbox_button_item_new_from_verb_with_doubleclick( GtkWidget *t, Inkscape::IconSize size, SPButtonType type,
+static GtkToolItem * sp_toolbox_button_item_new_from_verb_with_doubleclick( GtkWidget *t, GtkIconSize size, SPButtonType type,
Inkscape::Verb *verb, Inkscape::Verb *doubleclick_verb,
Inkscape::UI::View::View *view);
@@ -301,11 +300,6 @@ VerbAction::~VerbAction()
Gtk::Widget* VerbAction::create_menu_item_vfunc()
{
-// First call in to get the icon rendered if present in SVG
- Gtk::Widget *widget = sp_icon_get_icon( get_icon_name(), Inkscape::ICON_SIZE_MENU );
- delete widget;
- widget = 0;
-
Gtk::Widget* widg = Gtk::Action::create_menu_item_vfunc();
// g_message("create_menu_item_vfunc() = %p for '%s'", widg, verb->get_id());
return widg;
@@ -314,7 +308,7 @@ Gtk::Widget* VerbAction::create_menu_item_vfunc()
Gtk::Widget* VerbAction::create_tool_item_vfunc()
{
// Gtk::Widget* widg = Gtk::Action::create_tool_item_vfunc();
- Inkscape::IconSize toolboxSize = ToolboxFactory::prefToSize("/toolbox/tools/small");
+ GtkIconSize toolboxSize = ToolboxFactory::prefToSize("/toolbox/tools/small");
GtkWidget* toolbox = 0;
GtkToolItem *button_toolitem = sp_toolbox_button_item_new_from_verb_with_doubleclick( toolbox, toolboxSize,
SP_BUTTON_TYPE_TOGGLE,
@@ -452,7 +446,7 @@ void delete_prefspusher(GObject * /*obj*/, PrefPusher *watcher )
// ------------------------------------------------------
-GtkToolItem * sp_toolbox_button_item_new_from_verb_with_doubleclick(GtkWidget *t, Inkscape::IconSize size, SPButtonType type,
+GtkToolItem * sp_toolbox_button_item_new_from_verb_with_doubleclick(GtkWidget *t, GtkIconSize size, SPButtonType type,
Inkscape::Verb *verb, Inkscape::Verb *doubleclick_verb,
Inkscape::UI::View::View *view)
{
@@ -504,7 +498,7 @@ static void trigger_sp_action( GtkAction* /*act*/, gpointer user_data )
}
}
-static GtkAction* create_action_for_verb( Inkscape::Verb* verb, Inkscape::UI::View::View* view, Inkscape::IconSize size )
+static GtkAction* create_action_for_verb( Inkscape::Verb* verb, Inkscape::UI::View::View* view, GtkIconSize size )
{
GtkAction* act = 0;
@@ -584,7 +578,7 @@ static Glib::RefPtr<Gtk::ActionGroup> create_or_fetch_actions( SPDesktop* deskto
SP_VERB_ZOOM_SELECTION
};
- Inkscape::IconSize toolboxSize = ToolboxFactory::prefToSize("/toolbox/small");
+ GtkIconSize toolboxSize = ToolboxFactory::prefToSize("/toolbox/small");
Glib::RefPtr<Gtk::ActionGroup> mainActions;
if (desktop == NULL)
{
@@ -840,10 +834,10 @@ static void setupToolboxCommon( GtkWidget *toolbox,
gtk_ui_manager_insert_action_group( mgr, mainActions->gobj(), 0 );
- char const *filename = get_filename(UI, ui_file);
- gtk_ui_manager_add_ui_from_file( mgr, filename, &err );
+ Glib::ustring filename = get_filename(UIS, ui_file);
+ gtk_ui_manager_add_ui_from_file( mgr, filename.c_str(), &err );
if(err) {
- g_warning("Failed to load %s: %s", filename, err->message);
+ g_warning("Failed to load %s: %s", filename.c_str(), err->message);
g_error_free(err);
return;
}
@@ -853,7 +847,7 @@ static void setupToolboxCommon( GtkWidget *toolbox,
gtk_toolbar_set_style( GTK_TOOLBAR(toolBar), GTK_TOOLBAR_ICONS );
}
- Inkscape::IconSize toolboxSize = ToolboxFactory::prefToSize(sizePref);
+ GtkIconSize toolboxSize = ToolboxFactory::prefToSize(sizePref);
gtk_toolbar_set_icon_size( GTK_TOOLBAR(toolBar), static_cast<GtkIconSize>(toolboxSize) );
GtkPositionType pos = static_cast<GtkPositionType>(GPOINTER_TO_INT(g_object_get_data( G_OBJECT(toolbox), HANDLE_POS_MARK )));
@@ -984,10 +978,10 @@ void setup_aux_toolbox(GtkWidget *toolbox, SPDesktop *desktop)
GError *err = 0;
gtk_ui_manager_insert_action_group( mgr, mainActions->gobj(), 0 );
- char const *filename = get_filename(UI, "select-toolbar.ui");
- guint ret = gtk_ui_manager_add_ui_from_file(mgr, filename, &err);
+ Glib::ustring filename = get_filename(UIS, "select-toolbar.ui");
+ guint ret = gtk_ui_manager_add_ui_from_file(mgr, filename.c_str(), &err);
if(err) {
- g_warning("Failed to load aux toolbar %s: %s", filename, err->message);
+ g_warning("Failed to load aux toolbar %s: %s", filename.c_str(), err->message);
g_error_free(err);
return;
}
@@ -1039,7 +1033,7 @@ void setup_aux_toolbox(GtkWidget *toolbox, SPDesktop *desktop)
gtk_toolbar_set_style( GTK_TOOLBAR(toolBar), GTK_TOOLBAR_ICONS );
}
- Inkscape::IconSize toolboxSize = ToolboxFactory::prefToSize("/toolbox/small");
+ GtkIconSize toolboxSize = ToolboxFactory::prefToSize("/toolbox/small");
gtk_toolbar_set_icon_size( GTK_TOOLBAR(toolBar), static_cast<GtkIconSize>(toolboxSize) );
gtk_widget_set_hexpand(toolBar, TRUE);
gtk_grid_attach( GTK_GRID(holder), toolBar, 0, 0, 1, 1);
@@ -1230,7 +1224,7 @@ void setup_snap_toolbox(GtkWidget *toolbox, SPDesktop *desktop)
{
Glib::RefPtr<Gtk::ActionGroup> mainActions = create_or_fetch_actions(desktop);
- Inkscape::IconSize secondarySize = ToolboxFactory::prefToSize("/toolbox/secondary", 1);
+ GtkIconSize secondarySize = ToolboxFactory::prefToSize("/toolbox/secondary", 1);
{
// TODO: This is a cludge. On the one hand we have verbs+actions,
diff --git a/src/widgets/toolbox.h b/src/widgets/toolbox.h
index db9130034..09178ec2f 100644
--- a/src/widgets/toolbox.h
+++ b/src/widgets/toolbox.h
@@ -61,7 +61,7 @@ public:
static void updateSnapToolbox(SPDesktop *desktop, Inkscape::UI::Tools::ToolBase *eventcontext, GtkWidget *toolbox);
- static Inkscape::IconSize prefToSize(Glib::ustring const &path, int base = 0 );
+ static GtkIconSize prefToSize(Glib::ustring const &path, int base = 0 );
private:
ToolboxFactory();
diff --git a/src/widgets/tweak-toolbar.cpp b/src/widgets/tweak-toolbar.cpp
index a6b8ba436..6a2847c68 100644
--- a/src/widgets/tweak-toolbar.cpp
+++ b/src/widgets/tweak-toolbar.cpp
@@ -117,7 +117,7 @@ static void tweak_toggle_doo(GtkToggleAction *act, gpointer /*data*/) {
void sp_tweak_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions, GObject* holder)
{
- Inkscape::IconSize secondarySize = ToolboxFactory::prefToSize("/toolbox/secondary", 1);
+ GtkIconSize secondarySize = ToolboxFactory::prefToSize("/toolbox/secondary", 1);
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
{
@@ -286,7 +286,7 @@ void sp_tweak_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions, GObj
_("Hue"),
_("In color mode, act on objects' hue"),
NULL,
- Inkscape::ICON_SIZE_DECORATION );
+ GTK_ICON_SIZE_MENU );
//TRANSLATORS: "H" here stands for hue
g_object_set( act, "short_label", C_("Hue", "H"), NULL );
gtk_action_group_add_action( mainActions, GTK_ACTION( act ) );
@@ -302,7 +302,7 @@ void sp_tweak_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions, GObj
_("Saturation"),
_("In color mode, act on objects' saturation"),
NULL,
- Inkscape::ICON_SIZE_DECORATION );
+ GTK_ICON_SIZE_MENU );
//TRANSLATORS: "S" here stands for Saturation
g_object_set( act, "short_label", C_("Saturation", "S"), NULL );
gtk_action_group_add_action( mainActions, GTK_ACTION( act ) );
@@ -318,7 +318,7 @@ void sp_tweak_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions, GObj
_("Lightness"),
_("In color mode, act on objects' lightness"),
NULL,
- Inkscape::ICON_SIZE_DECORATION );
+ GTK_ICON_SIZE_MENU );
//TRANSLATORS: "L" here stands for Lightness
g_object_set( act, "short_label", C_("Lightness", "L"), NULL );
gtk_action_group_add_action( mainActions, GTK_ACTION( act ) );
@@ -334,7 +334,7 @@ void sp_tweak_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions, GObj
_("Opacity"),
_("In color mode, act on objects' opacity"),
NULL,
- Inkscape::ICON_SIZE_DECORATION );
+ GTK_ICON_SIZE_MENU );
//TRANSLATORS: "O" here stands for Opacity
g_object_set( act, "short_label", C_("Opacity", "O"), NULL );
gtk_action_group_add_action( mainActions, GTK_ACTION( act ) );
@@ -372,7 +372,7 @@ void sp_tweak_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions, GObj
_("Pressure"),
_("Use the pressure of the input device to alter the force of tweak action"),
INKSCAPE_ICON("draw-use-pressure"),
- Inkscape::ICON_SIZE_DECORATION );
+ GTK_ICON_SIZE_MENU );
gtk_action_group_add_action( mainActions, GTK_ACTION( act ) );
g_signal_connect_after( G_OBJECT(act), "toggled", G_CALLBACK(sp_tweak_pressure_state_changed), NULL);
gtk_toggle_action_set_active( GTK_TOGGLE_ACTION(act), prefs->getBool("/tools/tweak/usepressure", true) );