1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
| gboolean
callback_background_color (GtkWidget *widget, cairo_t *cr, gpointer user_data)
{
GdkRGBA *color = (GdkRGBA*) user_data;
GtkAllocation allocation;
/* Récupération de la taille du widget */
gtk_widget_get_allocation (widget, &allocation);
/* Affectation de la couleur de fond */
cairo_set_source_rgba (cr, color->red, color->green, color->blue, color->alpha);
/* Remplissage de la surface du widget */
cairo_rectangle (cr, 0, 0, allocation.width, allocation.height);
cairo_fill(cr);
return FALSE;
}
void
callback_color_cellrender (GtkComboBox *combobox, gpointer user_data)
{
gint i;
AtkObject *atk;
GdkRGBA *color = (GdkRGBA*) user_data;
GtkWidget *widget = NULL;
for (i=0; i < atk_object_get_n_accessible_children (gtk_combo_box_get_popup_accessible (combobox)); i++)
{
atk = atk_object_ref_accessible_child (gtk_combo_box_get_popup_accessible (combobox), i);
widget = gtk_accessible_get_widget ((GtkAccessible*)atk);
g_signal_connect(G_OBJECT(widget), "draw", G_CALLBACK(callback_background_color), color);
}
} |
Partager