| Top |
The data browser is both an entity that monitors of various data in Gwyddion and the corresponding user interface showing the data lists and letting the user deleting or copying them. The public functions are generally related to the first part.
Data browser functions may only be called from the main thread. Therefore, there is no locking.
An GwyFile that represents an SPM file is managed by functions such as gwy_data_browser_add() or
gwy_data_browser_remove(). Note that the high-level libgwyapp functions generally call the data browser functions
as appropriate. Low-level functions, e.g. GwyFile functions, do not. If a GwyFile has not been added to the data
browser it is unmanaged and cannot be used with data browser functions (there are, however, quite a few data
managing operations GwyFile itself can do).
An important part of the data browser is keeping track which data item is currently selected (to know what a data
processing method should process, etc.). You can obtain the information about various currently selected objects
using gwy_data_browser_get_current(). Making a data item currently selected is accomplished either using function
such as gwy_data_browser_select_widget(), which corresponds to the user switching windows, or
gwy_data_browser_select_data() which selects a data item as current in the browser. The latter is less safe and can
result in a strange behaviour because for some purposes only data displayed in a window can really be ‘current’.
void (*GwyDataBrowserForeachFunc) (GwyFile *file,gpointer user_data);
Type of data file for-each function.
Such function is passed to gwy_data_browser_foreach().
file |
A data container managed by the data-browser. |
|
user_data |
User data passed to |
[closure] |
void (*GwyDataWatchFunc) (GwyFile *file,gint id,GwyDataWatchEventType event,gpointer user_data);
Type of data watch function.
Such function is passed to gwy_data_browser_add_watch().
file |
A data container managed by the data-browser. |
|
id |
Object (channel) id in the container. |
|
user_data |
User data passed to |
[closure] |
void
gwy_data_browser_add (GwyFile *file);
Adds a data file container to the application data browser.
The file becomes managed by the data browser. Use gwy_data_browser_remove() to remove it. The data browser takes
a reference on the file; you can usually release yours.
If the file is still marked in construction, the construction is finished. If some data objects that need an image representation (e.g. volume or XYZ data) lack previews, default previews are created for them.
If GUI is running, windows are created, showing file
's data according to visibility flags. If nothing is marked
visible, the first found data are displayed.
void
gwy_data_browser_remove (GwyFile *file);
Removes a data file container to the application data browser.
If GUI is running, all windows displaying file
's data are closed. The file ceases being managed by the data
browser. The data browser releases its reference on the file. This often leads to file
's destruction.
The current file may not be removed while switching is blocked with gwy_data_browser_block_switching(). It would
lead to a contradiction: the browser must switch away from file
but it is not allowed to change the current file.
GwyFile *
gwy_data_browser_get_file (gint id);
Finds a file by its numerical id.
Only files managed by the data browser have an id. It is not an error to request a file which does not exist. In
such case, NULL is returned. See also gwy_file_get_id().
gint gwy_data_browser_copy_data (GwyFile *source,GwyDataKind data_kind,gint id,GwyFile *dest);
Adds a new data items as a duplicate of existing data including all auxiliary information.
The function differs from gwy_file_copy_data() in two primary aspects: It adds a log entry and it makes the new data
visible. Therefore, it suitable for data duplication in a running GUI, as opposed to mere file manipulation
function.
gint gwy_data_browser_reset_visibility (GwyFile *file,GwyVisibilityResetType reset_type);
Resets visibility of all data objects in a container.
It is possible to perform the reset when GUI is disabled. In such case the visibility flags in the file are set,
but no windows are created or closed. The GWY_VISIBILITY_RESET_RESTORE mode is a no-op in such case because it
does not change the visibility flags. GWY_VISIBILITY_RESET_DEFAULT is often also no-op, but it may set the flag
for some data if none are currently marked visible.
This function prevents the file from being closed when all windows are closed. Usually, a GUI caller should close the file when getting a zero return value.
GwyFile * gwy_data_browser_find_object (GObject *object,GQuark *key);
Finds file and the corresponding key for any data object.
The function does not actually scan all open files and is relatively cheap. The behaviour during changes in the file, such as data replacement, addition or removal, is currently undefined (it may return values corresponding either to the old or the new state).
void gwy_data_browser_foreach (GwyDataBrowserForeachFunc function,gpointer user_data,GDestroyNotify destroy);
Calls a function for every file managed by the data browser.
The function must not remove files from the data browser nor add new ones to it.
void
gwy_data_browser_select_widget (GtkWidget *widget);
Selects the file and data item corresponding to a data displaying widget as current.
Selecting an image window switches the active tool to this window.
You can pass NULL to select no data. Usually when some data exist, some data are selected as current. However, it
is possible to have no data selected when data exist.
It is an error to pass non-data-displaying widgets.
GtkWindow * gwy_data_browser_get_window_for_data (GwyFile *file,GwyDataKind data_kind,gint id);
Gets the top-level window displaying given data.
It is not an error to ask for nonexistend windows, even windows which could not exist (for example because data
is not a managed file or id
is negative).
gboolean gwy_data_browser_get_data_for_widget (GtkWidget *widget,GwyFile **file,GwyDataKind *data_kind,gint *id);
Identifies the data displayed by a data displaying widget.
The preferred argument for widget
is the top-level window. However, there is some liberty. The function also
identifies the data correctly when given the data displaying widget such as GwyDataWindow or GwyGraph.
It is not an error to pass a window not showing any data, although there should not be any reasong for doing so.
If the function return FALSE, the values of file
, data_kind
and id
are kept intact.
The returned data kind is the primary data kind for that window.
void gwy_data_browser_select_data (GwyFile *file,GwyDataKind data_kind,gint id);
Selects a file and data item.
void
gwy_data_browser_block_switching (void);
Temporarily blocks data switching.
Normally, the current data item is switched according to the active window.
This may be necessary during operations which would be derailed by data switching. For instance DnD from tree views
showing the contents of active data does not work correctly if the window manager switches active windows during
the DnD, so at the drop time the tree view content no longer matches the dragged row. While switching is blocked,
functions such as gwy_data_browser_select_data() will only queue the change.
Use gwy_data_browser_unblock_switching() to restore data switching. It will also switch data to the window that
should be currently active, if the active window has changed (but without any intermediate steps if the active
window has changed multiple times).
Switching must not be blocked permanently because it would get the data browser out of sync.
void
gwy_data_browser_unblock_switching (void);
Stops temporarily blocking of data switching.
If some data switching has been blocked, the most recent will be realised now.
The blocking is started by gwy_data_browser_block_switching(). See its description for details.
GwyDataKind
gwy_data_browser_get_current_data_kind
(void);
Gets the kind of current data.
This is what the active data lists shows, for instance. However, even the inactive lists have their own current
data items which you can get using gwy_data_browser_get_current_data_id().
GwyFile *
gwy_data_browser_get_current_file (void);
Gets the current file.
gint
gwy_data_browser_get_current_file_id (void);
Gets the numerical id of the current file.
gint
gwy_data_browser_get_current_data_id (GwyDataKind data_kind);
Gets the numerical id of the current data of given kind.
Use in conjuction with gwy_data_browser_get_current_data_kind() to get the selected data in the active data list
of the browser.
void gwy_data_browser_get_current (GwyAppWhat what,...);
Gets information about current objects.
All output arguments are always set to some value, even if the requested object does not exist. Object arguments
are set to pointer to the object if it exists (no reference is added), or cleared to NULL if no such object
exists.
Quark arguments are set to the corresponding key even if no such object is actually present (use object arguments to check for object presence) but the location where it would be stored is known. This is common with presentations and masks. They are be set to 0 if no corresponding location exists -- for example, when the current mask key is requested but the current data contains no channel (or there is no current data at all).
The rules for id arguments are similar to quarks, except they are set to -1 to indicate undefined result.
The current objects can change due to user interaction even during the execution of modal dialogs (typically used by modules). Therefore to achieve consistency one has to ask for the complete set of current objects at once.
what |
First information about current objects to obtain. |
|
... |
pointer to store the information to (object pointer for objects, GQuark pointer for keys, gint pointer for ids), followed by 0-terminated list of GwyAppWhat, pointer couples. |
gulong gwy_data_browser_add_watch (GwyDataWatchFunc function,GwyDataKind data_kind,gpointer user_data,GDestroyNotify destroy);
Adds a function watching a specific kind of data.
void
gwy_data_browser_remove_watch (gulong id);
Removes a function watching a specific kind of data.
The identifier is obtained when adding such function with gwy_data_browser_add_watch().
gboolean
gwy_data_browser_get_gui_enabled (void);
Reports whether creation of windows by the data-browser is enabled.
void
gwy_data_browser_set_gui_enabled (gboolean setting);
Globally enables or disables creation of widgets by the data-browser.
By default, the data-browser creates windows for data objects automatically, for instance when reconstructing view
of a loaded file, after a module function creates a new channel or graph or when it is explicitly asked so by
gwy_data_browser_show_gl(). Non-GUI applications that run module functions usually wish to disable GUI.
If GUI is disabled the data browser never creates windows showing data objects and also gwy_data_browser_show()
becomes no-op.
Disabling GUI after widgets have been already created is a bad idea. Hence you should do so before loading files or calling module functions.
GtkWidget *
gwy_data_browser_widget (void);
Obtains the data browser widget.
The data browser is a singleton. If browser GUI is enabled and the widget already exists, it is simply returned. It may be newly created as necessary. In any case, the widget is owned by the browser. Destroy it to shut down (but not disable) the data browser.
If browser GUI is disabled, the function returns NULL.
Types of current objects that can be requested with gwy_data_browser_get_current().
|
Data container (corresponds to files). |
||
|
The type of currently selected in the browser page as GwyDataKind. |
||
|
Data view widget (shows a channel). |
||
|
Graph widget (shows a graph model). |
||
|
Data field (image). |
||
|
Quark corresponding to the data field (image). |
||
|
Number (id) of the data field (image) in its container. |
||
|
Mask data field. |
||
|
Quark corresponding to the mask field. |
||
|
Presentation data field. |
||
|
Quark corresponding to the presentation field. |
||
|
Graph model. |
||
|
Quark corresponding to the graph model. |
||
|
Number (id) of the graph model in its container. |
||
|
Single point spectra. |
||
|
Quark corresponding to the single point spectra. |
||
|
Number (id) of the the single point spectra in its container. |
||
|
Data view widget (shows preview of volume data). |
||
|
Data brick (volume data). |
||
|
Quark corresponding to the data brick. |
||
|
Number (id) of the the data brick in its container. |
||
|
Numeric id of data container. |
||
|
Data view widget (shows preview of surface XYZ data). |
||
|
Surface data (XYZ). |
||
|
Quark corresponding to the surface data. |
||
|
Number (id) of the the surface data in its container. |
||
|
Lawn (curve map). |
||
|
Quark corresponding to the curve map. |
||
|
Number (id) of the lawn (curve map) in its container. |
||
|
Data view widget (shows preview of curve map lawn data). |
Data object visibility reset type.
The precise behaviour of GWY_VISIBILITY_RESET_DEFAULT
may be subject of further changes. It indicates the wish to
restore saved visibilities and do something reasonable when there are no visibilities to restore.