Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWalter Bender <walter@walter-laptop.(none)>2009-03-28 14:30:40 (GMT)
committer Walter Bender <walter@walter-laptop.(none)>2009-03-28 14:30:40 (GMT)
commitb7560b44fd9b9cb8feb7f15f9d0bc90fbf0dfcc8 (patch)
tree7a48ab1629cf5256694ab73253ee9fdeb1a6f229
parente9aa825d1f10faa9420662303d71134ad5e363a9 (diff)
changes to enable command-line operation
-rw-r--r--NEWS5
-rw-r--r--TurtleArtActivity.py32
-rw-r--r--taexporthtml.py5
-rw-r--r--talogo.py20
-rw-r--r--tasetup.py4
-rw-r--r--tawindow.py37
6 files changed, 61 insertions, 42 deletions
diff --git a/NEWS b/NEWS
index b719616..118f6f2 100644
--- a/NEWS
+++ b/NEWS
@@ -1,3 +1,8 @@
+46
+
+* full screen mode
+* scrolled window
+
45
* alt chars for keyboard shortcuts
diff --git a/TurtleArtActivity.py b/TurtleArtActivity.py
index 40debc2..b1f1001 100644
--- a/TurtleArtActivity.py
+++ b/TurtleArtActivity.py
@@ -67,8 +67,9 @@ class TurtleArtActivity(activity.Activity):
except:
# early versions of Sugar (e.g., 656) didn't support
# get_activity_root()
- datapath = \
- "/home/olpc/.sugar/default/org.laptop.TurtleArtActivity/data"
+ datapath = os.path.join( \
+ os.environ['HOME'], \
+ ".sugar/default/org.laptop.TurtleArtActivity/data")
self.toolbox = activity.ActivityToolbox(self)
self.set_toolbox(self.toolbox)
@@ -89,13 +90,16 @@ class TurtleArtActivity(activity.Activity):
self.sw = gtk.ScrolledWindow()
self.set_canvas(self.sw)
- self.sw.set_policy(gtk.POLICY_ALWAYS, gtk.POLICY_ALWAYS)
+ # self.sw.set_policy(gtk.POLICY_ALWAYS, gtk.POLICY_ALWAYS)
+ self.sw.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
self.sw.show()
canvas = gtk.DrawingArea()
- print str(gtk.gdk.screen_width()*2) + " " + \
+ print "ask: " + str(gtk.gdk.screen_width()*2) + " " + \
str(gtk.gdk.screen_height()*2)
canvas.set_size_request(gtk.gdk.screen_width()*2, \
gtk.gdk.screen_height()*2)
+ a,b = canvas.get_size_request()
+ print "and you shall receive: " + str(a) + " " + str(b)
self.sw.add_with_viewport(canvas)
canvas.show()
@@ -152,8 +156,8 @@ class TurtleArtActivity(activity.Activity):
lang,self)
self.tw.activity = self
self.tw.window.grab_focus()
- self.tw.save_folder=os.path.join(os.environ['SUGAR_ACTIVITY_ROOT'], \
- 'data')
+ self.tw.save_folder=os.path.join( \
+ os.environ['SUGAR_ACTIVITY_ROOT'], 'data')
if self._jobject and self._jobject.file_path:
self.read_file(self._jobject.file_path)
@@ -177,11 +181,11 @@ class TurtleArtActivity(activity.Activity):
"""
def recenter(self):
hadj = self.sw.get_hadjustment()
- print hadj
+ # print hadj
hadj.set_value(0)
self.sw.set_hadjustment(hadj)
vadj = self.sw.get_vadjustment()
- print vadj
+ # print vadj
vadj.set_value(0)
self.sw.set_vadjustment(vadj)
@@ -293,7 +297,7 @@ class TurtleArtActivity(activity.Activity):
tawindow.button_release(self.tw,int(x),int(y),False)
elif text[0] == 'm': # mouse move
e,x,y = re.split(":",text)
- _logger.debug("recieving move: " + x + " " + y)
+ _logger.debug("receiving move: " + x + " " + y)
tawindow.mouse_move(self.tw,0,0,False,int(x),int(y))
elif text[0] == 'k': # typing
e,mask,keyname = re.split(":",text,3)
@@ -495,8 +499,9 @@ class SaveAsToolbar(gtk.Toolbar):
datapath = os.path.join(activity.get_activity_root(), "instance")
except:
# early versions of Sugar (656) didn't support get_activity_root()
- datapath = \
- "/home/olpc/.sugar/default/org.laptop.TurtleArtActivity/instance"
+ datapath = os.path.join( \
+ os.environ['HOME'], \
+ ".sugar/default/org.laptop.TurtleArtActivity/instance")
html_file = os.path.join(datapath, "taportfolio.html")
f = file(html_file, "w")
@@ -558,8 +563,9 @@ class SaveAsToolbar(gtk.Toolbar):
datapath = os.path.join(activity.get_activity_root(), "instance")
except:
# early versions of Sugar (656) didn't support get_activity_root()
- datapath = \
- "/home/olpc/.sugar/default/org.laptop.TurtleArtActivity/instance"
+ datapath = os.path.join( \
+ os.environ['HOME'], \
+ ".sugar/default/org.laptop.TurtleArtActivity/instance")
#Write the actual file to the data directory of this activity's root.
file_path = os.path.join(datapath, filename)
diff --git a/taexporthtml.py b/taexporthtml.py
index f3f7fbb..7fa0748 100644
--- a/taexporthtml.py
+++ b/taexporthtml.py
@@ -33,8 +33,9 @@ def save_html(self, tw, embed_flag=True):
datapath = os.path.join(activity.get_activity_root(), "instance")
except:
# early versions of Sugar (656) didn't support get_activity_root()
- datapath = \
- "/home/olpc/.sugar/default/org.laptop.TurtleArtActivity/instance"
+ datapath = os.path.join( \
+ os.environ['HOME'], \
+ ".sugar/default/org.laptop.TurtleArtActivity/instance")
# dictionary defines the html wrappers around template elements
# start of block, end of block
diff --git a/talogo.py b/talogo.py
index 250512f..d5dce93 100644
--- a/talogo.py
+++ b/talogo.py
@@ -498,12 +498,12 @@ def lcNew(tw):
# this dictionary is used to define the relative size and postion of
# template elements (w, h, x, y, dx, dy, dx1, dy1...)
lc.templates = {
- 'tp1': (0.5, 0.5, 0.125, 0.125, 1, 0),
- 'tp2': (0.5, 0.5, 0.125, 0.125, 1, 1.05),
- 'tp3': (1, 1, 0.125, 0.125, 0, 0.1),
- 'tp6': (0.45, 0.45, 0.125, 0.125, 1, 1.05),
- 'tp7': (0.45, 0.45, 0.125, 0.125, 1, 1.05),
- 'tp8': (0.9, 0.9, 0.125, 0.125, 0, 0),
+ 'tp1': (0.5, 0.5, 0.0625, 0.125, 1.05, 0),
+ 'tp2': (0.5, 0.5, 0.0625, 0.125, 1.05, 1.05),
+ 'tp3': (1, 1, 0.0625, 0.125, 0, 0.1),
+ 'tp6': (0.45, 0.45, 0.0625, 0.125, 1.05, 1.05),
+ 'tp7': (0.45, 0.45, 0.0625, 0.125, 1.05, 1.05),
+ 'tp8': (0.9, 0.9, 0.0625, 0.125, 0, 0),
'insertimage': (0.333, 0.333)
}
@@ -599,7 +599,7 @@ def show_template1(lc, title, media):
draw_title(lc,title,x,y)
if media[0:5] == 'media':
show_picture(lc, media, x, y, w, h)
- show_description(lc, media, x+dx, y+dy, w, h)
+ show_description(lc, media, x+dx, y+dy, w-30, h)
# title, two images (horizontal), two descriptions
def show_template2(lc, title, media1, media2):
@@ -610,7 +610,7 @@ def show_template2(lc, title, media1, media2):
show_description(lc, media1, x, y+dy, w, h)
if media2[0:5] == 'media':
show_picture(lc, media2, x+dx, y, w, h)
- show_description(lc, media2, x+dx, y+dy, w, h)
+ show_description(lc, media2, x+dx, y+dy, w-30, h)
# title and seven bullets
def show_template3(lc, title, s1, s2, s3, s4, s5, s6, s7):
@@ -642,10 +642,10 @@ def show_template6(lc, title, media1, media2):
draw_title(lc,title,x,y)
if media1[0:5] == 'media':
show_picture(lc, media1, x, y, w, h)
- show_description(lc, media1, x+dx, y, w, h)
+ show_description(lc, media1, x+dx, y, w-30, h)
if media2[0:5] == 'media':
show_picture(lc, media2, x, y+dy, w, h)
- show_description(lc, media2, x+dx, y+dy, w, h)
+ show_description(lc, media2, x+dx, y+dy, w-30, h)
# title and four images
def show_template7(lc, title, media1, media2, media3, media4):
diff --git a/tasetup.py b/tasetup.py
index f84dec3..30cb79c 100644
--- a/tasetup.py
+++ b/tasetup.py
@@ -305,7 +305,9 @@ def load_image(path, dir, file):
datapath = os.path.join(activity.get_activity_root(), "data")
except:
# early versions of Sugar (656) didn't support get_activity_root()
- datapath = "/home/olpc/.sugar/default/org.sugarlabs.TAPortfolioActivity/data"
+ datapath = os.path.join( \
+ os.environ['HOME'], \
+ ".sugar/default/org.laptop.TurtleArtActivity/data")
# first try to open the cached image
# if you fail, open the .svg file and cache the result as png
diff --git a/tawindow.py b/tawindow.py
index 573c903..e68921c 100644
--- a/tawindow.py
+++ b/tawindow.py
@@ -116,7 +116,8 @@ def buttonpress_cb(win, event, tw):
x, y = xy(event)
button_press(tw, event.get_state()&gtk.gdk.CONTROL_MASK, x, y)
# if sharing, send button press
- if hasattr(tw.activity, 'chattube') and tw.activity.chattube is not None:
+ if hasattr(tw, 'activity') and \
+ hasattr(tw.activity, 'chattube') and tw.activity.chattube is not None:
# print "sending button pressed"
if event.get_state()&gtk.gdk.CONTROL_MASK is True:
tw.activity._send_event("p:"+str(x)+":"+str(y)+":"+'T')
@@ -157,11 +158,13 @@ def block_selector_pressed(tw,x,y):
def hideshow_palette(tw,state):
if state is False:
tw.palette == False
- tw.activity.projectToolbar.do_hidepalette()
+ if hasattr(tw,'activity'):
+ tw.activity.projectToolbar.do_hidepalette()
hide_palette(tw)
else:
tw.palette == True
- tw.activity.projectToolbar.do_showpalette()
+ if hasattr(tw,'activity'):
+ tw.activity.projectToolbar.do_showpalette()
show_palette(tw)
def show_palette(tw):
@@ -268,8 +271,6 @@ def turtle_pressed(tw,x,y):
def move_cb(win, event, tw):
x,y = xy(event)
mouse_move(tw, x, y)
-# if hasattr(tw.activity, 'chattube')and tw.activity.chattube is not None:
-# tw.activity._send_event("m:"+str(x)+":"+str(y))
return True
def mouse_move(tw, x, y, verbose=False, mdx=0, mdy=0):
@@ -323,19 +324,22 @@ def mouse_move(tw, x, y, verbose=False, mdx=0, mdy=0):
def buttonrelease_cb(win, event, tw):
x,y = xy(event)
button_release(tw, x, y)
- if hasattr(tw.activity, 'chattube') and tw.activity.chattube is not None:
+ if hasattr(tw, 'activity') and \
+ hasattr(tw.activity, 'chattube') and tw.activity.chattube is not None:
# print "sending release button"
tw.activity._send_event("r:"+str(x)+":"+str(y))
return True
def button_release(tw, x, y, verbose=False):
- if tw.dx != 0 or tw.dy != 0 and \
- hasattr(tw.activity, 'chattube') and tw.activity.chattube is not None:
- if verbose:
- print "processing accumulated move: " + str(tw.dx) + " " + str(tw.dy)
- tw.activity._send_event("m:"+str(tw.dx)+":"+str(tw.dy))
- tw.dx = 0
- tw.dy = 0
+ if tw.dx != 0 or tw.dy != 0:
+ if hasattr(tw, 'activity') and \
+ hasattr(tw.activity, 'chattube') and \
+ tw.activity.chattube is not None:
+ if verbose:
+ print "processing move: " + str(tw.dx) + " " + str(tw.dy)
+ tw.activity._send_event("m:"+str(tw.dx)+":"+str(tw.dy))
+ tw.dx = 0
+ tw.dy = 0
if verbose:
print "processing remote button release: " + str(x) + " " + str(y)
if tw.draggroup == None:
@@ -504,7 +508,7 @@ def keypress_cb(area, event, tw):
alt_mask = False
results = key_press(tw, alt_mask, keyname)
# keyname = unichr(gtk.gdk.keyval_to_unicode(event.keyval))
- if keyname is not None and \
+ if keyname is not None and hasattr(tw, 'activity') and \
hasattr(tw.activity, 'chattube') and tw.activity.chattube is not None:
# print "key press"
if event.get_state()&gtk.gdk.MOD4_MASK:
@@ -520,10 +524,11 @@ def key_press(tw, alt_mask, keyname, verbose=False):
print "processing remote key press: " + keyname
tw.keypress = keyname
if alt_mask is True and tw.selected_block==None:
- if keyname=="i":
+ if keyname=="i" and hasattr(tw, 'activity'):
tw.activity.waiting_for_blocks = True
tw.activity._send_event("i") # request sync for sharing
-
+ elif keyname=="p":
+ hideshow_button(tw)
return True
if tw.selected_block==None:
return False