def Delete_Inner_Backup(self): count = os.listdir(Functions.home + "/" + Functions.bd).__len__() if count > 0: GLib.idle_add(setMessage,self.label_info, "Removing ...") GLib.idle_add(setProgress, self.progressbar, 0.3) treeselect = self.treeView2.get_selection() for filename in os.listdir(Functions.home + "/" + Functions.bd + "/" + self.backs.get_active_text()): (model, pathlist) = treeselect.get_selected_rows() for path in pathlist : tree_iter = model.get_iter(path) value = model.get_value(tree_iter,0) if filename == value: # print(value) if os.path.isdir(Functions.home + "/" + Functions.bd + "/" + self.backs.get_active_text() + "/" + filename): Functions.shutil.rmtree(Functions.home + "/" + Functions.bd + "/" + self.backs.get_active_text() + "/" + filename) elif os.path.isfile(Functions.home + "/" + Functions.bd + "/" + self.backs.get_active_text() + "/" + filename): os.unlink(Functions.home + "/" + Functions.bd + "/" + self.backs.get_active_text() + "/" + filename) GLib.idle_add(refresh_inner, self) GLib.idle_add(setProgress, self.progressbar, 1) GLib.idle_add(Functions.show_in_app_notification,self, "Config backups cleaned.") GLib.idle_add(setMessage,self.label_info, "Idle ...") GLib.idle_add(button_toggles, self, True) GLib.idle_add(setProgress, self.progressbar, 0)
def get_cursor_themes(self, combo): if os.path.isfile(Functions.gtk3_settings): try: combo.get_model().clear() active_combo_cursor = "" coms = [] with open(Functions.gtk3_settings, "r") as f: lines = f.readlines() f.close() pos = int( Functions.gtk_get_position(lines, "gtk-cursor-theme-name")) output = lines[pos].split("=") active_combo_cursor = output[1].lstrip().rstrip() for folder in os.listdir("/usr/share/icons"): if os.path.isdir("/usr/share/icons/" + folder): check = os.listdir("/usr/share/icons/" + folder) if "cursors" in check: coms.append(folder) coms.sort() for i in range(len(coms)): combo.append_text(coms[i]) if (coms[i] == active_combo_cursor): combo.set_active(i) except: Functions.MessageBox( "ERROR!!", "An error has occured getting this setting \'gtk-cursor-theme-name\'" )
def refresh_inner(self): count = os.listdir(Functions.home + "/" + Functions.bd).__len__() active_text = "".join([str(self.backs.get_active_text()), ""]) if count > 0: if os.path.isdir(Functions.home + "/" + Functions.bd + "/" + active_text): self.store2.clear() for filename in os.listdir(Functions.home + "/" + Functions.bd + "/" + active_text): self.store2.append([filename]) else: self.store2.clear()
def get_slimlock(combo): coms = [] if os.path.isfile(Functions.slimlock_conf): with open(Functions.slimlock_conf, "r") as f: lines = f.readlines() f.close() for line in lines: if "current_theme" in line: # value = line.split(" ") # val = value[len(value)-1].lstrip().rstrip() # coms.append(val) if "#" not in line: value = line.split(" ") val = value[len(value) - 1].lstrip().rstrip() active = val.strip() for folder in os.listdir("/usr/share/slim/themes/"): if os.path.isdir("/usr/share/slim/themes/" + folder): coms.append(folder) coms.sort() for i in range(len(coms)): combo.append_text(coms[i]) if (coms[i] == active): combo.set_active(i)
def pop_bar(self, *args, **kwargs): active = 0 name = "" self.pbcombo.get_model().clear() if os.path.isfile(launch): with open(launch, "r") as f: lines = f.readlines() f.close() for j in range(len(lines)): if "MONITOR=$m" in lines[j]: nline = lines[j].split(" ") for i in range(len(nline)): if "polybar/" in nline[i]: name = os.path.basename(nline[i]) break else: self.pblabel4.set_markup("<span foreground=\"orange\">launch.sh <b>NOT</b> found!</span>") if kwargs.get('imported', None) is not None: name = kwargs.get('impname', None) if os.path.isdir(home + "/.config/polybar"): items = os.listdir(home + "/.config/polybar") for i in range(len(items)): if "config" in items[i]: if name.strip() == items[i].strip(): active = i self.pbcombo.append_text(items[i]) self.pbcombo.set_active(active)
def Delete_Backup(self): count = os.listdir(Functions.home + "/" + Functions.bd).__len__() if count > 0: GLib.idle_add(setMessage,self.label_info, "Removing ...") GLib.idle_add(setProgress, self.progressbar, 0.3) for filename in os.listdir(Functions.home + "/" + Functions.bd): if filename == self.backs.get_active_text(): Functions.shutil.rmtree(Functions.home + "/" + Functions.bd + "/" + filename) GLib.idle_add(refresh, self) GLib.idle_add(refresh_inner, self) GLib.idle_add(setProgress, self.progressbar, 1) GLib.idle_add(Functions.show_in_app_notification,self, "Config backups cleaned.") GLib.idle_add(button_toggles, self, True) GLib.idle_add(setMessage,self.label_info, "Idle ...") GLib.idle_add(setProgress, self.progressbar, 0)
def get_themes(combo): # noqa if os.path.isdir(Functions.home + "/.config/termite/themes/"): themes = os.listdir(Functions.home + "/.config/termite/themes/") combo.get_model().clear() with open(Functions.termite_config, "r") as f: lines = f.readlines() f.close() try: theme_line = lines[Functions._get_position(lines, "[colors]") + 1] active = "" coms = [] for theme in themes: if ".config" in theme: if theme.replace("base16-", "").replace( ".config", "").capitalize() in theme_line: active = theme.replace(".config", "") coms.append(theme.replace(".config", "")) coms.sort() if Functions.os.path.isfile(Functions.config): themes = Settings.read_settings("TERMITE", "theme") if len(themes) > 1: active = themes for i in range(len(coms)): combo.append_text(coms[i]) if active == coms[i]: combo.set_active(i) except: # noqa pass
def Flush_All(self): count = os.listdir(Functions.home + "/" + Functions.bd).__len__() if count > 0: count = ((count/count)/count) GLib.idle_add(setMessage,self.label_info, "Deleting Backup") for filename in os.listdir(Functions.home + "/" + Functions.bd): if os.path.isdir(Functions.home + "/" + Functions.bd + "/" + filename): GLib.idle_add(setProgress, self.progressbar, self.progressbar.get_fraction() + count) Functions.shutil.rmtree(Functions.home + "/" + Functions.bd + "/" + filename) GLib.idle_add(Functions.show_in_app_notification,self, "Backups directory has been cleaned.") GLib.idle_add(refresh, self) GLib.idle_add(refresh_inner, self) GLib.idle_add(setProgress, self.progressbar, 0) GLib.idle_add(button_toggles, self, True) GLib.idle_add(setMessage,self.label_info, "Idle ...")
def refresh(self): if not os.path.exists(Functions.home + "/" + Functions.bd): os.makedirs(Functions.home + "/" + Functions.bd) self.backs.get_model().clear() BACKUPS_CATS = [] for filename in os.listdir(Functions.home + "/" + Functions.bd): if os.path.isdir(Functions.home + "/" + Functions.bd + "/" + filename): BACKUPS_CATS.append(filename) for item in BACKUPS_CATS: self.backs.append_text(item) self.backs.set_active(0)
def reload_import(combo, theme): combo.get_model().clear() coms = [] if os.path.isfile(Functions.slimlock_conf): # with open(Functions.slimlock_conf, "r") as f: # lines = f.readlines() # f.close() for folder in os.listdir("/usr/share/slim/themes/"): if os.path.isdir("/usr/share/slim/themes/" + folder): coms.append(folder) coms.sort() for i in range(len(coms)): combo.append_text(coms[i]) if (coms[i] == theme): combo.set_active(i)
def pop_neofetch_box(combo): if os.path.isfile(Functions.neofetch_config): com = [] for image in os.listdir(Functions.home + "/.config/neofetch/"): if ".png" in image: com.append(image) sorted_com = sorted(com) active = 0 lines = get_neofetch() for i in range(len(lines)): if "image_source" in lines[i]: if not "#" in lines[i]: line = lines[i].split("=")[1].replace("\"", "") active = i + 1 for i in range(len(sorted_com)): combo.append_text(sorted_com[i]) #if sorted_com[i] == active: combo.set_active(i)