Typedefs | |
typedef void( | osso_application_top_cb_f )(const gchar *arguments, gpointer data) |
Functions | |
osso_return_t | osso_application_top (osso_context_t *osso, const gchar *application, const gchar *arguments) |
osso_return_t | osso_application_set_top_cb (osso_context_t *osso, osso_application_top_cb_f *cb, gpointer data) |
osso_return_t | osso_application_unset_top_cb (osso_context_t *osso, osso_application_top_cb_f *cb, gpointer data) |
typedef void( osso_application_top_cb_f)(const gchar *arguments, gpointer data) |
This is the type for the top callback function.
arguments | This string lists some extra parameters for the application. It can be used to give the names of the files to open, etc. | |
data | The data that was set with the osso_application_set_top_cb function. |
osso_return_t osso_application_set_top_cb | ( | osso_context_t * | osso, | |
osso_application_top_cb_f * | cb, | |||
gpointer | data | |||
) |
This function registers a top event callback function.
osso | The library context as returned by osso_initialize. | |
cb | The callback function. | |
data | Arbitrary application specific pointer that will be passed to the callback and ignored by Libosso. |
osso_return_t osso_application_top | ( | osso_context_t * | osso, | |
const gchar * | application, | |||
const gchar * | arguments | |||
) |
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.
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. |
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 // this will split the arguments string into something similar to // what one would get in main. g_shell_parse_argv(arguments, &argc, &argv, &err); // This forces getopt to start from the first argument every time optind=0; optarg=argv; // call the generic commandline parser parse_commandline(argc, argv); // Free memory allocated previously. g_strfreev(argv); } void parse_commandline(int argc, char *argv[]) { static struct option long_options[] = { {"to", 1, 0, 't'}, // "to" requires an argument {"files", 1, 0, 'f'}, {"url", 1, 0, 'u'}, {0, 0, 0, 0} }; gint index = 0, r; while(1) { // This function will parse and return the next argument, // see getopt(3) for more info. r = getopt_long(argc, argv, "t:f:u:", long_options, &index); // No more arguments if (r == -1) break; switch(r) { case 't': // do something with the argument, optarg is a global, external // variable that will point to the parameter value handle_to(optarg); break; // And so on } } }
osso_return_t osso_application_unset_top_cb | ( | osso_context_t * | osso, | |
osso_application_top_cb_f * | cb, | |||
gpointer | data | |||
) |
This function unregisters a top event callback function.
osso | The library context as returned by osso_initialize. | |
cb | The callback function. | |
data | The same pointer that was used with the call to osso_application_set_top_cb |