|
This function tops an application (i.e. brings it to the foreground). If the application is not already running, D-BUS will launch it via the auto-activation mechanism. By using this function, only one instance of the application will be running at any given time. If the application is already running, this function will only bring it to the foreground.
- Parameters:
-
| osso | The library context as returned by osso_initialize. |
| application | The name of the application to top. |
| arguments | This string lists some parameters for the application. It can be used to give the names of the files to open, etc. If no arguments are to be passed, this can be NULL. |
- Returns:
- OSSO_OK if the application launch request was successfully sent to the D-BUS daemon, OSSO_ERROR if not.
Example
This is an example on how to parse the argument from a top message. The format is the same as a commandline with long options, i.e. --param=value... So that the same arguments can be easily implemented as commandline arguments. #include <unistd.h>
#define _GNU_SOURCE
#include <getopt.h>
void top_handler(const gchar *arguments, gpointer data);
{
gchar **argv;
gint argc;
GError *err
g_shell_parse_argv(arguments, &argc, &argv, &err);
optind=0;
optarg=argv;
parse_commandline(argc, argv);
g_strfreev(argv);
}
void parse_commandline(int argc, char *argv[])
{
static struct option long_options[] = {
{"to", 1, 0, 't'},
{"files", 1, 0, 'f'},
{"url", 1, 0, 'u'},
{0, 0, 0, 0}
};
gint index = 0, r;
while(1) {
r = getopt_long(argc, argv, "t:f:u:", long_options, &index);
if (r == -1) break;
switch(r) {
case 't':
handle_to(optarg);
break;
}
}
}
|