Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ported to Gtk3 #31

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
68 changes: 48 additions & 20 deletions activity.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,57 +17,85 @@
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
"""Activity helper classes."""
from sugar.activity import activity

import os

from gi.repository import Gtk
from gi.repository import Gdk
from gi.repository import Pango
from gi.repository import Vte
from gi.repository import GLib

from sugar3.activity import activity
from sugar3.graphics.toolbarbox import ToolbarBox
from sugar3.activity.widgets import ActivityButton
from sugar3.activity.widgets import TitleEntry
from sugar3.activity.widgets import StopButton

# Set to false to hide terminal and auto quit on exit
DEBUG_TERMINAL = False

class VteActivity(activity.Activity):
"""Activity subclass built around the Vte terminal widget."""
def __init__(self, handle):
import gtk, pango, vte
super(VteActivity, self).__init__(handle, create_jobject=False)
self.__source_object_id = None

# creates vte widget
self._vte = vte.Terminal()
self._vte = Vte.Terminal()

if DEBUG_TERMINAL:
toolbox = activity.ActivityToolbox(self)
toolbar = toolbox.get_activity_toolbar()
self.set_toolbox(toolbox)
toolbox = ToolbarBox()
toolbar = toolbox.toolbar
self.set_toolbar_box(toolbox)

activity_button = ActivityButton(self)
toolbar.insert(activity_button, 0)
activity_button.show()

title_entry = TitleEntry(self)
toolbar.insert(title_entry, -1)
title_entry.show()

separator = Gtk.SeparatorToolItem()
separator.props.draw = False
separator.set_expand(True)
toolbar.insert(separator, -1)
separator.show()

stop_button = StopButton(self)
toolbar.insert(stop_button, -1)
stop_button.show()

self._vte.set_size(30,5)
self._vte.set_size_request(200, 300)
font = 'Monospace 10'
self._vte.set_font(pango.FontDescription(font))
self._vte.set_colors(gtk.gdk.color_parse ('#E7E7E7'),
gtk.gdk.color_parse ('#000000'),
self._vte.set_font(Pango.FontDescription(font))
self._vte.set_colors(Gdk.color_parse ('#E7E7E7'),
Gdk.color_parse ('#000000'),
[])

vtebox = gtk.HBox()
vtebox.pack_start(self._vte)
vtesb = gtk.VScrollbar(self._vte.get_adjustment())
vtebox = Gtk.HBox()
vtebox.pack_start(self._vte, True, True, 0)
vtesb = Gtk.VScrollbar(self._vte.get_vadjustment())
vtesb.show()
vtebox.pack_start(vtesb, False, False, 0)
self.set_canvas(vtebox)

toolbox.show()
self.show_all()
toolbar.share.hide()
toolbar.keep.hide()

# now start subprocess.
self._vte.connect('child-exited', self.on_child_exit)
self._vte.grab_focus()
bundle_path = activity.get_bundle_path()
self._pid = self._vte.fork_command \
(command='/bin/sh',
argv=['/bin/sh','-c',
self._pid = self._vte.spawn_sync \
(Vte.PtyFlags.DEFAULT, bundle_path,
['/bin/sh','-c',
'python %s/LemonadeStand.py --width=1200 --height=875 --font=36 --shopFont=52 --shopNumFont=72 --menuFont=90' % bundle_path],
envv=["PYTHONPATH=%s/library" % bundle_path],
directory=bundle_path)
def on_child_exit(self, widget):
["PYTHONPATH=%s/library:%s" % (bundle_path, os.environ["PYTHONPATH"])],
GLib.SpawnFlags.DO_NOT_REAP_CHILD, None, None)
def on_child_exit(self, widget, data):
"""This method is invoked when the user's script exits."""
if not DEBUG_TERMINAL:
import sys
Expand Down
2 changes: 1 addition & 1 deletion constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -703,7 +703,7 @@ def __init__(self, language):
}

import locale
locale.setlocale(locale.LC_ALL, '')
locale.setlocale(locale.LC_ALL, 'en_US.UTF-8')


CURRENCY = {
Expand Down