From 5161c53f3cffcc66431384962b76aef18f88dd0a Mon Sep 17 00:00:00 2001 From: Alx Sa Date: Sat, 3 Aug 2024 18:24:46 +0000 Subject: [PATCH] libgimpwidgets: Make GimpPickButton a derivable type Per Jehan, we should remove gimppickbutton-default.[ch] and move the functions into gimppickbutton.c. Then we can make the GimpPickButtonPrivate API actually private without any additional public functions. --- libgimpwidgets/gimppickbutton-default.c | 334 ------------------------ libgimpwidgets/gimppickbutton-default.h | 25 -- libgimpwidgets/gimppickbutton-kwin.c | 1 - libgimpwidgets/gimppickbutton-private.h | 4 +- libgimpwidgets/gimppickbutton-xdg.c | 1 - libgimpwidgets/gimppickbutton.c | 322 ++++++++++++++++++++++- libgimpwidgets/gimppickbutton.h | 23 +- libgimpwidgets/meson.build | 1 - 8 files changed, 317 insertions(+), 394 deletions(-) delete mode 100644 libgimpwidgets/gimppickbutton-default.c delete mode 100644 libgimpwidgets/gimppickbutton-default.h diff --git a/libgimpwidgets/gimppickbutton-default.c b/libgimpwidgets/gimppickbutton-default.c deleted file mode 100644 index c6f33007f3..0000000000 --- a/libgimpwidgets/gimppickbutton-default.c +++ /dev/null @@ -1,334 +0,0 @@ -/* LIBGIMP - The GIMP Library - * Copyright (C) 1995-1997 Peter Mattis and Spencer Kimball - * - * gimppickbutton.c - * Copyright (C) 2002 Michael Natterer - * - * based on gtk+/gtk/gtkcolorsel.c - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library. If not, see - * . - */ - -#include "config.h" - -#include -#include -#include - -#ifdef G_OS_WIN32 -#define WIN32_LEAN_AND_MEAN -#include -#endif - -#include "libgimpcolor/gimpcolor.h" - -#include "gimpwidgetstypes.h" - -#include "gimpcairo-utils.h" -#include "gimphelpui.h" -#include "gimpicons.h" -#include "gimppickbutton.h" -#include "gimppickbutton-default.h" -#include "gimppickbutton-private.h" -#include "gimpwidgetsutils.h" - -#include "libgimp/libgimp-intl.h" - - -static gboolean gimp_pick_button_mouse_press (GtkWidget *invisible, - GdkEventButton *event, - GimpPickButton *button); -static gboolean gimp_pick_button_key_press (GtkWidget *invisible, - GdkEventKey *event, - GimpPickButton *button); -static gboolean gimp_pick_button_mouse_motion (GtkWidget *invisible, - GdkEventMotion *event, - GimpPickButton *button); -static gboolean gimp_pick_button_mouse_release (GtkWidget *invisible, - GdkEventButton *event, - GimpPickButton *button); -static void gimp_pick_button_shutdown (GimpPickButton *button); -static void gimp_pick_button_pick (GimpPickButton *button, - GdkEvent *event); - - -static GdkCursor * -make_cursor (GdkDisplay *display) -{ - GdkPixbuf *pixbuf; - GError *error = NULL; - - pixbuf = gdk_pixbuf_new_from_resource ("/org/gimp/color-picker-cursors/cursor-color-picker.png", - &error); - - if (pixbuf) - { - GdkCursor *cursor = gdk_cursor_new_from_pixbuf (display, pixbuf, 1, 30); - - g_object_unref (pixbuf); - - return cursor; - } - else - { - g_critical ("Failed to create cursor image: %s", error->message); - g_clear_error (&error); - } - - return NULL; -} - -static gboolean -gimp_pick_button_mouse_press (GtkWidget *invisible, - GdkEventButton *event, - GimpPickButton *button) -{ - if (event->type == GDK_BUTTON_PRESS && event->button == 1) - { - g_signal_connect (invisible, "motion-notify-event", - G_CALLBACK (gimp_pick_button_mouse_motion), - button); - g_signal_connect (invisible, "button-release-event", - G_CALLBACK (gimp_pick_button_mouse_release), - button); - - g_signal_handlers_disconnect_by_func (invisible, - gimp_pick_button_mouse_press, - button); - g_signal_handlers_disconnect_by_func (invisible, - gimp_pick_button_key_press, - button); - - gimp_pick_button_pick (button, (GdkEvent *) event); - - return TRUE; - } - - return FALSE; -} - -static gboolean -gimp_pick_button_key_press (GtkWidget *invisible, - GdkEventKey *event, - GimpPickButton *button) -{ - if (event->keyval == GDK_KEY_Escape) - { - gimp_pick_button_shutdown (button); - - g_signal_handlers_disconnect_by_func (invisible, - gimp_pick_button_mouse_press, - button); - g_signal_handlers_disconnect_by_func (invisible, - gimp_pick_button_key_press, - button); - - return TRUE; - } - - return FALSE; -} - -static gboolean -gimp_pick_button_mouse_motion (GtkWidget *invisible, - GdkEventMotion *event, - GimpPickButton *button) -{ - gimp_pick_button_pick (button, (GdkEvent *) event); - - return TRUE; -} - -static gboolean -gimp_pick_button_mouse_release (GtkWidget *invisible, - GdkEventButton *event, - GimpPickButton *button) -{ - if (event->button != 1) - return FALSE; - - gimp_pick_button_pick (button, (GdkEvent *) event); - - gimp_pick_button_shutdown (button); - - g_signal_handlers_disconnect_by_func (invisible, - gimp_pick_button_mouse_motion, - button); - g_signal_handlers_disconnect_by_func (invisible, - gimp_pick_button_mouse_release, - button); - - return TRUE; -} - -static void -gimp_pick_button_shutdown (GimpPickButton *button) -{ - GdkDisplay *display = gtk_widget_get_display (button->priv->grab_widget); - - gtk_grab_remove (button->priv->grab_widget); - - gdk_seat_ungrab (gdk_display_get_default_seat (display)); -} - -static void -gimp_pick_button_pick (GimpPickButton *button, - GdkEvent *event) -{ - GdkScreen *screen = gdk_event_get_screen (event); - GimpColorProfile *monitor_profile; - GdkMonitor *monitor; - GeglColor *rgb = gegl_color_new ("black"); - const Babl *space = NULL; - gint x_root; - gint y_root; - gdouble x_win; - gdouble y_win; - - gdk_window_get_origin (gdk_event_get_window (event), &x_root, &y_root); - gdk_event_get_coords (event, &x_win, &y_win); - x_root += x_win; - y_root += y_win; - - monitor = gdk_display_get_monitor_at_point (gdk_screen_get_display (screen), - x_root, y_root); - monitor_profile = gimp_monitor_get_color_profile (monitor); - - if (monitor_profile) - space = gimp_color_profile_get_space (monitor_profile, - GIMP_COLOR_RENDERING_INTENT_PERCEPTUAL, - NULL); - -#ifdef G_OS_WIN32 - - { - HDC hdc; - RECT rect; - COLORREF win32_color; - guchar temp_rgb[3]; - - /* For MS Windows, use native GDI functions to get the pixel, as - * cairo does not handle the case where you have multiple monitors - * with a monitor on the left or above the primary monitor. That - * scenario create a cairo primary surface with negative extent, - * which is not handled properly (bug 740634). - */ - - hdc = GetDC (HWND_DESKTOP); - GetClipBox (hdc, &rect); - win32_color = GetPixel (hdc, x_root + rect.left, y_root + rect.top); - ReleaseDC (HWND_DESKTOP, hdc); - - temp_rgb[0] = GetRValue (win32_color); - temp_rgb[1] = GetGValue (win32_color); - temp_rgb[2] = GetBValue (win32_color); - - gegl_color_set_pixel (rgb, babl_format_with_space ("R'G'B' u8", space), - temp_rgb); - } - -#else - - { - GdkWindow *window; - gint x_window; - gint y_window; - cairo_surface_t *image; - cairo_t *cr; - guchar *data; - guchar color[3]; - - /* we try to pick from the local window under the cursor, and fall - * back to picking from the root window if this fails (i.e., if - * the cursor is not under a local window). on wayland, picking - * from the root window is not supported, so this at least allows - * us to pick from local windows. see bug #780375. - */ - window = gdk_device_get_window_at_position (gdk_event_get_device (event), - &x_window, &y_window); - if (! window) - { - window = gdk_screen_get_root_window (screen); - x_window = x_root; - y_window = y_root; - } - - image = cairo_image_surface_create (CAIRO_FORMAT_RGB24, 1, 1); - - cr = cairo_create (image); - - gdk_cairo_set_source_window (cr, window, -x_window, -y_window); - cairo_paint (cr); - - cairo_destroy (cr); - - data = cairo_image_surface_get_data (image); - GIMP_CAIRO_RGB24_GET_PIXEL (data, color[0], color[1], color[2]); - - cairo_surface_destroy (image); - - gegl_color_set_pixel (rgb, babl_format_with_space ("R'G'B' u8", space), - color); - } - -#endif - - g_signal_emit_by_name (button, "color-picked", rgb); - g_object_unref (rgb); -} - -/* entry point to this file, called from gimppickbutton.c */ -void -_gimp_pick_button_default_pick (GimpPickButton *button) -{ - GdkDisplay *display; - GtkWidget *widget; - - if (! button->priv->cursor) - button->priv->cursor = - make_cursor (gtk_widget_get_display (GTK_WIDGET (button))); - - if (! button->priv->grab_widget) - { - button->priv->grab_widget = gtk_invisible_new (); - - gtk_widget_add_events (button->priv->grab_widget, - GDK_BUTTON_PRESS_MASK | - GDK_BUTTON_RELEASE_MASK | - GDK_BUTTON1_MOTION_MASK); - - gtk_widget_show (button->priv->grab_widget); - } - - widget = button->priv->grab_widget; - - display = gtk_widget_get_display (widget); - - if (gdk_seat_grab (gdk_display_get_default_seat (display), - gtk_widget_get_window (widget), - GDK_SEAT_CAPABILITY_ALL, - FALSE, - button->priv->cursor, - NULL, - NULL, NULL) != GDK_GRAB_SUCCESS) - { - g_warning ("Failed to grab seat to do eyedropper"); - return; - } - - gtk_grab_add (widget); - - g_signal_connect (widget, "button-press-event", - G_CALLBACK (gimp_pick_button_mouse_press), - button); - g_signal_connect (widget, "key-press-event", - G_CALLBACK (gimp_pick_button_key_press), - button); -} diff --git a/libgimpwidgets/gimppickbutton-default.h b/libgimpwidgets/gimppickbutton-default.h deleted file mode 100644 index 8b252b8f00..0000000000 --- a/libgimpwidgets/gimppickbutton-default.h +++ /dev/null @@ -1,25 +0,0 @@ -/* LIBGIMP - The GIMP Library - * Copyright (C) 1995-1997 Peter Mattis and Spencer Kimball - * - * gimppickbutton-default.h - * Copyright (C) 2017 Jehan - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library. If not, see - * . - */ - -/* Private header file which is not meant to be exported. */ -#ifndef __GIMP_PICK_BUTTON_DEFAULT_H__ -#define __GIMP_PICK_BUTTON_DEFAULT_H__ - -void _gimp_pick_button_default_pick (GimpPickButton *button); - -#endif /* __GIMP_PICK_BUTTON_DEFAULT_H__ */ - - diff --git a/libgimpwidgets/gimppickbutton-kwin.c b/libgimpwidgets/gimppickbutton-kwin.c index 25280241e6..ddf6bea937 100644 --- a/libgimpwidgets/gimppickbutton-kwin.c +++ b/libgimpwidgets/gimppickbutton-kwin.c @@ -23,7 +23,6 @@ #include "gimpwidgetstypes.h" #include "gimppickbutton.h" -#include "gimppickbutton-default.h" #include "gimppickbutton-kwin.h" #include "libgimp/libgimp-intl.h" diff --git a/libgimpwidgets/gimppickbutton-private.h b/libgimpwidgets/gimppickbutton-private.h index c63856d9ed..564132e750 100644 --- a/libgimpwidgets/gimppickbutton-private.h +++ b/libgimpwidgets/gimppickbutton-private.h @@ -17,11 +17,11 @@ #define __GIMP_PICK_BUTTON_PRIVATE_H__ -struct _GimpPickButtonPrivate +typedef struct _GimpPickButtonPrivate { GdkCursor *cursor; GtkWidget *grab_widget; -}; +} GimpPickButtonPrivate; #endif /* ! __GIMP_PICK_BUTTON_PRIVATE_H__ */ diff --git a/libgimpwidgets/gimppickbutton-xdg.c b/libgimpwidgets/gimppickbutton-xdg.c index 08902f7569..7a3eba4e16 100644 --- a/libgimpwidgets/gimppickbutton-xdg.c +++ b/libgimpwidgets/gimppickbutton-xdg.c @@ -27,7 +27,6 @@ #include "gimpwidgetstypes.h" #include "gimppickbutton.h" -#include "gimppickbutton-default.h" #include "gimppickbutton-xdg.h" #include "libgimp/libgimp-intl.h" diff --git a/libgimpwidgets/gimppickbutton.c b/libgimpwidgets/gimppickbutton.c index 4af94014d4..d35d41968a 100644 --- a/libgimpwidgets/gimppickbutton.c +++ b/libgimpwidgets/gimppickbutton.c @@ -25,6 +25,10 @@ #ifdef GDK_WINDOWING_X11 #include #endif +#ifdef G_OS_WIN32 +#define WIN32_LEAN_AND_MEAN +#include +#endif #include "libgimpcolor/gimpcolor.h" @@ -35,6 +39,7 @@ #include "gimpicons.h" #include "gimppickbutton.h" #include "gimppickbutton-private.h" +#include "gimpwidgetsutils.h" #include "libgimp/libgimp-intl.h" @@ -43,7 +48,6 @@ #elif defined (GDK_WINDOWING_WIN32) #include "gimppickbutton-win32.h" #else -#include "gimppickbutton-default.h" #include "gimppickbutton-kwin.h" #include "gimppickbutton-xdg.h" #endif @@ -65,10 +69,28 @@ enum LAST_SIGNAL }; +#define GET_PRIVATE(obj) ((GimpPickButtonPrivate *) gimp_pick_button_get_instance_private ((GimpPickButton *) (obj))) -static void gimp_pick_button_dispose (GObject *object); +static void gimp_pick_button_dispose (GObject *object); + +static void gimp_pick_button_clicked (GtkButton *button); + +static gboolean gimp_pick_button_mouse_press (GtkWidget *invisible, + GdkEventButton *event, + GimpPickButton *button); +static gboolean gimp_pick_button_key_press (GtkWidget *invisible, + GdkEventKey *event, + GimpPickButton *button); +static gboolean gimp_pick_button_mouse_motion (GtkWidget *invisible, + GdkEventMotion *event, + GimpPickButton *button); +static gboolean gimp_pick_button_mouse_release (GtkWidget *invisible, + GdkEventButton *event, + GimpPickButton *button); +static void gimp_pick_button_shutdown (GimpPickButton *button); +static void gimp_pick_button_pick (GimpPickButton *button, + GdkEvent *event); -static void gimp_pick_button_clicked (GtkButton *button); G_DEFINE_TYPE_WITH_PRIVATE (GimpPickButton, gimp_pick_button, GTK_TYPE_BUTTON) @@ -112,8 +134,6 @@ gimp_pick_button_init (GimpPickButton *button) { GtkWidget *image; - button->priv = gimp_pick_button_get_instance_private (button); - image = gtk_image_new_from_icon_name (GIMP_ICON_COLOR_PICK_FROM_SCREEN, GTK_ICON_SIZE_BUTTON); gtk_container_add (GTK_CONTAINER (button), image); @@ -128,18 +148,19 @@ gimp_pick_button_init (GimpPickButton *button) static void gimp_pick_button_dispose (GObject *object) { - GimpPickButton *button = GIMP_PICK_BUTTON (object); + GimpPickButton *button = GIMP_PICK_BUTTON (object); + GimpPickButtonPrivate *priv = GET_PRIVATE (button); - if (button->priv->cursor) + if (priv->cursor) { - g_object_unref (button->priv->cursor); - button->priv->cursor = NULL; + g_object_unref (priv->cursor); + priv->cursor = NULL; } - if (button->priv->grab_widget) + if (priv->grab_widget) { - gtk_widget_destroy (button->priv->grab_widget); - button->priv->grab_widget = NULL; + gtk_widget_destroy (priv->grab_widget); + priv->grab_widget = NULL; } G_OBJECT_CLASS (parent_class)->dispose (object); @@ -177,6 +198,283 @@ gimp_pick_button_clicked (GtkButton *button) #endif } +/* default implementation functions */ + +static GdkCursor * +make_cursor (GdkDisplay *display) +{ + GdkPixbuf *pixbuf; + GError *error = NULL; + + pixbuf = gdk_pixbuf_new_from_resource ("/org/gimp/color-picker-cursors/cursor-color-picker.png", + &error); + + if (pixbuf) + { + GdkCursor *cursor = gdk_cursor_new_from_pixbuf (display, pixbuf, 1, 30); + + g_object_unref (pixbuf); + + return cursor; + } + else + { + g_critical ("Failed to create cursor image: %s", error->message); + g_clear_error (&error); + } + + return NULL; +} + +static gboolean +gimp_pick_button_mouse_press (GtkWidget *invisible, + GdkEventButton *event, + GimpPickButton *button) +{ + if (event->type == GDK_BUTTON_PRESS && event->button == 1) + { + g_signal_connect (invisible, "motion-notify-event", + G_CALLBACK (gimp_pick_button_mouse_motion), + button); + g_signal_connect (invisible, "button-release-event", + G_CALLBACK (gimp_pick_button_mouse_release), + button); + + g_signal_handlers_disconnect_by_func (invisible, + gimp_pick_button_mouse_press, + button); + g_signal_handlers_disconnect_by_func (invisible, + gimp_pick_button_key_press, + button); + + gimp_pick_button_pick (button, (GdkEvent *) event); + + return TRUE; + } + + return FALSE; +} + +static gboolean +gimp_pick_button_key_press (GtkWidget *invisible, + GdkEventKey *event, + GimpPickButton *button) +{ + if (event->keyval == GDK_KEY_Escape) + { + gimp_pick_button_shutdown (button); + + g_signal_handlers_disconnect_by_func (invisible, + gimp_pick_button_mouse_press, + button); + g_signal_handlers_disconnect_by_func (invisible, + gimp_pick_button_key_press, + button); + + return TRUE; + } + + return FALSE; +} + +static gboolean +gimp_pick_button_mouse_motion (GtkWidget *invisible, + GdkEventMotion *event, + GimpPickButton *button) +{ + gimp_pick_button_pick (button, (GdkEvent *) event); + + return TRUE; +} + +static gboolean +gimp_pick_button_mouse_release (GtkWidget *invisible, + GdkEventButton *event, + GimpPickButton *button) +{ + if (event->button != 1) + return FALSE; + + gimp_pick_button_pick (button, (GdkEvent *) event); + + gimp_pick_button_shutdown (button); + + g_signal_handlers_disconnect_by_func (invisible, + gimp_pick_button_mouse_motion, + button); + g_signal_handlers_disconnect_by_func (invisible, + gimp_pick_button_mouse_release, + button); + + return TRUE; +} + +static void +gimp_pick_button_shutdown (GimpPickButton *button) +{ + GimpPickButtonPrivate *priv = GET_PRIVATE (button); + GdkDisplay *display = gtk_widget_get_display (priv->grab_widget); + + gtk_grab_remove (priv->grab_widget); + + gdk_seat_ungrab (gdk_display_get_default_seat (display)); +} + +static void +gimp_pick_button_pick (GimpPickButton *button, + GdkEvent *event) +{ + GdkScreen *screen = gdk_event_get_screen (event); + GimpColorProfile *monitor_profile; + GdkMonitor *monitor; + GeglColor *rgb = gegl_color_new ("black"); + const Babl *space = NULL; + gint x_root; + gint y_root; + gdouble x_win; + gdouble y_win; + + gdk_window_get_origin (gdk_event_get_window (event), &x_root, &y_root); + gdk_event_get_coords (event, &x_win, &y_win); + x_root += x_win; + y_root += y_win; + + monitor = gdk_display_get_monitor_at_point (gdk_screen_get_display (screen), + x_root, y_root); + monitor_profile = gimp_monitor_get_color_profile (monitor); + + if (monitor_profile) + space = gimp_color_profile_get_space (monitor_profile, + GIMP_COLOR_RENDERING_INTENT_PERCEPTUAL, + NULL); + +#ifdef G_OS_WIN32 + + { + HDC hdc; + RECT rect; + COLORREF win32_color; + guchar temp_rgb[3]; + + /* For MS Windows, use native GDI functions to get the pixel, as + * cairo does not handle the case where you have multiple monitors + * with a monitor on the left or above the primary monitor. That + * scenario create a cairo primary surface with negative extent, + * which is not handled properly (bug 740634). + */ + + hdc = GetDC (HWND_DESKTOP); + GetClipBox (hdc, &rect); + win32_color = GetPixel (hdc, x_root + rect.left, y_root + rect.top); + ReleaseDC (HWND_DESKTOP, hdc); + + temp_rgb[0] = GetRValue (win32_color); + temp_rgb[1] = GetGValue (win32_color); + temp_rgb[2] = GetBValue (win32_color); + + gegl_color_set_pixel (rgb, babl_format_with_space ("R'G'B' u8", space), + temp_rgb); + } + +#else + + { + GdkWindow *window; + gint x_window; + gint y_window; + cairo_surface_t *image; + cairo_t *cr; + guchar *data; + guchar color[3]; + + /* we try to pick from the local window under the cursor, and fall + * back to picking from the root window if this fails (i.e., if + * the cursor is not under a local window). on wayland, picking + * from the root window is not supported, so this at least allows + * us to pick from local windows. see bug #780375. + */ + window = gdk_device_get_window_at_position (gdk_event_get_device (event), + &x_window, &y_window); + if (! window) + { + window = gdk_screen_get_root_window (screen); + x_window = x_root; + y_window = y_root; + } + + image = cairo_image_surface_create (CAIRO_FORMAT_RGB24, 1, 1); + + cr = cairo_create (image); + + gdk_cairo_set_source_window (cr, window, -x_window, -y_window); + cairo_paint (cr); + + cairo_destroy (cr); + + data = cairo_image_surface_get_data (image); + GIMP_CAIRO_RGB24_GET_PIXEL (data, color[0], color[1], color[2]); + + cairo_surface_destroy (image); + + gegl_color_set_pixel (rgb, babl_format_with_space ("R'G'B' u8", space), + color); + } + +#endif + + g_signal_emit_by_name (button, "color-picked", rgb); + g_object_unref (rgb); +} + +/* entry point to this file, called from gimppickbutton.c */ +void +_gimp_pick_button_default_pick (GimpPickButton *button) +{ + GimpPickButtonPrivate *priv = GET_PRIVATE (button); + GdkDisplay *display; + GtkWidget *widget; + + if (! priv->cursor) + priv->cursor = + make_cursor (gtk_widget_get_display (GTK_WIDGET (button))); + + if (! priv->grab_widget) + { + priv->grab_widget = gtk_invisible_new (); + + gtk_widget_add_events (priv->grab_widget, + GDK_BUTTON_PRESS_MASK | + GDK_BUTTON_RELEASE_MASK | + GDK_BUTTON1_MOTION_MASK); + + gtk_widget_show (priv->grab_widget); + } + + widget = priv->grab_widget; + + display = gtk_widget_get_display (widget); + + if (gdk_seat_grab (gdk_display_get_default_seat (display), + gtk_widget_get_window (widget), + GDK_SEAT_CAPABILITY_ALL, + FALSE, + priv->cursor, + NULL, + NULL, NULL) != GDK_GRAB_SUCCESS) + { + g_warning ("Failed to grab seat to do eyedropper"); + return; + } + + gtk_grab_add (widget); + + g_signal_connect (widget, "button-press-event", + G_CALLBACK (gimp_pick_button_mouse_press), + button); + g_signal_connect (widget, "key-press-event", + G_CALLBACK (gimp_pick_button_key_press), + button); +} /* public functions */ diff --git a/libgimpwidgets/gimppickbutton.h b/libgimpwidgets/gimppickbutton.h index c2036a4b51..959c1e0238 100644 --- a/libgimpwidgets/gimppickbutton.h +++ b/libgimpwidgets/gimppickbutton.h @@ -26,23 +26,8 @@ G_BEGIN_DECLS -#define GIMP_TYPE_PICK_BUTTON (gimp_pick_button_get_type ()) -#define GIMP_PICK_BUTTON(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GIMP_TYPE_PICK_BUTTON, GimpPickButton)) -#define GIMP_PICK_BUTTON_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GIMP_TYPE_PICK_BUTTON, GimpPickButtonClass)) -#define GIMP_IS_PICK_BUTTON(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GIMP_TYPE_PICK_BUTTON)) -#define GIMP_IS_PICK_BUTTON_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GIMP_TYPE_PICK_BUTTON)) -#define GIMP_PICK_BUTTON_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GIMP_TYPE_PICK_BUTTON, GimpPickButtonClass)) - - -typedef struct _GimpPickButtonPrivate GimpPickButtonPrivate; -typedef struct _GimpPickButtonClass GimpPickButtonClass; - -struct _GimpPickButton -{ - GtkButton parent_instance; - - GimpPickButtonPrivate *priv; -}; +#define GIMP_TYPE_PICK_BUTTON (gimp_pick_button_get_type ()) +G_DECLARE_DERIVABLE_TYPE (GimpPickButton, gimp_pick_button, GIMP, PICK_BUTTON, GtkButton) struct _GimpPickButtonClass { @@ -63,9 +48,11 @@ struct _GimpPickButtonClass }; -GType gimp_pick_button_get_type (void) G_GNUC_CONST; GtkWidget * gimp_pick_button_new (void); +/* for internal use only */ +G_GNUC_INTERNAL void _gimp_pick_button_default_pick (GimpPickButton *button); + G_END_DECLS diff --git a/libgimpwidgets/meson.build b/libgimpwidgets/meson.build index c556f87373..bb86d0fc09 100644 --- a/libgimpwidgets/meson.build +++ b/libgimpwidgets/meson.build @@ -197,7 +197,6 @@ elif platform_windows ] else libgimpwidgets_sources += [ - 'gimppickbutton-default.c', 'gimppickbutton-kwin.c', 'gimppickbutton-xdg.c', ]