[alacarte] MenuEditor: Remove silly Layout class stuff
- From: Jasper St. Pierre <jstpierre src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [alacarte] MenuEditor: Remove silly Layout class stuff
- Date: Wed, 20 Jun 2012 23:02:06 +0000 (UTC)
commit 37cc73d654f8774b1b23596874960a7a607425ea
Author: Jasper St. Pierre <jstpierre mecheye net>
Date: Wed Jun 20 15:04:45 2012 -0400
MenuEditor: Remove silly Layout class stuff
Alacarte/MenuEditor.py | 43 ++++++++++---------------------------------
1 files changed, 10 insertions(+), 33 deletions(-)
---
diff --git a/Alacarte/MenuEditor.py b/Alacarte/MenuEditor.py
index e1d07fb..f04dd20 100644
--- a/Alacarte/MenuEditor.py
+++ b/Alacarte/MenuEditor.py
@@ -488,7 +488,7 @@ class MenuEditor(object):
# add new layout
node = dom.createElement('Layout')
- for order in layout.order:
+ for order in layout:
if order[0] == 'Separator':
child = dom.createElement('Separator')
node.appendChild(child)
@@ -513,25 +513,18 @@ class MenuEditor(object):
return element.appendChild(node)
def createLayout(self, items):
- layout = Layout()
- layout.order = []
-
- layout.order.append(['Merge', 'menus'])
+ layout = []
+ layout.append(('Merge', 'menus'))
for item in items:
- if isinstance(item, tuple):
- if item[0] == 'Separator':
- layout.parseSeparator()
- elif item[0] == 'Menu':
- layout.parseMenuname(item[1])
- elif item[0] == 'Item':
- layout.parseFilename(item[1])
- elif isinstance(item, GMenu.TreeDirectory):
- layout.parseMenuname(item.get_menu_id())
+ if isinstance(item, GMenu.TreeDirectory):
+ layout.append(('Menuname', item.get_menu_id()))
elif isinstance(item, GMenu.TreeEntry):
- layout.parseFilename(item.get_desktop_file_id())
+ layout.append(('Filename', item.get_desktop_file_id()))
elif isinstance(item, GMenu.TreeSeparator):
- layout.parseSeparator()
- layout.order.append(['Merge', 'files'])
+ layout.append(('Separator',))
+ else:
+ layout.append(item)
+ layout.append(('Merge', 'files'))
return layout
def addItem(self, parent, file_id, dom):
@@ -609,19 +602,3 @@ class MenuEditor(object):
node.appendChild(self.addXmlTextElement(node, 'Old', final_old, dom))
node.appendChild(self.addXmlTextElement(node, 'New', new, dom))
return element.appendChild(node)
-
-class Layout(object):
- def __init__(self):
- self.order = []
-
- def parseMenuname(self, value):
- self.order.append(['Menuname', value])
-
- def parseSeparator(self):
- self.order.append(['Separator'])
-
- def parseFilename(self, value):
- self.order.append(['Filename', value])
-
- def parseMerge(self, merge_type='all'):
- self.order.append(['Merge', merge_type])
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]