# EuGTK Internals

<heading>

##

EuGTK 4.12.0

### Quick Function List

</heading>

###

Public functions ~ commonly-used

- create() returns handle to newly-created widget: win = create(GtkWindow)
- set() sets a property for a widget: set(win,"background","blue")
- get() gets a property: ? get(win,"background")
- add() adds a widget to a container: add(win,panel); spaces divided equally
- pack_start() adds at top/left
- pack_end() adds at bottom/right
- show() show a widget: show(btn)
- show_all() show a container and all items contained within: show_all(win)
- hide() hide a widget: hide(btn)
- hide_all() hide a container and all items contained within: hide_all(win)
- connect() connect a signal to a Eu function: connect(btn1,"clicked","FooBar",33) Note: connect() returns a sigid, usually ignored unless you plan to disconnect.
- disconnect() disconnect a signal: disconnect(btn1,sigid)
- main() start the GTK main processing loop: main()
- requires() pop up an Error dialog if not available: requires("3.10","GtkRevealer")
- destroy() destroy a widget: destroy(win)
- unpack() convert data attached to a control back into format usable by Euphoria: unpack(data)
- show_uri() call default handler for uri (file, http, etc...): show_uri("http://gtk.org")
- "Quit" global call to shut down the GTK main processing loop: connect(win,"destroy","Quit")
- pointer() obtains a handle, a.k.a. pointer, to an object loaded from Glade constant win = pointer("help:window1")
- _() shorthand for call_back(routine_id()), links signals to local functions, no global declarations required
- $... shorthand for signal links e.g. $destroy=Quit

See HowItWorks for details on the above functions, you will use some of them frequently!

See also: settings

###

Utility functions ~ sometimes used

##### General functions

- has_icon(name) returns TRUE if named icon exists in current theme
- list_icons() returns a {list} of all icon names in current theme
- valid_icon({list}) given a list of possible icon names, returns handle to an image made from first valid name
- valid_icon_name({list}) given a list of possible icon names, returns first valid name
- icon_info(handle) returns a sequence: pointer to info struct, name, path, size, scale
- class_name(handle) returns the classname from a widget handle: display(classname(win)) => "GtkWindow"
- class_id(handle) returns the enumerated class for the handle: if classid(win) = GtkWindow then ...
- object_name(handle) returns name if object has a name, -nil- otherwise
- register(handle,class) registers handle as a class: register(win,GtkWindow) hardly ever needed.
- to_sequence(GList) converts a glist pointer back into a Eu sequence: rarely used!
- to_rgba(str) converts a color description to a pointer: ? to_rgba("skyblue")
- from_rgba(ptr) converts a color pointer into "rgb(r,g,b)" or "rgba(r,g,b,a)"
- pixbuf_formats() returns a list of implemented formats for pixbuf loader

##### Settings

- settings:Save()
- settings:Load()
- settings:Add()

##### Events

- events:id returns unique event id: ? events:id(event)
- events:xy returns location of event
- events:axes
- events:time
- events:state
- events:window
- events:device
- events:clicks returns # of mouse clicks in event
- events:scroll_dir
- events:key returns keypressed value
- events:button returns mouse button 1..3 when given an event: ? events:button(event)
- events:pending used when multitasking
- events:main_iteration
- events:main_iteration_do
</ul) </ul>

##### Networking

- networked returns TRUE if your computer is part of a network
- inet_connected returns TRUE if internet could be reached
- get_net_address returns 127.0.0.1 or your current ip

See events

###

Exported constants ~ available if you need them

- version EuGTK version: "4.11.8"
- release EuGTK release date: "Aug 1, 2014"
- copyright EuGTK copyright: "(c) 2015 by Irv Mullins"
- major_version for GTK 3.10.1: 3
- minor_version for GTK 3.10.1: 10
- micro_version for GTK 3.10.1: 1
- user_name The user logged-in: irv
- real_name Full name: Irv Mullins
- host_name host name of computer: Mint17
- host_addr host address: 192.168.1.100
- home_dir logged-in user's home: /home/irv
- temp_dir user's temp dir: /tmp
- curr_dir user's currently-logged into directory
- conf_dir user's config directory /home/irv/.conf
- runt_dir user's runtime directory /run/user/1000
- prg_name current program test0.ex
- os_name Linux
- os_distro Mint 17
- os_version 3.13.0-24-generic
- os_comp #46-Ubuntu SMP Thu Apr 10...
- os_arch x86_64
- os_term xterm
- os_shell /bin/bash
- eu_version version string: "4.1.0"
- eu_revision revision # 6318
- eu_date date compiled
- today date program started
- start_time time program started
- def_lang default language en-us
- CMD1 command_line[1] e.g. eui
- CMD2 command_line[2] e.g. /home/irv/demos/test1.ex
- LGPL Text of the Lesser General Public License
- stock_list List of GTK stock items - soon to be deprecated!

Note 1: these constants are generated when EuGTK starts up, and are available in two different forms:

- As individual constants
- As key/value pairs in the gtk:info structure, provided mainly for convenience when displaying them: `display("[{prg_name}]",gtk:info)`

See test0 for an example.

###

Other Stuff

Identifiers

Below are unique identifiers used to specify storage types in List/Tree models, not only do these control how the value is stored, but also how it is displayed:

- gINT Store and display as an integer (rounds floats down)
- gDBL Store and display as a double
- gSTR Store and display as a string
- gPTR Generic pointer - seldom used
- gFLT Displays with six digits following the decimal point
- gBOOL anything other than 0 displays TRUE, 0 displays FALSE
- gPIX Stores handle to a pixbuf, displays that image
- gCOMBO Stores handle to a GtkComboBox

Unique identifiers below save space in method prototypes; programmer may use them when calling the three user functions which follow.

- P = C_POINTER expected parameter is a pointer
- I = C_INT expected parameter is an integer
- S = E_OBJECT expected parameter is a string
- B = C_BYTE expected parameter is boolean
- D = C_DOUBLE expected parameter is a double
- F = C_FLOAT expected parameter is a floating-point value
- A = E_SEQUENCE expected parameter is an array

User functions

While mostly used internally by EuGTK, they may be useful when testing or when implementing GTK methods which haven't been added to EuGTK.

- gtk_func Example:`gtk_func("gtk_label_set_text",{P},{allocate_string("Hello")})`
- gtk_str_func Example:`puts(1,gtk_str_func("gtk_label_get_text",{P},{lbl})`
- gtk_proc Example:`gtk_proc("gtk_widget_hide",{P},{win})`