1 /* -*- Mode: C; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2; -*- */
2 /* logview-main.c - logview main
4 * Copyright (C) 2005 Vincent Noel <vnoel@cox.net>
5 * Copyright (C) 2008 Cosimo Cecchi <cosimoc@gnome.org>
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License as
9 * published by the Free Software Foundation; either version 2 of the
10 * License, or (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
26 #include <glib/gi18n.h>
31 #include "logview-app.h"
33 /* log files specified on the command line */
34 static char **log_files
= NULL
;
37 app_quit_cb (LogviewApp
*app
,
44 logview_show_version_and_quit (void)
46 g_print ("%s - Version %s\n"
47 "Copyright (C) 2004-2008 Vincent Noel, Cosimo Cecchi and others.\n",
48 g_get_application_name (),
54 static GOptionContext
*
55 create_option_context (void)
57 GOptionContext
*context
;
59 const GOptionEntry entries
[] = {
60 { "version", 'V', G_OPTION_FLAG_NO_ARG
, G_OPTION_ARG_CALLBACK
,
61 logview_show_version_and_quit
, N_("Show the application's version"), NULL
},
62 { G_OPTION_REMAINING
, '\0', 0, G_OPTION_ARG_FILENAME_ARRAY
, &log_files
,
63 NULL
, N_("[LOGFILE...]") },
67 context
= g_option_context_new (_(" - Browse and monitor logs"));
68 g_option_context_set_translation_domain (context
, GETTEXT_PACKAGE
);
69 g_option_context_add_main_entries (context
, entries
, GETTEXT_PACKAGE
);
70 g_option_context_set_ignore_unknown_options (context
, TRUE
);
71 g_option_context_add_group (context
, gtk_get_option_group (TRUE
));
77 main (int argc
, char *argv
[])
80 GOptionContext
*context
;
83 bindtextdomain (GETTEXT_PACKAGE
, GNOMELOCALEDIR
);
84 bind_textdomain_codeset (GETTEXT_PACKAGE
, "UTF-8");
85 textdomain (GETTEXT_PACKAGE
);
89 context
= create_option_context ();
91 g_option_context_parse (context
, &argc
, &argv
, &error
);
94 g_critical ("Unable to parse arguments: %s", error
->message
);
96 g_option_context_free (context
);
101 g_option_context_free (context
);
102 g_set_application_name (_("Log Viewer"));
104 app
= logview_app_get ();
107 g_critical ("Unable to create the user interface.");
111 g_signal_connect (app
, "app-quit",
112 G_CALLBACK (app_quit_cb
), NULL
);
115 logview_app_initialize (app
, log_files
);
119 g_object_unref (app
);