]> gitweb.factorcode.org Git - factor.git/commitdiff
irc.ui: Userlists no longer use list gadgets
authorWilliam Schlieper <schlieper@unc.edu>
Fri, 1 Aug 2008 01:36:16 +0000 (21:36 -0400)
committerWilliam Schlieper <schlieper@unc.edu>
Fri, 1 Aug 2008 01:36:16 +0000 (21:36 -0400)
extra/irc/ui/ui.factor

index c91d797f252791f67401cbdf76d46b5e8970a938..0ceeed1d35b4c469bf649687dff32ea30f619acd 100755 (executable)
@@ -5,7 +5,7 @@ USING: accessors kernel threads combinators concurrency.mailboxes
        sequences strings hashtables splitting fry assocs hashtables\r
        ui ui.gadgets ui.gadgets.panes ui.gadgets.editors\r
        ui.gadgets.scrollers ui.commands ui.gadgets.frames ui.gestures\r
-       ui.gadgets.tabs ui.gadgets.grids ui.gadgets.lists ui.gadgets.labels\r
+       ui.gadgets.tabs ui.gadgets.grids ui.gadgets.packs ui.gadgets.labels\r
        io io.styles namespaces calendar calendar.format models continuations\r
        irc.client irc.client.private irc.messages irc.messages.private\r
        irc.ui.commandparser irc.ui.load qualified ;\r
@@ -20,7 +20,7 @@ SYMBOL: client
 \r
 TUPLE: ui-window client tabs ;\r
 \r
-TUPLE: irc-tab < frame listener client listmodel ;\r
+TUPLE: irc-tab < frame listener client userlist ;\r
 \r
 : write-color ( str color -- )\r
     foreground associate format ;\r
@@ -116,16 +116,15 @@ M: irc-message write-irc
 \r
 GENERIC: handle-inbox ( tab message -- )\r
 \r
-: filter-participants ( assoc val -- alist )\r
-    [ >alist ] dip\r
-   '[ second , = ] filter ;\r
+: filter-participants ( pack alist val color -- )\r
+   '[ , = [ <label> , >>color add-gadget ] [ drop ] if ] assoc-each ;\r
 \r
 : update-participants ( tab -- )\r
-    [ listmodel>> ] [ listener>> participants>> ] bi\r
-    [ +operator+ filter-participants ]\r
-    [ +voice+ filter-participants ]\r
-    [ +normal+ filter-participants ] tri\r
-    append append swap set-model ;\r
+    [ userlist>> [ clear-gadget ] keep ]\r
+    [ listener>> participants>> ] bi\r
+    [ +operator+ green filter-participants ]\r
+    [ +voice+ blue filter-participants ]\r
+    [ +normal+ black filter-participants ] 2tri ;\r
 \r
 M: participant-changed handle-inbox\r
     drop update-participants ;\r
@@ -162,11 +161,6 @@ irc-editor "general" f {
     { T{ key-down f f "ENTER" } editor-send }\r
 } define-command-map\r
 \r
-: <irc-list> ( -- gadget model )\r
-    [ drop ]\r
-    [ first2 [ <label> ] dip >>color ]\r
-    { } <model> [ <list> ] keep ;\r
-\r
 : <irc-tab> ( listener client -- irc-tab )\r
     irc-tab new-frame\r
     swap client>> >>client swap >>listener\r
@@ -175,19 +169,19 @@ irc-editor "general" f {
 \r
 : <irc-channel-tab> ( listener client -- irc-tab )\r
     <irc-tab>\r
-    <irc-list> [ <scroller> @right grid-add ] dip >>listmodel\r
-    [ update-participants ] keep ;\r
+    <pile> [ <scroller> @right grid-add ] keep >>userlist ;\r
 \r
 : <irc-server-tab> ( listener client -- irc-tab )\r
     <irc-tab> ;\r
 \r
 M: irc-tab graft*\r
-    [ listener>> ] [ client>> ] bi\r
-    add-listener ;\r
+    [ listener>> ] [ client>> ] bi add-listener ;\r
 \r
 M: irc-tab ungraft*\r
-    [ listener>> ] [ client>> ] bi\r
-    remove-listener ;\r
+    [ listener>> ] [ client>> ] bi remove-listener ;\r
+\r
+M: irc-tab pref-dim*\r
+    drop { 480 480 } ;\r
 \r
 : join-channel ( name ui-window -- )\r
     [ dup <irc-channel-listener> ] dip\r