More work on the new design
parent
0cbe559dbf
commit
d4cb9a2714
@ -1,45 +1,50 @@
|
||||
from gettext import gettext as _
|
||||
|
||||
import gtk
|
||||
|
||||
from sugar.activity import Activity
|
||||
|
||||
class NewActivityButton(gtk.Button):
|
||||
def __init__(self):
|
||||
gtk.Button.__init__(self)
|
||||
class NewActivityButton(gtk.MenuToolButton):
|
||||
def __init__(self, shell):
|
||||
gtk.MenuToolButton.__init__(self, None, _('New Activity'))
|
||||
|
||||
hbox = gtk.HBox(False, 6)
|
||||
|
||||
label = gtk.Label("New Activity")
|
||||
hbox.pack_start(label)
|
||||
label.show()
|
||||
self._shell = shell
|
||||
|
||||
arrow = gtk.Arrow(gtk.ARROW_DOWN, gtk.SHADOW_NONE)
|
||||
hbox.pack_start(arrow)
|
||||
arrow.show()
|
||||
|
||||
self.set_image(hbox)
|
||||
|
||||
self.connect("clicked", self.__clicked_cb)
|
||||
self.set_menu(gtk.Menu())
|
||||
self.connect("show-menu", self.__show_menu_cb)
|
||||
|
||||
def __clicked_cb(self, button):
|
||||
print Activity.list_activities
|
||||
def __show_menu_cb(self, button):
|
||||
menu = gtk.Menu()
|
||||
|
||||
for activity_info in self._shell.get_registry().list_activities():
|
||||
item = gtk.MenuItem(activity_info.get_title(), False)
|
||||
name = activity_info.get_name()
|
||||
item.connect('activate', self.__menu_item_activate_cb, name)
|
||||
menu.append(item)
|
||||
item.show()
|
||||
|
||||
self.set_menu(menu)
|
||||
|
||||
def __menu_item_activate_cb(self, item, name):
|
||||
Activity.create(name)
|
||||
|
||||
class Toolbar(gtk.HBox):
|
||||
def __init__(self):
|
||||
gtk.HBox.__init__(self)
|
||||
class Toolbar(gtk.Toolbar):
|
||||
def __init__(self, shell):
|
||||
gtk.Toolbar.__init__(self)
|
||||
|
||||
new_activity_button = NewActivityButton()
|
||||
self.pack_start(new_activity_button)
|
||||
new_activity_button = NewActivityButton(shell)
|
||||
self.insert(new_activity_button, -1)
|
||||
new_activity_button.show()
|
||||
|
||||
class HomeWindow(gtk.Window):
|
||||
def __init__(self):
|
||||
def __init__(self, shell):
|
||||
gtk.Window.__init__(self)
|
||||
|
||||
|
||||
vbox = gtk.VBox()
|
||||
|
||||
toolbar = Toolbar()
|
||||
vbox.pack_start(toolbar)
|
||||
toolbar = Toolbar(shell)
|
||||
vbox.pack_start(toolbar, False)
|
||||
toolbar.show()
|
||||
|
||||
self.add(vbox)
|
||||
|
||||
vbox.show()
|
||||
|
Loading…
Reference in New Issue