After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 310693 - Editable labels
Editable labels
Status: RESOLVED OBSOLETE
Product: gtk+
Classification: Platform
Component: Widget: GtkLabel
unspecified
Other All
: Normal enhancement
: 3.0
Assigned To: gtk-bugs
gtk-bugs
Depends on:
Blocks:
 
 
Reported: 2005-07-18 01:58 UTC by Johan (not receiving bugmail) Dahlin
Modified: 2018-05-02 14:11 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
v1: Initial patch based on EelEditableLabel (45.62 KB, patch)
2005-07-18 02:00 UTC, Johan (not receiving bugmail) Dahlin
none Details | Review
Updated patch to apply against HEAD with blinking cursor (47.94 KB, patch)
2006-11-24 01:49 UTC, James Bowes
none Details | Review
Fix text_deletion seg fault (48.06 KB, patch)
2006-11-28 01:01 UTC, James Bowes
rejected Details | Review
implement GtkEditableLabel as subclass of GtkLabel (63.56 KB, patch)
2008-09-08 22:52 UTC, Cosimo Cecchi
none Details | Review
another approach (57.85 KB, patch)
2010-07-29 08:58 UTC, Cosimo Cecchi
none Details | Review

Description Johan (not receiving bugmail) Dahlin 2005-07-18 01:58:11 UTC
Editable labels are useful, nautilus uses for renaming of items. Another usecase
is a ui designer, being able to change the name of a label.

Alexander Larsson wrote an editable label which is included in eel:
http://cvs.gnome.org/viewcvs/eel/eel/eel-editable-label.c?view=markup
Comment 1 Johan (not receiving bugmail) Dahlin 2005-07-18 02:00:08 UTC
Created attachment 49337 [details] [review]
v1: Initial patch based on EelEditableLabel

TODO: popup, blinking cursor, investigate ::selectable/::editable relation.
Comment 2 James Bowes 2006-11-24 01:49:19 UTC
Created attachment 77086 [details] [review]
Updated patch to apply against HEAD with blinking cursor

I updated the patch to apply cleanly to HEAD (gtk+ 2.11), and added cursor blinking, based on the implementation in gtkentry.c
Comment 3 James Bowes 2006-11-28 01:01:29 UTC
Created attachment 77259 [details] [review]
Fix text_deletion seg fault

The previous patch would cause applications to crash if set_text was used. This patch fixes the error.
Comment 4 Andrew Krause 2007-04-07 17:48:55 UTC
I'm interested in using this in an application. Is there any way this is going to get into GTK+ 2.12?
Comment 5 Emmanuele Bassi (:ebassi) 2007-04-07 18:08:53 UTC
just a first rough look at the patch: it breaks the ABI so you'll need to remove as much padding pointers as needed by the new signals. unfortunately, GtkLabel has just 4 padding slots and the patch adds 5 new signals.
Comment 6 Emmanuele Bassi (:ebassi) 2007-04-07 18:10:11 UTC
instead of adding editability to the label widget, can't we create a GtkEditableLabel subclass which implements the GtkEditable interface? this would avoid breaking the ABI.
Comment 7 Andrew Krause 2007-05-15 20:50:10 UTC
I agree. That would leave the 4 padding signal slots, and wouldn't require the GtkLabel widget to carry around any extra baggage. Given that the summer has just started, I'm going to implement a GtkEditableLabel. Is anyone else already doing this, or think it should be another way, or something of the sort? I don't want to reinvent the wheel.
Comment 8 Johan (not receiving bugmail) Dahlin 2008-01-30 12:17:13 UTC
Formally rejecting the patch. ABI needs to be preserved.
Comment 9 Cosimo Cecchi 2008-09-07 22:34:09 UTC
I am working on a patch which does what Emmanuele proposed in comment 6.
Comment 10 Cosimo Cecchi 2008-09-08 22:52:00 UTC
Created attachment 118336 [details] [review]
implement GtkEditableLabel as subclass of GtkLabel

Implementation of GtkEditableLabel as a subclass of GtkLabel. Works fine in my testing, comments more than welcome!
Comment 11 Johan (not receiving bugmail) Dahlin 2008-09-09 11:11:45 UTC
(In reply to comment #10)
> Created an attachment (id=118336) [edit]
> implement GtkEditableLabel as subclass of GtkLabel
> 
> Implementation of GtkEditableLabel as a subclass of GtkLabel. Works fine in my
> testing, comments more than welcome!
> 

A very quick look at it, and it looks quite acceptable.
However, I'm a bit worried about the size of changes in GtkLabel itself. Renaming and & making a bit of the private api accessible from GtkEditableLabel is fine.
I'm more worried about the other changes. Can they be removed/refactored to reduce the likelihood of regressions?
[ I didn't look at the content of the changes, just talking about the presence of them per se ]
Comment 12 Cosimo Cecchi 2008-09-09 11:43:34 UTC
(In reply to comment #11)

> A very quick look at it, and it looks quite acceptable.
> However, I'm a bit worried about the size of changes in GtkLabel itself.
> Renaming and & making a bit of the private api accessible from GtkEditableLabel
> is fine.
> I'm more worried about the other changes. Can they be removed/refactored to
> reduce the likelihood of regressions?
> [ I didn't look at the content of the changes, just talking about the presence
> of them per se ]

Hi Johan,

If you exclude renaming and opening up some bits of private API, the main change to GtkLabel is text managing (i.e. implementing insert_text () and delete_text () into GtkLabel and use these functions to mimic gtk_label_set_text () old behavior). AFAICS, this is quite unavoidable as GtkEditableLabel needs a way to insert/delete text into an arbitrary position for implementing GtkEditable and I can't find a way to move insert_text () and delete_text () into GtkEditableLabel without duplicating lots of code and doing ugly tricks.

One question: if I need to add a field (e.g. a guint) to GtkLabel, is it better to add it GSEALed to the GtkLabel struct in gtklabel.h or add it in GtkLabelPrivate and provide getters and setters in gtklabelprivate.h?
Comment 13 Javier Jardón (IRC: jjardon) 2009-05-25 17:43:20 UTC
Link to Gnome wiki: http://live.gnome.org/ProjectRidley/EelEditableLabel
Comment 14 Javier Jardón (IRC: jjardon) 2009-12-04 18:49:39 UTC
(In reply to comment #12)
> One question: if I need to add a field (e.g. a guint) to GtkLabel, is it better
> to add it GSEALed to the GtkLabel struct in gtklabel.h or add it in
> GtkLabelPrivate and provide getters and setters in gtklabelprivate.h?

I'd would say that you can simply add it to GtkLabelPrivate struct. As far as I know, in the 2.90 branch, all variables in the public structure will be moved to the private ones, so in GtkLabel.h you will have:

struct _GtkLabel
{
  GtkMisc misc;

  /*< private >*/
  GtkLabelPrivate *priv;
};
Comment 15 Javier Jardón (IRC: jjardon) 2010-04-16 12:42:39 UTC
Any progress on this?

Seems that this is the only request to get rid of libeel deprecated library (see http://live.gnome.org/ProjectRidley)
Comment 16 Emmanuele Bassi (:ebassi) 2010-04-17 10:17:51 UTC
so: EditableLabel would be good for 2.x - but it fell off the radar. for 2.90 we can break API/ABI, and add support for editability directly to GtkLabel. we should probably decide this either on the mailing list or in an IRC meeting.

definitely 3.0 material, though.
Comment 17 Matthias Clasen 2010-06-08 22:01:12 UTC
Recent irc discussion of this contains my thoughts on it

<ebassi> editable label: sub-class or not?
<ebassi> the sub-class idea was due to the "we can't break ABI and we're out of slots on LabelClass"
<ebassi> I guess now we can simply extend that
<mclasen> I must admit I never fully grokked the idea of an editable label as a widget
<mclasen> isn't that just a notebook with a label and an entry ?
<mitch> haha i agree
<mitch> it's a WTF
<ebassi> well, nautilus has them to rename files :-)
<ebassi> it's a bit ad hoc, though
<mitch> ebassi: aren't these tree rows?
<ebassi> no
<ebassi> in icon view
<ebassi> not in list view
* mclasen has done a lot of label + editable widget in a notebook in the accountsdialog
<jjardon> It's needed to replace EelEditableLabel: Its one of the items of ProjectRidley: http://live.gnome.org/ProjectRidley
<mclasen> it can be tricky sometimes to get focus handling right
<jjardon> bug here: https://bugzilla.gnome.org/show_bug.cgi?id=310693
<ebassi> jjardon: yep, EelEditableLabel is what nautilus is using (in tree)
<ebassi> dunno if there are other projects using it, though
<mclasen> I would invite anybody to study the accountsdialog set of label-that-turns-into-entry, label-that=turns-into-button, label-that-turns-into-combo
<jjardon> cosimoc offered to make a patch if an implementation was decided here
<jjardon> mclasen, yeah It's pretty cool ;)
<mclasen> so, I'd be more interested in investigating if there is a more general pattern of editable-uneditable widget that we can  support, instead of just copying eeleditablelabel
<garnacho> I wonder if it doesn't make more sense to make it the other way around, a non-editable entry that looks like a label
<mclasen> the thing is that label and entry have distinct feature sets
<mclasen> there's a big overlap, certainly
<mclasen> but there is also a difference
<garnacho> I see, should check the use cases
<mclasen> labels do urls, they can or cannot be selectable, they can wrap,..
<mclasen> entries can be invisible, they can show icons, they can not wrap, etc etc
<garnacho> a GtkLabel subclass makes sense then
<mclasen> what will that class do ? reimplement gtkentry ?
<ebassi> and in case of word wrapping, does it become a text area? :-)
Comment 18 Cosimo Cecchi 2010-07-29 08:58:21 UTC
Created attachment 166759 [details] [review]
another approach

Hi,

I found some time to work on this again, and I came up with this patch, which uses another approach than my last one.

- The implementation is done inside GtkLabel, by implementing the GtkEditable interface.
- Also, I added two methods, gtk_label_[get/set]_editable, and an 'editable' property that do what their name suggest.

The patch reuses most of the code from EelEditableLabel, and it's working fine; I added some test code to testgtk.c to demonstrate the feature. Also, note that this is just the outcome of two afternoons of hacking at GUADEC, so the patch could probably be improved.

Feedback welcome.
Comment 19 Maël Lavault 2011-02-17 18:02:17 UTC
Editable label are very useful in some special case. As a member of the openshot team, i would be very happy to use them to rename track, put label on markers and for our title editor for example.

Any progress on this ? I know it's too late for GTK3 inclusion, maybe 3.2 ?
Comment 20 Matthias Clasen 2018-02-10 04:34:21 UTC
We're moving to gitlab! As part of this move, we are closing bugs that haven't seen activity in more than 5 years. If this issue is still imporant to you and
still relevant with GTK+ 3.22 or master, please consider creating a gitlab issue
for it.
Comment 21 Bastien Nocera 2018-02-13 09:47:06 UTC
Would still be useful.
Comment 22 GNOME Infrastructure Team 2018-05-02 14:11:39 UTC
-- GitLab Migration Automatic Message --

This bug has been migrated to GNOME's GitLab instance and has been closed from further activity.

You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.gnome.org/GNOME/gtk/issues/250.