~ubuntu-branches/ubuntu/utopic/xneur/utopic

« back to all changes in this revision

Viewing changes to lib/notify/osd.c

  • Committer: Bazaar Package Importer
  • Author(s): Alexander GQ Gerasiov
  • Date: 2009-08-21 15:46:47 UTC
  • mfrom: (1.1.5 upstream) (2.2.2 squeeze)
  • Revision ID: james.westby@ubuntu.com-20090821154647-tkntx3xle87fnqoi
Tags: 0.9.5.1-2
* debian/* switching to CDBS.
* Added 05_nonewline_fix.patch: fix building with gcc4.1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 *  This program is free software; you can redistribute it and/or modify
 
3
 *  it under the terms of the GNU General Public License as published by
 
4
 *  the Free Software Foundation; either version 2 of the License, or
 
5
 *  (at your option) any later version.
 
6
 *
 
7
 *  This program is distributed in the hope that it will be useful,
 
8
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 
9
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
10
 *  GNU General Public License for more details.
 
11
 *
 
12
 *  You should have received a copy of the GNU General Public License
 
13
 *  along with this program; if not, write to the Free Software
 
14
 *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
 
15
 *
 
16
 *  Copyright (C) 2006-2009 XNeur Team
 
17
 *
 
18
 */
 
19
 
 
20
#ifdef HAVE_CONFIG_H
 
21
#  include "config.h"
 
22
#endif
 
23
 
 
24
#include <stdlib.h>
 
25
 
 
26
#ifdef WITH_XOSD
 
27
 
 
28
#include <xosd.h>
 
29
#include <pthread.h>
 
30
#include <stdio.h>
 
31
#include <string.h>
 
32
#include <stdarg.h>
 
33
 
 
34
#include "xnconfig.h"
 
35
 
 
36
#include "debug.h"
 
37
#include "log.h"
 
38
 
 
39
#include "osd.h"
 
40
 
 
41
extern struct _xneur_config *xconfig;
 
42
 
 
43
static void osd_show_thread(void *osd_text)
 
44
{
 
45
        xosd *osd = xosd_create(1);
 
46
 
 
47
        xosd_set_font(osd, xconfig->osd_font);
 
48
        xosd_set_colour(osd, "Red");
 
49
        xosd_set_timeout(osd, 2);
 
50
        xosd_set_shadow_offset(osd, 1);
 
51
        xosd_set_align(osd, XOSD_right);
 
52
 
 
53
        xosd_display(osd, 0, XOSD_string, (char *) osd_text);
 
54
 
 
55
        xosd_wait_until_no_display(osd);
 
56
        xosd_destroy(osd);
 
57
        
 
58
        free(osd_text);
 
59
}
 
60
 
 
61
void osd_show(char *osd_text)
 
62
{
 
63
        if (!xconfig->show_osd)
 
64
        {
 
65
                free(osd_text);
 
66
                return;
 
67
        }
 
68
        
 
69
        pthread_attr_t osd_thread_attr;
 
70
        pthread_attr_init(&osd_thread_attr);
 
71
        pthread_attr_setdetachstate(&osd_thread_attr, PTHREAD_CREATE_DETACHED);
 
72
 
 
73
        log_message(DEBUG, _("Show OSD \"%s\""), osd_text);
 
74
 
 
75
        pthread_t osd_thread;
 
76
        pthread_create(&osd_thread, &osd_thread_attr, (void *) &osd_show_thread, osd_text);
 
77
 
 
78
        pthread_attr_destroy(&osd_thread_attr);
 
79
}
 
80
 
 
81
#else /* WITH_XOSD */
 
82
 
 
83
void osd_show(char *osd_text)
 
84
{
 
85
        free(osd_text);
 
86
}
 
87
 
 
88
#endif /* WITH_XOSD */