Commit Graph

1169 Commits

Author SHA1 Message Date
Manish
2b0f65a9ee Fixes "Logs are not line buffered" #868 issue in sugar repo
Reason why it was working in python 2 is because this file is
added only when switched to python 3. Compare
[logger.py](https://github.com/sugarlabs/sugar-toolkit-gtk3/blob/v0.95.2/src/sugar3/logger.py)
file in sugar3 directory of v0.95.2 with
[sugar directory](https://github.com/sugarlabs/sugar-toolkit-gtk3/tree/v0.95.1/src/sugar)
of v0.95.1
2020-05-25 23:18:50 +10:00
Ibiam Chihurumnaya
8c976bd56a xml.etree.CElementTree deprecated
Any activity fails to build with Python 3.9;

Traceback (most recent call last):
  File "setup.py", line 19, in <module>
    from sugar3.activity import bundlebuilder
  File "sugar3/activity/bundlebuilder.py", line 44, in <module>
    import xml.etree.cElementTree as ET
ModuleNotFoundError: No module named 'xml.etree.cElementTree'

See https://docs.python.org/3.9/whatsnew/3.9.html#removed
"The xml.etree.cElementTree module has been removed."

Fixes https://bugzilla.redhat.com/show_bug.cgi?id=1817644

Signed-off-by: Ibiam Chihurumnaya <ibiamchihurumnaya@gmail.com>
Signed-off-by: James Cameron <quozl@laptop.org>
2020-03-28 14:12:05 +11:00
Ryan Van
72d36cc964 Add RedoButton accelerator
- use ctrl+y to be consistent with Write Activity,

- a design discussion gave no responses,
  http://lists.sugarlabs.org/archive/sugar-devel/2020-March/057832.html

Signed-off-by: James Cameron <quozl@laptop.org>
2020-03-12 18:35:10 +11:00
Ibiam Chihurumnaya
ecf335c19c Add --from-code parameter to xgettext for a python3 activity
Signed-off-by: Ibiam Chihurumnaya <ibiamchihurumnaya@gmail.com>
2020-02-24 12:53:28 +11:00
Srevin Saju
6fc675e848 Fix icon size in ColorButton
ColorButton did not show button icon, and swatches were too small
making it almost unusable. Color chooser toolbar had been using
Gtk.IconSize.LARGE_TOOLBAR which return 0 as size.
style.GRID_CELL_SIZE was used as size reference
2020-01-23 10:16:59 +11:00
Bas Hulsken
39b12bbf7f Fix sugar-install-bundle - Python 2
On Python 2 is seen
ConfigParser instance has no attribute 'read_string'

Regression introduced by 2018c930ad

Fixes https://github.com/sugarlabs/sugar-toolkit-gtk3/issues/438

Signed-off-by: James Cameron <quozl@laptop.org>
2020-01-06 11:23:10 +11:00
Martin Abente Lahaye
5de5116ea2 speech: Check if speech schema is present
The schema is provided by the sugar shell package and
in scenarios where that package is not present trying
to reference ends up in segfaults, e.g. flatpak apps.
2019-12-30 12:11:39 +11:00
Srevin Saju
7e4264aeab Fix is comparison against literals : Python3.8 Syntax Warning . Fixes #434 2019-12-28 11:19:46 +11:00
Srevin Saju
139370d888 Correct SyntaxWarning - Python3.8 2019-12-28 11:19:46 +11:00
James Cameron
88adb38a42 Fix RuntimeError: could not create signal for _closing
On Ubuntu 20.04 with GTK 3.24.13, importing sugar3.activity.activity
fails with RuntimeError: could not create signal for _closing, preceeded
by an assertion is_valid_signal_name failed.

Cause is upstream 89f955d ("gsignal: Canonicalise signal names at
installation time ") which requires application signal names to not
start with a hyphen or underscore.

Remove the prefix from our signal name.  The signal remains reserved and
private to the Activity class.
2019-12-27 20:23:34 +11:00
James Cameron
aca045bde2 Reduce width of exception handler for linfo file
ParsingError is only expected during read.
2019-12-27 14:15:39 +11:00
James Cameron
2018c930ad Fix sugar-install-bundle
Traceback (most recent call last):
  File "/usr/bin/sugar-install-bundle", line 21, in <module>
    bundle = ActivityBundle(name)
  File "/usr/lib/python3.7/dist-packages/sugar3/bundle/activitybundle.py", line 118, in __init__
    info_file = self.get_file('activity/activity.info')
  File "/usr/lib/python3.7/dist-packages/sugar3/bundle/bundle.py", line 126, in get_file
    f = six.StringIO(data)
TypeError: initial_value must be str or None, not bytes

Fix by always reading bundle and metadata as Bytes, and converting to
String before passing to ConfigParser.

Did not fix ContentBundle, as it has been unused for some time, and was
only kept for use with OLPC XO and Python 2.
2019-12-27 14:10:28 +11:00
James Cameron
15caa5478d Demote speech module utterance logging 2019-09-11 14:58:09 +10:00
James Cameron
c911c6cb30 Port to Python 3 - preview metadata is bytes
Preview metadata in 0.114 and earlier was returned by datastore client
as a dbus.ByteArray.

Regression introduced by aa8a5e7 ("Port from Python 2 to six").

Traceback (most recent call last):
  File "/usr/lib/python3.7/dist-packages/jarabe/journal/expandedentry.py", line 378, in _create_preview
    pixbuf = get_preview_pixbuf(metadata.get('preview', ''))
  File "/usr/lib/python3.7/dist-packages/sugar3/graphics/objectchooser.py", line 85, in get_preview_pixbuf
    preview_data = base64.b64decode(preview_data)
  File "/usr/lib/python3.7/base64.py", line 87, in b64decode
    return binascii.a2b_base64(s)
binascii.Error: Invalid base64-encoded string: number of data characters (237) cannot be 1 more than a multiple of 4

Related to
https://github.com/sugarlabs/sugar-datastore/issues/16
2019-09-04 07:38:52 +10:00
James Cameron
90c2539135 Fix unnecessary whitespace in warning
Regression introduced by 3b28597 ("flake8 fixes").

Fixes https://github.com/sugarlabs/sugar-toolkit-gtk3/issues/424
2019-08-28 17:28:37 +10:00
James Cameron
381c9b1b61 Fix install TypeError
Activity install target used by downstream activity packaging did fail
with;

Traceback (most recent call last):
  File "setup.py", line 21, in <module>
    bundlebuilder.start()
  File "/usr/lib/python3.7/dist-packages/sugar3/activity/bundlebuilder.py", line 633, in start
    globals()['cmd_' + options.command](config, options)
  File "/usr/lib/python3.7/dist-packages/sugar3/activity/bundlebuilder.py", line 513, in cmd_install
    options.install_desktop_file)
  File "/usr/lib/python3.7/dist-packages/sugar3/activity/bundlebuilder.py", line 290, in install
    for f in self.get_files_in_git():
  File "/usr/lib/python3.7/dist-packages/sugar3/activity/bundlebuilder.py", line 209, in get_files_in_git
    stdout.strip('\n').split('\n')]
TypeError: a bytes-like object is required, not 'str'

Workaround was to hide .git directory.

Cause was subprocess pipe returning a bytes-like object in Python 3.

Regression introduced by incomplete ed46c21 ("Port to six").

Fixes https://github.com/sugarlabs/sugar-toolkit-gtk3/issues/426
2019-08-28 13:36:44 +10:00
James Cameron
7b85b807b2 Fix AppStream metadata warning
* wrong pydoc module reference,

* was too verbose.
2019-08-28 13:36:11 +10:00
James Cameron
6e517aa3c7 Clean activity logs successful completion
Status zero is normal, so don't report it.

Also don't print the log_file object.

Changes log messages such as this;

Exited with status 0, pid 3765 data (<_io.TextIOWrapper name=13 mode='w'
encoding='UTF-8'>, '5312a7726254b3b0b9a15267c54600aec9db187e')

To this;

Normal successful completion, pid 3765 activity_id 5312a7726254b3b0b9a15267c54600aec9db187e
2019-08-15 16:25:57 +10:00
James Cameron
ec753badbc Fix whitespace in AppStream metadata warning
Encountered on Hello World activity.
2019-08-14 16:48:06 +10:00
James Cameron
a62bb885fc Port to Python 3 - use rb for message catalog file
Reported and patch proposed by Bas Hulsken.

Fixes https://github.com/sugarlabs/sugar-toolkit-gtk3/issues/425

Signed-off-by: James Cameron <quozl@laptop.org>
2019-08-12 07:49:06 +10:00
Ibiam Chihurumnaya
fc81121f19 Dash in signal names
GLib accepts signal names with dash or underscore and
documents the signals with a dash.

Use of signal names in Sugar was mixed, change to using
dash only.

No functional change.
2019-07-30 10:05:11 +10:00
Ibiam Chihurumnaya
b74c3570d5 Fix NameError introduced by 23e664df05 2019-07-25 01:29:35 +05:30
James Cameron
23e664df05 sugar3.speech - expose player pipeline
Expose the GstSpeechPlayer pipeline so that the activities may add their
own handlers.

A quick way to get the rest of the gst-plugins-espeak signals available.
2019-07-24 17:03:48 +10:00
Ibiam Chihurumnaya
9a6c9ce69c sugar3.speech - expose mark messages
Mark messages can be used for text highlight.

Signed-off-by: James Cameron <quozl@laptop.org>
2019-07-24 17:03:48 +10:00
Aniket21mathur
5043d53e7b Typecast into "int" 2019-07-17 17:32:05 +10:00
Aniket21mathur
e4725ad196 Fix utf encoding error via six 2019-07-16 09:59:02 +10:00
Aniket21mathur
490a602367 Fix "target" attribute calls via six 2019-07-16 09:59:02 +10:00
Aniket21mathur
ed46c219a9 Port to six 2019-07-16 09:59:02 +10:00
Aniket21mathur
3b28597486 flake8 fixes 2019-07-09 14:54:57 +10:00
James Cameron
f5c86da271 flake8 fixes (several remain to be fixed) 2019-07-06 14:48:05 +10:00
Aniket Mathur
88ea8e1f4f Port to TelepathyGLib
Co-authored-by: tonadev <tonadevv@gmail.com> [initial port]
Co-authored-by: Aniket21mathur <aniketmathur320@gmail.com> [further work]
Co-authored-by: James Cameron <quozl@laptop.org> [minimising changes]
2019-07-06 14:11:18 +10:00
James Cameron
12a899f374 Defer Gtk.Window.iconify
Defer iconify call to after the activity has been shown.  Remember the
iconify call was requested, and make the call just prior to entering the
main loop.

On Ubuntu 18.04 with Metacity 3.32.0 the Journal does appear over the
Home View on Sugar start on a VM with two virtual CPUs, yet the previous
fix in Metacity (074af8f) is present.  This is suggestive of a race
condition.

Tests with a minimal GTK reproducer shows order of three specific calls
is critical to success of iconify.  The ordering and results are;

* iconify, maximize, show; not iconified,

* maximize, iconify, show; not iconified,

* iconify, show, maximize; not iconified,

* maximize, show, iconify; app with focus will flicker, iconified,

* show, maximize, iconify; app with focus may flicker, iconified,

* show, iconify, maximize; app with focus may flicker, iconified,

Sugar Toolkit combined with Journal uses the "maximize, iconify, show"
ordering.  Using a Hello World activity with a call to iconify, the new
activity is not iconified.

When changed to "mazimise, show, iconify" ordering, there is no flicker
of the app in focus, and the new activity is iconified.
2019-06-05 12:33:31 +05:30
James Cameron
481e0bac80 Fix collaboration call_async
Port to Python 3 via Six aa8a5e7 did introduce a regression during
activity collaboration on both sharing and joining.

Fixes https://github.com/sugarlabs/sugar-toolkit-gtk3/issues/406
2019-04-03 16:23:20 +11:00
James Cameron
2453d13b03 Clean up activity environment variables
Ensure environment variables needed by Python activities are available
in each of the three supported scenarios;

- started from Sugar,

- started from Terminal inside Sugar,

- started by other desktop environments.

Variables always available are;

SUGAR_ACTIVITY_ROOT
SUGAR_BUNDLE_ID
SUGAR_BUNDLE_NAME
SUGAR_BUNDLE_PATH
SUGAR_BUNDLE_VERSION

Variables also available when started from Sugar are;

SUGAR_ACTIVITIES_HIDDEN
SUGAR_APISOCKET_KEY
SUGAR_APISOCKET_PORT
SUGAR_GROUP_LABELS
SUGAR_HOME
SUGAR_MIME_DEFAULTS
SUGAR_PROFILE
SUGAR_SCALING
SUGAR_VERSION

Variables also available when started from Terminal are;

SUGAR_TERMINAL_VERSION

Other changes;

- use os.makedirs in place of distutils.dir_util.mkpath,

- avoid redundant setting of SUGAR_BUNDLE_PATH,

- do not set SUGAR_BUNDLE_ID unnecessarily,

- add explanatory comment,

Tested on Ubuntu 18.04.

Signed-off-by: James Cameron <quozl@laptop.org>
2019-03-28 15:29:02 +11:00
Pro-Panda
aa8a5e70c4 Port from Python 2 to six
Signed-off-by: James Cameron <quozl@laptop.org>
2019-03-13 14:23:06 +11:00
James Cameron
6345da8e07 docs - move get_activity_root description
When it was moved from the class to the module, the full description did
not move with it.
2019-01-31 08:07:03 +11:00
Frederick Grose
f228909710 get_profile() - Use tuple instead of list.
Fixes fix 39b7e606 handle new OpenSSH DSA key format.
2019-01-02 07:07:26 +11:00
James Cameron
39b7e606df get_profile() - handle new OpenSSH DSA key format
OpenSSH changed the format of the DSA key, and this broke Sugar
connection to Jabber.

Fixes https://github.com/sugarlabs/sugar/issues/814

Fixes http://bugs.sugarlabs.org/ticket/4992
2019-01-01 16:04:54 +11:00
James Cameron
87fcfb62e4 Fedora 18 backport - GLib does not have unix_signal_add 2018-12-26 12:26:12 +11:00
James Cameron
85fc4680e9 Fedora 18 backport - GObject.ParamFlags does not have READWRITE 2018-12-26 12:26:06 +11:00
Vipul Gupta (@vipulgupta2048)
c7a7dcea7d Add to tags
Add new parameters category, categories, website
Update example of browse activity
Add more description of already defined parameters from https://wiki.sugarlabs.org/go/Development_Team/Almanac/Activity_Bundles#.info_file_format

Signed-off-by: Vipul Gupta (@vipulgupta2048) <vipulgupta2048@gmail.com>
2018-10-24 16:49:33 +11:00
James Cameron
13fc98e193 Review: Port from GObject to GLib
Fix a typo in 13a2282.
2018-07-31 17:58:37 +10:00
James Cameron
84a7286986 Review: Port from GObject to GLib
Fix new flake8 issues introduced by cb0d6e2.
2018-07-26 13:11:27 +10:00
Rahul Bothra
13a2282e5e Port from GObject to GLib 2018-07-26 13:11:27 +10:00
James Cameron
6730d129cd Handle SIGINT from Ctrl+C in shell
Used when testing from the shell prompt using sugar-activity{,3}.
When Ctrl+C is pressed, close the activity.

May be used by other processes to request a clean activity stop, but
with save-as enabled may require user input.
2018-07-04 08:51:40 +05:30
Pro-Panda
06a28fae0e use created to send signal on receiving Created signal
Tested-by: Rahul Bothra <f2016015@pilani.bits-pilani.ac.in> # Ubuntu 16.04
2018-06-29 14:33:14 +10:00
James Cameron
e32aea6a4f sugar3/bundle - activity metadata standard rewording
Move definition of bundle identifier from Wiki.
2018-06-28 12:28:59 +10:00
Vipul Gupta (@vipulgupta2048)
47563e678f sugar3/bundle - activity metadata standard
* encourage "url" for either home page or user documentation,

* give examples for categorisation tags, define format,

* make "website" an alias for "url",

* make "category" and "categories" aliases for "tags".

* add the aliases to deprecated list; valid for use, but not encouraged.

Deprecates https://wiki.sugarlabs.org/go/Development_Team/Almanac/Activity_Bundles#.info_file_format

Signed-off-by: Vipul Gupta (@vipulgupta2048) <vipulgupta2048@gmail.com>
Signed-off-by: James Cameron <quozl@laptop.org>
Reviewed-by: Rahul Bothra <f2016015@pilani.bits-pilani.ac.in>
Reviewed-by: Yash Agrawal <yagrawal900@gmail.com>
2018-06-04 07:43:21 +10:00
James Cameron
58224cb15d Fix traceback when an icon name matches a GNOME theme icon
When an icon file name matches a GNOME theme icon;

Traceback (most recent call last):
  File "/usr/lib/python2.7/dist-packages/sugar3/graphics/icon.py", line 214, in _get_attach_points
    cp.readfp(config_file)
  File "/usr/lib/python2.7/ConfigParser.py", line 324, in readfp
    self._read(fp, filename)
  File "/usr/lib/python2.7/ConfigParser.py", line 512, in _read
    raise MissingSectionHeaderError(fpname, lineno, line)
MissingSectionHeaderError: File contains no section headers.

Caused by reading a .png file as if it were config file, in turn
because the icon was expected by the toolkit to be .svg file type.

Regression introduced by f796638.

Fixes https://github.com/sugarlabs/activity-abacus/issues/16
2018-05-24 08:46:58 +05:30
Pro-Panda
5407ae4cdb Remove unused imports 2018-05-21 17:20:29 +10:00