Commit cb474a08 authored by Michael Natterer's avatar Michael Natterer 😴 Committed by Michael Natterer

made a real object (GtkDialog subclass) out of it. The API will change

2001-09-20  Michael Natterer  <mitch@gimp.org>

	* libgimpwidgets/gimpdialog.[ch]: made a real object (GtkDialog
	subclass) out of it. The API will change soon too.

	* libgimpwidgets/gimpwidgetstypes.h: added GimpDialog typedef.

	* libgimpwidgets/gimpbutton.[ch]
	* libgimpwidgets/gimpchainbutton.[ch]
	* libgimpwidgets/gimpcolorarea.[ch]
	* libgimpwidgets/gimpcolorbutton.[ch]
	* libgimpwidgets/gimpfileselection.[ch]
	* libgimpwidgets/gimpoffsetarea.[ch]
	* libgimpwidgets/gimppatheditor.[ch]
	* libgimpwidgets/gimppixmap.c
	* libgimpwidgets/gimpsizeentry.c
	* libgimpwidgets/gimpunitmenu.c: removed GtkType stuff and use
	GType in all get_type() functions. Some random GObject porting.

	* app/gui/info-dialog.c
	* app/gui/info-window.c
	* app/tools/gimpcolorpickertool.c
	* app/tools/gimpcroptool.c
	* app/tools/gimpmeasuretool.c
	* app/tools/gimptransformtool.c: changed accordingly.
parent 58afaec6
2001-09-20 Michael Natterer <mitch@gimp.org>
* libgimpwidgets/gimpdialog.[ch]: made a real object (GtkDialog
subclass) out of it. The API will change soon too.
* libgimpwidgets/gimpwidgetstypes.h: added GimpDialog typedef.
* libgimpwidgets/gimpbutton.[ch]
* libgimpwidgets/gimpchainbutton.[ch]
* libgimpwidgets/gimpcolorarea.[ch]
* libgimpwidgets/gimpcolorbutton.[ch]
* libgimpwidgets/gimpfileselection.[ch]
* libgimpwidgets/gimpoffsetarea.[ch]
* libgimpwidgets/gimppatheditor.[ch]
* libgimpwidgets/gimppixmap.c
* libgimpwidgets/gimpsizeentry.c
* libgimpwidgets/gimpunitmenu.c: removed GtkType stuff and use
GType in all get_type() functions. Some random GObject porting.
* app/gui/info-dialog.c
* app/gui/info-window.c
* app/tools/gimpcolorpickertool.c
* app/tools/gimpcroptool.c
* app/tools/gimpmeasuretool.c
* app/tools/gimptransformtool.c: changed accordingly.
2001-09-20 Sven Neumann <sven@gimp.org>
* app/gdisplay.c: fixed resize of cursor position label that I broke
......
......@@ -496,7 +496,7 @@ gimp_transform_tool_button_press (GimpTool *tool,
gimp_context_get_tool (gimp_get_user_context (gdisp->gimage->gimp))->tool_type;
gimp_dialog_create_action_area
(GTK_DIALOG (transform_info->shell),
(GIMP_DIALOG (transform_info->shell),
/* FIXME: this does not belong here */
(tool_type == GIMP_TYPE_ROTATE_TOOL) ? _("Rotate") :
......
......@@ -496,7 +496,7 @@ gimp_transform_tool_button_press (GimpTool *tool,
gimp_context_get_tool (gimp_get_user_context (gdisp->gimage->gimp))->tool_type;
gimp_dialog_create_action_area
(GTK_DIALOG (transform_info->shell),
(GIMP_DIALOG (transform_info->shell),
/* FIXME: this does not belong here */
(tool_type == GIMP_TYPE_ROTATE_TOOL) ? _("Rotate") :
......
......@@ -350,7 +350,7 @@ gimp_color_picker_tool_button_press (GimpTool *tool,
/* create the action area */
gimp_dialog_create_action_area
(GTK_DIALOG (gimp_color_picker_tool_info->shell),
(GIMP_DIALOG (gimp_color_picker_tool_info->shell),
GTK_STOCK_CLOSE, gimp_color_picker_tool_info_window_close_callback,
gimp_color_picker_tool_info, NULL, NULL, TRUE, FALSE,
......
......@@ -173,7 +173,7 @@ info_dialog_new_extended (gchar *title,
idialog->field_list = NULL;
idialog->nfields = 0;
shell = gtk_dialog_new ();
shell = g_object_new (GIMP_TYPE_DIALOG, NULL);
gtk_window_set_wmclass (GTK_WINDOW (shell), "info_dialog", "Gimp");
gtk_window_set_title (GTK_WINDOW (shell), title);
......
......@@ -331,7 +331,7 @@ info_window_create (GDisplay *gdisp)
g_free (title);
/* create the action area */
gimp_dialog_create_action_area (GTK_DIALOG (info_win->shell),
gimp_dialog_create_action_area (GIMP_DIALOG (info_win->shell),
GTK_STOCK_CLOSE, info_window_close_callback,
info_win, NULL, NULL, TRUE, FALSE,
......
......@@ -173,7 +173,7 @@ info_dialog_new_extended (gchar *title,
idialog->field_list = NULL;
idialog->nfields = 0;
shell = gtk_dialog_new ();
shell = g_object_new (GIMP_TYPE_DIALOG, NULL);
gtk_window_set_wmclass (GTK_WINDOW (shell), "info_dialog", "Gimp");
gtk_window_set_title (GTK_WINDOW (shell), title);
......
......@@ -331,7 +331,7 @@ info_window_create (GDisplay *gdisp)
g_free (title);
/* create the action area */
gimp_dialog_create_action_area (GTK_DIALOG (info_win->shell),
gimp_dialog_create_action_area (GIMP_DIALOG (info_win->shell),
GTK_STOCK_CLOSE, info_window_close_callback,
info_win, NULL, NULL, TRUE, FALSE,
......
......@@ -350,7 +350,7 @@ gimp_color_picker_tool_button_press (GimpTool *tool,
/* create the action area */
gimp_dialog_create_action_area
(GTK_DIALOG (gimp_color_picker_tool_info->shell),
(GIMP_DIALOG (gimp_color_picker_tool_info->shell),
GTK_STOCK_CLOSE, gimp_color_picker_tool_info_window_close_callback,
gimp_color_picker_tool_info, NULL, NULL, TRUE, FALSE,
......
......@@ -877,7 +877,7 @@ crop_info_create (GimpTool *tool)
tool_manager_help_func, NULL);
/* create the action area */
gimp_dialog_create_action_area (GTK_DIALOG (crop_info->shell),
gimp_dialog_create_action_area (GIMP_DIALOG (crop_info->shell),
_("Crop"), crop_crop_callback,
NULL, NULL, NULL, TRUE, FALSE,
......
......@@ -381,7 +381,7 @@ gimp_measure_tool_button_press (GimpTool *tool,
info_dialog_add_label (measure_tool_info, _("Distance:"), distance_buf);
info_dialog_add_label (measure_tool_info, _("Angle:"), angle_buf);
gimp_dialog_create_action_area (GTK_DIALOG (measure_tool_info->shell),
gimp_dialog_create_action_area (GIMP_DIALOG (measure_tool_info->shell),
GTK_STOCK_CLOSE,
measure_tool_info_window_close_callback,
......
......@@ -496,7 +496,7 @@ gimp_transform_tool_button_press (GimpTool *tool,
gimp_context_get_tool (gimp_get_user_context (gdisp->gimage->gimp))->tool_type;
gimp_dialog_create_action_area
(GTK_DIALOG (transform_info->shell),
(GIMP_DIALOG (transform_info->shell),
/* FIXME: this does not belong here */
(tool_type == GIMP_TYPE_ROTATE_TOOL) ? _("Rotate") :
......
......@@ -57,19 +57,22 @@ gimp_button_get_type (void)
if (! button_type)
{
GtkTypeInfo button_info =
static const GTypeInfo button_info =
{
"GimpButton",
sizeof (GimpButton),
sizeof (GimpButtonClass),
(GtkClassInitFunc) gimp_button_class_init,
(GtkObjectInitFunc) gimp_button_init,
/* reserved_1 */ NULL,
/* reserved_2 */ NULL,
(GtkClassInitFunc) NULL
sizeof (GimpButtonClass),
(GBaseInitFunc) NULL,
(GBaseFinalizeFunc) NULL,
(GClassInitFunc) gimp_button_class_init,
NULL, /* class_finalize */
NULL, /* class_data */
sizeof (GimpButton),
0, /* n_preallocs */
(GInstanceInitFunc) gimp_button_init,
};
button_type = gtk_type_unique (GTK_TYPE_BUTTON, &button_info);
button_type = g_type_register_static (GTK_TYPE_BUTTON,
"GimpButton",
&button_info, 0);
}
return button_type;
......@@ -81,8 +84,8 @@ gimp_button_class_init (GimpButtonClass *klass)
GObjectClass *object_class;
GtkWidgetClass *widget_class;
object_class = (GObjectClass *) klass;
widget_class = (GtkWidgetClass *) klass;
object_class = G_OBJECT_CLASS (klass);
widget_class = GTK_WIDGET_CLASS (klass);
parent_class = g_type_class_peek_parent (klass);
......
......@@ -23,6 +23,10 @@
#ifndef __GIMP_BUTTON_H__
#define __GIMP_BUTTON_H__
#include <gtk/gtkbutton.h>
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
......@@ -35,6 +39,7 @@ extern "C" {
#define GIMP_BUTTON_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GIMP_TYPE_BUTTON, GimpButtonClass))
#define GIMP_IS_BUTTON(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GIMP_TYPE_BUTTON))
#define GIMP_IS_BUTTON_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GIMP_TYPE_BUTTON))
#define GIMP_BUTTON_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GIMP_TYPE_BUTTON, GimpButtonClass))
typedef struct _GimpButtonClass GimpButtonClass;
......
......@@ -83,19 +83,22 @@ gimp_chain_button_get_type (void)
if (! gcb_type)
{
GtkTypeInfo gcb_info =
static const GTypeInfo gcb_info =
{
"GimpChainButton",
sizeof (GimpChainButton),
sizeof (GimpChainButtonClass),
(GtkClassInitFunc) gimp_chain_button_class_init,
(GtkObjectInitFunc) gimp_chain_button_init,
/* reserved_1 */ NULL,
/* reserved_2 */ NULL,
(GtkClassInitFunc) NULL
sizeof (GimpChainButtonClass),
(GBaseInitFunc) NULL,
(GBaseFinalizeFunc) NULL,
(GClassInitFunc) gimp_chain_button_class_init,
NULL, /* class_finalize */
NULL, /* class_data */
sizeof (GimpChainButton),
0, /* n_preallocs */
(GInstanceInitFunc) gimp_chain_button_init,
};
gcb_type = gtk_type_unique (gtk_table_get_type (), &gcb_info);
gcb_type = g_type_register_static (GTK_TYPE_TABLE,
"GimpChainButton",
&gcb_info, 0);
}
return gcb_type;
......@@ -107,8 +110,8 @@ gimp_chain_button_class_init (GimpChainButtonClass *klass)
GtkObjectClass *object_class;
GtkWidgetClass *widget_class;
object_class = (GtkObjectClass *) klass;
widget_class = (GtkWidgetClass *) klass;
object_class = GTK_OBJECT_CLASS (klass);
widget_class = GTK_WIDGET_CLASS (klass);
parent_class = g_type_class_peek_parent (klass);
......@@ -148,7 +151,7 @@ gimp_chain_button_init (GimpChainButton *gcb)
gtk_pixmap_set_build_insensitive (GTK_PIXMAP (gcb->pixmap), TRUE);
g_signal_connect (G_OBJECT(gcb->button), "clicked",
g_signal_connect (G_OBJECT (gcb->button), "clicked",
G_CALLBACK (gimp_chain_button_clicked_callback),
gcb);
g_signal_connect (G_OBJECT (gcb->line1), "expose_event",
......
......@@ -41,6 +41,7 @@ extern "C" {
#define GIMP_CHAIN_BUTTON_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GIMP_TYPE_CHAIN_BUTTON, GimpChainButtonClass))
#define GIMP_IS_CHAIN_BUTTON(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GIMP_TYPE_CHAIN_BUTTON))
#define GIMP_IS_CHAIN_BUTTON_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GIMP_TYPE_CHAIN_BUTTON))
#define GIMP_CHAIN_BUTTON_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GIMP_TYPE_CHAIN_BUTTON, GimpChainButtonClass))
typedef struct _GimpChainButtonClass GimpChainButtonClass;
......@@ -56,7 +57,7 @@ typedef enum
struct _GimpChainButton
{
GtkTable table;
GtkTable parent_instance;
GimpChainPosition position;
GtkWidget *button;
......@@ -72,14 +73,16 @@ struct _GimpChainButton
struct _GimpChainButtonClass
{
GtkTableClass parent_class;
GtkTableClass parent_class;
void (* toggled) (GimpChainButton *gcb);
};
GtkType gimp_chain_button_get_type (void);
GType gimp_chain_button_get_type (void);
GtkWidget * gimp_chain_button_new (GimpChainPosition position);
void gimp_chain_button_set_active (GimpChainButton *gcb,
gboolean is_active);
gboolean gimp_chain_button_get_active (GimpChainButton *gcb);
......
......@@ -36,16 +36,18 @@
#define DRAG_ICON_OFFSET -8
static const GtkTargetEntry targets[] = { { "application/x-color", 0 } };
enum
{
COLOR_CHANGED,
LAST_SIGNAL
};
static guint gimp_color_area_signals[LAST_SIGNAL] = { 0 };
static GtkWidgetClass *parent_class = NULL;
static const GtkTargetEntry targets[] = { { "application/x-color", 0 } };
static guint gimp_color_area_signals[LAST_SIGNAL] = { 0 };
static GtkWidgetClass * parent_class = NULL;
static void gimp_color_area_class_init (GimpColorAreaClass *klass);
......@@ -84,19 +86,22 @@ gimp_color_area_get_type (void)
if (!gca_type)
{
GtkTypeInfo gca_info =
static const GTypeInfo gca_info =
{
"GimpColorArea",
sizeof (GimpColorArea),
sizeof (GimpColorAreaClass),
(GtkClassInitFunc) gimp_color_area_class_init,
(GtkObjectInitFunc) gimp_color_area_init,
/* reserved_1 */ NULL,
/* reserved_2 */ NULL,
(GtkClassInitFunc) NULL
sizeof (GimpColorAreaClass),
(GBaseInitFunc) NULL,
(GBaseFinalizeFunc) NULL,
(GClassInitFunc) gimp_color_area_class_init,
NULL, /* class_finalize */
NULL, /* class_data */
sizeof (GimpColorArea),
0, /* n_preallocs */
(GInstanceInitFunc) gimp_color_area_init,
};
gca_type = gtk_type_unique (GTK_TYPE_PREVIEW, &gca_info);
gca_type = g_type_register_static (GTK_TYPE_PREVIEW,
"GimpColorArea",
&gca_info, 0);
}
return gca_type;
......
......@@ -42,20 +42,14 @@ extern "C" {
#define GIMP_COLOR_AREA_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GIMP_TYPE_COLOR_AREA, GimpColorAreaClass))
#define GIMP_IS_COLOR_AREA(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GIMP_TYPE_COLOR_AREA))
#define GIMP_IS_COLOR_AREA_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GIMP_TYPE_COLOR_AREA))
#define GIMP_COLOR_AREA_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GIMP_TYPE_COLOR_AREA, GimpColorAreaClass))
typedef enum
{
GIMP_COLOR_AREA_FLAT = 0,
GIMP_COLOR_AREA_SMALL_CHECKS,
GIMP_COLOR_AREA_LARGE_CHECKS
} GimpColorAreaType;
typedef struct _GimpColorAreaClass GimpColorAreaClass;
struct _GimpColorArea
{
GtkPreview preview;
GtkPreview parent_instance;
/*< private >*/
GimpColorAreaType type;
......@@ -65,16 +59,18 @@ struct _GimpColorArea
struct _GimpColorAreaClass
{
GtkPreviewClass parent_class;
GtkPreviewClass parent_class;
void (* color_changed) (GimpColorArea *gca);
};
GtkType gimp_color_area_get_type (void);
GType gimp_color_area_get_type (void);
GtkWidget * gimp_color_area_new (const GimpRGB *color,
GimpColorAreaType type,
GdkModifierType drag_mask);
void gimp_color_area_set_color (GimpColorArea *gca,
const GimpRGB *color);
void gimp_color_area_get_color (GimpColorArea *gca,
......
......@@ -36,6 +36,13 @@
#include "libgimp/libgimp-intl.h"
enum
{
COLOR_CHANGED,
LAST_SIGNAL
};
static void gimp_color_button_class_init (GimpColorButtonClass *klass);
static void gimp_color_button_init (GimpColorButton *gcb);
static void gimp_color_button_destroy (GtkObject *object);
......@@ -71,50 +78,40 @@ static GtkItemFactoryEntry menu_items[] =
{ N_("/Use Foreground Color"), NULL, gimp_color_button_use_fg, 2, NULL },
{ N_("/Use Background Color"), NULL, gimp_color_button_use_bg, 2, NULL }
};
static gint nmenu_items = sizeof (menu_items) / sizeof (menu_items[0]);
enum
{
COLOR_CHANGED,
LAST_SIGNAL
};
static guint gimp_color_button_signals[LAST_SIGNAL] = { 0 };
static guint gimp_color_button_signals[LAST_SIGNAL] = { 0 };
static GtkPreviewClass *parent_class = NULL;
static GimpButtonClass * parent_class = NULL;
static void
gimp_color_button_destroy (GtkObject *object)
GType
gimp_color_button_get_type (void)
{
GimpColorButton *gcb = GIMP_COLOR_BUTTON (object);
g_return_if_fail (gcb != NULL);
static GType gcb_type = 0;
if (gcb->title)
{
g_free (gcb->title);
gcb->title = NULL;
}
if (gcb->dialog)
if (!gcb_type)
{
gtk_widget_destroy (gcb->dialog);
gcb->dialog = NULL;
}
static const GTypeInfo gcb_info =
{
sizeof (GimpColorButtonClass),
(GBaseInitFunc) NULL,
(GBaseFinalizeFunc) NULL,
(GClassInitFunc) gimp_color_button_class_init,
NULL, /* class_finalize */
NULL, /* class_data */
sizeof (GimpColorButton),
0, /* n_preallocs */
(GInstanceInitFunc) gimp_color_button_init,
};
if (gcb->color_area)
{
gtk_widget_destroy (gcb->color_area);
gcb->color_area = NULL;
gcb_type = g_type_register_static (GIMP_TYPE_BUTTON,
"GimpColorButton",
&gcb_info, 0);
}
if (GTK_OBJECT_CLASS (parent_class)->destroy)
GTK_OBJECT_CLASS (parent_class)->destroy (object);
return gcb_type;
}
static void
gimp_color_button_class_init (GimpColorButtonClass *klass)
{
......@@ -122,9 +119,9 @@ gimp_color_button_class_init (GimpColorButtonClass *klass)
GtkWidgetClass *widget_class;
GtkButtonClass *button_class;
object_class = (GtkObjectClass *) klass;
widget_class = (GtkWidgetClass *) klass;
button_class = (GtkButtonClass *) klass;
object_class = GTK_OBJECT_CLASS (klass);
widget_class = GTK_WIDGET_CLASS (klass);
button_class = GTK_BUTTON_CLASS (klass);
parent_class = g_type_class_peek_parent (klass);
......@@ -151,8 +148,8 @@ gimp_color_button_init (GimpColorButton *gcb)
{
GimpRGB color;
gcb->title = NULL;
gcb->dialog = NULL;
gcb->title = NULL;
gcb->dialog = NULL;
gimp_rgba_set (&color, 0.0, 0.0, 0.0, 1.0);
gcb->color_area = gimp_color_area_new (&color, FALSE, GDK_BUTTON2_MASK);
......@@ -169,35 +166,52 @@ gimp_color_button_init (GimpColorButton *gcb)
gimp_color_button_menu_translate,
NULL, NULL);
gtk_item_factory_create_items (gcb->item_factory,
nmenu_items, menu_items, gcb);
G_N_ELEMENTS (menu_items), menu_items, gcb);
g_signal_connect (G_OBJECT (gcb), "button_press_event",
G_CALLBACK (gimp_color_button_menu_popup),
gcb);
}
GtkType
gimp_color_button_get_type (void)
static void
gimp_color_button_destroy (GtkObject *object)
{
static GtkType gcb_type = 0;
GimpColorButton *gcb = GIMP_COLOR_BUTTON (object);
g_return_if_fail (gcb != NULL);
if (!gcb_type)
if (gcb->title)
{
GtkTypeInfo gcb_info =
{
"GimpColorButton",
sizeof (GimpColorButton),
sizeof (GimpColorButtonClass),
(GtkClassInitFunc) gimp_color_button_class_init,
(GtkObjectInitFunc) gimp_color_button_init,
/* reserved_1 */ NULL,
/* reserved_2 */ NULL,
(GtkClassInitFunc) NULL
};
g_free (gcb->title);
gcb->title = NULL;
}
gcb_type = gtk_type_unique (gtk_button_get_type (), &gcb_info);
if (gcb->dialog)
{
gtk_widget_destroy (gcb->dialog);
gcb->dialog = NULL;
}
if (gcb->color_area)
{
gtk_widget_destroy (gcb->color_area);
gcb->color_area = NULL;
}
return gcb_type;
if (GTK_OBJECT_CLASS (parent_class)->destroy)
GTK_OBJECT_CLASS (parent_class)->destroy (object);
}
static void
gimp_color_button_state_changed (GtkWidget *widget,
GtkStateType previous_state)
{
g_return_if_fail (GIMP_IS_COLOR_BUTTON (widget));
if (!GTK_WIDGET_IS_SENSITIVE (widget) && GIMP_COLOR_BUTTON (widget)->dialog)
gtk_widget_hide (GIMP_COLOR_BUTTON (widget)->dialog);
if (GTK_WIDGET_CLASS (parent_class)->state_changed)
GTK_WIDGET_CLASS (parent_class)->state_changed (widget, previous_state);
}
/**
......@@ -301,20 +315,6 @@ gimp_color_button_set_type (GimpColorButton *gcb,
gimp_color_area_set_type (GIMP_COLOR_AREA (gcb->color_area), type);
}
static void
gimp_color_button_state_changed (GtkWidget *widget,
GtkStateType previous_state)
{
g_return_if_fail (widget != NULL);
g_return_if_fail (GIMP_IS_COLOR_BUTTON (widget));
if (!GTK_WIDGET_IS_SENSITIVE (widget) && GIMP_COLOR_BUTTON (widget)->dialog)
gtk_widget_hide (GIMP_COLOR_BUTTON (widget)->dialog);
if (GTK_WIDGET_CLASS (parent_class)->state_changed)
GTK_WIDGET_CLASS (parent_class)->state_changed (widget, previous_state);
}
static gint
gimp_color_button_menu_popup (GtkWidget *widget,
GdkEvent *event,
......@@ -325,7 +325,6 @@ gimp_color_button_menu_popup (GtkWidget *widget,
gint x;
gint y;
g_return_val_if_fail (data != NULL, FALSE);
g_return_val_if_fail (GIMP_IS_COLOR_BUTTON (data), FALSE);
gcb = GIMP_COLOR_BUTTON (data);
......@@ -353,7 +352,6 @@ gimp_color_button_clicked (GtkButton *button)
GimpRGB color;
gdouble dcolor[4];
g_return_if_fail (button != NULL);
g_return_if_fail (GIMP_IS_COLOR_BUTTON (button));
gcb = GIMP_COLOR_BUTTON (button);
......@@ -402,7 +400,6 @@ gimp_color_button_dialog_ok (GtkWidget *widget,
GimpRGB color;
gdouble dcolor[4];
g_return_if_fail (data != NULL);
g_return_if_fail (GIMP_IS_COLOR_BUTTON (data));
gcb = GIMP_COLOR_BUTTON (data);
......@@ -419,7 +416,6 @@ static void
gimp_color_button_dialog_cancel (GtkWidget *widget,
gpointer data)
{
g_return_if_fail (data != NULL);
g_return_if_fail (GIMP_IS_COLOR_BUTTON (data));
gtk_widget_hide (GIMP_COLOR_BUTTON (data)->dialog);
......@@ -433,7 +429,6 @@ gimp_color_button_use_fg (gpointer callback_data,
{
GimpRGB color;
g_return_if_fail (callback_data != NULL);
g_return_if_fail (GIMP_IS_COLOR_BUTTON (callback_data));
gimp_color_button_get_color (GIMP_COLOR_BUTTON (callback_data), &color);
......@@ -448,7 +443,6 @@ gimp_color_button_use_bg (gpointer callback_data,
{
GimpRGB color;
g_return_if_fail (callback_data != NULL);
g_return_if_fail (GIMP_IS_COLOR_BUTTON (callback_data));
gimp_color_button_get_color (GIMP_COLOR_BUTTON (callback_data), &color);
......
......@@ -30,7 +30,7 @@
#define __GIMP_COLOR_BUTTON_H__
#include "libgimpwidgets/gimpcolorarea.h"
#include <libgimpwidgets/gimpbutton.h>
#ifdef __cplusplus
......@@ -43,13 +43,14 @@ extern "C" {
#define GIMP_COLOR_BUTTON_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GIMP_TYPE_COLOR_BUTTON, GimpColorButtonClass))
#define GIMP_IS_COLOR_BUTTON(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GIMP_TYPE_COLOR_BUTTON))
#define GIMP_IS_COLOR_BUTTON_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GIMP_TYPE_COLOR_BUTTON))
#define GIMP_COLOR_BUTTON_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GIMP_TYPE_COLOR_BUTTON, GimpColorButtonClass))
typedef struct _GimpColorButtonClass GimpColorButtonClass;
struct _GimpColorButton
{
GtkButton button;
GimpButton parent_instance;
gchar *title;
......@@ -60,18 +61,20 @@ struct _GimpColorButton
struct _GimpColorButtonClass
{
GtkButtonClass parent_class;
GimpButtonClass parent_class;
void (* color_changed) (GimpColorButton *gcb);
};
GtkType gimp_color_button_get_type (void);
GType gimp_color_button_get_type (void);
GtkWidget * gimp_color_button_new (const gchar *title,
gint width,
gint height,
const GimpRGB *color,
GimpColorAreaType type);
void gimp_color_button_set_color (GimpColorButton *gcb,
const GimpRGB *color);
void gimp_color_button_get_color (GimpColorButton *gcb,
......
......@@ -38,33 +38,77 @@ typedef void (* GimpDialogCancelCallback) (GtkWidget *widget,
gpointer data);
/* local callbacks of gimp_dialog_new () */
static gboolean
gimp_dialog_delete_callback (GtkWidget *widget,
GdkEvent *event,
gpointer data)
{
GimpDialogCancelCallback cancel_callback;
GtkWidget *cancel_widget;
static void gimp_dialog_class_init (GimpDialogClass *klass);
static void gimp_dialog_init (GimpDialog *dialog);
cancel_callback = (GimpDialogCancelCallback)
g_object_get_data (G_OBJECT (widget), "gimp_dialog_cancel_callback");
static void gimp_dialog_realize (GtkWidget *widget);
static void gimp_dialog_real_realize (GtkWidget *widget);
static gboolean gimp_dialog_delete_event (GtkWidget *widget,
GdkEventAny *event);
cancel_widget = (GtkWidget *)
g_object_get_data (G_OBJECT (widget), "gimp_dialog_cancel_widget");
/* the cancel callback has to destroy the dialog */
if (cancel_callback)
static GtkDialogClass *parent_class = NULL;
GType
gimp_dialog_get_type (void)
{
static GType dialog_type = 0;
if (! dialog_type)
{
cancel_callback (cancel_widget, data);
static const GTypeInfo dialog_info =
{
sizeof (GimpDialogClass),
(GBaseInitFunc) NULL,
(GBaseFinalizeFunc) NULL,
(GClassInitFunc) gimp_dialog_class_init,
NULL, /* class_finalize */
NULL, /* class_data */
sizeof (GimpDialog),
0, /* n_preallocs */
(GInstanceInitFunc) gimp_dialog_init,