-------------------------------------------------------------------- --# GtkInfoBar, used to show messages without a dialog. -- It is often temporarily shown at the top or bottom of a document. -- In contrast to GtkDialog, which has a action area at the bottom, -- GtkInfoBar has an action area at the side. -- WORTHLESS in WINDOWS. -------------------------------------------------------------------- include GtkEngine.e constant docs = `Info Bar will appear when you click either of the two buttons above. Programmer can change the color of the info bar to indication importance of the message. ` enum BUG, GOOSE, CLOSE sequence pix = repeat(0,2) pix[BUG] = "thumbnails/bug-buddy.png" pix[GOOSE] = "thumbnails/mongoose.png" constant fmt = `The last button pressed was the %s Button [#%d]` constant win = create(GtkWindow, "title=`GTK INFO BAR`,size=430x400,border_width=10,position=1x1,background=skyblue,$destroy=Quit") constant panel = create(GtkBox,VERTICAL) add(win,panel) constant btnbox = create(GtkButtonBox) add(panel,btnbox) constant btn1 = create(GtkButton,pix[BUG] & "# _Bug",_("PopupBar"),BUG) set(btn1,"tooltip text","This is button #1") constant btn2 = create(GtkButton,pix[GOOSE] & "# _Mongoose",_("PopupBar"),GOOSE) set(btn2,"tooltip text","This is button #2") add(btnbox,{btn1,btn2}) constant lbl = create(GtkLabel,{ {"markup",docs}, {"margin top",20}}) add(panel,lbl) constant ib = create(GtkInfoBar) constant ca = get(ib,"content area") constant img = create(GtkImage) -- add a container for the infobar image; add(ca,img) show_all(ca) constant iblabel = create(GtkLabel) -- text for infobar, with close button; add(ca,iblabel) set(ib,{ {"message type",GTK_MESSAGE_OTHER}, -- (*) {"add button","gtk-close",CLOSE}, {"signal","response",_("PopupBar")}}) pack_end(panel,ib,1,0) -- (*) For the theme I am using at the moment: -- GTK_MESSAGE_INFO = normal background color -- GTK_MESSAGE_WARNING = yellow -- GTK_MESSAGE_QUESTION = blue -- GTK_MESSAGE_ERROR = red -- GTK_MESSAGE_OTHER = borderless, use default window background color -- Possibly this may change depending upon the window theme in use. show_all(win) set(ib,"hide") main() ------------------------------------------------------------------------ function PopupBar(atom ctl, object z) ------------------------------------------------------------------------ object txt if z = CLOSE then set(ib,"hide") else txt = remove_item('_',get(ctl,"label")) set(iblabel,"markup",sprintf(fmt,{txt,z})) set(iblabel,"show") set(img,"from file",locate_file(pix[z])) set(ib,"show_all") end if return 1 end function