diff options
| author | Sylvain Chiron <chironsylvain@orange.fr> | 2017-07-01 12:08:02 +0000 |
|---|---|---|
| committer | Sylvain Chiron <chironsylvain@orange.fr> | 2017-07-01 12:08:02 +0000 |
| commit | b311d097b148a2cf5213ca86a45cb562bdd02986 (patch) | |
| tree | 56b5c507727a852325a093ddedd2c3f44793c4ce /src | |
| parent | Updated libs from the Adaptagrams project: libavoid, libcola and libvspc; cha... (diff) | |
| parent | Fix a compiling error on debian testing (diff) | |
| download | inkscape-b311d097b148a2cf5213ca86a45cb562bdd02986.tar.gz inkscape-b311d097b148a2cf5213ca86a45cb562bdd02986.zip | |
Merge branch 'master' of gitlab.com:inkscape/inkscape
Diffstat (limited to 'src')
112 files changed, 709 insertions, 514 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/init.cpp b/src/extension/init.cpp index f2e74377d..a40196a74 100644 --- a/src/extension/init.cpp +++ b/src/extension/init.cpp @@ -66,6 +66,7 @@ #endif #ifdef WITH_IMAGE_MAGICK +#include <Magick++.h> #include "internal/bitmap/adaptiveThreshold.h" #include "internal/bitmap/addNoise.h" #include "internal/bitmap/blur.h" @@ -204,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(); 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/io/resource.cpp b/src/io/resource.cpp index ffe612e43..73dc7117e 100644 --- a/src/io/resource.cpp +++ b/src/io/resource.cpp @@ -20,7 +20,6 @@ #include "config.h" #endif -#include <glib.h> // g_assert() #include "path-prefix.h" #include "io/sys.h" #include "io/resource.h" @@ -49,6 +48,7 @@ gchar *_get_path(Domain domain, Type type, char const *filename) 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; @@ -71,6 +71,9 @@ 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) { @@ -80,6 +83,7 @@ gchar *_get_path(Domain domain, Type type, char const *filename) 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; diff --git a/src/io/resource.h b/src/io/resource.h index 8b60775b5..0ea5ab4f0 100644 --- a/src/io/resource.h +++ b/src/io/resource.h @@ -17,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 { @@ -35,6 +36,7 @@ enum Type { ICONS, KEYS, MARKERS, + NONE, PALETTES, PATTERNS, SCREENS, @@ -49,6 +51,7 @@ enum Type { enum Domain { SYSTEM, CREATE, + CACHE, USER }; 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/shortcuts.cpp b/src/shortcuts.cpp index f8a647040..8a8d36d5a 100644 --- a/src/shortcuts.cpp +++ b/src/shortcuts.cpp @@ -122,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 ); @@ -138,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) { @@ -607,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); } @@ -694,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/ui/CMakeLists.txt b/src/ui/CMakeLists.txt index c253daed9..b6b88e50b 100644 --- a/src/ui/CMakeLists.txt +++ b/src/ui/CMakeLists.txt @@ -72,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 @@ -216,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/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/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/dock-behavior.cpp b/src/ui/dialog/dock-behavior.cpp index 299584a31..0c8bb3194 100644 --- a/src/ui/dialog/dock-behavior.cpp +++ b/src/ui/dialog/dock-behavior.cpp @@ -39,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/filter-editor.cpp b/src/ui/dialog/filter-editor.cpp new file mode 100644 index 000000000..1b532578d --- /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.c_str()); + 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 5d7422279..bb8fc564a 100644 --- a/src/ui/dialog/grid-arrange-tab.cpp +++ b/src/ui/dialog/grid-arrange-tab.cpp @@ -610,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); @@ -640,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(" × "); XByYLabelVBox.pack_start(XByYLabel, false, false, MARGIN); @@ -650,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); @@ -676,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/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 be3b4af06..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> @@ -113,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 = gtk_image_new_from_icon_name( iconName, GTK_ICON_SIZE_MENU ); + iconWidget = Gtk::manage(new Gtk::Image()); + iconWidget->set_from_icon_name( iconName, Gtk::ICON_SIZE_MENU ); } if ( desktop ) { @@ -125,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 = gtk_image_new_from_icon_name( action->image, GTK_ICON_SIZE_MENU ); + iconWidget = Gtk::manage(new Gtk::Image()); + iconWidget->set_from_icon_name( action->image, Gtk::ICON_SIZE_MENU ); } if ( action ) { @@ -138,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/objects.cpp b/src/ui/dialog/objects.cpp index e76da241a..4b673b8b7 100644 --- a/src/ui/dialog/objects.cpp +++ b/src/ui/dialog/objects.cpp @@ -241,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 = gtk_image_new_from_icon_name( iconName, GTK_ICON_SIZE_MENU ); + 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 = gtk_image_new_from_icon_name( action->image, GTK_ICON_SIZE_MENU ); + 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; } } } @@ -266,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/styledialog.cpp b/src/ui/dialog/styledialog.cpp index 73dd6937a..3642c0168 100644 --- a/src/ui/dialog/styledialog.cpp +++ b/src/ui/dialog/styledialog.cpp @@ -264,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); 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/tags.cpp b/src/ui/dialog/tags.cpp index b990ccfef..176719995 100644 --- a/src/ui/dialog/tags.cpp +++ b/src/ui/dialog/tags.cpp @@ -155,7 +155,7 @@ Gtk::MenuItem& TagsPanel::_addPopupItem( SPDesktop *desktop, unsigned int code, } if ( action ) { - label = action->name; + // label = action->name; } } } @@ -166,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/interface.cpp b/src/ui/interface.cpp index 4246ae34e..a0ee5c72b 100644 --- a/src/ui/interface.cpp +++ b/src/ui/interface.cpp @@ -136,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 @@ -1441,33 +1439,6 @@ sp_ui_menu_item_set_name(GtkWidget *data, Glib::ustring const &name) } } } - -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 ); - } - } - } - } -} - /* Local Variables: mode:c++ 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 9332335fe..935463942 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 ¢er, 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 0c948c91c..08aacf805 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) @@ -773,14 +773,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 927b8a3d4..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); 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 9231db7c8..0467b984e 100644 --- a/src/ui/tools/tool-base.cpp +++ b/src/ui/tools/tool-base.cpp @@ -86,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) @@ -104,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) { } @@ -154,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(); @@ -208,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/dock-item.cpp b/src/ui/widget/dock-item.cpp index d268be785..60ea03fb7 100644 --- a/src/ui/widget/dock-item.cpp +++ b/src/ui/widget/dock-item.cpp @@ -21,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), @@ -70,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(); @@ -214,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 @@ -258,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(); |
