Commit 9c299a8f authored by Michael Natterer's avatar Michael Natterer 😴 Committed by Michael Natterer

app/widgets/Makefile.am app/widgets/widgets-types.h new widget factored

2008-10-24  Michael Natterer  <mitch@gimp.org>

	* app/widgets/Makefile.am
	* app/widgets/widgets-types.h
	* app/widgets/gimpfilleditor.[ch]: new widget factored out of
	GimpStrokeEditor.

	* app/widgets/gimpstrokeeditor.[ch]: derive from GimpFillEditor
	and remove UI for the properties of GimpFillOptions.


svn path=/trunk/; revision=27390
parent 1a453c37
2008-10-24 Michael Natterer <mitch@gimp.org>
* app/widgets/Makefile.am
* app/widgets/widgets-types.h
* app/widgets/gimpfilleditor.[ch]: new widget factored out of
GimpStrokeEditor.
* app/widgets/gimpstrokeeditor.[ch]: derive from GimpFillEditor
and remove UI for the properties of GimpFillOptions.
2008-10-24 Michael Natterer <mitch@gimp.org>
* app/core/Makefile.am
......
......@@ -153,6 +153,8 @@ libappwidgets_a_sources = \
gimpfiledialog.h \
gimpfileprocview.c \
gimpfileprocview.h \
gimpfilleditor.c \
gimpfilleditor.h \
gimpfontselect.c \
gimpfontselect.h \
gimpfontview.c \
......
/* GIMP - The GNU Image Manipulation Program
* Copyright (C) 1995-1999 Spencer Kimball and Peter Mattis
*
* gimpfilleditor.c
* Copyright (C) 2008 Michael Natterer <mitch@gimp.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include "config.h"
#include <gtk/gtk.h>
#include "libgimpbase/gimpbase.h"
#include "libgimpwidgets/gimpwidgets.h"
#include "widgets-types.h"
#include "core/gimpfilloptions.h"
#include "gimpfilleditor.h"
#include "gimp-intl.h"
enum
{
PROP_0,
PROP_OPTIONS,
PROP_RESOLUTION
};
static GObject * gimp_fill_editor_constructor (GType type,
guint n_params,
GObjectConstructParam *params);
static void gimp_fill_editor_finalize (GObject *object);
static void gimp_fill_editor_set_property (GObject *object,
guint property_id,
const GValue *value,
GParamSpec *pspec);
static void gimp_fill_editor_get_property (GObject *object,
guint property_id,
GValue *value,
GParamSpec *pspec);
G_DEFINE_TYPE (GimpFillEditor, gimp_fill_editor, GTK_TYPE_VBOX)
#define parent_class gimp_fill_editor_parent_class
static void
gimp_fill_editor_class_init (GimpFillEditorClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
object_class->constructor = gimp_fill_editor_constructor;
object_class->finalize = gimp_fill_editor_finalize;
object_class->set_property = gimp_fill_editor_set_property;
object_class->get_property = gimp_fill_editor_get_property;
g_object_class_install_property (object_class, PROP_OPTIONS,
g_param_spec_object ("options", NULL, NULL,
GIMP_TYPE_FILL_OPTIONS,
GIMP_PARAM_READWRITE |
G_PARAM_CONSTRUCT_ONLY));
}
static void
gimp_fill_editor_init (GimpFillEditor *editor)
{
}
static GObject *
gimp_fill_editor_constructor (GType type,
guint n_params,
GObjectConstructParam *params)
{
GObject *object;
GimpFillEditor *editor;
GtkWidget *box;
object = G_OBJECT_CLASS (parent_class)->constructor (type, n_params, params);
editor = GIMP_FILL_EDITOR (object);
g_assert (GIMP_IS_FILL_OPTIONS (editor->options));
gtk_box_set_spacing (GTK_BOX (editor), 12);
box = gimp_prop_enum_radio_box_new (G_OBJECT (editor->options), "style",
0, 0);
gtk_box_pack_start (GTK_BOX (editor), box, FALSE, FALSE, 0);
gtk_widget_show (box);
return object;
}
static void
gimp_fill_editor_finalize (GObject *object)
{
GimpFillEditor *editor = GIMP_FILL_EDITOR (object);
if (editor->options)
{
g_object_unref (editor->options);
editor->options = NULL;
}
G_OBJECT_CLASS (parent_class)->finalize (object);
}
static void
gimp_fill_editor_set_property (GObject *object,
guint property_id,
const GValue *value,
GParamSpec *pspec)
{
GimpFillEditor *editor = GIMP_FILL_EDITOR (object);
switch (property_id)
{
case PROP_OPTIONS:
if (editor->options)
g_object_unref (editor->options);
editor->options = g_value_dup_object (value);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;
}
}
static void
gimp_fill_editor_get_property (GObject *object,
guint property_id,
GValue *value,
GParamSpec *pspec)
{
GimpFillEditor *editor = GIMP_FILL_EDITOR (object);
switch (property_id)
{
case PROP_OPTIONS:
g_value_set_object (value, editor->options);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;
}
}
GtkWidget *
gimp_fill_editor_new (GimpFillOptions *options)
{
g_return_val_if_fail (GIMP_IS_FILL_OPTIONS (options), NULL);
return g_object_new (GIMP_TYPE_FILL_EDITOR,
"options", options,
NULL);
}
/* GIMP - The GNU Image Manipulation Program
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* gimpfilleditor.h
* Copyright (C) 2008 Michael Natterer <mitch@gimp.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifndef __GIMP_FILL_EDITOR_H__
#define __GIMP_FILL_EDITOR_H__
#define GIMP_TYPE_FILL_EDITOR (gimp_fill_editor_get_type ())
#define GIMP_FILL_EDITOR(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GIMP_TYPE_FILL_EDITOR, GimpFillEditor))
#define GIMP_FILL_EDITOR_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GIMP_TYPE_FILL_EDITOR, GimpFillEditorClass))
#define GIMP_IS_FILL_EDITOR(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GIMP_TYPE_FILL_EDITOR))
#define GIMP_IS_FILL_EDITOR_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GIMP_TYPE_FILL_EDITOR))
#define GIMP_FILL_EDITOR_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GIMP_TYPE_FILL_EDITOR, GimpFillEditorClass))
typedef struct _GimpFillEditorClass GimpFillEditorClass;
struct _GimpFillEditor
{
GtkVBox parent_instance;
GimpFillOptions *options;
};
struct _GimpFillEditorClass
{
GtkVBoxClass parent_class;
};
GType gimp_fill_editor_get_type (void) G_GNUC_CONST;
GtkWidget * gimp_fill_editor_new (GimpFillOptions *options);
#endif /* __GIMP_FILL_EDITOR_H__ */
......@@ -54,7 +54,6 @@ static void gimp_stroke_editor_get_property (GObject *object,
guint property_id,
GValue *value,
GParamSpec *pspec);
static void gimp_stroke_editor_finalize (GObject *object);
static gboolean gimp_stroke_editor_paint_button (GtkWidget *widget,
GdkEventExpose *event,
gpointer data);
......@@ -65,7 +64,7 @@ static void gimp_stroke_editor_combo_fill (GimpStrokeOptions *options,
GtkComboBox *box);
G_DEFINE_TYPE (GimpStrokeEditor, gimp_stroke_editor, GTK_TYPE_VBOX)
G_DEFINE_TYPE (GimpStrokeEditor, gimp_stroke_editor, GIMP_TYPE_FILL_EDITOR)
#define parent_class gimp_stroke_editor_parent_class
......@@ -78,7 +77,6 @@ gimp_stroke_editor_class_init (GimpStrokeEditorClass *klass)
object_class->constructor = gimp_stroke_editor_constructor;
object_class->set_property = gimp_stroke_editor_set_property;
object_class->get_property = gimp_stroke_editor_get_property;
object_class->finalize = gimp_stroke_editor_finalize;
g_object_class_install_property (object_class, PROP_OPTIONS,
g_param_spec_object ("options", NULL, NULL,
......@@ -106,14 +104,15 @@ gimp_stroke_editor_set_property (GObject *object,
const GValue *value,
GParamSpec *pspec)
{
GimpStrokeEditor *editor = GIMP_STROKE_EDITOR (object);
GimpFillEditor *fill_editor = GIMP_FILL_EDITOR (object);
GimpStrokeEditor *editor = GIMP_STROKE_EDITOR (object);
switch (property_id)
{
case PROP_OPTIONS:
if (editor->options)
g_object_unref (editor->options);
editor->options = g_value_dup_object (value);
if (fill_editor->options)
g_object_unref (fill_editor->options);
fill_editor->options = g_value_dup_object (value);
break;
case PROP_RESOLUTION:
......@@ -132,12 +131,13 @@ gimp_stroke_editor_get_property (GObject *object,
GValue *value,
GParamSpec *pspec)
{
GimpStrokeEditor *editor = GIMP_STROKE_EDITOR (object);
GimpFillEditor *fill_editor = GIMP_FILL_EDITOR (object);
GimpStrokeEditor *editor = GIMP_STROKE_EDITOR (object);
switch (property_id)
{
case PROP_OPTIONS:
g_value_set_object (value, editor->options);
g_value_set_object (value, fill_editor->options);
break;
case PROP_RESOLUTION:
......@@ -155,28 +155,31 @@ gimp_stroke_editor_constructor (GType type,
guint n_params,
GObjectConstructParam *params)
{
GimpStrokeEditor *editor;
GimpEnumStore *store;
GEnumValue *value;
GtkWidget *box;
GtkWidget *size;
GtkWidget *label;
GtkWidget *frame;
GtkWidget *table;
GtkWidget *expander;
GtkWidget *dash_editor;
GtkWidget *button;
GtkCellRenderer *cell;
GObject *object;
gint row = 0;
GObject *object;
GimpFillEditor *fill_editor;
GimpStrokeEditor *editor;
GimpStrokeOptions *options;
GimpEnumStore *store;
GEnumValue *value;
GtkWidget *box;
GtkWidget *size;
GtkWidget *label;
GtkWidget *frame;
GtkWidget *table;
GtkWidget *expander;
GtkWidget *dash_editor;
GtkWidget *button;
GtkCellRenderer *cell;
gint row = 0;
object = G_OBJECT_CLASS (parent_class)->constructor (type, n_params, params);
editor = GIMP_STROKE_EDITOR (object);
fill_editor = GIMP_FILL_EDITOR (object);
editor = GIMP_STROKE_EDITOR (object);
g_assert (editor->options != NULL);
g_assert (GIMP_IS_STROKE_OPTIONS (fill_editor->options));
gtk_box_set_spacing (GTK_BOX (editor), 12);
options = GIMP_STROKE_OPTIONS (fill_editor->options);
box = gtk_hbox_new (FALSE, 6);
gtk_box_pack_start (GTK_BOX (editor), box, FALSE, FALSE, 0);
......@@ -186,7 +189,7 @@ gimp_stroke_editor_constructor (GType type,
gtk_box_pack_start (GTK_BOX (box), label, FALSE, FALSE, 0);
gtk_widget_show (label);
size = gimp_prop_size_entry_new (G_OBJECT (editor->options),
size = gimp_prop_size_entry_new (G_OBJECT (options),
"width", FALSE, "unit",
"%a", GIMP_SIZE_ENTRY_UPDATE_SIZE,
editor->resolution);
......@@ -194,11 +197,6 @@ gimp_stroke_editor_constructor (GType type,
gtk_box_pack_start (GTK_BOX (box), size, FALSE, FALSE, 0);
gtk_widget_show (size);
box = gimp_prop_enum_radio_box_new (G_OBJECT (editor->options), "style",
0, 0);
gtk_box_pack_start (GTK_BOX (editor), box, FALSE, FALSE, 0);
gtk_widget_show (box);
expander = gtk_expander_new_with_mnemonic (_("_Line Style"));
gtk_box_pack_start (GTK_BOX (editor), expander, FALSE, FALSE, 0);
gtk_widget_show (expander);
......@@ -215,19 +213,19 @@ gimp_stroke_editor_constructor (GType type,
gtk_container_add (GTK_CONTAINER (frame), table);
gtk_widget_show (table);
box = gimp_prop_enum_stock_box_new (G_OBJECT (editor->options), "cap-style",
box = gimp_prop_enum_stock_box_new (G_OBJECT (options), "cap-style",
"gimp-cap", 0, 0);
gimp_table_attach_aligned (GTK_TABLE (table), 0, row++,
_("_Cap style:"), 0.0, 0.5,
box, 2, TRUE);
box = gimp_prop_enum_stock_box_new (G_OBJECT (editor->options), "join-style",
box = gimp_prop_enum_stock_box_new (G_OBJECT (options), "join-style",
"gimp-join", 0, 0);
gimp_table_attach_aligned (GTK_TABLE (table), 0, row++,
_("_Join style:"), 0.0, 0.5,
box, 2, TRUE);
gimp_prop_scale_entry_new (G_OBJECT (editor->options), "miter-limit",
gimp_prop_scale_entry_new (G_OBJECT (options), "miter-limit",
GTK_TABLE (table), 0, row++,
_("_Miter limit:"),
1.0, 1.0, 1,
......@@ -243,7 +241,7 @@ gimp_stroke_editor_constructor (GType type,
gtk_container_add (GTK_CONTAINER (frame), box);
gtk_widget_show (box);
dash_editor = gimp_dash_editor_new (editor->options);
dash_editor = gimp_dash_editor_new (options);
button = g_object_new (GTK_TYPE_BUTTON,
"width-request", 14,
......@@ -309,17 +307,18 @@ gimp_stroke_editor_constructor (GType type,
gtk_cell_layout_add_attribute (GTK_CELL_LAYOUT (box), cell,
"pattern", GIMP_INT_STORE_USER_DATA);
gimp_stroke_editor_combo_fill (editor->options, GTK_COMBO_BOX (box));
gimp_stroke_editor_combo_fill (options, GTK_COMBO_BOX (box));
g_signal_connect (box, "changed",
G_CALLBACK (gimp_stroke_editor_dash_preset),
editor->options);
g_signal_connect_object (editor->options, "dash-info-changed",
options);
g_signal_connect_object (options, "dash-info-changed",
G_CALLBACK (gimp_int_combo_box_set_active),
box, G_CONNECT_SWAPPED);
button = gimp_prop_check_button_new (G_OBJECT (editor->options), "antialias",
button = gimp_prop_check_button_new (G_OBJECT (options),
"antialias",
_("_Antialiasing"));
gtk_table_attach (GTK_TABLE (table), button, 0, 3, row, row + 1,
GTK_SHRINK | GTK_FILL, GTK_SHRINK | GTK_FILL, 0, 0);
......@@ -329,20 +328,6 @@ gimp_stroke_editor_constructor (GType type,
return object;
}
static void
gimp_stroke_editor_finalize (GObject *object)
{
GimpStrokeEditor *editor = GIMP_STROKE_EDITOR (object);
if (editor->options)
{
g_object_unref (editor->options);
editor->options = NULL;
}
G_OBJECT_CLASS (parent_class)->finalize (object);
}
GtkWidget *
gimp_stroke_editor_new (GimpStrokeOptions *options,
gdouble resolution)
......
......@@ -23,6 +23,9 @@
#define __GIMP_STROKE_EDITOR_H__
#include "gimpfilleditor.h"
#define GIMP_TYPE_STROKE_EDITOR (gimp_stroke_editor_get_type ())
#define GIMP_STROKE_EDITOR(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GIMP_TYPE_STROKE_EDITOR, GimpStrokeEditor))
#define GIMP_STROKE_EDITOR_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GIMP_TYPE_STROKE_EDITOR, GimpStrokeEditorClass))
......@@ -35,22 +38,21 @@ typedef struct _GimpStrokeEditorClass GimpStrokeEditorClass;
struct _GimpStrokeEditor
{
GtkVBox parent_instance;
GimpFillEditor parent_instance;
GimpStrokeOptions *options;
gdouble resolution;
gdouble resolution;
};
struct _GimpStrokeEditorClass
{
GtkVBoxClass parent_class;
GimpFillEditorClass parent_class;
};
GType gimp_stroke_editor_get_type (void) G_GNUC_CONST;
GType gimp_stroke_editor_get_type (void) G_GNUC_CONST;
GtkWidget * gimp_stroke_editor_new (GimpStrokeOptions *options,
gdouble resolution);
GtkWidget * gimp_stroke_editor_new (GimpStrokeOptions *options,
gdouble resolution);
#endif /* __GIMP_STROKE_EDITOR_H__ */
#endif /* __GIMP_STROKE_EDITOR_H__ */
......@@ -163,6 +163,7 @@ typedef struct _GimpDashEditor GimpDashEditor;
typedef struct _GimpFgBgEditor GimpFgBgEditor;
typedef struct _GimpFgBgView GimpFgBgView;
typedef struct _GimpFileProcView GimpFileProcView;
typedef struct _GimpFillEditor GimpFillEditor;
typedef struct _GimpGridEditor GimpGridEditor;
typedef struct _GimpHandleBar GimpHandleBar;
typedef struct _GimpHistogramBox GimpHistogramBox;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment