|
Post by Pjot on May 30, 2020 9:19:57 GMT 1
Hi vovchik, Thanks. I was a little bit unhappy about the name 'GUIACT', and so I have changed it to 'GUIFN' to be more in line with other BaCon statements, like 'DEF FN'. Hope this is OK. Also, I have updated all radio programs once again, so the necessary function pointers are declared locally in the function where they are actually needed. I have updated other parts in the GTK code because we do not need the "visible" attribute anymore (except for the menu widgets). - The Radio program for Xaw here
- The Radio program for Motif here
- The Radio program for GTK here
As usual, if you run into trouble, please let me know. Best regards Peter
|
|
|
Post by bigbass on May 30, 2020 14:18:23 GMT 1
all your fixes produced a clean compile! thanks Joe I'm sure this will give you some ideas (would like to have an option inside the bacon code if possible) GTK_THEME=Adwaita:dark ./radio-gtk
|
|
|
Post by Pjot on May 30, 2020 17:58:48 GMT 1
Thanks Joe, Never knew that we can set the GTK theme like this... thinking about it BR Peter
|
|
|
Post by vovchik on May 30, 2020 18:33:08 GMT 1
Dear Peter,
I have two perhaps naive questions about the new GUI:
- Any way to do a FIXED container, where all widget locations can be specified by x and y, like in HUG?
- How would you do a sync to complete a drawing operation and have the IMAGE or other widget get updated?
I have been thinking of porting some old HUG demos and am wondering....
With kind regards, vovchik
|
|
|
Post by bigbass on May 30, 2020 18:53:39 GMT 1
when using geany there is an option set build commands so this is only a runtime prefix setting
I got this working and only applies to that app without changing your global theme
env GTK_THEME=Adwaita:dark "./%e"
|
|
|
Post by vovchik on May 30, 2020 19:28:33 GMT 1
Dear Joe,
I you want to set that theme within your bacon gtk3 app, just include this somewhere at the top of your code:
SETENVIRON "GTK_THEME", "Mint-Y-Brown"
It worked for me...
With kind regards, vovchik
|
|
|
Post by Pjot on May 30, 2020 19:50:29 GMT 1
- Any way to do a FIXED container, where all widget locations can be specified by x and y, like in HUG? I was afraid somebody would ask this some day ...the problem with GTK is that the widgets do not own their coordinates. So, X- and Y-position are not properties of the widget, like they are in libXt. Nevertheless, there is a way to do it: OPTION GUI TRUE PRAGMA GUI gtk3
DECLARE (*put)() = gtk_fixed_put TYPE void
id = GUIDEFINE(" \ { type=WINDOW name=window callback=delete-event title=\"GtkFixed demo\" height-request=200 width-request=300 } \ { type=FIXED name=fixed parent=window } \ { type=BUTTON name=button callback=clicked label=\"Click here\" }")
CALL GUIFN(id, "fixed", put, GUIWIDGET(id, "button"), 100, 100)
WHILE TRUE event$ = GUIEVENT$(id) SELECT event$ CASE "window" END CASE "button" PRINT "Button clicked" ENDSELECT WEND
For your other question, I would use ALARM similarly as I do in my radio-gtk program and then, in the alarmed function, flush GTK. The flush looks like this in C: while (gtk_events_pending()){ gtk_main_iteration(); }
HTH Peter
|
|
|
Post by bigbass on May 30, 2020 20:03:53 GMT 1
Thanks vovchik thanks for better bacon syntax I flipped the switch but the light didn't turn on quick enough for me to code it after finally realizing it was a run time env we could set it in BaCon the end goal is having some improvements in the GUI styling that we can finally test easily this is really a nice way to test some themes without changing the default settings Joe
|
|
|
Post by vovchik on May 30, 2020 21:24:16 GMT 1
Dear Peter and Joe,
Thanks. FIXED works nicely. I still have to try out ALARM. As for themes,we could write a little program with a few different widgets and then pass the theme name as an argument in order to test themes painlessly and without editing any gtk3 settings files.
With kind regards, vovchik
|
|
|
Post by bigbass on May 31, 2020 0:22:20 GMT 1
hello Peter and vovchik now that we can use function pointers to get a better grip on things I looked for a reduced example non GUI I could port from here I can compile those examples correctly in c and c+ www.cprogramming.com/tutorial/function-pointers.htmlbut when I port it to bacon I can only get it to compile cleanly in c I can force -fpermissive and get it to compile in g++ but that's as far as I get ( maybe I need a rest) I thought if you had some working code to test in just c it would make porting from gtk easier this works in bacon using c as the ported code
'====================================== FUNCTION my_int_func(int x) TYPE void '====================================== PRINT x FORMAT "%d\n" END FUNCTION '---note foo is a function pointer DECLARE (*foo)(int) TYPE void foo = &my_int_func ' call my_int_func (note that you do not need to write (*foo)(2) ) CALL foo(2) ' but if you want to, you may CALL (*foo)(2)
|
|
|
Post by bigbass on May 31, 2020 2:51:33 GMT 1
ok I got it now
there was an error at the very end of the doc page that had me stumped now fixed here
we make our own cool function
but we use a function pointer to it this time we want a string instead char*
not needed when we use gcc
PRAGMA COMPILER gcc PRAGMA OPTIONS -Wno-write-strings -Wno-deprecated
'if c++ needed 'PRAGMA OPTIONS -fpermissive -Wno-write-strings -Wno-deprecated
'====================================== FUNCTION cool(STRING y) TYPE void '====================================== PRINT y FORMAT "%s\n" END FUNCTION
'--- let's use a char* DECLARE (*func_pointer)(STRING) TYPE void func_pointer = &cool CALL func_pointer("hello")
|
|
|
Post by bigbass on May 31, 2020 4:55:21 GMT 1
we can call the function pointers whatever DECLARE (*ATTACH)() = gtk_fixed_put TYPE void
CALL GUIFN(id, "fixed",ATTACH, GUIWIDGET(id, "button"), 100, 100)
now the fun begins
|
|
|
Post by bigbass on May 31, 2020 7:25:23 GMT 1
ok I SEE now how to get different widgets going and callbacks
OPTION GUI TRUE PRAGMA GUI gtk3
DECLARE (*ATTACH)() = gtk_fixed_put TYPE void DECLARE entry1 TYPE GtkWidget*
id = GUIDEFINE(" \ { type=WINDOW name=window callback=delete-event title=\"GtkFixed demo\" height-request=200 width-request=300 } \ { type=FIXED name=fixed parent=window } \ { type=ENTRY name=entry1 callback=activate text=\"input something\" } \ { type=BUTTON name=button callback=clicked label=\"Click here1\" } \ { type=LINK_BUTTON name=button2 uri=\"http://www.basic-converter.org/\" callback=clicked label=\"website\" }")
CALL GUIFN(id, "fixed",ATTACH, GUIWIDGET(id, "entry1"), 100, 60) CALL GUIFN(id, "fixed",ATTACH, GUIWIDGET(id, "button"), 100, 100) CALL GUIFN(id, "fixed",ATTACH, GUIWIDGET(id, "button2"), 100, 140)
WHILE TRUE event$ = GUIEVENT$(id) SELECT event$ CASE "window" END CASE "entry1" 'PRINT "entry cb " CALL GUIGET(id, "entry1","text", &entry1) PRINT entry1 FORMAT "%s\n" CASE "button" PRINT "Button clicked" CASE "button2" PRINT "URL Button clicked2" ENDSELECT WEND
|
|
|
Post by rikky on May 31, 2020 7:41:30 GMT 1
With this editor out of my stomach I have a little time to play around. Sort of between two impossible projects. All the examples still work, as predicted. Or so I think. For I do get an error: ** (gtk_fixed_demo:19037): WARNING **: Error retrieving accessibility bus address: org.freedesktop.DBus.Error.ServiceUnknown: The name org.a11y.Bus was not provided by any .service files
But it does not seem to harm. An extra sweety: Latina - Le son latino France | http://broadcast.infomaniak.net/start-latina-high.mp3
Rik.
|
|
|
Post by Pjot on May 31, 2020 7:53:41 GMT 1
Hi rikky,
Your error warning seems to be a generic issue with RPI, apparently you need to install the 'at-spi2-core' package to get rid of it.
BR Peter
|
|