Puppy Linux Discussion Forum Forum Index Puppy Linux Discussion Forum
Puppy HOME page : puppylinux.com
"THE" alternative forum : puppylinux.info
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

The time now is Thu 28 Aug 2014, 07:12
All times are UTC - 4
 Forum index » Advanced Topics » Cutting edge
gtkbasic-0.0.2
Moderators: Flash, Ian, JohnMurga
Post new topic   Reply to topic View previous topic :: View next topic
Page 1 of 6 [78 Posts]   Goto page: 1, 2, 3, 4, 5, 6 Next
Author Message
MU


Joined: 24 Aug 2005
Posts: 13642
Location: Karlsruhe, Germany

PostPosted: Sat 05 May 2007, 17:11    Post subject:  gtkbasic-0.0.2  

download:

Puppy 3:
http://dotpups.de/puppy3/dotpups/Programming/Gtkbasic-002.pup

Puppy 2:
http://dotpups.de/dotpups/Programming/Gtkbasic-002.pup

If the fileselectors do not work in Puppy 2, try the Puppy 3 dotpup, but I did not test this combination yet.

----------------------

http://noforum.de/files/wxbasic/gtkbasic/

ginsbasic is a modified version of Puppybasic with new inbuilt functions written in C, based on "gins" by Fabrix ( http://freeweb.lombardiacom.it/kirsoft/gins.html )

License:
GPL (gins) and LGPL (Puppybasic)

The archive includes source and binary.
Extract it, and type "make install" to copy ginsbasic to /usr/bin

Then type "make test" to run a simple example.

The example is "testgins.pb":

Code:
#!/usr/bin/ginsbasic001


//-- load  file and show the window
gins_glade("test.glade")
gins_main()


//-- manipulate a widget, e.g. move the window
gins_set("window1" , "10" , "10" , "<uposition>")


//-- get information about a widget
a = gins_get("button1" , "label" , "<str>")
print a


//-- mainloop with eventhandling
while 1

  widget , event , pdata = gins_event()

  if widget != Nothing then
    print widget
    print event
    print pdata

    if event = "GDK_DELETE" then
      gins_exit()
      end
    end if

  end if

  xwin_usleep(10000)

wend


And this is test.glade, a window with a button:
Code:

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE glade-interface SYSTEM "glade-2.0.dtd">
<!--Generated with glade3 3.0.3 on Sat May  5 18:12:54 2007 by root@puppypc-->
<glade-interface>
  <widget class="GtkWindow" id="window1">
  <property name="visible">True</property>
    <child>
      <widget class="GtkVBox" id="vbox1">
        <property name="visible">True</property>
        <child>
          <widget class="GtkButton" id="button1">
            <property name="visible">True</property>
            <property name="label" translatable="yes">button</property>
          </widget>
        </child>
      </widget>
    </child>
  </widget>
</glade-interface>


I created it with Glade, and just added by hand this line:
Quote:
<property name="visible">True</property>


This should make development pretty easy.
I used the sourcecode of Puppybasic 2.5 and the (inofficial) gins 0.9.1, see:
http://www.puppyos.net/forum/azbb.php?1172392169;4

I also activated again all events, that were disabled by BradChuck.
As gins now is a set of inbuilt C-functions in Puppybasic, it is more responsive than communicating using shell-commands.
So the eventhandling should also work on old computers. Please tell me, if this is correct.

Mark

Last edited by MU on Fri 09 Nov 2007, 14:39; edited 6 times in total
Back to top
View user's profile Send private message Visit poster's website 
klhrevolutionist


Joined: 08 Jun 2005
Posts: 1124

PostPosted: Sat 05 May 2007, 17:27    Post subject:  

This is a really good idea ! So for those who know puppybasic they can now fool with gins when & if the need arises. Great way to keep the community on a single track.
_________________
Heaven is on the way, until then let's get the truth out!
Back to top
View user's profile Send private message 
MU


Joined: 24 Aug 2005
Posts: 13642
Location: Karlsruhe, Germany

PostPosted: Sun 06 May 2007, 01:27    Post subject:  

I updated the archive, it now includes a small calculator written in ginsbasic.

Screenshot:


You can run it like this:

./calc.pb

You also can load calc.glade in Glade to edit the Window-layout.

Mark

Last edited by MU on Fri 18 May 2007, 20:52; edited 1 time in total
Back to top
View user's profile Send private message Visit poster's website 
Pizzasgood


Joined: 04 May 2005
Posts: 6270
Location: Knoxville, TN, USA

PostPosted: Sun 06 May 2007, 12:02    Post subject:  

Does this work with stuff like the file-select dialogs? I was trying to use gins through Bash a couple weeks ago, but I couldn't make the file-select work and had to call it quits for a while.
_________________
Between depriving a man of one hour from his life and depriving him of his life there exists only a difference of degree. --Muad'Dib

Back to top
View user's profile Send private message Visit poster's website 
MU


Joined: 24 Aug 2005
Posts: 13642
Location: Karlsruhe, Germany

PostPosted: Sun 06 May 2007, 18:21    Post subject:  

ok, this was a bit "pain in the ass", but I had to do it anyway.

Yes, Glade has a widget FileChooserbutton.
You drag it on your Windowlayout, and if you run the program, a fileselection opens, if you click on that button.

BUT: the chosen file is no "attribute" that gins could handle.
This will NOT work:
thefile = gins_get("filechooserbutton1" , "filename" , "<str>")

Instead, the filename must be found out with a native Gtk-function.
(
this helped me:
http://lists.ximian.com/pipermail/glade-users/2006-June/002989.html
https://stage.maemo.org/svn/maemo/projects/haf/trunk/gtk+/ChangeLog.gtk-async-file-chooser
)

A programmer certainly will encounter such a problem more often, so I decided to write a function:
gins_gtkwidgetfunction( widgetname , Gtkfunction )

This currently just supports 2 Gtk-functions:
"gtk_file_chooser_get_current_folder"
"gtk_file_chooser_get_filename"

But my C-code is pretty simple, and could quickly be enhanced on request:
(from gins.c):
Code:

//////////////////////

// here a LOT of GTK functions can be added...


   if (strncmp(thefunction,"gtk_file_chooser_get_current_folder", 34)==0) {
      resultbuffer = gtk_file_chooser_get_current_folder(GTK_FILE_CHOOSER(obj));
      sprintf(result , "%s" , resultbuffer);
   }

   if (strncmp(thefunction,"gtk_file_chooser_get_filename", 28)==0) {
      resultbuffer = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(obj));
      sprintf(result , "%s" , resultbuffer);
   }


So adding more of them will be important for further versions of ginsbasic.

I updated the archive with a small example:
./testfilechooser.pb

Version still is 001, as I am too tired to add versioning to the makefile (ToDo).

Good night, Mark
Back to top
View user's profile Send private message Visit poster's website 
MU


Joined: 24 Aug 2005
Posts: 13642
Location: Karlsruhe, Germany

PostPosted: Mon 07 May 2007, 21:19    Post subject:  

I updated the archive, the syntax of gins_gtkwidgetfunction changed:
gins_gtkwidgetfunction( widgetname , Gtkfunction , arg1 , arg2)

I think in the next version I will rename it to simply "gins_gtk()".

So you can pass up to 2 arguments.
If you need no argument, set 0 instead.

Example:

a = gins_gtkwidgetfunction("label1" , "gtk_label_set_selectable" , "1" , 0)

It calls gtk_label_set_selectable with the value 1, so activates the textselection of a label.
a will be "Nothing", as that function returns no value (returnvalue is "void", which means nothing is returned).
You also could leave away "a=" here, I just use it to show the general usage.
http://developer.gnome.org/doc/API/2.0/gtk/GtkLabel.html

It can be tested with
./testgtkfunctions.pb

After you click on the button, you can select text of the label.

With the current changes I prepared ginsbasic for the next step (not done yet).
This will be a script, that parses the Gtk-documentation, and generates C functions for gins.c, so that you can access all compatible Gtk functions.

This will cover most functions, only few need special treatment, like those returning arrays. That would follow somewhen later then.

Mark
Back to top
View user's profile Send private message Visit poster's website 
BarryK
Puppy Master


Joined: 09 May 2005
Posts: 7047
Location: Perth, Western Australia

PostPosted: Mon 07 May 2007, 23:22    Post subject:  

Mark, I have looked at ginsbasic001, the calc.pb example does not work for me. The buttons display but when a button is pressed nothing displays.
Back to top
View user's profile Send private message Visit poster's website 
MU


Joined: 24 Aug 2005
Posts: 13642
Location: Karlsruhe, Germany

PostPosted: Tue 08 May 2007, 02:22    Post subject:  

modify calc.glade

Code:
            <property name="sensitive">False</property>

to
Code:
            <property name="sensitive">True</property>


Maybe your theme just does use wrong colors.

Or in calc.pb:

replace
Code:
 if event = "GDK_BUTTON_PRESS" then
   ' print widget
   ' print event
   ' print pdata


with
Quote:

if event = "GDK_BUTTON_PRESS" then
print widget
print event
print pdata


This will show, if the eventhandling works.
It will write them to the xterm.

or line 61
Code:
        gins_set("entry1" , "text" , n & widget , "<str>")


Code:
        gins_set("entry1" , "text" , n & widget , "<str>")
print n & widget


this should print the numbers to the xterm.

These changes should help to encircle your error.

Mark
Back to top
View user's profile Send private message Visit poster's website 
Pizzasgood


Joined: 04 May 2005
Posts: 6270
Location: Knoxville, TN, USA

PostPosted: Tue 08 May 2007, 19:44    Post subject:  

Grrr. Now I don't have an excuse not to get back to work Smile
_________________
Between depriving a man of one hour from his life and depriving him of his life there exists only a difference of degree. --Muad'Dib

Back to top
View user's profile Send private message Visit poster's website 
MU


Joined: 24 Aug 2005
Posts: 13642
Location: Karlsruhe, Germany

PostPosted: Fri 11 May 2007, 18:09    Post subject:  

I updated the archive, but you can ignore that unless you are a C-coder who is curious about what will/might come.
Just unfinished teststuff.
Details:
http://wxbasic.sourceforge.net/phpBB2/viewtopic.php?p=5250#5250

Mark
Back to top
View user's profile Send private message Visit poster's website 
MU


Joined: 24 Aug 2005
Posts: 13642
Location: Karlsruhe, Germany

PostPosted: Sat 12 May 2007, 22:40    Post subject:  

updated the archive.
It now includes
./___build_new_ginsbasic

This is a shellscript, that launches some other ones, and then compiles ginsbasic.

The "other ones" will scan the Gtk documentation, and build a new gins.c.

The path to the gtk-documentation must be set in "_html2func.pb".
In this file you also can set, which pages are scanned.

The current functionlist does not cover everything, but these:

Code:
 
 a =  gtk_set_locale (  0 , 0 , 0 , 0 , 0 , 0 )
 gtk_disable_setlocale (  0 , 0 , 0 , 0 , 0 , 0 )
 gtk_exit ( gint error_code , 0 , 0 , 0 , 0 , 0 )
 a =  gtk_events_pending (  0 , 0 , 0 , 0 , 0 , 0 )
 gtk_main (  0 , 0 , 0 , 0 , 0 , 0 )
 gtk_main_quit (  0 , 0 , 0 , 0 , 0 , 0 )
 a =  gtk_main_iteration (  0 , 0 , 0 , 0 , 0 , 0 )
 a =  gtk_main_iteration_do ( gboolean blocking , 0 , 0 , 0 , 0 , 0 )
 gtk_main_do_event ( GDK_EVENT *event , 0 , 0 , 0 , 0 , 0 )
 a =  gtk_true (  0 , 0 , 0 , 0 , 0 , 0 )
 a =  gtk_false (  0 , 0 , 0 , 0 , 0 , 0 )
 gtk_grab_add ( GTK_WIDGET *widget , 0 , 0 , 0 , 0 , 0 )
 gtk_grab_remove ( GTK_WIDGET *widget , 0 , 0 , 0 , 0 , 0 )
 gtk_quit_remove ( guint quit_handler_id , 0 , 0 , 0 , 0 , 0 )
 gtk_quit_remove_by_data ( gpointer data , 0 , 0 , 0 , 0 , 0 )
 gtk_timeout_remove ( guint timeout_handler_id , 0 , 0 , 0 , 0 , 0 )
 gtk_idle_remove ( guint idle_handler_id , 0 , 0 , 0 , 0 , 0 )
 gtk_idle_remove_by_data ( gpointer data , 0 , 0 , 0 , 0 , 0 )
 gtk_input_remove ( guint input_handler_id , 0 , 0 , 0 , 0 , 0 )
 gtk_key_snooper_remove ( guint snooper_handler_id , 0 , 0 , 0 , 0 , 0 )
 a =  gtk_get_current_event_state ( GDK_MODIFIER_TYPE *state , 0 , 0 , 0 , 0 , 0 )
 gtk_accel_group_lock ( GTK_ACCEL_GROUP *accel_group , 0 , 0 , 0 , 0 , 0 )
 gtk_accel_group_unlock ( GTK_ACCEL_GROUP *accel_group , 0 , 0 , 0 , 0 , 0 )
 gtk_drag_dest_unset ( GTK_WIDGET *widget , 0 , 0 , 0 , 0 , 0 )
 gtk_drag_dest_add_text_targets ( GTK_WIDGET *widget , 0 , 0 , 0 , 0 , 0 )
 gtk_drag_dest_add_image_targets ( GTK_WIDGET *widget , 0 , 0 , 0 , 0 , 0 )
 gtk_drag_dest_add_uri_targets ( GTK_WIDGET *widget , 0 , 0 , 0 , 0 , 0 )
 gtk_drag_highlight ( GTK_WIDGET *widget , 0 , 0 , 0 , 0 , 0 )
 gtk_drag_unhighlight ( GTK_WIDGET *widget , 0 , 0 , 0 , 0 , 0 )
 gtk_drag_set_icon_stock ( GDK_DRAG_CONTEXT *context , const gchar *stock_id , gint hot_x , gint hot_y , 0 , 0 )
 gtk_drag_set_icon_name ( GDK_DRAG_CONTEXT *context , const gchar *icon_name , gint hot_x , gint hot_y , 0 , 0 )
 gtk_drag_set_icon_default ( GDK_DRAG_CONTEXT *context , 0 , 0 , 0 , 0 , 0 )
 a =  gtk_drag_check_threshold ( GTK_WIDGET *widget , gint start_x , gint start_y , gint current_x , gint current_y , 0 )
 gtk_drag_source_set_icon_stock ( GTK_WIDGET *widget , const gchar *stock_id , 0 , 0 , 0 , 0 )
 gtk_drag_source_set_icon_name ( GTK_WIDGET *widget , const gchar *icon_name , 0 , 0 , 0 , 0 )
 gtk_drag_source_unset ( GTK_WIDGET *widget , 0 , 0 , 0 , 0 , 0 )
 gtk_drag_source_add_text_targets ( GTK_WIDGET *widget , 0 , 0 , 0 , 0 , 0 )
 gtk_drag_source_add_image_targets ( GTK_WIDGET *widget , 0 , 0 , 0 , 0 , 0 )
 gtk_drag_source_add_uri_targets ( GTK_WIDGET *widget , 0 , 0 , 0 , 0 , 0 )
 gtk_icon_theme_set_search_path ( GTK_ICON_THEME *icon_theme , const gchar *path[] , gint n_elements , 0 , 0 , 0 )
 gtk_icon_theme_get_search_path ( GTK_ICON_THEME *icon_theme , gchar **path[] , gint *n_elements , 0 , 0 , 0 )
 gtk_icon_theme_append_search_path ( GTK_ICON_THEME *icon_theme , const gchar *path , 0 , 0 , 0 , 0 )
 gtk_icon_theme_prepend_search_path ( GTK_ICON_THEME *icon_theme , const gchar *path , 0 , 0 , 0 , 0 )
 gtk_icon_theme_set_custom_theme ( GTK_ICON_THEME *icon_theme , const gchar *theme_name , 0 , 0 , 0 , 0 )
 a =  gtk_icon_theme_has_icon ( GTK_ICON_THEME *icon_theme , const gchar *icon_name , 0 , 0 , 0 , 0 )
 a =  gtk_icon_theme_rescan_if_needed ( GTK_ICON_THEME *icon_theme , 0 , 0 , 0 , 0 , 0 )
 gtk_icon_info_free ( GTK_ICON_INFO *icon_info , 0 , 0 , 0 , 0 , 0 )
 a =  gtk_icon_info_get_filename ( GTK_ICON_INFO *icon_info , 0 , 0 , 0 , 0 , 0 )
 gtk_icon_info_set_raw_coordinates ( GTK_ICON_INFO *icon_info , gboolean raw_coordinates , 0 , 0 , 0 , 0 )
 a =  gtk_icon_info_get_display_name ( GTK_ICON_INFO *icon_info , 0 , 0 , 0 , 0 , 0 )
 gtk_clipboard_clear ( GTK_CLIPBOARD *clipboard , 0 , 0 , 0 , 0 , 0 )
 gtk_clipboard_set_text ( GTK_CLIPBOARD *clipboard , const gchar *text , gint len , 0 , 0 , 0 )
 a =  gtk_clipboard_wait_for_text ( GTK_CLIPBOARD *clipboard , 0 , 0 , 0 , 0 , 0 )
 a =  gtk_clipboard_wait_is_text_available ( GTK_CLIPBOARD *clipboard , 0 , 0 , 0 , 0 , 0 )
 a =  gtk_clipboard_wait_is_image_available ( GTK_CLIPBOARD *clipboard , 0 , 0 , 0 , 0 , 0 )
 gtk_clipboard_store ( GTK_CLIPBOARD *clipboard , 0 , 0 , 0 , 0 , 0 )
 gtk_rc_add_widget_name_style ( GTK_RC_STYLE *rc_style , const gchar *pattern , 0 , 0 , 0 , 0 )
 gtk_rc_add_widget_class_style ( GTK_RC_STYLE *rc_style , const gchar *pattern , 0 , 0 , 0 , 0 )
 gtk_rc_add_class_style ( GTK_RC_STYLE *rc_style , const gchar *pattern , 0 , 0 , 0 , 0 )
 gtk_rc_parse ( const gchar *filename , 0 , 0 , 0 , 0 , 0 )
 gtk_rc_parse_string ( const gchar *rc_string , 0 , 0 , 0 , 0 , 0 )
 a =  gtk_rc_reparse_all (  0 , 0 , 0 , 0 , 0 , 0 )
 a =  gtk_rc_reparse_all_for_settings ( GTK_SETTINGS *settings , gboolean force_load , 0 , 0 , 0 , 0 )
 gtk_rc_reset_styles ( GTK_SETTINGS *settings , 0 , 0 , 0 , 0 , 0 )
 gtk_rc_add_default_file ( const gchar *filename , 0 , 0 , 0 , 0 , 0 )
 gtk_rc_set_default_files ( gchar **filenames , 0 , 0 , 0 , 0 , 0 )
 a =  gtk_rc_find_module_in_path ( const gchar *module_file , 0 , 0 , 0 , 0 , 0 )
 a =  gtk_rc_get_module_dir (  0 , 0 , 0 , 0 , 0 , 0 )
 a =  gtk_rc_get_im_module_path (  0 , 0 , 0 , 0 , 0 , 0 )
 a =  gtk_rc_get_im_module_file (  0 , 0 , 0 , 0 , 0 , 0 )
 a =  gtk_rc_get_theme_dir (  0 , 0 , 0 , 0 , 0 , 0 )
 gtk_rc_style_ref ( GTK_RC_STYLE *rc_style , 0 , 0 , 0 , 0 , 0 )
 gtk_rc_style_unref ( GTK_RC_STYLE *rc_style , 0 , 0 , 0 , 0 , 0 )
 a =  gtk_check_version ( guint required_major , guint required_minor , guint required_micro , 0 , 0 , 0 )
 gtk_label_set_text ( GTK_LABEL *label , const gchar *str , 0 , 0 , 0 , 0 )
 gtk_label_set_markup ( GTK_LABEL *label , const gchar *str , 0 , 0 , 0 , 0 )
 gtk_label_set_markup_with_mnemonic ( GTK_LABEL *label , const gchar *str , 0 , 0 , 0 , 0 )
 gtk_label_set_pattern ( GTK_LABEL *label , const gchar *pattern , 0 , 0 , 0 , 0 )
 gtk_label_set_width_chars ( GTK_LABEL *label , gint n_chars , 0 , 0 , 0 , 0 )
 gtk_label_set_max_width_chars ( GTK_LABEL *label , gint n_chars , 0 , 0 , 0 , 0 )
 gtk_label_get ( GTK_LABEL *label , gchar **str , 0 , 0 , 0 , 0 )
 gtk_label_set_line_wrap ( GTK_LABEL *label , gboolean wrap , 0 , 0 , 0 , 0 )
 gtk_label_get_layout_offsets ( GTK_LABEL *label , gint *x , gint *y , 0 , 0 , 0 )
 a =  gtk_label_get_selectable ( GTK_LABEL *label , 0 , 0 , 0 , 0 , 0 )
 a =  gtk_label_get_text ( GTK_LABEL *label , 0 , 0 , 0 , 0 , 0 )
 gtk_label_select_region ( GTK_LABEL *label , gint start_offset , gint end_offset , 0 , 0 , 0 )
 gtk_label_set_selectable ( GTK_LABEL *label , gboolean setting , 0 , 0 , 0 , 0 )
 gtk_label_set_text_with_mnemonic ( GTK_LABEL *label , const gchar *str , 0 , 0 , 0 , 0 )
 a =  gtk_label_get_label ( GTK_LABEL *label , 0 , 0 , 0 , 0 , 0 )
 a =  gtk_label_get_line_wrap ( GTK_LABEL *label , 0 , 0 , 0 , 0 , 0 )
 a =  gtk_label_get_selection_bounds ( GTK_LABEL *label , gint *start , gint *end , 0 , 0 , 0 )
 a =  gtk_label_get_use_markup ( GTK_LABEL *label , 0 , 0 , 0 , 0 , 0 )
 a =  gtk_label_get_use_underline ( GTK_LABEL *label , 0 , 0 , 0 , 0 , 0 )
 a =  gtk_label_get_single_line_mode ( GTK_LABEL *label , 0 , 0 , 0 , 0 , 0 )
 a =  gtk_label_get_angle ( GTK_LABEL *label , 0 , 0 , 0 , 0 , 0 )
 gtk_label_set_label ( GTK_LABEL *label , const gchar *str , 0 , 0 , 0 , 0 )
 gtk_label_set_use_markup ( GTK_LABEL *label , gboolean setting , 0 , 0 , 0 , 0 )
 gtk_label_set_use_underline ( GTK_LABEL *label , gboolean setting , 0 , 0 , 0 , 0 )
 gtk_label_set_single_line_mode ( GTK_LABEL *label , gboolean single_line_mode , 0 , 0 , 0 , 0 )
 gtk_label_set_angle ( GTK_LABEL *label , gdouble angle , 0 , 0 , 0 , 0 )
 gtk_button_pressed ( GTK_BUTTON *button , 0 , 0 , 0 , 0 , 0 )
 gtk_button_released ( GTK_BUTTON *button , 0 , 0 , 0 , 0 , 0 )
 gtk_button_clicked ( GTK_BUTTON *button , 0 , 0 , 0 , 0 , 0 )
 gtk_button_enter ( GTK_BUTTON *button , 0 , 0 , 0 , 0 , 0 )
 gtk_button_leave ( GTK_BUTTON *button , 0 , 0 , 0 , 0 , 0 )
 a =  gtk_button_get_label ( GTK_BUTTON *button , 0 , 0 , 0 , 0 , 0 )
 gtk_button_set_label ( GTK_BUTTON *button , const gchar *label , 0 , 0 , 0 , 0 )
 a =  gtk_button_get_use_stock ( GTK_BUTTON *button , 0 , 0 , 0 , 0 , 0 )
 gtk_button_set_use_stock ( GTK_BUTTON *button , gboolean use_stock , 0 , 0 , 0 , 0 )
 a =  gtk_button_get_use_underline ( GTK_BUTTON *button , 0 , 0 , 0 , 0 , 0 )
 gtk_button_set_use_underline ( GTK_BUTTON *button , gboolean use_underline , 0 , 0 , 0 , 0 )
 gtk_button_set_focus_on_click ( GTK_BUTTON *button , gboolean focus_on_click , 0 , 0 , 0 , 0 )
 a =  gtk_button_get_focus_on_click ( GTK_BUTTON *button , 0 , 0 , 0 , 0 , 0 )
 gtk_button_set_alignment ( GTK_BUTTON *button , gfloat xalign , gfloat yalign , 0 , 0 , 0 )
 gtk_button_get_alignment ( GTK_BUTTON *button , gfloat *xalign , gfloat *yalign , 0 , 0 , 0 )
 gtk_file_chooser_set_local_only ( GTK_FILE_CHOOSER *chooser , gboolean local_only , 0 , 0 , 0 , 0 )
 a =  gtk_file_chooser_get_local_only ( GTK_FILE_CHOOSER *chooser , 0 , 0 , 0 , 0 , 0 )
 gtk_file_chooser_set_select_multiple ( GTK_FILE_CHOOSER *chooser , gboolean select_multiple , 0 , 0 , 0 , 0 )
 a =  gtk_file_chooser_get_select_multiple ( GTK_FILE_CHOOSER *chooser , 0 , 0 , 0 , 0 , 0 )
 gtk_file_chooser_set_show_hidden ( GTK_FILE_CHOOSER *chooser , gboolean show_hidden , 0 , 0 , 0 , 0 )
 a =  gtk_file_chooser_get_show_hidden ( GTK_FILE_CHOOSER *chooser , 0 , 0 , 0 , 0 , 0 )
 gtk_file_chooser_set_do_overwrite_confirmation ( GTK_FILE_CHOOSER *chooser , gboolean do_overwrite_confirmation , 0 , 0 , 0 , 0 )
 a =  gtk_file_chooser_get_do_overwrite_confirmation ( GTK_FILE_CHOOSER *chooser , 0 , 0 , 0 , 0 , 0 )
 gtk_file_chooser_set_current_name ( GTK_FILE_CHOOSER *chooser , const gchar *name , 0 , 0 , 0 , 0 )
 a =  gtk_file_chooser_get_filename ( GTK_FILE_CHOOSER *chooser , 0 , 0 , 0 , 0 , 0 )
 gtk_file_chooser_select_all ( GTK_FILE_CHOOSER *chooser , 0 , 0 , 0 , 0 , 0 )
 gtk_file_chooser_unselect_all ( GTK_FILE_CHOOSER *chooser , 0 , 0 , 0 , 0 , 0 )
 a =  gtk_file_chooser_set_current_folder ( GTK_FILE_CHOOSER *chooser , const gchar *filename , 0 , 0 , 0 , 0 )
 a =  gtk_file_chooser_get_current_folder ( GTK_FILE_CHOOSER *chooser , 0 , 0 , 0 , 0 , 0 )
 a =  gtk_file_chooser_get_uri ( GTK_FILE_CHOOSER *chooser , 0 , 0 , 0 , 0 , 0 )
 a =  gtk_file_chooser_set_current_folder_uri ( GTK_FILE_CHOOSER *chooser , const gchar *uri , 0 , 0 , 0 , 0 )
 a =  gtk_file_chooser_get_current_folder_uri ( GTK_FILE_CHOOSER *chooser , 0 , 0 , 0 , 0 , 0 )
 gtk_file_chooser_set_preview_widget_active ( GTK_FILE_CHOOSER *chooser , gboolean active , 0 , 0 , 0 , 0 )
 a =  gtk_file_chooser_get_preview_widget_active ( GTK_FILE_CHOOSER *chooser , 0 , 0 , 0 , 0 , 0 )
 gtk_file_chooser_set_use_preview_label ( GTK_FILE_CHOOSER *chooser , gboolean use_label , 0 , 0 , 0 , 0 )
 a =  gtk_file_chooser_get_use_preview_label ( GTK_FILE_CHOOSER *chooser , 0 , 0 , 0 , 0 , 0 )
 a =  gtk_file_chooser_button_get_title ( GTK_FILE_CHOOSER_BUTTON *button , 0 , 0 , 0 , 0 , 0 )
 gtk_file_chooser_button_set_title ( GTK_FILE_CHOOSER_BUTTON *button , const gchar *title , 0 , 0 , 0 , 0 )
 gtk_file_chooser_button_set_width_chars ( GTK_FILE_CHOOSER_BUTTON *button , gint n_chars , 0 , 0 , 0 , 0 )
 gtk_file_selection_set_filename ( GTK_FILE_SELECTION *filesel , const gchar *filename , 0 , 0 , 0 , 0 )
 a =  gtk_file_selection_get_filename ( GTK_FILE_SELECTION *filesel , 0 , 0 , 0 , 0 , 0 )
 gtk_file_selection_complete ( GTK_FILE_SELECTION *filesel , const gchar *pattern , 0 , 0 , 0 , 0 )
 gtk_file_selection_show_fileop_buttons ( GTK_FILE_SELECTION *filesel , 0 , 0 , 0 , 0 , 0 )
 gtk_file_selection_hide_fileop_buttons ( GTK_FILE_SELECTION *filesel , 0 , 0 , 0 , 0 , 0 )
 gtk_file_selection_set_select_multiple ( GTK_FILE_SELECTION *filesel , gboolean select_multiple , 0 , 0 , 0 , 0 )
 a =  gtk_file_selection_get_select_multiple ( GTK_FILE_SELECTION *filesel , 0 , 0 , 0 , 0 , 0 )
 gtk_color_button_set_use_alpha ( GTK_COLOR_BUTTON *color_button , gboolean use_alpha , 0 , 0 , 0 , 0 )
 a =  gtk_color_button_get_use_alpha ( GTK_COLOR_BUTTON *color_button , 0 , 0 , 0 , 0 , 0 )
 gtk_color_button_set_title ( GTK_COLOR_BUTTON *color_button , const gchar *title , 0 , 0 , 0 , 0 )
 a =  gtk_color_button_get_title ( GTK_COLOR_BUTTON *color_button , 0 , 0 , 0 , 0 , 0 )
 a =  gtk_text_view_place_cursor_onscreen ( GTK_TEXT_VIEW *text_view , 0 , 0 , 0 , 0 , 0 )
 a =  gtk_text_child_anchor_get_deleted ( GTK_TEXT_CHILD_ANCHOR *anchor , 0 , 0 , 0 , 0 , 0 )
 gtk_text_view_set_editable ( GTK_TEXT_VIEW *text_view , gboolean setting , 0 , 0 , 0 , 0 )
 a =  gtk_text_view_get_editable ( GTK_TEXT_VIEW *text_view , 0 , 0 , 0 , 0 , 0 )
 gtk_text_view_set_cursor_visible ( GTK_TEXT_VIEW *text_view , gboolean setting , 0 , 0 , 0 , 0 )
 a =  gtk_text_view_get_cursor_visible ( GTK_TEXT_VIEW *text_view , 0 , 0 , 0 , 0 , 0 )
 gtk_text_view_set_overwrite ( GTK_TEXT_VIEW *text_view , gboolean overwrite , 0 , 0 , 0 , 0 )
 a =  gtk_text_view_get_overwrite ( GTK_TEXT_VIEW *text_view , 0 , 0 , 0 , 0 , 0 )
 gtk_text_view_set_pixels_above_lines ( GTK_TEXT_VIEW *text_view , gint pixels_above_lines , 0 , 0 , 0 , 0 )
 gtk_text_view_set_pixels_below_lines ( GTK_TEXT_VIEW *text_view , gint pixels_below_lines , 0 , 0 , 0 , 0 )
 gtk_text_view_set_pixels_inside_wrap ( GTK_TEXT_VIEW *text_view , gint pixels_inside_wrap , 0 , 0 , 0 , 0 )
 gtk_text_view_set_left_margin ( GTK_TEXT_VIEW *text_view , gint left_margin , 0 , 0 , 0 , 0 )
 gtk_text_view_set_right_margin ( GTK_TEXT_VIEW *text_view , gint right_margin , 0 , 0 , 0 , 0 )
 gtk_text_view_set_indent ( GTK_TEXT_VIEW *text_view , gint indent , 0 , 0 , 0 , 0 )
 gtk_text_view_set_accepts_tab ( GTK_TEXT_VIEW *text_view , gboolean accepts_tab , 0 , 0 , 0 , 0 )
 a =  gtk_text_view_get_accepts_tab ( GTK_TEXT_VIEW *text_view , 0 , 0 , 0 , 0 , 0 )
 gtk_entry_set_text ( GTK_ENTRY *entry , const gchar *text , 0 , 0 , 0 , 0 )
 gtk_entry_append_text ( GTK_ENTRY *entry , const gchar *text , 0 , 0 , 0 , 0 )
 gtk_entry_prepend_text ( GTK_ENTRY *entry , const gchar *text , 0 , 0 , 0 , 0 )
 gtk_entry_set_position ( GTK_ENTRY *entry , gint position , 0 , 0 , 0 , 0 )
 a =  gtk_entry_get_text ( GTK_ENTRY *entry , 0 , 0 , 0 , 0 , 0 )
 gtk_entry_select_region ( GTK_ENTRY *entry , gint start , gint end , 0 , 0 , 0 )
 gtk_entry_set_visibility ( GTK_ENTRY *entry , gboolean visible , 0 , 0 , 0 , 0 )
 gtk_entry_set_editable ( GTK_ENTRY *entry , gboolean editable , 0 , 0 , 0 , 0 )
 gtk_entry_set_max_length ( GTK_ENTRY *entry , gint max , 0 , 0 , 0 , 0 )
 a =  gtk_entry_get_activates_default ( GTK_ENTRY *entry , 0 , 0 , 0 , 0 , 0 )
 a =  gtk_entry_get_has_frame ( GTK_ENTRY *entry , 0 , 0 , 0 , 0 , 0 )
 gtk_entry_set_activates_default ( GTK_ENTRY *entry , gboolean setting , 0 , 0 , 0 , 0 )
 gtk_entry_set_has_frame ( GTK_ENTRY *entry , gboolean setting , 0 , 0 , 0 , 0 )
 gtk_entry_set_width_chars ( GTK_ENTRY *entry , gint n_chars , 0 , 0 , 0 , 0 )
 gtk_entry_set_alignment ( GTK_ENTRY *entry , gfloat xalign , 0 , 0 , 0 , 0 )
 gtk_entry_get_layout_offsets ( GTK_ENTRY *entry , gint *x , gint *y , 0 , 0 , 0 )
 a =  gtk_entry_get_visibility ( GTK_ENTRY *entry , 0 , 0 , 0 , 0 , 0 )
 


Not every function might work, some might crash ginsbasic due to conversion-errors. But most incompatible ones are already sorted out automatically.
Note that the syntax changed:
now it is:
Code:

 //-- this function uses no Glade widget,
//-- so the first argument is a value instead of a widgetname

a = gins_gtkwidgetfunction( "gtk_check_version", "2" , "9" , "0" ,0 ,0 ,0)


or:
Code:

//-- "label1" is the name of the label you created with Glade

a = gins_gtkwidgetfunction( "gtk_label_get_text" ,"label1" , 0 , 0 ,0 ,0 ,0)


I'm sorry for this, but this is under heavy development, so there might be more changes in future.
But I hope, like this now I have more or less the final syntax.

Mark
Back to top
View user's profile Send private message Visit poster's website 
MU


Joined: 24 Aug 2005
Posts: 13642
Location: Karlsruhe, Germany

PostPosted: Sun 13 May 2007, 13:48    Post subject:  

More updates.
Imported more functions to manage windows, entry and Textview.

The Textview was a real problem, and is not solved finally yet.
But for simple things it can be used already.

The problem is, that Puppybasic cannot pass back GObjects.
Puppybasic uses as every Basic automatic type-conversion, so you don't need to care about int or char or other difficult things.
The disadvantage is, that it is not easy to add new types like Gobjects to the interpreter (not for me at least).

The Textview uses a GtkTextBuffer and GtkTextIterators to handle things like selecting text, so as I cannot handle them directly, I had to add some wrappers, that use some "fixed" Objects. This still can be enhanced.
But keep in mind, ginsbasic is not indended to replace Perl or Java.
If you want to write a full-featured texteditor like Geany, you need those languages or C/C++ or similar.

But for small tools, the included testprograms will provide you with examples you can use and enhance in own projects.

That's it for this weekend, during the week at work I have no time to continue (except if you request something specific).

I'll attach a picture (the "red" is made by parsing one of Barrys Themefiles Smile )

I also add the current functionlist.
Again, some of themmight crash or simply not work, as type-conversion is not checked in detail.

Time to sleep soon, after around 26 hours of programming without sleep Wink

Mark

Picture:



Functions (324):

Note that the "ginswrap" values can be anything like "dummy", as ginsbasic will ignore them, and use "fixed" internal objects instead.
This list is generated automatically by my scripts.
"gint" and gfloat are numbers (like "215"), gchar are strings (like "abc").
gboolean is "0" or "1".
The list just shows that, to make it easier to see, if a number or string is expected, ginsbasic internally handles them all as "variant", a type that represents them all.

***removed, outdated***

Last edited by MU on Fri 18 May 2007, 20:54; edited 1 time in total
Back to top
View user's profile Send private message Visit poster's website 
Jesse

Joined: 08 May 2005
Posts: 465
Location: Auckland, NZ

PostPosted: Sun 13 May 2007, 17:21    Post subject:  

Hi MU,

can you clarify a point? are all the functions you've listed (intended to be) directly accessable from the gins-basic script?, or are these things that you are adding into gins?

I had a look into gins, and it seems nice but overly simplified, I doesn't appear to have add/remove components on the fly. If it had these two simple commands added it would be a lot more fun and hugely more flexible for the slightly more dynamic gui-application.

Jesse
Back to top
View user's profile Send private message 
MU


Joined: 24 Aug 2005
Posts: 13642
Location: Karlsruhe, Germany

PostPosted: Sun 13 May 2007, 17:50    Post subject:  

In Perl or C you can do stuff like:

window1 = new GtkWindow();
window1.resize( 100 , 200);


This would not work in ginsbasic, as "window1" here is a reference to a Gtk-Object.
Ginsbasic just knows standart types like "string".

So it uses the libglade-functions, that I learned from gins (hence ginsbasic).
You load an XML-file, and gins does the internal handling of those objects.

If your XML-file has a window "window1", you now can access it (indirectly) from Basic by its name (but not directly as an object).

//-- load all widgets
gins_glade("testtextview.glade")
//-- access them with direct Gtk-API calls.
gins_gtkwidgetfunction("gtk_window_resize" ,"window1" , "300" , "300", 0,0,0)

Gins will determine the Gtkobject from that name, and then we can run a native Gtk API-call (gtk_window_resize) on that object.
This trick is the "glue" between Puppybasic and Gtkobjects.
This is the relevant part from the C-code:
Code:

// libglade to find the object
   GtkWidget *obj;
   obj = glade_xml_get_widget(xml, arg0);

//Gtk native to modify it
   gtk_window_resize(  GTK_WINDOW(obj) , atoi(arg1)  , atoi(arg2)  );

So in a real object orientated language, you can create + modify.
In ginsbasic, you load + modify.

This is no problem, as long as you use simple widgets like the calculator or a wizard.
But if you wanted to create your own IDE, you would reach limitations, as you could not create your own, "abstract" objects, like textiterators.

Another limit currently is, that the functions can only pass int , char, float.
But not GtkObject.
You can do (simplified code):

("gtk_move" , "window1" , x , y )

But not:
("gtk_add_child" , window1 , button1)
Because Button1 is an object.

You can show or hide elements.
This to a certain degree allows to build "dynamical" applications, but I think for larger projects it would not be sufficient.

Conclusion:
ginsbasic allows to quickly build applications with a GUI-designer.
And you can access each widget in it to a certain degree.
This makes ginsbasic easier to use and more flexible like for example Xdialog or Gtkdialog (the old one, I think the new one supports Glade, too).

So it is perfect for people who felt limitations in those old tools, but don't want to learn more complex approaches like GtkPerl.

Mark

Last edited by MU on Sun 13 May 2007, 18:37; edited 1 time in total
Back to top
View user's profile Send private message Visit poster's website 
MU


Joined: 24 Aug 2005
Posts: 13642
Location: Karlsruhe, Germany

PostPosted: Sun 13 May 2007, 18:30    Post subject:  

here is the code of the small filechooser on the screenshot.

Gins can create the chooser, but it misses the ability to get the selected filename.
So here I add a native GTK-Api call to get the filename from the filechooserwidget.

Code:
#!/usr/bin/ginsbasic001


//-- load  file and show the window
gins_glade("filechooser.glade")
gins_main()

//-- mainloop with eventhandling
while 1

  widget , event , pdata = gins_event()

  if widget != Nothing then

    if event = "GDK_DELETE" then
      gins_exit()
      end
    end if

    if event = "GDK_BUTTON_PRESS" then
      if widget = "button1" then


        // access Gtk directly to do more than gins could do

        selectedfile = gins_gtkwidgetfunction( "gtk_file_chooser_get_filename" , "filechooserbutton1" ,0 , 0, 0,0,0)


        gins_set("label1" , "label" ,   selectedfile , "<str>")
      end if
    end if

  end if

  gins_usleep(10000)

wend


So yes, you can access those functions directly from the Basic-script.

Mark
Back to top
View user's profile Send private message Visit poster's website 
Display posts from previous:   Sort by:   
Page 1 of 6 [78 Posts]   Goto page: 1, 2, 3, 4, 5, 6 Next
Post new topic   Reply to topic View previous topic :: View next topic
 Forum index » Advanced Topics » Cutting edge
Jump to:  

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group
[ Time: 0.1720s ][ Queries: 13 (0.0095s) ][ GZIP on ]