~ubuntu-branches/ubuntu/trusty/scid/trusty

« back to all changes in this revision

Viewing changes to tcl/windows/gamelist.tcl

  • Committer: Package Import Robot
  • Author(s): Oliver Korff
  • Date: 2012-03-11 22:53:54 UTC
  • mfrom: (18.1.4 sid)
  • Revision ID: package-import@ubuntu.com-20120311225354-0qdtceosm3263cal
Tags: 1:4.3.0.cvs20120311-1
* New Upstream Version.
* Updated to standards version 3.9.3
* scid now recommends tdom and tcllib, which is necessary for the built-in
  xfcc support. Thanks to Ian Zimmerman for giving this hint. 
  (Closes: #656699) 
* Scid filter mode: "AND" is now working again. Thanks to Ian Zimmerman for
  the Report, and to Fulvio solving the bug upstream. (Closes: #661836) 

Show diffs side-by-side

added added

removed removed

Lines of Context:
1023
1023
  $w.glist tag configure fsmall -font font_Small
1024
1024
  menu $w.glist.header_menu
1025
1025
  menu $w.glist.header_menu.addcol
1026
 
  menu $w.glist.header_menu.sort -disabledforeground blue
1027
1026
  menu $w.glist.game_menu
1028
1027
  bind $w.glist <Configure> "set ::glistResized($w.glist) 1"
1029
1028
  bind $w.glist <2> "glist.popupmenu_ %W %x %y %X %Y $layout"
1030
1029
  bind $w.glist <3> "glist.popupmenu_ %W %x %y %X %Y $layout"
1031
1030
  bind $w.glist <ButtonRelease-1> "glist.release_ %W %x %y $layout"
1032
 
  bind $w.glist <Double-ButtonPress-1> {
1033
 
    foreach {idx ply} [split [%W selection] "_"] {}
1034
 
    if {[info exist idx]} {
1035
 
      sc_base switch $::glistBase(%W)
1036
 
      ::game::Load $idx $ply
1037
 
    }
1038
 
  }
 
1031
  bind $w.glist <Double-ButtonRelease-1> "glist.doubleclick_ %W %x %y $layout"
1039
1032
  bind $w.glist <Destroy> "glist.destroy_ $w.glist"
1040
1033
 
1041
1034
  set i 0
1174
1167
    set current_game -1
1175
1168
  }
1176
1169
  set i 0
1177
 
  busyCursor .
1178
1170
  foreach {idx line} [sc_base gameslist $base $::glistFirst($w) [expr 1 + $::glistVisibleLn($w)]\
1179
1171
                                        $::glistFilter($w) $::glistSortStr($w)] {
1180
1172
    $w insert {} end -id $idx -values $line -tag fsmall
1184
1176
    incr i
1185
1177
  }
1186
1178
  set ::glistLoaded($w) $i
1187
 
  unbusyCursor .
1188
1179
}
1189
1180
 
1190
1181
proc glist.showfindbar_ {{w} {layout}} {
1204
1195
}
1205
1196
 
1206
1197
proc glist.findgame_ {{w_parent} {dir ""}} {
1207
 
  busyCursor .
1208
1198
  set w $w_parent.glist
1209
1199
  set w_entryN $w_parent.find.gnum
1210
1200
  set gnum [$w_entryN get]
1212
1202
  set txt [$w_entryT get]
1213
1203
  $w_entryN configure -bg white
1214
1204
  $w_entryT configure -bg white
 
1205
  busyCursor .
 
1206
  update idletasks
1215
1207
 
1216
1208
  if {$dir == ""} {
1217
1209
    set r [sc_base gamelocation $::glistBase($w) $::glistFilter($w) $::glistSortStr($w) $gnum]
1241
1233
  unbusyCursor .
1242
1234
}
1243
1235
 
 
1236
proc glist.doubleclick_ {{w} {x} {y} {layout}} {
 
1237
  lassign [$w identify $x $y] what
 
1238
  if {$what == "heading"} {
 
1239
    foreach {c dir} $::glist_Sort($layout) { $w heading $c -image "" }
 
1240
    set ::glist_Sort($layout) {}
 
1241
    glist.sortClickHandle_ $w $x $y $layout
 
1242
  } else {
 
1243
    foreach {idx ply} [split [$w selection] "_"] {}
 
1244
    if {[info exist idx]} {
 
1245
      sc_base switch $::glistBase($w)
 
1246
      ::game::Load $idx $ply
 
1247
    }
 
1248
  }
 
1249
}
 
1250
 
1244
1251
proc glist.popupmenu_ {{w} {x} {y} {abs_x} {abs_y} {layout}} {
1245
1252
# identify region requires at least tk 8.5.9
1246
1253
# identify row have scrollbar problems
1297
1304
    set col_idx [lsearch -exact $::glist_Headers [$w column $col -id] ]
1298
1305
    $w.header_menu delete 0 end
1299
1306
 
1300
 
    #SORT
1301
 
    $w.header_menu.sort delete 0 end
1302
 
    if {"???" != [lindex $::glist_SortShortcuts $col_idx]} {
1303
 
      $w.header_menu.sort add command -label $::tr(GlistNewSort) -image ::glist_Arrows(0)\
1304
 
                               -compound right -command [list glist.sortBy_ $w $col_idx + $layout 1]
1305
 
      $w.header_menu.sort add command -label $::tr(GlistNewSort) -image ::glist_Arrows(1)\
1306
 
                               -compound right -command [list glist.sortBy_ $w $col_idx - $layout 1]
1307
 
      set a1 [llength $::glist_Sort($layout)]
1308
 
      set a2 [expr $a1 +1]
1309
 
      if {[lsearch -exact $::glist_Sort($layout) $col_idx ] == -1 && $a1 <= 16} {
1310
 
        $w.header_menu.sort add separator
1311
 
        $w.header_menu.sort add command -label $::tr(GlistAddToSort) -image ::glist_Arrows($a1)\
1312
 
                                -compound right -command [list glist.sortBy_ $w $col_idx + $layout 0]
1313
 
        $w.header_menu.sort add command -label $::tr(GlistAddToSort) -image ::glist_Arrows($a2)\
1314
 
                                -compound right -command [list glist.sortBy_ $w $col_idx - $layout 0]
1315
 
    }
1316
 
    $w.header_menu.sort add separator
1317
 
    }
1318
 
    $w.header_menu.sort add command -label $::tr(GlistCurrentSep) -state disabled
1319
 
    set i 0
1320
 
    foreach {c dir} $::glist_Sort($layout) {
1321
 
      set h [lindex $::glist_Headers $c]
1322
 
      set arrow_idx [expr $i *2]
1323
 
      if {$dir == "-"} { incr arrow_idx }
1324
 
      $w.header_menu.sort add command -label $::tr($h) -image ::glist_Arrows($arrow_idx) \
1325
 
                                      -compound left -state disabled
1326
 
      incr i
1327
 
    }
1328
 
    $w.header_menu add cascade -label $::tr(Sort) -menu $w.header_menu.sort
1329
 
 
1330
1307
    #CHANGE ALIGNMENT
1331
 
    $w.header_menu add separator
1332
1308
    set cur_a [lindex $::glist_ColAnchor($layout) $col_idx]
1333
1309
    if {$cur_a != "w"} {
1334
1310
      $w.header_menu add command -label $::tr(GlistAlignL) \
1381
1357
  }
1382
1358
}
1383
1359
 
1384
 
proc glist.sortBy_ {w col direction {layout} clear} {
1385
 
  foreach {c dir} $::glist_Sort($layout) { $w heading $c -image "" }
1386
 
  if {$clear} { unset ::glist_Sort($layout) }
1387
 
  lappend ::glist_Sort($layout) $col $direction
 
1360
proc glist.sortClickHandle_ {{w} {x} {y} {layout}} {
 
1361
  set col [$w identify column $x $y]
 
1362
  set col_idx [lsearch -exact $::glist_Headers [$w column $col -id] ]
 
1363
  if {"???" == [lindex $::glist_SortShortcuts $col_idx]} {
 
1364
    # TODO: notify the user that the column cannot be used for sorting
 
1365
    return
 
1366
  }
 
1367
 
 
1368
  set exists [lsearch -exact $::glist_Sort($layout) $col_idx ]
 
1369
  if {$exists == -1} {
 
1370
    lappend ::glist_Sort($layout) $col_idx -
 
1371
  } else {
 
1372
    incr exists
 
1373
    if {[lindex $::glist_Sort($layout) $exists ] == "+"} {
 
1374
      lset ::glist_Sort($layout) $exists {-}
 
1375
    } else {
 
1376
      lset ::glist_Sort($layout) $exists {+}
 
1377
    }
 
1378
  }
 
1379
 
1388
1380
  glist.sortInit_ $w $layout
1389
1381
  if {[info exist ::glistBase($w)]} { glist.update_ $w $::glistBase($w) }
1390
1382
}
1515
1507
        set from [expr [string trimleft $::ttk::treeview::State(heading) {#}] -1]
1516
1508
        set to [expr [string trimleft $new_col {#}] -1]
1517
1509
        set val [lindex $::glist_ColOrder($layout) $from]
1518
 
        set ::glist_ColOrder($layout) [lreplace $::glist_ColOrder($layout) $from $from]
1519
 
        set ::glist_ColOrder($layout) [linsert $::glist_ColOrder($layout) $to $val]
1520
 
        $w configure -displaycolumns $::glist_ColOrder($layout)
 
1510
        if {$from != $to} {
 
1511
          set ::glist_ColOrder($layout) [lreplace $::glist_ColOrder($layout) $from $from]
 
1512
          set ::glist_ColOrder($layout) [linsert $::glist_ColOrder($layout) $to $val]
 
1513
          $w configure -displaycolumns $::glist_ColOrder($layout)
 
1514
        } else {
 
1515
          glist.sortClickHandle_ $w $x $y $layout
 
1516
        }
1521
1517
      }
1522
1518
    }
1523
1519
  }