removed static variables, don't use GIMP_CONFIG_INSTALL_PROP_FOO() for
2004-02-19 Michael Natterer <mitch@gimp.org> * app/widgets/gimpdasheditor.[ch]: removed static variables, don't use GIMP_CONFIG_INSTALL_PROP_FOO() for non-config classes, trailing whitespace, cleanup.
This commit is contained in:

committed by
Michael Natterer

parent
b60050534c
commit
c33e0e8bc0
@ -1,3 +1,9 @@
|
|||||||
|
2004-02-19 Michael Natterer <mitch@gimp.org>
|
||||||
|
|
||||||
|
* app/widgets/gimpdasheditor.[ch]: removed static variables, don't
|
||||||
|
use GIMP_CONFIG_INSTALL_PROP_FOO() for non-config classes,
|
||||||
|
trailing whitespace, cleanup.
|
||||||
|
|
||||||
2004-02-19 Simon Budig <simon@gimp.org>
|
2004-02-19 Simon Budig <simon@gimp.org>
|
||||||
|
|
||||||
* plug-ins/common/lic.c: fixed gimp_dialog_new invocation.
|
* plug-ins/common/lic.c: fixed gimp_dialog_new invocation.
|
||||||
|
@ -39,6 +39,7 @@
|
|||||||
|
|
||||||
#define DEFAULT_N_SEGMENTS 24
|
#define DEFAULT_N_SEGMENTS 24
|
||||||
|
|
||||||
|
|
||||||
enum
|
enum
|
||||||
{
|
{
|
||||||
PROP_0,
|
PROP_0,
|
||||||
@ -51,6 +52,7 @@ enum
|
|||||||
static void gimp_dash_editor_class_init (GimpDashEditorClass *klass);
|
static void gimp_dash_editor_class_init (GimpDashEditorClass *klass);
|
||||||
static void gimp_dash_editor_init (GimpDashEditor *editor);
|
static void gimp_dash_editor_init (GimpDashEditor *editor);
|
||||||
|
|
||||||
|
static void gimp_dash_editor_finalize (GObject *object);
|
||||||
static void gimp_dash_editor_set_property (GObject *object,
|
static void gimp_dash_editor_set_property (GObject *object,
|
||||||
guint property_id,
|
guint property_id,
|
||||||
const GValue *value,
|
const GValue *value,
|
||||||
@ -59,7 +61,7 @@ static void gimp_dash_editor_get_property (GObject *object,
|
|||||||
guint property_id,
|
guint property_id,
|
||||||
GValue *value,
|
GValue *value,
|
||||||
GParamSpec *pspec);
|
GParamSpec *pspec);
|
||||||
static void gimp_dash_editor_finalize (GObject *object);
|
|
||||||
static void gimp_dash_editor_size_request (GtkWidget *widget,
|
static void gimp_dash_editor_size_request (GtkWidget *widget,
|
||||||
GtkRequisition *requisition);
|
GtkRequisition *requisition);
|
||||||
static gboolean gimp_dash_editor_expose (GtkWidget *widget,
|
static gboolean gimp_dash_editor_expose (GtkWidget *widget,
|
||||||
@ -72,16 +74,13 @@ static gboolean gimp_dash_editor_motion_notify (GtkWidget *widget,
|
|||||||
GdkEventMotion *bevent);
|
GdkEventMotion *bevent);
|
||||||
|
|
||||||
/* helper function */
|
/* helper function */
|
||||||
static void update_segments_from_options (GimpDashEditor *editor);
|
static void update_segments_from_options (GimpDashEditor *editor);
|
||||||
static void update_options_from_segments (GimpDashEditor *editor);
|
static void update_options_from_segments (GimpDashEditor *editor);
|
||||||
static void update_blocksize (GimpDashEditor *editor);
|
static void update_blocksize (GimpDashEditor *editor);
|
||||||
static gint dash_x_to_index (GimpDashEditor *editor,
|
static gint dash_x_to_index (GimpDashEditor *editor,
|
||||||
gint x);
|
gint x);
|
||||||
|
|
||||||
|
|
||||||
static gboolean edit_mode = TRUE;
|
|
||||||
static gint edit_button_x0 = 0;
|
|
||||||
|
|
||||||
static GtkDrawingAreaClass *parent_class = NULL;
|
static GtkDrawingAreaClass *parent_class = NULL;
|
||||||
|
|
||||||
|
|
||||||
@ -116,17 +115,14 @@ gimp_dash_editor_get_type (void)
|
|||||||
static void
|
static void
|
||||||
gimp_dash_editor_class_init (GimpDashEditorClass *klass)
|
gimp_dash_editor_class_init (GimpDashEditorClass *klass)
|
||||||
{
|
{
|
||||||
GObjectClass *object_class;
|
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
||||||
GtkWidgetClass *widget_class;
|
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
|
||||||
|
|
||||||
parent_class = g_type_class_peek_parent (klass);
|
parent_class = g_type_class_peek_parent (klass);
|
||||||
|
|
||||||
object_class = G_OBJECT_CLASS (klass);
|
object_class->finalize = gimp_dash_editor_finalize;
|
||||||
widget_class = GTK_WIDGET_CLASS (klass);
|
|
||||||
|
|
||||||
object_class->get_property = gimp_dash_editor_get_property;
|
object_class->get_property = gimp_dash_editor_get_property;
|
||||||
object_class->set_property = gimp_dash_editor_set_property;
|
object_class->set_property = gimp_dash_editor_set_property;
|
||||||
object_class->finalize = gimp_dash_editor_finalize;
|
|
||||||
|
|
||||||
widget_class->size_request = gimp_dash_editor_size_request;
|
widget_class->size_request = gimp_dash_editor_size_request;
|
||||||
widget_class->expose_event = gimp_dash_editor_expose;
|
widget_class->expose_event = gimp_dash_editor_expose;
|
||||||
@ -135,28 +131,36 @@ gimp_dash_editor_class_init (GimpDashEditorClass *klass)
|
|||||||
widget_class->motion_notify_event = gimp_dash_editor_motion_notify;
|
widget_class->motion_notify_event = gimp_dash_editor_motion_notify;
|
||||||
|
|
||||||
g_object_class_install_property (object_class, PROP_STROKE_OPTIONS,
|
g_object_class_install_property (object_class, PROP_STROKE_OPTIONS,
|
||||||
g_param_spec_object("stroke-options",
|
g_param_spec_object ("stroke-options",
|
||||||
NULL, NULL,
|
NULL, NULL,
|
||||||
GIMP_TYPE_STROKE_OPTIONS,
|
GIMP_TYPE_STROKE_OPTIONS,
|
||||||
G_PARAM_READWRITE |
|
G_PARAM_READWRITE |
|
||||||
G_PARAM_CONSTRUCT_ONLY));
|
G_PARAM_CONSTRUCT_ONLY));
|
||||||
|
|
||||||
GIMP_CONFIG_INSTALL_PROP_INT (object_class, PROP_N_SEGMENTS,
|
g_object_class_install_property (object_class, PROP_N_SEGMENTS,
|
||||||
"n-segments", NULL,
|
g_param_spec_int ("n-segments",
|
||||||
2, 120, DEFAULT_N_SEGMENTS, 0);
|
NULL, NULL,
|
||||||
|
2, 120, DEFAULT_N_SEGMENTS,
|
||||||
|
G_PARAM_READWRITE |
|
||||||
|
G_PARAM_CONSTRUCT));
|
||||||
|
|
||||||
GIMP_CONFIG_INSTALL_PROP_DOUBLE (object_class, PROP_LENGTH,
|
g_object_class_install_property (object_class, PROP_LENGTH,
|
||||||
"dash-length", NULL,
|
g_param_spec_double ("dash-length",
|
||||||
0.0, 2000.0, 0.5 * DEFAULT_N_SEGMENTS,
|
NULL, NULL,
|
||||||
0);
|
0.0, 2000.0,
|
||||||
|
0.5 * DEFAULT_N_SEGMENTS,
|
||||||
|
G_PARAM_READWRITE |
|
||||||
|
G_PARAM_CONSTRUCT));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gimp_dash_editor_init (GimpDashEditor *editor)
|
gimp_dash_editor_init (GimpDashEditor *editor)
|
||||||
{
|
{
|
||||||
editor->segments = NULL;
|
editor->segments = NULL;
|
||||||
editor->block_width = 6;
|
editor->block_width = 6;
|
||||||
editor->block_height = 6;
|
editor->block_height = 6;
|
||||||
|
editor->edit_mode = TRUE;
|
||||||
|
editor->edit_button_x0 = 0;
|
||||||
|
|
||||||
gtk_widget_add_events (GTK_WIDGET (editor),
|
gtk_widget_add_events (GTK_WIDGET (editor),
|
||||||
GDK_BUTTON_PRESS_MASK |
|
GDK_BUTTON_PRESS_MASK |
|
||||||
@ -164,6 +168,20 @@ gimp_dash_editor_init (GimpDashEditor *editor)
|
|||||||
GDK_BUTTON1_MOTION_MASK);
|
GDK_BUTTON1_MOTION_MASK);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
gimp_dash_editor_finalize (GObject *object)
|
||||||
|
{
|
||||||
|
GimpDashEditor *editor = GIMP_DASH_EDITOR (object);
|
||||||
|
|
||||||
|
if (editor->stroke_options)
|
||||||
|
{
|
||||||
|
g_object_unref (editor->stroke_options);
|
||||||
|
editor->stroke_options = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
G_OBJECT_CLASS (parent_class)->finalize (object);
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gimp_dash_editor_set_property (GObject *object,
|
gimp_dash_editor_set_property (GObject *object,
|
||||||
guint property_id,
|
guint property_id,
|
||||||
@ -229,21 +247,6 @@ gimp_dash_editor_get_property (GObject *object,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
|
||||||
gimp_dash_editor_finalize (GObject *object)
|
|
||||||
{
|
|
||||||
GimpDashEditor *editor = GIMP_DASH_EDITOR (object);
|
|
||||||
|
|
||||||
if (editor->stroke_options)
|
|
||||||
{
|
|
||||||
g_object_unref (editor->stroke_options);
|
|
||||||
editor->stroke_options = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
G_OBJECT_CLASS (parent_class)->finalize (object);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gimp_dash_editor_size_request (GtkWidget *widget,
|
gimp_dash_editor_size_request (GtkWidget *widget,
|
||||||
GtkRequisition *requisition)
|
GtkRequisition *requisition)
|
||||||
@ -348,17 +351,17 @@ gimp_dash_editor_button_press (GtkWidget *widget,
|
|||||||
GimpDashEditor *editor = GIMP_DASH_EDITOR (widget);
|
GimpDashEditor *editor = GIMP_DASH_EDITOR (widget);
|
||||||
gint index;
|
gint index;
|
||||||
|
|
||||||
if (bevent->button == 1)
|
if (bevent->button == 1 && bevent->type == GDK_BUTTON_PRESS)
|
||||||
{
|
{
|
||||||
gdk_pointer_grab (widget->window, FALSE,
|
gdk_pointer_grab (widget->window, FALSE,
|
||||||
GDK_BUTTON_RELEASE_MASK | GDK_BUTTON1_MOTION_MASK,
|
GDK_BUTTON_RELEASE_MASK | GDK_BUTTON1_MOTION_MASK,
|
||||||
NULL, NULL, bevent->time);
|
NULL, NULL, bevent->time);
|
||||||
index = dash_x_to_index (editor, bevent->x);
|
index = dash_x_to_index (editor, bevent->x);
|
||||||
|
|
||||||
edit_mode = ! editor->segments [index];
|
editor->edit_mode = ! editor->segments [index];
|
||||||
edit_button_x0 = bevent->x;
|
editor->edit_button_x0 = bevent->x;
|
||||||
|
|
||||||
editor->segments [index] = edit_mode;
|
editor->segments [index] = editor->edit_mode;
|
||||||
|
|
||||||
gtk_widget_queue_draw (widget);
|
gtk_widget_queue_draw (widget);
|
||||||
}
|
}
|
||||||
@ -391,23 +394,23 @@ gimp_dash_editor_motion_notify (GtkWidget *widget,
|
|||||||
gint x, index;
|
gint x, index;
|
||||||
|
|
||||||
index = dash_x_to_index (editor, mevent->x);
|
index = dash_x_to_index (editor, mevent->x);
|
||||||
editor->segments [index] = edit_mode;
|
editor->segments [index] = editor->edit_mode;
|
||||||
|
|
||||||
if (mevent->x > edit_button_x0)
|
if (mevent->x > editor->edit_button_x0)
|
||||||
{
|
{
|
||||||
for (x = edit_button_x0; x < mevent->x; x += editor->block_width)
|
for (x = editor->edit_button_x0; x < mevent->x; x += editor->block_width)
|
||||||
{
|
{
|
||||||
index = dash_x_to_index (editor, x);
|
index = dash_x_to_index (editor, x);
|
||||||
editor->segments[index] = edit_mode;
|
editor->segments[index] = editor->edit_mode;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mevent->x < edit_button_x0)
|
if (mevent->x < editor->edit_button_x0)
|
||||||
{
|
{
|
||||||
for (x = edit_button_x0; x > mevent->x; x -= editor->block_width)
|
for (x = editor->edit_button_x0; x > mevent->x; x -= editor->block_width)
|
||||||
{
|
{
|
||||||
index = dash_x_to_index (editor, x);
|
index = dash_x_to_index (editor, x);
|
||||||
editor->segments[index] = edit_mode;
|
editor->segments[index] = editor->edit_mode;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -426,13 +429,13 @@ gimp_dash_editor_new (GimpStrokeOptions *stroke_options)
|
|||||||
NULL);
|
NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
gimp_dash_editor_shift_right (GimpDashEditor *editor)
|
gimp_dash_editor_shift_right (GimpDashEditor *editor)
|
||||||
{
|
{
|
||||||
gint i;
|
|
||||||
gboolean swap;
|
gboolean swap;
|
||||||
|
gint i;
|
||||||
|
|
||||||
|
g_return_if_fail (GIMP_IS_DASH_EDITOR (editor));
|
||||||
g_return_if_fail (editor->n_segments > 0);
|
g_return_if_fail (editor->n_segments > 0);
|
||||||
|
|
||||||
swap = editor->segments[editor->n_segments - 1];
|
swap = editor->segments[editor->n_segments - 1];
|
||||||
@ -446,9 +449,10 @@ gimp_dash_editor_shift_right (GimpDashEditor *editor)
|
|||||||
void
|
void
|
||||||
gimp_dash_editor_shift_left (GimpDashEditor *editor)
|
gimp_dash_editor_shift_left (GimpDashEditor *editor)
|
||||||
{
|
{
|
||||||
gint i;
|
|
||||||
gboolean swap;
|
gboolean swap;
|
||||||
|
gint i;
|
||||||
|
|
||||||
|
g_return_if_fail (GIMP_IS_DASH_EDITOR (editor));
|
||||||
g_return_if_fail (editor->n_segments > 0);
|
g_return_if_fail (editor->n_segments > 0);
|
||||||
|
|
||||||
swap = editor->segments[0];
|
swap = editor->segments[0];
|
||||||
@ -462,9 +466,9 @@ gimp_dash_editor_shift_left (GimpDashEditor *editor)
|
|||||||
static void
|
static void
|
||||||
update_segments_from_options (GimpDashEditor *editor)
|
update_segments_from_options (GimpDashEditor *editor)
|
||||||
{
|
{
|
||||||
gdouble factor, sum = 0;
|
gdouble factor, sum = 0;
|
||||||
gint i, j;
|
gint i, j;
|
||||||
gboolean paint;
|
gboolean paint;
|
||||||
GArray *dash_info;
|
GArray *dash_info;
|
||||||
|
|
||||||
if (editor->stroke_options == NULL || editor->segments == NULL)
|
if (editor->stroke_options == NULL || editor->segments == NULL)
|
||||||
@ -567,8 +571,6 @@ update_options_from_segments (GimpDashEditor *editor)
|
|||||||
g_array_free (dash_array, TRUE);
|
g_array_free (dash_array, TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
update_blocksize (GimpDashEditor *editor)
|
update_blocksize (GimpDashEditor *editor)
|
||||||
{
|
{
|
||||||
@ -597,4 +599,3 @@ dash_x_to_index (GimpDashEditor *editor,
|
|||||||
|
|
||||||
return index;
|
return index;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -52,26 +52,23 @@ struct _GimpDashEditor
|
|||||||
gint y0;
|
gint y0;
|
||||||
gint block_width;
|
gint block_width;
|
||||||
gint block_height;
|
gint block_height;
|
||||||
|
|
||||||
|
gboolean edit_mode;
|
||||||
|
gint edit_button_x0;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct _GimpDashEditorClass
|
struct _GimpDashEditorClass
|
||||||
{
|
{
|
||||||
GtkDrawingAreaClass parent_class;
|
GtkDrawingAreaClass parent_class;
|
||||||
|
|
||||||
/*
|
|
||||||
void (* range_changed) (GimpDashEditor *view,
|
|
||||||
gint start,
|
|
||||||
gint end);
|
|
||||||
*/
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
GType gimp_dash_editor_get_type (void) G_GNUC_CONST;
|
GType gimp_dash_editor_get_type (void) G_GNUC_CONST;
|
||||||
|
|
||||||
GtkWidget * gimp_dash_editor_new (GimpStrokeOptions *stroke_options);
|
|
||||||
|
|
||||||
void gimp_dash_editor_shift_left (GimpDashEditor *editor);
|
GtkWidget * gimp_dash_editor_new (GimpStrokeOptions *stroke_options);
|
||||||
void gimp_dash_editor_shift_right (GimpDashEditor *editor);
|
|
||||||
|
void gimp_dash_editor_shift_left (GimpDashEditor *editor);
|
||||||
|
void gimp_dash_editor_shift_right (GimpDashEditor *editor);
|
||||||
|
|
||||||
|
|
||||||
#endif /* __GIMP_DASH_EDITOR_H__ */
|
#endif /* __GIMP_DASH_EDITOR_H__ */
|
||||||
|
Reference in New Issue
Block a user