]> www.fi.muni.cz Git - evince.git/blob - shell/ev-presentation-timer.c
[dualscreen] timer continue, maybe I should remove that text... [dualscreen] cleanup
[evince.git] / shell / ev-presentation-timer.c
1 /* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8; c-indent-level: 8 -*- */
2 /* this file is part of evince, a gnome document viewer
3  *
4  *
5  *  Author:
6  *    Lukas Bezdicka <255993@mail.muni.cz>
7  *
8  * Evince is free software; you can redistribute it and/or modify it
9  * under the terms of the GNU General Public License as published by
10  * the Free Software Foundation; either version 2 of the License, or
11  * (at your option) any later version.
12  *
13  * Evince is distributed in the hope that it will be useful, but
14  * WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16  * General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program; if not, write to the Free Software
20  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
21  */
22
23 #ifdef HAVE_CONFIG_H
24 #include "config.h"
25 #endif
26
27 #include <cairo.h>
28 #include <glib/gi18n.h>
29 #include <gtk/gtk.h>
30 #include <math.h>
31
32 #include "ev-presentation-timer.h"
33
34 struct _EvPresentationTimerPrivate
35 {
36         guint page;
37         guint pages;
38 };
39
40 #define EV_PRESENTATION_TIMER_GET_PRIVATE(object) \
41         (G_TYPE_INSTANCE_GET_PRIVATE ((object), EV_TYPE_PRESENTATION_TIMER, EvPresentationTimerPrivate))
42
43 G_DEFINE_TYPE (EvPresentationTimer, ev_presentation_timer, GTK_TYPE_DRAWING_AREA);
44
45
46 static gboolean
47 ev_presentation_timer_draw(GtkWidget *timer, cairo_t *cr)
48 {
49   EvPresentationTimer *ev_timer = EV_PRESENTATION_TIMER(timer);
50   GtkAllocation allocation;
51   gtk_widget_get_allocation (timer, &allocation);
52   //cairo_translate(cr,allocation.x,allocation.y);
53   cairo_set_source_rgb (cr, 0, 0, 0);
54   cairo_select_font_face (cr, "Sans", CAIRO_FONT_SLANT_NORMAL,
55       CAIRO_FONT_WEIGHT_NORMAL);
56   cairo_set_font_size (cr, 40);
57   guint pos = (allocation.width/ev_timer->priv->pages)*ev_timer->priv->page;
58   cairo_move_to (cr, pos, 40);
59   cairo_show_text (cr, "Disziplin ist Macht.");
60
61
62         return FALSE;
63 }
64
65 void
66 ev_presentation_timer_set_pages (EvPresentationTimer *ev_timer, guint pages)
67 {
68         ev_timer->priv->pages = pages;
69 }
70
71 void
72 ev_presentation_timer_set_page (EvPresentationTimer *ev_timer, guint page)
73 {
74         ev_timer->priv->page = page;
75          gtk_widget_queue_draw(GTK_WIDGET(ev_timer));
76 }
77
78 static void
79 ev_presentation_timer_init (EvPresentationTimer *ev_timer)
80 {
81         ev_timer->priv = EV_PRESENTATION_TIMER_GET_PRIVATE (ev_timer);
82         ev_timer->priv->page = 0;
83         ev_timer->priv->pages = 0;
84 }
85
86 static void
87 ev_presentation_timer_class_init (EvPresentationTimerClass *klass)
88 {
89         GObjectClass    *object_class = G_OBJECT_CLASS (klass);
90         GtkWidgetClass  *widget_class = GTK_WIDGET_CLASS (klass);
91         //GtkDrawingAreaClass     *drawing_area_class = GTK_DRAWING_AREA_CLASS (klass);
92         g_type_class_add_private (object_class, sizeof (EvPresentationTimerPrivate));
93         widget_class->draw = ev_presentation_timer_draw;
94
95         /*object_class->finalize = ev_presentation_timer_finalize;*/
96 }
97
98 GtkWidget *
99 ev_presentation_timer_new (void)
100 {
101         EvPresentationTimer     *ev_timer;
102
103         ev_timer = g_object_new (EV_TYPE_PRESENTATION_TIMER, NULL);
104         return GTK_WIDGET (ev_timer);
105 }