aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xuserdrake43
-rw-r--r--userdrake.spec5
2 files changed, 32 insertions, 16 deletions
diff --git a/userdrake b/userdrake
index 67c62cd..a0acdfd 100755
--- a/userdrake
+++ b/userdrake
@@ -37,6 +37,7 @@ use USER;
use Gtk2::Gdk::Keysyms;
use utf8;
use log;
+use Digest::MD5;
my $conffile = '/etc/sysconfig/userdrake';
my $secfile = '/etc/sysconfig/msec';
@@ -230,37 +231,49 @@ sub Refresh {
RefreshGroupsFull($filt, $strfilt);
GrayDelEdit()
}
-sub GetFaceIcon {
+sub GetFileMd5 {
+ my @md5;
+ foreach my $file (@_) {
+ open(FILE, $file) or do { print STDERR "Can't open '$file': $!"; push @md5, "" };
+ binmode(FILE);
+ push @md5, Digest::MD5->new->addfile(*FILE)->hexdigest;
+ close(FILE);
+ }
+ return wantarray() ? @md5 : $md5[0];
+}
+sub GetFaceIcon {
my ($user) = @_;
- my $i = 0;
my @icones = any::facesnames();
+ my $i;
+ my $current_icon;
my $user_icon = "$::prefix/usr/share/faces/$user.png";
gtkpack_(my $hb = Gtk2::HBox->new(0, 2),
0, Gtk2::Label->new(N("Click on the icon to change it") . ' '),
- 0, my $bt = Gtk2::Button->new
+ 0, my $bt = Gtk2::Button->new
);
my $set = sub {
my ($icon) = @_;
gtkdestroy($us->{o}{icon});
my $f = $icon =~ m,^/, ? $icon : any::face2png($icon);
- if (-e $f) {
- $us->{o}{icon} = gtkpack__(Gtk2::HBox->new(0,0),
- gtkcreate_img($f),
- $f eq $user_icon ? Gtk2::Label->new(" $user ") : ()
- );
- } else {
- $us->{o}{icon} = Gtk2::Label->new("No Icon");
- }
+ $us->{o}{icon} = -e $f ? gtkcreate_img($f) : Gtk2::Label->new("No Icon");
$bt->add($us->{o}{icon});
$us->{o}{icon}->show;
};
if (-e $user_icon) {
- push @icones, $user_icon;
- $i = @icones - 1;
+ my $current_md5 = GetFileMd5($user_icon);
+ eval { $i = find_index { GetFileMd5(any::face2png($_)) =~ /$current_md5/ } @icones };
+ if (!$@) { #- current icon found in @icones, select it
+ $current_icon = any::face2png($icones[$i]);
+ } else { #- add and select current icon in @icones
+ push @icones, $user_icon;
+ $current_icon = $user_icon;
+ $i = @icones - 1;
+ }
} else {
- $i = rand(@icones);
+ #- no icon yet, select a random one
+ $current_icon = any::face2png($icones[$i = rand(@icones)]);
}
- $set->($us->{o}{iconval} = $icones[$i]);
+ $set->($us->{o}{iconval} = $current_icon);
my $leave = 0;
$bt->signal_connect(enter => sub { $leave = 0; });
$bt->signal_connect(leave => sub { $leave = 1; });
diff --git a/userdrake.spec b/userdrake.spec
index b7f4789..c6c83bb 100644
--- a/userdrake.spec
+++ b/userdrake.spec
@@ -7,7 +7,7 @@
Summary: A graphical interface for administering users and groups
Name: %{name}
Version: %{version}
-Release: 1mdk
+Release: 2mdk
#cvs source
# http://www.linuxmandrake.com/en/cvs.php3
Source0: %{name}-%{version}.tar.bz2
@@ -78,6 +78,9 @@ rm -rf %{buildroot}
%{_liconsdir}/*.png
%changelog
+* Mon May 10 2004 Daouda LO <daouda@mandrakesoft.com> 1.0-2mdk
+- use md5sum to find cuurent face icon (Oliver Blin) - #9653
+
* Mon May 10 2004 Daouda LO <daouda@mandrakesoft.com> 1.0-1mdk
- bumped to 1.0 (stable enough)
- random icon display and icon browsing fixes #8085 - #9653 (Olivier