def on_new_menu_button_clicked(self, button): menu_tree = self.tree.get_object('menu_tree') menus, iter = menu_tree.get_selection().get_selected() if not iter: parent = menus[(0,)][3] menu_tree.expand_to_path((0,)) menu_tree.get_selection().select_path((0,)) else: parent = menus[iter][3] file_path = os.path.join(util.getUserDirectoryPath(), util.getUniqueFileId('alacarte-made', '.directory')) process = subprocess.Popen(['cinnamon-desktop-editor', '-mdirectory', '-o' + file_path], env=os.environ) GObject.timeout_add(100, self.waitForNewMenuProcess, process, parent.get_menu_id(), file_path)
def on_new_item_button_clicked(self, button): menu_tree = self.tree.get_object('menu_tree') menus, iter = menu_tree.get_selection().get_selected() if not iter: parent = menus[(0,)][2] menu_tree.expand_to_path((0,)) menu_tree.get_selection().select_path((0,)) else: parent = menus[iter][2] file_path = os.path.join(util.getUserItemPath(), util.getUniqueFileId('alacarte-made', '.desktop')) process = subprocess.Popen(['gnome-desktop-item-edit', file_path], env=os.environ) GObject.timeout_add(100, self.waitForNewItemProcess, process, parent.get_menu_id(), file_path)
def on_new_item_button_clicked(self, button): menu_tree = self.tree.get_object('menu_tree') menus, iter = menu_tree.get_selection().get_selected() if not iter: parent = menus[(0,)][3] menu_tree.expand_to_path((0,)) menu_tree.get_selection().select_path((0,)) else: parent = menus[iter][3] file_path = os.path.join(util.getUserItemPath(), util.getUniqueFileId('alacarte-made', '.desktop')) process = subprocess.Popen(['cinnamon-desktop-editor', '-mlauncher', '-o' + file_path], env=os.environ) GObject.timeout_add(100, self.waitForNewItemProcess, process, parent.get_menu_id(), file_path)
def on_new_item_button_clicked(self, button): menu_tree = self.tree.get_object("menu_tree") menus, iter = menu_tree.get_selection().get_selected() if not iter: parent = menus[(0,)][3] menu_tree.expand_to_path((0,)) menu_tree.get_selection().select_path((0,)) else: parent = menus[iter][3] file_path = os.path.join(util.getUserItemPath(), util.getUniqueFileId("alacarte-made", ".desktop")) process = subprocess.Popen(["cinnamon-desktop-editor", "-mlauncher", "-o" + file_path], env=os.environ) GObject.timeout_add(100, self.waitForNewItemProcess, process, parent.get_menu_id(), file_path)
def on_new_menu_button_clicked(self, button): menu_tree = self.tree.get_object('menu_tree') menus, iter = menu_tree.get_selection().get_selected() if not iter: parent = menus[(0,)][3] menu_tree.expand_to_path((0,)) menu_tree.get_selection().select_path((0,)) else: parent = menus[iter][3] file_path = os.path.join(util.getUserDirectoryPath(), util.getUniqueFileId('alacarte-made', '.directory')) process = subprocess.Popen(['gnome-desktop-item-edit', file_path], env=os.environ) GObject.timeout_add(100, self.waitForNewMenuProcess, process, parent.get_menu_id(), file_path)
def writeItem(self, item, **kwargs): if item is not None: file_path = item.get_desktop_file_path() else: file_path = None keyfile = self.makeKeyFile(file_path, kwargs) if item is not None: file_id = item.get_desktop_file_id() else: file_id = util.getUniqueFileId(keyfile.get_string(GLib.KEY_FILE_DESKTOP_GROUP, 'Name'), '.desktop') contents, length = keyfile.to_data() f = open(os.path.join(util.getUserItemPath(), file_id), 'w') f.write(contents) f.close() return file_id
def pasteItem(self, cut_copy_buffer, menu, file_id = None): try: path = self.getPath(menu) util.fillKeyFile(cut_copy_buffer, dict(Hidden=False, NoDisplay=False)) name = util.getNameFromKeyFile(cut_copy_buffer) if file_id is None: file_id = util.getUniqueFileId(name.replace(os.sep, '-'), '.desktop') out_path = os.path.join(util.getUserItemPath(), file_id) contents, length = cut_copy_buffer.to_data() f = open(out_path, 'w') f.write(contents) f.close() menu_xml = self.getXmlMenu(path, self.dom.documentElement, self.dom) self.addXmlFilename(menu_xml, self.dom, file_id, 'Include') self.addXmlTextElement(menu_xml, 'AppDir', util.getUserItemPath(), self.dom) self.save() return True except: return False
def writeMenu(self, menu, **kwargs): if menu is not None: file_id = os.path.split(menu.get_desktop_file_path())[1] file_path = menu.get_desktop_file_path() keyfile = GLib.KeyFile() keyfile.load_from_file(file_path, util.KEY_FILE_FLAGS) elif menu is None and 'Name' not in kwargs: raise Exception('New menus need a name') else: file_id = util.getUniqueFileId(kwargs['Name'], '.directory') keyfile = GLib.KeyFile() util.fillKeyFile(keyfile, kwargs) contents, length = keyfile.to_data() f = open(os.path.join(util.getUserDirectoryPath(), file_id), 'w') f.write(contents) f.close() return file_id
def copyItem(self, item, new_parent, before=None, after=None): dom = self.dom file_path = item.get_desktop_file_path() keyfile = GLib.KeyFile() keyfile.load_from_file(file_path, util.KEY_FILE_FLAGS) util.fillKeyFile(keyfile, dict(Categories=[], Hidden=False)) app_info = item.get_app_info() file_id = util.getUniqueFileId(app_info.get_name().replace(os.sep, '-'), '.desktop') out_path = os.path.join(util.getUserItemPath(), file_id) contents, length = keyfile.to_data() f = open(out_path, 'w') f.write(contents) f.close() self.addItem(new_parent, file_id, dom) self.positionItem(new_parent, ('Item', file_id), before, after) self.save() return file_id