mirror of https://github.com/GNOME/gimp.git
libgimpwidgets: More widgets are now FINAL types
This commit is contained in:
parent
0b72b028e8
commit
bd23d5a926
|
@ -56,11 +56,13 @@ enum
|
|||
static GParamSpec *object_props[N_PROPS] = { NULL, };
|
||||
|
||||
|
||||
typedef struct _GimpLabelColorPrivate
|
||||
struct _GimpLabelColor
|
||||
{
|
||||
GtkWidget *area;
|
||||
gboolean editable;
|
||||
} GimpLabelColorPrivate;
|
||||
GimpLabeled parent_instance;
|
||||
|
||||
GtkWidget *area;
|
||||
gboolean editable;
|
||||
};
|
||||
|
||||
static void gimp_label_color_constructed (GObject *object);
|
||||
static void gimp_label_color_set_property (GObject *object,
|
||||
|
@ -79,7 +81,7 @@ static GtkWidget * gimp_label_color_populate (GimpLabeled *color,
|
|||
gint *height);
|
||||
|
||||
|
||||
G_DEFINE_TYPE_WITH_PRIVATE (GimpLabelColor, gimp_label_color, GIMP_TYPE_LABELED)
|
||||
G_DEFINE_TYPE (GimpLabelColor, gimp_label_color, GIMP_TYPE_LABELED)
|
||||
|
||||
#define parent_class gimp_label_color_parent_class
|
||||
|
||||
|
@ -95,7 +97,7 @@ gimp_label_color_class_init (GimpLabelColorClass *klass)
|
|||
g_signal_new ("value-changed",
|
||||
G_TYPE_FROM_CLASS (klass),
|
||||
G_SIGNAL_RUN_FIRST,
|
||||
G_STRUCT_OFFSET (GimpLabelColorClass, value_changed),
|
||||
0,
|
||||
NULL, NULL, NULL,
|
||||
G_TYPE_NONE, 0);
|
||||
|
||||
|
@ -139,17 +141,16 @@ gimp_label_color_class_init (GimpLabelColorClass *klass)
|
|||
static void
|
||||
gimp_label_color_init (GimpLabelColor *color)
|
||||
{
|
||||
GimpLabelColorPrivate *priv = gimp_label_color_get_instance_private (color);
|
||||
GeglColor *black = gegl_color_new ("black");
|
||||
GeglColor *black = gegl_color_new ("black");
|
||||
|
||||
priv->editable = FALSE;
|
||||
priv->area = gimp_color_area_new (black, GIMP_COLOR_AREA_SMALL_CHECKS,
|
||||
color->editable = FALSE;
|
||||
color->area = gimp_color_area_new (black, GIMP_COLOR_AREA_SMALL_CHECKS,
|
||||
GDK_BUTTON1_MASK | GDK_BUTTON2_MASK);
|
||||
|
||||
/* Typically for a labelled color area, a small square next to your
|
||||
* label is probably what you want to display.
|
||||
*/
|
||||
gtk_widget_set_size_request (priv->area, 20, 20);
|
||||
gtk_widget_set_size_request (color->area, 20, 20);
|
||||
|
||||
g_object_unref (black);
|
||||
}
|
||||
|
@ -157,8 +158,7 @@ gimp_label_color_init (GimpLabelColor *color)
|
|||
static void
|
||||
gimp_label_color_constructed (GObject *object)
|
||||
{
|
||||
GimpLabelColor *color = GIMP_LABEL_COLOR (object);
|
||||
GimpLabelColorPrivate *priv = gimp_label_color_get_instance_private (color);
|
||||
GimpLabelColor *color = GIMP_LABEL_COLOR (object);
|
||||
|
||||
G_OBJECT_CLASS (parent_class)->constructed (object);
|
||||
|
||||
|
@ -166,8 +166,8 @@ gimp_label_color_constructed (GObject *object)
|
|||
* will allow config object to bind the "value" property of this
|
||||
* widget, and therefore be updated automatically.
|
||||
*/
|
||||
g_object_bind_property (G_OBJECT (priv->area), "color",
|
||||
G_OBJECT (color), "value",
|
||||
g_object_bind_property (G_OBJECT (color->area), "color",
|
||||
G_OBJECT (color), "value",
|
||||
G_BINDING_BIDIRECTIONAL | G_BINDING_SYNC_CREATE);
|
||||
}
|
||||
|
||||
|
@ -177,8 +177,7 @@ gimp_label_color_set_property (GObject *object,
|
|||
const GValue *value,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
GimpLabelColor *lcolor = GIMP_LABEL_COLOR (object);
|
||||
GimpLabelColorPrivate *priv = gimp_label_color_get_instance_private (lcolor);
|
||||
GimpLabelColor *lcolor = GIMP_LABEL_COLOR (object);
|
||||
|
||||
switch (property_id)
|
||||
{
|
||||
|
@ -189,7 +188,7 @@ gimp_label_color_set_property (GObject *object,
|
|||
|
||||
new_color = g_value_get_object (value);
|
||||
|
||||
g_object_get (priv->area,
|
||||
g_object_get (lcolor->area,
|
||||
"color", &color,
|
||||
NULL);
|
||||
|
||||
|
@ -198,14 +197,14 @@ gimp_label_color_set_property (GObject *object,
|
|||
*/
|
||||
if (! gimp_color_is_perceptually_identical (color, new_color))
|
||||
{
|
||||
g_object_set (priv->area, "color", new_color, NULL);
|
||||
g_object_set (lcolor->area, "color", new_color, NULL);
|
||||
g_signal_emit (object, gimp_label_color_signals[VALUE_CHANGED], 0);
|
||||
}
|
||||
g_object_unref (color);
|
||||
}
|
||||
break;
|
||||
case PROP_EDITABLE:
|
||||
if (priv->editable != g_value_get_boolean (value))
|
||||
if (lcolor->editable != g_value_get_boolean (value))
|
||||
{
|
||||
const gchar *dialog_title;
|
||||
GimpLabeled *labeled;
|
||||
|
@ -220,34 +219,34 @@ gimp_label_color_set_property (GObject *object,
|
|||
*/
|
||||
dialog_title = gtk_label_get_text (GTK_LABEL (gimp_labeled_get_label (labeled)));
|
||||
|
||||
attached = (gtk_widget_get_parent (priv->area) != NULL);
|
||||
g_object_get (priv->area,
|
||||
attached = (gtk_widget_get_parent (lcolor->area) != NULL);
|
||||
g_object_get (lcolor->area,
|
||||
"type", &type,
|
||||
"color", &color,
|
||||
NULL);
|
||||
|
||||
gtk_widget_destroy (priv->area);
|
||||
gtk_widget_destroy (lcolor->area);
|
||||
|
||||
priv->editable = g_value_get_boolean (value);
|
||||
lcolor->editable = g_value_get_boolean (value);
|
||||
|
||||
if (priv->editable)
|
||||
priv->area = gimp_color_button_new (dialog_title,
|
||||
if (lcolor->editable)
|
||||
lcolor->area = gimp_color_button_new (dialog_title,
|
||||
20, 20, color, type);
|
||||
else
|
||||
priv->area = gimp_color_area_new (color, type,
|
||||
lcolor->area = gimp_color_area_new (color, type,
|
||||
GDK_BUTTON1_MASK | GDK_BUTTON2_MASK);
|
||||
g_object_unref (color);
|
||||
|
||||
gtk_widget_set_size_request (priv->area, 20, 20);
|
||||
g_object_bind_property (G_OBJECT (priv->area), "color",
|
||||
gtk_widget_set_size_request (lcolor->area, 20, 20);
|
||||
g_object_bind_property (G_OBJECT (lcolor->area), "color",
|
||||
G_OBJECT (lcolor), "value",
|
||||
G_BINDING_BIDIRECTIONAL | G_BINDING_SYNC_CREATE);
|
||||
|
||||
if (attached)
|
||||
{
|
||||
gtk_grid_attach (GTK_GRID (lcolor), priv->area, 1, 0, 1, 1);
|
||||
gtk_widget_show (priv->area);
|
||||
g_signal_emit_by_name (object, "mnemonic-widget-changed", priv->area);
|
||||
gtk_grid_attach (GTK_GRID (lcolor), lcolor->area, 1, 0, 1, 1);
|
||||
gtk_widget_show (lcolor->area);
|
||||
g_signal_emit_by_name (object, "mnemonic-widget-changed", lcolor->area);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
@ -264,8 +263,7 @@ gimp_label_color_get_property (GObject *object,
|
|||
GValue *value,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
GimpLabelColor *color = GIMP_LABEL_COLOR (object);
|
||||
GimpLabelColorPrivate *priv = gimp_label_color_get_instance_private (color);
|
||||
GimpLabelColor *lcolor = GIMP_LABEL_COLOR (object);
|
||||
|
||||
switch (property_id)
|
||||
{
|
||||
|
@ -273,14 +271,14 @@ gimp_label_color_get_property (GObject *object,
|
|||
{
|
||||
GeglColor *color;
|
||||
|
||||
g_object_get (priv->area,
|
||||
g_object_get (lcolor->area,
|
||||
"color", &color,
|
||||
NULL);
|
||||
g_value_take_object (value, color);
|
||||
}
|
||||
break;
|
||||
case PROP_EDITABLE:
|
||||
g_value_set_boolean (value, priv->editable);
|
||||
g_value_set_boolean (value, lcolor->editable);
|
||||
break;
|
||||
|
||||
|
||||
|
@ -297,16 +295,15 @@ gimp_label_color_populate (GimpLabeled *labeled,
|
|||
gint *width,
|
||||
gint *height)
|
||||
{
|
||||
GimpLabelColor *color = GIMP_LABEL_COLOR (labeled);
|
||||
GimpLabelColorPrivate *priv = gimp_label_color_get_instance_private (color);
|
||||
GimpLabelColor *color = GIMP_LABEL_COLOR (labeled);
|
||||
|
||||
gtk_grid_attach (GTK_GRID (color), priv->area, 1, 0, 1, 1);
|
||||
gtk_grid_attach (GTK_GRID (color), color->area, 1, 0, 1, 1);
|
||||
/* Make sure the label and color won't be glued next to each other's. */
|
||||
gtk_grid_set_column_spacing (GTK_GRID (color),
|
||||
4 * gtk_widget_get_scale_factor (GTK_WIDGET (color)));
|
||||
gtk_widget_show (priv->area);
|
||||
gtk_widget_show (color->area);
|
||||
|
||||
return priv->area;
|
||||
return color->area;
|
||||
}
|
||||
|
||||
|
||||
|
@ -379,13 +376,12 @@ gimp_label_color_set_value (GimpLabelColor *color,
|
|||
GeglColor *
|
||||
gimp_label_color_get_value (GimpLabelColor *color)
|
||||
{
|
||||
GimpLabelColorPrivate *priv = gimp_label_color_get_instance_private (color);
|
||||
GeglColor *value = NULL;
|
||||
GeglColor *retval;
|
||||
GeglColor *value = NULL;
|
||||
GeglColor *retval;
|
||||
|
||||
g_return_val_if_fail (GIMP_IS_LABEL_COLOR (color), NULL);
|
||||
|
||||
g_object_get (priv->area,
|
||||
g_object_get (color->area,
|
||||
"color", &value,
|
||||
NULL);
|
||||
retval = gegl_color_duplicate (value);
|
||||
|
@ -421,13 +417,9 @@ gimp_label_color_set_editable (GimpLabelColor *color,
|
|||
gboolean
|
||||
gimp_label_color_is_editable (GimpLabelColor *color)
|
||||
{
|
||||
GimpLabelColorPrivate *priv = gimp_label_color_get_instance_private (color);
|
||||
|
||||
g_return_val_if_fail (GIMP_IS_LABEL_COLOR (color), FALSE);
|
||||
|
||||
priv = gimp_label_color_get_instance_private (color);
|
||||
|
||||
return GIMP_IS_COLOR_SELECT (priv->area);
|
||||
return GIMP_IS_COLOR_SELECT (color->area);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -443,9 +435,7 @@ gimp_label_color_is_editable (GimpLabelColor *color)
|
|||
GtkWidget *
|
||||
gimp_label_color_get_color_widget (GimpLabelColor *color)
|
||||
{
|
||||
GimpLabelColorPrivate *priv = gimp_label_color_get_instance_private (color);
|
||||
|
||||
g_return_val_if_fail (GIMP_IS_LABEL_COLOR (color), NULL);
|
||||
|
||||
return priv->area;
|
||||
return color->area;
|
||||
}
|
||||
|
|
|
@ -31,25 +31,8 @@
|
|||
G_BEGIN_DECLS
|
||||
|
||||
#define GIMP_TYPE_LABEL_COLOR (gimp_label_color_get_type ())
|
||||
G_DECLARE_DERIVABLE_TYPE (GimpLabelColor, gimp_label_color, GIMP, LABEL_COLOR, GimpLabeled)
|
||||
G_DECLARE_FINAL_TYPE (GimpLabelColor, gimp_label_color, GIMP, LABEL_COLOR, GimpLabeled)
|
||||
|
||||
struct _GimpLabelColorClass
|
||||
{
|
||||
GimpLabeledClass parent_class;
|
||||
|
||||
/* Signals */
|
||||
void (* value_changed) (GimpLabelColor *color);
|
||||
|
||||
/* 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);
|
||||
};
|
||||
|
||||
GtkWidget * gimp_label_color_new (const gchar *label,
|
||||
GeglColor *color,
|
||||
|
|
|
@ -51,10 +51,12 @@ enum
|
|||
PROP_VALUE,
|
||||
};
|
||||
|
||||
typedef struct _GimpLabelEntryPrivate
|
||||
struct _GimpLabelEntry
|
||||
{
|
||||
GtkWidget *entry;
|
||||
} GimpLabelEntryPrivate;
|
||||
GimpLabeled parent_class;
|
||||
|
||||
GtkWidget *entry;
|
||||
};
|
||||
|
||||
static void gimp_label_entry_constructed (GObject *object);
|
||||
static void gimp_label_entry_set_property (GObject *object,
|
||||
|
@ -72,7 +74,7 @@ static GtkWidget * gimp_label_entry_populate (GimpLabeled *entry,
|
|||
gint *width,
|
||||
gint *height);
|
||||
|
||||
G_DEFINE_TYPE_WITH_PRIVATE (GimpLabelEntry, gimp_label_entry, GIMP_TYPE_LABELED)
|
||||
G_DEFINE_TYPE (GimpLabelEntry, gimp_label_entry, GIMP_TYPE_LABELED)
|
||||
|
||||
#define parent_class gimp_label_entry_parent_class
|
||||
|
||||
|
@ -88,7 +90,7 @@ gimp_label_entry_class_init (GimpLabelEntryClass *klass)
|
|||
g_signal_new ("value-changed",
|
||||
G_TYPE_FROM_CLASS (klass),
|
||||
G_SIGNAL_RUN_FIRST,
|
||||
G_STRUCT_OFFSET (GimpLabelEntryClass, value_changed),
|
||||
0,
|
||||
NULL, NULL, NULL,
|
||||
G_TYPE_NONE, 0);
|
||||
|
||||
|
@ -116,17 +118,14 @@ gimp_label_entry_class_init (GimpLabelEntryClass *klass)
|
|||
static void
|
||||
gimp_label_entry_init (GimpLabelEntry *entry)
|
||||
{
|
||||
GimpLabelEntryPrivate *priv = gimp_label_entry_get_instance_private (entry);
|
||||
|
||||
priv->entry = gtk_entry_new ();
|
||||
entry->entry = gtk_entry_new ();
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_label_entry_constructed (GObject *object)
|
||||
{
|
||||
GimpLabelEntry *entry = GIMP_LABEL_ENTRY (object);
|
||||
GimpLabelEntryPrivate *priv = gimp_label_entry_get_instance_private (entry);
|
||||
GtkEntryBuffer *buffer = gtk_entry_get_buffer (GTK_ENTRY (priv->entry));
|
||||
GimpLabelEntry *entry = GIMP_LABEL_ENTRY (object);
|
||||
GtkEntryBuffer *buffer = gtk_entry_get_buffer (GTK_ENTRY (entry->entry));
|
||||
|
||||
G_OBJECT_CLASS (parent_class)->constructed (object);
|
||||
|
||||
|
@ -145,14 +144,13 @@ gimp_label_entry_set_property (GObject *object,
|
|||
const GValue *value,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
GimpLabelEntry *entry = GIMP_LABEL_ENTRY (object);
|
||||
GimpLabelEntryPrivate *priv = gimp_label_entry_get_instance_private (entry);
|
||||
GimpLabelEntry *entry = GIMP_LABEL_ENTRY (object);
|
||||
|
||||
switch (property_id)
|
||||
{
|
||||
case PROP_VALUE:
|
||||
{
|
||||
GtkEntryBuffer *buffer = gtk_entry_get_buffer (GTK_ENTRY (priv->entry));
|
||||
GtkEntryBuffer *buffer = gtk_entry_get_buffer (GTK_ENTRY (entry->entry));
|
||||
|
||||
/* Avoid looping forever since we have bound this widget's
|
||||
* "value" property with the entry button "value" property.
|
||||
|
@ -177,14 +175,13 @@ gimp_label_entry_get_property (GObject *object,
|
|||
GValue *value,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
GimpLabelEntry *entry = GIMP_LABEL_ENTRY (object);
|
||||
GimpLabelEntryPrivate *priv = gimp_label_entry_get_instance_private (entry);
|
||||
GimpLabelEntry *entry = GIMP_LABEL_ENTRY (object);
|
||||
|
||||
switch (property_id)
|
||||
{
|
||||
case PROP_VALUE:
|
||||
{
|
||||
GtkEntryBuffer *buffer = gtk_entry_get_buffer (GTK_ENTRY (priv->entry));
|
||||
GtkEntryBuffer *buffer = gtk_entry_get_buffer (GTK_ENTRY (entry->entry));
|
||||
|
||||
g_value_set_string (value, gtk_entry_buffer_get_text (buffer));
|
||||
}
|
||||
|
@ -203,16 +200,15 @@ gimp_label_entry_populate (GimpLabeled *labeled,
|
|||
gint *width,
|
||||
gint *height)
|
||||
{
|
||||
GimpLabelEntry *entry = GIMP_LABEL_ENTRY (labeled);
|
||||
GimpLabelEntryPrivate *priv = gimp_label_entry_get_instance_private (entry);
|
||||
GimpLabelEntry *entry = GIMP_LABEL_ENTRY (labeled);
|
||||
|
||||
gtk_grid_attach (GTK_GRID (entry), priv->entry, 1, 0, 1, 1);
|
||||
gtk_grid_attach (GTK_GRID (entry), entry->entry, 1, 0, 1, 1);
|
||||
/* Make sure the label and entry won't be glued next to each other's. */
|
||||
gtk_grid_set_column_spacing (GTK_GRID (entry),
|
||||
4 * gtk_widget_get_scale_factor (GTK_WIDGET (entry)));
|
||||
gtk_widget_show (priv->entry);
|
||||
gtk_widget_show (entry->entry);
|
||||
|
||||
return priv->entry;
|
||||
return entry->entry;
|
||||
}
|
||||
|
||||
|
||||
|
@ -267,12 +263,11 @@ gimp_label_entry_set_value (GimpLabelEntry *entry,
|
|||
const gchar *
|
||||
gimp_label_entry_get_value (GimpLabelEntry *entry)
|
||||
{
|
||||
GimpLabelEntryPrivate *priv = gimp_label_entry_get_instance_private (entry);
|
||||
GtkEntryBuffer *buffer;
|
||||
GtkEntryBuffer *buffer;
|
||||
|
||||
g_return_val_if_fail (GIMP_IS_LABEL_ENTRY (entry), NULL);
|
||||
|
||||
buffer = gtk_entry_get_buffer (GTK_ENTRY (priv->entry));
|
||||
buffer = gtk_entry_get_buffer (GTK_ENTRY (entry->entry));
|
||||
|
||||
return gtk_entry_buffer_get_text (buffer);
|
||||
}
|
||||
|
@ -288,9 +283,7 @@ gimp_label_entry_get_value (GimpLabelEntry *entry)
|
|||
GtkWidget *
|
||||
gimp_label_entry_get_entry (GimpLabelEntry *entry)
|
||||
{
|
||||
GimpLabelEntryPrivate *priv = gimp_label_entry_get_instance_private (entry);
|
||||
|
||||
g_return_val_if_fail (GIMP_IS_LABEL_ENTRY (entry), NULL);
|
||||
|
||||
return priv->entry;
|
||||
return entry->entry;
|
||||
}
|
||||
|
|
|
@ -31,25 +31,8 @@
|
|||
G_BEGIN_DECLS
|
||||
|
||||
#define GIMP_TYPE_LABEL_ENTRY (gimp_label_entry_get_type ())
|
||||
G_DECLARE_DERIVABLE_TYPE (GimpLabelEntry, gimp_label_entry, GIMP, LABEL_ENTRY, GimpLabeled)
|
||||
G_DECLARE_FINAL_TYPE (GimpLabelEntry, gimp_label_entry, GIMP, LABEL_ENTRY, GimpLabeled)
|
||||
|
||||
struct _GimpLabelEntryClass
|
||||
{
|
||||
GimpLabeledClass parent_class;
|
||||
|
||||
/* Signals */
|
||||
void (* value_changed) (GimpLabelEntry *entry);
|
||||
|
||||
/* 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);
|
||||
};
|
||||
|
||||
GtkWidget * gimp_label_entry_new (const gchar *label);
|
||||
|
||||
|
|
|
@ -53,13 +53,13 @@ enum
|
|||
PROP_WIDGET,
|
||||
};
|
||||
|
||||
typedef struct _GimpLabelIntWidgetPrivate
|
||||
struct _GimpLabelIntWidget
|
||||
{
|
||||
GimpLabeled parent_instance;
|
||||
|
||||
GtkWidget *widget;
|
||||
gint value;
|
||||
} GimpLabelIntWidgetPrivate;
|
||||
};
|
||||
|
||||
static void gimp_label_int_widget_constructed (GObject *object);
|
||||
static void gimp_label_int_widget_set_property (GObject *object,
|
||||
|
@ -77,7 +77,7 @@ static GtkWidget * gimp_label_int_widget_populate (GimpLabeled *widge
|
|||
gint *width,
|
||||
gint *height);
|
||||
|
||||
G_DEFINE_TYPE_WITH_PRIVATE (GimpLabelIntWidget, gimp_label_int_widget, GIMP_TYPE_LABELED)
|
||||
G_DEFINE_TYPE (GimpLabelIntWidget, gimp_label_int_widget, GIMP_TYPE_LABELED)
|
||||
|
||||
#define parent_class gimp_label_int_widget_parent_class
|
||||
|
||||
|
@ -93,7 +93,7 @@ gimp_label_int_widget_class_init (GimpLabelIntWidgetClass *klass)
|
|||
g_signal_new ("value-changed",
|
||||
G_TYPE_FROM_CLASS (klass),
|
||||
G_SIGNAL_RUN_FIRST,
|
||||
G_STRUCT_OFFSET (GimpLabelIntWidgetClass, value_changed),
|
||||
0,
|
||||
NULL, NULL, NULL,
|
||||
G_TYPE_NONE, 0);
|
||||
|
||||
|
@ -139,8 +139,7 @@ gimp_label_int_widget_init (GimpLabelIntWidget *widget)
|
|||
static void
|
||||
gimp_label_int_widget_constructed (GObject *object)
|
||||
{
|
||||
GimpLabelIntWidget *widget = GIMP_LABEL_INT_WIDGET (object);
|
||||
GimpLabelIntWidgetPrivate *priv = gimp_label_int_widget_get_instance_private (widget);
|
||||
GimpLabelIntWidget *widget = GIMP_LABEL_INT_WIDGET (object);
|
||||
|
||||
G_OBJECT_CLASS (parent_class)->constructed (object);
|
||||
|
||||
|
@ -151,8 +150,8 @@ gimp_label_int_widget_constructed (GObject *object)
|
|||
* will allow config object to bind the "value" property of this
|
||||
* widget, and therefore be updated automatically.
|
||||
*/
|
||||
g_object_bind_property (G_OBJECT (priv->widget), "value",
|
||||
object, "value",
|
||||
g_object_bind_property (G_OBJECT (widget->widget), "value",
|
||||
object, "value",
|
||||
G_BINDING_BIDIRECTIONAL |
|
||||
G_BINDING_SYNC_CREATE);
|
||||
}
|
||||
|
@ -164,16 +163,15 @@ gimp_label_int_widget_set_property (GObject *object,
|
|||
GParamSpec *pspec)
|
||||
{
|
||||
GimpLabelIntWidget *widget = GIMP_LABEL_INT_WIDGET (object);
|
||||
GimpLabelIntWidgetPrivate *priv = gimp_label_int_widget_get_instance_private (widget);
|
||||
|
||||
switch (property_id)
|
||||
{
|
||||
case PROP_VALUE:
|
||||
priv->value = g_value_get_int (value);
|
||||
widget->value = g_value_get_int (value);
|
||||
g_signal_emit (object, gimp_label_int_widget_signals[VALUE_CHANGED], 0);
|
||||
break;
|
||||
case PROP_WIDGET:
|
||||
priv->widget = g_value_get_object (value);
|
||||
widget->widget = g_value_get_object (value);
|
||||
break;
|
||||
|
||||
default:
|
||||
|
@ -188,16 +186,15 @@ gimp_label_int_widget_get_property (GObject *object,
|
|||
GValue *value,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
GimpLabelIntWidget *widget = GIMP_LABEL_INT_WIDGET (object);
|
||||
GimpLabelIntWidgetPrivate *priv = gimp_label_int_widget_get_instance_private (widget);
|
||||
GimpLabelIntWidget *widget = GIMP_LABEL_INT_WIDGET (object);
|
||||
|
||||
switch (property_id)
|
||||
{
|
||||
case PROP_VALUE:
|
||||
g_value_set_int (value, priv->value);
|
||||
g_value_set_int (value, widget->value);
|
||||
break;
|
||||
case PROP_WIDGET:
|
||||
g_value_set_object (value, priv->widget);
|
||||
g_value_set_object (value, widget->widget);
|
||||
break;
|
||||
|
||||
default:
|
||||
|
@ -213,13 +210,12 @@ gimp_label_int_widget_populate (GimpLabeled *labeled,
|
|||
gint *width,
|
||||
gint *height)
|
||||
{
|
||||
GimpLabelIntWidget *widget = GIMP_LABEL_INT_WIDGET (labeled);
|
||||
GimpLabelIntWidgetPrivate *priv = gimp_label_int_widget_get_instance_private (widget);
|
||||
GimpLabelIntWidget *widget = GIMP_LABEL_INT_WIDGET (labeled);
|
||||
|
||||
gtk_grid_attach (GTK_GRID (widget), priv->widget, 1, 0, 1, 1);
|
||||
gtk_widget_show (priv->widget);
|
||||
gtk_grid_attach (GTK_GRID (widget), widget->widget, 1, 0, 1, 1);
|
||||
gtk_widget_show (widget->widget);
|
||||
|
||||
return priv->widget;
|
||||
return widget->widget;
|
||||
}
|
||||
|
||||
/* Public Functions */
|
||||
|
@ -263,11 +259,7 @@ gimp_label_int_widget_new (const gchar *text,
|
|||
GtkWidget *
|
||||
gimp_label_int_widget_get_widget (GimpLabelIntWidget *widget)
|
||||
{
|
||||
GimpLabelIntWidgetPrivate *priv;
|
||||
|
||||
g_return_val_if_fail (GIMP_IS_LABEL_INT_WIDGET (widget), NULL);
|
||||
|
||||
priv = gimp_label_int_widget_get_instance_private (widget);
|
||||
|
||||
return priv->widget;
|
||||
return widget->widget;
|
||||
}
|
||||
|
|
|
@ -31,25 +31,8 @@
|
|||
G_BEGIN_DECLS
|
||||
|
||||
#define GIMP_TYPE_LABEL_INT_WIDGET (gimp_label_int_widget_get_type ())
|
||||
G_DECLARE_DERIVABLE_TYPE (GimpLabelIntWidget, gimp_label_int_widget, GIMP, LABEL_INT_WIDGET, GimpLabeled)
|
||||
G_DECLARE_FINAL_TYPE (GimpLabelIntWidget, gimp_label_int_widget, GIMP, LABEL_INT_WIDGET, GimpLabeled)
|
||||
|
||||
struct _GimpLabelIntWidgetClass
|
||||
{
|
||||
GimpLabeledClass parent_class;
|
||||
|
||||
/* Signals */
|
||||
void (* value_changed) (GtkWidget *int_widget);
|
||||
|
||||
/* 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);
|
||||
};
|
||||
|
||||
GtkWidget * gimp_label_int_widget_new (const gchar *text,
|
||||
GtkWidget *widget);
|
||||
|
|
|
@ -53,13 +53,13 @@ enum
|
|||
PROP_WIDGET,
|
||||
};
|
||||
|
||||
typedef struct _GimpLabelStringWidgetPrivate
|
||||
struct _GimpLabelStringWidget
|
||||
{
|
||||
GimpLabeled parent_instance;
|
||||
|
||||
GtkWidget *widget;
|
||||
gchar *value;
|
||||
} GimpLabelStringWidgetPrivate;
|
||||
};
|
||||
|
||||
static void gimp_label_string_widget_constructed (GObject *object);
|
||||
static void gimp_label_string_widget_finalize (GObject *object);
|
||||
|
@ -78,7 +78,7 @@ static GtkWidget * gimp_label_string_widget_populate (GimpLabeled *wi
|
|||
gint *width,
|
||||
gint *height);
|
||||
|
||||
G_DEFINE_TYPE_WITH_PRIVATE (GimpLabelStringWidget, gimp_label_string_widget, GIMP_TYPE_LABELED)
|
||||
G_DEFINE_TYPE (GimpLabelStringWidget, gimp_label_string_widget, GIMP_TYPE_LABELED)
|
||||
|
||||
#define parent_class gimp_label_string_widget_parent_class
|
||||
|
||||
|
@ -94,7 +94,7 @@ gimp_label_string_widget_class_init (GimpLabelStringWidgetClass *klass)
|
|||
g_signal_new ("value-changed",
|
||||
G_TYPE_FROM_CLASS (klass),
|
||||
G_SIGNAL_RUN_FIRST,
|
||||
G_STRUCT_OFFSET (GimpLabelStringWidgetClass, value_changed),
|
||||
0,
|
||||
NULL, NULL, NULL,
|
||||
G_TYPE_NONE, 0);
|
||||
|
||||
|
@ -141,8 +141,7 @@ gimp_label_string_widget_init (GimpLabelStringWidget *widget)
|
|||
static void
|
||||
gimp_label_string_widget_constructed (GObject *object)
|
||||
{
|
||||
GimpLabelStringWidget *widget = GIMP_LABEL_STRING_WIDGET (object);
|
||||
GimpLabelStringWidgetPrivate *priv = gimp_label_string_widget_get_instance_private (widget);
|
||||
GimpLabelStringWidget *widget = GIMP_LABEL_STRING_WIDGET (object);
|
||||
|
||||
G_OBJECT_CLASS (parent_class)->constructed (object);
|
||||
|
||||
|
@ -153,7 +152,7 @@ gimp_label_string_widget_constructed (GObject *object)
|
|||
* will allow config object to bind the "value" property of this
|
||||
* widget, and therefore be updated automatically.
|
||||
*/
|
||||
g_object_bind_property (G_OBJECT (priv->widget), "value",
|
||||
g_object_bind_property (G_OBJECT (widget->widget), "value",
|
||||
object, "value",
|
||||
G_BINDING_BIDIRECTIONAL |
|
||||
G_BINDING_SYNC_CREATE);
|
||||
|
@ -162,10 +161,9 @@ gimp_label_string_widget_constructed (GObject *object)
|
|||
static void
|
||||
gimp_label_string_widget_finalize (GObject *object)
|
||||
{
|
||||
GimpLabelStringWidget *widget = GIMP_LABEL_STRING_WIDGET (object);
|
||||
GimpLabelStringWidgetPrivate *priv = gimp_label_string_widget_get_instance_private (widget);
|
||||
GimpLabelStringWidget *widget = GIMP_LABEL_STRING_WIDGET (object);
|
||||
|
||||
g_free (priv->value);
|
||||
g_free (widget->value);
|
||||
|
||||
G_OBJECT_CLASS (parent_class)->finalize (object);
|
||||
}
|
||||
|
@ -176,21 +174,20 @@ gimp_label_string_widget_set_property (GObject *object,
|
|||
const GValue *value,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
GimpLabelStringWidget *widget = GIMP_LABEL_STRING_WIDGET (object);
|
||||
GimpLabelStringWidgetPrivate *priv = gimp_label_string_widget_get_instance_private (widget);
|
||||
GimpLabelStringWidget *widget = GIMP_LABEL_STRING_WIDGET (object);
|
||||
|
||||
switch (property_id)
|
||||
{
|
||||
case PROP_VALUE:
|
||||
if (g_strcmp0 (priv->value, g_value_get_string (value)) != 0)
|
||||
if (g_strcmp0 (widget->value, g_value_get_string (value)) != 0)
|
||||
{
|
||||
g_free (priv->value);
|
||||
priv->value = g_value_dup_string (value);
|
||||
g_free (widget->value);
|
||||
widget->value = g_value_dup_string (value);
|
||||
g_signal_emit (object, gimp_label_string_widget_signals[VALUE_CHANGED], 0);
|
||||
}
|
||||
break;
|
||||
case PROP_WIDGET:
|
||||
priv->widget = g_value_get_object (value);
|
||||
widget->widget = g_value_get_object (value);
|
||||
break;
|
||||
|
||||
default:
|
||||
|
@ -205,16 +202,15 @@ gimp_label_string_widget_get_property (GObject *object,
|
|||
GValue *value,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
GimpLabelStringWidget *widget = GIMP_LABEL_STRING_WIDGET (object);
|
||||
GimpLabelStringWidgetPrivate *priv = gimp_label_string_widget_get_instance_private (widget);
|
||||
GimpLabelStringWidget *widget = GIMP_LABEL_STRING_WIDGET (object);
|
||||
|
||||
switch (property_id)
|
||||
{
|
||||
case PROP_VALUE:
|
||||
g_value_set_string (value, priv->value);
|
||||
g_value_set_string (value, widget->value);
|
||||
break;
|
||||
case PROP_WIDGET:
|
||||
g_value_set_object (value, priv->widget);
|
||||
g_value_set_object (value, widget->widget);
|
||||
break;
|
||||
|
||||
default:
|
||||
|
@ -230,13 +226,12 @@ gimp_label_string_widget_populate (GimpLabeled *labeled,
|
|||
gint *width,
|
||||
gint *height)
|
||||
{
|
||||
GimpLabelStringWidget *widget = GIMP_LABEL_STRING_WIDGET (labeled);
|
||||
GimpLabelStringWidgetPrivate *priv = gimp_label_string_widget_get_instance_private (widget);
|
||||
GimpLabelStringWidget *widget = GIMP_LABEL_STRING_WIDGET (labeled);
|
||||
|
||||
gtk_grid_attach (GTK_GRID (widget), priv->widget, 1, 0, 1, 1);
|
||||
gtk_widget_show (priv->widget);
|
||||
gtk_grid_attach (GTK_GRID (widget), widget->widget, 1, 0, 1, 1);
|
||||
gtk_widget_show (widget->widget);
|
||||
|
||||
return priv->widget;
|
||||
return widget->widget;
|
||||
}
|
||||
|
||||
/* Public Functions */
|
||||
|
@ -281,11 +276,7 @@ gimp_label_string_widget_new (const gchar *text,
|
|||
GtkWidget *
|
||||
gimp_label_string_widget_get_widget (GimpLabelStringWidget *widget)
|
||||
{
|
||||
GimpLabelStringWidgetPrivate *priv;
|
||||
|
||||
g_return_val_if_fail (GIMP_IS_LABEL_STRING_WIDGET (widget), NULL);
|
||||
|
||||
priv = gimp_label_string_widget_get_instance_private (widget);
|
||||
|
||||
return priv->widget;
|
||||
return widget->widget;
|
||||
}
|
||||
|
|
|
@ -31,25 +31,8 @@
|
|||
G_BEGIN_DECLS
|
||||
|
||||
#define GIMP_TYPE_LABEL_STRING_WIDGET (gimp_label_string_widget_get_type ())
|
||||
G_DECLARE_DERIVABLE_TYPE (GimpLabelStringWidget, gimp_label_string_widget, GIMP, LABEL_STRING_WIDGET, GimpLabeled)
|
||||
G_DECLARE_FINAL_TYPE (GimpLabelStringWidget, gimp_label_string_widget, GIMP, LABEL_STRING_WIDGET, GimpLabeled)
|
||||
|
||||
struct _GimpLabelStringWidgetClass
|
||||
{
|
||||
GimpLabeledClass parent_class;
|
||||
|
||||
/* Signals */
|
||||
void (* value_changed) (GtkWidget *string_widget);
|
||||
|
||||
/* 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);
|
||||
};
|
||||
|
||||
GtkWidget * gimp_label_string_widget_new (const gchar *text,
|
||||
GtkWidget *widget);
|
||||
|
|
|
@ -51,8 +51,10 @@ enum
|
|||
};
|
||||
|
||||
|
||||
typedef struct _GimpMemsizeEntryPrivate
|
||||
struct _GimpMemsizeEntry
|
||||
{
|
||||
GtkBox parent_instance;
|
||||
|
||||
guint64 value;
|
||||
guint64 lower;
|
||||
guint64 upper;
|
||||
|
@ -63,7 +65,7 @@ typedef struct _GimpMemsizeEntryPrivate
|
|||
GtkAdjustment *adjustment;
|
||||
GtkWidget *spinbutton;
|
||||
GtkWidget *menu;
|
||||
} GimpMemsizeEntryPrivate;
|
||||
} ;
|
||||
|
||||
|
||||
static void gimp_memsize_entry_adj_callback (GtkAdjustment *adj,
|
||||
|
@ -74,7 +76,7 @@ static void gimp_memsize_entry_unit_callback (GtkWidget *widget,
|
|||
static guint64 gimp_memsize_entry_get_rounded_value (GimpMemsizeEntry *entry,
|
||||
guint64 value);
|
||||
|
||||
G_DEFINE_TYPE_WITH_PRIVATE (GimpMemsizeEntry, gimp_memsize_entry, GTK_TYPE_BOX)
|
||||
G_DEFINE_TYPE (GimpMemsizeEntry, gimp_memsize_entry, GTK_TYPE_BOX)
|
||||
|
||||
#define parent_class gimp_memsize_entry_parent_class
|
||||
|
||||
|
@ -84,13 +86,11 @@ static guint gimp_memsize_entry_signals[LAST_SIGNAL] = { 0 };
|
|||
static void
|
||||
gimp_memsize_entry_class_init (GimpMemsizeEntryClass *klass)
|
||||
{
|
||||
klass->value_changed = NULL;
|
||||
|
||||
gimp_memsize_entry_signals[VALUE_CHANGED] =
|
||||
g_signal_new ("value-changed",
|
||||
G_TYPE_FROM_CLASS (klass),
|
||||
G_SIGNAL_RUN_FIRST,
|
||||
G_STRUCT_OFFSET (GimpMemsizeEntryClass, value_changed),
|
||||
0,
|
||||
NULL, NULL, NULL,
|
||||
G_TYPE_NONE, 0);
|
||||
}
|
||||
|
@ -108,16 +108,13 @@ static void
|
|||
gimp_memsize_entry_adj_callback (GtkAdjustment *adj,
|
||||
GimpMemsizeEntry *entry)
|
||||
{
|
||||
GimpMemsizeEntryPrivate *private;
|
||||
guint64 size = gtk_adjustment_get_value (adj);
|
||||
guint64 size = gtk_adjustment_get_value (adj);
|
||||
|
||||
private = gimp_memsize_entry_get_instance_private (entry);
|
||||
|
||||
if (gimp_memsize_entry_get_rounded_value (entry, private->value) != size)
|
||||
if (gimp_memsize_entry_get_rounded_value (entry, entry->value) != size)
|
||||
/* Do not allow losing accuracy if the converted/displayed value
|
||||
* stays the same.
|
||||
*/
|
||||
private->value = size << private->shift;
|
||||
entry->value = size << entry->shift;
|
||||
|
||||
g_signal_emit (entry, gimp_memsize_entry_signals[VALUE_CHANGED], 0);
|
||||
}
|
||||
|
@ -126,10 +123,7 @@ static void
|
|||
gimp_memsize_entry_unit_callback (GtkWidget *widget,
|
||||
GimpMemsizeEntry *entry)
|
||||
{
|
||||
GimpMemsizeEntryPrivate *private;
|
||||
guint shift;
|
||||
|
||||
private = gimp_memsize_entry_get_instance_private (entry);
|
||||
guint shift;
|
||||
|
||||
gimp_int_combo_box_get_active (GIMP_INT_COMBO_BOX (widget), (gint *) &shift);
|
||||
|
||||
|
@ -139,17 +133,17 @@ gimp_memsize_entry_unit_callback (GtkWidget *widget,
|
|||
# define CAST
|
||||
#endif
|
||||
|
||||
if (shift != private->shift)
|
||||
if (shift != entry->shift)
|
||||
{
|
||||
private->shift = shift;
|
||||
entry->shift = shift;
|
||||
|
||||
gtk_adjustment_configure (private->adjustment,
|
||||
gimp_memsize_entry_get_rounded_value (entry, private->value),
|
||||
CAST private->lower >> shift,
|
||||
CAST private->upper >> shift,
|
||||
gtk_adjustment_get_step_increment (private->adjustment),
|
||||
gtk_adjustment_get_page_increment (private->adjustment),
|
||||
gtk_adjustment_get_page_size (private->adjustment));
|
||||
gtk_adjustment_configure (entry->adjustment,
|
||||
gimp_memsize_entry_get_rounded_value (entry, entry->value),
|
||||
CAST entry->lower >> shift,
|
||||
CAST entry->upper >> shift,
|
||||
gtk_adjustment_get_step_increment (entry->adjustment),
|
||||
gtk_adjustment_get_page_increment (entry->adjustment),
|
||||
gtk_adjustment_get_page_size (entry->adjustment));
|
||||
}
|
||||
|
||||
#undef CAST
|
||||
|
@ -168,10 +162,7 @@ static guint64
|
|||
gimp_memsize_entry_get_rounded_value (GimpMemsizeEntry *entry,
|
||||
guint64 value)
|
||||
{
|
||||
GimpMemsizeEntryPrivate *private;
|
||||
guint64 converted;
|
||||
|
||||
private = gimp_memsize_entry_get_instance_private (entry);
|
||||
guint64 converted;
|
||||
|
||||
#if _MSC_VER < 1300
|
||||
# define CAST (gint64)
|
||||
|
@ -179,8 +170,8 @@ gimp_memsize_entry_get_rounded_value (GimpMemsizeEntry *entry,
|
|||
# define CAST
|
||||
#endif
|
||||
|
||||
converted = (CAST value >> private->shift) +
|
||||
((CAST private->value >> (private->shift - 1)) & 1);
|
||||
converted = (CAST value >> entry->shift) +
|
||||
((CAST entry->value >> (entry->shift - 1)) & 1);
|
||||
|
||||
#undef CAST
|
||||
|
||||
|
@ -204,9 +195,8 @@ gimp_memsize_entry_new (guint64 value,
|
|||
guint64 lower,
|
||||
guint64 upper)
|
||||
{
|
||||
GimpMemsizeEntry *entry;
|
||||
GimpMemsizeEntryPrivate *private;
|
||||
guint shift;
|
||||
GimpMemsizeEntry *entry;
|
||||
guint shift;
|
||||
|
||||
#if _MSC_VER < 1300
|
||||
# define CAST (gint64)
|
||||
|
@ -218,8 +208,6 @@ gimp_memsize_entry_new (guint64 value,
|
|||
|
||||
entry = g_object_new (GIMP_TYPE_MEMSIZE_ENTRY, NULL);
|
||||
|
||||
private = gimp_memsize_entry_get_instance_private (entry);
|
||||
|
||||
for (shift = 30; shift > 10; shift -= 10)
|
||||
{
|
||||
if (value > (G_GUINT64_CONSTANT (1) << shift) &&
|
||||
|
@ -227,43 +215,43 @@ gimp_memsize_entry_new (guint64 value,
|
|||
break;
|
||||
}
|
||||
|
||||
private->value = value;
|
||||
private->lower = lower;
|
||||
private->upper = upper;
|
||||
private->shift = shift;
|
||||
entry->value = value;
|
||||
entry->lower = lower;
|
||||
entry->upper = upper;
|
||||
entry->shift = shift;
|
||||
|
||||
private->adjustment = gtk_adjustment_new (gimp_memsize_entry_get_rounded_value (entry,
|
||||
private->value),
|
||||
entry->adjustment = gtk_adjustment_new (gimp_memsize_entry_get_rounded_value (entry,
|
||||
entry->value),
|
||||
CAST (lower >> shift),
|
||||
CAST (upper >> shift),
|
||||
1, 8, 0);
|
||||
|
||||
private->spinbutton = gimp_spin_button_new (private->adjustment, 1.0, 0);
|
||||
gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (private->spinbutton), TRUE);
|
||||
entry->spinbutton = gimp_spin_button_new (entry->adjustment, 1.0, 0);
|
||||
gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (entry->spinbutton), TRUE);
|
||||
|
||||
#undef CAST
|
||||
|
||||
gtk_entry_set_width_chars (GTK_ENTRY (private->spinbutton), 7);
|
||||
gtk_box_pack_start (GTK_BOX (entry), private->spinbutton, FALSE, FALSE, 0);
|
||||
gtk_widget_show (private->spinbutton);
|
||||
gtk_entry_set_width_chars (GTK_ENTRY (entry->spinbutton), 7);
|
||||
gtk_box_pack_start (GTK_BOX (entry), entry->spinbutton, FALSE, FALSE, 0);
|
||||
gtk_widget_show (entry->spinbutton);
|
||||
|
||||
g_signal_connect (private->adjustment, "value-changed",
|
||||
g_signal_connect (entry->adjustment, "value-changed",
|
||||
G_CALLBACK (gimp_memsize_entry_adj_callback),
|
||||
entry);
|
||||
|
||||
private->menu = gimp_int_combo_box_new (_("Kibibyte"), 10,
|
||||
_("Mebibyte"), 20,
|
||||
_("Gibibyte"), 30,
|
||||
NULL);
|
||||
entry->menu = gimp_int_combo_box_new (_("Kibibyte"), 10,
|
||||
_("Mebibyte"), 20,
|
||||
_("Gibibyte"), 30,
|
||||
NULL);
|
||||
|
||||
gimp_int_combo_box_set_active (GIMP_INT_COMBO_BOX (private->menu), shift);
|
||||
gimp_int_combo_box_set_active (GIMP_INT_COMBO_BOX (entry->menu), shift);
|
||||
|
||||
g_signal_connect (private->menu, "changed",
|
||||
g_signal_connect (entry->menu, "changed",
|
||||
G_CALLBACK (gimp_memsize_entry_unit_callback),
|
||||
entry);
|
||||
|
||||
gtk_box_pack_start (GTK_BOX (entry), private->menu, FALSE, FALSE, 0);
|
||||
gtk_widget_show (private->menu);
|
||||
gtk_box_pack_start (GTK_BOX (entry), entry->menu, FALSE, FALSE, 0);
|
||||
gtk_widget_show (entry->menu);
|
||||
|
||||
return GTK_WIDGET (entry);
|
||||
}
|
||||
|
@ -280,14 +268,11 @@ void
|
|||
gimp_memsize_entry_set_value (GimpMemsizeEntry *entry,
|
||||
guint64 value)
|
||||
{
|
||||
GimpMemsizeEntryPrivate *private;
|
||||
guint shift;
|
||||
guint shift;
|
||||
|
||||
g_return_if_fail (GIMP_IS_MEMSIZE_ENTRY (entry));
|
||||
|
||||
private = gimp_memsize_entry_get_instance_private (entry);
|
||||
|
||||
g_return_if_fail (value >= private->lower && value <= private->upper);
|
||||
g_return_if_fail (value >= entry->lower && value <= entry->upper);
|
||||
|
||||
for (shift = 30; shift > 10; shift -= 10)
|
||||
{
|
||||
|
@ -296,10 +281,10 @@ gimp_memsize_entry_set_value (GimpMemsizeEntry *entry,
|
|||
break;
|
||||
}
|
||||
|
||||
if (shift != private->shift)
|
||||
gimp_int_combo_box_set_active (GIMP_INT_COMBO_BOX (private->menu), shift);
|
||||
if (shift != entry->shift)
|
||||
gimp_int_combo_box_set_active (GIMP_INT_COMBO_BOX (entry->menu), shift);
|
||||
|
||||
gtk_adjustment_set_value (private->adjustment,
|
||||
gtk_adjustment_set_value (entry->adjustment,
|
||||
(gdouble) gimp_memsize_entry_get_rounded_value (entry, value));
|
||||
|
||||
#undef CASE
|
||||
|
@ -316,13 +301,9 @@ gimp_memsize_entry_set_value (GimpMemsizeEntry *entry,
|
|||
guint64
|
||||
gimp_memsize_entry_get_value (GimpMemsizeEntry *entry)
|
||||
{
|
||||
GimpMemsizeEntryPrivate *private;
|
||||
|
||||
g_return_val_if_fail (GIMP_IS_MEMSIZE_ENTRY (entry), 0);
|
||||
|
||||
private = gimp_memsize_entry_get_instance_private (entry);
|
||||
|
||||
return private->value;
|
||||
return entry->value;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -336,11 +317,7 @@ gimp_memsize_entry_get_value (GimpMemsizeEntry *entry)
|
|||
GtkWidget *
|
||||
gimp_memsize_entry_get_spinbutton (GimpMemsizeEntry *entry)
|
||||
{
|
||||
GimpMemsizeEntryPrivate *private;
|
||||
|
||||
g_return_val_if_fail (GIMP_IS_MEMSIZE_ENTRY (entry), 0);
|
||||
|
||||
private = gimp_memsize_entry_get_instance_private (entry);
|
||||
|
||||
return private->spinbutton;
|
||||
return entry->spinbutton;
|
||||
}
|
||||
|
|
|
@ -30,24 +30,7 @@ G_BEGIN_DECLS
|
|||
|
||||
|
||||
#define GIMP_TYPE_MEMSIZE_ENTRY (gimp_memsize_entry_get_type ())
|
||||
G_DECLARE_DERIVABLE_TYPE (GimpMemsizeEntry, gimp_memsize_entry, GIMP, MEMSIZE_ENTRY, GtkBox)
|
||||
|
||||
struct _GimpMemsizeEntryClass
|
||||
{
|
||||
GtkBoxClass parent_class;
|
||||
|
||||
void (* value_changed) (GimpMemsizeEntry *entry);
|
||||
|
||||
/* 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);
|
||||
};
|
||||
G_DECLARE_FINAL_TYPE (GimpMemsizeEntry, gimp_memsize_entry, GIMP, MEMSIZE_ENTRY, GtkBox)
|
||||
|
||||
|
||||
GtkWidget * gimp_memsize_entry_new (guint64 value,
|
||||
|
|
|
@ -82,8 +82,10 @@ typedef enum
|
|||
} ParseResult;
|
||||
|
||||
|
||||
typedef struct _GimpNumberPairEntryPrivate
|
||||
struct _GimpNumberPairEntry
|
||||
{
|
||||
GtkEntry parent_instance;
|
||||
|
||||
/* The current number pair displayed in the widget. */
|
||||
gdouble left_number;
|
||||
gdouble right_number;
|
||||
|
@ -119,7 +121,7 @@ typedef struct _GimpNumberPairEntryPrivate
|
|||
/* What range of values considered valid. */
|
||||
gdouble min_valid_value;
|
||||
gdouble max_valid_value;
|
||||
} GimpNumberPairEntryPrivate;
|
||||
};
|
||||
|
||||
|
||||
static void gimp_number_pair_entry_finalize (GObject *entry);
|
||||
|
@ -160,8 +162,7 @@ static gchar * gimp_number_pair_entry_strdup_number_pair_string
|
|||
|
||||
|
||||
|
||||
G_DEFINE_TYPE_WITH_PRIVATE (GimpNumberPairEntry, gimp_number_pair_entry,
|
||||
GTK_TYPE_ENTRY)
|
||||
G_DEFINE_TYPE (GimpNumberPairEntry, gimp_number_pair_entry, GTK_TYPE_ENTRY)
|
||||
|
||||
|
||||
#define parent_class gimp_number_pair_entry_parent_class
|
||||
|
@ -184,7 +185,7 @@ gimp_number_pair_entry_class_init (GimpNumberPairEntryClass *klass)
|
|||
g_signal_new ("numbers-changed",
|
||||
G_TYPE_FROM_CLASS (klass),
|
||||
G_SIGNAL_RUN_FIRST,
|
||||
G_STRUCT_OFFSET (GimpNumberPairEntryClass, numbers_changed),
|
||||
0,
|
||||
NULL, NULL, NULL,
|
||||
G_TYPE_NONE, 0);
|
||||
|
||||
|
@ -192,7 +193,7 @@ gimp_number_pair_entry_class_init (GimpNumberPairEntryClass *klass)
|
|||
g_signal_new ("ratio-changed",
|
||||
G_TYPE_FROM_CLASS (klass),
|
||||
G_SIGNAL_RUN_FIRST,
|
||||
G_STRUCT_OFFSET (GimpNumberPairEntryClass, ratio_changed),
|
||||
0,
|
||||
NULL, NULL, NULL,
|
||||
G_TYPE_NONE, 0);
|
||||
|
||||
|
@ -200,9 +201,6 @@ gimp_number_pair_entry_class_init (GimpNumberPairEntryClass *klass)
|
|||
object_class->get_property = gimp_number_pair_entry_get_property;
|
||||
object_class->finalize = gimp_number_pair_entry_finalize;
|
||||
|
||||
klass->numbers_changed = NULL;
|
||||
klass->ratio_changed = NULL;
|
||||
|
||||
g_object_class_install_property (object_class, PROP_LEFT_NUMBER,
|
||||
g_param_spec_double ("left-number",
|
||||
"Left number",
|
||||
|
@ -300,22 +298,18 @@ gimp_number_pair_entry_class_init (GimpNumberPairEntryClass *klass)
|
|||
static void
|
||||
gimp_number_pair_entry_init (GimpNumberPairEntry *entry)
|
||||
{
|
||||
GimpNumberPairEntryPrivate *priv;
|
||||
|
||||
priv = gimp_number_pair_entry_get_instance_private (entry);
|
||||
|
||||
priv->left_number = 1.0;
|
||||
priv->right_number = 1.0;
|
||||
priv->default_left_number = 1.0;
|
||||
priv->default_right_number = 1.0;
|
||||
priv->user_override = FALSE;
|
||||
priv->font_italic = FALSE;
|
||||
priv->separators = NULL;
|
||||
priv->default_text = NULL;
|
||||
priv->num_separators = 0;
|
||||
priv->allow_simplification = FALSE;
|
||||
priv->min_valid_value = G_MINDOUBLE;
|
||||
priv->max_valid_value = G_MAXDOUBLE;
|
||||
entry->left_number = 1.0;
|
||||
entry->right_number = 1.0;
|
||||
entry->default_left_number = 1.0;
|
||||
entry->default_right_number = 1.0;
|
||||
entry->user_override = FALSE;
|
||||
entry->font_italic = FALSE;
|
||||
entry->separators = NULL;
|
||||
entry->default_text = NULL;
|
||||
entry->num_separators = 0;
|
||||
entry->allow_simplification = FALSE;
|
||||
entry->min_valid_value = G_MINDOUBLE;
|
||||
entry->max_valid_value = G_MAXDOUBLE;
|
||||
|
||||
g_signal_connect (entry, "changed",
|
||||
G_CALLBACK (gimp_number_pair_entry_changed),
|
||||
|
@ -340,15 +334,12 @@ gimp_number_pair_entry_init (GimpNumberPairEntry *entry)
|
|||
static void
|
||||
gimp_number_pair_entry_finalize (GObject *object)
|
||||
{
|
||||
GimpNumberPairEntry *entry = GIMP_NUMBER_PAIR_ENTRY (object);
|
||||
GimpNumberPairEntryPrivate *priv;
|
||||
GimpNumberPairEntry *entry = GIMP_NUMBER_PAIR_ENTRY (object);
|
||||
|
||||
priv = gimp_number_pair_entry_get_instance_private (entry);
|
||||
g_clear_pointer (&entry->separators, g_free);
|
||||
entry->num_separators = 0;
|
||||
|
||||
g_clear_pointer (&priv->separators, g_free);
|
||||
priv->num_separators = 0;
|
||||
|
||||
g_clear_pointer (&priv->default_text, g_free);
|
||||
g_clear_pointer (&entry->default_text, g_free);
|
||||
|
||||
G_OBJECT_CLASS (parent_class)->finalize (object);
|
||||
}
|
||||
|
@ -487,13 +478,9 @@ gimp_number_pair_entry_set_ratio (GimpNumberPairEntry *entry,
|
|||
gdouble
|
||||
gimp_number_pair_entry_get_ratio (GimpNumberPairEntry *entry)
|
||||
{
|
||||
GimpNumberPairEntryPrivate *priv;
|
||||
|
||||
g_return_val_if_fail (GIMP_IS_NUMBER_PAIR_ENTRY (entry), 1.0);
|
||||
|
||||
priv = gimp_number_pair_entry_get_instance_private (entry);
|
||||
|
||||
return priv->left_number / priv->right_number;
|
||||
return entry->left_number / entry->right_number;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -513,22 +500,19 @@ gimp_number_pair_entry_set_values (GimpNumberPairEntry *entry,
|
|||
gdouble left,
|
||||
gdouble right)
|
||||
{
|
||||
GimpNumberPairEntryPrivate *priv;
|
||||
GimpAspectType old_aspect;
|
||||
gdouble old_ratio;
|
||||
gdouble old_left_number;
|
||||
gdouble old_right_number;
|
||||
gboolean numbers_changed = FALSE;
|
||||
gboolean ratio_changed = FALSE;
|
||||
GimpAspectType old_aspect;
|
||||
gdouble old_ratio;
|
||||
gdouble old_left_number;
|
||||
gdouble old_right_number;
|
||||
gboolean numbers_changed = FALSE;
|
||||
gboolean ratio_changed = FALSE;
|
||||
|
||||
g_return_if_fail (GIMP_IS_NUMBER_PAIR_ENTRY (entry));
|
||||
|
||||
priv = gimp_number_pair_entry_get_instance_private (entry);
|
||||
|
||||
/* Store current values */
|
||||
|
||||
old_left_number = priv->left_number;
|
||||
old_right_number = priv->right_number;
|
||||
old_left_number = entry->left_number;
|
||||
old_right_number = entry->right_number;
|
||||
old_ratio = gimp_number_pair_entry_get_ratio (entry);
|
||||
old_aspect = gimp_number_pair_entry_get_aspect (entry);
|
||||
|
||||
|
@ -540,8 +524,8 @@ gimp_number_pair_entry_set_values (GimpNumberPairEntry *entry,
|
|||
|
||||
/* Set the new numbers and update the entry */
|
||||
|
||||
priv->left_number = left;
|
||||
priv->right_number = right;
|
||||
entry->left_number = left;
|
||||
entry->right_number = right;
|
||||
|
||||
g_object_notify (G_OBJECT (entry), "left-number");
|
||||
g_object_notify (G_OBJECT (entry), "right-number");
|
||||
|
@ -561,8 +545,8 @@ gimp_number_pair_entry_set_values (GimpNumberPairEntry *entry,
|
|||
g_object_notify (G_OBJECT (entry), "aspect");
|
||||
}
|
||||
|
||||
if (old_left_number != priv->left_number ||
|
||||
old_right_number != priv->right_number)
|
||||
if (old_left_number != entry->left_number ||
|
||||
old_right_number != entry->right_number)
|
||||
{
|
||||
numbers_changed = TRUE;
|
||||
}
|
||||
|
@ -597,17 +581,13 @@ gimp_number_pair_entry_get_values (GimpNumberPairEntry *entry,
|
|||
gdouble *left,
|
||||
gdouble *right)
|
||||
{
|
||||
GimpNumberPairEntryPrivate *priv;
|
||||
|
||||
g_return_if_fail (GIMP_IS_NUMBER_PAIR_ENTRY (entry));
|
||||
|
||||
priv = gimp_number_pair_entry_get_instance_private (entry);
|
||||
|
||||
if (left != NULL)
|
||||
*left = priv->left_number;
|
||||
*left = entry->left_number;
|
||||
|
||||
if (right != NULL)
|
||||
*right = priv->right_number;
|
||||
*right = entry->right_number;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -629,14 +609,10 @@ void
|
|||
gimp_number_pair_entry_set_default_text (GimpNumberPairEntry *entry,
|
||||
const gchar *string)
|
||||
{
|
||||
GimpNumberPairEntryPrivate *priv;
|
||||
|
||||
g_return_if_fail (GIMP_IS_NUMBER_PAIR_ENTRY (entry));
|
||||
|
||||
priv = gimp_number_pair_entry_get_instance_private (entry);
|
||||
|
||||
g_free (priv->default_text);
|
||||
priv->default_text = g_strdup (string);
|
||||
g_free (entry->default_text);
|
||||
entry->default_text = g_strdup (string);
|
||||
|
||||
gimp_number_pair_entry_update_text (entry);
|
||||
|
||||
|
@ -655,13 +631,9 @@ gimp_number_pair_entry_set_default_text (GimpNumberPairEntry *entry,
|
|||
const gchar *
|
||||
gimp_number_pair_entry_get_default_text (GimpNumberPairEntry *entry)
|
||||
{
|
||||
GimpNumberPairEntryPrivate *priv;
|
||||
|
||||
g_return_val_if_fail (GIMP_IS_NUMBER_PAIR_ENTRY (entry), NULL);
|
||||
|
||||
priv = gimp_number_pair_entry_get_instance_private (entry);
|
||||
|
||||
return priv->default_text;
|
||||
return entry->default_text;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -679,28 +651,24 @@ void
|
|||
gimp_number_pair_entry_set_aspect (GimpNumberPairEntry *entry,
|
||||
GimpAspectType aspect)
|
||||
{
|
||||
GimpNumberPairEntryPrivate *priv;
|
||||
|
||||
g_return_if_fail (GIMP_IS_NUMBER_PAIR_ENTRY (entry));
|
||||
|
||||
if (gimp_number_pair_entry_get_aspect (entry) == aspect)
|
||||
return;
|
||||
|
||||
priv = gimp_number_pair_entry_get_instance_private (entry);
|
||||
|
||||
switch (aspect)
|
||||
{
|
||||
case GIMP_ASPECT_SQUARE:
|
||||
gimp_number_pair_entry_set_values (entry,
|
||||
priv->left_number,
|
||||
priv->left_number);
|
||||
entry->left_number,
|
||||
entry->left_number);
|
||||
break;
|
||||
|
||||
case GIMP_ASPECT_LANDSCAPE:
|
||||
case GIMP_ASPECT_PORTRAIT:
|
||||
gimp_number_pair_entry_set_values (entry,
|
||||
priv->right_number,
|
||||
priv->left_number);
|
||||
entry->right_number,
|
||||
entry->left_number);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -718,17 +686,13 @@ gimp_number_pair_entry_set_aspect (GimpNumberPairEntry *entry,
|
|||
GimpAspectType
|
||||
gimp_number_pair_entry_get_aspect (GimpNumberPairEntry *entry)
|
||||
{
|
||||
GimpNumberPairEntryPrivate *priv;
|
||||
|
||||
g_return_val_if_fail (GIMP_IS_NUMBER_PAIR_ENTRY (entry), GIMP_ASPECT_SQUARE);
|
||||
|
||||
priv = gimp_number_pair_entry_get_instance_private (entry);
|
||||
|
||||
if (priv->left_number > priv->right_number)
|
||||
if (entry->left_number > entry->right_number)
|
||||
{
|
||||
return GIMP_ASPECT_LANDSCAPE;
|
||||
}
|
||||
else if (priv->left_number < priv->right_number)
|
||||
else if (entry->left_number < entry->right_number)
|
||||
{
|
||||
return GIMP_ASPECT_PORTRAIT;
|
||||
}
|
||||
|
@ -742,12 +706,9 @@ static void
|
|||
gimp_number_pair_entry_modify_font (GimpNumberPairEntry *entry,
|
||||
gboolean italic)
|
||||
{
|
||||
GimpNumberPairEntryPrivate *priv;
|
||||
GtkStyleContext *style;
|
||||
GtkStyleContext *style;
|
||||
|
||||
priv = gimp_number_pair_entry_get_instance_private (entry);
|
||||
|
||||
if (priv->font_italic == italic)
|
||||
if (entry->font_italic == italic)
|
||||
return;
|
||||
|
||||
style = gtk_widget_get_style_context (GTK_WIDGET (entry));
|
||||
|
@ -761,7 +722,7 @@ gimp_number_pair_entry_modify_font (GimpNumberPairEntry *entry,
|
|||
GTK_ENTRY_ICON_SECONDARY,
|
||||
! italic);
|
||||
|
||||
priv->font_italic = italic;
|
||||
entry->font_italic = italic;
|
||||
}
|
||||
|
||||
|
||||
|
@ -781,19 +742,15 @@ void
|
|||
gimp_number_pair_entry_set_user_override (GimpNumberPairEntry *entry,
|
||||
gboolean user_override)
|
||||
{
|
||||
GimpNumberPairEntryPrivate *priv;
|
||||
|
||||
g_return_if_fail (GIMP_IS_NUMBER_PAIR_ENTRY (entry));
|
||||
|
||||
priv = gimp_number_pair_entry_get_instance_private (entry);
|
||||
|
||||
priv->user_override = user_override;
|
||||
entry->user_override = user_override;
|
||||
|
||||
if (! user_override)
|
||||
{
|
||||
gimp_number_pair_entry_set_default_values (entry,
|
||||
priv->default_left_number,
|
||||
priv->default_right_number);
|
||||
entry->default_left_number,
|
||||
entry->default_right_number);
|
||||
}
|
||||
|
||||
gimp_number_pair_entry_modify_font (entry, ! user_override);
|
||||
|
@ -812,13 +769,9 @@ gimp_number_pair_entry_set_user_override (GimpNumberPairEntry *entry,
|
|||
gboolean
|
||||
gimp_number_pair_entry_get_user_override (GimpNumberPairEntry *entry)
|
||||
{
|
||||
GimpNumberPairEntryPrivate *priv;
|
||||
|
||||
g_return_val_if_fail (GIMP_IS_NUMBER_PAIR_ENTRY (entry), FALSE);
|
||||
|
||||
priv = gimp_number_pair_entry_get_instance_private (entry);
|
||||
|
||||
return priv->user_override;
|
||||
return entry->user_override;
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -839,11 +792,9 @@ static gboolean
|
|||
gimp_number_pair_entry_events (GtkWidget *widget,
|
||||
GdkEvent *event)
|
||||
{
|
||||
GimpNumberPairEntry *entry = GIMP_NUMBER_PAIR_ENTRY (widget);
|
||||
GimpNumberPairEntryPrivate *priv;
|
||||
gboolean force_user_override;
|
||||
GimpNumberPairEntry *entry = GIMP_NUMBER_PAIR_ENTRY (widget);
|
||||
gboolean force_user_override;
|
||||
|
||||
priv = gimp_number_pair_entry_get_instance_private (entry);
|
||||
force_user_override = FALSE;
|
||||
|
||||
switch (event->type)
|
||||
|
@ -882,8 +833,8 @@ gimp_number_pair_entry_events (GtkWidget *widget,
|
|||
{
|
||||
case PARSE_VALID:
|
||||
{
|
||||
if (priv->left_number != left_value ||
|
||||
priv->right_number != right_value ||
|
||||
if (entry->left_number != left_value ||
|
||||
entry->right_number != right_value ||
|
||||
force_user_override)
|
||||
{
|
||||
gimp_number_pair_entry_set_values (entry,
|
||||
|
@ -931,14 +882,11 @@ gimp_number_pair_entry_strdup_number_pair_string (GimpNumberPairEntry *entry,
|
|||
gdouble left_number,
|
||||
gdouble right_number)
|
||||
{
|
||||
GimpNumberPairEntryPrivate *priv;
|
||||
gchar sep[8];
|
||||
gint len;
|
||||
gchar sep[8];
|
||||
gint len;
|
||||
|
||||
priv = gimp_number_pair_entry_get_instance_private (entry);
|
||||
|
||||
if (priv->num_separators > 0)
|
||||
len = g_unichar_to_utf8 (priv->separators[0], sep);
|
||||
if (entry->num_separators > 0)
|
||||
len = g_unichar_to_utf8 (entry->separators[0], sep);
|
||||
else
|
||||
len = g_unichar_to_utf8 (DEFAULT_SEPARATOR, sep);
|
||||
|
||||
|
@ -950,24 +898,21 @@ gimp_number_pair_entry_strdup_number_pair_string (GimpNumberPairEntry *entry,
|
|||
static void
|
||||
gimp_number_pair_entry_update_text (GimpNumberPairEntry *entry)
|
||||
{
|
||||
GimpNumberPairEntryPrivate *priv;
|
||||
gchar *buffer;
|
||||
gchar *buffer;
|
||||
|
||||
priv = gimp_number_pair_entry_get_instance_private (entry);
|
||||
|
||||
if (! priv->user_override &&
|
||||
priv->default_text != NULL)
|
||||
if (! entry->user_override &&
|
||||
entry->default_text != NULL)
|
||||
{
|
||||
/* Instead of the numbers, show the string explicitly set by a
|
||||
* client to show when in automatic mode.
|
||||
*/
|
||||
buffer = g_strdup (priv->default_text);
|
||||
buffer = g_strdup (entry->default_text);
|
||||
}
|
||||
else
|
||||
{
|
||||
buffer = gimp_number_pair_entry_strdup_number_pair_string (entry,
|
||||
priv->left_number,
|
||||
priv->right_number);
|
||||
entry->left_number,
|
||||
entry->right_number);
|
||||
}
|
||||
|
||||
g_signal_handlers_block_by_func (entry,
|
||||
|
@ -979,23 +924,19 @@ gimp_number_pair_entry_update_text (GimpNumberPairEntry *entry)
|
|||
g_signal_handlers_unblock_by_func (entry,
|
||||
gimp_number_pair_entry_changed, NULL);
|
||||
|
||||
gimp_number_pair_entry_modify_font (entry, ! priv->user_override);
|
||||
gimp_number_pair_entry_modify_font (entry, ! entry->user_override);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gimp_number_pair_entry_valid_separator (GimpNumberPairEntry *entry,
|
||||
gunichar candidate)
|
||||
{
|
||||
GimpNumberPairEntryPrivate *priv;
|
||||
|
||||
priv = gimp_number_pair_entry_get_instance_private (entry);
|
||||
|
||||
if (priv->num_separators > 0)
|
||||
if (entry->num_separators > 0)
|
||||
{
|
||||
gint i;
|
||||
|
||||
for (i = 0; i < priv->num_separators; i++)
|
||||
if (priv->separators[i] == candidate)
|
||||
for (i = 0; i < entry->num_separators; i++)
|
||||
if (entry->separators[i] == candidate)
|
||||
return TRUE;
|
||||
}
|
||||
else if (candidate == DEFAULT_SEPARATOR)
|
||||
|
@ -1012,13 +953,10 @@ gimp_number_pair_entry_parse_text (GimpNumberPairEntry *entry,
|
|||
gdouble *left_value,
|
||||
gdouble *right_value)
|
||||
{
|
||||
GimpNumberPairEntryPrivate *priv;
|
||||
gdouble new_left_number;
|
||||
gdouble new_right_number;
|
||||
gboolean simplify = FALSE;
|
||||
gchar *end;
|
||||
|
||||
priv = gimp_number_pair_entry_get_instance_private (entry);
|
||||
gdouble new_left_number;
|
||||
gdouble new_right_number;
|
||||
gboolean simplify = FALSE;
|
||||
gchar *end;
|
||||
|
||||
/* skip over whitespace */
|
||||
while (g_unichar_isspace (g_utf8_get_char (text)))
|
||||
|
@ -1061,7 +999,7 @@ gimp_number_pair_entry_parse_text (GimpNumberPairEntry *entry,
|
|||
/* check for the simplification char */
|
||||
if (g_utf8_get_char (text) == SIMPLIFICATION_CHAR)
|
||||
{
|
||||
simplify = priv->allow_simplification;
|
||||
simplify = entry->allow_simplification;
|
||||
text = g_utf8_next_char (text);
|
||||
}
|
||||
|
||||
|
@ -1101,30 +1039,27 @@ gimp_number_pair_entry_set_property (GObject *object,
|
|||
GParamSpec *pspec)
|
||||
{
|
||||
GimpNumberPairEntry *entry = GIMP_NUMBER_PAIR_ENTRY (object);
|
||||
GimpNumberPairEntryPrivate *priv;
|
||||
|
||||
priv = gimp_number_pair_entry_get_instance_private (entry);
|
||||
|
||||
switch (property_id)
|
||||
{
|
||||
case PROP_LEFT_NUMBER:
|
||||
gimp_number_pair_entry_set_values (entry,
|
||||
g_value_get_double (value),
|
||||
priv->right_number);
|
||||
entry->right_number);
|
||||
break;
|
||||
case PROP_RIGHT_NUMBER:
|
||||
gimp_number_pair_entry_set_values (entry,
|
||||
priv->left_number,
|
||||
entry->left_number,
|
||||
g_value_get_double (value));
|
||||
break;
|
||||
case PROP_DEFAULT_LEFT_NUMBER:
|
||||
gimp_number_pair_entry_set_default_values (entry,
|
||||
g_value_get_double (value),
|
||||
priv->default_right_number);
|
||||
entry->default_right_number);
|
||||
break;
|
||||
case PROP_DEFAULT_RIGHT_NUMBER:
|
||||
gimp_number_pair_entry_set_default_values (entry,
|
||||
priv->default_left_number,
|
||||
entry->default_left_number,
|
||||
g_value_get_double (value));
|
||||
break;
|
||||
case PROP_USER_OVERRIDE:
|
||||
|
@ -1132,26 +1067,26 @@ gimp_number_pair_entry_set_property (GObject *object,
|
|||
g_value_get_boolean (value));
|
||||
break;
|
||||
case PROP_SEPARATORS:
|
||||
g_free (priv->separators);
|
||||
priv->num_separators = 0;
|
||||
g_free (entry->separators);
|
||||
entry->num_separators = 0;
|
||||
if (g_value_get_string (value))
|
||||
priv->separators = g_utf8_to_ucs4 (g_value_get_string (value), -1,
|
||||
NULL, &priv->num_separators, NULL);
|
||||
entry->separators = g_utf8_to_ucs4 (g_value_get_string (value), -1,
|
||||
NULL, &entry->num_separators, NULL);
|
||||
else
|
||||
priv->separators = NULL;
|
||||
entry->separators = NULL;
|
||||
break;
|
||||
case PROP_DEFAULT_TEXT:
|
||||
gimp_number_pair_entry_set_default_text (entry,
|
||||
g_value_get_string (value));
|
||||
break;
|
||||
case PROP_ALLOW_SIMPLIFICATION:
|
||||
priv->allow_simplification = g_value_get_boolean (value);
|
||||
entry->allow_simplification = g_value_get_boolean (value);
|
||||
break;
|
||||
case PROP_MIN_VALID_VALUE:
|
||||
priv->min_valid_value = g_value_get_double (value);
|
||||
entry->min_valid_value = g_value_get_double (value);
|
||||
break;
|
||||
case PROP_MAX_VALID_VALUE:
|
||||
priv->max_valid_value = g_value_get_double (value);
|
||||
entry->max_valid_value = g_value_get_double (value);
|
||||
break;
|
||||
case PROP_RATIO:
|
||||
gimp_number_pair_entry_set_ratio (entry, g_value_get_double (value));
|
||||
|
@ -1171,45 +1106,42 @@ gimp_number_pair_entry_get_property (GObject *object,
|
|||
GValue *value,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
GimpNumberPairEntry *entry = GIMP_NUMBER_PAIR_ENTRY (object);
|
||||
GimpNumberPairEntryPrivate *priv;
|
||||
|
||||
priv = gimp_number_pair_entry_get_instance_private (entry);
|
||||
GimpNumberPairEntry *entry = GIMP_NUMBER_PAIR_ENTRY (object);
|
||||
|
||||
switch (property_id)
|
||||
{
|
||||
case PROP_LEFT_NUMBER:
|
||||
g_value_set_double (value, priv->left_number);
|
||||
g_value_set_double (value, entry->left_number);
|
||||
break;
|
||||
case PROP_RIGHT_NUMBER:
|
||||
g_value_set_double (value, priv->right_number);
|
||||
g_value_set_double (value, entry->right_number);
|
||||
break;
|
||||
case PROP_DEFAULT_LEFT_NUMBER:
|
||||
g_value_set_double (value, priv->default_left_number);
|
||||
g_value_set_double (value, entry->default_left_number);
|
||||
break;
|
||||
case PROP_DEFAULT_RIGHT_NUMBER:
|
||||
g_value_set_double (value, priv->default_right_number);
|
||||
g_value_set_double (value, entry->default_right_number);
|
||||
break;
|
||||
case PROP_USER_OVERRIDE:
|
||||
g_value_set_boolean (value, priv->user_override);
|
||||
g_value_set_boolean (value, entry->user_override);
|
||||
break;
|
||||
case PROP_SEPARATORS:
|
||||
g_value_take_string (value,
|
||||
g_ucs4_to_utf8 (priv->separators,
|
||||
priv->num_separators,
|
||||
g_ucs4_to_utf8 (entry->separators,
|
||||
entry->num_separators,
|
||||
NULL, NULL, NULL));
|
||||
break;
|
||||
case PROP_ALLOW_SIMPLIFICATION:
|
||||
g_value_set_boolean (value, priv->allow_simplification);
|
||||
g_value_set_boolean (value, entry->allow_simplification);
|
||||
break;
|
||||
case PROP_DEFAULT_TEXT:
|
||||
g_value_set_string (value, priv->default_text);
|
||||
g_value_set_string (value, entry->default_text);
|
||||
break;
|
||||
case PROP_MIN_VALID_VALUE:
|
||||
g_value_set_double (value, priv->min_valid_value);
|
||||
g_value_set_double (value, entry->min_valid_value);
|
||||
break;
|
||||
case PROP_MAX_VALID_VALUE:
|
||||
g_value_set_double (value, priv->max_valid_value);
|
||||
g_value_set_double (value, entry->max_valid_value);
|
||||
break;
|
||||
case PROP_RATIO:
|
||||
g_value_set_double (value, gimp_number_pair_entry_get_ratio (entry));
|
||||
|
@ -1236,20 +1168,16 @@ gimp_number_pair_entry_set_default_values (GimpNumberPairEntry *entry,
|
|||
gdouble left,
|
||||
gdouble right)
|
||||
{
|
||||
GimpNumberPairEntryPrivate *priv;
|
||||
|
||||
g_return_if_fail (GIMP_IS_NUMBER_PAIR_ENTRY (entry));
|
||||
|
||||
priv = gimp_number_pair_entry_get_instance_private (entry);
|
||||
entry->default_left_number = left;
|
||||
entry->default_right_number = right;
|
||||
|
||||
priv->default_left_number = left;
|
||||
priv->default_right_number = right;
|
||||
|
||||
if (! priv->user_override)
|
||||
if (! entry->user_override)
|
||||
{
|
||||
gimp_number_pair_entry_set_values (entry,
|
||||
priv->default_left_number,
|
||||
priv->default_right_number);
|
||||
entry->default_left_number,
|
||||
entry->default_right_number);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1266,17 +1194,13 @@ gimp_number_pair_entry_get_default_values (GimpNumberPairEntry *entry,
|
|||
gdouble *left,
|
||||
gdouble *right)
|
||||
{
|
||||
GimpNumberPairEntryPrivate *priv;
|
||||
|
||||
g_return_if_fail (GIMP_IS_NUMBER_PAIR_ENTRY (entry));
|
||||
|
||||
priv = gimp_number_pair_entry_get_instance_private (entry);
|
||||
|
||||
if (left != NULL)
|
||||
*left = priv->default_left_number;
|
||||
*left = entry->default_left_number;
|
||||
|
||||
if (right != NULL)
|
||||
*right = priv->default_right_number;
|
||||
*right = entry->default_right_number;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
|
@ -1284,12 +1208,8 @@ gimp_number_pair_entry_numbers_in_range (GimpNumberPairEntry *entry,
|
|||
gdouble left_number,
|
||||
gdouble right_number)
|
||||
{
|
||||
GimpNumberPairEntryPrivate *priv;
|
||||
|
||||
priv = gimp_number_pair_entry_get_instance_private (entry);
|
||||
|
||||
return (left_number >= priv->min_valid_value &&
|
||||
left_number <= priv->max_valid_value &&
|
||||
right_number >= priv->min_valid_value &&
|
||||
right_number <= priv->max_valid_value);
|
||||
return (left_number >= entry->min_valid_value &&
|
||||
left_number <= entry->max_valid_value &&
|
||||
right_number >= entry->min_valid_value &&
|
||||
right_number <= entry->max_valid_value);
|
||||
}
|
||||
|
|
|
@ -32,25 +32,7 @@ G_BEGIN_DECLS
|
|||
|
||||
|
||||
#define GIMP_TYPE_NUMBER_PAIR_ENTRY (gimp_number_pair_entry_get_type ())
|
||||
G_DECLARE_DERIVABLE_TYPE (GimpNumberPairEntry, gimp_number_pair_entry, GIMP, NUMBER_PAIR_ENTRY, GtkEntry)
|
||||
|
||||
struct _GimpNumberPairEntryClass
|
||||
{
|
||||
GtkEntryClass parent_class;
|
||||
|
||||
void (* numbers_changed) (GimpNumberPairEntry *entry);
|
||||
void (* ratio_changed) (GimpNumberPairEntry *entry);
|
||||
|
||||
/* 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);
|
||||
};
|
||||
G_DECLARE_FINAL_TYPE (GimpNumberPairEntry, gimp_number_pair_entry, GIMP, NUMBER_PAIR_ENTRY, GtkEntry)
|
||||
|
||||
|
||||
GtkWidget * gimp_number_pair_entry_new (const gchar *separators,
|
||||
|
|
|
@ -48,17 +48,19 @@ enum
|
|||
};
|
||||
|
||||
|
||||
typedef struct _GimpOffsetAreaPrivate
|
||||
struct _GimpOffsetArea
|
||||
{
|
||||
gint orig_width;
|
||||
gint orig_height;
|
||||
gint width;
|
||||
gint height;
|
||||
gint offset_x;
|
||||
gint offset_y;
|
||||
gdouble display_ratio_x;
|
||||
gdouble display_ratio_y;
|
||||
} GimpOffsetAreaPrivate;
|
||||
GtkDrawingArea parent_instance;
|
||||
|
||||
gint orig_width;
|
||||
gint orig_height;
|
||||
gint width;
|
||||
gint height;
|
||||
gint offset_x;
|
||||
gint offset_y;
|
||||
gdouble display_ratio_x;
|
||||
gdouble display_ratio_y;
|
||||
};
|
||||
|
||||
|
||||
static void gimp_offset_area_resize (GimpOffsetArea *area);
|
||||
|
@ -72,8 +74,7 @@ static gboolean gimp_offset_area_draw (GtkWidget *widget,
|
|||
cairo_t *cr);
|
||||
|
||||
|
||||
G_DEFINE_TYPE_WITH_PRIVATE (GimpOffsetArea, gimp_offset_area,
|
||||
GTK_TYPE_DRAWING_AREA)
|
||||
G_DEFINE_TYPE (GimpOffsetArea, gimp_offset_area, GTK_TYPE_DRAWING_AREA)
|
||||
|
||||
#define parent_class gimp_offset_area_parent_class
|
||||
|
||||
|
@ -89,7 +90,7 @@ gimp_offset_area_class_init (GimpOffsetAreaClass *klass)
|
|||
g_signal_new ("offsets-changed",
|
||||
G_TYPE_FROM_CLASS (klass),
|
||||
G_SIGNAL_RUN_FIRST,
|
||||
G_STRUCT_OFFSET (GimpOffsetAreaClass, offsets_changed),
|
||||
0,
|
||||
NULL, NULL,
|
||||
_gimp_widgets_marshal_VOID__INT_INT,
|
||||
G_TYPE_NONE, 2,
|
||||
|
@ -105,12 +106,8 @@ gimp_offset_area_class_init (GimpOffsetAreaClass *klass)
|
|||
static void
|
||||
gimp_offset_area_init (GimpOffsetArea *area)
|
||||
{
|
||||
GimpOffsetAreaPrivate *private;
|
||||
|
||||
private = gimp_offset_area_get_instance_private (area);
|
||||
|
||||
private->display_ratio_x = 1.0;
|
||||
private->display_ratio_y = 1.0;
|
||||
area->display_ratio_x = 1.0;
|
||||
area->display_ratio_y = 1.0;
|
||||
|
||||
gtk_widget_add_events (GTK_WIDGET (area),
|
||||
GDK_BUTTON_PRESS_MASK |
|
||||
|
@ -133,18 +130,15 @@ GtkWidget *
|
|||
gimp_offset_area_new (gint orig_width,
|
||||
gint orig_height)
|
||||
{
|
||||
GimpOffsetArea *area;
|
||||
GimpOffsetAreaPrivate *private;
|
||||
GimpOffsetArea *area;
|
||||
|
||||
g_return_val_if_fail (orig_width > 0, NULL);
|
||||
g_return_val_if_fail (orig_height > 0, NULL);
|
||||
|
||||
area = g_object_new (GIMP_TYPE_OFFSET_AREA, NULL);
|
||||
|
||||
private = gimp_offset_area_get_instance_private (area);
|
||||
|
||||
private->orig_width = private->width = orig_width;
|
||||
private->orig_height = private->height = orig_height;
|
||||
area->orig_width = area->width = orig_width;
|
||||
area->orig_height = area->height = orig_height;
|
||||
|
||||
gimp_offset_area_resize (area);
|
||||
|
||||
|
@ -190,39 +184,35 @@ gimp_offset_area_set_size (GimpOffsetArea *area,
|
|||
gint width,
|
||||
gint height)
|
||||
{
|
||||
GimpOffsetAreaPrivate *private;
|
||||
|
||||
g_return_if_fail (GIMP_IS_OFFSET_AREA (area));
|
||||
g_return_if_fail (width > 0 && height > 0);
|
||||
|
||||
private = gimp_offset_area_get_instance_private (area);
|
||||
|
||||
if (private->width != width || private->height != height)
|
||||
if (area->width != width || area->height != height)
|
||||
{
|
||||
gint offset_x;
|
||||
gint offset_y;
|
||||
|
||||
private->width = width;
|
||||
private->height = height;
|
||||
area->width = width;
|
||||
area->height = height;
|
||||
|
||||
if (private->orig_width <= private->width)
|
||||
offset_x = CLAMP (private->offset_x,
|
||||
0, private->width - private->orig_width);
|
||||
if (area->orig_width <= area->width)
|
||||
offset_x = CLAMP (area->offset_x,
|
||||
0, area->width - area->orig_width);
|
||||
else
|
||||
offset_x = CLAMP (private->offset_x,
|
||||
private->width - private->orig_width, 0);
|
||||
offset_x = CLAMP (area->offset_x,
|
||||
area->width - area->orig_width, 0);
|
||||
|
||||
if (private->orig_height <= private->height)
|
||||
offset_y = CLAMP (private->offset_y,
|
||||
0, private->height - private->orig_height);
|
||||
if (area->orig_height <= area->height)
|
||||
offset_y = CLAMP (area->offset_y,
|
||||
0, area->height - area->orig_height);
|
||||
else
|
||||
offset_y = CLAMP (private->offset_y,
|
||||
private->height - private->orig_height, 0);
|
||||
offset_y = CLAMP (area->offset_y,
|
||||
area->height - area->orig_height, 0);
|
||||
|
||||
if (offset_x != private->offset_x || offset_y != private->offset_y)
|
||||
if (offset_x != area->offset_x || offset_y != area->offset_y)
|
||||
{
|
||||
private->offset_x = offset_x;
|
||||
private->offset_y = offset_y;
|
||||
area->offset_x = offset_x;
|
||||
area->offset_y = offset_y;
|
||||
|
||||
g_signal_emit (area,
|
||||
gimp_offset_area_signals[OFFSETS_CHANGED], 0,
|
||||
|
@ -247,27 +237,23 @@ gimp_offset_area_set_offsets (GimpOffsetArea *area,
|
|||
gint offset_x,
|
||||
gint offset_y)
|
||||
{
|
||||
GimpOffsetAreaPrivate *private;
|
||||
|
||||
g_return_if_fail (GIMP_IS_OFFSET_AREA (area));
|
||||
|
||||
private = gimp_offset_area_get_instance_private (area);
|
||||
|
||||
if (private->offset_x != offset_x || private->offset_y != offset_y)
|
||||
if (area->offset_x != offset_x || area->offset_y != offset_y)
|
||||
{
|
||||
if (private->orig_width <= private->width)
|
||||
private->offset_x = CLAMP (offset_x,
|
||||
0, private->width - private->orig_width);
|
||||
if (area->orig_width <= area->width)
|
||||
area->offset_x = CLAMP (offset_x,
|
||||
0, area->width - area->orig_width);
|
||||
else
|
||||
private->offset_x = CLAMP (offset_x,
|
||||
private->width - private->orig_width, 0);
|
||||
area->offset_x = CLAMP (offset_x,
|
||||
area->width - area->orig_width, 0);
|
||||
|
||||
if (private->orig_height <= private->height)
|
||||
private->offset_y = CLAMP (offset_y,
|
||||
0, private->height - private->orig_height);
|
||||
if (area->orig_height <= area->height)
|
||||
area->offset_y = CLAMP (offset_y,
|
||||
0, area->height - area->orig_height);
|
||||
else
|
||||
private->offset_y = CLAMP (offset_y,
|
||||
private->height - private->orig_height, 0);
|
||||
area->offset_y = CLAMP (offset_y,
|
||||
area->height - area->orig_height, 0);
|
||||
|
||||
gtk_widget_queue_draw (GTK_WIDGET (area));
|
||||
}
|
||||
|
@ -276,25 +262,22 @@ gimp_offset_area_set_offsets (GimpOffsetArea *area,
|
|||
static void
|
||||
gimp_offset_area_resize (GimpOffsetArea *area)
|
||||
{
|
||||
GimpOffsetAreaPrivate *private;
|
||||
gint width;
|
||||
gint height;
|
||||
gdouble ratio;
|
||||
gint width;
|
||||
gint height;
|
||||
gdouble ratio;
|
||||
|
||||
private = gimp_offset_area_get_instance_private (area);
|
||||
|
||||
if (private->orig_width == 0 || private->orig_height == 0)
|
||||
if (area->orig_width == 0 || area->orig_height == 0)
|
||||
return;
|
||||
|
||||
if (private->orig_width <= private->width)
|
||||
width = private->width;
|
||||
if (area->orig_width <= area->width)
|
||||
width = area->width;
|
||||
else
|
||||
width = private->orig_width * 2 - private->width;
|
||||
width = area->orig_width * 2 - area->width;
|
||||
|
||||
if (private->orig_height <= private->height)
|
||||
height = private->height;
|
||||
if (area->orig_height <= area->height)
|
||||
height = area->height;
|
||||
else
|
||||
height = private->orig_height * 2 - private->height;
|
||||
height = area->orig_height * 2 - area->height;
|
||||
|
||||
ratio = (gdouble) DRAWING_AREA_SIZE / (gdouble) MAX (width, height);
|
||||
|
||||
|
@ -309,23 +292,20 @@ static void
|
|||
gimp_offset_area_size_allocate (GtkWidget *widget,
|
||||
GtkAllocation *allocation)
|
||||
{
|
||||
GimpOffsetArea *area = GIMP_OFFSET_AREA (widget);
|
||||
GimpOffsetAreaPrivate *private;
|
||||
GdkPixbuf *pixbuf;
|
||||
GimpOffsetArea *area = GIMP_OFFSET_AREA (widget);
|
||||
GdkPixbuf *pixbuf;
|
||||
|
||||
GTK_WIDGET_CLASS (parent_class)->size_allocate (widget, allocation);
|
||||
|
||||
private = gimp_offset_area_get_instance_private (area);
|
||||
area->display_ratio_x = ((gdouble) allocation->width /
|
||||
((area->orig_width <= area->width) ?
|
||||
area->width :
|
||||
area->orig_width * 2 - area->width));
|
||||
|
||||
private->display_ratio_x = ((gdouble) allocation->width /
|
||||
((private->orig_width <= private->width) ?
|
||||
private->width :
|
||||
private->orig_width * 2 - private->width));
|
||||
|
||||
private->display_ratio_y = ((gdouble) allocation->height /
|
||||
((private->orig_height <= private->height) ?
|
||||
private->height :
|
||||
private->orig_height * 2 - private->height));
|
||||
area->display_ratio_y = ((gdouble) allocation->height /
|
||||
((area->orig_height <= area->height) ?
|
||||
area->height :
|
||||
area->orig_height * 2 - area->height));
|
||||
|
||||
pixbuf = g_object_get_data (G_OBJECT (area), "pixbuf");
|
||||
|
||||
|
@ -335,10 +315,10 @@ gimp_offset_area_size_allocate (GtkWidget *widget,
|
|||
gint pixbuf_width;
|
||||
gint pixbuf_height;
|
||||
|
||||
pixbuf_width = private->display_ratio_x * private->orig_width;
|
||||
pixbuf_width = area->display_ratio_x * area->orig_width;
|
||||
pixbuf_width = MAX (pixbuf_width, 1);
|
||||
|
||||
pixbuf_height = private->display_ratio_y * private->orig_height;
|
||||
pixbuf_height = area->display_ratio_y * area->orig_height;
|
||||
pixbuf_height = MAX (pixbuf_height, 1);
|
||||
|
||||
copy = g_object_get_data (G_OBJECT (area), "pixbuf-copy");
|
||||
|
@ -383,14 +363,11 @@ gimp_offset_area_event (GtkWidget *widget,
|
|||
static gint start_x = 0;
|
||||
static gint start_y = 0;
|
||||
|
||||
GimpOffsetArea *area = GIMP_OFFSET_AREA (widget);
|
||||
GimpOffsetAreaPrivate *private;
|
||||
gint offset_x;
|
||||
gint offset_y;
|
||||
GimpOffsetArea *area = GIMP_OFFSET_AREA (widget);
|
||||
gint offset_x;
|
||||
gint offset_y;
|
||||
|
||||
private = gimp_offset_area_get_instance_private (area);
|
||||
|
||||
if (private->orig_width == 0 || private->orig_height == 0)
|
||||
if (area->orig_width == 0 || area->orig_height == 0)
|
||||
return FALSE;
|
||||
|
||||
switch (event->type)
|
||||
|
@ -400,8 +377,8 @@ gimp_offset_area_event (GtkWidget *widget,
|
|||
{
|
||||
gtk_grab_add (widget);
|
||||
|
||||
orig_offset_x = private->offset_x;
|
||||
orig_offset_y = private->offset_y;
|
||||
orig_offset_x = area->offset_x;
|
||||
orig_offset_y = area->offset_y;
|
||||
start_x = event->button.x;
|
||||
start_y = event->button.y;
|
||||
}
|
||||
|
@ -409,17 +386,17 @@ gimp_offset_area_event (GtkWidget *widget,
|
|||
|
||||
case GDK_MOTION_NOTIFY:
|
||||
offset_x = (orig_offset_x +
|
||||
(event->motion.x - start_x) / private->display_ratio_x);
|
||||
(event->motion.x - start_x) / area->display_ratio_x);
|
||||
offset_y = (orig_offset_y +
|
||||
(event->motion.y - start_y) / private->display_ratio_y);
|
||||
(event->motion.y - start_y) / area->display_ratio_y);
|
||||
|
||||
if (private->offset_x != offset_x || private->offset_y != offset_y)
|
||||
if (area->offset_x != offset_x || area->offset_y != offset_y)
|
||||
{
|
||||
gimp_offset_area_set_offsets (area, offset_x, offset_y);
|
||||
|
||||
g_signal_emit (area,
|
||||
gimp_offset_area_signals[OFFSETS_CHANGED], 0,
|
||||
private->offset_x, private->offset_y);
|
||||
area->offset_x, area->offset_y);
|
||||
}
|
||||
break;
|
||||
|
||||
|
@ -443,32 +420,29 @@ static gboolean
|
|||
gimp_offset_area_draw (GtkWidget *widget,
|
||||
cairo_t *cr)
|
||||
{
|
||||
GimpOffsetArea *area = GIMP_OFFSET_AREA (widget);
|
||||
GimpOffsetAreaPrivate *private;
|
||||
GtkStyleContext *context = gtk_widget_get_style_context (widget);
|
||||
GtkAllocation allocation;
|
||||
GdkPixbuf *pixbuf;
|
||||
gint w, h;
|
||||
gint x, y;
|
||||
|
||||
private = gimp_offset_area_get_instance_private (area);
|
||||
GimpOffsetArea *area = GIMP_OFFSET_AREA (widget);
|
||||
GtkStyleContext *context = gtk_widget_get_style_context (widget);
|
||||
GtkAllocation allocation;
|
||||
GdkPixbuf *pixbuf;
|
||||
gint w, h;
|
||||
gint x, y;
|
||||
|
||||
gtk_widget_get_allocation (widget, &allocation);
|
||||
|
||||
x = (private->display_ratio_x *
|
||||
((private->orig_width <= private->width) ?
|
||||
private->offset_x :
|
||||
private->offset_x + private->orig_width - private->width));
|
||||
x = (area->display_ratio_x *
|
||||
((area->orig_width <= area->width) ?
|
||||
area->offset_x :
|
||||
area->offset_x + area->orig_width - area->width));
|
||||
|
||||
y = (private->display_ratio_y *
|
||||
((private->orig_height <= private->height) ?
|
||||
private->offset_y :
|
||||
private->offset_y + private->orig_height - private->height));
|
||||
y = (area->display_ratio_y *
|
||||
((area->orig_height <= area->height) ?
|
||||
area->offset_y :
|
||||
area->offset_y + area->orig_height - area->height));
|
||||
|
||||
w = private->display_ratio_x * private->orig_width;
|
||||
w = area->display_ratio_x * area->orig_width;
|
||||
w = MAX (w, 1);
|
||||
|
||||
h = private->display_ratio_y * private->orig_height;
|
||||
h = area->display_ratio_y * area->orig_height;
|
||||
h = MAX (h, 1);
|
||||
|
||||
pixbuf = g_object_get_data (G_OBJECT (widget), "pixbuf-copy");
|
||||
|
@ -488,15 +462,15 @@ gimp_offset_area_draw (GtkWidget *widget,
|
|||
gtk_render_frame (context, cr, x, y, w, h);
|
||||
}
|
||||
|
||||
if (private->orig_width > private->width ||
|
||||
private->orig_height > private->height)
|
||||
if (area->orig_width > area->width ||
|
||||
area->orig_height > area->height)
|
||||
{
|
||||
gint line_width;
|
||||
|
||||
if (private->orig_width > private->width)
|
||||
if (area->orig_width > area->width)
|
||||
{
|
||||
x = private->display_ratio_x * (private->orig_width - private->width);
|
||||
w = private->display_ratio_x * private->width;
|
||||
x = area->display_ratio_x * (area->orig_width - area->width);
|
||||
w = area->display_ratio_x * area->width;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -504,10 +478,10 @@ gimp_offset_area_draw (GtkWidget *widget,
|
|||
w = allocation.width + 2;
|
||||
}
|
||||
|
||||
if (private->orig_height > private->height)
|
||||
if (area->orig_height > area->height)
|
||||
{
|
||||
y = private->display_ratio_y * (private->orig_height - private->height);
|
||||
h = private->display_ratio_y * private->height;
|
||||
y = area->display_ratio_y * (area->orig_height - area->height);
|
||||
h = area->display_ratio_y * area->height;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -32,26 +32,7 @@ G_BEGIN_DECLS
|
|||
/* For information look into the C source or the html documentation */
|
||||
|
||||
#define GIMP_TYPE_OFFSET_AREA (gimp_offset_area_get_type ())
|
||||
G_DECLARE_DERIVABLE_TYPE (GimpOffsetArea, gimp_offset_area, GIMP, OFFSET_AREA, GtkDrawingArea)
|
||||
|
||||
struct _GimpOffsetAreaClass
|
||||
{
|
||||
GtkDrawingAreaClass parent_class;
|
||||
|
||||
void (* offsets_changed) (GimpOffsetArea *offset_area,
|
||||
gint offset_x,
|
||||
gint offset_y);
|
||||
|
||||
/* 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);
|
||||
};
|
||||
G_DECLARE_FINAL_TYPE (GimpOffsetArea, gimp_offset_area, GIMP, OFFSET_AREA, GtkDrawingArea)
|
||||
|
||||
|
||||
GtkWidget * gimp_offset_area_new (gint orig_width,
|
||||
|
|
|
@ -72,8 +72,10 @@ enum
|
|||
};
|
||||
|
||||
|
||||
typedef struct _GimpPageSelectorPrivate
|
||||
struct _GimpPageSelector
|
||||
{
|
||||
GtkBox parent_instance;
|
||||
|
||||
gint n_pages;
|
||||
GimpPageSelectorTarget target;
|
||||
|
||||
|
@ -84,7 +86,7 @@ typedef struct _GimpPageSelectorPrivate
|
|||
GtkWidget *range_entry;
|
||||
|
||||
GdkPixbuf *default_thumbnail;
|
||||
} GimpPageSelectorPrivate;
|
||||
};
|
||||
|
||||
|
||||
static void gimp_page_selector_finalize (GObject *object);
|
||||
|
@ -117,7 +119,7 @@ static GdkPixbuf * gimp_page_selector_add_frame (GtkWidget *widget,
|
|||
GdkPixbuf *pixbuf);
|
||||
|
||||
|
||||
G_DEFINE_TYPE_WITH_PRIVATE (GimpPageSelector, gimp_page_selector, GTK_TYPE_BOX)
|
||||
G_DEFINE_TYPE (GimpPageSelector, gimp_page_selector, GTK_TYPE_BOX)
|
||||
|
||||
#define parent_class gimp_page_selector_parent_class
|
||||
|
||||
|
@ -134,9 +136,6 @@ gimp_page_selector_class_init (GimpPageSelectorClass *klass)
|
|||
object_class->get_property = gimp_page_selector_get_property;
|
||||
object_class->set_property = gimp_page_selector_set_property;
|
||||
|
||||
klass->selection_changed = NULL;
|
||||
klass->activate = NULL;
|
||||
|
||||
/**
|
||||
* GimpPageSelector::selection-changed:
|
||||
* @widget: the object which received the signal.
|
||||
|
@ -149,7 +148,7 @@ gimp_page_selector_class_init (GimpPageSelectorClass *klass)
|
|||
g_signal_new ("selection-changed",
|
||||
G_TYPE_FROM_CLASS (klass),
|
||||
G_SIGNAL_RUN_FIRST,
|
||||
G_STRUCT_OFFSET (GimpPageSelectorClass, selection_changed),
|
||||
0,
|
||||
NULL, NULL, NULL,
|
||||
G_TYPE_NONE, 0);
|
||||
|
||||
|
@ -166,7 +165,7 @@ gimp_page_selector_class_init (GimpPageSelectorClass *klass)
|
|||
g_signal_new ("activate",
|
||||
G_OBJECT_CLASS_TYPE (object_class),
|
||||
G_SIGNAL_RUN_FIRST | G_SIGNAL_ACTION,
|
||||
G_STRUCT_OFFSET (GimpPageSelectorClass, activate),
|
||||
0,
|
||||
NULL, NULL, NULL,
|
||||
G_TYPE_NONE, 0);
|
||||
widget_class->activate_signal = selector_signals[ACTIVATE];
|
||||
|
@ -204,20 +203,17 @@ gimp_page_selector_class_init (GimpPageSelectorClass *klass)
|
|||
static void
|
||||
gimp_page_selector_init (GimpPageSelector *selector)
|
||||
{
|
||||
GimpPageSelectorPrivate *priv;
|
||||
GtkWidget *vbox;
|
||||
GtkWidget *sw;
|
||||
GtkWidget *hbox;
|
||||
GtkWidget *hbbox;
|
||||
GtkWidget *button;
|
||||
GtkWidget *label;
|
||||
GtkWidget *combo;
|
||||
GtkCellRenderer *renderer;
|
||||
GtkWidget *vbox;
|
||||
GtkWidget *sw;
|
||||
GtkWidget *hbox;
|
||||
GtkWidget *hbbox;
|
||||
GtkWidget *button;
|
||||
GtkWidget *label;
|
||||
GtkWidget *combo;
|
||||
GtkCellRenderer *renderer;
|
||||
|
||||
priv = gimp_page_selector_get_instance_private (selector);
|
||||
|
||||
priv->n_pages = 0;
|
||||
priv->target = GIMP_PAGE_SELECTOR_TARGET_LAYERS;
|
||||
selector->n_pages = 0;
|
||||
selector->target = GIMP_PAGE_SELECTOR_TARGET_LAYERS;
|
||||
|
||||
gtk_orientable_set_orientation (GTK_ORIENTABLE (selector),
|
||||
GTK_ORIENTATION_VERTICAL);
|
||||
|
@ -237,27 +233,27 @@ gimp_page_selector_init (GimpPageSelector *selector)
|
|||
gtk_box_pack_start (GTK_BOX (vbox), sw, TRUE, TRUE, 0);
|
||||
gtk_widget_show (sw);
|
||||
|
||||
priv->store = gtk_list_store_new (4,
|
||||
G_TYPE_INT,
|
||||
GDK_TYPE_PIXBUF,
|
||||
G_TYPE_STRING,
|
||||
G_TYPE_BOOLEAN);
|
||||
selector->store = gtk_list_store_new (4,
|
||||
G_TYPE_INT,
|
||||
GDK_TYPE_PIXBUF,
|
||||
G_TYPE_STRING,
|
||||
G_TYPE_BOOLEAN);
|
||||
|
||||
priv->view = gtk_icon_view_new_with_model (GTK_TREE_MODEL (priv->store));
|
||||
gtk_icon_view_set_selection_mode (GTK_ICON_VIEW (priv->view),
|
||||
selector->view = gtk_icon_view_new_with_model (GTK_TREE_MODEL (selector->store));
|
||||
gtk_icon_view_set_selection_mode (GTK_ICON_VIEW (selector->view),
|
||||
GTK_SELECTION_MULTIPLE);
|
||||
gtk_container_add (GTK_CONTAINER (sw), priv->view);
|
||||
gtk_widget_show (priv->view);
|
||||
gtk_container_add (GTK_CONTAINER (sw), selector->view);
|
||||
gtk_widget_show (selector->view);
|
||||
|
||||
renderer = gtk_cell_renderer_pixbuf_new ();
|
||||
gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (priv->view), renderer, FALSE);
|
||||
gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (priv->view), renderer,
|
||||
gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (selector->view), renderer, FALSE);
|
||||
gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (selector->view), renderer,
|
||||
"pixbuf", COLUMN_THUMBNAIL,
|
||||
NULL);
|
||||
|
||||
renderer = gtk_cell_renderer_text_new ();
|
||||
gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (priv->view), renderer, FALSE);
|
||||
gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (priv->view), renderer,
|
||||
gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (selector->view), renderer, FALSE);
|
||||
gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (selector->view), renderer,
|
||||
"text", COLUMN_LABEL,
|
||||
NULL);
|
||||
g_object_set (renderer,
|
||||
|
@ -267,22 +263,22 @@ gimp_page_selector_init (GimpPageSelector *selector)
|
|||
"yalign", 0.0,
|
||||
NULL);
|
||||
|
||||
g_signal_connect (priv->view, "selection-changed",
|
||||
g_signal_connect (selector->view, "selection-changed",
|
||||
G_CALLBACK (gimp_page_selector_selection_changed),
|
||||
selector);
|
||||
g_signal_connect (priv->view, "item-activated",
|
||||
g_signal_connect (selector->view, "item-activated",
|
||||
G_CALLBACK (gimp_page_selector_item_activated),
|
||||
selector);
|
||||
|
||||
/* Count label */
|
||||
|
||||
priv->count_label = gtk_label_new (_("Nothing selected"));
|
||||
gtk_label_set_xalign (GTK_LABEL (priv->count_label), 0.0);
|
||||
gimp_label_set_attributes (GTK_LABEL (priv->count_label),
|
||||
selector->count_label = gtk_label_new (_("Nothing selected"));
|
||||
gtk_label_set_xalign (GTK_LABEL (selector->count_label), 0.0);
|
||||
gimp_label_set_attributes (GTK_LABEL (selector->count_label),
|
||||
PANGO_ATTR_STYLE, PANGO_STYLE_ITALIC,
|
||||
-1);
|
||||
gtk_box_pack_start (GTK_BOX (vbox), priv->count_label, FALSE, FALSE, 0);
|
||||
gtk_widget_show (priv->count_label);
|
||||
gtk_box_pack_start (GTK_BOX (vbox), selector->count_label, FALSE, FALSE, 0);
|
||||
gtk_widget_show (selector->count_label);
|
||||
|
||||
/* Select all button & range entry */
|
||||
|
||||
|
@ -302,15 +298,15 @@ gimp_page_selector_init (GimpPageSelector *selector)
|
|||
G_CALLBACK (gimp_page_selector_select_all),
|
||||
selector);
|
||||
|
||||
priv->range_entry = gtk_entry_new ();
|
||||
gtk_widget_set_size_request (priv->range_entry, 80, -1);
|
||||
gtk_box_pack_end (GTK_BOX (hbox), priv->range_entry, TRUE, TRUE, 0);
|
||||
gtk_widget_show (priv->range_entry);
|
||||
selector->range_entry = gtk_entry_new ();
|
||||
gtk_widget_set_size_request (selector->range_entry, 80, -1);
|
||||
gtk_box_pack_end (GTK_BOX (hbox), selector->range_entry, TRUE, TRUE, 0);
|
||||
gtk_widget_show (selector->range_entry);
|
||||
|
||||
g_signal_connect (priv->range_entry, "focus-out-event",
|
||||
g_signal_connect (selector->range_entry, "focus-out-event",
|
||||
G_CALLBACK (gimp_page_selector_range_focus_out),
|
||||
selector);
|
||||
g_signal_connect (priv->range_entry, "activate",
|
||||
g_signal_connect (selector->range_entry, "activate",
|
||||
G_CALLBACK (gimp_page_selector_range_activate),
|
||||
selector);
|
||||
|
||||
|
@ -318,7 +314,7 @@ gimp_page_selector_init (GimpPageSelector *selector)
|
|||
gtk_box_pack_end (GTK_BOX (hbox), label, FALSE, FALSE, 0);
|
||||
gtk_widget_show (label);
|
||||
|
||||
gtk_label_set_mnemonic_widget (GTK_LABEL (label), priv->range_entry);
|
||||
gtk_label_set_mnemonic_widget (GTK_LABEL (label), selector->range_entry);
|
||||
|
||||
/* Target combo */
|
||||
|
||||
|
@ -336,7 +332,7 @@ gimp_page_selector_init (GimpPageSelector *selector)
|
|||
|
||||
gtk_label_set_mnemonic_widget (GTK_LABEL (label), combo);
|
||||
|
||||
priv->default_thumbnail =
|
||||
selector->default_thumbnail =
|
||||
gtk_icon_theme_load_icon (gtk_icon_theme_get_default (),
|
||||
"text-x-generic", 32, 0, NULL);
|
||||
}
|
||||
|
@ -344,12 +340,9 @@ gimp_page_selector_init (GimpPageSelector *selector)
|
|||
static void
|
||||
gimp_page_selector_finalize (GObject *object)
|
||||
{
|
||||
GimpPageSelector *selector = GIMP_PAGE_SELECTOR (object);
|
||||
GimpPageSelectorPrivate *priv;
|
||||
GimpPageSelector *selector = GIMP_PAGE_SELECTOR (object);
|
||||
|
||||
priv = gimp_page_selector_get_instance_private (selector);
|
||||
|
||||
g_clear_object (&priv->default_thumbnail);
|
||||
g_clear_object (&selector->default_thumbnail);
|
||||
|
||||
G_OBJECT_CLASS (parent_class)->finalize (object);
|
||||
}
|
||||
|
@ -360,18 +353,15 @@ gimp_page_selector_get_property (GObject *object,
|
|||
GValue *value,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
GimpPageSelector *selector = GIMP_PAGE_SELECTOR (object);
|
||||
GimpPageSelectorPrivate *priv;
|
||||
|
||||
priv = gimp_page_selector_get_instance_private (selector);
|
||||
GimpPageSelector *selector = GIMP_PAGE_SELECTOR (object);
|
||||
|
||||
switch (property_id)
|
||||
{
|
||||
case PROP_N_PAGES:
|
||||
g_value_set_int (value, priv->n_pages);
|
||||
g_value_set_int (value, selector->n_pages);
|
||||
break;
|
||||
case PROP_TARGET:
|
||||
g_value_set_enum (value, priv->target);
|
||||
g_value_set_enum (value, selector->target);
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
||||
|
@ -385,10 +375,7 @@ gimp_page_selector_set_property (GObject *object,
|
|||
const GValue *value,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
GimpPageSelector *selector = GIMP_PAGE_SELECTOR (object);
|
||||
GimpPageSelectorPrivate *priv;
|
||||
|
||||
priv = gimp_page_selector_get_instance_private (selector);
|
||||
GimpPageSelector *selector = GIMP_PAGE_SELECTOR (object);
|
||||
|
||||
switch (property_id)
|
||||
{
|
||||
|
@ -396,7 +383,7 @@ gimp_page_selector_set_property (GObject *object,
|
|||
gimp_page_selector_set_n_pages (selector, g_value_get_int (value));
|
||||
break;
|
||||
case PROP_TARGET:
|
||||
priv->target = g_value_get_enum (value);
|
||||
selector->target = g_value_get_enum (value);
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
||||
|
@ -435,39 +422,35 @@ void
|
|||
gimp_page_selector_set_n_pages (GimpPageSelector *selector,
|
||||
gint n_pages)
|
||||
{
|
||||
GimpPageSelectorPrivate *priv;
|
||||
|
||||
g_return_if_fail (GIMP_IS_PAGE_SELECTOR (selector));
|
||||
g_return_if_fail (n_pages >= 0);
|
||||
|
||||
priv = gimp_page_selector_get_instance_private (selector);
|
||||
|
||||
if (n_pages != priv->n_pages)
|
||||
if (n_pages != selector->n_pages)
|
||||
{
|
||||
GtkTreeIter iter;
|
||||
gint i;
|
||||
|
||||
if (n_pages < priv->n_pages)
|
||||
if (n_pages < selector->n_pages)
|
||||
{
|
||||
for (i = n_pages; i < priv->n_pages; i++)
|
||||
for (i = n_pages; i < selector->n_pages; i++)
|
||||
{
|
||||
gtk_tree_model_iter_nth_child (GTK_TREE_MODEL (priv->store),
|
||||
gtk_tree_model_iter_nth_child (GTK_TREE_MODEL (selector->store),
|
||||
&iter, NULL, n_pages);
|
||||
gtk_list_store_remove (priv->store, &iter);
|
||||
gtk_list_store_remove (selector->store, &iter);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for (i = priv->n_pages; i < n_pages; i++)
|
||||
for (i = selector->n_pages; i < n_pages; i++)
|
||||
{
|
||||
gchar *text;
|
||||
|
||||
text = g_strdup_printf (_("Page %d"), i + 1);
|
||||
|
||||
gtk_list_store_append (priv->store, &iter);
|
||||
gtk_list_store_set (priv->store, &iter,
|
||||
gtk_list_store_append (selector->store, &iter);
|
||||
gtk_list_store_set (selector->store, &iter,
|
||||
COLUMN_PAGE_NO, i,
|
||||
COLUMN_THUMBNAIL, priv->default_thumbnail,
|
||||
COLUMN_THUMBNAIL, selector->default_thumbnail,
|
||||
COLUMN_LABEL, text,
|
||||
COLUMN_LABEL_SET, FALSE,
|
||||
-1);
|
||||
|
@ -476,7 +459,7 @@ gimp_page_selector_set_n_pages (GimpPageSelector *selector,
|
|||
}
|
||||
}
|
||||
|
||||
priv->n_pages = n_pages;
|
||||
selector->n_pages = n_pages;
|
||||
|
||||
g_object_notify (G_OBJECT (selector), "n-pages");
|
||||
}
|
||||
|
@ -493,13 +476,9 @@ gimp_page_selector_set_n_pages (GimpPageSelector *selector,
|
|||
gint
|
||||
gimp_page_selector_get_n_pages (GimpPageSelector *selector)
|
||||
{
|
||||
GimpPageSelectorPrivate *priv;
|
||||
|
||||
g_return_val_if_fail (GIMP_IS_PAGE_SELECTOR (selector), 0);
|
||||
|
||||
priv = gimp_page_selector_get_instance_private (selector);
|
||||
|
||||
return priv->n_pages;
|
||||
return selector->n_pages;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -513,16 +492,12 @@ void
|
|||
gimp_page_selector_set_target (GimpPageSelector *selector,
|
||||
GimpPageSelectorTarget target)
|
||||
{
|
||||
GimpPageSelectorPrivate *priv;
|
||||
|
||||
g_return_if_fail (GIMP_IS_PAGE_SELECTOR (selector));
|
||||
g_return_if_fail (target <= GIMP_PAGE_SELECTOR_TARGET_IMAGES);
|
||||
|
||||
priv = gimp_page_selector_get_instance_private (selector);
|
||||
|
||||
if (target != priv->target)
|
||||
if (target != selector->target)
|
||||
{
|
||||
priv->target = target;
|
||||
selector->target = target;
|
||||
|
||||
g_object_notify (G_OBJECT (selector), "target");
|
||||
}
|
||||
|
@ -539,14 +514,10 @@ gimp_page_selector_set_target (GimpPageSelector *selector,
|
|||
GimpPageSelectorTarget
|
||||
gimp_page_selector_get_target (GimpPageSelector *selector)
|
||||
{
|
||||
GimpPageSelectorPrivate *priv;
|
||||
|
||||
g_return_val_if_fail (GIMP_IS_PAGE_SELECTOR (selector),
|
||||
GIMP_PAGE_SELECTOR_TARGET_LAYERS);
|
||||
|
||||
priv = gimp_page_selector_get_instance_private (selector);
|
||||
|
||||
return priv->target;
|
||||
return selector->target;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -565,22 +536,19 @@ gimp_page_selector_set_page_thumbnail (GimpPageSelector *selector,
|
|||
gint page_no,
|
||||
GdkPixbuf *thumbnail)
|
||||
{
|
||||
GimpPageSelectorPrivate *priv;
|
||||
GtkTreeIter iter;
|
||||
GtkTreeIter iter;
|
||||
|
||||
g_return_if_fail (GIMP_IS_PAGE_SELECTOR (selector));
|
||||
g_return_if_fail (thumbnail == NULL || GDK_IS_PIXBUF (thumbnail));
|
||||
|
||||
priv = gimp_page_selector_get_instance_private (selector);
|
||||
g_return_if_fail (page_no >= 0 && page_no < selector->n_pages);
|
||||
|
||||
g_return_if_fail (page_no >= 0 && page_no < priv->n_pages);
|
||||
|
||||
gtk_tree_model_iter_nth_child (GTK_TREE_MODEL (priv->store),
|
||||
gtk_tree_model_iter_nth_child (GTK_TREE_MODEL (selector->store),
|
||||
&iter, NULL, page_no);
|
||||
|
||||
if (! thumbnail)
|
||||
{
|
||||
thumbnail = g_object_ref (priv->default_thumbnail);
|
||||
thumbnail = g_object_ref (selector->default_thumbnail);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -588,7 +556,7 @@ gimp_page_selector_set_page_thumbnail (GimpPageSelector *selector,
|
|||
thumbnail);
|
||||
}
|
||||
|
||||
gtk_list_store_set (priv->store, &iter,
|
||||
gtk_list_store_set (selector->store, &iter,
|
||||
COLUMN_THUMBNAIL, thumbnail,
|
||||
-1);
|
||||
g_clear_object (&thumbnail);
|
||||
|
@ -609,26 +577,23 @@ GdkPixbuf *
|
|||
gimp_page_selector_get_page_thumbnail (GimpPageSelector *selector,
|
||||
gint page_no)
|
||||
{
|
||||
GimpPageSelectorPrivate *priv;
|
||||
GdkPixbuf *thumbnail;
|
||||
GtkTreeIter iter;
|
||||
GdkPixbuf *thumbnail;
|
||||
GtkTreeIter iter;
|
||||
|
||||
g_return_val_if_fail (GIMP_IS_PAGE_SELECTOR (selector), NULL);
|
||||
|
||||
priv = gimp_page_selector_get_instance_private (selector);
|
||||
g_return_val_if_fail (page_no >= 0 && page_no < selector->n_pages, NULL);
|
||||
|
||||
g_return_val_if_fail (page_no >= 0 && page_no < priv->n_pages, NULL);
|
||||
|
||||
gtk_tree_model_iter_nth_child (GTK_TREE_MODEL (priv->store),
|
||||
gtk_tree_model_iter_nth_child (GTK_TREE_MODEL (selector->store),
|
||||
&iter, NULL, page_no);
|
||||
gtk_tree_model_get (GTK_TREE_MODEL (priv->store), &iter,
|
||||
gtk_tree_model_get (GTK_TREE_MODEL (selector->store), &iter,
|
||||
COLUMN_THUMBNAIL, &thumbnail,
|
||||
-1);
|
||||
|
||||
if (thumbnail)
|
||||
g_object_unref (thumbnail);
|
||||
|
||||
if (thumbnail == priv->default_thumbnail)
|
||||
if (thumbnail == selector->default_thumbnail)
|
||||
return NULL;
|
||||
|
||||
return thumbnail;
|
||||
|
@ -649,24 +614,21 @@ gimp_page_selector_set_page_label (GimpPageSelector *selector,
|
|||
gint page_no,
|
||||
const gchar *label)
|
||||
{
|
||||
GimpPageSelectorPrivate *priv;
|
||||
GtkTreeIter iter;
|
||||
gchar *tmp;
|
||||
GtkTreeIter iter;
|
||||
gchar *tmp;
|
||||
|
||||
g_return_if_fail (GIMP_IS_PAGE_SELECTOR (selector));
|
||||
|
||||
priv = gimp_page_selector_get_instance_private (selector);
|
||||
|
||||
g_return_if_fail (page_no >= 0 && page_no < priv->n_pages);
|
||||
g_return_if_fail (page_no >= 0 && page_no < selector->n_pages);
|
||||
|
||||
if (! label)
|
||||
tmp = g_strdup_printf (_("Page %d"), page_no + 1);
|
||||
else
|
||||
tmp = (gchar *) label;
|
||||
|
||||
gtk_tree_model_iter_nth_child (GTK_TREE_MODEL (priv->store),
|
||||
gtk_tree_model_iter_nth_child (GTK_TREE_MODEL (selector->store),
|
||||
&iter, NULL, page_no);
|
||||
gtk_list_store_set (priv->store, &iter,
|
||||
gtk_list_store_set (selector->store, &iter,
|
||||
COLUMN_LABEL, tmp,
|
||||
COLUMN_LABEL_SET, label != NULL,
|
||||
-1);
|
||||
|
@ -690,20 +652,17 @@ gchar *
|
|||
gimp_page_selector_get_page_label (GimpPageSelector *selector,
|
||||
gint page_no)
|
||||
{
|
||||
GimpPageSelectorPrivate *priv;
|
||||
GtkTreeIter iter;
|
||||
gchar *label;
|
||||
gboolean label_set;
|
||||
GtkTreeIter iter;
|
||||
gchar *label;
|
||||
gboolean label_set;
|
||||
|
||||
g_return_val_if_fail (GIMP_IS_PAGE_SELECTOR (selector), NULL);
|
||||
|
||||
priv = gimp_page_selector_get_instance_private (selector);
|
||||
g_return_val_if_fail (page_no >= 0 && page_no < selector->n_pages, NULL);
|
||||
|
||||
g_return_val_if_fail (page_no >= 0 && page_no < priv->n_pages, NULL);
|
||||
|
||||
gtk_tree_model_iter_nth_child (GTK_TREE_MODEL (priv->store),
|
||||
gtk_tree_model_iter_nth_child (GTK_TREE_MODEL (selector->store),
|
||||
&iter, NULL, page_no);
|
||||
gtk_tree_model_get (GTK_TREE_MODEL (priv->store), &iter,
|
||||
gtk_tree_model_get (GTK_TREE_MODEL (selector->store), &iter,
|
||||
COLUMN_LABEL, &label,
|
||||
COLUMN_LABEL_SET, &label_set,
|
||||
-1);
|
||||
|
@ -728,13 +687,9 @@ gimp_page_selector_get_page_label (GimpPageSelector *selector,
|
|||
void
|
||||
gimp_page_selector_select_all (GimpPageSelector *selector)
|
||||
{
|
||||
GimpPageSelectorPrivate *priv;
|
||||
|
||||
g_return_if_fail (GIMP_IS_PAGE_SELECTOR (selector));
|
||||
|
||||
priv = gimp_page_selector_get_instance_private (selector);
|
||||
|
||||
gtk_icon_view_select_all (GTK_ICON_VIEW (priv->view));
|
||||
gtk_icon_view_select_all (GTK_ICON_VIEW (selector->view));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -748,13 +703,9 @@ gimp_page_selector_select_all (GimpPageSelector *selector)
|
|||
void
|
||||
gimp_page_selector_unselect_all (GimpPageSelector *selector)
|
||||
{
|
||||
GimpPageSelectorPrivate *priv;
|
||||
|
||||
g_return_if_fail (GIMP_IS_PAGE_SELECTOR (selector));
|
||||
|
||||
priv = gimp_page_selector_get_instance_private (selector);
|
||||
|
||||
gtk_icon_view_unselect_all (GTK_ICON_VIEW (priv->view));
|
||||
gtk_icon_view_unselect_all (GTK_ICON_VIEW (selector->view));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -770,21 +721,18 @@ void
|
|||
gimp_page_selector_select_page (GimpPageSelector *selector,
|
||||
gint page_no)
|
||||
{
|
||||
GimpPageSelectorPrivate *priv;
|
||||
GtkTreeIter iter;
|
||||
GtkTreePath *path;
|
||||
GtkTreeIter iter;
|
||||
GtkTreePath *path;
|
||||
|
||||
g_return_if_fail (GIMP_IS_PAGE_SELECTOR (selector));
|
||||
|
||||
priv = gimp_page_selector_get_instance_private (selector);
|
||||
g_return_if_fail (page_no >= 0 && page_no < selector->n_pages);
|
||||
|
||||
g_return_if_fail (page_no >= 0 && page_no < priv->n_pages);
|
||||
|
||||
gtk_tree_model_iter_nth_child (GTK_TREE_MODEL (priv->store),
|
||||
gtk_tree_model_iter_nth_child (GTK_TREE_MODEL (selector->store),
|
||||
&iter, NULL, page_no);
|
||||
path = gtk_tree_model_get_path (GTK_TREE_MODEL (priv->store), &iter);
|
||||
path = gtk_tree_model_get_path (GTK_TREE_MODEL (selector->store), &iter);
|
||||
|
||||
gtk_icon_view_select_path (GTK_ICON_VIEW (priv->view), path);
|
||||
gtk_icon_view_select_path (GTK_ICON_VIEW (selector->view), path);
|
||||
|
||||
gtk_tree_path_free (path);
|
||||
}
|
||||
|
@ -802,21 +750,18 @@ void
|
|||
gimp_page_selector_unselect_page (GimpPageSelector *selector,
|
||||
gint page_no)
|
||||
{
|
||||
GimpPageSelectorPrivate *priv;
|
||||
GtkTreeIter iter;
|
||||
GtkTreePath *path;
|
||||
GtkTreeIter iter;
|
||||
GtkTreePath *path;
|
||||
|
||||
g_return_if_fail (GIMP_IS_PAGE_SELECTOR (selector));
|
||||
|
||||
priv = gimp_page_selector_get_instance_private (selector);
|
||||
g_return_if_fail (page_no >= 0 && page_no < selector->n_pages);
|
||||
|
||||
g_return_if_fail (page_no >= 0 && page_no < priv->n_pages);
|
||||
|
||||
gtk_tree_model_iter_nth_child (GTK_TREE_MODEL (priv->store),
|
||||
gtk_tree_model_iter_nth_child (GTK_TREE_MODEL (selector->store),
|
||||
&iter, NULL, page_no);
|
||||
path = gtk_tree_model_get_path (GTK_TREE_MODEL (priv->store), &iter);
|
||||
path = gtk_tree_model_get_path (GTK_TREE_MODEL (selector->store), &iter);
|
||||
|
||||
gtk_icon_view_unselect_path (GTK_ICON_VIEW (priv->view), path);
|
||||
gtk_icon_view_unselect_path (GTK_ICON_VIEW (selector->view), path);
|
||||
|
||||
gtk_tree_path_free (path);
|
||||
}
|
||||
|
@ -834,22 +779,19 @@ gboolean
|
|||
gimp_page_selector_page_is_selected (GimpPageSelector *selector,
|
||||
gint page_no)
|
||||
{
|
||||
GimpPageSelectorPrivate *priv;
|
||||
GtkTreeIter iter;
|
||||
GtkTreePath *path;
|
||||
gboolean selected;
|
||||
GtkTreeIter iter;
|
||||
GtkTreePath *path;
|
||||
gboolean selected;
|
||||
|
||||
g_return_val_if_fail (GIMP_IS_PAGE_SELECTOR (selector), FALSE);
|
||||
|
||||
priv = gimp_page_selector_get_instance_private (selector);
|
||||
g_return_val_if_fail (page_no >= 0 && page_no < selector->n_pages, FALSE);
|
||||
|
||||
g_return_val_if_fail (page_no >= 0 && page_no < priv->n_pages, FALSE);
|
||||
|
||||
gtk_tree_model_iter_nth_child (GTK_TREE_MODEL (priv->store),
|
||||
gtk_tree_model_iter_nth_child (GTK_TREE_MODEL (selector->store),
|
||||
&iter, NULL, page_no);
|
||||
path = gtk_tree_model_get_path (GTK_TREE_MODEL (priv->store), &iter);
|
||||
path = gtk_tree_model_get_path (GTK_TREE_MODEL (selector->store), &iter);
|
||||
|
||||
selected = gtk_icon_view_path_is_selected (GTK_ICON_VIEW (priv->view),
|
||||
selected = gtk_icon_view_path_is_selected (GTK_ICON_VIEW (selector->view),
|
||||
path);
|
||||
|
||||
gtk_tree_path_free (path);
|
||||
|
@ -871,18 +813,15 @@ gint *
|
|||
gimp_page_selector_get_selected_pages (GimpPageSelector *selector,
|
||||
gint *n_selected_pages)
|
||||
{
|
||||
GimpPageSelectorPrivate *priv;
|
||||
GList *selected;
|
||||
GList *list;
|
||||
gint *array;
|
||||
gint i;
|
||||
GList *selected;
|
||||
GList *list;
|
||||
gint *array;
|
||||
gint i;
|
||||
|
||||
g_return_val_if_fail (GIMP_IS_PAGE_SELECTOR (selector), NULL);
|
||||
g_return_val_if_fail (n_selected_pages != NULL, NULL);
|
||||
|
||||
priv = gimp_page_selector_get_instance_private (selector);
|
||||
|
||||
selected = gtk_icon_view_get_selected_items (GTK_ICON_VIEW (priv->view));
|
||||
selected = gtk_icon_view_get_selected_items (GTK_ICON_VIEW (selector->view));
|
||||
|
||||
*n_selected_pages = g_list_length (selected);
|
||||
array = g_new0 (gint, *n_selected_pages);
|
||||
|
@ -921,17 +860,14 @@ void
|
|||
gimp_page_selector_select_range (GimpPageSelector *selector,
|
||||
const gchar *range)
|
||||
{
|
||||
GimpPageSelectorPrivate *priv;
|
||||
gchar **ranges;
|
||||
gchar **ranges;
|
||||
|
||||
g_return_if_fail (GIMP_IS_PAGE_SELECTOR (selector));
|
||||
|
||||
priv = gimp_page_selector_get_instance_private (selector);
|
||||
|
||||
if (! range)
|
||||
range = "";
|
||||
|
||||
g_signal_handlers_block_by_func (priv->view,
|
||||
g_signal_handlers_block_by_func (selector->view,
|
||||
gimp_page_selector_selection_changed,
|
||||
selector);
|
||||
|
||||
|
@ -966,17 +902,17 @@ gimp_page_selector_select_range (GimpPageSelector *selector,
|
|||
page_from = 1;
|
||||
|
||||
if (sscanf (to, "%i", &page_to) != 1 && strlen (to) == 0)
|
||||
page_to = priv->n_pages;
|
||||
page_to = selector->n_pages;
|
||||
|
||||
if (page_from > 0 &&
|
||||
page_to > 0 &&
|
||||
page_from <= page_to &&
|
||||
page_from <= priv->n_pages)
|
||||
page_from <= selector->n_pages)
|
||||
{
|
||||
gint page_no;
|
||||
|
||||
page_from = MAX (page_from, 1) - 1;
|
||||
page_to = MIN (page_to, priv->n_pages) - 1;
|
||||
page_to = MIN (page_to, selector->n_pages) - 1;
|
||||
|
||||
for (page_no = page_from; page_no <= page_to; page_no++)
|
||||
gimp_page_selector_select_page (selector, page_no);
|
||||
|
@ -988,7 +924,7 @@ gimp_page_selector_select_range (GimpPageSelector *selector,
|
|||
|
||||
if (sscanf (range, "%i", &page_no) == 1 &&
|
||||
page_no >= 1 &&
|
||||
page_no <= priv->n_pages)
|
||||
page_no <= selector->n_pages)
|
||||
{
|
||||
gimp_page_selector_select_page (selector, page_no - 1);
|
||||
}
|
||||
|
@ -998,11 +934,11 @@ gimp_page_selector_select_range (GimpPageSelector *selector,
|
|||
g_strfreev (ranges);
|
||||
}
|
||||
|
||||
g_signal_handlers_unblock_by_func (priv->view,
|
||||
g_signal_handlers_unblock_by_func (selector->view,
|
||||
gimp_page_selector_selection_changed,
|
||||
selector);
|
||||
|
||||
gimp_page_selector_selection_changed (GTK_ICON_VIEW (priv->view), selector);
|
||||
gimp_page_selector_selection_changed (GTK_ICON_VIEW (selector->view), selector);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1062,38 +998,35 @@ gimp_page_selector_get_selected_range (GimpPageSelector *selector)
|
|||
}
|
||||
|
||||
|
||||
/* private functions */
|
||||
/* selectorate functions */
|
||||
|
||||
static void
|
||||
gimp_page_selector_selection_changed (GtkIconView *icon_view,
|
||||
GimpPageSelector *selector)
|
||||
{
|
||||
GimpPageSelectorPrivate *priv;
|
||||
GList *selected;
|
||||
gint n_selected;
|
||||
gchar *range;
|
||||
GList *selected;
|
||||
gint n_selected;
|
||||
gchar *range;
|
||||
|
||||
priv = gimp_page_selector_get_instance_private (selector);
|
||||
|
||||
selected = gtk_icon_view_get_selected_items (GTK_ICON_VIEW (priv->view));
|
||||
selected = gtk_icon_view_get_selected_items (GTK_ICON_VIEW (selector->view));
|
||||
n_selected = g_list_length (selected);
|
||||
g_list_free_full (selected, (GDestroyNotify) gtk_tree_path_free);
|
||||
|
||||
if (n_selected == 0)
|
||||
{
|
||||
gtk_label_set_text (GTK_LABEL (priv->count_label),
|
||||
gtk_label_set_text (GTK_LABEL (selector->count_label),
|
||||
_("Nothing selected"));
|
||||
}
|
||||
else if (n_selected == 1)
|
||||
{
|
||||
gtk_label_set_text (GTK_LABEL (priv->count_label),
|
||||
gtk_label_set_text (GTK_LABEL (selector->count_label),
|
||||
_("One page selected"));
|
||||
}
|
||||
else
|
||||
{
|
||||
gchar *text;
|
||||
|
||||
if (n_selected == priv->n_pages)
|
||||
if (n_selected == selector->n_pages)
|
||||
text = g_strdup_printf (ngettext ("%d page selected",
|
||||
"All %d pages selected", n_selected),
|
||||
n_selected);
|
||||
|
@ -1103,15 +1036,15 @@ gimp_page_selector_selection_changed (GtkIconView *icon_view,
|
|||
n_selected),
|
||||
n_selected);
|
||||
|
||||
gtk_label_set_text (GTK_LABEL (priv->count_label), text);
|
||||
gtk_label_set_text (GTK_LABEL (selector->count_label), text);
|
||||
g_free (text);
|
||||
}
|
||||
|
||||
range = gimp_page_selector_get_selected_range (selector);
|
||||
gtk_entry_set_text (GTK_ENTRY (priv->range_entry), range);
|
||||
gtk_entry_set_text (GTK_ENTRY (selector->range_entry), range);
|
||||
g_free (range);
|
||||
|
||||
gtk_editable_set_position (GTK_EDITABLE (priv->range_entry), -1);
|
||||
gtk_editable_set_position (GTK_EDITABLE (selector->range_entry), -1);
|
||||
|
||||
g_signal_emit (selector, selector_signals[SELECTION_CHANGED], 0);
|
||||
}
|
||||
|
|
|
@ -29,25 +29,7 @@
|
|||
G_BEGIN_DECLS
|
||||
|
||||
#define GIMP_TYPE_PAGE_SELECTOR (gimp_page_selector_get_type ())
|
||||
G_DECLARE_DERIVABLE_TYPE (GimpPageSelector, gimp_page_selector, GIMP, PAGE_SELECTOR, GtkBox)
|
||||
|
||||
struct _GimpPageSelectorClass
|
||||
{
|
||||
GtkBoxClass parent_class;
|
||||
|
||||
void (* selection_changed) (GimpPageSelector *selector);
|
||||
void (* activate) (GimpPageSelector *selector);
|
||||
|
||||
/* 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);
|
||||
};
|
||||
G_DECLARE_FINAL_TYPE (GimpPageSelector, gimp_page_selector, GIMP, PAGE_SELECTOR, GtkBox)
|
||||
|
||||
|
||||
GtkWidget * gimp_page_selector_new (void);
|
||||
|
|
|
@ -76,7 +76,7 @@ enum
|
|||
};
|
||||
|
||||
|
||||
typedef struct _GimpPathEditorPrivate
|
||||
struct _GimpPathEditor
|
||||
{
|
||||
GtkWidget *upper_hbox;
|
||||
|
||||
|
@ -95,9 +95,7 @@ typedef struct _GimpPathEditorPrivate
|
|||
GtkTreeViewColumn *writable_column;
|
||||
|
||||
gint num_items;
|
||||
} GimpPathEditorPrivate;
|
||||
|
||||
#define GET_PRIVATE(obj) ((GimpPathEditorPrivate *) gimp_path_editor_get_instance_private ((GimpPathEditor *) (obj)))
|
||||
};
|
||||
|
||||
|
||||
static void gimp_path_editor_new_clicked (GtkWidget *widget,
|
||||
|
@ -115,7 +113,7 @@ static void gimp_path_editor_writable_toggled (GtkCellRendererToggle *toggle
|
|||
GimpPathEditor *editor);
|
||||
|
||||
|
||||
G_DEFINE_TYPE_WITH_PRIVATE (GimpPathEditor, gimp_path_editor, GTK_TYPE_BOX)
|
||||
G_DEFINE_TYPE (GimpPathEditor, gimp_path_editor, GTK_TYPE_BOX)
|
||||
|
||||
#define parent_class gimp_path_editor_parent_class
|
||||
|
||||
|
@ -135,7 +133,7 @@ gimp_path_editor_class_init (GimpPathEditorClass *klass)
|
|||
g_signal_new ("path-changed",
|
||||
G_TYPE_FROM_CLASS (klass),
|
||||
G_SIGNAL_RUN_FIRST,
|
||||
G_STRUCT_OFFSET (GimpPathEditorClass, path_changed),
|
||||
0,
|
||||
NULL, NULL, NULL,
|
||||
G_TYPE_NONE, 0);
|
||||
|
||||
|
@ -150,43 +148,39 @@ gimp_path_editor_class_init (GimpPathEditorClass *klass)
|
|||
g_signal_new ("writable-changed",
|
||||
G_TYPE_FROM_CLASS (klass),
|
||||
G_SIGNAL_RUN_FIRST,
|
||||
G_STRUCT_OFFSET (GimpPathEditorClass, writable_changed),
|
||||
0,
|
||||
NULL, NULL, NULL,
|
||||
G_TYPE_NONE, 0);
|
||||
|
||||
klass->path_changed = NULL;
|
||||
klass->writable_changed = NULL;
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_path_editor_init (GimpPathEditor *editor)
|
||||
{
|
||||
GimpPathEditorPrivate *priv = GET_PRIVATE (editor);
|
||||
GtkWidget *button_box;
|
||||
GtkWidget *button;
|
||||
GtkWidget *image;
|
||||
GtkWidget *scrolled_window;
|
||||
GtkWidget *tv;
|
||||
GtkTreeViewColumn *col;
|
||||
GtkCellRenderer *renderer;
|
||||
GtkWidget *button_box;
|
||||
GtkWidget *button;
|
||||
GtkWidget *image;
|
||||
GtkWidget *scrolled_window;
|
||||
GtkWidget *tv;
|
||||
GtkTreeViewColumn *col;
|
||||
GtkCellRenderer *renderer;
|
||||
|
||||
priv->file_entry = NULL;
|
||||
priv->sel_path = NULL;
|
||||
priv->num_items = 0;
|
||||
editor->file_entry = NULL;
|
||||
editor->sel_path = NULL;
|
||||
editor->num_items = 0;
|
||||
|
||||
gtk_orientable_set_orientation (GTK_ORIENTABLE (editor),
|
||||
GTK_ORIENTATION_VERTICAL);
|
||||
|
||||
priv->upper_hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 2);
|
||||
gtk_box_pack_start (GTK_BOX (editor), priv->upper_hbox, FALSE, TRUE, 0);
|
||||
gtk_widget_show (priv->upper_hbox);
|
||||
editor->upper_hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 2);
|
||||
gtk_box_pack_start (GTK_BOX (editor), editor->upper_hbox, FALSE, TRUE, 0);
|
||||
gtk_widget_show (editor->upper_hbox);
|
||||
|
||||
button_box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
|
||||
gtk_box_set_homogeneous (GTK_BOX (button_box), TRUE);
|
||||
gtk_box_pack_start (GTK_BOX (priv->upper_hbox), button_box, FALSE, TRUE, 0);
|
||||
gtk_box_pack_start (GTK_BOX (editor->upper_hbox), button_box, FALSE, TRUE, 0);
|
||||
gtk_widget_show (button_box);
|
||||
|
||||
priv->new_button = button = gtk_button_new ();
|
||||
editor->new_button = button = gtk_button_new ();
|
||||
gtk_box_pack_start (GTK_BOX (button_box), button, TRUE, TRUE, 0);
|
||||
gtk_widget_show (button);
|
||||
|
||||
|
@ -199,11 +193,11 @@ gimp_path_editor_init (GimpPathEditor *editor)
|
|||
G_CALLBACK (gimp_path_editor_new_clicked),
|
||||
editor);
|
||||
|
||||
gimp_help_set_help_data (priv->new_button,
|
||||
gimp_help_set_help_data (editor->new_button,
|
||||
_("Add a new folder"),
|
||||
NULL);
|
||||
|
||||
priv->up_button = button = gtk_button_new ();
|
||||
editor->up_button = button = gtk_button_new ();
|
||||
gtk_widget_set_sensitive (button, FALSE);
|
||||
gtk_box_pack_start (GTK_BOX (button_box), button, TRUE, TRUE, 0);
|
||||
gtk_widget_show (button);
|
||||
|
@ -217,11 +211,11 @@ gimp_path_editor_init (GimpPathEditor *editor)
|
|||
G_CALLBACK (gimp_path_editor_move_clicked),
|
||||
editor);
|
||||
|
||||
gimp_help_set_help_data (priv->up_button,
|
||||
gimp_help_set_help_data (editor->up_button,
|
||||
_("Move the selected folder up"),
|
||||
NULL);
|
||||
|
||||
priv->down_button = button = gtk_button_new ();
|
||||
editor->down_button = button = gtk_button_new ();
|
||||
gtk_widget_set_sensitive (button, FALSE);
|
||||
gtk_box_pack_start (GTK_BOX (button_box), button, TRUE, TRUE, 0);
|
||||
gtk_widget_show (button);
|
||||
|
@ -235,11 +229,11 @@ gimp_path_editor_init (GimpPathEditor *editor)
|
|||
G_CALLBACK (gimp_path_editor_move_clicked),
|
||||
editor);
|
||||
|
||||
gimp_help_set_help_data (priv->down_button,
|
||||
gimp_help_set_help_data (editor->down_button,
|
||||
_("Move the selected folder down"),
|
||||
NULL);
|
||||
|
||||
priv->delete_button = button = gtk_button_new ();
|
||||
editor->delete_button = button = gtk_button_new ();
|
||||
gtk_widget_set_sensitive (button, FALSE);
|
||||
gtk_box_pack_start (GTK_BOX (button_box), button, TRUE, TRUE, 0);
|
||||
gtk_widget_show (button);
|
||||
|
@ -253,7 +247,7 @@ gimp_path_editor_init (GimpPathEditor *editor)
|
|||
G_CALLBACK (gimp_path_editor_delete_clicked),
|
||||
editor);
|
||||
|
||||
gimp_help_set_help_data (priv->delete_button,
|
||||
gimp_help_set_help_data (editor->delete_button,
|
||||
_("Remove the selected folder from the list"),
|
||||
NULL);
|
||||
|
||||
|
@ -266,12 +260,12 @@ gimp_path_editor_init (GimpPathEditor *editor)
|
|||
gtk_box_pack_start (GTK_BOX (editor), scrolled_window, TRUE, TRUE, 2);
|
||||
gtk_widget_show (scrolled_window);
|
||||
|
||||
priv->dir_list = gtk_list_store_new (NUM_COLUMNS,
|
||||
G_TYPE_STRING,
|
||||
G_TYPE_STRING,
|
||||
G_TYPE_BOOLEAN);
|
||||
tv = gtk_tree_view_new_with_model (GTK_TREE_MODEL (priv->dir_list));
|
||||
g_object_unref (priv->dir_list);
|
||||
editor->dir_list = gtk_list_store_new (NUM_COLUMNS,
|
||||
G_TYPE_STRING,
|
||||
G_TYPE_STRING,
|
||||
G_TYPE_BOOLEAN);
|
||||
tv = gtk_tree_view_new_with_model (GTK_TREE_MODEL (editor->dir_list));
|
||||
g_object_unref (editor->dir_list);
|
||||
|
||||
renderer = gtk_cell_renderer_toggle_new ();
|
||||
|
||||
|
@ -279,7 +273,7 @@ gimp_path_editor_init (GimpPathEditor *editor)
|
|||
G_CALLBACK (gimp_path_editor_writable_toggled),
|
||||
editor);
|
||||
|
||||
priv->writable_column = col = gtk_tree_view_column_new ();
|
||||
editor->writable_column = col = gtk_tree_view_column_new ();
|
||||
gtk_tree_view_column_set_title (col, _("Writable"));
|
||||
gtk_tree_view_column_pack_start (col, renderer, FALSE);
|
||||
gtk_tree_view_column_add_attribute (col, renderer, "active", COLUMN_WRITABLE);
|
||||
|
@ -299,8 +293,8 @@ gimp_path_editor_init (GimpPathEditor *editor)
|
|||
gtk_container_add (GTK_CONTAINER (scrolled_window), tv);
|
||||
gtk_widget_show (tv);
|
||||
|
||||
priv->sel = gtk_tree_view_get_selection (GTK_TREE_VIEW (tv));
|
||||
g_signal_connect (priv->sel, "changed",
|
||||
editor->sel = gtk_tree_view_get_selection (GTK_TREE_VIEW (tv));
|
||||
g_signal_connect (editor->sel, "changed",
|
||||
G_CALLBACK (gimp_path_editor_selection_changed),
|
||||
editor);
|
||||
}
|
||||
|
@ -321,21 +315,19 @@ GtkWidget *
|
|||
gimp_path_editor_new (const gchar *title,
|
||||
const gchar *path)
|
||||
{
|
||||
GimpPathEditor *editor;
|
||||
GimpPathEditorPrivate *priv;
|
||||
GimpPathEditor *editor;
|
||||
|
||||
g_return_val_if_fail (title != NULL, NULL);
|
||||
|
||||
editor = g_object_new (GIMP_TYPE_PATH_EDITOR, NULL);
|
||||
priv = GET_PRIVATE (editor);
|
||||
|
||||
priv->file_entry = gimp_file_entry_new (title, "", TRUE, TRUE);
|
||||
gtk_widget_set_sensitive (priv->file_entry, FALSE);
|
||||
gtk_box_pack_start (GTK_BOX (priv->upper_hbox), priv->file_entry,
|
||||
editor->file_entry = gimp_file_entry_new (title, "", TRUE, TRUE);
|
||||
gtk_widget_set_sensitive (editor->file_entry, FALSE);
|
||||
gtk_box_pack_start (GTK_BOX (editor->upper_hbox), editor->file_entry,
|
||||
TRUE, TRUE, 0);
|
||||
gtk_widget_show (priv->file_entry);
|
||||
gtk_widget_show (editor->file_entry);
|
||||
|
||||
g_signal_connect (priv->file_entry, "filename-changed",
|
||||
g_signal_connect (editor->file_entry, "filename-changed",
|
||||
G_CALLBACK (gimp_path_editor_file_entry_changed),
|
||||
editor);
|
||||
|
||||
|
@ -359,17 +351,14 @@ gimp_path_editor_new (const gchar *title,
|
|||
gchar *
|
||||
gimp_path_editor_get_path (GimpPathEditor *editor)
|
||||
{
|
||||
GimpPathEditorPrivate *priv;
|
||||
GtkTreeModel *model;
|
||||
GString *path;
|
||||
GtkTreeIter iter;
|
||||
gboolean iter_valid;
|
||||
GtkTreeModel *model;
|
||||
GString *path;
|
||||
GtkTreeIter iter;
|
||||
gboolean iter_valid;
|
||||
|
||||
g_return_val_if_fail (GIMP_IS_PATH_EDITOR (editor), g_strdup (""));
|
||||
|
||||
priv = GET_PRIVATE (editor);
|
||||
|
||||
model = GTK_TREE_MODEL (priv->dir_list);
|
||||
model = GTK_TREE_MODEL (editor->dir_list);
|
||||
|
||||
path = g_string_new ("");
|
||||
|
||||
|
@ -406,14 +395,12 @@ void
|
|||
gimp_path_editor_set_path (GimpPathEditor *editor,
|
||||
const gchar *path)
|
||||
{
|
||||
GimpPathEditorPrivate *priv;
|
||||
gchar *old_path;
|
||||
GList *path_list;
|
||||
GList *list;
|
||||
gchar *old_path;
|
||||
GList *path_list;
|
||||
GList *list;
|
||||
|
||||
g_return_if_fail (GIMP_IS_PATH_EDITOR (editor));
|
||||
|
||||
priv = GET_PRIVATE (editor);
|
||||
old_path = gimp_path_editor_get_path (editor);
|
||||
|
||||
if (old_path && path && strcmp (old_path, path) == 0)
|
||||
|
@ -426,7 +413,7 @@ gimp_path_editor_set_path (GimpPathEditor *editor,
|
|||
|
||||
path_list = gimp_path_parse (path, 256, FALSE, NULL);
|
||||
|
||||
gtk_list_store_clear (priv->dir_list);
|
||||
gtk_list_store_clear (editor->dir_list);
|
||||
|
||||
for (list = path_list; list; list = g_list_next (list))
|
||||
{
|
||||
|
@ -436,16 +423,16 @@ gimp_path_editor_set_path (GimpPathEditor *editor,
|
|||
|
||||
utf8 = g_filename_to_utf8 (directory, -1, NULL, NULL, NULL);
|
||||
|
||||
gtk_list_store_append (priv->dir_list, &iter);
|
||||
gtk_list_store_set (priv->dir_list, &iter,
|
||||
COLUMN_UTF8, utf8,
|
||||
COLUMN_DIRECTORY, directory,
|
||||
COLUMN_WRITABLE, FALSE,
|
||||
gtk_list_store_append (editor->dir_list, &iter);
|
||||
gtk_list_store_set (editor->dir_list, &iter,
|
||||
COLUMN_UTF8, utf8,
|
||||
COLUMN_DIRECTORY, directory,
|
||||
COLUMN_WRITABLE, FALSE,
|
||||
-1);
|
||||
|
||||
g_free (utf8);
|
||||
|
||||
priv->num_items++;
|
||||
editor->num_items++;
|
||||
}
|
||||
|
||||
gimp_path_free (path_list);
|
||||
|
@ -456,17 +443,14 @@ gimp_path_editor_set_path (GimpPathEditor *editor,
|
|||
gchar *
|
||||
gimp_path_editor_get_writable_path (GimpPathEditor *editor)
|
||||
{
|
||||
GimpPathEditorPrivate *priv;
|
||||
GtkTreeModel *model;
|
||||
GString *path;
|
||||
GtkTreeIter iter;
|
||||
gboolean iter_valid;
|
||||
GtkTreeModel *model;
|
||||
GString *path;
|
||||
GtkTreeIter iter;
|
||||
gboolean iter_valid;
|
||||
|
||||
g_return_val_if_fail (GIMP_IS_PATH_EDITOR (editor), g_strdup (""));
|
||||
|
||||
priv = GET_PRIVATE (editor);
|
||||
|
||||
model = GTK_TREE_MODEL (priv->dir_list);
|
||||
model = GTK_TREE_MODEL (editor->dir_list);
|
||||
|
||||
path = g_string_new ("");
|
||||
|
||||
|
@ -500,22 +484,19 @@ void
|
|||
gimp_path_editor_set_writable_path (GimpPathEditor *editor,
|
||||
const gchar *path)
|
||||
{
|
||||
GimpPathEditorPrivate *priv;
|
||||
GtkTreeModel *model;
|
||||
GtkTreeIter iter;
|
||||
gboolean iter_valid;
|
||||
GList *path_list;
|
||||
gboolean writable_changed = FALSE;
|
||||
GtkTreeModel *model;
|
||||
GtkTreeIter iter;
|
||||
gboolean iter_valid;
|
||||
GList *path_list;
|
||||
gboolean writable_changed = FALSE;
|
||||
|
||||
g_return_if_fail (GIMP_IS_PATH_EDITOR (editor));
|
||||
|
||||
priv = GET_PRIVATE (editor);
|
||||
|
||||
gtk_tree_view_column_set_visible (priv->writable_column, TRUE);
|
||||
gtk_tree_view_column_set_visible (editor->writable_column, TRUE);
|
||||
|
||||
path_list = gimp_path_parse (path, 256, FALSE, NULL);
|
||||
|
||||
model = GTK_TREE_MODEL (priv->dir_list);
|
||||
model = GTK_TREE_MODEL (editor->dir_list);
|
||||
|
||||
for (iter_valid = gtk_tree_model_get_iter_first (model, &iter);
|
||||
iter_valid;
|
||||
|
@ -537,7 +518,7 @@ gimp_path_editor_set_writable_path (GimpPathEditor *editor,
|
|||
|
||||
if (dir_writable != new_writable)
|
||||
{
|
||||
gtk_list_store_set (priv->dir_list, &iter,
|
||||
gtk_list_store_set (editor->dir_list, &iter,
|
||||
COLUMN_WRITABLE, new_writable,
|
||||
-1);
|
||||
|
||||
|
@ -555,17 +536,14 @@ gboolean
|
|||
gimp_path_editor_get_dir_writable (GimpPathEditor *editor,
|
||||
const gchar *directory)
|
||||
{
|
||||
GimpPathEditorPrivate *priv;
|
||||
GtkTreeModel *model;
|
||||
GtkTreeIter iter;
|
||||
gboolean iter_valid;
|
||||
GtkTreeModel *model;
|
||||
GtkTreeIter iter;
|
||||
gboolean iter_valid;
|
||||
|
||||
g_return_val_if_fail (GIMP_IS_PATH_EDITOR (editor), FALSE);
|
||||
g_return_val_if_fail (directory != NULL, FALSE);
|
||||
|
||||
priv = GET_PRIVATE (editor);
|
||||
|
||||
model = GTK_TREE_MODEL (priv->dir_list);
|
||||
model = GTK_TREE_MODEL (editor->dir_list);
|
||||
|
||||
for (iter_valid = gtk_tree_model_get_iter_first (model, &iter);
|
||||
iter_valid;
|
||||
|
@ -597,17 +575,14 @@ gimp_path_editor_set_dir_writable (GimpPathEditor *editor,
|
|||
const gchar *directory,
|
||||
gboolean writable)
|
||||
{
|
||||
GimpPathEditorPrivate *priv;
|
||||
GtkTreeModel *model;
|
||||
GtkTreeIter iter;
|
||||
gboolean iter_valid;
|
||||
GtkTreeModel *model;
|
||||
GtkTreeIter iter;
|
||||
gboolean iter_valid;
|
||||
|
||||
g_return_if_fail (GIMP_IS_PATH_EDITOR (editor));
|
||||
g_return_if_fail (directory != NULL);
|
||||
|
||||
priv = GET_PRIVATE (editor);
|
||||
|
||||
model = GTK_TREE_MODEL (priv->dir_list);
|
||||
model = GTK_TREE_MODEL (editor->dir_list);
|
||||
|
||||
for (iter_valid = gtk_tree_model_get_iter_first (model, &iter);
|
||||
iter_valid;
|
||||
|
@ -623,7 +598,7 @@ gimp_path_editor_set_dir_writable (GimpPathEditor *editor,
|
|||
|
||||
if (! strcmp (dir, directory) && dir_writable != writable)
|
||||
{
|
||||
gtk_list_store_set (priv->dir_list, &iter,
|
||||
gtk_list_store_set (editor->dir_list, &iter,
|
||||
COLUMN_WRITABLE, writable ? TRUE : FALSE,
|
||||
-1);
|
||||
|
||||
|
@ -638,66 +613,63 @@ gimp_path_editor_set_dir_writable (GimpPathEditor *editor,
|
|||
}
|
||||
|
||||
|
||||
/* private functions */
|
||||
/* editorate functions */
|
||||
|
||||
static void
|
||||
gimp_path_editor_new_clicked (GtkWidget *widget,
|
||||
GimpPathEditor *editor)
|
||||
{
|
||||
GimpPathEditorPrivate *priv = GET_PRIVATE (editor);
|
||||
|
||||
if (priv->sel_path)
|
||||
if (editor->sel_path)
|
||||
{
|
||||
g_signal_handlers_block_by_func (priv->sel,
|
||||
g_signal_handlers_block_by_func (editor->sel,
|
||||
gimp_path_editor_selection_changed,
|
||||
editor);
|
||||
|
||||
gtk_tree_selection_unselect_path (priv->sel, priv->sel_path);
|
||||
gtk_tree_selection_unselect_path (editor->sel, editor->sel_path);
|
||||
|
||||
g_signal_handlers_unblock_by_func (priv->sel,
|
||||
g_signal_handlers_unblock_by_func (editor->sel,
|
||||
gimp_path_editor_selection_changed,
|
||||
editor);
|
||||
|
||||
gtk_tree_path_free (priv->sel_path);
|
||||
priv->sel_path = NULL;
|
||||
gtk_tree_path_free (editor->sel_path);
|
||||
editor->sel_path = NULL;
|
||||
}
|
||||
|
||||
gtk_widget_set_sensitive (priv->delete_button, FALSE);
|
||||
gtk_widget_set_sensitive (priv->up_button, FALSE);
|
||||
gtk_widget_set_sensitive (priv->down_button, FALSE);
|
||||
gtk_widget_set_sensitive (priv->file_entry, TRUE);
|
||||
gtk_widget_set_sensitive (editor->delete_button, FALSE);
|
||||
gtk_widget_set_sensitive (editor->up_button, FALSE);
|
||||
gtk_widget_set_sensitive (editor->down_button, FALSE);
|
||||
gtk_widget_set_sensitive (editor->file_entry, TRUE);
|
||||
|
||||
gtk_editable_set_position
|
||||
(GTK_EDITABLE (gimp_file_entry_get_entry (GIMP_FILE_ENTRY (priv->file_entry))), -1);
|
||||
(GTK_EDITABLE (gimp_file_entry_get_entry (GIMP_FILE_ENTRY (editor->file_entry))), -1);
|
||||
gtk_widget_grab_focus
|
||||
(gimp_file_entry_get_entry (GIMP_FILE_ENTRY (priv->file_entry)));
|
||||
(gimp_file_entry_get_entry (GIMP_FILE_ENTRY (editor->file_entry)));
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_path_editor_move_clicked (GtkWidget *widget,
|
||||
GimpPathEditor *editor)
|
||||
{
|
||||
GimpPathEditorPrivate *priv = GET_PRIVATE (editor);
|
||||
GtkTreePath *path;
|
||||
GtkTreeModel *model;
|
||||
GtkTreeIter iter1, iter2;
|
||||
gchar *utf81, *utf82;
|
||||
gchar *dir1, *dir2;
|
||||
gboolean writable1, writable2;
|
||||
GtkTreePath *path;
|
||||
GtkTreeModel *model;
|
||||
GtkTreeIter iter1, iter2;
|
||||
gchar *utf81, *utf82;
|
||||
gchar *dir1, *dir2;
|
||||
gboolean writable1, writable2;
|
||||
|
||||
if (priv->sel_path == NULL)
|
||||
if (editor->sel_path == NULL)
|
||||
return;
|
||||
|
||||
path = gtk_tree_path_copy (priv->sel_path);
|
||||
path = gtk_tree_path_copy (editor->sel_path);
|
||||
|
||||
if (widget == priv->up_button)
|
||||
if (widget == editor->up_button)
|
||||
gtk_tree_path_prev (path);
|
||||
else
|
||||
gtk_tree_path_next (path);
|
||||
|
||||
model = GTK_TREE_MODEL (priv->dir_list);
|
||||
model = GTK_TREE_MODEL (editor->dir_list);
|
||||
|
||||
gtk_tree_model_get_iter (model, &iter1, priv->sel_path);
|
||||
gtk_tree_model_get_iter (model, &iter1, editor->sel_path);
|
||||
gtk_tree_model_get_iter (model, &iter2, path);
|
||||
|
||||
gtk_tree_model_get (model, &iter1,
|
||||
|
@ -711,12 +683,12 @@ gimp_path_editor_move_clicked (GtkWidget *widget,
|
|||
COLUMN_WRITABLE, &writable2,
|
||||
-1);
|
||||
|
||||
gtk_list_store_set (priv->dir_list, &iter1,
|
||||
gtk_list_store_set (editor->dir_list, &iter1,
|
||||
COLUMN_UTF8, utf82,
|
||||
COLUMN_DIRECTORY, dir2,
|
||||
COLUMN_WRITABLE, writable2,
|
||||
-1);
|
||||
gtk_list_store_set (priv->dir_list, &iter2,
|
||||
gtk_list_store_set (editor->dir_list, &iter2,
|
||||
COLUMN_UTF8, utf81,
|
||||
COLUMN_DIRECTORY, dir1,
|
||||
COLUMN_WRITABLE, writable1,
|
||||
|
@ -728,7 +700,7 @@ gimp_path_editor_move_clicked (GtkWidget *widget,
|
|||
g_free (dir2);
|
||||
g_free (dir1);
|
||||
|
||||
gtk_tree_selection_select_iter (priv->sel, &iter2);
|
||||
gtk_tree_selection_select_iter (editor->sel, &iter2);
|
||||
|
||||
g_signal_emit (editor, gimp_path_editor_signals[PATH_CHANGED], 0);
|
||||
}
|
||||
|
@ -737,53 +709,52 @@ static void
|
|||
gimp_path_editor_delete_clicked (GtkWidget *widget,
|
||||
GimpPathEditor *editor)
|
||||
{
|
||||
GimpPathEditorPrivate *priv = GET_PRIVATE (editor);
|
||||
GtkTreeIter iter;
|
||||
gboolean dir_writable;
|
||||
GtkTreeIter iter;
|
||||
gboolean dir_writable;
|
||||
|
||||
if (priv->sel_path == NULL)
|
||||
if (editor->sel_path == NULL)
|
||||
return;
|
||||
|
||||
gtk_tree_model_get_iter (GTK_TREE_MODEL (priv->dir_list), &iter,
|
||||
priv->sel_path);
|
||||
gtk_tree_model_get_iter (GTK_TREE_MODEL (editor->dir_list), &iter,
|
||||
editor->sel_path);
|
||||
|
||||
gtk_tree_model_get (GTK_TREE_MODEL (priv->dir_list), &iter,
|
||||
gtk_tree_model_get (GTK_TREE_MODEL (editor->dir_list), &iter,
|
||||
COLUMN_WRITABLE, &dir_writable,
|
||||
-1);
|
||||
|
||||
gtk_list_store_remove (priv->dir_list, &iter);
|
||||
gtk_list_store_remove (editor->dir_list, &iter);
|
||||
|
||||
priv->num_items--;
|
||||
editor->num_items--;
|
||||
|
||||
if (priv->num_items == 0)
|
||||
if (editor->num_items == 0)
|
||||
{
|
||||
gtk_tree_path_free (priv->sel_path);
|
||||
priv->sel_path = NULL;
|
||||
gtk_tree_path_free (editor->sel_path);
|
||||
editor->sel_path = NULL;
|
||||
|
||||
g_signal_handlers_block_by_func (priv->file_entry,
|
||||
g_signal_handlers_block_by_func (editor->file_entry,
|
||||
gimp_path_editor_file_entry_changed,
|
||||
editor);
|
||||
|
||||
gimp_file_entry_set_filename (GIMP_FILE_ENTRY (priv->file_entry), "");
|
||||
gimp_file_entry_set_filename (GIMP_FILE_ENTRY (editor->file_entry), "");
|
||||
|
||||
g_signal_handlers_unblock_by_func (priv->file_entry,
|
||||
g_signal_handlers_unblock_by_func (editor->file_entry,
|
||||
gimp_path_editor_file_entry_changed,
|
||||
editor);
|
||||
|
||||
gtk_widget_set_sensitive (priv->delete_button, FALSE);
|
||||
gtk_widget_set_sensitive (priv->up_button, FALSE);
|
||||
gtk_widget_set_sensitive (priv->down_button, FALSE);
|
||||
gtk_widget_set_sensitive (priv->file_entry, FALSE);
|
||||
gtk_widget_set_sensitive (editor->delete_button, FALSE);
|
||||
gtk_widget_set_sensitive (editor->up_button, FALSE);
|
||||
gtk_widget_set_sensitive (editor->down_button, FALSE);
|
||||
gtk_widget_set_sensitive (editor->file_entry, FALSE);
|
||||
}
|
||||
else
|
||||
{
|
||||
gint *indices;
|
||||
|
||||
indices = gtk_tree_path_get_indices (priv->sel_path);
|
||||
if ((indices[0] == priv->num_items) && (indices[0] > 0))
|
||||
gtk_tree_path_prev (priv->sel_path);
|
||||
indices = gtk_tree_path_get_indices (editor->sel_path);
|
||||
if ((indices[0] == editor->num_items) && (indices[0] > 0))
|
||||
gtk_tree_path_prev (editor->sel_path);
|
||||
|
||||
gtk_tree_selection_select_path (priv->sel, priv->sel_path);
|
||||
gtk_tree_selection_select_path (editor->sel, editor->sel_path);
|
||||
}
|
||||
|
||||
g_signal_emit (editor, gimp_path_editor_signals[PATH_CHANGED], 0);
|
||||
|
@ -796,10 +767,9 @@ static void
|
|||
gimp_path_editor_file_entry_changed (GtkWidget *widget,
|
||||
GimpPathEditor *editor)
|
||||
{
|
||||
GimpPathEditorPrivate *priv = GET_PRIVATE (editor);
|
||||
gchar *dir;
|
||||
gchar *utf8;
|
||||
GtkTreeIter iter;
|
||||
gchar *dir;
|
||||
gchar *utf8;
|
||||
GtkTreeIter iter;
|
||||
|
||||
dir = gimp_file_entry_get_filename (GIMP_FILE_ENTRY (widget));
|
||||
if (strcmp (dir, "") == 0)
|
||||
|
@ -810,23 +780,23 @@ gimp_path_editor_file_entry_changed (GtkWidget *widget,
|
|||
|
||||
utf8 = g_filename_display_name (dir);
|
||||
|
||||
if (priv->sel_path == NULL)
|
||||
if (editor->sel_path == NULL)
|
||||
{
|
||||
gtk_list_store_append (priv->dir_list, &iter);
|
||||
gtk_list_store_set (priv->dir_list, &iter,
|
||||
gtk_list_store_append (editor->dir_list, &iter);
|
||||
gtk_list_store_set (editor->dir_list, &iter,
|
||||
COLUMN_UTF8, utf8,
|
||||
COLUMN_DIRECTORY, dir,
|
||||
COLUMN_WRITABLE, FALSE,
|
||||
-1);
|
||||
priv->num_items++;
|
||||
editor->num_items++;
|
||||
|
||||
gtk_tree_selection_select_iter (priv->sel, &iter);
|
||||
gtk_tree_selection_select_iter (editor->sel, &iter);
|
||||
}
|
||||
else
|
||||
{
|
||||
gtk_tree_model_get_iter (GTK_TREE_MODEL (priv->dir_list), &iter,
|
||||
priv->sel_path);
|
||||
gtk_list_store_set (priv->dir_list, &iter,
|
||||
gtk_tree_model_get_iter (GTK_TREE_MODEL (editor->dir_list), &iter,
|
||||
editor->sel_path);
|
||||
gtk_list_store_set (editor->dir_list, &iter,
|
||||
COLUMN_UTF8, utf8,
|
||||
COLUMN_DIRECTORY, dir,
|
||||
-1);
|
||||
|
@ -842,43 +812,42 @@ static void
|
|||
gimp_path_editor_selection_changed (GtkTreeSelection *sel,
|
||||
GimpPathEditor *editor)
|
||||
{
|
||||
GimpPathEditorPrivate *priv = GET_PRIVATE (editor);
|
||||
GtkTreeIter iter;
|
||||
gchar *directory;
|
||||
gint *indices;
|
||||
GtkTreeIter iter;
|
||||
gchar *directory;
|
||||
gint *indices;
|
||||
|
||||
if (gtk_tree_selection_get_selected (sel, NULL, &iter))
|
||||
{
|
||||
gtk_tree_model_get (GTK_TREE_MODEL (priv->dir_list), &iter,
|
||||
gtk_tree_model_get (GTK_TREE_MODEL (editor->dir_list), &iter,
|
||||
COLUMN_DIRECTORY, &directory,
|
||||
-1);
|
||||
|
||||
g_signal_handlers_block_by_func (priv->file_entry,
|
||||
g_signal_handlers_block_by_func (editor->file_entry,
|
||||
gimp_path_editor_file_entry_changed,
|
||||
editor);
|
||||
|
||||
gimp_file_entry_set_filename (GIMP_FILE_ENTRY (priv->file_entry),
|
||||
gimp_file_entry_set_filename (GIMP_FILE_ENTRY (editor->file_entry),
|
||||
directory);
|
||||
|
||||
g_signal_handlers_unblock_by_func (priv->file_entry,
|
||||
g_signal_handlers_unblock_by_func (editor->file_entry,
|
||||
gimp_path_editor_file_entry_changed,
|
||||
editor);
|
||||
|
||||
g_free (directory);
|
||||
|
||||
if (priv->sel_path)
|
||||
gtk_tree_path_free (priv->sel_path);
|
||||
if (editor->sel_path)
|
||||
gtk_tree_path_free (editor->sel_path);
|
||||
|
||||
priv->sel_path =
|
||||
gtk_tree_model_get_path (GTK_TREE_MODEL (priv->dir_list), &iter);
|
||||
editor->sel_path =
|
||||
gtk_tree_model_get_path (GTK_TREE_MODEL (editor->dir_list), &iter);
|
||||
|
||||
indices = gtk_tree_path_get_indices (priv->sel_path);
|
||||
indices = gtk_tree_path_get_indices (editor->sel_path);
|
||||
|
||||
gtk_widget_set_sensitive (priv->delete_button, TRUE);
|
||||
gtk_widget_set_sensitive (priv->up_button, (indices[0] > 0));
|
||||
gtk_widget_set_sensitive (priv->down_button,
|
||||
(indices[0] < (priv->num_items - 1)));
|
||||
gtk_widget_set_sensitive (priv->file_entry, TRUE);
|
||||
gtk_widget_set_sensitive (editor->delete_button, TRUE);
|
||||
gtk_widget_set_sensitive (editor->up_button, (indices[0] > 0));
|
||||
gtk_widget_set_sensitive (editor->down_button,
|
||||
(indices[0] < (editor->num_items - 1)));
|
||||
gtk_widget_set_sensitive (editor->file_entry, TRUE);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -886,7 +855,7 @@ gimp_path_editor_selection_changed (GtkTreeSelection *sel,
|
|||
gimp_path_editor_selection_changed,
|
||||
editor);
|
||||
|
||||
gtk_tree_selection_select_path (priv->sel, priv->sel_path);
|
||||
gtk_tree_selection_select_path (editor->sel, editor->sel_path);
|
||||
|
||||
g_signal_handlers_unblock_by_func (sel,
|
||||
gimp_path_editor_selection_changed,
|
||||
|
@ -899,21 +868,20 @@ gimp_path_editor_writable_toggled (GtkCellRendererToggle *toggle,
|
|||
gchar *path_str,
|
||||
GimpPathEditor *editor)
|
||||
{
|
||||
GimpPathEditorPrivate *priv = GET_PRIVATE (editor);
|
||||
GtkTreePath *path;
|
||||
GtkTreeIter iter;
|
||||
GtkTreePath *path;
|
||||
GtkTreeIter iter;
|
||||
|
||||
path = gtk_tree_path_new_from_string (path_str);
|
||||
|
||||
if (gtk_tree_model_get_iter (GTK_TREE_MODEL (priv->dir_list), &iter, path))
|
||||
if (gtk_tree_model_get_iter (GTK_TREE_MODEL (editor->dir_list), &iter, path))
|
||||
{
|
||||
gboolean dir_writable;
|
||||
|
||||
gtk_tree_model_get (GTK_TREE_MODEL (priv->dir_list), &iter,
|
||||
gtk_tree_model_get (GTK_TREE_MODEL (editor->dir_list), &iter,
|
||||
COLUMN_WRITABLE, &dir_writable,
|
||||
-1);
|
||||
|
||||
gtk_list_store_set (priv->dir_list, &iter,
|
||||
gtk_list_store_set (editor->dir_list, &iter,
|
||||
COLUMN_WRITABLE, ! dir_writable,
|
||||
-1);
|
||||
|
||||
|
|
|
@ -32,25 +32,7 @@ G_BEGIN_DECLS
|
|||
|
||||
|
||||
#define GIMP_TYPE_PATH_EDITOR (gimp_path_editor_get_type ())
|
||||
G_DECLARE_DERIVABLE_TYPE (GimpPathEditor, gimp_path_editor, GIMP, PATH_EDITOR, GtkBox)
|
||||
|
||||
struct _GimpPathEditorClass
|
||||
{
|
||||
GtkBoxClass parent_class;
|
||||
|
||||
void (* path_changed) (GimpPathEditor *editor);
|
||||
void (* writable_changed) (GimpPathEditor *editor);
|
||||
|
||||
/* 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);
|
||||
};
|
||||
G_DECLARE_FINAL_TYPE (GimpPathEditor, gimp_path_editor, GIMP, PATH_EDITOR, GtkBox)
|
||||
|
||||
|
||||
/* For information look into the C source or the html documentation */
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -33,26 +33,7 @@ G_BEGIN_DECLS
|
|||
|
||||
|
||||
#define GIMP_TYPE_SIZE_ENTRY (gimp_size_entry_get_type ())
|
||||
G_DECLARE_DERIVABLE_TYPE (GimpSizeEntry, gimp_size_entry, GIMP, SIZE_ENTRY, GtkGrid)
|
||||
|
||||
struct _GimpSizeEntryClass
|
||||
{
|
||||
GtkGridClass parent_class;
|
||||
|
||||
void (* value_changed) (GimpSizeEntry *gse);
|
||||
void (* refval_changed) (GimpSizeEntry *gse);
|
||||
void (* unit_changed) (GimpSizeEntry *gse);
|
||||
|
||||
/* 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);
|
||||
};
|
||||
G_DECLARE_FINAL_TYPE (GimpSizeEntry, gimp_size_entry, GIMP, SIZE_ENTRY, GtkGrid)
|
||||
|
||||
|
||||
/* For information look into the C source or the html documentation */
|
||||
|
|
Loading…
Reference in New Issue