]> www.fi.muni.cz Git - evince.git/commitdiff
[dualscreen] cleanup
authorLukas Bezdicka <255993@mail.muni.cz>
Sun, 10 Apr 2011 22:38:51 +0000 (00:38 +0200)
committerJan "Yenya" Kasprzak <kas@fi.muni.cz>
Wed, 1 Jun 2011 11:09:21 +0000 (13:09 +0200)
shell/ev-dualscreen.c
shell/ev-dualscreen.h

index fdec315fe016aa5610a40df1a2486bf91c4a1a9c..04d67d15cfb9cf9391fa7998aa5be26373080d9f 100644 (file)
@@ -1,6 +1,11 @@
 /* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8; c-indent-level: 8 -*- */
 /* this file is part of evince, a gnome document viewer
  *
+ *  Copyright (C) 2007 Johannes Buchner
+ *
+ *  Author:
+ *    Johannes Buchner <buchner.johannes@gmx.at>
+ *    Lukas Bezdicka <255993@mail.muni.cz>
  *
  * Evince is free software; you can redistribute it and/or modify it
  * under the terms of the GNU General Public License as published by
 struct _EvDSCWindowPrivate {
        GtkWidget *main_box;
        GtkWidget *menubar;
-       GtkWidget *overview;
+       GtkWidget *sidebar;
        GtkWidget *notesview;
        EvDocumentModel *model;
        EvDocument * notesdocument;
 
-       GtkWidget *overview_scrolled_window;
        GtkWidget *notesview_scrolled_window;
        GtkWidget *presentation_window;
 
@@ -208,6 +212,24 @@ ev_dscwindow_presentation_page_changed_cb (EvViewPresentation *pview,
        ev_document_model_set_page (ev_dscwindow->priv->model, page);
 }
 
+static gboolean
+ev_dscwindow_notes_clicked (GtkWidget *widget, GdkEvent *event,
+       EvDSCWindow *self)
+{
+       if (!self || !EV_IS_DSCWINDOW (self) || !event)
+               return FALSE;
+       gint page = ev_document_model_get_page (self->priv->model);
+
+       if (event->type == GDK_2BUTTON_PRESS && ((GdkEventButton *)event)->button == 1) {
+               ev_dscwindow_notes_interaction (NULL, self);
+       } else if (event->type == GDK_BUTTON_PRESS && ((GdkEventButton *)event)->button == 1) {
+               ev_document_model_set_page (self->priv->model, page+1);
+       } else if (event->type == GDK_BUTTON_PRESS && ((GdkEventButton *)event)->button == 3) {
+               ev_document_model_set_page (self->priv->model, page-1);
+       }
+       return FALSE;
+}
+
 /**
  * ev_dscwindow_set_presentation: Set presentation document
  * @presentation_window: Main window we can reuse for presentation
@@ -224,6 +246,10 @@ ev_dscwindow_set_presentation (EvDSCWindow *ev_dscwindow,
        ev_dscwindow->priv->presentation_view = EV_VIEW_PRESENTATION(pview);
        ev_document_model_set_document(ev_dscwindow->priv->model,
                document);
+       g_signal_connect_swapped (ev_dscwindow->priv->presentation_view,
+                                 "destroy",
+                                 G_CALLBACK (gtk_widget_destroy),
+                                 ev_dscwindow);
        g_signal_connect (G_OBJECT(ev_dscwindow->priv->presentation_view),
                          "notify::page",
                          G_CALLBACK (ev_dscwindow_presentation_page_changed_cb),
@@ -232,7 +258,7 @@ ev_dscwindow_set_presentation (EvDSCWindow *ev_dscwindow,
 }
 
 /**
- * ev_dscwindow_end: Stop presentation mode.
+ * ev_dscwindow_end: Destroy control window but keep presentation
  */
 static gboolean
 ev_dscwindow_end (GtkWidget *widget, GdkEvent *event)
@@ -242,7 +268,7 @@ ev_dscwindow_end (GtkWidget *widget, GdkEvent *event)
 }
 
 /**
-* ev_dscwindow_init: Initialize multihead presentation
+ * ev_dscwindow_init: Initialize multihead presentation
 *
 * @ev_dscwindow: EvDSCWindow.
 *
@@ -265,11 +291,11 @@ ev_dscwindow_init (EvDSCWindow *ev_dscwindow)
                          "notify::page",
                          G_CALLBACK (ev_dscwindow_page_changed_cb),
                          ev_dscwindow);
-       ev_dscwindow->priv->overview = ev_sidebar_new ();
-       ev_sidebar_set_model (EV_SIDEBAR (ev_dscwindow->priv->overview),
+       ev_dscwindow->priv->sidebar = ev_sidebar_new ();
+       ev_sidebar_set_model (EV_SIDEBAR (ev_dscwindow->priv->sidebar),
                              ev_dscwindow->priv->model);
-       gtk_box_pack_start (GTK_BOX (v), ev_dscwindow->priv->overview, TRUE , TRUE, 0);
-       gtk_widget_show (ev_dscwindow->priv->overview);
+       gtk_box_pack_start (GTK_BOX (v), ev_dscwindow->priv->sidebar, TRUE , TRUE, 0);
+       gtk_widget_show (ev_dscwindow->priv->sidebar);
 
        GtkWidget *sidebar_widget;
        sidebar_widget = ev_sidebar_thumbnails_new ();
@@ -279,19 +305,10 @@ ev_dscwindow_init (EvDSCWindow *ev_dscwindow)
                          ev_window);
        sidebar_page_main_widget_update_cb (G_OBJECT (sidebar_widget), NULL, ev_window);*/
        gtk_widget_show (sidebar_widget);
-       ev_sidebar_add_page (EV_SIDEBAR (ev_dscwindow->priv->overview),
+       ev_sidebar_add_page (EV_SIDEBAR (ev_dscwindow->priv->sidebar),
                             sidebar_widget);
 
-/*     ev_dscwindow->priv->overview_scrolled_window = GTK_WIDGET (g_object_new (
-                       GTK_TYPE_SCROLLED_WINDOW, "shadow-type", GTK_SHADOW_IN, NULL));
-       gtk_box_pack_start (GTK_BOX (v), ev_dscwindow->priv->overview_scrolled_window, TRUE, TRUE, 0);
-
-
-       ev_dscwindow->priv->overview = ev_view_new ();
-       ev_view_set_page_cache_size (EV_VIEW (ev_dscwindow->priv->overview), PAGE_CACHE_SIZE);
-       ev_view_set_model (EV_VIEW (ev_dscwindow->priv->overview), ev_dscwindow->priv->model);*/
-
-       ev_document_model_set_continuous (ev_dscwindow->priv->model, TRUE);
+       ev_document_model_set_continuous (ev_dscwindow->priv->model, FALSE);
        ev_document_model_set_dual_page (ev_dscwindow->priv->model, FALSE);
        ev_document_model_set_sizing_mode (ev_dscwindow->priv->model, EV_SIZING_BEST_FIT);
 
@@ -315,6 +332,7 @@ ev_dscwindow_init (EvDSCWindow *ev_dscwindow)
        GtkToolItem* b_close = gtk_tool_button_new (NULL, _("End presentation"));
        gtk_tool_button_set_icon_name (GTK_TOOL_BUTTON (b_close), "view-restore");
        gtk_toolbar_insert (GTK_TOOLBAR (t), b_close, -1);
+       /*TODO: rework close*/
        g_signal_connect (b_close, "clicked",
                G_CALLBACK (ev_dscwindow_end), NULL);
 
@@ -334,19 +352,14 @@ ev_dscwindow_init (EvDSCWindow *ev_dscwindow)
        gtk_widget_show_all (h);
        gtk_container_add (GTK_CONTAINER (ev_dscwindow), h);
 
-/* fallback if we have >2 monitors (see window placement) */
-/*+    gtk_window_set_default_size (GTK_WINDOW (self), 800, 600);
-+
-+
-+      /* This would just open new windows. */
-/*+    gtk_drag_dest_unset (GTK_WIDGET (priv->notesview));
-+      gtk_drag_dest_unset (GTK_WIDGET (priv->overview));
-+
-+      gint click = GDK_BUTTON1_MOTION_MASK | GDK_KEY_PRESS_MASK;
-+      gtk_widget_add_events (GTK_WIDGET (priv->overview), click);
-+      g_signal_connect (priv->notesview, "button-press-event",
-+                        G_CALLBACK (ev_dscwindow_notes_clicked), self);
-*/
+       gtk_drag_dest_unset (GTK_WIDGET (ev_dscwindow->priv->notesview));
+       gtk_drag_dest_unset (GTK_WIDGET (ev_dscwindow->priv->sidebar));
+
+       gint click = GDK_BUTTON1_MOTION_MASK | GDK_KEY_PRESS_MASK;
+       gtk_widget_add_events (GTK_WIDGET (ev_dscwindow->priv->sidebar), click);
+       /* TODO: actions*/
+       g_signal_connect (ev_dscwindow->priv->notesview, "button-press-event",
+                         G_CALLBACK (ev_dscwindow_notes_clicked), ev_dscwindow);
 }
 
 
@@ -356,19 +369,6 @@ ev_dscwindow_dispose (GObject *obj)
        EvDSCWindow * ev_dscwindow = EV_DSCWINDOW (obj);
        EvDSCWindowPrivate *priv = ev_dscwindow->priv;
 
-//     if (EV_IS_VIEW (priv->overview) {
-//             ev_document_model_set_document (priv->model, NULL);
-
-//             ev_view_set_document (EV_VIEW (priv->overview),  NULL);
-//             g_object_unref (priv->overview);
-//     }
-//     if (EV_IS_VIEW (priv->notesview)) {
-//             ev_view_set_document (EV_VIEW (priv->notesview), NULL);
-//             g_object_unref (priv->notesview);
-//     }
-/*TODO: save fulscreen state*/
-       ev_window_stop_presentation (EV_WINDOW(priv->presentation_window), 0);
-
        if (priv->moveback_monitor >= 0) {
                GtkWindow * presentation_window = GTK_WINDOW (priv->presentation_window);
                GdkRectangle coords;
@@ -379,6 +379,12 @@ ev_dscwindow_dispose (GObject *obj)
 
                gtk_window_move (presentation_window, coords.x, coords.y);
        }
+       ev_window_stop_presentation (EV_WINDOW(priv->presentation_window), TRUE);
+       /*if (priv->overview) {
+               g_object_unref (priv->overview);
+               priv->overview = NULL;
+       }*/
+
 
        G_OBJECT_CLASS (ev_dscwindow_parent_class)->dispose (obj);
 }
@@ -387,7 +393,6 @@ static void
 ev_dscwindow_class_init (EvDSCWindowClass *ev_dscwindow_class)
 {
        GObjectClass *g_object_class = G_OBJECT_CLASS (ev_dscwindow_class);
-       /*parent_class = g_type_class_peek_parent (ev_dscwindow_class);*/
        g_type_class_add_private (g_object_class, sizeof (EvDSCWindowPrivate));
        g_object_class->dispose  = ev_dscwindow_dispose;
 }
index 6db456aec28f5960b3d301f868f6d628a53dbbdb..356998761bba247cd67c0083988315abe12c56d1 100644 (file)
 #ifndef EV_DUALSCREEN_H
 #define EV_DUALSCREEN_H
 
-/*#include <gtk/gtk.h>
-#include <glib.h>
-#include <glib/gi18n.h>
-#include "ev-window.h"
-#include "ev-document.h"*/
 #include "ev-window.h"
 #include "ev-view-presentation.h"