]> www.fi.muni.cz Git - evince.git/commitdiff
[timer] fix Issue #5
authorxbezdick <255993@mail.muni.cz>
Tue, 3 May 2011 23:18:34 +0000 (01:18 +0200)
committerJan "Yenya" Kasprzak <kas@fi.muni.cz>
Wed, 1 Jun 2011 11:09:22 +0000 (13:09 +0200)
shell/ev-dualscreen.c
shell/ev-presentation-timer.c

index 648a1f2e759b416be8c7920869fbc0ac71556511..507c76b1d80bc0754567fc8bd8df2dc05f726f2d 100644 (file)
@@ -62,12 +62,29 @@ 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    21 /* This seems like bug in gtk to me */
+#define SIDEBAR_DEFAULT_SIZE    25 /* This seems like bug in gtk to me */
 #define MAX_PRESENTATION_TIME   1440 /*60*24 ONE DAY*/
 
 G_DEFINE_TYPE (EvDSCWindow, ev_dscwindow, GTK_TYPE_WINDOW)
 
 
+static void
+ev_dscwindow_window_placement (EvDSCWindow *ev_dscwindow)
+{
+       GtkWindow *presentation_window = GTK_WINDOW (ev_dscwindow->priv->presentation_window);
+       GdkScreen *screen = gtk_window_get_screen (presentation_window);
+       gint work_monitor = gdk_screen_get_monitor_at_window (screen,
+               gtk_widget_get_window (GTK_WIDGET (presentation_window)));
+       gint presentation_monitor = (work_monitor + 1) % 2;
+       GdkRectangle coords;
+       gdk_screen_get_monitor_geometry (screen, presentation_monitor,
+               &coords);
+
+       gtk_window_move (presentation_window, coords.x, coords.y);
+       ev_dscwindow->priv->moveback_monitor = work_monitor;
+       gtk_window_maximize (GTK_WINDOW (ev_dscwindow));
+}
+
 static gboolean
 ev_dscwindow_switch_monitors (GtkWidget *widget, EvDSCWindow *ev_dscwindow)
 {
@@ -202,7 +219,7 @@ ev_dscwindow_notes_interaction (GtkContainer *container, EvDSCWindow *ev_dscwind
 EvDSCWindow *
 ev_dscwindow_get_control (void)
 {
-       static EvDSCWindow * control = NULL;
+       static EvDSCWindow *control = NULL;
 
        if (!control || !EV_IS_DSCWINDOW (control)) {
                control = EV_DSCWINDOW (g_object_new (EV_TYPE_DSCWINDOW, NULL));
@@ -211,23 +228,6 @@ ev_dscwindow_get_control (void)
        return control;
 }
 
-static void
-ev_dscwindow_window_placement (EvDSCWindow *ev_dscwindow)
-{
-       GtkWindow * presentation_window = GTK_WINDOW (ev_dscwindow->priv->presentation_window);
-       GdkScreen * screen = gtk_window_get_screen (presentation_window);
-       gint work_monitor = gdk_screen_get_monitor_at_window (screen,
-               gtk_widget_get_window (GTK_WIDGET (presentation_window)));
-       gint presentation_monitor = (work_monitor + 1) % 2;
-       GdkRectangle coords;
-       gdk_screen_get_monitor_geometry (screen, presentation_monitor,
-               &coords);
-
-       gtk_window_move (presentation_window, coords.x, coords.y);
-       ev_dscwindow->priv->moveback_monitor = work_monitor;
-       gtk_window_maximize (GTK_WINDOW (ev_dscwindow));
-}
-
 void
 ev_dscwindow_set_presentation (EvDSCWindow *ev_dscwindow,
        EvWindow *presentation_window, EvDocument *document, EvViewPresentation *pview)
@@ -246,7 +246,7 @@ ev_dscwindow_set_presentation (EvDSCWindow *ev_dscwindow,
        g_signal_connect_swapped (ev_dscwindow->priv->presentation_view,
                                  "destroy",
                                  G_CALLBACK (gtk_widget_destroy),
-                                 ev_dscwindow);
+                                 GTK_WIDGET (ev_dscwindow));
        g_signal_connect (G_OBJECT(ev_dscwindow->priv->model),
                          "notify::page",
                          G_CALLBACK (ev_dscwindow_page_changed_cb),
@@ -264,7 +264,7 @@ ev_dscwindow_set_presentation (EvDSCWindow *ev_dscwindow,
 static gboolean
 ev_dscwindow_end (GtkWidget *widget, GdkEvent *event)
 {
-       gtk_widget_destroy (GTK_WIDGET (ev_dscwindow_get_control ()));
+       gtk_widget_destroy (widget);
        return TRUE;
 }
 
@@ -342,8 +342,8 @@ ev_dscwindow_init (EvDSCWindow *ev_dscwindow)
        gtk_tool_button_set_label (GTK_TOOL_BUTTON(b_close), _("End presentation"));
        gtk_tool_item_set_tooltip_text (b_close, _("End presentation"));
        gtk_toolbar_insert (GTK_TOOLBAR (toolbar), b_close, -1);
-       g_signal_connect (b_close, "clicked",
-               G_CALLBACK (ev_dscwindow_end), NULL);
+       g_signal_connect_swapped (b_close, "clicked",
+               G_CALLBACK (ev_dscwindow_end), ev_dscwindow);
 
        GtkToolItem *b_sidebar = gtk_tool_button_new_from_stock (GTK_STOCK_PAGE_SETUP);
        gtk_tool_button_set_label (GTK_TOOL_BUTTON(b_sidebar), _("Show sidebar"));
@@ -383,10 +383,10 @@ static void
 ev_dscwindow_dispose (GObject *obj)
 {
        EvDSCWindow *ev_dscwindow = EV_DSCWINDOW (obj);
-       EvDSCWindowPrivate *priv = ev_dscwindow->priv;
+       EvDSCWindowPrivate *priv = EV_DSCWINDOW (ev_dscwindow)->priv;
 
        if (priv->moveback_monitor >= 0) {
-               GtkWindow * presentation_window = GTK_WINDOW (priv->presentation_window);
+               GtkWindow *presentation_window = GTK_WINDOW (priv->presentation_window);
                GdkRectangle coords;
 
                gdk_screen_get_monitor_geometry (
@@ -395,11 +395,6 @@ ev_dscwindow_dispose (GObject *obj)
 
                gtk_window_move (presentation_window, coords.x, coords.y);
        }
-       /*if (priv->timer) {
-               g_object_unref (priv->timer);
-               priv->timer = NULL;
-       }*/
-       ev_presentation_timer_stop(EV_PRESENTATION_TIMER (priv->timer));
        ev_window_stop_presentation (EV_WINDOW(priv->presentation_window), TRUE);
        G_OBJECT_CLASS (ev_dscwindow_parent_class)->dispose (obj);
 }
index 12c7d1be380e14a4629c7d4a8ef89f67398d8318..d1b3474d46ada8002edb65a1f874725239cec39a 100644 (file)
@@ -37,6 +37,7 @@ struct _EvPresentationTimerPrivate
        gint       remaining;
        guint      page;
        guint      pages;
+       guint      timeout;
        gboolean   running;
 };
 
@@ -117,6 +118,7 @@ ev_presentation_timer_init (EvPresentationTimer *ev_timer)
        ev_timer->priv->pages = 0;
        ev_timer->priv->remaining = 0;
        ev_timer->priv->time = 0;
+       ev_timer->priv->timeout = 0;
        ev_timer->priv->running = FALSE;
 }
 
@@ -127,7 +129,7 @@ ev_presentation_timer_start (EvPresentationTimer *ev_timer)
        {
                ev_timer->priv->remaining = (ev_timer->priv->time)*60;
                ev_timer->priv->running = TRUE;
-               g_timeout_add_seconds (1, timeout_cb, ev_timer);
+               ev_timer->priv->timeout = g_timeout_add_seconds (1, timeout_cb, ev_timer);
        }
 }
 
@@ -147,6 +149,16 @@ ev_presentation_timer_set_time (EvPresentationTimer *ev_timer,
        ev_timer->priv->time = (time < -1)? -1:time;
 }
 
+static void
+ev_presentation_timer_dispose (GObject *gobject)
+{
+       EvPresentationTimer *ev_timer = EV_PRESENTATION_TIMER (gobject);
+       EvPresentationTimerPrivate *priv = EV_PRESENTATION_TIMER (ev_timer)->priv;
+       if (priv->timeout > 0)
+               g_source_remove (priv->timeout);
+       G_OBJECT_CLASS (ev_presentation_timer_parent_class)->dispose (gobject);
+}
+
 static void
 ev_presentation_timer_class_init (EvPresentationTimerClass *klass)
 {
@@ -154,7 +166,7 @@ ev_presentation_timer_class_init (EvPresentationTimerClass *klass)
        GtkWidgetClass  *widget_class = GTK_WIDGET_CLASS (klass);
        g_type_class_add_private (object_class, sizeof (EvPresentationTimerPrivate));
        widget_class->draw = ev_presentation_timer_draw;
-       /*object_class->finalize = ev_presentation_timer_finalize;*/
+       object_class->dispose =  ev_presentation_timer_dispose;
 }
 
 GtkWidget *