Exemple #1
0
 def create_new_group(self):
     name = one_line_dialog(_("Create Group"), self.controls.main_window, message_text1=_("Enter group name"))
     if not name:
         return
     bean = self.get_selected_bean()
     folder_bean = FModel(name)
     if bean:
         if bean.is_file:
             folder_bean.add_parent(bean.parent_level)
         else:
             folder_bean.add_parent(bean.level)
     self.append(folder_bean)
Exemple #2
0
 def create_folder(self, a):
     model, tree_path, row = a
     file_path = row[self.path[0]]
     new_folder_path = create_folder_dialog(file_path)
     bean = FModel(os.path.basename(new_folder_path), new_folder_path).add_is_file(False)
     if os.path.isfile(file_path):
         bean.add_parent(row[self.parent_level[0]])
     elif os.path.isdir(file_path):
         bean.add_parent(row[self.level[0]])
     else:
         logging.error("So path doesn't exist")
     self.tree_append(bean)
     self.save_beans_from_tree()
Exemple #3
0
 def on_add_station(self):
     name, url = two_line_dialog(_("Add New Radio Station"),
                                 parent = self.controls.main_window,
                                 message_text1 = _("Enter station name and URL"),
                                 message_text2 = None,
                                 entry_text1 = None, 
                                 entry_text2 = "http://")
     if not name or not url:
         return
     bean = self.get_selected_bean()
     new_bean = FModel(name, url).add_type(FTYPE_RADIO).add_is_file(True)
     if bean:
         if bean.is_file:
             new_bean.add_parent(bean.parent_level)
         else:
             new_bean.add_parent(bean.level)
     self.append(new_bean)
Exemple #4
0
 def auto_add_user_station(self):
     if os.path.isfile(CACHE_RADIO_FILE) and os.path.getsize(CACHE_RADIO_FILE) > 0:
         with open(CACHE_RADIO_FILE, 'r') as f:
             list = f.readlines()
             parent_level_for_depth = {}
             previous = {"bean": None, "depth": 0, "name": '', "url": ''} 
             for line in list:
                 depth = self.simbol_counter(line, '-')
                 try:
                     name = line[depth : line.index('#')]
                 except ValueError, e:
                     logging.warning('\'#\' ' + str(e) + ' in line \"' + line + '\"')
                     continue
                 url = line[line.index('#') + 1 : -1]
                 bean = FModel(name)
                 if url:
                     bean.add_is_file(True).add_path(url).add_type(FTYPE_RADIO)
                 if previous["depth"] < depth:
                     bean.add_parent(previous["bean"].level)
                 elif previous["depth"] > depth:
                     bean.add_parent(parent_level_for_depth[depth]) 
                 else:
                     if previous["bean"]:
                         bean.add_parent(previous["bean"].parent_level)
                     
                 self.append(bean)
                 parent_level_for_depth[depth] = bean.parent_level
                 previous = {"bean": bean, "depth": depth, "name": name, "url": url}