Deleted
Deleted Member
Posts: 0
|
Post by Deleted on Apr 15, 2013 3:19:57 GMT 1
jrs@laptop:~/BaCon/V2B1$ bacon asst.bac Converting 'asst.bac'... done. Compiling 'asst.bac'... In file included from ./asst.bac.h:614:0, from ./asst.bac.c:2: ./asst.get_name.h: In function 'get_name': ./asst.get_name.h:6:1: warning: passing argument 1 of '__b2c__strdup' makes pointer from integer without a cast [enabled by default] ./asst.bac.h:93:7: note: expected 'const char *' but argument is of type 'int' In file included from ./asst.bac.h:615:0, from ./asst.bac.c:2: ./asst.submit.h: In function 'submit': ./asst.submit.h:6:1: warning: passing argument 1 of '__b2c__strdup' makes pointer from integer without a cast [enabled by default] ./asst.bac.h:93:7: note: expected 'const char *' but argument is of type 'int' done. Program 'asst' ready. jrs@laptop:~/BaCon/V2B1$ ./asst
|
|
|
Post by bigbass on Apr 15, 2013 4:10:42 GMT 1
Hey Alex Thanks for the new widget ! @jrs some fine tuning needed only it is caused by name$ but if you don't use "$" it compiles cleanly but a number is displayed the example widget expresses well how to convert C code to PROTO @alex congratulations on converting that we will have more custom widgets ! Joe
|
|
|
Post by alexfish on Apr 15, 2013 10:36:51 GMT 1
Hi John and Joe
The example was compile on Bacon GUI , 32 bit , No ERRORs show , and works as expected.
Did test in Bacon + bacon bash , Err do show , tried to eliminate errs,
can get rid of one , by passing arg's in the user data in the callback function
but one always remain's. ?
Perhaps this is one Peter can have a Look at it ,
Have left the code as is for now.
Edited:: have updated demo code , with temp hack using IMPORT statement
Seems to work in bacon2 + bacon2.bash
BR
Alex
|
|
|
Post by alexfish on Apr 15, 2013 15:41:28 GMT 1
jrs@laptop:~/BaCon/V2B1$ bacon asst.bac Converting 'asst.bac'... done. Compiling 'asst.bac'... In file included from ./asst.bac.h:614:0, from ./asst.bac.c:2: ./asst.get_name.h: In function 'get_name': ./asst.get_name.h:6:1: warning: passing argument 1 of '__b2c__strdup' makes pointer from integer without a cast [enabled by default] ./asst.bac.h:93:7: note: expected 'const char *' but argument is of type 'int' In file included from ./asst.bac.h:615:0, from ./asst.bac.c:2: ./asst.submit.h: In function 'submit': ./asst.submit.h:6:1: warning: passing argument 1 of '__b2c__strdup' makes pointer from integer without a cast [enabled by default] ./asst.bac.h:93:7: note: expected 'const char *' but argument is of type 'int' done. Program 'asst' ready. jrs@laptop:~/BaCon/V2B1$ ./asst
Hi John Have check out all options , these are general warnings from the compiler it is possible that the GUI version suppresses the warnings but not sure to suppress warnings with bacon and bacon.bash use the -o -w EG: ./bacon -o -w assistant.bac HTH Alex
|
|
|
Post by bigbass on Apr 15, 2013 16:05:06 GMT 1
Needed the easiest menu widget for starters will add more as a second example ported to PROTO from this link added callbacks zetcode.com/tutorials/gtktutorial/menusandtoolbars/P.S if you add widgets please be kind and add the link to the source if it was used as a reference this will also help for debugging or adding removed features and make clearer what was done to get a working bacon PROTO example that we can get more widgets added to bacon PRAGMA LDFLAGS `pkg-config --cflags --libs gtk+-2.0`
PROTO gtk_box_pack_start PROTO gtk_container_add PROTO gtk_init PROTO gtk_main PROTO gtk_menu_item_set_submenu PROTO gtk_menu_shell_append PROTO gtk_widget_show_all PROTO gtk_window_set_default_size PROTO gtk_window_set_position PROTO gtk_window_set_title PROTO gtk_menu_bar_new PROTO gtk_menu_item_new_with_label PROTO gtk_menu_new PROTO gtk_vbox_new PROTO gtk_window_new PROTO gtk_main_quit PROTO g_signal_connect_data
' get the needed missing values GTK_WINDOW_TOPLEVEL = 0 GTK_WIN_POS_CENTER = 1
'===================== SUB exit_prog '===================== gtk_main_quit END SUB
gtk_init(0,0)
window = gtk_window_new(GTK_WINDOW_TOPLEVEL) gtk_window_set_position(window, GTK_WIN_POS_CENTER) gtk_window_set_default_size(window, 250, 200) gtk_window_set_title(window, "menu") g_signal_connect_data(window, "delete-event", exit_prog, 0, 0, 0)
vbox = gtk_vbox_new(FALSE, 0) gtk_container_add(window, vbox)
menubar = gtk_menu_bar_new() filemenu = gtk_menu_new()
file = gtk_menu_item_new_with_label("File") quit = gtk_menu_item_new_with_label("Quit")
gtk_menu_item_set_submenu(file, filemenu) gtk_menu_shell_append(filemenu, quit) gtk_menu_shell_append(menubar, file) gtk_box_pack_start(vbox, menubar, FALSE, FALSE, 3)
g_signal_connect_data(quit, "activate",exit_prog, 0, 0, 0) gtk_widget_show_all(window)
gtk_main
|
|
|
Post by alexfish on Apr 15, 2013 18:29:06 GMT 1
Hi all Depending on your Distribution then it may help to install devhelp REF: developer.gnome.org/or can use the site above just using the net HTH Alex
|
|
Deleted
Deleted Member
Posts: 0
|
Post by Deleted on Apr 15, 2013 20:36:05 GMT 1
|
|
|
Post by alexfish on Apr 16, 2013 21:48:50 GMT 1
Hi All :: another PROTO demo Which can be Expanded on '@ Expander demo by alexfish `bacon converter forum`
PRAGMA LDFLAGS `pkg-config --cflags --libs gtk+-3.0`
PROTO gtk_init PROTO gtk_window_new PROTO gtk_main PROTO gtk_main_quit PROTO gtk_window_set_title PROTO gtk_container_add
PROTO gtk_widget_show_all PROTO gtk_window_set_default_size PROTO gtk_window_set_title PROTO gtk_label_new PROTO gtk_expander_new_with_mnemonic PROTO gtk_expander_set_expanded
PROTO gtk_box_new PROTO gtk_box_set_homogeneous PROTO gtk_box_pack_start
PROTO g_signal_connect_data
'===================== SUB exit_prog '===================== gtk_main_quit END SUB '==================== GTK_WINDOW_TOPLEVEL = 0 GTK_ORIENTATION_VERTICAL = 1
gtk_init(0, 0) window = gtk_window_new (GTK_WINDOW_TOPLEVEL) gtk_window_set_title (window, "Expander Example") gtk_window_set_default_size (window, 300, 200) g_signal_connect_data(window, "delete-event", exit_prog, 0, 0, 0) box1 = gtk_box_new (GTK_ORIENTATION_VERTICAL, 2) gtk_box_set_homogeneous (box1, TRUE)
lab1 = gtk_label_new_with_mnemonic ("BaCon ConVerter") gtk_box_pack_start (box1, lab1, TRUE, TRUE, 2)
exp_1=gtk_expander_new_with_mnemonic("click me") gtk_box_pack_start (box1, exp_1, TRUE, TRUE, 2) lab2 = gtk_label_new_with_mnemonic ("BaCon is Brill") gtk_container_add(exp_1,lab2)
gtk_container_add(window,box1) gtk_widget_show_all (window) gtk_main Have Fun Alex
|
|
|
Post by alexfish on Apr 16, 2013 22:41:31 GMT 1
Hi all GTK BUILDER Demo EDITED:: have looked at further examples of GTK-BUILDER some indicate the use of unref as in
g_object_unref(object) So have added to the code
'@ GTK BUILDER this is converted from Offical GTK-Demos , Should be able to install from repo's '@ alexfish Bacon Converter Forums '@ Should be able to read Glade Files , saved as Gtk-Builder Files
PRAGMA LDFLAGS `pkg-config --cflags --libs gtk+-3.0`
PROTO gtk_init PROTO gtk_builder_new PROTO gtk_builder_add_from_file PROTO gtk_builder_get_object PROTO g_signal_connect_data PROTO gtk_main_quit PROTO gtk_main '@ ADDED unref for the builder PROTO g_object_unref gtk_init(0, 0)
'===================== SUB exit_prog '===================== gtk_main_quit END SUB
SUB print_hello PRINT "Hello World" END SUB
builder = gtk_builder_new () '@ change the path to the ui file gtk_builder_add_from_file (builder, "builder.ui", NULL) window = gtk_builder_get_object (builder, "window") g_signal_connect_data(window, "delete-event", exit_prog, 0, 0, 0)
button1 = gtk_builder_get_object (builder, "button1") g_signal_connect_data(button1, "clicked",print_hello, 0, 0, 0) button2 = gtk_builder_get_object (builder, "quit") g_signal_connect_data(button2, "clicked",exit_prog, 0, 0, 0)
'@ everything ready Now unref the builder ' note the official doc does not indicate the use of ' but have added , since it makes sence.. will remove if indicators points differ.
g_object_unref(builder)
gtk_main
the "builder.ui" Save as 'builder.ui' : ensure to set the path within the above builder-code
<interface> <object id="window" class="GtkWindow"> <property name="visible">True</property> <property name="title">Grid</property> <property name="border-width">10</property> <child> <object id="grid" class="GtkGrid"> <property name="visible">True</property> <child> <object id="button1" class="GtkButton"> <property name="visible">True</property> <property name="label">Button 1</property> </object> <packing> <property name="left-attach">0</property> <property name="top-attach">0</property> </packing> </child> <child> <object id="button2" class="GtkButton"> <property name="visible">True</property> <property name="label">Button 2</property> </object> <packing> <property name="left-attach">1</property> <property name="top-attach">0</property> </packing> </child> <child> <object id="quit" class="GtkButton"> <property name="visible">True</property> <property name="label">Quit</property> </object> <packing> <property name="left-attach">0</property> <property name="top-attach">1</property> <property name="width">2</property> </packing> </child> </object> <packing> </packing> </child> </object> </interface>
Have Fun
Alex
ADDED: forgot to mention after compiling Builder UI can change the ui file /// so if make changes in glade then save them / Run the prog see what happens
or edit the file directly. EG have line in the builder ui
<property name="title">Grid</property> change it to
<property name="title">BaCon-ConVerter</property> do not recompile the Program , Just Run it :
|
|
|
Post by bigbass on Apr 17, 2013 6:53:16 GMT 1
Hey Alex I really like the example for GTK BUILDER! I uploaded it and included it with the PROTO demos under BUILDER here code.google.com/p/bigbass-porteus/wiki/EmbedGtk3BaConthanks for the other widget too will include it converting to PROTO is easier than I expected I only hit a small snag with the fileselect of all that I tried so far now any custom widget could be made with more practice ... of course Joe
|
|
|
Post by alexfish on Apr 17, 2013 16:04:46 GMT 1
Hi Joe Thanks for the compliments Only Posting Widgets such as which are Container Types. Leaving the rest to be Expanded on But this becomes all to Easy with Gtk-Builder Make the Ui in Glade save it , Open up Bacon Gui , Start the PROTO, with a FEW LINES OF CODE From Builder , open up the .ui in Bacon leave Glade Open so can see the widget , then only need one or two lines for each widget , rest is down to Yourself with the callbacks. Can Still edit the widgets in Glade, just save it an reload the UI in Bacon . Easy Peasy. Posted screen shot of the demo code in glade , think it is only 5 click's , save it then it's ready for the BaCon touch. it will really save a lot of research work. BR Alex Attachments:
|
|
|
Post by alexfish on Apr 17, 2013 21:43:58 GMT 1
Hi joe Can you do something with This, this = a Gtk-builder file , can use the original builder save as 'filechooser.ui' <?xml version="1.0" encoding="UTF-8"?> <interface> <!-- interface-requires gtk+ 3.0 --> <object class="GtkFileChooserDialog" id="filechooserdialog1"> <property name="visible">True</property> <property name="can_focus">False</property> <property name="tooltip_text" translatable="yes">File Chooser</property> <property name="border_width">5</property> <property name="window_position">center</property> <property name="default_width">320</property> <property name="default_height">260</property> <property name="type_hint">dialog</property> <property name="opacity">0.5</property> <property name="has_resize_grip">False</property> <child internal-child="vbox"> <object class="GtkBox" id="filechooserdialog-vbox1"> <property name="can_focus">False</property> <property name="orientation">vertical</property> <property name="spacing">2</property> <child internal-child="action_area"> <object class="GtkButtonBox" id="filechooserdialog-action_area1"> <property name="can_focus">False</property> <property name="layout_style">end</property> <child> <object class="GtkButton" id="button1"> <property name="label" translatable="yes">button</property> <property name="visible">True</property> <property name="can_focus">True</property> <property name="receives_default">True</property> <property name="use_action_appearance">False</property> </object> <packing> <property name="expand">False</property> <property name="fill">True</property> <property name="position">0</property> </packing> </child> <child> <object class="GtkButton" id="button2"> <property name="label" translatable="yes">button</property> <property name="visible">True</property> <property name="can_focus">True</property> <property name="receives_default">True</property> <property name="use_action_appearance">False</property> </object> <packing> <property name="expand">False</property> <property name="fill">True</property> <property name="position">1</property> </packing> </child> </object> <packing> <property name="expand">False</property> <property name="fill">True</property> <property name="pack_type">end</property> <property name="position">0</property> </packing> </child> <child> <object class="GtkLabel" id="label1"> <property name="visible">True</property> <property name="can_focus">False</property> <property name="label" translatable="yes">Hey Alex
Thanks for the new widget !
@jrs some fine tuning needed only it is caused by name$
but if you don't use "$" it compiles cleanly but a number is displayed the example widget expresses well how to convert C code to PROTO</property> <property name="wrap">True</property> </object> <packing> <property name="expand">False</property> <property name="fill">True</property> <property name="position">2</property> </packing> </child> </object> </child> <action-widgets> <action-widget response="0">button1</action-widget> <action-widget response="0">button2</action-widget> </action-widgets> </object> </interface> this is a basic gtk-builder code for it '@ alexfish Bacon Converter Forums
PRAGMA LDFLAGS `pkg-config --cflags --libs gtk+-3.0`
PROTO gtk_init PROTO gtk_builder_new PROTO gtk_builder_add_from_file PROTO gtk_builder_get_object PROTO g_signal_connect_data PROTO gtk_main_quit PROTO gtk_main
gtk_init(0, 0)
'===================== SUB exit_prog gtk_main_quit END SUB '======================
builder = gtk_builder_new () '@ change the path to the ui file gtk_builder_add_from_file (builder, "filechooser.ui", NULL) window = gtk_builder_get_object (builder, "filechooserdialog1") g_signal_connect_data(window, "delete-event", exit_prog, 0, 0, 0)
gtk_main HTH Forgot to mention : With Gtk-Builder U can use the gtk_builder_add_from_file as many times as U wish from within the main program: so if have already got builder code then all U do is , load it Can Remember someone Wanting some kind of lib This way Is so easy , one can make there own This file chooser was 5 clicks in Glade + copy and paste From this forum, then save as gtk builder, You can do all the main TOP Level dialog's in about 10 Minutes , think there are 11 in glade How much time will that save in coding ? + do not have to re-write code every time , just call the bits as mentioned. ADDED: For Those who have Puppy Linux and looking for Glade there is a link here www.murga-linux.com/puppy/viewtopic.php?t=74882BR Alex ADDED:: Link to GTK3 + GLADE .. should find most of what is needed HERE glade.gnome.org/
|
|
|
Post by bigbass on Apr 29, 2013 2:10:34 GMT 1
we need to have all stand alone GTK3 widgets converted to PROTO because when you want to add callbacks for example to glade having everything converted first gives you a good place to start when connecting the GUI to the BaCon code so a little at a time I will keep adding more widgets to the list code.google.com/p/bigbass-porteus/wiki/EmbedGtk3BaCon Here is a simple entry widget with the call back activated when you press enter
official source converted to PROTO developer.gnome.org/gnome-devel-demos/3.5/entry.c.html.en PRAGMA LDFLAGS `pkg-config --cflags --libs gtk+-3.0`PROTO gtk_init PROTO gtk_window_new PROTO gtk_main_quit PROTO g_signal_connect_data PROTO gtk_main PROTO gtk_container_add PROTO gtk_container_set_border_width PROTO gtk_widget_show_all PROTO gtk_window_set_default_size PROTO gtk_window_set_title PROTO gtk_entry_get_text PROTO gtk_entry_new
'======================= SUB EXIT_PROG() '======================= gtk_main_quit END SUB
'---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. '---when you press enter
'======================= SUB on_activate '======================= name$ = (char *)gtk_entry_get_text (entry_box) 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 () gtk_window_set_title (window, "To get the entry press enter") gtk_window_set_default_size (window, 350, 100) gtk_container_set_border_width (window, 10) g_signal_connect_data(window, "destroy", EXIT_PROG, 0, 0, 0)
'---Create a new entry box, and add it to the window entry_box = gtk_entry_new () gtk_container_add (window, entry_box)
'---Connecting the activate signal to the callback g_signal_connect_data (entry_box, "activate", on_activate,0,0,0)
gtk_widget_show_all (window) gtk_main
|
|
|
Post by bigbass on Apr 29, 2013 17:05:55 GMT 1
simple progress bar stepping A button click shows how a progress bar gets updated then reset to get a better understanding of what is going on one step at a time
PRAGMA LDFLAGS `pkg-config --cflags --libs gtk+-3.0`
PROTO gtk_init PROTO gtk_window_new PROTO gtk_main_quit PROTO gtk_main PROTO gtk_container_add PROTO gtk_grid_attach PROTO gtk_grid_attach_next_to PROTO gtk_progress_bar_pulse PROTO gtk_widget_show_all PROTO gtk_window_set_title PROTO gtk_application_new PROTO gtk_button_new_with_label PROTO gtk_grid_new PROTO gtk_progress_bar_new PROTO gtk_window_new PROTO g_signal_connect_data PROTO gtk_progress_bar_set_fraction PROTO gtk_progress_bar_get_fraction PROTO gtk_window_set_default_size
GTK_POS_BOTTOM = 3
fraction = 0.1
'---Signal handler for the "clicked" signal of the Button. Each '---click generates a progress bar pulse
SUB on_button_click
gtk_progress_bar_pulse (progress_bar)
'fraction = gtk_progress_bar_get_fraction (progress_bar)
'---Increase the bar by 10% each time this function is called '---Fill in the bar with the new fraction gtk_progress_bar_set_fraction (progress_bar, fraction)
fraction = fraction + 0.1 IF fraction >= 1 THEN fraction = 0 END IF
END SUB
'============== SUB EXIT_PROG '============== gtk_main_quit END SUB
gtk_init(0, 0)
'---Create the window and set a title 'window = gtk_application_window_new (app) window = gtk_window_new () gtk_window_set_title (window, "Progress Example") gtk_window_set_default_size (window, 270, 70) g_signal_connect_data(window, "destroy", EXIT_PROG, 0, 0, 0)
'---Create a button with a label button = gtk_button_new_with_label ("Button")
'---Create the progress bar progress_bar = gtk_progress_bar_new ()
'---Create a grid and attach the button and progress bar accordingly grid = gtk_grid_new () gtk_grid_attach (grid, button, 1, 1, 1, 1) gtk_grid_attach_next_to (grid, \ progress_bar, \ button, \ GTK_POS_BOTTOM, 1, 1)
'---Connecting the clicked signal to the callback function g_signal_connect_data (button, "clicked", on_button_click)
gtk_container_add (window, grid) gtk_widget_show_all (window) gtk_main
|
|
|
Post by bigbass on May 1, 2013 21:56:39 GMT 1
This is how to add a timeout to GTK3and use it with PROTOnow the progressbar auto updates automatically there wasn't a complete simple example so I had to make one I like pointer->free code PRAGMA LDFLAGS `pkg-config --cflags --libs gtk+-3.0`
PROTO gtk_init PROTO gtk_window_new PROTO gtk_main_quit PROTO gtk_main PROTO gtk_container_add PROTO gtk_grid_attach PROTO gtk_grid_attach_next_to PROTO gtk_progress_bar_pulse PROTO gtk_widget_show_all PROTO gtk_window_set_title PROTO gtk_application_new PROTO gtk_button_new_with_label PROTO gtk_grid_new PROTO gtk_progress_bar_new PROTO gtk_window_new PROTO g_signal_connect_data PROTO gtk_progress_bar_set_fraction PROTO gtk_progress_bar_get_fraction PROTO gtk_window_set_default_size PROTO g_timeout_add
GTK_POS_BOTTOM = 3
fraction = 0.1
'---How to use a time out to update a progress bar
'============================= FUNCTION timeout_callback '=============================
gtk_progress_bar_pulse (progress_bar)
'---Increase the bar by 10% each time this function is called
'---Fill in the bar with the new fraction gtk_progress_bar_set_fraction (progress_bar, fraction)
fraction = fraction + 0.1 IF fraction >= 1 THEN fraction = 0 END IF RETURN TRUE
END FUNCTION
'============== SUB EXIT_PROG '============== gtk_main_quit END SUB
gtk_init(0, 0)
'---Create the window and set a title window = gtk_window_new () gtk_window_set_title (window, "Progress Example") gtk_window_set_default_size (window, 270, 70) g_signal_connect_data(window, "destroy", EXIT_PROG, 0, 0, 0)
'---Create a button with a label button = gtk_button_new_with_label ("QUIT")
'---Create the progress bar progress_bar = gtk_progress_bar_new ()
'---Create a grid and attach the button and progress bar accordingly grid = gtk_grid_new () gtk_grid_attach (grid, button, 1, 1, 1, 1) gtk_grid_attach_next_to (grid, \ progress_bar, \ button, \ GTK_POS_BOTTOM, 1, 1)
'---Connecting the clicked signal to the callback function g_signal_connect_data (button, "clicked", EXIT_PROG)
g_timeout_add(500, timeout_callback, NULL) gtk_container_add (window, grid) gtk_widget_show_all (window) gtk_main
|
|