gnome-specimen r5 - in trunk-from-bzr: . glade
- From: wbolster svn gnome org
- To: svn-commits-list gnome org
- Subject: gnome-specimen r5 - in trunk-from-bzr: . glade
- Date: Tue, 17 Jun 2008 18:41:17 +0000 (UTC)
Author: wbolster
Date: Tue Jun 17 18:41:17 2008
New Revision: 5
URL: http://svn.gnome.org/viewvc/gnome-specimen?rev=5&view=rev
Log:
* specimenwindow.py:
- Show all faces of a family in child rows
* glade/gnome-specimen.glade:
- Set a default window size
- Change some treeview settings
* gnome-specimen:
- Silently handle keyboard interrupts
Modified:
trunk-from-bzr/ (props changed)
trunk-from-bzr/glade/gnome-specimen.glade
trunk-from-bzr/gnome-specimen
trunk-from-bzr/specimenwindow.py
Modified: trunk-from-bzr/glade/gnome-specimen.glade
==============================================================================
--- trunk-from-bzr/glade/gnome-specimen.glade (original)
+++ trunk-from-bzr/glade/gnome-specimen.glade Tue Jun 17 18:41:17 2008
@@ -9,6 +9,8 @@
<property name="type">GTK_WINDOW_TOPLEVEL</property>
<property name="window_position">GTK_WIN_POS_NONE</property>
<property name="modal">False</property>
+ <property name="default_width">640</property>
+ <property name="default_height">480</property>
<property name="resizable">True</property>
<property name="destroy_with_parent">False</property>
<property name="decorated">True</property>
@@ -235,8 +237,9 @@
<child>
<widget class="GtkTreeView" id="fonts-treeview">
<property name="visible">True</property>
+ <property name="can_default">True</property>
<property name="can_focus">True</property>
- <property name="headers_visible">True</property>
+ <property name="headers_visible">False</property>
<property name="rules_hint">True</property>
<property name="reorderable">False</property>
<property name="enable_search">True</property>
Modified: trunk-from-bzr/gnome-specimen
==============================================================================
--- trunk-from-bzr/gnome-specimen (original)
+++ trunk-from-bzr/gnome-specimen Tue Jun 17 18:41:17 2008
@@ -39,5 +39,8 @@
gtk.window_set_default_icon_name ("stock_font")
w = SpecimenWindow()
- gtk.main ()
+ try:
+ gtk.main ()
+ except (KeyboardInterrupt):
+ pass
Modified: trunk-from-bzr/specimenwindow.py
==============================================================================
--- trunk-from-bzr/specimenwindow.py (original)
+++ trunk-from-bzr/specimenwindow.py Tue Jun 17 18:41:17 2008
@@ -30,7 +30,7 @@
self.load_fonts()
# show the window
- self.window.show()
+ self.window.show_all()
def on_destroy_event(self, widget, data=None):
"Callback for the window destroy event"
@@ -39,50 +39,36 @@
def load_fonts(self):
"Loads all fonts and updates the fonts treeview"
+ # prepare the tree model
+ self.fonts_treestore = gtk.TreeStore(str, pango.FontFamily, pango.FontFace)
+ self.fonts_treemodelsort = gtk.TreeModelSort(self.fonts_treestore)
+ self.fonts_treeview.set_model(self.fonts_treemodelsort)
+ self.fonts_treemodelsort.set_sort_column_id(0, gtk.SORT_ASCENDING)
+
# retrieve all available fonts
context = self.window.get_pango_context()
self.families = context.list_families()
- # populate the treeview
- names = [family.get_name() for family in self.families]
- names.sort()
- #print '\n'.join(names)
-
- self.fonts_treestore = gtk.TreeStore(str, pango.FontFamily)
- self.fonts_treemodelsort = gtk.TreeModelSort(self.fonts_treestore)
-
- self.fonts_treeview.set_model(self.fonts_treemodelsort)
- self.fonts_treemodelsort.set_sort_column_id(0, gtk.SORT_ASCENDING)
+ # FIXME: cut-off for speed. Ultimately loading should be done
+ # asynchronously in an idle handler.
+ self.families = self.families[:20]
+ # populate the tree model
for family in self.families:
- piter = self.fonts_treestore.append(None, [
- family.get_name(),
- family
- ])
-
- #for child in range(3):
- # self.fonts_treestore.append(piter, ['child %i of parent %i' %
- # (child, parent)])
+ piter = self.fonts_treestore.append(None,
+ [family.get_name(), family, None])
+ for face in family.list_faces():
+ self.fonts_treestore.append(piter,
+ [face.get_face_name(), family, face])
- name_column = gtk.TreeViewColumn('Font Name')
+ # prepare the font name column
+ name_column = gtk.TreeViewColumn()
self.fonts_treeview.append_column(name_column)
-
cell_renderer = gtk.CellRendererText()
name_column.pack_start(cell_renderer, True)
-
- # set the cell "text" attribute to column 0 - retrieve text
- # from that column in treestore
name_column.add_attribute(cell_renderer, 'text', 0)
- # make it searchable
- self.fonts_treeview.set_search_column(0)
- # Allow sorting on the column
- name_column.set_sort_column_id(0)
-
- self.fonts_treeview.show_all()
self.window.show_all()
-
-
# about dialog
def on_about_clicked(self, widget, data=None):
name = 'GNOME Specimen'
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]