Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAjay Garg <ajay@activitycentral.com>2012-09-19 19:29:37 (GMT)
committer Ajay Garg <ajay@activitycentral.com>2012-09-19 19:32:23 (GMT)
commit0a57dae531cdcd8c98f700c890c1d623e64c731a (patch)
treed6dddc9aa8f133971b4302a8b41a3fdd567f435e
parent7dfbdf526106bbe32fc7cea9fb2891fbb7bc8d4e (diff)
sdxo#1592: Incorporating "Age"-Page-at-boot-up.
The approximate timestamp of the user birthTIME is stored in the gconf-key "/desktop/sugar/user/birth_timestamp".
-rw-r--r--rpms/sugar/0138-sdxo-1592-PART-1-Bringing-no-hippo-intro-pages-into-.patch352
-rw-r--r--rpms/sugar/0139-sdxo-1592-PART-2-Incorporating-Age-Page-at-boot-up.patch155
2 files changed, 507 insertions, 0 deletions
diff --git a/rpms/sugar/0138-sdxo-1592-PART-1-Bringing-no-hippo-intro-pages-into-.patch b/rpms/sugar/0138-sdxo-1592-PART-1-Bringing-no-hippo-intro-pages-into-.patch
new file mode 100644
index 0000000..f493878
--- /dev/null
+++ b/rpms/sugar/0138-sdxo-1592-PART-1-Bringing-no-hippo-intro-pages-into-.patch
@@ -0,0 +1,352 @@
+From 233642096d746269b3b7cf919fde4c2a1ff739f8 Mon Sep 17 00:00:00 2001
+From: Ajay Garg <ajay@activitycentral.com>
+Date: Thu, 20 Sep 2012 00:20:50 +0530
+Subject: [PATCH 1/2] sdxo#1592 [PART-1]: Bringing "no-hippo" intro-pages into
+ dx3. This is required, since there is no correspondent
+ to "gtk.SpinButton" in Hippo.
+Organization: Sugar Labs Foundation
+
+
+Signed-off-by: Ajay Garg <ajay@activitycentral.com>
+---
+ src/jarabe/intro/colorpicker.py | 24 +++---
+ src/jarabe/intro/window.py | 149 ++++++++++++++++++++-------------------
+ 2 files changed, 89 insertions(+), 84 deletions(-)
+
+diff --git a/src/jarabe/intro/colorpicker.py b/src/jarabe/intro/colorpicker.py
+index 997199b..75c15c1 100644
+--- a/src/jarabe/intro/colorpicker.py
++++ b/src/jarabe/intro/colorpicker.py
+@@ -14,27 +14,27 @@
+ # along with this program; if not, write to the Free Software
+ # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+
+-import hippo
++import gtk
+
+-from sugar.graphics.icon import CanvasIcon
++from sugar.graphics.icon import Icon
+ from sugar.graphics import style
+ from sugar.graphics.xocolor import XoColor
+
+
+-class ColorPicker(hippo.CanvasBox, hippo.CanvasItem):
+- def __init__(self, **kwargs):
+- hippo.CanvasBox.__init__(self, **kwargs)
+- self.props.orientation = hippo.ORIENTATION_HORIZONTAL
++class ColorPicker(gtk.EventBox):
++ def __init__(self):
++ gtk.EventBox.__init__(self)
+ self._xo_color = None
+
+- self._xo = CanvasIcon(size=style.XLARGE_ICON_SIZE,
+- icon_name='computer-xo')
++ self._xo = Icon(pixel_size=style.XLARGE_ICON_SIZE,
++ icon_name='computer-xo')
+ self._set_random_colors()
+- self._xo.connect('activated', self._xo_activated_cb)
+- self.append(self._xo)
++ self.connect('button-press-event', self._button_press_cb)
++ self.add(self._xo)
+
+- def _xo_activated_cb(self, item):
+- self._set_random_colors()
++ def _button_press_cb(self, widget, event):
++ if event.button == 1 and event.type == gtk.gdk.BUTTON_PRESS:
++ self._set_random_colors()
+
+ def get_color(self):
+ return self._xo_color
+diff --git a/src/jarabe/intro/window.py b/src/jarabe/intro/window.py
+index df19fbf..a6a2a29 100644
+--- a/src/jarabe/intro/window.py
++++ b/src/jarabe/intro/window.py
+@@ -15,6 +15,7 @@
+ # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+
+ import os
++import os.path
+ import logging
+ from gettext import gettext as _
+ import gconf
+@@ -22,12 +23,11 @@ import pwd
+
+ import gtk
+ import gobject
+-import hippo
+
+ from sugar import env
++from sugar import profile
+ from sugar.graphics import style
+ from sugar.graphics.icon import Icon
+-from sugar.graphics.entry import CanvasEntry
+ from sugar.graphics.xocolor import XoColor
+
+ from jarabe.intro import colorpicker
+@@ -45,25 +45,36 @@ def create_profile(name, color=None):
+ client.set_string('/desktop/sugar/user/color', color.to_string())
+ client.suggest_sync()
+
++ if profile.get_pubkey() and profile.get_profile().privkey_hash:
++ logging.info('Valid key pair found, skipping generation.')
++ return
++
+ # Generate keypair
+ import commands
+ keypath = os.path.join(env.get_profile_path(), 'owner.key')
+- if not os.path.isfile(keypath):
+- cmd = "ssh-keygen -q -t dsa -f %s -C '' -N ''" % keypath
+- (s, o) = commands.getstatusoutput(cmd)
+- if s != 0:
+- logging.error('Could not generate key pair: %d %s', s, o)
+- else:
+- logging.error('Keypair exists, skip generation.')
++ if os.path.exists(keypath):
++ os.rename(keypath, keypath + '.broken')
++ logging.warning('Existing private key %s moved to %s.broken',
++ keypath, keypath)
++
++ if os.path.exists(keypath + '.pub'):
++ os.rename(keypath + '.pub', keypath + '.pub.broken')
++ logging.warning('Existing public key %s.pub moved to %s.pub.broken',
++ keypath, keypath)
+
++ cmd = "ssh-keygen -q -t dsa -f %s -C '' -N ''" % (keypath, )
++ (s, o) = commands.getstatusoutput(cmd)
++ if s != 0:
++ logging.error('Could not generate key pair: %d %s', s, o)
+
+-class _Page(hippo.CanvasBox):
++
++class _Page(gtk.VBox):
+ __gproperties__ = {
+ 'valid': (bool, None, None, False, gobject.PARAM_READABLE),
+ }
+
+- def __init__(self, **kwargs):
+- hippo.CanvasBox.__init__(self, **kwargs)
++ def __init__(self):
++ gtk.VBox.__init__(self)
+ self.valid = False
+
+ def set_valid(self, valid):
+@@ -80,27 +91,23 @@ class _Page(hippo.CanvasBox):
+
+ class _NamePage(_Page):
+ def __init__(self, intro):
+- _Page.__init__(self, xalign=hippo.ALIGNMENT_CENTER,
+- background_color=_BACKGROUND_COLOR.get_int(),
+- spacing=style.DEFAULT_SPACING,
+- orientation=hippo.ORIENTATION_HORIZONTAL,)
+-
++ _Page.__init__(self)
+ self._intro = intro
+
+- label = hippo.CanvasText(text=_('Name:'))
+- self.append(label)
+-
+- self._entry = CanvasEntry(box_width=style.zoom(300))
+- self._entry.set_background(_BACKGROUND_COLOR.get_html())
+- self._entry.connect('notify::text', self._text_changed_cb)
++ alignment = gtk.Alignment(0.5, 0.5, 0, 0)
++ self.pack_start(alignment, expand=True, fill=True)
+
+- widget = self._entry.props.widget
+- widget.set_max_length(45)
++ hbox = gtk.HBox(spacing=style.DEFAULT_SPACING)
++ alignment.add(hbox)
+
+- self.append(self._entry)
++ label = gtk.Label(_('Name:'))
++ hbox.pack_start(label, expand=False)
+
+- if gtk.widget_get_default_direction() == gtk.TEXT_DIR_RTL:
+- self.reverse()
++ self._entry = gtk.Entry()
++ self._entry.connect('notify::text', self._text_changed_cb)
++ self._entry.set_size_request(style.zoom(300), -1)
++ self._entry.set_max_length(45)
++ hbox.pack_start(self._entry, expand=False)
+
+ def _text_changed_cb(self, entry, pspec):
+ valid = len(entry.props.text.strip()) > 0
+@@ -113,22 +120,21 @@ class _NamePage(_Page):
+ self._entry.props.text = new_name
+
+ def activate(self):
+- self._entry.props.widget.grab_focus()
++ self._entry.grab_focus()
+
+
+ class _ColorPage(_Page):
+- def __init__(self, **kwargs):
+- _Page.__init__(self, xalign=hippo.ALIGNMENT_CENTER,
+- background_color=_BACKGROUND_COLOR.get_int(),
+- spacing=style.DEFAULT_SPACING,
+- yalign=hippo.ALIGNMENT_CENTER, **kwargs)
++ def __init__(self):
++ _Page.__init__(self)
+
+- self._label = hippo.CanvasText(text=_('Click to change color:'),
+- xalign=hippo.ALIGNMENT_CENTER)
+- self.append(self._label)
++ vbox = gtk.VBox(spacing=style.DEFAULT_SPACING)
++ self.pack_start(vbox, expand=True, fill=False)
+
+- self._cp = colorpicker.ColorPicker(xalign=hippo.ALIGNMENT_CENTER)
+- self.append(self._cp)
++ self._label = gtk.Label(_('Click to change color:'))
++ vbox.pack_start(self._label)
++
++ self._cp = colorpicker.ColorPicker()
++ vbox.pack_start(self._cp)
+
+ self._color = self._cp.get_color()
+ self.set_valid(True)
+@@ -137,7 +143,7 @@ class _ColorPage(_Page):
+ return self._cp.get_color()
+
+
+-class _IntroBox(hippo.CanvasBox):
++class _IntroBox(gtk.VBox):
+ __gsignals__ = {
+ 'done': (gobject.SIGNAL_RUN_FIRST, gobject.TYPE_NONE,
+ ([gobject.TYPE_PYOBJECT, gobject.TYPE_PYOBJECT])),
+@@ -150,8 +156,8 @@ class _IntroBox(hippo.CanvasBox):
+ PAGE_LAST = PAGE_COLOR
+
+ def __init__(self):
+- hippo.CanvasBox.__init__(self, padding=style.zoom(30),
+- background_color=_BACKGROUND_COLOR.get_int())
++ gtk.VBox.__init__(self)
++ self.set_border_width(style.zoom(30))
+
+ self._page = self.PAGE_NAME
+ self._name_page = _NamePage(self)
+@@ -172,58 +178,57 @@ class _IntroBox(hippo.CanvasBox):
+ self._setup_page()
+
+ def _setup_page(self):
+- self.remove_all()
++ for child in self.get_children():
++ self.remove(child)
+
+ if self._page == self.PAGE_NAME:
+ self._current_page = self._name_page
+ elif self._page == self.PAGE_COLOR:
+ self._current_page = self._color_page
+
+- self.append(self._current_page, hippo.PACK_EXPAND)
++ self.pack_start(self._current_page, expand=True)
+
+- button_box = hippo.CanvasBox(orientation=hippo.ORIENTATION_HORIZONTAL)
++ button_box = gtk.HButtonBox()
+
+- if self._page != self.PAGE_FIRST:
+- back_button = hippo.CanvasButton(text=_('Back'))
++ if self._page == self.PAGE_FIRST:
++ button_box.set_layout(gtk.BUTTONBOX_END)
++ else:
++ button_box.set_layout(gtk.BUTTONBOX_EDGE)
++ back_button = gtk.Button(_('Back'))
+ image = Icon(icon_name='go-left')
+- back_button.props.widget.set_image(image)
+- back_button.connect('activated', self._back_activated_cb)
+- button_box.append(back_button)
+-
+- spacer = hippo.CanvasBox()
+- button_box.append(spacer, hippo.PACK_EXPAND)
++ back_button.set_image(image)
++ back_button.connect('clicked', self._back_activated_cb)
++ button_box.pack_start(back_button)
+
+- self._next_button = hippo.CanvasButton()
++ self._next_button = gtk.Button()
+ image = Icon(icon_name='go-right')
+- self._next_button.props.widget.set_image(image)
++ self._next_button.set_image(image)
+
+ if self._page == self.PAGE_LAST:
+- self._next_button.props.text = _('Done')
+- self._next_button.connect('activated', self._done_activated_cb)
++ self._next_button.set_label(_('Done'))
++ self._next_button.connect('clicked', self._done_activated_cb)
+ else:
+- self._next_button.props.text = _('Next')
+- self._next_button.connect('activated', self._next_activated_cb)
++ self._next_button.set_label(_('Next'))
++ self._next_button.connect('clicked', self._next_activated_cb)
+
+ self._current_page.activate()
+
+ self._update_next_button()
+- button_box.append(self._next_button)
++ button_box.pack_start(self._next_button)
+
+ self._current_page.connect('notify::valid',
+ self._page_valid_changed_cb)
+- self.append(button_box)
+
+- if gtk.widget_get_default_direction() == gtk.TEXT_DIR_RTL:
+- button_box.reverse()
++ self.pack_start(button_box, expand=False)
++ self.show_all()
+
+ def _update_next_button(self):
+- widget = self._next_button.props.widget
+- widget.props.sensitive = self._current_page.props.valid
++ self._next_button.set_sensitive(self._current_page.props.valid)
+
+ def _page_valid_changed_cb(self, page, pspec):
+ self._update_next_button()
+
+- def _back_activated_cb(self, item):
++ def _back_activated_cb(self, widget):
+ self.back()
+
+ def back(self):
+@@ -231,7 +236,7 @@ class _IntroBox(hippo.CanvasBox):
+ self._page -= 1
+ self._setup_page()
+
+- def _next_activated_cb(self, item):
++ def _next_activated_cb(self, widget):
+ self.next()
+
+ def next(self):
+@@ -241,7 +246,7 @@ class _IntroBox(hippo.CanvasBox):
+ self._page += 1
+ self._setup_page()
+
+- def _done_activated_cb(self, item):
++ def _done_activated_cb(self, widget):
+ self.done()
+
+ def done(self):
+@@ -252,19 +257,19 @@ class _IntroBox(hippo.CanvasBox):
+
+
+ class IntroWindow(gtk.Window):
++ __gtype_name__ = 'SugarIntroWindow'
++
+ def __init__(self):
+ gtk.Window.__init__(self)
+
+ self.props.decorated = False
+ self.maximize()
+
+- self._canvas = hippo.Canvas()
+ self._intro_box = _IntroBox()
+ self._intro_box.connect('done', self._done_cb)
+- self._canvas.set_root(self._intro_box)
+
+- self.add(self._canvas)
+- self._canvas.show()
++ self.add(self._intro_box)
++ self._intro_box.show()
+ self.connect('key-press-event', self.__key_press_cb)
+
+ def _done_cb(self, box, name, color):
+--
+1.7.4.4
+
diff --git a/rpms/sugar/0139-sdxo-1592-PART-2-Incorporating-Age-Page-at-boot-up.patch b/rpms/sugar/0139-sdxo-1592-PART-2-Incorporating-Age-Page-at-boot-up.patch
new file mode 100644
index 0000000..3626c16
--- /dev/null
+++ b/rpms/sugar/0139-sdxo-1592-PART-2-Incorporating-Age-Page-at-boot-up.patch
@@ -0,0 +1,155 @@
+From bc0718f0b8e089bf344e98f789e6d7a68c39e97a Mon Sep 17 00:00:00 2001
+From: Ajay Garg <ajay@activitycentral.com>
+Date: Thu, 20 Sep 2012 00:56:53 +0530
+Subject: [PATCH 2/2] sdxo#1592 [PART-2]: Incorporating "Age"-Page-at-boot-up.
+Organization: Sugar Labs Foundation
+Signed-off-by: Ajay Garg <ajay@activitycentral.com>
+---
+ src/jarabe/intro/window.py | 75 +++++++++++++++++++++++++++++++++++++++-----
+ 1 files changed, 67 insertions(+), 8 deletions(-)
+
+diff --git a/src/jarabe/intro/window.py b/src/jarabe/intro/window.py
+index a6a2a29..daa0c72 100644
+--- a/src/jarabe/intro/window.py
++++ b/src/jarabe/intro/window.py
+@@ -36,12 +36,29 @@ from jarabe.intro import colorpicker
+ _BACKGROUND_COLOR = style.COLOR_WHITE
+
+
+-def create_profile(name, color=None):
++def create_profile(name, age, color=None):
+ if not color:
+ color = XoColor()
+
+ client = gconf.client_get_default()
+ client.set_string('/desktop/sugar/user/nick', name)
++
++ # Algorithm to generate the timestamp of the birthday of the
++ # XO-user ::
++ #
++ # timestamp = current_timestamp - [age * (365 * 24 * 60 * 60)]
++ #
++ # Note that, this timestamp may actually (in worst-case) be
++ # off-target by 1 year, but that is ok, since we want an
++ # "approximate" age of the XO-user (for statistics-collection).
++ import time
++ current_timestamp = time.time()
++ xo_user_age_as_timestamp = int(age) * 365 * 24 * 60 * 60
++
++ approx_timestamp_at_user_birthday = current_timestamp - xo_user_age_as_timestamp
++ client.set_int('/desktop/sugar/user/birth_timestamp', int(approx_timestamp_at_user_birthday))
++ # Done.
++
+ client.set_string('/desktop/sugar/user/color', color.to_string())
+ client.suggest_sync()
+
+@@ -89,6 +106,42 @@ class _Page(gtk.VBox):
+ pass
+
+
++class _AgePage(_Page):
++ def __init__(self, intro):
++ _Page.__init__(self)
++ self._intro = intro
++
++ alignment = gtk.Alignment(0.5, 0.5, 0, 0)
++ self.pack_start(alignment, expand=True, fill=True)
++
++ hbox = gtk.HBox(spacing=style.DEFAULT_SPACING)
++ alignment.add(hbox)
++
++ label = gtk.Label(_('Name:'))
++ hbox.pack_start(label, expand=False)
++
++ adjustment = gtk.Adjustment(0, 0, 1000, 1, 0, 0)
++ self._entry = gtk.SpinButton(adjustment)
++ self._entry.props.editable = False
++ self._entry.connect('notify::text', self._text_changed_cb)
++ self._entry.set_max_length(15)
++ hbox.pack_start(self._entry, expand=False)
++
++ label = gtk.Label(_('years'))
++ hbox.pack_start(label, expand=False)
++
++
++ def _text_changed_cb(self, entry, pspec):
++ valid = int(entry.props.text) > 0
++ self.set_valid(valid)
++
++ def get_age(self):
++ return self._entry.props.text
++
++ def activate(self):
++ self._entry.grab_focus()
++
++
+ class _NamePage(_Page):
+ def __init__(self, intro):
+ _Page.__init__(self)
+@@ -146,13 +199,15 @@ class _ColorPage(_Page):
+ class _IntroBox(gtk.VBox):
+ __gsignals__ = {
+ 'done': (gobject.SIGNAL_RUN_FIRST, gobject.TYPE_NONE,
+- ([gobject.TYPE_PYOBJECT, gobject.TYPE_PYOBJECT])),
++ ([gobject.TYPE_PYOBJECT, gobject.TYPE_PYOBJECT, gobject.TYPE_PYOBJECT])),
+ }
+
+ PAGE_NAME = 0
+- PAGE_COLOR = 1
++ PAGE_AGE = 1
++ PAGE_COLOR = 2
+
+ PAGE_FIRST = PAGE_NAME
++ PAGE_SECOND = PAGE_AGE
+ PAGE_LAST = PAGE_COLOR
+
+ def __init__(self):
+@@ -161,6 +216,7 @@ class _IntroBox(gtk.VBox):
+
+ self._page = self.PAGE_NAME
+ self._name_page = _NamePage(self)
++ self._age_page = _AgePage(self)
+ self._color_page = _ColorPage()
+ self._current_page = None
+ self._next_button = None
+@@ -183,6 +239,8 @@ class _IntroBox(gtk.VBox):
+
+ if self._page == self.PAGE_NAME:
+ self._current_page = self._name_page
++ if self._page == self.PAGE_AGE:
++ self._current_page = self._age_page
+ elif self._page == self.PAGE_COLOR:
+ self._current_page = self._color_page
+
+@@ -251,9 +309,10 @@ class _IntroBox(gtk.VBox):
+
+ def done(self):
+ name = self._name_page.get_name()
++ age = self._age_page.get_age()
+ color = self._color_page.get_color()
+
+- self.emit('done', name, color)
++ self.emit('done', name, age, color)
+
+
+ class IntroWindow(gtk.Window):
+@@ -272,12 +331,12 @@ class IntroWindow(gtk.Window):
+ self._intro_box.show()
+ self.connect('key-press-event', self.__key_press_cb)
+
+- def _done_cb(self, box, name, color):
++ def _done_cb(self, box, name, age, color):
+ self.hide()
+- gobject.idle_add(self._create_profile_cb, name, color)
++ gobject.idle_add(self._create_profile_cb, name, age, color)
+
+- def _create_profile_cb(self, name, color):
+- create_profile(name, color)
++ def _create_profile_cb(self, name, age, color):
++ create_profile(name, age, color)
+ gtk.main_quit()
+
+ return False
+--
+1.7.4.4
+