![]() |
![]() |
![]() |
GNOME UI Library Reference Manual | ![]() |
---|---|---|---|---|
Top | Description | Object Hierarchy | Signals |
#include <libgnomeui/libgnomeui.h> #define GNOME_CLIENT_CONNECTED (obj) enum GnomeDialogType; enum GnomeRestartStyle; enum GnomeClientFlags; enum GnomeSaveStyle; enum GnomeInteractStyle; void (*GnomeInteractFunction) (GnomeClient *client, gint key, GnomeDialogType dialog_type, gpointer data); GnomeClient; #define GNOME_CLIENT_PARAM_SM_CONNECT GnomeClient * gnome_master_client (void); const gchar* gnome_client_get_config_prefix (GnomeClient *client); const gchar* gnome_client_get_global_config_prefix (GnomeClient *client); const GnomeModuleInfo * gnome_client_module_info_get (void); void gnome_client_set_global_config_prefix (GnomeClient *client, const gchar *prefix); GnomeClientFlags gnome_client_get_flags (GnomeClient *client); void gnome_client_set_restart_style (GnomeClient *client, GnomeRestartStyle style); void gnome_client_set_priority (GnomeClient *client, guint priority); void gnome_client_set_restart_command (GnomeClient *client, gint argc, gchar *argv[]); void gnome_client_add_static_arg (GnomeClient *client, ...); void gnome_client_set_discard_command (GnomeClient *client, gint argc, gchar *argv[]); void gnome_client_set_resign_command (GnomeClient *client, gint argc, gchar *argv[]); void gnome_client_set_shutdown_command (GnomeClient *client, gint argc, gchar *argv[]); void gnome_client_set_current_directory (GnomeClient *client, const gchar *dir); void gnome_client_set_environment (GnomeClient *client, const gchar *name, const gchar *value); void gnome_client_set_clone_command (GnomeClient *client, gint argc, gchar *argv[]); void gnome_client_set_process_id (GnomeClient *client, pid_t pid); void gnome_client_set_program (GnomeClient *client, const gchar *program); void gnome_client_set_user_id (GnomeClient *client, const gchar *id); void gnome_client_save_any_dialog (GnomeClient *client, GtkDialog *dialog); void gnome_client_save_error_dialog (GnomeClient *client, GtkDialog *dialog); void gnome_client_request_phase_2 (GnomeClient *client); void gnome_client_request_save (GnomeClient *client, GnomeSaveStyle save_style, gboolean shutdown, GnomeInteractStyle interact_style, gboolean fast, gboolean global); void gnome_client_flush (GnomeClient *client); void gnome_client_disable_master_connection (void); GnomeClient * gnome_client_new (void); GnomeClient * gnome_client_new_without_connection (void); void gnome_client_connect (GnomeClient *client); void gnome_client_disconnect (GnomeClient *client); void gnome_client_set_id (GnomeClient *client, const gchar *id); const gchar* gnome_client_get_id (GnomeClient *client); const gchar* gnome_client_get_previous_id (GnomeClient *client); const gchar* gnome_client_get_desktop_id (GnomeClient *client); void gnome_client_request_interaction (GnomeClient *client, GnomeDialogType dialog_type, GnomeInteractFunction function, gpointer data); void gnome_client_request_interaction_interp (GnomeClient *client, GnomeDialogType dialog_type, GtkCallbackMarshal function, gpointer data, GDestroyNotify destroy); void gnome_interaction_key_return (gint key, gboolean cancel_shutdown);
"connect" : Run First "die" : Run Last "disconnect" : Run First "save-complete" : Run First "save-yourself" : Run Last "shutdown-cancelled" : Run First
#define GNOME_CLIENT_CONNECTED(obj) (GNOME_CLIENT (obj)->smc_conn)
Determine if the GnomeClient instance has connected to the session manager already.
|
A GnomeClient instance. |
Returns : |
%TRUE if already connected to the session manager, FALSE otherwise.
|
typedef enum { GNOME_DIALOG_ERROR, GNOME_DIALOG_NORMAL } GnomeDialogType;
The dialogs used by the session manager to handler user interactions.
typedef enum { /* update structure when adding an enum */ GNOME_RESTART_IF_RUNNING, GNOME_RESTART_ANYWAY, GNOME_RESTART_IMMEDIATELY, GNOME_RESTART_NEVER } GnomeRestartStyle;
The various ways in which the session manager can restart a client. Set by
calling gnome_client_set_restart_style()
.
Restart if the client was running when the previous session exited. | |
Restart even if the client was exited before the user logged out of the previous session. | |
Restart the client immediately whenever it crashes or exits. | |
Do not restart the client. |
typedef enum { GNOME_CLIENT_IS_CONNECTED= 1 << 0, GNOME_CLIENT_RESTARTED = 1 << 1, GNOME_CLIENT_RESTORED = 1 << 2 } GnomeClientFlags;
Flags indicating the status of a client (as seen by the session manager). Used
as return values by gnome_client_get_flags()
.
The client is connected to the session manager. | |
The client has been restarted (i.e. it has been running with the same client id previously). | |
There may be a configuration file from which the client's state should be restored (applies only to the master client). |
typedef enum { /* update structure when adding an enum */ GNOME_SAVE_GLOBAL, GNOME_SAVE_LOCAL, GNOME_SAVE_BOTH } GnomeSaveStyle;
Which pieces of data a client should save when receiving a "SaveYourself" call from the session manager.
typedef enum { GNOME_INTERACT_NONE, GNOME_INTERACT_ERRORS, GNOME_INTERACT_ANY } GnomeInteractStyle;
Indicates how a "SaveYourself" command should interact with the user.
void (*GnomeInteractFunction) (GnomeClient *client, gint key, GnomeDialogType dialog_type, gpointer data);
A function called when the client wishes to interact with the user a the
session manager's convenience (usually during shutdown and restarts). All other
clients are blocked from interacting with the user until the key
is released
via a call to gnome_interaction_key_return()
.
Although the function is not obliged to respect the passed in dialog_type
, it
is bad form not to do so.
|
The GnomeClient instance doing the interaction. |
|
A unique key. |
|
The GnomeDialogType that should be used to do the interaction. |
|
Application specific data that was specified at the time the callback was set up. |
typedef struct _GnomeClient GnomeClient;
A widget representing a client and containing information about the client's interaction with the session manager.
#define GNOME_CLIENT_PARAM_SM_CONNECT "sm-connect"
Passed as a parameter to the application's gnome_program_init()
call (with a
value of TRUE
or FALSE
) to indicate whether the application should attempt to
connect to the session manager or not. Can be overridden by the user passing
--sm-disable
on the command line and defaults to TRUE
.
GnomeClient * gnome_master_client (void);
Get the master session management client. This master client gets a client
id, that may be specified by the '--sm-client-id' command line option. A
master client will be generated by gnome_program_init()
. If possible the
master client will contact the session manager after command-line parsing is
finished (unless gnome_client_disable_master_connection()
was called). The
master client will also set the SM_CLIENT_ID property on the client leader
window of your application.
Additionally, the master client gets some static arguments set automatically
(see gnome_client_add_static_arg()
for static arguments):
gnome_program_init()
passes all the command line options which are
recognised by gtk as static arguments to the master client.
Returns : |
Pointer to the master client |
const gchar* gnome_client_get_config_prefix (GnomeClient *client);
Get the config prefix for a client. This config prefix
provides a suitable place to store any details about the state of
the client which can not be described using the app's command line
arguments (as set in the restart command). You may push the
returned value using gnome_config_push_prefix()
and read or write
any values you require.
|
Pointer to GNOME session client object. |
Returns : |
Config prefix. The returned string belongs to libgnomeui library and should NOT be freed by the caller. |
const gchar* gnome_client_get_global_config_prefix (GnomeClient *client);
Get the config prefix that will be returned by
gnome_client_get_config_prefix()
for clients which have NOT been restarted
or cloned (i.e. for clients started by the user without `--sm-' options).
This config prefix may be used to write the user's preferred config for
these "new" clients.
You could also use this prefix as a place to store and retrieve config details that you wish to apply to ALL instances of the app. However, this practice limits the users freedom to configure each instance in a different way so it should be used with caution.
|
Pointer to GNOME session client object. |
Returns : |
The config prefix as a newly allocated string. |
const GnomeModuleInfo * gnome_client_module_info_get (void);
Returns : |
void gnome_client_set_global_config_prefix (GnomeClient *client, const gchar *prefix);
Set the value used for the global config prefix. The config
prefixes returned by gnome_client_get_config_prefix()
are formed by
extending this prefix with an unique identifier.
The global config prefix defaults to a name based on the name of the executable. This function allows you to set it to a different value. It should be called BEFORE retrieving the config prefix for the first time. Later calls will be ignored.
For example, setting a global config prefix of "/app.d/session/" would ensure that all your session save files or directories would be gathered together into the app.d directory.
|
Pointer to GNOME session client object. |
|
Prefix for saving the global configuration. |
GnomeClientFlags gnome_client_get_flags (GnomeClient *client);
Determine the client's status with the session manager.,
|
Pointer to GNOME session client object. |
Returns : |
Various GnomeClientFlag flags which have been or'd together. |
void gnome_client_set_restart_style (GnomeClient *client, GnomeRestartStyle style);
Tells the session manager how the client should be restarted in future session. The options are given by the GnomeRestartStyle enum.
|
Pointer to GNOME session client object. |
|
When to restart the client. |
void gnome_client_set_priority (GnomeClient *client, guint priority);
The gnome-session manager restarts clients in order of their priorities in a similar way to the start up ordering in SysV. This function allows the app to suggest a position in this ordering. The value should be between 0 and 99. A default value of 50 is assigned to apps that do not provide a value. The user may assign a different priority.
|
Pointer to GNOME session client object. |
|
Position of client in session start up ordering. |
void gnome_client_set_restart_command (GnomeClient *client, gint argc, gchar *argv[]);
When clients crash or the user logs out and back in, they are
restarted. This command should perform the restart. Executing the restart
command on the local host should reproduce the state of the client at the
time of the session save as closely as possible. Saving config info under
the gnome_client_get_config_prefix()
is generally useful.
|
Pointer to GNOME session client object. |
|
Number of strings in argv. |
|
Argument vector to an execv() to restart the client.
|
void gnome_client_add_static_arg (GnomeClient *client, ...);
You can add arguments to your restart command's argv with this
function. This function provides an alternative way of adding new arguments
to the restart command. The arguments are placed before the arguments
specified by gnome_client_set_restart_command()
and after the arguments
recognised by GTK+ that are specified by the user on the original command
line.
|
Pointer to GNOME session client object. |
|
NULL -terminated list of arguments to add to the restart command.
|
void gnome_client_set_discard_command (GnomeClient *client, gint argc, gchar *argv[]);
Provides a command to run when a client is removed from the session. It might delete session-specific config files for example. Executing the discard command on the local host should delete the information saved as part of the session save that was in progress when the discard command was set. For example:
Example 1. Setting up a client's discard command
gchar *prefix = gnome_client_get_config_prefix (client); gchar *argv[] = { "rm", "-r", NULL }; argv[2] = gnome_config_get_real_path (prefix); gnome_client_set_discard_command (client, 3, argv);
|
The GnomeClient of interest. |
|
Number of strings in argv .
|
|
Vector of strings such as those passed to exev() .
|
void gnome_client_set_resign_command (GnomeClient *client, gint argc, gchar *argv[]);
Some clients can be "undone," removing their effects and deleting any saved state. For example, xmodmap could register a resign command to undo the keymap changes it saved.
Used by clients that use the GNOME_RESTART_ANYWAY restart style to to undo their effects (these clients usually perform initialisation functions and leave effects behind after they die). The resign command combines the effects of a shutdown command and a discard command. It is executed when the user decides that the client should cease to be restarted.
|
Pointer to GNOME session client object. |
|
Number of strings in argv .
|
|
execv() -style command to undo the effects of the client.
|
void gnome_client_set_shutdown_command (GnomeClient *client, gint argc, gchar *argv[]);
GNOME_RESTART_ANYWAY clients can set this command to run when the user logs out but the client is no longer running.
Used by clients that use the GNOME_RESTART_ANYWAY restart style to to undo their effects (these clients usually perform initialisation functions and leave effects behind after they die). The shutdown command simply undoes the effects of the client. It is executed during a normal logout.
|
Pointer to GNOME session client object. |
|
Number of strings in argv. |
|
Command to shutdown the client if the client isn't running. |
void gnome_client_set_current_directory (GnomeClient *client, const gchar *dir);
Set the directory to be in when running shutdown, discard, restart, etc. commands.
|
Pointer to GNOME session client object. |
|
Directory path. |
void gnome_client_set_environment (GnomeClient *client, const gchar *name, const gchar *value);
Set an environment variable to be placed in the client's environment prior to running restart, shutdown, discard, etc. commands.
|
Pointer to GNOME session client object. |
|
Name of the environment variable |
|
Value of the environment variable |
void gnome_client_set_clone_command (GnomeClient *client, gint argc, gchar *argv[]);
Set a command the session manager can use to create a new instance of the application.
|
Pointer to GNOME session client object. |
|
Number of strings in the argv vector.
|
|
Argument strings, suitable for use with execv() .
|
void gnome_client_set_process_id (GnomeClient *client, pid_t pid);
The client should tell the session manager the result of
getpid()
. However, GNOME does this automatically; so you do not need this
function.
|
Pointer to GNOME session client object. |
|
PID to set as the client's PID. |
void gnome_client_set_program (GnomeClient *client, const gchar *program);
Used to tell the session manager the name of your program. Set automatically; this function isn't needed.
|
Pointer to GNOME session client object. |
|
Name of the program. |
void gnome_client_set_user_id (GnomeClient *client, const gchar *id);
Tell the session manager the user's login name. GNOME does this automatically; no need to call the function.
|
Pointer to GNOME session client object. |
|
Username. |
void gnome_client_save_any_dialog (GnomeClient *client, GtkDialog *dialog);
May be called during a "save_youself" handler to request that a (modal) dialog is presented to the user. The session manager decides when the dialog is shown, but it will not be shown it unless the session manager is sending an interaction style of GNOME_INTERACT_ANY. A "Cancel Logout" button will be added during a shutdown.
|
Pointer to GnomeClient object. |
|
Pointer to GNOME dialog widget (a GtkDialog widget). |
void gnome_client_save_error_dialog (GnomeClient *client, GtkDialog *dialog);
May be called during a "save_youself" handler when an error has occurred during the save. The session manager decides when the dialog is shown, but it will not be shown it unless the session manager is sending an interaction style of GNOME_INTERACT_ANY. A "Cancel Logout" button will be added during a shutdown.
|
Pointer to GnomeClient object. |
|
Pointer to GNOME dialog widget (a GtkDialog widget). |
void gnome_client_request_phase_2 (GnomeClient *client);
Request the session managaer to emit the "save_yourself" signal for a second time after all the clients in the session have ceased interacting with the user and entered an idle state. This might be useful if your app manages other apps and requires that they are in an idle state before saving its final data.
|
A GnomeClient object. |
void gnome_client_request_save (GnomeClient *client, GnomeSaveStyle save_style, gboolean shutdown, GnomeInteractStyle interact_style, gboolean fast, gboolean global);
Request the session manager to save the session in some way. The arguments correspond with the arguments passed to the "save_yourself" signal handler.
The save_style indicates whether the save should affect data
accessible to other users (GNOME_SAVE_GLOBAL) or only the state
visible to the current user (GNOME_SAVE_LOCAL) or both. Setting
shutdown to TRUE
will initiate a logout. The interact_style
specifies which kinds of interaction will be available. Setting
fast to TRUE
will limit the save to setting the session manager
properties plus any essential data. Setting the value of global to
TRUE
will request that all the other apps in the session do a save
as well. A global save is mandatory when doing a shutdown.
|
Pointer to GNOME session client object. |
|
Save style to request. |
|
Whether to log out of the session. |
|
Whether to allow user interaction. |
|
Minimize activity to save as soon as possible. |
|
Request that all other apps in the session also save their state. |
void gnome_client_flush (GnomeClient *client);
This will force the underlying connection to the session manager to be flushed. This is useful if you have some pending changes that you want to make sure get committed.
|
A GnomeClient instance. |
void gnome_client_disable_master_connection (void);
gnome_client_disable_master_connection
is deprecated and should not be used in newly-written code.
Don't connect the master client to the session manager. Usually invoked by users when they pass the --sm-disable argument to a Gnome application.
GnomeClient * gnome_client_new (void);
Allocates memory for a new GNOME session management client
object. After allocating, the client tries to connect to a session manager.
You probably want to use gnome_master_client()
instead.
Returns : |
Pointer to a newly allocated GNOME session management client object. |
GnomeClient * gnome_client_new_without_connection (void);
Allocates memory for a new GNOME session management client
object. You probably want to use gnome_master_client()
instead.
Returns : |
Pointer to a newly allocated GNOME session management client object. |
void gnome_client_connect (GnomeClient *client);
Causes the client to connect to the session manager. Usually happens automatically; no need to call this function.
|
A GnomeClient instance. |
void gnome_client_disconnect (GnomeClient *client);
Disconnect the client from the session manager.
|
A GnomeClient instance. |
void gnome_client_set_id (GnomeClient *client, const gchar *id);
Set the client's session management ID; must be done before connecting to the session manager. There is usually no reason to call this function.
|
A GnomeClient instance. |
|
Session management ID. |
const gchar* gnome_client_get_id (GnomeClient *client);
Returns session management ID
|
A GnomeClient instance. |
Returns : |
Session management ID for this client; NULL if not connected to a
session manager.
|
const gchar* gnome_client_get_previous_id (GnomeClient *client);
Get the session management ID from the previous session.
|
A GnomeClient instance. |
Returns : |
Pointer to the session management ID the client had in the last
session, or NULL if it was not in a previous session.
|
const gchar* gnome_client_get_desktop_id (GnomeClient *client);
Get the client ID of the desktop's current instance, i.e. if
you consider the desktop as a whole as a session managed app, this
returns its session ID using a GNOME extension to session
management. May return NULL
for apps not running under a recent
version of gnome-session; apps should handle that case.
|
A GnomeClient instance. |
Returns : |
Session ID of GNOME desktop instance, or NULL if none.
|
void gnome_client_request_interaction (GnomeClient *client, GnomeDialogType dialog_type, GnomeInteractFunction function, gpointer data);
Use the following functions, if you want to interact with the
user during a "save_yourself" handler without being restricted to using the
dialog based commands gnome_client_save_any_dialog()
or
gnome_client_save_error_dialog()
. Note, however, that overriding the session
manager specified preference in this way (by using arbitrary dialog boxes)
is not very nice.
If and when the session manager decides that it's the app's turn to interact
then 'func' will be called with the specified arguments and a unique
'GnomeInteractionKey'. The session manager will block other
clients from interacting until this key is returned with
gnome_interaction_key_return()
.
|
A GnomeClient object. |
|
The type of dialog to create. |
|
Callback to invoke to perform the interaction. |
|
Callback data. |
void gnome_client_request_interaction_interp (GnomeClient *client, GnomeDialogType dialog_type, GtkCallbackMarshal function, gpointer data, GDestroyNotify destroy);
Similar to gnome_client_request_interaction()
, but used when
you need to destroy the callback data after the interaction.
|
Pointer to GNOME session client object. |
|
Type of dialog to show. |
|
Callback to perform the interaction (a GnomeInteractFunction). |
|
Callback data. |
|
Function to destroy callback data. |
"connect"
signalvoid user_function (GnomeClient *client, gboolean arg1, gpointer user_data) : Run First
Called once the client has been connected to the signal manager.
|
the object which received the signal. |
|
%TRUE if the application has been restarted. |
|
user data set when the signal handler was connected. |
"die"
signalvoid user_function (GnomeClient *client, gpointer user_data) : Run Last
Called when the session manager wants the client to shut down.
|
the object which received the signal. |
|
user data set when the signal handler was connected. |
"disconnect"
signalvoid user_function (GnomeClient *client, gpointer user_data) : Run First
Called when the client is disconnected from the session manager.
|
the object which received the signal. |
|
user data set when the signal handler was connected. |
"save-complete"
signalvoid user_function (GnomeClient *client, gpointer user_data) : Run First
Called when the session manager has finished checkpointing all of the clients. Clients are then free to change their state.
|
the object which received the signal. |
|
user data set when the signal handler was connected. |
"save-yourself"
signalgboolean user_function (GnomeClient *client, gint arg1, GnomeSaveStyle arg2, gboolean arg3, GnomeInteractStyle arg4, gboolean arg5, gpointer user_data) : Run Last
Called when either a "SaveYourself" or a "SaveYourselfPhase2" call is made by the session manager.
|
the object which received the signal. |
|
The phase of the "SaveYourself" command ('1' or '2'). |
|
The data which should be saved by the client (local, global or both). |
|
%TRUE if the session manager is shutting down. |
|
How the client is allowed to interact with the user while saving. |
|
%TRUE if this is to be a "fast" shutdown (saving minimal data). |
|
user data set when the signal handler was connected. |
Returns : |
%TRUE if the "SaveYourself" was completed succesfully, FALSE
otherwise.
|
"shutdown-cancelled"
signalvoid user_function (GnomeClient *client, gpointer user_data) : Run First
Called if the session manager had sent a "SaveYourself" to all clients in preparation for shutting down and the shutdown was then cancelled. A client can then continue running and change its state.
|
the object which received the signal. |
|
user data set when the signal handler was connected. |