]> www.fi.muni.cz Git - evince.git/blobdiff - shell/ev-dualscreen.c
[timer] fix Issue #5
[evince.git] / shell / ev-dualscreen.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);
 }