#include "ev-sidebar-thumbnails.h"
struct _EvDSCWindowPrivate {
- GtkWidget *main_box;
- GtkWidget *menubar;
- GtkWidget *sidebar;
- GtkWidget *notesview;
+ GtkWidget *main_box;
+ GtkWidget *menubar;
+ GtkWidget *sidebar;
+ GtkWidget *notesview;
EvDocumentModel *model;
- EvDocument * notesdocument;
+ EvDocumentModel *notes_model;
+ EvDocument *presentation_document;
+ EvDocument *notes_document;
- GtkWidget *notesview_scrolled_window;
- GtkWidget *presentation_window;
+ GtkWidget *presentation_window;
+ GtkWidget *overview_scrolled_window;
+ GtkWidget *notesview_scrolled_window;
EvViewPresentation *presentation_view;
- EvDocument * presentation_document;
- gint moveback_monitor;
+ gint moveback_monitor;
};
#define EV_DSCWINDOW_GET_PRIVATE(object) \
#define PAGE_CACHE_SIZE 52428800 /* 50MB */
#define SIDEBAR_DEFAULT_SIZE 132
-/*static gpointer parent_class = NULL;*/
G_DEFINE_TYPE (EvDSCWindow, ev_dscwindow, GTK_TYPE_WINDOW)
* @self: EvDSCWindow
**/
static gboolean
-ev_dscwindow_switch_monitors (GtkWidget *widget, EvDSCWindow *self)
+ev_dscwindow_switch_monitors (GtkWidget *widget, EvDSCWindow *ev_dscwindow)
{
-/*
-+ if (!EV_IS_DSCWINDOW (self))
-+ return FALSE;
-+
-+ EvDSCWindowPrivate *priv = EV_DSCWINDOW_GET_PRIVATE (self);
-+
-+ gint num_monitors = get_num_monitors (GTK_WINDOW (self));
-+
-+ if (num_monitors == 2) {
-+ GtkWindow * presentation_window = GTK_WINDOW (priv->presentation_window);
-+ GdkScreen * screen = gtk_window_get_screen (presentation_window);
-+
-+ gint monitor_1 = gdk_screen_get_monitor_at_window (screen,
-+ GTK_WIDGET (presentation_window)->window);
-+
-+ gint monitor_2 = (monitor_1 + 1) % 2;
-+
-+ GdkRectangle coords;
-+ gdk_screen_get_monitor_geometry (screen, monitor_2, &coords);
-+ ev_window_stop_presentation (priv->presentation_window);
-+ gtk_window_move (presentation_window, coords.x, coords.y);
-+ ev_window_run_presentation (priv->presentation_window);
-+ priv->moveback_monitor = monitor_1;
-+
-+ gdk_screen_get_monitor_geometry (screen, monitor_1, &coords);
-+ gtk_window_unmaximize (GTK_WINDOW (self));
-+ gtk_window_move (GTK_WINDOW (self), coords.x, coords.y);
-+ gtk_window_maximize (GTK_WINDOW (self));
-+ }*/
+
+ if (!EV_IS_DSCWINDOW (ev_dscwindow))
+ return FALSE;
+
+ gint num_monitors = get_num_monitors (GTK_WINDOW (ev_dscwindow));
+
+ if (num_monitors == 2) {
+ GtkWindow *presentation_window = GTK_WINDOW (ev_dscwindow->priv->presentation_window);
+ GdkScreen *screen = gtk_window_get_screen (presentation_window);
+
+ gint monitor_1 = gdk_screen_get_monitor_at_window (screen,
+ gtk_widget_get_window (GTK_WIDGET (presentation_window)));
+
+ gint monitor_2 = (monitor_1 + 1) % 2;
+
+ GdkRectangle coords;
+ gdk_screen_get_monitor_geometry (screen, monitor_2, &coords);
+ gtk_window_move (presentation_window, coords.x, coords.y);
+ ev_dscwindow->priv->moveback_monitor = monitor_1;
+
+ gdk_screen_get_monitor_geometry (screen, monitor_1, &coords);
+ gtk_window_unmaximize (GTK_WINDOW (ev_dscwindow));
+ gtk_window_move (GTK_WINDOW (ev_dscwindow), coords.x, coords.y);
+ gtk_window_maximize (GTK_WINDOW (ev_dscwindow));
+ }
return TRUE;
}
+/**
+ * ev_dscwindow_page_changed_cb: Callback to change page on all views
+ *
+ **/
+static void
+ev_dscwindow_page_changed_cb (EvDocumentModel *model,
+ GParamSpec *pspec,
+ EvDSCWindow *ev_dscwindow)
+{
+ 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)
+ 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);
+ }
+}
+static void
+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_notes_interaction: User wants to load a different file as notes.
**/
static gboolean
-ev_dscwindow_notes_interaction (GtkContainer *container, EvDSCWindow *self)
+ev_dscwindow_notes_interaction (GtkContainer *container, EvDSCWindow *ev_dscwindow)
{
-/*
-+ EvDSCWindowPrivate *priv = EV_DSCWINDOW_GET_PRIVATE (self);
-+ GtkWidget *dialog;
-+
-+ dialog = gtk_file_chooser_dialog_new (
-+ _("Open Document"),
-+ GTK_WINDOW (self),
-+ GTK_FILE_CHOOSER_ACTION_OPEN,
-+ GTK_STOCK_CANCEL, GTK_RESPONSE_REJECT,
-+ GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT,
-+ NULL);
-+
-+ ev_document_factory_add_filters (dialog, NULL);
-+ gtk_file_chooser_set_select_multiple (GTK_FILE_CHOOSER (dialog), FALSE);
-+ gtk_file_chooser_set_local_only (GTK_FILE_CHOOSER (dialog), TRUE);
-+
-+ if (gtk_dialog_run (GTK_DIALOG (dialog)) == GTK_RESPONSE_ACCEPT)
-+ {
-+ char * uri = gtk_file_chooser_get_uri (GTK_FILE_CHOOSER (dialog));
-+ GError * error = NULL;
-+ ev_view_set_loading (EV_VIEW (priv->notesview), TRUE);
-+
-+ if (priv->notesdocument) {
-+ ev_document_load (priv->notesdocument, uri, &error);
-+ } else {
-+ priv->notesdocument = ev_document_factory_get_document (uri,
-+ &error);
-+ }
-+ g_free (uri);
-+ if (error == NULL){
-+ ev_view_set_document (EV_VIEW (priv->notesview),
-+ priv->notesdocument);
-+ /* TODO: go to the same page that is open at the moment, or
-+ * move the presentation to the beginning. *//*
-+ }
-+ }
-+ gtk_widget_destroy (dialog);
-*/
+ GtkWidget *dialog;
+
+ dialog = gtk_file_chooser_dialog_new (
+ _("Open Document"),
+ GTK_WINDOW (ev_dscwindow),
+ GTK_FILE_CHOOSER_ACTION_OPEN,
+ GTK_STOCK_CANCEL, GTK_RESPONSE_REJECT,
+ GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT,
+ NULL);
+
+ ev_document_factory_add_filters (dialog, NULL);
+ gtk_file_chooser_set_select_multiple (GTK_FILE_CHOOSER (dialog), FALSE);
+ gtk_file_chooser_set_local_only (GTK_FILE_CHOOSER (dialog), TRUE);
+
+ if (gtk_dialog_run (GTK_DIALOG (dialog)) == GTK_RESPONSE_ACCEPT)
+ {
+ char * uri = gtk_file_chooser_get_uri (GTK_FILE_CHOOSER (dialog));
+ GError * error = NULL;
+ ev_view_set_loading (EV_VIEW (ev_dscwindow->priv->notesview), TRUE);
+
+ if (ev_dscwindow->priv->notes_document) {
+ ev_document_load (ev_dscwindow->priv->notes_document, uri, &error);
+ } else {
+ ev_dscwindow->priv->notes_document = ev_document_factory_get_document (uri,
+ &error);
+ }
+ g_free (uri);
+ if (error == NULL){
+ ev_dscwindow->priv->notes_model = ev_document_model_new_with_document (ev_dscwindow->priv->notes_document);
+ ev_view_set_model(EV_VIEW(ev_dscwindow->priv->notesview),
+ ev_dscwindow->priv->notes_model);
+ g_signal_connect (G_OBJECT(ev_dscwindow->priv->notes_model),
+ "notify::page",
+ G_CALLBACK (ev_dscwindow_page_changed_cb),
+ ev_dscwindow);
+ }
+ }
+ gtk_widget_destroy (dialog);
+
return TRUE;
}
return control;
}
-/*TODO: Fix me!*/
static void
ev_dscwindow_window_placement (EvDSCWindow *ev_dscwindow)
{
gint num_monitors = get_num_monitors (GTK_WINDOW (ev_dscwindow));
- //if (num_monitors == 2) {
+ if (num_monitors == 2) {
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,
&coords);
gtk_window_move (presentation_window, coords.x, coords.y);
- //ev_window_run_presentation (ev_dscwindow->priv->presentation_window);
ev_dscwindow->priv->moveback_monitor = work_monitor;
gtk_window_maximize (GTK_WINDOW (ev_dscwindow));
- //}
-}
-/**
- * ev_dscwindow_page_changed_cb: Callback to change page on all views
- *
- **/
-static void
-ev_dscwindow_page_changed_cb (EvDocumentModel *model,
- GParamSpec *pspec,
- EvDSCWindow *ev_dscwindow)
-{
- 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);
-}
-static void
-ev_dscwindow_presentation_page_changed_cb (EvViewPresentation *pview,
- GParamSpec *pspec,
- EvDSCWindow *ev_dscwindow)
-{
- gint page = ev_view_presentation_get_current_page (pview);
- ev_document_model_set_page (ev_dscwindow->priv->model, page);
+ }
}
static gboolean
{
ev_dscwindow->priv = EV_DSCWINDOW_GET_PRIVATE (ev_dscwindow);
ev_dscwindow->priv->moveback_monitor = -1;
- ev_dscwindow->priv->notesdocument = NULL;
+ ev_dscwindow->priv->notes_document = NULL;
gtk_window_set_title (GTK_WINDOW (ev_dscwindow), _("Presentation Control"));
GtkWidget *sidebar_widget;
sidebar_widget = ev_sidebar_thumbnails_new ();
- /*g_signal_connect (sidebar_widget,
- "notify::main-widget",
- G_CALLBACK (sidebar_page_main_widget_update_cb),
- 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->sidebar),
sidebar_widget);
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);
g_object_ref (ev_dscwindow->priv->notesview);
gtk_container_add (GTK_CONTAINER (ev_dscwindow->priv->notesview_scrolled_window),
ev_dscwindow->priv->notesview);
- ev_view_set_model (EV_VIEW (ev_dscwindow->priv->notesview), ev_dscwindow->priv->model);
+ 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 (h);
gtk_container_add (GTK_CONTAINER (ev_dscwindow), h);