From dd7c11af6233329e7f0a05947167dfd8debc3dea Mon Sep 17 00:00:00 2001 From: Jim Evins Date: Sun, 3 Oct 2010 22:24:28 -0400 Subject: [PATCH] Initial port to GTK3. Still has update and drawing problems with view.c. --- configure.ac | 16 ++++---- src/Makefile.am | 2 +- src/color-swatch.c | 36 +++++------------ src/cursors/Makefile.am | 26 ++++++++++++ src/cursors/cursor_barcode.png | Bin 0 -> 198 bytes src/cursors/cursor_box.png | Bin 0 -> 200 bytes src/cursors/cursor_ellipse.png | Bin 0 -> 243 bytes src/cursors/cursor_image.png | Bin 0 -> 247 bytes src/cursors/cursor_line.png | Bin 0 -> 198 bytes src/cursors/cursor_text.png | Bin 0 -> 210 bytes src/font-sample.c | 36 +++++------------ src/media-select.c | 4 +- src/merge-properties-dialog.c | 1 - src/mini-label-preview.c | 37 +++++------------ src/mini-preview.c | 42 +++++-------------- src/prefs-dialog.c | 1 - src/view-barcode.c | 27 +++++-------- src/view-box.c | 27 +++++-------- src/view-ellipse.c | 27 +++++-------- src/view-image.c | 27 +++++-------- src/view-line.c | 27 +++++-------- src/view-text.c | 26 +++++------- src/view.c | 72 ++++++++++++++------------------- src/wdgt-chain-button.c | 4 ++ src/window.c | 18 ++++----- 25 files changed, 177 insertions(+), 279 deletions(-) create mode 100644 src/cursors/Makefile.am create mode 100644 src/cursors/cursor_barcode.png create mode 100644 src/cursors/cursor_box.png create mode 100644 src/cursors/cursor_ellipse.png create mode 100644 src/cursors/cursor_image.png create mode 100644 src/cursors/cursor_line.png create mode 100644 src/cursors/cursor_text.png diff --git a/configure.ac b/configure.ac index 645fd2f6..2a595204 100644 --- a/configure.ac +++ b/configure.ac @@ -30,6 +30,7 @@ AC_PROG_INSTALL GNOME_COMPILE_WARNINGS AC_PATH_PROG(GLIB_GENMARSHAL, glib-genmarshal) +AC_PATH_PROG(GDK_PIXBUF_CSOURCE, gdk-pixbuf-csource) AC_PATH_PROG(UPDATE_MIME_DATABASE, update-mime-database) AC_PATH_PROG(UPDATE_DESKTOP_DATABASE, update-desktop-database) AC_PATH_PROG(GTK_UPDATE_ICON_CACHE, gtk-update-icon-cache) @@ -72,13 +73,13 @@ dnl --------------------------------------------------------------------------- dnl - Library dependencies dnl --------------------------------------------------------------------------- dnl Required dependencies -GLIB_REQUIRED=2.25.11 -GTK_REQUIRED=2.20.0 -LIBXML_REQUIRED=2.7.0 -LIBRSVG_REQUIRED=2.26.0 +GLIB_REQUIRED=2.27.1 +GTK_REQUIRED=2.91.1 +LIBXML_REQUIRED=2.7.7 +LIBRSVG_REQUIRED=2.26.3 dnl Optional dependencies -LIBEBOOK_REQUIRED=2.28.0 +LIBEBOOK_REQUIRED=2.30.3 LIBBARCODE_REQUIRED=0.98 LIBQRENCODE_REQUIRED=3.1.0 LIBIEC16022_REQUIRED=0.2.4 @@ -100,9 +101,9 @@ dnl - GLABELS prerequisites dnl --------------------------------------------------------------------------- PKG_CHECK_MODULES(GLABELS, [\ glib-2.0 >= $GLIB_REQUIRED \ - gtk+-2.0 >= $GTK_REQUIRED \ + gtk+-3.0 >= $GTK_REQUIRED \ libxml-2.0 >= $LIBXML_REQUIRED \ - librsvg-2.0 > $LIBRSVG_REQUIRED \ + librsvg-2.0 >= $LIBRSVG_REQUIRED \ ]) AC_SUBST(GLABELS_CFLAGS) @@ -270,6 +271,7 @@ Makefile libglabels/Makefile libglabels/${LIBGLABELS_BRANCH}.pc src/Makefile +src/cursors/Makefile src/pixmaps/Makefile data/Makefile data/desktop/Makefile diff --git a/src/Makefile.am b/src/Makefile.am index aac2b7ef..4c464dee 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -1,5 +1,5 @@ -SUBDIRS= ../libglabels pixmaps +SUBDIRS= ../libglabels pixmaps cursors bin_PROGRAMS = glabels-3 glabels-3-batch diff --git a/src/color-swatch.c b/src/color-swatch.c index 19f4ed69..b36fdc29 100644 --- a/src/color-swatch.c +++ b/src/color-swatch.c @@ -58,8 +58,8 @@ static void style_set_cb (GtkWidget *widget, static void redraw (glColorSwatch *this); -static gboolean expose_event_cb (GtkWidget *widget, - GdkEventExpose *event); +static gboolean draw_cb (GtkWidget *widget, + cairo_t *cr); static void draw_swatch (glColorSwatch *this, cairo_t *cr); @@ -85,8 +85,8 @@ gl_color_swatch_class_init (glColorSwatchClass *class) gobject_class->finalize = gl_color_swatch_finalize; - widget_class->expose_event = expose_event_cb; widget_class->style_set = style_set_cb; + widget_class->draw = draw_cb; } @@ -172,17 +172,15 @@ style_set_cb (GtkWidget *widget, static void redraw (glColorSwatch *this) { - GdkWindow *window; - GdkRegion *region; + GdkWindow *window; + GtkAllocation allocation; window = gtk_widget_get_window (GTK_WIDGET (this)); if (window) { - /* redraw the cairo canvas forcing an expose event */ - region = gdk_drawable_get_clip_region (window); - gdk_window_invalidate_region (window, region, TRUE); - gdk_region_destroy (region); + gtk_widget_get_allocation (GTK_WIDGET (this), &allocation); + gdk_window_invalidate_rect (window, &allocation, FALSE); } } @@ -191,29 +189,13 @@ redraw (glColorSwatch *this) /* "Expose event" callback. */ /*****************************************************************************/ static gboolean -expose_event_cb (GtkWidget *widget, - GdkEventExpose *event) +draw_cb (GtkWidget *widget, + cairo_t *cr) { - GdkWindow *window; - cairo_t *cr; GtkAllocation allocation; - window = gtk_widget_get_window (widget); - - cr = gdk_cairo_create (window); - - cairo_rectangle (cr, - event->area.x, event->area.y, - event->area.width, event->area.height); - cairo_clip (cr); - - gtk_widget_get_allocation (widget, &allocation); - cairo_translate (cr, allocation.x, allocation.y); - draw_swatch (GL_COLOR_SWATCH (widget), cr); - cairo_destroy (cr); - return FALSE; } diff --git a/src/cursors/Makefile.am b/src/cursors/Makefile.am new file mode 100644 index 00000000..6a01d8e6 --- /dev/null +++ b/src/cursors/Makefile.am @@ -0,0 +1,26 @@ + +CURSOR_IMAGES = \ + cursor_barcode.png \ + cursor_box.png \ + cursor_ellipse.png \ + cursor_image.png \ + cursor_line.png \ + cursor_text.png + +VARIABLES1 = \ + cursor_barcode_pixdata $(srcdir)/cursor_barcode.png \ + cursor_box_pixdata $(srcdir)/cursor_box.png \ + cursor_ellipse_pixdata $(srcdir)/cursor_ellipse.png \ + cursor_image_pixdata $(srcdir)/cursor_image.png \ + cursor_line_pixdata $(srcdir)/cursor_line.png \ + cursor_text_pixdata $(srcdir)/cursor_text.png + +noinst_DATA = cursor_pixdata.h +CLEANFILES = $(noinst_DATA) + +cursor_pixdata.h: $(CURSOR_IMAGES) + $(AM_V_GEN) $(GDK_PIXBUF_CSOURCE) \ + --struct --build-list $(VARIABLES1) > $(srcdir)/cursor_pixdata.h || \ + ( rm -f $(srcdir)/cursor_pixdata.h && false ) + +EXTRA_DIST = $(CURSOR_IMAGES) cursor_pixdata.h diff --git a/src/cursors/cursor_barcode.png b/src/cursors/cursor_barcode.png new file mode 100644 index 0000000000000000000000000000000000000000..59ba92859bb03261d42b140851d2684fd5c8af57 GIT binary patch literal 198 zcmeAS@N?(olHy`uVBq!ia0vp^3LwnE1|*BCs=fdz#^NA%Cx&(BWL^R}Y)RhkE)4%c zaKYZ?lYt_f1s;*b3=G`DAk4@xYmNj^kiEpy*OmPi7c&#DSZbH;6`+utr;B4q#NoG> z4Y?Q$I9MFN{;xO74T|uzIJno%bF$!-oQhB1*%!_eU|`74*zopr0GjPN00000 literal 0 HcmV?d00001 diff --git a/src/cursors/cursor_box.png b/src/cursors/cursor_box.png new file mode 100644 index 0000000000000000000000000000000000000000..c30c0d494e6f15c61153f5cdee7464820e37afcd GIT binary patch literal 200 zcmeAS@N?(olHy`uVBq!ia0vp^3LwnE1|*BCs=fdz#^NA%Cx&(BWL^R}Y)RhkE)4%c zaKYZ?lYt_f1s;*b3=G`DAk4@xYmNj^kiEpy*OmPi7c-N9NXZL>CqN+&PZ!6Kh{JEM zHVQHb@Hk&QcC-Ge1k>~)d+rKd%h0orZ?pG&X<=ZQkHQU{XPf8( kH8V7rH3Zi;&cEwm!|i^J&1{=NJ;<#Lp00i_>zopr09-9P+5i9m literal 0 HcmV?d00001 diff --git a/src/cursors/cursor_ellipse.png b/src/cursors/cursor_ellipse.png new file mode 100644 index 0000000000000000000000000000000000000000..40924af40c5803f28a29464dd3f815d7a4fd02d1 GIT binary patch literal 243 zcmeAS@N?(olHy`uVBq!ia0vp^3LwnE1|*BCs=fdz#^NA%Cx&(BWL^R}Y)RhkE)4%c zaKYZ?lYt_f1s;*b3=G`DAk4@xYmNj^kiEpy*OmPi7c-Nf@rj>X&H;srJzX3_A`ZU| zbL2aqz@v5SfBnq6)6X7eTdVeT#kPc_Sx25Nn4J*vego?khCcH=`Mv4thJ3=|6fU&ussz`=6x!+(AM`4^UPXNmMl91=>qnDcqTu7eS_iQE~CdKcd19u}J*xN!zI|3zD) z2gzHnrWrY0`z4Sa5b0E*%$yeYDP(sizhxTNgLG!2m6oF1)@O1TaS?83{1OO*JREhuq literal 0 HcmV?d00001 diff --git a/src/cursors/cursor_line.png b/src/cursors/cursor_line.png new file mode 100644 index 0000000000000000000000000000000000000000..31d8c6e0ae1c7b2509e51e15e77abe5eff290e4f GIT binary patch literal 198 zcmeAS@N?(olHy`uVBq!ia0vp^3LwnE1|*BCs=fdz#^NA%Cx&(BWL^R}Y)RhkE)4%c zaKYZ?lYt_f1s;*b3=G`DAk4@xYmNj^kiEpy*OmPi7c-Lx*Q@Rm%|IbHPZ!6Kh{JC$ zALIp^?;M!$f9`80HMxLS56c_FnOth*_OhL_RbNLFNZ}x;TbJ9DY0P zATQ8-=9RzS_i#%jH;Kw$XRQjDCGc_QrCftu>MRTlqU&O>2rw|@UAu5sz|wp{YolMg u^fTU5k_YvKE;0cPdhj)RYOKDrQ>yP2S2n|)-*QWVf()LnelF{r5}E+BNIuH| literal 0 HcmV?d00001 diff --git a/src/font-sample.c b/src/font-sample.c index ea1f5b7a..fbda8230 100644 --- a/src/font-sample.c +++ b/src/font-sample.c @@ -61,8 +61,8 @@ static void style_set_cb (GtkWidget *widget, static void redraw (glFontSample *this); -static gboolean expose_event_cb (GtkWidget *widget, - GdkEventExpose *event); +static gboolean draw_cb (GtkWidget *widget, + cairo_t *cr); static void draw_sample (glFontSample *this, cairo_t *cr); @@ -88,8 +88,8 @@ gl_font_sample_class_init (glFontSampleClass *class) gobject_class->finalize = gl_font_sample_finalize; - widget_class->expose_event = expose_event_cb; widget_class->style_set = style_set_cb; + widget_class->draw = draw_cb; } @@ -163,17 +163,15 @@ style_set_cb (GtkWidget *widget, static void redraw (glFontSample *this) { - GdkWindow *window; - GdkRegion *region; + GdkWindow *window; + GtkAllocation allocation; window = gtk_widget_get_window (GTK_WIDGET (this)); if (window) { - /* redraw the cairo canvas forcing an expose event */ - region = gdk_drawable_get_clip_region (window); - gdk_window_invalidate_region (window, region, TRUE); - gdk_region_destroy (region); + gtk_widget_get_allocation (GTK_WIDGET (this), &allocation); + gdk_window_invalidate_rect (window, &allocation, FALSE); } } @@ -182,29 +180,13 @@ redraw (glFontSample *this) /* "Expose event" callback. */ /*****************************************************************************/ static gboolean -expose_event_cb (GtkWidget *widget, - GdkEventExpose *event) +draw_cb (GtkWidget *widget, + cairo_t *cr) { - GdkWindow *window; - cairo_t *cr; GtkAllocation allocation; - window = gtk_widget_get_window (widget); - - cr = gdk_cairo_create (window); - - cairo_rectangle (cr, - event->area.x, event->area.y, - event->area.width, event->area.height); - cairo_clip (cr); - - gtk_widget_get_allocation (widget, &allocation); - cairo_translate (cr, allocation.x, allocation.y); - draw_sample (GL_FONT_SAMPLE (widget), cr); - cairo_destroy (cr); - return FALSE; } diff --git a/src/media-select.c b/src/media-select.c index e6f1c534..4391d3c0 100644 --- a/src/media-select.c +++ b/src/media-select.c @@ -132,7 +132,7 @@ static void custom_delete_clicked_cb (GtkButton *button, gpointer user_data); static void page_changed_cb (GtkNotebook *notebook, - GtkNotebookPage *page, + GtkWidget *page, guint page_num, gpointer user_data); @@ -648,7 +648,7 @@ custom_delete_clicked_cb (GtkButton *button, /*--------------------------------------------------------------------------*/ static void page_changed_cb (GtkNotebook *notebook, - GtkNotebookPage *page, + GtkWidget *page, guint page_num, gpointer user_data) { diff --git a/src/merge-properties-dialog.c b/src/merge-properties-dialog.c index bce6508f..e6f3d69c 100644 --- a/src/merge-properties-dialog.c +++ b/src/merge-properties-dialog.c @@ -154,7 +154,6 @@ gl_merge_properties_dialog_init (glMergePropertiesDialog *dialog) vbox = gtk_dialog_get_content_area (GTK_DIALOG (dialog)); - gtk_dialog_set_has_separator (GTK_DIALOG(dialog), FALSE); gtk_dialog_add_button (GTK_DIALOG (dialog), GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL); dialog->priv->ok_button = gtk_dialog_add_button (GTK_DIALOG (dialog), diff --git a/src/mini-label-preview.c b/src/mini-label-preview.c index d1f06c7e..ad7565e8 100644 --- a/src/mini-label-preview.c +++ b/src/mini-label-preview.c @@ -63,8 +63,8 @@ static void style_set_cb (GtkWidget *widget, static void redraw (glMiniLabelPreview *this); -static gboolean expose_event_cb (GtkWidget *widget, - GdkEventExpose *event); +static gboolean draw_cb (GtkWidget *widget, + cairo_t *cr); static void draw_preview (glMiniLabelPreview *this, cairo_t *cr); @@ -89,8 +89,8 @@ gl_mini_label_preview_class_init (glMiniLabelPreviewClass *class) gobject_class->finalize = gl_mini_label_preview_finalize; - widget_class->expose_event = expose_event_cb; widget_class->style_set = style_set_cb; + widget_class->draw = draw_cb; } @@ -181,17 +181,15 @@ style_set_cb (GtkWidget *widget, static void redraw (glMiniLabelPreview *this) { - GdkWindow *window; - GdkRegion *region; + GdkWindow *window; + GtkAllocation allocation; window = gtk_widget_get_window (GTK_WIDGET (this)); if (window) { - /* redraw the cairo canvas forcing an expose event */ - region = gdk_drawable_get_clip_region (window); - gdk_window_invalidate_region (window, region, TRUE); - gdk_region_destroy (region); + gtk_widget_get_allocation (GTK_WIDGET (this), &allocation); + gdk_window_invalidate_rect (window, &allocation, FALSE); } } @@ -200,29 +198,12 @@ redraw (glMiniLabelPreview *this) /* "Expose event" callback. */ /*****************************************************************************/ static gboolean -expose_event_cb (GtkWidget *widget, - GdkEventExpose *event) +draw_cb (GtkWidget *widget, + cairo_t *cr) { - GdkWindow *window; - cairo_t *cr; - GtkAllocation allocation; - - window = gtk_widget_get_window (widget); - - cr = gdk_cairo_create (window); - - cairo_rectangle (cr, - event->area.x, event->area.y, - event->area.width, event->area.height); - cairo_clip (cr); - - gtk_widget_get_allocation (widget, &allocation); - cairo_translate (cr, allocation.x, allocation.y); draw_preview (GL_MINI_LABEL_PREVIEW (widget), cr); - cairo_destroy (cr); - return FALSE; } diff --git a/src/mini-preview.c b/src/mini-preview.c index 11741046..3ea0956d 100644 --- a/src/mini-preview.c +++ b/src/mini-preview.c @@ -120,8 +120,8 @@ static gboolean button_release_event_cb (GtkWidget *widget, GdkEventButton *event); -static gboolean expose_event_cb (GtkWidget *widget, - GdkEventExpose *event, +static gboolean draw_cb (GtkWidget *widget, + cairo_t *cr, glMiniPreview *this); static void style_set_cb (GtkWidget *widget, GtkStyle *previous_style, @@ -237,8 +237,8 @@ gl_mini_preview_init (glMiniPreview *this) gtk_widget_set_has_window(this->priv->canvas, FALSE); gtk_container_add (GTK_CONTAINER (this), this->priv->canvas); - g_signal_connect (G_OBJECT (this->priv->canvas), "expose-event", - G_CALLBACK (expose_event_cb), this); + g_signal_connect (G_OBJECT (this->priv->canvas), "draw", + G_CALLBACK (draw_cb), this); g_signal_connect (G_OBJECT (this->priv->canvas), "style-set", G_CALLBACK (style_set_cb), this); @@ -788,34 +788,15 @@ find_closest_label (glMiniPreview *this, /* Expose event handler. */ /*--------------------------------------------------------------------------*/ static gboolean -expose_event_cb (GtkWidget *widget, - GdkEventExpose *event, - glMiniPreview *this) +draw_cb (GtkWidget *widget, + cairo_t *cr, + glMiniPreview *this) { - GdkWindow *window; - cairo_t *cr; - GtkAllocation allocation; - gl_debug (DEBUG_MINI_PREVIEW, "START"); this->priv->update_scheduled_flag = FALSE; - - window = gtk_widget_get_window (widget); - - cr = gdk_cairo_create (window); - - cairo_rectangle (cr, - event->area.x, event->area.y, - event->area.width, event->area.height); - cairo_clip (cr); - - gtk_widget_get_allocation (widget, &allocation); - cairo_translate (cr, allocation.x, allocation.y); - draw (this, cr); - cairo_destroy (cr); - gl_debug (DEBUG_MINI_PREVIEW, "END"); return FALSE; } @@ -843,8 +824,8 @@ style_set_cb (GtkWidget *widget, static void redraw (glMiniPreview *this) { - GdkWindow *window; - GdkRegion *region; + GdkWindow *window; + GtkAllocation allocation; gl_debug (DEBUG_MINI_PREVIEW, "START"); @@ -857,9 +838,8 @@ redraw (glMiniPreview *this) { this->priv->update_scheduled_flag = TRUE; - region = gdk_drawable_get_clip_region (window); - gdk_window_invalidate_region (window, region, TRUE); - gdk_region_destroy (region); + gtk_widget_get_allocation (GTK_WIDGET (this), &allocation); + gdk_window_invalidate_rect (window, &allocation, FALSE); } } diff --git a/src/prefs-dialog.c b/src/prefs-dialog.c index 9dc28831..dd3bcca1 100644 --- a/src/prefs-dialog.c +++ b/src/prefs-dialog.c @@ -158,7 +158,6 @@ gl_prefs_dialog_init (glPrefsDialog *dialog) return; } - gtk_dialog_set_has_separator (GTK_DIALOG(dialog), FALSE); gtk_dialog_add_button (GTK_DIALOG(dialog), GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE); gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_CLOSE); diff --git a/src/view-barcode.c b/src/view-barcode.c index 3f87b5bd..6510e770 100644 --- a/src/view-barcode.c +++ b/src/view-barcode.c @@ -22,10 +22,10 @@ #include "view-barcode.h" -#include "label-barcode.h" +#include -#include "pixmaps/cursor_barcode.xbm" -#include "pixmaps/cursor_barcode_mask.xbm" +#include "label-barcode.h" +#include "cursors/cursor_pixdata.h" #include "debug.h" @@ -34,6 +34,9 @@ /* Private macros and constants. */ /*========================================================*/ +#define X_HOTSPOT 7 +#define Y_HOTSPOT 7 + /*========================================================*/ /* Private types. */ @@ -57,23 +60,13 @@ GdkCursor * gl_view_barcode_get_create_cursor (void) { GdkCursor *cursor = NULL; - GdkPixmap *pixmap_data, *pixmap_mask; - GdkColor fg = { 0, 0, 0, 0 }; - GdkColor bg = { 0, 65535, 65535, 65535 }; + GdkPixbuf *pixbuf; gl_debug (DEBUG_VIEW, "START"); - pixmap_data = gdk_bitmap_create_from_data (NULL, - (gchar *)cursor_barcode_bits, - cursor_barcode_width, - cursor_barcode_height); - pixmap_mask = gdk_bitmap_create_from_data (NULL, - (gchar *)cursor_barcode_mask_bits, - cursor_barcode_mask_width, - cursor_barcode_mask_height); - cursor = gdk_cursor_new_from_pixmap (pixmap_data, pixmap_mask, &fg, - &bg, cursor_barcode_x_hot, - cursor_barcode_y_hot); + pixbuf = gdk_pixbuf_from_pixdata (&cursor_barcode_pixdata, FALSE, NULL); + cursor = gdk_cursor_new_from_pixbuf (gdk_display_get_default (), pixbuf, X_HOTSPOT, Y_HOTSPOT); + g_object_unref (pixbuf); gl_debug (DEBUG_VIEW, "END"); diff --git a/src/view-box.c b/src/view-box.c index 3c392194..a69bfd1c 100644 --- a/src/view-box.c +++ b/src/view-box.c @@ -22,10 +22,10 @@ #include "view-box.h" -#include "label-box.h" +#include -#include "pixmaps/cursor_box.xbm" -#include "pixmaps/cursor_box_mask.xbm" +#include "label-box.h" +#include "cursors/cursor_pixdata.h" #include "debug.h" @@ -34,6 +34,9 @@ /* Private macros and constants. */ /*========================================================*/ +#define X_HOTSPOT 7 +#define Y_HOTSPOT 7 + /*========================================================*/ /* Private types. */ @@ -57,23 +60,13 @@ GdkCursor * gl_view_box_get_create_cursor (void) { GdkCursor *cursor = NULL; - GdkPixmap *pixmap_data, *pixmap_mask; - GdkColor fg = { 0, 0, 0, 0 }; - GdkColor bg = { 0, 65535, 65535, 65535 }; + GdkPixbuf *pixbuf; gl_debug (DEBUG_VIEW, "START"); - pixmap_data = gdk_bitmap_create_from_data (NULL, - (gchar *)cursor_box_bits, - cursor_box_width, - cursor_box_height); - pixmap_mask = gdk_bitmap_create_from_data (NULL, - (gchar *)cursor_box_mask_bits, - cursor_box_mask_width, - cursor_box_mask_height); - cursor = gdk_cursor_new_from_pixmap (pixmap_data, pixmap_mask, &fg, - &bg, cursor_box_x_hot, - cursor_box_y_hot); + pixbuf = gdk_pixbuf_from_pixdata (&cursor_box_pixdata, FALSE, NULL); + cursor = gdk_cursor_new_from_pixbuf (gdk_display_get_default (), pixbuf, X_HOTSPOT, Y_HOTSPOT); + g_object_unref (pixbuf); gl_debug (DEBUG_VIEW, "END"); diff --git a/src/view-ellipse.c b/src/view-ellipse.c index 1f0707cc..7de5cd76 100644 --- a/src/view-ellipse.c +++ b/src/view-ellipse.c @@ -22,10 +22,10 @@ #include "view-ellipse.h" -#include "label-ellipse.h" +#include -#include "pixmaps/cursor_ellipse.xbm" -#include "pixmaps/cursor_ellipse_mask.xbm" +#include "label-ellipse.h" +#include "cursors/cursor_pixdata.h" #include "debug.h" @@ -34,6 +34,9 @@ /* Private macros and constants. */ /*========================================================*/ +#define X_HOTSPOT 7 +#define Y_HOTSPOT 7 + /*========================================================*/ /* Private types. */ @@ -57,23 +60,13 @@ GdkCursor * gl_view_ellipse_get_create_cursor (void) { GdkCursor *cursor = NULL; - GdkPixmap *pixmap_data, *pixmap_mask; - GdkColor fg = { 0, 0, 0, 0 }; - GdkColor bg = { 0, 65535, 65535, 65535 }; + GdkPixbuf *pixbuf; gl_debug (DEBUG_VIEW, "START"); - pixmap_data = gdk_bitmap_create_from_data (NULL, - (gchar *)cursor_ellipse_bits, - cursor_ellipse_width, - cursor_ellipse_height); - pixmap_mask = gdk_bitmap_create_from_data (NULL, - (gchar *)cursor_ellipse_mask_bits, - cursor_ellipse_mask_width, - cursor_ellipse_mask_height); - cursor = gdk_cursor_new_from_pixmap (pixmap_data, pixmap_mask, &fg, - &bg, cursor_ellipse_x_hot, - cursor_ellipse_y_hot); + pixbuf = gdk_pixbuf_from_pixdata (&cursor_ellipse_pixdata, FALSE, NULL); + cursor = gdk_cursor_new_from_pixbuf (gdk_display_get_default (), pixbuf, X_HOTSPOT, Y_HOTSPOT); + g_object_unref (pixbuf); gl_debug (DEBUG_VIEW, "END"); diff --git a/src/view-image.c b/src/view-image.c index d3351707..e6bd8ae4 100644 --- a/src/view-image.c +++ b/src/view-image.c @@ -22,10 +22,10 @@ #include "view-image.h" -#include "label-image.h" +#include -#include "pixmaps/cursor_image.xbm" -#include "pixmaps/cursor_image_mask.xbm" +#include "label-image.h" +#include "cursors/cursor_pixdata.h" #include "debug.h" @@ -34,6 +34,9 @@ /* Private macros and constants. */ /*========================================================*/ +#define X_HOTSPOT 7 +#define Y_HOTSPOT 7 + /*========================================================*/ /* Private types. */ @@ -56,23 +59,13 @@ GdkCursor * gl_view_image_get_create_cursor (void) { GdkCursor *cursor = NULL; - GdkPixmap *pixmap_data, *pixmap_mask; - GdkColor fg = { 0, 0, 0, 0 }; - GdkColor bg = { 0, 65535, 65535, 65535 }; + GdkPixbuf *pixbuf; gl_debug (DEBUG_VIEW, "START"); - pixmap_data = gdk_bitmap_create_from_data (NULL, - (gchar *)cursor_image_bits, - cursor_image_width, - cursor_image_height); - pixmap_mask = gdk_bitmap_create_from_data (NULL, - (gchar *)cursor_image_mask_bits, - cursor_image_mask_width, - cursor_image_mask_height); - cursor = gdk_cursor_new_from_pixmap (pixmap_data, pixmap_mask, &fg, - &bg, cursor_image_x_hot, - cursor_image_y_hot); + pixbuf = gdk_pixbuf_from_pixdata (&cursor_image_pixdata, FALSE, NULL); + cursor = gdk_cursor_new_from_pixbuf (gdk_display_get_default (), pixbuf, X_HOTSPOT, Y_HOTSPOT); + g_object_unref (pixbuf); gl_debug (DEBUG_VIEW, "END"); diff --git a/src/view-line.c b/src/view-line.c index 5a91234c..9da709e1 100644 --- a/src/view-line.c +++ b/src/view-line.c @@ -22,10 +22,10 @@ #include "view-line.h" -#include "label-line.h" +#include -#include "pixmaps/cursor_line.xbm" -#include "pixmaps/cursor_line_mask.xbm" +#include "label-line.h" +#include "cursors/cursor_pixdata.h" #include "debug.h" @@ -34,6 +34,9 @@ /* Private macros and constants. */ /*========================================================*/ +#define X_HOTSPOT 7 +#define Y_HOTSPOT 7 + /*========================================================*/ /* Private types. */ @@ -57,23 +60,13 @@ GdkCursor * gl_view_line_get_create_cursor (void) { GdkCursor *cursor = NULL; - GdkPixmap *pixmap_data, *pixmap_mask; - GdkColor fg = { 0, 0, 0, 0 }; - GdkColor bg = { 0, 65535, 65535, 65535 }; + GdkPixbuf *pixbuf; gl_debug (DEBUG_VIEW, "START"); - pixmap_data = gdk_bitmap_create_from_data (NULL, - (gchar *)cursor_line_bits, - cursor_line_width, - cursor_line_height); - pixmap_mask = gdk_bitmap_create_from_data (NULL, - (gchar *)cursor_line_mask_bits, - cursor_line_mask_width, - cursor_line_mask_height); - cursor = gdk_cursor_new_from_pixmap (pixmap_data, pixmap_mask, &fg, - &bg, cursor_line_x_hot, - cursor_line_y_hot); + pixbuf = gdk_pixbuf_from_pixdata (&cursor_line_pixdata, FALSE, NULL); + cursor = gdk_cursor_new_from_pixbuf (gdk_display_get_default (), pixbuf, X_HOTSPOT, Y_HOTSPOT); + g_object_unref (pixbuf); gl_debug (DEBUG_VIEW, "END"); diff --git a/src/view-text.c b/src/view-text.c index 9668b790..47579919 100644 --- a/src/view-text.c +++ b/src/view-text.c @@ -23,11 +23,10 @@ #include "view-text.h" #include +#include #include "label-text.h" - -#include "pixmaps/cursor_text.xbm" -#include "pixmaps/cursor_text_mask.xbm" +#include "cursors/cursor_pixdata.h" #include "debug.h" @@ -36,6 +35,9 @@ /* Private macros and constants. */ /*========================================================*/ +#define X_HOTSPOT 7 +#define Y_HOTSPOT 7 + /*========================================================*/ /* Private types. */ @@ -59,23 +61,13 @@ GdkCursor * gl_view_text_get_create_cursor (void) { GdkCursor *cursor = NULL; - GdkPixmap *pixmap_data, *pixmap_mask; - GdkColor fg = { 0, 0, 0, 0 }; - GdkColor bg = { 0, 65535, 65535, 65535 }; + GdkPixbuf *pixbuf; gl_debug (DEBUG_VIEW, "START"); - pixmap_data = gdk_bitmap_create_from_data (NULL, - (gchar *)cursor_text_bits, - cursor_text_width, - cursor_text_height); - pixmap_mask = gdk_bitmap_create_from_data (NULL, - (gchar *)cursor_text_mask_bits, - cursor_text_mask_width, - cursor_text_mask_height); - cursor = gdk_cursor_new_from_pixmap (pixmap_data, pixmap_mask, &fg, - &bg, cursor_text_x_hot, - cursor_text_y_hot); + pixbuf = gdk_pixbuf_from_pixdata (&cursor_text_pixdata, FALSE, NULL); + cursor = gdk_cursor_new_from_pixbuf (gdk_display_get_default (), pixbuf, X_HOTSPOT, Y_HOTSPOT); + g_object_unref (pixbuf); gl_debug (DEBUG_VIEW, "END"); diff --git a/src/view.c b/src/view.c index 31bfec99..3ea2ed95 100644 --- a/src/view.c +++ b/src/view.c @@ -125,8 +125,8 @@ static gdouble get_home_scale (glView *view); static void prefs_changed_cb (glView *view); -static gboolean expose_cb (glView *view, - GdkEventExpose *event); +static gboolean draw_cb (glView *view, + cairo_t *cr); static void realize_cb (glView *view); @@ -308,8 +308,8 @@ gl_view_init (glView *view) g_signal_connect_swapped (G_OBJECT (gl_prefs), "changed", G_CALLBACK (prefs_changed_cb), view); - g_signal_connect_swapped (G_OBJECT (view->canvas), "expose-event", - G_CALLBACK (expose_cb), view); + g_signal_connect_swapped (G_OBJECT (view->canvas), "draw", + G_CALLBACK (draw_cb), view); g_signal_connect_swapped (G_OBJECT (view->canvas), "realize", G_CALLBACK (realize_cb), view); g_signal_connect_swapped (G_OBJECT (view->canvas), "size-allocate", @@ -472,23 +472,24 @@ prefs_changed_cb (glView *view) void gl_view_update (glView *view) { - GdkWindow *window; - GdkRegion *region; - + GdkWindow *window; + GtkAllocation allocation; + gl_debug (DEBUG_VIEW, "START"); window = gtk_widget_get_window (GTK_WIDGET (view->canvas)); - if (!window) return; - - if ( !view->update_scheduled_flag ) + if (window) { - view->update_scheduled_flag = TRUE; - region = gdk_drawable_get_clip_region (window); - /* redraw the cairo canvas completely by exposing it */ - gdk_window_invalidate_region (window, region, TRUE); - gdk_region_destroy (region); + if ( !view->update_scheduled_flag ) + { + view->update_scheduled_flag = TRUE; + + gtk_widget_get_allocation (GTK_WIDGET (view->canvas), &allocation); + gdk_window_invalidate_rect (window, &allocation, TRUE); + } + } gl_debug (DEBUG_VIEW, "END"); @@ -536,28 +537,14 @@ gl_view_update_region (glView *view, /* PRIVATE. Expose handler. */ /*---------------------------------------------------------------------------*/ static gboolean -expose_cb (glView *view, - GdkEventExpose *event) +draw_cb (glView *view, + cairo_t *cr) { - GdkWindow *bin_window; - cairo_t *cr; - gl_debug (DEBUG_VIEW, "START"); view->update_scheduled_flag = FALSE; - - bin_window = gtk_layout_get_bin_window (GTK_LAYOUT (view->canvas)); - cr = gdk_cairo_create (bin_window); - - cairo_rectangle (cr, - event->area.x, event->area.y, - event->area.width, event->area.height); - cairo_clip (cr); - draw_layers (view, cr); - cairo_destroy (cr); - gl_debug (DEBUG_VIEW, "END"); return FALSE; @@ -705,7 +692,8 @@ draw_layers (glView *view, scale = view->home_scale * view->zoom; gtk_layout_set_size (GTK_LAYOUT (view->canvas), w*scale+8, h*scale+8); - gdk_drawable_get_size (bin_window, &canvas_w, &canvas_h); + canvas_w = gdk_window_get_width (bin_window); + canvas_h = gdk_window_get_height (bin_window); view->x0 = (canvas_w/scale - w) / 2.0; view->y0 = (canvas_h/scale - h) / 2.0; @@ -1822,24 +1810,24 @@ key_press_event_cb (glView *view, { switch (event->keyval) { - case GDK_Left: - case GDK_KP_Left: + case GDK_KEY_Left: + case GDK_KEY_KP_Left: gl_label_move_selection (view->label, -1.0 / (view->zoom), 0.0); break; - case GDK_Up: - case GDK_KP_Up: + case GDK_KEY_Up: + case GDK_KEY_KP_Up: gl_label_move_selection (view->label, 0.0, -1.0 / (view->zoom)); break; - case GDK_Right: - case GDK_KP_Right: + case GDK_KEY_Right: + case GDK_KEY_KP_Right: gl_label_move_selection (view->label, 1.0 / (view->zoom), 0.0); break; - case GDK_Down: - case GDK_KP_Down: + case GDK_KEY_Down: + case GDK_KEY_KP_Down: gl_label_move_selection (view->label, 0.0, 1.0 / (view->zoom)); break; - case GDK_Delete: - case GDK_KP_Delete: + case GDK_KEY_Delete: + case GDK_KEY_KP_Delete: gl_label_delete_selection (view->label); cursor = gdk_cursor_new (GDK_LEFT_PTR); gdk_window_set_cursor (window, cursor); diff --git a/src/wdgt-chain-button.c b/src/wdgt-chain-button.c index c9f7ad23..a290e21c 100644 --- a/src/wdgt-chain-button.c +++ b/src/wdgt-chain-button.c @@ -98,12 +98,14 @@ gl_wdgt_chain_button_init (glWdgtChainButton *button) g_signal_connect (button->button, "clicked", G_CALLBACK (gl_wdgt_chain_button_clicked_callback), button); +#if 0 g_signal_connect (button->line1, "expose_event", G_CALLBACK (gl_wdgt_chain_button_draw_lines), button); g_signal_connect (button->line2, "expose_event", G_CALLBACK (gl_wdgt_chain_button_draw_lines), button); +#endif } @@ -307,6 +309,7 @@ gl_wdgt_chain_button_draw_lines (GtkWidget *widget, points[2] = buf; } +#if 0 gtk_paint_polygon (gtk_widget_get_style (widget), gtk_widget_get_window (widget), GTK_STATE_NORMAL, @@ -317,6 +320,7 @@ gl_wdgt_chain_button_draw_lines (GtkWidget *widget, points, 3, FALSE); +#endif return TRUE; } diff --git a/src/window.c b/src/window.c index 2359a1b1..e2acbeda 100644 --- a/src/window.c +++ b/src/window.c @@ -59,7 +59,7 @@ static GList *window_list = NULL; /*===========================================================================*/ static void gl_window_finalize (GObject *object); -static void gl_window_destroy (GtkObject *gtk_object); +static void gl_window_dispose (GObject *object); static void set_window_title (glWindow *window, glLabel *label); @@ -119,15 +119,13 @@ static void gl_window_class_init (glWindowClass *class) { GObjectClass *object_class = G_OBJECT_CLASS (class); - GtkObjectClass *gtk_object_class = GTK_OBJECT_CLASS (class); gl_debug (DEBUG_WINDOW, "START"); gl_window_parent_class = g_type_class_peek_parent (class); object_class->finalize = gl_window_finalize; - - gtk_object_class->destroy = gl_window_destroy; + object_class->dispose = gl_window_dispose; gl_debug (DEBUG_WINDOW, "END"); } @@ -232,17 +230,17 @@ gl_window_finalize (GObject *object) static void -gl_window_destroy (GtkObject *gtk_object) +gl_window_dispose (GObject *object) { glWindow *window; GtkClipboard *clipboard; gl_debug (DEBUG_WINDOW, "START"); - g_return_if_fail (gtk_object != NULL); - g_return_if_fail (GL_IS_WINDOW (gtk_object)); + g_return_if_fail (object != NULL); + g_return_if_fail (GL_IS_WINDOW (object)); - window = GL_WINDOW (gtk_object); + window = GL_WINDOW (object); window_list = g_list_remove (window_list, window); if (window->ui) { @@ -262,8 +260,8 @@ gl_window_destroy (GtkObject *gtk_object) g_object_unref (window->label); } - if (GTK_OBJECT_CLASS (gl_window_parent_class)->destroy) { - GTK_OBJECT_CLASS (gl_window_parent_class)->destroy (gtk_object); + if (G_OBJECT_CLASS (gl_window_parent_class)->dispose) { + G_OBJECT_CLASS (gl_window_parent_class)->dispose (object); } gl_debug (DEBUG_WINDOW, "END"); -- 2.39.5