Hi Gary,<br><br><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;"><br>
Make your changes, commit, push, and then request a merge?<br>
<br></blockquote><div><br></div><div>I have filed the merge request.Please look into it. Also I made it backward compatible to previous sugar versions as you suggested. It would fall back to older toolbar design in case of previous sugar versions.</div>
<div><br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
Having a quick scan through the below patch I don't see any fallback to the old toolbar setup if someone is running an older version of Sugar. I don't want to loose compatibility 99% of our current user base if at all possible (check the git reps of Moon, Calculator, TurtleArt, and I'm sure many other activities for dual toolbar support).<br>
<br>
Thanks again for taking the time to submit a patch.<br>
<br>
Kind Regards,<br>
<font color="#888888">--Gary<br>
</font><div><div></div><div class="h5"><br>
> Signed-off-by: akashg1611 <<a href="mailto:akashg1611@gmail.com">akashg1611@gmail.com</a>><br>
> ---<br>
> activity.py | 77 ++++++++++++++++++++++++++-------------------<br>
> icons/toolbar-create.svg | 44 ++++++++++++++++++++++++++<br>
> 2 files changed, 88 insertions(+), 33 deletions(-)<br>
> create mode 100644 icons/toolbar-create.svg<br>
><br>
> diff --git a/activity.py b/activity.py<br>
> index 273a001..ca18aad 100644<br>
> --- a/activity.py<br>
> +++ b/activity.py<br>
> @@ -21,6 +21,10 @@ import olpcgames<br>
> import pygame<br>
> from sugar.graphics.radiotoolbutton import RadioToolButton<br>
> from sugar.graphics.toolbutton import ToolButton<br>
> +from sugar.graphics.toolbarbox import ToolbarBox<br>
> +from sugar.graphics.toolbarbox import ToolbarButton<br>
> +from sugar.activity.widgets import ActivityToolbarButton<br>
> +from sugar.activity.widgets import StopButton<br>
> from sugar.activity import activity<br>
> from gettext import gettext as _<br>
> import gtk<br>
> @@ -34,6 +38,44 @@ class PhysicsActivity(olpcgames.PyGameActivity):<br>
> super(PhysicsActivity, self).__init__(handle)<br>
> self.metadata['mime_type'] = 'application/x-physics-activity'<br>
><br>
> + toolbar_box = ToolbarBox()<br>
> +<br>
> + activity_button = ActivityToolbarButton(self)<br>
> + toolbar_box.toolbar.insert(activity_button, 0)<br>
> + activity_button.page.keep.props.accelerator = '<Ctrl><Shift>S'<br>
> + activity_button.show()<br>
> +<br>
> + create_toolbar = self._create_create_toolbar()<br>
> + create_toolbar_button = ToolbarButton(<br>
> + page=create_toolbar,<br>
> + icon_name='toolbar-create')<br>
> + create_toolbar.show()<br>
> + toolbar_box.toolbar.insert(create_toolbar_button, -1)<br>
> + create_toolbar_button.show()<br>
> +<br>
> + stop_play = ToolButton('media-playback-stop')<br>
> + stop_play_state = True<br>
> + stop_play.set_tooltip(_("Stop"))<br>
> + stop_play.set_accelerator(_('<ctrl>space'))<br>
> + stop_play.connect('clicked', self.stop_play_cb)<br>
> + toolbar_box.toolbar.insert(stop_play, -1)<br>
> + stop_play.show()<br>
> +<br>
> + separator = gtk.SeparatorToolItem()<br>
> + separator.props.draw = False<br>
> + separator.set_expand(True)<br>
> + toolbar_box.toolbar.insert(separator, -1)<br>
> + separator.show()<br>
> +<br>
> + stop_button = StopButton(self)<br>
> + stop_button.props.accelerator = '<Ctrl><Shift>Q'<br>
> + toolbar_box.toolbar.insert(stop_button, -1)<br>
> + stop_button.show()<br>
> +<br>
> + self.set_toolbar_box(toolbar_box)<br>
> + toolbar_box.show()<br>
> +<br>
> +<br>
> def write_file(self, file_path):<br>
> """Over-ride olpcgames write_file so that title keeps working.<br>
> """<br>
> @@ -46,31 +88,8 @@ class PhysicsActivity(olpcgames.PyGameActivity):<br>
> event.block()<br>
> event.retire() # <- without this, title editing stops updating<br>
><br>
> - # setup the toolbar<br>
> - def build_toolbar(self):<br>
> - # make a toolbox<br>
> - toolbox = activity.ActivityToolbox(self)<br>
> -<br>
> - # modify the Activity tab<br>
> - activity_toolbar = toolbox.get_activity_toolbar()<br>
> - activity_toolbar.share.props.visible = False<br>
> - self.blocklist = []<br>
> - # make a 'create' toolbar<br>
> + def _create_create_toolbar(self):<br>
> create_toolbar = gtk.Toolbar()<br>
> -<br>
> - # stop/play button<br>
> - self.stop_play_state = True<br>
> - self.stop_play = ToolButton('media-playback-stop')<br>
> - self.stop_play.set_tooltip(_("Stop"))<br>
> - self.stop_play.set_accelerator(_('<ctrl>space'))<br>
> - self.stop_play.connect('clicked', self.stop_play_cb)<br>
> - create_toolbar.insert(self.stop_play, 0)<br>
> - self.stop_play.show()<br>
> -<br>
> - separator = gtk.SeparatorToolItem()<br>
> - create_toolbar.insert(separator, 1)<br>
> - separator.show()<br>
> -<br>
> # make + add the component buttons<br>
> self.radioList = {}<br>
> firstButton = None<br>
> @@ -87,15 +106,7 @@ class PhysicsActivity(olpcgames.PyGameActivity):<br>
> create_toolbar.insert(button,-1)<br>
> button.show()<br>
> self.radioList[button] = <a href="http://c.name" target="_blank">c.name</a><br>
> -<br>
> - # add the toolbars to the toolbox<br>
> - toolbox.add_toolbar(_("Create"),create_toolbar)<br>
> - create_toolbar.show()<br>
> -<br>
> - toolbox.show()<br>
> - self.set_toolbox(toolbox)<br>
> - toolbox.set_current_toolbar(1)<br>
> - return activity_toolbar<br>
> + return create_toolbar<br>
><br>
> def stop_play_cb(self, button):<br>
> pygame.event.post(olpcgames.eventwrap.Event(pygame.USEREVENT, action="stop_start_toggle"))<br>
> diff --git a/icons/toolbar-create.svg b/icons/toolbar-create.svg<br>
> new file mode 100644<br>
> index 0000000..ea7c0ce<br>
> --- /dev/null<br>
> +++ b/icons/toolbar-create.svg<br>
> @@ -0,0 +1,44 @@<br>
> +<?xml version="1.0" ?><!-- Created with Inkscape (<a href="http://www.inkscape.org/" target="_blank">http://www.inkscape.org/</a>) --><!DOCTYPE svg PUBLIC '-//W3C//DTD SVG 1.1//EN' '<a href="http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd" target="_blank">http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd</a>' [<br>
> + <!ENTITY stroke_color "none"><br>
> + <!ENTITY fill_color "#ffffff"><br>
> +]><svg height="48pt" id="svg1" inkscape:version="0.47 r22583" sodipodi:docname="toolbar-create.svg" sodipodi:version="0.32" style="" version="1.0" width="48pt" x="0" xmlns="<a href="http://www.w3.org/2000/svg" target="_blank">http://www.w3.org/2000/svg</a>" xmlns:cc="<a href="http://creativecommons.org/ns#" target="_blank">http://creativecommons.org/ns#</a>" xmlns:dc="<a href="http://purl.org/dc/elements/1.1/" target="_blank">http://purl.org/dc/elements/1.1/</a>" xmlns:inkscape="<a href="http://www.inkscape.org/namespaces/inkscape" target="_blank">http://www.inkscape.org/namespaces/inkscape</a>" xmlns:rdf="<a href="http://www.w3.org/1999/02/22-rdf-syntax-ns#" target="_blank">http://www.w3.org/1999/02/22-rdf-syntax-ns#</a>" xmlns:sodipodi="<a href="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" target="_blank">http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd</a>" xmlns:svg="<a href="http://www.w3.org/2000/svg" target="_blank">http://www.w3.org/2000/svg</a>" xmlns:xlink="<a href="http://www.w3.org/1999/xlink" target="_blank">http://www.w3.org/1999/xlink</a>" y="0"><br>
> + <metadata id="metadata2985" style=""><br>
> + <rdf:RDF style=""><br>
> + <cc:Work rdf:about="" style=""><br>
> + <dc:format style="">image/svg+xml</dc:format><br>
> + <dc:type rdf:resource="<a href="http://purl.org/dc/dcmitype/StillImage" target="_blank">http://purl.org/dc/dcmitype/StillImage</a>" style=""/><br>
> + <dc:title style=""/><br>
> + </cc:Work><br>
> + </rdf:RDF><br>
> + </metadata><br>
> + <sodipodi:namedview bordercolor="#666666" borderopacity="1.0" horizgrid="false" id="base" inkscape:current-layer="svg1" inkscape:cx="-10.626905" inkscape:cy="21.859944" inkscape:pageopacity="0.0" inkscape:pageshadow="2" inkscape:window-height="825" inkscape:window-maximized="1" inkscape:window-width="1440" inkscape:window-x="0" inkscape:window-y="24" inkscape:zoom="4.9119411" pagecolor="#ffffff" showgrid="false" snaptogrid="false" snaptoguides="false" style="" vertgrid="false"/><br>
> + <defs id="defs3" style=""><br>
> + <inkscape:perspective id="perspective2987" inkscape:persp3d-origin="30 : 20 : 1" inkscape:vp_x="0 : 30 : 1" inkscape:vp_y="0 : 1000 : 0" inkscape:vp_z="60 : 30 : 1" sodipodi:type="inkscape:persp3d" style=""/><br>
> + <linearGradient id="linearGradient570" style=""><br>
> + <stop id="stop571" offset="0" style="stop-color:#ffffff;stop-opacity:1;"/><br>
> + <stop id="stop572" offset="1" style="stop-color:#ffffff;stop-opacity:0;"/><br>
> + </linearGradient><br>
> + <linearGradient id="linearGradient563" style=""><br>
> + <stop id="stop564" offset="0.00000000" style="stop-color:#666666;stop-opacity:1;"/><br>
> + <stop id="stop565" offset="1.00000000" style="stop-color:#666666;stop-opacity:1;"/><br>
> + </linearGradient><br>
> + <linearGradient gradientTransform="matrix(1.04498,0,0,0.9569561,-74.308708,-2.6466114)" gradientUnits="userSpaceOnUse" id="linearGradient566" style="" x1="23.402853" x2="35.835532" xlink:href="#linearGradient563" y1="23.747154" y2="36.390283"/><br>
> + <linearGradient id="linearGradient569" style="" x1="0.009905" x2="0.985224" xlink:href="#linearGradient570" y1="0.007809" y2="1.015625"/><br>
> + <linearGradient gradientTransform="scale(0.999995,1.000005)" id="linearGradient573" style="" x1="0.015742" x2="0.976382" xlink:href="#linearGradient570" y1="0.015626" y2="0.999995"/><br>
> + <linearGradient id="linearGradient575" style="" x1="0.006623" x2="0.973510" xlink:href="#linearGradient570" y1="0.007813" y2="0.984375"/><br>
> + <linearGradient gradientTransform="scale(1.2487241,0.80081741)" gradientUnits="userSpaceOnUse" id="linearGradient578" style="" x1="4.5679298" x2="11.042724" xlink:href="#linearGradient570" y1="46.001992" y2="52.375657"/><br>
> + <linearGradient id="linearGradient583" style="" x1="0.012999" x2="1.012987" xlink:href="#linearGradient570" y1="0.015680" y2="1.000001"/><br>
> + <linearGradient id="linearGradient637" style="" x1="0.07954545" x2="0.95454544" xlink:href="#linearGradient563" y1="0.06250000" y2="0.97656250"/><br>
> + <linearGradient id="linearGradient640" style="" x1="0.03225806" x2="0.99596775" xlink:href="#linearGradient563" y1="0.05468750" y2="1.00000000"/><br>
> + <linearGradient id="linearGradient645" style="" x1="0.010877" x2="0.989090" xlink:href="#linearGradient570" y1="0.038449" y2="0.987177"/><br>
> + <linearGradient id="linearGradient646" style="" x1="0.056578" x2="0.867923" xlink:href="#linearGradient570" y1="0.023450" y2="0.976563"/><br>
> + <linearGradient id="linearGradient647" style="" x1="0.000007" x2="0.951807" xlink:href="#linearGradient570" y1="0.000000" y2="0.984375"/><br>
> + <linearGradient id="linearGradient675" style="" x1="0.056605" x2="0.943396" xlink:href="#linearGradient570" y1="0.015625" y2="0.984375"/><br>
> + <linearGradient id="linearGradient676" style="" x1="0.011765" x2="1.011765" xlink:href="#linearGradient570" y1="-0.000000" y2="1.015625"/><br>
> + <linearGradient id="linearGradient684" style="" x1="0.09210526" x2="0.93421054" xlink:href="#linearGradient563" y1="0.12500000" y2="0.92187500"/><br>
> + <linearGradient id="linearGradient685" style="" x1="0.06603774" x2="0.94339621" xlink:href="#linearGradient563" y1="0.07812500" y2="0.95312500"/><br>
> + </defs><br>
> + <path d="m 1.6714541,46.028933 c 2.5395548,1.861985 4.9782017,-5.378683 9.5887409,1.564511 5.202194,7.839595 -2.2748278,8.004289 -1.5908585,11.218364 0.5434475,2.15168 7.8018915,0.78452 9.4836775,-1.356607 1.708234,-2.174518 -1.328528,-8.961765 0.686245,-11.589945 6.679753,-8.71269 16.362463,-17.130631 25.397539,-22.432085 2.941573,-1.725842 8.191049,3.04221 10.532509,1.349931 2.272038,-1.642373 4.894662,-10.122847 3.307654,-11.353779 C 56.639324,11.47279 52.997644,20.80289 48.606866,13.989506 44.186925,7.129412<br>
> + 52.142642,4.5631634 51.662085,1.862198 51.217131,-0.33348689 43.318205,0.8930759 41.301114,3.1327101 39.311696,5.3415778 39.98847,13.033259 37.810293,15.81846 31.052456,24.45924 23.378731,32.160168 14.492957,37.410639 11.915703,38.933488 7.3485542,34.119614 5.2533614,35.52793 3.0747599,36.992339 0.03942982,44.719057 1.6714541,46.028933 z" id="path636" sodipodi:nodetypes="cccsssscscssssc" style="font-size:12px;opacity:1.0;fill:&fill_color;;fill-rule:evenodd;stroke-width:12.5"/><br>
> + <path d="m 36.034635,17.45063 -4.701433,-2.805627 -4.976523,2.282375 1.215487,-5.338314 -3.708498,-4.0276614 5.452645,-0.4936332 2.684545,-4.7716069 2.154433,5.0332324 5.367638,1.0786459 -4.121133,3.6043422 0.632839,5.438247 z" id="path3942" inkscape:flatsided="false" inkscape:randomized="0" inkscape:rounded="0" sodipodi:arg1="0.9964915" sodipodi:arg2="1.62481" sodipodi:cx="31.555754" sodipodi:cy="10.528723" sodipodi:r1="8.2445841" sodipodi:r2="4.122292" sodipodi:sides="5" sodipodi:type="star" style="opacity:1.0;fill:&fill_color;;fill-opacity:1.0" transform="matrix(1.7410551,0,0,1.8060416,-29.492251,-3.6830718)"/><br>
> +</svg><br>
> --<br>
> 1.7.0.4<br>
><br>
<br>
</div></div></blockquote></div><br><br clear="all"><br>-- <br>Best Regards<br>Akash Gangil<br><br>