|
Post by bigbass on Jun 7, 2020 4:47:33 GMT 1
Hello vovchik all your work with images greatly improves the possibilities to make nice looking widgets thanks for all your work there is a lot we can do with gtk2 still and even more with gtk3
P.S you can even on the fly add css with the gtk inspector something that gtk3 does differently
Joe
|
|
|
Post by vovchik on Jun 7, 2020 11:30:48 GMT 1
Dear Joe (and all), Thanks. Here is a variation of BaCon Rocks with media player type controls. These could be at the bottom of BaCon Radio, along with a volume spin or slider, just for convenience. I have since also added a mockup of a compact BaCon Radio gui, where the stations would be visible in the combo box. I am just experimenting... With kind regards, vovchik UPDATED: I now have a working compact version but am still working out little imperfections. I hope the mock-up - which is no longer just a mock-up - works for you.
|
|
|
Post by rikky on Jun 8, 2020 9:12:20 GMT 1
It works. But so far I am able to copy / past some examples. If I try something new it's like as if I'm learning Chinese. So I want this status icon. developer.gnome.org/pygtk/stable/class-gtkstatusicon.htmlOPTION GUI TRUE PRAGMA GUI gtk2
DECLARE id
icon$ = CONCAT$("<svg width='256' height='256' viewBox='0 0 199 199'> " \ "<linearGradient id='l1' gradientUnits='objectBoundingBox' " \ " x1='1' x2='1' y1='0' y2='1'>" \ " <stop stop-color='white' offset='0'/>" \ " <stop stop-color='gold' offset='0.5'/>" \ " <stop stop-color='white' offset='1'/>" \ "</linearGradient>" \ "<radialGradient" \ " id='r1' cx='50' cy='50' fx='50%' fy='50' r='160%'" \ " gradientUnits='userSpaceOnUse'>" \ " <stop style='stop-color:crimson;stop-opacity:1;' offset='0'/>" \ " <stop style='stop-color:darkred;stop-opacity:1;' offset='1'/>" \ "</radialGradient> " \ "<rect x='2%' y='2%' rx='15%' ry='15%' width='96%' height='96%' " \ " fill='url(#r1)' stroke='url(#l1)' stroke-width='2.5%'/>" \ "<g transform='translate(15,22) scale(0.85,0.85)' " \ " fill='url(#l1)' stroke='gold' stroke-width='1.0%'>" \ "<path d='M102 4c-9 5-22 15-44 31L39 50l-14 1C0 52 0 51 1 " \ " 132c1 40 0 39 7 44l4 3h170l3-3c7-6 7-7 8-35 0-22 " \ " 0-25 2-27 5-6 5-32 1-38-2-2-3-4-3-8-2-16-4-17-90-18H54c0-1 " \ " 9-7 21-15 35-25 40-30 38-34-2-2-5-1-11 3z'/>" \ "</g>" \ "<g fill='url(#r1)' stroke='gold' stroke-width='1.0%'>" \ " <circle cx='30%' cy='60%' r='20%' stroke='gold' fill='url(#r1)'/>" \ " <circle cx='30%' cy='60%' r='15%' fill='url(#l1)' stroke='gold'/>" \ " <rect x='55%' y='43%' rx='1%' ry='1%' width='30%' height='6%'/>" \ " <rect x='55%' y='53%' rx='1%' ry='1%' width='30%' height='6%'/>" \ " <rect x='55%' y='63%' rx='1%' ry='1%' width='30%' height='6%'/>" \ " <rect x='55%' y='73%' rx='1%' ry='1%' width='30%' height='6%'/>" \ "</g>" \ "</svg>")
FUNCTION SVG_BUFF(STRING svg$) ' ------------------ LOCAL pixloader TYPE GdkPixbufLoader* LOCAL pixbuf TYPE GdkPixbuf* LOCAL size TYPE NUMBER LOCAL res TYPE int LOCAL raw_array TYPE unsigned char* size = LEN(svg$) raw_array = (unsigned char*)svg$ pixloader = gdk_pixbuf_loader_new() res = gdk_pixbuf_loader_write(pixloader, raw_array, size, 0) res = gdk_pixbuf_loader_close(pixloader, 0) pixbuf = gdk_pixbuf_loader_get_pixbuf(pixloader) RETURN pixbuf END FUNCTION
SUB start_program
PRINT "hallo" END SUB
id = GUIDEFINE("{ type=STATUS_ICON name=window}") CALL GUISET(id,"window", "set_visible",1) CALL GUISET(id,"window", "pixbuf",SVG_BUFF(icon$))
'g_signal_connect_data(id, "button-press-event", ADDRESS(start_program), 0, 0, 0)
WHILE TRUE event$ = GUIEVENT$(id) PRINT event$ WEND It compiles without complaining, so STATUS_ICON exists as a type. But it doesn't run. (icon:16897): Gtk-CRITICAL **: IA__gtk_widget_new: assertion 'g_type_is_a (type, GTK_TYPE_WIDGET)' failed
(icon:16897): Gtk-CRITICAL **: IA__gtk_widget_set_name: assertion 'GTK_IS_WIDGET (widget)' failed
(icon:16897): Gtk-CRITICAL **: IA__gtk_widget_get_name: assertion 'GTK_IS_WIDGET (widget)' failed ERROR: signal for SEGMENTATION FAULT received - memory invalid or array out of bounds? Try to compile the program with TRAP LOCAL to find the cause. Well, the question is not really how to make a status icon, but how to read (and understand) such a manual. It's horrible. Rik.
|
|
|
Post by vovchik on Jun 8, 2020 12:18:28 GMT 1
Dear all, Here is a slightly improved version of the compact gui BaCon Radio player. I still have to incorporate Peter's nice popup for editing and adding entries and track info (and, maybe, a volume slider). With kind regards, vovchik UPDATED: Added track info. Still have to do the error, edit and slider bits. Still am sorting out what to do with UTF8 or other encoding in the track info so the wavy svg and track info display properly in cases where some weird chars are encountered. Any ideas? Peter has written some filters for this purpose, and I will test those.
|
|
|
Post by Pjot on Jun 9, 2020 6:24:00 GMT 1
Thanks vovchik, Very nice! Also I like the scrolling of the current track title Best regards Peter
|
|
|
Post by rikky on Jun 9, 2020 8:31:59 GMT 1
Never mind my last post. I'll figure it out some day. I should not skip 6 chapters of the learning curve up to the tray icons, once I start to think I understand a tiny little bit anyway. There is this tiny thing in the radio compact gui. The UTF8 seems to not be working correctly. I get the attached screenshot. The play icon is working, the pause and stop not. I have included an OPTION UTF8 TRUE in the code, but to no avail. Rik. Attachments:
|
|
|
Post by vovchik on Jun 9, 2020 10:40:54 GMT 1
Dear Peter and Rik,
I have noticed that the svg wavy display can stop, and we get some kind of mini-crash, whenever the track info contains some characters that the svg renderer in gtk does not like. I am trying to understand how to fix that. We could have a translation table to take care of some of these problematic chars by converting them into html entities. I have to try that. Or by escaping/converting chars with values greater than ASC 127 and chars such as "' ? <> /", etc. Any ideas or insights? UCS will deliver the numeric codes of such UTF8 chars, although sites may be sending ASCII > 128 or using some other encoding (e.g. ISO-8859-?).
With kind regards, vovchik
|
|
|
Post by vovchik on Jun 9, 2020 12:12:20 GMT 1
Dear Peter and Rik,
I made some headway. The "&" in track info was one problem. As was "Ö" in "Ö24" in my stations list, since it gets passed to track info when there is no real track info for display. This means that our svg renderer does not really like certain chars, and they either have to be filtered out or escaped. After loading the track info (line 3 of SUB TRACK_UPDATE), I added:
track_msg$ = REPLACE$(track_msg$, "&", "and")
which took care of nearly all problems. Then I noticed the umlaut problem.
We could replace all diacriticals/non-ascii in this table:
āáǎàēéěèīíǐìōóǒòūúǔùǖǘǚǜĀÁǍÀĒÉĚÈĪÍǏÌŌÓǑÒŪÚǓÙǕǗǙǛ
with normal ASCII:
aaaaeeeeiiiioooouuuuüüüüAAAAEEEEIIIIOOOOUUUUÜÜÜÜ
but we might not catch all of them, and escaping or using html entities might be a better solution. Any ideas for an elegant solution (e.g. REGEX alnum or something better)?
With kind regards, vovchik
|
|
|
Post by Pjot on Jun 9, 2020 16:24:41 GMT 1
Hi vovchik, You could bruteforcefully try the TOASCII$ function? It will simply put bit 7 to 0 to make sure the character is ASCII compliant. HTH Peter
|
|
|
Post by vovchik on Jun 9, 2020 17:06:53 GMT 1
Dear Peter, Thanks. This seems to work for all but once case: track_msg$ = TOASCII$(REPLACE$(track_msg$, "&", "+")) With once stream, however, I get the following error when trying to fetch track info: Name: Radio Dismuke Vintage 1925 Index: 62 URL: http://74.208.197.50:8087 Track: Fetching...
ERROR: signal for SEGMENTATION FAULT received - memory invalid or array out of bounds? Try to compile the program with TRAP LOCAL to find the cause.
The stream plays, and the logo is dynamic (no crash), but that error crops up in the terminal. So far, that is the oly badly behaved stream I have found. With kind regards, vovchik
|
|
|
Post by Pjot on Jun 9, 2020 17:16:56 GMT 1
With once stream, however, I get the following error when trying to fetch track info That's correct, the stream should contain "//" and a separate "/". Previously the program did not check it. But this was fixed in the 1.8 version. Are you using this version? If not, then when you use the following URL: http://74.208.197.50:8087/
...then it should work. Alternatively, try to use the code of the 1.8 version if you did not already. HTH Peter
|
|
|
Post by vovchik on Jun 9, 2020 18:02:15 GMT 1
Dear Peter, Thanks. I updated the track update code using 1.8 and fixed up the url in the stations file (.radio.cfg), and it seems to be working. I just got the idea of turning the play and pause buttons into a single play/pause (using a toggle), which means one could be removed and there would be room for a button that could launch the popup editor. And, if I remove the throbber, which is really unnecessary if Bacon Radio logo is moving, then there could be a vertical slider in its place for volume, making everything very compact and tidy. Some work ahead... With kind regards, vovchik UPDATED: Had to change pos for pos1 in TRACK_UPDATE (a regression error). Sorry.
|
|
|
Post by bigbass on Jun 9, 2020 18:34:04 GMT 1
Hello vovchik looking good!
I had solved the toggle before here is working code to get it all in one button a little odd you have to think backwards logic
should just drop in easily but didn't test using your demo
'--- use toggle logic with one button '--- and no timeout loop needed '--- first press is always on SUB SPINNER_CB PRINT "spinner" IF cnt THEN gtk_spinner_stop(SPINNER) cnt = 0 ELSE gtk_spinner_start(SPINNER) cnt = 1 END IF END SUB
|
|
|
Post by vovchik on Jun 9, 2020 21:37:52 GMT 1
Dear Joe, Thanks for testing. I am now playing with a toggle button. Get the latest, above your last post, since I fixed a var in a sub, resulting in incorrect track info being displayed (pos/pos1 in TRACK_UPDATE). With kind regards, vovchik
|
|
|
Post by bigbass on Jun 9, 2020 22:35:03 GMT 1
Hello vovchik
the snippet I posted wont drop into your code it does work in my code using gtk3
so I took your kitty demo above and stripped it down to demo only a toggle button just to show some simple widgets with the new GUI code syntax Peter made for bacon
OPTION GUI TRUE PRAGMA GUI gtk3 OPTION PARSE FALSE
' Needed if we run this GTK2 sample in GTK3 PRAGMA OPTIONS -Wno-deprecated-declarations PRAGMA OPTIONS -Wno-write-strings -Wno-deprecated
DECLARE (*ATTACH)() = gtk_fixed_put TYPE void
'--- use toggle logic with one button '--- and no timeout loop needed '--- first press is always on SUB SPIN_TOGGLE() PRINT "spinner" IF cnt THEN CALL GUISET(id, "spinner", "active", 0) cnt = 0 ELSE CALL GUISET(id, "spinner", "active", 1) cnt = 1 END IF END SUB
' ------------------ SUB MY_QUIT() ' ------------------ ' quit program PRINT NL$, "End of demo...", NL$ END END SUB
' ------------------ SUB MK_GUI() ' ------------------ ' set window size win_w = 220 win_h = 220 ' define all gui elements id = GUIDEFINE(" \ { type=WINDOW name=window callback=delete-event } \ { type=FIXED name=fixed parent=window } \ { type=SPINNER name=spinner } \ { type=BUTTON name=toggle callback=clicked } \ { type=IMAGE name=image } \ { type=BUTTON name=myexit callback=clicked }")
' widget properties ' window CALL GUISET(id, "window", "window-position", GTK_WIN_POS_CENTER) CALL GUISET(id, "window", "width-request", win_w) CALL GUISET(id, "window", "height-request", win_h) CALL GUISET(id, "window", "title", "Spinner")
' buttons CALL GUISET(id, "toggle", "width-request", 70) CALL GUISET(id, "myexit", "width-request", 70)
CALL GUISET(id, "toggle", "height-request", 30) CALL GUISET(id, "myexit", "height-request", 30) CALL GUISET(id, "toggle", "label", "Toggle") CALL GUISET(id, "myexit", "label", "Exit") ' define tooltips CALL GUISET(id, "toggle", "tooltip-text", "Toggle BaCon throbber demo.") CALL GUISET(id, "myexit", "tooltip-text", "Quit BaCon throbber demo.")
' spinner size CALL GUISET(id, "spinner", "width-request", 24) CALL GUISET(id, "spinner", "height-request", 24)
' widget placement CALL GUIFN(id, "fixed", ATTACH, GUIWIDGET(id, "toggle"), 10, 10) CALL GUIFN(id, "fixed", ATTACH, GUIWIDGET(id, "spinner"), 97, 14) CALL GUIFN(id, "fixed", ATTACH, GUIWIDGET(id, "myexit"), 140, 170)
END SUB
' make gui MK_GUI()
' endless loop WHILE TRUE event$ = GUIEVENT$(id) PRINT "Event: ", event$ SELECT event$ CASE "window" END CASE "toggle" SPIN_TOGGLE CASE "myexit" MY_QUIT END SELECT SLEEP 1 WEND
|
|