Hi,
#1
What about using a GtkMenuButton instead? You could do combining features as using GtkCheckMenuItem or a single action using GtkMenuItem. Further 2 button mouse is not supported by every device.
https://developer.gnome.org/gtk3/stable/GtkMenuButton.html
But I think this would do it for you:
https://developer.gnome.org/gtk3/stable/GtkEventBox.html
Then connect to GtkWidget::button-release-event().
https://developer.gnome.org/gtk3/stable/GtkWidget.html#GtkWidget-button-release-event
struct MyData
{
/* ... */
};
gboolean
my_button_release_callback(GtkWidget *widget, GdkEvent *event, gpointer user_data)
{
if(event->button == 1){
/* mouse button 1 released */
}else if(event->button == 2){
/* mouse button 2 released */
}
return(FALSE);
}
GtkEventBox *event_box;
struct MyData my_data;
event_box = gtk_event_box_new();
g_signal_connect(event_box, "button-release",
G_CALLBACK(my_button_release_callback), &my_data);
2
I think it is due to the design of GtkButton, it has only these signals:
- GtkButton::activate()
- GtkButton::clicked()
- GtkButton::enter()
- GtkButton::leave()
- GtkButton::pressed()
- GtkButton::released()
related #1
Why not connect to GtkWidget::draw()
and do draw your BG using cairo?
https://developer.gnome.org/gtk3/stable/GtkWidget.html#GtkWidget-draw
GtkAllocation allocation;
gdouble red, green, blue;
gdouble alpha;
red = 1.0;
green = 0.0;
blue = 0.0;
alpha = 0.25;
gtk_widget_get_allocation((GtkWidget *) event_box, &allocation);
/* clear with background color */
cairo_set_source_rgba(cr,
red,
green,
blue,
alpha);
cairo_rectangle(cr,
0.0, 0.0,
(double) allocation.width, (double) allocation.height);
cairo_fill(cr);
regards, Joël