From 3ab79ed743f5574c3f9120c2892d377128e2d7bc Mon Sep 17 00:00:00 2001 From: Gerd Hoffmann Date: Wed, 15 Aug 2012 23:45:18 +0200 Subject: start guest menu/toolbar item --- domain.c | 12 ++++++++---- vconsole.c | 38 ++++++++++++++++++++++++++++++++++++++ vconsole.h | 2 ++ 3 files changed, 48 insertions(+), 4 deletions(-) diff --git a/domain.c b/domain.c index 1bfe303..4cbe726 100644 --- a/domain.c +++ b/domain.c @@ -121,15 +121,13 @@ static void domain_user_input(VteTerminal *vte, gchar *buf, guint len, gpointer opaque) { struct vconsole_domain *dom = opaque; - virDomainPtr d; if (dom->stream) { virStreamSend(dom->stream, buf, len); return; } if (dom->info.state == VIR_DOMAIN_SHUTOFF) { - d = virDomainLookupByUUIDString(dom->conn->ptr, dom->uuid); - virDomainCreate(d); + domain_start(dom); } } @@ -163,6 +161,12 @@ static void domain_connect(struct vconsole_domain *dom, virDomainPtr d) /* ------------------------------------------------------------------ */ +void domain_start(struct vconsole_domain *dom) +{ + virDomainPtr d = virDomainLookupByUUIDString(dom->conn->ptr, dom->uuid); + virDomainCreate(d); +} + void domain_update(struct vconsole_connect *conn, virDomainPtr d, virDomainEventType event) { @@ -300,7 +304,7 @@ static void domain_close_tab(struct vconsole_domain *dom) dom->status = NULL; } -static struct vconsole_domain *domain_find_current_tab(struct vconsole_window *win) +struct vconsole_domain *domain_find_current_tab(struct vconsole_window *win) { GtkTreeModel *model = GTK_TREE_MODEL(win->store); GtkTreeIter host, guest; diff --git a/vconsole.c b/vconsole.c index 8fcd3de..4a30ffe 100644 --- a/vconsole.c +++ b/vconsole.c @@ -198,6 +198,28 @@ static void menu_cb_config_bg(GtkAction *action, void *data) domain_configure_all_vtes(win); } +static struct vconsole_domain *find_guest(struct vconsole_window *win) +{ + struct vconsole_domain *dom; + + if (gtk_notebook_get_current_page(GTK_NOTEBOOK(win->notebook)) == 0) { + fprintf(stderr, "%s: [ TODO ] figure list selected guest\n", __func__); + dom = NULL; + } else { + dom = domain_find_current_tab(win); + } + return dom; +} + +static void menu_cb_vm_run(GtkAction *action, void *data) +{ + struct vconsole_window *win = data; + struct vconsole_domain *dom = find_guest(win); + + if (dom) + domain_start(dom); +} + static void menu_cb_about(GtkAction *action, gpointer userdata) { static char *comments = "virtual machine console"; @@ -236,6 +258,9 @@ static const GtkActionEntry entries[] = { },{ .name = "ViewMenu", .label = "_View", + },{ + .name = "GuestMenu", + .label = "_Guest", },{ .name = "HelpMenu", .label = "_Help", @@ -280,6 +305,13 @@ static const GtkActionEntry entries[] = { .callback = G_CALLBACK(menu_cb_config_bg), },{ + /* --- guest menu --- */ + .name = "GuestRun", + .stock_id = GTK_STOCK_MEDIA_PLAY, + .label = "Start", + .callback = G_CALLBACK(menu_cb_vm_run), + + },{ /* --- help menu --- */ .name = "About", .stock_id = GTK_STOCK_ABOUT, @@ -313,10 +345,16 @@ static char ui_xml[] = " \n" " \n" " \n" +" \n" +" \n" +" \n" " \n" " \n" " \n" " \n" +" " +" \n" +" \n" "\n"; static char recent_xml[] = diff --git a/vconsole.h b/vconsole.h index 424042f..6422db7 100644 --- a/vconsole.h +++ b/vconsole.h @@ -74,8 +74,10 @@ struct vconsole_domain { virDomainInfo info; }; +void domain_start(struct vconsole_domain *dom); void domain_update(struct vconsole_connect *conn, virDomainPtr d, virDomainEventType event); void domain_activate(struct vconsole_domain *dom); void domain_configure_all_vtes(struct vconsole_window *win); +struct vconsole_domain *domain_find_current_tab(struct vconsole_window *win); void domain_close_current_tab(struct vconsole_window *win); -- cgit