aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--domain.c12
-rw-r--r--vconsole.c38
-rw-r--r--vconsole.h2
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";
@@ -237,6 +259,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[] =
" <menuitem action='TerminalBackground'/>\n"
" <menuitem action='TerminalBlink'/>\n"
" </menu>\n"
+" <menu action='GuestMenu'>\n"
+" <menuitem action='GuestRun'/>\n"
+" </menu>\n"
" <menu action='HelpMenu'>\n"
" <menuitem action='About'/>\n"
" </menu>\n"
" </menubar>\n"
+" <toolbar action='ToolBar'>"
+" <toolitem action='GuestRun'/>\n"
+" </toolbar>\n"
"</ui>\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);