Re: [gtk-list] Re: gtk_entry and passwords...





On Fri, 3 Oct 1997, Otto Hammersmith wrote:

> Better that, than some shoulder surfer knowing how long your password
> is, so as soon as he can take a gander at /etc/passwd, he can start
> running crack on it only using items in the dictionary of length 'n'. 
> 
> By far the ideal would to let gtk_entry_get_text() work, but still
> have things invisible by using peter's suggestion.  I actually think
> the cleanest (and safest) solution is a new widget, but I just don't
> have the time for that.

A password field is also something required by gzilla, so I looked into 
this a month or so ago.

It seemed to me that the best way to accomplish a password entry is to 
make a new widget which is a subclass of gtk_entry. You'd redo 
gtk_entry_draw_text so that it draws "****" instead of the actual text. 
Other routines would need to get redone as well, including 
gtk_entry_draw_cursor, gtk_entry_adjust_scroll, and gtk_entry_position. 
Then, you'd need to duplicate all of the routines that call these, up to 
the point where its a method you can just override. A quick check through 
the source reveals gtk_entry_button_press, gtk_entry_motion_notify, 
gtk_entry_set_text, gtk_entry_draw, gtk_entry_expose, 
gtk_entry_queue_draw, gtk_entry_button_release, gtk_entry_key_press, 
gtk_entry_selection_clear, gtk_entry_selection_received, and 
gtk_entry_size_allocate.

It would certainly be possible to reoganize the code so that the three 
routines that really need changes become methods rather than static 
functions. This would certainly reduce code duplication, and is probably 
the way I'd go. But it is possible to subclass the thing without making 
any changes to GTK+ itself.

Good luck!

Raph



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