libgimpwidgets: Convert widgets to final/derived type

This patch converts libgimpwidgets with
no signals to be final or derived types.
The remaining widgets will be converted
in a subsequent patch.
This commit is contained in:
Alx Sa 2024-07-29 01:51:38 +00:00
parent 70ae12eb16
commit 74e7e16ec3
28 changed files with 866 additions and 1342 deletions

View file

@ -49,8 +49,10 @@ enum
}; };
struct _GimpBusyBoxPrivate struct _GimpBusyBox
{ {
GtkBox parent_instance;
GtkLabel *label; GtkLabel *label;
}; };
@ -67,7 +69,7 @@ static void gimp_busy_box_get_property (GObject *object,
GParamSpec *pspec); GParamSpec *pspec);
G_DEFINE_TYPE_WITH_PRIVATE (GimpBusyBox, gimp_busy_box, GTK_TYPE_BOX) G_DEFINE_TYPE (GimpBusyBox, gimp_busy_box, GTK_TYPE_BOX)
#define parent_class gimp_busy_box_parent_class #define parent_class gimp_busy_box_parent_class
@ -105,8 +107,6 @@ gimp_busy_box_init (GimpBusyBox *box)
GtkWidget *spinner; GtkWidget *spinner;
GtkWidget *label; GtkWidget *label;
box->priv = gimp_busy_box_get_instance_private (box);
gtk_widget_set_halign (GTK_WIDGET (box), GTK_ALIGN_CENTER); gtk_widget_set_halign (GTK_WIDGET (box), GTK_ALIGN_CENTER);
gtk_widget_set_valign (GTK_WIDGET (box), GTK_ALIGN_CENTER); gtk_widget_set_valign (GTK_WIDGET (box), GTK_ALIGN_CENTER);
gtk_box_set_spacing (GTK_BOX (box), 8); gtk_box_set_spacing (GTK_BOX (box), 8);
@ -119,7 +119,7 @@ gimp_busy_box_init (GimpBusyBox *box)
/* the label */ /* the label */
label = gtk_label_new (NULL); label = gtk_label_new (NULL);
box->priv->label = GTK_LABEL (label); box->label = GTK_LABEL (label);
gimp_label_set_attributes (GTK_LABEL (label), gimp_label_set_attributes (GTK_LABEL (label),
PANGO_ATTR_STYLE, PANGO_STYLE_ITALIC, PANGO_ATTR_STYLE, PANGO_STYLE_ITALIC,
-1); -1);
@ -138,7 +138,7 @@ gimp_busy_box_set_property (GObject *object,
switch (property_id) switch (property_id)
{ {
case PROP_MESSAGE: case PROP_MESSAGE:
gtk_label_set_text (box->priv->label, g_value_get_string (value)); gtk_label_set_text (box->label, g_value_get_string (value));
break; break;
default: default:
@ -158,7 +158,7 @@ gimp_busy_box_get_property (GObject *object,
switch (property_id) switch (property_id)
{ {
case PROP_MESSAGE: case PROP_MESSAGE:
g_value_set_string (value, gtk_label_get_text (box->priv->label)); g_value_set_string (value, gtk_label_get_text (box->label));
break; break;
default: default:
@ -228,5 +228,5 @@ gimp_busy_box_get_message (GimpBusyBox *box)
{ {
g_return_val_if_fail (GIMP_IS_BUSY_BOX (box), NULL); g_return_val_if_fail (GIMP_IS_BUSY_BOX (box), NULL);
return gtk_label_get_text (box->priv->label); return gtk_label_get_text (box->label);
} }

View file

@ -28,42 +28,10 @@
G_BEGIN_DECLS G_BEGIN_DECLS
#define GIMP_TYPE_BUSY_BOX (gimp_busy_box_get_type ()) #define GIMP_TYPE_BUSY_BOX (gimp_busy_box_get_type ())
#define GIMP_BUSY_BOX(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GIMP_TYPE_BUSY_BOX, GimpBusyBox)) G_DECLARE_FINAL_TYPE (GimpBusyBox, gimp_busy_box, GIMP, BUSY_BOX, GtkBox)
#define GIMP_BUSY_BOX_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GIMP_TYPE_BUSY_BOX, GimpBusyBoxClass))
#define GIMP_IS_BUSY_BOX(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GIMP_TYPE_BUSY_BOX))
#define GIMP_IS_BUSY_BOX_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GIMP_TYPE_BUSY_BOX))
#define GIMP_BUSY_BOX_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GIMP_TYPE_BUSY_BOX, GimpBusyBoxClass))
typedef struct _GimpBusyBoxPrivate GimpBusyBoxPrivate;
typedef struct _GimpBusyBoxClass GimpBusyBoxClass;
struct _GimpBusyBox
{
GtkBox parent_instance;
GimpBusyBoxPrivate *priv;
};
struct _GimpBusyBoxClass
{
GtkBoxClass parent_class;
/* Padding for future expansion */
void (* _gimp_reserved1) (void);
void (* _gimp_reserved2) (void);
void (* _gimp_reserved3) (void);
void (* _gimp_reserved4) (void);
void (* _gimp_reserved5) (void);
void (* _gimp_reserved6) (void);
void (* _gimp_reserved7) (void);
void (* _gimp_reserved8) (void);
};
GType gimp_busy_box_get_type (void) G_GNUC_CONST;
GtkWidget * gimp_busy_box_new (const gchar *message); GtkWidget * gimp_busy_box_new (const gchar *message);
void gimp_busy_box_set_message (GimpBusyBox *box, void gimp_busy_box_set_message (GimpBusyBox *box,

View file

@ -54,15 +54,15 @@ enum
}; };
struct _GimpCellRendererColorPrivate struct _GimpCellRendererColor
{ {
GeglColor *color; GtkCellRenderer parent_instance;
gboolean opaque;
GtkIconSize size;
gint border;
};
#define GET_PRIVATE(obj) (((GimpCellRendererColor *) (obj))->priv) GeglColor *color;
gboolean opaque;
GtkIconSize size;
gint border;
};
static void gimp_cell_renderer_color_finalize (GObject *object); static void gimp_cell_renderer_color_finalize (GObject *object);
@ -90,8 +90,7 @@ static void gimp_cell_renderer_color_render (GtkCellRenderer *cell,
G_DEFINE_TYPE_WITH_PRIVATE (GimpCellRendererColor, gimp_cell_renderer_color, G_DEFINE_TYPE (GimpCellRendererColor, gimp_cell_renderer_color, GTK_TYPE_CELL_RENDERER)
GTK_TYPE_CELL_RENDERER)
#define parent_class gimp_cell_renderer_color_parent_class #define parent_class gimp_cell_renderer_color_parent_class
@ -138,17 +137,15 @@ gimp_cell_renderer_color_class_init (GimpCellRendererColorClass *klass)
static void static void
gimp_cell_renderer_color_init (GimpCellRendererColor *cell) gimp_cell_renderer_color_init (GimpCellRendererColor *cell)
{ {
cell->priv = gimp_cell_renderer_color_get_instance_private (cell); cell->color = gegl_color_new ("black");
cell->priv->color = gegl_color_new ("black");
} }
static void static void
gimp_cell_renderer_color_finalize (GObject *object) gimp_cell_renderer_color_finalize (GObject *object)
{ {
GimpCellRendererColorPrivate *private = GET_PRIVATE (object); GimpCellRendererColor *renderer = GIMP_CELL_RENDERER_COLOR (object);
g_clear_object (&private->color); g_clear_object (&renderer->color);
G_OBJECT_CLASS (parent_class)->finalize (object); G_OBJECT_CLASS (parent_class)->finalize (object);
} }
@ -159,19 +156,19 @@ gimp_cell_renderer_color_get_property (GObject *object,
GValue *value, GValue *value,
GParamSpec *pspec) GParamSpec *pspec)
{ {
GimpCellRendererColorPrivate *private = GET_PRIVATE (object); GimpCellRendererColor *renderer = GIMP_CELL_RENDERER_COLOR (object);
switch (param_id) switch (param_id)
{ {
case PROP_COLOR: case PROP_COLOR:
g_clear_object (&private->color); g_clear_object (&renderer->color);
private->color = gegl_color_duplicate (g_value_get_object (value)); renderer->color = gegl_color_duplicate (g_value_get_object (value));
break; break;
case PROP_OPAQUE: case PROP_OPAQUE:
g_value_set_boolean (value, private->opaque); g_value_set_boolean (value, renderer->opaque);
break; break;
case PROP_SIZE: case PROP_SIZE:
g_value_set_int (value, private->size); g_value_set_int (value, renderer->size);
break; break;
default: default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec); G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
@ -185,18 +182,18 @@ gimp_cell_renderer_color_set_property (GObject *object,
const GValue *value, const GValue *value,
GParamSpec *pspec) GParamSpec *pspec)
{ {
GimpCellRendererColorPrivate *private = GET_PRIVATE (object); GimpCellRendererColor *renderer = GIMP_CELL_RENDERER_COLOR (object);
switch (param_id) switch (param_id)
{ {
case PROP_COLOR: case PROP_COLOR:
g_set_object (&private->color, g_value_get_object (value)); g_set_object (&renderer->color, g_value_get_object (value));
break; break;
case PROP_OPAQUE: case PROP_OPAQUE:
private->opaque = g_value_get_boolean (value); renderer->opaque = g_value_get_boolean (value);
break; break;
case PROP_SIZE: case PROP_SIZE:
private->size = g_value_get_int (value); renderer->size = g_value_get_int (value);
break; break;
default: default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec); G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
@ -213,15 +210,15 @@ gimp_cell_renderer_color_get_size (GtkCellRenderer *cell,
gint *width, gint *width,
gint *height) gint *height)
{ {
GimpCellRendererColorPrivate *private = GET_PRIVATE (cell); GimpCellRendererColor *renderer = GIMP_CELL_RENDERER_COLOR (cell);
gint calc_width; gint calc_width;
gint calc_height; gint calc_height;
gfloat xalign; gfloat xalign;
gfloat yalign; gfloat yalign;
gint xpad; gint xpad;
gint ypad; gint ypad;
gtk_icon_size_lookup (private->size, &calc_width, &calc_height); gtk_icon_size_lookup (renderer->size, &calc_width, &calc_height);
gtk_cell_renderer_get_alignment (cell, &xalign, &yalign); gtk_cell_renderer_get_alignment (cell, &xalign, &yalign);
gtk_cell_renderer_get_padding (cell, &xpad, &ypad); gtk_cell_renderer_get_padding (cell, &xpad, &ypad);
@ -262,10 +259,10 @@ gimp_cell_renderer_color_render (GtkCellRenderer *cell,
const GdkRectangle *cell_area, const GdkRectangle *cell_area,
GtkCellRendererState flags) GtkCellRendererState flags)
{ {
GimpCellRendererColorPrivate *private = GET_PRIVATE (cell); GimpCellRendererColor *renderer = GIMP_CELL_RENDERER_COLOR (cell);
GdkRectangle rect; GdkRectangle rect;
gint xpad; gint xpad;
gint ypad; gint ypad;
gimp_cell_renderer_color_get_size (cell, widget, cell_area, gimp_cell_renderer_color_get_size (cell, widget, cell_area,
&rect.x, &rect.x,
@ -291,12 +288,12 @@ gimp_cell_renderer_color_render (GtkCellRenderer *cell,
rect.x + 1, rect.y + 1, rect.x + 1, rect.y + 1,
rect.width - 2, rect.height - 2); rect.width - 2, rect.height - 2);
gimp_cairo_set_source_color (cr, private->color, NULL, FALSE, gimp_cairo_set_source_color (cr, renderer->color, NULL, FALSE,
widget); widget);
cairo_fill (cr); cairo_fill (cr);
gegl_color_get_pixel (private->color, babl_format ("R'G'B'A double"), rgba); gegl_color_get_pixel (renderer->color, babl_format ("R'G'B'A double"), rgba);
if (! private->opaque && rgba[3] < 1.0) if (! renderer->opaque && rgba[3] < 1.0)
{ {
cairo_pattern_t *pattern; cairo_pattern_t *pattern;
@ -313,7 +310,7 @@ gimp_cell_renderer_color_render (GtkCellRenderer *cell,
cairo_fill_preserve (cr); cairo_fill_preserve (cr);
gimp_cairo_set_source_color (cr, private->color, NULL, FALSE, gimp_cairo_set_source_color (cr, renderer->color, NULL, FALSE,
widget); widget);
cairo_fill (cr); cairo_fill (cr);
} }

View file

@ -29,42 +29,10 @@
G_BEGIN_DECLS G_BEGIN_DECLS
#define GIMP_TYPE_CELL_RENDERER_COLOR (gimp_cell_renderer_color_get_type ()) #define GIMP_TYPE_CELL_RENDERER_COLOR (gimp_cell_renderer_color_get_type ())
#define GIMP_CELL_RENDERER_COLOR(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GIMP_TYPE_CELL_RENDERER_COLOR, GimpCellRendererColor)) G_DECLARE_FINAL_TYPE (GimpCellRendererColor, gimp_cell_renderer_color, GIMP, CELL_RENDERER_COLOR, GtkCellRenderer)
#define GIMP_CELL_RENDERER_COLOR_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GIMP_TYPE_CELL_RENDERER_COLOR, GimpCellRendererColorClass))
#define GIMP_IS_CELL_RENDERER_COLOR(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GIMP_TYPE_CELL_RENDERER_COLOR))
#define GIMP_IS_CELL_RENDERER_COLOR_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GIMP_TYPE_CELL_RENDERER_COLOR))
#define GIMP_CELL_RENDERER_COLOR_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GIMP_TYPE_CELL_RENDERER_COLOR, GimpCellRendererColorClass))
typedef struct _GimpCellRendererColorPrivate GimpCellRendererColorPrivate;
typedef struct _GimpCellRendererColorClass GimpCellRendererColorClass;
struct _GimpCellRendererColor
{
GtkCellRenderer parent_instance;
GimpCellRendererColorPrivate *priv;
};
struct _GimpCellRendererColorClass
{
GtkCellRendererClass parent_class;
/* Padding for future expansion */
void (* _gimp_reserved1) (void);
void (* _gimp_reserved2) (void);
void (* _gimp_reserved3) (void);
void (* _gimp_reserved4) (void);
void (* _gimp_reserved5) (void);
void (* _gimp_reserved6) (void);
void (* _gimp_reserved7) (void);
void (* _gimp_reserved8) (void);
};
GType gimp_cell_renderer_color_get_type (void) G_GNUC_CONST;
GtkCellRenderer * gimp_cell_renderer_color_new (void); GtkCellRenderer * gimp_cell_renderer_color_new (void);

View file

@ -50,8 +50,10 @@
**/ **/
struct _GimpColorProfileChooserDialogPrivate struct _GimpColorProfileChooserDialog
{ {
GtkFileChooserDialog parent_instance;
GimpColorProfileView *profile_view; GimpColorProfileView *profile_view;
}; };
@ -65,9 +67,8 @@ static void gimp_color_profile_chooser_dialog_add_shortcut (GimpColorProfi
static void gimp_color_profile_chooser_dialog_update_preview (GimpColorProfileChooserDialog *dialog); static void gimp_color_profile_chooser_dialog_update_preview (GimpColorProfileChooserDialog *dialog);
G_DEFINE_TYPE_WITH_PRIVATE (GimpColorProfileChooserDialog, G_DEFINE_TYPE (GimpColorProfileChooserDialog, gimp_color_profile_chooser_dialog,
gimp_color_profile_chooser_dialog, GTK_TYPE_FILE_CHOOSER_DIALOG)
GTK_TYPE_FILE_CHOOSER_DIALOG)
#define parent_class gimp_color_profile_chooser_dialog_parent_class #define parent_class gimp_color_profile_chooser_dialog_parent_class
@ -86,8 +87,6 @@ gimp_color_profile_chooser_dialog_class_init (GimpColorProfileChooserDialogClass
static void static void
gimp_color_profile_chooser_dialog_init (GimpColorProfileChooserDialog *dialog) gimp_color_profile_chooser_dialog_init (GimpColorProfileChooserDialog *dialog)
{ {
dialog->priv =
gimp_color_profile_chooser_dialog_get_instance_private (dialog);
} }
static void static void
@ -131,7 +130,7 @@ gimp_color_profile_chooser_dialog_constructed (GObject *object)
gtk_container_add (GTK_CONTAINER (scrolled_window), profile_view); gtk_container_add (GTK_CONTAINER (scrolled_window), profile_view);
gtk_widget_show (profile_view); gtk_widget_show (profile_view);
dialog->priv->profile_view = GIMP_COLOR_PROFILE_VIEW (profile_view); dialog->profile_view = GIMP_COLOR_PROFILE_VIEW (profile_view);
gtk_file_chooser_set_preview_widget (GTK_FILE_CHOOSER (dialog), gtk_file_chooser_set_preview_widget (GTK_FILE_CHOOSER (dialog),
scrolled_window); scrolled_window);
@ -186,9 +185,9 @@ gimp_color_profile_chooser_dialog_new (const gchar *title,
} }
gimp_dialog_set_alternative_button_order (GTK_DIALOG (dialog), gimp_dialog_set_alternative_button_order (GTK_DIALOG (dialog),
GTK_RESPONSE_ACCEPT, GTK_RESPONSE_ACCEPT,
GTK_RESPONSE_CANCEL, GTK_RESPONSE_CANCEL,
-1); -1);
gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_ACCEPT); gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_ACCEPT);
@ -210,8 +209,10 @@ add_shortcut (GimpColorProfileChooserDialog *dialog,
static void static void
gimp_color_profile_chooser_dialog_add_shortcut (GimpColorProfileChooserDialog *dialog) gimp_color_profile_chooser_dialog_add_shortcut (GimpColorProfileChooserDialog *dialog)
{ {
#ifndef G_OS_WIN32
gboolean save = (gtk_file_chooser_get_action (GTK_FILE_CHOOSER (dialog)) == gboolean save = (gtk_file_chooser_get_action (GTK_FILE_CHOOSER (dialog)) ==
GTK_FILE_CHOOSER_ACTION_SAVE); GTK_FILE_CHOOSER_ACTION_SAVE);
#endif
#ifdef G_OS_WIN32 #ifdef G_OS_WIN32
{ {
@ -318,7 +319,7 @@ gimp_color_profile_chooser_dialog_update_preview (GimpColorProfileChooserDialog
if (! file) if (! file)
{ {
gimp_color_profile_view_set_profile (dialog->priv->profile_view, NULL); gimp_color_profile_view_set_profile (dialog->profile_view, NULL);
return; return;
} }
@ -329,25 +330,25 @@ gimp_color_profile_chooser_dialog_update_preview (GimpColorProfileChooserDialog
if (! profile) if (! profile)
{ {
gimp_color_profile_view_set_error (dialog->priv->profile_view, gimp_color_profile_view_set_error (dialog->profile_view,
error->message); error->message);
g_clear_error (&error); g_clear_error (&error);
} }
else else
{ {
gimp_color_profile_view_set_profile (dialog->priv->profile_view, gimp_color_profile_view_set_profile (dialog->profile_view,
profile); profile);
g_object_unref (profile); g_object_unref (profile);
} }
break; break;
case G_FILE_TYPE_DIRECTORY: case G_FILE_TYPE_DIRECTORY:
gimp_color_profile_view_set_error (dialog->priv->profile_view, gimp_color_profile_view_set_error (dialog->profile_view,
_("Folder")); _("Folder"));
break; break;
default: default:
gimp_color_profile_view_set_error (dialog->priv->profile_view, gimp_color_profile_view_set_error (dialog->profile_view,
_("Not a regular file.")); _("Not a regular file."));
break; break;
} }

View file

@ -25,41 +25,8 @@
G_BEGIN_DECLS G_BEGIN_DECLS
#define GIMP_TYPE_COLOR_PROFILE_CHOOSER_DIALOG (gimp_color_profile_chooser_dialog_get_type ()) #define GIMP_TYPE_COLOR_PROFILE_CHOOSER_DIALOG (gimp_color_profile_chooser_dialog_get_type ())
#define GIMP_COLOR_PROFILE_CHOOSER_DIALOG(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GIMP_TYPE_COLOR_PROFILE_CHOOSER_DIALOG, GimpColorProfileChooserDialog)) G_DECLARE_FINAL_TYPE (GimpColorProfileChooserDialog, gimp_color_profile_chooser_dialog, GIMP, COLOR_PROFILE_CHOOSER_DIALOG, GtkFileChooserDialog)
#define GIMP_COLOR_PROFILE_CHOOSER_DIALOG_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GIMP_TYPE_COLOR_PROFILE_CHOOSER_DIALOG, GimpColorProfileChooserDialogClass))
#define GIMP_IS_COLOR_PROFILE_CHOOSER_DIALOG(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GIMP_TYPE_COLOR_PROFILE_CHOOSER_DIALOG))
#define GIMP_IS_COLOR_PROFILE_CHOOSER_DIALOG_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GIMP_TYPE_COLOR_PROFILE_CHOOSER_DIALOG))
#define GIMP_COLOR_PROFILE_CHOOSER_DIALOG_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GIMP_TYPE_COLOR_PROFILE_CHOOSER_DIALOG, GimpColorProfileChooserDialogClass))
typedef struct _GimpColorProfileChooserDialogClass GimpColorProfileChooserDialogClass;
typedef struct _GimpColorProfileChooserDialogPrivate GimpColorProfileChooserDialogPrivate;
struct _GimpColorProfileChooserDialog
{
GtkFileChooserDialog parent_instance;
GimpColorProfileChooserDialogPrivate *priv;
};
struct _GimpColorProfileChooserDialogClass
{
GtkFileChooserDialogClass parent_class;
/* Padding for future expansion */
void (* _gimp_reserved1) (void);
void (* _gimp_reserved2) (void);
void (* _gimp_reserved3) (void);
void (* _gimp_reserved4) (void);
void (* _gimp_reserved5) (void);
void (* _gimp_reserved6) (void);
void (* _gimp_reserved7) (void);
void (* _gimp_reserved8) (void);
};
GType gimp_color_profile_chooser_dialog_get_type (void) G_GNUC_CONST;
GtkWidget * gimp_color_profile_chooser_dialog_new (const gchar *title, GtkWidget * gimp_color_profile_chooser_dialog_new (const gchar *title,
GtkWindow *parent, GtkWindow *parent,

View file

@ -52,14 +52,14 @@ enum
}; };
struct _GimpColorProfileComboBoxPrivate struct _GimpColorProfileComboBox
{ {
GtkComboBox parent_instance;
GtkWidget *dialog; GtkWidget *dialog;
GtkTreePath *last_path; GtkTreePath *last_path;
}; };
#define GET_PRIVATE(obj) (((GimpColorProfileComboBox *) (obj))->priv)
static void gimp_color_profile_combo_box_finalize (GObject *object); static void gimp_color_profile_combo_box_finalize (GObject *object);
static void gimp_color_profile_combo_box_set_property (GObject *object, static void gimp_color_profile_combo_box_set_property (GObject *object,
@ -81,8 +81,7 @@ static void gimp_color_profile_combo_dialog_response (GimpColorProfileChooserD
GimpColorProfileComboBox *combo); GimpColorProfileComboBox *combo);
G_DEFINE_TYPE_WITH_PRIVATE (GimpColorProfileComboBox, G_DEFINE_TYPE (GimpColorProfileComboBox, gimp_color_profile_combo_box, GTK_TYPE_COMBO_BOX)
gimp_color_profile_combo_box, GTK_TYPE_COMBO_BOX)
#define parent_class gimp_color_profile_combo_box_parent_class #define parent_class gimp_color_profile_combo_box_parent_class
@ -138,8 +137,6 @@ gimp_color_profile_combo_box_init (GimpColorProfileComboBox *combo_box)
{ {
GtkCellRenderer *cell; GtkCellRenderer *cell;
combo_box->priv = gimp_color_profile_combo_box_get_instance_private (combo_box);
cell = gtk_cell_renderer_text_new (); cell = gtk_cell_renderer_text_new ();
g_object_set (cell, g_object_set (cell,
@ -161,18 +158,18 @@ gimp_color_profile_combo_box_init (GimpColorProfileComboBox *combo_box)
static void static void
gimp_color_profile_combo_box_finalize (GObject *object) gimp_color_profile_combo_box_finalize (GObject *object)
{ {
GimpColorProfileComboBoxPrivate *private = GET_PRIVATE (object); GimpColorProfileComboBox *combo = GIMP_COLOR_PROFILE_COMBO_BOX (object);
if (private->dialog) if (combo->dialog)
{ {
if (GIMP_IS_COLOR_PROFILE_CHOOSER_DIALOG (private->dialog)) if (GIMP_IS_COLOR_PROFILE_CHOOSER_DIALOG (combo->dialog))
gtk_widget_destroy (private->dialog); gtk_widget_destroy (combo->dialog);
g_object_unref (private->dialog); g_object_unref (combo->dialog);
private->dialog = NULL; combo->dialog = NULL;
} }
g_clear_pointer (&private->last_path, gtk_tree_path_free); g_clear_pointer (&combo->last_path, gtk_tree_path_free);
G_OBJECT_CLASS (parent_class)->finalize (object); G_OBJECT_CLASS (parent_class)->finalize (object);
} }
@ -183,16 +180,16 @@ gimp_color_profile_combo_box_set_property (GObject *object,
const GValue *value, const GValue *value,
GParamSpec *pspec) GParamSpec *pspec)
{ {
GimpColorProfileComboBoxPrivate *private = GET_PRIVATE (object); GimpColorProfileComboBox *combo = GIMP_COLOR_PROFILE_COMBO_BOX (object);
switch (property_id) switch (property_id)
{ {
case PROP_DIALOG: case PROP_DIALOG:
g_return_if_fail (private->dialog == NULL); g_return_if_fail (combo->dialog == NULL);
private->dialog = g_value_dup_object (value); combo->dialog = g_value_dup_object (value);
if (GIMP_IS_COLOR_PROFILE_CHOOSER_DIALOG (private->dialog)) if (GIMP_IS_COLOR_PROFILE_CHOOSER_DIALOG (combo->dialog))
g_signal_connect (private->dialog, "response", g_signal_connect (combo->dialog, "response",
G_CALLBACK (gimp_color_profile_combo_dialog_response), G_CALLBACK (gimp_color_profile_combo_dialog_response),
object); object);
break; break;
@ -214,12 +211,12 @@ gimp_color_profile_combo_box_get_property (GObject *object,
GValue *value, GValue *value,
GParamSpec *pspec) GParamSpec *pspec)
{ {
GimpColorProfileComboBoxPrivate *private = GET_PRIVATE (object); GimpColorProfileComboBox *combo = GIMP_COLOR_PROFILE_COMBO_BOX (object);
switch (property_id) switch (property_id)
{ {
case PROP_DIALOG: case PROP_DIALOG:
g_value_set_object (value, private->dialog); g_value_set_object (value, combo->dialog);
break; break;
case PROP_MODEL: case PROP_MODEL:
@ -236,10 +233,10 @@ gimp_color_profile_combo_box_get_property (GObject *object,
static void static void
gimp_color_profile_combo_box_changed (GtkComboBox *combo) gimp_color_profile_combo_box_changed (GtkComboBox *combo)
{ {
GimpColorProfileComboBoxPrivate *priv = GET_PRIVATE (combo); GimpColorProfileComboBox *color_combo = GIMP_COLOR_PROFILE_COMBO_BOX (combo);
GtkTreeModel *model = gtk_combo_box_get_model (combo); GtkTreeModel *model = gtk_combo_box_get_model (combo);
GtkTreeIter iter; GtkTreeIter iter;
gint type; gint type;
if (! gtk_combo_box_get_active_iter (combo, &iter)) if (! gtk_combo_box_get_active_iter (combo, &iter))
return; return;
@ -255,13 +252,13 @@ gimp_color_profile_combo_box_changed (GtkComboBox *combo)
GtkWidget *parent = gtk_widget_get_toplevel (GTK_WIDGET (combo)); GtkWidget *parent = gtk_widget_get_toplevel (GTK_WIDGET (combo));
if (GTK_IS_WINDOW (parent)) if (GTK_IS_WINDOW (parent))
gtk_window_set_transient_for (GTK_WINDOW (priv->dialog), gtk_window_set_transient_for (GTK_WINDOW (color_combo->dialog),
GTK_WINDOW (parent)); GTK_WINDOW (parent));
gtk_window_present (GTK_WINDOW (priv->dialog)); gtk_window_present (GTK_WINDOW (color_combo->dialog));
if (priv->last_path && if (color_combo->last_path &&
gtk_tree_model_get_iter (model, &iter, priv->last_path)) gtk_tree_model_get_iter (model, &iter, color_combo->last_path))
{ {
gtk_combo_box_set_active_iter (combo, &iter); gtk_combo_box_set_active_iter (combo, &iter);
} }
@ -269,10 +266,10 @@ gimp_color_profile_combo_box_changed (GtkComboBox *combo)
break; break;
case GIMP_COLOR_PROFILE_STORE_ITEM_FILE: case GIMP_COLOR_PROFILE_STORE_ITEM_FILE:
if (priv->last_path) if (color_combo->last_path)
gtk_tree_path_free (priv->last_path); gtk_tree_path_free (color_combo->last_path);
priv->last_path = gtk_tree_model_get_path (model, &iter); color_combo->last_path = gtk_tree_model_get_path (model, &iter);
_gimp_color_profile_store_history_reorder (GIMP_COLOR_PROFILE_STORE (model), _gimp_color_profile_store_history_reorder (GIMP_COLOR_PROFILE_STORE (model),
&iter); &iter);

View file

@ -28,42 +28,10 @@
G_BEGIN_DECLS G_BEGIN_DECLS
#define GIMP_TYPE_COLOR_PROFILE_COMBO_BOX (gimp_color_profile_combo_box_get_type ()) #define GIMP_TYPE_COLOR_PROFILE_COMBO_BOX (gimp_color_profile_combo_box_get_type ())
#define GIMP_COLOR_PROFILE_COMBO_BOX(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GIMP_TYPE_COLOR_PROFILE_COMBO_BOX, GimpColorProfileComboBox)) G_DECLARE_FINAL_TYPE (GimpColorProfileComboBox, gimp_color_profile_combo_box, GIMP, COLOR_PROFILE_COMBO_BOX, GtkComboBox)
#define GIMP_COLOR_PROFILE_COMBO_BOX_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GIMP_TYPE_COLOR_PROFILE_COMBO_BOX, GimpColorProfileComboBoxClass))
#define GIMP_IS_COLOR_PROFILE_COMBO_BOX(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GIMP_TYPE_COLOR_PROFILE_COMBO_BOX))
#define GIMP_IS_COLOR_PROFILE_COMBO_BOX_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GIMP_TYPE_COLOR_PROFILE_COMBO_BOX))
#define GIMP_COLOR_PROFILE_COMBO_BOX_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GIMP_TYPE_COLOR_PROFILE_COMBO_BOX, GimpColorProfileComboBoxClass))
typedef struct _GimpColorProfileComboBoxPrivate GimpColorProfileComboBoxPrivate;
typedef struct _GimpColorProfileComboBoxClass GimpColorProfileComboBoxClass;
struct _GimpColorProfileComboBox
{
GtkComboBox parent_instance;
GimpColorProfileComboBoxPrivate *priv;
};
struct _GimpColorProfileComboBoxClass
{
GtkComboBoxClass parent_class;
/* Padding for future expansion */
void (* _gimp_reserved1) (void);
void (* _gimp_reserved2) (void);
void (* _gimp_reserved3) (void);
void (* _gimp_reserved4) (void);
void (* _gimp_reserved5) (void);
void (* _gimp_reserved6) (void);
void (* _gimp_reserved7) (void);
void (* _gimp_reserved8) (void);
};
GType gimp_color_profile_combo_box_get_type (void) G_GNUC_CONST;
GtkWidget * gimp_color_profile_combo_box_new (GtkWidget *dialog, GtkWidget * gimp_color_profile_combo_box_new (GtkWidget *dialog,
GFile *history); GFile *history);
GtkWidget * gimp_color_profile_combo_box_new_with_model (GtkWidget *dialog, GtkWidget * gimp_color_profile_combo_box_new_with_model (GtkWidget *dialog,

View file

@ -56,12 +56,12 @@ enum
}; };
struct _GimpColorProfileStorePrivate struct _GimpColorProfileStore
{ {
GFile *history; GtkListStore parent_instance;
};
#define GET_PRIVATE(obj) (((GimpColorProfileStore *) (obj))->priv) GFile *history;
};
static void gimp_color_profile_store_constructed (GObject *object); static void gimp_color_profile_store_constructed (GObject *object);
@ -92,8 +92,7 @@ static gboolean gimp_color_profile_store_load (GimpColorProfileStore
GError **error); GError **error);
G_DEFINE_TYPE_WITH_PRIVATE (GimpColorProfileStore, gimp_color_profile_store, G_DEFINE_TYPE (GimpColorProfileStore, gimp_color_profile_store, GTK_TYPE_LIST_STORE)
GTK_TYPE_LIST_STORE)
#define parent_class gimp_color_profile_store_parent_class #define parent_class gimp_color_profile_store_parent_class
@ -137,8 +136,6 @@ gimp_color_profile_store_init (GimpColorProfileStore *store)
G_TYPE_INT /* GIMP_COLOR_PROFILE_STORE_INDEX */ G_TYPE_INT /* GIMP_COLOR_PROFILE_STORE_INDEX */
}; };
store->priv = gimp_color_profile_store_get_instance_private (store);
gtk_list_store_set_column_types (GTK_LIST_STORE (store), gtk_list_store_set_column_types (GTK_LIST_STORE (store),
G_N_ELEMENTS (types), types); G_N_ELEMENTS (types), types);
} }
@ -146,9 +143,8 @@ gimp_color_profile_store_init (GimpColorProfileStore *store)
static void static void
gimp_color_profile_store_constructed (GObject *object) gimp_color_profile_store_constructed (GObject *object)
{ {
GimpColorProfileStore *store = GIMP_COLOR_PROFILE_STORE (object); GimpColorProfileStore *store = GIMP_COLOR_PROFILE_STORE (object);
GimpColorProfileStorePrivate *private = GET_PRIVATE (store); GtkTreeIter iter;
GtkTreeIter iter;
G_OBJECT_CLASS (parent_class)->constructed (object); G_OBJECT_CLASS (parent_class)->constructed (object);
@ -160,18 +156,17 @@ gimp_color_profile_store_constructed (GObject *object)
_("Select color profile from disk..."), _("Select color profile from disk..."),
-1); -1);
if (private->history) if (store->history)
gimp_color_profile_store_load (store, private->history, NULL); gimp_color_profile_store_load (store, store->history, NULL);
} }
static void static void
gimp_color_profile_store_dispose (GObject *object) gimp_color_profile_store_dispose (GObject *object)
{ {
GimpColorProfileStore *store = GIMP_COLOR_PROFILE_STORE (object); GimpColorProfileStore *store = GIMP_COLOR_PROFILE_STORE (object);
GimpColorProfileStorePrivate *private = GET_PRIVATE (store);
if (private->history) if (store->history)
gimp_color_profile_store_save (store, private->history, NULL); gimp_color_profile_store_save (store, store->history, NULL);
G_OBJECT_CLASS (parent_class)->dispose (object); G_OBJECT_CLASS (parent_class)->dispose (object);
} }
@ -179,9 +174,9 @@ gimp_color_profile_store_dispose (GObject *object)
static void static void
gimp_color_profile_store_finalize (GObject *object) gimp_color_profile_store_finalize (GObject *object)
{ {
GimpColorProfileStorePrivate *private = GET_PRIVATE (object); GimpColorProfileStore *store = GIMP_COLOR_PROFILE_STORE (object);
g_clear_object (&private->history); g_clear_object (&store->history);
G_OBJECT_CLASS (parent_class)->finalize (object); G_OBJECT_CLASS (parent_class)->finalize (object);
} }
@ -192,13 +187,13 @@ gimp_color_profile_store_set_property (GObject *object,
const GValue *value, const GValue *value,
GParamSpec *pspec) GParamSpec *pspec)
{ {
GimpColorProfileStorePrivate *private = GET_PRIVATE (object); GimpColorProfileStore *store = GIMP_COLOR_PROFILE_STORE (object);
switch (property_id) switch (property_id)
{ {
case PROP_HISTORY: case PROP_HISTORY:
g_return_if_fail (private->history == NULL); g_return_if_fail (store->history == NULL);
private->history = g_value_dup_object (value); store->history = g_value_dup_object (value);
break; break;
default: default:
@ -213,12 +208,12 @@ gimp_color_profile_store_get_property (GObject *object,
GValue *value, GValue *value,
GParamSpec *pspec) GParamSpec *pspec)
{ {
GimpColorProfileStorePrivate *private = GET_PRIVATE (object); GimpColorProfileStore *store = GIMP_COLOR_PROFILE_STORE (object);
switch (property_id) switch (property_id)
{ {
case PROP_HISTORY: case PROP_HISTORY:
g_value_set_object (value, private->history); g_value_set_object (value, store->history);
break; break;
default: default:

View file

@ -29,41 +29,10 @@
G_BEGIN_DECLS G_BEGIN_DECLS
#define GIMP_TYPE_COLOR_PROFILE_STORE (gimp_color_profile_store_get_type ()) #define GIMP_TYPE_COLOR_PROFILE_STORE (gimp_color_profile_store_get_type ())
#define GIMP_COLOR_PROFILE_STORE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GIMP_TYPE_COLOR_PROFILE_STORE, GimpColorProfileStore)) G_DECLARE_FINAL_TYPE (GimpColorProfileStore, gimp_color_profile_store, GIMP, COLOR_PROFILE_STORE, GtkListStore)
#define GIMP_COLOR_PROFILE_STORE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GIMP_TYPE_COLOR_PROFILE_STORE, GimpColorProfileStoreClass))
#define GIMP_IS_COLOR_PROFILE_STORE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GIMP_TYPE_COLOR_PROFILE_STORE))
#define GIMP_IS_COLOR_PROFILE_STORE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GIMP_TYPE_COLOR_PROFILE_STORE))
#define GIMP_COLOR_PROFILE_STORE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GIMP_TYPE_COLOR_PROFILE_STORE, GimpColorProfileStoreClass))
typedef struct _GimpColorProfileStorePrivate GimpColorProfileStorePrivate;
typedef struct _GimpColorProfileStoreClass GimpColorProfileStoreClass;
struct _GimpColorProfileStore
{
GtkListStore parent_instance;
GimpColorProfileStorePrivate *priv;
};
struct _GimpColorProfileStoreClass
{
GtkListStoreClass parent_class;
void (* _gimp_reserved1) (void);
void (* _gimp_reserved2) (void);
void (* _gimp_reserved3) (void);
void (* _gimp_reserved4) (void);
void (* _gimp_reserved5) (void);
void (* _gimp_reserved6) (void);
void (* _gimp_reserved7) (void);
void (* _gimp_reserved8) (void);
};
GType gimp_color_profile_store_get_type (void) G_GNUC_CONST;
GtkListStore * gimp_color_profile_store_new (GFile *history); GtkListStore * gimp_color_profile_store_new (GFile *history);
void gimp_color_profile_store_add_file (GimpColorProfileStore *store, void gimp_color_profile_store_add_file (GimpColorProfileStore *store,

View file

@ -43,8 +43,10 @@
**/ **/
struct _GimpColorProfileViewPrivate struct _GimpColorProfileView
{ {
GtkTextView parent_instance;
GimpColorProfile *profile; GimpColorProfile *profile;
}; };
@ -53,8 +55,7 @@ static void gimp_color_profile_view_constructed (GObject *object);
static void gimp_color_profile_view_finalize (GObject *object); static void gimp_color_profile_view_finalize (GObject *object);
G_DEFINE_TYPE_WITH_PRIVATE (GimpColorProfileView, gimp_color_profile_view, G_DEFINE_TYPE (GimpColorProfileView, gimp_color_profile_view, GTK_TYPE_TEXT_VIEW)
GTK_TYPE_TEXT_VIEW)
#define parent_class gimp_color_profile_view_parent_class #define parent_class gimp_color_profile_view_parent_class
@ -71,7 +72,6 @@ gimp_color_profile_view_class_init (GimpColorProfileViewClass *klass)
static void static void
gimp_color_profile_view_init (GimpColorProfileView *view) gimp_color_profile_view_init (GimpColorProfileView *view)
{ {
view->priv = gimp_color_profile_view_get_instance_private (view);
} }
static void static void
@ -109,7 +109,7 @@ gimp_color_profile_view_finalize (GObject *object)
{ {
GimpColorProfileView *view = GIMP_COLOR_PROFILE_VIEW (object); GimpColorProfileView *view = GIMP_COLOR_PROFILE_VIEW (object);
g_clear_object (&view->priv->profile); g_clear_object (&view->profile);
G_OBJECT_CLASS (parent_class)->finalize (object); G_OBJECT_CLASS (parent_class)->finalize (object);
} }
@ -129,14 +129,14 @@ gimp_color_profile_view_set_profile (GimpColorProfileView *view,
g_return_if_fail (GIMP_IS_COLOR_PROFILE_VIEW (view)); g_return_if_fail (GIMP_IS_COLOR_PROFILE_VIEW (view));
g_return_if_fail (profile == NULL || GIMP_IS_COLOR_PROFILE (profile)); g_return_if_fail (profile == NULL || GIMP_IS_COLOR_PROFILE (profile));
if (profile == view->priv->profile) if (profile == view->profile)
return; return;
buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (view)); buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (view));
gtk_text_buffer_set_text (buffer, "", 0); gtk_text_buffer_set_text (buffer, "", 0);
if (g_set_object (&view->priv->profile, profile) && profile) if (g_set_object (&view->profile, profile) && profile)
{ {
GtkTextIter iter; GtkTextIter iter;
const gchar *text; const gchar *text;

View file

@ -24,42 +24,10 @@
G_BEGIN_DECLS G_BEGIN_DECLS
#define GIMP_TYPE_COLOR_PROFILE_VIEW (gimp_color_profile_view_get_type ()) #define GIMP_TYPE_COLOR_PROFILE_VIEW (gimp_color_profile_view_get_type ())
#define GIMP_COLOR_PROFILE_VIEW(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GIMP_TYPE_COLOR_PROFILE_VIEW, GimpColorProfileView)) G_DECLARE_FINAL_TYPE (GimpColorProfileView, gimp_color_profile_view, GIMP, COLOR_PROFILE_VIEW, GtkTextView)
#define GIMP_COLOR_PROFILE_VIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GIMP_TYPE_COLOR_PROFILE_VIEW, GimpColorProfileViewClass))
#define GIMP_IS_COLOR_PROFILE_VIEW(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GIMP_TYPE_COLOR_PROFILE_VIEW))
#define GIMP_IS_COLOR_PROFILE_VIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GIMP_TYPE_COLOR_PROFILE_VIEW))
#define GIMP_COLOR_PROFILE_VIEW_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GIMP_TYPE_COLOR_PROFILE_VIEW, GimpColorProfileViewClass))
typedef struct _GimpColorProfileViewClass GimpColorProfileViewClass;
typedef struct _GimpColorProfileViewPrivate GimpColorProfileViewPrivate;
struct _GimpColorProfileView
{
GtkTextView parent_instance;
GimpColorProfileViewPrivate *priv;
};
struct _GimpColorProfileViewClass
{
GtkTextViewClass parent_class;
/* Padding for future expansion */
void (* _gimp_reserved1) (void);
void (* _gimp_reserved2) (void);
void (* _gimp_reserved3) (void);
void (* _gimp_reserved4) (void);
void (* _gimp_reserved5) (void);
void (* _gimp_reserved6) (void);
void (* _gimp_reserved7) (void);
void (* _gimp_reserved8) (void);
};
GType gimp_color_profile_view_get_type (void) G_GNUC_CONST;
GtkWidget * gimp_color_profile_view_new (void); GtkWidget * gimp_color_profile_view_new (void);
void gimp_color_profile_view_set_profile (GimpColorProfileView *view, void gimp_color_profile_view_set_profile (GimpColorProfileView *view,

View file

@ -54,16 +54,10 @@ enum
}; };
typedef struct _GimpLCH GimpLCH; struct _GimpColorScale
struct _GimpLCH
{ {
gdouble l, c, h, a; GtkScale parent_instance;
};
struct _GimpColorScalePrivate
{
GimpColorConfig *config; GimpColorConfig *config;
guchar oog_color[3]; guchar oog_color[3];
const Babl *format; const Babl *format;
@ -79,8 +73,6 @@ struct _GimpColorScalePrivate
gboolean needs_render; gboolean needs_render;
}; };
#define GET_PRIVATE(obj) (((GimpColorScale *) (obj))->priv)
static void gimp_color_scale_dispose (GObject *object); static void gimp_color_scale_dispose (GObject *object);
static void gimp_color_scale_finalize (GObject *object); static void gimp_color_scale_finalize (GObject *object);
@ -106,7 +98,7 @@ static void gimp_color_scale_notify_config (GimpColorConfig *config,
GimpColorScale *scale); GimpColorScale *scale);
G_DEFINE_TYPE_WITH_PRIVATE (GimpColorScale, gimp_color_scale, GTK_TYPE_SCALE) G_DEFINE_TYPE (GimpColorScale, gimp_color_scale, GTK_TYPE_SCALE)
#define parent_class gimp_color_scale_parent_class #define parent_class gimp_color_scale_parent_class
@ -158,13 +150,8 @@ gimp_color_scale_class_init (GimpColorScaleClass *klass)
static void static void
gimp_color_scale_init (GimpColorScale *scale) gimp_color_scale_init (GimpColorScale *scale)
{ {
GimpColorScalePrivate *priv; GtkRange *range = GTK_RANGE (scale);
GtkRange *range = GTK_RANGE (scale); GtkCssProvider *css;
GtkCssProvider *css;
scale->priv = gimp_color_scale_get_instance_private (scale);
priv = scale->priv;
gtk_widget_set_can_focus (GTK_WIDGET (scale), TRUE); gtk_widget_set_can_focus (GTK_WIDGET (scale), TRUE);
@ -172,13 +159,13 @@ gimp_color_scale_init (GimpColorScale *scale)
gtk_range_set_flippable (GTK_RANGE (scale), TRUE); gtk_range_set_flippable (GTK_RANGE (scale), TRUE);
gtk_scale_set_draw_value (GTK_SCALE (scale), FALSE); gtk_scale_set_draw_value (GTK_SCALE (scale), FALSE);
priv->channel = GIMP_COLOR_SELECTOR_VALUE; scale->channel = GIMP_COLOR_SELECTOR_VALUE;
priv->needs_render = TRUE; scale->needs_render = TRUE;
gtk_orientable_set_orientation (GTK_ORIENTABLE (range), gtk_orientable_set_orientation (GTK_ORIENTABLE (range),
GTK_ORIENTATION_HORIZONTAL); GTK_ORIENTATION_HORIZONTAL);
priv->color = gegl_color_new ("black"); scale->color = gegl_color_new ("black");
css = gtk_css_provider_new (); css = gtk_css_provider_new ();
gtk_css_provider_load_from_data (css, gtk_css_provider_load_from_data (css,
@ -216,13 +203,13 @@ gimp_color_scale_dispose (GObject *object)
static void static void
gimp_color_scale_finalize (GObject *object) gimp_color_scale_finalize (GObject *object)
{ {
GimpColorScalePrivate *priv = GET_PRIVATE (object); GimpColorScale *scale = GIMP_COLOR_SCALE (object);
g_clear_pointer (&priv->buf, g_free); g_clear_pointer (&scale->buf, g_free);
priv->width = 0; scale->width = 0;
priv->height = 0; scale->height = 0;
priv->rowstride = 0; scale->rowstride = 0;
g_object_unref (priv->color); g_object_unref (scale->color);
G_OBJECT_CLASS (parent_class)->finalize (object); G_OBJECT_CLASS (parent_class)->finalize (object);
} }
@ -233,12 +220,12 @@ gimp_color_scale_get_property (GObject *object,
GValue *value, GValue *value,
GParamSpec *pspec) GParamSpec *pspec)
{ {
GimpColorScalePrivate *priv = GET_PRIVATE (object); GimpColorScale *scale = GIMP_COLOR_SCALE (object);
switch (property_id) switch (property_id)
{ {
case PROP_CHANNEL: case PROP_CHANNEL:
g_value_set_enum (value, priv->channel); g_value_set_enum (value, scale->channel);
break; break;
default: default:
@ -271,27 +258,27 @@ static void
gimp_color_scale_size_allocate (GtkWidget *widget, gimp_color_scale_size_allocate (GtkWidget *widget,
GtkAllocation *allocation) GtkAllocation *allocation)
{ {
GimpColorScalePrivate *priv = GET_PRIVATE (widget); GimpColorScale *scale = GIMP_COLOR_SCALE (widget);
GtkRange *range = GTK_RANGE (widget); GtkRange *range = GTK_RANGE (widget);
GdkRectangle range_rect; GdkRectangle range_rect;
GTK_WIDGET_CLASS (parent_class)->size_allocate (widget, allocation); GTK_WIDGET_CLASS (parent_class)->size_allocate (widget, allocation);
gtk_range_get_range_rect (range, &range_rect); gtk_range_get_range_rect (range, &range_rect);
if (range_rect.width != priv->width || if (range_rect.width != scale->width ||
range_rect.height != priv->height) range_rect.height != scale->height)
{ {
priv->width = range_rect.width; scale->width = range_rect.width;
priv->height = range_rect.height; scale->height = range_rect.height;
/* TODO: we should move to CAIRO_FORMAT_RGBA128F. */ /* TODO: we should move to CAIRO_FORMAT_RGBA128F. */
priv->rowstride = cairo_format_stride_for_width (CAIRO_FORMAT_RGB24, priv->width); scale->rowstride = cairo_format_stride_for_width (CAIRO_FORMAT_RGB24, scale->width);
g_free (priv->buf); g_free (scale->buf);
priv->buf = g_new (guchar, 3 * priv->width * priv->height); scale->buf = g_new (guchar, 3 * scale->width * scale->height);
priv->needs_render = TRUE; scale->needs_render = TRUE;
} }
} }
@ -299,23 +286,22 @@ static gboolean
gimp_color_scale_draw (GtkWidget *widget, gimp_color_scale_draw (GtkWidget *widget,
cairo_t *cr) cairo_t *cr)
{ {
GimpColorScale *scale = GIMP_COLOR_SCALE (widget); GimpColorScale *scale = GIMP_COLOR_SCALE (widget);
GimpColorScalePrivate *priv = GET_PRIVATE (widget); GtkRange *range = GTK_RANGE (widget);
GtkRange *range = GTK_RANGE (widget); GtkStyleContext *context = gtk_widget_get_style_context (widget);
GtkStyleContext *context = gtk_widget_get_style_context (widget); GdkRectangle range_rect;
GdkRectangle range_rect; GdkRectangle area = { 0, };
GdkRectangle area = { 0, }; cairo_surface_t *buffer;
cairo_surface_t *buffer; guchar *buf = NULL;
guchar *buf = NULL; guchar *src;
guchar *src; guchar *dest;
guchar *dest; gint slider_start;
gint slider_start; gint slider_end;
gint slider_end; gint slider_mid;
gint slider_mid; gint slider_size;
gint slider_size; const Babl *render_space;
const Babl *render_space;
if (! priv->buf) if (! scale->buf)
return FALSE; return FALSE;
gtk_range_get_range_rect (range, &range_rect); gtk_range_get_range_rect (range, &range_rect);
@ -324,35 +310,35 @@ gimp_color_scale_draw (GtkWidget *widget,
slider_mid = slider_start + (slider_end - slider_start) / 2; slider_mid = slider_start + (slider_end - slider_start) / 2;
slider_size = 6; slider_size = 6;
if (priv->needs_render) if (scale->needs_render)
{ {
gimp_color_scale_render (scale); gimp_color_scale_render (scale);
priv->needs_render = FALSE; scale->needs_render = FALSE;
} }
render_space = gimp_widget_get_render_space (widget, priv->config); render_space = gimp_widget_get_render_space (widget, scale->config);
fish_rgb_to_cairo = babl_fish (babl_format_with_space ("R'G'B' u8", priv->format), fish_rgb_to_cairo = babl_fish (babl_format_with_space ("R'G'B' u8", scale->format),
babl_format_with_space ("cairo-RGB24", render_space)), babl_format_with_space ("cairo-RGB24", render_space)),
src = priv->buf; src = scale->buf;
buf = g_new (guchar, priv->rowstride * priv->height); buf = g_new (guchar, scale->rowstride * scale->height);
dest = buf; dest = buf;
/* We convert per line because the cairo rowstride may be bigger than the /* We convert per line because the cairo rowstride may be bigger than the
* real contents. * real contents.
*/ */
for (gint i = 0; i < priv->height; i++) for (gint i = 0; i < scale->height; i++)
{ {
babl_process (fish_rgb_to_cairo, src, dest, priv->width); babl_process (fish_rgb_to_cairo, src, dest, scale->width);
src += 3 * priv->width; src += 3 * scale->width;
dest += priv->rowstride; dest += scale->rowstride;
} }
buffer = cairo_image_surface_create_for_data (buf, buffer = cairo_image_surface_create_for_data (buf,
CAIRO_FORMAT_RGB24, CAIRO_FORMAT_RGB24,
priv->width, scale->width,
priv->height, scale->height,
priv->rowstride); scale->rowstride);
cairo_surface_set_user_data (buffer, NULL, buf, (cairo_destroy_func_t) g_free); cairo_surface_set_user_data (buffer, NULL, buf, (cairo_destroy_func_t) g_free);
switch (gtk_orientable_get_orientation (GTK_ORIENTABLE (range))) switch (gtk_orientable_get_orientation (GTK_ORIENTABLE (range)))
@ -514,14 +500,14 @@ void
gimp_color_scale_set_format (GimpColorScale *scale, gimp_color_scale_set_format (GimpColorScale *scale,
const Babl *format) const Babl *format)
{ {
if (scale->priv->format != format) if (scale->format != format)
{ {
scale->priv->format = format; scale->format = format;
fish_lch_to_rgb = babl_fish (babl_format ("CIE LCH(ab) double"), fish_lch_to_rgb = babl_fish (babl_format ("CIE LCH(ab) double"),
babl_format_with_space ("R'G'B' double", format)); babl_format_with_space ("R'G'B' double", format));
fish_hsv_to_rgb = babl_fish (babl_format_with_space ("HSV float", format), fish_hsv_to_rgb = babl_fish (babl_format_with_space ("HSV float", format),
babl_format_with_space ("R'G'B' double", format)); babl_format_with_space ("R'G'B' double", format));
scale->priv->needs_render = TRUE; scale->needs_render = TRUE;
gtk_widget_queue_draw (GTK_WIDGET (scale)); gtk_widget_queue_draw (GTK_WIDGET (scale));
} }
} }
@ -537,17 +523,13 @@ void
gimp_color_scale_set_channel (GimpColorScale *scale, gimp_color_scale_set_channel (GimpColorScale *scale,
GimpColorSelectorChannel channel) GimpColorSelectorChannel channel)
{ {
GimpColorScalePrivate *priv;
g_return_if_fail (GIMP_IS_COLOR_SCALE (scale)); g_return_if_fail (GIMP_IS_COLOR_SCALE (scale));
priv = GET_PRIVATE (scale); if (channel != scale->channel)
if (channel != priv->channel)
{ {
priv->channel = channel; scale->channel = channel;
priv->needs_render = TRUE; scale->needs_render = TRUE;
gtk_widget_queue_draw (GTK_WIDGET (scale)); gtk_widget_queue_draw (GTK_WIDGET (scale));
g_object_notify (G_OBJECT (scale), "channel"); g_object_notify (G_OBJECT (scale), "channel");
@ -565,20 +547,17 @@ void
gimp_color_scale_set_color (GimpColorScale *scale, gimp_color_scale_set_color (GimpColorScale *scale,
GeglColor *color) GeglColor *color)
{ {
GimpColorScalePrivate *priv; GeglColor *old_color;
GeglColor *old_color;
g_return_if_fail (GIMP_IS_COLOR_SCALE (scale)); g_return_if_fail (GIMP_IS_COLOR_SCALE (scale));
g_return_if_fail (GEGL_IS_COLOR (color)); g_return_if_fail (GEGL_IS_COLOR (color));
priv = GET_PRIVATE (scale); old_color = scale->color;
scale->color = gegl_color_duplicate (color);
old_color = priv->color; if (! gimp_color_is_perceptually_identical (old_color, scale->color))
priv->color = gegl_color_duplicate (color);
if (! gimp_color_is_perceptually_identical (old_color, priv->color))
{ {
priv->needs_render = TRUE; scale->needs_render = TRUE;
gtk_widget_queue_draw (GTK_WIDGET (scale)); gtk_widget_queue_draw (GTK_WIDGET (scale));
} }
@ -598,31 +577,27 @@ void
gimp_color_scale_set_color_config (GimpColorScale *scale, gimp_color_scale_set_color_config (GimpColorScale *scale,
GimpColorConfig *config) GimpColorConfig *config)
{ {
GimpColorScalePrivate *priv;
g_return_if_fail (GIMP_IS_COLOR_SCALE (scale)); g_return_if_fail (GIMP_IS_COLOR_SCALE (scale));
g_return_if_fail (config == NULL || GIMP_IS_COLOR_CONFIG (config)); g_return_if_fail (config == NULL || GIMP_IS_COLOR_CONFIG (config));
priv = GET_PRIVATE (scale); if (config != scale->config)
if (config != priv->config)
{ {
if (priv->config) if (scale->config)
{ {
g_signal_handlers_disconnect_by_func (priv->config, g_signal_handlers_disconnect_by_func (scale->config,
gimp_color_scale_notify_config, gimp_color_scale_notify_config,
scale); scale);
} }
g_set_object (&priv->config, config); g_set_object (&scale->config, config);
if (priv->config) if (scale->config)
{ {
g_signal_connect (priv->config, "notify", g_signal_connect (scale->config, "notify",
G_CALLBACK (gimp_color_scale_notify_config), G_CALLBACK (gimp_color_scale_notify_config),
scale); scale);
gimp_color_scale_notify_config (priv->config, NULL, scale); gimp_color_scale_notify_config (scale->config, NULL, scale);
} }
} }
} }
@ -654,35 +629,34 @@ should_invert (GtkRange *range)
static void static void
gimp_color_scale_render (GimpColorScale *scale) gimp_color_scale_render (GimpColorScale *scale)
{ {
GimpColorScalePrivate *priv = GET_PRIVATE (scale); GtkRange *range = GTK_RANGE (scale);
GtkRange *range = GTK_RANGE (scale); gdouble rgb[4];
gdouble rgb[4]; gfloat hsv[3];
gfloat hsv[3]; gdouble lch[3];
gdouble lch[3]; gint multiplier = 1;
gint multiplier = 1; guint x, y;
guint x, y; gdouble *channel_value = NULL;
gdouble *channel_value = NULL; gfloat *channel_value_f = NULL;
gfloat *channel_value_f = NULL; gboolean from_hsv = FALSE;
gboolean from_hsv = FALSE; gboolean from_lch = FALSE;
gboolean from_lch = FALSE; gboolean invert;
gboolean invert; guchar *buf;
guchar *buf; guchar *d;
guchar *d;
if ((buf = priv->buf) == NULL) if ((buf = scale->buf) == NULL)
return; return;
if (priv->channel == GIMP_COLOR_SELECTOR_ALPHA) if (scale->channel == GIMP_COLOR_SELECTOR_ALPHA)
{ {
gimp_color_scale_render_alpha (scale); gimp_color_scale_render_alpha (scale);
return; return;
} }
gegl_color_get_pixel (priv->color, babl_format_with_space ("R'G'B'A double", priv->format), rgb); gegl_color_get_pixel (scale->color, babl_format_with_space ("R'G'B'A double", scale->format), rgb);
gegl_color_get_pixel (priv->color, babl_format_with_space ("HSV float", priv->format), hsv); gegl_color_get_pixel (scale->color, babl_format_with_space ("HSV float", scale->format), hsv);
gegl_color_get_pixel (priv->color, babl_format ("CIE LCH(ab) double"), lch); gegl_color_get_pixel (scale->color, babl_format ("CIE LCH(ab) double"), lch);
switch (priv->channel) switch (scale->channel)
{ {
case GIMP_COLOR_SELECTOR_HUE: channel_value_f = &hsv[0]; break; case GIMP_COLOR_SELECTOR_HUE: channel_value_f = &hsv[0]; break;
case GIMP_COLOR_SELECTOR_SATURATION: channel_value_f = &hsv[1]; break; case GIMP_COLOR_SELECTOR_SATURATION: channel_value_f = &hsv[1]; break;
@ -698,7 +672,7 @@ gimp_color_scale_render (GimpColorScale *scale)
case GIMP_COLOR_SELECTOR_LCH_HUE: channel_value = &lch[2]; break; case GIMP_COLOR_SELECTOR_LCH_HUE: channel_value = &lch[2]; break;
} }
switch (priv->channel) switch (scale->channel)
{ {
case GIMP_COLOR_SELECTOR_HUE: case GIMP_COLOR_SELECTOR_HUE:
case GIMP_COLOR_SELECTOR_SATURATION: case GIMP_COLOR_SELECTOR_SATURATION:
@ -728,9 +702,9 @@ gimp_color_scale_render (GimpColorScale *scale)
switch (gtk_orientable_get_orientation (GTK_ORIENTABLE (range))) switch (gtk_orientable_get_orientation (GTK_ORIENTABLE (range)))
{ {
case GTK_ORIENTATION_HORIZONTAL: case GTK_ORIENTATION_HORIZONTAL:
for (x = 0, d = buf; x < priv->width; x++, d += 3) for (x = 0, d = buf; x < scale->width; x++, d += 3)
{ {
gdouble value = (gdouble) x * multiplier / (gdouble) (priv->width - 1); gdouble value = (gdouble) x * multiplier / (gdouble) (scale->width - 1);
if (invert) if (invert)
value = multiplier - value; value = multiplier - value;
@ -753,9 +727,9 @@ gimp_color_scale_render (GimpColorScale *scale)
rgb[1] < 0.0 || rgb[1] > 1.0 || rgb[1] < 0.0 || rgb[1] > 1.0 ||
rgb[2] < 0.0 || rgb[2] > 1.0) rgb[2] < 0.0 || rgb[2] > 1.0)
{ {
d[0] = priv->oog_color[0]; d[0] = scale->oog_color[0];
d[1] = priv->oog_color[1]; d[1] = scale->oog_color[1];
d[2] = priv->oog_color[2]; d[2] = scale->oog_color[2];
} }
else else
{ {
@ -765,18 +739,18 @@ gimp_color_scale_render (GimpColorScale *scale)
} }
} }
d = buf + priv->width * 3; d = buf + scale->width * 3;
for (y = 1; y < priv->height; y++) for (y = 1; y < scale->height; y++)
{ {
memcpy (d, buf, priv->width * 3); memcpy (d, buf, scale->width * 3);
d += priv->width * 3; d += scale->width * 3;
} }
break; break;
case GTK_ORIENTATION_VERTICAL: case GTK_ORIENTATION_VERTICAL:
for (y = 0; y < priv->height; y++) for (y = 0; y < scale->height; y++)
{ {
gdouble value = (gdouble) y * multiplier / (gdouble) (priv->height - 1); gdouble value = (gdouble) y * multiplier / (gdouble) (scale->height - 1);
guchar u8rgb[3]; guchar u8rgb[3];
if (invert) if (invert)
@ -796,9 +770,9 @@ gimp_color_scale_render (GimpColorScale *scale)
rgb[1] < 0.0 || rgb[1] > 1.0 || rgb[1] < 0.0 || rgb[1] > 1.0 ||
rgb[2] < 0.0 || rgb[2] > 1.0) rgb[2] < 0.0 || rgb[2] > 1.0)
{ {
u8rgb[0] = priv->oog_color[0]; u8rgb[0] = scale->oog_color[0];
u8rgb[1] = priv->oog_color[1]; u8rgb[1] = scale->oog_color[1];
u8rgb[2] = priv->oog_color[2]; u8rgb[2] = scale->oog_color[2];
} }
else else
{ {
@ -807,14 +781,14 @@ gimp_color_scale_render (GimpColorScale *scale)
u8rgb[2] = rgb[2] * 255; u8rgb[2] = rgb[2] * 255;
} }
for (x = 0, d = buf; x < priv->width; x++, d += 3) for (x = 0, d = buf; x < scale->width; x++, d += 3)
{ {
d[0] = u8rgb[0]; d[0] = u8rgb[0];
d[1] = u8rgb[1]; d[1] = u8rgb[1];
d[2] = u8rgb[2]; d[2] = u8rgb[2];
} }
buf += priv->width * 3; buf += scale->width * 3;
} }
break; break;
} }
@ -823,19 +797,20 @@ gimp_color_scale_render (GimpColorScale *scale)
static void static void
gimp_color_scale_render_alpha (GimpColorScale *scale) gimp_color_scale_render_alpha (GimpColorScale *scale)
{ {
GimpColorScalePrivate *priv = GET_PRIVATE (scale); GtkRange *range = GTK_RANGE (scale);
GtkRange *range = GTK_RANGE (scale); gdouble rgb[3];
gdouble rgb[3]; gboolean invert;
gboolean invert; gdouble a;
gdouble a; guint x, y;
guint x, y; guchar *buf;
guchar *buf; guchar *d, *l;
guchar *d, *l;
invert = should_invert (range); invert = should_invert (range);
buf = priv->buf; buf = scale->buf;
gegl_color_get_pixel (priv->color, babl_format_with_space ("R'G'B' double", priv->format), rgb); gegl_color_get_pixel (scale->color,
babl_format_with_space ("R'G'B' double", scale->format),
rgb);
switch (gtk_orientable_get_orientation (GTK_ORIENTABLE (range))) switch (gtk_orientable_get_orientation (GTK_ORIENTABLE (range)))
{ {
@ -846,10 +821,10 @@ gimp_color_scale_render_alpha (GimpColorScale *scale)
light = buf; light = buf;
/* this won't work correctly for very thin scales */ /* this won't work correctly for very thin scales */
dark = (priv->height > GIMP_CHECK_SIZE_SM ? dark = (scale->height > GIMP_CHECK_SIZE_SM ?
buf + GIMP_CHECK_SIZE_SM * 3 * priv->width : light); buf + GIMP_CHECK_SIZE_SM * 3 * scale->width : light);
for (x = 0, d = light, l = dark; x < priv->width; x++) for (x = 0, d = light, l = dark; x < scale->width; x++)
{ {
if ((x % GIMP_CHECK_SIZE_SM) == 0) if ((x % GIMP_CHECK_SIZE_SM) == 0)
{ {
@ -860,7 +835,7 @@ gimp_color_scale_render_alpha (GimpColorScale *scale)
l = t; l = t;
} }
a = (gdouble) x / (gdouble) (priv->width - 1); a = (gdouble) x / (gdouble) (scale->width - 1);
if (invert) if (invert)
a = 1.0 - a; a = 1.0 - a;
@ -876,15 +851,15 @@ gimp_color_scale_render_alpha (GimpColorScale *scale)
d += 3; d += 3;
} }
for (y = 0, d = buf; y < priv->height; y++, d += 3 * priv->width) for (y = 0, d = buf; y < scale->height; y++, d += 3 * scale->width)
{ {
if (y == 0 || y == GIMP_CHECK_SIZE_SM) if (y == 0 || y == GIMP_CHECK_SIZE_SM)
continue; continue;
if ((y / GIMP_CHECK_SIZE_SM) & 1) if ((y / GIMP_CHECK_SIZE_SM) & 1)
memcpy (d, dark, 3 * priv->width); memcpy (d, dark, 3 * scale->width);
else else
memcpy (d, light, 3 * priv->width); memcpy (d, light, 3 * scale->width);
} }
} }
break; break;
@ -894,9 +869,9 @@ gimp_color_scale_render_alpha (GimpColorScale *scale)
guchar light[3] = {0xff, 0xff, 0xff}; guchar light[3] = {0xff, 0xff, 0xff};
guchar dark[3] = {0xff, 0xff, 0xff}; guchar dark[3] = {0xff, 0xff, 0xff};
for (y = 0, d = buf; y < priv->height; y++, d += priv->width * 3) for (y = 0, d = buf; y < scale->height; y++, d += scale->width * 3)
{ {
a = (gdouble) y / (gdouble) (priv->height - 1); a = (gdouble) y / (gdouble) (scale->height - 1);
if (invert) if (invert)
a = 1.0 - a; a = 1.0 - a;
@ -909,7 +884,7 @@ gimp_color_scale_render_alpha (GimpColorScale *scale)
dark[1] = (GIMP_CHECK_DARK + (rgb[1] - GIMP_CHECK_DARK) * a) * 255.999; dark[1] = (GIMP_CHECK_DARK + (rgb[1] - GIMP_CHECK_DARK) * a) * 255.999;
dark[2] = (GIMP_CHECK_DARK + (rgb[2] - GIMP_CHECK_DARK) * a) * 255.999; dark[2] = (GIMP_CHECK_DARK + (rgb[2] - GIMP_CHECK_DARK) * a) * 255.999;
for (x = 0, l = d; x < priv->width; x++, l += 3) for (x = 0, l = d; x < scale->width; x++, l += 3)
{ {
if (((x / GIMP_CHECK_SIZE_SM) ^ (y / GIMP_CHECK_SIZE_SM)) & 1) if (((x / GIMP_CHECK_SIZE_SM) ^ (y / GIMP_CHECK_SIZE_SM)) & 1)
{ {
@ -935,15 +910,14 @@ gimp_color_scale_notify_config (GimpColorConfig *config,
const GParamSpec *pspec, const GParamSpec *pspec,
GimpColorScale *scale) GimpColorScale *scale)
{ {
GimpColorScalePrivate *priv = GET_PRIVATE (scale); GeglColor *color;
GeglColor *color;
color = gimp_color_config_get_out_of_gamut_color (config); color = gimp_color_config_get_out_of_gamut_color (config);
/* TODO: shouldn't this be color-managed too, using the target space into /* TODO: shouldn't this be color-managed too, using the target space into
* consideration? * consideration?
*/ */
gegl_color_get_pixel (color, babl_format ("R'G'B' u8"), priv->oog_color); gegl_color_get_pixel (color, babl_format ("R'G'B' u8"), scale->oog_color);
priv->needs_render = TRUE; scale->needs_render = TRUE;
g_object_unref (color); g_object_unref (color);
} }

View file

@ -30,41 +30,10 @@
G_BEGIN_DECLS G_BEGIN_DECLS
#define GIMP_TYPE_COLOR_SCALE (gimp_color_scale_get_type ()) #define GIMP_TYPE_COLOR_SCALE (gimp_color_scale_get_type ())
#define GIMP_COLOR_SCALE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GIMP_TYPE_COLOR_SCALE, GimpColorScale)) G_DECLARE_FINAL_TYPE (GimpColorScale, gimp_color_scale, GIMP, COLOR_SCALE, GtkScale)
#define GIMP_COLOR_SCALE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GIMP_TYPE_COLOR_SCALE, GimpColorScaleClass))
#define GIMP_IS_COLOR_SCALE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GIMP_TYPE_COLOR_SCALE))
#define GIMP_IS_COLOR_SCALE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GIMP_TYPE_COLOR_SCALE))
#define GIMP_COLOR_SCALE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GIMP_TYPE_COLOR_SCALE, GimpColorScaleClass))
typedef struct _GimpColorScalePrivate GimpColorScalePrivate;
typedef struct _GimpColorScaleClass GimpColorScaleClass;
struct _GimpColorScale
{
GtkScale parent_instance;
GimpColorScalePrivate *priv;
};
struct _GimpColorScaleClass
{
GtkScaleClass parent_class;
/* Padding for future expansion */
void (* _gimp_reserved1) (void);
void (* _gimp_reserved2) (void);
void (* _gimp_reserved3) (void);
void (* _gimp_reserved4) (void);
void (* _gimp_reserved5) (void);
void (* _gimp_reserved6) (void);
void (* _gimp_reserved7) (void);
void (* _gimp_reserved8) (void);
};
GType gimp_color_scale_get_type (void) G_GNUC_CONST;
GtkWidget * gimp_color_scale_new (GtkOrientation orientation, GtkWidget * gimp_color_scale_new (GtkOrientation orientation,
GimpColorSelectorChannel channel); GimpColorSelectorChannel channel);

View file

@ -47,13 +47,13 @@ enum
}; };
struct _GimpEnumLabelPrivate struct _GimpEnumLabel
{ {
GtkLabel parent_instance;
GEnumClass *enum_class; GEnumClass *enum_class;
}; };
#define GET_PRIVATE(obj) (((GimpEnumLabel *) (obj))->priv)
static void gimp_enum_label_finalize (GObject *object); static void gimp_enum_label_finalize (GObject *object);
static void gimp_enum_label_get_property (GObject *object, static void gimp_enum_label_get_property (GObject *object,
@ -66,7 +66,7 @@ static void gimp_enum_label_set_property (GObject *object,
GParamSpec *pspec); GParamSpec *pspec);
G_DEFINE_TYPE_WITH_PRIVATE (GimpEnumLabel, gimp_enum_label, GTK_TYPE_LABEL) G_DEFINE_TYPE (GimpEnumLabel, gimp_enum_label, GTK_TYPE_LABEL)
#define parent_class gimp_enum_label_parent_class #define parent_class gimp_enum_label_parent_class
@ -114,15 +114,14 @@ gimp_enum_label_class_init (GimpEnumLabelClass *klass)
static void static void
gimp_enum_label_init (GimpEnumLabel *enum_label) gimp_enum_label_init (GimpEnumLabel *enum_label)
{ {
enum_label->priv = gimp_enum_label_get_instance_private (enum_label);
} }
static void static void
gimp_enum_label_finalize (GObject *object) gimp_enum_label_finalize (GObject *object)
{ {
GimpEnumLabelPrivate *private = GET_PRIVATE (object); GimpEnumLabel *label = GIMP_ENUM_LABEL (object);
g_clear_pointer (&private->enum_class, g_type_class_unref); g_clear_pointer (&label->enum_class, g_type_class_unref);
G_OBJECT_CLASS (parent_class)->finalize (object); G_OBJECT_CLASS (parent_class)->finalize (object);
} }
@ -133,13 +132,13 @@ gimp_enum_label_get_property (GObject *object,
GValue *value, GValue *value,
GParamSpec *pspec) GParamSpec *pspec)
{ {
GimpEnumLabelPrivate *private = GET_PRIVATE (object); GimpEnumLabel *label = GIMP_ENUM_LABEL (object);
switch (property_id) switch (property_id)
{ {
case PROP_ENUM_TYPE: case PROP_ENUM_TYPE:
if (private->enum_class) if (label->enum_class)
g_value_set_gtype (value, G_TYPE_FROM_CLASS (private->enum_class)); g_value_set_gtype (value, G_TYPE_FROM_CLASS (label->enum_class));
else else
g_value_set_gtype (value, G_TYPE_NONE); g_value_set_gtype (value, G_TYPE_NONE);
break; break;
@ -156,13 +155,12 @@ gimp_enum_label_set_property (GObject *object,
const GValue *value, const GValue *value,
GParamSpec *pspec) GParamSpec *pspec)
{ {
GimpEnumLabel *label = GIMP_ENUM_LABEL (object); GimpEnumLabel *label = GIMP_ENUM_LABEL (object);
GimpEnumLabelPrivate *private = GET_PRIVATE (label);
switch (property_id) switch (property_id)
{ {
case PROP_ENUM_TYPE: case PROP_ENUM_TYPE:
private->enum_class = g_type_class_ref (g_value_get_gtype (value)); label->enum_class = g_type_class_ref (g_value_get_gtype (value));
break; break;
case PROP_ENUM_VALUE: case PROP_ENUM_VALUE:
@ -207,20 +205,17 @@ void
gimp_enum_label_set_value (GimpEnumLabel *label, gimp_enum_label_set_value (GimpEnumLabel *label,
gint value) gint value)
{ {
GimpEnumLabelPrivate *private; const gchar *nick;
const gchar *nick; const gchar *desc;
const gchar *desc;
g_return_if_fail (GIMP_IS_ENUM_LABEL (label)); g_return_if_fail (GIMP_IS_ENUM_LABEL (label));
private = GET_PRIVATE (label); if (! gimp_enum_get_value (G_TYPE_FROM_CLASS (label->enum_class), value,
if (! gimp_enum_get_value (G_TYPE_FROM_CLASS (private->enum_class), value,
NULL, &nick, &desc, NULL)) NULL, &nick, &desc, NULL))
{ {
g_warning ("%s: %d is not valid for enum of type '%s'", g_warning ("%s: %d is not valid for enum of type '%s'",
G_STRLOC, value, G_STRLOC, value,
g_type_name (G_TYPE_FROM_CLASS (private->enum_class))); g_type_name (G_TYPE_FROM_CLASS (label->enum_class)));
return; return;
} }

View file

@ -29,42 +29,10 @@
G_BEGIN_DECLS G_BEGIN_DECLS
#define GIMP_TYPE_ENUM_LABEL (gimp_enum_label_get_type ()) #define GIMP_TYPE_ENUM_LABEL (gimp_enum_label_get_type ())
#define GIMP_ENUM_LABEL(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GIMP_TYPE_ENUM_LABEL, GimpEnumLabel)) G_DECLARE_FINAL_TYPE (GimpEnumLabel, gimp_enum_label, GIMP, ENUM_LABEL, GtkScale)
#define GIMP_ENUM_LABEL_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GIMP_TYPE_ENUM_LABEL, GimpEnumLabelClass))
#define GIMP_IS_ENUM_LABEL(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GIMP_TYPE_ENUM_LABEL))
#define GIMP_IS_ENUM_LABEL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GIMP_TYPE_ENUM_LABEL))
#define GIMP_ENUM_LABEL_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GIMP_TYPE_ENUM_LABEL, GimpEnumLabelClass))
typedef struct _GimpEnumLabelPrivate GimpEnumLabelPrivate;
typedef struct _GimpEnumLabelClass GimpEnumLabelClass;
struct _GimpEnumLabel
{
GtkLabel parent_instance;
GimpEnumLabelPrivate *priv;
};
struct _GimpEnumLabelClass
{
GtkLabelClass parent_class;
/* Padding for future expansion */
void (* _gimp_reserved1) (void);
void (* _gimp_reserved2) (void);
void (* _gimp_reserved3) (void);
void (* _gimp_reserved4) (void);
void (* _gimp_reserved5) (void);
void (* _gimp_reserved6) (void);
void (* _gimp_reserved7) (void);
void (* _gimp_reserved8) (void);
};
GType gimp_enum_label_get_type (void) G_GNUC_CONST;
GtkWidget * gimp_enum_label_new (GType enum_type, GtkWidget * gimp_enum_label_new (GType enum_type,
gint value); gint value);
void gimp_enum_label_set_value (GimpEnumLabel *label, void gimp_enum_label_set_value (GimpEnumLabel *label,

View file

@ -45,8 +45,10 @@ enum
PROP_HINT PROP_HINT
}; };
struct _GimpHintBoxPrivate struct _GimpHintBox
{ {
GtkBox parent_instance;
gchar *icon_name; gchar *icon_name;
gchar *hint; gchar *hint;
}; };
@ -64,7 +66,7 @@ static void gimp_hint_box_get_property (GObject *object,
GParamSpec *pspec); GParamSpec *pspec);
G_DEFINE_TYPE_WITH_PRIVATE (GimpHintBox, gimp_hint_box, GTK_TYPE_BOX) G_DEFINE_TYPE (GimpHintBox, gimp_hint_box, GTK_TYPE_BOX)
#define parent_class gimp_hint_box_parent_class #define parent_class gimp_hint_box_parent_class
@ -99,8 +101,6 @@ gimp_hint_box_class_init (GimpHintBoxClass *klass)
static void static void
gimp_hint_box_init (GimpHintBox *box) gimp_hint_box_init (GimpHintBox *box)
{ {
box->priv = gimp_hint_box_get_instance_private (box);
gtk_orientable_set_orientation (GTK_ORIENTABLE (box), gtk_orientable_set_orientation (GTK_ORIENTABLE (box),
GTK_ORIENTATION_HORIZONTAL); GTK_ORIENTATION_HORIZONTAL);
} }
@ -116,9 +116,9 @@ gimp_hint_box_constructed (GObject *object)
gtk_box_set_spacing (GTK_BOX (box), 12); gtk_box_set_spacing (GTK_BOX (box), 12);
if (box->priv->icon_name) if (box->icon_name)
{ {
image = gtk_image_new_from_icon_name (box->priv->icon_name, image = gtk_image_new_from_icon_name (box->icon_name,
GTK_ICON_SIZE_DIALOG); GTK_ICON_SIZE_DIALOG);
} }
@ -129,7 +129,7 @@ gimp_hint_box_constructed (GObject *object)
} }
label = g_object_new (GTK_TYPE_LABEL, label = g_object_new (GTK_TYPE_LABEL,
"label", box->priv->hint, "label", box->hint,
"wrap", TRUE, "wrap", TRUE,
"justify", GTK_JUSTIFY_LEFT, "justify", GTK_JUSTIFY_LEFT,
"xalign", 0.0, "xalign", 0.0,
@ -148,8 +148,8 @@ gimp_hint_box_finalize (GObject *object)
{ {
GimpHintBox *box = GIMP_HINT_BOX (object); GimpHintBox *box = GIMP_HINT_BOX (object);
g_clear_pointer (&box->priv->icon_name, g_free); g_clear_pointer (&box->icon_name, g_free);
g_clear_pointer (&box->priv->hint, g_free); g_clear_pointer (&box->hint, g_free);
G_OBJECT_CLASS (parent_class)->finalize (object); G_OBJECT_CLASS (parent_class)->finalize (object);
} }
@ -165,11 +165,11 @@ gimp_hint_box_set_property (GObject *object,
switch (property_id) switch (property_id)
{ {
case PROP_ICON_NAME: case PROP_ICON_NAME:
box->priv->icon_name = g_value_dup_string (value); box->icon_name = g_value_dup_string (value);
break; break;
case PROP_HINT: case PROP_HINT:
box->priv->hint = g_value_dup_string (value); box->hint = g_value_dup_string (value);
break; break;
default: default:
@ -189,11 +189,11 @@ gimp_hint_box_get_property (GObject *object,
switch (property_id) switch (property_id)
{ {
case PROP_ICON_NAME: case PROP_ICON_NAME:
g_value_set_string (value, box->priv->icon_name); g_value_set_string (value, box->icon_name);
break; break;
case PROP_HINT: case PROP_HINT:
g_value_set_string (value, box->priv->hint); g_value_set_string (value, box->hint);
break; break;
default: default:

View file

@ -31,42 +31,10 @@ G_BEGIN_DECLS
/* For information look into the C source or the html documentation */ /* For information look into the C source or the html documentation */
#define GIMP_TYPE_HINT_BOX (gimp_hint_box_get_type ()) #define GIMP_TYPE_HINT_BOX (gimp_hint_box_get_type ())
#define GIMP_HINT_BOX(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GIMP_TYPE_HINT_BOX, GimpHintBox)) G_DECLARE_FINAL_TYPE (GimpHintBox, gimp_hint_box, GIMP, HINT_BOX, GtkBox)
#define GIMP_HINT_BOX_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GIMP_TYPE_HINT_BOX, GimpHintBoxClass))
#define GIMP_IS_HINT_BOX(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GIMP_TYPE_HINT_BOX))
#define GIMP_IS_HINT_BOX_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GIMP_TYPE_HINT_BOX))
#define GIMP_HINT_BOX_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GIMP_TYPE_HINT_BOX, GimpHintBoxClass))
typedef struct _GimpHintBoxPrivate GimpHintBoxPrivate;
typedef struct _GimpHintBoxClass GimpHintBoxClass;
struct _GimpHintBox
{
GtkBox parent_instance;
GimpHintBoxPrivate *priv;
};
struct _GimpHintBoxClass
{
GtkBoxClass parent_class;
/* Padding for future expansion */
void (* _gimp_reserved1) (void);
void (* _gimp_reserved2) (void);
void (* _gimp_reserved3) (void);
void (* _gimp_reserved4) (void);
void (* _gimp_reserved5) (void);
void (* _gimp_reserved6) (void);
void (* _gimp_reserved7) (void);
void (* _gimp_reserved8) (void);
};
GType gimp_hint_box_get_type (void) G_GNUC_CONST;
GtkWidget * gimp_hint_box_new (const gchar *hint); GtkWidget * gimp_hint_box_new (const gchar *hint);

View file

@ -53,7 +53,7 @@ enum
}; };
struct _GimpIntComboBoxPrivate typedef struct _GimpIntComboBoxPrivate
{ {
GtkCellRenderer *text_renderer; GtkCellRenderer *text_renderer;
@ -64,9 +64,7 @@ struct _GimpIntComboBoxPrivate
GimpIntSensitivityFunc sensitivity_func; GimpIntSensitivityFunc sensitivity_func;
gpointer sensitivity_data; gpointer sensitivity_data;
GDestroyNotify sensitivity_destroy; GDestroyNotify sensitivity_destroy;
}; } GimpIntComboBoxPrivate;
#define GET_PRIVATE(obj) (((GimpIntComboBox *) (obj))->priv)
static void gimp_int_combo_box_constructed (GObject *object); static void gimp_int_combo_box_constructed (GObject *object);
@ -175,7 +173,7 @@ gimp_int_combo_box_init (GimpIntComboBox *combo_box)
GimpIntComboBoxPrivate *priv; GimpIntComboBoxPrivate *priv;
GtkListStore *store; GtkListStore *store;
combo_box->priv = priv = gimp_int_combo_box_get_instance_private (combo_box); priv = gimp_int_combo_box_get_instance_private (combo_box);
store = g_object_new (GIMP_TYPE_INT_STORE, NULL); store = g_object_new (GIMP_TYPE_INT_STORE, NULL);
gtk_combo_box_set_model (GTK_COMBO_BOX (combo_box), GTK_TREE_MODEL (store)); gtk_combo_box_set_model (GTK_COMBO_BOX (combo_box), GTK_TREE_MODEL (store));
@ -199,7 +197,10 @@ gimp_int_combo_box_constructed (GObject *object)
static void static void
gimp_int_combo_box_finalize (GObject *object) gimp_int_combo_box_finalize (GObject *object)
{ {
GimpIntComboBoxPrivate *priv = GET_PRIVATE (object); GimpIntComboBox *combo = GIMP_INT_COMBO_BOX (object);
GimpIntComboBoxPrivate *priv;
priv = gimp_int_combo_box_get_instance_private (combo);
g_clear_pointer (&priv->label, g_free); g_clear_pointer (&priv->label, g_free);
@ -220,7 +221,10 @@ gimp_int_combo_box_set_property (GObject *object,
const GValue *value, const GValue *value,
GParamSpec *pspec) GParamSpec *pspec)
{ {
GimpIntComboBoxPrivate *priv = GET_PRIVATE (object); GimpIntComboBox *combo = GIMP_INT_COMBO_BOX (object);
GimpIntComboBoxPrivate *priv;
priv = gimp_int_combo_box_get_instance_private (combo);
switch (property_id) switch (property_id)
{ {
@ -257,7 +261,10 @@ gimp_int_combo_box_get_property (GObject *object,
GValue *value, GValue *value,
GParamSpec *pspec) GParamSpec *pspec)
{ {
GimpIntComboBoxPrivate *priv = GET_PRIVATE (object); GimpIntComboBox *combo = GIMP_INT_COMBO_BOX (object);
GimpIntComboBoxPrivate *priv;
priv = gimp_int_combo_box_get_instance_private (combo);
switch (property_id) switch (property_id)
{ {
@ -520,7 +527,7 @@ gboolean
gimp_int_combo_box_get_active (GimpIntComboBox *combo_box, gimp_int_combo_box_get_active (GimpIntComboBox *combo_box,
gint *value) gint *value)
{ {
GtkTreeIter iter; GtkTreeIter iter;
g_return_val_if_fail (GIMP_IS_INT_COMBO_BOX (combo_box), FALSE); g_return_val_if_fail (GIMP_IS_INT_COMBO_BOX (combo_box), FALSE);
g_return_val_if_fail (value != NULL, FALSE); g_return_val_if_fail (value != NULL, FALSE);
@ -586,7 +593,7 @@ gboolean
gimp_int_combo_box_get_active_user_data (GimpIntComboBox *combo_box, gimp_int_combo_box_get_active_user_data (GimpIntComboBox *combo_box,
gpointer *user_data) gpointer *user_data)
{ {
GtkTreeIter iter; GtkTreeIter iter;
g_return_val_if_fail (GIMP_IS_INT_COMBO_BOX (combo_box), FALSE); g_return_val_if_fail (GIMP_IS_INT_COMBO_BOX (combo_box), FALSE);
g_return_val_if_fail (user_data != NULL, FALSE); g_return_val_if_fail (user_data != NULL, FALSE);
@ -669,7 +676,7 @@ gimp_int_combo_box_set_label (GimpIntComboBox *combo_box,
g_return_if_fail (GIMP_IS_INT_COMBO_BOX (combo_box)); g_return_if_fail (GIMP_IS_INT_COMBO_BOX (combo_box));
priv = GET_PRIVATE (combo_box); priv = gimp_int_combo_box_get_instance_private (combo_box);
if (label == priv->label) if (label == priv->label)
return; return;
@ -712,9 +719,13 @@ gimp_int_combo_box_set_label (GimpIntComboBox *combo_box,
const gchar * const gchar *
gimp_int_combo_box_get_label (GimpIntComboBox *combo_box) gimp_int_combo_box_get_label (GimpIntComboBox *combo_box)
{ {
GimpIntComboBoxPrivate *priv;
g_return_val_if_fail (GIMP_IS_INT_COMBO_BOX (combo_box), NULL); g_return_val_if_fail (GIMP_IS_INT_COMBO_BOX (combo_box), NULL);
return GET_PRIVATE (combo_box)->label; priv = gimp_int_combo_box_get_instance_private (combo_box);
return priv->label;
} }
/** /**
@ -734,7 +745,7 @@ gimp_int_combo_box_set_layout (GimpIntComboBox *combo_box,
g_return_if_fail (GIMP_IS_INT_COMBO_BOX (combo_box)); g_return_if_fail (GIMP_IS_INT_COMBO_BOX (combo_box));
priv = GET_PRIVATE (combo_box); priv = gimp_int_combo_box_get_instance_private (combo_box);
if (layout == priv->layout) if (layout == priv->layout)
return; return;
@ -759,10 +770,14 @@ gimp_int_combo_box_set_layout (GimpIntComboBox *combo_box,
GimpIntComboBoxLayout GimpIntComboBoxLayout
gimp_int_combo_box_get_layout (GimpIntComboBox *combo_box) gimp_int_combo_box_get_layout (GimpIntComboBox *combo_box)
{ {
GimpIntComboBoxPrivate *priv;
g_return_val_if_fail (GIMP_IS_INT_COMBO_BOX (combo_box), g_return_val_if_fail (GIMP_IS_INT_COMBO_BOX (combo_box),
GIMP_INT_COMBO_BOX_LAYOUT_ABBREVIATED); GIMP_INT_COMBO_BOX_LAYOUT_ABBREVIATED);
return GET_PRIVATE (combo_box)->layout; priv = gimp_int_combo_box_get_instance_private (combo_box);
return priv->layout;
} }
/** /**
@ -791,7 +806,7 @@ gimp_int_combo_box_set_sensitivity (GimpIntComboBox *combo_box,
g_return_if_fail (GIMP_IS_INT_COMBO_BOX (combo_box)); g_return_if_fail (GIMP_IS_INT_COMBO_BOX (combo_box));
priv = GET_PRIVATE (combo_box); priv = gimp_int_combo_box_get_instance_private (combo_box);
if (priv->sensitivity_destroy) if (priv->sensitivity_destroy)
{ {
@ -825,12 +840,14 @@ gimp_int_combo_box_changed (GtkComboBox *combo_box,
static void static void
gimp_int_combo_box_create_cells (GimpIntComboBox *combo_box) gimp_int_combo_box_create_cells (GimpIntComboBox *combo_box)
{ {
GimpIntComboBoxPrivate *priv = GET_PRIVATE (combo_box); GimpIntComboBoxPrivate *priv;
GtkCellLayout *layout = GTK_CELL_LAYOUT (combo_box); GtkCellLayout *layout = GTK_CELL_LAYOUT (combo_box);
GtkCellRenderer *text_renderer; GtkCellRenderer *text_renderer;
GtkCellRenderer *pixbuf_renderer; GtkCellRenderer *pixbuf_renderer;
gboolean popup_shown; gboolean popup_shown;
priv = gimp_int_combo_box_get_instance_private (combo_box);
g_object_get (combo_box, "popup-shown", &popup_shown, NULL); g_object_get (combo_box, "popup-shown", &popup_shown, NULL);
gtk_cell_layout_clear (layout); gtk_cell_layout_clear (layout);

View file

@ -29,24 +29,10 @@
G_BEGIN_DECLS G_BEGIN_DECLS
#define GIMP_TYPE_INT_COMBO_BOX (gimp_int_combo_box_get_type ()) #define GIMP_TYPE_INT_COMBO_BOX (gimp_int_combo_box_get_type ())
#define GIMP_INT_COMBO_BOX(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GIMP_TYPE_INT_COMBO_BOX, GimpIntComboBox)) G_DECLARE_DERIVABLE_TYPE (GimpIntComboBox, gimp_int_combo_box, GIMP, INT_COMBO_BOX, GtkComboBox)
#define GIMP_INT_COMBO_BOX_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GIMP_TYPE_INT_COMBO_BOX, GimpIntComboBoxClass))
#define GIMP_IS_INT_COMBO_BOX(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GIMP_TYPE_INT_COMBO_BOX))
#define GIMP_IS_INT_COMBO_BOX_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GIMP_TYPE_INT_COMBO_BOX))
#define GIMP_INT_COMBO_BOX_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GIMP_TYPE_INT_COMBO_BOX, GimpIntComboBoxClass))
typedef struct _GimpIntComboBoxPrivate GimpIntComboBoxPrivate;
typedef struct _GimpIntComboBoxClass GimpIntComboBoxClass;
struct _GimpIntComboBox
{
GtkComboBox parent_instance;
GimpIntComboBoxPrivate *priv;
};
struct _GimpIntComboBoxClass struct _GimpIntComboBoxClass
{ {
GtkComboBoxClass parent_class; GtkComboBoxClass parent_class;
@ -72,9 +58,6 @@ typedef gboolean (* GimpIntSensitivityFunc) (gint value,
gpointer data); gpointer data);
GType gimp_int_combo_box_get_type (void) G_GNUC_CONST;
GtkWidget * gimp_int_combo_box_new (const gchar *first_label, GtkWidget * gimp_int_combo_box_new (const gchar *first_label,
gint first_value, gint first_value,
...) G_GNUC_NULL_TERMINATED; ...) G_GNUC_NULL_TERMINATED;

File diff suppressed because it is too large Load diff

View file

@ -26,42 +26,10 @@
G_BEGIN_DECLS G_BEGIN_DECLS
#define GIMP_TYPE_PREVIEW_AREA (gimp_preview_area_get_type ()) #define GIMP_TYPE_PREVIEW_AREA (gimp_preview_area_get_type ())
#define GIMP_PREVIEW_AREA(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GIMP_TYPE_PREVIEW_AREA, GimpPreviewArea)) G_DECLARE_FINAL_TYPE (GimpPreviewArea, gimp_preview_area, GIMP, PREVIEW_AREA, GtkDrawingArea)
#define GIMP_PREVIEW_AREA_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GIMP_TYPE_PREVIEW_AREA, GimpPreviewAreaClass))
#define GIMP_IS_PREVIEW_AREA(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GIMP_TYPE_PREVIEW_AREA))
#define GIMP_IS_PREVIEW_AREA_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GIMP_TYPE_PREVIEW_AREA))
#define GIMP_PREVIEW_AREA_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GIMP_TYPE_PREVIEW_AREA, GimpPreviewArea))
typedef struct _GimpPreviewAreaPrivate GimpPreviewAreaPrivate;
typedef struct _GimpPreviewAreaClass GimpPreviewAreaClass;
struct _GimpPreviewArea
{
GtkDrawingArea parent_instance;
GimpPreviewAreaPrivate *priv;
};
struct _GimpPreviewAreaClass
{
GtkDrawingAreaClass parent_class;
/* Padding for future expansion */
void (* _gimp_reserved1) (void);
void (* _gimp_reserved2) (void);
void (* _gimp_reserved3) (void);
void (* _gimp_reserved4) (void);
void (* _gimp_reserved5) (void);
void (* _gimp_reserved6) (void);
void (* _gimp_reserved7) (void);
void (* _gimp_reserved8) (void);
};
GType gimp_preview_area_get_type (void) G_GNUC_CONST;
GtkWidget * gimp_preview_area_new (void); GtkWidget * gimp_preview_area_new (void);
void gimp_preview_area_draw (GimpPreviewArea *area, void gimp_preview_area_draw (GimpPreviewArea *area,

View file

@ -55,10 +55,10 @@
#define MAX_DIGITS 20 #define MAX_DIGITS 20
struct _GimpSpinButtonPrivate typedef struct _GimpSpinButtonPrivate
{ {
gboolean changed; gboolean changed;
}; } GimpSpinButtonPrivate;
/* local function prototypes */ /* local function prototypes */
@ -105,8 +105,6 @@ gimp_spin_button_class_init (GimpSpinButtonClass *klass)
static void static void
gimp_spin_button_init (GimpSpinButton *spin_button) gimp_spin_button_init (GimpSpinButton *spin_button)
{ {
spin_button->priv = gimp_spin_button_get_instance_private (spin_button);
g_signal_connect (spin_button, "changed", g_signal_connect (spin_button, "changed",
G_CALLBACK (gimp_spin_button_changed), G_CALLBACK (gimp_spin_button_changed),
NULL); NULL);
@ -208,9 +206,12 @@ static gboolean
gimp_spin_button_focus_in (GtkWidget *widget, gimp_spin_button_focus_in (GtkWidget *widget,
GdkEventFocus *event) GdkEventFocus *event)
{ {
GimpSpinButton *spin_button = GIMP_SPIN_BUTTON (widget); GimpSpinButton *spin_button = GIMP_SPIN_BUTTON (widget);
GimpSpinButtonPrivate *priv;
spin_button->priv->changed = FALSE; priv = gimp_spin_button_get_instance_private (spin_button);
priv->changed = FALSE;
return GTK_WIDGET_CLASS (parent_class)->focus_in_event (widget, event); return GTK_WIDGET_CLASS (parent_class)->focus_in_event (widget, event);
} }
@ -219,18 +220,21 @@ static gboolean
gimp_spin_button_focus_out (GtkWidget *widget, gimp_spin_button_focus_out (GtkWidget *widget,
GdkEventFocus *event) GdkEventFocus *event)
{ {
GimpSpinButton *spin_button = GIMP_SPIN_BUTTON (widget); GimpSpinButton *spin_button = GIMP_SPIN_BUTTON (widget);
gboolean editable; GimpSpinButtonPrivate *priv;
gboolean result; gboolean editable;
gboolean result;
priv = gimp_spin_button_get_instance_private (spin_button);
editable = gtk_editable_get_editable (GTK_EDITABLE (widget)); editable = gtk_editable_get_editable (GTK_EDITABLE (widget));
if (! spin_button->priv->changed) if (! priv->changed)
gtk_editable_set_editable (GTK_EDITABLE (widget), FALSE); gtk_editable_set_editable (GTK_EDITABLE (widget), FALSE);
result = GTK_WIDGET_CLASS (parent_class)->focus_out_event (widget, event); result = GTK_WIDGET_CLASS (parent_class)->focus_out_event (widget, event);
if (! spin_button->priv->changed) if (! priv->changed)
gtk_editable_set_editable (GTK_EDITABLE (widget), editable); gtk_editable_set_editable (GTK_EDITABLE (widget), editable);
return result; return result;
@ -285,9 +289,12 @@ static void
gimp_spin_button_changed (GtkEditable *editable, gimp_spin_button_changed (GtkEditable *editable,
gpointer data) gpointer data)
{ {
GimpSpinButton *spin_button = GIMP_SPIN_BUTTON (editable); GimpSpinButton *spin_button = GIMP_SPIN_BUTTON (editable);
GimpSpinButtonPrivate *priv;
spin_button->priv->changed = TRUE; priv = gimp_spin_button_get_instance_private (spin_button);
priv->changed = TRUE;
} }

View file

@ -31,24 +31,10 @@ G_BEGIN_DECLS
/* For information look into the C source or the html documentation */ /* For information look into the C source or the html documentation */
#define GIMP_TYPE_SPIN_BUTTON (gimp_spin_button_get_type ()) #define GIMP_TYPE_SPIN_BUTTON (gimp_spin_button_get_type ())
#define GIMP_SPIN_BUTTON(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GIMP_TYPE_SPIN_BUTTON, GimpSpinButton)) G_DECLARE_DERIVABLE_TYPE (GimpSpinButton, gimp_spin_button, GIMP, SPIN_BUTTON, GtkSpinButton)
#define GIMP_SPIN_BUTTON_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GIMP_TYPE_SPIN_BUTTON, GimpSpinButtonClass))
#define GIMP_IS_SPIN_BUTTON(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GIMP_TYPE_SPIN_BUTTON))
#define GIMP_IS_SPIN_BUTTON_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GIMP_TYPE_SPIN_BUTTON))
#define GIMP_SPIN_BUTTON_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GIMP_TYPE_SPIN_BUTTON, GimpSpinButtonClass))
typedef struct _GimpSpinButtonPrivate GimpSpinButtonPrivate;
typedef struct _GimpSpinButtonClass GimpSpinButtonClass;
struct _GimpSpinButton
{
GtkSpinButton parent_instance;
GimpSpinButtonPrivate *priv;
};
struct _GimpSpinButtonClass struct _GimpSpinButtonClass
{ {
GtkSpinButtonClass parent_class; GtkSpinButtonClass parent_class;
@ -61,8 +47,6 @@ struct _GimpSpinButtonClass
}; };
GType gimp_spin_button_get_type (void) G_GNUC_CONST;
GtkWidget * gimp_spin_button_new (GtkAdjustment *adjustment, GtkWidget * gimp_spin_button_new (GtkAdjustment *adjustment,
gdouble climb_rate, gdouble climb_rate,
guint digits); guint digits);

View file

@ -54,10 +54,10 @@ typedef enum
} SpinScaleTarget; } SpinScaleTarget;
typedef struct _GimpSpinScalePrivate GimpSpinScalePrivate; struct _GimpSpinScale
struct _GimpSpinScalePrivate
{ {
GimpSpinButton parent_instance;
gchar *label; gchar *label;
gchar *label_text; gchar *label_text;
gchar *label_pattern; gchar *label_pattern;
@ -87,8 +87,6 @@ struct _GimpSpinScalePrivate
gint pointer_warp_start_x; gint pointer_warp_start_x;
}; };
#define GET_PRIVATE(obj) ((GimpSpinScalePrivate *) gimp_spin_scale_get_instance_private ((GimpSpinScale *) (obj)))
static void gimp_spin_scale_dispose (GObject *object); static void gimp_spin_scale_dispose (GObject *object);
static void gimp_spin_scale_finalize (GObject *object); static void gimp_spin_scale_finalize (GObject *object);
@ -137,8 +135,7 @@ static gdouble odd_pow (gdouble x,
gdouble y); gdouble y);
G_DEFINE_TYPE_WITH_PRIVATE (GimpSpinScale, gimp_spin_scale, G_DEFINE_TYPE (GimpSpinScale, gimp_spin_scale, GIMP_TYPE_SPIN_BUTTON)
GIMP_TYPE_SPIN_BUTTON)
#define parent_class gimp_spin_scale_parent_class #define parent_class gimp_spin_scale_parent_class
@ -179,8 +176,6 @@ gimp_spin_scale_class_init (GimpSpinScaleClass *klass)
static void static void
gimp_spin_scale_init (GimpSpinScale *scale) gimp_spin_scale_init (GimpSpinScale *scale)
{ {
GimpSpinScalePrivate *private = GET_PRIVATE (scale);
gtk_widget_add_events (GTK_WIDGET (scale), gtk_widget_add_events (GTK_WIDGET (scale),
GDK_BUTTON_PRESS_MASK | GDK_BUTTON_PRESS_MASK |
GDK_BUTTON_RELEASE_MASK | GDK_BUTTON_RELEASE_MASK |
@ -191,22 +186,22 @@ gimp_spin_scale_init (GimpSpinScale *scale)
gtk_entry_set_alignment (GTK_ENTRY (scale), 1.0); gtk_entry_set_alignment (GTK_ENTRY (scale), 1.0);
gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (scale), TRUE); gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (scale), TRUE);
private->mnemonic_keyval = GDK_KEY_VoidSymbol; scale->mnemonic_keyval = GDK_KEY_VoidSymbol;
private->gamma = 1.0; scale->gamma = 1.0;
} }
static void static void
gimp_spin_scale_dispose (GObject *object) gimp_spin_scale_dispose (GObject *object)
{ {
GimpSpinScalePrivate *private = GET_PRIVATE (object); GimpSpinScale *scale = GIMP_SPIN_SCALE (object);
guint keyval; guint keyval;
keyval = private->mnemonic_keyval; keyval = scale->mnemonic_keyval;
private->mnemonic_keyval = GDK_KEY_VoidSymbol; scale->mnemonic_keyval = GDK_KEY_VoidSymbol;
gimp_spin_scale_setup_mnemonic (GIMP_SPIN_SCALE (object), keyval); gimp_spin_scale_setup_mnemonic (GIMP_SPIN_SCALE (object), keyval);
g_clear_object (&private->layout); g_clear_object (&scale->layout);
G_OBJECT_CLASS (parent_class)->dispose (object); G_OBJECT_CLASS (parent_class)->dispose (object);
} }
@ -214,11 +209,11 @@ gimp_spin_scale_dispose (GObject *object)
static void static void
gimp_spin_scale_finalize (GObject *object) gimp_spin_scale_finalize (GObject *object)
{ {
GimpSpinScalePrivate *private = GET_PRIVATE (object); GimpSpinScale *scale = GIMP_SPIN_SCALE (object);
g_clear_pointer (&private->label, g_free); g_clear_pointer (&scale->label, g_free);
g_clear_pointer (&private->label_text, g_free); g_clear_pointer (&scale->label_text, g_free);
g_clear_pointer (&private->label_pattern, g_free); g_clear_pointer (&scale->label_pattern, g_free);
G_OBJECT_CLASS (parent_class)->finalize (object); G_OBJECT_CLASS (parent_class)->finalize (object);
} }
@ -268,9 +263,9 @@ gimp_spin_scale_get_preferred_width (GtkWidget *widget,
gint *minimum_width, gint *minimum_width,
gint *natural_width) gint *natural_width)
{ {
GimpSpinScalePrivate *private = GET_PRIVATE (widget); GimpSpinScale *scale = GIMP_SPIN_SCALE (widget);
PangoContext *context = gtk_widget_get_pango_context (widget); PangoContext *context = gtk_widget_get_pango_context (widget);
PangoFontMetrics *metrics; PangoFontMetrics *metrics;
GTK_WIDGET_CLASS (parent_class)->get_preferred_width (widget, GTK_WIDGET_CLASS (parent_class)->get_preferred_width (widget,
minimum_width, minimum_width,
@ -280,7 +275,7 @@ gimp_spin_scale_get_preferred_width (GtkWidget *widget,
pango_context_get_font_description (context), pango_context_get_font_description (context),
pango_context_get_language (context)); pango_context_get_language (context));
if (private->label) if (scale->label)
{ {
gint char_width; gint char_width;
gint digit_width; gint digit_width;
@ -311,11 +306,11 @@ gimp_spin_scale_get_preferred_height (GtkWidget *widget,
static void static void
gimp_spin_scale_style_updated (GtkWidget *widget) gimp_spin_scale_style_updated (GtkWidget *widget)
{ {
GimpSpinScalePrivate *private = GET_PRIVATE (widget); GimpSpinScale *scale = GIMP_SPIN_SCALE (widget);
GTK_WIDGET_CLASS (parent_class)->style_updated (widget); GTK_WIDGET_CLASS (parent_class)->style_updated (widget);
g_clear_object (&private->layout); g_clear_object (&scale->layout);
} }
static PangoAttrList * static PangoAttrList *
@ -361,13 +356,13 @@ static gboolean
gimp_spin_scale_draw (GtkWidget *widget, gimp_spin_scale_draw (GtkWidget *widget,
cairo_t *cr) cairo_t *cr)
{ {
GimpSpinScalePrivate *private = GET_PRIVATE (widget); GimpSpinScale *scale = GIMP_SPIN_SCALE (widget);
cairo_save (cr); cairo_save (cr);
GTK_WIDGET_CLASS (parent_class)->draw (widget, cr); GTK_WIDGET_CLASS (parent_class)->draw (widget, cr);
cairo_restore (cr); cairo_restore (cr);
if (private->label) if (scale->label)
{ {
GtkStyleContext *style = gtk_widget_get_style_context (widget); GtkStyleContext *style = gtk_widget_get_style_context (widget);
GtkAllocation allocation; GtkAllocation allocation;
@ -396,36 +391,36 @@ gimp_spin_scale_draw (GtkWidget *widget,
&minimum_width, &minimum_width,
&natural_width); &natural_width);
if (! private->layout) if (! scale->layout)
{ {
private->layout = gtk_widget_create_pango_layout (widget, scale->layout = gtk_widget_create_pango_layout (widget,
private->label_text); scale->label_text);
pango_layout_set_ellipsize (private->layout, PANGO_ELLIPSIZE_END); pango_layout_set_ellipsize (scale->layout, PANGO_ELLIPSIZE_END);
/* Needing to force right-to-left layout when the widget is /* Needing to force right-to-left layout when the widget is
* set so, even when the text is not RTL text. Without this, * set so, even when the text is not RTL text. Without this,
* such case is broken because on the left side, we'd have * such case is broken because on the left side, we'd have
* both the value and the label texts. * both the value and the label texts.
*/ */
pango_layout_set_auto_dir (private->layout, FALSE); pango_layout_set_auto_dir (scale->layout, FALSE);
if (private->mnemonics_visible) if (scale->mnemonics_visible)
{ {
PangoAttrList *attrs; PangoAttrList *attrs;
attrs = pattern_to_attrs (private->label_text, attrs = pattern_to_attrs (scale->label_text,
private->label_pattern); scale->label_pattern);
if (attrs) if (attrs)
{ {
pango_layout_set_attributes (private->layout, attrs); pango_layout_set_attributes (scale->layout, attrs);
pango_attr_list_unref (attrs); pango_attr_list_unref (attrs);
} }
} }
} }
pango_layout_set_width (private->layout, pango_layout_set_width (scale->layout,
PANGO_SCALE * PANGO_SCALE *
(allocation.width - minimum_width)); (allocation.width - minimum_width));
pango_layout_get_pixel_extents (private->layout, &ink, NULL); pango_layout_get_pixel_extents (scale->layout, &ink, NULL);
gtk_entry_get_layout_offsets (GTK_ENTRY (widget), NULL, &layout_offset_y); gtk_entry_get_layout_offsets (GTK_ENTRY (widget), NULL, &layout_offset_y);
@ -471,7 +466,7 @@ gimp_spin_scale_draw (GtkWidget *widget,
cairo_move_to (cr, layout_offset_x, cairo_move_to (cr, layout_offset_x,
text_area.y - ink.y + text_area.height / 2 - ink.height / 2); text_area.y - ink.y + text_area.height / 2 - ink.height / 2);
gdk_cairo_set_source_rgba (cr, &text_color); gdk_cairo_set_source_rgba (cr, &text_color);
pango_cairo_show_layout (cr, private->layout); pango_cairo_show_layout (cr, scale->layout);
cairo_restore (cr); cairo_restore (cr);
@ -482,7 +477,7 @@ gimp_spin_scale_draw (GtkWidget *widget,
cairo_move_to (cr, layout_offset_x, cairo_move_to (cr, layout_offset_x,
text_area.y - ink.y + text_area.height / 2 - ink.height / 2); text_area.y - ink.y + text_area.height / 2 - ink.height / 2);
gdk_cairo_set_source_rgba (cr, &bar_text_color); gdk_cairo_set_source_rgba (cr, &bar_text_color);
pango_cairo_show_layout (cr, private->layout); pango_cairo_show_layout (cr, scale->layout);
} }
return FALSE; return FALSE;
@ -637,11 +632,11 @@ static void
gimp_spin_scale_update_cursor (GtkWidget *widget, gimp_spin_scale_update_cursor (GtkWidget *widget,
GdkWindow *window) GdkWindow *window)
{ {
GimpSpinScalePrivate *private = GET_PRIVATE (widget); GimpSpinScale *scale = GIMP_SPIN_SCALE (widget);
GdkDisplay *display = gtk_widget_get_display (widget); GdkDisplay *display = gtk_widget_get_display (widget);
GdkCursor *cursor = NULL; GdkCursor *cursor = NULL;
switch (private->target) switch (scale->target)
{ {
case TARGET_NUMBER: case TARGET_NUMBER:
cursor = gdk_cursor_new_from_name (display, "text"); cursor = gdk_cursor_new_from_name (display, "text");
@ -675,14 +670,14 @@ gimp_spin_scale_update_target (GtkWidget *widget,
gdouble y, gdouble y,
GdkEvent *event) GdkEvent *event)
{ {
GimpSpinScalePrivate *private = GET_PRIVATE (widget); GimpSpinScale *scale = GIMP_SPIN_SCALE (widget);
SpinScaleTarget target; SpinScaleTarget target;
target = gimp_spin_scale_get_target (widget, x, y, (GdkEvent *) event); target = gimp_spin_scale_get_target (widget, x, y, (GdkEvent *) event);
if (target != private->target) if (target != scale->target)
{ {
private->target = target; scale->target = target;
gimp_spin_scale_update_cursor (widget, window); gimp_spin_scale_update_cursor (widget, window);
} }
@ -692,11 +687,11 @@ static void
gimp_spin_scale_clear_target (GtkWidget *widget, gimp_spin_scale_clear_target (GtkWidget *widget,
GdkWindow *window) GdkWindow *window)
{ {
GimpSpinScalePrivate *private = GET_PRIVATE (widget); GimpSpinScale *scale = GIMP_SPIN_SCALE (widget);
if (private->target != TARGET_NONE) if (scale->target != TARGET_NONE)
{ {
private->target = TARGET_NONE; scale->target = TARGET_NONE;
gimp_spin_scale_update_cursor (widget, window); gimp_spin_scale_update_cursor (widget, window);
} }
@ -707,12 +702,10 @@ gimp_spin_scale_get_limits (GimpSpinScale *scale,
gdouble *lower, gdouble *lower,
gdouble *upper) gdouble *upper)
{ {
GimpSpinScalePrivate *private = GET_PRIVATE (scale); if (scale->scale_limits_set)
if (private->scale_limits_set)
{ {
*lower = private->scale_lower; *lower = scale->scale_lower;
*upper = private->scale_upper; *upper = scale->scale_upper;
} }
else else
{ {
@ -729,15 +722,15 @@ gimp_spin_scale_change_value (GtkWidget *widget,
gdouble x, gdouble x,
guint state) guint state)
{ {
GimpSpinScalePrivate *private = GET_PRIVATE (widget); GimpSpinScale *scale = GIMP_SPIN_SCALE (widget);
GtkSpinButton *spin_button = GTK_SPIN_BUTTON (widget); GtkSpinButton *spin_button = GTK_SPIN_BUTTON (widget);
GtkAdjustment *adjustment = gtk_spin_button_get_adjustment (spin_button); GtkAdjustment *adjustment = gtk_spin_button_get_adjustment (spin_button);
GdkRectangle text_area; GdkRectangle text_area;
gdouble lower; gdouble lower;
gdouble upper; gdouble upper;
gdouble value; gdouble value;
gint digits; gint digits;
gint power = 1; gint power = 1;
gtk_entry_get_text_area (GTK_ENTRY (widget), &text_area); gtk_entry_get_text_area (GTK_ENTRY (widget), &text_area);
@ -746,16 +739,16 @@ gimp_spin_scale_change_value (GtkWidget *widget,
if (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_RTL) if (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_RTL)
x = text_area.width - x; x = text_area.width - x;
if (private->relative_change) if (scale->relative_change)
{ {
gdouble step; gdouble step;
step = (upper - lower) / text_area.width * RELATIVE_CHANGE_SPEED; step = (upper - lower) / text_area.width * RELATIVE_CHANGE_SPEED;
if (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_RTL) if (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_RTL)
step *= x - (text_area.width - private->start_x); step *= x - (text_area.width - scale->start_x);
else else
step *= x - private->start_x; step *= x - scale->start_x;
if (state & GDK_CONTROL_MASK) if (state & GDK_CONTROL_MASK)
{ {
@ -764,20 +757,20 @@ gimp_spin_scale_change_value (GtkWidget *widget,
step = RINT (step / page_inc) * page_inc; step = RINT (step / page_inc) * page_inc;
} }
value = private->start_value + step; value = scale->start_value + step;
} }
else else
{ {
gdouble x0, x1; gdouble x0, x1;
gdouble fraction; gdouble fraction;
x0 = odd_pow (lower, 1.0 / private->gamma); x0 = odd_pow (lower, 1.0 / scale->gamma);
x1 = odd_pow (upper, 1.0 / private->gamma); x1 = odd_pow (upper, 1.0 / scale->gamma);
fraction = x / (gdouble) text_area.width; fraction = x / (gdouble) text_area.width;
value = fraction * (x1 - x0) + x0; value = fraction * (x1 - x0) + x0;
value = odd_pow (value, private->gamma); value = odd_pow (value, scale->gamma);
if (state & GDK_CONTROL_MASK) if (state & GDK_CONTROL_MASK)
{ {
@ -799,7 +792,7 @@ gimp_spin_scale_change_value (GtkWidget *widget,
value = RINT (value); value = RINT (value);
value /= power; value /= power;
if (private->constrain_drag) if (scale->constrain_drag)
value = rint (value); value = rint (value);
gtk_adjustment_set_value (adjustment, value); gtk_adjustment_set_value (adjustment, value);
@ -809,12 +802,12 @@ static gboolean
gimp_spin_scale_button_press (GtkWidget *widget, gimp_spin_scale_button_press (GtkWidget *widget,
GdkEventButton *event) GdkEventButton *event)
{ {
GimpSpinScalePrivate *private = GET_PRIVATE (widget); GimpSpinScale *scale = GIMP_SPIN_SCALE (widget);
gdouble x, y; gdouble x, y;
private->changing_value = FALSE; scale->changing_value = FALSE;
private->relative_change = FALSE; scale->relative_change = FALSE;
private->pointer_warp = FALSE; scale->pointer_warp = FALSE;
gimp_spin_scale_event_to_widget_coords (widget, event->window, gimp_spin_scale_event_to_widget_coords (widget, event->window,
event->x, event->y, event->x, event->y,
@ -822,11 +815,11 @@ gimp_spin_scale_button_press (GtkWidget *widget,
gimp_spin_scale_update_target (widget, event->window, x, y, (GdkEvent *) event); gimp_spin_scale_update_target (widget, event->window, x, y, (GdkEvent *) event);
switch (private->target) switch (scale->target)
{ {
case TARGET_GRAB: case TARGET_GRAB:
case TARGET_GRABBING: case TARGET_GRABBING:
private->changing_value = TRUE; scale->changing_value = TRUE;
gtk_widget_grab_focus (widget); gtk_widget_grab_focus (widget);
@ -837,16 +830,16 @@ gimp_spin_scale_button_press (GtkWidget *widget,
return TRUE; return TRUE;
case TARGET_RELATIVE: case TARGET_RELATIVE:
private->changing_value = TRUE; scale->changing_value = TRUE;
gtk_widget_grab_focus (widget); gtk_widget_grab_focus (widget);
private->relative_change = TRUE; scale->relative_change = TRUE;
private->start_x = x; scale->start_x = x;
private->start_value = gtk_adjustment_get_value (gtk_spin_button_get_adjustment (GTK_SPIN_BUTTON (widget))); scale->start_value = gtk_adjustment_get_value (gtk_spin_button_get_adjustment (GTK_SPIN_BUTTON (widget)));
private->start_pointer_x = floor (event->x_root); scale->start_pointer_x = floor (event->x_root);
private->start_pointer_y = floor (event->y_root); scale->start_pointer_y = floor (event->y_root);
gimp_spin_scale_update_cursor (widget, event->window); gimp_spin_scale_update_cursor (widget, event->window);
@ -867,33 +860,33 @@ static gboolean
gimp_spin_scale_button_release (GtkWidget *widget, gimp_spin_scale_button_release (GtkWidget *widget,
GdkEventButton *event) GdkEventButton *event)
{ {
GimpSpinScalePrivate *private = GET_PRIVATE (widget); GimpSpinScale *scale = GIMP_SPIN_SCALE (widget);
gdouble x, y; gdouble x, y;
gimp_spin_scale_event_to_widget_coords (widget, event->window, gimp_spin_scale_event_to_widget_coords (widget, event->window,
event->x, event->y, event->x, event->y,
&x, &y); &x, &y);
if (private->changing_value) if (scale->changing_value)
{ {
private->changing_value = FALSE; scale->changing_value = FALSE;
/* don't change the value if we're in the middle of a pointer warp, since /* don't change the value if we're in the middle of a pointer warp, since
* we didn't adjust start_x yet. see the comment in * we didn't adjust start_x yet. see the comment in
* gimp_spin_scale_motion_notify(). * gimp_spin_scale_motion_notify().
*/ */
if (! private->pointer_warp) if (! scale->pointer_warp)
gimp_spin_scale_change_value (widget, x, event->state); gimp_spin_scale_change_value (widget, x, event->state);
if (private->relative_change) if (scale->relative_change)
{ {
gdk_device_warp (gdk_event_get_device ((GdkEvent *) event), gdk_device_warp (gdk_event_get_device ((GdkEvent *) event),
gdk_event_get_screen ((GdkEvent *) event), gdk_event_get_screen ((GdkEvent *) event),
private->start_pointer_x, scale->start_pointer_x,
private->start_pointer_y); scale->start_pointer_y);
} }
if (private->hover) if (scale->hover)
{ {
gimp_spin_scale_update_target (widget, event->window, gimp_spin_scale_update_target (widget, event->window,
0.0, 0.0, NULL); 0.0, 0.0, NULL);
@ -915,8 +908,8 @@ static gboolean
gimp_spin_scale_motion_notify (GtkWidget *widget, gimp_spin_scale_motion_notify (GtkWidget *widget,
GdkEventMotion *event) GdkEventMotion *event)
{ {
GimpSpinScalePrivate *private = GET_PRIVATE (widget); GimpSpinScale *scale = GIMP_SPIN_SCALE (widget);
gdouble x, y; gdouble x, y;
gimp_spin_scale_event_to_widget_coords (widget, event->window, gimp_spin_scale_event_to_widget_coords (widget, event->window,
event->x, event->y, event->x, event->y,
@ -924,9 +917,9 @@ gimp_spin_scale_motion_notify (GtkWidget *widget,
gdk_event_request_motions (event); gdk_event_request_motions (event);
private->hover = TRUE; scale->hover = TRUE;
if (private->changing_value) if (scale->changing_value)
{ {
GdkScreen *screen; GdkScreen *screen;
GdkDisplay *display; GdkDisplay *display;
@ -971,20 +964,20 @@ gimp_spin_scale_motion_notify (GtkWidget *widget,
* across half the screen.) yes, this is an ugly ugly hack :) * across half the screen.) yes, this is an ugly ugly hack :)
*/ */
if (private->pointer_warp) if (scale->pointer_warp)
{ {
if (pointer_x == private->pointer_warp_x) if (pointer_x == scale->pointer_warp_x)
return TRUE; return TRUE;
private->pointer_warp = FALSE; scale->pointer_warp = FALSE;
if (ABS (pointer_x - private->pointer_warp_x) < monitor_geometry.width / 2) if (ABS (pointer_x - scale->pointer_warp_x) < monitor_geometry.width / 2)
private->start_x = private->pointer_warp_start_x; scale->start_x = scale->pointer_warp_start_x;
} }
gimp_spin_scale_change_value (widget, x, event->state); gimp_spin_scale_change_value (widget, x, event->state);
if (private->relative_change) if (scale->relative_change)
{ {
GtkAdjustment *adjustment; GtkAdjustment *adjustment;
gdouble value; gdouble value;
@ -1011,23 +1004,23 @@ gimp_spin_scale_motion_notify (GtkWidget *widget,
if (pointer_x <= monitor_geometry.x && if (pointer_x <= monitor_geometry.x &&
value > lower) value > lower)
{ {
private->pointer_warp = TRUE; scale->pointer_warp = TRUE;
private->pointer_warp_x = (monitor_geometry.width - 1) + pointer_x - 1; scale->pointer_warp_x = (monitor_geometry.width - 1) + pointer_x - 1;
private->pointer_warp_start_x = private->start_x + (monitor_geometry.width - 2); scale->pointer_warp_start_x = scale->start_x + (monitor_geometry.width - 2);
} }
else if (pointer_x >= monitor_geometry.x + (monitor_geometry.width - 1) && else if (pointer_x >= monitor_geometry.x + (monitor_geometry.width - 1) &&
value < upper) value < upper)
{ {
private->pointer_warp = TRUE; scale->pointer_warp = TRUE;
private->pointer_warp_x = pointer_x - (monitor_geometry.width - 1) + 1; scale->pointer_warp_x = pointer_x - (monitor_geometry.width - 1) + 1;
private->pointer_warp_start_x = private->start_x - (monitor_geometry.width - 2); scale->pointer_warp_start_x = scale->start_x - (monitor_geometry.width - 2);
} }
if (private->pointer_warp) if (scale->pointer_warp)
{ {
gdk_device_warp (gdk_event_get_device ((GdkEvent *) event), gdk_device_warp (gdk_event_get_device ((GdkEvent *) event),
screen, screen,
private->pointer_warp_x, scale->pointer_warp_x,
pointer_y); pointer_y);
} }
} }
@ -1039,7 +1032,7 @@ gimp_spin_scale_motion_notify (GtkWidget *widget,
if (! (event->state & if (! (event->state &
(GDK_BUTTON1_MASK | GDK_BUTTON2_MASK | GDK_BUTTON3_MASK)) && (GDK_BUTTON1_MASK | GDK_BUTTON2_MASK | GDK_BUTTON3_MASK)) &&
private->hover) scale->hover)
{ {
gimp_spin_scale_update_target (widget, event->window, gimp_spin_scale_update_target (widget, event->window,
x, y, (GdkEvent *) event); x, y, (GdkEvent *) event);
@ -1052,9 +1045,9 @@ static gboolean
gimp_spin_scale_leave_notify (GtkWidget *widget, gimp_spin_scale_leave_notify (GtkWidget *widget,
GdkEventCrossing *event) GdkEventCrossing *event)
{ {
GimpSpinScalePrivate *private = GET_PRIVATE (widget); GimpSpinScale *scale = GIMP_SPIN_SCALE (widget);
private->hover = FALSE; scale->hover = FALSE;
if (! (event->state & if (! (event->state &
(GDK_BUTTON1_MASK | GDK_BUTTON2_MASK | GDK_BUTTON3_MASK))) (GDK_BUTTON1_MASK | GDK_BUTTON2_MASK | GDK_BUTTON3_MASK)))
@ -1069,21 +1062,20 @@ static void
gimp_spin_scale_hierarchy_changed (GtkWidget *widget, gimp_spin_scale_hierarchy_changed (GtkWidget *widget,
GtkWidget *old_toplevel) GtkWidget *old_toplevel)
{ {
GimpSpinScalePrivate *private = GET_PRIVATE (widget); GimpSpinScale *scale = GIMP_SPIN_SCALE (widget);
gimp_spin_scale_setup_mnemonic (GIMP_SPIN_SCALE (widget), gimp_spin_scale_setup_mnemonic (GIMP_SPIN_SCALE (widget),
private->mnemonic_keyval); scale->mnemonic_keyval);
} }
static void static void
gimp_spin_scale_screen_changed (GtkWidget *widget, gimp_spin_scale_screen_changed (GtkWidget *widget,
GdkScreen *old_screen) GdkScreen *old_screen)
{ {
GimpSpinScale *scale = GIMP_SPIN_SCALE (widget); GimpSpinScale *scale = GIMP_SPIN_SCALE (widget);
GimpSpinScalePrivate *private = GET_PRIVATE (scale); GtkSettings *settings;
GtkSettings *settings;
g_clear_object (&private->layout); g_clear_object (&scale->layout);
if (old_screen) if (old_screen)
{ {
@ -1112,21 +1104,21 @@ gimp_spin_scale_screen_changed (GtkWidget *widget,
static void static void
gimp_spin_scale_value_changed (GtkSpinButton *spin_button) gimp_spin_scale_value_changed (GtkSpinButton *spin_button)
{ {
GimpSpinScalePrivate *private = GET_PRIVATE (spin_button); GimpSpinScale *scale = GIMP_SPIN_SCALE (spin_button);
GtkAdjustment *adjustment = gtk_spin_button_get_adjustment (spin_button); GtkAdjustment *adjustment = gtk_spin_button_get_adjustment (spin_button);
gdouble lower; gdouble lower;
gdouble upper; gdouble upper;
gdouble value; gdouble value;
gdouble x0, x1; gdouble x0, x1;
gdouble x; gdouble x;
gimp_spin_scale_get_limits (GIMP_SPIN_SCALE (spin_button), &lower, &upper); gimp_spin_scale_get_limits (GIMP_SPIN_SCALE (spin_button), &lower, &upper);
value = CLAMP (gtk_adjustment_get_value (adjustment), lower, upper); value = CLAMP (gtk_adjustment_get_value (adjustment), lower, upper);
x0 = odd_pow (lower, 1.0 / private->gamma); x0 = odd_pow (lower, 1.0 / scale->gamma);
x1 = odd_pow (upper, 1.0 / private->gamma); x1 = odd_pow (upper, 1.0 / scale->gamma);
x = odd_pow (value, 1.0 / private->gamma); x = odd_pow (value, 1.0 / scale->gamma);
gtk_entry_set_progress_fraction (GTK_ENTRY (spin_button), gtk_entry_set_progress_fraction (GTK_ENTRY (spin_button),
(x - x0) / (x1 - x0)); (x - x0) / (x1 - x0));
@ -1148,10 +1140,9 @@ gimp_spin_scale_mnemonics_notify (GtkWindow *window,
const GParamSpec *pspec, const GParamSpec *pspec,
GimpSpinScale *scale) GimpSpinScale *scale)
{ {
GimpSpinScalePrivate *private = GET_PRIVATE (scale); gboolean mnemonics_visible = FALSE;
gboolean mnemonics_visible = FALSE; gboolean enable_mnemonics;
gboolean enable_mnemonics; gboolean auto_mnemonics;
gboolean auto_mnemonics;
g_object_get (gtk_widget_get_settings (GTK_WIDGET (scale)), g_object_get (gtk_widget_get_settings (GTK_WIDGET (scale)),
"gtk-enable-mnemonics", &enable_mnemonics, "gtk-enable-mnemonics", &enable_mnemonics,
@ -1167,11 +1158,11 @@ gimp_spin_scale_mnemonics_notify (GtkWindow *window,
NULL); NULL);
} }
if (private->mnemonics_visible != mnemonics_visible) if (scale->mnemonics_visible != mnemonics_visible)
{ {
private->mnemonics_visible = mnemonics_visible; scale->mnemonics_visible = mnemonics_visible;
g_clear_object (&private->layout); g_clear_object (&scale->layout);
gtk_widget_queue_draw (GTK_WIDGET (scale)); gtk_widget_queue_draw (GTK_WIDGET (scale));
} }
@ -1181,31 +1172,30 @@ static void
gimp_spin_scale_setup_mnemonic (GimpSpinScale *scale, gimp_spin_scale_setup_mnemonic (GimpSpinScale *scale,
guint previous_keyval) guint previous_keyval)
{ {
GimpSpinScalePrivate *private = GET_PRIVATE (scale); GtkWidget *widget = GTK_WIDGET (scale);
GtkWidget *widget = GTK_WIDGET (scale); GtkWidget *toplevel;
GtkWidget *toplevel;
if (private->mnemonic_window) if (scale->mnemonic_window)
{ {
g_signal_handlers_disconnect_by_func (private->mnemonic_window, g_signal_handlers_disconnect_by_func (scale->mnemonic_window,
gimp_spin_scale_mnemonics_notify, gimp_spin_scale_mnemonics_notify,
scale); scale);
gtk_window_remove_mnemonic (private->mnemonic_window, gtk_window_remove_mnemonic (scale->mnemonic_window,
previous_keyval, previous_keyval,
widget); widget);
private->mnemonic_window = NULL; scale->mnemonic_window = NULL;
} }
toplevel = gtk_widget_get_toplevel (widget); toplevel = gtk_widget_get_toplevel (widget);
if (gtk_widget_is_toplevel (toplevel) && if (gtk_widget_is_toplevel (toplevel) &&
private->mnemonic_keyval != GDK_KEY_VoidSymbol) scale->mnemonic_keyval != GDK_KEY_VoidSymbol)
{ {
gtk_window_add_mnemonic (GTK_WINDOW (toplevel), gtk_window_add_mnemonic (GTK_WINDOW (toplevel),
private->mnemonic_keyval, scale->mnemonic_keyval,
widget); widget);
private->mnemonic_window = GTK_WINDOW (toplevel); scale->mnemonic_window = GTK_WINDOW (toplevel);
g_signal_connect (toplevel, "notify::mnemonics-visible", g_signal_connect (toplevel, "notify::mnemonics-visible",
G_CALLBACK (gimp_spin_scale_mnemonics_notify), G_CALLBACK (gimp_spin_scale_mnemonics_notify),
@ -1320,40 +1310,37 @@ void
gimp_spin_scale_set_label (GimpSpinScale *scale, gimp_spin_scale_set_label (GimpSpinScale *scale,
const gchar *label) const gchar *label)
{ {
GimpSpinScalePrivate *private; guint accel_key = GDK_KEY_VoidSymbol;
guint accel_key = GDK_KEY_VoidSymbol; gchar *text = NULL;
gchar *text = NULL; gchar *pattern = NULL;
gchar *pattern = NULL;
g_return_if_fail (GIMP_IS_SPIN_SCALE (scale)); g_return_if_fail (GIMP_IS_SPIN_SCALE (scale));
private = GET_PRIVATE (scale); if (label == scale->label)
if (label == private->label)
return; return;
if (label && ! separate_uline_pattern (label, &accel_key, &text, &pattern)) if (label && ! separate_uline_pattern (label, &accel_key, &text, &pattern))
return; return;
g_free (private->label); g_free (scale->label);
private->label = g_strdup (label); scale->label = g_strdup (label);
g_free (private->label_text); g_free (scale->label_text);
private->label_text = text; /* don't dup */ scale->label_text = text; /* don't dup */
g_free (private->label_pattern); g_free (scale->label_pattern);
private->label_pattern = pattern; /* don't dup */ scale->label_pattern = pattern; /* don't dup */
if (private->mnemonic_keyval != accel_key) if (scale->mnemonic_keyval != accel_key)
{ {
guint previous = private->mnemonic_keyval; guint previous = scale->mnemonic_keyval;
private->mnemonic_keyval = accel_key; scale->mnemonic_keyval = accel_key;
gimp_spin_scale_setup_mnemonic (scale, previous); gimp_spin_scale_setup_mnemonic (scale, previous);
} }
g_clear_object (&private->layout); g_clear_object (&scale->layout);
gtk_widget_queue_resize (GTK_WIDGET (scale)); gtk_widget_queue_resize (GTK_WIDGET (scale));
@ -1365,7 +1352,7 @@ gimp_spin_scale_get_label (GimpSpinScale *scale)
{ {
g_return_val_if_fail (GIMP_IS_SPIN_SCALE (scale), NULL); g_return_val_if_fail (GIMP_IS_SPIN_SCALE (scale), NULL);
return GET_PRIVATE (scale)->label; return scale->label;
} }
void void
@ -1373,23 +1360,21 @@ gimp_spin_scale_set_scale_limits (GimpSpinScale *scale,
gdouble lower, gdouble lower,
gdouble upper) gdouble upper)
{ {
GimpSpinScalePrivate *private; GtkSpinButton *spin_button;
GtkSpinButton *spin_button; GtkAdjustment *adjustment;
GtkAdjustment *adjustment;
g_return_if_fail (GIMP_IS_SPIN_SCALE (scale)); g_return_if_fail (GIMP_IS_SPIN_SCALE (scale));
private = GET_PRIVATE (scale);
spin_button = GTK_SPIN_BUTTON (scale); spin_button = GTK_SPIN_BUTTON (scale);
adjustment = gtk_spin_button_get_adjustment (spin_button); adjustment = gtk_spin_button_get_adjustment (spin_button);
g_return_if_fail (lower >= gtk_adjustment_get_lower (adjustment)); g_return_if_fail (lower >= gtk_adjustment_get_lower (adjustment));
g_return_if_fail (upper <= gtk_adjustment_get_upper (adjustment)); g_return_if_fail (upper <= gtk_adjustment_get_upper (adjustment));
private->scale_limits_set = TRUE; scale->scale_limits_set = TRUE;
private->scale_lower = lower; scale->scale_lower = lower;
private->scale_upper = upper; scale->scale_upper = upper;
private->gamma = 1.0; scale->gamma = 1.0;
gimp_spin_scale_value_changed (spin_button); gimp_spin_scale_value_changed (spin_button);
} }
@ -1397,15 +1382,11 @@ gimp_spin_scale_set_scale_limits (GimpSpinScale *scale,
void void
gimp_spin_scale_unset_scale_limits (GimpSpinScale *scale) gimp_spin_scale_unset_scale_limits (GimpSpinScale *scale)
{ {
GimpSpinScalePrivate *private;
g_return_if_fail (GIMP_IS_SPIN_SCALE (scale)); g_return_if_fail (GIMP_IS_SPIN_SCALE (scale));
private = GET_PRIVATE (scale); scale->scale_limits_set = FALSE;
scale->scale_lower = 0.0;
private->scale_limits_set = FALSE; scale->scale_upper = 0.0;
private->scale_lower = 0.0;
private->scale_upper = 0.0;
gimp_spin_scale_value_changed (GTK_SPIN_BUTTON (scale)); gimp_spin_scale_value_changed (GTK_SPIN_BUTTON (scale));
} }
@ -1415,32 +1396,24 @@ gimp_spin_scale_get_scale_limits (GimpSpinScale *scale,
gdouble *lower, gdouble *lower,
gdouble *upper) gdouble *upper)
{ {
GimpSpinScalePrivate *private;
g_return_val_if_fail (GIMP_IS_SPIN_SCALE (scale), FALSE); g_return_val_if_fail (GIMP_IS_SPIN_SCALE (scale), FALSE);
private = GET_PRIVATE (scale);
if (lower) if (lower)
*lower = private->scale_lower; *lower = scale->scale_lower;
if (upper) if (upper)
*upper = private->scale_upper; *upper = scale->scale_upper;
return private->scale_limits_set; return scale->scale_limits_set;
} }
void void
gimp_spin_scale_set_gamma (GimpSpinScale *scale, gimp_spin_scale_set_gamma (GimpSpinScale *scale,
gdouble gamma) gdouble gamma)
{ {
GimpSpinScalePrivate *private;
g_return_if_fail (GIMP_IS_SPIN_SCALE (scale)); g_return_if_fail (GIMP_IS_SPIN_SCALE (scale));
private = GET_PRIVATE (scale); scale->gamma = gamma;
private->gamma = gamma;
gimp_spin_scale_value_changed (GTK_SPIN_BUTTON (scale)); gimp_spin_scale_value_changed (GTK_SPIN_BUTTON (scale));
} }
@ -1450,7 +1423,7 @@ gimp_spin_scale_get_gamma (GimpSpinScale *scale)
{ {
g_return_val_if_fail (GIMP_IS_SPIN_SCALE (scale), 1.0); g_return_val_if_fail (GIMP_IS_SPIN_SCALE (scale), 1.0);
return GET_PRIVATE (scale)->gamma; return scale->gamma;
} }
/** /**
@ -1468,13 +1441,9 @@ void
gimp_spin_scale_set_constrain_drag (GimpSpinScale *scale, gimp_spin_scale_set_constrain_drag (GimpSpinScale *scale,
gboolean constrain) gboolean constrain)
{ {
GimpSpinScalePrivate *private;
g_return_if_fail (GIMP_IS_SPIN_SCALE (scale)); g_return_if_fail (GIMP_IS_SPIN_SCALE (scale));
private = GET_PRIVATE (scale); scale->constrain_drag = constrain;
private->constrain_drag = constrain;
} }
gboolean gboolean
@ -1482,7 +1451,7 @@ gimp_spin_scale_get_constrain_drag (GimpSpinScale *scale)
{ {
g_return_val_if_fail (GIMP_IS_SPIN_SCALE (scale), 1.0); g_return_val_if_fail (GIMP_IS_SPIN_SCALE (scale), 1.0);
return GET_PRIVATE (scale)->constrain_drag; return scale->constrain_drag;
} }
/** /**
@ -1499,5 +1468,5 @@ gimp_spin_scale_get_mnemonic_keyval (GimpSpinScale *scale)
{ {
g_return_val_if_fail (GIMP_IS_SPIN_SCALE (scale), GDK_KEY_VoidSymbol); g_return_val_if_fail (GIMP_IS_SPIN_SCALE (scale), GDK_KEY_VoidSymbol);
return GET_PRIVATE (scale)->mnemonic_keyval; return scale->mnemonic_keyval;
} }

View file

@ -30,30 +30,10 @@
G_BEGIN_DECLS G_BEGIN_DECLS
#define GIMP_TYPE_SPIN_SCALE (gimp_spin_scale_get_type ()) #define GIMP_TYPE_SPIN_SCALE (gimp_spin_scale_get_type ())
#define GIMP_SPIN_SCALE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GIMP_TYPE_SPIN_SCALE, GimpSpinScale)) G_DECLARE_FINAL_TYPE (GimpSpinScale, gimp_spin_scale, GIMP, SPIN_SCALE, GimpSpinButton)
#define GIMP_SPIN_SCALE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GIMP_TYPE_SPIN_SCALE, GimpSpinScaleClass))
#define GIMP_IS_SPIN_SCALE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GIMP_TYPE_SPIN_SCALE))
#define GIMP_IS_SPIN_SCALE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GIMP_TYPE_SPIN_SCALE))
#define GIMP_SPIN_SCALE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GIMP_TYPE_SPIN_SCALE, GimpSpinScaleClass))
typedef struct _GimpSpinScale GimpSpinScale;
typedef struct _GimpSpinScaleClass GimpSpinScaleClass;
struct _GimpSpinScale
{
GimpSpinButton parent_instance;
};
struct _GimpSpinScaleClass
{
GimpSpinButtonClass parent_class;
};
GType gimp_spin_scale_get_type (void) G_GNUC_CONST;
GtkWidget * gimp_spin_scale_new (GtkAdjustment *adjustment, GtkWidget * gimp_spin_scale_new (GtkAdjustment *adjustment,
const gchar *label, const gchar *label,
gint digits); gint digits);

View file

@ -51,7 +51,7 @@ enum
}; };
struct _GimpStringComboBoxPrivate typedef struct _GimpStringComboBoxPrivate
{ {
gint id_column; gint id_column;
gint label_column; gint label_column;
@ -60,9 +60,7 @@ struct _GimpStringComboBoxPrivate
GimpStringSensitivityFunc sensitivity_func; GimpStringSensitivityFunc sensitivity_func;
gpointer sensitivity_data; gpointer sensitivity_data;
GDestroyNotify sensitivity_destroy; GDestroyNotify sensitivity_destroy;
}; } GimpStringComboBoxPrivate;
#define GET_PRIVATE(obj) (((GimpStringComboBox *) (obj))->priv)
static void gimp_string_combo_box_constructed (GObject *object); static void gimp_string_combo_box_constructed (GObject *object);
@ -170,13 +168,13 @@ gimp_string_combo_box_class_init (GimpStringComboBoxClass *klass)
static void static void
gimp_string_combo_box_init (GimpStringComboBox *combo_box) gimp_string_combo_box_init (GimpStringComboBox *combo_box)
{ {
combo_box->priv = gimp_string_combo_box_get_instance_private (combo_box);
} }
static void static void
gimp_string_combo_box_constructed (GObject *object) gimp_string_combo_box_constructed (GObject *object)
{ {
GimpStringComboBoxPrivate *priv = GET_PRIVATE (object); GimpStringComboBox *combo = GIMP_STRING_COMBO_BOX (object);
GimpStringComboBoxPrivate *priv = gimp_string_combo_box_get_instance_private (combo);
GtkCellRenderer *cell; GtkCellRenderer *cell;
G_OBJECT_CLASS (parent_class)->constructed (object); G_OBJECT_CLASS (parent_class)->constructed (object);
@ -205,7 +203,8 @@ gimp_string_combo_box_set_property (GObject *object,
const GValue *value, const GValue *value,
GParamSpec *pspec) GParamSpec *pspec)
{ {
GimpStringComboBoxPrivate *priv = GET_PRIVATE (object); GimpStringComboBox *combo = GIMP_STRING_COMBO_BOX (object);
GimpStringComboBoxPrivate *priv = gimp_string_combo_box_get_instance_private (combo);
switch (property_id) switch (property_id)
{ {
@ -238,7 +237,8 @@ gimp_string_combo_box_get_property (GObject *object,
GValue *value, GValue *value,
GParamSpec *pspec) GParamSpec *pspec)
{ {
GimpStringComboBoxPrivate *priv = GET_PRIVATE (object); GimpStringComboBox *combo = GIMP_STRING_COMBO_BOX (object);
GimpStringComboBoxPrivate *priv = gimp_string_combo_box_get_instance_private (combo);
switch (property_id) switch (property_id)
{ {
@ -351,8 +351,12 @@ gboolean
gimp_string_combo_box_set_active (GimpStringComboBox *combo_box, gimp_string_combo_box_set_active (GimpStringComboBox *combo_box,
const gchar *id) const gchar *id)
{ {
GimpStringComboBoxPrivate *priv;
g_return_val_if_fail (GIMP_IS_STRING_COMBO_BOX (combo_box), FALSE); g_return_val_if_fail (GIMP_IS_STRING_COMBO_BOX (combo_box), FALSE);
priv = gimp_string_combo_box_get_instance_private (combo_box);
if (id) if (id)
{ {
GtkTreeModel *model; GtkTreeModel *model;
@ -361,7 +365,7 @@ gimp_string_combo_box_set_active (GimpStringComboBox *combo_box,
model = gtk_combo_box_get_model (GTK_COMBO_BOX (combo_box)); model = gtk_combo_box_get_model (GTK_COMBO_BOX (combo_box));
column = GET_PRIVATE (combo_box)->id_column; column = priv->id_column;
if (gimp_string_model_lookup (model, column, id, &iter)) if (gimp_string_model_lookup (model, column, id, &iter))
{ {
@ -394,17 +398,20 @@ gimp_string_combo_box_set_active (GimpStringComboBox *combo_box,
gchar * gchar *
gimp_string_combo_box_get_active (GimpStringComboBox *combo_box) gimp_string_combo_box_get_active (GimpStringComboBox *combo_box)
{ {
GtkTreeIter iter; GtkTreeIter iter;
GimpStringComboBoxPrivate *priv;
g_return_val_if_fail (GIMP_IS_STRING_COMBO_BOX (combo_box), NULL); g_return_val_if_fail (GIMP_IS_STRING_COMBO_BOX (combo_box), NULL);
priv = gimp_string_combo_box_get_instance_private (combo_box);
if (gtk_combo_box_get_active_iter (GTK_COMBO_BOX (combo_box), &iter)) if (gtk_combo_box_get_active_iter (GTK_COMBO_BOX (combo_box), &iter))
{ {
GtkTreeModel *model = gtk_combo_box_get_model (GTK_COMBO_BOX (combo_box)); GtkTreeModel *model = gtk_combo_box_get_model (GTK_COMBO_BOX (combo_box));
gchar *value; gchar *value;
gint column; gint column;
column = GET_PRIVATE (combo_box)->id_column; column = priv->id_column;
gtk_tree_model_get (model, &iter, gtk_tree_model_get (model, &iter,
column, &value, column, &value,
@ -442,7 +449,7 @@ gimp_string_combo_box_set_sensitivity (GimpStringComboBox *combo_box,
g_return_if_fail (GIMP_IS_STRING_COMBO_BOX (combo_box)); g_return_if_fail (GIMP_IS_STRING_COMBO_BOX (combo_box));
priv = GET_PRIVATE (combo_box); priv = gimp_string_combo_box_get_instance_private (combo_box);
if (priv->sensitivity_destroy) if (priv->sensitivity_destroy)
{ {

View file

@ -38,23 +38,8 @@ typedef gboolean (* GimpStringSensitivityFunc) (const gchar *id,
gpointer data); gpointer data);
#define GIMP_TYPE_STRING_COMBO_BOX (gimp_string_combo_box_get_type ()) #define GIMP_TYPE_STRING_COMBO_BOX (gimp_string_combo_box_get_type ())
#define GIMP_STRING_COMBO_BOX(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GIMP_TYPE_STRING_COMBO_BOX, GimpStringComboBox)) G_DECLARE_DERIVABLE_TYPE (GimpStringComboBox, gimp_string_combo_box, GIMP, STRING_COMBO_BOX, GtkComboBox)
#define GIMP_STRING_COMBO_BOX_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GIMP_TYPE_STRING_COMBO_BOX, GimpStringComboBoxClass))
#define GIMP_IS_STRING_COMBO_BOX(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GIMP_TYPE_STRING_COMBO_BOX))
#define GIMP_IS_STRING_COMBO_BOX_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GIMP_TYPE_STRING_COMBO_BOX))
#define GIMP_STRING_COMBO_BOX_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GIMP_TYPE_STRING_COMBO_BOX, GimpStringComboBoxClass))
typedef struct _GimpStringComboBoxPrivate GimpStringComboBoxPrivate;
typedef struct _GimpStringComboBoxClass GimpStringComboBoxClass;
struct _GimpStringComboBox
{
GtkComboBox parent_instance;
GimpStringComboBoxPrivate *priv;
};
struct _GimpStringComboBoxClass struct _GimpStringComboBoxClass
{ {
@ -72,8 +57,6 @@ struct _GimpStringComboBoxClass
}; };
GType gimp_string_combo_box_get_type (void) G_GNUC_CONST;
GtkWidget * gimp_string_combo_box_new (GtkTreeModel *model, GtkWidget * gimp_string_combo_box_new (GtkTreeModel *model,
gint id_column, gint id_column,
gint label_column); gint label_column);