Editable GtkCellRendererText and focus
- From: Tim Evans <t evans aranz com>
- To: gtk-devel-list gnome org
- Subject: Editable GtkCellRendererText and focus
- Date: Mon, 11 Jun 2007 17:27:05 +1200
In our application, I have run into a problem with the behaviour of
GtkCellRendererText when an cell being edited loses focus. The problem
appears to be caused by the fix to Bug #164494:
bug: http://bugzilla.gnome.org/show_bug.cgi?id=164494
patch:
http://svn.gnome.org/viewcvs/gtk%2B/trunk/gtk/gtkcellrenderertext.c?r1=16769&r2=16809
I've attached a small PyGTK script that illustrates the problem. Our
users are presented with a GtkTreeView containing a list of strings to
edit. Having changed the values to their satisfaction, they click "OK".
The problem is that the last change they make is not applied: no
'edited' signal is emitted on the GtkCellRendererText, so my code does
not modify the underlying model.
Clicking the "OK" button (or using the Alt+O mnemonic) removes focus
from the GtkEntry that is editing the cell and places it on the OK
button, standard behaviour for buttons. The problem is that when the
focus is removed from the GtkEntry editing is cancelled rather than
confirmed. If the user press enter (even tab or the up or down arrow)
then the change is correctly applied. But they feel no need to press
enter, the value looks correct and they don't see the significance of it
being a GtkEntry in an editable cell rather than a normal tree-view
display. The text is as they want it and by pressing "OK" they mean to
confirm their changes.
I can't help but feel that this is a bug in GTK, and that the patch
linked above is incorrect at least in my case. Does anyone else feel
the same, or am I doing something wrong on my end?
--
Tim Evans
Applied Research Associates NZ
http://www.aranz.co.nz/
import gtk, gobject
ls = gtk.ListStore(gobject.TYPE_STRING)
ls.append(("test1",))
ls.append(("test2",))
ls.append(("test3",))
def edited(r, path, new_text, ls):
ls[path][0] = new_text
crt = gtk.CellRendererText()
crt.props.editable = True
crt.connect("edited", edited, ls)
tv = gtk.TreeView(ls)
tv.props.headers_visible = False
tv.insert_column_with_attributes(0, '', crt, text=0)
sw = gtk.ScrolledWindow()
sw.add(tv)
sw.props.shadow_type = 'in'
sw.props.hscrollbar_policy = 'never'
sw.props.vscrollbar_policy = 'automatic'
sw.show_all()
d = gtk.Dialog(title='Edit Strings', buttons=(gtk.STOCK_OK, gtk.RESPONSE_ACCEPT))
d.props.has_separator = False
d.vbox.props.border_width = 12
d.vbox.pack_start(sw)
d.run()
for row in ls:
print row[0]
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]