Re: [PATCH 1/2] Guess user name from full name (#517269)

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



I forgot to put the subject prefix, this patch is for firstboot, and the other one too

--

  Martin Gracik

----- "Martin Gracik" <mgracik@xxxxxxxxxx> wrote:

> ---
>  modules/create_user.py |   42
> ++++++++++++++++++++++++++++++++++--------
>  1 files changed, 34 insertions(+), 8 deletions(-)
> 
> diff --git a/modules/create_user.py b/modules/create_user.py
> index ba37b2b..ee77072 100644
> --- a/modules/create_user.py
> +++ b/modules/create_user.py
> @@ -221,8 +221,13 @@ class moduleClass(Module):
>          label.set_alignment(0.0, 0.5)
>          label.set_size_request(500, -1)
>  
> -        self.usernameEntry = gtk.Entry()
>          self.fullnameEntry = gtk.Entry()
> +        self.usernameEntry = gtk.Entry()
> +
> +        self.guessUserName = True
> +        self.fullnameEntry.connect("changed",
> self.fullnameEntry_changed)
> +        self.usernameEntry.connect("changed",
> self.usernameEntry_changed)
> +
>          self.passwordEntry = gtk.Entry()
>          self.passwordEntry.set_visibility(False)
>          self.passwordEntry.set_property("primary-icon-stock",
> @@ -240,19 +245,20 @@ class moduleClass(Module):
>          table = gtk.Table(2, 4)
>          table.set_row_spacings(6)
>          table.set_col_spacings(6)
> -        label = gtk.Label(_("_Username:"))
> +
> +        label = gtk.Label(_("Full Nam_e:"))
>          label.set_use_underline(True)
> -        label.set_mnemonic_widget(self.usernameEntry)
> +        label.set_mnemonic_widget(self.fullnameEntry)
>          label.set_alignment(0.0, 0.5)
>          table.attach(label, 0, 1, 0, 1, gtk.FILL)
> -        table.attach(self.usernameEntry, 1, 2, 0, 1, gtk.SHRINK,
> gtk.FILL, 5)
> +        table.attach(self.fullnameEntry, 1, 2, 0, 1, gtk.SHRINK,
> gtk.FILL, 5)
>  
> -        label = gtk.Label(_("Full Nam_e:"))
> +        label = gtk.Label(_("_Username:"))
>          label.set_use_underline(True)
> -        label.set_mnemonic_widget(self.fullnameEntry)
> +        label.set_mnemonic_widget(self.usernameEntry)
>          label.set_alignment(0.0, 0.5)
>          table.attach(label, 0, 1, 1, 2, gtk.FILL)
> -        table.attach(self.fullnameEntry, 1, 2, 1, 2, gtk.SHRINK,
> gtk.FILL, 5)
> +        table.attach(self.usernameEntry, 1, 2, 1, 2, gtk.SHRINK,
> gtk.FILL, 5)
>  
>          label = gtk.Label(_("_Password:"))
>          label.set_use_underline(True)
> @@ -306,7 +312,7 @@ class moduleClass(Module):
>          self.vbox.pack_start(scuHBox, False, False)
>  
>      def focus(self):
> -        self.usernameEntry.grab_focus()
> +        self.fullnameEntry.grab_focus()
>  
>      def initializeUI(self):
>          pass
> @@ -357,6 +363,26 @@ class moduleClass(Module):
>          dlg.destroy()
>          return None
>  
> +    def fullnameEntry_changed(self, fn_entry):
> +        if not self.guessUserName:
> +            return
> +
> +        name = fn_entry.get_text()
> +        try:
> +            user = name.split()[0]
> +        except IndexError:
> +            user = ""
> +        else:
> +            user = user.encode("ascii", "ascii_transliterate")
> +            user = user.lower()
> +
> +       
> self.usernameEntry.handler_block_by_func(self.usernameEntry_changed)
> +        self.usernameEntry.set_text(user)
> +       
> self.usernameEntry.handler_unblock_by_func(self.usernameEntry_changed)
> +
> +    def usernameEntry_changed(self, un_entry):
> +        self.guessUserName = not bool(un_entry.get_text())
> +
>      def passwordEntry_changed(self, entry):
>          pw = entry.get_text()
>          if not pw:
> -- 
> 1.7.1.1
> 
> _______________________________________________
> Anaconda-devel-list mailing list
> Anaconda-devel-list@xxxxxxxxxx
> https://www.redhat.com/mailman/listinfo/anaconda-devel-list

_______________________________________________
Anaconda-devel-list mailing list
Anaconda-devel-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/anaconda-devel-list


[Index of Archives]     [Kickstart]     [Fedora Users]     [Fedora Legacy List]     [Fedora Maintainers]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [Yosemite Photos]     [KDE Users]     [Fedora Tools]
  Powered by Linux