123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330(**************************************************************************)(* Lablgtk *)(* *)(* This program is free software; you can redistribute it *)(* and/or modify it under the terms of the GNU Library General *)(* Public License as published by the Free Software Foundation *)(* version 2, with the exception described in file COPYING which *)(* comes with the library. *)(* *)(* This program is distributed in the hope that it will be useful, *)(* but WITHOUT ANY WARRANTY; without even the implied warranty of *)(* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *)(* GNU Library General Public License for more details. *)(* *)(* You should have received a copy of the GNU Library General *)(* Public License along with this program; if not, write to the *)(* Free Software Foundation, Inc., 59 Temple Place, Suite 330, *)(* Boston, MA 02111-1307 USA *)(* *)(* *)(**************************************************************************)(* $Id$ *)openGobjectopenGtk(** Stock Items: prebuilt common menu/toolbar items and corresponding icons *)external_gtkstock_init:unit->unit="ml_gtkstock_init"let()=_gtkstock_init()typegtk_stock_id=[|`ABOUT(** since GTK 2.6 *)|`ADD|`APPLY|`BOLD|`CANCEL|`CAPS_LOCK_WARNING(** since GTK 2.16 *)|`CDROM|`CLEAR|`CLOSE|`COLOR_PICKER(** since GTK 2.2 *)|`CONVERT|`CONNECT(** since GTK 2.6 *)|`COPY|`CUT|`DELETE|`DIALOG_AUTHENTICATION(** since GTK 2.4 *)|`DIALOG_INFO|`DIALOG_WARNING|`DIALOG_ERROR|`DIALOG_QUESTION|`DIRECTORY(** since GTK 2.6 *)|`DISCONNECT(** since GTK 2.6 *)|`DND|`DND_MULTIPLE|`EDIT(** since GTK 2.6 *)|`EXECUTE|`FILE(** since GTK 2.6 *)|`FIND|`FIND_AND_REPLACE|`FLOPPY|`FULLSCREEN(** since GTK 2.8 *)|`GOTO_BOTTOM|`GOTO_FIRST|`GOTO_LAST|`GOTO_TOP|`GO_BACK|`GO_DOWN|`GO_FORWARD|`GO_UP|`HARDDISK(** since GTK 2.4 *)|`HELP|`HOME|`INDEX|`INDENT(** since GTK 2.4 *)|`INFO(** since GTK 2.8 *)|`ITALIC|`JUMP_TO|`JUSTIFY_CENTER|`JUSTIFY_FILL|`JUSTIFY_LEFT|`JUSTIFY_RIGHT|`LEAVE_FULLSCREEN(** since GTK 2.8 *)|`MISSING_IMAGE|`MEDIA_FORWARD(** since GTK 2.6 *)|`MEDIA_NEXT(** since GTK 2.6 *)|`MEDIA_PAUSE(** since GTK 2.6 *)|`MEDIA_PLAY(** since GTK 2.6 *)|`MEDIA_PREVIOUS(** since GTK 2.6 *)|`MEDIA_RECORD(** since GTK 2.6 *)|`MEDIA_REWIND(** since GTK 2.6 *)|`MEDIA_STOP(** since GTK 2.6 *)|`NETWORK(** since GTK 2.4 *)|`NEW|`NO|`OK|`OPEN|`ORIENTATION_LANDSCAPE(** since GTK 2.10 *)|`ORIENTATION_PORTRAIT(** since GTK 2.10 *)|`ORIENTATION_REVERSE_LANDSCAPE(** since GTK 2.10 *)|`ORIENTATION_REVERSE_PORTRAIT(** since GTK 2.10 *)|`PAGE_SETUP(** since GTK 2.14 *)|`PASTE|`PREFERENCES|`PRINT|`PRINT_ERROR|`PRINT_PAUSED|`PRINT_PREVIEW|`PRINT_REPORT|`PRINT_WARNING|`PROPERTIES|`QUIT|`REDO|`REFRESH|`REMOVE|`REVERT_TO_SAVED|`SAVE|`SAVE_AS|`SELECT_ALL(** since GTK 2.10 *)|`SELECT_COLOR|`SELECT_FONT|`SORT_ASCENDING|`SORT_DESCENDING|`SPELL_CHECK|`STOP|`STRIKETHROUGH|`UNDELETE|`UNDERLINE|`UNDO|`UNINDENT(** since GTK 2.4 *)|`YES|`ZOOM_100|`ZOOM_FIT|`ZOOM_IN|`ZOOM_OUT]typeid=[gtk_stock_id|`STOCKofstring]letid_table=Hashtbl.create37letconvert_id:id->string=function|`STOCKs->s|id->Hashtbl.findid_tableidletconv={kind=`STRING;proj=(function`STRING(Somes)->`STOCKs|_->failwith"GtkStock.get_id");inj=(funid->`STRING(Some(convert_idid)))}(* awk '/^#define GTK_STOCK_/ { sub(/GTK_STOCK_/, "", $2) ; print "`" $2 ", " $3 ";"}' /mnt/garnome/root-cvs/include/gtk-2.0/gtk/gtkstock.h *)let()=List.iter(fun(k,d)->Hashtbl.addid_tablekd)[`DIALOG_AUTHENTICATION,"gtk-dialog-authentication";`DIALOG_INFO,"gtk-dialog-info";`DIALOG_WARNING,"gtk-dialog-warning";`DIALOG_ERROR,"gtk-dialog-error";`DIALOG_QUESTION,"gtk-dialog-question";`DND,"gtk-dnd";`DND_MULTIPLE,"gtk-dnd-multiple";`ABOUT,"gtk-about";`ADD,"gtk-add";`APPLY,"gtk-apply";`BOLD,"gtk-bold";`CANCEL,"gtk-cancel";`CAPS_LOCK_WARNING,"gtk-caps-lock-warning";`CDROM,"gtk-cdrom";`CLEAR,"gtk-clear";`CLOSE,"gtk-close";`COLOR_PICKER,"gtk-color-picker";`CONVERT,"gtk-convert";`CONNECT,"gtk-connect";`COPY,"gtk-copy";`CUT,"gtk-cut";`DELETE,"gtk-delete";`DIRECTORY,"gtk-directory";`DISCONNECT,"gtk-disconnect";`EDIT,"gtk-edit";`EXECUTE,"gtk-execute";`FILE,"gtk-file";`FIND,"gtk-find";`FIND_AND_REPLACE,"gtk-find-and-replace";`FLOPPY,"gtk-floppy";`FULLSCREEN,"gtk-fullscreen";`GOTO_BOTTOM,"gtk-goto-bottom";`GOTO_FIRST,"gtk-goto-first";`GOTO_LAST,"gtk-goto-last";`GOTO_TOP,"gtk-goto-top";`GO_BACK,"gtk-go-back";`GO_DOWN,"gtk-go-down";`GO_FORWARD,"gtk-go-forward";`GO_UP,"gtk-go-up";`HARDDISK,"gtk-harddisk";`HELP,"gtk-help";`HOME,"gtk-home";`INDEX,"gtk-index";`INDENT,"gtk-indent";`INFO,"gtk-info";`ITALIC,"gtk-italic";`JUMP_TO,"gtk-jump-to";`JUSTIFY_CENTER,"gtk-justify-center";`JUSTIFY_FILL,"gtk-justify-fill";`JUSTIFY_LEFT,"gtk-justify-left";`JUSTIFY_RIGHT,"gtk-justify-right";`LEAVE_FULLSCREEN,"gtk-leave-fullscreen";(*@ *)`MISSING_IMAGE,"gtk-missing-image";`MEDIA_FORWARD,"gtk-media-forward";`MEDIA_NEXT,"gtk-media-next";`MEDIA_PAUSE,"gtk-media-pause";`MEDIA_PLAY,"gtk-media-play";`MEDIA_PREVIOUS,"gtk-media-previous";`MEDIA_RECORD,"gtk-media-record";`MEDIA_REWIND,"gtk-media-rewind";`MEDIA_STOP,"gtk-media-stop";`NETWORK,"gtk-network";`NEW,"gtk-new";`NO,"gtk-no";`OK,"gtk-ok";`OPEN,"gtk-open";`ORIENTATION_PORTRAIT,"gtk-orientation-portrait";`ORIENTATION_LANDSCAPE,"gtk-orientation-landscape";`ORIENTATION_REVERSE_LANDSCAPE,"gtk-orientation-reverse-landscape";`ORIENTATION_REVERSE_PORTRAIT,"gtk-orientation-reverse-portrait";`PAGE_SETUP,"gtk-page-setup";`PASTE,"gtk-paste";`PREFERENCES,"gtk-preferences";`PRINT,"gtk-print";`PRINT_ERROR,"gtk-print-error";`PRINT_PAUSED,"gtk-print-paused";`PRINT_PREVIEW,"gtk-print-preview";`PRINT_REPORT,"gtk-print-report";`PRINT_WARNING,"gtk-print-warning";`PROPERTIES,"gtk-properties";`QUIT,"gtk-quit";`REDO,"gtk-redo";`REFRESH,"gtk-refresh";`REMOVE,"gtk-remove";`REVERT_TO_SAVED,"gtk-revert-to-saved";`SAVE,"gtk-save";`SAVE_AS,"gtk-save-as";`SELECT_ALL,"gtk-select-all";(*@ *)`SELECT_COLOR,"gtk-select-color";`SELECT_FONT,"gtk-select-font";`SORT_ASCENDING,"gtk-sort-ascending";`SORT_DESCENDING,"gtk-sort-descending";`SPELL_CHECK,"gtk-spell-check";`STOP,"gtk-stop";`STRIKETHROUGH,"gtk-strikethrough";`UNDELETE,"gtk-undelete";`UNDERLINE,"gtk-underline";`UNDO,"gtk-undo";`UNINDENT,"gtk-unindent";`YES,"gtk-yes";`ZOOM_100,"gtk-zoom-100";`ZOOM_FIT,"gtk-zoom-fit";`ZOOM_IN,"gtk-zoom-in";`ZOOM_OUT,"gtk-zoom-out";]moduleIcon_source=structexternalnew_icon_source:unit->icon_source="ml_gtk_icon_source_new"externalset_filename:icon_source->string->unit="ml_gtk_icon_source_set_filename"externalset_pixbuf:icon_source->GdkPixbuf.pixbuf->unit="ml_gtk_icon_source_set_pixbuf"externalset_direction_wildcarded:icon_source->bool->unit="ml_gtk_icon_source_set_direction_wildcarded"externalset_state_wildcarded:icon_source->bool->unit="ml_gtk_icon_source_set_state_wildcarded"externalset_size_wildcarded:icon_source->bool->unit="ml_gtk_icon_source_set_size_wildcarded"externalset_direction:icon_source->Gtk.Tags.text_direction->unit="ml_gtk_icon_source_set_direction"externalset_state:icon_source->Gtk.Tags.state_type->unit="ml_gtk_icon_source_set_state"externalset_size:icon_source->Gtk.Tags.icon_size->unit="ml_gtk_icon_source_set_size"endmoduleIcon_set=structexternalnew_icon_set:unit->icon_set="ml_gtk_icon_set_new"externalnew_from_pixbuf:GdkPixbuf.pixbuf->icon_set="ml_gtk_icon_set_new_from_pixbuf"externaladd_source:icon_set->icon_source->unit="ml_gtk_icon_set_add_source"externalget_sizes:icon_set->Gtk.Tags.icon_sizelist="ml_gtk_icon_set_get_sizes"endmoduleIcon_factory=structexternalnew_factory:unit->icon_factory="ml_gtk_icon_factory_new"externaladd:icon_factory->string->icon_set->unit="ml_gtk_icon_factory_add"externallookup:icon_factory->string->icon_set="ml_gtk_icon_factory_lookup"externaladd_default:icon_factory->unit="ml_gtk_icon_factory_add_default"externalremove_default:icon_factory->unit="ml_gtk_icon_factory_remove_default"externallookup_default:string->icon_set="ml_gtk_icon_factory_lookup_default"endletmake_icon_source?filename?pixbuf?direction?state?size()=lets=Icon_source.new_icon_source()inGaux.may(Icon_source.set_filenames)filename;Gaux.may(Icon_source.set_pixbufs)pixbuf;Gaux.may(funp->Icon_source.set_direction_wildcardedsfalse;Icon_source.set_directionsp)direction;Gaux.may(funp->Icon_source.set_state_wildcardedsfalse;Icon_source.set_statesp)state;Gaux.may(funp->Icon_source.set_size_wildcardedsfalse;Icon_source.set_sizesp)size;sletmake_icon_set?pixbufsources=lets=matchpixbufwith|None->Icon_set.new_icon_set()|Somepb->Icon_set.new_from_pixbufpbinList.iter(Icon_set.add_sources)sources;sletmake_icon_factory?(default=true)?icons()=letf=Icon_factory.new_factory()inGaux.mayicons~f:(List.iter(fun(n,i)->Icon_factory.addf(convert_idn)i));ifdefaultthenIcon_factory.add_defaultf;ftypeitem={stock_id:string;label:string;modifier:Gdk.Tags.modifierlist;keyval:Gdk.keysym;}moduleItem=structexternaladd:item->unit="ml_gtk_stock_add"externallist_ids:unit->stringlist="ml_gtk_stock_list_ids"externallookup:string->item="ml_gtk_stock_lookup"letlookupid=lookup(convert_idid)end