1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
|
/* ghosd -- OSD with fake transparency, cairo, and pango.
* Copyright (C) 2006 Evan Martin <martine@danga.com>
*/
#include <stdio.h>
#include <cairo/cairo.h>
#include <pango/pangocairo.h>
#include <time.h>
#include <unistd.h>
#include "example-shared.h"
#include <X11/Xlib.h>
#include <ghosd/ghosd.h>
#include <ghosd/ghosd-text.h>
int posX = -50;
int posY = -50;
char displayText[200] = "default message";
float red = 1.0;
float green = 1.0;
float blue = 1.0;
int ftSize = 30;
int fadIn = 500;
int fadOt = 3300;
static void
render(Ghosd *ghosd, cairo_t *cr, void* data) {
PangoLayout *layout = data;
/* drop shadow! */
cairo_set_source_rgba(cr, 0, 0, 0, 0.5);
cairo_move_to(cr, 2, 2);
pango_cairo_show_layout(cr, layout);
/* and the actual text. */
cairo_set_source_rgba(cr, red, green, blue, 1.0);
cairo_move_to(cr, 0, 0);
pango_cairo_show_layout(cr, layout);
}
int main(int argc, char* argv[]) {
Ghosd *ghosd;
char *filename = NULL;
filename="/usr/share/pixmaps/gnome-logo-large.png\n";
cairo_surface_t* layout = cairo_image_surface_create_from_png(filename);
g_type_init();
PangoContext *context;
// PangoLayout *layout;
context = pango_cairo_font_map_create_context(
PANGO_CAIRO_FONT_MAP(pango_cairo_font_map_get_default()));
// layout = pango_layout_new(context);
if( argc == 10 )
{
posX = atoi(argv[2]);
posY = atoi(argv[3]);
red = atoi(argv[4]);
green = atoi(argv[5]);
blue = atoi(argv[6]);
ftSize = atoi(argv[7]);
fadIn = atoi(argv[8]);
fadOt = atoi(argv[9]);
sprintf(displayText,
"<span font_desc='Trebuchet %d'>%s</span>", ftSize, argv[1]);
}else{
sprintf(displayText,
"<span font_desc='Trebuchet 30'>Incomplete command</span>");
}
pango_layout_set_markup(layout, displayText, -1 );
ghosd = ghosd_new();
ghosd_text_set_position(ghosd, posX, posY, layout);
ghosd_set_render(ghosd, render, layout);
ghosd_flash(ghosd, fadIn, fadOt);
return 0;
}
/* vim: set ts=2 sw=2 et cino=(0 : */
|