diff options
author | Ted Gould <ted@canonical.com> | 2009-10-05 14:41:33 -0400 |
---|---|---|
committer | Ted Gould <ted@canonical.com> | 2009-10-05 14:41:33 -0400 |
commit | 16e4975a08b5c1024cb974d0785e51eca3c0ab48 (patch) | |
tree | c53a736601744541ba842787516d0d2576cdb3eb /tools | |
parent | 15658f9f9026a02a87d251aa0128df8ce382ddb9 (diff) | |
download | libdbusmenu-16e4975a08b5c1024cb974d0785e51eca3c0ab48.tar.gz libdbusmenu-16e4975a08b5c1024cb974d0785e51eca3c0ab48.tar.bz2 libdbusmenu-16e4975a08b5c1024cb974d0785e51eca3c0ab48.zip |
Adding preferences for the dbus stuff.
Diffstat (limited to 'tools')
-rw-r--r-- | tools/dbusmenu-dumper.c | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/tools/dbusmenu-dumper.c b/tools/dbusmenu-dumper.c index 0277fd0..753c682 100644 --- a/tools/dbusmenu-dumper.c +++ b/tools/dbusmenu-dumper.c @@ -25,12 +25,53 @@ with this program. If not, see <http://www.gnu.org/licenses/>. #include <libdbusmenu-glib/client.h> #include <libdbusmenu-glib/menuitem.h> +static gchar * dbusname = NULL; +static gchar * dbusobject = NULL; +static gboolean +option_dbusname (const gchar * arg, const gchar * value, gpointer data, GError ** error) +{ + if (dbusname != NULL) { + g_set_error(error, G_OPTION_ERROR, G_OPTION_ERROR_BAD_VALUE, "DBus name already set to '%s' can't reset it to '%s'.", dbusname, value); + return FALSE; + } + + dbusname = g_strdup(value); + return TRUE; +} + +static gboolean +option_dbusobject (const gchar * arg, const gchar * value, gpointer data, GError ** error) +{ + if (dbusobject != NULL) { + g_set_error(error, G_OPTION_ERROR, G_OPTION_ERROR_BAD_VALUE, "DBus name already set to '%s' can't reset it to '%s'.", dbusobject, value); + return FALSE; + } + dbusobject = g_strdup(value); + return TRUE; +} + +static GOptionEntry general_options[] = { + {"dbus-name", 'd', 0, G_OPTION_ARG_CALLBACK, option_dbusname, "The name of the program to connect to (i.e. org.test.bob", "dbusname"}, + {"dbus-object", 'o', 0, G_OPTION_ARG_CALLBACK, option_dbusobject, "The path to the Dbus object (i.e /org/test/bob/alvin)", "dbusobject"} +}; int main (int argc, char ** argv) { + GError * error = NULL; + GOptionContext * context; + + context = g_option_context_new("- Grab the entires in a DBus Menu"); + + g_option_context_add_main_entries(context, general_options, "dbusmenu-dumper"); + + if (!g_option_context_parse(context, &argc, &argv, &error)) { + g_print("option parsing failed: %s\n", error->message); + g_error_free(error); + return 1; + } return 0; } |