Fix pop up menu on right mouse button click on gallery images. The menu variable must be declared as an instance variable to prevent the Gtk.Menu object from being garbage collected, otherwise the menu fails to appear.
svn: r20095
This commit is contained in:
parent
871b58ae3d
commit
08a00f49cd
@ -118,7 +118,8 @@ class GalleryTab(ButtonTab, DbGUIElement):
|
|||||||
elif gui.utils.is_right_click(event):
|
elif gui.utils.is_right_click(event):
|
||||||
reflist = self.iconlist.get_selected_items()
|
reflist = self.iconlist.get_selected_items()
|
||||||
if len(reflist) == 1:
|
if len(reflist) == 1:
|
||||||
ref = self.media_list[reflist[0][0]]
|
path = reflist[0].get_indices()
|
||||||
|
ref = self.media_list[path[0]]
|
||||||
self.right_click(ref, event)
|
self.right_click(ref, event)
|
||||||
return True
|
return True
|
||||||
return
|
return
|
||||||
@ -131,7 +132,7 @@ class GalleryTab(ButtonTab, DbGUIElement):
|
|||||||
(True, True, Gtk.STOCK_REMOVE, self.del_button_clicked),
|
(True, True, Gtk.STOCK_REMOVE, self.del_button_clicked),
|
||||||
]
|
]
|
||||||
|
|
||||||
menu = Gtk.Menu()
|
self.menu = Gtk.Menu()
|
||||||
|
|
||||||
ref_obj = self.dbstate.db.get_object_from_handle(obj.ref)
|
ref_obj = self.dbstate.db.get_object_from_handle(obj.ref)
|
||||||
media_path = media_path_full(self.dbstate.db, ref_obj.get_path())
|
media_path = media_path_full(self.dbstate.db, ref_obj.get_path())
|
||||||
@ -142,27 +143,27 @@ class GalleryTab(ButtonTab, DbGUIElement):
|
|||||||
item.set_image(img)
|
item.set_image(img)
|
||||||
item.connect('activate', make_launcher(media_path))
|
item.connect('activate', make_launcher(media_path))
|
||||||
item.show()
|
item.show()
|
||||||
menu.append(item)
|
self.menu.append(item)
|
||||||
mfolder, mfile = os.path.split(media_path)
|
mfolder, mfile = os.path.split(media_path)
|
||||||
item = Gtk.MenuItem(label=_('Open Containing _Folder'))
|
item = Gtk.MenuItem(label=_('Open Containing _Folder'))
|
||||||
item.connect('activate', make_launcher(mfolder))
|
item.connect('activate', make_launcher(mfolder))
|
||||||
item.show()
|
item.show()
|
||||||
menu.append(item)
|
self.menu.append(item)
|
||||||
item = Gtk.SeparatorMenuItem()
|
item = Gtk.SeparatorMenuItem()
|
||||||
item.show()
|
item.show()
|
||||||
menu.append(item)
|
self.menu.append(item)
|
||||||
|
|
||||||
for (needs_write_access, image, title, func) in itemlist:
|
for (needs_write_access, image, title, func) in itemlist:
|
||||||
if image:
|
if image:
|
||||||
item = Gtk.ImageMenuItem(stock_id=title)
|
item = Gtk.ImageMenuItem.new_from_stock(title, None)
|
||||||
else:
|
else:
|
||||||
item = Gtk.MenuItem(label=title)
|
item = Gtk.MenuItem(label=title)
|
||||||
item.connect('activate', func)
|
item.connect('activate', func)
|
||||||
if needs_write_access and self.dbstate.db.readonly:
|
if needs_write_access and self.dbstate.db.readonly:
|
||||||
item.set_sensitive(False)
|
item.set_sensitive(False)
|
||||||
item.show()
|
item.show()
|
||||||
menu.append(item)
|
self.menu.append(item)
|
||||||
menu.popup(None, None, None, None, event.button, event.time)
|
self.menu.popup(None, None, None, None, event.button, event.time)
|
||||||
|
|
||||||
def get_icon_name(self):
|
def get_icon_name(self):
|
||||||
return 'gramps-media'
|
return 'gramps-media'
|
||||||
|
Loading…
Reference in New Issue
Block a user