|
Post by alexfish on Jun 8, 2014 19:07:41 GMT 1
Hi Joe Nice compact code, everything works since everything is gtk at what I call the upper level more or less how hug works , yes we know can get values back since we do know in simple terms it works but not as per first post by Peter , and nor will it work 100% with other libs and nor does it work 100% with an app to which has a mixture of libs in essence if the user opts to use DECLARED , IE first example by Peter declaring *win GtkWidget first to prove what does work with gtk in general , first added the bits to your demo , then some bits that may and may not work with gtk and another lib with reference to my first example '--- Needed for gtk2 PRAGMA LDFLAGS gtk-x11-2.0
'--- Needed to connect signals PRAGMA LDFLAGS gobject-2.0
PROTO gtk_init ALIAS INIT PROTO gtk_main_quit ALIAS QUIT PROTO gtk_window_new ALIAS WINDOW PROTO gtk_window_set_default_size ALIAS WINDOW_SIZE PROTO gtk_window_set_title ALIAS TITLE PROTO gtk_table_new ALIAS TABLE PROTO gtk_container_add ALIAS CONTAINER PROTO gtk_table_attach_defaults ALIAS ATTACH_TABLE PROTO gtk_button_new_from_stock ALIAS BUTTON PROTO gtk_table_attach_defaults ALIAS ATTACH_TABLE PROTO g_signal_connect_data ALIAS CALLBACK PROTO gtk_widget_show_all ALIAS SHOW PROTO gtk_label_new ALIAS LABEL PROTO gtk_main ALIAS DISPLAY PROTO gtk_check_button_new_with_label ALIAS CHECK
SUB exit_prog gtk_main_quit END SUB
FUNCTION BUTTON_STATE(NUMBER widget) TYPE int PROTO gtk_toggle_button_get_active LOCAL val val=gtk_toggle_button_get_active(widget)
RETURN val END FUNCTION
SUB GET_CHECK(NUMBER widget) LOCAL val val=BUTTON_STATE(widget) PRINT val END SUB
INIT(0, 0)
window = WINDOW() WINDOW_SIZE(window, 200, 200) TITLE(window, "Hello world ")
table = TABLE(15, 15, 1) CONTAINER(window, table) label = LABEL("Bacon and GTK shared lib example!") button = BUTTON("gtk-quit") ck=CHECK("My Check")
ATTACH_TABLE(table, button, 10, 14, 12, 14) ATTACH_TABLE(table, label, 1, 8, 3, 7) ATTACH_TABLE(table,ck,1,14,12,14)
CALLBACK(window, "delete-event", exit_prog, 0, 0, 0) CALLBACK(button, "clicked", exit_prog, 0, 0, 0) CALLBACK(ck,"clicked",GET_CHECK,0,0,0)
SHOW(window) DISPLAY
some short examples of what did not work and what did this will not work FUNCTION BUTTON_STATE_1(WIDGET *widget) TYPE int PROTO gtk_toggle_button_get_active LOCAL val val=gtk_toggle_button_get_active(widget)
RETURN val END FUNCTION
here is a top level trying to get value of a slider :: now this fails and can in some instances cause the app to crash FUNCTION GET_SLIDER_VAL(NUMBER widget) LOCAL sliderval sliderval=elm_slider_value_get(widget)
RETURN sliderval END FUNCTION
where as this works FUNCTION GET_SLIDER_VAL(WIDGET *widget) LOCAL sliderval sliderval=elm_slider_value_get(widget)
RETURN sliderval END FUNCTION
BR Alex
|
|
|
Post by alexfish on Jun 9, 2014 2:55:07 GMT 1
Hi All
thought I will try to clarify what some of this is about
IF have Elementary installed then will be able to test this bit of code : Compile with latest BaCon beta
best to read though it to try understand what it is doing , also inpart = part of a bigger demo
alias's are not cast in stone , since using bits that will highlight to get the picture.
BR Alex
'@ use the low level INIT SUB INIT PRAGMA LDFLAGS `pkg-config --libs elementary ` PRAGMA OPTIONS `pkg-config --cflags elementary ` PRAGMA INCLUDE elementary-1/Elementary.h
PROTO elm_init PROTO elm_policy_set PROTO elm_win_util_standard_add PROTO elm_win_autodel_set PROTO evas_object_resize PROTO evas_object_show PROTO elm_object_part_text_set PROTO evas_object_move PROTO evas_object_smart_callback_add PROTO elm_run PROTO elm_shutdown PROTO elm_entry_add PROTO elm_object_scale_set elm_init(0,0) '@ PROTO ALIAS PROTO Eina_Bool ALIAS boolean PROTO Evas_Object ALIAS WIDGET PROTO Evas ALIAS CANVAS PROTO Ecore_Timer ALIAS TIMEOUT
'@ fix conflict with bacon entry USEC #define ENTRY ELM_ENTRY END USEC PRINT "INIT DONE" END SUB
PROTO eina_convert_itoa ALIAS INT_STR PROTO eina_convert_xtoa ALIAS HEX_STR PROTO eina_convert_dtoa ALIAS DOUBLE_STR PROTO eina_convert_atod ALIAS STR_DOUBLE PROTO eina_convert_fptoa ALIAS FIXED_STR PROTO eina_convert_atofp ALIAS STR_FIXED PROTO eina_str_split PROTO free PROTO printf ALIAS SPRINT PROTO puts PROTO eina_init() PROTO Eina_Value ALIAS VAR PROTO eina_value_new PROTO eina_value_new ALIAS VARIANT PROTO eina_value_set ALIAS ALLOCATE PROTO eina_value_flush ALIAS FLUSH PROTO eina_value_free ALIAS SHRED PROTO eina_value_pget ALIAS PGET PROTO eina_value_pset ALIAS PSET PROTO eina_value_to_string ALIAS EVAL PROTO eina_value_to_string ALIAS GET PROTO eina_value_setup ALIAS CHANGE PROTO Eina_Value_Type PROTO eina_value_type_get
' DECLARES --------------------------- names$ = "Calvin;Leoben;D'anna;Simon;Doral;Six;Daniel;Sharon" str$="" tmp$="" prologue$="" part1$ = "The Cylons were created by man. They evolved. They rebelled." part2$ = "There are many copies. And they have a plan." DECLARE **arr TYPE char LOCAL arr$[1] TYPE STRING DECLARE i TYPE int DECLARE tmpy[128] TYPE char
INIT
FOR y$ IN names$ STEP ";" INCR i NEXT
PRINT i arr = eina_str_split(names$, ";", i) FOR t= 0 TO i -1 SPRINT("%s\n", arr[t]) puts (arr[t]) NEXT
INT_STR(45,tmpy) SPRINT("value: %s\n", tmpy); HEX_STR(0xA1, tmpy) SPRINT("value: %s\n", tmpy);
free(arr[0]) free(arr)
'@ Now rounding in to use the values then use Bacon to print without ' using puts or printf etc etc
VAR *value = VARIANT(EINA_VALUE_TYPE_INT) VAR *stringy$ = VARIANT(EINA_VALUE_TYPE_STRING) ALLOCATE(value, 1234) ALLOCATE(stringy$,"what is this") a$=EVAL(value) PRINT "value : " , a$ SPRINT("value: %s\n", a$)
a$=GET(stringy$) PRINT "string --> ",a$ a$="test" LOCAL setp= 99999 TYPE int
FLUSH(value) FLUSH(stringy$) '@ CHANGE int type to string CHANGE(value, EINA_VALUE_TYPE_STRING) '@ CHANGE string type to int CHANGE(stringy$, EINA_VALUE_TYPE_INT)
PSET(value, &a$) PSET(stringy$ ,&setp) a$=GET(value) PRINT "value : " , a$ a$=GET(stringy$) PRINT "stringy$ : " , a$ SHRED(stringy$) SHRED(value) '@ end all that
The pointer type is dependent on chosen value type. The list for basic types:
EINA_VALUE_TYPE_UCHAR: unsigned char* EINA_VALUE_TYPE_USHORT: unsigned short* EINA_VALUE_TYPE_UINT: unsigned int* EINA_VALUE_TYPE_ULONG: unsigned long* EINA_VALUE_TYPE_UINT64: uint64_t* EINA_VALUE_TYPE_CHAR: char* EINA_VALUE_TYPE_SHORT: short* EINA_VALUE_TYPE_INT: int* EINA_VALUE_TYPE_LONG: long* EINA_VALUE_TYPE_INT64: int64_t* EINA_VALUE_TYPE_FLOAT: float* EINA_VALUE_TYPE_DOUBLE: double* EINA_VALUE_TYPE_STRINGSHARE: const char ** EINA_VALUE_TYPE_STRING: const char ** EINA_VALUE_TYPE_ARRAY: Eina_Value_Array* EINA_VALUE_TYPE_LIST: Eina_Value_List* EINA_VALUE_TYPE_HASH: Eina_Value_Hash* EINA_VALUE_TYPE_TIMEVAL: struct timeval* EINA_VALUE_TYPE_BLOB: Eina_Value_Blob* EINA_VALUE_TYPE_STRUCT: Eina_Value_Struct*
|
|
|
Post by bigbass on Jun 9, 2014 7:37:30 GMT 1
Hey Alex I haven't worked out all the problems with mixed libs yet but with some deep thought and help we could get there but here is a demo with callbacks and signal events to show it can be done to a degree original link to sources given so it can be seen what was done to port and modify the code for bacon this time with gtk3 '---ported code example and modified +2 more switches by BaCon by bigbass '---https://developer.gnome.org/gnome-devel-demos/3.5/switch.c.html.en
'--- Needed for gtk3 PRAGMA LDFLAGS gtk-3
'--- Needed to connect signals PRAGMA LDFLAGS gobject-2.0
PROTO gtk_init ALIAS INIT PROTO gtk_window_new ALIAS WINDOW PROTO gtk_main ALIAS DISPLAY PROTO gtk_main_quit ALIAS QUIT PROTO g_signal_connect_data ALIAS CALLBACK PROTO gtk_box_set_homogeneous ALIAS BOX_H PROTO gtk_box_new ALIAS BOX PROTO gtk_box_pack_start ALIAS BOX_START PROTO gtk_container_add ALIAS CONTAINER PROTO gtk_widget_show_all ALIAS SHOW PROTO gtk_switch_new ALIAS SWITCH PROTO gtk_label_new ALIAS LABEL
'--- set undeclared values GTK_WINDOW_TOPLEVEL = 0 GTK_ORIENTATION_VERTICAL = 1
'===================== SUB exit_prog '===================== QUIT END SUB
'===================== SUB switch_clicked() '===================== CLEAR PRINT "switch button1" SW1 = gtk_switch_get_active (switch1) PRINT SW1 END SUB
'===================== SUB switch_clicked2() '===================== CLEAR PRINT "switch button2" SW2 = gtk_switch_get_active (switch2) PRINT SW2 END SUB
'===================== SUB switch_clicked3() '===================== CLEAR PRINT "switch button3" SW3 = gtk_switch_get_active (switch3) PRINT SW3 END SUB
INIT(0, 0)
window = WINDOW(GTK_WINDOW_TOPLEVEL)
box = BOX(GTK_ORIENTATION_VERTICAL, 2) BOX_H(box, TRUE) CALLBACK(window, "delete-event", exit_prog, 0, 0, 0)
label = LABEL("Switch Test ");
'---Create a switch button1 switch1 = SWITCH() CALLBACK(switch1, "notify::active",switch_clicked, 0, 0, 0)
'---Create a switch button2 switch2 = SWITCH() CALLBACK(switch2, "notify::active",switch_clicked2, 0, 0, 0)
'---Create a switch button3 switch3 = SWITCH() CALLBACK(switch3, "notify::active",switch_clicked3, 0, 0, 0)
'---Pack them into a box, then show all the widgets BOX_START(box, label, 0, 0, 1, 1) BOX_START(box, switch1, TRUE, TRUE, 2) BOX_START(box, switch2, TRUE, TRUE, 2) BOX_START(box, switch3, TRUE, TRUE, 2) CONTAINER(window, box) SHOW(window)
DISPLAY
|
|
|
Post by bigbass on Jun 9, 2014 15:12:02 GMT 1
Hey Alex
I got it ! This is an undocumented new way to declare a type with PROTO
The official documented HUG way
Now just use this syntax instead when working with PROTO
'--- Needed for gtk2 PRAGMA LDFLAGS gtk-x11-2.0
Here with a new way DECLAREing the whole gtk function with a type The PROTO way to simulate how HUG does things now we can use the real functions without redefining anything (maybe this is just the first test)
P.S I didnt ALIAS anything so its easier to see the gtk stuff clearly
slider2.bac
'--- A new way of declaring a type with PROTO by bigbass '--- to get at the low level values in the slider
PRAGMA LDFLAGS `pkg-config --libs gtk+-2.0` PRAGMA OPTIONS `pkg-config --cflags gtk+-2.0` PRAGMA COMPILER gcc
OPTION PARSE FALSE '--- Get needed functions from GTK PROTO gtk_table_attach_defaults PROTO gtk_window_set_title PROTO gtk_button_new_from_stock PROTO gtk_window_set_default_size PROTO gtk_table_new PROTO gtk_window_new PROTO gtk_container_add PROTO gtk_exit PROTO gtk_hscale_new_with_range PROTO gtk_init PROTO gtk_label_new PROTO gtk_widget_show_all PROTO gtk_main
PROTO g_signal_connect_data '--- Callback for closing window SUB exit_prog PRINT "QUIT" gtk_exit(0) END SUB '============================ FUNCTION Changed(long get) '============================ '---finally solved the PROTO with a type problem ! DECLARE gtk_range_get_value(long) TYPE double DECLARE gtk_hscale_new_with_range(double,double,double) TYPE long
get = gtk_range_get_value(Hscale) PRINT " CHANGED ",get RETURN get END FUNCTION '--- Main program starts here gtk_init(0, 0) window = gtk_window_new(0) gtk_window_set_default_size(window, 400, 300) gtk_window_set_title(window, "scale PROTO") table = gtk_table_new(15, 15, 1) gtk_container_add(window, table) Hscale = gtk_hscale_new_with_range(0,1000,1) button = gtk_button_new_from_stock("gtk-quit") gtk_table_attach_defaults(table, button, 10, 14, 12, 14) gtk_table_attach_defaults(table,Hscale, 1, 14, 3, 14) '--- Use as callback the defined SUB g_signal_connect_data(button, "clicked",exit_prog, 0, 0, 0) g_signal_connect_data(Hscale, "value-changed", Changed ,0, 0, 0) g_signal_connect_data(window, "delete-event", exit_prog, 0, 0, 0) '--- Show whole GUI gtk_widget_show_all(window) gtk_main
|
|
|
Post by vovchik on Jun 9, 2014 15:36:01 GMT 1
Dear Joe,
Whoopeee!!!! Great!!!!
With kind regards, vovchik
UPDATE: And I am getting values back from my FLTK sliders now, too!
|
|
|
Post by bigbass on Jun 9, 2014 17:17:41 GMT 1
Hey Vovchik Excellent news and thats a c++ function ! I wanted to test this to see if it would work with a heavier much uglier gtk3 example *with a big spoonful of extra header crud* gtk3 a vslider and hslider demo (ported to bacon below) developer.gnome.org/gnome-devel-demos/3.5/scale.c.html.enJust to show we can nuke the pointers and casting with a little bit of care getting some stuff declared from the headers and place it in the main code
'---gtk3 no headers no casting callback function to low level stuff '---vhsliders3easy.bac
'---ported source code by bigbass '---https://developer.gnome.org/gnome-devel-demos/3.5/scale.c.html.en
PRAGMA OPTIONS `pkg-config --cflags gtk+-3.0` PRAGMA LDFLAGS `pkg-config --libs gtk+-3.0` PRAGMA COMPILER gcc
PROTO gtk_label_set_text ALIAS TEXT PROTO gtk_container_add ALIAS CONTAINER PROTO gtk_container_set_border_width ALIAS BORDER PROTO gtk_grid_attach ALIAS ATTACH_GRID PROTO gtk_grid_set_column_homogeneous ALIAS HOMOGENEOUS PROTO gtk_grid_set_column_spacing ALIAS SPACING PROTO gtk_scale_set_digits ALIAS DIGITS PROTO gtk_widget_set_hexpand ALIAS HEXPAND PROTO gtk_widget_set_valign ALIAS VALIGN PROTO gtk_widget_set_vexpand ALIAS VEXPAND PROTO gtk_widget_show_all ALIAS SHOW PROTO gtk_window_set_default_size ALIAS WINDOW_SIZE PROTO gtk_window_set_title ALIAS TITLE PROTO gtk_adjustment_new ALIAS ADJUSTMENT PROTO gtk_application_new ALIAS APP_NEW PROTO gtk_window_new ALIAS WINDOW PROTO gtk_grid_new ALIAS GRID PROTO gtk_label_new ALIAS LABEL PROTO gtk_range_get_value ALIAS GET_VALUE PROTO gtk_scale_new ALIAS SCALE '--- added after PROTO gtk_init ALIAS INIT PROTO gtk_main ALIAS DISPLAY PROTO g_signal_connect_data ALIAS CALLBACK PROTO gtk_main_quit ALIAS QUIT PROTO gtk_scale_get_value_pos ALIAS VALUE_POS PROTO gtk_adjustment_get_value ALIAS ADJ_GET_VALUE
'--- set undeclared values GTK_WINDOW_TOPLEVEL = 0
GTK_ORIENTATION_HORIZONTAL =0 GTK_ORIENTATION_VERTICAL = 1
GTK_ALIGN_FILL =0 GTK_ALIGN_START =1 GTK_ALIGN_END =2 GTK_ALIGN_CENTER =3 GTK_ALIGN_BASELINE=4
DECLARE gtk_adjustment_new(double,double,double,double,double,double) TYPE long
'--- had to replace low level stuff styled after HUG DECLARE gtk_adjustment_get_value(long) TYPE double
'--- This is the callback function. It is a handler function which '--- reacts to the signal. with hscale and vscale '================================= FUNCTION get_bits_hscale(long val) '=================================
val=gtk_adjustment_get_value(Hscale_adjustment) PRINT " SLIDER H ",val RETURN val END FUNCTION
'================================= FUNCTION get_bits_vscale(long val) '=================================
val=gtk_adjustment_get_value(Vscale_adjustment) PRINT " SLIDER V ",val RETURN val END FUNCTION '============== SUB EXIT_PROG '============== QUIT
END SUB INIT(0, 0) '--- Create a window with a title and a default size window = WINDOW(GTK_WINDOW_TOPLEVEL) TITLE (window, "Scale Example GTK3") WINDOW_SIZE(window, 400, 300) BORDER(window, 5) '---Connecting the clicked signal to the callback function CALLBACK(window, "destroy", EXIT_PROG, 0, 0, 0) '--- Two labels to be shown in the window hlabel = LABEL("Move the scale handle...") vlabel = LABEL("Move the scale handle...") '--- gtk_adjustment_new takes six parameters, three of which '--- may be difficult to understand: '--- step increment- move the handle with the arrow keys on your keyboard to see. '--- page increment - move the handle by clicking away from it '--- on the scale to see. '--- page size - not used here. Hscale_adjustment = ADJUSTMENT(0,0,100,5,10,0) Vscale_adjustment = ADJUSTMENT(0,0,100,5,10,0) '--- Create the Horizontal scale, making sure the '--- digits used have no decimals. h_scale = SCALE(GTK_ORIENTATION_HORIZONTAL, Hscale_adjustment) DIGITS(h_scale, 0) '--- Allow it to expand horizontally (if there's space), and '--- set the vertical alignment HEXPAND(h_scale, TRUE) VALIGN(h_scale, GTK_ALIGN_START) '--- Connecting the "value-changed" signal for the horizontal scale '--- to the appropriate callback function. '---take note that GtkRange is part of GtkScale's Object Hierarchy. CALLBACK(h_scale, "value-changed", get_bits_hscale, 0, 0, 0) '--- Create the Vertical scale. This time, we will see what happens '--- when the digits arent initially set. v_scale = SCALE(GTK_ORIENTATION_VERTICAL, Vscale_adjustment) DIGITS(v_scale, 0) VEXPAND(v_scale, TRUE) '--- Connecting the "value-changed" signal for the vertical scale to '--- the appropriate callback function. CALLBACK(v_scale, "value-changed", get_bits_vscale, 0, 0, 0) '--- Create a grid and arrange everything accordingly grid = GRID() gtk_grid_set_column_spacing (grid, 10) HOMOGENEOUS(grid, TRUE) ATTACH_GRID(grid, h_scale, 0, 0, 1, 1) ATTACH_GRID(grid, v_scale, 1, 0, 1, 1) ATTACH_GRID(grid, hlabel, 0, 1, 1, 1) ATTACH_GRID(grid, vlabel, 1, 1, 1, 1) CONTAINER(window, grid) SHOW(window) DISPLAY
|
|
|
Post by vovchik on Jun 9, 2014 17:31:15 GMT 1
Dear Joe,
Works beautifully. Thanks...
With kind regards, vovchik
|
|
|
Post by alexfish on Jun 9, 2014 21:41:58 GMT 1
Hi Joe Think Vovchik summed it up , I just adding a BR Alex thought would test your Bits , no pun intended , against Elementary widgets , Yes they now work as in getting the Values looks now that U have Cracked the nut to find common ground of getting the results from the widgets. List now looks like GTK2 GTK3 FLTK ELM as in Elementary Would also Like to Thank Peter for Latest Improvements to Beta 3.0.1 Dank u wel + BR Alex
|
|
|
Post by bigbass on Jun 18, 2014 17:16:38 GMT 1
After going through all the gtk2 and gtk3 example demos I put all the values usually declared in the gtk.h into a BaCon file we can add more as we go but this list covers all the demo examples I posted a long process of testing stand alone widgets one at a time to make this compact list Here is an complete example how to include many enums at once for **gtk2** by vovchik gtkenum2.bac wiki.basic-converter.org/index.php?title=Gtkenum2.bacHere is an complete example how to include many enums at once for **gtk3** by bigbass enum-include.bac wiki.basic-converter.org/index.php?title=Enum-incude.bacGTK_HEADERS.bac
'--- gtk declaring values from headers '--- so we don't need to use casting and pointers '--- bigbass 2014
GTK_WRAP_WORD = 2 GTK_POLICY_AUTOMATIC = 1 GTK_WINDOW_TOPLEVEL = 0 GTK_ORIENTATION_VERTICAL = 1
GTK_ASSISTANT_PAGE_CONTENT = 0 GTK_ASSISTANT_PAGE_INTRO = 1 GTK_ASSISTANT_PAGE_CONFIRM = 2 GTK_ASSISTANT_PAGE_SUMMARY = 3 GTK_ASSISTANT_PAGE_PROGRESS = 4 GTK_ASSISTANT_PAGE_CUSTOM = 5
GTK_POS_BOTTOM = 3 GTK_POS_TOP = 2 GTK_POS_LEFT = 0 GTK_SHADOW_IN = 1
CONST GTK_STOCK_OK = 1 CONST GTK_MESSAGE_INFO = 0 CONST GTK_MESSAGE_WARNING = 1 CONST GTK_MESSAGE_QUESTION = 2 CONST GTK_MESSAGE_ERROR = 3 CONST GTK_STOCK_OK = 1 CONST GTK_STOCK_CLOSE = 2 CONST GTK_STOCK_CANCEL = 3 CONST GTK_BUTTONS_YES_NO = 4
CONST GTK_STOCK_NEW = "gtk-new" CONST GTK_STOCK_OPEN = "gtk-open" CONST GTK_STOCK_QUIT = "gtk-quit" CONST GTK_STOCK_CANCEL = "gtk-cancel" CONST GTK_STOCK_OPEN = "gtk-open" CONST GTK_STOCK_CUT = "gtk-cut" CONST GTK_STOCK_COPY = "gtk-copy" CONST GTK_STOCK_PASTE = "gtk-paste" CONST GTK_STOCK_HELP = "gtk-help" CONST GTK_STOCK_ABOUT = "gtk-about" GDK_CONTROL_MASK = 4 GTK_ACCEL_VISIBLE = 1
'--- low level button signals CONST GTK_RESPONSE_OK = -5 CONST GTK_RESPONSE_CANCEL = -6 CONST GTK_RESPONSE_CLOSE = -7 CONST GTK_RESPONSE_DELETE_EVENT = -4
'--- low level button signals CONST GTK_RESPONSE_OK = -5 CONST GTK_RESPONSE_CANCEL = -6 CONST GTK_RESPONSE_CLOSE = -7 CONST GTK_RESPONSE_DELETE_EVENT = -4 CONST GTK_RESPONSE_ACCEPT = -3 CONST GTK_FILE_CHOOSER_ACTION_CREATE_FOLDER = 3 CONST GTK_FILE_CHOOSER_ACTION_OPEN = 0 CONST GTK_FILE_CHOOSER_ACTION_SAVE = 1 CONST GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER = 2
'--- get around including headers by declaring only what you need CONST _GDK_MAKE_ATOM = 69 GDK_SELECTION_CLIPBOARD = _GDK_MAKE_ATOM GTK_ALIGN_FILL =0 GTK_ALIGN_START =1 GTK_ALIGN_END =2 GTK_ALIGN_CENTER =3 GTK_ALIGN_BASELINE=4
ENUM GTK_POLICY_ALWAYS, GTK_POLICY_AUTOMATIC, GTK_POLICY_NEVER END ENUM
|
|
|
Post by bigbass on Sept 20, 2017 7:11:14 GMT 1
Hello
have some real problems compiling all PROTO code above with gtk3 it used to compile before? though could be my computer...?
so had to go a different way using DECLARE this demo does work for me with gtk3
PRAGMA LDFLAGS `pkg-config --libs gtk+-3.0` PRAGMA OPTIONS `pkg-config --cflags gtk+-3.0` PRAGMA COMPILER gcc
OPTION PARSE FALSE
DECLARE gtk_init(int*,void*) DECLARE gtk_window_new(int) DECLARE gtk_window_set_title(long,const char*) DECLARE g_signal_connect_data(long,char*,void*,long,long,int) DECLARE gtk_widget_show_all(long) DECLARE gtk_main() DECLARE gtk_main_quit()
' get the needed missing values GTK_WINDOW_TOPLEVEL = 0
'=============== SUB exit_prog '=============== gtk_main_quit END SUB
gtk_init(0, 0) window = gtk_window_new(GTK_WINDOW_TOPLEVEL) gtk_window_set_title(window, "Hello World!")
'--- Connect the main window to the destroy ---> replace with SUB exit_prog g_signal_connect_data(window, "delete-event", exit_prog, 0, 0, 0) gtk_widget_show_all(window) gtk_main()
|
|
|
Post by vovchik on Sept 20, 2017 8:03:50 GMT 1
Dear Joe,
The solution is, I think, very simple. Just use this order at the very top:
PRAGMA OPTIONS `pkg-config --cflags gtk+-3.0` PRAGMA LDFLAGS `pkg-config --libs gtk+-3.0` PRAGMA COMPILER gcc
First the PRAGMA options and then the flags. That works on my machine. I think gcc became stricter in some recent update in terms of the order of things passed to the compiler.
With kind regards, vovchik
|
|
|
Post by bigbass on Sept 20, 2017 16:28:56 GMT 1
Thanks vovchik
I fixed the two examples slider gtk2 and gtk3 on this page with your suggestion(but many more demos I have to sort out now)
however Peter's first post in this thread won't compile for me on my computer with your suggested fix ?
I can goof up at times but I know his demo worked before
P.S since I have been away for awhile I am walking through old demo code and testing it out Joe
|
|
|
Post by vovchik on Sept 20, 2017 16:50:48 GMT 1
Dear Joe, Try this at the top: PRAGMA OPTIONS `pkg-config --cflags gtk+-2.0` PRAGMA LDFLAGS `pkg-config --libs gtk+-2.0` PRAGMA INCLUDE <gtk-2.0/gtk/gtk.h> It works for me. With kind regards, vovchik
|
|
|
Post by bigbass on Sept 20, 2017 17:08:47 GMT 1
Thanks again I think I need to drink a lot of coffee Joe
|
|
|
Post by bigbass on Oct 9, 2017 17:59:43 GMT 1
Hey Guys Note : Will be using IMPORTS on this one I had a hard time mentally picking up on using gtk IMPORTS before but PROTO just made sense to me so I stayed with that for some time and converted many new widgets from gtk3 and the reason why was what gets changed during all the conversions from the official widget names and pointers and the renaming long int char* .. I took some time studying it all and now it makes more sense finally But I really wanted to add some stuff to gtk2 and use IMPORTS so I figured that I would back port what I could from the new gtk3 demos I finally got those "official callbacks" working too ! After drinking some coffee I can think again Joe gnome entry '--- a working generic template made from entry.c '--- Ported by bigbass from gnome gtk3 to gtk2 HUG imports style tested on a 64 bit cpu
'--- auto generated a short IMPORTS list of gtk function with args HUG styled IMPORT "gtk_container_add(long,long)" FROM "libgtk-x11-2.0.so" TYPE void IMPORT "gtk_container_set_border_width(long,int)" FROM "libgtk-x11-2.0.so" TYPE void IMPORT "gtk_entry_get_text(long)" FROM "libgtk-x11-2.0.so" TYPE char* IMPORT "gtk_entry_new" FROM "libgtk-x11-2.0.so" TYPE long IMPORT "gtk_widget_show_all(long)" FROM "libgtk-x11-2.0.so" TYPE void IMPORT "gtk_window_set_default_size(long,int,int)" FROM "libgtk-x11-2.0.so" TYPE void IMPORT "gtk_window_set_title(long,char*)" FROM "libgtk-x11-2.0.so" TYPE void
'--- auto generated a short IMPORTS list of gtk/ gdk functions with args HUG styled '--- we need these always IMPORT "gtk_init(int*,void*)" FROM "libgtk-x11-2.0.so" TYPE void IMPORT "gtk_main" FROM "libgtk-x11-2.0.so" TYPE void IMPORT "gtk_exit(int)" FROM "libgtk-x11-2.0.so" TYPE void
IMPORT "gtk_window_new(int)" FROM "libgtk-x11-2.0.so" TYPE long
IMPORT "g_signal_connect_data(long,char*,long,long,long,int)" FROM "libgobject-2.0.so.0" TYPE void
'--- set undeclared values try to auto catch some too
'===================== SUB exit_prog '===================== gtk_exit(0) ENDSUB
'--- This is the callback function. It is a handler function '--- which reacts to the signal. In this case, it will grab the '--- text input from the entry box and print out a line to the user. '==================================== SUB on_activate (long entry ,long user_data) '====================================
name$ = (char *)gtk_entry_get_text (entry) PRINT name$ END SUB
gtk_init(0, 0)
'--- Create a window with a title, a default size, and a set border width window =gtk_window_new (0) gtk_window_set_title (window, "What is your name?") gtk_window_set_default_size (window, 300, 100) gtk_container_set_border_width (window, 10)
'--- Create a new entry box, and add it to the window entry_box = gtk_entry_new (0) gtk_container_add (window, entry_box)
'--- Connecting the activate signal to the callback g_signal_connect_data(entry_box,"activate", ADDRESS(on_activate), 0, 0, 0) g_signal_connect_data(window, "delete-event", ADDRESS(exit_prog), 0, 0, 0)
gtk_widget_show_all (window) gtk_main
|
|