Kiln » TortoiseHg » TortoiseHg
Clone URL:  
Pushed to one repository · View In Graph Contained in 1.0, 1.0.1, and 1.0.2

browse: migrate over to MenuBuilder

Changeset a50fb34c9e85

Parent ef0d1265b30d

by Yuki KODAMA

Changes to one file · Browse files at a50fb34c9e85 Showing diff from parent ef0d1265b30d Diff from another changeset...

 
291
292
293
294
295
296
297
298
299
 
 
 
 
 
 
 
 
 
 
 
 
 
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
 
322
323
324
 
291
292
293
 
 
 
 
 
 
294
295
296
297
298
299
300
301
302
303
304
305
306
307
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
308
309
310
311
@@ -291,34 +291,21 @@
  finally:   os.chdir(oldcwd)   - def create_menu(label, hgcmd=None): - menuitem = gtk.MenuItem(label, True) - if hgcmd: - menuitem.connect('activate', rundialog, hgcmd) - menuitem.set_border_width(1) - return menuitem + def build(menus): + m = gtklib.MenuBuilder() + for info in menus: + if info.isSep(): + m.append_sep() + elif info.isSubmenu(): + m.append_submenu(info.menutext, icon=info.icon, + submenu=build(info.get_menus())) + elif info.state: + # TODO: do something with info.helptext + m.append(info.menutext, rundialog, info.icon, + args=[info.hgcmd]) + return m.build()   - def create_submenu(label, menu): - m = create_menu(label) - m.set_submenu(menu) - return m - - def buildmenus(menus): - m = gtklib.MenuItems() - for menu_info in menus: - if menu_info.isSep(): - m.append_sep() - elif menu_info.isSubmenu(): - item = create_submenu(menu_info.menutext, - buildmenus(menu_info.get_menus())) - m.append(item) - elif menu_info.state: - # TODO: do something with menu_info.helptext, .icon - item = create_menu(menu_info.menutext, menu_info.hgcmd) - m.append(item) - return m.create_menu() - - menu = buildmenus(menus) + menu = build(menus)   menu.show_all()   menu.popup(None, None, None, 0, 0)