diff options
author | Gerd Hoffmann <kraxel@redhat.com> | 2012-08-15 23:08:50 +0200 |
---|---|---|
committer | Gerd Hoffmann <kraxel@redhat.com> | 2012-08-15 23:09:14 +0200 |
commit | 915c3330450b7fcc94cf5e72ca479e6db292ac18 (patch) | |
tree | da956d1be668810dcf9bb73674ba1714f3889b83 | |
parent | daf23c350f0fe8fffbbde331d43460c517d3e445 (diff) | |
download | vconsole-915c3330450b7fcc94cf5e72ca479e6db292ac18.tar.gz |
windup file/connect ...
-rw-r--r-- | README | 5 | ||||
-rw-r--r-- | vconsole.c | 55 |
2 files changed, 53 insertions, 7 deletions
@@ -30,11 +30,6 @@ that). Known issues / TODO list ======================== -Dialog asking for a libvirt uri isn't implemented yet, so you have to -use the -c command line switch. vconsole will remember successful -connects though and offer the hosts in a menu, so you have to do that -only once per host. - vconsole doesn't handle undefining domains yet. vconsole doesn't handle connection drops (caused by libvirtd restart @@ -43,10 +43,61 @@ void config_write(void) /* ------------------------------------------------------------------ */ +static int gtk_getstring(GtkWidget *window, char *title, char *message, + char *dest, int dlen) +{ + GtkWidget *dialog, *label, *entry; + const char *txt; + int retval; + + /* Create the widgets */ + dialog = gtk_dialog_new_with_buttons(title, + GTK_WINDOW(window), + GTK_DIALOG_DESTROY_WITH_PARENT, + GTK_STOCK_OK, + GTK_RESPONSE_ACCEPT, + GTK_STOCK_CANCEL, + GTK_RESPONSE_REJECT, + NULL); + gtk_dialog_set_default_response(GTK_DIALOG(dialog), GTK_RESPONSE_ACCEPT); + + label = gtk_label_new(message); + gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5); + + entry = gtk_entry_new(); + gtk_entry_set_text(GTK_ENTRY(entry), dest); + gtk_entry_set_activates_default(GTK_ENTRY(entry), TRUE); + + gtk_container_add(GTK_CONTAINER(GTK_DIALOG(dialog)->vbox), label); + gtk_container_add(GTK_CONTAINER(GTK_DIALOG(dialog)->vbox), entry); + gtk_box_set_spacing(GTK_BOX(GTK_DIALOG(dialog)->vbox), 10); + + /* show and wait for response */ + gtk_widget_show_all(dialog); + switch (gtk_dialog_run(GTK_DIALOG(dialog))) { + case GTK_RESPONSE_ACCEPT: + txt = gtk_entry_get_text(GTK_ENTRY(entry)); + snprintf(dest, dlen, "%s", txt); + retval = 0; + break; + default: + retval = -1; + break; + } + gtk_widget_destroy(dialog); + return retval; +} + static void menu_cb_connect_ask(GtkAction *action, gpointer userdata) { -// struct vconsole_window *win = userdata; - fprintf(stderr, "%s: [ FIXME ]\n", __func__); + struct vconsole_window *win = userdata; + char uri[256] = ""; + int rc; + + rc = gtk_getstring(win->toplevel, "Connect to host", "libvirt uri", + uri, sizeof(uri)); + if (rc == 0 && strlen(uri)) + connect_init(win, uri); } static void menu_cb_connect_menu(GtkAction *action, gpointer userdata) |