Example #1
0
    def on_drag_data_received(self, widget, context, x, y, selection, info,
                              timestamp):
        root_y = widget.allocation.y + y
        try:
            pos = self.get_coordinate_row(root_y)
        except:
            pos = None

        if pos == None:
            pos = len(self.items)

        if selection.target in [
                "text/uri-list", "text/plain", "text/deepin-songs"
        ]:
            if selection.target == "text/deepin-songs" and selection.data:
                self.add_uris(selection.data.splitlines(), pos, False)
            elif selection.target == "text/uri-list":
                selected_uris = selection.get_uris()
                if len(selected_uris) == 1 and os.path.isdir(
                        utils.get_path_from_uri(selected_uris[0])):
                    self.recursion_add_dir(
                        utils.get_path_from_uri(selected_uris[0]))
                else:
                    utils.async_parse_uris(selection.get_uris(), True, False,
                                           self.add_uris, pos)
            elif selection.target == "text/plain":
                raw_path = selection.data
                path = eval("u" + repr(raw_path).replace("\\\\", "\\"))
                utils.async_get_uris_from_plain_text(path, self.add_uris, pos)
 def on_drag_data_received(self, widget, context, x, y, selection, info, timestamp):    
     root_y = widget.allocation.y + y
     try:
         pos = self.get_coordinate_row(root_y)
     except:    
         pos = None
         
     if pos == None:    
         pos = len(self.items)
         
     if selection.target in ["text/uri-list", "text/plain", "text/deepin-songs"]:
         if selection.target == "text/deepin-songs" and selection.data:
             self.add_uris(selection.data.splitlines(), pos, False)
         elif selection.target == "text/uri-list":    
             selected_uris = selection.get_uris()
             if len(selected_uris) == 1 and os.path.isdir(utils.get_path_from_uri(selected_uris[0])):
                 self.recursion_add_dir(utils.get_path_from_uri(selected_uris[0]))
             else:
                 utils.async_parse_uris(selection.get_uris(), True, False, self.add_uris, pos)
         elif selection.target == "text/plain":    
             raw_path = selection.data
             path = eval("u" + repr(raw_path).replace("\\\\", "\\"))
             utils.async_get_uris_from_plain_text(path, self.add_uris, pos)
 def async_add_uris(self, uris, follow_folder=True):        
     if not isinstance(uris, (list, tuple, set)):
         uris = [ uris ]
     utils.async_parse_uris(uris, follow_folder, True, self.add_uris)
 def add_dir(self):            
     select_dir = WinDir().run()
     if select_dir:
         utils.async_parse_uris([select_dir], True, False, self.add_uris)
Example #5
0
 def async_add_uris(self, uris, follow_folder=True):
     if not isinstance(uris, (list, tuple, set)):
         uris = [uris]
     utils.async_parse_uris(uris, follow_folder, True, self.add_uris)
Example #6
0
 def add_dir(self):
     select_dir = WinDir().run()
     if select_dir:
         utils.async_parse_uris([select_dir], True, False, self.add_uris)