Re: [patch] delete attributes with Del key
Dodji Seketeli <[email protected]> Sun, 01 Feb 2004 02:13:23 +0100
| Newsgroups | gmane.editors.mlview.devel |
|---|---|
| Message-ID | <[email protected]> |
Hi, The patch looks good to me. It's applied and commited in CVS HEAD. Thank you ! Dodji. Le sam 31/01/2004 à 20:59, Sebastien Bacher a écrit : > Hi, > > With this patch it's possible to delete an attribute by pressing the Del > key. It's a part of the wishlist #132700. > > All the comments are welcome, it's my first patch for mlview ... :) > > > Cheers, > > Sebastien > > > ______________________________________________________________________ > Index: ChangeLog > =================================================================== > RCS file: /cvs/gnome/mlview/ChangeLog,v > retrieving revision 1.217 > diff -u -r1.217 ChangeLog > --- ChangeLog 29 Jan 2004 10:04:35 -0000 1.217 > +++ ChangeLog 31 Jan 2004 19:52:45 -0000 > @@ -1,3 +1,9 @@ > +2004-01-31 Sebastien Bacher <[email protected]> > + > + * src/mlview-attrs-editor.c: (mlview_attrs_editor_construct), > + (tree_key_press_cb): allow to delete the selected attribute by pressing > + the Del key in the list of the attributes. > + > 2004-01-29 Kjartan Maraas <[email protected]> > > * configure.in: Added "no" to ALL_LINGUAS. > Index: src/mlview-attrs-editor.c > =================================================================== > RCS file: /cvs/gnome/mlview/src/mlview-attrs-editor.c,v > retrieving revision 1.21 > diff -u -r1.21 mlview-attrs-editor.c > --- src/mlview-attrs-editor.c 21 Dec 2003 21:46:56 -0000 1.21 > +++ src/mlview-attrs-editor.c 31 Jan 2004 19:53:08 -0000 > @@ -30,6 +30,7 @@ > #include "mlview-attrs-editor.h" > #include "mlview-attribute-picker.h" > #include "mlview-marshal.h" > +#include <gdk/gdkkeysyms.h> > > /** > *@file > @@ -149,6 +150,11 @@ > xmlAttr *a_attr, > MlViewAttrsEditor *a_editor) ; > > +static gboolean > +tree_key_press_cb (GtkTreeView *a_tree, > + GdkEventKey *a_event, > + MlViewAttrsEditor *a_this); > + > /* > *Mandatory private functions to comply with the gtk object > *framework. go to http://www.gtk.org/tutorial/sec-theanatomyofawidget.html > @@ -257,6 +263,11 @@ > (PRIVATE (a_this)->model)) ; > g_return_if_fail (PRIVATE (a_this)->attrs_view) ; > > + g_signal_connect (G_OBJECT (PRIVATE (a_this)->attrs_view), > + "key_press_event", > + G_CALLBACK (tree_key_press_cb), > + a_this) ; > + > selection = gtk_tree_view_get_selection > (PRIVATE (a_this)->attrs_view) ; > g_return_if_fail (selection) ; > @@ -821,6 +832,34 @@ > } > } > > + > +/** > + *callback for key_press_event in the attributes treeview > + *remove the selected attribute if DEL key is pressed > + */ > + > +static gboolean > +tree_key_press_cb (GtkTreeView *a_tree, > + GdkEventKey *a_event, > + MlViewAttrsEditor *a_this) > +{ > + enum MlViewStatus status = MLVIEW_OK ; > + GtkTreeIter iter = {0} ; > + > + g_return_val_if_fail (a_tree && a_event && a_this, FALSE) ; > + > + status = mlview_attrs_editor_get_cur_sel_iter(a_this, &iter); > + if(status != MLVIEW_OK) > + return FALSE ; > + > + if (a_event->keyval == GDK_Delete) { > + mlview_attrs_editor_remove_attribute (a_this, &iter) ; > + return TRUE ; > + } > + > + return FALSE ; > +} > + > /************************ > *public methods * > ************************/