Updated Spanish translation
[gnome-utils.git] / logview / logview-main.c
blobffa30a46274142404e4fb12d9a72e83243bd4c34
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.
22 #include "config.h"
24 #include <stdlib.h>
26 #include <glib/gi18n.h>
27 #include <glib.h>
29 #include <gtk/gtk.h>
31 #include "logview-app.h"
33 /* log files specified on the command line */
34 static char **log_files = NULL;
36 static void
37 app_quit_cb (LogviewApp *app,
38 gpointer user_data)
40 gtk_main_quit ();
43 static void
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 (),
49 VERSION);
51 exit (0);
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...]") },
64 { NULL },
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));
73 return context;
76 int
77 main (int argc, char *argv[])
79 GError *error = NULL;
80 GOptionContext *context;
81 LogviewApp *app;
83 bindtextdomain (GETTEXT_PACKAGE, GNOMELOCALEDIR);
84 bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
85 textdomain (GETTEXT_PACKAGE);
87 g_thread_init (NULL);
89 context = create_option_context ();
91 g_option_context_parse (context, &argc, &argv, &error);
93 if (error) {
94 g_critical ("Unable to parse arguments: %s", error->message);
95 g_error_free (error);
96 g_option_context_free (context);
98 exit (1);
101 g_option_context_free (context);
102 g_set_application_name (_("Log Viewer"));
104 app = logview_app_get ();
106 if (!app) {
107 g_critical ("Unable to create the user interface.");
109 exit (1);
110 } else {
111 g_signal_connect (app, "app-quit",
112 G_CALLBACK (app_quit_cb), NULL);
115 logview_app_initialize (app, log_files);
117 gtk_main ();
119 g_object_unref (app);
121 return EXIT_SUCCESS;