From f28e9ccf4400e87da3fa9960becc6feb2ed041cb Mon Sep 17 00:00:00 2001 From: =?utf8?q?Luk=C3=A1=C5=A1=20Bezdi=C4=8Dka?= <255993@mail.muni.cz> Date: Thu, 28 Apr 2011 23:52:35 +0200 Subject: [PATCH] [dualscreen] timer continue, maybe I should remove that text... [dualscreen] cleanup --- shell/ev-dualscreen.c | 47 ++++++++++++++++++++--------------- shell/ev-presentation-timer.c | 35 ++++++++++++++++++++------ shell/ev-presentation-timer.h | 8 ++++-- 3 files changed, 61 insertions(+), 29 deletions(-) diff --git a/shell/ev-dualscreen.c b/shell/ev-dualscreen.c index 208fe349..80c029b2 100644 --- a/shell/ev-dualscreen.c +++ b/shell/ev-dualscreen.c @@ -60,9 +60,11 @@ struct _EvDSCWindowPrivate { #define EV_DSCWINDOW_GET_PRIVATE(object) \ (G_TYPE_INSTANCE_GET_PRIVATE ((object), EV_TYPE_DSCWINDOW, EvDSCWindowPrivate)) #define PAGE_CACHE_SIZE 52428800 /* 50MB */ +#define SIDEBAR_DEFAULT_SIZE 300 G_DEFINE_TYPE (EvDSCWindow, ev_dscwindow, GTK_TYPE_WINDOW) + static gboolean ev_dscwindow_switch_monitors (GtkWidget *widget, EvDSCWindow *ev_dscwindow) { @@ -100,11 +102,8 @@ ev_dscwindow_sidebar_visibility(GtkWidget *sidebar) } static void -ev_dscwindow_page_changed_cb (EvDocumentModel *model, - GParamSpec *pspec, - EvDSCWindow *ev_dscwindow) +ev_dscwindow_set_page (EvDSCWindow *ev_dscwindow, gint page) { - gint page = ev_document_model_get_page (model); if(page != ev_view_presentation_get_current_page (ev_dscwindow->priv->presentation_view)) { ev_view_presentation_set_page (EV_VIEW_PRESENTATION(ev_dscwindow->priv->presentation_view), page); if( ev_document_model_get_page (ev_dscwindow->priv->model) != page) @@ -112,6 +111,15 @@ ev_dscwindow_page_changed_cb (EvDocumentModel *model, if( ev_document_model_get_page (ev_dscwindow->priv->notes_model) != page) ev_document_model_set_page(ev_dscwindow->priv->notes_model, page); } + ev_presentation_timer_set_page (EV_PRESENTATION_TIMER(ev_dscwindow->priv->timer), page); +} + +static void +ev_dscwindow_page_changed_cb (EvDocumentModel *model, + GParamSpec *pspec, + EvDSCWindow *ev_dscwindow) +{ + ev_dscwindow_set_page (ev_dscwindow, ev_document_model_get_page (model)); } static void @@ -119,11 +127,7 @@ ev_dscwindow_presentation_page_changed_cb (EvViewPresentation *pview, GParamSpec *pspec, EvDSCWindow *ev_dscwindow) { - gint page = ev_view_presentation_get_current_page (pview); - if( ev_document_model_get_page (ev_dscwindow->priv->model) != page) - ev_document_model_set_page(ev_dscwindow->priv->model, page); - if( ev_document_model_get_page (ev_dscwindow->priv->notes_model) != page) - ev_document_model_set_page(ev_dscwindow->priv->notes_model, page); + ev_dscwindow_set_page (ev_dscwindow, ev_view_presentation_get_current_page (pview)); } static gboolean @@ -232,6 +236,7 @@ ev_dscwindow_set_presentation (EvDSCWindow *ev_dscwindow, "notify::page", G_CALLBACK (ev_dscwindow_presentation_page_changed_cb), ev_dscwindow); + ev_presentation_timer_set_pages (EV_PRESENTATION_TIMER(ev_dscwindow->priv->timer), ev_document_get_n_pages (document)); ev_dscwindow_window_placement (ev_dscwindow); } @@ -264,26 +269,27 @@ ev_dscwindow_init (EvDSCWindow *ev_dscwindow) ev_dscwindow->priv->sidebar = ev_sidebar_new (); ev_sidebar_set_model (EV_SIDEBAR (ev_dscwindow->priv->sidebar), ev_dscwindow->priv->model); + GtkWidget *sidebar_widget; sidebar_widget = ev_sidebar_thumbnails_new (); - gtk_widget_show (sidebar_widget); ev_sidebar_add_page (EV_SIDEBAR (ev_dscwindow->priv->sidebar), sidebar_widget); - gtk_widget_show (ev_dscwindow->priv->sidebar); - gtk_paned_add1(GTK_PANED(hpaned), ev_dscwindow->priv->sidebar); ev_dscwindow->priv->notesview_scrolled_window = GTK_WIDGET ( g_object_new (GTK_TYPE_SCROLLED_WINDOW,"shadow-type", GTK_SHADOW_IN, NULL)); - gtk_paned_add2 (GTK_PANED (hpaned), ev_dscwindow->priv->notesview_scrolled_window); + gtk_paned_pack1 (GTK_PANED (hpaned), ev_dscwindow->priv->sidebar, FALSE, TRUE); + gtk_paned_pack2 (GTK_PANED (hpaned), ev_dscwindow->priv->notesview_scrolled_window, TRUE, TRUE); + gtk_paned_set_position (GTK_PANED (hpaned), SIDEBAR_DEFAULT_SIZE); ev_dscwindow->priv->notesview = ev_view_new (); - g_object_ref (ev_dscwindow->priv->notesview); +// g_object_ref (ev_dscwindow->priv->notesview); gtk_container_add (GTK_CONTAINER (ev_dscwindow->priv->notesview_scrolled_window), ev_dscwindow->priv->notesview); + ev_dscwindow->priv->notes_model = ev_dscwindow->priv->model; ev_view_set_model (EV_VIEW (ev_dscwindow->priv->notesview), ev_dscwindow->priv->notes_model); - gtk_widget_show_all (hpaned); + gtk_box_pack_start(GTK_BOX(vbox),hpaned,TRUE,TRUE,0); GtkWidget *expander = gtk_expander_new (_("Expensive features")); @@ -316,13 +322,14 @@ ev_dscwindow_init (EvDSCWindow *ev_dscwindow) gtk_container_add (GTK_CONTAINER (expander), toolbar); - GtkWidget *hbox = gtk_hbox_new (FALSE,0); - gtk_box_pack_start (GTK_BOX (hbox), expander, FALSE, TRUE, 0); + GtkWidget *hpan = gtk_hpaned_new (); + gtk_paned_pack1 (GTK_PANED(hpan), expander, FALSE, TRUE); ev_dscwindow->priv->timer = ev_presentation_timer_new (); - gtk_box_pack_end (GTK_BOX (hbox), ev_dscwindow->priv->timer, TRUE, TRUE, 0); - gtk_box_pack_end (GTK_BOX (vbox), hbox, FALSE, TRUE, 0); - gtk_widget_show_all(vbox); + gtk_paned_pack2 (GTK_PANED(hpan),ev_dscwindow->priv->timer, TRUE, TRUE); + gtk_paned_set_position (GTK_PANED (hpan), SIDEBAR_DEFAULT_SIZE); + gtk_box_pack_end (GTK_BOX (vbox), hpan, FALSE, TRUE, 0); gtk_container_add (GTK_CONTAINER (ev_dscwindow), vbox); + gtk_widget_show_all(vbox); } static void diff --git a/shell/ev-presentation-timer.c b/shell/ev-presentation-timer.c index abf5d6d8..6c5b9309 100644 --- a/shell/ev-presentation-timer.c +++ b/shell/ev-presentation-timer.c @@ -33,7 +33,8 @@ struct _EvPresentationTimerPrivate { - cairo_surface_t *surface; + guint page; + guint pages; }; #define EV_PRESENTATION_TIMER_GET_PRIVATE(object) \ @@ -45,21 +46,41 @@ G_DEFINE_TYPE (EvPresentationTimer, ev_presentation_timer, GTK_TYPE_DRAWING_AREA static gboolean ev_presentation_timer_draw(GtkWidget *timer, cairo_t *cr) { - cairo_set_source_rgb(cr, 0, 0, 0); - cairo_select_font_face(cr, "Sans", CAIRO_FONT_SLANT_NORMAL, + EvPresentationTimer *ev_timer = EV_PRESENTATION_TIMER(timer); + GtkAllocation allocation; + gtk_widget_get_allocation (timer, &allocation); + //cairo_translate(cr,allocation.x,allocation.y); + cairo_set_source_rgb (cr, 0, 0, 0); + cairo_select_font_face (cr, "Sans", CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_NORMAL); - cairo_set_font_size(cr, 40.0); + cairo_set_font_size (cr, 40); + guint pos = (allocation.width/ev_timer->priv->pages)*ev_timer->priv->page; + cairo_move_to (cr, pos, 40); + cairo_show_text (cr, "Disziplin ist Macht."); - cairo_move_to(cr, 10.0, 50.0); - cairo_show_text(cr, "Disziplin ist Macht."); return FALSE; } +void +ev_presentation_timer_set_pages (EvPresentationTimer *ev_timer, guint pages) +{ + ev_timer->priv->pages = pages; +} + +void +ev_presentation_timer_set_page (EvPresentationTimer *ev_timer, guint page) +{ + ev_timer->priv->page = page; + gtk_widget_queue_draw(GTK_WIDGET(ev_timer)); +} + static void ev_presentation_timer_init (EvPresentationTimer *ev_timer) { -// ev_timer->priv = EV_DSCWINDOW_GET_PRIVATE (ev_timer); + ev_timer->priv = EV_PRESENTATION_TIMER_GET_PRIVATE (ev_timer); + ev_timer->priv->page = 0; + ev_timer->priv->pages = 0; } static void diff --git a/shell/ev-presentation-timer.h b/shell/ev-presentation-timer.h index 3dc5208b..5da7a3e1 100644 --- a/shell/ev-presentation-timer.h +++ b/shell/ev-presentation-timer.h @@ -47,8 +47,12 @@ struct _EvPresentationTimer EvPresentationTimerPrivate *priv; }; -GType ev_presentation_timer_get_type (void); -GtkWidget *ev_presentation_timer_new (void); +void ev_presentation_timer_set_pages (EvPresentationTimer *ev_timer, + guint pages); +void ev_presentation_timer_set_page (EvPresentationTimer *ev_timer, + guint page); +GType ev_presentation_timer_get_type (void); +GtkWidget *ev_presentation_timer_new (void); G_END_DECLS -- 2.39.3