From 16e4975a08b5c1024cb974d0785e51eca3c0ab48 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 5 Oct 2009 14:41:33 -0400 Subject: Adding preferences for the dbus stuff. --- tools/dbusmenu-dumper.c | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) (limited to 'tools') 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 . #include #include +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; } -- cgit v1.2.3