summaryrefslogtreecommitdiffstats
path: root/src/main.c
blob: b48886f0acbb537e2c7fe4c486b7bec5a64862fc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
/*
 * Application entry point
 *
 * Copyright (C) 2017  Patrick McDermott
 *
 * This file is part of Marquee.
 *
 * Marquee is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * Marquee 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 General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with Marquee.  If not, see <http://www.gnu.org/licenses/>.
 */

#ifdef HAVE_CONFIG_H
#include <config.h>
#endif

#include <stdlib.h>

#include <gtk/gtk.h>

#include "application.h"

extern const char *PACKAGE_VERSION_GIT;

static const gchar *opt_profile = "default";
static gboolean opt_version;
static const gchar **opt_uris;

static GOptionEntry entries[] = {
	{"profile", 'P', G_OPTION_FLAG_NONE, G_OPTION_ARG_STRING,
		&opt_profile,
		"Load configuration and browsing data from PROFILE",
		"PROFILE"},
	{"version", 'V', G_OPTION_FLAG_NONE, G_OPTION_ARG_NONE,
		&opt_version,
		"Show application version",
		NULL},
	{G_OPTION_REMAINING, '\0',
		G_OPTION_FLAG_NONE, G_OPTION_ARG_STRING_ARRAY,
		&opt_uris,
		"URIs",
		NULL},
	{NULL}
};

int
main(int argc, char *argv[])
{
	GError        *error;
	MqApplication *application;

	if (G_UNLIKELY(!gtk_init_with_args(&argc, &argv, "[URI]", entries, NULL,
					&error))) {
		g_print("%s: %s\n", PACKAGE, error->message);
		return EXIT_FAILURE;
	}

	if (G_UNLIKELY(opt_version)) {
		g_print("%s %s%s\n", PACKAGE_NAME, PACKAGE_VERSION,
			PACKAGE_VERSION_GIT);
		g_print("Copyright (C) %s  %s\n", "2017", "Patrick McDermott");
		g_print("License GPLv3+: GNU GPL version 3 or later "
			"<http://gnu.org/licenses/gpl.html>.\n"
			"This is free software: you are free to change and "
			"redistribute it.\n"
			"There is NO WARRANTY, to the extent permitted by "
			"law.\n\n");
		g_print("Please report bugs to <%s>.\n", PACKAGE_BUGREPORT);
		return EXIT_SUCCESS;
	}

	g_set_application_name(PACKAGE_NAME);

	application = mq_application_new(opt_profile);
	mq_application_add_window(application, opt_uris);

	return mq_application_main(application);
}