obmenu-1.0/icons/mnu48.png0000644000175000001440000000374310347640622014474 0ustar kolmeusersPNG  IHDR00WbKGD pHYsARtIME 0$pIDATh혽o[~E)q`72$bu:vKNСS tH;e;ق;KjчA+"MRy?=]İ$NHu \syҾq~ ˿n890JR My`'(.|}$nn~֠O0L4UXh,FlnkDTʕ+q<|avO J~LhB)e! &^4MZWnzj~%zш3gP׏_]]aB]{!axeY g5[qZ8CP@u00 t]?Կ\.iT zJ)(jC?3$y!՛Z"d^ʧ~zW:mx {#bշHSW{N՟w݅:0 ${k̙,XQy!$IH0p7o~0Qbc:Dױ GD<_+Wlm|R^ܤl8ٽZZZ";ӐR666ƝNGnUPrq+66֙/#Du,..fk(?8v=fy$?|"b?~Lg'l+뿵L%O"c,u]._r}7RwTU꣔z*+ie4Mcaaat|?2I&p.[[[p8\.) 4MZvq+++x!JwHB j5iH)B>/_4촯^xo/z-rvY5M#"<# Ct:9V5a|.]DϬH,Y!cRr9z=";K|}1Sհm/꿲µkBP*4Ml~xE"J)t]0cYvaC:I:eti4=`awwϳHdSi)wwwI4{ ߪʹsjpܹCacc˲40 ۶oqh\.eYDQ@Q'4M1M8 0[;R²'BH)a$ISQ<}Μ9C$xGV؛Z㬄h4ό^ٳgcS8"d~~Mwy!I8 1P.i6hF}.anq]~קjH)%omjJ^4Mai{/RP4 !ĉBnj<=j^/+ + KKKtxmS,R"'<秧BSV ۶ pHCc;MS< 9;`0 `0 C < [0Q*Vԏo߾vhI'I‡~(t:LL@ >?^B,IHOL04M-q.{j7B{?~o*`4MS=v]R꟮IAm˲m !.~;2V"=K{ii]bS]IENDB`obmenu-1.0/icons/mnu16.png0000644000175000001440000000104010347640466014461 0ustar kolmeusersPNG  IHDRabKGD pHYsARtIME .RXG4IDAT8˭1p@-D:kFdb.n . &Np 7i0JP^m 9\&n;?v;w΋{R !K`0h]j 7_sy0 tb8׎(Nzt E'pCuxbK[O 8d 0 or len(child.children) > 0: obmenu.createMenu(pid, child.title, "xdg-" + child.name) child._create_obmenu(obmenu, root) for item in self.items: obmenu.createItem(pid, item["name"], "Execute", item["exec"]) class XdgLogic: def __init__(self, tipe): self.tipe = tipe self.items = [] self.value = False self.cat = "" def append(self, item): self.items.append(item) def evaluate(self, list, filename): if self.tipe == "CATEGORY": self.value = self.cat in list return self.value if self.tipe == "FILENAME": self.value = self.cat == filename return self.value if self.tipe == "NOT": self.value = False for i in self.items: self.value = self.value or not i.evaluate(list, filename) return self.value if self.tipe == "AND": self.value = True for i in self.items: if not i.evaluate(list, filename): self.value = False return self.value return self.value if self.tipe == "OR": self.value = False for i in self.items: self.value = self.value or i.evaluate(list, filename) return self.value if self.tipe == "ALL": self.value = True return self.value def setCategory(self, cat): self.cat = cat if __name__ == "__main__": mnu = XdgMenu() if os.getenv("LANG") != "": mnu.lang = os.getenv("LANG") home = os.getenv("HOME") xdg_cd = os.getenv("XDG_CONFIG_DIRS") xdg_ch = os.getenv("XDG_CONFIG_HOME") if not xdg_ch: xdg_ch = "%s/.config" % (home) if not xdg_cd: xdg_cd = "/etc/xdg" filename = "" role = None if os.path.isfile("%s/menus/applications.menu"%(xdg_ch)): filename = "%s/menus/applications.menu"%(xdg_ch) else: for cdir in xdg_cd.split(":"): if os.path.isfile("%s/menus/applications.menu"%(cdir)): filename = "%s/menus/applications.menu"%(cdir) break for arg in sys.argv[1:]: if arg == "--import": role = "import" elif arg == "-i": role = "import" elif arg == "--replace": role = "replace" elif arg == "-r": role = "replace" else: if os.path.isfile(sys.argv[1]): filename = sys.argv[1] mnu.parseFile(filename) if role in ("replace", "import"): mnu.loadItems() obmenu = obxml.ObMenu() obmenu.newMenu() if role == "replace": mnuid = "root-menu" mnulb = "Openbox 3" else: mnuid = "obm-xdg-menus" mnulb = "Gnome menus" obmenu.createMenu(None, mnulb, mnuid) mnu._create_obmenu(obmenu, mnuid) if role == "replace": obmenu.createMenu(mnuid, "Openbox", "Openbox-Conf-Menu") obmenu.createItem("Openbox-Conf-Menu", "Edit preferences", "Execute", "obconf") obmenu.createItem("Openbox-Conf-Menu", "Edit menus", "Execute", "obmenu") obmenu.createItem("Openbox-Conf-Menu", "Reload prefences", "Reconfigure", "") obmenu.createSep("Openbox-Conf-Menu") obmenu.createItem("Openbox-Conf-Menu", "Exit", "Exit", "") obmenu.createSep(mnuid) obmenu.createLink(mnuid, "client-list-menu") if not os.path.isdir(xdg_ch): os.mkdir(xdg_ch) if not os.path.isdir("%s/openbox"%(xdg_ch)): os.mkdir("%s/openbox"%(xdg_ch)) if os.path.isfile("%s/openbox/menu.xml"%(xdg_ch)): os.rename("%s/openbox/menu.xml"%(xdg_ch), "%s/openbox/menu.xml~"%(xdg_ch)) obmenu.saveMenu("%s/openbox/menu.xml"%(xdg_ch)) else: obmenu.saveMenu("gnome-menus.xml") else: cachefile = "%s/.obmxdg.xml" % (home) if os.path.isfile(cachefile): new = False for appdir in mnu.getAllAppdirs(): if os.path.getmtime(appdir) > os.path.getmtime(cachefile): new = True break if not new: cache = open(cachefile) print cache.read() cache.close() sys.exit() mnu.loadItems() obmenu = obxml.ObMenu() obmenu.newPipe() mnu._create_obmenu(obmenu) obmenu.saveMenu(cachefile) obmenu.printXml() obmenu-1.0/pipes/obm-moz0000744000175000001440000001254310364710217014317 0ustar kolmeusers#!/usr/bin/env python -O ######################################################################### # Copyright 2005 Manuel Colmenero # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # ######################################################################## # # a mozilla bookmarks to openbox menus translator # import obxml, sys, os from HTMLParser import HTMLParser from optparse import OptionParser class MozParser(HTMLParser, obxml.ObMenu): def init(self): self.stack = [None] self.data = "" self.newPipe() self.href = "" self.root = "" self.started = False self.finished = False self.browser = "firefox" def openFile(self,filename): try: f = open(filename) except: mp.createItem(None, "Couldn't open file!", "Execute", "true") return mp.feed(f.read()) f.close() def handle_data(self, data): if self.finished: return d = data.strip() if d != "": self.data = unicode(d,"utf-8") def handle_starttag(self, tag, attrs): if self.finished: return if tag == "h3" or tag == "h1": if not self.started: if self.root == "" or self.data == self.root: for a in attrs: if a[0] == "id": self.stack.append(a[1]) self.started = True else: for a in attrs: if a[0] == "id": self.stack.append(a[1]) if self.started and tag == "a": for attr in attrs: if attr[0] == "href": self.href = attr[1] def handle_endtag(self, tag): if self.finished: return if self.started: if tag == "dl": self.stack.pop(-1) if len(self.stack) == 0: self.finished = True elif tag == "h3" : if len(self.stack) > 1: self.createMenu(self.stack[-2], self.data, self.stack[-1]) if tag == "a": self.createItem(self.stack[-1], self.data, "Execute", "%s %s" % (self.browser, self.href)) def get_firefox_bm (): if os.path.isdir(home + "/.mozilla"): if os.path.isdir(home + "/.mozilla/firefox"): for f in os.listdir(home+"/.mozilla/firefox"): if ".default" in f: if os.path.isfile(home + "/.mozilla/firefox/" + f + "/bookmarks.html"): return home + "/.mozilla/firefox/" + f + "/bookmarks.html" return "" def get_mozilla_bm (): if os.path.isdir(home + "/.mozilla/default"): l = os.listdir(home + "/.mozilla/default") if len(l) == 1: if os.path.isfile(home + "/.mozilla/default/" + l[0] + "/bookmarks.html"): return home + "/.mozilla/default/" + l[0] + "/bookmarks.html" return "" def print_error(error): obm = obxml.ObMenu() obm.newPipe() for line in error.split("\n"): obm.createItem(None, line, "Execute", "true") obm.printXml() if __name__ == "__main__": home = os.getenv("HOME") opt = OptionParser() opt.add_option("-f", "--firefox", action="store_const", const=1, dest="nav", help="Look for Firefox bookmarks") opt.add_option("-m", "--mozilla", action="store_const", const=2, dest="nav", help="Look for Mozilla Suite bookmarks") opt.add_option("-b", "--bookmarks", action="store", dest="filename", help="Especify the path to the bookmarks.html file") opt.add_option("-r", "--root", action="store", dest="root", help="Root folder of the bookmarks") opt.add_option("-n", "--navigator", action="store", dest="browser", help="Command to run the web browser.") (opts, args) = opt.parse_args() nav = 0 if opts.nav: nav = opts.nav browser = "" if opts.browser: browser = opts.browser if browser == "": browser = "firefox" filename = "" if opts.filename: filename = opts.filename root = "" if opts.root: root = opts.root if filename != "": if not os.path.isfile(filename): print_error("ERROR: %s: not found" % (filename)) sys.exit(1) else: if nav == 0: filename = get_firefox_bm() if filename == "": filename = get_mozilla_bm() if filename == "": print_error("ERROR: No bookmarks found, please especify location.") sys.exit(1) if nav == 1: filename = get_firefox_bm() if filename == "": print_error("ERROR: Firefox bookmarks not found, please especify location.") sys.exit(1) if nav == 2: filename = get_mozilla_bm() if filename == "": print_error("ERROR: Mozilla suite bookmarks not found, please especify location.") sys.exit(1) cachefile = "%s/.obmmoz.xml" % (home) lastopts = "%s/.obmmoz.conf" % (home) if os.path.isfile(lastopts): f = open(lastopts) last = eval(f.read()) f.close() if last == opts and os.path.isfile(cachefile) and os.path.getmtime(filename) < os.path.getmtime(cachefile): cache = open(cachefile) print cache.read() cache.close() sys.exit() mp = MozParser() mp.init() mp.root = root mp.browser = browser mp.openFile(filename) mp.saveMenu(cachefile) f = open(lastopts, "w") f.write(str(opts)) f.close() mp.printXml() obmenu-1.0/pipes/obm-nav0000744000175000001440000000446710372441165014306 0ustar kolmeusers#!/usr/bin/env python -O ######################################################################### # Copyright 2005 Manuel Colmenero # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # ######################################################################## import obxml, sys, os menu = obxml.ObMenu() menu.newPipe() if len(sys.argv) != 4: menu.createItem(None, "ERROR: Wrong number of arguments", "Execute", "true") menu.printXml() sys.exit() if not os.path.isdir(sys.argv[1]): menu.createItem(None, "ERROR: Not a directory", "Execute", "true") menu.printXml() sys.exit() dirs = [] files = [] for itm in os.listdir(sys.argv[1]): if itm[0] != ".": if os.path.isdir(sys.argv[1] + "/" + itm): dirs.append(unicode(itm, "utf-8", errors='ignore')) else: files.append(unicode(itm, "utf-8", errors='ignore')) menu.createItem(None, "open", "Execute", "%s \"%s\"" % (sys.argv[2], sys.argv[1])) menu.createItem(None, "terminal", "Execute", "sh -c \"cd \\\"%s\\\"; %s\"" % (sys.argv[1], sys.argv[3])) if not len(dirs) == 0 or not len(files) == 0: menu.createSep(None) n = 0 p = 1 mid = None for d in dirs: if n > 15: menu.createSep(mid,0) menu.createMenu(mid, "more", "%s%d" % (sys.argv[1], p),0) mid = "%s%d" % (sys.argv[1], p) n = 0 p += 1 menu.createPipe(mid, "obm-nav-" + d, d, "%s \"%s/%s\" \"%s\" \"%s\"" % (sys.argv[0], sys.argv[1], d, sys.argv[2], sys.argv[3])) n += 1 for f in files: if n > 15: menu.createSep(mid, 0) menu.createMenu(mid, "more", "%s%d" % (sys.argv[1], p),0) mid = "%s%d" % (sys.argv[1], p) n = 0 p += 1 menu.createItem(mid, f, "Execute", "%s \"%s/%s\"" % (sys.argv[2], sys.argv[1], f)) n += 1 menu.printXml() obmenu-1.0/pipes/obm-dir0000744000175000001440000000436310364710200014261 0ustar kolmeusers#!/usr/bin/env python -O ######################################################################### # Copyright 2005 Manuel Colmenero # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # ######################################################################## # This is an example of what the obxml module can do import obxml, sys, os, time def alfabetiza(lista): dic = {} for each in lista: k = each[0].lower() if not dic.has_key(k): dic[k] = [each] else: dic[k].append(each) for key in dic.keys(): dic[key].sort() return dic def clasifica(lista, humbral): lgrupos = [] if len(lista) / humbral > 1: grupo = [] n = 0 primera = "" alf = alfabetiza(lista) ids = alf.keys() ids.sort() for k in ids: if primera == "": primera = k grupo = grupo + alf[k] n += len(alf[k]) if n / humbral >= 1: lgrupos.append( ( "%s-%s" % (primera, k), grupo) ) primera = "" grupo = [] n = 0 if n != 0: lgrupos.append( ( "%s-%s" % (primera, k), grupo) ) return lgrupos menu = obxml.ObMenu() menu.newPipe() if len(sys.argv) == 3: vmenu = clasifica( [unicode(each, "utf-8", errors='ignore') for each in os.listdir(sys.argv[1])],10) else: menu.createItem(None, "ERROR: Wrong number of arguments:", "Execute", "true") menu.createItem(None, "%s /path/to/directory command" % (sys.argv[0]), "Execute", "true") menu.printXml() sys.exit(1) for m in vmenu: (mid, lst) = m menu.createMenu(None, mid, mid) for itm in lst: menu.createItem(mid, itm, "execute", sys.argv[2] + " " + ("\"" + sys.argv[1] + "/" + itm + "\"")) menu.printXml() obmenu-1.0/COPYING0000644000175000001440000003542510364707446012744 0ustar kolmeusers GNU GENERAL PUBLIC LICENSE Version 2, June 1991 Copyright (C) 1989, 1991 Free Software Foundation, Inc. 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This General Public License applies to most of the Free Software Foundation's software and to any other program whose authors commit to using it. (Some other Free Software Foundation software is covered by the GNU Library General Public License instead.) You can apply it to your programs, too. When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things. To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it. For example, if you distribute copies of such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software. Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations. Finally, any free program is threatened constantly by software patents. We wish to avoid the danger that redistributors of a free program will individually obtain patent licenses, in effect making the program proprietary. To prevent this, we have made it clear that any patent must be licensed for everyone's free use or not licensed at all. The precise terms and conditions for copying, distribution and modification follow. GNU GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any derivative work under copyright law: that is to say, a work containing the Program or a portion of it, either verbatim or with modifications and/or translated into another language. (Hereinafter, translation is included without limitation in the term "modification".) Each licensee is addressed as "you". Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running the Program is not restricted, and the output from the Program is covered only if its contents constitute a work based on the Program (independent of having been made by running the Program). Whether that is true depends on what the Program does. 1. You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and give any other recipients of the Program a copy of this License along with the Program. You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. 2. You may modify your copy or copies of the Program or any portion of it, thus forming a work based on the Program, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: a) You must cause the modified files to carry prominent notices stating that you changed the files and the date of any change. b) You must cause any work that you distribute or publish, that in whole or in part contains or is derived from the Program or any part thereof, to be licensed as a whole at no charge to all third parties under the terms of this License. c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the most ordinary way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this License. (Exception: if the Program itself is interactive but does not normally print such an announcement, your work based on the Program is not required to print an announcement.) These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Program, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Program, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Program. In addition, mere aggregation of another work not based on the Program with the Program (or with a work based on the Program) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. 3. You may copy and distribute the Program (or a work based on it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you also do one of the following: a) Accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, b) Accompany it with a written offer, valid for at least three years, to give any third party, for a charge no more than your cost of physically performing source distribution, a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, c) Accompany it with the information you received as to the offer to distribute corresponding source code. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form with such an offer, in accord with Subsection b above.) The source code for a work means the preferred form of the work for making modifications to it. For an executable work, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the executable. However, as a special exception, the source code distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. If distribution of executable or object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place counts as distribution of the source code, even though third parties are not compelled to copy the source along with the object code. 4. You may not copy, modify, sublicense, or distribute the Program except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense or distribute the Program is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. 5. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Program or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Program (or any work based on the Program), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Program or works based on it. 6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties to this License. 7. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Program at all. For example, if a patent license would not permit royalty-free redistribution of the Program by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Program. If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply and the section as a whole is intended to apply in other circumstances. It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system, which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. 8. If the distribution and/or use of the Program is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Program under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. 9. The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of this License, you may choose any version ever published by the Free Software Foundation. 10. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS obmenu-1.0/obxml.py0000644000175000001440000002471610367771056013406 0ustar kolmeusers#!/usr/bin/python # # Openbox Menu Editor 1.0 beta # # Copyright 2005 Manuel Colmenero # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # ObMenu can be used as a module in python scripts, for example, to # Generate dynamic menus (pipemenus) import xml.dom.minidom class ObMenu: # Internal functions ============================================= # (These mess with the xml tree) # given its ID, and its parent (or None for top-level) # returns the dom tree of the menu. Recursively. def _get_dom_menu(self, menu, parent=None): if not menu: return None if not parent: parent = self.dom.documentElement for item in parent.childNodes: if item.nodeName == "menu" and item.hasChildNodes(): if item.attributes["id"].nodeValue == menu: return item else: b = self._get_dom_menu(menu, item) if b: return b return None # given its ID, and its parent (or None for top-level) # returns the dom tree of the menu. Recursively. def _get_dom_ref(self, menu, parent): if not parent: parent = self.dom.documentElement for item in parent.childNodes: if item.nodeName == "menu": if not item.hasChildNodes(): if item.attributes["id"].nodeValue == menu: return item else: b = self._get_dom_menu(menu, item) if b: return b return None # Get an item of 'menu', given its number (order) def _get_dom_item(self,menu,num): if not menu: item = self.dom.documentElement else: item = self._get_dom_menu(menu) if not item: return None i = 0 for it in item.childNodes: if it.nodeType == 1: if i == num: return it i += 1 # Insert a node in the xml tree def _put_dom_item(self, menu, nodo, pos=None): parent = self._get_dom_menu(menu) if not parent: parent = self.dom.documentElement if pos == None or pos > self._get_menu_len(menu): parent.appendChild(nodo) elif pos >= 0: ant = self._get_dom_item(menu, pos) parent.insertBefore(nodo, ant) # Get the number of items of a menu def _get_menu_len(self,menu): if menu: item = self._get_dom_menu(menu) else: item = self.dom.documentElement i = 0 for it in item.childNodes: if it.nodeType == 1: i += 1 return i # Get "real" item number (counting with comments, text, etc in the xml) def _get_real_num(self,menu,num): if menu: item = self._get_dom_menu(menu) else: item = self.dom.documentElement i = 0 n = 0 for it in item.childNodes: if it.nodeType == 1: if i == num: return n i += 1 n += 1 # get the properties of an item from the xml, and returns them as a # dictionary. def _get_item_props(self,node): etiqueta = node.attributes["label"].nodeValue accion = "" param = "" for it in node.childNodes: if it.nodeType == 1: accion = it.attributes["name"].nodeValue if accion.lower() == "execute": for itm in it.childNodes: if itm.nodeType == 1 and itm.nodeName.lower() == "execute": for item in itm.childNodes: if item.nodeType == 3: param = item.nodeValue.strip() return { "type": "item", "label": etiqueta, "action": accion, "execute": param } # get the properties of a menu from the xml, and returns them as a # dictionary. def _get_menu_props(self, node): lb = "" ex = "" act = "" mid = node.attributes["id"].nodeValue if node.hasAttribute("label"): lb = node.attributes["label"].nodeValue else: mnu = self._get_dom_menu(mid) if mnu: lb = mnu.attributes["label"].nodeValue else: lb = mid if not node.hasChildNodes(): if node.hasAttribute("execute"): ex = node.attributes["execute"].nodeValue act = "Pipemenu" else: act = "Link" if node.hasAttribute("execute"): ex = node.attributes["execute"].nodeValue return { "type": "menu", "label": lb, "action": act, "execute": ex, "id": mid } # Public functions =================================================== # Most of them are self-explanatory def loadMenu(self, filename): fil = open(filename) self.dom = xml.dom.minidom.parseString(fil.read()) fil.close() def newMenu(self): self.dom = xml.dom.minidom.parseString( "") #self.dom._set_async(False) def newPipe(self): self.dom = xml.dom.minidom.parseString( "") def saveMenu(self, filename): output = open(filename, "w") for line in self.dom.toprettyxml("\t","\n","utf-8").splitlines(): if line.strip() != "": output.write("%s\n" %(line)) output.close() def printXml(self): for line in self.dom.toprettyxml("\t","\n","utf-8").splitlines(): if line.strip() != "": print line def getXml(self): res = "" for line in self.dom.toprettyxml("\t","\n","utf-8").splitlines(): if line.strip() != "": res = res + "%s\n" % (line) return res def removeItem(self,menu, num): if menu: dom_mnu = self._get_dom_menu(menu) else: dom_mnu = self.dom.documentElement item = self._get_dom_item(menu,num) dom_mnu.removeChild(item) item.unlink() def removeMenu(self,menu): dom_mnu = self._get_dom_menu(menu) if not dom_mnu.parentNode: self.dom.documentElement.removeChild(dom_mnu) else: dom_mnu.parentNode.removeChild(dom_mnu) dom_mnu.unlink() def createSep(self, menu, pos=None): nodo = self.dom.createElement("separator") self._put_dom_item(menu, nodo, pos) def createItem(self, menu, label, action, execute, pos=None): nodo = self.dom.createElement("item") nodo.attributes["label"] = label accion = self.dom.createElement("action") accion.attributes["name"] = "Execute" exe = self.dom.createElement("execute") txt = self.dom.createTextNode("") txt.nodeValue = execute exe.appendChild(txt) accion.appendChild(exe) nodo.appendChild(accion) self._put_dom_item(menu, nodo, pos) def createLink(self, menu, mid, pos=None): nodo = self.dom.createElement("menu") nodo.attributes["id"] = mid self._put_dom_item(menu, nodo, pos) def createPipe(self, menu, mid, label, execute, pos=None): nodo = self.dom.createElement("menu") nodo.attributes["id"] = mid nodo.attributes["label"] = label nodo.attributes["execute"] = execute self._put_dom_item(menu, nodo, pos) def createMenu(self, menu, label, mid, pos=None): nodo = self.dom.createElement("menu") nodo.attributes["label"] = label nodo.attributes["id"] = mid txt = self.dom.createTextNode("") txt.nodeValue = "\n" nodo.appendChild(txt) self._put_dom_item(menu, nodo, pos) def interchange(self, menu, n1, n2): if not menu: dom_mnu = self.dom.documentElement else: dom_mnu = self._get_dom_menu(menu) i1 = self._get_real_num(menu, n1) i2 = self._get_real_num(menu, n2) uno = dom_mnu.childNodes[i1] dom_mnu.childNodes[i1] = dom_mnu.childNodes[i2] dom_mnu.childNodes[i2] = uno def setItemProps(self, menu, n, label, action, exe): itm = self._get_dom_item(menu,n) itm.attributes["label"].nodeValue = label for it in itm.childNodes: if it.nodeType == 1: it.attributes["name"].nodeValue = action if action == "Execute": if not it.childNodes: elm = xml.dom.minidom.Element("execute") txt = xml.dom.minidom.Text() txt.nodeValue = exe elm.appendChild(txt) it.appendChild(elm) else: for i in it.childNodes: if i.nodeType == 1 and i.nodeName == "execute": for item in i.childNodes: if item.nodeType == 3: item.nodeValue = exe else: for item in it.childNodes: it.removeChild(item) def setMenuLabel(self, menu, label): mnu = self._get_dom_menu(menu) if mnu: mnu.attributes["label"].nodeValue = label def getMenuLabel(self,menu): mnu = self._get_dom_menu(menu) if mnu: return mnu.attributes["label"].nodeValue def setRefLabel(self, parent, mid, label): prnt = self._get_dom_menu(parent) if prnt: mnu = self._get_dom_ref(mid, prnt) if mnu: mnu.setAttribute("label", label) def setRefId(self, parent, mid, new_id): prnt = self._get_dom_menu(parent) if prnt: mnu = self._get_dom_ref(mid, prnt) if mnu: mnu.setAttribute("id", new_id) def setMenuExecute(self, parent, mid, execute): prnt = self._get_dom_menu(parent) if prnt: mnu = self._get_dom_ref(mid, prnt) if mnu: mnu.setAttribute("execute", execute) # Return just an item, given its parent menu an its number def getItem(self,menu,num): mnu = self._get_dom_menu(menu) if not mnu: return n = 0 for i in mnu.childNodes: if i.nodeType == 1: if n == num: if i.nodeName == "menu": return self._get_menu_props(i) elif i.nodeName == "separator": return { "type": "separator" } elif i.nodeName == "item": return self.get_item_props(i) n += 1 # Is menu? Returns True if it's an existing ID def isMenu(self,menu): dom = self._get_dom_menu(menu) if dom: return True else: return False # Returns a whole menu, as a list of dictionaries. # Each dictionary has the items properties. def getMenu(self,menu): lst = [] if menu: mnu = self._get_dom_menu(menu) if not mnu: return else: mnu = self.dom.documentElement for i in mnu.childNodes: if i.nodeType == 1: if i.nodeName == "menu": d = self._get_menu_props(i) d["parent"] = menu lst.append(d) elif i.nodeName == "separator": lst.append({"type": "separator", "parent": menu}) elif i.nodeName == "item": d = self._get_item_props(i) d["parent"] = menu lst.append(d) return lst # replace all old_id's in file with new_id's # parent shuld start with None def replaceId(self, old_id, new_id, parent=None): if not parent: parent = self.dom.documentElement for item in parent.childNodes: if item.nodeName == "menu": if item.attributes["id"].nodeValue == old_id: item.setAttribute("id", new_id) elif item.hasChildNodes(): self.replaceId(old_id, new_id, item) if __name__ == "__main__": print "This is a module. Use obmenu instead." exit(0) obmenu-1.0/obmenu0000744000175000001440000004364010370372432013106 0ustar kolmeusers#!/usr/bin/python # # Openbox Menu Editor 1.0 beta # # Copyright 2005 Manuel Colmenero # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA import obxml, gtk, gtk.glade, gobject, random, time, os, sys class App: def reconfigureOpenbox(self): lines = os.popen("ps aux").read().splitlines() ob = os.popen("which openbox").read().strip() for line in lines: if ob in " ".join(line.split()[10:]): os.kill(int(line.split()[1]), 12) break # Recursively creates the treeview model def createTree(self, padre, menuid): for it in self.menu.getMenu(menuid): if it["type"] == "item": self.treemodel.append(padre, (it["label"], 'item',it["action"],it["execute"],it["parent"],"")) elif it["type"] == "separator": self.treemodel.append(padre, ("", "separator", "", "", it["parent"], "")) elif it["type"] == "menu": hijo=self.treemodel.append(padre, (it["label"], 'menu',it["action"],it["execute"], it["parent"], it["id"])) if self.menu.getMenu(it["id"]) and it["action"] == "": self.createTree(hijo, it["id"]) def deleteTree(self): # treemodel.iter(label, type, [action], [execute], parent, [menu-id]) self.treemodel=gtk.TreeStore(gobject.TYPE_STRING, gobject.TYPE_STRING, gobject.TYPE_STRING, gobject.TYPE_STRING, gobject.TYPE_STRING, gobject.TYPE_STRING) self.treeview.set_model(self.treemodel) # Sets the state of "menu modified" # Refreshes the window's title def _sth_changed(self, op): self.sth_changed = op if op: s = "(*)" else: s = "" self.arbol.get_widget("window1").set_title("Obmenu: %s %s" % (self.menu_path, s)) # Auxiliary function for model.foreach() def _change_id(self, model, path, it,(old_id, new_id)): mid = model.get_value(it,5) if mid == old_id: model.set(it, 5, new_id) parent = model.get_value(it,4) if parent == old_id: model.set(it, 4, new_id) def clear_fields(self): self.auto_change = True self.label_entry for each in (self.label_entry, self.id_entry, self.execute_entry): each.set_sensitive(False) each.set_text("") self.action_entry.set_sensitive(False) self.auto_change = False def confirm(self, message): dlg = gtk.MessageDialog(None,0,gtk.MESSAGE_WARNING, gtk.BUTTONS_YES_NO,message) res = dlg.run() dlg.destroy() if res == -8: return True else: return False def ask_for_path(self, title, op): if op == 0: action = gtk.FILE_CHOOSER_ACTION_OPEN else: action = gtk.FILE_CHOOSER_ACTION_SAVE dlg = gtk.FileChooserDialog(title,None,action,(gtk.STOCK_OK, 1, gtk.STOCK_CANCEL, 3)) dlg.set_default_response(1) res = dlg.run() flnm = dlg.get_filename() dlg.destroy() if res == 1: return flnm # New file clicked def new(self, bt): if self.sth_changed: res = self.confirm("Changes in %s will be lost. Continue?" % (self.menu_path)) if not res: return self.deleteTree() self.menu.newMenu() self.unsaved_menu = True self.menu_path = "Untitled" self._sth_changed(True) self.clear_fields() def open(self, bt): if self.sth_changed: res = self.confirm("Changes in %s will be lost. Continue?" % (self.menu_path)) if not res: return path = self.ask_for_path("Open", 0) if not path: return self.menu_path = path self.unsaved_menu = False self._sth_changed(False) # Load in memory the real xml menu self.menu = obxml.ObMenu() self.menu.loadMenu(self.menu_path) self.deleteTree() #Not really deleting this time, just initialiting self.createTree(None, None) self.clear_fields() # save the menu def save(self, bt): if self.unsaved_menu: path = self.ask_for_path("Save as...", 1) if not path: return self.menu_path = path self.unsaved_menu = False self.menu.saveMenu(self.menu_path) self.reconfigureOpenbox() self._sth_changed(False) # save as... def save_as(self, bt): path = self.ask_for_path("Save as...", 1) if not path: return self.menu_path = path self.unsaved_menu = False self._sth_changed(False) self.menu.saveMenu(self.menu_path) self.reconfigureOpenbox() # quit signal def quit (self, bt, arg2): if self.sth_changed: res = self.confirm("There are unsaved changes. Exit anyway?") if not res: return True gtk.main_quit() # file->quit menu signal def mnu_quit (self, bt): self.quit(None,None) # id_entry changed signal def change_id(self, pa): if self.auto_change: return self._sth_changed(True) (model, ite) = self.treeview.get_selection().get_selected() if not ite: return if model.get_value(ite, 1).lower() != "menu": return old_id = model.get_value(ite, 5) new_id = self.id_entry.get_text() if model.get_value(ite, 2).lower() == "link": self.auto_change = True if self.menu.getMenuLabel(new_id): model.set(ite, 0, self.menu.getMenuLabel(new_id), 5, new_id) self.label_entry.set_text(self.menu.getMenuLabel(new_id)) else: model.set(ite, 0, new_id, 5, new_id) self.label_entry.set_text(new_id) self.auto_change = False self.menu.setRefId( model.get_value(ite, 4), old_id, new_id) else: if old_id != new_id and not self.menu.isMenu(new_id): self.menu.replaceId(old_id, new_id) model.foreach(self._change_id, (old_id, new_id)) # label_entry changed signal def change_label(self, pa): if self.auto_change: return self._sth_changed(True) (model, ite) = self.treeview.get_selection().get_selected() if not ite: return (label, tipe, aaa, eee, menu, mid) = model.get(ite,0,1,2,3,4,5) lb = self.label_entry.get_text() p = model.get_path(ite) n = p[len(p)-1] if tipe == "item": self.menu.setItemProps(menu, n, lb, aaa, eee) elif tipe == "menu": if aaa == "": self.menu.setMenuLabel(mid, lb) else: self.menu.setRefLabel(menu, mid, lb) model.set(ite, 0, lb) # action_combo_box changed signal def change_action(self, pa): if self.auto_change: return self._sth_changed(True) (model, ite) = self.treeview.get_selection().get_selected() if not ite: return (label, tipe, aaa, eee, menu, mid) = model.get(ite,0,1,2,3,4,5) p = model.get_path(ite) n = p[len(p)-1] if tipe == "item": ac = self.action_entry.get_active() self.execute_entry.set_sensitive(False) self.execute_srch.set_sensitive(False) if ac == 0: action = "Execute" self.execute_entry.set_sensitive(True) self.execute_srch.set_sensitive(True) elif ac == 1: action = "Reconfigure" eee = "" elif ac == 2: action = "Restart" eee = "" elif ac == 3: action = "Exit" eee = "" self.menu.setItemProps(menu, n, label, action, eee) model.set(ite, 2, action, 3, eee) # execute_entry changed signal def change_execute(self, pa): if self.auto_change: return self._sth_changed(True) (model, ite) = self.treeview.get_selection().get_selected() if not ite: return (label, tipe, aaa, eee, menu, mid) = model.get(ite,0,1,2,3,4,5) p = model.get_path(ite) n = p[len(p)-1] ex = self.execute_entry.get_text() if tipe == "item": p = model.get_path(ite) n = p[len(p)-1] self.menu.setItemProps(menu, n, label, aaa, ex) elif tipe == "menu": self.menu.setMenuExecute(menu, mid, ex) model.set(ite, 3, ex) # buton [...] clicked signal def search_clicked(self, arg): path = self.ask_for_path("Select file", 0) if path: self.execute_entry.set_text(path) # treeview key pressed signal def tree_key_pressed(self, treeview, ev): # if Delete key has been pressed if ev.keyval == 65535: self.remove(None) # treeview clicked signal def treeview_changed(self, param): (model, ite) = param.get_selection().get_selected() if not ite: return (label, tipe, action, exe, menu, mid) = model.get(ite,0,1,2,3,4,5) self.auto_change = True self.label_entry.set_text(label) self.execute_entry.set_text(exe) self.label_entry.set_sensitive(tipe == "item" or (tipe == "menu" and action != "Link")) self.action_entry.set_sensitive(tipe == "item") self.id_entry.set_sensitive(tipe == "menu") self.id_entry.set_text(mid) if tipe == "item": self.execute_entry.set_sensitive(False) self.execute_srch.set_sensitive(False) if action.lower() == "execute": self.action_entry.set_active(0) self.execute_entry.set_sensitive(True) self.execute_srch.set_sensitive(True) elif action.lower() == "reconfigure": self.action_entry.set_active(1) elif action.lower() == "restart": self.action_entry.set_active(2) elif action.lower() == "exit": self.action_entry.set_active(3) else: self.action_entry.set_sensitive(False) elif tipe == "menu": self.execute_entry.set_sensitive(action == "Pipemenu") self.execute_srch.set_sensitive(action == "Pipemenu") else: self.execute_entry.set_sensitive(False) self.execute_srch.set_sensitive(False) self.auto_change = False # new menu button clicked def new_menu(self, param): (model, ite) = self.treeview.get_selection().get_selected() if ite: (label, tipe, action, exe, menu, mid) = model.get(ite,0,1,2,3,4,5) parent = model.iter_parent(ite) n = model.get_path(ite)[-1] else: menu = None parent = model.get_iter_root() n = 0 nmid="%s-%d%d%d" % (menu, random.randint(0,99), time.gmtime()[4], time.gmtime()[5]) n_menu = self.treemodel.insert_before(parent, ite,("New Menu", "menu", "", "", menu, nmid)) itm = self.treemodel.append(n_menu, ("New Item", "item", "Execute", "command", nmid, "")) self.menu.createMenu(menu, "New Menu", nmid, n) self.menu.createItem(nmid, "New Item", "Execute", "command") path = model.get_path(n_menu) self.treeview.set_cursor(path, None, False) self.label_entry.select_region(0, -1) self.label_entry.grab_focus() self._sth_changed(True) # new item button clicked def new_item(self,param): (model, ite) = self.treeview.get_selection().get_selected() if not ite: return (label, tipe, action, exe, menu, mid) = model.get(ite,0,1,2,3,4,5) if menu == None: return n = model.get_path(ite)[-1] parent = model.iter_parent(ite) self.menu.createItem(menu, "New Item", "Execute", "command", n) itm = self.treemodel.insert_before(parent, ite, ("New Item", 'item','Execute','command', menu, "")) path = model.get_path(itm) self.treeview.set_cursor(path, None, False) self.label_entry.select_region(0, -1) self.label_entry.grab_focus() self._sth_changed(True) # new separator button clicked def new_separator(self,param): (model, ite) = self.treeview.get_selection().get_selected() if not ite: return (label, tipe, action, exe, menu, mid) = model.get(ite,0,1,2,3,4,5) if menu == None: return n = model.get_path(ite)[-1] parent = model.iter_parent(ite) self.menu.createSep(menu, n) itm = self.treemodel.insert_before(parent, ite, ("", 'separator', '','', menu, "")) path = model.get_path(itm) self.treeview.set_cursor(path, None, False) self.treeview.grab_focus() self._sth_changed(True) # new link button clicked def new_link(self,param): (model, ite) = self.treeview.get_selection().get_selected() if not ite: return (label, tipe, action, exe, menu, mid) = model.get(ite,0,1,2,3,4,5) if menu == None: return n = model.get_path(ite)[-1] parent = model.iter_parent(ite) nmid="link-%d%d%d" % (random.randint(0,99), time.gmtime()[4], time.gmtime()[5]) self.menu.createLink(menu, nmid, n) itm = self.treemodel.insert_before(parent, ite, (nmid, 'menu', 'Link','', menu, nmid)) path = model.get_path(itm) self.treeview.set_cursor(path, None, False) self.id_entry.select_region(0, -1) self.id_entry.grab_focus() self._sth_changed(True) # new pipe button clicked def new_pipe(self,param): (model, ite) = self.treeview.get_selection().get_selected() if not ite: return (label, tipe, action, exe, menu, mid) = model.get(ite,0,1,2,3,4,5) if menu == None: return n = model.get_path(ite)[-1] parent = model.iter_parent(ite) nmid="pipe-%d%d%d" % (random.randint(0,99), time.gmtime()[4], time.gmtime()[5]) self.menu.createPipe(menu, nmid, "Newpipe", "command", n) itm = self.treemodel.insert_before(parent, ite, ("Newpipe", 'menu', 'Pipemenu','command', menu, nmid)) path = model.get_path(itm) self.treeview.set_cursor(path, None, False) self.label_entry.select_region(0, -1) self.label_entry.grab_focus() self._sth_changed(True) # up button clicked def up(self,param): (model, ite) = self.treeview.get_selection().get_selected() if not ite: return (label, tipe, action, exe, menu, mid) = model.get(ite,0,1,2,3,4,5) if menu == "None": menu = None p = model.get_path(ite) n = p[len(p)-1] if n > 0: self._sth_changed(True) self.menu.interchange(menu, n, n-1) l = list(p) l[len(l)-1] -= 1 p = tuple(l) upper = model.get_iter(p) model.move_before(ite,upper) # down button clicked def down(self,param): (model, ite) = self.treeview.get_selection().get_selected() if not ite: return (label, tipe, action, exe, menu, mid) = model.get(ite,0,1,2,3,4,5) p = model.get_path(ite) n = p[len(p)-1] if n < self.menu._get_menu_len(menu) -1: self._sth_changed(True) self.menu.interchange(menu, n, n+1) l = list(p) l[len(l)-1] += 1 p = tuple(l) upper = model.get_iter(p) model.move_after(ite,upper) # remove button clicked def remove(self, param): (model, ite) = self.treeview.get_selection().get_selected() if not ite: return self._sth_changed(True) (label, tipe, action, exe, menu, mid) = model.get(ite,0,1,2,3,4,5) path = model.get_path(ite) n = path[len(path)-1] if tipe == "menu": if model.iter_has_child(ite): self.menu.removeMenu(mid) else: self.menu.removeItem(menu, n) else: self.menu.removeItem(menu, n) model.remove(ite) self.clear_fields() def mnu_remove(self, param): if self.treeview.is_focus(): self.remove(None) def show_about(self, args): #gtk.glade.XML("/usr/local/share/obmenu/obmenu.glade", "aboutdialog1") gtk.glade.XML(self.gladefile, "aboutdialog1") # application init def init(self): if len(sys.argv) == 2: # must be a path to a menu self.menu_path = sys.argv[1] elif len(sys.argv) == 1: self.menu_path = os.getenv("HOME") + "/.config/openbox/menu.xml" else: print "Error: Wrong number of arguments" print "Usage: obmenu /path/to/menu.xml" print "\tOr just obmenu, to edit the default file" return if not os.path.isfile(self.menu_path): print "Error: \"%s\" not found" % self.menu_path return self.unsaved_menu = False # Load in memory the real xml menu self.menu = obxml.ObMenu() self.menu.loadMenu(self.menu_path) # Look for my glade file! if os.path.isfile("obmenu.glade"): # It's here.. looks like a pre-installation execution self.gladefile = "obmenu.glade" elif os.path.isfile("/usr/local/share/obmenu/obmenu.glade"): self.gladefile = "/usr/local/share/obmenu/obmenu.glade" elif os.path.isfile("/usr/share/obmenu/obmenu.glade"): self.gladefile = "/usr/share/obmenu/obmenu.glade" else: print "ERROR: obmenu.glade not found!" print " check that everything was installed all right" sys.exit(1) # Set the basics for GTK self.arbol = gtk.glade.XML(self.gladefile, "window1") self.treeview=self.arbol.get_widget("treeview1") self.label_entry = self.arbol.get_widget("entry1") self.action_entry = self.arbol.get_widget("combobox1") self.execute_entry = self.arbol.get_widget("entry2") self.execute_srch = self.arbol.get_widget("button1") self.id_entry = self.arbol.get_widget("entry3") # treemodel.iter(label, type, [action], [execute], parent, [menu-id]) self.treemodel=gtk.TreeStore(gobject.TYPE_STRING, gobject.TYPE_STRING, gobject.TYPE_STRING, gobject.TYPE_STRING, gobject.TYPE_STRING, gobject.TYPE_STRING) self.treeview.set_model(self.treemodel) # Signals self.arbol.signal_autoconnect ({ "new_clicked": self.new, "open_clicked": self.open, "save_clicked": self.save, "save_as_clicked": self.save_as, "mnu_quit": self.mnu_quit, "mnu_remove": self.mnu_remove, "label_changed": self.change_label, "id_changed": self.change_id, "action_changed": self.change_action, "execute_changed": self.change_execute, "action_changed": self.change_action, "search_clicked": self.search_clicked, "on_treeview1": self.treeview_changed, "tree_key_pressed": self.tree_key_pressed, "menu_clicked": self.new_menu, "item_clicked": self.new_item, "separator_clicked": self.new_separator, "pipe_clicked": self.new_pipe, "link_clicked": self.new_link, "remove_clicked": self.remove, "up_clicked": self.up, "down_clicked": self.down, "show_about": self.show_about, "exit": self.quit }) # Set the columns self.treeview.set_headers_visible(True) renderer=gtk.CellRendererText() column=gtk.TreeViewColumn("Label",renderer, text=0) column.set_resizable(True) self.treeview.append_column(column) renderer=gtk.CellRendererText() column=gtk.TreeViewColumn("Type",renderer,text=1) column.set_resizable(True) self.treeview.append_column(column) renderer=gtk.CellRendererText() column=gtk.TreeViewColumn("Action",renderer,text=2) column.set_resizable(True) self.treeview.append_column(column) renderer=gtk.CellRendererText() column=gtk.TreeViewColumn("Execute",renderer,text=3) column.set_resizable(True) self.treeview.append_column(column) # Some states of the app self.auto_change = False self._sth_changed(False) # Create the menu tree self.createTree(None, None) # Let's roll! gtk.main() if __name__ == "__main__": app = App() app.init() obmenu-1.0/pipes-help0000644000175000001440000000252510370374633013670 0ustar kolmeusersobm-dir ======= obm-dir Builds a menu from a directory, alphabetically sorted. Example: obm-dir "/home/kolme/wallpaper" "fbsetbg" obm-moz ======= usage: obm-moz [options] options: -h, --help show this help message and exit -f, --firefox Look for Firefox bookmarks -m, --mozilla Look for Mozilla Suite bookmarks -b FILENAME, --bookmarks=FILENAME Especify the path to the bookmarks.html file -r ROOT, --root=ROOT Root folder of the bookmarks -n BROWSER, --navigator=BROWSER Command to run the web browser. Translates any mozilla-compatible bookmarks into an openbox menu. If no arguments are given, it'll try to find your bookmarks. A bookmarks folder can be passed as an argument, It'll try to find it and build the menu out of that folder. Example: obm-moz -b "/path/to/bookmarks.html" -r "Bookmarks Toolbar Folder" obm-nav ======= obm-nav Recursively builds a menu to navigate directories. Example: obm-nav /home/kolme rox aterm obm-xdg ======= obm-xdg --import Creates a file called "gnome-menus.xml" obm-xdg --replace Replaces the Openbox menu with the Gnome menus obm-xdg Prints a pipemenu (normal behaviour) A path to a different gnome menu can be passed: obm-xdg [options] /path/to/system.menu obmenu-1.0/minisetup.py0000644000175000001440000000053510364706463014270 0ustar kolmeusersfrom distutils.core import setup setup(name='obMenu', version='1.0', description='Openbox Menu Editor', author='Manuel Colmenero', author_email='m.kolme@gmail.com', scripts=['obmenu'], py_modules=['obxml'], data_files=[('/usr/local/share/obmenu', ['obmenu.glade', 'icons/mnu16.png', 'icons/mnu48.png'])] ) obmenu-1.0/obmenu.glade0000644000175000001440000007243410363260561014164 0ustar kolmeusers True Openbox Menu Editor GTK_WINDOW_TOPLEVEL GTK_WIN_POS_NONE False 500 500 True False True False False GDK_WINDOW_TYPE_HINT_NORMAL GDK_GRAVITY_NORTH True True False 0 True True _File True True gtk-new True True gtk-open True True gtk-save True True gtk-save-as True True True gtk-quit True True _Edit True True Move _up True True Move dow_n True True True _Delete True True gtk-delete 1 0.5 0.5 0 0 True _Add True True Menu True True Item True True Separator True True Pipemenu True True Link True True _Help True True _About True 0 False False True GTK_ORIENTATION_HORIZONTAL GTK_TOOLBAR_BOTH_HORIZ True True True Save the menu gtk-save True True False False True True True True True False False True New menu True gtk-index True True True False True True New item True gtk-execute True True True False True True New separator True gtk-file True True True False True True True True True False False True Move up gtk-go-up True True False False True True Move down gtk-go-down True True False False True True True True True False False True Removes a menu or an item gtk-remove True True False False True 0 False False True False 0 True True GTK_POLICY_ALWAYS GTK_POLICY_ALWAYS GTK_SHADOW_IN GTK_CORNER_TOP_LEFT True True True True True False False False False False False 0 True True True 4 2 False 0 0 True Label False False GTK_JUSTIFY_LEFT False False 0 0.5 0 0 PANGO_ELLIPSIZE_NONE -1 False 0 0 1 0 1 4 fill True Id False False GTK_JUSTIFY_LEFT False False 0 0.5 0 0 PANGO_ELLIPSIZE_NONE -1 False 0 0 1 1 2 4 fill True Action False False GTK_JUSTIFY_LEFT False False 0 0.5 0 0 PANGO_ELLIPSIZE_NONE -1 False 0 0 1 2 3 4 fill True Execute False False GTK_JUSTIFY_LEFT False False 0 0.5 0 0 PANGO_ELLIPSIZE_NONE -1 False 0 0 1 3 4 4 fill True False True True True 0 True * False 1 2 0 1 4 True False True True True 0 True * False 1 2 1 2 4 True False Execute Reconfigure Restart Exit False True 1 2 2 3 4 fill fill True False 0 True False True True True 0 True * False 0 True True True False True ... True GTK_RELIEF_NORMAL True 0 False False 1 2 3 4 4 fill fill 0 False True 0 True True True True Openbox Menu Editor Thank you for using this sofware. Send any feedback to m.kolme@gmail.com obmenu: Openbox Menu Editor Copyright (C) 2005-2006 Manuel Colmenero This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA http://obmenu.sourceforge.net/ Website Manuel Colmenero <m.kolme@gmail.com> translator-credits mnu48.png obmenu-1.0/README0000644000175000001440000000322010372444763012554 0ustar kolmeusers========== OBMENU 1.0 ========== Obmenu is an Openbox menu editor, written in python. It allows to edit menus in an intuitive way. REQUERIMENTS: python >= 2.3, pygtk, python-glade INSTALLATION: Type these commands in a shell: su python setup.py install or python minisetup.py install if you don't want the pipemenus CHANGELOG: - Automatically reconfigures Openbox - Create and modify pipemenus. Pipemenus are a way of creating menus dynamically. For more info, visit openbox documentation. - The same with "link" menus, which are references to other menus by their IDs. That way you can reproduce a menu in several places of your file. - Lot's of GUI enhancements - Multifile support (New, open, save, ..) CREDITS: Manuel Colmenero 2005-2006 Thanks to Mikael from the Openbox project, who gave me lots of ideas and tested the program. And thanks to all the helpful guys in the openbox list. NOTICE: This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA obmenu-1.0/.obmenu_temp0000644000175000001440000000525110351406104014175 0ustar kolmeusers accion: 00 Sueltos accion: 01 listas accion: 03 Videos accion: ACDC - Back in Black accion: ACDC - Ballbreaker accion: ACDC - Highway to Hell accion: Aerosmith-Pump (1989) accion: Anthrax - The Greater Of Two Evils (2004) accion: Anthrax_(State_of_Euphria) accion: Anthrax_-_Music_of_Mass_Destruction_2004 accion: BSO Full Metal Jacket accion: GTA San Andreas complete soundtrack (10 CDs) - RELEASE - by GaGGiU accion: KoRn - Follow The Leader accion: NOFX - (1999) The Decline accion: Screaming Headless Torsos - 2005 obmenu-1.0/obxml-help0000644000175000001440000000236710370377561013700 0ustar kolmeusers class ObMenu: ObMenu.newMenu() Initialices a new menu. ObMenu.newPipe() Initialices a new pipe. ObMenu.loadMenu(filename) Loads an existing menu file. NOTE: It's necessary to call one of the above before doing anything else. ObMenu.saveMenu(filename) ObMenu.printXml() ObMenu.getXml() ___________________________ menu: The ID of the menu you want to modify. If None, the root menu will be modified. n: The position of the item in its submenu, starting in 0. ObMenu.removeItem(menu, n) ObMenu.removeMenu(menu) ObMenu.createSep(menum, n) If n not specified, separator will be appended ObMenu.createItem(menu, label, action, execute, n) If n not specified, item will be appended ObMenu.createLink(menu, mid) If n not specified, link will be appended ObMenu.createPipe(menu, mid, label, execute) If n not specified, pipe will be appended ObMenu.createMenu(menu, label, mid) If n not specified, menu will be appended ObMenu.interchange(menu, n1, n2) ObMenu.setItemProps(menu, n, label, action, exe) ObMenu.setMenuLabel(menu, label) ObMenu.getMenuLabel(menu) ObMenu.setRefLabel(parent, link_id, label) parent: ID of the parent menu menu_id ObMenu.setRefId(parent, menu_id, new_id) obmenu-1.0/setup.py0100644000175000001440000000075410372705571013415 0ustar kolmeusersimport os, sys, glob from distutils.core import setup libdir = 'share/obmenu' sys.path += [os.path.join(os.curdir, libdir)] setup(name='obMenu', version='1.0', description='Openbox Menu Editor', author='Manuel Colmenero', author_email='m.kolme@gmail.com', scripts=['obmenu', 'pipes/obm-xdg','pipes/obm-dir','pipes/obm-moz','pipes/obm-nav'], py_modules=['obxml'], data_files=[(libdir, ['obmenu.glade', 'icons/mnu16.png','icons/mnu48.png'])] )