Right click for popup working on listviews
svn: r19954
This commit is contained in:
parent
2a6790d795
commit
140f23536f
@ -33,6 +33,7 @@ from gen.ggettext import gettext as _
|
||||
# GTK libraries
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
from gi.repository import GObject
|
||||
from gi.repository import Gtk
|
||||
from gi.repository import Pango
|
||||
WEIGHT_NORMAL = Pango.Weight.NORMAL
|
||||
|
@ -34,6 +34,7 @@ from gen.ggettext import gettext as _
|
||||
# GTK libraries
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
from gi.repository import GObject
|
||||
from gi.repository import Gtk
|
||||
from gi.repository import Pango
|
||||
WEIGHT_NORMAL = Pango.Weight.NORMAL
|
||||
|
@ -27,7 +27,6 @@
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
from gi.repository import Gtk
|
||||
from gi.repository import GObject
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
|
@ -55,17 +55,6 @@ from gen.constfunc import has_display, is_quartz, mac, win
|
||||
#
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
def add_menuitem(menu, msg, obj, func):
|
||||
"""
|
||||
add a menuitem to menu with label msg, which activates func, and has data
|
||||
obj
|
||||
"""
|
||||
from gi.repository import Gtk
|
||||
item = Gtk.MenuItem(label=msg)
|
||||
item.set_data('o', obj)
|
||||
item.connect("activate", func)
|
||||
item.show()
|
||||
menu.append(item)
|
||||
|
||||
class CLIVbox():
|
||||
"""
|
||||
|
@ -57,7 +57,7 @@ from gui.columnorder import ColumnOrder
|
||||
from gen.config import config
|
||||
from gen.errors import WindowActiveError
|
||||
from gui.filters import SearchBar
|
||||
from gui.utils import add_menuitem
|
||||
from gui.widgets.menuitem import add_menuitem
|
||||
from gen.const import CUSTOM_FILTERS, USE_TIPS
|
||||
from gen.utils.debug import profile
|
||||
from gen.utils.string import data_recover_msg
|
||||
|
@ -14,6 +14,7 @@ pkgpython_PYTHON = \
|
||||
grampletpane.py \
|
||||
labels.py \
|
||||
linkbox.py \
|
||||
menuitem.py \
|
||||
menutoolbuttonaction.py \
|
||||
monitoredwidgets.py \
|
||||
multitreeview.py \
|
||||
|
@ -49,6 +49,7 @@ from gen.const import URL_MANUAL_PAGE, VERSION_DIR
|
||||
from gui.editors import EditPerson, EditFamily
|
||||
from gui.managedwindow import ManagedWindow
|
||||
import gui.utils
|
||||
from gui.widgets.menuitem import add_menuitem
|
||||
from gui.plug.quick import run_quick_report_by_name
|
||||
from gui.display import display_help, display_url
|
||||
from gui.glade import Glade
|
||||
@ -1386,7 +1387,7 @@ class GrampletPane(Gtk.ScrolledWindow):
|
||||
if gplug.navtypes == []]
|
||||
names.sort()
|
||||
for name in names:
|
||||
gui.utils.add_menuitem(qr_menu, name, None,
|
||||
add_menuitem(qr_menu, name, None,
|
||||
self.add_gramplet)
|
||||
ag_menu.set_submenu(qr_menu)
|
||||
rg_menu = uiman.get_widget('/GrampletPopup/RestoreGramplet')
|
||||
@ -1400,7 +1401,7 @@ class GrampletPane(Gtk.ScrolledWindow):
|
||||
if len(names) > 0:
|
||||
qr_menu = Gtk.Menu()
|
||||
for name in names:
|
||||
gui.utils.add_menuitem(qr_menu, name, None,
|
||||
add_menuitem(qr_menu, name, None,
|
||||
self.restore_gramplet)
|
||||
rg_menu.set_submenu(qr_menu)
|
||||
menu = uiman.get_widget('/GrampletPopup')
|
||||
|
74
src/gui/widgets/menuitem.py
Normal file
74
src/gui/widgets/menuitem.py
Normal file
@ -0,0 +1,74 @@
|
||||
#
|
||||
# Gramps - a GTK+/GNOME based genealogy program
|
||||
#
|
||||
# Copyright (C) 2008 Zsolt Foldvari
|
||||
#
|
||||
# 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
|
||||
#
|
||||
|
||||
# $Id: toolcomboentry.py 19858 2012-06-17 21:25:37Z bmcage $
|
||||
|
||||
"ToolComboEntry class."
|
||||
|
||||
__all__ = ["MenuItemWithData", "add_menuitem"]
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# Python modules
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
import logging
|
||||
_LOG = logging.getLogger(".widgets.menuitem")
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# GTK modules
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
from gi.repository import GObject
|
||||
from gi.repository import Gtk
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# MenuItemWithData class
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
|
||||
|
||||
class MenuItemWithData(Gtk.MenuItem):
|
||||
""" A MenuItem that stores a data property. As set_data in GTK3 is not
|
||||
working, this is a workaround to have set_data"""
|
||||
data = GObject.Property(type=object)
|
||||
|
||||
def __init__(self, label=''):
|
||||
GObject.GObject.__init__(self, label=label)
|
||||
|
||||
def set_data(self, data):
|
||||
self.data = data
|
||||
|
||||
def get_data(self, _=None):
|
||||
""" obtain the data, for backward compat, we allow a dummy argument"""
|
||||
return self.data
|
||||
|
||||
def add_menuitem(menu, msg, obj, func):
|
||||
"""
|
||||
add a menuitem to menu with label msg, which activates func, and has data
|
||||
obj
|
||||
"""
|
||||
item = MenuItemWithData(label=msg)
|
||||
item.set_data(obj)
|
||||
item.connect("activate", func)
|
||||
item.show()
|
||||
menu.append(item)
|
@ -47,7 +47,7 @@ from gi.repository import Gtk
|
||||
#-------------------------------------------------------------------------
|
||||
import gen.lib
|
||||
from gui.views.listview import ListView
|
||||
from gui.utils import add_menuitem
|
||||
from gui.widgets.menuitem import add_menuitem
|
||||
from gen.errors import WindowActiveError
|
||||
from gui.views.bookmarks import PlaceBookmarks
|
||||
from gen.config import config
|
||||
|
Loading…
Reference in New Issue
Block a user