Re: Need to change icon selection method.

Juergen Schoenwaelder (schoenw@sol)
Sun, 17 Apr 94 22:56:25 +0200

Hi!

John> I currently have 150 different icons. Sadly only the first 52 or so
John> show up in the pulldown menu. I have a couple of suggestions:
John>
John> 1) Create a listbox to hold all of the various icons. This way
John> we can scroll it to the proper point. This does mean that
John> the icon name will have to be a file name and not a menu
John> item name.
John>
John> or
John>
John> 2) Create a multiple heirarchy of icons, so I can do:
John>
John> icon->node->Sun Workstations->SparcStations->4_90
John>
John> and
John>
John> icon->node->Network Components->Routers->Cisco AGS

Below is a diff that implements version 2. Please try it and let me
know if its broken. With this diff, you can put a `menu path'
separated by colons before the icon name in the tkined.defaults file:

tkined.node72: s4_90.bm Sun Workstations:SparcStations:4_75
tkined.node73: s4_90.bm Sun Workstations:SparcStations:4_90

John> I would stringly suggest that you save icons by icon file
John> name, and not by some menu hook. Doing this prevents your new
John> icon definitions from screwing up my icon definitons (e.g. in
John> 0.9 tkined you added a couple of new icons (compared to 0.7),
John> and many of my nodes were displayed with the wrong icons).

I am not sure about this. Saving the menu name and not the bitmap file
name has the advantage that you could move bitmap files without
breaking saved maps by modifying the tkined.defaults file. All version
before 0.9 were a little bit buggy regarding this point, so there
might have been some problems (sorry). The question is, whether menu
entries or bitmap filenames are changing more frequently.

John> Also it would be nice if there is some way to see all of the
John> icons.

This would add an extra dialog (means more source code) and it would
not add new functionality. I use the tear-off menus to browse the
icons. But I did not have 150 - perhaps I will change my opinion.

John> As soon as I have finished converting the rest of the donated
John> sun-net-manager icons, I will make sure that I put them up
John> somewhere.

If you like, you can put the icons in the /pub/incoming directory on
ftp.ibr.cs.tu-bs.de [134.169.34.15] and I will move them to the tkined
directory on our server.

Thanks for pointing out the problem.
Juergen

---8<---8<---8<---8<---8<---8<---8<---8<---8<---8<---8<---8<---8<---8<--

*** tkined_editor.tcl.old Wed Mar 9 17:38:12 1994
--- tkined_editor.tcl Sun Apr 17 22:13:42 1994
***************
*** 363,369 ****
if {$name == ""} {
$w.menu.icon.m.node add sep
} else {
! $w.menu.icon.m.node add radio -label " $name" \
-variable node$w -value "$name" \
-command "$w.menu.icon configure -state disabled; \
update idletasks; \
--- 368,375 ----
if {$name == ""} {
$w.menu.icon.m.node add sep
} else {
! tkined_makemenu $w.menu.icon.m.node $name last name
! $last add radio -label " $name" \
-variable node$w -value "$name" \
-command "$w.menu.icon configure -state disabled; \
update idletasks; \
***************
*** 388,395 ****
if {$name == ""} {
$w.menu.icon.m.network add sep
} else {
! $w.menu.icon.m.network add radio -label " $name" \
! -variable network$w -value "$name" \
-command "$w.menu.icon configure -state disabled; \
update idletasks; \
tkined_icon_command $editor NETWORK {$name}; \
--- 394,402 ----
if {$name == ""} {
$w.menu.icon.m.network add sep
} else {
! tkined_makemenu $w.menu.icon.m.network $name last name
! $last add radio -label " $name" \
! -variable network$w -value $name \
-command "$w.menu.icon configure -state disabled; \
update idletasks; \
tkined_icon_command $editor NETWORK {$name}; \
***************
*** 413,420 ****
if {$name == ""} {
$w.menu.icon.m.group add sep
} else {
! $w.menu.icon.m.group add radio -label " $name" \
! -variable group$w -value "$name" \
-command "$w.menu.icon configure -state disabled;
update idletasks; \
tkined_icon_command $editor GROUP {$name}; \
--- 420,428 ----
if {$name == ""} {
$w.menu.icon.m.group add sep
} else {
! tkined_makemenu $w.menu.icon.m.group $name last name
! $last add radio -label " $name" \
! -variable group$w -value $name \
-command "$w.menu.icon configure -state disabled;
update idletasks; \
tkined_icon_command $editor GROUP {$name}; \
***************
*** 438,445 ****
if {$name == ""} {
$w.menu.icon.m.font add sep
} else {
! $w.menu.icon.m.font add radio -label " $name" \
! -variable font$w -value "$name" \
-command "$w.menu.icon configure -state disabled;
update idletasks; \
tkined_font_command $editor {$name}; \
--- 472,480 ----
if {$name == ""} {
$w.menu.icon.m.font add sep
} else {
! tkined_makemenu $w.menu.icon.m.font $name last name
! $last add radio -label " $name" \
! -variable font$w -value $name \
-command "$w.menu.icon configure -state disabled;
update idletasks; \
tkined_font_command $editor {$name}; \
***************
*** 465,472 ****
if {$name == ""} {
$w.menu.icon.m.color add sep
} else {
! $w.menu.icon.m.color add radio -label " $name" \
! -variable color$w -value "$name" \
-command "$w.menu.icon configure -state disabled;
update idletasks; \
tkined_color_command $editor {$name}; \
--- 500,508 ----
if {$name == ""} {
$w.menu.icon.m.color add sep
} else {
! tkined_makemenu $w.menu.icon.m.color $name last name
! $last add radio -label " $name" \
! -variable color$w -value $name \
-command "$w.menu.icon configure -state disabled;
update idletasks; \
tkined_color_command $editor {$name}; \
***************
*** 678,682 ****
if {[catch {exec /bin/sh -c "( fortune || yow )" 2> /dev/null} txt]} {
set txt "You do not have fortune or yow on your system? Unbelievable!"
}
! tkined_acknowledge $c $txt
}
--- 718,754 ----
if {[catch {exec /bin/sh -c "( fortune || yow )" 2> /dev/null} txt]} {
set txt "You do not have fortune or yow on your system? Unbelievable!"
}
! tkined_acknowledge $c $txt
! }
!
! ##
! ## Make a menu entry.
! ##
!
! proc tkined_makemenu {w path rlast rname} {
!
! static widgetpath
! static count
!
! upvar $rlast last
! upvar $rname name
!
! if {![info exists count]} { set count 0 }
! incr count
!
! set path [split $path :]
! set len [llength $path]
! set name [lindex $path [incr len -1]]
! set last $w
!
! foreach elem [lrange $path 0 [incr len -1]] {
!
! if {![info exists widgetpath($elem)]} {
! set widgetpath($elem) $last.$count
! menu $widgetpath($elem)
! $last add cascade -label " $elem" -menu $widgetpath($elem)
! }
!
! set last $widgetpath($elem)
! }
}
*** editor.c.old Wed Mar 2 10:47:24 1994
--- editor.c Sun Apr 17 22:13:43 1994
***************
*** 868,873 ****
--- 874,890 ----
while (*name && isspace(*name)) name++;
if (*name == '\0') return;

+ /* skip leading elements that are separated with colons */
+
+ {
+ char *p;
+ for (p = name; *p != '\0'; p++) {
+ if (*p == ':') {
+ name = p+1;
+ }
+ }
+ }
+
/* make our own copy since findfile will reuse the buffer space */

icon = xstrdup (icon);