--- choose-2.75.cc Sat Jun 16 12:05:00 2001 +++ choose.cc Sat Jun 23 13:13:01 2001 @@ -100,48 +100,45 @@ isinstalled (Package *pkg, int trust) static void set_action (Package *pkg, bool preinc) { - pkg->srcpicked = 0; - if (!pkg->action || preinc) - ((int) pkg->action)++; + /* Don't worry about SAME variations during state transitions */ + switch (pkg->action) + { + case ACTION_SAME_PREV: + case ACTION_SAME_CURR: + case ACTION_SAME_TEST: + (int) pkg->action -= ACTION_SAME; + break; + case ACTION_SAME_LAST: + pkg->action = ACTION_LAST; + } - /* Exercise the action state machine. */ + /* Exercise the action state machine. + Return when an acceptable action is reached. */ + if (preinc) + ((int) pkg->action)++; for (;; ((int) pkg->action)++) switch (pkg->action) { - case ACTION_ERROR: case ACTION_UNKNOWN: - pkg->action = (actions) (ACTION_CURR - 1); - break; case ACTION_LAST: + case ACTION_ERROR: + /* Never set or past end, previous version */ pkg->action = ACTION_PREV; /* fall through intentionally */ case ACTION_PREV: case ACTION_CURR: case ACTION_TEST: - /* Try to find the next best action. We may not have all of - prev, curr, or test but we should have at least one of those. */ + /* See if this version is available, at least one should be */ Info *inf; inf = pkg->info + pkg->action; if (inf->version && inf->install_exists) { + /* Switch to SAME variation if this version is installed */ if (isinstalled (pkg, pkg->action)) (int) pkg->action += ACTION_SAME; return; } break; - /* ACTION_SAME_* are used when the installed version is the same - as the given action. */ - case ACTION_SAME_CURR: - case ACTION_SAME_TEST: - if (!preinc) /* Previously set to this value */ - return; - (int) pkg->action -= ACTION_SAME + 1; /* revert to ACTION_CURR, etc. */ - break; - case ACTION_SAME_PREV: - if (!preinc) /* Previously set to this value */ - return; - pkg->action = ACTION_UNINSTALL; - /* Fall through intentionally */ case ACTION_UNINSTALL: if (pkg->installed) return; @@ -155,13 +152,12 @@ set_action (Package *pkg, bool preinc) if (pkg->installed && pkg->installed->source_exists) return; break; - case ACTION_SAME_LAST: - pkg->action = ACTION_SKIP; - /* Fall through intentionally */ case ACTION_SKIP: - return; + if (! pkg->installed) + return; + break; default: - log (0, "should never get here %d\n", pkg->action); + log (0, "set_action(): invalid state %d\n", pkg->action); } } @@ -237,7 +233,8 @@ paint (HWND hwnd) TextOut (hdc, x + headers[CURRENT_COL].x, r, pkg->installed->version, strlen (pkg->installed->version)); SelectObject (bitmap_dc, bm_rtarrow); - BitBlt (hdc, x + headers[CURRENT_COL].x + headers[0].width + ICON_MARGIN/2 + HMARGIN/2, by, + BitBlt (hdc, x + headers[CURRENT_COL].x + headers[0].width + + ICON_MARGIN/2 + HMARGIN/2, by, 11, 11, bitmap_dc, 0, 0, SRCCOPY); } @@ -367,11 +364,13 @@ list_click (HWND hwnd, BOOL dblclk, int Package *pkg = package + package_indexes[r]; - if (x >= headers[NEW_COL].x - (HMARGIN / 2) && x <= headers[NEW_COL + 1].x - HMARGIN/2) + if (x >= headers[NEW_COL].x - (HMARGIN / 2) && + x <= headers[NEW_COL + 1].x - HMARGIN / 2) set_action (pkg, 1); - if (x >= headers[SRC_COL].x - HMARGIN/2 && x <= headers[SRC_COL + 1].x - HMARGIN/2) - pkg->srcpicked ^= 1; + if (x >= headers[SRC_COL].x - HMARGIN / 2 && + x <= headers[SRC_COL + 1].x - HMARGIN / 2) + pkg->srcpicked = !pkg->srcpicked; RECT rect; rect.left = headers[NEW_COL].x - scroll_ulc_x; @@ -482,6 +481,7 @@ default_trust (HWND h, trusts trust) { pkg->action = (actions) trust; set_action (pkg, 0); + pkg->srcpicked = 0; } RECT r; GetClientRect (h, &r); @@ -581,9 +581,11 @@ create_listview (HWND dlg, RECT *r) note_width (dc, "uninstall", NEW_COL_SIZE_SLOP, NEW_COL); headers[CURRENT_COL].x = HMARGIN/2; - headers[NEW_COL].x = headers[CURRENT_COL].x + headers[CURRENT_COL].width + NEW_COL_SIZE_SLOP + HMARGIN; + headers[NEW_COL].x = headers[CURRENT_COL].x + headers[CURRENT_COL].width + + NEW_COL_SIZE_SLOP + HMARGIN; headers[SRC_COL].x = headers[NEW_COL].x + headers[NEW_COL].width + HMARGIN; - headers[PACKAGE_COL].x = headers[SRC_COL].x + headers[SRC_COL].width + HMARGIN; + headers[PACKAGE_COL].x = headers[SRC_COL].x + headers[SRC_COL].width + + HMARGIN; default_trust (lv, TRUST_CURR); set_full_list (lv, full_list); @@ -931,11 +933,15 @@ do_choose (HINSTANCE h) nextbutton = 0; bm_spin = LoadImage (h, MAKEINTRESOURCE (IDB_SPIN), IMAGE_BITMAP, 0, 0, 0); - bm_rtarrow = LoadImage (h, MAKEINTRESOURCE (IDB_RTARROW), IMAGE_BITMAP, 0, 0, 0); + bm_rtarrow = LoadImage (h, MAKEINTRESOURCE (IDB_RTARROW), IMAGE_BITMAP, + 0, 0, 0); - bm_checkyes = LoadImage (h, MAKEINTRESOURCE (IDB_CHECK_YES), IMAGE_BITMAP, 0, 0, 0); - bm_checkno = LoadImage (h, MAKEINTRESOURCE (IDB_CHECK_NO), IMAGE_BITMAP, 0, 0, 0); - bm_checkna = LoadImage (h, MAKEINTRESOURCE (IDB_CHECK_NA), IMAGE_BITMAP, 0, 0, 0); + bm_checkyes = LoadImage (h, MAKEINTRESOURCE (IDB_CHECK_YES), IMAGE_BITMAP, + 0, 0, 0); + bm_checkno = LoadImage (h, MAKEINTRESOURCE (IDB_CHECK_NO), IMAGE_BITMAP, + 0, 0, 0); + bm_checkna = LoadImage (h, MAKEINTRESOURCE (IDB_CHECK_NA), IMAGE_BITMAP, + 0, 0, 0); register_windows (h); @@ -967,15 +973,16 @@ do_choose (HINSTANCE h) : "unknown"); const char *excluded = (pkg->exclude ? "yes" : "no"); - log (LOG_BABBLE, "[%s] action=%s trust=%s installed=%s excluded=%s src?=%s", + log (LOG_BABBLE, + "[%s] action=%s trust=%s installed=%s excluded=%s src?=%s", pkg->name, action, trust, installed, excluded, pkg->srcpicked ? "yes" : "no"); for (int t = 1; t < NTRUST; t++) { if (pkg->info[t].install) - log (LOG_BABBLE, " [%s] ver=%s\r\n" - " inst=%s %d exists=%s\r\n" - " src=%s %d exists=%s", + log (LOG_BABBLE, " [%s] ver=%s\n" + " inst=%s %d exists=%s\n" + " src=%s %d exists=%s", infos[t], pkg->info[t].version ?: "(none)", pkg->info[t].install ?: "(none)", @@ -983,7 +990,7 @@ do_choose (HINSTANCE h) (pkg->info[t].install_exists) ? "yes":"no", pkg->info[t].source ?: "(none)", pkg->info[t].source_size, - (pkg->info[t].source_exists == 1) ? "yes":"no"); + (pkg->info[t].source_exists) ? "yes":"no"); } } }