Try to make our PGP signing more useful:
[u/mdw/putty] / unix / gtkwin.c
index 1b0ba4a..c93aeda 100644 (file)
@@ -64,7 +64,7 @@ struct gui_data {
        int is_wide;
     } fontinfo[4];
     int xpos, ypos, gotpos, gravity;
-    GdkCursor *rawcursor, *textcursor, *blankcursor, *currcursor;
+    GdkCursor *rawcursor, *textcursor, *blankcursor, *waitcursor, *currcursor;
     GdkColor cols[NALLCOLOURS];
     GdkColormap *colmap;
     wchar_t *pastein_data;
@@ -76,6 +76,7 @@ struct gui_data {
     int width, height;
     int ignore_sbar;
     int mouseptr_visible;
+    int busy_status;
     guint term_paste_idle_id;
     int alt_keycode;
     int alt_digits;
@@ -94,6 +95,7 @@ struct gui_data {
     char *progname, **gtkargvstart;
     int ngtkargs;
     guint32 input_event_time; /* Timestamp of the most recent input event. */
+    int reconfiguring;
 };
 
 struct draw_ctx {
@@ -372,15 +374,34 @@ gint delete_window(GtkWidget *widget, GdkEvent *event, gpointer data)
     return FALSE;
 }
 
+static void update_mouseptr(struct gui_data *inst)
+{
+    switch (inst->busy_status) {
+      case BUSY_NOT:
+       if (!inst->mouseptr_visible) {
+           gdk_window_set_cursor(inst->area->window, inst->blankcursor);
+       } else if (send_raw_mouse) {
+           gdk_window_set_cursor(inst->area->window, inst->rawcursor);
+       } else {
+           gdk_window_set_cursor(inst->area->window, inst->textcursor);
+       }
+       break;
+      case BUSY_WAITING:    /* XXX can we do better? */
+      case BUSY_CPU:
+       /* We always display these cursors. */
+       gdk_window_set_cursor(inst->area->window, inst->waitcursor);
+       break;
+      default:
+       assert(0);
+    }
+}
+
 static void show_mouseptr(struct gui_data *inst, int show)
 {
     if (!inst->cfg.hide_mouseptr)
        show = 1;
-    if (show)
-       gdk_window_set_cursor(inst->area->window, inst->currcursor);
-    else
-       gdk_window_set_cursor(inst->area->window, inst->blankcursor);
     inst->mouseptr_visible = show;
+    update_mouseptr(inst);
 }
 
 void draw_backing_rect(struct gui_data *inst)
@@ -1149,7 +1170,7 @@ void notify_remote_exit(void *frontend)
        inst->exited = TRUE;
        if (inst->cfg.close_on_exit == FORCE_ON ||
            (inst->cfg.close_on_exit == AUTO && exitcode == 0))
-           exit(0);                   /* just go. */
+           gtk_main_quit();           /* just go */
        if (inst->ldisc) {
            ldisc_free(inst->ldisc);
            inst->ldisc = NULL;
@@ -1227,6 +1248,13 @@ gint focus_event(GtkWidget *widget, GdkEventFocus *event, gpointer data)
     return FALSE;
 }
 
+void set_busy_status(void *frontend, int status)
+{
+    struct gui_data *inst = (struct gui_data *)frontend;
+    inst->busy_status = status;
+    update_mouseptr(inst);
+}
+
 /*
  * set or clear the "raw mouse message" mode
  */
@@ -1235,11 +1263,7 @@ void set_raw_mouse_mode(void *frontend, int activate)
     struct gui_data *inst = (struct gui_data *)frontend;
     activate = activate && !inst->cfg.no_mouse_rep;
     send_raw_mouse = activate;
-    if (send_raw_mouse)
-       inst->currcursor = inst->rawcursor;
-    else
-       inst->currcursor = inst->textcursor;
-    show_mouseptr(inst, inst->mouseptr_visible);
+    update_mouseptr(inst);
 }
 
 void request_resize(void *frontend, int w, int h)
@@ -2537,7 +2561,11 @@ int do_cmdline(int argc, char **argv, int do_everything,
        } else if(!strcmp(p, "-help") || !strcmp(p, "--help")) {
            help(stdout);
            exit(0);
-           
+
+        } else if (!strcmp(p, "-pgpfp")) {
+            pgp_fingerprints();
+            exit(1);
+
        } else if(p[0] != '-' && (!do_everything ||
                                   process_nonoption_arg(p, cfg))) {
             /* do nothing */
@@ -2855,6 +2883,11 @@ void change_settings_menuitem(GtkMenuItem *item, gpointer data)
 
     assert(lenof(ww) == NCFGCOLOURS);
 
+    if (inst->reconfiguring)
+      return;
+    else
+      inst->reconfiguring = TRUE;
+
     cfg2 = inst->cfg;                  /* structure copy */
 
     if (do_config_box(title, &cfg2, 1,
@@ -2972,6 +3005,7 @@ void change_settings_menuitem(GtkMenuItem *item, gpointer data)
        gtk_widget_queue_draw(inst->area);
     }
     sfree(title);
+    inst->reconfiguring = FALSE;
 }
 
 void fork_and_exec_self(struct gui_data *inst, int fd_to_close, ...)
@@ -3310,6 +3344,7 @@ int pt_main(int argc, char **argv)
     inst = snew(struct gui_data);
     memset(inst, 0, sizeof(*inst));
     inst->alt_keycode = -1;            /* this one needs _not_ to be zero */
+    inst->busy_status = BUSY_NOT;
 
     /* defer any child exit handling until we're ready to deal with
      * it */
@@ -3520,6 +3555,7 @@ int pt_main(int argc, char **argv)
 
     inst->textcursor = make_mouse_ptr(inst, GDK_XTERM);
     inst->rawcursor = make_mouse_ptr(inst, GDK_LEFT_PTR);
+    inst->waitcursor = make_mouse_ptr(inst, GDK_WATCH);
     inst->blankcursor = make_mouse_ptr(inst, -1);
     make_mouse_ptr(inst, -2);         /* clean up cursor font */
     inst->currcursor = inst->textcursor;