Exemplo n.º 1
0
 def updatemenubar(self):
     changed = 0
     on = (self.active <> None)
     if on <> self.windowgroup_on:
         for m in self.windowgroup:
             m.enable(on)
         self.windowgroup_on = on
         changed = 1
     if on:
         # only if we have an edit menu
         on = self.active.have_selection()
         if on <> self.focusgroup_on:
             for m in self.focusgroup:
                 m.enable(on)
             self.focusgroup_on = on
             changed = 1
         if hasattr(Scrap, 'InfoScrap'):
             on = (Scrap.InfoScrap()[0] <> 0)
         else:
             flavors = Scrap.GetCurrentScrap().GetScrapFlavorInfoList()
             for tp, info in flavors:
                 if tp == 'TEXT':
                     on = 1
                     break
             else:
                 on = 0
         if on <> self.pastegroup_on:
             self.pasteitem.enable(on)
             self.pastegroup_on = on
             changed = 1
     if changed:
         DrawMenuBar()
Exemplo n.º 2
0
def FrontWindowInsert(stuff):
    if not stuff:
        return
    if type(stuff) <> StringType:
        raise TypeError, 'string expected'
    import W
    app = W.getapplication()
    wid = MyFrontWindow()
    if wid and app._windows.has_key(wid):
        window = app._windows[wid]
        if hasattr(window, "insert"):
            try:
                window.insert(stuff)
                return
            except:
                pass
    import EasyDialogs
    if EasyDialogs.AskYesNoCancel(
            "Can't find window or widget to insert text into; copy to clipboard instead?",
            1) == 1:
        from Carbon import Scrap
        if hasattr(Scrap, 'PutScrap'):
            Scrap.ZeroScrap()
            Scrap.PutScrap('TEXT', stuff)
        else:
            Scrap.ClearCurrentScrap()
            sc = Scrap.GetCurrentScrap()
            sc.PutScrapFlavor('TEXT', 0, stuff)
Exemplo n.º 3
0
 def domenu_copy(self, *args):
     sel = self.getselection()
     selitems = []
     for i in sel:
         selitems.append(str(self.items[i]))
     text = string.join(selitems, '\r')
     if text:
         if hasattr(Scrap, 'PutScrap'):
             Scrap.ZeroScrap()
             Scrap.PutScrap('TEXT', text)
         else:
             Scrap.ClearCurrentScrap()
             sc = Scrap.GetCurrentScrap()
             sc.PutScrapFlavor('TEXT', 0, text)
Exemplo n.º 4
0
 def domenu_copy(self, *args):
     sel = self.getselectedobjects()
     selitems = []
     for key, value, dummy, dummy in sel:
         selitems.append(double_repr(key, value))
     text = string.join(selitems, '\r')
     if text:
         from Carbon import Scrap
         if hasattr(Scrap, 'PutScrap'):
             Scrap.ZeroScrap()
             Scrap.PutScrap('TEXT', text)
         else:
             Scrap.ClearCurrentScrap()
             sc = Scrap.GetCurrentScrap()
             sc.PutScrapFlavor('TEXT', 0, text)
Exemplo n.º 5
0
 def domenu_openbyname(self, *args):
     # Open a file by name. If the clipboard contains a filename
     # use that as the default.
     from Carbon import Scrap
     try:
         sc = Scrap.GetCurrentScrap()
         dft = sc.GetScrapFlavorData("TEXT")
     except Scrap.Error:
         dft = ""
     else:
         if not os.path.exists(dft):
             dft = ""
     filename = EasyDialogs.AskString("Open File Named:",
                                      default=dft,
                                      ok="Open")
     if filename:
         self.openscript(filename)