Some default dash pattern enum. regenerated.

2003-12-28  Simon Budig  <simon@gimp.org>

	* app/core/core-enums.h: Some default dash pattern enum.
	* app/core/core-enums.c: regenerated.

	* app/core/gimpstrokeoptions.[ch]: Implement default dash
	patterns, add a signal when the dash pattern changes.

	* app/widgets/gimpstrokeeditor.c: Add an option menu for
	the dash pattern and connect it to the signal mentioned above.
This commit is contained in:
Simon Budig 2003-12-28 17:09:41 +00:00 committed by Simon Budig
parent 5058627932
commit 411b54d149
6 changed files with 202 additions and 1 deletions

View File

@ -1,3 +1,14 @@
2003-12-28 Simon Budig <simon@gimp.org>
* app/core/core-enums.h: Some default dash pattern enum.
* app/core/core-enums.c: regenerated.
* app/core/gimpstrokeoptions.[ch]: Implement default dash
patterns, add a signal when the dash pattern changes.
* app/widgets/gimpstrokeeditor.c: Add an option menu for
the dash pattern and connect it to the signal mentioned above.
2003-12-28 Simon Budig <simon@gimp.org> 2003-12-28 Simon Budig <simon@gimp.org>
* app/widgets/gimpstrokeeditor.c: Fixed packing of the widgets. * app/widgets/gimpstrokeeditor.c: Fixed packing of the widgets.

View File

@ -314,6 +314,34 @@ gimp_cap_style_get_type (void)
} }
static const GEnumValue gimp_dash_preset_enum_values[] =
{
{ GIMP_DASH_CUSTOM, N_("Custom"), "custom" },
{ GIMP_DASH_LINE, N_("Line"), "line" },
{ GIMP_DASH_LONG_DASH, N_("Long Dashes"), "long-dash" },
{ GIMP_DASH_MEDIUM_DASH, N_("Medium Dashes"), "medium-dash" },
{ GIMP_DASH_SHORT_DASH, N_("Short Dashes"), "short-dash" },
{ GIMP_DASH_SPARSE_DOTS, N_("Sparse Dots"), "sparse-dots" },
{ GIMP_DASH_NORMAL_DOTS, N_("Normal Dots"), "normal-dots" },
{ GIMP_DASH_DENSE_DOTS, N_("Dense Dots"), "dense-dots" },
{ GIMP_DASH_STIPPLES, N_("Stipples"), "stipples" },
{ GIMP_DASH_DASH_DOT, N_("Dash Dot..."), "dash-dot" },
{ GIMP_DASH_DASH_DOT_DOT, N_("Dash Dot Dot..."), "dash-dot-dot" },
{ 0, NULL, NULL }
};
GType
gimp_dash_preset_get_type (void)
{
static GType enum_type = 0;
if (!enum_type)
enum_type = g_enum_register_static ("GimpDashPreset", gimp_dash_preset_enum_values);
return enum_type;
}
static const GEnumValue gimp_image_base_type_enum_values[] = static const GEnumValue gimp_image_base_type_enum_values[] =
{ {
{ GIMP_RGB, N_("RGB"), "rgb" }, { GIMP_RGB, N_("RGB"), "rgb" },

View File

@ -231,6 +231,26 @@ typedef enum /*< pdb-skip >*/
} GimpCapStyle; } GimpCapStyle;
#define GIMP_TYPE_DASH_PRESET (gimp_dash_preset_get_type ())
GType gimp_dash_preset_get_type (void) G_GNUC_CONST;
typedef enum /*< pdb-skip >*/
{
GIMP_DASH_CUSTOM, /*< desc="Custom" >*/
GIMP_DASH_LINE, /*< desc="Line" >*/
GIMP_DASH_LONG_DASH, /*< desc="Long Dashes" >*/
GIMP_DASH_MEDIUM_DASH, /*< desc="Medium Dashes" >*/
GIMP_DASH_SHORT_DASH, /*< desc="Short Dashes" >*/
GIMP_DASH_SPARSE_DOTS, /*< desc="Sparse Dots" >*/
GIMP_DASH_NORMAL_DOTS, /*< desc="Normal Dots" >*/
GIMP_DASH_DENSE_DOTS, /*< desc="Dense Dots" >*/
GIMP_DASH_STIPPLES, /*< desc="Stipples" >*/
GIMP_DASH_DASH_DOT, /*< desc="Dash Dot..." >*/
GIMP_DASH_DASH_DOT_DOT /*< desc="Dash Dot Dot..." >*/
} GimpDashPreset;
#define GIMP_TYPE_IMAGE_BASE_TYPE (gimp_image_base_type_get_type ()) #define GIMP_TYPE_IMAGE_BASE_TYPE (gimp_image_base_type_get_type ())
GType gimp_image_base_type_get_type (void) G_GNUC_CONST; GType gimp_image_base_type_get_type (void) G_GNUC_CONST;

View File

@ -29,6 +29,7 @@
#include "config/gimpconfig-params.h" #include "config/gimpconfig-params.h"
#include "gimpmarshal.h"
#include "gimpstrokeoptions.h" #include "gimpstrokeoptions.h"
enum enum
@ -46,6 +47,11 @@ enum
PROP_DASH_INFO PROP_DASH_INFO
}; };
enum
{
DASH_INFO_CHANGED,
LAST_SIGNAL
};
static void gimp_stroke_options_class_init (GimpStrokeOptionsClass *klass); static void gimp_stroke_options_class_init (GimpStrokeOptionsClass *klass);
@ -58,6 +64,7 @@ static void gimp_stroke_options_get_property (GObject *object,
GValue *value, GValue *value,
GParamSpec *pspec); GParamSpec *pspec);
static guint stroke_options_signals[LAST_SIGNAL] = { 0 };
static GimpContextClass *parent_class = NULL; static GimpContextClass *parent_class = NULL;
@ -100,6 +107,18 @@ gimp_stroke_options_class_init (GimpStrokeOptionsClass *klass)
parent_class = g_type_class_peek_parent (klass); parent_class = g_type_class_peek_parent (klass);
stroke_options_signals[DASH_INFO_CHANGED] =
g_signal_new ("dash_info_changed",
G_TYPE_FROM_CLASS (klass),
G_SIGNAL_RUN_FIRST,
G_STRUCT_OFFSET (GimpStrokeOptionsClass, dash_info_changed),
NULL, NULL,
gimp_marshal_VOID__ENUM,
G_TYPE_NONE, 1,
GIMP_TYPE_DASH_PRESET);
klass->dash_info_changed = NULL;
object_class->set_property = gimp_stroke_options_set_property; object_class->set_property = gimp_stroke_options_set_property;
object_class->get_property = gimp_stroke_options_get_property; object_class->get_property = gimp_stroke_options_get_property;
@ -214,6 +233,9 @@ gimp_stroke_options_set_property (GObject *object,
val); val);
} }
} }
g_signal_emit (options,
stroke_options_signals [DASH_INFO_CHANGED], 0,
GIMP_DASH_CUSTOM);
} }
break; break;
@ -292,3 +314,90 @@ gimp_stroke_options_get_property (GObject *object,
break; break;
} }
} }
void
gimp_stroke_options_set_dash_preset (GimpStrokeOptions *options,
GimpDashPreset preset)
{
GArray *new_pattern;
gdouble dash;
gint i;
if (preset == GIMP_DASH_CUSTOM)
return;
new_pattern = g_array_new (FALSE, FALSE, sizeof (gdouble));
switch (preset)
{
case GIMP_DASH_LINE:
break;
case GIMP_DASH_LONG_DASH:
dash = 9.0; g_array_append_val (new_pattern, dash);
dash = 3.0; g_array_append_val (new_pattern, dash);
break;
case GIMP_DASH_MEDIUM_DASH:
dash = 6.0; g_array_append_val (new_pattern, dash);
dash = 6.0; g_array_append_val (new_pattern, dash);
break;
case GIMP_DASH_SHORT_DASH:
dash = 3.0; g_array_append_val (new_pattern, dash);
dash = 9.0; g_array_append_val (new_pattern, dash);
break;
case GIMP_DASH_SPARSE_DOTS:
for (i = 0; i < 2; i++)
{
dash = 1.0; g_array_append_val (new_pattern, dash);
dash = 5.0; g_array_append_val (new_pattern, dash);
}
break;
case GIMP_DASH_NORMAL_DOTS:
for (i = 0; i < 3; i++)
{
dash = 1.0; g_array_append_val (new_pattern, dash);
dash = 3.0; g_array_append_val (new_pattern, dash);
}
break;
case GIMP_DASH_DENSE_DOTS:
for (i = 0; i < 12; i++)
{
dash = 1.0; g_array_append_val (new_pattern, dash);
}
break;
case GIMP_DASH_STIPPLES:
for (i = 0; i < 24; i++)
{
dash = 0.5; g_array_append_val (new_pattern, dash);
}
break;
case GIMP_DASH_DASH_DOT:
dash = 7.0; g_array_append_val (new_pattern, dash);
dash = 2.0; g_array_append_val (new_pattern, dash);
dash = 1.0; g_array_append_val (new_pattern, dash);
dash = 2.0; g_array_append_val (new_pattern, dash);
break;
case GIMP_DASH_DASH_DOT_DOT:
dash = 7.0; g_array_append_val (new_pattern, dash);
for (i=0; i < 5; i++)
{
dash = 1.0; g_array_append_val (new_pattern, dash);
}
break;
default:
g_printerr ("Unknown Dash pattern: %d\n", preset);
}
if (options->dash_info != NULL)
g_array_free (options->dash_info, TRUE);
options->dash_info = NULL;
if (new_pattern->len >= 2)
options->dash_info = new_pattern;
else
g_array_free (new_pattern, TRUE);
g_signal_emit (options,
stroke_options_signals [DASH_INFO_CHANGED], 0,
preset);
g_object_notify (G_OBJECT (options), "dash-info");
}

View File

@ -59,10 +59,15 @@ struct _GimpStrokeOptions
struct _GimpStrokeOptionsClass struct _GimpStrokeOptionsClass
{ {
GimpContextClass parent_class; GimpContextClass parent_class;
void (* dash_info_changed) (GimpStrokeOptions *stroke_options,
GimpDashPreset preset);
}; };
GType gimp_stroke_options_get_type (void) G_GNUC_CONST; GType gimp_stroke_options_get_type (void) G_GNUC_CONST;
void gimp_stroke_options_set_dash_preset (GimpStrokeOptions *options,
GimpDashPreset preset);
#endif /* __GIMP_STROKE_OPTIONS_H__ */ #endif /* __GIMP_STROKE_OPTIONS_H__ */

View File

@ -29,6 +29,7 @@
#include "gimppropwidgets.h" #include "gimppropwidgets.h"
#include "gimpdasheditor.h" #include "gimpdasheditor.h"
#include "gimpenummenu.h"
#include "gimpstrokeeditor.h" #include "gimpstrokeeditor.h"
#include "gimp-intl.h" #include "gimp-intl.h"
@ -57,6 +58,9 @@ static void gimp_stroke_editor_finalize (GObject *object);
static gboolean gimp_stroke_editor_paint_button (GtkWidget *widget, static gboolean gimp_stroke_editor_paint_button (GtkWidget *widget,
GdkEventExpose *event, GdkEventExpose *event,
gpointer user_data); gpointer user_data);
static void gimp_stroke_editor_dash_preset (GtkWidget *widget,
gpointer user_data);
static GtkVBoxClass *parent_class = NULL; static GtkVBoxClass *parent_class = NULL;
@ -256,6 +260,18 @@ gimp_stroke_editor_constructor (GType type,
gimp_table_attach_aligned (GTK_TABLE (table), 0, row++, gimp_table_attach_aligned (GTK_TABLE (table), 0, row++,
_("Dash Pattern:"), 1.0, 0.5, frame, 2, FALSE); _("Dash Pattern:"), 1.0, 0.5, frame, 2, FALSE);
box = gimp_enum_option_menu_new (GIMP_TYPE_DASH_PRESET,
G_CALLBACK (gimp_stroke_editor_dash_preset),
editor->options);
g_signal_connect_object (G_OBJECT (editor->options), "dash_info_changed",
G_CALLBACK (gtk_option_menu_set_history),
box, G_CONNECT_SWAPPED);
gimp_table_attach_aligned (GTK_TABLE (table), 0, row++,
_("Dash Preset:"), 1.0, 0.5, box, 2, TRUE);
gtk_widget_show (box);
button = gimp_prop_check_button_new (G_OBJECT (editor->options), "antialias", button = gimp_prop_check_button_new (G_OBJECT (editor->options), "antialias",
_("_Antialiasing")); _("_Antialiasing"));
gtk_table_attach (GTK_TABLE (table), button, 0, 2, row, row + 1, gtk_table_attach (GTK_TABLE (table), button, 0, 2, row, row + 1,
@ -320,3 +336,15 @@ gimp_stroke_editor_paint_button (GtkWidget *widget,
w, w); w, w);
return FALSE; return FALSE;
} }
static void
gimp_stroke_editor_dash_preset (GtkWidget *widget,
gpointer user_data)
{
gint value;
value = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (widget),
"gimp-item-data"));
gimp_stroke_options_set_dash_preset (GIMP_STROKE_OPTIONS (user_data), value);
}