Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorIgnacio Rodríguez <ignaciorodriguez@sugarlabs.org>2012-12-16 21:09:10 (GMT)
committer Ignacio Rodríguez <ignaciorodriguez@sugarlabs.org>2012-12-16 21:09:10 (GMT)
commitc3b7feb79c76b419e553f44f9acbd7e403ea211e (patch)
treef1cccaafef593f0ce9a78dc3ae87f20be1161865
parent7985475cbfd4db1a82acace6dd2996af876ef30b (diff)
Colors & Font, now saved.
-rw-r--r--Toolbars.py36
-rw-r--r--abook.py130
-rw-r--r--textbook.py7
3 files changed, 136 insertions, 37 deletions
diff --git a/Toolbars.py b/Toolbars.py
index 2dc5c30..f8a06e7 100644
--- a/Toolbars.py
+++ b/Toolbars.py
@@ -2,6 +2,7 @@
# -*- coding: utf-8 -*-
# Toolbars.py
# Gabriel, hice esto porque es un revoltijo abook.py :P
+
try:
import gtk
import sys
@@ -59,6 +60,7 @@ check_button = ToolButton("broken")
def Color_Toolbar(toolbar):
+
color_button = ToolbarButton(icon_name='color-preview')
color_toolbar = gtk.Toolbar()
ColorContentLabel = gtk.Label(_('Text color'))
@@ -94,6 +96,7 @@ def Color_Toolbar(toolbar):
def Text_Toolbar(toolbar):
+
text_button = ToolbarButton(icon_name="format-text-size")
text_toolbar = gtk.Toolbar()
A = gtk.Label(_('Content:'))
@@ -126,10 +129,10 @@ def Text_Toolbar(toolbar):
def Read_Toolbar(toolbar):
+
# read toolbar
read_button = ToolbarButton(icon_name="read")
read_toolbar = gtk.Toolbar()
-
restart_button.set_tooltip(_("Start from the begining"))
@@ -150,16 +153,17 @@ def Read_Toolbar(toolbar):
read_toolbar.insert(Sep, -1)
Sep.show()
- credits.set_tooltip(_("Credits"))
+ credits.set_tooltip(_("Tutorial and credits"))
read_toolbar.insert(credits, -1)
- read_toolbar.insert(tutorial, -1)
- tutorial.show()
+# read_toolbar.insert(tutorial, -1)
+# tutorial.show()
credits.show()
toolbar.toolbar.insert(read_button, -1)
def Write_Toolbar(toolbar):
+
# write toolbar
write_button = ToolbarButton(icon_name="edit")
write_toolbar = gtk.Toolbar()
@@ -185,6 +189,7 @@ def Write_Toolbar(toolbar):
def Ayuda(toolbar):
+
Boton_Ayuda = Ayudas()
# Porfavor, traducir esto al ingles! #
Boton_Ayuda.add_section(_("Creating a book"))
@@ -194,16 +199,25 @@ def Ayuda(toolbar):
Boton_Ayuda.add_paragraph(_("To edit the book, click on"),'edit')
Boton_Ayuda.add_paragraph(_("Then click on"),'edit-c')
Boton_Ayuda.add_section(_("Editing the book properties"))
- Boton_Ayuda.add_paragraph(_("To edit the book properties, click on"),'edit')
+ Boton_Ayuda.add_paragraph(_("To edit the book properties, click on"),
+ 'edit')
Boton_Ayuda.add_paragraph(_("Then click on"),'edit-p')
Boton_Ayuda.add_section(_("Reading a book"))
Boton_Ayuda.add_paragraph(_("To read a book, click on"),'read')
- Boton_Ayuda.add_paragraph(_("If you want to go to the first page, click on"),'home')
- Boton_Ayuda.add_paragraph(_("If you want to load a book from the journal, click on"),'open-from-journal')
- Boton_Ayuda.add_paragraph(_("If you want to read a tutorial and the credits, click on"),'credits')
+ Boton_Ayuda.add_paragraph(_("If you want to go to the first page, "
+ "click on"),'home')
+ Boton_Ayuda.add_paragraph(_("If you want to load a book from the "
+ "journal, click on"),'open-from-journal')
+ Boton_Ayuda.add_paragraph(_("If you want to read a tutorial and "
+ "the credits, click on"),'credits')
Boton_Ayuda.add_section(_("Editing the text style"))
- Boton_Ayuda.add_paragraph(_("To change the font size, click on"),'format-text-size')
- Boton_Ayuda.add_paragraph(_("If you want to edit the font name, click on the text box (e.g., 'Purisa 8'); a font list will be displayed. Select one."))
- Boton_Ayuda.add_paragraph(_("If you want to change the color, click on"), 'color-preview')
+ Boton_Ayuda.add_paragraph(_("To change the font size, click on"),
+ 'format-text-size')
+ Boton_Ayuda.add_paragraph(_("If you want to edit the font name, "
+ "click on the text box (e.g., "
+ "'Purisa 8'); a font list will be "
+ "displayed. Select one."))
+ Boton_Ayuda.add_paragraph(_("If you want to change the color, "
+ "click on"), 'color-preview')
Boton_Ayuda.show()
toolbar.toolbar.insert(Boton_Ayuda, -1)
diff --git a/abook.py b/abook.py
index 9fb484d..b9b8e96 100644
--- a/abook.py
+++ b/abook.py
@@ -60,13 +60,14 @@ from Toolbars import Ayuda
import Toolbars
EventBox = gtk.EventBox()
+
class AdventureBookActivity(activity.Activity):
def __init__(self, handle):
+
activity.Activity.__init__(self, handle, True)
toolbarbox = ToolbarBox()
self._main_view = gtk.VBox()
-
EventBox.add(self._main_view)
## CONNECTS ##
Toolbars.restart_button.connect("clicked", self._restart_button_cb)
@@ -74,24 +75,30 @@ class AdventureBookActivity(activity.Activity):
Toolbars.load_button.connect("clicked", self._load_button_cb)
Toolbars.credits.connect("clicked", self.Credits)
Toolbars.new_button.connect("clicked", self._new_button_cb)
- Toolbars.book_button.connect("clicked", self._edit_book_button_cb, Toolbars.ColorLetra.get_color())
- Toolbars.page_button.connect("clicked", self._edit_page_button_cb, EventBox)
- Toolbars.check_button.connect("clicked", self._check_button_cb, Toolbars.ColorLetra.get_color())
- Toolbars.ColorLetra.set_title(_('Select color for font and go to home page'))
+ Toolbars.book_button.connect("clicked", self._edit_book_button_cb,
+ Toolbars.ColorLetra.get_color())
+ Toolbars.page_button.connect("clicked", self._edit_page_button_cb,
+ EventBox)
+ Toolbars.check_button.connect("clicked", self._check_button_cb,
+ Toolbars.ColorLetra.get_color())
+ Toolbars.ColorLetra.set_title(_(
+ 'Select color for font and go to home page'))
Toolbars.ColorLetra.connect('notify::color', self.Home)
- Toolbars.ColorFondo.set_title(_('Select color for page and go to home page'))
+ Toolbars.ColorFondo.set_title(_("Select color for page and "
+ "go to home page"))
Toolbars.ColorFondo.connect('notify::color', self.Home)
Toolbars.Fonts.connect('change_selection', self.Home)
Toolbars.Title_Tam.connect('change_selection', self.Home)
- Toolbars.ColorTitle.set_title(_('Select color for title and go to home page'))
+ Toolbars.ColorTitle.set_title(_("Select color for title and "
+ "go to home page"))
Toolbars.ColorTitle.connect('notify::color', self.Home)
Toolbars.tutorial.connect("clicked", self.Tutorial)
# FIN DE CONNECTS #
# The Activity Button:
activity_button = ActivityToolbarButton(self)
-
- # Insert the Activity Toolbar Button in the toolbarbox
+
+ # Insert the Activity Toolbar Button in the toolbarbox
toolbarbox.toolbar.insert(activity_button, 0)
toolbarbox.toolbar.insert(gtk.SeparatorToolItem(), -1)
Read_Toolbar(toolbarbox)
@@ -120,9 +127,14 @@ class AdventureBookActivity(activity.Activity):
self._book = empty_book()
self._start_book(Toolbars.ColorLetra.get_color())
+
def Home(self, widget, pspec):
+
self._restart_button_cb(None)
- EventBox.modify_bg(gtk.STATE_NORMAL, Toolbars.ColorFondo.get_color())
+ EventBox.modify_bg(gtk.STATE_NORMAL,
+ Toolbars.ColorFondo.get_color())
+
+
def _clean_main_view(self):
for w in self._main_view.get_children():
@@ -130,6 +142,9 @@ class AdventureBookActivity(activity.Activity):
def _start_book(self, Color):
+
+ EventBox.modify_bg(gtk.STATE_NORMAL,
+ Toolbars.ColorFondo.get_color())
Tam = pango.FontDescription(Toolbars.Fonts.get_active_text())
Title = pango.FontDescription(Toolbars.Title_Tam.get_active_text())
Color_ts = Toolbars.ColorTitle.get_color()
@@ -176,11 +191,12 @@ class AdventureBookActivity(activity.Activity):
def _show_page(self, Color):
+
self._clean_main_view()
Tam = pango.FontDescription(Toolbars.Fonts.get_active_text())
Title = pango.FontDescription(Toolbars.Title_Tam.get_active_text())
Color_ts = Toolbars.ColorTitle.get_color()
- print Tam
+# print Tam
title_label = gtk.Label(self._current_page.get_title())
title_label.modify_fg(gtk.STATE_NORMAL, Color_ts)
title_label.show()
@@ -203,8 +219,11 @@ class AdventureBookActivity(activity.Activity):
def _option_button_cb(self, widget, option):
+
self._current_page = option.get_page()
self._show_page(Toolbars.ColorLetra.get_color())
+
+
def _load_button_cb(self, widget):
chooser = ObjectChooser(parent=self)
@@ -217,13 +236,15 @@ class AdventureBookActivity(activity.Activity):
alerta = NotifyAlert(10)
alerta.props.title = _('Good!')
alerta.props.msg = _('Book loaded')
- alerta.connect('response', lambda w, i: self.remove_alert(w))
+ alerta.connect('response', lambda w,
+ i: self.remove_alert(w))
self.add_alert(alerta)
except IOError:
alerta = NotifyAlert(10)
alerta.props.title = 'Error'
alerta.props.msg = _('Error in load book')
- alerta.connect('response', lambda w, i: self.remove_alert(w))
+ alerta.connect('response', lambda w,
+ i: self.remove_alert(w))
self.add_alert(alerta)
else:
return
@@ -234,23 +255,44 @@ class AdventureBookActivity(activity.Activity):
self._book = empty_book()
self._start_book(Toolbars.ColorLetra.get_color())
EventBox.modify_bg(gtk.STATE_NORMAL, Toolbars.ColorFondo.get_color())
-
# self._start_button_cb(widget)
def Credits(self, widget):
+
self._book = tutorial_book() #credits_book()
+
+ Toolbars.ColorLetra.set_color(gtk.gdk.Color('#000'))
+ Toolbars.ColorTitle.set_color(gtk.gdk.Color('#d00000'))
+ Toolbars.ColorFondo.set_color(gtk.gdk.Color('#ffffd0'))
+ font_text = 'Purisa 8'
+ font_title = 'Purisa 12'
+ fonts_tree_model = Toolbars.Fonts.get_model()
+ # next loop is to set the right entry in the combo
+ for i in fonts_tree_model:
+ Toolbars.Fonts.set_active_iter(i.iter)
+ if font_text == Toolbars.Fonts.get_active_text():
+ break
+ tam_tree_model = Toolbars.Title_Tam.get_model()
+ # next loop is to set the right entry in the combo
+ for i in tam_tree_model:
+ Toolbars.Title_Tam.set_active_iter(i.iter)
+ if font_title == Toolbars.Title_Tam.get_active_text():
+ break
+
self._start_book(Toolbars.ColorLetra.get_color())
EventBox.modify_bg(gtk.STATE_NORMAL, Toolbars.ColorFondo.get_color())
def Tutorial(self, widget):
+
self._book = tutorial_book()
self._start_book(Toolbars.ColorLetra.get_color())
EventBox.modify_bg(gtk.STATE_NORMAL, Toolbars.ColorFondo.get_color())
def _edit_book_button_cb(self, widget, Color):
+
Tam = pango.FontDescription('8')
Col = gtk.gdk.Color('#ff0000')
EventBox.modify_bg(gtk.STATE_NORMAL, Col)
@@ -310,21 +352,25 @@ class AdventureBookActivity(activity.Activity):
def _title_changed_cb(self, w):
+
EventBox.modify_bg(gtk.STATE_NORMAL, Toolbars.ColorFondo.get_color())
self._book.set_title(w.get_text())
def _author_changed_cb(self, w):
+
EventBox.modify_bg(gtk.STATE_NORMAL, Toolbars.ColorFondo.get_color())
self._book.set_author(w.get_text())
def _license_changed_cb(self, w):
+
EventBox.modify_bg(gtk.STATE_NORMAL, Toolbars.ColorFondo.get_color())
self._book.set_license(w.get_active_text())
def _edit_page_button_cb(self, widget,Caja):
+
self._clean_main_view()
page_hbox = gtk.HBox()
list_vbox = gtk.VBox()
@@ -408,6 +454,7 @@ class AdventureBookActivity(activity.Activity):
def _page_selected_for_edition_cb(self, w, page_vbox, Color):
+
Tam = pango.FontDescription('10')
for ch in page_vbox.get_children():
@@ -496,13 +543,16 @@ class AdventureBookActivity(activity.Activity):
def _page_title_changed_cb(self, w, p, treemodel, treeiter):
- print w
+
+# print w
p.set_title(w.get_text(w.get_start_iter(),w.get_end_iter()))
- treemodel.set_value(treeiter, 0, w.get_text(w.get_start_iter(),w.get_end_iter()))
+ treemodel.set_value(treeiter, 0, w.get_text(w.get_start_iter(),
+ w.get_end_iter()))
def _page_text_changed_cb(self, w, p, treemodel, treeiter):
- print w
+
+# print w
p.set_text(w.get_text(w.get_start_iter(),w.get_end_iter()))
@@ -518,6 +568,7 @@ class AdventureBookActivity(activity.Activity):
def _add_option_button_cb(self, w, page, option_hbox, options_vbox):
+
Tam = pango.FontDescription('10')
w.get_parent().remove(w)
@@ -567,6 +618,7 @@ class AdventureBookActivity(activity.Activity):
def _check_button_cb(self, widget, Color):
+
Tam = pango.FontDescription('10')
self._clean_main_view()
@@ -580,8 +632,8 @@ class AdventureBookActivity(activity.Activity):
pointed_to = True
if not pointed_to:
print "Page "+ p1.get_title() + " not referenced"
- msg_label = gtk.Label("Error: Page '"+ p1.get_title() +
- "' not referenced from any other page")
+ msg_label = gtk.Label(_("Error: Page '")+ p1.get_title() +
+ _("' not referenced from any other page"))
msg_label.modify_fg(gtk.STATE_NORMAL, Color)
msg_label.modify_font(Tam)
self._main_view.pack_start(msg_label)
@@ -590,8 +642,9 @@ class AdventureBookActivity(activity.Activity):
for p1 in self._book.get_pages():
for p in self._book.get_pages():
if p1.get_title() == p.get_title() and p1 != p:
- msg_label = gtk.Label("Error: Page title '"+ p1.get_title() +
- "' is not unique")
+ msg_label = gtk.Label(_("Error: Page title '")+
+ p1.get_title() +
+ _("' is not unique"))
msg_label.modify_fg(gtk.STATE_NORMAL, Color)
msg_label.modify_font(Tam)
self._main_view.pack_start(msg_label)
@@ -622,6 +675,14 @@ class AdventureBookActivity(activity.Activity):
book_props = {'title': self._book.get_title(),
'author': self._book.get_author(),
'license': self._book.get_license(),
+ 'color_text':
+ Toolbars.ColorLetra.get_color().to_string(),
+ 'color_title':
+ Toolbars.ColorTitle.get_color().to_string(),
+ 'color_bg':
+ Toolbars.ColorFondo.get_color().to_string(),
+ 'font_text': Toolbars.Fonts.get_active_text(),
+ 'font_title': Toolbars.Title_Tam.get_active_text(),
'pages': pages_props}
try:
@@ -642,6 +703,31 @@ class AdventureBookActivity(activity.Activity):
self._book = cBook(book_props['title'])
self._book.set_author(book_props['author'])
self._book.set_license(book_props['license'])
+ try:
+ Toolbars.ColorLetra.set_color(
+ gtk.gdk.Color(book_props['color_text']))
+ Toolbars.ColorTitle.set_color(
+ gtk.gdk.Color(book_props['color_title']))
+ Toolbars.ColorFondo.set_color(
+ gtk.gdk.Color(book_props['color_bg']))
+ font_text = book_props['font_text']
+ font_title = book_props['font_title']
+ fonts_tree_model = Toolbars.Fonts.get_model()
+ # next loop is to set the right entry in the combo
+ for i in fonts_tree_model:
+ Toolbars.Fonts.set_active_iter(i.iter)
+ if font_text == Toolbars.Fonts.get_active_text():
+ break
+ tam_tree_model = Toolbars.Title_Tam.get_model()
+ # next loop is to set the right entry in the combo
+ for i in tam_tree_model:
+ Toolbars.Title_Tam.set_active_iter(i.iter)
+ if font_title == Toolbars.Title_Tam.get_active_text():
+ break
+ except:
+ # probably an old version of the journal entry
+ pass
+
page_list = book_props['pages']
for p in page_list:
page_props = cPage(p['title'])
@@ -662,5 +748,3 @@ class AdventureBookActivity(activity.Activity):
page_orig.add_option(option_props)
self._start_book(Toolbars.ColorLetra.get_color())
-
-
diff --git a/textbook.py b/textbook.py
index 619e7a8..e69d25a 100644
--- a/textbook.py
+++ b/textbook.py
@@ -68,7 +68,7 @@ Thanks to: Flavio Danesse <fdanesse@gmail.com>
¡Thanks for using this program! :)
-To continue create an empty book!"""))
+To continue create an empty book or load one from the Journal!"""))
o1 = cOption(_("How to read"),p2)
o2 = cOption(_("How to create"), p3)
@@ -93,8 +93,9 @@ def empty_book():
mybook = cBook(_("Title"))
mybook.set_license(_("CC-BY"))
- p1 = cPage(_("First page"))
- op = cOption(_("Return"), mybook)
+ p1 = cPage(_("First page title"))
+ p1.set_text(_("Text for the first page"))
+ op = cOption(_("Return to the first page"), p1)
p1.add_option(op)
mybook.add_page(p1)