blob: c37f0c7e6e44005c6c3288ac58b77fd3b52aa169 [file] [log] [blame]
Stepan Salenikovichd81ef292015-02-17 18:47:37 -05001/*
2 * Copyright (C) 2013-2015 Savoir-Faire Linux Inc.
3 * Author: Tristan Matthews <tristan.matthews@savoirfairelinux.com>
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 3 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Additional permission under GNU GPL version 3 section 7:
20 *
21 * If you modify this program, or any covered work, by linking or
22 * combining it with the OpenSSL project's OpenSSL library (or a
23 * modified version of that library), containing parts covered by the
24 * terms of the OpenSSL or SSLeay licenses, Savoir-Faire Linux Inc.
25 * grants you additional permission to convey the resulting work.
26 * Corresponding Source for a non-source form of such a combination
27 * shall include the source code for the parts of OpenSSL used as well
28 * as that of the covered work.
29 */
30
31#include "ring_client_options.h"
32
33/* TODO: add header for auto generated config
34 * #include "config.h"
35 */
36
37#include <glib/gi18n.h>
38#include <gtk/gtk.h>
39#include <stdlib.h>
40
41G_GNUC_NORETURN static gboolean
42option_version_cb(G_GNUC_UNUSED const gchar *option_name,
43 G_GNUC_UNUSED const gchar *value,
44 G_GNUC_UNUSED gpointer data,
45 G_GNUC_UNUSED GError **error)
46{
47 /* TODO: replace with auto generated version */
48 g_print("%s\n", "0.1");
49 exit(EXIT_SUCCESS);
50}
51
52static gboolean
53option_debug_cb(G_GNUC_UNUSED const gchar *option_name,
54 G_GNUC_UNUSED const gchar *value,
55 G_GNUC_UNUSED gpointer data,
56 G_GNUC_UNUSED GError **error)
57{
58 g_setenv("G_MESSAGES_DEBUG", "all", TRUE);
59 g_debug("debug enabled");
60 return TRUE;
61}
62
63static const GOptionEntry all_options[] = {
64 {"version", 'v', G_OPTION_FLAG_NO_ARG, G_OPTION_ARG_CALLBACK, option_version_cb, NULL, NULL},
65 {"debug", 'd', G_OPTION_FLAG_NO_ARG, G_OPTION_ARG_CALLBACK, option_debug_cb, "Enable debug", NULL},
66 {NULL} /* list must be NULL-terminated */
67};
68
69GOptionContext *
70ring_client_options_get_context()
71{
72 /* TODO: for some reason the given description and added options aren't printed
73 * when '--help' is invoked... possibly a GTK bug.
74 */
75 GOptionContext *context = g_option_context_new("- GNOME client for Ring");
Stepan Salenikovich36c025c2015-03-03 19:06:44 -050076 g_option_context_set_ignore_unknown_options(context, TRUE);
Stepan Salenikovichd81ef292015-02-17 18:47:37 -050077
78 /* TODO: add translation domain */
79 g_option_context_add_main_entries(context, all_options, NULL);
80 g_option_context_add_group(context, gtk_get_option_group(TRUE));
81 return context;
82}