[Glade-users] Re: naming widgets in XML trees semi-automatically with names that will make sense to the programmer

Well, here is an idea... I will be looking into DOM XML parsing, so
just pseudocode
for now, but I think the result will be really useful, since, renaming
from a command
line is certainly gonna be faster than from glade, when there are so
many widgets:


interactive procedure fast_rename_glade_xml_vars():

use depth

IDNAME["classname1"] = "idname1" # basically user defined
IDNAME["classname2"] = "idname2" # basically user defined
IDNAME["classname3"] = "idname3" # basically user defined
# e.g. GtkImageMenuItem -> item
#      GtkImage -> image

global prefixname

DepthFirstSearchIterator iter = XMLTree.iterator()

while (node = iter.next())
  if node.elementname() == "widget"
    output node with id attribute set \
      to foo(node.depth(), node.attributeValue("class"))
    output the node


use a hash table called counter of (user defined prefixname, classnames)
hasing to a counter for given pair


foo(depth, classname)
  get prefixname from user (else use default when user hits enter)
  set node name to prefixname + \
   IDNAME["classname"] + counter(user defined prefixname, foo)


note in practice, prefixname will be a composition of perfixnames,
as specified by the user, (e.g. foo, foo_bar, foo_bar_hello,
foo_bar_hello_world), but only those places where the user
deems appropriate a prefix change get the prefix change




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]