1
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
3
* Copyright (C) 2002 CodeFactory AB
4
* Copyright (C) 2002-2003 Richard Hult <richard@imendio.com>
6
* This program is free software; you can redistribute it and/or
7
* modify it under the terms of the GNU General Public License as
8
* published by the Free Software Foundation; either version 2 of the
9
* License, or (at your option) any later version.
11
* This program is distributed in the hope that it will be useful,
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14
* General Public License for more details.
16
* You should have received a copy of the GNU General Public
17
* License along with this program; if not, write to the
18
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
19
* Boston, MA 02110-1301, USA.
25
#include <glib/gi18n.h>
29
#include "drw-selection.h"
32
gboolean debug = FALSE;
34
#ifndef HAVE_APP_INDICATOR
38
#if GTK_CHECK_VERSION (3, 0, 0)
39
Screen *xscreen = DefaultScreenOfDisplay (gdk_x11_display_get_xdisplay(gdk_display_get_default()));
41
Screen *xscreen = DefaultScreenOfDisplay (gdk_display);
44
char *selection_atom_name;
46
selection_atom_name = g_strdup_printf ("_NET_SYSTEM_TRAY_S%d",
47
XScreenNumberOfScreen (xscreen));
48
selection_atom = XInternAtom (DisplayOfScreen (xscreen), selection_atom_name, False);
49
g_free (selection_atom_name);
51
if (XGetSelectionOwner (DisplayOfScreen (xscreen), selection_atom)) {
57
#endif /* HAVE_APP_INDICATOR */
60
main (int argc, char *argv[])
63
DrwSelection *selection;
64
gboolean no_check = FALSE;
65
const GOptionEntry options[] = {
66
{ "debug", 'd', 0, G_OPTION_ARG_NONE, &debug,
67
N_("Enable debugging code"), NULL },
68
{ "no-check", 'n', 0, G_OPTION_ARG_NONE, &no_check,
69
N_("Don't check whether the notification area exists"), NULL },
72
GOptionContext *option_context;
76
bindtextdomain (GETTEXT_PACKAGE, MATELOCALEDIR);
77
bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
78
textdomain (GETTEXT_PACKAGE);
80
option_context = g_option_context_new (NULL);
81
#if GLIB_CHECK_VERSION (2, 12, 0)
82
g_option_context_set_translation_domain (option_context, GETTEXT_PACKAGE);
84
g_option_context_add_main_entries (option_context, options, GETTEXT_PACKAGE);
85
g_option_context_add_group (option_context, gtk_get_option_group (TRUE));
87
retval = g_option_context_parse (option_context, &argc, &argv, &error);
88
g_option_context_free (option_context);
90
g_print ("%s\n", error->message);
95
g_set_application_name (_("Typing Monitor"));
96
gtk_window_set_default_icon_name ("mate-typing-monitor");
98
selection = drw_selection_start ();
99
if (!drw_selection_is_master (selection)) {
100
g_message ("The typing monitor is already running, exiting.");
104
#ifndef HAVE_APP_INDICATOR
105
if (!no_check && !have_tray ()) {
108
dialog = gtk_message_dialog_new (
112
_("The typing monitor uses the notification area to display "
113
"information. You don't seem to have a notification area "
114
"on your panel. You can add it by right-clicking on your "
115
"panel and choosing 'Add to panel', selecting 'Notification "
116
"area' and clicking 'Add'."));
118
gtk_dialog_run (GTK_DIALOG (dialog));
120
gtk_widget_destroy (dialog);
122
#endif /* HAVE_APP_INDICATOR */
124
drwright = drwright_new ();