<span style= "FONT-SIZE:18PX;" > #include <stdio.h> #include <gtk/gtk.h> void Enter_button (Gtkwidget *widget, gpointer data) {G_print ("
Enter button\n ");
} void Leave_button (Gtkwidget *widget, gpointer data) {G_print ("Leave button\n");} int main (int argc, char* argv[]) {
Gtkwidget *window;
Gtkwidget *fixed;
Gtkwidget *button;
Gtk_init (&ARGC, &ARGV);
window = Gtk_window_new (gtk_window_toplevel);
Gtk_window_set_position (Gtk_window (window), gtk_win_pos_center);
Gtk_window_set_default_size (Gtk_window (window), 250,200);
Gtk_window_set_title (Gtk_window (window), "gtkfixed");
Fixed = Gtk_fixed_new ();
Gtk_container_add (Gtk_container (window), fixed);
button = Gtk_button_new_with_label ("button");
Gtk_fixed_put (gtk_fixed (fixed), button, 150, 50);
Gtk_widget_set_size_request (Button, 80, 35);
g_signal_connect_swapped (Gtk_window (window), "Destroy", G_callback (Gtk_main_quit), NULL); G_signal_connect (Gtk_button (Button), "Enter", G_callback (Enter_button), NULL);
G_signal_connect (Gtk_button (Button), "Leave", G_callback (Leave_button), NULL);
Gtk_widget_show_all (window);
Gtk_main ();
return 0; } </span>
Online people ask: button on the toolbar this method can not be used
People on the Internet answered:
You can put the button in the Gtkeventbox, and then put the Eventbox into toolbar, so that Eventbox motion-notify-event can be processed.
Mouse move-in and move-out handler functions
Static Gboolean Banner_image_motion_notify_handler (gtkwidget *widget,gdkeventmotion *event,gpointer data)
{
Mouse Move in
if (Event->type = = gdk_enter_notify) {//Enter the thumbnail, you will cancel the autohide temporary thread
Banner_cancel_autohide ();
Mouse out control
} else if (Event->type = = gdk_leave_notify) {//need to re-open autohide thread
Banner_autohide_tip_window ();
}
Return false;//no need to process anymore.
}