/[paths]/src/egg_link.c
ViewVC logotype

Contents of /src/egg_link.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 57 - (show annotations)
Sat Aug 25 05:43:31 2012 UTC (7 years, 1 month ago) by ben
File MIME type: text/plain
File size: 885 byte(s)
various drawing tests
1 #include <stdlib.h>
2 #include <glib.h>
3 #include <cairo/cairo.h>
4 #include <gtk/gtk.h>
5
6 #include "egg_link.h"
7
8 G_DEFINE_TYPE (EggLink, egg_link, GTK_TYPE_DRAWING_AREA);
9
10 /* object constructor */
11 static void egg_link_init(EggLink *link)
12 {
13 gtk_widget_set_has_window (GTK_WIDGET(link), FALSE);
14 gtk_widget_set_size_request (GTK_WIDGET(link), 50, 50);
15 }
16
17 /* draw handler */
18 static gboolean egg_link_draw (GtkWidget *link, cairo_t *cr)
19 {
20 GtkAllocation a;
21
22 gtk_widget_get_allocation (link, &a);
23
24 cairo_move_to(cr, 0, 0);
25
26 cairo_line_to(cr, a.width, a.height);
27 cairo_stroke(cr);
28
29 return FALSE;
30 }
31
32
33 /* class constructor */
34 static void egg_link_class_init (EggLinkClass *class)
35 {
36 GtkWidgetClass *widget_class;
37
38 widget_class = GTK_WIDGET_CLASS(class);
39
40 widget_class->draw = egg_link_draw;
41 }
42
43 /* public API */
44
45 GtkWidget *egg_link_new(void)
46 {
47 return g_object_new(EGG_TYPE_LINK, NULL);
48 }
49

  ViewVC Help
Powered by ViewVC 1.1.26