Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDaniel Francis <francis@sugarlabs.org>2012-09-15 21:46:19 (GMT)
committer Daniel Francis <francis@sugarlabs.org>2012-09-15 21:46:19 (GMT)
commit0736b85e86f73da4ac719357e11a2a3b2e9248ce (patch)
tree916240e3715af3f7240ac10f421e8acedb3107d6
parent5dfc09b741faebf99b15adbac4a00550f3a4a476 (diff)
Update to sweetener-devel version.
-rw-r--r--Makefile3
-rw-r--r--activity.py6
-rwxr-xr-xapplication.py (renamed from graph-plotter.py)35
-rw-r--r--desktop/sweetener/basic_options.py40
-rw-r--r--desktop/sweetener/coloritem.py15
-rw-r--r--desktop/sweetener/colors.py9
-rw-r--r--desktop/sweetener/help.py10
-rwxr-xr-xgraph-plotter11
-rw-r--r--makescripts/command.py29
-rw-r--r--makescripts/desktop_luncher.py16
-rw-r--r--makescripts/systeminstall.py52
-rw-r--r--options.py (renamed from toolbars.py)0
12 files changed, 176 insertions, 50 deletions
diff --git a/Makefile b/Makefile
index 100721b..04eca7b 100644
--- a/Makefile
+++ b/Makefile
@@ -8,7 +8,8 @@ activity: activity.info mimetypes.xml
if [ -f mimetypes.xml ]; then cp mimetypes.xml activity; fi
app-entry.desktop: app-icon
python makescripts/desktop_luncher.py
-local: app-entry.desktop mimetypes.xml
+install: app-entry.desktop mimetypes.xml
+ python makescripts/systeminstall.py
mv app-entry.desktop $N.desktop
xdg-desktop-menu install $N.desktop
if [ -f mimetypes.xml ]; then cp mimetypes.xml $M.xml; xdg-mime install $M.xml; python makescripts/svg2png.py activity/$M.svg ./mimetype.png; xdg-icon-resource install --context mimetypes --size 48 mimetype.png $M; fi
diff --git a/activity.py b/activity.py
index 7f6891b..c868c66 100644
--- a/activity.py
+++ b/activity.py
@@ -20,6 +20,7 @@
import tempfile
import os
+os.environ['PROGRAMRUNNING'] = 'SUGAR'
import logging
logging.basicConfig(level=logging.DEBUG)
logger = logging.getLogger('graph-plotter')
@@ -37,10 +38,9 @@ except ImportError:
sys.path.append(os.path.abspath('./sugar'))
import sweetener
-os.environ['DATA_DIR'] = os.path.abspath(os.path.join(
- os.environ['SUGAR_BUNDLE_PATH'], 'data'))
+os.environ['DATA_DIR'] = os.path.abspath('./data')
-from toolbars import Options
+from options import Options
from canvas import Canvas
diff --git a/graph-plotter.py b/application.py
index ad60b83..fe11039 100755
--- a/graph-plotter.py
+++ b/application.py
@@ -30,7 +30,7 @@ glib.set_prgname(appname)
glib.set_application_name(appname)
import gtk
-from toolbars import Options
+from options import Options
from canvas import Canvas
this_dir = os.path.split('__file__')[:-1]
@@ -100,7 +100,7 @@ class UnfullscreenButton(gtk.Window):
self._reposition()
-class GraphPlotter(gtk.Window):
+class Application(gtk.Window):
def __init__(self):
gtk.Window.__init__(self)
self.save_type = info.io_mode
@@ -132,10 +132,12 @@ class GraphPlotter(gtk.Window):
self._vbox.show()
self._is_fullscreen = False
+ self.set_events(gtk.gdk.ALL_EVENTS_MASK)
self.connect('motion-notify-event', self.motion_cb)
- self.connect('expose-event', self.expose_event)
+ self.canvas.connect('expose-event', self.expose_event)
def expose_event(self, widget, event):
+ logger.debug('Exposing')
if not self.started:
if self.file_path != None:
self.canvas.read_file(self.file_path)
@@ -195,6 +197,9 @@ class GraphPlotter(gtk.Window):
self.set_title(appname)
def stop(self):
+ if info.io_mode == info.CONFIG:
+ self.file_path = os.path.join(os.environ['HOME'], '.' + info.lower_name)
+ self.save()
gtk.main_quit()
def open(self):
@@ -237,18 +242,24 @@ class GraphPlotter(gtk.Window):
if __name__ == '__main__':
logger.debug('Initializing Graph Plotter')
import sys
- if len(sys.argv) > 1:
- logger.debug('Open from args %s' % sys.argv[1])
- if os.path.exists(sys.argv[1]):
- file_path = sys.argv[1]
- logger.debug('Found file')
+ if info.io_mode == info.DOCUMENT:
+ if len(sys.argv) > 1:
+ logger.debug('Open from args %s' % sys.argv[1])
+ if os.path.exists(sys.argv[1]):
+ file_path = sys.argv[1]
+ logger.debug('Found file')
+ else:
+ file_path = None
+ logger.error('Could not find file')
else:
file_path = None
- logger.error('Could not find file')
+ logger.debug('Create new file')
else:
- file_path = None
- logger.debug('Create new file')
- window = GraphPlotter()
+ if os.path.exists(os.path.join(os.environ['HOME'], '.' + info.lower_name)):
+ file_path = os.path.join(os.environ['HOME'], '.' + info.lower_name)
+ else:
+ file_path = None
+ window = Application()
window.file_path = file_path
window.show()
gtk.main()
diff --git a/desktop/sweetener/basic_options.py b/desktop/sweetener/basic_options.py
index b8b656f..83636e1 100644
--- a/desktop/sweetener/basic_options.py
+++ b/desktop/sweetener/basic_options.py
@@ -1,6 +1,7 @@
-#!/usr/bin/env python
-# -*- coding: utf-8 -*-
-#
+"""
+This module provides a "File" menu at desktops and an ActivityToolbar at Sugar.
+See class BasicOptions.
+"""
# Copyright (C) 2012 S. Daniel Francis <francis@sugarlabs.org>
#
# This program is free software; you can redistribute it and/or modify
@@ -30,7 +31,14 @@ CONFIG = 1
class BasicOptions(ItemGroup):
+ """This class has the basic options for your program."""
def __init__(self, activity, box, export_formats=None):
+ """Create and append the basic items to a ItemBox.
+ activity -- The activity used as argument at Canvas and Options.
+ box -- sweetener.itembox.ItemBox of the activity.
+ export_formats -- list of tuples or none. Each tuple should have:
+ ['generic_type', 'mime_type', 'mime_filter', 'filter_name']
+ """
ItemGroup.__init__(self, box, _('_File'), None)
if activity.save_type != CONFIG:
@@ -47,17 +55,17 @@ class BasicOptions(ItemGroup):
save_as_option = Item(gtk.STOCK_SAVE_AS)
save_as_option.connect('activate', lambda w: activity.save_as())
self.append_item(save_as_option)
- if export_formats != None:
- if len(export_formats) == 1:
- stock.register('sweetener-%s' % export_formats[0][1],
- _('Export as %s') % export_formats[0][0],
- None, export_formats[0][1].replace('/',
- '-'))
- export = Item('sweetener-%s' % export_formats[0][1])
- export.connect('activate', activity.export,
- export_formats[0])
- self.append_item(export)
+ if export_formats != None:
+ if len(export_formats) == 1:
+ stock.register('sweetener-%s' % export_formats[0][1],
+ _('Export as %s') % export_formats[0][0],
+ None, export_formats[0][1].replace('/',
+ '-'))
+ export = Item('sweetener-%s' % export_formats[0][1])
+ export.connect('activate', activity.export,
+ export_formats[0])
+ self.append_item(export)
self.append_separator()
- _quit = Item(gtk.STOCK_QUIT)
- _quit.connect('activate', lambda w: activity.stop())
- self.append_item(_quit)
+ _quit = Item(gtk.STOCK_QUIT)
+ _quit.connect('activate', lambda w: activity.stop())
+ self.append_item(_quit)
diff --git a/desktop/sweetener/coloritem.py b/desktop/sweetener/coloritem.py
index d71d37e..1db0e69 100644
--- a/desktop/sweetener/coloritem.py
+++ b/desktop/sweetener/coloritem.py
@@ -1,6 +1,4 @@
-#!/usr/bin/env python
-# -*- coding: utf-8 -*-
-#
+"""The color item gives the user the posibility to choice a colour."""
# Copyright (C) 2012 S. Daniel Francis <francis@sugarlabs.org>
#
# This program is free software; you can redistribute it and/or modify
@@ -29,15 +27,26 @@ from item import Item
class ColorItem(Item):
+ """Color Selecting interface.
+ In Sugar it creates a sugar.graphics.colorbutton.ColorToolButton.
+ In other desktops it's a sweetener.item.Item connected to a
+ gtk.ColorSelectionDialog.
+ """
__gsignals__ = {'updated': (gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE,
(gobject.TYPE_STRING,))}
def __init__(self, parent=None, important=False):
+ """Constructor.
+ parent -- A window where focus the dialog or None.
+ important -- bool , if it's True, in desktops a ToolItem will be
+ appended to the Toolbar.
+ """
Item.__init__(self, gtk.STOCK_SELECT_COLOR, important)
self.parent = parent
self.color = '#FFFFFF'
def set_color(self, color):
+ """color -- RGB color"""
self.color = color
def _color_changed_cb(self, widget):
diff --git a/desktop/sweetener/colors.py b/desktop/sweetener/colors.py
index 3b5d938..d825f4c 100644
--- a/desktop/sweetener/colors.py
+++ b/desktop/sweetener/colors.py
@@ -1,6 +1,6 @@
-#!/usr/bin/env python
-# -*- coding: utf-8 -*-
-#
+"""Color handling.
+Utilities for handle color data and conversions.
+"""
# Copyright (C) 2012 S. Daniel Francis <francis@sugarlabs.org>
#
# This program is free software; you can redistribute it and/or modify
@@ -23,6 +23,9 @@ logger = logging.getLogger('colors')
def color2string(color):
+ """Converts a GdkColor to a RGB string
+ color -- gtk.gdk.Color
+ """
color_string = ["#"]
color_string.append("%02x" % (color.red / 256))
color_string.append("%02x" % (color.green / 256))
diff --git a/desktop/sweetener/help.py b/desktop/sweetener/help.py
index 1fef4d3..a43c887 100644
--- a/desktop/sweetener/help.py
+++ b/desktop/sweetener/help.py
@@ -1,6 +1,4 @@
-#!/usr/bin/env python
-# -*- coding: utf-8 -*-
-#
+""" 'Help' and 'About' information."""
# Copyright (C) 2012 S. Daniel Francis <francis@sugarlabs.org>
#
# This program is free software; you can redistribute it and/or modify
@@ -49,7 +47,13 @@ class AboutItem(Item):
class Help(ItemGroup):
+ """
+ This class makes the help menu on desktops and a HelpButton on Sugar.
+ """
def __init__(self, box):
+ """Constructor.
+ box -- sweetener.ItemBox where append it
+ """
title = gtk.stock_lookup(gtk.STOCK_HELP)[1]
ItemGroup.__init__(self, box, title, 'toolbar-help')
stock.register('sweetener-help-contents', _('Contents'),
diff --git a/graph-plotter b/graph-plotter
index 4050b30..aede908 100755
--- a/graph-plotter
+++ b/graph-plotter
@@ -1,12 +1,12 @@
#!/usr/bin/env python
-#
+#
# Copyright 2012 Daniel Francis <francis@sugarlabs.org>
-#
+#
# 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
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
-#
+#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
@@ -28,5 +28,8 @@ os.chdir(current_list_dir)
sys.path.append(os.path.join(current_list_dir, 'desktop'))
os.environ['PYTHONPATH'] = ':'.join(sys.path)
os.environ['DATADIR'] = 'programabspath/data'
+os.environ['TRANSLATIONDIR'] = 'programabspath/locale'
+os.environ['PROGRAMRUNNING'] = 'DESKTOP'
os.environ['ICONDIR'] = 'programabspath/desktop/icons'
-os.system('python graph-plotter.py %s' % (('"%s"' % sys.argv[1]) if len(sys.argv) > 1 else ''))
+os.system('python application.py %s' % (('"%s"' % sys.argv[1])
+ if len(sys.argv) > 1 else ''))
diff --git a/makescripts/command.py b/makescripts/command.py
new file mode 100644
index 0000000..d6e2a0c
--- /dev/null
+++ b/makescripts/command.py
@@ -0,0 +1,29 @@
+#!/usr/bin/env python
+#
+# Copyright 2012 Daniel Francis <francis@sugarlabs.org>
+#
+# 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
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+# MA 02110-1301, USA.
+#
+
+import sys
+import os
+name = os.path.split(sys.argv[0])[-1]
+os.environ['DATADIR'] = '/usr/share/%s' % name
+os.environ['PROGRAMRUNNING'] = 'DESKTOP'
+os.environ['ICONDIR'] = '/usr/share/%s/icons' % name
+os.environ['TRANSLATIONDIR'] = '/usr/share/locale'
+os.system('python /usr/share/%s/application.py %s' % (name,
+ ('"%s"' % sys.argv[1]) if len(sys.argv) > 1 else ''))
diff --git a/makescripts/desktop_luncher.py b/makescripts/desktop_luncher.py
index 89aaad9..a2bb02d 100644
--- a/makescripts/desktop_luncher.py
+++ b/makescripts/desktop_luncher.py
@@ -20,17 +20,23 @@
import sys
import os
-appdir = os.path.abspath('./')
-sys.path.append(appdir)
-
+import pwd
+sys.path.append(os.path.abspath('./'))
import info
+user = pwd.getpwuid(os.getuid()).pw_name
+execdir = '/usr/bin' if user == 'root' else os.path.abspath('./')
+appdir = '/usr/share/%s' % info.lower_name if user ==\
+ 'root' else os.path.abspath('./')
desktop_file = open('app-entry.desktop', 'w')
string = '[Desktop Entry]\nEncoding=UTF-8\n'
-string += 'Name=' +info.name
+string += 'Name=' + info.name
string += '\nGenericName=' + info.generic_name
string += '\nComment=' + info.description
-string += '\nExec=' + os.path.join(appdir, info.lower_name) + ' %U'
+if user == 'root':
+ string += '\nExec=/usr/bin/command %U'.replace('command', info.lower_name)
+else:
+ string += '\nExec=' + os.path.join(appdir, info.lower_name) + ' %U'
string += '\nIcon=' + os.path.join(appdir, info.lower_name + '.png')
string += '\nTerminal=false'
string += '\nCategories=' + ';'.join(info.categories)
diff --git a/makescripts/systeminstall.py b/makescripts/systeminstall.py
new file mode 100644
index 0000000..faad71e
--- /dev/null
+++ b/makescripts/systeminstall.py
@@ -0,0 +1,52 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+#
+# Copyright (C) 2012 S. Daniel Francis <francis@sugarlabs.org>
+#
+# 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
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+# MA 02110-1301, USA.
+
+import sys
+import os
+import pwd
+sys.path.append(os.path.abspath('./'))
+import info
+user = pwd.getpwuid(os.getuid()).pw_name
+
+if user == 'root':
+ os.system('cp makescripts/command.py /usr/bin/%s' % info.lower_name)
+ try:
+ os.mkdir('/usr/share/%s' % info.lower_name)
+ os.mkdir('/usr/share/%s/icons' % info.lower_name)
+ except:
+ pass
+ os.system('cp -R desktop/sweetener /usr/share/%s/sweetener' %\
+ info.lower_name)
+ os.system('cp data/* /usr/share/%s/' % info.lower_name)
+ os.system('cp *.py /usr/share/%s/' % info.lower_name)
+ os.system('cp desktop/icons/*.svg /usr/share/%s/icons' %\
+ info.lower_name)
+ os.system('cp %s.png /usr/share/%s/' % (info.lower_name,
+ info.lower_name))
+ for i in os.listdir('locale'):
+ if not os.path.exists(os.path.join('/usr/share/locale', i)):
+ os.mkdir(os.path.join('/usr/share/locale', i))
+ if not os.path.exists(os.path.join('/usr/share/locale', i,
+ 'LC_MESSAGES')):
+ os.mkdir(os.path.join('/usr/share/locale', i,
+ 'LC_MESSAGES'))
+ os.system(
+ 'cp locale/%n%/LC_MESSAGES/*.mo /usr/share/locale/%n%/LC_MESSAGES/'.replace(
+ '%n%', i))
diff --git a/toolbars.py b/options.py
index d5cbfc0..d5cbfc0 100644
--- a/toolbars.py
+++ b/options.py