# Copyright 2009 Simon Schampijer # # 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 St, Fifth Floor, Boston, MA 02110-1301 USA from gi.repository import Gtk from gi.repository import Gdk from gi.repository import GObject import logging from gettext import gettext as _ from sugar3.activity import activity from sugar3.graphics.toolbarbox import ToolbarBox from sugar3.activity.widgets import ActivityToolbarButton from sugar3.activity.widgets import TitleEntry from sugar3.activity.widgets import StopButton from sugar3.activity.widgets import ShareButton from sugar3.graphics import iconentry from sugar3.graphics.toolbutton import ToolButton from sugar3.graphics.toggletoolbutton import ToggleToolButton from sugar3.graphics.toolcombobox import ToolComboBox from sugar3.graphics.combobox import ComboBox from sugar3.graphics.menuitem import MenuItem USE_LOCAL_CSS = False class TestTheme3Activity(activity.Activity): """HelloWorldActivity class as specified in activity.info""" def __init__(self, handle): """Set up the HelloWorld activity.""" activity.Activity.__init__(self, handle) screen = Gdk.Screen.get_default() if USE_LOCAL_CSS: css_provider = Gtk.CssProvider() css_provider.load_from_path('sugar-theme.css') context = Gtk.StyleContext() context.add_provider_for_screen(screen, css_provider, Gtk.STYLE_PROVIDER_PRIORITY_USER) # toolbar with the new toolbar redesign toolbar_box = ToolbarBox() toolbar = toolbar_box.toolbar activity_button = ActivityToolbarButton(self) toolbar.insert(activity_button, 0) toolbar.insert(Gtk.SeparatorToolItem(), -1) tool_item = Gtk.ToolItem() icon_entry = iconentry.IconEntry() icon_entry.set_icon_from_name(iconentry.ICON_ENTRY_PRIMARY, 'system-search') icon_entry.add_clear_button() width = int(Gdk.Screen.width() / 5) icon_entry.set_size_request(width, -1) tool_item.add(icon_entry) toolbar.insert(tool_item, -1) combo = ComboBox() combotool = ToolComboBox(combo) combo.append_item('0', _('First option')) combo.append_item('1', _('Second option')) toolbar.insert(combotool, -1) tool_bt = ToolButton('next') tool_bt.set_tooltip(_('ToolButton')) toolbar.insert(tool_bt, -1) palette = tool_bt.get_palette() mn1 = MenuItem(text_label=_("First MenuItem")) palette.menu.append(mn1) # NOTE: toolbar.show_all() don't show menu items mn1.show() mn2 = MenuItem(text_label=_("Second MenuItem")) palette.menu.append(mn2) mn2.show() toggle_bt = ToggleToolButton('stop') toggle_bt.set_tooltip(_('ToggleToolButton')) toolbar.insert(toggle_bt, -1) separator = Gtk.SeparatorToolItem() separator.props.draw = False separator.set_expand(True) toolbar_box.toolbar.insert(separator, -1) toolbar_box.toolbar.insert(StopButton(self), -1) self.set_toolbar_box(toolbar_box) toolbar_box.show_all() notebook = Gtk.Notebook() hbox = Gtk.HBox() notebook.append_page(hbox, Gtk.Label('Page 1')) hbox2 = Gtk.HBox() notebook.append_page(hbox2, Gtk.Label('Page 2')) hbox3 = Gtk.HBox() notebook.append_page(hbox3, Gtk.Label('Page 3')) vbox1 = Gtk.VBox() hbox.add(vbox1) label = Gtk.Label(_("Label")) vbox1.pack_start(label, False, False, 5) adj = Gtk.Adjustment(0, 0, 10, 1, 32, 0) #spin = Gtk.SpinButton(adj, 0.0, 0) spin = Gtk.SpinButton() spin.set_adjustment(adj) vbox1.pack_start(spin, False, False, 5) hb_group = Gtk.HBox() item1 = Gtk.RadioButton.new_with_label_from_widget(None, _('RadioBt 1')) item2 = Gtk.RadioButton.new_with_label_from_widget(item1, _('RadioBt 2')) item3 = Gtk.RadioButton.new_with_label_from_widget(item1, _('RadioBt 3')) hb_group.pack_start(item1, False, False, 5) hb_group.pack_start(item2, False, False, 5) hb_group.pack_start(item3, False, False, 5) vbox1.pack_start(hb_group, False, False, 5) checkbutton = Gtk.CheckButton(_('CheckButton')) vbox1.pack_start(checkbutton, False, False, 5) entry = Gtk.Entry() vbox1.pack_start(entry, False, False, 5) treev = Gtk.TreeView() treev.headers_clickble = True treev.hover_expand = True treev.rules_hint = True treev.set_enable_search(False) treem = Gtk.ListStore(GObject.TYPE_STRING) treem.append(['first row']) treem.append(['second row']) treev.set_model(treem) renderer = Gtk.CellRendererText() renderer.set_property('wrap-mode', Gtk.WrapMode.WORD) treecol = Gtk.TreeViewColumn(_('Catalogs'), renderer, text=0) treecol.set_property('clickable', True) treev.append_column(treecol) vbox1.pack_start(treev, True, True, 5) separa = Gtk.VSeparator() hbox.add(separa) #vscale = Gtk.VScale(adj) vscale = Gtk.VScale() vscale.set_adjustment(adj) hbox.add(vscale) vbox2 = Gtk.VBox() hbox.add(vbox2) #hscale = Gtk.HScale(adj) hscale = Gtk.HScale() hscale.set_adjustment(adj) vbox2.pack_start(hscale, False, False, 5) combo2 = ComboBox() combo2.append_item('0', _('First option')) combo2.append_item('1', _('Second option')) vbox2.pack_start(combo2, False, False, 5) button = Gtk.Button('Button') vbox2.pack_start(button, False, False, 5) tbutton = Gtk.ToggleButton('ToggleButton') vbox2.pack_start(tbutton, False, False, 5) separa_h = Gtk.HSeparator() vbox2.pack_start(separa_h, False, False, 5) scrollwin = Gtk.ScrolledWindow() scrollwin.set_policy(Gtk.PolicyType.ALWAYS, Gtk.PolicyType.ALWAYS) self.image = Gtk.Image() scrollwin.add_with_viewport(self.image) vbox2.pack_start(scrollwin, True, True, 5) notebook.show_all() self.set_canvas(notebook) label.show()