51 if(gtk_widget_get_allocated_height(widget) < 2 || gtk_widget_get_allocated_width(widget) < 2)
return TRUE;
53 GtkStateFlags
state = gtk_widget_get_state_flags(widget);
55 GdkRGBA *fg_color, *bg_color;
56 GtkStyleContext *context = gtk_widget_get_style_context(widget);
57 gtk_style_context_get(context,
state, GTK_STYLE_PROPERTY_COLOR, &fg_color, GTK_STYLE_PROPERTY_BACKGROUND_COLOR,
61 gtk_style_context_get_margin(context,
state, &margin);
62 gtk_widget_set_margin_bottom(widget, margin.bottom);
63 gtk_widget_set_margin_top(widget, margin.top);
64 gtk_widget_set_margin_start(widget, margin.left);
65 gtk_widget_set_margin_end(widget, margin.right);
67 if(fg_color->alpha == 0 && bg_color->alpha == 0)
70 gdk_rgba_free(fg_color);
71 gdk_rgba_free(bg_color);
77 gdk_cairo_set_source_rgba(cr, fg_color);
82 GtkAllocation allocation;
83 gtk_widget_get_allocation(widget, &allocation);
86 if(
state & GTK_STATE_FLAG_PRELIGHT)
89 flags &= ~CPF_PRELIGHT;
91 if(
state & GTK_STATE_FLAG_ACTIVE)
97 gtk_style_context_get_padding(context,
state, &padding);
99 const float icon_x = padding.left;
100 const float icon_y = padding.top;
101 const float icon_w = allocation.width - (padding.left + padding.right);
102 const float icon_h = allocation.height - (padding.top + padding.bottom);
104 cr, icon_x, icon_y, icon_w, icon_h,
flags,
109 gtk_render_frame(context, cr, 0, 0, gtk_widget_get_allocated_width(widget),
110 gtk_widget_get_allocated_height(widget));
112 gdk_rgba_free(fg_color);
113 gdk_rgba_free(bg_color);
121 if(event->type == GDK_ENTER_NOTIFY)
122 gtk_widget_set_state_flags(widget, GTK_STATE_FLAG_PRELIGHT,
FALSE);
124 gtk_widget_unset_state_flags(widget, GTK_STATE_FLAG_PRELIGHT);
126 gtk_widget_queue_draw(widget);
148 static GType dtgtk_thumbnail_btn_type = 0;
149 if(!dtgtk_thumbnail_btn_type)
151 static const GTypeInfo dtgtk_thumbnail_btn_info = {
154 (GBaseFinalizeFunc)NULL,
162 dtgtk_thumbnail_btn_type
163 = g_type_register_static(GTK_TYPE_DRAWING_AREA,
"GtkDarktableThumbnailBtn", &dtgtk_thumbnail_btn_info, 0);
165 return dtgtk_thumbnail_btn_type;
void(* DTGTKCairoPaintIconFunc)(cairo_t *cr, gint x, gint y, gint w, gint h, gint flags, void *data)