Exemplo n.º 1
0
 def getCopyToGroupSubMenu(self, path, event):
     ## returns a MenuItem instance
     item = labelStockMenuItem(
         _('Copy to %s')%'...',
         None,## FIXME
     )
     subMenu = gtk.Menu()
     ###
     for new_group in ui.eventGroups:
         #if not new_group.enable:## FIXME
         #    continue
         if event.name in new_group.acceptsEventTypes:
             new_groupItem = gtk.ImageMenuItem()
             new_groupItem.set_label(new_group.title)
             ##
             image = gtk.Image()
             image.set_from_pixbuf(newOutlineSquarePixbuf(new_group.color, 20))
             new_groupItem.set_image(image)
             ##
             new_groupItem.connect(
                 'activate',
                 self.copyEventToGroupFromMenu,
                 path,
                 event,
                 new_group,
             )
             ##
             subMenu.add(new_groupItem)
     ##
     item.set_submenu(subMenu)
     return item
Exemplo n.º 2
0
	def getCopyToGroupSubMenu(self, path, event):
		## returns a MenuItem instance
		item = labelStockMenuItem(
			_('Copy to %s')%'...',
			None,## FIXME
		)
		subMenu = gtk.Menu()
		###
		for new_group in ui.eventGroups:
			#if not new_group.enable:## FIXME
			#	continue
			if event.name in new_group.acceptsEventTypes:
				new_groupItem = gtk.ImageMenuItem()
				new_groupItem.set_label(new_group.title)
				##
				image = gtk.Image()
				image.set_from_pixbuf(newOutlineSquarePixbuf(new_group.color, 20))
				new_groupItem.set_image(image)
				##
				new_groupItem.connect(
					'activate',
					self.copyEventToGroupFromMenu,
					path,
					event,
					new_group,
				)
				##
				subMenu.add(new_groupItem)
		##
		item.set_submenu(subMenu)
		return item
Exemplo n.º 3
0
def menuItemFromEventGroup(group):
    item = gtk.ImageMenuItem()
    item.set_label(group.title)
    ##
    image = gtk.Image()
    image.set_from_pixbuf(newOutlineSquarePixbuf(group.color, 20))
    item.set_image(image)
    return item
Exemplo n.º 4
0
def menuItemFromEventGroup(group):
    item = gtk.ImageMenuItem()
    item.set_label(group.title)
    ##
    image = gtk.Image()
    image.set_from_pixbuf(newOutlineSquarePixbuf(group.color, 20))
    item.set_image(image)
    return item
Exemplo n.º 5
0
 def onEventLabelPopup(self, label, menu, ids):
     menu = gtk.Menu()
     self.labelMenuAddCopyItems(label, menu)
     ####
     groupId, eventId = ids
     event = ui.getEvent(groupId, eventId)
     group = ui.eventGroups[groupId]
     if not event.readOnly:
         menu.add(gtk.SeparatorMenuItem())
         ###
         winTitle = _('Edit ') + event.desc
         menu.add(labelStockMenuItem(
             winTitle,
             gtk.STOCK_EDIT,
             self.editEventClicked,
             winTitle,
             event,
             groupId,
         ))
         ###
         moveToItem = labelStockMenuItem(
             _('Move to %s')%'...',
             None,## FIXME
         )
         moveToMenu = gtk.Menu()
         for new_group in ui.eventGroups:
             if new_group.id == group.id:
                 continue
             if not new_group.enable:
                 continue
             if event.name in new_group.acceptsEventTypes:
                 new_groupItem = gtk.ImageMenuItem()
                 new_groupItem.set_label(new_group.title)
                 ##
                 image = gtk.Image()
                 image.set_from_pixbuf(newOutlineSquarePixbuf(new_group.color, 20))
                 new_groupItem.set_image(image)
                 ##
                 new_groupItem.connect('activate', self.moveEventToGroupFromMenu, event, group, new_group)
                 ##
                 moveToMenu.add(new_groupItem)
         moveToItem.set_submenu(moveToMenu)
         menu.add(moveToItem)
         ###
         menu.add(gtk.SeparatorMenuItem())
         ###
         menu.add(labelImageMenuItem(
             _('Move to %s') % ui.eventTrash.title,
             ui.eventTrash.icon,
             self.moveEventToTrash,
             event,
             groupId,
         ))
     ####
     menu.show_all()
     menu.popup(None, None, None, 3, 0)
     ui.updateFocusTime()
Exemplo n.º 6
0
 def getEventAddToMenuItem(self):
     from scal2.ui_gtk.drawing import newOutlineSquarePixbuf
     addToItem = labelStockMenuItem('_Add to', gtk.STOCK_ADD)
     menu2 = gtk.Menu()
     ##
     for group in ui.eventGroups:
         if not group.enable:
             continue
         if not group.showInCal():  ## FIXME
             continue
         eventTypes = group.acceptsEventTypes
         if not eventTypes:
             continue
         item2 = gtk.ImageMenuItem()
         item2.set_label(group.title)
         ##
         image = gtk.Image()
         if group.icon:
             image.set_from_file(group.icon)
         else:
             image.set_from_pixbuf(newOutlineSquarePixbuf(group.color, 20))
         item2.set_image(image)
         ##
         if len(eventTypes) == 1:
             item2.connect('activate', self.addToGroupFromMenu, group,
                           eventTypes[0])
         else:
             menu3 = gtk.Menu()
             for eventType in eventTypes:
                 eventClass = event_lib.classes.event.byName[eventType]
                 item3 = gtk.ImageMenuItem()
                 item3.set_label(eventClass.desc)
                 icon = eventClass.getDefaultIcon()
                 if icon:
                     item3.set_image(gtk.image_new_from_file(icon))
                 item3.connect('activate', self.addToGroupFromMenu, group,
                               eventType)
                 menu3.add(item3)
             menu3.show_all()
             item2.set_submenu(menu3)
         menu2.add(item2)
     ##
     menu2.show_all()
     addToItem.set_submenu(menu2)
     return addToItem
Exemplo n.º 7
0
 def treeviewButtonPress(self, treev, g_event):
     pos_t = treev.get_path_at_pos(int(g_event.x), int(g_event.y))
     if not pos_t:
         return
     path, col, xRel, yRel = pos_t
     if not path:
         return
     if g_event.button == 3:
         self.openRightClickMenu(path, g_event.time)
     elif g_event.button == 1:
         if not col:
             return
         if not rectangleContainsPoint(
             treev.get_cell_area(path, col),
             g_event.x,
             g_event.y,
         ):
             return
         obj_list = self.getObjsByPath(path)
         if len(obj_list) == 1:## group, not event
             group = obj_list[0]
             if group.name != 'trash':
                 cell = col.get_cell_renderers()[0]
                 try:
                     cell.get_property('pixbuf')
                 except:
                     pass
                 else:
                     group.enable = not group.enable
                     groupIter = self.trees.get_iter(path)
                     self.trees.set_value(
                         groupIter,
                         1,
                         newOutlineSquarePixbuf(
                             group.color,
                             20,
                             0 if group.enable else 15,
                             self.getRowBgColor(),
                         ),
                     )
                     group.save()
                     self.onGroupModify(group)
                     treev.set_cursor(path)
                     return True
Exemplo n.º 8
0
 def getEventAddToMenuItem(self):
     from scal2.ui_gtk.drawing import newOutlineSquarePixbuf
     addToItem = labelStockMenuItem('_Add to', gtk.STOCK_ADD)
     menu2 = gtk.Menu()
     ##
     for group in ui.eventGroups:
         if not group.enable:
             continue
         if not group.showInCal():## FIXME
             continue
         eventTypes = group.acceptsEventTypes
         if not eventTypes:
             continue
         item2 = gtk.ImageMenuItem()
         item2.set_label(group.title)
         ##
         image = gtk.Image()
         if group.icon:
             image.set_from_file(group.icon)
         else:
             image.set_from_pixbuf(newOutlineSquarePixbuf(group.color, 20))
         item2.set_image(image)
         ##
         if len(eventTypes)==1:
             item2.connect('activate', self.addToGroupFromMenu, group, eventTypes[0])
         else:
             menu3 = gtk.Menu()
             for eventType in eventTypes:
                 eventClass = event_lib.classes.event.byName[eventType]
                 item3 = gtk.ImageMenuItem()
                 item3.set_label(eventClass.desc)
                 icon = eventClass.getDefaultIcon()
                 if icon:
                     item3.set_image(gtk.image_new_from_file(icon))
                 item3.connect('activate', self.addToGroupFromMenu, group, eventType)
                 menu3.add(item3)
             menu3.show_all()
             item2.set_submenu(menu3)
         menu2.add(item2)
     ##
     menu2.show_all()
     addToItem.set_submenu(menu2)
     return addToItem
Exemplo n.º 9
0
 def treeviewButtonPress(self, treev, gevent):
     pos_t = treev.get_path_at_pos(int(gevent.x), int(gevent.y))
     if not pos_t:
         return
     path, col, xRel, yRel = pos_t
     if not path:
         return
     if gevent.button == 3:
         self.openRightClickMenu(path, gevent.time)
     elif gevent.button == 1:
         if not col:
             return
         if not rectangleContainsPoint(treev.get_cell_area(path, col), gevent.x, gevent.y):
             return
         obj_list = self.getObjsByPath(path)
         if len(obj_list) == 1:  ## group, not event
             group = obj_list[0]
             if group.name != "trash":
                 cell = col.get_cell_renderers()[0]
                 try:
                     cell.get_property("pixbuf")
                 except:
                     pass
                 else:
                     group.enable = not group.enable
                     groupIter = self.trees.get_iter(path)
                     self.trees.set_value(
                         groupIter,
                         1,
                         newOutlineSquarePixbuf(group.color, 20, 0 if group.enable else 15, self.getRowBgColor()),
                     )
                     group.save()
                     if group.enable and self.trees.iter_n_children(groupIter) == 0 and len(group) > 0:
                         for event in group:
                             self.appendEventRow(groupIter, event)
                         self.loadedGroupIds.add(group.id)
                     self.onGroupModify(group)
                     treev.set_cursor(path)
                     return True
Exemplo n.º 10
0
from scal2.ui_gtk.drawing import newOutlineSquarePixbuf

import gtk
from gtk import gdk

from scal2.ui_gtk.mywidgets import TextFrame
from scal2.ui_gtk.mywidgets.multi_spin_button import IntSpinButton, FloatSpinButton

#print 'Testing translator', __file__, _('_About')## OK


getGroupRow = lambda group, rowBgColor: (
    group.id,
    newOutlineSquarePixbuf(
        group.color,
        20,
        0 if group.enable else 15,
        rowBgColor,
    ),
    group.title
)

class IconSelectButton(gtk.Button):
    def __init__(self, filename=''):
        gtk.Button.__init__(self)
        self.image = gtk.Image()
        self.add(self.image)
        self.dialog = gtk.FileChooserDialog(
            title=_('Select Icon File'),
            action=gtk.FILE_CHOOSER_ACTION_OPEN,
        )
        okB = self.dialog.add_button(gtk.STOCK_OK, gtk.RESPONSE_OK)
Exemplo n.º 11
0
from scal2.ui_gtk import *
from scal2.ui_gtk.utils import toolButtonFromStock, set_tooltip, labelStockMenuItem
from scal2.ui_gtk.utils import dialog_add_button, getStyleColor
from scal2.ui_gtk.drawing import newOutlineSquarePixbuf
from scal2.ui_gtk.mywidgets import TextFrame
from scal2.ui_gtk.mywidgets.icon import IconSelectButton
from scal2.ui_gtk.mywidgets.multi_spin.integer import IntSpinButton
from scal2.ui_gtk.mywidgets.multi_spin.float_num import FloatSpinButton
from scal2.ui_gtk.event import makeWidget
from scal2.ui_gtk.event.utils import *

getGroupRow = lambda group, rowBgColor: (group.id,
                                         newOutlineSquarePixbuf(
                                             group.color,
                                             20,
                                             0 if group.enable else 15,
                                             rowBgColor,
                                         ), group.title)


class WidgetClass(gtk.VBox):
    def __init__(self, event):
        from scal2.ui_gtk.mywidgets.cal_type_combo import CalTypeCombo
        from scal2.ui_gtk.mywidgets.tz_combo import TimeZoneComboBoxEntry
        gtk.VBox.__init__(self)
        self.event = event
        ###########
        hbox = gtk.HBox()
        ###
        pack(hbox, gtk.Label(_('Calendar Type')))
        combo = CalTypeCombo()
Exemplo n.º 12
0
 def genRightClickMenu(self, path):
     ## how about multi-selection? FIXME
     ## and Select _All menu item
     obj_list = self.getObjsByPath(path)
     #print(len(obj_list))
     menu = gtk.Menu()
     if len(obj_list)==1:
         group = obj_list[0]
         if group.name == 'trash':
             #print('right click on trash', group.title)
             menu.add(labelStockMenuItem(
                 'Edit',
                 gtk.STOCK_EDIT,
                 self.editTrash,
             ))
             menu.add(labelStockMenuItem(
                 'Empty Trash',
                 gtk.STOCK_CLEAR,
                 self.emptyTrash,
             ))
             #menu.add(gtk.SeparatorMenuItem())
             #menu.add(labelStockMenuItem(
             #    'Add New Group',
             #    gtk.STOCK_NEW,
             #    self.addGroupBeforeSelection,
             #))## FIXME
         else:
             #print('right click on group', group.title)
             menu.add(labelStockMenuItem(
                 'Edit',
                 gtk.STOCK_EDIT,
                 self.editGroupFromMenu,
                 path,
             ))
             eventTypes = group.acceptsEventTypes
             if eventTypes is None:
                 eventTypes = event_lib.classes.event.names
             if len(eventTypes) > 3:
                 menu.add(labelStockMenuItem(
                     _('Add Event'),
                     gtk.STOCK_ADD,
                     self.addGenericEventToGroupFromMenu,
                     path,
                     group,
                 ))
             else:
                 for eventType in eventTypes:
                     #if eventType == 'custom':## FIXME
                     #    desc = _('Add ') + _('Event')
                     #else:
                     label = _('Add ') + event_lib.classes.event.byName[eventType].desc
                     menu.add(labelStockMenuItem(
                         label,
                         gtk.STOCK_ADD,
                         self.addEventToGroupFromMenu,
                         path,
                         group,
                         eventType,
                         label,
                     ))
             pasteItem = labelStockMenuItem(
                 'Paste Event',
                 gtk.STOCK_PASTE,
                 self.pasteEventFromMenu,
                 path,
             )
             menu.add(pasteItem)
             pasteItem.set_sensitive(self.canPasteToGroup(group))
             ##
             menu.add(gtk.SeparatorMenuItem())
             #menu.add(labelStockMenuItem(
             #    'Add New Group',
             #    gtk.STOCK_NEW,
             #    self.addGroupBeforeGroup,
             #    path,
             #))## FIXME
             menu.add(labelStockMenuItem(
                 'Duplicate',
                 gtk.STOCK_COPY,
                 self.duplicateGroupFromMenu,
                 path,
             ))
             ###
             dupAllItem = labelStockMenuItem(
                 'Duplicate with All Events',
                 gtk.STOCK_COPY,
                 self.duplicateGroupWithEventsFromMenu,
                 path,
             )
             menu.add(dupAllItem)
             dupAllItem.set_sensitive(bool(group.idList))
             ###
             menu.add(gtk.SeparatorMenuItem())
             menu.add(labelStockMenuItem(
                 'Delete Group',
                 gtk.STOCK_DELETE,
                 self.deleteGroupFromMenu,
                 path,
             ))
             menu.add(gtk.SeparatorMenuItem())
             ##
             #menu.add(labelStockMenuItem(
             #    'Move Up',
             #    gtk.STOCK_GO_UP,
             #    self.moveUpFromMenu,
             #    path,
             #))
             #menu.add(labelStockMenuItem(
             #    'Move Down',
             #    gtk.STOCK_GO_DOWN,
             #    self.moveDownFromMenu,
             #    path,
             #))
             ##
             menu.add(labelStockMenuItem(
                 _('Export'),
                 gtk.STOCK_CONVERT,
                 self.groupExportFromMenu,
                 group,
             ))
             ###
             sortItem = labelStockMenuItem(
                 _('Sort Events'),
                 gtk.STOCK_SORT_ASCENDING,
                 self.groupSortFromMenu,
                 path,
             )
             menu.add(sortItem)
             sortItem.set_sensitive(bool(group.idList))
             ###
             convertItem = labelStockMenuItem(
                 _('Convert Calendar Type'),
                 gtk.STOCK_CONVERT,
                 self.groupConvertModeFromMenu,
                 group,
             )
             menu.add(convertItem)
             convertItem.set_sensitive(bool(group.idList))
             ###
             #if group.remoteIds:
             #    account = ui.eventAccounts[group.remoteIds[0]]
             #    menu.add(labelImageMenuItem(
             #    _('Synchronize with %s') % account.title,
             #    gtk.STOCK_REFRESH,
             #    self.syncGroup,
             #    path,
             #))
             ###
             for newGroupType in group.canConvertTo:
                 menu.add(labelStockMenuItem(
                     _('Convert to %s')%event_lib.classes.group.byName[newGroupType].desc,
                     None,
                     self.groupConvertTo,
                     group,
                     newGroupType,
                 ))
             ###
             bulkItem = labelStockMenuItem(
                 _('Bulk Edit Events'),
                 gtk.STOCK_EDIT,
                 self.groupBulkEditFromMenu,
                 group,
                 path,
             )
             menu.add(bulkItem)
             bulkItem.set_sensitive(bool(group.idList))
             ###
             for actionName, actionFuncName in group.actions:
                 menu.add(labelStockMenuItem(
                     _(actionName),
                     None,
                     self.groupActionClicked,
                     group,
                     actionFuncName,
                 ))
     elif len(obj_list) == 2:
         group, event = obj_list
         #print('right click on event', event.summary)
         if group.name != 'trash':
             menu.add(labelStockMenuItem(
                 'Edit',
                 gtk.STOCK_EDIT,
                 self.editEventFromMenu,
                 path,
             ))
         ####
         moveToItem = labelStockMenuItem(
             _('Move to %s')%'...',
             None,## FIXME
         )
         moveToMenu = gtk.Menu()
         for new_group in ui.eventGroups:
             if new_group.id == group.id:
                 continue
             #if not new_group.enable:## FIXME
             #    continue
             new_groupPath = self.trees.get_path(self.groupIterById[new_group.id])
             if event.name in new_group.acceptsEventTypes:
                 new_groupItem = gtk.ImageMenuItem()
                 new_groupItem.set_label(new_group.title)
                 ##
                 image = gtk.Image()
                 image.set_from_pixbuf(newOutlineSquarePixbuf(new_group.color, 20))
                 new_groupItem.set_image(image)
                 ##
                 new_groupItem.connect(
                     'activate',
                     self.moveEventToPathFromMenu,
                     path,
                     new_groupPath,
                 )
                 ##
                 moveToMenu.add(new_groupItem)
         moveToItem.set_submenu(moveToMenu)
         menu.add(moveToItem)
         ####
         menu.add(gtk.SeparatorMenuItem())
         ####
         menu.add(labelStockMenuItem(
             'Cut',
             gtk.STOCK_CUT,
             self.cutEvent,
             path,
         ))
         menu.add(labelStockMenuItem(
             'Copy',
             gtk.STOCK_COPY,
             self.copyEvent,
             path,
         ))
         ##
         if group.name == 'trash':
             menu.add(gtk.SeparatorMenuItem())
             menu.add(labelStockMenuItem(
                 'Delete',
                 gtk.STOCK_DELETE,
                 self.deleteEventFromTrash,
                 path,
             ))
         else:
             pasteItem = labelStockMenuItem(
                 'Paste',
                 gtk.STOCK_PASTE,
                 self.pasteEventFromMenu,
                 path,
             )
             menu.add(pasteItem)
             pasteItem.set_sensitive(self.canPasteToGroup(group))
             ##
             menu.add(gtk.SeparatorMenuItem())
             menu.add(labelImageMenuItem(
                 _('Move to %s')%ui.eventTrash.title,
                 ui.eventTrash.icon,
                 self.moveEventToTrashFromMenu,
                 path,
             ))
     else:
         return
     menu.show_all()
     return menu