gnome-specimen r4 - in branches/import-from-bzr: . glade
- From: wbolster svn gnome org
- To: svn-commits-list gnome org
- Subject: gnome-specimen r4 - in branches/import-from-bzr: . glade
- Date: Tue, 17 Jun 2008 18:51:53 +0000 (UTC)
Author: wbolster
Date: Tue Jun 17 18:51:53 2008
New Revision: 4
URL: http://svn.gnome.org/viewvc/gnome-specimen?rev=4&view=rev
Log:
* glade/gnome-specimen.glade, specimenwindow.py:
- Show a sorted list of font families in the left
treeview. Thanks to the PyGTK manual I got the treeview
to work pretty easily.
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:51:53 2008
@@ -224,7 +224,7 @@
<property name="can_focus">True</property>
<child>
- <widget class="GtkScrolledWindow" id="scrolledwindow1">
+ <widget class="GtkScrolledWindow" id="fonts-treeview-window">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="hscrollbar_policy">GTK_POLICY_NEVER</property>
@@ -236,11 +236,11 @@
<widget class="GtkTreeView" id="fonts-treeview">
<property name="visible">True</property>
<property name="can_focus">True</property>
- <property name="headers_visible">False</property>
+ <property name="headers_visible">True</property>
<property name="rules_hint">True</property>
<property name="reorderable">False</property>
<property name="enable_search">True</property>
- <property name="fixed_height_mode">True</property>
+ <property name="fixed_height_mode">False</property>
<property name="hover_selection">False</property>
<property name="hover_expand">False</property>
</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:51:53 2008
@@ -1,9 +1,14 @@
import gtk
import gtk.glade
+import pango
class SpecimenWindow:
+
+ # list of pango.FontFamily objects
+ families = []
+
def __init__(self):
"Initializes the application"
@@ -21,12 +26,62 @@
self.fonts_treeview = tree.get_widget('fonts-treeview')
self.preview_treeview = tree.get_widget('preview-treeview')
+ # populate the UI
+ self.load_fonts()
+
+ # show the window
self.window.show()
def on_destroy_event(self, widget, data=None):
"Callback for the window destroy event"
gtk.main_quit()
+ def load_fonts(self):
+ "Loads all fonts and updates the fonts treeview"
+
+ # 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)
+
+ 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)])
+
+ name_column = gtk.TreeViewColumn('Font Name')
+ 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):
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]