Changeset 87

Show
Ignore:
Timestamp:
Wed Aug 3 10:55:50 2005
Author:
fredrikc
Message:

Drag & Drop files to open files in xliffeditor works (Only tested on win32).
Refactored to prepare for creating a TM Gui.

Files:

Legend:

Unmodified
Added
Removed
Modified
  • trunk/transolution/xliffeditor/gtk_main.py

    r83 r87  
    74 74     return formatter  
    75 75  
    76   from transolution.path_mod import path  
    77   def getLangCodes():  
    78       flangcodes = path(transolution.xliffeditor.langsdir) / 'langcodes.txt'  
    79       for line in flangcodes.lines():  
    80           cols = line.strip().split('\t')  
    81           try:  
    82               lang,country,lcid = cols  
    83           except ValueError,e:  
    84               print e  
    85           else:  
    86               yield lang,country,lcid  
    87 76  
    88 77 import tm  
      78 from transolution import getLangCodes  
    89 79 import transolution.xliffeditor  
      80 from transolution.path_mod import path  
      81  
    90 82  
    91 83 class TmSettings(object):  
     
    474 466 ##        self.tag_table.foreach(lambda a,b: a.set_property('scale',pango.SCALE_LARGE),None)  
    475 467  
    476   class MainWindowBase2(MainWindowBase):  
    477       'Add Search & replace dialog and callbacks to MainWindowBase'  
      468  
      469 class MainWindowBase1(MainWindowBase):  
      470     'Add Drag/Drop fileopen support MainWindowBase'  
    478 471     def __init__(self,*args,**kwargs):  
    479 472         MainWindowBase.__init__(self,*args,**kwargs)  
      473  
      474         # enable Drag/Drop  
      475         self.window.drag_dest_set(gtk.gdk.ACTION_DEFAULT, [], 0)  
      476         self.window.connect('drag_drop', self.target_drag_drop)  
      477         self.window.connect('drag_data_received', self.target_drag_data_received)  
      478  
      479     def target_drag_drop(self, widget, context, x, y, time):  
      480         if context.targets:  
      481             widget.drag_get_data(context, context.targets[0], time)  
      482             return True  
      483         return False  
      484  
      485     def target_drag_data_received(self, widget, context, x, y, selection, targetType,time):  
      486         'Called when things are dropped on the main window'  
      487         if selection.format == 8:  
      488             from urllib import url2pathname  
      489             # try and open all file URL's dropped  
      490             for fname in selection.data.split(os.linesep):  
      491                 fname = fname.replace('file:///','')  
      492                 fname = path(url2pathname(fname))  
      493                 if fname.isfile():  
      494                     self.openFile(fname)  
      495             context.finish(True, False, time)  
      496         else:  
      497             context.finish(False, False, time)  
      498  
      499  
      500 class MainWindowBase2(MainWindowBase1):  
      501     'Add Search & replace dialog and callbacks to MainWindowBase'  
      502     def __init__(self,*args,**kwargs):  
      503         MainWindowBase1.__init__(self,*args,**kwargs)  
    480 504         self.search_replace_dlg = SearchReplaceDialog(self.window)  
    481 505         self.search_replace_dlg.hide()  
  • trunk/transolution/xliffeditor/__init__.py

    r63 r87  
    2 2 GLADEDIR ='glade'  
    3 3 IMAGEDIR ='images'  
    4   LANGSDIR ='langs'  
    5 4 gladename="xliffeditor.glade"  
    6 5  
     
    11 10 imagedir = os.path.join(__path__[0], IMAGEDIR)  
    12 11  
    13   langsdir = os.path.join(__path__[0], LANGSDIR)  
    14    
    15 12 # makes it work when run as py2exe  
    16 13 if not os.path.isfile(gladefile):  
     
    18 15 if not os.path.isdir(imagedir):  
    19 16     imagedir = os.path.join('', IMAGEDIR)  
    20   if not os.path.isdir(langsdir):  
    21       langsdir = os.path.join('', LANGSDIR)  
  • trunk/transolution/tm/server/__init__.py

    r2 r87  
    1 1 __doc__ = '''Transilation Memory server module'''  
      2  
      3 import os  
      4 GLADEDIR ='glade'  
      5 IMAGEDIR ='images'  
      6 LANGSDIR ='langs'  
      7 gladename="tm_server.glade"  
      8  
      9 ##    gladedir = os.path.join(os.path.dirname(__file__), GLADEDIR)  
      10 gladedir = os.path.join(__path__[0], GLADEDIR)  
      11 gladefile = os.path.join(gladedir, gladename)  
      12  
      13 imagedir = os.path.join(__path__[0], IMAGEDIR)  
      14  
      15 langsdir = os.path.join(__path__[0], LANGSDIR)  
      16  
      17 # makes it work when run as py2exe  
      18 if not os.path.isfile(gladefile):  
      19     gladefile = os.path.join(GLADEDIR, gladename)  
      20 if not os.path.isdir(imagedir):  
      21     imagedir = os.path.join('', IMAGEDIR)  
      22 if not os.path.isdir(langsdir):  
      23     langsdir = os.path.join('', LANGSDIR)  
     
  • trunk/transolution/tm/server/estreen.py

    r74 r87  
    153 153             return tuv.seg.node.cloneNode(True)  
    154 154  
    155   def main():  
      155 def startServer(slang1,tlang1,fnames,port):  
    155 155     global slang,tlang,tmidx  
    156       options = parseArgs()  
    157       slang = options.slang  
    158       tlang = options.tlang  
    159    
      156     slang = slang1  
      157     tlang = tlang1  
      158      
    160 159     tmidx = index.VectorIndex()  
    161 160     tmidx.nodesize = 40  
    162 161     tmidx.fuzz = 0  
    163 162  
    164       for tmxfile in options.fnames:  
      163     for tmxfile in fnames:  
    164 163         print "importing:%s"%(tmxfile,)  
    165 164         tmidx = importTMX(tmxfile,tmidx)  
     
    170 169     import SimpleXMLRPCServer  
    171 170     tm = TMServer()  
    172       server = SimpleXMLRPCServer.SimpleXMLRPCServer(("localhost", options.port))  
      171     server = SimpleXMLRPCServer.SimpleXMLRPCServer(("localhost", port))  
    172 171     server.register_instance(tm)  
    173 172  
    174 173     #Go into the main listener loop  
    175       print "TM server listening on port",options.port  
      174     print "TM server listening on port",port  
    175 174     server.serve_forever()  
      175      
      176 def main(**options):  
      177     if not options:  
      178         # parse commandline  
      179         options = parseArgs()  
      180     # Start the server  
      181     startServer(options.slang,options.tlang,options.fnames,options.port)  
    176 182  
    177 183 if __name__ == '__main__':  
  • trunk/transolution/__init__.py

    r2 r87  
      1 import os  
      2 LANGSDIR ='langs'  
      3 langsdir = os.path.join(__path__[0], LANGSDIR)  
      4  
      5 # makes it work when run as py2exe  
      6 if not os.path.isdir(langsdir):  
      7     langsdir = os.path.join('', LANGSDIR)  
      8  
      9 from path_mod import path  
      10 def getLangCodes():  
      11     flangcodes = path(langsdir) / 'langcodes.txt'  
      12     for line in flangcodes.lines():  
      13         cols = line.strip().split('\t')  
      14         try:  
      15             lang,country,lcid = cols  
      16         except ValueError,e:  
      17             print e  
      18         else:  
      19             yield lang,country,lcid  
  • trunk/transolution/tmx/__init__.py

    r86 r87  
    121 121             raise TMXSyntaxError("Invalid TMX Syntax, expected tu\n")  
    122 122     def getKey(self,lang):  
    123           key = []  
      123         key = []  
      124         lang = lang.upper()  
    124 125         retkey = []  
    125 126         for tuv in self.tuvs:  
    126               if tuv.lang == lang:  
      127             if tuv.lang.upper() == lang:  
    126 127                 for word in tuv.seg.data.split():  
    127 128                     key.append(hash(word))  
  • trunk/win_setup.py

    r77 r87  
    42 42     data_files=[("images", glob.glob("transolution/xliffeditor/images/*.png")),  
    43 43                 ("glade", glob.glob("transolution/xliffeditor/glade/*")),  
    44                   ("langs", glob.glob("transolution/xliffeditor/langs/*")),  
      44                 ("langs", glob.glob("transolution/langs/*")),  
    44 44                 ("po", glob.glob("transolution/xliffeditor/po/*")),  
    45 45                 ("filter_settings", glob.glob("transolution/filters/filter_settings/*"))