; Module/File: Pixbuf_Flip.pb ; Function: Flip Pixbuf hor. or vert. - Linux ; Author: Omi ; Date: Jun. 18, 2016 ; Version: 0.1 ; Target Compiler: PureBasic 5.22/5.31/5.4 ; Target OS: Linux: (X/K/L)ubuntu, Mint, 32/64, Ascii/Uni ;-------------------------------------------------------------- ;System icon are loaded by name as pixbufs (same as ImageID(#Image) and can be used everywhere, ImageID(#Image) is used. ;If Icon doesn't exist, '0' is returned and no Image is used -> NO CRASH !!! :-) EnableExplicit ;UsePNGImageDecoder(); :-) ImportC "" gtk_icon_theme_load_icon(*icon_theme.GtkIconTheme, icon_name.p-utf8, size, flags, *error.GError); gtk2.4+ gdk_pixbuf_flip(*srcpixbuf, horizontal) EndImport Enumeration GtkIconLookupFlags #GTK_ICON_LOOKUP_ALL = 0; Not gtk-defined, own constant to clearify #GTK_ICON_LOOKUP_NO_SVG = 1 #GTK_ICON_LOOKUP_FORCE_SVG = 2 #GTK_ICON_LOOKUP_USE_BUILTIN = 4 #GTK_ICON_LOOKUP_GENERIC_FALLBACK = 8 #GTK_ICON_LOOKUP_FORCE_SIZE = 16 EndEnumeration ; Object constants #Win_Main = 0 Global.i gEvent, gEventWin, gQuit Global *gPixbuf Procedure IconTheme_LoadIconFromName(icon_name.s, icon_size, flags) Protected *error.GError Protected *pixbuf= gtk_icon_theme_load_icon(gtk_icon_theme_get_default_(), icon_name, icon_size, flags, @*error) If *error : Debug icon_name + ": " + PeekS(*error\message, -1, #PB_UTF8) : EndIf ProcedureReturn *pixbuf EndProcedure Procedure GdkPixbuf_Flip(*srcpixbuf, horizontal, unref) Protected *pixbuf= gdk_pixbuf_flip(*srcpixbuf, horizontal) If unref g_object_unref_(*srcpixbuf) EndIf ProcedureReturn *pixbuf EndProcedure Procedure Create_WinMain() If OpenWindow(#Win_Main, 300, 200, 550, 240, "System-flip pixbufs...", #PB_Window_SystemMenu | #PB_Window_ScreenCentered) SetWindowColor (#Win_Main, $CFFFFF) *gPixbuf= IconTheme_LoadIconFromName("find", 32, #GTK_ICON_LOOKUP_ALL) TextGadget (#PB_Any, 5, 5, 250, 22, "Flip Pixbuf from System icon 'find' ...") TextGadget (#PB_Any, 5, 35, 190, 22, "ImageGadget:" + #LF$ + " Orig. pixbuf!") ImageGadget (0, 200, 30, 32, 32, *gPixbuf, #PB_Image_Border) TextGadget (#PB_Any, 5, 75, 190, 22, "ImageGadget Flip hor.:") ImageGadget (1, 200, 70, 32, 32, GdkPixbuf_Flip(*gPixbuf, #True, #False)) TextGadget (#PB_Any, 5, 115, 190, 22, "ImageGadget Flip vert.:") ImageGadget (2, 200, 110, 32, 32, GdkPixbuf_Flip(*gPixbuf, #False, #True)); now free *gPixbuf with #True EndIf EndProcedure Create_WinMain() Repeat gEvent= WaitWindowEvent() Select gEvent Case #PB_Event_CloseWindow gQuit= #True EndSelect Until gQuit ; IDE Options = PureBasic 5.44 LTS (Linux - x86) ; CursorPosition = 53 ; Folding = - ; EnableUnicode ; EnableXP