chiark / gitweb /
Merge login window fix from 4.1 branch
authorRichard Kettlewell <rjk@greenend.org.uk>
Sun, 29 Jun 2008 11:49:00 +0000 (12:49 +0100)
committerRichard Kettlewell <rjk@greenend.org.uk>
Sun, 29 Jun 2008 11:49:00 +0000 (12:49 +0100)
1  2 
disobedience/client.c
disobedience/login.c

diff --combined disobedience/client.c
index a8d33a92d666e4343a06715f9d9dfdebea8c5de9,5c82953d479ab947586f160ef5664014fddc7fb7..24069034a548f4a98622ad9571137231e7b38990
@@@ -68,8 -68,7 +68,7 @@@ static gboolean gtkclient_dispatch(GSou
    if(revents & (G_IO_OUT|G_IO_HUP|G_IO_ERR))
      mode |= DISORDER_POLL_WRITE;
    time(&esource->last_poll);
-   if(!login_window)
-     disorder_eclient_polled(esource->client, mode);
+   disorder_eclient_polled(esource->client, mode);
    return TRUE;                          /* ??? not documented */
  }
  
@@@ -126,14 -125,20 +125,15 @@@ static void gtkclient_comms_error(void 
  /** @brief Report a protocol-level error
   *
   * The error will not be retried.  We offer a callback to the submitter of the
-  * original command and if none is supplied we pop up an error box.
+  * original command and if none is supplied we drop the error message in the
+  * status bar.
   */
  static void gtkclient_protocol_error(void attribute((unused)) *u,
 -                                   void *v,
 +                                   void attribute((unused)) *v,
                                       int code,
                                     const char *msg) {
 -  struct callbackdata *cbd = v;
 -
    D(("gtkclient_protocol_error %s", msg));
-   popup_protocol_error(code, msg);
 -  if(cbd && cbd->onerror)
 -    cbd->onerror(cbd, code, msg);
 -  else
 -    gtk_label_set_text(GTK_LABEL(report_label), msg);
++  gtk_label_set_text(GTK_LABEL(report_label), msg);
  }
  
  /** @brief Report callback from eclient */
diff --combined disobedience/login.c
index df826724b0996022d4413012798204b309b57462,c9bf82659938a64dc5ecced0324bbda9ef8ce206..7cb64c9d38cc9efce7260356a9ac9f82476a8467
@@@ -29,6 -29,7 +29,6 @@@
   * It you hit Cancel then the window disappears without saving anything.
   *
   * TODO
 - * - escape and return should work
   * - cancel/close should be consistent with properties
   */
  
@@@ -162,6 -163,8 +162,8 @@@ static void login_ok(GtkButton attribut
    } else {
      /* Failed to connect - report the error */
      popup_msg(GTK_MESSAGE_ERROR, disorder_last(c));
+     /* TODO it would be nice to restore the config (not the entry contents!) to
+      * the last known good one if we were already connected to something. */
    }
    disorder_close(c);                    /* no use for this any more */
  }
@@@ -172,24 -175,6 +174,24 @@@ static void login_cancel(GtkButton attr
    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[] = {
    {
@@@ -226,7 -211,7 +228,7 @@@ void login_box(void) 
                   G_CALLBACK(gtk_widget_destroyed), &login_window);
    gtk_window_set_title(GTK_WINDOW(login_window), "Login Details");
    /* Construct the form */
 -  table = gtk_table_new(NLWIS + 1/*rows*/, 2/*columns*/, FALSE/*homogenous*/);
 +  table = gtk_table_new(NLWIS/*rows*/, 2/*columns*/, FALSE/*homogenous*/);
    gtk_widget_set_style(table, tool_style);
    for(n = 0; n < NLWIS; ++n) {
      label = gtk_label_new(lwis[n].description);
    }
    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,
    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);
  }