gnome-specimen r25 - in branches/import-from-bzr: . glade
- From: wbolster svn gnome org
- To: svn-commits-list gnome org
- Subject: gnome-specimen r25 - in branches/import-from-bzr: . glade
- Date: Tue, 17 Jun 2008 18:52:15 +0000 (UTC)
Author: wbolster
Date: Tue Jun 17 18:52:15 2008
New Revision: 25
URL: http://svn.gnome.org/viewvc/gnome-specimen?rev=25&view=rev
Log:
* specimenwindow.py:
- Pressing delete key removes previews
- Made the deleted_selected() method a smarter. It now
tries very hard to set the cursor to a sane position
after a preview has been removed.
- Added a move-cursor handler that makes sure only the
font name rows get focus and the font preview labels
themselves are skipped when the up/down/pageup/pagedown
keys are pressed.
* glade/gnome-specimen.glade:
- Added some signal handlers to make the above work.
Modified:
branches/import-from-bzr/ (props changed)
branches/import-from-bzr/glade/gnome-specimen.glade
branches/import-from-bzr/specimenwindow.py
Modified: branches/import-from-bzr/glade/gnome-specimen.glade
==============================================================================
--- branches/import-from-bzr/glade/gnome-specimen.glade (original)
+++ branches/import-from-bzr/glade/gnome-specimen.glade Tue Jun 17 18:52:15 2008
@@ -355,6 +355,8 @@
<property name="fixed_height_mode">False</property>
<property name="hover_selection">False</property>
<property name="hover_expand">False</property>
+ <signal name="key_release_event" handler="on_previews_treeview_key_release_event" last_modification_time="Wed, 03 May 2006 21:11:12 GMT"/>
+ <signal name="move_cursor" handler="on_previews_treeview_move_cursor" last_modification_time="Wed, 03 May 2006 22:12:33 GMT"/>
</widget>
</child>
</widget>
Modified: branches/import-from-bzr/specimenwindow.py
==============================================================================
--- branches/import-from-bzr/specimenwindow.py (original)
+++ branches/import-from-bzr/specimenwindow.py Tue Jun 17 18:52:15 2008
@@ -230,6 +230,35 @@
'Clears all previews'
self.previews_store.clear()
+ def delete_selected(self):
+ (model, iter) = self.previews_treeview.get_selection().get_selected()
+ if iter is not None:
+ # Remove 2 rows
+ model.remove(iter)
+ still_valid = model.remove(iter)
+
+ # Set the cursor to a remaining row instead of having the cursor
+ # disappear. This allows for easy deletion of multiple previews by
+ # hitting the Remove button repeatedly.
+ if still_valid:
+ # The iter is still valid. This means that there's another row
+ # has "shifted" to the location the deleted row occupied
+ # before. Set the cursor to that row.
+ new_path = self.previews_store.get_path(iter)
+ else:
+ # The iter is no longer valid. In our case this means the
+ # bottom row in the treeview was deleted. Set the cursor to the
+ # new bottom font name row.
+ number_of_rows = self.previews_store.iter_n_children(None)
+ # Subtract 2 because all previews have 2 rows and we want the
+ # bottom name row.
+ new_path = (number_of_rows - 2,)
+
+ # Finally, set the cursor. In some cases the path contains a
+ # negative value. Just ignore it.
+ if (new_path[0] >= 0):
+ self.previews_treeview.set_cursor(new_path)
+
# user interaction callbacks
def on_row_activated(self, treeview, path, viewcolumn, *user_data):
@@ -265,11 +294,33 @@
self.add_preview(family, face)
def on_remove_button_clicked(self, widget, data=None):
- (model, iter) = self.previews_treeview.get_selection().get_selected()
- if iter is not None:
- # remove 2 rows
- model.remove(iter)
- model.remove(iter)
+ self.delete_selected();
+ return True
+
+ def on_previews_treeview_move_cursor(self, treeview, step, count, data=None):
+ 'Makes sure only name rows can be selected/have focus'
+ (path, column) = treeview.get_cursor()
+ if path is not None and path[0] % 2 == 0:
+ if count == 1: new_path = (path[0] + 1,) # forward
+ else: new_path = (path[0] -1,) # backward
+
+ treeview.set_cursor(new_path)
+ return True
+
+ return False
+
+
+ def on_previews_treeview_key_release_event(self, treeview, event, data=None):
+ import gtk.keysyms as syms
+ keyval = event.keyval
+
+ # Delete removes the row
+ if keyval == syms.Delete:
+ self.delete_selected();
+ return True
+
+ # propagate the event
+ return False
def on_clear_button_clicked(self, widget, data=None):
self.clear_previews()
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]