This site has been retired. For up to date information, see handbook.gnome.org or gitlab.gnome.org.


[Home] [TitleIndex] [WordIndex

Scratch Pad

Scratch pad for those items we just want to 'jot down now' for inclusion later.

AtkValue

atk_value_set_current_value ()

"Implementor note: The implementation must handle values outisde of the range given by min and max. THe behavior in those cases is implementation-defined. If the implementation allows multiple behaviors, clamping is preferred."

Best-Practices-Like Stuff Found During the Wiki Clean-Up

How to issue events to reflect "focused" change

It is quite simple for us to notice what is going on when operating on the computer, but it may be a little challenging for a blind person to do so. As a result, we should provide feedback to these users by issuing events to Orca (a flexible accessibility application for people with visual impairments) to tell it what is going on. Specifically, to tell users which object is focused on the desktop, we need to issue "object:state-changed:focused" and "focus:" events to reflect the new object with focus.

The "object:state-changed:focused" Event

When to Emit "object:state-changed:focused" Event

When focus moves from one object to another, this event should be issued to reflect that the former object lost "focused" state and the latter one got it. Consequently, if there is a "focused" change, "object:state-changed:focused" event with regard to the above two objects will be emitted to specify the state change for both of them.

For example, if we press Arrow Right to move focus from one object (named "bin") to another ("boot"), Orca will receive the following events:

 object:state-changed:focused(0, 0, None)
        source: [icon | bin]
        application: [application | gtk-demo]
 object:state-changed:focused(1, 0, None)
        source: [icon | boot]
        application: [application | gtk-demo]

Where focused(0, 0, None) represents that "focused" state has been removed from "bin", while focused(1, 0, None) denotes that "focused" state has been added to "boot".

How to Emit "object:state-changed:focused" Event

To illustrate the process of emitting events, we continue to analyse the above example, pressing Arrow Right to move focus from one object ("bin") to another ("boot").

The "focus:" Event

When to Emit "focus:" Event

Let's take the above case as an example again, pressing Arrow Right to move focus from one object(named "bin") to another ("boot"). As the focus on the desktop has changed, it is reasonable to report this alteration to Orca. Consequently, "focus:" event as follows is needed to tell Orca which object is focused currently.

 focus:(0, 0, None)
       source: [icon | boot]
       application: [application | gtk-demo]

The above event denotes that the icon named "boot" is focused at present.

How to Emit "focus:" Event

There are several key functions to complete this process:

How to add children to GtkContainer

Quick Introduction to GtkContainer

A GTK+ user interface is constructed by nesting widgets inside widget. Container widgets are the inner nodes in the resulting tree of widgets: they contain other widgets. For example, you might have a GtkWindow containing a GtkButton containing a GtkLabel.

Abstractly, GtkContainer is a base class for widgets which contain other widgets. GtkBin, GtkBox, GtkTable, GtkList, GtkMenuShell... are all subclasses of the abstract GtkContainer base class. Generally, all the subclasses could be divided into two major kinds of container widgets in GTK+. The first type of container widget has a single child widget and derives from GtkBin, such as GtkButton, GtkFrame. The second type of container widget has more than one child, such as, GtkBox, GtkTable.

Anyway, all the container widgets are aimed to contain other widget. Consequently, the following will discuss how to add widgets to containers.

How to add a widget to containers

To demonstrate the process of adding a child to containers, we firstly take GtkBox as an example.

Example: GtkBox

GtkBox is a typical subclass of GtkContainer, which could contain more than one child. If we want to add a menubar to a GtkBox, the process is described as follows.


2024-10-23 10:57