summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: db746cb)
raw | patch | inline | side by side (parent: db746cb)
author | Sebastian Harl <sh@tokkee.org> | |
Thu, 22 Dec 2011 23:00:27 +0000 (00:00 +0100) | ||
committer | Sebastian Harl <sh@tokkee.org> | |
Thu, 22 Dec 2011 23:00:27 +0000 (00:00 +0100) |
This is done by pressing the 'M' (move) key.
For this purpose, the functions gtk_tpdfv_screens_window_set() and
gtk_tpdfv_screens_window_get() have been added, querying the list of screens
for the right settings.
For this purpose, the functions gtk_tpdfv_screens_window_set() and
gtk_tpdfv_screens_window_get() have been added, querying the list of screens
for the right settings.
src/gtk-tpdfv-screen.c | patch | blob | history | |
src/gtk-tpdfv.h | patch | blob | history | |
src/tpdfview.c | patch | blob | history |
diff --git a/src/gtk-tpdfv-screen.c b/src/gtk-tpdfv-screen.c
index a118d79f67c6a6a559b4cbad93b6b713711de3ea..104522e01e81b2d6b0d7f063d81933ba3b1de5a3 100644 (file)
--- a/src/gtk-tpdfv-screen.c
+++ b/src/gtk-tpdfv-screen.c
}
}
return screens;
-} /* gtk_tpdfv_new */
+} /* gtk_tpdfv_screens_init */
void
gtk_tpdfv_screens_destroy(gtk_tpdfv_screens_t *screens)
if (screens->screens)
free(screens->screens);
free(screens);
-} /* gtk_tpdfv_destroy_screens */
+} /* gtk_tpdfv_screens_destroy */
gint
gtk_tpdfv_screens_number(const gtk_tpdfv_screens_t *screens)
return screens->num_screens;
} /* gtk_tpdfv_screens_number */
+void
+gtk_tpdfv_screens_window_set(const gtk_tpdfv_screens_t *screens,
+ GtkWindow *window, gint screen)
+{
+ screen_t *s_old, *s_new;
+
+ gint x = 0, y = 0;
+ gint current;
+
+ if ((! screens) || (! window)
+ || (screen < 0) || (screen >= screens->num_screens))
+ return;
+
+ gtk_window_get_position(window, &x, &y);
+
+ current = gtk_tpdfv_screens_window_get(screens, window);
+ assert((0 <= current) && (current < screens->num_screens));
+
+ s_old = screens->screens + current;
+ s_new = screens->screens + screen;
+
+ gtk_window_set_screen(window, s_new->screen);
+ gtk_window_move(window,
+ s_new->x + (x - s_old->x), s_new->y + (y - s_old->y));
+} /* gtk_tpdfv_screens_window_set */
+
+gint
+gtk_tpdfv_screens_window_get(const gtk_tpdfv_screens_t *screens,
+ GtkWindow *window)
+{
+ GdkScreen *gdk_screen;
+
+ gint x = 0, y = 0;
+ gint i;
+
+ if ((! screens) || (! window))
+ return -1;
+
+ gdk_screen = gtk_window_get_screen(window);
+ gtk_window_get_position(window, &x, &y);
+
+ for (i = 0; i < screens->num_screens; ++i) {
+ screen_t *screen = screens->screens + i;
+
+ if ((screen->screen == gdk_screen)
+ && (screen->x <= x) && (x <= screen->x + screen->width)
+ && (screen->y <= y) && (y <= screen->y + screen->height))
+ return i;
+ }
+ return -1;
+} /* gtk_tpdfv_screens_window_set */
+
/* vim: set tw=78 sw=4 ts=4 noexpandtab : */
diff --git a/src/gtk-tpdfv.h b/src/gtk-tpdfv.h
index 44ffd71d0dfe6577d2cd9cd165b131826afdf4c2..9dd48f8183b6bff57f43353f13f99b0d91c983f6 100644 (file)
--- a/src/gtk-tpdfv.h
+++ b/src/gtk-tpdfv.h
gint
gtk_tpdfv_screens_number(const gtk_tpdfv_screens_t *screens);
+/*
+ * gtk_tpdfv_screens_window_set, gtk_tpdfv_screens_window_get:
+ * Set or get the screen of a window.
+ */
+void
+gtk_tpdfv_screens_window_set(const gtk_tpdfv_screens_t *screens,
+ GtkWindow *window, gint screen);
+gint
+gtk_tpdfv_screens_window_get(const gtk_tpdfv_screens_t *screens,
+ GtkWindow *window);
+
#ifdef __cplusplus
} /* extern "C" */
#endif
diff --git a/src/tpdfview.c b/src/tpdfview.c
index b15bad3a078d0b87aa93e9dee03b034508106aaf..e6fee214669f91edc7a8f68fa661d361229ef402 100644 (file)
--- a/src/tpdfview.c
+++ b/src/tpdfview.c
#include <gtk/gtk.h>
#include <gdk/gdkkeysyms.h>
+/*
+ * Global variables.
+ */
+static gtk_tpdfv_screens_t *screens = NULL;
+
static void
exit_usage(char *name, int status)
{
case GDK_Right:
gtk_tpdfv_scroll_right(tpdfv);
break;
+
+ /* screen management */
+ case GDK_M:
+ {
+ gint n_screens = gtk_tpdfv_screens_number(screens);
+ gint screen = gtk_tpdfv_screens_window_get(screens,
+ GTK_WINDOW(window));
+
+ gtk_tpdfv_screens_window_set(screens,
+ GTK_WINDOW(window), (screen + 1) % n_screens);
+ }
+ break;
}
return FALSE;
} /* key_press */
int
main(int argc, char **argv)
{
- gtk_tpdfv_screens_t *screens;
-
GtkWidget *win = NULL;
GtkWidget *tpdfv = NULL;