[dia] [gdk-deprecated] Create cursors from PNG/pixbufs
- From: Hans Breuer <hans src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [dia] [gdk-deprecated] Create cursors from PNG/pixbufs
- Date: Sun, 19 Aug 2012 17:36:55 +0000 (UTC)
commit 954be2f0e6229869e830f9d36081c25cb8b7c5e1
Author: Hans Breuer <hans breuer org>
Date: Mon Jul 30 18:36:29 2012 +0200
[gdk-deprecated] Create cursors from PNG/pixbufs
app/Makefile.am | 23 ++++++-----
app/cursor.c | 74 ++++++++++++------------------------
app/cursor.h | 3 -
app/makefile.msc | 8 +++-
app/pixmaps/cursor-create-data.xbm | 8 ----
app/pixmaps/cursor-create-mask.xbm | 8 ----
app/pixmaps/hand-closed-data.xbm | 9 ----
app/pixmaps/hand-closed-mask.xbm | 9 ----
app/pixmaps/hand-open-data.xbm | 9 ----
app/pixmaps/hand-open-mask.xbm | 9 ----
app/pixmaps/magnify-minus-data.xbm | 17 --------
app/pixmaps/magnify-minus-mask.xbm | 17 --------
app/pixmaps/magnify-plus-data.xbm | 17 --------
app/pixmaps/magnify-plus-mask.xbm | 17 --------
14 files changed, 43 insertions(+), 185 deletions(-)
---
diff --git a/app/Makefile.am b/app/Makefile.am
index 9ca4013..7a01993 100644
--- a/app/Makefile.am
+++ b/app/Makefile.am
@@ -50,6 +50,12 @@ ICON_PNG_PAIRS= \
dia_layers $(srcdir)/pixmaps/layers.png \
dia_layer_add $(srcdir)/pixmaps/layer-add.png \
dia_layer_rename $(srcdir)/pixmaps/layer-rename.png
+ \
+ dia_cursor_create $(srcdir)/pixmaps/cursor-create.png \
+ dia_cursor_hand_open $(srcdir)/pixmaps/cursor-hand-open.png \
+ dia_cursor_hand_closed $(srcdir)/pixmaps/cursor-hand-closed.png \
+ dia_cursor_magnify_minus $(srcdir)/pixmaps/cursor-magnify-minus.png \
+ dia_cursor_magnify_plus $(srcdir)/pixmaps/cursor-magnify-plus.png \
ICON_PNGS= \
@@ -61,7 +67,12 @@ ICON_PNGS= \
pixmaps/off-grid.png \
pixmaps/visible.png \
pixmaps/visible-empty.png \
- \
+ \
+ pixmaps/cursor-create.png \
+ pixmaps/cursor-hand-open.png \
+ pixmaps/cursor-hand-closed.png \
+ pixmaps/cursor-magnify-minus.png \
+ pixmaps/cursor-magnify-plus.png \
\
pixmaps/arrow-22.png \
pixmaps/scroll-22.png \
@@ -234,16 +245,6 @@ EXTRA_DIST = \
pixmaps/portrait.xpm \
pixmaps/landscape.xpm \
\
- pixmaps/cursor-create-data.xbm \
- pixmaps/cursor-create-mask.xbm \
- pixmaps/hand-open-data.xbm \
- pixmaps/hand-open-mask.xbm \
- pixmaps/hand-closed-data.xbm \
- pixmaps/hand-closed-mask.xbm \
- pixmaps/magnify-plus-data.xbm \
- pixmaps/magnify-plus-mask.xbm \
- pixmaps/magnify-minus-data.xbm \
- pixmaps/magnify-minus-mask.xbm \
\
pixmaps/missing.xpm \
pixmaps/n_a.xpm \
diff --git a/app/cursor.c b/app/cursor.c
index 90fb174..0423dd8 100644
--- a/app/cursor.c
+++ b/app/cursor.c
@@ -25,56 +25,34 @@
#include "display.h"
#include "cursor.h"
-#include "pixmaps/hand-open-data.xbm"
-#include "pixmaps/hand-open-mask.xbm"
-#include "pixmaps/hand-closed-data.xbm"
-#include "pixmaps/hand-closed-mask.xbm"
-#include "pixmaps/magnify-plus-data.xbm"
-#include "pixmaps/magnify-plus-mask.xbm"
-#include "pixmaps/magnify-minus-data.xbm"
-#include "pixmaps/magnify-minus-mask.xbm"
-#include "pixmaps/cursor-create-data.xbm"
-#include "pixmaps/cursor-create-mask.xbm"
+#include "dia-app-icons.h"
static struct {
/* Can't use a union because it can't be statically initialized
(except for the first element) */
int gdk_cursor_number;
- gchar *data;
- int width;
- int height;
- gchar *mask;
+ const gchar *data;
int hot_x;
int hot_y;
GdkCursor *cursor;
} cursors[MAX_CURSORS] = {
{ GDK_LEFT_PTR }, /* CURSOR_POINT */
{ DIA_CURSOR, /* CURSOR_CREATE */
- cursor_create_data_bits,
- cursor_create_data_width, cursor_create_data_height,
- cursor_create_mask_bits,
+ dia_cursor_create,
0, 0},
{ GDK_FLEUR }, /* CURSOR_SCROLL */
{ DIA_CURSOR, /* CURSOR_GRAB */
- hand_open_data_bits,
- hand_open_data_width, hand_open_data_height,
- hand_open_mask_bits,
- hand_open_data_width/2, hand_open_data_height/2},
+ dia_cursor_hand_open,
+ 10, 10 },
{ DIA_CURSOR, /* CURSOR_GRABBING */
- hand_closed_data_bits,
- hand_closed_data_width, hand_closed_data_height,
- hand_closed_mask_bits,
- hand_closed_data_width/2, hand_closed_data_height/2},
+ dia_cursor_hand_closed,
+ 10, 10 },
{ DIA_CURSOR, /* CURSOR_ZOOM_OUT */
- magnify_minus_data_bits,
- magnify_minus_data_width, magnify_minus_data_height,
- magnify_minus_mask_bits,
- magnify_minus_data_x_hot, magnify_minus_data_y_hot},
+ dia_cursor_magnify_minus,
+ 8, 8 },
{ DIA_CURSOR, /* CURSOR_ZOOM_IN */
- magnify_plus_data_bits,
- magnify_plus_data_width, magnify_plus_data_height,
- magnify_plus_mask_bits,
- magnify_plus_data_x_hot, magnify_plus_data_y_hot},
+ dia_cursor_magnify_plus,
+ 8, 8 },
{ GDK_CROSS_REVERSE }, /* CURSOR_CONNECT */
{ GDK_XTERM }, /* CURSOR_XTERM */
/* for safety reasons these should be last and must be in the same order HANDLE_RESIZE_* */
@@ -88,6 +66,11 @@ static struct {
{ GDK_BOTTOM_RIGHT_CORNER }, /* SW */
};
+
+static GdkCursor *create_cursor(GdkWindow *window,
+ const gchar *data,
+ int hot_x, int hot_y);
+
GdkCursor *
get_cursor(DiaCursorType ctype) {
if (ctype >= MAX_CURSORS || ctype < 0) {
@@ -103,9 +86,6 @@ get_cursor(DiaCursorType ctype) {
if (active_display != NULL)
new_cursor = create_cursor(gtk_widget_get_window(active_display->canvas),
cursors[ctype].data,
- cursors[ctype].width,
- cursors[ctype].height,
- cursors[ctype].mask,
cursors[ctype].hot_x,
cursors[ctype].hot_y);
}
@@ -117,28 +97,22 @@ get_cursor(DiaCursorType ctype) {
GdkCursor *
create_cursor(GdkWindow *window,
- const gchar *data, int width, int height,
- const gchar *mask, int hot_x, int hot_y)
+ const gchar *data,
+ int hot_x, int hot_y)
{
- GdkBitmap *dbit, *mbit;
- GdkColor black, white;
+ GdkPixbuf *pixbuf;
GdkCursor *cursor;
+ GdkDisplay *display;
g_return_val_if_fail(window != NULL, NULL);
+ display = gdk_drawable_get_display (GDK_DRAWABLE (window));
- dbit = gdk_bitmap_create_from_data(window, data, width, height);
- mbit = gdk_bitmap_create_from_data(window, mask, width, height);
- g_assert(dbit != NULL && mbit != NULL);
-
- /* For some odd reason, black and white is inverted */
- gdk_color_black(gdk_window_get_colormap(window), &white);
- gdk_color_white(gdk_window_get_colormap(window), &black);
+ pixbuf = gdk_pixbuf_new_from_inline(-1, data, FALSE, NULL);
- cursor = gdk_cursor_new_from_pixmap(dbit, mbit, &white, &black, hot_x,hot_y);
+ cursor = gdk_cursor_new_from_pixbuf (display, pixbuf, hot_x,hot_y);
g_assert(cursor != NULL);
- g_object_unref(dbit);
- g_object_unref(mbit);
+ g_object_unref(pixbuf);
return cursor;
}
diff --git a/app/cursor.h b/app/cursor.h
index 0cf4e0d..2b185cf 100644
--- a/app/cursor.h
+++ b/app/cursor.h
@@ -37,6 +37,3 @@ typedef enum {
/* Preferred way to get a cursor */
GdkCursor *get_cursor(DiaCursorType ctype);
-GdkCursor *create_cursor(GdkWindow *window,
- const gchar *data, int width, int height,
- const gchar *mask, int hot_x, int hot_y);
diff --git a/app/makefile.msc b/app/makefile.msc
index 1cad410..a0569b6 100644
--- a/app/makefile.msc
+++ b/app/makefile.msc
@@ -103,7 +103,13 @@ ICON_PNG_PAIRS = \
dia_objects_layer_below pixmaps\objects-layer-below.png \
dia_layers pixmaps\layers.png \
dia_layer_add pixmaps\layer-add.png \
- dia_layer_rename pixmaps\layer-rename.png
+ dia_layer_rename pixmaps\layer-rename.png \
+ \
+ dia_cursor_create pixmaps\cursor-create.png \
+ dia_cursor_hand_open pixmaps\cursor-hand-open.png \
+ dia_cursor_hand_closed pixmaps\cursor-hand-closed.png \
+ dia_cursor_magnify_minus pixmaps\cursor-magnify-minus.png \
+ dia_cursor_magnify_plus pixmaps\cursor-magnify-plus.png \
dia-app-icons.h : makefile.msc pixmaps\*.png
gdk-pixbuf-csource --build-list \
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]