Icon/native image options in Linux

Linux specific forum
Oma
Enthusiast
Enthusiast
Posts: 312
Joined: Thu Jun 26, 2014 9:17 am
Location: Germany

Re: Icon/native image options in Linux

Post by Oma »

Code: Select all

Oma, I take it you're Omi 
Yes, a small (not correctable) mishap when registering :oops:

There are also routines for pics in window or application in the library, but till now they need UsePNGImageDecoder() when embedded in exe. Only the loaded versions get along without the Decoder.
But at the moment the API-Library is updated (for gtk3 too) and extended. http://www.chabba.de/

Bye
PureBasic 5.4-5.7, Linux: (X/L/K)Ubuntus+Mint - Windows XP (32Bit)
PureBasic Linux-API-Library & Viewer: http://www.chabba.de
User avatar
Keya
Addict
Addict
Posts: 1891
Joined: Thu Jun 04, 2015 7:10 am

Re: Icon/native image options in Linux

Post by Keya »

I tried loading the PNG into a buf and pointing gtk_image_new_from_pixbuf at that but havent had any luck yet

Ive seen one sample using this:

Code: Select all

GPimage =gdk_pixbuf_new_from_file(nom,Gerr);
  GWimage = gtk_image_new_from_pixbuf (GPimage);
So it seems that the 'pixbuf' data is probably of an uncompressed bitmap-style type, rather than PNG data

If that's the case i'll probably have to use that to convert all PNGs to pixbuf and dump the pixbuf to disk so i can later compress and embed them. Before compression theyll probably be about the same size as .BMP im guessing - but with alpha channel ready to go ... so then i'll just compress using BriefLZ or similar, adding only ~10kb to the elf executable.

I'm still keen on a from-memory way of loading PNG via GTK API though, so i'll keep digging! :)

Im currently looking at ...
https://developer.gnome.org/gdk-pixbuf/ ... emory.html
But at the moment the API-Library is updated (for gtk3 too) and extended. http://www.chabba.de/
I only discovered chabba.de today and it looks quite comprehensive!!! A lot to go through, nice :) :)
User avatar
Keya
Addict
Addict
Posts: 1891
Joined: Thu Jun 04, 2015 7:10 am

Re: Icon/native image options in Linux

Post by Keya »

http://stackoverflow.com/questions/1412 ... rom-memory
Very simple demo there that loads the buffer of a JPG from memory
Essentially its just this:

Code: Select all

  f = fopen ("test.jpg", "r");
  length = fread (buffer, 1, sizeof(buffer), f);
  fclose (f);

  loader = gdk_pixbuf_loader_new ();
  gdk_pixbuf_loader_write (loader, buffer, length, NULL);
  pixbuf = gdk_pixbuf_loader_get_pixbuf (loader);
  image = gtk_image_new_from_pixbuf (pixbuf);
I havent had any luck getting my PB port to work though :(
Oma
Enthusiast
Enthusiast
Posts: 312
Joined: Thu Jun 26, 2014 9:17 am
Location: Germany

Re: Icon/native image options in Linux

Post by Oma »

Hi Keya,

the code in your link could make it.
I tried it on some of my examples, but pixbuf stays empty (0), even if i wait a certain time.

After a call of gdk_pixbuf_loader_close(gLoader, @*err) the *err stays empty too.
And i have no idea why!

Regards
PureBasic 5.4-5.7, Linux: (X/L/K)Ubuntus+Mint - Windows XP (32Bit)
PureBasic Linux-API-Library & Viewer: http://www.chabba.de
User avatar
Keya
Addict
Addict
Posts: 1891
Joined: Thu Jun 04, 2015 7:10 am

Re: Icon/native image options in Linux

Post by Keya »

Yes thats what im experiencing too... for:
pixbuf = gdk_pixbuf_loader_get_pixbuf (loader)
pixbuf is always returning 0, but the code looks fine and virtually the same as that C demo!
User avatar
Keya
Addict
Addict
Posts: 1891
Joined: Thu Jun 04, 2015 7:10 am

Re: Icon/native image options in Linux

Post by Keya »

SUCCESS!!! My 2 week quest has resulted in a happy Sunday heehee :) :) :)

Strangely for some reason that "working" C code demo is missing a call to gdk_pixbuf_loader_close(*loader, *error). For that reason it wasnt working at all on my Linux Mint x86.

Calling that close function AFTER gdk_pixbuf_loader_write and BEFORE gdk_pixbuf_loader_get_pixbuf is successful, so gdk_pixbuf_loader_get_pixbuf is returning valid address instead of 0 now :)

Ill post a working demo shortly
User avatar
Keya
Addict
Addict
Posts: 1891
Joined: Thu Jun 04, 2015 7:10 am

Re: Icon/native image options in Linux

Post by Keya »

Linux - Load PNG/JPG/etc from memory using GTK2/3 (without using PB's UseXxxDecoder() helpers, allowing for minimal executable size), and add to Button as image

Code: Select all

;This is a from-memory version based on this original from-file version by Omi: http://www.chabba.de/Linux/ButtonGadget/Button_AddImage.pb
EnableExplicit
 
ImportC ""
  gtk_button_set_image(*button.GtkButton, *image.GtkWidget)
  gtk_button_set_image_position(*button.GtkButton, position)
  gtk_button_set_label(*button.GtkButton, label.p-utf8)
  gtk_image_clear(*image.GtkWidget) 
  gtk_image_new_from_pixbuf(*pimg)

  g_object_set(*object.GObject, property_name.p-utf8, *data, v= 0)
  
  gdk_pixbuf_loader_new.i()
  gdk_pixbuf_loader_write.l(*loader, *buffer, *count, *error)
  gdk_pixbuf_loader_get_pixbuf.i(*loader)
  gdk_pixbuf_loader_close(*loader, *error)
EndImport

#MainWin= 0

Enumeration
  #myButton1
EndEnumeration

Global *image1

Procedure ButtonImages_Activate(Show)
  g_object_set(gtk_settings_get_default_(), "gtk-button-images", Show, #Null)
EndProcedure


Procedure ButtonGadget_AddImage(Gadget, *Pic, Label.s, Alignment)
  gtk_button_set_image(GadgetID(Gadget), *Pic)
  gtk_button_set_label(GadgetID(Gadget), Label)
  gtk_button_set_image_position(GadgetID(Gadget), Alignment)
EndProcedure


If OpenWindow(#MainWin, #PB_Ignore, #PB_Ignore, 250, 150, "Linux Button with image from memory", #PB_Window_ScreenCentered) 
  Define hFile.i, *ximage, *pimg, fLen.q, *pixbuf, *error, *loader
  ButtonGadget(#myButton1, 20, 20, 200, 80, "")	 
  hFile.i = ReadFile(#PB_Any, "/home/administrator/Desktop/testpng24bit.png")    ;pretend this is an IncludeBinary()!
  If hFile = 0
    MessageRequester("Error","Couldnt readfile image file")
  Else
      fLen = Lof(hFile)
      *pimg = AllocateMemory(fLen)
      ReadData(hFile, *pimg, fLen)
    CloseFile(hFile)

 ;---
    *loader = gdk_pixbuf_loader_new()
    gdk_pixbuf_loader_write(*loader, *pimg, fLen, 0)
    gdk_pixbuf_loader_close(*loader, *error)
    FreeMemory(*pimg)
    *pixbuf = gdk_pixbuf_loader_get_pixbuf(*loader)
    *image1 = gtk_image_new_from_pixbuf(*pixbuf)   
 ;---
    ButtonGadget_AddImage(#myButton1, *image1, "", #GTK_POS_LEFT)
    ButtonImages_Activate(#True)

  EndIf      
Else
  End
EndIf

Repeat
Until WaitWindowEvent() = #PB_Event_CloseWindow

;free image-memory...
If *image1
  gtk_image_clear(*image1) 
EndIf
End
As far as i can tell it doesnt use any deprecated functions. It was frustrating coming across so many apparent solutions to this only to find out they were using deprecated functions like PixData (PixBuf is fine, but PixData is deprecated), so im extra happy to have overcome that.

Thankyou to everyone who posted to this thread and Omi/Oma whose from-file code my from-memory code is based on, i didnt know which way North was at the start as im so new to Linux and Purebasic so all help was very useful, much appreciated, and fruitful, and im now displaying my 1kb icons on Linux in less than 1kb of code just like i am on Windows and Mac :) (taking nothing away from UsePNGDecoder() of course!!! but there is a time and a place! :D)

Thats enough programming for this Sunday i think! lol. I'll get back to my programming Linux and Mac for newbies books with a glass of wine heehee :)
Last edited by Keya on Mon Sep 21, 2015 12:23 pm, edited 1 time in total.
Oma
Enthusiast
Enthusiast
Posts: 312
Joined: Thu Jun 26, 2014 9:17 am
Location: Germany

Re: Icon/native image options in Linux

Post by Oma »

Hi Keya,

congratulations! Your load-version runs fine.

I got it running yesterday evening too. And yes, you're right: gdk_pixbuf_loader_close() is the starting shot for the previous command!
You posted one of the best links the last time. It opens graphical doors to PureBasic-Linux. :D

Here's my quick&dirty pics-embedded version (i hope it doesn't make you angry, but it's the best thread to place):
- The bad thing: This version doesn't care about timing ("prepared" und "updatet" signal) as recommended in doku.
- but it is shorter then my solid version, easier to handle and seem to run too (had no problem till now)
- no need for any PureBasic ImageDecoder
- images can be embedded in the exe when compiling (no pics must be included to published Apps, no search, load, memory-handling of pics necessary)
- you can use it for API commands like Window- or Application-icons, images on Buttons
- AND you can use it for all PureBasic-Gadgets or GadgetItems with images
- no limitation to PB-ImageDecoder-Formats (gif, vector graphics (svg) are possible (and tested) too). Just load the pic to the data-section:
Xubuntu 14.04 lists as supported formats on console: "gdk-pixbuf-query-loaders" or gdk_pixbuf_get_formats ():
-- ani
-- bmp
-- PNM/PBM/PGM/PPM
-- jpeg2000/jp2/jpc/jpx/j2k/jpf
-- tga/targa
-- png
-- ico/cur
-- gif
-- jpeg/jpe/jpg
-- icns
-- tiff/tif
-- pcx
-- wbmp
-- xbm
-- xpm
-- ras
-- qtif/qif
-- svg

Code: Select all

EnableExplicit

; UsePNGImageDecoder(); NOT :-)

ImportC ""
	gtk_button_set_image(*button.GtkButton, *image.GtkWidget)
	gtk_button_set_image_position(*button.GtkButton, position)
	gtk_button_set_label(*button.GtkButton, label.p-utf8)
	gtk_image_clear(*image.GtkWidget)
	gtk_button_set_alignment(*button.GtkButton, xalign.f, yalign.f)
	g_object_set(*object.GObject, property_name.p-utf8, *data, v= 0)
	gdk_pixbuf_loader_write(*loader, *buf, count, *error)
	gdk_pixbuf_loader_get_pixbuf(*loader)
	gdk_pixbuf_loader_new()
	gdk_pixbuf_loader_close(*loader, *error)
	g_signal_connect(*instance, detailed_signal.p-ascii, *c_handler, *pdata, destroy= 0, flags= 0) As "g_signal_connect_data"
EndImport

#Win_Main= 0

Enumeration
	#But1
	#But2
	#Dummy
	#ImG1
	#BIG1
	#Txt1
	#LIG
EndEnumeration

Global.i gEvent, gQuit
Global   *gPixbuf
Global   *gImage1, *gImage2

;Declare ButtonGadget_AddImage(Gadget, *Pic, Label.s, Alignment)

Procedure GetGadgetPixbuf(mem, size)
	Protected loader = gdk_pixbuf_loader_new()
	Protected *pixbuf, *err.GError
	
	*err= 0 : gdk_pixbuf_loader_write(loader, mem, size, @*err)
	If *err : Debug "Error: " + PeekS(*err\message, -1, #PB_UTF8) : EndIf
	
	*err= 0 : gdk_pixbuf_loader_close(loader, @*err);  Important to get the things going, else: Do you know 'Sankt Nimmerleinstag'?!
	If *err : Debug "Error: " + PeekS(*err\message, -1, #PB_UTF8) : EndIf
	
	*pixbuf = gdk_pixbuf_loader_get_pixbuf(loader)
	
	ProcedureReturn *pixbuf
EndProcedure

; -----

Procedure ButtonImages_Activate(Show)
	g_object_set(gtk_settings_get_default_(), "gtk-button-images", Show, #Null)
EndProcedure

Procedure ButtonGadget_AddImage(Gadget, *Pic, Label.s, Alignment)
	gtk_button_set_image(GadgetID(Gadget), *Pic)
	gtk_button_set_label(GadgetID(Gadget), Label)
	gtk_button_set_image_position(GadgetID(Gadget), Alignment)
EndProcedure

gtk_window_set_default_icon_(GetGadgetPixbuf(?Img3, ?Img4-?Img3));   If gtk_window_set_default_icon_() is used, comment gtk_window_set_icon_() call below.

If OpenWindow(#Win_Main, #PB_Ignore, #PB_Ignore, 500, 300, "Use exe embedded images w/o ImageDecoder", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
	
	;if icons are not shown, uncomment the following line ...
	ButtonImages_Activate(#True)
	
	ButtonGadget(#But1,   5,   5, 290,  30, " ", #PB_Button_Toggle)
	ButtonGadget(#But2,   5,  40, 290,  30, " ", #PB_Button_Toggle)
	TextGadget  (#Txt1,   5,  80, 240,  30, "Look at window-/taskbar-/dock- icon")
	TextGadget  (#PB_Any, 5, 115, 190,  22, "A PB ImageGadget()")
	TextGadget  (#PB_Any, 5, 145, 190,  22, "A PB ButtonImageGadget()")
	ListIconGadget(#LIG,  5, 175, 490, 120, "Col1 with embedded pixbufs w/o ImageDecoder", 350, #PB_ListIcon_GridLines)
	AddGadgetColumn(#LIG, 1, "Col 2", 90)
	
	;Further Gadgets with embedded, decoderless images are created here ...
	*gImage1= gtk_image_new_from_pixbuf_(GetGadgetPixbuf(?Img1, ?Img2-?Img1));                  Needs Ptr to free it
	ButtonGadget_AddImage(#But1, *gImage1, "1. ButtonGadget with left image", #GTK_POS_LEFT);   add pixbuf to #But1
	*gImage2= gtk_image_new_from_pixbuf_(GetGadgetPixbuf(?Img2, ?Img3-?Img2))
	ButtonGadget_AddImage(#But2, *gImage2, "2. ButtonGadget with right image", #GTK_POS_RIGHT); add pixbuf to #But2
	ImageGadget(#ImG1, 200, 110, 16, 16, GetGadgetPixbuf(?Img4, ?Img5-?Img4))
	ButtonImageGadget(#BIG1, 200, 140, 28, 28, GetGadgetPixbuf(?Img5, ?Img6-?Img5))
	AddGadgetItem(#LIG, -1, "1-1" + #LF$ + "1-2", GetGadgetPixbuf(?Img4, ?Img5-?Img4))
	AddGadgetItem(#LIG, -1, "2-1" + #LF$ + "2-2", GetGadgetPixbuf(?Img5, ?Img6-?Img5))
	
;	gtk_window_set_icon_(WindowID(#Win_Main), GetGadgetPixbuf(?Img3, ?Img4-?Img3)); if used, comment gtk_window_set_default_icon_() above
	
Else
	End
EndIf

Repeat
	gEvent= WaitWindowEvent()
	
	If EventWindow() = #Win_Main
		
		Select gEvent
				
			Case #PB_Event_CloseWindow
				gQuit= #True
				
		EndSelect
		
	EndIf
Until gQuit

;free global image-memory...
gtk_image_clear(*gImage1)
gtk_image_clear(*gImage2)


DataSection
	;Choose your pathes and pics here ...
	Img1:  : IncludeBinary "/usr/share/icons/default.kde4/16x16/actions/arrow-left.png"
	Img2:  : IncludeBinary "/usr/share/icons/default.kde4/16x16/actions/arrow-right.png"
	Img3:  : IncludeBinary "/usr/share/icons/default.kde4/48x48/apps/preferences-desktop-screensaver.png"
	Img4:  : IncludeBinary "/usr/share/icons/default.kde4/16x16/actions/arrow-down.png"
	Img5:  : IncludeBinary "/usr/share/icons/default.kde4/16x16/actions/arrow-up.png"
	Img6:  : ; MUST! End of Img5-Mem:
EndDataSection
A good Sunday and cheers
Charly
PureBasic 5.4-5.7, Linux: (X/L/K)Ubuntus+Mint - Windows XP (32Bit)
PureBasic Linux-API-Library & Viewer: http://www.chabba.de
Fred
Administrator
Administrator
Posts: 16690
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Re: Icon/native image options in Linux

Post by Fred »

Good work :)
User avatar
Keya
Addict
Addict
Posts: 1891
Joined: Thu Jun 04, 2015 7:10 am

Re: Icon/native image options in Linux

Post by Keya »

Oma, your code is so much more elegant than mine :) I should apologise for butchering your code so much during my trial-and-error process heehee :)
And thankyou for sharing your code! I had felt strangely alone on this journey, which is scary being a new OS :( - Google shows that nobody had used gdk_pixbuf_loader_get_pixbuf in purebasic before so i had to break ground! ... but im a complete Linux newbie! Scary stuff lol, but programming would be boring if there were no challenges? I was scared of Linux and Mac before Purebasic made me take the plunge :)
anyway needless to say it was a big relief when i found your original image button code!!! :)

On with the show!...

Enumerate supported image formats - gdk_pixbuf_get_formats() with optional gdk_pixbuf_format_is_writable()

Code: Select all

EnableExplicit
 
ImportC "" 
  gdk_pixbuf_get_formats()
  gdk_pixbuf_format_is_writable(pdata)
EndImport

Procedure GdkEnumPixbufFormats()
  Protected sAccess.s, *gdkfmts.GSList = gdk_pixbuf_get_formats()
  If *gdkfmts
    Repeat
      If gdk_pixbuf_format_is_writable(*gdkfmts\data): sAccess = "RW:": Else: sAccess = "R:": EndIf
      Debug( sAccess + #TAB$ + PeekS(PeekI(*gdkfmts\data),-1,#PB_Ascii) )
      *gdkfmts = *gdkfmts\next    ;linked list
    Until *gdkfmts = 0
  EndIf
EndProcedure
 
GdkEnumPixbufFormats()
MessageRequester("Done","Finished enumerating, see Debug window")
My ubuntu Linux Mint 17.1 x86 supports (* = Writable):
GdkPixdata, *tiff, icns, *ico, ani, xbm, xpm, *jpeg, wbmp, pcx, gif, *bmp, tga, ras, qtif, *png, svg, pnm
(so, apparently not jpeg2000? unless 'jpeg' supports that) Also interesting that GdkPixdata isnt a writable format


_____________________________________________________________________


Get address of raw pixels and size in bytes just requires a *pixbuf, such as this from previous demo: *pixbuf = gdk_pixbuf_loader_get_pixbuf(*loader)
(this isnt the full PixBuf structure, just the raw pixels part)

Code: Select all

ImportC ""
  gdk_pixbuf_get_byte_length(*pixbuf)    ;length of pixels in bytes
  gdk_pixbuf_get_pixels(*pixbuf)         ;address of pixels
EndImport
 
sizepixels = gdk_pixbuf_get_byte_length(*pixbuf)    
addrpixels = gdk_pixbuf_get_pixels(*pixbuf)
MessageRequester("PixBuf pixels", Str(sizepixels) + " bytes (comprising " + Str(sizepixels / 4) + " RGBA pixels?) @ 0x" + Hex(addrpixels))
There is gdk_pixbuf_GET_pixels:
Queries a pointer to the pixel data of a pixbuf. This function will cause an implicit copy of the pixbuf data if the pixbuf was created from read-only data.
and gdk_pixbuf_READ_pixels:
Returns a read-only pointer to the raw pixel data; must not be modified. This function allows skipping the implicit copy that must be made if gdk_pixbuf_get_pixels() is called on a read-only pixbuf.
thats working fine though i could only get the _GET_pixels one to compile ('undefined reference' for _READ_pixels), i dont know if thats just something im doing wrong or...
Last edited by Keya on Wed Sep 23, 2015 11:16 am, edited 4 times in total.
User avatar
heartbone
Addict
Addict
Posts: 1058
Joined: Fri Apr 12, 2013 1:55 pm
Location: just outside of Ferguson

Re: Icon/native image options in Linux

Post by heartbone »

Keya, your first method works for my system running UBUNTU 14.04 x86

Congratulations, and thank you for working through this to a successful result.
Image

I was going to try to look at this next week if you hadn't made the break through.
Being a BASIC programmer I'm quite sure that I would have been frustrated, so thanks again.

I've yet to try Oma's version, but I'm sure it will work.
I just could not wait to post this.
Enjoy your victory!
Keep it BASIC.
User avatar
Vera
Addict
Addict
Posts: 858
Joined: Tue Aug 11, 2009 1:56 pm
Location: Essen (Germany)

Re: Icon/native image options in Linux

Post by Vera »

Dito Thanks to you both Image

@Charly
runing your example works well, though I get a warning in ButtonImages_Activate(Show)

Code: Select all

; [WARNING] GLib-GObject (WARNING): IA__g_object_set_valist: object class `GtkSettings' has no property named `gtk-button-images'
   g_object_set(gtk_settings_get_default_(), "gtk-button-images", Show, #Null)
But if I comment call and procedure it runs alike and without warning.

greets ~ Vera
User avatar
Keya
Addict
Addict
Posts: 1891
Joined: Thu Jun 04, 2015 7:10 am

Re: Icon/native image options in Linux

Post by Keya »

thankyou Fred, heartbone, and Vera for kind words of encouragement :) :) :)

Let the party roll into the night, another demo...

Save *pixbuf to image file - gdk_pixbuf_save()
Can save to jpeg, png, bmp, tiff, ico etc - see my previous demo above in this thread to enumerate writable formats.
This also makes conversion from one type to another really simple - in this example i load a PNG and save to JPEG with complete control over the quality % ...

Code: Select all

EnableExplicit

ImportC ""
  gdk_pixbuf_loader_new.i()
  gdk_pixbuf_loader_write.l(*loader, *buffer, *count, *perror)
  gdk_pixbuf_loader_get_pixbuf.i(*loader)
  gdk_pixbuf_loader_close(*loader, *error)  
  
  gdk_pixbuf_save(*pixbuf, filename.p-utf8, type.p-utf8, *perror, var1.p-utf8, var2.p-utf8, stopvar=#Null)  ;can have more vars if required. last must be #Null as terminator
EndImport


Procedure ConvertImageFile(ImgFileIn.s, ImgFileOut.s)
  Define hFile.i, *ximage, *pimg, fLen.q, *pixbuf, *perror, *loader
  
  hFile.i = ReadFile(#PB_Any, ImgFileIn)
  If hFile = 0
    MessageRequester("Error","Couldnt readfile image file")
    End
  EndIf
  fLen = Lof(hFile)
  *pimg = AllocateMemory(fLen)
  ReadData(hFile, *pimg, fLen)
  CloseFile(hFile)
  
  *loader = gdk_pixbuf_loader_new()
  gdk_pixbuf_loader_write(*loader, *pimg, fLen, 0)
  gdk_pixbuf_loader_close(*loader, *perror)
  *pixbuf = gdk_pixbuf_loader_get_pixbuf(*loader)    
  FreeMemory(*pimg)
  
  *perror = 0
  ;If gdk_pixbuf_save(*pixbuf, ImgFileOut, "bmp", *perror, #Null, #Null, #Null)          ;eg. save as Windows BMP from Linux, nice
  ;If gdk_pixbuf_save(*pixbuf, ImgFileOut, "png", *perror, #Null, #Null, #Null)          ;eg. save as PNG
  ;If gdk_pixbuf_save(*pixbuf, ImgFileOut, "png", *perror, "compression", "9", #Null)    ;eg. save as PNG with variable Compression (0-9)
  If gdk_pixbuf_save(*pixbuf, ImgFileOut, "jpeg", *perror, "quality", "100", #Null)      ;eg. save as JPG with variable Quality (0-100%)
    MessageRequester("OK","Saved")
  Else
    MessageRequester("Error","Failed to save")
  EndIf  
EndProcedure

 
Define sImageIn.s, sImageOut.s
sImageIn = "/home/administrator/Desktop/testimg.png"      ;PNG in...
sImageOut =  "/home/administrator/Desktop/testout.jpg"    ;JPG out, because why not :)
ConvertImageFile(sImageIn, sImageOut)
End
[edit] added Oma's fixes for unicode support
Last edited by Keya on Sun Sep 20, 2015 6:48 pm, edited 3 times in total.
Oma
Enthusiast
Enthusiast
Posts: 312
Joined: Thu Jun 26, 2014 9:17 am
Location: Germany

Re: Icon/native image options in Linux

Post by Oma »

:D Go, Keya go ... :mrgreen:
I see you got a relaxed sunday and a little bottle wine mobilizes the reserves.

I tried your enumerate writable formats too and have to stop, because of:
;purebasic.o:(.text+0x2c): Nicht definierter Verweis auf `gdk_pixbuf_get_formats'
;collect2: error: ld returned 1 exit status
I now realized on your example that some codes need a Window + Event-Loop or MessageRequester. The no error is thrown :?

Good work - indeed! And i see that your diligence could deliver some very usefull parts for the Linux API-Lib (if you want). Be sure to get your credits.

I saw that your last Code is limited to Ascii. One Tip. If you change the prototypes and calls to e.g.

Code: Select all

gdk_pixbuf_save(*pixbuf, filename.p-utf8, type.p-utf8, *perror, var1.p-utf8, var2.p-utf8, Stop=0)
If gdk_pixbuf_save(*pixbuf, ImgFileOut, "jpeg", *perror, "quality", "100", #Null)
;Set Strings as Strings without Pointer-@ in the call.
it runs as Unicode too.
But i'm not absolutely sure whether filename has to be Ascii or UTF8.

@Vera:
Sprichst Du noch mit mir? :oops:
I can't confirm the warning (Ascii/Unicode/32/64-Bit) but i will tried it the next days on the other systems.
And the warning is wrong! https://developer.gnome.org/gtk3/stable ... tings.html
The Property "gtk-button-images" exists in gtk2- and gtk3-GtkSettings :?:

Bye to all,
Charly
PureBasic 5.4-5.7, Linux: (X/L/K)Ubuntus+Mint - Windows XP (32Bit)
PureBasic Linux-API-Library & Viewer: http://www.chabba.de
User avatar
Keya
Addict
Addict
Posts: 1891
Joined: Thu Jun 04, 2015 7:10 am

Re: Icon/native image options in Linux

Post by Keya »

Oma,
Oma wrote::D Go, Keya go ... :mrgreen:
I see you got a relaxed sunday and a little bottle wine mobilizes the reserves.
lol, yes I stopped to read for about five minutes before having another idea and wanting to try something. Im very tired now though, its been a long day so im going to retire to bed with one of my programming Linux/Mac for newbies books heehe, see if i can keep my eyes open for five more minutes :)

Interesting regarding the error you encountered during the formats enumeration ... is that problem solved if we have a window and messageloop? *fingers crossed*
Oma wrote:;Set Strings as Strings without Pointer-@ in the call.[/code] it runs as Unicode too.
But i'm not absolutely sure whether filename has to be Ascii or UTF8.
Im not sure either, i guess we can test over the coming days to be sure, but in the first page of this thread Trond said "A problem with gdk/gtk functions is that they require strings in UTF-8 format." so your current p-utf8's probably are right then :)

ps. Oma what is the reason your original button demo has ButtonImages_Activate commented out? (i couldnt see any icons until i uncommented it) :)


Vera,
Vera wrote:@Charly
runing your example works well, though I get a warning in ButtonImages_Activate(Show)

Code: Select all

; [WARNING] GLib-GObject (WARNING): IA__g_object_set_valist: object class `GtkSettings' has no property named `gtk-button-images'
   g_object_set(gtk_settings_get_default_(), "gtk-button-images", Show, #Null)
But if I comment call and procedure it runs alike and without warning.
greets ~ Vera
I call Oma's ButtonImages_Activate() also... do you get the error in my version too? in my version i only call it after initialising them (ive got no idea if that makes a difference or not - perhaps youve just found the answer, i just moved it to the end as it felt right, lol), so if you move that call down towards the end does that fix this problem?
Post Reply