~ubuntu-branches/ubuntu/dapper/gnome-screensaver/dapper

« back to all changes in this revision

Viewing changes to src/gnome-screensaver.c

  • Committer: Bazaar Package Importer
  • Author(s): Oliver Grawert
  • Date: 2005-10-10 00:18:18 UTC
  • Revision ID: james.westby@ubuntu.com-20051010001818-3mujs05r8rht7xi1
Tags: upstream-0.0.15
ImportĀ upstreamĀ versionĀ 0.0.15

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 8; tab-width: 8 -*-
 
2
 *
 
3
 * Copyright (C) 2004-2005 William Jon McCann <mccann@jhu.edu>
 
4
 *
 
5
 * This program is free software; you can redistribute it and/or
 
6
 * modify it under the terms of the GNU General Public License as
 
7
 * published by the Free Software Foundation; either version 2 of the
 
8
 * License, or (at your option) any later version.
 
9
 *
 
10
 * This program is distributed in the hope that it will be useful, but
 
11
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 
12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 
13
 * 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., 59 Temple Place - Suite 330, Boston, MA
 
18
 * 02111-1307, USA.
 
19
 *
 
20
 * Authors: William Jon McCann <mccann@jhu.edu>
 
21
 *
 
22
 */
 
23
 
 
24
#include "config.h"
 
25
#include <stdlib.h>
 
26
#include <string.h>
 
27
#include <sys/time.h>
 
28
#include <sys/types.h>
 
29
#include <sys/wait.h>
 
30
 
 
31
#include <glib/gi18n.h>
 
32
#include <gtk/gtk.h>
 
33
 
 
34
#include "gnome-screensaver.h"
 
35
#include "gs-monitor.h"
 
36
 
 
37
void
 
38
gnome_screensaver_quit (void)
 
39
{
 
40
        gtk_main_quit ();
 
41
}
 
42
 
 
43
int
 
44
main (int    argc,
 
45
      char **argv)
 
46
{
 
47
        GSMonitor          *monitor;
 
48
        GError             *error = NULL;
 
49
        static gboolean     show_version = FALSE;
 
50
        static GOptionEntry entries []   = {
 
51
                { "version", 0, 0, G_OPTION_ARG_NONE, &show_version,
 
52
                  N_("Version of this application"), NULL },
 
53
                { NULL }
 
54
        };
 
55
 
 
56
#ifdef ENABLE_NLS
 
57
        bindtextdomain (GETTEXT_PACKAGE, GNOMELOCALEDIR);
 
58
# ifdef HAVE_BIND_TEXTDOMAIN_CODESET
 
59
        bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
 
60
# endif 
 
61
        textdomain (GETTEXT_PACKAGE);
 
62
#endif 
 
63
 
 
64
        if (! gtk_init_with_args (&argc, &argv, NULL, entries, NULL, &error)) {
 
65
                if (error) {
 
66
                        g_warning ("%s", error->message);
 
67
                        g_error_free (error);
 
68
                } else {
 
69
                        g_warning ("Unable to initialize GTK+");
 
70
                }
 
71
                exit (1);
 
72
        }
 
73
 
 
74
        if (show_version) {
 
75
                g_print ("%s %s\n", argv [0], VERSION);
 
76
                exit (1);
 
77
        }
 
78
 
 
79
        monitor = gs_monitor_new ();
 
80
 
 
81
        if (! monitor)
 
82
                exit (1);
 
83
 
 
84
        error = NULL;
 
85
        if (! gs_monitor_start (monitor, &error)) {
 
86
                if (error) {
 
87
                        g_warning ("%s", error->message);
 
88
                        g_error_free (error);
 
89
                } else {
 
90
                        g_warning ("Unable to start screensaver");
 
91
                }
 
92
                exit (1);
 
93
        }
 
94
 
 
95
        gtk_main ();
 
96
 
 
97
        g_object_unref (monitor);
 
98
 
 
99
        return 0;
 
100
}