forked from AuroraMiddleware/gtk
color-swatch: derive directly from GtkWidget
Instead of GtkDrawingArea, since that calls in realize gtk_style_context_set_background(). We don't want that to happen, given that we do all the painting ourselves in _draw().
This commit is contained in:
parent
b58d50a0da
commit
8e85702dca
@ -62,7 +62,7 @@ enum
|
|||||||
|
|
||||||
static guint signals[LAST_SIGNAL];
|
static guint signals[LAST_SIGNAL];
|
||||||
|
|
||||||
G_DEFINE_TYPE (GtkColorSwatch, gtk_color_swatch, GTK_TYPE_DRAWING_AREA)
|
G_DEFINE_TYPE (GtkColorSwatch, gtk_color_swatch, GTK_TYPE_WIDGET)
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gtk_color_swatch_init (GtkColorSwatch *swatch)
|
gtk_color_swatch_init (GtkColorSwatch *swatch)
|
||||||
@ -495,6 +495,34 @@ swatch_button_release (GtkWidget *widget,
|
|||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
swatch_realize (GtkWidget *widget)
|
||||||
|
{
|
||||||
|
GtkAllocation allocation;
|
||||||
|
GdkWindow *window;
|
||||||
|
GdkWindowAttr attributes;
|
||||||
|
gint attributes_mask;
|
||||||
|
|
||||||
|
gtk_widget_set_realized (widget, TRUE);
|
||||||
|
gtk_widget_get_allocation (widget, &allocation);
|
||||||
|
|
||||||
|
attributes.window_type = GDK_WINDOW_CHILD;
|
||||||
|
attributes.x = allocation.x;
|
||||||
|
attributes.y = allocation.y;
|
||||||
|
attributes.width = allocation.width;
|
||||||
|
attributes.height = allocation.height;
|
||||||
|
attributes.wclass = GDK_INPUT_OUTPUT;
|
||||||
|
attributes.visual = gtk_widget_get_visual (widget);
|
||||||
|
attributes.event_mask = gtk_widget_get_events (widget) | GDK_EXPOSURE_MASK;
|
||||||
|
|
||||||
|
attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL;
|
||||||
|
|
||||||
|
window = gdk_window_new (gtk_widget_get_parent_window (widget),
|
||||||
|
&attributes, attributes_mask);
|
||||||
|
gdk_window_set_user_data (window, widget);
|
||||||
|
gtk_widget_set_window (widget, window);
|
||||||
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
swatch_popup_menu (GtkWidget *swatch)
|
swatch_popup_menu (GtkWidget *swatch)
|
||||||
{
|
{
|
||||||
@ -582,6 +610,7 @@ gtk_color_swatch_class_init (GtkColorSwatchClass *class)
|
|||||||
widget_class->button_release_event = swatch_button_release;
|
widget_class->button_release_event = swatch_button_release;
|
||||||
widget_class->enter_notify_event = swatch_enter_notify;
|
widget_class->enter_notify_event = swatch_enter_notify;
|
||||||
widget_class->leave_notify_event = swatch_leave_notify;
|
widget_class->leave_notify_event = swatch_leave_notify;
|
||||||
|
widget_class->realize = swatch_realize;
|
||||||
|
|
||||||
signals[ACTIVATE] =
|
signals[ACTIVATE] =
|
||||||
g_signal_new ("activate",
|
g_signal_new ("activate",
|
||||||
|
@ -42,7 +42,7 @@ typedef struct _GtkColorSwatchPrivate GtkColorSwatchPrivate;
|
|||||||
|
|
||||||
struct _GtkColorSwatch
|
struct _GtkColorSwatch
|
||||||
{
|
{
|
||||||
GtkDrawingArea parent;
|
GtkWidget parent;
|
||||||
|
|
||||||
/*< private >*/
|
/*< private >*/
|
||||||
GtkColorSwatchPrivate *priv;
|
GtkColorSwatchPrivate *priv;
|
||||||
@ -50,7 +50,7 @@ struct _GtkColorSwatch
|
|||||||
|
|
||||||
struct _GtkColorSwatchClass
|
struct _GtkColorSwatchClass
|
||||||
{
|
{
|
||||||
GtkDrawingAreaClass parent_class;
|
GtkWidgetClass parent_class;
|
||||||
|
|
||||||
void ( * activate) (GtkColorSwatch *swatch);
|
void ( * activate) (GtkColorSwatch *swatch);
|
||||||
void ( * customize) (GtkColorSwatch *swatch);
|
void ( * customize) (GtkColorSwatch *swatch);
|
||||||
|
Loading…
Reference in New Issue
Block a user