Home modules.gotpike.org
Username: Password: [Create Account]
[Forgot Password?]

Modules

ADT
Database
GTK2
GUI
IP
PiJAX
Public
Sql
Stdio
Subversion
System
Tools
Xosd
lua
v4l2
wx

Recent Changes

Public.Parser.XML2 1.50
Public.ZeroMQ 1.1
Public.Template.Mustache 1.0
Public.Protocols.XMPP 1.4
Sql.Provider.jdbc 1.0

Popular Downloads

Public.Parser.JSON2 1.0
Public.Parser.JSON 0.2
GTK2 2.23
Public.Web.FCGI 1.8
Public.Parser.XML2 1.48


Pike Module Reference:

module version 0, prepared

  MODULE GUI
Modules
GTK2

Description

All Graphical User Interfaces available for Pike are in this module

  MODULE GUI.GTK2
Classes
Button
Container
HBox
Label
Object
VBox
Widget
Window

Methods
events_pending()
flush()
init()
main()
main_quit()
Description

A GTK+-2.x module for Pike

This is basically a wrapper around gtk functions. Only very little code (like the module handling) is done apart from gtk code.


Method init

void GUI.GTK2.init(array argv)

Description

Initializes everything needed to operate GTK

Parameter argv

Command line arguments that might affect GTK

Note

In contrary to the C gtk_init() function this one doesn't adjust argv to exclude GTK arguments


Method events_pending

int GUI.GTK2.events_pending()

Description

Checks if any events are pending. This can be used to update the GUI and invoke timeouts etc. while doing some time intensive computation.

Returns

1 if events are pending, 0 otherwise


Method flush

void GUI.GTK2.flush()

Description

Calls gdk_flush()


Method main

void GUI.GTK2.main()

Description

Runs the main loop until main_quit() is called. You can nest calls to main(). In that case main_quit() will make the innermost invocation of the main loop return.


Method main_quit

void GUI.GTK2.main_quit()

Description

Makes the innermost invocation of the main loop return when it regains control.

  CLASS GUI.GTK2.Widget
Methods
destroy()
hide()
hide_all()
map()
realize()
show()
show_all()
unmap()
unrealize()
Description

Base class for all widgets


Method show_all

void GUI.GTK2.Widget()->show_all()

Description

Recursively shows a widget, and any child widgets (if the widget is a container).


Method show

void GUI.GTK2.Widget()->show()

Description

Flags a widget to be displayed. Any widget that isn't shown will not appear on the screen. If you want to show all the widgets in a container, it's easier to call show_all() on the container, instead of individually showing the widgets.

Remember that you have to show the containers containing a widget, in addition to the widget itself, before it will appear onscreen.

When a toplevel container is shown, it is immediately realized and mapped; other shown widgets are realized and mapped when their toplevel container is realized and mapped.


Method hide

void GUI.GTK2.Widget()->hide()

Description

Reverses the effects of show(), causing the widget to be hidden (invisible to the user).


Method hide_all

void GUI.GTK2.Widget()->hide_all()

Description

Recursively hides a widget and any child widgets.


Method map

void GUI.GTK2.Widget()->map()

Description

This function is only for use in widget implementations. Causes a widget to be mapped if it isn't already.


Method unmap

void GUI.GTK2.Widget()->unmap()

Description

This function is only for use in widget implementations. Causes a widget to be unmapped if it's currently mapped.


Method realize

void GUI.GTK2.Widget()->realize()

Description

Creates the GDK (windowing system) resources associated with a widget. Normally realization happens implicitly; if you show a widget and all its parent containers, then the widget will be realized and mapped automatically.

Realizing a widget requires all the widget's parent widgets to be realized; calling realize() realizes the widget's parents in addition to widget itself. If a widget is not yet inside a toplevel window when you realize it, bad things will happen.

This function is primarily used in widget implementations, and isn't very useful otherwise.


Method unrealize

void GUI.GTK2.Widget()->unrealize()

Description

This function is only useful in widget implementations. Causes a widget to be unrealized (frees all GDK resources associated with the widget).


Method destroy

void GUI.GTK2.Widget()->destroy()

Description

Destroys a widget. When a widget is destroyed, it will break any references it holds to other objects. If the widget is inside a container, the widget will be removed from the container. If the widget is a toplevel (derived from Window), it will be removed from the list of toplevels, and the reference GTK+ holds to it will be removed. Removing a widget from its container or the list of toplevels results in the widget being finalized, unless you've added additional references to the widget with g_object_ref().

FIXME: implement g_object_ref() FIXME: convince me not to implement g_object_ref()

In most cases, only toplevel widgets (windows) require explicit destruction, because when you destroy a toplevel its children will be destroyed as well.

  CLASS GUI.GTK2.Button
Methods
create()
get_label()
set_label()
Description

A widget that creates a signal when clicked on.


Method create

void GUI.GTK2.Button()->create()
void GUI.GTK2.Button()->create(string label)
void GUI.GTK2.Button()->create(string label, int(0..1) mnemonic)

Description

create() creates a plain button to which you can add other Widgets using add(Widget w) create(string label) creates a button with the given text

Parameter label

the text on the button

Parameter mnemonic

whether the character after an underscore ('_') should be interpreted as a mnemonic


Method set_label

void GUI.GTK2.Button()->set_label(string label)

Description

Sets the label of the button

Parameter label

the new label


Method get_label

string GUI.GTK2.Button()->get_label()

Description

Returns the current label of the button, or 0 if not set

  CLASS GUI.GTK2.Label
Methods
create()
get_text()
set_text()
Description

A widget that displays a small to medium amount of text.


Method create

void GUI.GTK2.Label()->create(string label)

Description

Creates a new label with the given text inside it

Parameter label

text of the label


Method set_text

void GUI.GTK2.Label()->set_text(string label)

Description

Sets the text within the GtkLabel widget. It overwrites any text that was there before. This will also clear any previously set mnemonic accelerators

Parameter label

the text you want to set


Method get_text

string GUI.GTK2.Label()->get_text()

Description

Fetches the text from a label widget, as displayed on the screen. This does not include any embedded underlines indicating mnemonics

  CLASS GUI.GTK2.Container
Methods
add()
remove()
Description

Base class for widgets which contain other widgets


Method add

void GUI.GTK2.Container()->add(object(Widget) widget)

Description

Adds widget to this Container. Typically used for simple containers such as Window, Frame, or Button; for more complicated layout containers such as Box or Table, this function will pick default packing parameters that may not be correct. So consider functions such as Box->pack_start() and Table->attach() as an alternative to add() in those cases. A widget may be added to only one container at a time; you can't place the same widget inside two different containers.

FIXME: implement Frame, Button, Box, Table


Method remove

void GUI.GTK2.Container()->remove(object(Widget) widget)

Description

Removes widget from this Container. widget must be inside this Container. Note that this Container will own a reference to widget, and that this may be the last reference held; so removing a widget from its container can destroy that widget. If you want to use widget again, you need to add a reference to it while it's not inside a container, using g_object_ref(). If you don't want to use widget again it's usually more efficient to simply destroy it directly using destroy() since this will remove it from the container and help break any circular reference count cycles.

FIXME: implement g_object_ref();

  CLASS GUI.GTK2.Window
Methods
activate_focus()
create()
get_resizable()
get_title()
set_destroy_with_parent()
set_modal()
set_resizable()
set_title()
set_transient_for()
Description

Toplevel which can contain other widgets


Method create

void GUI.GTK2.Window()->create()
void GUI.GTK2.Window()->create(int type)
void GUI.GTK2.Window()->create(string title)
void GUI.GTK2.Window()->create(string title, int type)

Description

Create a new Window

Parameter title

The title of the Window

Parameter type

the Window type


Method set_title

void GUI.GTK2.Window()->set_title(string title)

Description

Sets the title of the Window. The title of a window will be displayed in its title bar; on the X Window System, the title bar is rendered by the window manager, so exactly how the title appears to users may vary according to a user's exact configuration. The title should help a user distinguish this window from other windows they may have open. A good title might include the application name and current document filename, for example.


Method set_resizable

void GUI.GTK2.Window()->set_resizable(int resizable)

Description

Sets whether the user can resize a window. Windows are user resizable by default.


Method get_resizable

int GUI.GTK2.Window()->get_resizable()

Description

Gets the value set by set_resizable().

Returns

1 if the window is resizable, 0 otherwise


Method activate_focus

int GUI.GTK2.Window()->activate_focus()

Description

Activates the current focused widget within the window.

Returns

1 if a widget got activated, 0 otherwise


Method set_modal

void GUI.GTK2.Window()->set_modal(int modal)

Description

Sets a window modal or non-modal. Modal windows prevent interaction with other windows in the same application. To keep modal dialogs on top of main application windows, use set_transient_for() to make the dialog transient for the parent; most window managers will then disallow lowering the dialog below the parent.


Method set_transient_for

void GUI.GTK2.Window()->set_transient_for(object(Window) parent)

Description

Dialog windows should be set transient for the main application window they were spawned from. This allows window managers to e.g. keep the dialog on top of the main window, or center the dialog over the main window.

On Windows, this function will and put the child window on top of the parent, much as the window manager would have done on X.


Method set_destroy_with_parent

void GUI.GTK2.Window()->set_destroy_with_parent(int setting)

Description

If setting is 1, then destroying the transient parent of window will also destroy window itself. This is useful for dialogs that shouldn't persist beyond the lifetime of the main window they're associated with, for example.


Method get_title

string GUI.GTK2.Window()->get_title()

Description

Retrieves the title of the window.

  CLASS GUI.GTK2.HBox
Methods
create()
Description

HBox is a container that organizes child widgets into a single row.


Method create

void GUI.GTK2.HBox()->create()
void GUI.GTK2.HBox()->create(int(0..1) homogeneous)
void GUI.GTK2.HBox()->create(int(0..1) homogeneous, int spacing)

Description

Creates a new HBox.

Parameter homogeneous

whether all children are to be given equal space allotments (default: 0)

Parameter spacing

the number of pixels to place by default between children (default: 0)

  CLASS GUI.GTK2.Object
Methods
signal_connect()
Description

The base class of the GTK+ type hierarchy.


Method signal_connect

void GUI.GTK2.Object()->signal_connect(string signal, function callback, mixed|void callback_arg)

Description

FIXME: broken, don't use

  CLASS GUI.GTK2.VBox
Methods
create()
Description

VBox is a container that organizes child widgets into a single column.


Method create

void GUI.GTK2.VBox()->create()
void GUI.GTK2.VBox()->create(int(0..1) homogeneous)
void GUI.GTK2.VBox()->create(int(0..1) homogeneous, int spacing)

Description

Creates a new VBox.

Parameter homogeneous

whether all children are to be given equal space allotments (default: 0)

Parameter spacing

the number of pixels to place by default between children (default: 0)

gotpike.org | Copyright © 2004 - 2019 | Pike is a trademark of Department of Computer and Information Science, Linköping University