|
楼主 |
发表于 2008-12-24 22:18:02
|
显示全部楼层
源代码就是下面这样的~~
tooltips 开关不起作用~
#include <gtk/gtk.h>
GtkWidget * close_button;
GtkWidget *tooltips_button;
/*设置tooltips on/off的回掉函数*/
void toggle_event (GtkWidget *widget,
gpointer data)
{
gtk_toolbar_set_tooltips (GTK_TOOLBAR (data),
GTK_TOGGLE_BUTTON (widget)->active);
}
int main(int argc, char * argv[])
{
GtkWidget *dialog;
GtkWidget *handlebox;
GtkWidget *toolbar;
GtkWidget *icon;
gtk_init (&argc ,&argv);
dialog = gtk_dialog_new ();
gtk_window_set_title (GTK_WINDOW(dialog),"GTKTOOLBAR");
gtk_widget_set_size_request (dialog ,300,100);
GTK_WINDOW(dialog)->allow_shrink = TRUE;
g_signal_connect (G_OBJECT(dialog),"delete_event",
G_CALLBACK(gtk_main_quit),
NULL);
gtk_widget_realize(dialog);
handlebox = gtk_handle_box_new ();
gtk_box_pack_start (GTK_BOX(GTK_DIALOG(dialog)->vbox),handlebox,FALSE,FALSE,5);
toolbar = gtk_toolbar_new();
gtk_toolbar_set_orientation (GTK_TOOLBAR(toolbar),GTK_ORIENTATION_HORIZONTAL);
gtk_toolbar_set_style(GTK_TOOLBAR (toolbar),GTK_TOOLBAR_BOTH);
gtk_container_set_border_width (GTK_CONTAINER (toolbar),5);
gtk_container_add (GTK_CONTAINER(handlebox),toolbar);
icon = gtk_image_new_from_file ("gtk.xpm");
close_button = gtk_toolbar_append_item (GTK_TOOLBAR(toolbar),
"Close",
"Close this dialog",
"rivate",
icon,
G_CALLBACK(gtk_main_quit),
NULL);
gtk_toolbar_append_space (GTK_TOOLBAR(toolbar));
icon = gtk_image_new_from_file ("gtk.xpm");
tooltips_button = gtk_toolbar_append_element (GTK_TOOLBAR(toolbar),
GTK_TOOLBAR_CHILD_TOGGLEBUTTON,
NULL,
"Tooltips On/Off",
"Toolbar with or without tips",
"rivate",
icon,
G_CALLBACK(toggle_event),
toolbar);
gtk_toolbar_append_space(GTK_TOOLBAR(toolbar));
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON(tooltips_button),TRUE);
gtk_widget_show_all (dialog);
gtk_main();
return 0;
} |
|