; Module/File: ComboBox_SystemImages.pb ; Function: ComboBox set system icons as images - Linux ; Author: Omi ; Date: Oct. 20, 2016 ; Version: 0.1 ; Target Compiler: PureBasic 5.22/5.31/5.4/5.5/5.6 ; Target OS: Linux: (X/K/L)ubuntu, Mint, 32/64, Ascii/Uni ;-------------------------------------------------------------- ;found no way to use StockImage/NamedIcon to use as Image (-> no Pixbuf available) EnableExplicit ImportC "" gtk_icon_theme_load_icon(*icon_theme.GtkIconTheme, icon_name.p-utf8, size, flags, *error.GError) EndImport #Win_Main= 0 #CbG1 = 0 Global.i gEvent, gQuit Global.s gIconName ;some standard system icon names in Linux (similar to stock-images or named-icons) ... ; gIconName= "address-book-new" ; gIconName= "application-exit" ; gIconName= "appointment-new" ; gIconName= "call-start" ; gIconName= "call-stop" ; gIconName= "contact-new" ; gIconName= "document-new" ; gIconName= "document-open" ; gIconName= "document-open-recent" ; gIconName= "document-page-setup" ; gIconName= "document-print" ; gIconName= "document-print-preview" ; gIconName= "document-properties" ; gIconName= "document-revert" ; gIconName= "document-save" ; gIconName= "document-save-as" ; gIconName= "document-send" ; gIconName= "edit-clear" ; gIconName= "edit-copy" ; gIconName= "edit-cut" ; gIconName= "edit-delete" ; gIconName= "edit-find" ; gIconName= "edit-find-replace" ; gIconName= "edit-paste" ; gIconName= "edit-redo" ; gIconName= "edit-select-all" ; gIconName= "edit-undo" ; gIconName= "folder-new" ; gIconName= "format-indent-less" ; gIconName= "format-indent-more" ; gIconName= "format-justify-center" ; gIconName= "format-justify-fill" ; gIconName= "format-justify-left" ; gIconName= "format-justify-right" ; gIconName= "format-text-direction-ltr" ; gIconName= "format-text-direction-rtl" ; gIconName= "format-text-bold" ; gIconName= "format-text-italic" ; gIconName= "format-text-underline" ; gIconName= "format-text-strikethrough" ; gIconName= "go-bottom" ; gIconName= "go-down" ; gIconName= "go-first" ; gIconName= "go-home" ; gIconName= "go-jump" ; gIconName= "go-last" ; gIconName= "go-next" ; gIconName= "go-previous" ; gIconName= "go-top" ; gIconName= "go-up" ; gIconName= "help-about" ; gIconName= "help-contents" ; gIconName= "help-faq" ; gIconName= "insert-image" ; gIconName= "insert-link" ; gIconName= "insert-object" ; gIconName= "insert-text" ; gIconName= "list-add" ; gIconName= "list-remove" ; gIconName= "mail-forward" ; gIconName= "mail-mark-important" ; gIconName= "mail-mark-junk" ; gIconName= "mail-mark-notjunk" ; gIconName= "mail-mark-read" ; gIconName= "mail-mark-unread" ; gIconName= "mail-message-new" ; gIconName= "mail-reply-all" ; gIconName= "mail-reply-sender" ; gIconName= "mail-send" ; gIconName= "mail-send-receive" ; gIconName= "media-eject" ; gIconName= "media-playback-pause" ; gIconName= "media-playback-start" ; gIconName= "media-playback-stop" ; gIconName= "media-record" ; gIconName= "media-seek-backward" ; gIconName= "media-seek-forward" ; gIconName= "media-skip-backward" ; gIconName= "media-skip-forward" ; gIconName= "object-flip-horizontal" ; gIconName= "object-flip-vertical" ; gIconName= "object-rotate-left" ; gIconName= "object-rotate-right" ; gIconName= "process-stop" ; gIconName= "system-lock-screen" ; gIconName= "system-log-out" ; gIconName= "system-run" ; gIconName= "system-search" ; gIconName= "system-reboot" ; gIconName= "system-shutdown" ; gIconName= "tools-check-spelling" ; gIconName= "view-fullscreen" ; gIconName= "view-refresh" ; gIconName= "view-restore" ; gIconName= "view-sort-ascending" ; gIconName= "view-sort-descending" ; gIconName= "window-close" ; gIconName= "window-new" ; gIconName= "zoom-fit-best" ; gIconName= "zoom-in" ; gIconName= "zoom-original" ; gIconName= "zoom-out" ; search file from name in default icon theme and return pixbuf or Null ... Procedure IconDefaultTheme_LoadIconFromName(icon_name.s, icon_size, flags= #Null) Protected *pixbuf Protected *error.GError *pixbuf= gtk_icon_theme_load_icon(gtk_icon_theme_get_default_(), icon_name, icon_size, flags, @*error) If *error : Debug PeekS(*error\message, -1, #PB_UTF8) : EndIf ProcedureReturn *pixbuf EndProcedure If OpenWindow(#Win_Main, #PB_Ignore, #PB_Ignore, 400, 250, "ComboBox w. system icons", #PB_Window_ScreenCentered) ComboBoxGadget(#CbG1, 5, 5, 200, 30, #PB_ComboBox_Editable | #PB_ComboBox_Image) ;if isn't found (e.g. non existing name), *pixbuf= 0 -> image isn't loaded -> no bang AddGadgetItem(#CbG1, -1, "Align left", IconDefaultTheme_LoadIconFromName("format-justify-left", 16, 0)) AddGadgetItem(#CbG1, -1, "Align mid", IconDefaultTheme_LoadIconFromName("format-justify-center", 16, 0)) AddGadgetItem(#CbG1, -1, "Align right", IconDefaultTheme_LoadIconFromName("format-justify-right", 16, 0)) AddGadgetItem(#CbG1, -1, "Align fill", IconDefaultTheme_LoadIconFromName("format-justify-fill", 16, 0)) AddGadgetItem(#CbG1, -1, "Indent less", IconDefaultTheme_LoadIconFromName("format-indent-less", 16, 0)) AddGadgetItem(#CbG1, -1, "Indent more", IconDefaultTheme_LoadIconFromName("format-indent-more", 16, 0)) AddGadgetItem(#CbG1, -1, "Text bold", IconDefaultTheme_LoadIconFromName("format-text-bold", 16, 0)) AddGadgetItem(#CbG1, -1, "Text italic", IconDefaultTheme_LoadIconFromName("format-text-italic", 16, 0)) AddGadgetItem(#CbG1, -1, "Text underline", IconDefaultTheme_LoadIconFromName("format-text-underline", 16, 0)) AddGadgetItem(#CbG1, -1, "Text strikethrough", IconDefaultTheme_LoadIconFromName("format-text-strikethrough", 16, 0)) SetGadgetState(#CbG1, 0) EndIf Repeat gEvent = WaitWindowEvent() If EventWindow()= #Win_Main Select gEvent Case #PB_Event_CloseWindow gQuit= #True Case #PB_Event_Gadget Select EventGadget() EndSelect EndSelect EndIf Until gQuit ; IDE Options = PureBasic 5.44 LTS (Linux - x86) ; CursorPosition = 155 ; FirstLine = 137 ; Folding = - ; EnableUnicode ; EnableXP