diff options
Diffstat (limited to 'bin/tools/common.c')
-rw-r--r-- | bin/tools/common.c | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/bin/tools/common.c b/bin/tools/common.c new file mode 100644 index 0000000..6ada379 --- /dev/null +++ b/bin/tools/common.c @@ -0,0 +1,60 @@ +/* Copyright (C) 2011-2013 Matthias Vogelgesang <matthias.vogelgesang@kit.edu> + (Karlsruhe Institute of Technology) + + This library is free software; you can redistribute it and/or modify it + under the terms of the GNU Lesser General Public License as published by the + Free Software Foundation; either version 2.1 of the License, or (at your + option) any later version. + + This library is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS + FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more + details. + + You should have received a copy of the GNU Lesser General Public License along + with this library; if not, write to the Free Software Foundation, Inc., 51 + Franklin St, Fifth Floor, Boston, MA 02110, USA */ + +#include "common.h" + + +static gchar * +get_camera_list (UcaPluginManager *manager) +{ + GList *types; + GString *str; + + manager = uca_plugin_manager_new (); + types = uca_plugin_manager_get_available_cameras (manager); + str = g_string_new ("[ "); + + if (types != NULL) { + for (GList *it = g_list_first (types); it != NULL; it = g_list_next (it)) { + gchar *name = (gchar *) it->data; + + if (g_list_next (it) == NULL) + g_string_append_printf (str, "%s ]", name); + else + g_string_append_printf (str, "%s, ", name); + } + } + else { + g_string_append (str, "]"); + } + + g_object_unref (manager); + return g_string_free (str, FALSE); +} + +GOptionContext * +uca_option_context_new (UcaPluginManager *manager) +{ + GOptionContext *context; + gchar *camera_list; + + camera_list = get_camera_list (manager); + context = g_option_context_new (camera_list); + g_free (camera_list); + + return context; +} |