# HG changeset patch
# User wycc@wycc-desktop
# Date 1229225014 -28800
# Node ID ad5c7a5c2c39afabe4b71930062eb00a5db700d0
# Parent 8d9d717c93005f156e790f84df48a685b54b72fb# Parent a0a3196b1a05513c8724fe6641fee1f5c0dba773
Add extention to the inkscape to edit one of the active/normal/click frame of a button. There is one unsolved issue. Users can not know the current frame easily unless they check the XML node editor. We should try to show something in the UI. However, I have no found any goo dway to do this. We may need to modify the inkscape directly for this function in the future.
diff -r 8d9d717c9300 -r ad5c7a5c2c39 inkscape/MB_EditActiveButton.py
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/inkscape/MB_EditActiveButton.py Sun Dec 14 11:23:34 2008 +0800
@@ -0,0 +1,70 @@
+#!/usr/bin/python
+import inkex
+import pygtk
+import gtk
+from copy import deepcopy
+
+class ConvertToButton(inkex.Effect):
+ def effect(self):
+ self.window = gtk.Window(gtk.WINDOW_TOPLEVEL)
+ self.window.set_position(gtk.WIN_POS_MOUSE)
+ self.defaultname = 'input symbol name here'
+ if self.fillcontent() == False:
+ self.window.show_all()
+ self.window.connect("delete_event", gtk.main_quit)
+ gtk.main()
+ def onQuit(self,data):
+ gtk.main_quit()
+ def onAssign(self,data):
+ text = self.text.get_text()
+ if text != self.defaultname:
+ self.node.set("mbname",text)
+ gtk.main_quit()
+
+ def confirm(self,msg):
+ vbox = gtk.VBox()
+ vbox.pack_start(gtk.Label(msg))
+ self.button = gtk.Button('OK')
+ vbox.pack_start(self.button)
+ self.button.connect("clicked", self.onQuit)
+ self.window.add(vbox)
+ def dumpattr(self,n):
+ s = ""
+ for a,v in n.attrib.items():
+ s = s + ("%s=%s" % (a,v))
+ return s
+
+ def dump(self,node,l=0):
+ print " " * l*2,"<", node.tag, self.dumpattr(node),">"
+ for n in node:
+ self.dump(n,l+1)
+ print " " * l * 2,"/>"
+
+ def hide_frame(self,frame):
+ frame.set('style','display:none')
+ def show_frame(self,frame):
+ frame.set('style','')
+
+
+ def fillcontent(self):
+ if len(self.selected) != 1:
+ self.confirm('Please select one group only')
+ return False
+ for id,node in self.selected.iteritems():
+ #self.dump(node)
+ name = node.get("mbname")
+ if name == None:
+ self.confirm("The MadButterFly symbol is not defined yet. Please convert it to the symbol before convert it to button.")
+ return False
+ for frame in node:
+ if frame.get('mbname') == name+'_active':
+ self.show_frame(frame)
+ else:
+ self.hide_frame(frame)
+ return True
+
+
+a=ConvertToButton()
+a.affect()
+
+# vim: set ts=4
diff -r 8d9d717c9300 -r ad5c7a5c2c39 inkscape/MB_EditClickButton.py
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/inkscape/MB_EditClickButton.py Sun Dec 14 11:23:34 2008 +0800
@@ -0,0 +1,70 @@
+#!/usr/bin/python
+import inkex
+import pygtk
+import gtk
+from copy import deepcopy
+
+class ConvertToButton(inkex.Effect):
+ def effect(self):
+ self.window = gtk.Window(gtk.WINDOW_TOPLEVEL)
+ self.window.set_position(gtk.WIN_POS_MOUSE)
+ self.defaultname = 'input symbol name here'
+ if self.fillcontent() == False:
+ self.window.show_all()
+ self.window.connect("delete_event", gtk.main_quit)
+ gtk.main()
+ def onQuit(self,data):
+ gtk.main_quit()
+ def onAssign(self,data):
+ text = self.text.get_text()
+ if text != self.defaultname:
+ self.node.set("mbname",text)
+ gtk.main_quit()
+
+ def confirm(self,msg):
+ vbox = gtk.VBox()
+ vbox.pack_start(gtk.Label(msg))
+ self.button = gtk.Button('OK')
+ vbox.pack_start(self.button)
+ self.button.connect("clicked", self.onQuit)
+ self.window.add(vbox)
+ def dumpattr(self,n):
+ s = ""
+ for a,v in n.attrib.items():
+ s = s + ("%s=%s" % (a,v))
+ return s
+
+ def dump(self,node,l=0):
+ print " " * l*2,"<", node.tag, self.dumpattr(node),">"
+ for n in node:
+ self.dump(n,l+1)
+ print " " * l * 2,"/>"
+
+ def hide_frame(self,frame):
+ frame.set('style','display:none')
+ def show_frame(self,frame):
+ frame.set('style','')
+
+
+ def fillcontent(self):
+ if len(self.selected) != 1:
+ self.confirm('Please select one group only')
+ return False
+ for id,node in self.selected.iteritems():
+ #self.dump(node)
+ name = node.get("mbname")
+ if name == None:
+ self.confirm("The MadButterFly symbol is not defined yet. Please convert it to the symbol before convert it to button.")
+ return False
+ for frame in node:
+ if frame.get('mbname') == name+'_click':
+ self.show_frame(frame)
+ else:
+ self.hide_frame(frame)
+ return True
+
+
+a=ConvertToButton()
+a.affect()
+
+# vim: set ts=4
diff -r 8d9d717c9300 -r ad5c7a5c2c39 inkscape/MB_EditNormalButton.py
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/inkscape/MB_EditNormalButton.py Sun Dec 14 11:23:34 2008 +0800
@@ -0,0 +1,70 @@
+#!/usr/bin/python
+import inkex
+import pygtk
+import gtk
+from copy import deepcopy
+
+class ConvertToButton(inkex.Effect):
+ def effect(self):
+ self.window = gtk.Window(gtk.WINDOW_TOPLEVEL)
+ self.window.set_position(gtk.WIN_POS_MOUSE)
+ self.defaultname = 'input symbol name here'
+ if self.fillcontent() == False:
+ self.window.show_all()
+ self.window.connect("delete_event", gtk.main_quit)
+ gtk.main()
+ def onQuit(self,data):
+ gtk.main_quit()
+ def onAssign(self,data):
+ text = self.text.get_text()
+ if text != self.defaultname:
+ self.node.set("mbname",text)
+ gtk.main_quit()
+
+ def confirm(self,msg):
+ vbox = gtk.VBox()
+ vbox.pack_start(gtk.Label(msg))
+ self.button = gtk.Button('OK')
+ vbox.pack_start(self.button)
+ self.button.connect("clicked", self.onQuit)
+ self.window.add(vbox)
+ def dumpattr(self,n):
+ s = ""
+ for a,v in n.attrib.items():
+ s = s + ("%s=%s" % (a,v))
+ return s
+
+ def dump(self,node,l=0):
+ print " " * l*2,"<", node.tag, self.dumpattr(node),">"
+ for n in node:
+ self.dump(n,l+1)
+ print " " * l * 2,"/>"
+
+ def hide_frame(self,frame):
+ frame.set('style','display:none')
+ def show_frame(self,frame):
+ frame.set('style','')
+
+
+ def fillcontent(self):
+ if len(self.selected) != 1:
+ self.confirm('Please select one group only')
+ return False
+ for id,node in self.selected.iteritems():
+ #self.dump(node)
+ name = node.get("mbname")
+ if name == None:
+ self.confirm("The MadButterFly symbol is not defined yet. Please convert it to the symbol before convert it to button.")
+ return False
+ for frame in node:
+ if frame.get('mbname') == name+'_normal':
+ self.show_frame(frame)
+ else:
+ self.hide_frame(frame)
+ return True
+
+
+a=ConvertToButton()
+a.affect()
+
+# vim: set ts=4
diff -r 8d9d717c9300 -r ad5c7a5c2c39 inkscape/MB_button_select_click.inx
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/inkscape/MB_button_select_click.inx Sun Dec 14 11:23:34 2008 +0800
@@ -0,0 +1,18 @@
+
+ Edit Click button
+ MadButterfly.EditClickButton
+ MB_EditClickButton.py
+ inkex.py
+
+ any
+
+
+
+
+
+
+
+
+
diff -r 8d9d717c9300 -r ad5c7a5c2c39 inkscape/MB_button_select_normal.inx
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/inkscape/MB_button_select_normal.inx Sun Dec 14 11:23:34 2008 +0800
@@ -0,0 +1,18 @@
+
+ Edit Normal button
+ MadButterfly.EditNormalButton
+ MB_EditNormalButton.py
+ inkex.py
+
+ any
+
+
+
+
+
+
+
+
+