class MainMenuToolbarItem(ToolbarItem): def __init__(self): ToolbarItem.__init__(self, 'mainMenu', None, '', _('Main Menu'), enableTooltip=False) self.connect('clicked', self.onClicked) self.updateImage() def optionsWidgetCreate(self): from scal3.ui_gtk.mywidgets.icon import IconSelectButton if self.optionsWidget: return self.optionsWidget = gtk.VBox() ### hbox = gtk.HBox() pack(hbox, gtk.Label(_('Icon') + ' ')) self.iconSelect = IconSelectButton() self.iconSelect.set_filename(ui.wcal_toolbar_mainMenu_icon) self.iconSelect.connect('changed', self.onIconChanged) pack(hbox, self.iconSelect) pack(hbox, gtk.Label(''), 1, 1) pack(self.optionsWidget, hbox) self.optionsWidget.show_all() def updateImage(self): from scal3.ui_gtk.utils import imageFromFile self.set_property('label-widget', imageFromFile(ui.wcal_toolbar_mainMenu_icon)) self.show_all() def getMenuPos(self): wcal = self.get_parent().get_parent() w = self.get_allocation().width h = self.get_allocation().height x0, y0 = self.translate_coordinates(wcal, 0, 0) return ( x0 if rtl else x0 + w, y0 + h, ) def onClicked(self, widget=None): x, y = self.getMenuPos() self.get_parent().get_parent().emit( 'popup-main-menu', 0, x, y, ) def onIconChanged(self, widget, icon): if not icon: icon = ui.wcal_toolbar_mainMenu_icon_default self.iconSelect.set_filename(icon) ui.wcal_toolbar_mainMenu_icon = icon self.updateImage()
class MainMenuToolbarItem(ToolbarItem): def __init__(self): ToolbarItem.__init__(self, 'mainMenu', None, '', _('Main Menu'), enableTooltip=False) self.connect('clicked', self.onClicked) self.updateImage() def optionsWidgetCreate(self): from scal3.ui_gtk.mywidgets.icon import IconSelectButton if self.optionsWidget: return self.optionsWidget = gtk.VBox() ### hbox = gtk.HBox() pack(hbox, gtk.Label(_('Icon')+' ')) self.iconSelect = IconSelectButton() self.iconSelect.set_filename(ui.wcal_toolbar_mainMenu_icon) self.iconSelect.connect('changed', self.onIconChanged) pack(hbox, self.iconSelect) pack(hbox, gtk.Label(''), 1, 1) pack(self.optionsWidget, hbox) self.optionsWidget.show_all() def updateImage(self): from scal3.ui_gtk.utils import imageFromFile self.set_property('label-widget', imageFromFile(ui.wcal_toolbar_mainMenu_icon)) self.show_all() def getMenuPos(self): wcal = self.get_parent().get_parent() w = self.get_allocation().width h = self.get_allocation().height x0, y0 = self.translate_coordinates(wcal, 0, 0) return ( x0 if rtl else x0+w, y0+h, ) def onClicked(self, widget=None): x, y = self.getMenuPos() self.get_parent().get_parent().emit( 'popup-main-menu', 0, x, y, ) def onIconChanged(self, widget, icon): if not icon: icon = ui.wcal_toolbar_mainMenu_icon_default self.iconSelect.set_filename(icon) ui.wcal_toolbar_mainMenu_icon = icon self.updateImage()
class MainMenuToolbarItem(ToolbarItem): def __init__(self): ToolbarItem.__init__( self, "mainMenu", None, "", _("Main Menu"), enableTooltip=False, ) self.connect("clicked", self.onClicked) self.updateImage() def optionsWidgetCreate(self): from os.path import isabs from scal3.ui_gtk.mywidgets.icon import IconSelectButton if self.optionsWidget: return self.optionsWidget = gtk.VBox() ### iconPath = ui.wcal_toolbar_mainMenu_icon if not isabs(iconPath): iconPath = join(pixDir, iconPath) ### hbox = gtk.HBox() pack(hbox, gtk.Label(_("Icon") + " ")) self.iconSelect = IconSelectButton() self.iconSelect.set_filename(iconPath) self.iconSelect.connect("changed", self.onIconChanged) pack(hbox, self.iconSelect) pack(hbox, gtk.Label(""), 1, 1) pack(self.optionsWidget, hbox) self.optionsWidget.show_all() def updateImage(self): from scal3.ui_gtk.utils import imageFromFile self.set_property( "label-widget", imageFromFile(ui.wcal_toolbar_mainMenu_icon), ) self.show_all() def getMenuPos(self): wcal = self.get_parent().get_parent() w = self.get_allocation().width h = self.get_allocation().height x0, y0 = self.translate_coordinates(wcal, 0, 0) return ( x0 if rtl else x0 + w, y0 + h, ) def onClicked(self, widget=None): x, y = self.getMenuPos() self.get_parent().get_parent().emit( "popup-main-menu", 0, x, y, ) def onIconChanged(self, widget, iconPath): if not iconPath: iconPath = ui.wcal_toolbar_mainMenu_icon_default self.iconSelect.set_filename(iconPath) direc = join(pixDir, "") if iconPath.startswith(direc): iconPath = iconPath[len(direc):] ui.wcal_toolbar_mainMenu_icon = iconPath self.updateImage()