~ubuntu-branches/ubuntu/jaunty/libnotify/jaunty

« back to all changes in this revision

Viewing changes to tests/test-replace.c

  • Committer: Bazaar Package Importer
  • Author(s): Michael Vogt
  • Date: 2006-01-02 15:56:18 UTC
  • mfrom: (1.1.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20060102155618-6sbpi0enbolsnng6
Tags: 0.3.0-0ubuntu1
* New upstream release
* works with new notify-daemon, contains a new (more gtk-ish) API

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*
2
 
 * @file tests/test-default-action.c Unit test: atomic replacements
3
 
 *
4
 
 * @Copyright (C) 2004 Mike Hearn <mike@navi.cx>
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
1
#include <libnotify/notify.h>
23
2
#include <stdio.h>
24
3
#include <unistd.h>
 
4
#include <glib.h>
25
5
 
26
6
int main() {
27
 
        notify_init("Replace Test");
28
 
 
29
 
        NotifyHandle *n = notify_send_notification(NULL, // replaces nothing
30
 
                                                   NULL,
31
 
                                                   NOTIFY_URGENCY_NORMAL,
32
 
                                                   "Summary", "Content",
33
 
                                                   NULL, // no icon
34
 
                                                   FALSE, 0, // does not expire
35
 
                                                                                           NULL, // no hints
36
 
                                                   NULL, // no user data
37
 
                                                   0); // no actions
38
 
 
39
 
        if (!n) {
40
 
                fprintf(stderr, "failed to send notification\n");
41
 
                return 1;
42
 
        }
43
 
 
44
 
 
45
 
        sleep(5);
46
 
 
47
 
        notify_send_notification(n, NULL, NOTIFY_URGENCY_NORMAL,
48
 
                                 "Second Summary", "Second Content",
49
 
                                 NULL, TRUE, 5, NULL, NULL, 0);
50
 
 
51
 
        return 0;
 
7
    NotifyNotification *n;
 
8
    GError *error;
 
9
    error = NULL;
 
10
 
 
11
    g_type_init ();
 
12
 
 
13
    notify_init("Replace Test");
 
14
   
 
15
    n = notify_notification_new ("Summary", "First message", 
 
16
                                  NULL,  //no icon
 
17
                                  NULL); //don't attach to widget
 
18
 
 
19
   
 
20
    notify_notification_set_timeout (n, 0); //don't timeout
 
21
    
 
22
    if (!notify_notification_show (n, &error)) {
 
23
        fprintf(stderr, "failed to send notification: %s\n", error->message);
 
24
        g_error_free (error);
 
25
        return 1;
 
26
    }
 
27
 
 
28
    sleep(3);
 
29
 
 
30
    notify_notification_update (n, "Second Summary", 
 
31
                                "First mesage was replaced", NULL); 
 
32
 
 
33
    if (!notify_notification_show (n, &error)) {
 
34
        fprintf(stderr, "failed to send notification: %s\n", error->message);
 
35
        g_error_free (error);
 
36
        return 1;
 
37
    }
 
38
 
 
39
    return 0;
52
40
}