X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~mdw/git/disorder/blobdiff_plain/f44417cf9d3d5ddea2f0dfb2e238a2826eb6691d..b2ea2aa69b7be1b80da98218f77e01b65cabe0ed:/disobedience/login.c diff --git a/disobedience/login.c b/disobedience/login.c index f5ef053..63e284b 100644 --- a/disobedience/login.c +++ b/disobedience/login.c @@ -27,6 +27,9 @@ * window remains. * * It you hit Cancel then the window disappears without saving anything. + * + * TODO + * - cancel/close should be consistent with properties */ #include "disobedience.h" @@ -153,7 +156,7 @@ static void login_ok(GtkButton attribute((unused)) *button, if(!disorder_connect(c)) { /* Success; save the config and start using it */ login_save_config(); - reset(); + logged_in(); /* Pop down login window */ gtk_widget_destroy(login_window); } else { @@ -169,6 +172,24 @@ static void login_cancel(GtkButton attribute((unused)) *button, gtk_widget_destroy(login_window); } +/** @brief Keypress handler */ +static gboolean login_keypress(GtkWidget attribute((unused)) *widget, + GdkEventKey *event, + gpointer attribute((unused)) user_data) { + if(event->state) + return FALSE; + switch(event->keyval) { + case GDK_Return: + login_ok(0, 0); + return TRUE; + case GDK_Escape: + login_cancel(0, 0); + return TRUE; + default: + return FALSE; + } +} + /* Buttons that appear at the bottom of the window */ static struct button buttons[] = { { @@ -230,13 +251,21 @@ void login_box(void) { } buttonbox = create_buttons(buttons, NBUTTONS); vbox = gtk_vbox_new(FALSE, 1); + gtk_box_pack_start(GTK_BOX(vbox), + gtk_image_new_from_pixbuf(find_image("logo256.png")), + TRUE/*expand*/, + TRUE/*fill*/, + 4/*padding*/); gtk_box_pack_start(GTK_BOX(vbox), table, TRUE/*expand*/, TRUE/*fill*/, 1/*padding*/); gtk_box_pack_start(GTK_BOX(vbox), buttonbox, FALSE/*expand*/, FALSE/*fill*/, 1/*padding*/); - gtk_container_add(GTK_CONTAINER(login_window), vbox); + gtk_container_add(GTK_CONTAINER(login_window), frame_widget(vbox, NULL)); gtk_window_set_transient_for(GTK_WINDOW(login_window), GTK_WINDOW(toplevel)); + /* Keyboard shortcuts */ + g_signal_connect(login_window, "key-press-event", + G_CALLBACK(login_keypress), 0); gtk_widget_show_all(login_window); }