aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--tools/dbusmenu-dumper.c41
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;
}