~ted/ubuntu/lucid/libnotify/no-error-message

« back to all changes in this revision

Viewing changes to tests/test-xy-actions.c

  • Committer: Bazaar Package Importer
  • Author(s): Gustavo Franco
  • Date: 2006-05-16 10:33:01 UTC
  • mfrom: (1.1.4 upstream)
  • Revision ID: james.westby@ubuntu.com-20060516103301-gn9omm7w3meamojx
Tags: 0.4.0-1
* New upstream release.
* debian/patches/notify-send_ppc.patch: removed
  (bug fixed by upstream)
* debian/rules: simple-patchsys include removed, 
  there are no patches left.
* debian/control:
  + Bump up Standards Version to 3.7.2
  + Fix lintian warning replacing > by >=
    - obsolete-relation-form depends: libdbus-glib-1-dev (> 0.35)
  

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * @file tests/test-xy-actions.c Unit test: X, Y hints and actions
 
3
 *
 
4
 * @Copyright (C) 2006 Christian Hammond <chipx86@chipx86.com>
 
5
 *
 
6
 * This library is free software; you can redistribute it and/or
 
7
 * modify it under the terms of the GNU Lesser General Public
 
8
 * License as published by the Free Software Foundation; either
 
9
 * version 2.1 of the License, or (at your option) any later version.
 
10
 *
 
11
 * This library 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
 * Lesser General Public License for more details.
 
15
 *
 
16
 * You should have received a copy of the GNU Lesser General Public
 
17
 * License along with this library; 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 <libnotify/notify.h>
 
23
#include <stdio.h>
 
24
#include <unistd.h>
 
25
 
 
26
#define DBUS_API_SUBJECT_TO_CHANGE
 
27
#include <dbus/dbus.h>
 
28
#include <dbus/dbus-glib.h>
 
29
#include <dbus/dbus-glib-lowlevel.h>
 
30
 
 
31
static GMainLoop *loop;
 
32
 
 
33
static void
 
34
action_cb(NotifyNotification *n, const char *action)
 
35
{
 
36
        printf("You clicked '%s'\n", action);
 
37
 
 
38
        g_main_loop_quit(loop);
 
39
}
 
40
 
 
41
int
 
42
main(int argc, char **argv)
 
43
{
 
44
        NotifyNotification *n;
 
45
        DBusConnection *conn;
 
46
 
 
47
        notify_init("XY");
 
48
 
 
49
        conn = dbus_bus_get(DBUS_BUS_SESSION, NULL);
 
50
        loop = g_main_loop_new(NULL, FALSE);
 
51
 
 
52
        dbus_connection_setup_with_g_main(conn, NULL);
 
53
 
 
54
        n = notify_notification_new("System update available",
 
55
                                                                "New system updates are available. It is "
 
56
                                                                "recommended that you install the updates.",
 
57
                                                                NULL, NULL);
 
58
 
 
59
        notify_notification_set_hint_int32(n, "x", 600);
 
60
        notify_notification_set_hint_int32(n, "y", 10);
 
61
        notify_notification_add_action(n, "help", "Help",
 
62
                                                                   (NotifyActionCallback)action_cb,
 
63
                                                                   NULL, NULL);
 
64
        notify_notification_add_action(n, "update", "Update",
 
65
                                                                   (NotifyActionCallback)action_cb,
 
66
                                                                   NULL, NULL);
 
67
 
 
68
        if (!notify_notification_show(n, NULL)) {
 
69
                fprintf(stderr, "failed to send notification\n");
 
70
                return 1;
 
71
        }
 
72
 
 
73
        g_main_loop_run(loop);
 
74
 
 
75
        return 0;
 
76
}