diff --git a/app/sanity.c b/app/sanity.c index a2b6d80feb..2c7049cd0f 100644 --- a/app/sanity.c +++ b/app/sanity.c @@ -325,8 +325,8 @@ static gchar * sanity_check_gdk_pixbuf (void) { #define GDK_PIXBUF_REQUIRED_MAJOR 2 -#define GDK_PIXBUF_REQUIRED_MINOR 24 -#define GDK_PIXBUF_REQUIRED_MICRO 1 +#define GDK_PIXBUF_REQUIRED_MINOR 30 +#define GDK_PIXBUF_REQUIRED_MICRO 8 if (! sanity_check_version (gdk_pixbuf_major_version, GDK_PIXBUF_REQUIRED_MAJOR, gdk_pixbuf_minor_version, GDK_PIXBUF_REQUIRED_MINOR, diff --git a/app/widgets/gimpcursor.c b/app/widgets/gimpcursor.c index cf9936fef1..192af60ab9 100644 --- a/app/widgets/gimpcursor.c +++ b/app/widgets/gimpcursor.c @@ -23,7 +23,7 @@ #include "gimpcursor.h" -#include "cursors/gimp-tool-cursors.h" +#include "cursors/gimp-tool-cursors.c" #define cursor_default_x_hot 10 @@ -43,10 +43,10 @@ typedef struct _GimpCursor GimpCursor; struct _GimpCursor { - const guint8 *pixbuf_data; - const gint x_hot, y_hot; + const gchar *resource_name; + const gint x_hot, y_hot; - GdkPixbuf *pixbuf; + GdkPixbuf *pixbuf; }; @@ -55,99 +55,99 @@ static GimpCursor gimp_cursors[] = /* these have to match up with enum GimpCursorType in widgets-enums.h */ { - cursor_none, + "cursor-none.png", cursor_default_x_hot, cursor_default_y_hot }, { - cursor_mouse, + "cursor-mouse.png", cursor_mouse_x_hot, cursor_mouse_y_hot }, { - cursor_crosshair, + "cursor-crosshair.png", cursor_crosshair_x_hot, cursor_crosshair_y_hot }, { - cursor_crosshair_small, + "cursor-crosshair-small.png", cursor_default_x_hot, cursor_default_y_hot }, { - cursor_bad, + "cursor-bad.png", cursor_default_x_hot, cursor_default_y_hot }, { - cursor_move, + "cursor-move.png", cursor_default_x_hot, cursor_default_y_hot }, { - cursor_zoom, + "cursor-zoom.png", cursor_zoom_x_hot, cursor_zoom_y_hot }, { - cursor_color_picker, + "cursor-color-picker.png", cursor_color_picker_x_hot, cursor_color_picker_y_hot }, { - cursor_corner_top, + "cursor-corner-top.png", cursor_default_x_hot, cursor_default_y_hot }, { - cursor_corner_top_right, + "cursor-corner-top-right.png", cursor_default_x_hot, cursor_default_y_hot }, { - cursor_corner_right, + "cursor-corner-right.png", cursor_default_x_hot, cursor_default_y_hot }, { - cursor_corner_bottom_right, + "cursor-corner-bottom-right.png", cursor_default_x_hot, cursor_default_y_hot }, { - cursor_corner_bottom, + "cursor-corner-bottom.png", cursor_default_x_hot, cursor_default_y_hot }, { - cursor_corner_bottom_left, + "cursor-corner-bottom-left.png", cursor_default_x_hot, cursor_default_y_hot }, { - cursor_corner_left, + "cursor-corner-left.png", cursor_default_x_hot, cursor_default_y_hot }, { - cursor_corner_top_left, + "cursor-corner-top-left.png", cursor_default_x_hot, cursor_default_y_hot }, { - cursor_side_top, + "cursor-sid-_top.png", cursor_default_x_hot, cursor_default_y_hot }, { - cursor_side_top_right, + "cursor-side-top-right.png", cursor_default_x_hot, cursor_default_y_hot }, { - cursor_side_right, + "cursor-side-right.png", cursor_default_x_hot, cursor_default_y_hot }, { - cursor_side_bottom_right, + "cursor-side-bottom-right.png", cursor_default_x_hot, cursor_default_y_hot }, { - cursor_side_bottom, + "cursor-side-bottom.png", cursor_default_x_hot, cursor_default_y_hot }, { - cursor_side_bottom_left, + "cursor-side-bottom-left.png", cursor_default_x_hot, cursor_default_y_hot }, { - cursor_side_left, + "cursor-side-left.png", cursor_default_x_hot, cursor_default_y_hot }, { - cursor_side_top_left, + "cursor-side-top-left.png", cursor_default_x_hot, cursor_default_y_hot } }; @@ -157,42 +157,42 @@ static GimpCursor gimp_tool_cursors[] = /* these have to match up with enum GimpToolCursorType in widgets-enums.h */ { NULL }, - { tool_rect_select }, - { tool_ellipse_select }, - { tool_free_select }, - { tool_polygon_select }, - { tool_fuzzy_select }, - { tool_paths }, - { tool_paths_anchor }, - { tool_paths_control }, - { tool_paths_segment }, - { tool_iscissors }, - { tool_move }, - { tool_zoom }, - { tool_crop }, - { tool_resize }, - { tool_rotate }, - { tool_shear }, - { tool_perspective }, - { tool_flip_horizontal }, - { tool_flip_vertical }, - { tool_text }, - { tool_color_picker }, - { tool_bucket_fill }, - { tool_blend }, - { tool_pencil }, - { tool_paintbrush }, - { tool_airbrush }, - { tool_ink }, - { tool_clone }, - { tool_heal }, - { tool_eraser }, - { tool_smudge }, - { tool_blur }, - { tool_dodge }, - { tool_burn }, - { tool_measure }, - { tool_hand } + { "tool-rect-select.png" }, + { "tool-ellipse-select.png" }, + { "tool-free-select.png" }, + { "tool-polygon-select.png" }, + { "tool-fuzzy-select.png" }, + { "tool-paths.png" }, + { "tool-paths-anchor.png" }, + { "tool-paths-control.png" }, + { "tool-paths-segment.png" }, + { "tool-iscissors.png" }, + { "tool-move.png" }, + { "tool-zoom.png" }, + { "tool-crop.png" }, + { "tool-resize.png" }, + { "tool-rotate.png" }, + { "tool-shear.png" }, + { "tool-perspective.png" }, + { "tool-flip-horizontal.png" }, + { "tool-flip-vertical.png" }, + { "tool-text.png" }, + { "tool-color-picker.png" }, + { "tool-bucket-fill.png" }, + { "tool-blend.png" }, + { "tool-pencil.png" }, + { "tool-paintbrush.png" }, + { "tool-airbrush.png" }, + { "tool-ink.png" }, + { "tool-clone.png" }, + { "tool-heal.png" }, + { "tool-eraser.png" }, + { "tool-smudge.png" }, + { "tool-blur.png" }, + { "tool-dodge.png" }, + { "tool-burn.png" }, + { "tool-measure.png" }, + { "tool-hand.png" } }; static GimpCursor gimp_cursor_modifiers[] = @@ -200,19 +200,19 @@ static GimpCursor gimp_cursor_modifiers[] = /* these have to match up with enum GimpCursorModifier in widgets-enums.h */ { NULL }, - { modifier_bad }, - { modifier_plus }, - { modifier_minus }, - { modifier_intersect }, - { modifier_move }, - { modifier_resize }, - { modifier_control }, - { modifier_anchor }, - { modifier_foreground }, - { modifier_background }, - { modifier_pattern }, - { modifier_join }, - { modifier_select } + { "modifier-bad.png" }, + { "modifier-plus.png" }, + { "modifier-minus.png" }, + { "modifier-intersect.png" }, + { "modifier-move.png" }, + { "modifier-resize.png" }, + { "modifier-control.png" }, + { "modifier-anchor.png" }, + { "modifier-foreground.png" }, + { "modifier-background.png" }, + { "modifier-pattern.png" }, + { "modifier-join.png" }, + { "modifier-select.png" } }; @@ -220,10 +220,23 @@ static const GdkPixbuf * get_cursor_pixbuf (GimpCursor *cursor) { if (! cursor->pixbuf) - cursor->pixbuf = gdk_pixbuf_new_from_inline (-1, - cursor->pixbuf_data, - FALSE, NULL); - g_return_val_if_fail (cursor->pixbuf != NULL, NULL); + { + gchar *resource_path; + GError *error = NULL; + + resource_path = g_strconcat ("/org/gimp/tool-cursors/", + cursor->resource_name, NULL); + + cursor->pixbuf = gdk_pixbuf_new_from_resource (resource_path, &error); + + if (! cursor->pixbuf) + { + g_critical ("Failed to create cursor image: %s", error->message); + g_clear_error (&error); + } + + g_free (resource_path); + } return cursor->pixbuf; } diff --git a/configure.ac b/configure.ac index 1f5b7e38fd..adab1757fc 100644 --- a/configure.ac +++ b/configure.ac @@ -48,7 +48,7 @@ m4_define([gegl_required_version], [0.3.0]) m4_define([glib_required_version], [2.40.0]) m4_define([atk_required_version], [2.2.0]) m4_define([gtk_required_version], [2.24.10]) -m4_define([gdk_pixbuf_required_version], [2.24.1]) +m4_define([gdk_pixbuf_required_version], [2.30.8]) m4_define([cairo_required_version], [1.12.2]) m4_define([cairo_pdf_required_version], [1.12.2]) m4_define([pangocairo_required_version], [1.29.4]) @@ -589,6 +589,11 @@ else PKG_CHECK_MODULES(GIO_UNIX, gio-unix-2.0) fi +AC_PATH_PROG(GLIB_COMPILE_RESOURCES, glib-compile-resources, no) +if test "x$GLIB_COMPILE_RESOURCES" = xno; then + AC_MSG_ERROR(Could not find glib-compile-resources in your PATH) +fi + AC_PATH_PROG(GDBUS_CODEGEN, gdbus-codegen, no) if test "x$GDBUS_CODEGEN" = xno; then AC_MSG_ERROR([Could not find gdbus-codegen in your PATH]) diff --git a/cursors/.gitignore b/cursors/.gitignore index 8b2ce5afaa..7cdea3a30d 100644 --- a/cursors/.gitignore +++ b/cursors/.gitignore @@ -2,7 +2,7 @@ /Makefile.in /.xvpics /.thumbnails -/color-picker-cursors.list -/tool-cursors.list -/gimp-color-picker-cursors.h -/gimp-tool-cursors.h +/gimp-color-picker-cursors.c +/gimp-color-picker-cursors.gresource.xml +/gimp-tool-cursors.c +/gimp-tool-cursors.gresource.xml diff --git a/cursors/Makefile.am b/cursors/Makefile.am index 634ab4a830..95ce459648 100644 --- a/cursors/Makefile.am +++ b/cursors/Makefile.am @@ -85,33 +85,45 @@ EXTRA_DIST = \ gimp-tool-cursors.xcf noinst_DATA = \ - gimp-tool-cursors.h \ - gimp-color-picker-cursors.h + gimp-tool-cursors.c \ + gimp-color-picker-cursors.c CLEANFILES = \ - gimp-tool-cursors.h \ - tool-cursors.list \ - gimp-color-picker-cursors.h \ - color-picker-cursors.list + gimp-tool-cursors.c \ + gimp-tool-cursors.gresource.xml \ + gimp-color-picker-cursors.c \ + gimp-color-picker-cursors.gresource.xml -tool-cursors.list: $(CURSOR_IMAGES) Makefile.am + +gimp-tool-cursors.gresource.xml: $(CURSOR_IMAGES) Makefile.am $(AM_V_GEN) ( rm -f $@; \ + echo '' > $@; \ + echo '' >> $@; \ + echo ' ' >> $@; \ for image in $(CURSOR_IMAGES); do \ - echo $$image | \ - sed -e 's|.*/||' -e 's|-|_|g' -e 's|\.png$$||' >> $@; \ - echo " $(srcdir)/$$image" >> $@; \ - done ) + echo " $$image" >> $@; \ + done; \ + echo ' ' >> $@; \ + echo '' >> $@ ) -color-picker-cursors.list: $(COLOR_PICKER_IMAGES) Makefile.am +gimp-tool-cursors.c: gimp-tool-cursors.gresource.xml + $(AM_V_GEN) $(GLIB_COMPILE_RESOURCES) \ + --sourcedir=$(srcdir) --generate-source \ + --target=$@ gimp-tool-cursors.gresource.xml + + +gimp-color-picker-cursors.gresource.xml: $(CURSOR_IMAGES) Makefile.am $(AM_V_GEN) ( rm -f $@; \ - for image in $(COLOR_PICKER_IMAGES); do \ - echo $$image | \ - sed -e 's|.*/||' -e 's|-|_|g' -e 's|\.png$$||' >> $@; \ - echo " $(srcdir)/$$image" >> $@; \ - done ) + echo '' > $@; \ + echo '' >> $@; \ + echo ' ' >> $@; \ + for image in $(CURSOR_IMAGES); do \ + echo " $$image" >> $@; \ + done; \ + echo ' ' >> $@; \ + echo '' >> $@ ) -$(srcdir)/gimp-tool-cursors.h: tool-cursors.list - $(AM_V_GEN) $(GDK_PIXBUF_CSOURCE) --raw --build-list `cat tool-cursors.list` > $(@F) - -$(srcdir)/gimp-color-picker-cursors.h: color-picker-cursors.list - $(AM_V_GEN) $(GDK_PIXBUF_CSOURCE) --raw --build-list `cat color-picker-cursors.list` > $(@F) +gimp-color-picker-cursors.c: gimp-color-picker-cursors.gresource.xml + $(AM_V_GEN) $(GLIB_COMPILE_RESOURCES) \ + --sourcedir=$(srcdir) --generate-source \ + --target=$@ gimp-color-picker-cursors.gresource.xml diff --git a/libgimpwidgets/gimppickbutton.c b/libgimpwidgets/gimppickbutton.c index 7a47c2eceb..2cfea92c1b 100644 --- a/libgimpwidgets/gimppickbutton.c +++ b/libgimpwidgets/gimppickbutton.c @@ -31,7 +31,7 @@ #include "gimppickbutton.h" #include "gimpstock.h" -#include "cursors/gimp-color-picker-cursors.h" +#include "cursors/gimp-color-picker-cursors.c" #include "libgimp/libgimp-intl.h" @@ -175,16 +175,27 @@ gimp_pick_button_new (void) static GdkCursor * make_cursor (GdkDisplay *display) { - GdkCursor *cursor; - GdkPixbuf *pixbuf; + GdkPixbuf *pixbuf; + GError *error = NULL; - pixbuf = gdk_pixbuf_new_from_inline (-1, cursor_color_picker, FALSE, NULL); + pixbuf = gdk_pixbuf_new_from_resource ("/org/gimp/color-picker-cursors/cursor-color-picker.png", + &error); - cursor = gdk_cursor_new_from_pixbuf (display, pixbuf, 1, 30); + if (pixbuf) + { + GdkCursor *cursor = gdk_cursor_new_from_pixbuf (display, pixbuf, 1, 30); - g_object_unref (pixbuf); + g_object_unref (pixbuf); - return cursor; + return cursor; + } + else + { + g_critical ("Failed to create cursor image: %s", error->message); + g_clear_error (&error); + } + + return NULL; } static void diff --git a/libgimpwidgets/gimpwidgets.def b/libgimpwidgets/gimpwidgets.def index a43394696c..d8c7e11420 100644 --- a/libgimpwidgets/gimpwidgets.def +++ b/libgimpwidgets/gimpwidgets.def @@ -72,6 +72,7 @@ EXPORTS gimp_color_hex_entry_set_color gimp_color_notebook_get_type gimp_color_notebook_set_has_page + gimp_color_picker_cursors_get_resource gimp_color_profile_chooser_dialog_get_type gimp_color_profile_chooser_dialog_new gimp_color_profile_combo_box_add