#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 25 /* This seems like bug in gtk to me */
-#define MAX_PRESENTATION_TIME 1440 /*60*24 ONE DAY*/
+#define SIDEBAR_DEFAULT_SIZE 30 /* 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)
+static gint
+ev_dscwindow_get_presentation_window_monitor (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));
+ gint work_monitor = gdk_screen_get_monitor_at_window (screen, gtk_widget_get_window (GTK_WIDGET (presentation_window)));
+ return work_monitor;
}
static gboolean
-ev_dscwindow_switch_monitors (GtkWidget *widget, EvDSCWindow *ev_dscwindow)
+ev_dscwindow_windows_placement (EvDSCWindow *ev_dscwindow)
{
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;
+ GdkScreen *screen = gtk_window_get_screen (GTK_WINDOW (ev_dscwindow));
+ gint presentation_monitor = ev_dscwindow_get_presentation_window_monitor(ev_dscwindow);
+ gint control_monitor = presentation_monitor;
- gdk_screen_get_monitor_geometry (screen, monitor_1, &coords);
+ gdk_screen_get_monitor_geometry (screen, control_monitor, &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;
+
+ presentation_monitor = (control_monitor + 1) % 2;
+ gdk_screen_get_monitor_geometry (screen, presentation_monitor,&coords);
+ gtk_window_move (GTK_WINDOW (ev_dscwindow->priv->presentation_window), coords.x, coords.y);
+
+ return TRUE;
+ } else
+ return FALSE;
}
static void
ev_dscwindow->priv->presentation_document = document;
ev_dscwindow->priv->presentation_view = EV_VIEW_PRESENTATION(pview);
ev_dscwindow->priv->page = ev_view_presentation_get_current_page (pview);
+ ev_dscwindow->priv->moveback_monitor = ev_dscwindow_get_presentation_window_monitor (ev_dscwindow);
ev_document_model_set_document(ev_dscwindow->priv->model, document);
ev_document_model_set_page(ev_dscwindow->priv->model, ev_dscwindow->priv->page);
ev_dscwindow);
ev_presentation_timer_set_pages (EV_PRESENTATION_TIMER(ev_dscwindow->priv->timer),
ev_document_get_n_pages (document));
-
- ev_dscwindow_window_placement (ev_dscwindow);
+ /* Wait for windows to get shown before moving them */
+ while(gtk_events_pending())
+ gtk_main_iteration();
+ /* something like http://mail.gnome.org/archives/gtk-list/2008-June/msg00061.html */
+ ev_dscwindow_windows_placement (ev_dscwindow);
}
static gboolean
_("Switch monitors, In case of more than two monitor window placing has to be manual."));
gtk_tool_button_set_icon_name (GTK_TOOL_BUTTON (b_switch), "object-flip-horizontal");
gtk_toolbar_insert (GTK_TOOLBAR (toolbar), b_switch, -1);
- g_signal_connect (b_switch, "clicked",
- G_CALLBACK (ev_dscwindow_switch_monitors), ev_dscwindow);
+ g_signal_connect_swapped (b_switch, "clicked",
+ G_CALLBACK (ev_dscwindow_windows_placement), ev_dscwindow);
GtkToolItem *b_notes = gtk_tool_button_new_from_stock (GTK_STOCK_OPEN);
gtk_tool_button_set_label (GTK_TOOL_BUTTON(b_notes), _("Load notes..."));
GtkWindow *presentation_window = GTK_WINDOW (priv->presentation_window);
GdkRectangle coords;
- gdk_screen_get_monitor_geometry (
- gtk_window_get_screen (presentation_window),
- priv->moveback_monitor, &coords);
-
+ gdk_screen_get_monitor_geometry (gtk_window_get_screen (presentation_window),
+ priv->moveback_monitor, &coords);
gtk_window_move (presentation_window, coords.x, coords.y);
}
ev_window_stop_presentation (EV_WINDOW(priv->presentation_window), TRUE);