File: Broadcast.tcl

package info (click to toggle)
tkchooser 2.0652-6
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 432 kB
  • ctags: 272
  • sloc: tcl: 3,344; makefile: 76; sh: 13
file content (108 lines) | stat: -rw-r--r-- 2,860 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
## This is the plugin to handle the mounting of Broadcast
## network volumes. It requires the afpfs package which
## implements an Broadcast mounter
##
## Ethan Gold <etgold@cs.vassar.edu> 2/24/98
##

if {[debug]} { puts "loading Broadcast plugin..." }

## register the plugin with the main chooser
register_plugin appletalk broadcast Broadcast

#### required procedures that simply return plugin information
proc broadcast.geticon {} { return "broadcast.ppm" }
proc broadcast.getpubname {} { return "Broadcast" }
proc broadcast.getprotocol {} { return "appletalk" }

#### real plugin functionality below here##

########## required functions #################

## start function - required
proc broadcast.start {} {
    global plug_globalflat
    if {[debug]} { puts "started Broadcast Plugin" }

    set entlabel [plug_list_label]
    $entlabel configure -text "Suckers:"
    update
    broadcast.widgets stop
    broadcast.widgets start
    broadcast.newzone
}

## stop funtion - required
proc broadcast.stop {} {
    if {[debug]} { puts "stopped Broadcast Plugin" }
    broadcast.clearentities
    broadcast.widgets stop
}

## function to call when a listitem is double-clicked
proc broadcast.doubleclick {} {
    if {[debug]} { puts "Broadcast: got double-click with [get_curr_item]" }
    broadcast.sendto
}

proc broadcast.newzone {} {
    set plugframe [plug_frame]
    $plugframe.status configure -text "scanning [appletalk.getcurrzone]..."
    update
    broadcast.clearentities
    broadcast.showentities [broadcast.getnames]
    $plugframe.status configure -text "ready."
}

############# End required functions ##################

proc broadcast.sendo {} {
    set sucker [get_curr_item]
    if {[string compare $sucker ""] == 0} {
	return
    }
    puts "Broadcast: pretending to bother $sucker"
}

## procedure to build and destroy Broadcast widgets
proc broadcast.widgets {command} {
    set plugframe [plug_frame]

    if {[string compare $command "start"] == 0} {
	button $plugframe.mount -text "Send..." -command broadcast.sendto
	pack $plugframe.mount
    } else {
	destroy $plugframe.mount
    }
    
}

## function to return the laserwriters in the current zone
proc broadcast.getnames {} {
    return [appletalk.namesfromlkup [broadcast.getentities]]
}

proc broadcast.getentities {} {
    set currzone [appletalk.getcurrzone]
    set entity "=:Broadcast@$currzone"
    set results [appletalk.nbplkup $entity]
    set results [appletalk.namesfromlkup $results]
    return $results
}

## function to display passed in entities in
## the plugin's entity list frame
proc broadcast.showentities {entitylist} {
    set lbox [plug_list]
    foreach entity $entitylist {
	$lbox insert end $entity
    }
}

proc broadcast.clearentities {} {
    set lbox [plug_list]
    $lbox delete 0 end
}

if {[debug]} { puts "finished loading Broadcast." }