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;
};
@ -67,7 +69,7 @@ static void gimp_busy_box_get_property (GObject *object,
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
@ -105,8 +107,6 @@ gimp_busy_box_init (GimpBusyBox *box)
GtkWidget *spinner;
GtkWidget *label;
box->priv = gimp_busy_box_get_instance_private (box);
gtk_widget_set_halign (GTK_WIDGET (box), GTK_ALIGN_CENTER);
gtk_widget_set_valign (GTK_WIDGET (box), GTK_ALIGN_CENTER);
gtk_box_set_spacing (GTK_BOX (box), 8);
@ -119,7 +119,7 @@ gimp_busy_box_init (GimpBusyBox *box)
/* the label */
label = gtk_label_new (NULL);
box->priv->label = GTK_LABEL (label);
box->label = GTK_LABEL (label);
gimp_label_set_attributes (GTK_LABEL (label),
PANGO_ATTR_STYLE, PANGO_STYLE_ITALIC,
-1);
@ -138,7 +138,7 @@ gimp_busy_box_set_property (GObject *object,
switch (property_id)
{
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;
default:
@ -158,7 +158,7 @@ gimp_busy_box_get_property (GObject *object,
switch (property_id)
{
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;
default:
@ -228,5 +228,5 @@ gimp_busy_box_get_message (GimpBusyBox *box)
{
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

@ -29,41 +29,9 @@
G_BEGIN_DECLS
#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))
#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))
G_DECLARE_FINAL_TYPE (GimpBusyBox, gimp_busy_box, GIMP, BUSY_BOX, GtkBox)
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);
void gimp_busy_box_set_message (GimpBusyBox *box,

View File

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

View File

@ -30,41 +30,9 @@ G_BEGIN_DECLS
#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))
#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))
G_DECLARE_FINAL_TYPE (GimpCellRendererColor, gimp_cell_renderer_color, GIMP, CELL_RENDERER_COLOR, GtkCellRenderer)
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);

View File

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

View File

@ -26,40 +26,7 @@ G_BEGIN_DECLS
#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))
#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;
G_DECLARE_FINAL_TYPE (GimpColorProfileChooserDialog, gimp_color_profile_chooser_dialog, GIMP, COLOR_PROFILE_CHOOSER_DIALOG, GtkFileChooserDialog)
GtkWidget * gimp_color_profile_chooser_dialog_new (const gchar *title,
GtkWindow *parent,

View File

@ -52,14 +52,14 @@ enum
};
struct _GimpColorProfileComboBoxPrivate
struct _GimpColorProfileComboBox
{
GtkComboBox parent_instance;
GtkWidget *dialog;
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_set_property (GObject *object,
@ -81,8 +81,7 @@ static void gimp_color_profile_combo_dialog_response (GimpColorProfileChooserD
GimpColorProfileComboBox *combo);
G_DEFINE_TYPE_WITH_PRIVATE (GimpColorProfileComboBox,
gimp_color_profile_combo_box, GTK_TYPE_COMBO_BOX)
G_DEFINE_TYPE (GimpColorProfileComboBox, gimp_color_profile_combo_box, GTK_TYPE_COMBO_BOX)
#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;
combo_box->priv = gimp_color_profile_combo_box_get_instance_private (combo_box);
cell = gtk_cell_renderer_text_new ();
g_object_set (cell,
@ -161,18 +158,18 @@ gimp_color_profile_combo_box_init (GimpColorProfileComboBox *combo_box)
static void
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))
gtk_widget_destroy (private->dialog);
if (GIMP_IS_COLOR_PROFILE_CHOOSER_DIALOG (combo->dialog))
gtk_widget_destroy (combo->dialog);
g_object_unref (private->dialog);
private->dialog = NULL;
g_object_unref (combo->dialog);
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);
}
@ -183,16 +180,16 @@ gimp_color_profile_combo_box_set_property (GObject *object,
const GValue *value,
GParamSpec *pspec)
{
GimpColorProfileComboBoxPrivate *private = GET_PRIVATE (object);
GimpColorProfileComboBox *combo = GIMP_COLOR_PROFILE_COMBO_BOX (object);
switch (property_id)
{
case PROP_DIALOG:
g_return_if_fail (private->dialog == NULL);
private->dialog = g_value_dup_object (value);
g_return_if_fail (combo->dialog == NULL);
combo->dialog = g_value_dup_object (value);
if (GIMP_IS_COLOR_PROFILE_CHOOSER_DIALOG (private->dialog))
g_signal_connect (private->dialog, "response",
if (GIMP_IS_COLOR_PROFILE_CHOOSER_DIALOG (combo->dialog))
g_signal_connect (combo->dialog, "response",
G_CALLBACK (gimp_color_profile_combo_dialog_response),
object);
break;
@ -214,12 +211,12 @@ gimp_color_profile_combo_box_get_property (GObject *object,
GValue *value,
GParamSpec *pspec)
{
GimpColorProfileComboBoxPrivate *private = GET_PRIVATE (object);
GimpColorProfileComboBox *combo = GIMP_COLOR_PROFILE_COMBO_BOX (object);
switch (property_id)
{
case PROP_DIALOG:
g_value_set_object (value, private->dialog);
g_value_set_object (value, combo->dialog);
break;
case PROP_MODEL:
@ -236,7 +233,7 @@ gimp_color_profile_combo_box_get_property (GObject *object,
static void
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);
GtkTreeIter iter;
gint type;
@ -255,13 +252,13 @@ gimp_color_profile_combo_box_changed (GtkComboBox *combo)
GtkWidget *parent = gtk_widget_get_toplevel (GTK_WIDGET (combo));
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_present (GTK_WINDOW (priv->dialog));
gtk_window_present (GTK_WINDOW (color_combo->dialog));
if (priv->last_path &&
gtk_tree_model_get_iter (model, &iter, priv->last_path))
if (color_combo->last_path &&
gtk_tree_model_get_iter (model, &iter, color_combo->last_path))
{
gtk_combo_box_set_active_iter (combo, &iter);
}
@ -269,10 +266,10 @@ gimp_color_profile_combo_box_changed (GtkComboBox *combo)
break;
case GIMP_COLOR_PROFILE_STORE_ITEM_FILE:
if (priv->last_path)
gtk_tree_path_free (priv->last_path);
if (color_combo->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),
&iter);

View File

@ -29,41 +29,9 @@
G_BEGIN_DECLS
#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))
#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))
G_DECLARE_FINAL_TYPE (GimpColorProfileComboBox, gimp_color_profile_combo_box, GIMP, COLOR_PROFILE_COMBO_BOX, GtkComboBox)
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,
GFile *history);
GtkWidget * gimp_color_profile_combo_box_new_with_model (GtkWidget *dialog,

View File

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

View File

@ -30,40 +30,9 @@ G_BEGIN_DECLS
#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))
#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))
G_DECLARE_FINAL_TYPE (GimpColorProfileStore, gimp_color_profile_store, GIMP, COLOR_PROFILE_STORE, GtkListStore)
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);
void gimp_color_profile_store_add_file (GimpColorProfileStore *store,

View File

@ -43,8 +43,10 @@
**/
struct _GimpColorProfileViewPrivate
struct _GimpColorProfileView
{
GtkTextView parent_instance;
GimpColorProfile *profile;
};
@ -53,8 +55,7 @@ static void gimp_color_profile_view_constructed (GObject *object);
static void gimp_color_profile_view_finalize (GObject *object);
G_DEFINE_TYPE_WITH_PRIVATE (GimpColorProfileView, gimp_color_profile_view,
GTK_TYPE_TEXT_VIEW)
G_DEFINE_TYPE (GimpColorProfileView, gimp_color_profile_view, GTK_TYPE_TEXT_VIEW)
#define parent_class gimp_color_profile_view_parent_class
@ -71,7 +72,6 @@ gimp_color_profile_view_class_init (GimpColorProfileViewClass *klass)
static void
gimp_color_profile_view_init (GimpColorProfileView *view)
{
view->priv = gimp_color_profile_view_get_instance_private (view);
}
static void
@ -109,7 +109,7 @@ gimp_color_profile_view_finalize (GObject *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);
}
@ -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 (profile == NULL || GIMP_IS_COLOR_PROFILE (profile));
if (profile == view->priv->profile)
if (profile == view->profile)
return;
buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (view));
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;
const gchar *text;

View File

@ -25,41 +25,9 @@ G_BEGIN_DECLS
#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))
#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))
G_DECLARE_FINAL_TYPE (GimpColorProfileView, gimp_color_profile_view, GIMP, COLOR_PROFILE_VIEW, GtkTextView)
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);
void gimp_color_profile_view_set_profile (GimpColorProfileView *view,

View File

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

View File

@ -31,40 +31,9 @@ G_BEGIN_DECLS
#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))
#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))
G_DECLARE_FINAL_TYPE (GimpColorScale, gimp_color_scale, GIMP, COLOR_SCALE, GtkScale)
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,
GimpColorSelectorChannel channel);

View File

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

View File

@ -30,41 +30,9 @@ G_BEGIN_DECLS
#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))
#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))
G_DECLARE_FINAL_TYPE (GimpEnumLabel, gimp_enum_label, GIMP, ENUM_LABEL, GtkScale)
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,
gint value);
void gimp_enum_label_set_value (GimpEnumLabel *label,

View File

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

View File

@ -32,41 +32,9 @@ G_BEGIN_DECLS
#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))
#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))
G_DECLARE_FINAL_TYPE (GimpHintBox, gimp_hint_box, GIMP, HINT_BOX, GtkBox)
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);

View File

@ -53,7 +53,7 @@ enum
};
struct _GimpIntComboBoxPrivate
typedef struct _GimpIntComboBoxPrivate
{
GtkCellRenderer *text_renderer;
@ -64,9 +64,7 @@ struct _GimpIntComboBoxPrivate
GimpIntSensitivityFunc sensitivity_func;
gpointer sensitivity_data;
GDestroyNotify sensitivity_destroy;
};
#define GET_PRIVATE(obj) (((GimpIntComboBox *) (obj))->priv)
} GimpIntComboBoxPrivate;
static void gimp_int_combo_box_constructed (GObject *object);
@ -175,7 +173,7 @@ gimp_int_combo_box_init (GimpIntComboBox *combo_box)
GimpIntComboBoxPrivate *priv;
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);
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
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);
@ -220,7 +221,10 @@ gimp_int_combo_box_set_property (GObject *object,
const GValue *value,
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)
{
@ -257,7 +261,10 @@ gimp_int_combo_box_get_property (GObject *object,
GValue *value,
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)
{
@ -669,7 +676,7 @@ gimp_int_combo_box_set_label (GimpIntComboBox *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)
return;
@ -712,9 +719,13 @@ gimp_int_combo_box_set_label (GimpIntComboBox *combo_box,
const gchar *
gimp_int_combo_box_get_label (GimpIntComboBox *combo_box)
{
GimpIntComboBoxPrivate *priv;
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));
priv = GET_PRIVATE (combo_box);
priv = gimp_int_combo_box_get_instance_private (combo_box);
if (layout == priv->layout)
return;
@ -759,10 +770,14 @@ gimp_int_combo_box_set_layout (GimpIntComboBox *combo_box,
GimpIntComboBoxLayout
gimp_int_combo_box_get_layout (GimpIntComboBox *combo_box)
{
GimpIntComboBoxPrivate *priv;
g_return_val_if_fail (GIMP_IS_INT_COMBO_BOX (combo_box),
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));
priv = GET_PRIVATE (combo_box);
priv = gimp_int_combo_box_get_instance_private (combo_box);
if (priv->sensitivity_destroy)
{
@ -825,12 +840,14 @@ gimp_int_combo_box_changed (GtkComboBox *combo_box,
static void
gimp_int_combo_box_create_cells (GimpIntComboBox *combo_box)
{
GimpIntComboBoxPrivate *priv = GET_PRIVATE (combo_box);
GimpIntComboBoxPrivate *priv;
GtkCellLayout *layout = GTK_CELL_LAYOUT (combo_box);
GtkCellRenderer *text_renderer;
GtkCellRenderer *pixbuf_renderer;
gboolean popup_shown;
priv = gimp_int_combo_box_get_instance_private (combo_box);
g_object_get (combo_box, "popup-shown", &popup_shown, NULL);
gtk_cell_layout_clear (layout);

View File

@ -30,23 +30,9 @@ G_BEGIN_DECLS
#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))
#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))
G_DECLARE_DERIVABLE_TYPE (GimpIntComboBox, gimp_int_combo_box, GIMP, INT_COMBO_BOX, GtkComboBox)
typedef struct _GimpIntComboBoxPrivate GimpIntComboBoxPrivate;
typedef struct _GimpIntComboBoxClass GimpIntComboBoxClass;
struct _GimpIntComboBox
{
GtkComboBox parent_instance;
GimpIntComboBoxPrivate *priv;
};
struct _GimpIntComboBoxClass
{
GtkComboBoxClass parent_class;
@ -72,9 +58,6 @@ typedef gboolean (* GimpIntSensitivityFunc) (gint value,
gpointer data);
GType gimp_int_combo_box_get_type (void) G_GNUC_CONST;
GtkWidget * gimp_int_combo_box_new (const gchar *first_label,
gint first_value,
...) G_GNUC_NULL_TERMINATED;

File diff suppressed because it is too large Load Diff

View File

@ -27,41 +27,9 @@ G_BEGIN_DECLS
#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))
#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))
G_DECLARE_FINAL_TYPE (GimpPreviewArea, gimp_preview_area, GIMP, PREVIEW_AREA, GtkDrawingArea)
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);
void gimp_preview_area_draw (GimpPreviewArea *area,

View File

@ -55,10 +55,10 @@
#define MAX_DIGITS 20
struct _GimpSpinButtonPrivate
typedef struct _GimpSpinButtonPrivate
{
gboolean changed;
};
} GimpSpinButtonPrivate;
/* local function prototypes */
@ -105,8 +105,6 @@ gimp_spin_button_class_init (GimpSpinButtonClass *klass)
static void
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_CALLBACK (gimp_spin_button_changed),
NULL);
@ -209,8 +207,11 @@ gimp_spin_button_focus_in (GtkWidget *widget,
GdkEventFocus *event)
{
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);
}
@ -220,17 +221,20 @@ gimp_spin_button_focus_out (GtkWidget *widget,
GdkEventFocus *event)
{
GimpSpinButton *spin_button = GIMP_SPIN_BUTTON (widget);
GimpSpinButtonPrivate *priv;
gboolean editable;
gboolean result;
priv = gimp_spin_button_get_instance_private (spin_button);
editable = gtk_editable_get_editable (GTK_EDITABLE (widget));
if (! spin_button->priv->changed)
if (! priv->changed)
gtk_editable_set_editable (GTK_EDITABLE (widget), FALSE);
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);
return result;
@ -286,8 +290,11 @@ gimp_spin_button_changed (GtkEditable *editable,
gpointer data)
{
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

@ -32,23 +32,9 @@ G_BEGIN_DECLS
#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))
#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))
G_DECLARE_DERIVABLE_TYPE (GimpSpinButton, gimp_spin_button, GIMP, SPIN_BUTTON, GtkSpinButton)
typedef struct _GimpSpinButtonPrivate GimpSpinButtonPrivate;
typedef struct _GimpSpinButtonClass GimpSpinButtonClass;
struct _GimpSpinButton
{
GtkSpinButton parent_instance;
GimpSpinButtonPrivate *priv;
};
struct _GimpSpinButtonClass
{
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,
gdouble climb_rate,
guint digits);

View File

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

View File

@ -31,29 +31,9 @@ G_BEGIN_DECLS
#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))
#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))
G_DECLARE_FINAL_TYPE (GimpSpinScale, gimp_spin_scale, GIMP, SPIN_SCALE, GimpSpinButton)
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,
const gchar *label,
gint digits);

View File

@ -51,7 +51,7 @@ enum
};
struct _GimpStringComboBoxPrivate
typedef struct _GimpStringComboBoxPrivate
{
gint id_column;
gint label_column;
@ -60,9 +60,7 @@ struct _GimpStringComboBoxPrivate
GimpStringSensitivityFunc sensitivity_func;
gpointer sensitivity_data;
GDestroyNotify sensitivity_destroy;
};
#define GET_PRIVATE(obj) (((GimpStringComboBox *) (obj))->priv)
} GimpStringComboBoxPrivate;
static void gimp_string_combo_box_constructed (GObject *object);
@ -170,13 +168,13 @@ gimp_string_combo_box_class_init (GimpStringComboBoxClass *klass)
static void
gimp_string_combo_box_init (GimpStringComboBox *combo_box)
{
combo_box->priv = gimp_string_combo_box_get_instance_private (combo_box);
}
static void
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;
G_OBJECT_CLASS (parent_class)->constructed (object);
@ -205,7 +203,8 @@ gimp_string_combo_box_set_property (GObject *object,
const GValue *value,
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)
{
@ -238,7 +237,8 @@ gimp_string_combo_box_get_property (GObject *object,
GValue *value,
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)
{
@ -351,8 +351,12 @@ gboolean
gimp_string_combo_box_set_active (GimpStringComboBox *combo_box,
const gchar *id)
{
GimpStringComboBoxPrivate *priv;
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)
{
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));
column = GET_PRIVATE (combo_box)->id_column;
column = priv->id_column;
if (gimp_string_model_lookup (model, column, id, &iter))
{
@ -395,16 +399,19 @@ gchar *
gimp_string_combo_box_get_active (GimpStringComboBox *combo_box)
{
GtkTreeIter iter;
GimpStringComboBoxPrivate *priv;
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))
{
GtkTreeModel *model = gtk_combo_box_get_model (GTK_COMBO_BOX (combo_box));
gchar *value;
gint column;
column = GET_PRIVATE (combo_box)->id_column;
column = priv->id_column;
gtk_tree_model_get (model, &iter,
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));
priv = GET_PRIVATE (combo_box);
priv = gimp_string_combo_box_get_instance_private (combo_box);
if (priv->sensitivity_destroy)
{

View File

@ -39,22 +39,7 @@ typedef gboolean (* GimpStringSensitivityFunc) (const gchar *id,
#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))
#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;
};
G_DECLARE_DERIVABLE_TYPE (GimpStringComboBox, gimp_string_combo_box, GIMP, STRING_COMBO_BOX, GtkComboBox)
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,
gint id_column,
gint label_column);