diff options
author | Gerd Hoffmann <kraxel@redhat.com> | 2012-08-15 23:45:18 +0200 |
---|---|---|
committer | Gerd Hoffmann <kraxel@redhat.com> | 2012-08-15 23:45:18 +0200 |
commit | 3ab79ed743f5574c3f9120c2892d377128e2d7bc (patch) | |
tree | 056095b2de19a76dd6c1566f18db9821530e6245 | |
parent | 98f99f5f4b7760010922041d92bf1d17cefd151d (diff) | |
download | vconsole-3ab79ed743f5574c3f9120c2892d377128e2d7bc.tar.gz |
start guest menu/toolbar item
-rw-r--r-- | domain.c | 12 | ||||
-rw-r--r-- | vconsole.c | 38 | ||||
-rw-r--r-- | vconsole.h | 2 |
3 files changed, 48 insertions, 4 deletions
@@ -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; @@ -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[] = @@ -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); |