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

Fix: #375 Pressing Enter during title editing saves the title #376

Closed
wants to merge 1 commit into from
Closed

Fix: #375 Pressing Enter during title editing saves the title #376

wants to merge 1 commit into from

Conversation

rahul-bothra
Copy link
Contributor

Fixed in this PR: #375 sugar3.activity.widgets.TitleEntry ignores enter key
Fix: Connected Key-Press event to a function which saves the title on detecting enter

Tested on: Packaged environment (using rdesktop) on Ubuntu 16.04
Activities on which tested:

  • Log
  • Pippy
  • Browse
  • Chat

@quozl kindly review.
Also, please point my mistakes in commit/PR style, if any.

Note: I don't have line:89 in my version of sucrose.
Activities fail to load on adding it, Err: No add_stop_button function in activity.
Works fine without that line

@quozl
Copy link
Contributor

quozl commented Jan 12, 2018

Thanks. Reviewed. Changes requested;

  • commit message is too brief, see our guidance; some of us use git bisect and a good commit message helps greatly,
  • what is your purpose of calling hide then show methods? Should be in commit message.
  • the activate signal of the Gtk.Entry class should be better for this, as it has already detected the key press event; either use activate or explain in commit message why it could not be used,

Yes, you will find your Ubuntu 16.04 packaged environment hard to work in, because it uses Sugar 0.106 and we are now on Sugar 0.112. It causes your line 89 observation. You may either;

  • install the repository over the top of your Ubuntu 16.04 files, see below, or;
  • upgrade Sugar packages only to Ubuntu 18.04 beta versions, or;
  • install a virtual machine of Sugar Live Build.

How to install the sugar-toolkit-gtk3 repository over your Ubuntu 16.04 Sugar Toolkit files

This is a hack. It takes the Python source files of the toolkit and installs them over the top of whatever toolkit you have on your system from the python-sugar3 package. I use a variant of this against VM or lab hardware over SSH, as part of my code editor.

From a clone of the sugar-toolkit-gtk3 repository, type this;

sudo rsync -rv --checksum src/sugar3 /usr/lib/python2.7/dist-packages/

It can be undone by reinstalling the package;

sudo apt-get install --reinstall python-sugar3

Sugar 0.106 shell probably works fine with Sugar 0.112 toolkit, but if it doesn't ...

How to install the sugar repository over your Ubuntu 16.04 Sugar files

there's an equivalent overwrite for the shell repository http://github.com/sugarlabs/sugar ... I don't have time to simplify it, and I'll be absent for the weekend, so here's my upload to lab hardware script;

#!/bin/bash -e

HOST=
PACK=dist-packages
NM=guest
DM=lightdm
RESTART=0
FULL=0

while [[ $# -gt 0 ]]; do
    case $1 in
        --restart)
            RESTART=1
            ;;
        --full)
            FULL=1
            ;;
        *)
            HOST=$1
            ;;
        *)
            echo huh
            exit 1
            ;;
    esac
    shift
done

rsync -r --checksum src/jarabe $HOST:/usr/lib/python2.7/$PACK/
rsync -r --checksum extensions $HOST:/usr/share/sugar/

if [ $FULL -eq 1 ]; then
    rsync --checksum data/org.sugarlabs.gschema.xml \
        $HOST:/usr/share/glib-2.0/schemas/

    ssh $HOST glib-compile-schemas /usr/share/glib-2.0/schemas/

    if [ -e data/activities.hidden ]; then
        rsync data/activities.hidden $HOST:/usr/share/sugar/data/
    fi
    ssh $HOST rm -f usr/share/sugar/data/activities.defaults

    sed 's%@prefix@%/usr%g' < bin/sugar.in | ssh $HOST "cat > /usr/bin/sugar"
fi

VERSION=$(grep AC_INIT configure.ac |cut -f3 -d'['|cut -f1 -d']')
sed "s%@SUCROSE_VERSION@%${VERSION}.git.$(date +%s)%g" < src/jarabe/config.py.in | \
    sed 's%@prefix@%/usr%g' | \
    ssh $HOST "cat > /usr/lib/python2.7/$PACK/jarabe/config.py"

if [ $RESTART -eq 1 ]; then
    ssh $HOST "service $DM restart && sleep 3 && tail -f /home/$NM/.sugar/default/logs/shell.log"
fi

How to upgrade Sugar packages only to Ubuntu 18.04 beta versions

  • take a backup copy of your /etc/apt/sources.list file,
  • change /etc/apt/sources.list from xenial to bionic,
  • sudo apt update
  • sudo apt install --dry-run python-sugar3 sucrose
  • examine what would be updated, and if it looks okay remove --dry-run,
  • restore the backup copy of the file.

Problem Solved: Enter Key was ignored while editing TitleEntry
Effect of this commit: Enter Key is now detected and the title is saved
Fixes: #375

Explanation:
'activate' signal is binded to a function, which saves the title
It calls self.entry.hide() and self.entry.show() to remove the cursor and focus from the titleEntry.
Otherwise, the title gets saved but the cursor still remains in TitleEntry for further editing

Approaches Used:
Used key-press event for checking Enter key press - Works fine
Used has_focus method to remove cursor - Didn't work
Set Entry.editable to false - Didn't work

modified:   src/sugar3/activity/widgets.py
@rahul-bothra
Copy link
Contributor Author

@quozl Thank you for the detailed review and installation guidance.
Earlier, I used 'key-press-event' as I was unsure if activate is emited only by Enter. Confirmed here

  • Commit message updated.
  • Purpose of calling hide then show methods should be in commit message.
  • activate signal of the Gtk.Entry class should be used.

Changes done and tested

@rahul-bothra
Copy link
Contributor Author

@quozl
Please review

@quozl
Copy link
Contributor

quozl commented Jan 15, 2018

Sorry for the silence. I've been testing and reviewing for some hours now, and was interrupted to fix some problems thrown up by my test cases.

@rahul-bothra
Copy link
Contributor Author

Thank you. Please let me know if there are any issues.

@quozl
Copy link
Contributor

quozl commented Jan 15, 2018

Thanks. I've cherry-picked and merged your change and added some of my own. This isn't a complete fix for #375, but it is a start. If you have any further changes, please rebase your branch and push new commits.

@quozl
Copy link
Contributor

quozl commented Jan 17, 2018

Unrelated to the pull request ... @Pro-Panda, a couple of HFOSS volunteers asked how to update Ubuntu 16.04, and I've pointed them to my comment above and to our discussion on IRC. Do you plan to update the Wiki?

@rahul-bothra
Copy link
Contributor Author

@quozl, I don't have a wiki login access, needed to create a page. Should I apply for one ?
Thanks

@walterbender
Copy link
Member

walterbender commented Jan 18, 2018 via email

@rahul-bothra
Copy link
Contributor Author

rahul-bothra commented Jan 19, 2018

@walterbender
Didn't recieve the credentials. Tried 'forgot password' as well
Should I be doing something else as well ?

Thank you

@quozl
Copy link
Contributor

quozl commented Feb 7, 2018

Looks like nothing else is forthcoming, so I'll close this pull request for the moment.

@quozl quozl closed this Feb 7, 2018
@rahul-bothra
Copy link
Contributor Author

Apologies.
Had forgotten about the same
Will reopen if I find a fix for the remaining parts.
Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants