From f3731bd3bdbcdc18c53e0f74bdaac93311046352 Mon Sep 17 00:00:00 2001 From: social Date: Sat, 9 Apr 2011 23:49:51 +0200 Subject: [PATCH] [dualscreen] beta pageswitch [shell] todo change run_presentation [presentation] todo add signals --- libview/ev-view-presentation.c | 33 +++++++++++- libview/ev-view-presentation.h | 2 + shell/ev-dualscreen.c | 94 ++++++++++++++++++---------------- shell/ev-dualscreen.h | 3 +- shell/ev-window.c | 47 ++++++----------- 5 files changed, 102 insertions(+), 77 deletions(-) diff --git a/libview/ev-view-presentation.c b/libview/ev-view-presentation.c index 8694e5e3..bbbfd4f9 100644 --- a/libview/ev-view-presentation.c +++ b/libview/ev-view-presentation.c @@ -30,6 +30,7 @@ #include "ev-transition-animation.h" #include "ev-view-cursor.h" #include "ev-page-cache.h" +#include "ev-view-marshal.h" enum { PROP_0, @@ -40,6 +41,7 @@ enum { }; enum { + PAGE_CHANGED, CHANGE_PAGE, FINISHED, SIGNAL_EXTERNAL_LINK, @@ -97,6 +99,9 @@ struct _EvViewPresentationClass GtkWidgetClass base_class; /* signals */ + void (* page_changed) (EvViewPresentation *pview, + gint old_page, + gint new_page); void (* change_page) (EvViewPresentation *pview, GtkScrollType scroll); void (* finished) (EvViewPresentation *pview); @@ -488,6 +493,8 @@ ev_view_presentation_update_current_page (EvViewPresentation *pview, } } + g_signal_emit (pview, signals[PAGE_CHANGED], 0, pview->current_page); + pview->current_page = page; if (pview->page_cache) @@ -504,6 +511,19 @@ ev_view_presentation_update_current_page (EvViewPresentation *pview, gtk_widget_queue_draw (GTK_WIDGET (pview)); } +void +ev_view_presentation_set_page (EvViewPresentation *pview, gint new_page) +{ + guint n_pages; + + n_pages = ev_document_get_n_pages (pview->document); + + if (new_page >= n_pages) + ev_view_presentation_set_end (pview); + else + ev_view_presentation_update_current_page (pview, new_page); +} + void ev_view_presentation_next_page (EvViewPresentation *pview) { @@ -1382,8 +1402,8 @@ ev_view_presentation_get_property (GObject *object, static GObject * ev_view_presentation_constructor (GType type, - guint n_construct_properties, - GObjectConstructParam *construct_params) + guint n_construct_properties, + GObjectConstructParam *construct_params) { GObject *object; EvViewPresentation *pview; @@ -1470,6 +1490,15 @@ ev_view_presentation_class_init (EvViewPresentationClass *klass) g_cclosure_marshal_VOID__ENUM, G_TYPE_NONE, 1, GTK_TYPE_SCROLL_TYPE); + signals [PAGE_CHANGED] = + g_signal_new ("page-changed", + EV_TYPE_VIEW_PRESENTATION, + G_SIGNAL_RUN_LAST, + G_STRUCT_OFFSET (EvViewPresentationClass, page_changed), + NULL, NULL, + g_cclosure_marshal_VOID__INT, + G_TYPE_NONE, 2, + G_TYPE_INT, G_TYPE_INT); signals[FINISHED] = g_signal_new ("finished", G_OBJECT_CLASS_TYPE (gobject_class), diff --git a/libview/ev-view-presentation.h b/libview/ev-view-presentation.h index e7857695..e1589243 100644 --- a/libview/ev-view-presentation.h +++ b/libview/ev-view-presentation.h @@ -45,6 +45,8 @@ GtkWidget *ev_view_presentation_new (EvDocument *document, guint rotation, gboolean inverted_colors); guint ev_view_presentation_get_current_page (EvViewPresentation *pview); +void ev_view_presentation_set_page (EvViewPresentation *pview, + gint new_page); void ev_view_presentation_next_page (EvViewPresentation *pview); void ev_view_presentation_previous_page (EvViewPresentation *pview); void ev_view_presentation_set_rotation (EvViewPresentation *pview, diff --git a/shell/ev-dualscreen.c b/shell/ev-dualscreen.c index 60cd2eb7..cdeb4aea 100644 --- a/shell/ev-dualscreen.c +++ b/shell/ev-dualscreen.c @@ -27,6 +27,7 @@ #include "ev-dualscreen.h" #include "ev-window.h" #include "ev-view.h" +#include "ev-view-presentation.h" #include "ev-utils.h" #include "ev-sidebar.h" #include "ev-sidebar-thumbnails.h" @@ -41,8 +42,9 @@ struct _EvDSCWindowPrivate { GtkWidget *overview_scrolled_window; GtkWidget *notesview_scrolled_window; + GtkWidget *presentation_window; - EvWindow *presentation_window; + EvView *presentation_view; EvDocument * presentation_document; gint moveback_monitor; }; @@ -50,6 +52,7 @@ 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 132 /*static gpointer parent_class = NULL;*/ @@ -167,27 +170,45 @@ static void ev_dscwindow_window_placement (EvDSCWindow *ev_dscwindow) { gint num_monitors = get_num_monitors (GTK_WINDOW (ev_dscwindow)); - if (num_monitors == 2) { + g_printf ("num_monitors: %d \n",num_monitors); + //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, 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_window_run_presentation (ev_dscwindow->priv->presentation_window); + //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); + g_printf("page:%d\n",page); + ev_view_presentation_set_page (EV_VIEW_PRESENTATION(ev_dscwindow->priv->presentation_view), page); +} +static void +ev_dscwindow_presentation_page_changed_cb (EvDocumentModel *model, + GParamSpec *pspec, + EvDSCWindow *ev_dscwindow) +{ + gint page = ev_view_presentation_get_current_page (ev_dscwindow->priv->presentation_view); + ev_document_model_set_page (ev_dscwindow->priv->model, page); +} /** * ev_dscwindow_set_presentation: Set presentation document @@ -195,21 +216,21 @@ ev_dscwindow_window_placement (EvDSCWindow *ev_dscwindow) **/ void ev_dscwindow_set_presentation (EvDSCWindow *ev_dscwindow, - EvWindow *presentation_window, EvDocument *document) + EvWindow *presentation_window, EvDocument *document, GtkWidget *pview) { if (!EV_IS_WINDOW (presentation_window)) return; ev_dscwindow->priv->presentation_window = presentation_window; ev_dscwindow->priv->presentation_document = document; - + ev_dscwindow->priv->presentation_view = pview; + g_signal_connect (ev_dscwindow->priv->presentation_view, + "notify::page", + G_CALLBACK (ev_dscwindow_presentation_page_changed_cb), + ev_dscwindow); ev_document_model_set_document(ev_dscwindow->priv->model, document); -/* ev_view_set_document (EV_VIEW (priv->notesview), - priv->presentation_document);*/ ev_dscwindow_window_placement (ev_dscwindow); - /*ev_dscwindow_handle_resized (NULL, NULL, self); - */ } /** @@ -225,7 +246,7 @@ ev_dscwindow_end (GtkWidget *widget, GdkEvent *event) /** * ev_dscwindow_init: Initialize multihead presentation * -* @self: EvDSCWindow. +* @ev_dscwindow: EvDSCWindow. * * ev_dscwindow_set_presentation has to be called afterwards for loading in a document. TBD **/ @@ -242,20 +263,18 @@ ev_dscwindow_init (EvDSCWindow *ev_dscwindow) GtkWidget *v = gtk_vbox_new (FALSE, 0); ev_dscwindow->priv->model = ev_document_model_new (); - + g_signal_connect (ev_dscwindow->priv->model, + "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->model); -/* gtk_paned_pack1 (GTK_PANED (h), - ev_dscwindow->priv->overview, FALSE, FALSE);*/ - gtk_box_pack_start (GTK_BOX (v), ev_dscwindow->priv->overview, TRUE, TRUE, 0); + gtk_box_pack_start (GTK_BOX (v), ev_dscwindow->priv->overview, TRUE , TRUE, 0); gtk_widget_show (ev_dscwindow->priv->overview); - /* Stub sidebar, for now */ - GtkWidget *sidebar_widget; sidebar_widget = ev_sidebar_thumbnails_new (); - /*ev_window->priv->sidebar_thumbs = sidebar_widget;*/ /*g_signal_connect (sidebar_widget, "notify::main-widget", G_CALLBACK (sidebar_page_main_widget_update_cb), @@ -278,11 +297,6 @@ ev_dscwindow_init (EvDSCWindow *ev_dscwindow) 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); - -/* gtk_container_add (GTK_CONTAINER (ev_dscwindow->priv->overview_scrolled_window), - ev_dscwindow->priv->overview); - */ - GtkWidget *e = gtk_expander_new (_("Expensive features")); gtk_expander_set_expanded (GTK_EXPANDER (e), TRUE); @@ -319,19 +333,12 @@ ev_dscwindow_init (EvDSCWindow *ev_dscwindow) 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); - - gtk_paned_set_position (GTK_PANED (h), 400); 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); + -+ g_signal_connect (h, "notify::position", -+ G_CALLBACK (ev_dscwindow_handle_resized), self); -+ -+ g_signal_connect (self, "size-allocate", -+ G_CALLBACK (ev_dscwindow_handle_resized), self); + + /* This would just open new windows. */ /*+ gtk_drag_dest_unset (GTK_WIDGET (priv->notesview)); @@ -351,16 +358,16 @@ 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); +// 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); -+ }*/ +// 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 (priv->presentation_window, 0); @@ -378,7 +385,6 @@ ev_dscwindow_dispose (GObject *obj) G_OBJECT_CLASS (ev_dscwindow_parent_class)->dispose (obj); } - static void ev_dscwindow_class_init (EvDSCWindowClass *ev_dscwindow_class) { diff --git a/shell/ev-dualscreen.h b/shell/ev-dualscreen.h index 643a21e7..790e161e 100644 --- a/shell/ev-dualscreen.h +++ b/shell/ev-dualscreen.h @@ -53,7 +53,8 @@ GType ev_dscwindow_get_type (void); GtkWidget *ev_dscwindow_new (void); void ev_dscwindow_set_presentation (EvDSCWindow *ev_dscwindow, EvWindow *presentation_window, - EvDocument *document); + EvDocument *document, + GtkWidget *pview); EvDSCWindow* ev_dscwindow_get_control (void); G_END_DECLS diff --git a/shell/ev-window.c b/shell/ev-window.c index dcc35360..dd9d1167 100644 --- a/shell/ev-window.c +++ b/shell/ev-window.c @@ -310,9 +310,6 @@ static void ev_window_stop_fullscreen (EvWindow *windo gboolean unfullscreen_window); static void ev_window_cmd_view_fullscreen (GtkAction *action, EvWindow *window); -static void ev_window_run_presentation_wrapper (EvWindow *window); -static void ev_window_stop_presentation_wrapper (EvWindow *window, - gboolean unfullscreen_window); static void ev_window_cmd_view_presentation (GtkAction *action, EvWindow *window); static void ev_view_popup_cmd_open_link (GtkAction *action, @@ -1027,7 +1024,7 @@ static void update_document_mode (EvWindow *window, EvDocumentMode mode) { if (mode == EV_DOCUMENT_MODE_PRESENTATION) { - ev_window_run_presentation_wrapper (window); + ev_window_run_presentation (window); } else if (mode == EV_DOCUMENT_MODE_FULL_SCREEN) { ev_window_run_fullscreen (window); @@ -1318,7 +1315,7 @@ setup_view_from_metadata (EvWindow *window) /* Presentation */ if (ev_metadata_get_boolean (window->priv->metadata, "presentation", &presentation)) { if (presentation) { - ev_window_run_presentation_wrapper (window); + ev_window_run_presentation (window); } } } @@ -1484,7 +1481,7 @@ ev_window_set_document (EvWindow *ev_window, EvDocument *document) /* Update the model with the current presentation page */ ev_document_model_set_page (ev_window->priv->model, current_page); - ev_window_run_presentation_wrapper (ev_window); + ev_window_run_presentation (ev_window); } if (ev_window->priv->setup_document_idle > 0) @@ -1621,7 +1618,7 @@ ev_window_load_job_cb (EvJob *job, ev_window_run_fullscreen (ev_window); break; case EV_WINDOW_MODE_PRESENTATION: - ev_window_run_presentation_wrapper (ev_window); + ev_window_run_presentation (ev_window); break; default: break; @@ -2158,7 +2155,7 @@ ev_window_open_document (EvWindow *ev_window, ev_window_run_fullscreen (ev_window); break; case EV_WINDOW_MODE_PRESENTATION: - ev_window_run_presentation_wrapper (ev_window); + ev_window_run_presentation (ev_window); break; default: break; @@ -4000,25 +3997,6 @@ ev_window_view_presentation_focus_out (EvWindow *window) return FALSE; } -static void -ev_window_run_presentation_wrapper (EvWindow *window) -{ - /*if ( get_num_monitors(GTK_WINDOW(window)) > 1) {*/ - EvWindow *presentation_window = window; - EvDSCWindow *control = ev_dscwindow_get_control(); - - ev_dscwindow_set_presentation (control, presentation_window, - presentation_window->priv->document); - gtk_window_present (GTK_WINDOW (control)); - /*} else - ev_window_run_presentation (window);*/ - -} -static void -ev_window_stop_presentation_wrapper(EvWindow *window, gboolean unfullscreen_window) -{ -} - void ev_window_run_presentation (EvWindow *window) { @@ -4042,6 +4020,7 @@ ev_window_run_presentation (EvWindow *window) current_page, rotation, inverted_colors); + g_signal_connect_swapped (window->priv->presentation_view, "finished", G_CALLBACK (ev_window_view_presentation_finished), window); @@ -4073,6 +4052,14 @@ ev_window_run_presentation (EvWindow *window) if (window->priv->metadata && !ev_window_is_empty (window)) ev_metadata_set_boolean (window->priv->metadata, "presentation", TRUE); + //if ( get_num_monitors(GTK_WINDOW(window)) > 1) { + + EvDSCWindow *control = ev_dscwindow_get_control(); + ev_dscwindow_set_presentation (control, window, + window->priv->document, + window->priv->presentation_view); + gtk_window_present (GTK_WINDOW (control)); + //} } void @@ -4115,7 +4102,7 @@ ev_window_cmd_view_presentation (GtkAction *action, EvWindow *window) presentation = gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action)); if (presentation) { - ev_window_run_presentation_wrapper (window); + ev_window_run_presentation (window); } } @@ -4593,7 +4580,7 @@ ev_window_cmd_leave_fullscreen (GtkAction *action, EvWindow *window) static void ev_window_cmd_start_presentation (GtkAction *action, EvWindow *window) { - ev_window_run_presentation_wrapper (window); + ev_window_run_presentation (window); } static void @@ -6784,7 +6771,7 @@ ev_window_media_player_key_pressed (EvWindow *window, * often seen keys */ if (strcmp (key, "Play") == 0) { - ev_window_run_presentation_wrapper (window); + ev_window_run_presentation (window); } else if (strcmp (key, "Previous") == 0) { if (EV_WINDOW_IS_PRESENTATION (window)) ev_view_presentation_previous_page (EV_VIEW_PRESENTATION (window->priv->presentation_view)); -- 2.39.3