summaryrefslogtreecommitdiff
path: root/src/logdiag.c
blob: c9c6af29b8533a96481733418fc3cb2fa2a516e6 (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
/*
 * logdiag.c -- logdiag main source file.
 *
 * This file is a part of logdiag.
 * Copyright Přemysl Janouch 2010 - 2011. All rights reserved.
 *
 * See the file LICENSE for licensing information.
 *
 */

#include <gtk/gtk.h>
#include <locale.h>

#include "config.h"

#include "ld-window-main.h"


int
main (int argc, char *argv[])
{
	GError *error;
#ifdef _WIN32
	gchar *install_dir;

	install_dir = g_win32_get_package_installation_directory_of_module (NULL);
	if (install_dir)
	{
		g_chdir (install_dir);
		g_free (install_dir);
	}
#endif

	setlocale (LC_ALL, "");

	bindtextdomain (GETTEXT_DOMAIN, GETTEXT_DIRNAME);
	bind_textdomain_codeset (GETTEXT_DOMAIN, "UTF-8");
	textdomain (GETTEXT_DOMAIN);

	error = NULL;
	gtk_init_with_args (&argc, &argv,
		N_("[FILE] - Schematic editor"), NULL, GETTEXT_DOMAIN, &error);
	if (error)
	{
		g_warning ("%s", error->message);
		g_error_free (error);
		return 1;
	}

	gtk_window_set_default_icon_name (PROJECT_NAME);

	/* TODO: Accept multiple files. */
	if (argc < 2)
		ld_window_main_new (NULL);
	else
	{
		gchar *arg_utf8, *arg_filename;

		arg_utf8 = g_locale_to_utf8 (argv[1], -1, NULL, NULL, &error);
		if (error)
		{
			g_warning ("%s", error->message);
			g_error_free (error);
			return 1;
		}
		arg_filename = g_filename_from_utf8 (arg_utf8, -1, NULL, NULL, &error);
		if (error)
		{
			g_warning ("%s", error->message);
			g_error_free (error);
			return 1;
		}
		ld_window_main_new (arg_filename);
		g_free (arg_filename);
		g_free (arg_utf8);
	}

	gtk_main ();
	return 0;
}