Running CTK+ Applications

Running CTK+ Applications — How to run and debug your CTK+ application

Running and debugging CTK+ Applications

Common commandline options

All CTK+ applications support a number of standard commandline options. These are removed from argv by ctk_init(). Modules may parse and remove further options. The X11 and Windows CDK backends parse some additional commandline options.

--ctk-module module A list of modules to load in addition to those specified in the CTK3_MODULES environment variable and the ctk-modules setting.

--g-fatal-warnings Make CTK+ abort on all warnings. This is useful to stop on the first warning in a debugger, if your application is printing multiple warnings. It's almost always best to start debugging with the first warning that occurs.

--ctk-debug options A list of debug options to turn on in addition to those specified in the CTK_DEBUG environment variable. This option is not available if CTK+ has been configured with --enable-debug=no.

--ctk-no-debug options A list of debug options to turn off. This option is only available if CTK+ has been configured with --enable-debug=yes.

The following options are really used by CDK, not by CTK+, but we list them here for completeness nevertheless.

--class class Sets the program class; see cdk_set_program_class().

--name name Sets the program name.

--cdk-debug options A list of debug options to turn on in addition to those specified in the CDK_DEBUG environment variable. This option is only available if CTK+ has been configured with --enable-debug=yes.

--cdk-no-debug options A list of debug options to turn off. This option is only available if CTK+ has been configured with --enable-debug=yes.


Environment variables

CTK+ inspects a number of environment variables in addition to standard variables like LANG, PATH, HOME or DISPLAY; mostly to determine paths to look for certain files. The X11, Windows and Broadway CDK backends use some additional environment variables.

CTK_DEBUG Unless CTK+ has been configured with --enable-debug=no, this variable can be set to a list of debug options, which cause CTK+ to print out different types of debugging information.

actions

Actions and menu models

baselines

Show baselines

builder

CtkBuilder support

geometry

Size allocation

icontheme

Icon themes

interactive

Open the interactive debugger

keybindings

Keybindings

misc

Miscellaneous information

modules

Loading of modules

no-css-cache

Bypass caching for CSS style properties

no-pixel-cache

Disable the pixel cache

plugsocket

Cross-process embedding

pixel-cache

Pixel cache

printing

Printing support

size-request

Size requests

text

Text widget internals

touchscreen

Pretend the pointer is a touchscreen device

tree

Tree widget internals

updates

Visual feedback about window updates

resize

Highlight resizing widgets

layout

Show layout borders

The special value all can be used to turn on all debug options. The special value help can be used to obtain a list of all supported debug options.

CTK3_MODULES A list of modules to load. Note that CTK+ also allows to specify modules to load via a commandline option (--ctk-module) and with the ctk-modules setting.

CTK_MODULES A list of modules to load in addition to the ones in the CTK3_MODULES variable.

Note that this environment variable is read by CTK+ 2.x too, which may not have the same set of modules available for loading. Use CTK3_MODULES for modules that are only compatible with CTK+ 3.

CTK_PATH Specifies a list of directories to search when CTK+ is looking for dynamically loaded objects such as the modules specified by CTK_MODULES, theme engines, input method modules, file system backends and print backends. If the path to the dynamically loaded object is given as an absolute path name, then CTK+ loads it directly. Otherwise, CTK+ goes in turn through the directories in CTK_PATH, followed by the directory .ctk-3.0 in the user's home directory, followed by the system default directory, which is libdir/ctk-3.0/modules. (If CTK_EXE_PREFIX is defined, libdir is $CTK_EXE_PREFIX/lib. Otherwise it is the libdir specified when CTK+ was configured, usually /usr/lib, or /usr/local/lib.) For each directory in this list, CTK+ actually looks in a subdirectory directory/version/host/type Where version is derived from the version of CTK+ (use pkg-config --variable=ctk_binary_version ctk+-3.0 to determine this from a script), host is the architecture on which CTK+ was built. (use pkg-config --variable=ctk_host ctk+-3.0 to determine this from a script), and type is a directory specific to the type of modules; currently it can be modules, engines, immodules, filesystems or printbackends, corresponding to the types of modules mentioned above. Either version, host, or both may be omitted. CTK+ looks first in the most specific directory, then in directories with fewer components. The components of CTK_PATH are separated by the ':' character on Linux and Unix, and the ';' character on Windows.

Note that this environment variable is read by CTK+ 2.x too, which makes it unsuitable for setting it system-wide (or session-wide), since doing so will cause either CTK+ 2.x applications or CTK+ 3 applications to see incompatible modules.

CTK_IM_MODULE Specifies an IM module to use in preference to the one determined from the locale. If this isn't set and you are running on the system that enables XSETTINGS and has a value in Ctk/IMModule, that will be used for the default IM module. This also can be a colon-separated list of input-methods, which CTK+ will try in turn until it finds one available on the system.

CTK_IM_MODULE_FILE Specifies the file listing the IM modules to load. This environment variable the default value libdir/ctk-3.0/3.0.0/immodules.cache (libdir has the same meaning here as explained for CTK_PATH). The immodules.cache file is generated by the ctk-query-immodules-3.0 utility.

Note that this environment variable is read by CTK+ 2.x too, which makes it unsuitable for setting it system-wide (or session-wide), since doing so will cause either CTK+ 2.x applications or CTK+ 3 applications to see the wrong list of IM modules.

CTK_EXE_PREFIX If set, CTK+ uses $CTK_EXE_PREFIX/lib instead of the libdir configured when CTK+ was compiled.

CTK_DATA_PREFIX If set, makes CTK+ use $CTK_DATA_PREFIX instead of the prefix configured when CTK+ was compiled.

CTK_THEME If set, makes CTK+ use the named theme instead of the theme that is specified by the ctk-theme-name setting. This is intended mainly for easy debugging of theme issues. It is also possible to specify a theme variant to load, by appending the variant name with a colon, like this: `CTK_THEME=Advaita:dark`.

The following environment variables are used by GdkPixbuf, CDK or Pango, not by CTK+ itself, but we list them here for completeness nevertheless.

GDK_PIXBUF_MODULE_FILE Specifies the file listing the GdkPixbuf loader modules to load. This environment variable overrides the default value libdir/ctk-3.0/3.0.0/loaders.cache (libdir is the sysconfdir specified when CTK+ was configured, usually /usr/local/lib.) The loaders.cache file is generated by the gdk-pixbuf-query-loaders utility.

CDK_DEBUG If CTK+ has been configured with --enable-debug=yes, this variable can be set to a list of debug options, which cause CDK to print out different types of debugging information.

cursor

Information about cursor objects (only win32)

dnd

Information about drag-and-drop

draw

Information about drawing operations (only win32)

eventloop

Information about event loop operation (mostly Quartz)

misc

Miscellaneous information

nogl

Turn off OpenGL. CDK will behave as if OpenGL support was not available.

nograbs

Turn off all pointer and keyboard grabs

xinerama

Simulate a multi-monitor setup

xim

Information about XIM support

The special value all can be used to turn on all debug options.

CDK_RENDERING If set, selects the way how CDK creates similar surfaces. This affects both the functionality of the function cdk_window_create_similar_surface() as well as the way CDK creates backing surfaces for double buffering. The following values can be used:

similar

Create similar surfaces to the window in use. This is the default behavior when the variable is not set.

image

Always create image surfaces. This essentially turns off all hardware acceleration inside CTK.

recording

Always create recording surfaces. This causes bare rendering to the backend without the creation of intermediate surfaces (Pixmaps in X) and will likely cause flicker.

All other values will be ignored and fall back to the default behavior. More values might be added in the future.

CDK_BACKEND If set, selects the CDK backend to use. Selecting a backend requires that CTK+ is compiled with support for that backend. The following backends can be selected, provided they are included in the CDK libraries you are using:

quartz

Selects the native Quartz backend

win32

Selects the native backend for Microsoft Windows

x11

Selects the native backend for connecting to X11 servers.

broadway

Selects the Broadway backend for display in web browsers

wayland

Selects the Wayland backend for connecting to Wayland display servers

Since 3.10, this environment variable can contain a comma-separated list of backend names, which are tried in order. The list may also contain a *, which means: try all remaining backends. The special value "help" can be used to make CDK print out a list of all available backends. For more information about selecting backends, see the cdk_display_manager_get() function.

CTK_CSD The default value of this environment variable is 1. If changed to 0, this disables the default use of client-side decorations on CTK+ windows, thus making the window manager responsible for drawing the decorations of windows that do not have a custom titlebar widget. CSD is always used for windows with a custom titlebar widget set, as the WM should not draw another titlebar or other decorations around the custom one.

CTK_OVERLAY_SCROLLING The default value of this environment variable is 1, which means that each instance of CtkScrolledWindow will choose whether to use overlay or full- size scrollbars via its own CtkScrolledWindow:overlay-scrolling property, which defaults to TRUE. If this variable is set to 0, all CtkScrolledWindow instances are made to use full/non-overlay scrollbars.

XDG_DATA_HOME, XDG_DATA_DIRS CTK+ uses these environment variables to locate icon themes and MIME information. For more information, see Icon Theme Specification, the Shared MIME-info Database and the Base Directory Specification.

DESKTOP_STARTUP_ID CTK+ uses this environment variable to provide startup notification according to the Startup Notification Spec. Following the specification, CTK+ unsets this variable after reading it (to keep it from leaking to child processes). So, if you need its value for your own purposes, you have to read it before calling ctk_init().


Interactive debugging

CTK+ includes an interactive debugger, called the CTK+ Inspector, which lets you explore the widget tree of any CTK+ application at runtime, as well as tweak the theme and trigger visual debugging aids. You can easily try out changes at runtime before putting them into the code.

Note that the CTK+ inspector can only show CTK+ internals. It can not understand the application-specific logic of a CTK+ application. Also, the fact that the CTK+ inspector is running in the application process limits what it can do. It is meant as a complement to full-blown debuggers and system tracing facilities such as DTrace, not as a replacement.

To enable the CTK+ inspector, you can use the Control-Shift-I or Control-Shift-D keyboard shortcuts, or set the CTK_DEBUG=interactive environment variable.

In some situations, it may be inappropriate to give users access to the CTK+ inspector. The keyboard shortcuts can be disabled with the `enable-inspector-keybinding` key in the `org.ctk.Settings.Debug` GSettings schema.