[Sugar-devel] [PATCH] touchpad section for Sugar Control Panel

Walter Bender walter.bender at gmail.com
Thu Jul 29 22:24:31 EDT 2010


On Thu, Jul 29, 2010 at 5:37 PM, Paul Fox <pgf at laptop.org> wrote:
> walter wrote:
>  > On Thu, Jul 29, 2010 at 6:27 AM, pbrobinson at gmail.com
>  > <pbrobinson at gmail.com> wrote:
>  > > On Wed, Jul 28, 2010 at 3:41 PM, Sascha Silbe
>  > > <sascha-ml-ui-sugar-devel at silbe.org> wrote:
>  > >> Excerpts from Paul Fox's message of Wed Jul 28 16:01:22 +0200 2010:
>  > >>> sascha wrote:
>  > >>>  > Even your latest patch still contains code that is specific to OLPC
>  > builds and will break on other systems.
>  > >>>  > Of course it's perfectly fine for you to say you only care about OLPC
>  > builds for XO-1 (because the number of XO-1s running non-OLPC builds is
>  > minimal, especially if you don't count developers). But in that case your patch
>  > should be included in the OLPC builds, not in Sugar mainline.
>  > >>>
>  > >>> can you remind me of the specific issue(s) here?
>  > >> I can remember two issues (there might be others as well):
>  > >> - hardcoded, absolute path (/home/olpc/whatever)
>  > >
>  > > I agree that it shouldn't ever user /home/olpc as hardcoded. At least
>  > > you ~/.olpc-blah as it will then work on what ever distro and what
>  > > ever user. I'm not sure of the general standard to use for this.
>  >
>  > How's this look?
>
> walter -- i didn't think of this when we were designing all of
> this:  how about if, in addition to this patch, you checked at sugar
> startup time and used the presence of that file in $HOME as an
> indication that you should set ptmode for the user?  then i could
> eliminate a chunk of the code from olpc-utils that sascha was
> complaining about.
>
> btw -- i just looked at your patch again -- what happens if
> NODE_PATH can't be opened for writing?  write_touchpad_mode()
> should fail gracefully in that case.  making the node writeable
> is the one line of code that will need to remain external to
> sugar, and we shouldn't assume that it has happened.  i'm
> referring to this:
>
>    +def write_touchpad_mode(touchpad):
>    +    """ Write the touchpad mode to the node path and set/unset the flag. """
>    +    touchpad_mode_index = TOUCHPAD_MODES.index(touchpad)
>    +
>    +    node_file_handle = open(NODE_PATH, 'w')
>    +    node_file_handle.write(str(touchpad_mode_index))
>    +    node_file_handle.close()
>    +
>    +    if touchpad_mode_index == 0:
>    +        if os.path.exists(FLAG_PATH):
>    +            os.remove(FLAG_PATH)
>    +    else:
>    +        flag_file_handle = open(FLAG_PATH, 'w')
>    +        flag_file_handle.close()
>
> paul
>
>
>  >
>  > 35,36c35,36
>  > < # FLAG_PATH is used to preserve status between boots.
>  > < FLAG_PATH = '/home/olpc/.olpc-pentablet-mode'
>  > ---
>  > > # FLAG_FILE is used to preserve status between boots.
>  > > FLAG_FILE = '.olpc-pentablet-mode'
>  > 123a124
>  > >     _flag_path = os.join(os.environ['HOME'], FLAG_FILE)
>  > 125,126c126,127
>  > <         if os.path.exists(FLAG_PATH):
>  > <             os.remove(FLAG_PATH)
>  > ---
>  > >         if os.path.exists(_flag_path):
>  > >             os.remove(_flag_path)
>  > 128c129
>  > <         flag_file_handle = open(FLAG_PATH, 'w')
>  > ---
>  > >         flag_file_handle = open(_flag_path, 'w')
>  >
>  > -walter
>  > >
>  > > Peter
>  > > _______________________________________________
>  > > Sugar-devel mailing list
>  > > Sugar-devel at lists.sugarlabs.org
>  > > http://lists.sugarlabs.org/listinfo/sugar-devel
>  > >
>  >
>  >
>  >
>  > --
>  > Walter Bender
>  > Sugar Labs
>  > http://www.sugarlabs.org
>  > _______________________________________________
>  > Sugar-devel mailing list
>  > Sugar-devel at lists.sugarlabs.org
>  > http://lists.sugarlabs.org/listinfo/sugar-devel
>
> =---------------------
>  paul fox, pgf at laptop.org
>

This do the trick?

35,36c35,36
< # FLAG_PATH is used to preserve status between boots.
< FLAG_PATH = '/home/olpc/.olpc-pentablet-mode'
---
> # FLAG_FILE is used to preserve status between boots.
> FLAG_FILE = '.olpc-pentablet-mode'
104a105,108
>         _flag_path = os.join(os.environ['HOME'], FLAG_FILE)
>         # if _flag_path exists, set the initial device value to stylus
>         if os.path.exists(_flag_path):
>             write_to_node_file(str(TOUCHPAD_MODES.index('stylus')))
120,122c124
<     node_file_handle = open(NODE_PATH, 'w')
<     node_file_handle.write(str(touchpad_mode_index))
<     node_file_handle.close()
---
>     write_to_node_file(str(touchpad_mode_index))
123a126
>     _flag_path = os.join(os.environ['HOME'], FLAG_FILE)
125c128
<         if os.path.exists(FLAG_PATH):
---
>         if os.path.exists(_flag_path):
128c131
<         flag_file_handle = open(FLAG_PATH, 'w')
---
>         flag_file_handle = open(_flag_path, 'w')
129a133,143
>
>
> def write_to_node_file(value):
>     """ Write to node path, catching exception is there is a problem """
>     try:
>         node_file_handle = open(NODE_PATH, 'w')
>     except IOError, e:
>         print e
>         return
>     node_file_handle.write(value)
>     node_file_handle.close()

-walter
-- 
Walter Bender
Sugar Labs
http://www.sugarlabs.org


More information about the Sugar-devel mailing list