From 62a38896178dea64f3d3c3e377cac7398c0448b2 Mon Sep 17 00:00:00 2001 From: Jehan Date: Sat, 19 Aug 2023 01:22:09 +0200 Subject: [PATCH] libgimp: rename Gimp*SelectButton widgets to Gimp*Chooser. This name was really irking me because it's not a button (anymore? Maybe it used to be just a button). Depending on the specific widget, it will have several sub-widgets, including a label. And it can theoretically even be something else than a button. So let's just rename these widgets with the more generic "chooser" name. --- ...brushselectbutton.c => gimpbrushchooser.c} | 124 ++++----- ...pfontselectbutton.h => gimpbrushchooser.h} | 23 +- ...mpfontselectbutton.c => gimpfontchooser.c} | 78 +++--- ...pbrushselectbutton.h => gimpfontchooser.h} | 23 +- ...ntselectbutton.c => gimpgradientchooser.c} | 98 ++++--- ...rnselectbutton.h => gimpgradientchooser.h} | 23 +- libgimp/gimpgradientselectbutton.h | 47 ---- ...tteselectbutton.c => gimppalettechooser.c} | 59 ++-- ...tteselectbutton.h => gimppalettechooser.h} | 21 +- ...ernselectbutton.c => gimppatternchooser.c} | 118 ++++---- libgimp/gimppatternchooser.h | 43 +++ libgimp/gimpproceduredialog.c | 4 +- libgimp/gimppropwidgets.c | 12 +- ...ceselectbutton.c => gimpresourcechooser.c} | 262 +++++++++--------- libgimp/gimpresourcechooser.h | 65 +++++ libgimp/gimpresourceselectbutton.h | 65 ----- libgimp/gimpui.def | 32 +-- libgimp/gimpui.h | 12 +- libgimp/gimpuitypes.h | 12 +- libgimp/meson.build | 24 +- .../fractal-explorer-dialogs.c | 4 +- plug-ins/gfig/gfig-dialog.c | 12 +- plug-ins/gfig/gfig-style.c | 12 +- .../libscriptfu/script-fu-interface.c | 14 +- 24 files changed, 578 insertions(+), 609 deletions(-) rename libgimp/{gimpbrushselectbutton.c => gimpbrushchooser.c} (72%) rename libgimp/{gimpfontselectbutton.h => gimpbrushchooser.h} (59%) rename libgimp/{gimpfontselectbutton.c => gimpfontchooser.c} (56%) rename libgimp/{gimpbrushselectbutton.h => gimpfontchooser.h} (58%) rename libgimp/{gimpgradientselectbutton.c => gimpgradientchooser.c} (67%) rename libgimp/{gimppatternselectbutton.h => gimpgradientchooser.h} (58%) delete mode 100644 libgimp/gimpgradientselectbutton.h rename libgimp/{gimppaletteselectbutton.c => gimppalettechooser.c} (63%) rename libgimp/{gimppaletteselectbutton.h => gimppalettechooser.h} (59%) rename libgimp/{gimppatternselectbutton.c => gimppatternchooser.c} (68%) create mode 100644 libgimp/gimppatternchooser.h rename libgimp/{gimpresourceselectbutton.c => gimpresourcechooser.c} (57%) create mode 100644 libgimp/gimpresourcechooser.h delete mode 100644 libgimp/gimpresourceselectbutton.h diff --git a/libgimp/gimpbrushselectbutton.c b/libgimp/gimpbrushchooser.c similarity index 72% rename from libgimp/gimpbrushselectbutton.c rename to libgimp/gimpbrushchooser.c index 05cc68bd42..82dd54ec98 100644 --- a/libgimp/gimpbrushselectbutton.c +++ b/libgimp/gimpbrushchooser.c @@ -1,7 +1,7 @@ /* LIBGIMP - The GIMP Library * Copyright (C) 1995-1997 Peter Mattis and Spencer Kimball * - * gimpbrushselectbutton.c + * gimpbrushchooser.c * Copyright (C) 1998 Andy Thomas * * This library is free software: you can redistribute it and/or @@ -29,15 +29,15 @@ #include "gimp.h" #include "gimpuitypes.h" -#include "gimpbrushselectbutton.h" +#include "gimpbrushchooser.h" #include "gimpuimarshal.h" #include "libgimp-intl.h" /** - * SECTION: gimpbrushselectbutton - * @title: GimpBrushSelectButton + * SECTION: gimpbrushchooser + * @title: GimpBrushChooser * @short_description: A button which pops up a brush selection dialog. * * A button which pops up a brush selection dialog. @@ -48,61 +48,61 @@ #define CELL_SIZE 40 -struct _GimpBrushSelectButton +struct _GimpBrushChooser { - GimpResourceSelectButton parent_instance; + GimpResourceChooser parent_instance; - GtkWidget *preview; - GtkWidget *popup; + GtkWidget *preview; + GtkWidget *popup; - GimpBrush *brush; - gint width; - gint height; - GeglBuffer *buffer; - GeglBuffer *mask; + GimpBrush *brush; + gint width; + gint height; + GeglBuffer *buffer; + GeglBuffer *mask; }; -static void gimp_brush_select_button_finalize (GObject *object); +static void gimp_brush_chooser_finalize (GObject *object); -static gboolean gimp_brush_select_on_preview_events (GtkWidget *widget, - GdkEvent *event, - GimpBrushSelectButton *button); +static gboolean gimp_brush_select_on_preview_events (GtkWidget *widget, + GdkEvent *event, + GimpBrushChooser *button); -static void gimp_brush_select_preview_draw (GimpBrushSelectButton *chooser, - GimpPreviewArea *area); +static void gimp_brush_select_preview_draw (GimpBrushChooser *chooser, + GimpPreviewArea *area); -static void gimp_brush_select_button_draw (GimpBrushSelectButton *self); -static void gimp_brush_select_button_get_brush_bitmap (GimpBrushSelectButton *self, - gint width, - gint height); +static void gimp_brush_chooser_draw (GimpBrushChooser *self); +static void gimp_brush_chooser_get_brush_bitmap (GimpBrushChooser *self, + gint width, + gint height); /* Popup methods. */ -static void gimp_brush_select_button_open_popup (GimpBrushSelectButton *button, - gint x, - gint y); -static void gimp_brush_select_button_close_popup (GimpBrushSelectButton *button); +static void gimp_brush_chooser_open_popup (GimpBrushChooser *button, + gint x, + gint y); +static void gimp_brush_chooser_close_popup (GimpBrushChooser *button); static const GtkTargetEntry drag_target = { "application/x-gimp-brush-name", 0, 0 }; -G_DEFINE_FINAL_TYPE (GimpBrushSelectButton, gimp_brush_select_button, GIMP_TYPE_RESOURCE_SELECT_BUTTON) +G_DEFINE_FINAL_TYPE (GimpBrushChooser, gimp_brush_chooser, GIMP_TYPE_RESOURCE_CHOOSER) static void -gimp_brush_select_button_class_init (GimpBrushSelectButtonClass *klass) +gimp_brush_chooser_class_init (GimpBrushChooserClass *klass) { GObjectClass *object_class = G_OBJECT_CLASS (klass); - GimpResourceSelectButtonClass *res_class = GIMP_RESOURCE_SELECT_BUTTON_CLASS (klass); + GimpResourceChooserClass *res_class = GIMP_RESOURCE_CHOOSER_CLASS (klass); - res_class->draw_interior = (void (*)(GimpResourceSelectButton *)) gimp_brush_select_button_draw; + res_class->draw_interior = (void (*)(GimpResourceChooser *)) gimp_brush_chooser_draw; res_class->resource_type = GIMP_TYPE_BRUSH; - object_class->finalize = gimp_brush_select_button_finalize; + object_class->finalize = gimp_brush_chooser_finalize; } static void -gimp_brush_select_button_init (GimpBrushSelectButton *chooser) +gimp_brush_chooser_init (GimpBrushChooser *chooser) { GtkWidget *widget; gint scale_factor = gtk_widget_get_scale_factor (GTK_WIDGET (chooser)); @@ -124,7 +124,7 @@ gimp_brush_select_button_init (GimpBrushSelectButton *chooser) gtk_widget_show (chooser->preview); g_signal_connect_swapped (chooser->preview, "size-allocate", - G_CALLBACK (gimp_brush_select_button_draw), + G_CALLBACK (gimp_brush_chooser_draw), chooser); g_signal_connect (chooser->preview, "event", @@ -134,28 +134,28 @@ gimp_brush_select_button_init (GimpBrushSelectButton *chooser) widget = gtk_button_new_with_mnemonic (_("_Browse...")); gtk_box_pack_start (GTK_BOX (chooser), widget, FALSE, FALSE, 0); - gimp_resource_select_button_set_drag_target (GIMP_RESOURCE_SELECT_BUTTON (chooser), + gimp_resource_chooser_set_drag_target (GIMP_RESOURCE_CHOOSER (chooser), chooser->preview, &drag_target); - gimp_resource_select_button_set_clickable (GIMP_RESOURCE_SELECT_BUTTON (chooser), + gimp_resource_chooser_set_clickable (GIMP_RESOURCE_CHOOSER (chooser), widget); gtk_widget_show (widget); } static void -gimp_brush_select_button_finalize (GObject *object) +gimp_brush_chooser_finalize (GObject *object) { - GimpBrushSelectButton *chooser = GIMP_BRUSH_SELECT_BUTTON (object); + GimpBrushChooser *chooser = GIMP_BRUSH_CHOOSER (object); g_clear_object (&chooser->buffer); g_clear_object (&chooser->mask); - G_OBJECT_CLASS (gimp_brush_select_button_parent_class)->finalize (object); + G_OBJECT_CLASS (gimp_brush_chooser_parent_class)->finalize (object); } /** - * gimp_brush_select_button_new: + * gimp_brush_chooser_new: * @title: (nullable): Title of the dialog to use or %NULL to use the default title. * @label: (nullable): Button label or %NULL for no label. * @resource: (nullable): Initial brush. @@ -170,9 +170,9 @@ gimp_brush_select_button_finalize (GObject *object) * Since: 2.4 */ GtkWidget * -gimp_brush_select_button_new (const gchar *title, - const gchar *label, - GimpResource *resource) +gimp_brush_chooser_new (const gchar *title, + const gchar *label, + GimpResource *resource) { GtkWidget *self; @@ -180,13 +180,13 @@ gimp_brush_select_button_new (const gchar *title, resource = GIMP_RESOURCE (gimp_context_get_brush ()); if (title) - self = g_object_new (GIMP_TYPE_BRUSH_SELECT_BUTTON, + self = g_object_new (GIMP_TYPE_BRUSH_CHOOSER, "title", title, "label", label, "resource", resource, NULL); else - self = g_object_new (GIMP_TYPE_BRUSH_SELECT_BUTTON, + self = g_object_new (GIMP_TYPE_BRUSH_CHOOSER, "label", label, "resource", resource, NULL); @@ -197,20 +197,20 @@ gimp_brush_select_button_new (const gchar *title, /* private functions */ static void -gimp_brush_select_button_draw (GimpBrushSelectButton *chooser) +gimp_brush_chooser_draw (GimpBrushChooser *chooser) { GtkAllocation allocation; gtk_widget_get_allocation (chooser->preview, &allocation); - gimp_brush_select_button_get_brush_bitmap (chooser, allocation.width, allocation.height); + gimp_brush_chooser_get_brush_bitmap (chooser, allocation.width, allocation.height); gimp_brush_select_preview_draw (chooser, GIMP_PREVIEW_AREA (chooser->preview)); } static void -gimp_brush_select_button_get_brush_bitmap (GimpBrushSelectButton *chooser, - gint width, - gint height) +gimp_brush_chooser_get_brush_bitmap (GimpBrushChooser *chooser, + gint width, + gint height) { GimpBrush *brush; @@ -297,9 +297,9 @@ gimp_brush_select_button_get_brush_bitmap (GimpBrushSelectButton *chooser, /* On mouse events in self's preview, popup a zoom view of entire brush */ static gboolean -gimp_brush_select_on_preview_events (GtkWidget *widget, - GdkEvent *event, - GimpBrushSelectButton *self) +gimp_brush_select_on_preview_events (GtkWidget *widget, + GdkEvent *event, + GimpBrushChooser *self) { GdkEventButton *bevent; @@ -311,7 +311,7 @@ gimp_brush_select_on_preview_events (GtkWidget *widget, if (bevent->button == 1) { gtk_grab_add (widget); - gimp_brush_select_button_open_popup (self, + gimp_brush_chooser_open_popup (self, bevent->x, bevent->y); } break; @@ -322,7 +322,7 @@ gimp_brush_select_on_preview_events (GtkWidget *widget, if (bevent->button == 1) { gtk_grab_remove (widget); - gimp_brush_select_button_close_popup (self); + gimp_brush_chooser_close_popup (self); } break; @@ -335,8 +335,8 @@ gimp_brush_select_on_preview_events (GtkWidget *widget, /* Draw a GimpPreviewArea with a given bitmap. */ static void -gimp_brush_select_preview_draw (GimpBrushSelectButton *chooser, - GimpPreviewArea *preview) +gimp_brush_select_preview_draw (GimpBrushChooser *chooser, + GimpPreviewArea *preview) { GimpPreviewArea *area = GIMP_PREVIEW_AREA (preview); GeglBuffer *src_buffer; @@ -394,9 +394,9 @@ gimp_brush_select_preview_draw (GimpBrushSelectButton *chooser, /* popup methods. */ static void -gimp_brush_select_button_open_popup (GimpBrushSelectButton *chooser, - gint x, - gint y) +gimp_brush_chooser_open_popup (GimpBrushChooser *chooser, + gint x, + gint y) { GtkWidget *frame; GtkWidget *preview; @@ -406,7 +406,7 @@ gimp_brush_select_button_open_popup (GimpBrushSelectButton *chooser, gint y_org; if (chooser->popup) - gimp_brush_select_button_close_popup (chooser); + gimp_brush_chooser_close_popup (chooser); if (chooser->width <= CELL_SIZE && chooser->height <= CELL_SIZE) return; @@ -450,7 +450,7 @@ gimp_brush_select_button_open_popup (GimpBrushSelectButton *chooser, } static void -gimp_brush_select_button_close_popup (GimpBrushSelectButton *self) +gimp_brush_chooser_close_popup (GimpBrushChooser *self) { g_clear_pointer (&self->popup, gtk_widget_destroy); } diff --git a/libgimp/gimpfontselectbutton.h b/libgimp/gimpbrushchooser.h similarity index 59% rename from libgimp/gimpfontselectbutton.h rename to libgimp/gimpbrushchooser.h index 3fa1d46691..1a0e05bf7d 100644 --- a/libgimp/gimpfontselectbutton.h +++ b/libgimp/gimpbrushchooser.h @@ -1,7 +1,7 @@ /* LIBGIMP - The GIMP Library * Copyright (C) 1995-1997 Peter Mattis and Spencer Kimball * - * gimpfontselectbutton.h + * gimpbrushchooser.h * * This library is free software: you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -22,25 +22,22 @@ #error "Only can be included directly." #endif -#ifndef __GIMP_FONT_SELECT_BUTTON_H__ -#define __GIMP_FONT_SELECT_BUTTON_H__ +#ifndef __GIMP_BRUSH_CHOOSER_H__ +#define __GIMP_BRUSH_CHOOSER_H__ -#include +#include G_BEGIN_DECLS -#define GIMP_TYPE_FONT_SELECT_BUTTON (gimp_font_select_button_get_type ()) -G_DECLARE_FINAL_TYPE (GimpFontSelectButton, - gimp_font_select_button, - GIMP, FONT_SELECT_BUTTON, - GimpResourceSelectButton) +#define GIMP_TYPE_BRUSH_CHOOSER (gimp_brush_chooser_get_type ()) +G_DECLARE_FINAL_TYPE (GimpBrushChooser, gimp_brush_chooser, GIMP, BRUSH_CHOOSER, GimpResourceChooser) -GtkWidget * gimp_font_select_button_new (const gchar *title, - const gchar *label, - GimpResource *resource); +GtkWidget * gimp_brush_chooser_new (const gchar *title, + const gchar *label, + GimpResource *resource); G_END_DECLS -#endif /* __GIMP_FONT_SELECT_BUTTON_H__ */ +#endif /* __GIMP_BRUSH_CHOOSER_H__ */ diff --git a/libgimp/gimpfontselectbutton.c b/libgimp/gimpfontchooser.c similarity index 56% rename from libgimp/gimpfontselectbutton.c rename to libgimp/gimpfontchooser.c index c1f683e2c6..c8c048cbec 100644 --- a/libgimp/gimpfontselectbutton.c +++ b/libgimp/gimpfontchooser.c @@ -1,7 +1,7 @@ /* LIBGIMP - The GIMP Library * Copyright (C) 1995-1997 Peter Mattis and Spencer Kimball * - * gimpfontselectbutton.c + * gimpfontchooser.c * Copyright (C) 2003 Sven Neumann * * This library is free software: you can redistribute it and/or @@ -29,50 +29,48 @@ #include "gimp.h" #include "gimpuitypes.h" -#include "gimpfontselectbutton.h" +#include "gimpfontchooser.h" #include "gimpuimarshal.h" #include "libgimp-intl.h" /** - * SECTION: gimpfontselectbutton - * @title: GimpFontSelectButton + * SECTION: gimpfontchooser + * @title: GimpFontChooser * @short_description: A button which pops up a font selection dialog. * * A button which pops up a font selection dialog. **/ -struct _GimpFontSelectButton +struct _GimpFontChooser { - GimpResourceSelectButton parent_instance; + GimpResourceChooser parent_instance; - GtkWidget *label; + GtkWidget *label; }; -static void gimp_font_select_button_draw_interior (GimpResourceSelectButton *self); +static void gimp_font_chooser_draw_interior (GimpResourceChooser *self); static const GtkTargetEntry drag_target = { "application/x-gimp-font-name", 0, 0 }; -G_DEFINE_FINAL_TYPE (GimpFontSelectButton, - gimp_font_select_button, - GIMP_TYPE_RESOURCE_SELECT_BUTTON) +G_DEFINE_FINAL_TYPE (GimpFontChooser, gimp_font_chooser, GIMP_TYPE_RESOURCE_CHOOSER) static void -gimp_font_select_button_class_init (GimpFontSelectButtonClass *klass) +gimp_font_chooser_class_init (GimpFontChooserClass *klass) { - GimpResourceSelectButtonClass *superclass = GIMP_RESOURCE_SELECT_BUTTON_CLASS (klass); + GimpResourceChooserClass *superclass = GIMP_RESOURCE_CHOOSER_CLASS (klass); - superclass->draw_interior = gimp_font_select_button_draw_interior; + superclass->draw_interior = gimp_font_chooser_draw_interior; superclass->resource_type = GIMP_TYPE_FONT; } static void -gimp_font_select_button_init (GimpFontSelectButton *self) +gimp_font_chooser_init (GimpFontChooser *self) { GtkWidget *button; GtkWidget *hbox; @@ -93,22 +91,20 @@ gimp_font_select_button_init (GimpFontSelectButton *self) gtk_widget_show_all (GTK_WIDGET (self)); - gimp_resource_select_button_set_drag_target (GIMP_RESOURCE_SELECT_BUTTON (self), - hbox, - &drag_target); + gimp_resource_chooser_set_drag_target (GIMP_RESOURCE_CHOOSER (self), + hbox, &drag_target); - gimp_resource_select_button_set_clickable (GIMP_RESOURCE_SELECT_BUTTON (self), - button); + gimp_resource_chooser_set_clickable (GIMP_RESOURCE_CHOOSER (self), button); } static void -gimp_font_select_button_draw_interior (GimpResourceSelectButton *self) +gimp_font_chooser_draw_interior (GimpResourceChooser *self) { - GimpFontSelectButton *font_select= GIMP_FONT_SELECT_BUTTON (self); - GimpResource *resource; - gchar *name = NULL; + GimpFontChooser *font_select= GIMP_FONT_CHOOSER (self); + GimpResource *resource; + gchar *name = NULL; - resource = gimp_resource_select_button_get_resource (self); + resource = gimp_resource_chooser_get_resource (self); if (resource) name = gimp_resource_get_name (resource); @@ -118,7 +114,7 @@ gimp_font_select_button_draw_interior (GimpResourceSelectButton *self) /** - * gimp_font_select_button_new: + * gimp_font_chooser_new: * @title: (nullable): Title of the dialog to use or %NULL to use the default title. * @label: (nullable): Button label or %NULL for no label. * @resource: (nullable): Initial font. @@ -133,11 +129,11 @@ gimp_font_select_button_draw_interior (GimpResourceSelectButton *self) * Since: 2.4 */ GtkWidget * -gimp_font_select_button_new (const gchar *title, - const gchar *label, - GimpResource *resource) +gimp_font_chooser_new (const gchar *title, + const gchar *label, + GimpResource *resource) { - GtkWidget *self; + GtkWidget *chooser; g_return_val_if_fail (resource == NULL || GIMP_IS_FONT (resource), NULL); @@ -145,18 +141,18 @@ gimp_font_select_button_new (const gchar *title, resource = GIMP_RESOURCE (gimp_context_get_font ()); if (title) - self = g_object_new (GIMP_TYPE_FONT_SELECT_BUTTON, - "title", title, - "label", label, - "resource", resource, - NULL); + chooser = g_object_new (GIMP_TYPE_FONT_CHOOSER, + "title", title, + "label", label, + "resource", resource, + NULL); else - self = g_object_new (GIMP_TYPE_FONT_SELECT_BUTTON, - "label", label, - "resource", resource, - NULL); + chooser = g_object_new (GIMP_TYPE_FONT_CHOOSER, + "label", label, + "resource", resource, + NULL); - gimp_font_select_button_draw_interior (GIMP_RESOURCE_SELECT_BUTTON (self)); + gimp_font_chooser_draw_interior (GIMP_RESOURCE_CHOOSER (chooser)); - return self; + return chooser; } diff --git a/libgimp/gimpbrushselectbutton.h b/libgimp/gimpfontchooser.h similarity index 58% rename from libgimp/gimpbrushselectbutton.h rename to libgimp/gimpfontchooser.h index 11ab353232..f6b1c4bb53 100644 --- a/libgimp/gimpbrushselectbutton.h +++ b/libgimp/gimpfontchooser.h @@ -1,7 +1,7 @@ /* LIBGIMP - The GIMP Library * Copyright (C) 1995-1997 Peter Mattis and Spencer Kimball * - * gimpbrushselectbutton.h + * gimpfontchooser.h * * This library is free software: you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -22,25 +22,22 @@ #error "Only can be included directly." #endif -#ifndef __GIMP_BRUSH_SELECT_BUTTON_H__ -#define __GIMP_BRUSH_SELECT_BUTTON_H__ +#ifndef __GIMP_FONT_CHOOSER_H__ +#define __GIMP_FONT_CHOOSER_H__ -#include +#include G_BEGIN_DECLS -#define GIMP_TYPE_BRUSH_SELECT_BUTTON (gimp_brush_select_button_get_type ()) -G_DECLARE_FINAL_TYPE (GimpBrushSelectButton, - gimp_brush_select_button, - GIMP, BRUSH_SELECT_BUTTON, - GimpResourceSelectButton) +#define GIMP_TYPE_FONT_CHOOSER (gimp_font_chooser_get_type ()) +G_DECLARE_FINAL_TYPE (GimpFontChooser, gimp_font_chooser, GIMP, FONT_CHOOSER, GimpResourceChooser) -GtkWidget * gimp_brush_select_button_new (const gchar *title, - const gchar *label, - GimpResource *resource); +GtkWidget * gimp_font_chooser_new (const gchar *title, + const gchar *label, + GimpResource *resource); G_END_DECLS -#endif /* __GIMP_BRUSH_SELECT_BUTTON_H__ */ +#endif /* __GIMP_FONT_CHOOSER_H__ */ diff --git a/libgimp/gimpgradientselectbutton.c b/libgimp/gimpgradientchooser.c similarity index 67% rename from libgimp/gimpgradientselectbutton.c rename to libgimp/gimpgradientchooser.c index b3a05f633c..326856ba7e 100644 --- a/libgimp/gimpgradientselectbutton.c +++ b/libgimp/gimpgradientchooser.c @@ -1,7 +1,7 @@ /* LIBGIMP - The GIMP Library * Copyright (C) 1995-1997 Peter Mattis and Spencer Kimball * - * gimpgradientselectbutton.c + * gimpgradientchooser.c * Copyright (C) 1998 Andy Thomas * * This library is free software: you can redistribute it and/or @@ -29,62 +29,62 @@ #include "gimp.h" #include "gimpuitypes.h" -#include "gimpgradientselectbutton.h" +#include "gimpgradientchooser.h" #include "gimpuimarshal.h" #include "libgimp-intl.h" /** - * SECTION: gimpgradientselectbutton - * @title: GimpGradientSelectButton + * SECTION: gimpgradientchooser + * @title: GimpGradientChooser * @short_description: A button which pops up a gradient select dialog. * * A button which pops up a gradient select dialog. **/ -struct _GimpGradientSelectButton +struct _GimpGradientChooser { - GimpResourceSelectButton parent_instance; + GimpResourceChooser parent_instance; - GtkWidget *preview; + GtkWidget *preview; }; /* local function prototypes */ -static void gimp_gradient_select_button_draw_interior (GimpResourceSelectButton *self); +static void gimp_gradient_chooser_draw_interior (GimpResourceChooser *self); -static void gimp_gradient_select_preview_size_allocate (GtkWidget *widget, - GtkAllocation *allocation, - GimpGradientSelectButton *self); -static gboolean gimp_gradient_select_preview_draw_handler (GtkWidget *preview, - cairo_t *cr, - GimpGradientSelectButton *self); +static void gimp_gradient_select_preview_size_allocate (GtkWidget *widget, + GtkAllocation *allocation, + GimpGradientChooser *self); +static gboolean gimp_gradient_select_preview_draw_handler (GtkWidget *preview, + cairo_t *cr, + GimpGradientChooser *self); static const GtkTargetEntry drag_target = { "application/x-gimp-gradient-name", 0 }; -G_DEFINE_FINAL_TYPE (GimpGradientSelectButton, - gimp_gradient_select_button, - GIMP_TYPE_RESOURCE_SELECT_BUTTON) +G_DEFINE_FINAL_TYPE (GimpGradientChooser, + gimp_gradient_chooser, + GIMP_TYPE_RESOURCE_CHOOSER) /* Initial dimensions of widget. */ #define CELL_HEIGHT 18 #define CELL_WIDTH 84 static void -gimp_gradient_select_button_class_init (GimpGradientSelectButtonClass *klass) +gimp_gradient_chooser_class_init (GimpGradientChooserClass *klass) { - GimpResourceSelectButtonClass *superclass = GIMP_RESOURCE_SELECT_BUTTON_CLASS (klass); + GimpResourceChooserClass *superclass = GIMP_RESOURCE_CHOOSER_CLASS (klass); - superclass->draw_interior = gimp_gradient_select_button_draw_interior; + superclass->draw_interior = gimp_gradient_chooser_draw_interior; superclass->resource_type = GIMP_TYPE_GRADIENT; } static void -gimp_gradient_select_button_init (GimpGradientSelectButton *self) +gimp_gradient_chooser_init (GimpGradientChooser *self) { GtkWidget *button; @@ -105,25 +105,23 @@ gimp_gradient_select_button_init (GimpGradientSelectButton *self) gtk_widget_show_all (GTK_WIDGET (self)); - gimp_resource_select_button_set_drag_target (GIMP_RESOURCE_SELECT_BUTTON (self), - self->preview, - &drag_target); + gimp_resource_chooser_set_drag_target (GIMP_RESOURCE_CHOOSER (self), + self->preview, &drag_target); - gimp_resource_select_button_set_clickable (GIMP_RESOURCE_SELECT_BUTTON (self), - button); + gimp_resource_chooser_set_clickable (GIMP_RESOURCE_CHOOSER (self), button); } static void -gimp_gradient_select_button_draw_interior (GimpResourceSelectButton *self) +gimp_gradient_chooser_draw_interior (GimpResourceChooser *self) { - GimpGradientSelectButton *gradient_select = GIMP_GRADIENT_SELECT_BUTTON (self); + GimpGradientChooser *gradient_select = GIMP_GRADIENT_CHOOSER (self); gtk_widget_queue_draw (gradient_select->preview); } /** - * gimp_gradient_select_button_new: + * gimp_gradient_chooser_new: * @title: (nullable): Title of the dialog to use or %NULL to use the default title. * @label: (nullable): Button label or %NULL for no label. * @gradient: (nullable): Initial gradient. @@ -136,9 +134,9 @@ gimp_gradient_select_button_draw_interior (GimpResourceSelectButton *self) * Since: 2.4 */ GtkWidget * -gimp_gradient_select_button_new (const gchar *title, - const gchar *label, - GimpResource *gradient) +gimp_gradient_chooser_new (const gchar *title, + const gchar *label, + GimpResource *gradient) { GtkWidget *self; @@ -146,18 +144,18 @@ gimp_gradient_select_button_new (const gchar *title, gradient = GIMP_RESOURCE (gimp_context_get_gradient ()); if (title) - self = g_object_new (GIMP_TYPE_GRADIENT_SELECT_BUTTON, + self = g_object_new (GIMP_TYPE_GRADIENT_CHOOSER, "title", title, "label", label, "resource", gradient, NULL); else - self = g_object_new (GIMP_TYPE_GRADIENT_SELECT_BUTTON, + self = g_object_new (GIMP_TYPE_GRADIENT_CHOOSER, "label", label, "resource", gradient, NULL); - gimp_gradient_select_button_draw_interior (GIMP_RESOURCE_SELECT_BUTTON (self)); + gimp_gradient_chooser_draw_interior (GIMP_RESOURCE_CHOOSER (self)); return self; } @@ -170,10 +168,10 @@ gimp_gradient_select_button_new (const gchar *title, * Return success. */ static gboolean -get_gradient_data (GimpGradientSelectButton *self, - gint allocation_width, - gint *sample_count, - gdouble **sample_array) +get_gradient_data (GimpGradientChooser *self, + gint allocation_width, + gint *sample_count, + gdouble **sample_array) { GimpGradient *gradient; gboolean result; @@ -204,9 +202,9 @@ get_gradient_data (GimpGradientSelectButton *self, /* Called on widget resized. */ static void -gimp_gradient_select_preview_size_allocate (GtkWidget *widget, - GtkAllocation *allocation, - GimpGradientSelectButton *self) +gimp_gradient_select_preview_size_allocate (GtkWidget *widget, + GtkAllocation *allocation, + GimpGradientChooser *self) { /* Do nothing. * @@ -225,10 +223,10 @@ gimp_gradient_select_preview_size_allocate (GtkWidget *widget, * This understands mostly cairo, and little about gradient. */ static void -gimp_gradient_select_preview_draw (cairo_t *cr, - gint src_width, - gint dest_width, - gdouble *src) +gimp_gradient_select_preview_draw (cairo_t *cr, + gint src_width, + gint dest_width, + gdouble *src) { cairo_pattern_t *pattern; cairo_surface_t *surface; @@ -270,8 +268,6 @@ gimp_gradient_select_preview_draw (cairo_t *cr, cairo_paint (cr); } - - /* Handles a draw signal. * Draw self, i.e. interior of button. * @@ -280,9 +276,9 @@ gimp_gradient_select_preview_draw (cairo_t *cr, * Is passed neither gradient nor attributes of gradient: get them now from self. */ static gboolean -gimp_gradient_select_preview_draw_handler (GtkWidget *widget, - cairo_t *cr, - GimpGradientSelectButton *self) +gimp_gradient_select_preview_draw_handler (GtkWidget *widget, + cairo_t *cr, + GimpGradientChooser *self) { GtkAllocation allocation; diff --git a/libgimp/gimppatternselectbutton.h b/libgimp/gimpgradientchooser.h similarity index 58% rename from libgimp/gimppatternselectbutton.h rename to libgimp/gimpgradientchooser.h index fec528d0e5..db322017bb 100644 --- a/libgimp/gimppatternselectbutton.h +++ b/libgimp/gimpgradientchooser.h @@ -1,7 +1,7 @@ /* LIBGIMP - The GIMP Library * Copyright (C) 1995-1997 Peter Mattis and Spencer Kimball * - * gimppatternselectbutton.h + * gimpgradientchooser.h * * This library is free software: you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -22,25 +22,22 @@ #error "Only can be included directly." #endif -#ifndef __GIMP_PATTERN_SELECT_BUTTON_H__ -#define __GIMP_PATTERN_SELECT_BUTTON_H__ +#ifndef __GIMP_GRADIENT_CHOOSER_H__ +#define __GIMP_GRADIENT_CHOOSER_H__ -#include +#include G_BEGIN_DECLS -#define GIMP_TYPE_PATTERN_SELECT_BUTTON (gimp_pattern_select_button_get_type ()) -G_DECLARE_FINAL_TYPE (GimpPatternSelectButton, - gimp_pattern_select_button, - GIMP, PATTERN_SELECT_BUTTON, - GimpResourceSelectButton) +#define GIMP_TYPE_GRADIENT_CHOOSER (gimp_gradient_chooser_get_type ()) +G_DECLARE_FINAL_TYPE (GimpGradientChooser, gimp_gradient_chooser, GIMP, GRADIENT_CHOOSER, GimpResourceChooser) -GtkWidget * gimp_pattern_select_button_new (const gchar *title, - const gchar *label, - GimpResource *resource); +GtkWidget * gimp_gradient_chooser_new (const gchar *title, + const gchar *label, + GimpResource *gradient); G_END_DECLS -#endif /* __GIMP_PATTERN_SELECT_BUTTON_H__ */ +#endif /* __GIMP_GRADIENT_CHOOSER_H__ */ diff --git a/libgimp/gimpgradientselectbutton.h b/libgimp/gimpgradientselectbutton.h deleted file mode 100644 index 78ed0c2455..0000000000 --- a/libgimp/gimpgradientselectbutton.h +++ /dev/null @@ -1,47 +0,0 @@ -/* LIBGIMP - The GIMP Library - * Copyright (C) 1995-1997 Peter Mattis and Spencer Kimball - * - * gimpgradientselectbutton.h - * - * This library is free software: you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * 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 - * Lesser 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 - * . - */ - -#if !defined (__GIMP_UI_H_INSIDE__) && !defined (GIMP_COMPILATION) -#error "Only can be included directly." -#endif - -#ifndef __GIMP_GRADIENT_SELECT_BUTTON_H__ -#define __GIMP_GRADIENT_SELECT_BUTTON_H__ - -#include - -G_BEGIN_DECLS - -#define GIMP_TYPE_GRADIENT_SELECT_BUTTON (gimp_gradient_select_button_get_type ()) -G_DECLARE_FINAL_TYPE (GimpGradientSelectButton, - gimp_gradient_select_button, - GIMP, - GRADIENT_SELECT_BUTTON, - GimpResourceSelectButton) - - -GtkWidget * gimp_gradient_select_button_new (const gchar *title, - const gchar *label, - GimpResource *gradient); - - -G_END_DECLS - -#endif /* __GIMP_GRADIENT_SELECT_BUTTON_H__ */ diff --git a/libgimp/gimppaletteselectbutton.c b/libgimp/gimppalettechooser.c similarity index 63% rename from libgimp/gimppaletteselectbutton.c rename to libgimp/gimppalettechooser.c index 1c219ec8f1..ca5b7e8aef 100644 --- a/libgimp/gimppaletteselectbutton.c +++ b/libgimp/gimppalettechooser.c @@ -1,7 +1,7 @@ /* LIBGIMP - The GIMP Library * Copyright (C) 1995-1997 Peter Mattis and Spencer Kimball * - * gimppaletteselectbutton.c + * gimppalettechooser.c * Copyright (C) 2004 Michael Natterer * * This library is free software: you can redistribute it and/or @@ -29,51 +29,49 @@ #include "gimp.h" #include "gimpuitypes.h" -#include "gimppaletteselectbutton.h" +#include "gimppalettechooser.h" #include "gimpuimarshal.h" #include "libgimp-intl.h" /** - * SECTION: gimppaletteselectbutton - * @title: GimpPaletteSelectButton + * SECTION: gimppalettechooser + * @title: GimpPaletteChooser * @short_description: A button which pops up a palette selection dialog. * * A button which pops up a palette selection dialog. **/ -struct _GimpPaletteSelectButton +struct _GimpPaletteChooser { - GimpResourceSelectButton parent_instance; + GimpResourceChooser parent_instance; - GtkWidget *label; - GtkWidget *button; + GtkWidget *label; + GtkWidget *button; }; -static void gimp_palette_select_button_draw_interior (GimpResourceSelectButton *self); +static void gimp_palette_chooser_draw_interior (GimpResourceChooser *self); static const GtkTargetEntry drag_target = { "application/x-gimp-palette-name", 0, 0 }; -G_DEFINE_FINAL_TYPE (GimpPaletteSelectButton, - gimp_palette_select_button, - GIMP_TYPE_RESOURCE_SELECT_BUTTON) +G_DEFINE_FINAL_TYPE (GimpPaletteChooser, gimp_palette_chooser, GIMP_TYPE_RESOURCE_CHOOSER) static void -gimp_palette_select_button_class_init (GimpPaletteSelectButtonClass *klass) +gimp_palette_chooser_class_init (GimpPaletteChooserClass *klass) { - GimpResourceSelectButtonClass *superclass = GIMP_RESOURCE_SELECT_BUTTON_CLASS (klass); + GimpResourceChooserClass *superclass = GIMP_RESOURCE_CHOOSER_CLASS (klass); - superclass->draw_interior = gimp_palette_select_button_draw_interior; + superclass->draw_interior = gimp_palette_chooser_draw_interior; superclass->resource_type = GIMP_TYPE_PALETTE; } static void -gimp_palette_select_button_init (GimpPaletteSelectButton *self) +gimp_palette_chooser_init (GimpPaletteChooser *self) { GtkWidget *hbox; GtkWidget *image; @@ -93,21 +91,19 @@ gimp_palette_select_button_init (GimpPaletteSelectButton *self) gtk_widget_show_all (GTK_WIDGET (self)); - gimp_resource_select_button_set_drag_target (GIMP_RESOURCE_SELECT_BUTTON (self), - hbox, - &drag_target); - gimp_resource_select_button_set_clickable (GIMP_RESOURCE_SELECT_BUTTON (self), - self->button); + gimp_resource_chooser_set_drag_target (GIMP_RESOURCE_CHOOSER (self), + hbox, &drag_target); + gimp_resource_chooser_set_clickable (GIMP_RESOURCE_CHOOSER (self), self->button); } static void -gimp_palette_select_button_draw_interior (GimpResourceSelectButton *self) +gimp_palette_chooser_draw_interior (GimpResourceChooser *self) { - GimpPaletteSelectButton *palette_select= GIMP_PALETTE_SELECT_BUTTON (self); + GimpPaletteChooser *palette_select= GIMP_PALETTE_CHOOSER (self); GimpResource *resource; gchar *name = NULL; - resource = gimp_resource_select_button_get_resource (self); + resource = gimp_resource_chooser_get_resource (self); if (resource) name = gimp_resource_get_name (resource); @@ -115,9 +111,8 @@ gimp_palette_select_button_draw_interior (GimpResourceSelectButton *self) gtk_label_set_text (GTK_LABEL (palette_select->label), name); } - /** - * gimp_palette_select_button_new: + * gimp_palette_chooser_new: * @title: (nullable): Title of the dialog to use or %NULL to use the default title. * @label: (nullable): Button label or %NULL for no label. * @resource: (nullable): Initial palette. @@ -132,9 +127,9 @@ gimp_palette_select_button_draw_interior (GimpResourceSelectButton *self) * Since: 2.4 */ GtkWidget * -gimp_palette_select_button_new (const gchar *title, - const gchar *label, - GimpResource *resource) +gimp_palette_chooser_new (const gchar *title, + const gchar *label, + GimpResource *resource) { GtkWidget *self; @@ -142,18 +137,18 @@ gimp_palette_select_button_new (const gchar *title, resource = GIMP_RESOURCE (gimp_context_get_palette ()); if (title) - self = g_object_new (GIMP_TYPE_PALETTE_SELECT_BUTTON, + self = g_object_new (GIMP_TYPE_PALETTE_CHOOSER, "title", title, "label", label, "resource", resource, NULL); else - self = g_object_new (GIMP_TYPE_PALETTE_SELECT_BUTTON, + self = g_object_new (GIMP_TYPE_PALETTE_CHOOSER, "label", label, "resource", resource, NULL); - gimp_palette_select_button_draw_interior (GIMP_RESOURCE_SELECT_BUTTON (self)); + gimp_palette_chooser_draw_interior (GIMP_RESOURCE_CHOOSER (self)); return self; } diff --git a/libgimp/gimppaletteselectbutton.h b/libgimp/gimppalettechooser.h similarity index 59% rename from libgimp/gimppaletteselectbutton.h rename to libgimp/gimppalettechooser.h index 9dbde2cb6f..b43778e0f1 100644 --- a/libgimp/gimppaletteselectbutton.h +++ b/libgimp/gimppalettechooser.h @@ -22,25 +22,22 @@ #error "Only can be included directly." #endif -#ifndef __GIMP_PALETTE_SELECT_BUTTON_H__ -#define __GIMP_PALETTE_SELECT_BUTTON_H__ +#ifndef __GIMP_PALETTE_CHOOSER_H__ +#define __GIMP_PALETTE_CHOOSER_H__ -#include +#include G_BEGIN_DECLS -#define GIMP_TYPE_PALETTE_SELECT_BUTTON (gimp_palette_select_button_get_type ()) -G_DECLARE_FINAL_TYPE (GimpPaletteSelectButton, - gimp_palette_select_button, - GIMP, PALETTE_SELECT_BUTTON, - GimpResourceSelectButton) +#define GIMP_TYPE_PALETTE_CHOOSER (gimp_palette_chooser_get_type ()) +G_DECLARE_FINAL_TYPE (GimpPaletteChooser, gimp_palette_chooser, GIMP, PALETTE_CHOOSER, GimpResourceChooser) -GtkWidget * gimp_palette_select_button_new (const gchar *title, - const gchar *label, - GimpResource *resource); +GtkWidget * gimp_palette_chooser_new (const gchar *title, + const gchar *label, + GimpResource *resource); G_END_DECLS -#endif /* __GIMP_PALETTE_SELECT_BUTTON_H__ */ +#endif /* __GIMP_PALETTE_CHOOSER_H__ */ diff --git a/libgimp/gimppatternselectbutton.c b/libgimp/gimppatternchooser.c similarity index 68% rename from libgimp/gimppatternselectbutton.c rename to libgimp/gimppatternchooser.c index 522128920e..cf6538ef96 100644 --- a/libgimp/gimppatternselectbutton.c +++ b/libgimp/gimppatternchooser.c @@ -1,7 +1,7 @@ /* LIBGIMP - The GIMP Library * Copyright (C) 1995-1997 Peter Mattis and Spencer Kimball * - * gimppatternselectbutton.c + * gimppatternchooser.c * Copyright (C) 1998 Andy Thomas * * This library is free software: you can redistribute it and/or @@ -29,15 +29,15 @@ #include "gimp.h" #include "gimpuitypes.h" -#include "gimppatternselectbutton.h" +#include "gimppatternchooser.h" #include "gimpuimarshal.h" #include "libgimp-intl.h" /** - * SECTION: gimppatternselectbutton - * @title: GimpPatternSelectButton + * SECTION: gimppatternchooser + * @title: GimpPatternChooser * @short_description: A button which pops up a pattern selection dialog. * * A button which pops up a pattern selection dialog. @@ -48,39 +48,39 @@ #define CELL_SIZE 40 -struct _GimpPatternSelectButton +struct _GimpPatternChooser { - GimpResourceSelectButton parent_instance; + GimpResourceChooser parent_instance; - GtkWidget *preview; - GtkWidget *popup; + GtkWidget *preview; + GtkWidget *popup; - GimpPattern *pattern; - GeglBuffer *buffer; - gint width; - gint height; + GimpPattern *pattern; + GeglBuffer *buffer; + gint width; + gint height; }; /* local */ -static gboolean gimp_pattern_select_on_preview_events (GtkWidget *widget, - GdkEvent *event, - GimpPatternSelectButton *button); +static gboolean gimp_pattern_select_on_preview_events (GtkWidget *widget, + GdkEvent *event, + GimpPatternChooser *button); /* local drawing methods. */ -static void gimp_pattern_select_preview_fill_draw (GimpPatternSelectButton *chooser, - GimpPreviewArea *area); +static void gimp_pattern_select_preview_fill_draw (GimpPatternChooser *chooser, + GimpPreviewArea *area); -static void gimp_pattern_select_button_draw (GimpResourceSelectButton *self); -static void gimp_pattern_select_button_get_pattern_image (GimpPatternSelectButton *self, - gint width, - gint height); +static void gimp_pattern_chooser_draw (GimpResourceChooser *self); +static void gimp_pattern_chooser_get_pattern_image (GimpPatternChooser *self, + gint width, + gint height); /* Popup methods. */ -static void gimp_pattern_select_button_open_popup (GimpPatternSelectButton *button, - gint x, - gint y); -static void gimp_pattern_select_button_close_popup (GimpPatternSelectButton *button); +static void gimp_pattern_chooser_open_popup (GimpPatternChooser *button, + gint x, + gint y); +static void gimp_pattern_chooser_close_popup (GimpPatternChooser *button); /* A GtkTargetEntry has a string and two ints. @@ -88,20 +88,20 @@ static void gimp_pattern_select_button_close_popup (GimpPatternSelectB */ static const GtkTargetEntry drag_target = { "application/x-gimp-pattern-name", 0, 0 }; -G_DEFINE_FINAL_TYPE (GimpPatternSelectButton, gimp_pattern_select_button, GIMP_TYPE_RESOURCE_SELECT_BUTTON) +G_DEFINE_FINAL_TYPE (GimpPatternChooser, gimp_pattern_chooser, GIMP_TYPE_RESOURCE_CHOOSER) static void -gimp_pattern_select_button_class_init (GimpPatternSelectButtonClass *klass) +gimp_pattern_chooser_class_init (GimpPatternChooserClass *klass) { - GimpResourceSelectButtonClass *superclass = GIMP_RESOURCE_SELECT_BUTTON_CLASS (klass); + GimpResourceChooserClass *superclass = GIMP_RESOURCE_CHOOSER_CLASS (klass); - superclass->draw_interior = gimp_pattern_select_button_draw; + superclass->draw_interior = gimp_pattern_chooser_draw; superclass->resource_type = GIMP_TYPE_PATTERN; } static void -gimp_pattern_select_button_init (GimpPatternSelectButton *self) +gimp_pattern_chooser_init (GimpPatternChooser *self) { GtkWidget *frame; GtkWidget *button; @@ -119,7 +119,7 @@ gimp_pattern_select_button_init (GimpPatternSelectButton *self) gtk_widget_show (self->preview); g_signal_connect_swapped (self->preview, "size-allocate", - G_CALLBACK (gimp_pattern_select_button_draw), + G_CALLBACK (gimp_pattern_chooser_draw), self); g_signal_connect (self->preview, "event", @@ -129,17 +129,15 @@ gimp_pattern_select_button_init (GimpPatternSelectButton *self) button = gtk_button_new_with_mnemonic (_("_Browse...")); gtk_box_pack_start (GTK_BOX (self), button, FALSE, FALSE, 0); - gimp_resource_select_button_set_drag_target (GIMP_RESOURCE_SELECT_BUTTON (self), - self->preview, - &drag_target); + gimp_resource_chooser_set_drag_target (GIMP_RESOURCE_CHOOSER (self), + self->preview, &drag_target); - gimp_resource_select_button_set_clickable (GIMP_RESOURCE_SELECT_BUTTON (self), - button); + gimp_resource_chooser_set_clickable (GIMP_RESOURCE_CHOOSER (self), button); gtk_widget_show (button); } /** - * gimp_pattern_select_button_new: + * gimp_pattern_chooser_new: * @title: (nullable): Title of the dialog to use or %NULL to use the default title. * @label: (nullable): Button label or %NULL for no label. * @resource: (nullable): Initial pattern. @@ -154,7 +152,7 @@ gimp_pattern_select_button_init (GimpPatternSelectButton *self) * Since: 2.4 */ GtkWidget * -gimp_pattern_select_button_new (const gchar *title, +gimp_pattern_chooser_new (const gchar *title, const gchar *label, GimpResource *resource) { @@ -165,39 +163,39 @@ gimp_pattern_select_button_new (const gchar *title, g_return_val_if_fail (GIMP_IS_PATTERN (resource), NULL); if (title) - self = g_object_new (GIMP_TYPE_PATTERN_SELECT_BUTTON, + self = g_object_new (GIMP_TYPE_PATTERN_CHOOSER, "title", title, "label", label, "resource", resource, NULL); else - self = g_object_new (GIMP_TYPE_PATTERN_SELECT_BUTTON, + self = g_object_new (GIMP_TYPE_PATTERN_CHOOSER, "label", label, "resource", resource, NULL); - gimp_pattern_select_button_draw (GIMP_RESOURCE_SELECT_BUTTON (self)); + gimp_pattern_chooser_draw (GIMP_RESOURCE_CHOOSER (self)); return self; } static void -gimp_pattern_select_button_draw (GimpResourceSelectButton *chooser) +gimp_pattern_chooser_draw (GimpResourceChooser *chooser) { - GimpPatternSelectButton *pchooser = GIMP_PATTERN_SELECT_BUTTON (chooser); - GtkAllocation allocation; + GimpPatternChooser *pchooser = GIMP_PATTERN_CHOOSER (chooser); + GtkAllocation allocation; gtk_widget_get_allocation (pchooser->preview, &allocation); - gimp_pattern_select_button_get_pattern_image (pchooser, allocation.width, allocation.height); + gimp_pattern_chooser_get_pattern_image (pchooser, allocation.width, allocation.height); gimp_pattern_select_preview_fill_draw (pchooser, GIMP_PREVIEW_AREA (pchooser->preview)); } static void -gimp_pattern_select_button_get_pattern_image (GimpPatternSelectButton *chooser, - gint width, - gint height) +gimp_pattern_chooser_get_pattern_image (GimpPatternChooser *chooser, + gint width, + gint height) { GimpPattern *pattern; @@ -224,9 +222,9 @@ gimp_pattern_select_button_get_pattern_image (GimpPatternSelectButton *chooser, /* On mouse events in self's preview, popup a zoom view of entire pattern */ static gboolean -gimp_pattern_select_on_preview_events (GtkWidget *widget, - GdkEvent *event, - GimpPatternSelectButton *self) +gimp_pattern_select_on_preview_events (GtkWidget *widget, + GdkEvent *event, + GimpPatternChooser *self) { GdkEventButton *bevent; @@ -238,7 +236,7 @@ gimp_pattern_select_on_preview_events (GtkWidget *widget, if (bevent->button == 1) { gtk_grab_add (widget); - gimp_pattern_select_button_open_popup (self, + gimp_pattern_chooser_open_popup (self, bevent->x, bevent->y); } break; @@ -249,7 +247,7 @@ gimp_pattern_select_on_preview_events (GtkWidget *widget, if (bevent->button == 1) { gtk_grab_remove (widget); - gimp_pattern_select_button_close_popup (self); + gimp_pattern_chooser_close_popup (self); } break; @@ -262,8 +260,8 @@ gimp_pattern_select_on_preview_events (GtkWidget *widget, /* Fill a GimpPreviewArea with a image then draw. */ static void -gimp_pattern_select_preview_fill_draw (GimpPatternSelectButton *chooser, - GimpPreviewArea *area) +gimp_pattern_select_preview_fill_draw (GimpPatternChooser *chooser, + GimpPreviewArea *area) { GeglBuffer *src_buffer; const Babl *format; @@ -323,9 +321,9 @@ gimp_pattern_select_preview_fill_draw (GimpPatternSelectButton *chooser, /* popup methods. */ static void -gimp_pattern_select_button_open_popup (GimpPatternSelectButton *chooser, - gint x, - gint y) +gimp_pattern_chooser_open_popup (GimpPatternChooser *chooser, + gint x, + gint y) { GtkWidget *frame; GtkWidget *preview; @@ -335,7 +333,7 @@ gimp_pattern_select_button_open_popup (GimpPatternSelectButton *chooser, gint y_org; if (chooser->popup) - gimp_pattern_select_button_close_popup (chooser); + gimp_pattern_chooser_close_popup (chooser); if (chooser->width <= CELL_SIZE && chooser->height <= CELL_SIZE) return; @@ -377,7 +375,7 @@ gimp_pattern_select_button_open_popup (GimpPatternSelectButton *chooser, } static void -gimp_pattern_select_button_close_popup (GimpPatternSelectButton *self) +gimp_pattern_chooser_close_popup (GimpPatternChooser *self) { g_clear_pointer (&self->popup, gtk_widget_destroy); } diff --git a/libgimp/gimppatternchooser.h b/libgimp/gimppatternchooser.h new file mode 100644 index 0000000000..b2b59d29d2 --- /dev/null +++ b/libgimp/gimppatternchooser.h @@ -0,0 +1,43 @@ +/* LIBGIMP - The GIMP Library + * Copyright (C) 1995-1997 Peter Mattis and Spencer Kimball + * + * gimppatternchooser.h + * + * This library is free software: you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * 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 + * Lesser 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 + * . + */ + +#if !defined (__GIMP_UI_H_INSIDE__) && !defined (GIMP_COMPILATION) +#error "Only can be included directly." +#endif + +#ifndef __GIMP_PATTERN_CHOOSER_H__ +#define __GIMP_PATTERN_CHOOSER_H__ + +#include + +G_BEGIN_DECLS + +#define GIMP_TYPE_PATTERN_CHOOSER (gimp_pattern_chooser_get_type ()) +G_DECLARE_FINAL_TYPE (GimpPatternChooser, gimp_pattern_chooser, GIMP, PATTERN_CHOOSER, GimpResourceChooser) + + +GtkWidget * gimp_pattern_chooser_new (const gchar *title, + const gchar *label, + GimpResource *resource); + + +G_END_DECLS + +#endif /* __GIMP_PATTERN_CHOOSER_H__ */ diff --git a/libgimp/gimpproceduredialog.c b/libgimp/gimpproceduredialog.c index bb5b92bc53..df57016a16 100644 --- a/libgimp/gimpproceduredialog.c +++ b/libgimp/gimpproceduredialog.c @@ -836,8 +836,8 @@ gimp_procedure_dialog_get_widget (GimpProcedureDialog *dialog, { if (GIMP_IS_LABELED (widget)) label = gimp_labeled_get_label (GIMP_LABELED (widget)); - else if (GIMP_IS_RESOURCE_SELECT_BUTTON (widget)) - label = gimp_resource_select_button_get_label (GIMP_RESOURCE_SELECT_BUTTON (widget)); + else if (GIMP_IS_RESOURCE_CHOOSER (widget)) + label = gimp_resource_chooser_get_label (GIMP_RESOURCE_CHOOSER (widget)); } if (label != NULL) gtk_size_group_add_widget (dialog->priv->label_group, label); diff --git a/libgimp/gimppropwidgets.c b/libgimp/gimppropwidgets.c index 98fdc6d9c5..ebbcf57e70 100644 --- a/libgimp/gimppropwidgets.c +++ b/libgimp/gimppropwidgets.c @@ -58,7 +58,7 @@ gimp_prop_brush_chooser_new (GObject *config, const gchar *property_name, const gchar *chooser_title) { - return gimp_prop_resource_chooser_factory (gimp_brush_select_button_new, + return gimp_prop_resource_chooser_factory (gimp_brush_chooser_new, config, property_name, chooser_title); } @@ -79,7 +79,7 @@ gimp_prop_font_chooser_new (GObject *config, const gchar *property_name, const gchar *chooser_title) { - return gimp_prop_resource_chooser_factory (gimp_font_select_button_new, + return gimp_prop_resource_chooser_factory (gimp_font_chooser_new, config, property_name, chooser_title); } @@ -100,7 +100,7 @@ gimp_prop_gradient_chooser_new (GObject *config, const gchar *property_name, const gchar *chooser_title) { - return gimp_prop_resource_chooser_factory (gimp_gradient_select_button_new, + return gimp_prop_resource_chooser_factory (gimp_gradient_chooser_new, config, property_name, chooser_title); } @@ -121,7 +121,7 @@ gimp_prop_palette_chooser_new (GObject *config, const gchar *property_name, const gchar *chooser_title) { - return gimp_prop_resource_chooser_factory (gimp_palette_select_button_new, + return gimp_prop_resource_chooser_factory (gimp_palette_chooser_new, config, property_name, chooser_title); } @@ -142,7 +142,7 @@ gimp_prop_pattern_chooser_new (GObject *config, const gchar *property_name, const gchar *chooser_title) { - return gimp_prop_resource_chooser_factory (gimp_pattern_select_button_new, + return gimp_prop_resource_chooser_factory (gimp_pattern_chooser_new, config, property_name, chooser_title); } @@ -175,7 +175,7 @@ gimp_prop_resource_chooser_factory (GimpResourceWidgetCreator widget_creator_fu label = g_param_spec_get_nick (param_spec); - /* Create the wrapped widget. For example, call gimp_font_select_button_new. + /* Create the wrapped widget. For example, call gimp_font_chooser_new. * When initial_resource is NULL, the widget creator will set it's resource * property from context. */ diff --git a/libgimp/gimpresourceselectbutton.c b/libgimp/gimpresourcechooser.c similarity index 57% rename from libgimp/gimpresourceselectbutton.c rename to libgimp/gimpresourcechooser.c index 0c3f13f089..010ae2b427 100644 --- a/libgimp/gimpresourceselectbutton.c +++ b/libgimp/gimpresourcechooser.c @@ -26,15 +26,15 @@ #include "gimp.h" #include "gimpuitypes.h" -#include "gimpresourceselectbutton.h" +#include "gimpresourcechooser.h" #include "gimpuimarshal.h" #include "libgimp-intl.h" /** - * SECTION: gimpresourceselectbutton - * @title: GimpResourceSelectButton + * SECTION: gimpresourcechooser + * @title: GimpResourceChooser * @short_description: Base class for buttons that popup a resource * selection dialog. * @@ -92,63 +92,63 @@ typedef struct gchar *callback; GtkWidget *label_widget; -} GimpResourceSelectButtonPrivate; +} GimpResourceChooserPrivate; /* local function prototypes */ -static void gimp_resource_select_button_constructed (GObject *object); -static void gimp_resource_select_button_dispose (GObject *object); -static void gimp_resource_select_button_finalize (GObject *object); +static void gimp_resource_chooser_constructed (GObject *object); +static void gimp_resource_chooser_dispose (GObject *object); +static void gimp_resource_chooser_finalize (GObject *object); -static void gimp_resource_select_button_set_property (GObject *object, - guint property_id, - const GValue *value, - GParamSpec *pspec); -static void gimp_resource_select_button_get_property (GObject *object, - guint property_id, - GValue *value, - GParamSpec *pspec); +static void gimp_resource_chooser_set_property (GObject *object, + guint property_id, + const GValue *value, + GParamSpec *pspec); +static void gimp_resource_chooser_get_property (GObject *object, + guint property_id, + GValue *value, + GParamSpec *pspec); -static void gimp_resource_select_button_clicked (GimpResourceSelectButton *self); +static void gimp_resource_chooser_clicked (GimpResourceChooser *self); -static void gimp_resource_select_button_callback (GimpResource *resource, - gboolean dialog_closing, - gpointer user_data); +static void gimp_resource_chooser_callback (GimpResource *resource, + gboolean dialog_closing, + gpointer user_data); -static void gimp_resource_select_drag_data_received (GimpResourceSelectButton *self, - GdkDragContext *context, - gint x, - gint y, - GtkSelectionData *selection, - guint info, - guint time); +static void gimp_resource_select_drag_data_received (GimpResourceChooser *self, + GdkDragContext *context, + gint x, + gint y, + GtkSelectionData *selection, + guint info, + guint time); -static void gimp_resource_select_button_set_remote_dialog (GimpResourceSelectButton *self, - GimpResource *resource); +static void gimp_resource_chooser_set_remote_dialog (GimpResourceChooser *self, + GimpResource *resource); static guint resource_button_signals[LAST_SIGNAL] = { 0 }; static GParamSpec *resource_button_props[N_PROPS] = { NULL, }; -G_DEFINE_ABSTRACT_TYPE_WITH_PRIVATE (GimpResourceSelectButton, gimp_resource_select_button, GTK_TYPE_BOX) +G_DEFINE_ABSTRACT_TYPE_WITH_PRIVATE (GimpResourceChooser, gimp_resource_chooser, GTK_TYPE_BOX) static void -gimp_resource_select_button_class_init (GimpResourceSelectButtonClass *klass) +gimp_resource_chooser_class_init (GimpResourceChooserClass *klass) { GObjectClass *object_class = G_OBJECT_CLASS (klass); - object_class->constructed = gimp_resource_select_button_constructed; - object_class->dispose = gimp_resource_select_button_dispose; - object_class->finalize = gimp_resource_select_button_finalize; - object_class->set_property = gimp_resource_select_button_set_property; - object_class->get_property = gimp_resource_select_button_get_property; + object_class->constructed = gimp_resource_chooser_constructed; + object_class->dispose = gimp_resource_chooser_dispose; + object_class->finalize = gimp_resource_chooser_finalize; + object_class->set_property = gimp_resource_chooser_set_property; + object_class->get_property = gimp_resource_chooser_get_property; klass->resource_set = NULL; /** - * GimpResourceSelectButton:title: + * GimpResourceChooser:title: * * The title to be used for the resource selection popup dialog. * @@ -163,7 +163,7 @@ gimp_resource_select_button_class_init (GimpResourceSelectButtonClass *klass) G_PARAM_CONSTRUCT_ONLY); /** - * GimpResourceSelectButton:label: + * GimpResourceChooser:label: * * Label text with mnemonic. * @@ -178,7 +178,7 @@ gimp_resource_select_button_class_init (GimpResourceSelectButtonClass *klass) G_PARAM_CONSTRUCT_ONLY); /** - * GimpResourceSelectButton:resource: + * GimpResourceChooser:resource: * * The currently selected resource. * @@ -195,7 +195,7 @@ gimp_resource_select_button_class_init (GimpResourceSelectButtonClass *klass) N_PROPS, resource_button_props); /** - * GimpResourceSelectButton::resource-set: + * GimpResourceChooser::resource-set: * @widget: the object which received the signal. * @resource: the currently selected resource. * @dialog_closing: whether the dialog was closed or not. @@ -208,7 +208,7 @@ gimp_resource_select_button_class_init (GimpResourceSelectButtonClass *klass) g_signal_new ("resource-set", G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_FIRST, - G_STRUCT_OFFSET (GimpResourceSelectButtonClass, resource_set), + G_STRUCT_OFFSET (GimpResourceChooserClass, resource_set), NULL, NULL, _gimpui_marshal_VOID__POINTER_BOOLEAN, G_TYPE_NONE, 2, @@ -217,11 +217,11 @@ gimp_resource_select_button_class_init (GimpResourceSelectButtonClass *klass) } static void -gimp_resource_select_button_init (GimpResourceSelectButton *self) +gimp_resource_chooser_init (GimpResourceChooser *self) { - GimpResourceSelectButtonPrivate *priv; + GimpResourceChooserPrivate *priv; - priv = gimp_resource_select_button_get_instance_private (GIMP_RESOURCE_SELECT_BUTTON (self)); + priv = gimp_resource_chooser_get_instance_private (GIMP_RESOURCE_CHOOSER (self)); gtk_orientable_set_orientation (GTK_ORIENTABLE (self), GTK_ORIENTATION_HORIZONTAL); @@ -232,25 +232,25 @@ gimp_resource_select_button_init (GimpResourceSelectButton *self) } static void -gimp_resource_select_button_constructed (GObject *object) +gimp_resource_chooser_constructed (GObject *object) { - GimpResourceSelectButtonPrivate *priv; + GimpResourceChooserPrivate *priv; - priv = gimp_resource_select_button_get_instance_private (GIMP_RESOURCE_SELECT_BUTTON (object)); + priv = gimp_resource_chooser_get_instance_private (GIMP_RESOURCE_CHOOSER (object)); gtk_label_set_text_with_mnemonic (GTK_LABEL (priv->label_widget), priv->label); gtk_widget_show (GTK_WIDGET (priv->label_widget)); - G_OBJECT_CLASS (gimp_resource_select_button_parent_class)->constructed (object); + G_OBJECT_CLASS (gimp_resource_chooser_parent_class)->constructed (object); } static void -gimp_resource_select_button_dispose (GObject *self) +gimp_resource_chooser_dispose (GObject *self) { - GimpResourceSelectButtonPrivate *priv; - GimpResourceSelectButtonClass *klass; + GimpResourceChooserPrivate *priv; + GimpResourceChooserClass *klass; - priv = gimp_resource_select_button_get_instance_private (GIMP_RESOURCE_SELECT_BUTTON (self)); - klass = GIMP_RESOURCE_SELECT_BUTTON_GET_CLASS (self); + priv = gimp_resource_chooser_get_instance_private (GIMP_RESOURCE_CHOOSER (self)); + klass = GIMP_RESOURCE_CHOOSER_GET_CLASS (self); if (priv->callback) { @@ -273,24 +273,24 @@ gimp_resource_select_button_dispose (GObject *self) g_clear_pointer (&priv->callback, g_free); } - G_OBJECT_CLASS (gimp_resource_select_button_parent_class)->dispose (self); + G_OBJECT_CLASS (gimp_resource_chooser_parent_class)->dispose (self); } static void -gimp_resource_select_button_finalize (GObject *object) +gimp_resource_chooser_finalize (GObject *object) { - GimpResourceSelectButton *self = GIMP_RESOURCE_SELECT_BUTTON (object); - GimpResourceSelectButtonPrivate *priv = gimp_resource_select_button_get_instance_private (self); + GimpResourceChooser *self = GIMP_RESOURCE_CHOOSER (object); + GimpResourceChooserPrivate *priv = gimp_resource_chooser_get_instance_private (self); g_clear_pointer (&priv->title, g_free); g_clear_pointer (&priv->label, g_free); - G_OBJECT_CLASS (gimp_resource_select_button_parent_class)->finalize (object); + G_OBJECT_CLASS (gimp_resource_chooser_parent_class)->finalize (object); } /** - * gimp_resource_select_button_set_drag_target: - * @self: A [class@ResourceSelectButton] + * gimp_resource_chooser_set_drag_target: + * @self: A [class@ResourceChooser] * @drag_region_widget: An interior widget to be a droppable region * and emit "drag-data-received" signal * @drag_target: The drag target to accept @@ -304,11 +304,11 @@ gimp_resource_select_button_finalize (GObject *object) * Since: 3.0 **/ void -gimp_resource_select_button_set_drag_target (GimpResourceSelectButton *self, - GtkWidget *drag_region_widget, - const GtkTargetEntry *drag_target) +gimp_resource_chooser_set_drag_target (GimpResourceChooser *self, + GtkWidget *drag_region_widget, + const GtkTargetEntry *drag_target) { - g_return_if_fail (GIMP_IS_RESOURCE_SELECT_BUTTON (self)); + g_return_if_fail (GIMP_IS_RESOURCE_CHOOSER (self)); g_return_if_fail (drag_target != NULL); g_return_if_fail (drag_region_widget != NULL); @@ -326,8 +326,8 @@ gimp_resource_select_button_set_drag_target (GimpResourceSelectButton *self, } /** - * gimp_resource_select_button_set_clickable: - * @self: A [class@ResourceSelectButton] + * gimp_resource_chooser_set_clickable: + * @self: A [class@ResourceChooser] * @widget: An interior widget that emits "clicked" signal * * Called by a subclass init to specialize the instance. @@ -339,22 +339,22 @@ gimp_resource_select_button_set_drag_target (GimpResourceSelectButton *self, * Since: 3.0 **/ void -gimp_resource_select_button_set_clickable (GimpResourceSelectButton *self, - GtkWidget *widget) +gimp_resource_chooser_set_clickable (GimpResourceChooser *self, + GtkWidget *widget) { - g_return_if_fail (GIMP_IS_RESOURCE_SELECT_BUTTON (self)); + g_return_if_fail (GIMP_IS_RESOURCE_CHOOSER (self)); g_return_if_fail (widget != NULL); g_return_if_fail (GTK_IS_WIDGET (widget)); /* Require the widget have a signal "clicked", usually a button. */ g_signal_connect_swapped (widget, "clicked", - G_CALLBACK (gimp_resource_select_button_clicked), + G_CALLBACK (gimp_resource_chooser_clicked), self); } /** - * gimp_resource_select_button_get_resource: - * @self: A #GimpResourceSelectButton + * gimp_resource_chooser_get_resource: + * @self: A #GimpResourceChooser * * Gets the currently selected resource. * @@ -363,20 +363,20 @@ gimp_resource_select_button_set_clickable (GimpResourceSelectButton *self, * Since: 3.0 */ GimpResource * -gimp_resource_select_button_get_resource (GimpResourceSelectButton *self) +gimp_resource_chooser_get_resource (GimpResourceChooser *self) { - GimpResourceSelectButtonPrivate *priv; + GimpResourceChooserPrivate *priv; - g_return_val_if_fail (GIMP_IS_RESOURCE_SELECT_BUTTON (self), NULL); + g_return_val_if_fail (GIMP_IS_RESOURCE_CHOOSER (self), NULL); - priv = gimp_resource_select_button_get_instance_private (self); + priv = gimp_resource_chooser_get_instance_private (self); return priv->resource; } /** - * gimp_resource_select_button_set_resource: - * @self: A #GimpResourceSelectButton + * gimp_resource_chooser_set_resource: + * @self: A #GimpResourceChooser * @resource: Resource to set. * * Sets the currently selected resource. @@ -385,15 +385,15 @@ gimp_resource_select_button_get_resource (GimpResourceSelectButton *self) * Since: 3.0 */ void -gimp_resource_select_button_set_resource (GimpResourceSelectButton *self, - GimpResource *resource) +gimp_resource_chooser_set_resource (GimpResourceChooser *self, + GimpResource *resource) { - GimpResourceSelectButtonPrivate *priv; + GimpResourceChooserPrivate *priv; - g_return_if_fail (GIMP_IS_RESOURCE_SELECT_BUTTON (self)); + g_return_if_fail (GIMP_IS_RESOURCE_CHOOSER (self)); g_return_if_fail (resource != NULL); - priv = gimp_resource_select_button_get_instance_private (self); + priv = gimp_resource_chooser_get_instance_private (self); if (priv->callback) { @@ -402,18 +402,18 @@ gimp_resource_select_button_set_resource (GimpResourceSelectButton *self, * (since all views of the resource must be consistent.) * That will call back, which will change our own view of the resource. */ - gimp_resource_select_button_set_remote_dialog (self, resource); + gimp_resource_chooser_set_remote_dialog (self, resource); } else { /* Call our own setter. */ - gimp_resource_select_button_callback (resource, FALSE, self); + gimp_resource_chooser_callback (resource, FALSE, self); } } /** - * gimp_resource_select_button_get_label: - * @widget: A [class@ResourceSelectButton]. + * gimp_resource_chooser_get_label: + * @widget: A [class@ResourceChooser]. * * Returns the label widget. * @@ -421,13 +421,13 @@ gimp_resource_select_button_set_resource (GimpResourceSelectButton *self, * Since: 3.0 */ GtkWidget * -gimp_resource_select_button_get_label (GimpResourceSelectButton *widget) +gimp_resource_chooser_get_label (GimpResourceChooser *widget) { - GimpResourceSelectButtonPrivate *priv; + GimpResourceChooserPrivate *priv; - g_return_val_if_fail (GIMP_IS_RESOURCE_SELECT_BUTTON (widget), NULL); + g_return_val_if_fail (GIMP_IS_RESOURCE_CHOOSER (widget), NULL); - priv = gimp_resource_select_button_get_instance_private (widget); + priv = gimp_resource_chooser_get_instance_private (widget); return priv->label_widget; } @@ -435,17 +435,17 @@ gimp_resource_select_button_get_label (GimpResourceSelectButton *widget) /* private functions */ static void -gimp_resource_select_button_set_remote_dialog (GimpResourceSelectButton *self, - GimpResource *resource) +gimp_resource_chooser_set_remote_dialog (GimpResourceChooser *self, + GimpResource *resource) { - GimpResourceSelectButtonPrivate *priv; - GimpResourceSelectButtonClass *klass; + GimpResourceChooserPrivate *priv; + GimpResourceChooserClass *klass; - g_return_if_fail (GIMP_IS_RESOURCE_SELECT_BUTTON (self)); + g_return_if_fail (GIMP_IS_RESOURCE_CHOOSER (self)); g_return_if_fail (resource != NULL); - priv = gimp_resource_select_button_get_instance_private (self); - klass = GIMP_RESOURCE_SELECT_BUTTON_GET_CLASS (self); + priv = gimp_resource_chooser_get_instance_private (self); + klass = GIMP_RESOURCE_CHOOSER_GET_CLASS (self); g_return_if_fail (klass->resource_type != G_TYPE_INVALID); g_return_if_fail (klass->resource_type == G_TYPE_FROM_INSTANCE (resource)); @@ -454,13 +454,13 @@ gimp_resource_select_button_set_remote_dialog (GimpResourceSelectButton *self, } static void -gimp_resource_select_button_set_property (GObject *object, - guint property_id, - const GValue *gvalue, - GParamSpec *pspec) +gimp_resource_chooser_set_property (GObject *object, + guint property_id, + const GValue *gvalue, + GParamSpec *pspec) { - GimpResourceSelectButton *self = GIMP_RESOURCE_SELECT_BUTTON (object); - GimpResourceSelectButtonPrivate *priv = gimp_resource_select_button_get_instance_private (self); + GimpResourceChooser *self = GIMP_RESOURCE_CHOOSER (object); + GimpResourceChooserPrivate *priv = gimp_resource_chooser_get_instance_private (self); switch (property_id) { @@ -483,13 +483,13 @@ gimp_resource_select_button_set_property (GObject *object, } static void -gimp_resource_select_button_get_property (GObject *object, - guint property_id, - GValue *value, - GParamSpec *pspec) +gimp_resource_chooser_get_property (GObject *object, + guint property_id, + GValue *value, + GParamSpec *pspec) { - GimpResourceSelectButton *self = GIMP_RESOURCE_SELECT_BUTTON (object); - GimpResourceSelectButtonPrivate *priv = gimp_resource_select_button_get_instance_private (self); + GimpResourceChooser *self = GIMP_RESOURCE_CHOOSER (object); + GimpResourceChooserPrivate *priv = gimp_resource_chooser_get_instance_private (self); switch (property_id) { @@ -521,16 +521,16 @@ gimp_resource_select_button_get_property (GObject *object, * Update the view, since model changed. */ static void -gimp_resource_select_button_callback (GimpResource *resource, - gboolean dialog_closing, - gpointer user_data) +gimp_resource_chooser_callback (GimpResource *resource, + gboolean dialog_closing, + gpointer user_data) { - GimpResourceSelectButton *self = GIMP_RESOURCE_SELECT_BUTTON (user_data); - GimpResourceSelectButtonPrivate *priv = gimp_resource_select_button_get_instance_private (self); + GimpResourceChooser *self = GIMP_RESOURCE_CHOOSER (user_data); + GimpResourceChooserPrivate *priv = gimp_resource_chooser_get_instance_private (self); priv->resource = resource; - GIMP_RESOURCE_SELECT_BUTTON_GET_CLASS (self)->draw_interior (self); + GIMP_RESOURCE_CHOOSER_GET_CLASS (self)->draw_interior (self); if (dialog_closing) g_clear_pointer (&priv->callback, g_free); @@ -540,15 +540,15 @@ gimp_resource_select_button_callback (GimpResource *resource, } static void -gimp_resource_select_button_clicked (GimpResourceSelectButton *self) +gimp_resource_chooser_clicked (GimpResourceChooser *self) { - GimpResourceSelectButtonPrivate *priv = gimp_resource_select_button_get_instance_private (self); - GimpResourceSelectButtonClass *klass = GIMP_RESOURCE_SELECT_BUTTON_GET_CLASS (self); + GimpResourceChooserPrivate *priv = gimp_resource_chooser_get_instance_private (self); + GimpResourceChooserClass *klass = GIMP_RESOURCE_CHOOSER_GET_CLASS (self); if (priv->callback) { /* Popup already created. Calling setter raises the popup. */ - gimp_resource_select_button_set_remote_dialog (self, priv->resource); + gimp_resource_chooser_set_remote_dialog (self, priv->resource); } else { @@ -562,10 +562,10 @@ gimp_resource_select_button_clicked (GimpResourceSelectButton *self) handle, priv->resource, klass->resource_type, - gimp_resource_select_button_callback, + gimp_resource_chooser_callback, self, NULL)); - gimp_resource_select_button_set_remote_dialog (self, priv->resource); + gimp_resource_chooser_set_remote_dialog (self, priv->resource); } } @@ -573,20 +573,20 @@ gimp_resource_select_button_clicked (GimpResourceSelectButton *self) /* Drag methods. */ static void -gimp_resource_select_drag_data_received (GimpResourceSelectButton *self, - GdkDragContext *context, - gint x, - gint y, - GtkSelectionData *selection, - guint info, - guint time) +gimp_resource_select_drag_data_received (GimpResourceChooser *self, + GdkDragContext *context, + gint x, + gint y, + GtkSelectionData *selection, + guint info, + guint time) { gint length = gtk_selection_data_get_length (selection); gchar *str; - GimpResourceSelectButtonClass *klass; + GimpResourceChooserClass *klass; - klass = GIMP_RESOURCE_SELECT_BUTTON_GET_CLASS (self); + klass = GIMP_RESOURCE_CHOOSER_GET_CLASS (self); /* Require class resource_type was initialized. */ g_assert (klass->resource_type != 0); @@ -614,7 +614,7 @@ gimp_resource_select_drag_data_received (GimpResourceSelectButton *self, GimpResource *resource; resource = gimp_resource_get_by_name (klass->resource_type, name); - gimp_resource_select_button_set_resource (self, resource); + gimp_resource_chooser_set_resource (self, resource); } } diff --git a/libgimp/gimpresourcechooser.h b/libgimp/gimpresourcechooser.h new file mode 100644 index 0000000000..413a9baae2 --- /dev/null +++ b/libgimp/gimpresourcechooser.h @@ -0,0 +1,65 @@ +/* LIBGIMP - The GIMP Library + * Copyright (C) 1995-1997 Peter Mattis and Spencer Kimball + * + * This library is free software: you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * 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 + * Lesser 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 + * . + */ + +#if !defined (__GIMP_UI_H_INSIDE__) && !defined (GIMP_COMPILATION) +#error "Only can be included directly." +#endif + +#ifndef __GIMP_RESOURCE_CHOOSER_H__ +#define __GIMP_RESOURCE_CHOOSER_H__ + +G_BEGIN_DECLS + +#define GIMP_TYPE_RESOURCE_CHOOSER (gimp_resource_chooser_get_type ()) +G_DECLARE_DERIVABLE_TYPE (GimpResourceChooser, gimp_resource_chooser, GIMP, RESOURCE_CHOOSER, GtkBox) + +struct _GimpResourceChooserClass +{ + GtkBoxClass parent_class; + + /* Signals */ + void (* resource_set) (GimpResourceChooser *chooser, + GimpResource *resource, + gboolean dialog_closing); + + /* Abstract methods and class variables */ + void (*draw_interior) (GimpResourceChooser *chooser); + + GType resource_type; + + /* Padding for future expansion */ + gpointer padding[8]; +}; + +GimpResource * gimp_resource_chooser_get_resource (GimpResourceChooser *chooser); +void gimp_resource_chooser_set_resource (GimpResourceChooser *chooser, + GimpResource *resource); +GtkWidget * gimp_resource_chooser_get_label (GimpResourceChooser *widget); + + +/* API from below, used by subclasses e.g. GimpBrushChooser */ + +void gimp_resource_chooser_set_drag_target (GimpResourceChooser *chooser, + GtkWidget *drag_region_widget, + const GtkTargetEntry *drag_target); +void gimp_resource_chooser_set_clickable (GimpResourceChooser *chooser, + GtkWidget *widget); + +G_END_DECLS + +#endif /* __GIMP_RESOURCE_CHOOSER_H__ */ diff --git a/libgimp/gimpresourceselectbutton.h b/libgimp/gimpresourceselectbutton.h deleted file mode 100644 index 4116164054..0000000000 --- a/libgimp/gimpresourceselectbutton.h +++ /dev/null @@ -1,65 +0,0 @@ -/* LIBGIMP - The GIMP Library - * Copyright (C) 1995-1997 Peter Mattis and Spencer Kimball - * - * This library is free software: you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * 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 - * Lesser 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 - * . - */ - -#if !defined (__GIMP_UI_H_INSIDE__) && !defined (GIMP_COMPILATION) -#error "Only can be included directly." -#endif - -#ifndef __GIMP_RESOURCE_SELECT_BUTTON_H__ -#define __GIMP_RESOURCE_SELECT_BUTTON_H__ - -G_BEGIN_DECLS - -#define GIMP_TYPE_RESOURCE_SELECT_BUTTON (gimp_resource_select_button_get_type ()) -G_DECLARE_DERIVABLE_TYPE (GimpResourceSelectButton, gimp_resource_select_button, GIMP, RESOURCE_SELECT_BUTTON, GtkBox) - -struct _GimpResourceSelectButtonClass -{ - GtkBoxClass parent_class; - - /* Signals */ - void (* resource_set) (GimpResourceSelectButton *self, - GimpResource *resource, - gboolean dialog_closing); - - /* Abstract methods and class variables */ - void (*draw_interior) (GimpResourceSelectButton *self); - - GType resource_type; - - /* Padding for future expansion */ - gpointer padding[8]; -}; - -GimpResource * gimp_resource_select_button_get_resource (GimpResourceSelectButton *self); -void gimp_resource_select_button_set_resource (GimpResourceSelectButton *self, - GimpResource *resource); -GtkWidget * gimp_resource_select_button_get_label (GimpResourceSelectButton *widget); - - -/* API from below, used by subclasses e.g. GimpBrushSelectButton */ - -void gimp_resource_select_button_set_drag_target (GimpResourceSelectButton *self, - GtkWidget *drag_region_widget, - const GtkTargetEntry *drag_target); -void gimp_resource_select_button_set_clickable (GimpResourceSelectButton *self, - GtkWidget *widget); - -G_END_DECLS - -#endif /* __GIMP_RESOURCE_SELECT_BUTTON_H__ */ diff --git a/libgimp/gimpui.def b/libgimp/gimpui.def index 4180c09bc8..959eb9ccb5 100644 --- a/libgimp/gimpui.def +++ b/libgimp/gimpui.def @@ -1,8 +1,8 @@ EXPORTS gimp_aspect_preview_get_type gimp_aspect_preview_new_from_drawable - gimp_brush_select_button_get_type - gimp_brush_select_button_new + gimp_brush_chooser_get_type + gimp_brush_chooser_new gimp_channel_combo_box_get_type gimp_channel_combo_box_new gimp_drawable_combo_box_get_type @@ -13,18 +13,18 @@ EXPORTS gimp_export_dialog_get_content_area gimp_export_dialog_new gimp_export_image - gimp_font_select_button_get_type - gimp_font_select_button_new - gimp_gradient_select_button_get_type - gimp_gradient_select_button_new + gimp_font_chooser_get_type + gimp_font_chooser_new + gimp_gradient_chooser_get_type + gimp_gradient_chooser_new gimp_image_combo_box_get_type gimp_image_combo_box_new gimp_layer_combo_box_get_type gimp_layer_combo_box_new - gimp_palette_select_button_get_type - gimp_palette_select_button_new - gimp_pattern_select_button_get_type - gimp_pattern_select_button_new + gimp_palette_chooser_get_type + gimp_palette_chooser_new + gimp_pattern_chooser_get_type + gimp_pattern_chooser_new gimp_proc_browser_dialog_get_selected gimp_proc_browser_dialog_get_type gimp_proc_browser_dialog_new @@ -63,12 +63,12 @@ EXPORTS gimp_prop_gradient_chooser_new gimp_prop_palette_chooser_new gimp_prop_pattern_chooser_new - gimp_resource_select_button_get_label - gimp_resource_select_button_get_resource - gimp_resource_select_button_get_type - gimp_resource_select_button_set_clickable - gimp_resource_select_button_set_drag_target - gimp_resource_select_button_set_resource + gimp_resource_chooser_get_label + gimp_resource_chooser_get_resource + gimp_resource_chooser_get_type + gimp_resource_chooser_set_clickable + gimp_resource_chooser_set_drag_target + gimp_resource_chooser_set_resource gimp_save_procedure_dialog_add_metadata gimp_save_procedure_dialog_get_type gimp_save_procedure_dialog_new diff --git a/libgimp/gimpui.h b/libgimp/gimpui.h index e4aaf8395c..03fb060dcb 100644 --- a/libgimp/gimpui.h +++ b/libgimp/gimpui.h @@ -30,16 +30,16 @@ #include #include -#include +#include #include #include -#include -#include -#include +#include +#include +#include #include #include -#include -#include +#include +#include #include #include #include diff --git a/libgimp/gimpuitypes.h b/libgimp/gimpuitypes.h index e361b6f7ee..5b519840dc 100644 --- a/libgimp/gimpuitypes.h +++ b/libgimp/gimpuitypes.h @@ -43,12 +43,12 @@ typedef struct _GimpLayerComboBox GimpLayerComboBox; typedef struct _GimpVectorsComboBox GimpVectorsComboBox; typedef struct _GimpImageComboBox GimpImageComboBox; -typedef struct _GimpSelectButton GimpSelectButton; -typedef struct _GimpBrushSelectButton GimpBrushSelectButton; -typedef struct _GimpFontSelectButton GimpFontSelectButton; -typedef struct _GimpGradientSelectButton GimpGradientSelectButton; -typedef struct _GimpPaletteSelectButton GimpPaletteSelectButton; -typedef struct _GimpPatternSelectButton GimpPatternSelectButton; +typedef struct _GimpResourceChooser GimpResourceChooser; +typedef struct _GimpBrushChooser GimpBrushChooser; +typedef struct _GimpFontChooser GimpFontChooser; +typedef struct _GimpGradientChooser GimpGradientChooser; +typedef struct _GimpPaletteChooser GimpPaletteChooser; +typedef struct _GimpPatternChooser GimpPatternChooser; G_END_DECLS diff --git a/libgimp/meson.build b/libgimp/meson.build index 3a29607f14..d2b0ba83d4 100644 --- a/libgimp/meson.build +++ b/libgimp/meson.build @@ -268,21 +268,21 @@ libgimp_headers = [ libgimpui_sources_introspectable = [ 'gimpaspectpreview.c', - 'gimpbrushselectbutton.c', + 'gimpbrushchooser.c', 'gimpdrawablepreview.c', 'gimpexport.c', - 'gimpfontselectbutton.c', - 'gimpgradientselectbutton.c', + 'gimpfontchooser.c', + 'gimpgradientchooser.c', 'gimpimagecombobox.c', 'gimpitemcombobox.c', - 'gimppaletteselectbutton.c', - 'gimppatternselectbutton.c', + 'gimppalettechooser.c', + 'gimppatternchooser.c', 'gimpprocbrowserdialog.c', 'gimpproceduredialog.c', 'gimpprocview.c', 'gimpprogressbar.c', 'gimppropwidgets.c', - 'gimpresourceselectbutton.c', + 'gimpresourcechooser.c', 'gimpsaveproceduredialog.c', 'gimpui.c', 'gimpzoompreview.c', @@ -300,21 +300,21 @@ libgimpui_headers_introspectable = [ # Other headers 'gimpaspectpreview.h', - 'gimpbrushselectbutton.h', + 'gimpbrushchooser.h', 'gimpdrawablepreview.h', 'gimpexport.h', - 'gimpfontselectbutton.h', - 'gimpgradientselectbutton.h', + 'gimpfontchooser.h', + 'gimpgradientchooser.h', 'gimpimagecombobox.h', 'gimpitemcombobox.h', - 'gimppaletteselectbutton.h', - 'gimppatternselectbutton.h', + 'gimppalettechooser.h', + 'gimppatternchooser.h', 'gimpprocbrowserdialog.h', 'gimpproceduredialog.h', 'gimpprocview.h', 'gimpprogressbar.h', 'gimppropwidgets.h', - 'gimpresourceselectbutton.h', + 'gimpresourcechooser.h', 'gimpsaveproceduredialog.h', 'gimpzoompreview.h', ] diff --git a/plug-ins/fractal-explorer/fractal-explorer-dialogs.c b/plug-ins/fractal-explorer/fractal-explorer-dialogs.c index d659448673..6fc5a83a31 100644 --- a/plug-ins/fractal-explorer/fractal-explorer-dialogs.c +++ b/plug-ins/fractal-explorer/fractal-explorer-dialogs.c @@ -1159,8 +1159,8 @@ explorer_dialog (void) &n_gradient_samples, &gradient_samples); - gradient_button = gimp_gradient_select_button_new (_("FractalExplorer Gradient"), - NULL, GIMP_RESOURCE (gradient)); + gradient_button = gimp_gradient_chooser_new (_("FractalExplorer Gradient"), + NULL, GIMP_RESOURCE (gradient)); g_signal_connect (gradient_button, "resource-set", G_CALLBACK (explorer_gradient_select_callback), NULL); diff --git a/plug-ins/gfig/gfig-dialog.c b/plug-ins/gfig/gfig-dialog.c index 10fac874ed..72b655d889 100644 --- a/plug-ins/gfig/gfig-dialog.c +++ b/plug-ins/gfig/gfig-dialog.c @@ -507,8 +507,8 @@ gfig_dialog (GimpGfig *gfig) /* brush selector in Stroke frame */ gfig_context->brush_select - = gimp_brush_select_button_new ("Brush", "Brush", - GIMP_RESOURCE (gfig_context->default_style.brush)); + = gimp_brush_chooser_new ("Brush", "Brush", + GIMP_RESOURCE (gfig_context->default_style.brush)); g_signal_connect (gfig_context->brush_select, "resource-set", G_CALLBACK (gfig_brush_changed_callback), NULL); gtk_box_pack_start (GTK_BOX (vbox), gfig_context->brush_select, @@ -573,8 +573,8 @@ gfig_dialog (GimpGfig *gfig) /* A page for the pattern selector */ gfig_context->pattern_select - = gimp_pattern_select_button_new ("Pattern", "Pattern", - GIMP_RESOURCE (gfig_context->default_style.pattern)); + = gimp_pattern_chooser_new ("Pattern", "Pattern", + GIMP_RESOURCE (gfig_context->default_style.pattern)); g_signal_connect (gfig_context->pattern_select, "resource-set", G_CALLBACK (gfig_pattern_changed_callback), NULL); gtk_widget_show (gfig_context->pattern_select); @@ -583,8 +583,8 @@ gfig_dialog (GimpGfig *gfig) /* A page for the gradient selector */ gfig_context->gradient_select - = gimp_gradient_select_button_new ("Gradient", "Gradient", - GIMP_RESOURCE (gfig_context->default_style.gradient)); + = gimp_gradient_chooser_new ("Gradient", "Gradient", + GIMP_RESOURCE (gfig_context->default_style.gradient)); g_signal_connect (gfig_context->gradient_select, "resource-set", G_CALLBACK (gfig_gradient_changed_callback), NULL); gtk_widget_show (gfig_context->gradient_select); diff --git a/plug-ins/gfig/gfig-style.c b/plug-ins/gfig/gfig-style.c index 9ddd61f072..9941cdd575 100644 --- a/plug-ins/gfig/gfig-style.c +++ b/plug-ins/gfig/gfig-style.c @@ -697,14 +697,14 @@ gfig_style_set_context_from_style (Style *style) gimp_context_set_brush_default_size (); - gimp_resource_select_button_set_resource (GIMP_RESOURCE_SELECT_BUTTON (gfig_context->brush_select), - GIMP_RESOURCE (style->brush)); + gimp_resource_chooser_set_resource (GIMP_RESOURCE_CHOOSER (gfig_context->brush_select), + GIMP_RESOURCE (style->brush)); - gimp_resource_select_button_set_resource (GIMP_RESOURCE_SELECT_BUTTON (gfig_context->pattern_select), - GIMP_RESOURCE (style->pattern)); + gimp_resource_chooser_set_resource (GIMP_RESOURCE_CHOOSER (gfig_context->pattern_select), + GIMP_RESOURCE (style->pattern)); - gimp_resource_select_button_set_resource (GIMP_RESOURCE_SELECT_BUTTON (gfig_context->gradient_select), - GIMP_RESOURCE (style->gradient)); + gimp_resource_chooser_set_resource (GIMP_RESOURCE_CHOOSER (gfig_context->gradient_select), + GIMP_RESOURCE (style->gradient)); set_context_bdesc (style->brush); diff --git a/plug-ins/script-fu/libscriptfu/script-fu-interface.c b/plug-ins/script-fu/libscriptfu/script-fu-interface.c index ef6fba79b6..4d4da05698 100644 --- a/plug-ins/script-fu/libscriptfu/script-fu-interface.c +++ b/plug-ins/script-fu/libscriptfu/script-fu-interface.c @@ -606,23 +606,23 @@ script_fu_resource_widget (const gchar *title, if (g_type_is_a (resource_type, GIMP_TYPE_FONT)) { - result_widget = gimp_font_select_button_new (title, title, resource); + result_widget = gimp_font_chooser_new (title, title, resource); } else if (g_type_is_a (resource_type, GIMP_TYPE_BRUSH)) { - result_widget = gimp_brush_select_button_new (title, title, resource); + result_widget = gimp_brush_chooser_new (title, title, resource); } else if (g_type_is_a (resource_type, GIMP_TYPE_GRADIENT)) { - result_widget = gimp_gradient_select_button_new (title, title, resource); + result_widget = gimp_gradient_chooser_new (title, title, resource); } else if (g_type_is_a (resource_type, GIMP_TYPE_PALETTE)) { - result_widget = gimp_palette_select_button_new (title, title, resource); + result_widget = gimp_palette_chooser_new (title, title, resource); } else if (g_type_is_a (resource_type, GIMP_TYPE_PATTERN)) { - result_widget = gimp_pattern_select_button_new (title, title, resource); + result_widget = gimp_pattern_chooser_new (title, title, resource); } else { @@ -961,8 +961,8 @@ script_fu_reset (SFScript *script) case SF_PATTERN: case SF_GRADIENT: case SF_BRUSH: - gimp_resource_select_button_set_resource (GIMP_RESOURCE_SELECT_BUTTON (widget), - NULL); + gimp_resource_chooser_set_resource (GIMP_RESOURCE_CHOOSER (widget), + NULL); break; case SF_OPTION: