Exemplo n.º 1
0
 def dragRec(self, obj, context, x, y, selection, target_id, etime):
     text = selection.get_text()
     if text==None:
         return
     date = ui.parseDroppedDate(text)
     if date==None:
         print('selectDateDialog: dropped text "%s"'%text)
         return
     print('selectDateDialog: dropped date: %d/%d/%d'%date)
     mode = self.comboMode.get_active()
     if mode!=ui.dragGetMode:
         date = convert(date[0], date[1], date[2], ui.dragGetMode, mode)
     self.dateInput.set_value(date)
     self.dateInput.add_history()
     return True
Exemplo n.º 2
0
	def dragRec(self, obj, context, x, y, selection, target_id, etime):
		text = selection.get_text()
		if text==None:
			return
		date = ui.parseDroppedDate(text)
		if date==None:
			print('selectDateDialog: dropped text "%s"'%text)
			return
		print('selectDateDialog: dropped date: %d/%d/%d'%date)
		mode = self.comboMode.get_active()
		if mode!=ui.dragGetMode:
			date = convert(date[0], date[1], date[2], ui.dragGetMode, mode)
		self.dateInput.set_value(date)
		self.dateInput.add_history()
		return True
Exemplo n.º 3
0
 def dragRec(self, obj, context, x, y, selection, target_id, etime):
     text = selection.get_text()
     if text==None:
         return
     date = ui.parseDroppedDate(text)
     if date==None:
         print 'selectDateDialog: dropped text "%s"'%text
         return
     print 'selectDateDialog: dropped date: %d/%d/%d'%date
     mode = self.comboMode.currentIndex()
     if mode!=ui.dragGetMode:
         date = convert(date[0], date[1], date[2], ui.dragGetMode, mode)
     y, m, d = date
     self.spinY.setValue(y)
     self.comboMonth.setCurrentIndex(m-1)
     self.spinD.setValue(d)
     self.dateInput.setDate(y, m, d)
     #self.dateInput.addHistory()
     return True
Exemplo n.º 4
0
def processDroppedDate(text, dtype):
    ## data_type: "UTF8_STRING", "application/x-color", "text/uri-list",
    if dtype=='UTF8_STRING':
        if text.startswith('file://'):
            path = core.urlToPath(text)
            try:
                t = os.stat(path).st_mtime ## modification time
            except OSError:
                print 'Dropped invalid file "%s"'%path
            else:
                y, m, d = localtime(t)[:3]
                #print 'Dropped file "%s", modification time: %s/%s/%s'%(path, y, m, d)
                return (y, m, d, core.DATE_GREG)
        else:
            date = ui.parseDroppedDate(text)
            if date:
                return date + (ui.dragRecMode,)
            else:
                ## Hot to deny dragged object (to return to it's first location)
                ## FIXME
                print 'Dropped unknown text "%s"'%text
                #print etime
                #context.drag_status(gdk.ACTION_DEFAULT, etime)
                #context.drop_reply(False, etime)
                #context.drag_abort(etime)##Segmentation fault
                #context.drop_finish(False, etime)
                #context.finish(False, True, etime)
                #return True
    elif dtype=='text/uri-list':
        path = core.urlToPath(selection.data)
        try:
            t = os.stat(path).st_mtime ## modification time
        except OSError:
            print 'Dropped invalid uri "%s"'%path
            return True
        else:
            return localtime(t)[:3] + (core.DATE_GREG,)
Exemplo n.º 5
0
 def dragDataRec(self, obj, context, x, y, selection, target_id, etime):
     try:
         dtype = selection.get_data_type()
     except AttributeError:## Old PyGTK
         dtype = selection.type
     text = selection.get_text()
     ## data_type: "UTF8_STRING", "application/x-color", "text/uri-list",
     if dtype=='UTF8_STRING':
         #text = selection.get_text()
         #print 'Dropped text "%s"'%text
         if text.startswith('file://'):
             path = core.urlToPath(text)
             try:
                 t = os.stat(path).st_mtime ## modification time
             except OSError:
                 print 'Dropped invalid file "%s"'%path
             else:
                 (y, m, d) = localtime(t)[:3]
                 #print 'Dropped file "%s", modification time: %s/%s/%s'%(path, y, m, d)
                 self.changeDate(y, m, d, core.DATE_GREG)
             """
         elif text.startswith('#') and len(text)>=7:## not occures! disable it????
             ui.bgColor = ui.htmlColorToGdk(text)
             self.emit('pref-update-bg-color')
             self.queue_draw()"""
         else:
             date = ui.parseDroppedDate(text)
             if date:
                 (y, m, d) = date
                 self.changeDate(y, m, d, ui.dragRecMode)
             else:
                 ## Hot to deny(throw down) dragged object (to return to it's first location)
                 ##??????????????????????????????????????????????????????
                 print 'Dropped unknown text "%s"'%text
                 #print etime
                 #context.drag_status(gdk.ACTION_DEFAULT, etime)
                 #context.drop_reply(False, etime)
                 #context.drag_abort(etime)##Segmentation fault
                 #context.drop_finish(False, etime)
                 #context.finish(False, True, etime)
                 #return True
     elif dtype=='application/x-color':
         ## selection.get_text() == None
         text = selection.data
         ui.bgColor = (
             ord(text[1]),
             ord(text[3]),
             ord(text[5]),
             ord(text[7]),
         )
         self.emit('pref-update-bg-color')
         self.queue_draw()
     elif dtype=='text/uri-list':
             path = core.urlToPath(selection.data)
             try:
                 t = os.stat(path).st_mtime ## modification time
             except OSError:
                 print 'Dropped invalid uri "%s"'%path
                 return True
             else:
                 (y, m, d) = localtime(t)[:3]
                 self.changeDate(y, m, d, core.DATE_GREG)
     else:
         print 'Unknown dropped data type "%s", text="%s", data="%s"'%(dtype, text, selection.data)
         return True
     return False