Add support for --fullscreen option

This commit is contained in:
Marc-André Lureau 2011-07-11 15:49:09 +01:00 committed by Daniel P. Berrange
parent 98499277db
commit 7da268c164
4 changed files with 33 additions and 3 deletions

View File

@ -57,6 +57,10 @@ Zoom level of the display window in percentage. Range 10-200.
Do not attempt to tunnel the console over SSH, even if the main connection URI
used SSH.
=item -f, --fullscreen
Start with the window maximised to fullscreen
=item --debug
Print debugging information

View File

@ -50,6 +50,7 @@ int main(int argc, char **argv)
gboolean direct = FALSE;
gboolean waitvm = FALSE;
gboolean reconnect = FALSE;
gboolean fullscreen = FALSE;
const char *help_msg = N_("Run '" PACKAGE " --help' to see a full list of available command line options");
const GOptionEntry options [] = {
{ "version", 'V', G_OPTION_FLAG_NO_ARG, G_OPTION_ARG_CALLBACK,
@ -68,9 +69,11 @@ int main(int argc, char **argv)
N_("Zoom level of window, in percentage"), "ZOOM" },
{ "debug", '\0', 0, G_OPTION_ARG_NONE, &debug,
N_("display debugging information"), NULL },
{ G_OPTION_REMAINING, '\0', 0, G_OPTION_ARG_STRING_ARRAY, &args,
{ "full-screen", 'f', 0, G_OPTION_ARG_NONE, &fullscreen,
N_("Open in full screen mode"), NULL },
{ G_OPTION_REMAINING, '\0', 0, G_OPTION_ARG_STRING_ARRAY, &args,
NULL, "DOMAIN-NAME|ID|UUID" },
{ NULL, 0, 0, G_OPTION_ARG_NONE, NULL, NULL, NULL }
{ NULL, 0, 0, G_OPTION_ARG_NONE, NULL, NULL, NULL }
};
setlocale(LC_ALL, "");
@ -104,7 +107,7 @@ int main(int argc, char **argv)
return 1;
}
ret = virt_viewer_start(uri, args[0], zoom, direct, waitvm, reconnect, verbose, debug, NULL);
ret = virt_viewer_start(uri, args[0], zoom, direct, waitvm, reconnect, verbose, debug, fullscreen, NULL);
if (ret != 0)
return ret;
@ -118,5 +121,6 @@ int main(int argc, char **argv)
* c-indent-level: 8
* c-basic-offset: 8
* tab-width: 8
* indent-tabs-mode: t
* End:
*/

View File

@ -520,6 +520,22 @@ virt_viewer_enter_fullscreen(VirtViewer *viewer)
ViewAutoDrawer_SetActive(VIEW_AUTODRAWER(viewer->layout), TRUE);
}
static gboolean
window_state_cb(GtkWidget *widget G_GNUC_UNUSED, GdkEventWindowState *event,
gpointer data)
{
VirtViewer *viewer = data;
if (!(event->changed_mask & GDK_WINDOW_STATE_FULLSCREEN))
return TRUE;
if (event->new_window_state & GDK_WINDOW_STATE_FULLSCREEN)
virt_viewer_enter_fullscreen(viewer);
else
virt_viewer_leave_fullscreen(viewer);
return TRUE;
}
static void
virt_viewer_toolbar_leave_fullscreen(GtkWidget *button G_GNUC_UNUSED,
@ -1539,6 +1555,7 @@ virt_viewer_start(const char *uri,
gboolean reconnect,
gboolean verbose,
gboolean debug,
gboolean fullscreen,
GtkWidget *container)
{
VirtViewer *viewer;
@ -1627,6 +1644,9 @@ virt_viewer_start(const char *uri,
viewer->accelList = g_slist_append(viewer->accelList, accels->data);
g_object_ref(G_OBJECT(accels->data));
}
g_signal_connect(G_OBJECT(window), "window-state-event", G_CALLBACK(window_state_cb), viewer);
if (fullscreen)
gtk_window_fullscreen(GTK_WINDOW(window));
gtk_widget_show_all(viewer->window);
}
@ -1658,5 +1678,6 @@ virt_viewer_start(const char *uri,
* c-indent-level: 8
* c-basic-offset: 8
* tab-width: 8
* indent-tabs-mode: t
* End:
*/

View File

@ -37,6 +37,7 @@ extern int virt_viewer_start(const char *uri,
gboolean reconnect,
gboolean verbose,
gboolean debug,
gboolean fullscreen,
GtkWidget *container);
#endif /* VIRT_VIEWER_H */