diff options
Diffstat (limited to 'abs/mv-core/ghosd/ghosd-0.0.1/examples/text.c')
-rw-r--r-- | abs/mv-core/ghosd/ghosd-0.0.1/examples/text.c | 83 |
1 files changed, 83 insertions, 0 deletions
diff --git a/abs/mv-core/ghosd/ghosd-0.0.1/examples/text.c b/abs/mv-core/ghosd/ghosd-0.0.1/examples/text.c new file mode 100644 index 0000000..77f59cd --- /dev/null +++ b/abs/mv-core/ghosd/ghosd-0.0.1/examples/text.c @@ -0,0 +1,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 : */ + |