Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--activity.py6
-rw-r--r--activity/activity.info4
-rw-r--r--fontslist.py87
3 files changed, 95 insertions, 2 deletions
diff --git a/activity.py b/activity.py
index c12418c..cbb8b0e 100644
--- a/activity.py
+++ b/activity.py
@@ -21,6 +21,8 @@ from sugar3.activity.widgets import StopButton
from sugar3.activity.widgets import ActivityToolbarButton
from sugar3.graphics.toolbarbox import ToolbarBox
+from fontslist import FontsList
+
class FontsActivity(activity.Activity):
@@ -44,6 +46,10 @@ class FontsActivity(activity.Activity):
toolbarbox.toolbar.insert(stopbtn, -1)
self.set_toolbar_box(toolbarbox)
+
+ fonts = FontsList()
+ self.set_canvas(fonts)
+
self.show_all()
def read_file(self, file_path):
diff --git a/activity/activity.info b/activity/activity.info
index 96a75f8..c125ca7 100644
--- a/activity/activity.info
+++ b/activity/activity.info
@@ -1,7 +1,7 @@
[Activity]
-name = Fonts
+name = Install Fonts
activity_version = 1
bundle_id = org.sugarlabs.Fonts
-exec = sugar-activity activity.Fonts -s
+exec = sugar-activity activity.FontsActivity -s
icon = icon
license = GPLv3+
diff --git a/fontslist.py b/fontslist.py
new file mode 100644
index 0000000..8511501
--- /dev/null
+++ b/fontslist.py
@@ -0,0 +1,87 @@
+# Copyright (C) 2012 Agustin Zubiaga <aguz@sugarlabs.org>
+# Copyright (C) 2012 Gonzalo Odiard <godiard@sugarlabs.org>
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+
+from gi.repository import Gtk
+from sugar3.graphics import style
+
+
+class FontsList(Gtk.EventBox):
+
+ def __init__(self):
+ super(FontsList, self).__init__()
+
+ self.modify_bg(Gtk.StateType.NORMAL,
+ style.COLOR_WHITE.get_gdk_color())
+
+ self.vbox = Gtk.Box(orientation=Gtk.Orientation.VERTICAL)
+ self.vbox.set_spacing(6)
+ self.add(self.vbox)
+
+ self.load_fonts()
+
+ self.show()
+
+ def load_fonts(self):
+ for i in range(7):
+ item = FontItem('Font Preview')
+ self.vbox.pack_start(item, False, False, 0)
+ item.queue_draw()
+
+
+class FontItem(Gtk.EventBox):
+
+ def __init__(self, fontname):
+ super(FontItem, self).__init__()
+
+ hbox = Gtk.Box()
+ checkbutton = Gtk.CheckButton()
+ #checkbutton.connect()
+ fontpreview = Gtk.Label(fontname)
+ hbox.pack_start(checkbutton, False, False, 10)
+ hbox.pack_start(fontpreview, False, True, 5)
+
+ height = style.GRID_CELL_SIZE
+ self.set_size_request(-1, height)
+
+ self.connect('draw', self._on_draw)
+
+ self.add(hbox)
+ self.show_all()
+
+ def _on_draw(self, widget, context):
+ alloc = widget.get_allocation()
+
+ x = float(style.DEFAULT_PADDING)
+ y = 0
+ w = float(alloc.width - (style.DEFAULT_PADDING * 2))
+ h = style.GRID_CELL_SIZE
+ r = style.zoom(10)
+
+ context.move_to(x + r, y)
+ context.line_to(x + w - r, y)
+ context.curve_to(x + w, y, x + w, y, x + w, y + r)
+ context.line_to(x + w, y + h - r)
+ context.curve_to(x + w, y + h, x + w, y + h, x + w - r, y + h)
+ context.line_to(x + r, y + h)
+ context.curve_to(x, y + h, x, y + h, x, y + h - r)
+ context.line_to(x, y + r)
+ context.curve_to(x, y, x, y, x + r, y)
+ context.close_path()
+
+ panel_grey = style.COLOR_PANEL_GREY.get_rgba()
+ context.set_source_rgba(*panel_grey)
+ context.fill_preserve() \ No newline at end of file