Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAgustin Zubiaga <aguz@sugarlabs.org>2012-09-25 18:19:08 (GMT)
committer Agustin Zubiaga <aguz@sugarlabs.org>2012-09-25 18:19:08 (GMT)
commit4a60019ca55ee6bec8a206aa2db9b1030a677011 (patch)
tree9d006ffd96a8a5889a72ffd14d8cf687cd63f64f
parentb369ad7a7424a582e48d9b8e23bd5a640237dee1 (diff)
parent866c7de63db5437819b8d26d4872a43ce01b38fe (diff)
Merge branch 'master' of git.sugarlabs.org:tic-tac-toe/mainline
-rw-r--r--activity.py5
-rw-r--r--dialogs.py90
-rw-r--r--game.py2
3 files changed, 42 insertions, 55 deletions
diff --git a/activity.py b/activity.py
index 2e197b6..d543b69 100644
--- a/activity.py
+++ b/activity.py
@@ -38,6 +38,7 @@ _logger.setLevel(logging.DEBUG)
logging.basicConfig()
import game
+from dialogs import HelpDialog
SERVICE = 'org.sugarlabs.TicTacToe'
IFACE = SERVICE
@@ -106,6 +107,7 @@ class Activity(activity.Activity):
help_btn = ToolButton()
help_btn.set_tooltip(_('Help'))
help_btn.props.icon_name = 'help-icon'
+ help_btn.connect('clicked', self.help_cb)
toolbarbox.toolbar.insert(help_btn, -1)
separator = Gtk.SeparatorToolItem()
@@ -121,6 +123,9 @@ class Activity(activity.Activity):
self.set_toolbar_box(toolbarbox)
self.show_all()
+ def help_cb(self, widget):
+ HelpDialog()
+
def _setup_presence_service(self):
"""Setup the Presence Service."""
self.pservice = presenceservice.get_instance()
diff --git a/dialogs.py b/dialogs.py
index 7cb00a0..3bbc1d9 100644
--- a/dialogs.py
+++ b/dialogs.py
@@ -1,5 +1,4 @@
-# Copyright (C) 2012 Agustin Zubiaga <aguz@sugarlabs.org>
-# Copyright (C) 2012 Cristhofer Travieso <cristhofert97@gmail.com>
+# -*- coding: utf-8 -*-
# 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
@@ -17,15 +16,16 @@
from gettext import gettext as _
-import gobject
-import gtk
+from gi.repository import GObject
+from gi.repository import Gtk
+from gi.repository import Gdk
+from gi.repository import Pango
-from sugar.graphics import style
-from sugar.graphics.toolbutton import ToolButton
-from sugar.graphics.icon import Icon
+from sugar3.graphics import style
+from sugar3.graphics.toolbutton import ToolButton
+from sugar3.graphics.icon import Icon
-
-class _DialogWindow(gtk.Window):
+class _DialogWindow(Gtk.Window):
# A base class for a modal dialog window.
@@ -33,22 +33,22 @@ class _DialogWindow(gtk.Window):
super(_DialogWindow, self).__init__()
self.set_border_width(style.LINE_WIDTH)
- width = gtk.gdk.screen_width() - style.GRID_CELL_SIZE * 2
- height = gtk.gdk.screen_height() - style.GRID_CELL_SIZE * 2
+ width = Gdk.Screen.width() - style.GRID_CELL_SIZE * 2
+ height = Gdk.Screen.height() - style.GRID_CELL_SIZE * 2
self.set_size_request(width, height)
- self.set_position(gtk.WIN_POS_CENTER_ALWAYS)
+ self.set_position(Gtk.WindowPosition.CENTER_ALWAYS)
self.set_decorated(False)
self.set_resizable(False)
self.set_modal(True)
- vbox = gtk.VBox()
+ vbox = Gtk.VBox()
self.add(vbox)
toolbar = _DialogToolbar(icon_name, title)
toolbar.connect('stop-clicked', self._stop_clicked_cb)
- vbox.pack_start(toolbar, False)
+ vbox.pack_start(toolbar, False, False , 0)
- self.content_vbox = gtk.VBox()
+ self.content_vbox = Gtk.VBox()
self.content_vbox.set_border_width(style.DEFAULT_SPACING)
vbox.add(self.content_vbox)
@@ -58,49 +58,49 @@ class _DialogWindow(gtk.Window):
self.destroy()
def _realize_cb(self, source):
- self.window.set_type_hint(gtk.gdk.WINDOW_TYPE_HINT_DIALOG)
- self.window.set_accept_focus(True)
+ self.set_type_hint(Gdk.WindowTypeHint.DIALOG)
+ self.set_accept_focus(True)
-class _DialogToolbar(gtk.Toolbar):
+class _DialogToolbar(Gtk.Toolbar):
# Displays a dialog window's toolbar, with title, icon, and close box.
__gsignals__ = {
- 'stop-clicked': (gobject.SIGNAL_RUN_LAST, None, ()),
+ 'stop-clicked': (GObject.SignalFlags.RUN_LAST, None, ()),
}
def __init__(self, icon_name, title):
super(_DialogToolbar, self).__init__()
if icon_name is not None:
- sep = gtk.SeparatorToolItem()
+ sep = Gtk.SeparatorToolItem()
sep.set_draw(False)
self._add_widget(sep)
icon = Icon()
- icon.set_from_icon_name(icon_name, gtk.ICON_SIZE_LARGE_TOOLBAR)
+ icon.set_from_icon_name(icon_name, Gtk.IconSize.LARGE_TOOLBAR)
self._add_widget(icon)
self._add_separator()
- label = gtk.Label(title)
+ label = Gtk.Label(label=title)
self._add_widget(label)
self._add_separator(expand=True)
- stop = ToolButton(icon_name='dialog-cancel')
+ stop = ToolButton(icon_name='button_cancel')
stop.set_tooltip(_('Done'))
stop.connect('clicked', self._stop_clicked_cb)
self.add(stop)
def _add_separator(self, expand=False):
- separator = gtk.SeparatorToolItem()
+ separator = Gtk.SeparatorToolItem()
separator.set_expand(expand)
separator.set_draw(False)
self.add(separator)
def _add_widget(self, widget):
- tool_item = gtk.ToolItem()
+ tool_item = Gtk.ToolItem()
tool_item.add(widget)
self.add(tool_item)
@@ -108,39 +108,21 @@ class _DialogToolbar(gtk.Toolbar):
self.emit('stop-clicked')
-class ScoreDialog(_DialogWindow):
-
- __gtype_name__ = 'ScoreDialog'
-
- def __init__(self, scores):
-
- super(ScoreDialog, self).__init__("score", _('Score'))
-
- scrollwin = gtk.ScrolledWindow()
- scrollwin.set_policy(gtk.POLICY_NEVER, gtk.POLICY_AUTOMATIC)
- self.content_vbox.pack_start(scrollwin)
-
- liststore = gtk.ListStore(str, str)
- treeview = gtk.TreeView(liststore)
+class HelpDialog(_DialogWindow):
- date_cell = gtk.CellRendererText()
- date_column = gtk.TreeViewColumn(_("Date and Time"))
- date_column.pack_start(date_cell)
- date_column.set_attributes(date_cell, text=1)
- treeview.append_column(date_column)
+ __gtype_name__ = 'HelpDialog'
- time_cell = gtk.CellRendererText()
- time_column = gtk.TreeViewColumn(_("Score"))
+ def __init__(self):
- time_column.pack_start(time_cell)
- time_column.set_attributes(time_cell, text=0)
+ super(HelpDialog, self).__init__('help-icon', _('Help'))
- treeview.append_column(time_column)
+ vbox = Gtk.VBox()
+ self.content_vbox.pack_start(vbox, True, True, 0)
- scores.sort()
+ label = Gtk.Label()
+ label.set_text(_('HELP'))
+ label.modify_font(Pango.FontDescription("bold 20"))
- for i in scores:
- score, date = i.split(",")
- liststore.append([score, date])
+ vbox.pack_start(label, True, True, 0)
- scrollwin.add_with_viewport(treeview)
+ self.show_all()
diff --git a/game.py b/game.py
index c873afc..ed00cd6 100644
--- a/game.py
+++ b/game.py
@@ -43,7 +43,7 @@ class Canvas(Gtk.DrawingArea):
None, [int])}
def __init__(self):
- Gtk.DrawingArea.__init__(self)
+ GObject.GObject.__init__(self)
self._mode = MODE_CROSS
self.circles = []