Heya :)

I've been testing your patch and I've only got one issue with it.  
Even with the second patch when I choose the "Change Display  
picture..." option from the chatwindow, it doesn't default to my  
pictures.. I can choose my user without problem it would just be  
better to default to my pictures without asking the user.

Any way off to bed.

Thanks!


On 4 Jan 2007, at 20:37, Cristofaro Del Prete wrote:

> I'm very sorry... but, as according with Murphy's Law, the last bug is
> found always *after* the release...
> Here's a new patch including a little fix for a case I forgot.
>
> Cristofaro Del Prete ha scritto:
>> Hi,
>> I've just finished implementing custom display pictures, and I  
>> thought
>> that, as is a new feature, it was better to post it here.
>>
>> This implementation of custom DP relies on the dpbrowser snit object,
>> that was almost complete (I just addded some bits here and there) and
>> that was already used in the contact properties screen.
>>
>> --- What's Done ---
>>
>> * Replaced all the calls to pictureBrowser with equivalent calls to
>> dpBrowser
>> * Added to the display picture's popup menu (in the chat window) the
>> options to change/remove custom display pictures
>> * Added ability to select image in dpbrowser
>> * Generalized dpBrowser and related functions to work also with other
>> contacts, not just with "self" user
>> * Added controls in contact properties screen (settings tab) to
>> change/remove custom display pictures
>> * Marked with TODOs all the procedures related to picturebrowser for
>> eventual removal
>>
>> --- What's Still To Do ---
>>
>> * Translate dpBrowser labels and buttons
>> * Translate label in the properties screen
>> * Translate new entries in display picture's popup menu
>>
>> Please comment my work, and make me know if you liked it.
>
> Index: automsg.tcl
> ===================================================================
> --- automsg.tcl       (revisione 7718)
> +++ automsg.tcl       (copia locale)
> @@ -219,7 +219,7 @@
>       $path add separator
>       $path add command -label "[trans changenick]..." -command  
> cmsn_change_name
>       
> -     $path add command -label "[trans changedisplaypic]..." -command  
> pictureBrowser
> +     $path add command -label "[trans changedisplaypic]..." -command  
> dpBrowser
>       
>       $path add command -label "[trans editmyprofile]..." -command  
> "::hotmail::hotmail_profile"
>       
> Index: gui.tcl
> ===================================================================
> --- gui.tcl   (revisione 7718)
> +++ gui.tcl   (copia locale)
> @@ -1764,8 +1764,26 @@
>               }
>               #Load Change Display Picture window
>               $win.picmenu add separator
> -             $win.picmenu add command -label "[trans changedisplaypic]..." - 
> command pictureBrowser
> +             $win.picmenu add command -label "[trans changedisplaypic]..." - 
> command dpBrowser
> +             foreach user $users {
> +                     $win.picmenu add command -label "[trans 
> changecustomuserpic  
> $user]" \
> +                             -command "autoChangeCustomDp $user"
> +             }
>
> +             #Section to remove custom display pictures
> +             set first_one 0
> +             foreach user $users {
> +                     if {[::abook::getContactData $user customdp ] != ""} {
> +                             # The separator is added only if the section is 
> really going  
> to be draw
> +                             if {$first_one == "0"} {
> +                                     $win.picmenu add separator
> +                                     set first_one 1
> +                             }
> +                             $win.picmenu add command -label "[trans 
> removecustomuserpic  
> $user]" \
> +                                     -command "autoRemoveCustomDp $user"
> +                     }
> +             }
> +
>               set user [$win.f.bottom.pic.image cget -image]
>               if { $user != "displaypicture_std_none" && $user !=  
> "displaypicture_std_self" } {
>                       #made easy for if we would change the image names
> @@ -3245,7 +3263,7 @@
>       #change nick
>       $accnt add command -label "[trans changenick]..." -command  
> cmsn_change_name -state disabled
>       #change dp
> -     $accnt add command -label "[trans changedisplaypic]..." -command  
> pictureBrowser -state disabled
> +     $accnt add command -label "[trans changedisplaypic]..." -command  
> dpBrowser -state disabled
>       #-------------------
>       $accnt add separator
>       #go to inbox
> @@ -7094,8 +7112,8 @@
>  }
>
>
> -proc dpBrowser {} {
> -     global selected_path
> +proc dpBrowser { {target_user "self" } } {
> +     global selected_path selected_image HOME
>
>       package require dpbrowser
>       
> @@ -7121,6 +7139,18 @@
>       #Sorts contacts
>       set contactlist [lsort -dictionary $contact_list]
>       
> +     # Select current DP (custom or not) for target user
> +     if { $target_user != "self" } {
> +             if { [::abook::getContactData $target_user customdp] != "" } {
> +                     set image_name [::abook::getContactData $target_user 
> customdp ""]
> +             } else {
> +                     set image_name [::abook::getContactData $target_user  
> displaypicfile ""]
> +             }
> +             if {$image_name != ""} {
> +                     set selected_path [file join $HOME displaypic cache 
> [filenoext  
> $image_name].png]
> +                     set selected_image "[filenoext $selected_path].png"
> +             }
> +     }
>       
>       ################
>       # First column #
> @@ -7135,33 +7165,52 @@
>       #combobox to choose user which configures the widget with -user  
> $user
>
>       set combo $w.moredpstitle.combo
> -     combobox::combobox $combo -highlightthickness 0 -width 22  -font  
> splainf -exportselection true -command "configuredpbrowser" - 
> editable false -bg #FFFFFF
> +     combobox::combobox $combo -highlightthickness 0 -width 22  -font  
> splainf -exportselection true -command "configuredpbrowser  
> $target_user" -editable false -bg #FFFFFF
>       $combo list delete 0 end
>       $combo list insert end "Select a contact:"
> +     
>       foreach contact $contactlist {
>               #put the name of the device in the widget
>               $combo list insert end $contact
> +             if {$contact == $target_user} {
> +                     set selection [expr [$combo list index end] - 1]
> +             }
>       }
> -     catch {$combo select 0}
> +     
> +     # If we are choosing a custom DP for a contact, show his cache in  
> the lower pane
> +     if {$target_user == "self"} {
> +             catch {$combo select 0}
> +             set selected_user ""
> +     } else {
> +             catch {$combo select $selection}
> +             set selected_user $target_user
> +     }
>
>       pack $w.moredpstitle.text -side left
>       pack $w.moredpstitle.combo -side right
>
> -     ::dpbrowser $w.mydps -width 3 -user self
> +     ::dpbrowser $w.mydps -width 3 -user self -post_select  
> updateDpBrowserSelection
>
> -     ::dpbrowser $w.moredps -width 3
> -
> +     ::dpbrowser $w.moredps -width 3 -user $selected_user -post_select  
> updateDpBrowserSelection -picinuse "yes"
> +     
>       #################
>       # second column #
>       #################
>
>       #preview
>       label $w.dppreviewtxt -text "Preview:"
> -     label $w.dppreview -image displaypicture_std_self
> +     if {$target_user == "self"} {
> +             label $w.dppreview -image displaypicture_std_self
> +     } else {
> +             if { $image_name == "" } {
> +                     label $w.dppreview -image displaypicture_std_none
> +             } else {
> +                     label $w.dppreview -image [image create photo 
> [TmpImgName] - 
> file $selected_path -format cximage]
> +             }
> +     }
>       
>       #browse button
>       button $w.browsebutton -command "set selected_path \ 
> [pictureChooseFile\]" -text "[trans browse]..."
> -#TODO: pictureChooseFile to be changed to our working and it  
> should update our preview
>       
>       #under this button is space for more buttons we'll make a frame  
> for so plugins can pack stuff in this frame
>       frame $w.pluginsframe -bd 0
> @@ -7172,7 +7221,7 @@
>       # lower pane    #
>       #################       
>       frame $w.lowerpane -bd 0
> -     button $w.lowerpane.ok -text "[trans ok]" -command  
> "set_displaypic \${selected_image};destroy $w"
> +     button $w.lowerpane.ok -text "[trans ok]" -command  
> "set_displaypic \${selected_image} $target_user;destroy $w"
>       button $w.lowerpane.cancel -text "[trans cancel]" -command  
> "destroy .dpbrowser"
>       pack $w.lowerpane.ok $w.lowerpane.cancel -side right -padx 5
>
> @@ -7194,13 +7243,34 @@
>  }
>
>
> -proc configuredpbrowser {combowidget selection} {
> +proc configuredpbrowser {target combowidget selection} {
>       #puts "$combowidget $selection"
>       if {$selection == "Select a contact:"} {set selection ""}
> -     [winfo toplevel $combowidget].moredps configure -user $selection
> +     if {$selection == $target} {
> +             [winfo toplevel $combowidget].moredps configure -user 
> $selection  
> -picinuse "no"
> +     } else {
> +             [winfo toplevel $combowidget].moredps configure -user 
> $selection  
> -picinuse "yes"
> +     }
>  }
>
> +# This procedure is called back from the dpbrowser pane when a  
> picture is selected
> +proc updateDpBrowserSelection { browser } {
> +     global selected_image
> +     set w [winfo toplevel $browser]
> +     # Get the path of the selected image and unselect all images in  
> the other pane
> +     if { [list $w.mydps] == $browser } {
> +             set selected_path [$w.mydps getselection]
> +             $w.moredps unselect_all
> +     } else {
> +             set selected_path [$w.moredps getselection]
> +             $w.mydps unselect_all
> +     }
> +     set image_name [image create photo [TmpImgName] -file  
> $selected_path -format cximage]
> +     $w.dppreview configure -image $image_name
> +     set selected_image "[filenoext $selected_path].png"
> +}
>
> +# TODO: no more used, delete if not needed
>  proc pictureBrowser {} {
>       global selected_image
>
> @@ -7226,7 +7296,7 @@
>       label .picbrowser.mypic -image displaypicture_std_self - 
> background white -borderwidth 2 -relief solid
>       label .picbrowser.mypic_label -text "[trans mypic]" -font splainf
>
> -     button .picbrowser.browse -command "set selected_image \ 
> [pictureChooseFile\]; reloadAvailablePics" -text "[trans browse]..."
> +     button .picbrowser.browse -command "set selected_image \ 
> [old_pictureChooseFile\]; reloadAvailablePics" -text "[trans  
> browse]..."
>       button .picbrowser.delete -command  
> "pictureDeleteFile ;reloadAvailablePics" -text "[trans delete]"
>       button .picbrowser.purge -command "purgePictures;  
> reloadAvailablePics" -text "[trans purge]..."
>       button .picbrowser.ok -command "set_displaypic \$ 
> {selected_image};destroy .picbrowser" -text "[trans ok]"
> @@ -7282,6 +7352,7 @@
>       moveinscreen .picbrowser 30
>  }
>
> +# TODO: no more used, delete if not needed
>  proc purgePictures {} {
>       global HOME
>
> @@ -7293,6 +7364,7 @@
>       }
>  }
>
> +# TODO: no more used, delete if not needed
>  proc deleteDisplayPicsInDir { folder } {
>               foreach filename [glob -nocomplain -directory $folder *.png] {
>                       catch { file delete $filename }
> @@ -7305,6 +7377,7 @@
>               }
>  }
>
> +# TODO: no more used, delete if not needed
>  proc getPictureDesc {filename} {
>       if { [file readable "[filenoext $filename].dat"] } {
>               set f [open "[filenoext $filename].dat"]
> @@ -7323,6 +7396,7 @@
>       return ""
>  }
>
> +# TODO: no more used, delete if not needed
>  proc addPicture {the_image pic_text filename} {
>       frame .picbrowser.pics.text.$the_image -borderwidth 0 - 
> highlightthickness 0 -background white -highlightbackground black
>       label .picbrowser.pics.text.$the_image.pic -image $the_image - 
> relief flat -borderwidth 0 -highlightthickness 2 \
> @@ -7338,6 +7412,7 @@
>       .picbrowser.pics.text insert end "\n"
>  }
>
> +# TODO: no more used, delete if not needed
>  proc reloadAvailablePics { } {
>       global HOME image_names show_cached_pics skin
>
> @@ -7498,7 +7573,7 @@
>       return $selfile
>  }
>
> -
> +# TODO: no more used, delete if not needed
>  proc pictureDeleteFile { {filename ""} {widget .picbrowser.mypic} } {
>       global selected_image HOME
>
> @@ -7545,13 +7620,13 @@
>               }
>
>               if { ![catch {convert_image_plus $file displaypic $convertsize} 
>  
> res]} {
> -                     if {![winfo exists .picbrowser]} {
> -                             pictureBrowser
> +                     if {![winfo exists .dpbrowser]} {
> +                             dpBrowser
>                       }
>
>                       set image_name [image create photo [TmpImgName] -file  
> [::skin::GetSkinFile "displaypic" "[filenoext [file tail  
> $file]].png"] -format cximage]
>                       status_log $image_name red
> -                     .picbrowser.mypic configure -image $image_name
> +                     .dpbrowser.dppreview configure -image $image_name
>                       set selected_image "[filenoext [file tail $file]].png"
>
>                       set desc_file "[filenoext [file tail $file]].dat"
> @@ -7616,22 +7691,29 @@
>       return $dpsize
>  }
>
> -proc set_displaypic { file } {
> -     catch {image delete displaypicture_std_self}
> -     catch {image delete displaypicture_not_self}
> -     if { $file != "" } {
> -             ::config::setKey displaypic $file
> -             status_log "set_displaypic: File set to $file\n" blue
> -             load_my_pic
> -             load_my_smaller_pic
> -             ::MSN::changeStatus [set ::MSN::myStatus]
> -             save_config
> +proc set_displaypic { file { email "self" } } {
> +     if { $email == "self" } {
> +             catch {image delete displaypicture_std_self}
> +             catch {image delete displaypicture_not_self}
> +             if { $file != "" } {
> +                     ::config::setKey displaypic $file
> +                     status_log "set_displaypic: File set to $file\n" blue
> +                     load_my_pic
> +                     load_my_smaller_pic
> +                     ::MSN::changeStatus [set ::MSN::myStatus]
> +                     save_config
> +             } else {
> +                     status_log "set_displaypic: Setting displaypic to  
> displaypicture_std_none\n" blue
> +                     clear_disp
> +                     load_my_pic 1
> +                     load_my_smaller_pic
> +                     ::MSN::changeStatus [set ::MSN::myStatus]
> +             }
>       } else {
> -             status_log "set_displaypic: Setting displaypic to  
> displaypicture_std_none\n" blue
> -             clear_disp
> -             load_my_pic 1
> -             load_my_smaller_pic
> -             ::MSN::changeStatus [set ::MSN::myStatus]
> +             set temp [filenoext $file]
> +             status_log "$temp"
> +             global customdp_$email
> +             set customdp_$email $file
>       }
>  }
>
> @@ -7650,6 +7732,31 @@
>               bind $pgBuddyTop.bigstate <<Button3>> {tk_popup .my_menu %X %Y}
>       }
>  }
> +
> +# Through these function the custom DP can be changed without  
> using the properties screen
> +proc autoChangeCustomDp { email } {
> +     global customdp_$email
> +     dpBrowser $email
> +     tkwait window .dpbrowser
> +     # Backup old custom dp
> +     set old_customdp [::abook::getContactData $email customdp ""]
> +     if {[set customdp_$email] != $old_customdp} {
> +             # Store custom dp
> +             ::abook::setAtomicContactData $email customdp [set 
> customdp_$email]
> +             # Update display picture
> +             ::skin::getDisplayPicture $email 1
> +             ::skin::getLittleDisplayPicture $email 1
> +     }
> +}
> +
> +proc autoRemoveCustomDp { email } {
> +     # Remove custom dp
> +     ::abook::setAtomicContactData $email customdp ""
> +     # Update display picture
> +     ::skin::getDisplayPicture $email 1
> +     ::skin::getLittleDisplayPicture $email 1
> +}
> +
>  ###################### Protocol Debugging ###########################
>  if { $initialize_amsn == 1 } {
>       global degt_protocol_window_visible degt_command_window_visible
> Index: skins.tcl
> ===================================================================
> --- skins.tcl (revisione 7718)
> +++ skins.tcl (copia locale)
> @@ -238,8 +238,16 @@
>                       return $picName
>               }
>
> -             set filename [::abook::getContactData $email displaypicfile ""]
> -             set file "[file join $HOME displaypic cache ${filename}].png"
> +             if { [::abook::getContactData $email customdp] != "" } {
> +                     set filename [::abook::getContactData $email customdp 
> ""]
> +                     # As custom DP can also be stored outside the cache 
> folder,
> +                     # customdp stores the full path to the image
> +                     set file $filename
> +             } else {
> +                     set filename [::abook::getContactData $email 
> displaypicfile ""]
> +                     set file "[file join $HOME displaypic cache 
> ${filename}].png"
> +             }
> +             
>               if { $filename != "" && [file readable "$file"] } {
>                       catch {image create photo $picName -file "$file" 
> -format cximage}
>               } else {
> @@ -282,9 +290,16 @@
>                       return $picName
>               }
>
> -             set filename [::abook::getContactData $email displaypicfile ""]
> -             set file "[file join $HOME displaypic cache ${filename}].png"
> -
> +             if { [::abook::getContactData $email customdp] != "" } {
> +                     set filename [::abook::getContactData $email customdp 
> ""]
> +                     # As custom DP can also be stored outside the cache 
> folder,
> +                     # customdp stores the full path to the image
> +                     set file $filename
> +             } else {
> +                     set filename [::abook::getContactData $email 
> displaypicfile ""]
> +                     set file "[file join $HOME displaypic cache 
> ${filename}].png"
> +             }
> +             
>               if { $filename != "" && [file readable $file] } {
>                       catch {image create photo $picName -file "$file" 
> -format cximage}
>               } else {
> Index: utils/dpbrowser/dpbrowser.tcl
> ===================================================================
> --- utils/dpbrowser/dpbrowser.tcl     (revisione 7718)
> +++ utils/dpbrowser/dpbrowser.tcl     (copia locale)
> @@ -7,8 +7,15 @@
>       option -width -default 5
>  #    option -height -default 500
>       option -bg -default white -configuremethod SetConfig
> +     option -bg_hl -default DarkBlue -configuremethod SetConfig
>       option -mode -default "properties"
>       #modes "properties" where you right-click with actions and mode  
> "select" where left click sets as your image preview for new pic  
> browser"
> +     
> +     # When using select mode, it's important to pass the name of a  
> procedure through this option.
> +     # Otherwise, the parent window will not react to the change of  
> selection.
> +     option -post_select -default ""
> +     option -picinuse -default "no" -configuremethod SetConfig
> +     option -disableselect -default "no"
>
>  #    option -addinuse -default 0 -configuremethod SetConfig
>
> @@ -55,7 +62,7 @@
>
>               if {$email == "self"} {
>                       set cachefiles [glob -nocomplain -directory [file join 
> $HOME  
> displaypic] *.dat]
> -                     set pic_in_use [::abook::getContactData $email 
> displaypicfile ""]
> +                     set pic_in_use ""
>               } else {
>                       set cachefiles [glob -nocomplain -directory [file join 
> $HOME  
> displaypic cache] *.dat]      
>                       set pic_in_use [::abook::getContactData $email 
> displaypicfile ""]
> @@ -75,7 +82,7 @@
>               
>                       foreach file $cachefiles {
>                               #exclude the image the user is currently using
> -                             if { [string first $pic_in_use $file] == -1 } {
> +                             if { $options(-picinuse) != "no" || [string 
> first $pic_in_use  
> $file] == -1 } {
>                               set fd [open $file]
>
>
> @@ -91,25 +98,19 @@
>                                       if { [catch { image create photo 
> userDP_${email}_$i -file  
> [filenoext $file].png -format cximage }] } { continue }
>                                       ::picture::ResizeWithRatio 
> userDP_${email}_$i 96 96
>                                       set entry $frame.${i}_shell
> -                                     frame $entry -bg $color -bd 0 -relief 
> flat
> +                                     frame $entry -bg $color -bd 2 -relief 
> flat
>
>                                       label $entry.img -image 
> userDP_${email}_$i -bg $color
>                                       bind $entry <Destroy> "catch { image 
> delete userDP_${email}_$i}"
> -                                     if {$email == "self"} {
> -                                             bind $entry.img <ButtonPress-3> 
> \
> -                                                     [list $self 
> dp_popup_menu %X %Y\
> -                                                     [filenoext $file].png 
> $entry.img $email]
> -                                             #selection binding
> -                                             bind $entry.img <ButtonPress-1> 
> [list $self selectdp  
> [filenoext $file].png $entry.img]
> -                                     } else {
> -                                             bind $entry.img <ButtonPress-3> 
> \
> -                                                     [list $self 
> dp_popup_menu %X %Y\
> -                                                     [filenoext $file].png 
> $entry.img $email]
> -                                     }
> +                                     bind $entry.img <ButtonPress-3> \
> +                                             [list $self dp_popup_menu %X %Y\
> +                                             [filenoext $file].png 
> $entry.img $email]
> +                                     #selection binding
> +                                     bind $entry.img <ButtonPress-1> [list 
> $self selectdp  
> [filenoext $file].png $entry.img]
>
>       #TODO: a tooltip with the full size image
> -                                     bind $entry.img <Enter> ""
> -                                     bind $entry.img <Leave> ""
> +#                                    bind $entry.img <Enter> "showtooltip %X 
> %Y [filenoext  
> $file].png"
> +#                                    bind $entry.img <Leave> "showtooltip %X 
> %Y [filenoext  
> $file].png"
>
>                                       label $entry.text -text [lindex $greps 
> 1] -bg $color
>
> @@ -181,7 +182,7 @@
>                       -label "[trans copytoclipboard [string tolower [trans  
> filename]]]" \
>                       -command [list clipboard clear ; clipboard append 
> $filename]
>               $the_menu add command -label "[trans delete]" \
> -                     -command [list pictureDeleteFile $filename $widget]
> +                     -command [list $self deleteentry $filename $widget]
>  #            $the_menu add command -label "Set as custom display picture for 
>  
> this user" \
>                       -command [list ::amsn::messageBox "Sorry, not yet 
> implemented"  
> ok error [trans failed]]
>               $the_menu add command -label "[trans setasmydp]" \
> @@ -190,14 +191,46 @@
>       }
>
>       method selectdp { file imgwidget } {
> -             global selected_path
> -             if { [catch { image create photo my_pic -file $file -format  
> cximage }] } { return }
> -             set selected_path $file
> -             #select the image in the widget ?
> +             if {$options(-disableselect) == "no" } {
> +                     global selected_path
> +                     if { [catch { image create photo my_pic -file $file 
> -format  
> cximage }] } { return }
> +                     set selected_path $file
> +                     # Highlight only the selected image
> +                     for {set i 0} {[winfo exists [$self.sw.sf 
> getframe].${i} 
> _shell]} {incr i} {
> +                             set entry [$self.sw.sf getframe].${i}_shell
> +                             set entry_img $entry.img
> +                             if { $entry_img != $imgwidget } {               
>                 
> +                                     $entry configure -background 
> $options(-bg)
> +                             } else {
> +                                     $entry configure -background 
> $options(-bg_hl)
> +                             }
> +                     }
> +                     # Execute the post-select procedure, sending the 
> browser window  
> as parameter
> +                     if { $options(-post_select) != "" } {
> +                             eval $options(-post_select) $self
> +                     }
> +             }
>       }
> +
> +     method unselect_all { } {
> +             for {set i 0} {[winfo exists [$self.sw.sf 
> getframe].${i}_shell]}  
> {incr i} {
> +                     set entry [$self.sw.sf getframe].${i}_shell
> +                     $entry configure -background $options(-bg)
> +             }
> +
> +     }
>       
>       method getselection {} {
>               global selected_path
>               return $selected_path
>       }
> +
> +     method deleteentry {filename widget} {
> +             global selected_path
> +             if {$selected_path == $filename} {
> +                     set selected_path ""
> +             }
> +             pictureDeleteFile $filename $widget
> +             $self fill
> +     }
>  }
> Index: abook.tcl
> ===================================================================
> --- abook.tcl (revisione 7718)
> +++ abook.tcl (copia locale)
> @@ -41,7 +41,7 @@
>
>               # This list stores the names of the fields about the visual  
> representation of the buddy.
>               # When this fields gets changed, we fire an event to redraw 
> that  
> contact on our CL.
> -             variable VisualData [list nick customnick customfnick  
> cust_p4c_name customcolor]
> +             variable VisualData [list nick customnick customfnick  
> cust_p4c_name customcolor customdp]
>
>               global pgc pcc
>       }
> @@ -1077,7 +1077,7 @@
>               set nbIdent [$nb getframe userDPs]
>               
>               if { ![winfo exists $nbIdent.otherpics]} {
> -                     ::dpbrowser $nbIdent.otherpics -user $email
> +                     ::dpbrowser $nbIdent.otherpics -user $email 
> -disableselect
>                       pack $nbIdent.otherpics -expand true -fill both
>               }
>       }
> @@ -1101,7 +1101,7 @@
>
>
>       proc showUserProperties { email } {
> -             global colorval_$email showcustomsmileys_$email ignorecontact_ 
> $email HOME
> +             global colorval_$email customdp_$email showcustomsmileys_$email 
>  
> ignorecontact_$email HOME
>               set w ".user_[::md5::md5 $email]_prop"
>               if { [winfo exists $w] } {
>                       raise $w
> @@ -1334,6 +1334,19 @@
>               pack $nbSettings.fNick.fColor.bset -side left -padx 3 -pady 2
>               pack $nbSettings.fNick.fColor.brem -side left -padx 3 -pady 2
>               
> +             # The custom display pic frame
> +             label $nbSettings.fNick.lDispl -text "[trans customdp]:"
> +             frame $nbSettings.fNick.fDispl -relief flat
> +             set customdp_$email [::abook::getContactData $email customdp]
> +             set customdp_img_$email [image create photo [TmpImgName] -file  
> [set customdp_$email]]
> +
> +             label $nbSettings.fNick.fDispl.dp -image [set customdp_img_$ 
> {email}] -borderwidth 0 -relief flat
> +             button $nbSettings.fNick.fDispl.bset -text "[trans change]" - 
> command "::abookGui::ChangeCustomDp $email $nbSettings"
> +             button $nbSettings.fNick.fDispl.brem -text "[trans delete]" - 
> command "::abookGui::RemoveCustomDp $email $nbSettings"
> +             pack $nbSettings.fNick.fDispl.dp -side left -expand true -fill 
> y  
> -pady 5 -padx 8
> +             pack $nbSettings.fNick.fDispl.bset -side left -padx 3 -pady 2
> +             pack $nbSettings.fNick.fDispl.brem -side left -padx 3 -pady 2
> +             
>               grid $nbSettings.fNick.customnickl -row 0 -column 0 -sticky e
>               grid $nbSettings.fNick.customnick -row 0 -column 1 -sticky we
>               grid $nbSettings.fNick.customfnickl -row 1 -column 0 -sticky e
> @@ -1342,6 +1355,8 @@
>               grid $nbSettings.fNick.ycustomfnick -row 2 -column 1 -sticky we
>               grid $nbSettings.fNick.lColor -row 3 -column 0 -sticky e
>               grid $nbSettings.fNick.fColor -row 3 -column 1 -sticky w
> +             grid $nbSettings.fNick.lDispl -row 4 -column 0 -sticky e
> +             grid $nbSettings.fNick.fDispl -row 4 -column 1 -sticky w
>               grid columnconfigure $nbSettings.fNick 1 -weight 1
>               
>               labelframe $nbSettings.fChat -relief groove -text [trans chat]
> @@ -1556,6 +1571,23 @@
>               $w.fNick.fColor.col configure -background [$w.fNick.fColor cget 
> - 
> background] -highlightthickness 0
>       }
>
> +     # These procedures change the custom DP. They need to be launched  
> from within the properties screen,
> +     # as the actual change is done through the PropOk procedure
> +     proc ChangeCustomDp { email w } {
> +             global customdp_$email
> +             dpBrowser $email
> +             tkwait window .dpbrowser
> +             set customdp_img_$email [image create photo [TmpImgName] -file  
> [set customdp_$email]]
> +             $w.fNick.fDispl.dp configure -image [set customdp_img_$email] - 
> borderwidth 0 -relief flat
> +             
> +     }
> +     
> +     proc RemoveCustomDp { email w } {       
> +             global customdp_$email
> +             set customdp_$email ""
> +             $w.fNick.fDispl.dp configure -image [set customdp_$email] - 
> borderwidth 0 -relief flat
> +     }
> +
>       proc SetGlobalNick { } {
>               
>               if {[winfo exists .globalnick]} {
> @@ -1604,7 +1636,7 @@
>       }
>
>       proc PropOk { email w } {
> -             global colorval_$email showcustomsmileys_$email ignorecontact_ 
> $email
> +             global colorval_$email customdp_$email showcustomsmileys_$email 
>  
> ignorecontact_$email
>               
>               if {[::alarms::SaveAlarm $email] != 0 } {
>                       return
> @@ -1612,11 +1644,20 @@
>       
>               set nbSettings [$w.nb getframe usersettings]
>               set nbSettings [$nbSettings.sw.sf getframe]
> +             
> +             # Backup old custom dp
> +             set old_customdp [::abook::getContactData $email customdp ""]
>
>               # Store custom display information options
> -             ::abook::setAtomicContactData $email [list customnick  
> customfnick cust_p4c_name customcolor showcustomsmileys ignored] \
> -                     [list [$nbSettings.fNick.customnick.ent get]  
> [$nbSettings.fNick.customfnick.ent get]  
> [$nbSettings.fNick.ycustomfnick.ent get] [set colorval_$email] [set  
> showcustomsmileys_$email] [set ignorecontact_$email]]
> -
> +             ::abook::setAtomicContactData $email [list customnick  
> customfnick cust_p4c_name customcolor customdp showcustomsmileys  
> ignored] \
> +                     [list [$nbSettings.fNick.customnick.ent get]  
> [$nbSettings.fNick.customfnick.ent get]  
> [$nbSettings.fNick.ycustomfnick.ent get] [set colorval_$email] [set  
> customdp_$email] [set showcustomsmileys_$email] [set ignorecontact_ 
> $email]]
> +             
> +             # Update display picture
> +             if {[set customdp_$email] != $old_customdp} {
> +                     ::skin::getDisplayPicture $email 1
> +                     ::skin::getLittleDisplayPicture $email 1
> +             }
> +             
>               # Store groups
>               ::groups::GroupmanagerOk $email
>               
> ---------------------------------------------------------------------- 
> ---
> Take Surveys. Earn Cash. Influence the Future of IT
> Join SourceForge.net's Techsay panel and you'll get the chance to  
> share your
> opinions on IT & business topics through brief surveys - and earn cash
> http://www.techsay.com/default.php? 
> page=join.php&p=sourceforge&CID=DEVDEV________________________________ 
> _______________
> Amsn-devel mailing list
> Amsn-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/amsn-devel


-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Amsn-devel mailing list
Amsn-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/amsn-devel

Reply via email to