~kroq-gar78/ubuntu/precise/gnome-control-center/fix-885947

« back to all changes in this revision

Viewing changes to typing-break/main.c

  • Committer: Bazaar Package Importer
  • Author(s): Rodrigo Moya
  • Date: 2011-05-17 10:47:27 UTC
  • mfrom: (0.1.11 experimental) (1.1.45 upstream)
  • Revision ID: james.westby@ubuntu.com-20110517104727-lqel6m8vhfw5jby1
Tags: 1:3.0.1.1-1ubuntu1
* Rebase on Debian, remaining Ubuntu changes:
* debian/control:
  - Build-Depend on hardening-wrapper, dpkg-dev and dh-autoreconf
  - Add dependency on ubuntu-system-service
  - Remove dependency on gnome-icon-theme-symbolic
  - Move dependency on apg, gnome-icon-theme-symbolic and accountsservice to
    be a Recommends: until we get them in main
* debian/rules:
  - Use autoreconf
  - Add binary-post-install rule for gnome-control-center-data
  - Run dh-autoreconf
* debian/gnome-control-center.dirs:
* debian/gnome-control-center.links:
  - Add a link to the control center shell for indicators
* debian/patches/00_disable-nm.patch:
  - Temporary patch to disable building with NetworkManager until we get
    the new one in the archive
* debian/patches/01_git_remove_gettext_calls.patch:
  - Remove calls to AM_GNU_GETTEXT, IT_PROG_INTLTOOL should be enough
* debian/patches/01_git_kill_warning.patch:
  - Kill warning
* debian/patches/50_ubuntu_systemwide_prefs.patch:
  - Ubuntu specific proxy preferences
* debian/patches/51_ubuntu_system_keyboard.patch:
  - Implement the global keyboard spec at https://wiki.ubuntu.com/DefaultKeyboardSettings

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
2
 
/*
3
 
 * Copyright (C) 2002 CodeFactory AB
4
 
 * Copyright (C) 2002-2003 Richard Hult <richard@imendio.com>
5
 
 *
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.
10
 
 *
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.
15
 
 *
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., 59 Temple Place - Suite 330,
19
 
 * Boston, MA 02111-1307, USA.
20
 
 */
21
 
 
22
 
#include <config.h>
23
 
#include <string.h>
24
 
#include <stdlib.h>
25
 
#include <glib/gi18n.h>
26
 
#include <gdk/gdkx.h>
27
 
#include <gtk/gtk.h>
28
 
 
29
 
#include "drw-selection.h"
30
 
#include "drwright.h"
31
 
 
32
 
gboolean debug = FALSE;
33
 
 
34
 
#ifndef HAVE_APP_INDICATOR
35
 
static gboolean
36
 
have_tray (void)
37
 
{
38
 
        Screen *xscreen = DefaultScreenOfDisplay (gdk_display);
39
 
        Atom    selection_atom;
40
 
        char   *selection_atom_name;
41
 
        
42
 
        selection_atom_name = g_strdup_printf ("_NET_SYSTEM_TRAY_S%d",
43
 
                                               XScreenNumberOfScreen (xscreen));
44
 
        selection_atom = XInternAtom (DisplayOfScreen (xscreen), selection_atom_name, False);
45
 
        g_free (selection_atom_name);
46
 
        
47
 
        if (XGetSelectionOwner (DisplayOfScreen (xscreen), selection_atom)) {
48
 
                return TRUE;
49
 
        } else {
50
 
                return FALSE;
51
 
        }
52
 
}
53
 
#endif /* HAVE_APP_INDICATOR */
54
 
 
55
 
int
56
 
main (int argc, char *argv[])
57
 
{
58
 
        DrWright     *drwright;
59
 
        DrwSelection *selection;
60
 
        gboolean      no_check = FALSE;
61
 
        const GOptionEntry options[] = {
62
 
          { "debug", 'd', 0, G_OPTION_ARG_NONE, &debug,
63
 
            N_("Enable debugging code"), NULL },
64
 
          { "no-check", 'n', 0, G_OPTION_ARG_NONE, &no_check,
65
 
            N_("Don't check whether the notification area exists"), NULL },
66
 
          { NULL }
67
 
        };
68
 
        GOptionContext *option_context;
69
 
        GError *error = NULL;
70
 
        gboolean retval;
71
 
 
72
 
        bindtextdomain (GETTEXT_PACKAGE, GNOMELOCALEDIR);  
73
 
        bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
74
 
        textdomain (GETTEXT_PACKAGE);
75
 
 
76
 
        option_context = g_option_context_new (NULL);
77
 
#if GLIB_CHECK_VERSION (2, 12, 0)
78
 
        g_option_context_set_translation_domain (option_context, GETTEXT_PACKAGE);
79
 
#endif
80
 
        g_option_context_add_main_entries (option_context, options, GETTEXT_PACKAGE);
81
 
        g_option_context_add_group (option_context, gtk_get_option_group (TRUE));
82
 
 
83
 
        retval = g_option_context_parse (option_context, &argc, &argv, &error);
84
 
        g_option_context_free (option_context);
85
 
        if (!retval) {
86
 
                g_print ("%s\n", error->message);
87
 
                g_error_free (error);
88
 
                exit (1);
89
 
        }
90
 
 
91
 
        g_set_application_name (_("Typing Monitor"));
92
 
        gtk_window_set_default_icon_name ("typing-monitor");
93
 
 
94
 
        selection = drw_selection_start ();
95
 
        if (!drw_selection_is_master (selection)) {
96
 
                g_message ("The typing monitor is already running, exiting.");
97
 
                return 0;
98
 
        }
99
 
 
100
 
#ifndef HAVE_APP_INDICATOR
101
 
        if (!no_check && !have_tray ()) {
102
 
                GtkWidget *dialog;
103
 
 
104
 
                dialog = gtk_message_dialog_new (
105
 
                        NULL, 0,
106
 
                        GTK_MESSAGE_INFO,
107
 
                        GTK_BUTTONS_CLOSE,
108
 
                        _("The typing monitor uses the notification area to display "
109
 
                          "information. You don't seem to have a notification area "
110
 
                          "on your panel. You can add it by right-clicking on your "
111
 
                          "panel and choosing 'Add to panel', selecting 'Notification "
112
 
                          "area' and clicking 'Add'."));
113
 
                
114
 
                gtk_dialog_run (GTK_DIALOG (dialog));
115
 
 
116
 
                gtk_widget_destroy (dialog);
117
 
        }
118
 
#endif /* HAVE_APP_INDICATOR */
119
 
        
120
 
        drwright = drwright_new ();
121
 
 
122
 
        gtk_main ();
123
 
 
124
 
        return 0;
125
 
}