Start convertion to introspection. Flat models work, as does relationship view

svn: r19858
This commit is contained in:
Benny Malengier 2012-06-17 21:25:37 +00:00
parent 0c447be83d
commit faed8a9f5f
256 changed files with 4420 additions and 4143 deletions

5
README
View File

@ -5,8 +5,9 @@ If building from source, also read the INSTALL file (at least through the
Requirements
--------------------------------
The following packages *MUST* be installed in order for Gramps to work:
Python 2.6 or greater
PyGTK2 2.16 or greater
Python 2.7 or greater
GTK 3.0 or greater
pygobject 3.3.2 or greater
librsvg2 (svg icon view)
xdg-utils

View File

@ -67,9 +67,9 @@ def resize_to_jpeg(source, destination, width, height, crop=None):
:param crop: cropping coordinates
:type crop: array of integers ([start_x, start_y, end_x, end_y])
"""
import gtk
from gi.repository import GdkPixbuf
img = gtk.gdk.pixbuf_new_from_file(source)
img = GdkPixbuf.Pixbuf.new_from_file(source)
if crop:
# Gramps cropping coorinates are [0, 100], so we need to convert to pixels
@ -84,7 +84,7 @@ def resize_to_jpeg(source, destination, width, height, crop=None):
# if the dimensions aren't close in size
(width, height) = image_actual_size(width, height, img.get_width(), img.get_height())
scaled = img.scale_simple(int(width), int(height), gtk.gdk.INTERP_BILINEAR)
scaled = img.scale_simple(int(width), int(height), GdkPixbuf.InterpType.BILINEAR)
scaled.save(destination, 'jpeg')
#-------------------------------------------------------------------------
@ -137,13 +137,13 @@ def image_size(source):
:rtype: tuple(int, int)
:returns: a tuple consisting of the width and height
"""
import gtk
import gobject
from gi.repository import GdkPixbuf
from gi.repository import GObject
try:
img = gtk.gdk.pixbuf_new_from_file(source)
img = GdkPixbuf.Pixbuf.new_from_file(source)
width = img.get_width()
height = img.get_height()
except gobject.GError:
except GObject.GError:
width = 0
height = 0
return (width, height)
@ -199,8 +199,8 @@ def resize_to_buffer(source, size, crop=None):
:rtype: buffer of data
:returns: raw data
"""
import gtk
img = gtk.gdk.pixbuf_new_from_file(source)
from gi.repository import GdkPixbuf
img = GdkPixbuf.Pixbuf.new_from_file(source)
if crop:
# Gramps cropping coorinates are [0, 100], so we need to convert to pixels
@ -215,7 +215,7 @@ def resize_to_buffer(source, size, crop=None):
# if the dimensions aren't close in size
(size[0], size[1]) = image_actual_size(size[0], size[1], img.get_width(), img.get_height())
scaled = img.scale_simple(int(size[0]), int(size[1]), gtk.gdk.INTERP_BILINEAR)
scaled = img.scale_simple(int(size[0]), int(size[1]), GdkPixbuf.InterpType.BILINEAR)
return scaled
@ -238,9 +238,9 @@ def resize_to_jpeg_buffer(source, size, crop=None):
:rtype: buffer of data
:returns: jpeg image as raw data
"""
import gtk
from gi.repository import GdkPixbuf
filed, dest = tempfile.mkstemp()
img = gtk.gdk.pixbuf_new_from_file(source)
img = GdkPixbuf.Pixbuf.new_from_file(source)
if crop:
# Gramps cropping coorinates are [0, 100], so we need to convert to pixels
@ -255,7 +255,7 @@ def resize_to_jpeg_buffer(source, size, crop=None):
# if the dimensions aren't close in size
(size[0], size[1]) = image_actual_size(size[0], size[1], img.get_width(), img.get_height())
scaled = img.scale_simple(int(size[0]), int(size[1]), gtk.gdk.INTERP_BILINEAR)
scaled = img.scale_simple(int(size[0]), int(size[1]), GdkPixbuf.InterpType.BILINEAR)
os.close(filed)
dest = Utils.get_unicode_path_from_env_var(dest)
scaled.save(dest, 'jpeg')

View File

@ -100,7 +100,7 @@ def setup_gettext():
try:
locale.bindtextdomain(LOCALEDOMAIN, LOCALEDIR)
except ValueError:
print 'Failed to bind text domain, gtk.Builder() has no translation'
print 'Failed to bind text domain, Gtk.Builder() has no translation'
#following installs _ as a python function, we avoid this as TransUtils is
#used sometimes:
@ -143,7 +143,7 @@ def init_windows_gettext(intl_path):
def setup_windows_gettext():
"""
Windows specific function for migrating from LibGlade to GtkBuilder
Glade had a gtk.glade.bindtextdomain() function to define the directory
Glade had a Gtk.glade.bindtextdomain() function to define the directory
where to look for translations (.mo-files). It is now replaced with call
to locale.bindtextdomain() which exposes the C librarys gettext
interface on systems that provide this interface.

View File

@ -24,7 +24,7 @@
"""
Some independent constants/functions that can be safely imported
without any translation happening yet. Do _not_ add imports that will
perform a translation on import, eg gtk.
perform a translation on import, eg Gtk.
"""
#------------------------------------------------------------------------
@ -90,27 +90,31 @@ def is_quartz():
"""
if mac():
try:
import gtk
from gi.repository import Gtk
from gi.repository import Gdk
except:
return False
return gtk.gdk.WINDOWING == "quartz"
return Gdk.WINDOWING == "quartz"
return False
def has_display():
"""
Tests to see if Python is currently running with gtk
"""
# FIXME: currently, gtk.init_check() requires all strings
# FIXME: currently, Gtk.init_check() requires all strings
# in argv, and we might have unicode.
temp, sys.argv = sys.argv, sys.argv[:1]
try:
import gtk
from gi.repository import Gtk
except:
return False
try:
gtk.init_check()
test = Gtk.init_check(temp)
sys.argv = temp
return True
if test:
return True
else:
return False
except:
sys.argv = temp
return False

View File

@ -1841,7 +1841,7 @@ class DbBsddb(DbBsddbRead, DbWriteBase, UpdateCallback):
if not transaction.batch:
# It can occur that the listview is already updated because of
# the "model-treeview automatic update" combined with a
# "while gtk.events_pending(): gtk.main_iteration() loop"
# "while Gtk.events_pending(): Gtk.main_iteration() loop"
# (typically used in a progress bar), so emit rebuild signals
# to correct that.
object_types = set([x[0] for x in transaction.keys()])

View File

@ -20,7 +20,7 @@
# $Id$
import gtk
from gi.repository import Gtk
try:
from gnomevfs import mime_get_short_list_applications, \

View File

@ -230,16 +230,16 @@ class Gramplet(object):
Set the textview to wrap or not.
"""
textview = self.gui.textview
import gtk
# gtk.WRAP_NONE, gtk.WRAP_CHAR, gtk.WRAP_WORD or gtk.WRAP_WORD_CHAR.
from gi.repository import Gtk
# Gtk.WrapMode.NONE, Gtk.WrapMode.CHAR, Gtk.WrapMode.WORD or Gtk.WrapMode.WORD_CHAR.
if value in [True, 1]:
textview.set_wrap_mode(gtk.WRAP_WORD)
textview.set_wrap_mode(Gtk.WrapMode.WORD)
elif value in [False, 0, None]:
textview.set_wrap_mode(gtk.WRAP_NONE)
textview.set_wrap_mode(Gtk.WrapMode.NONE)
elif value in ["char"]:
textview.set_wrap_mode(gtk.WRAP_CHAR)
textview.set_wrap_mode(Gtk.WrapMode.CHAR)
elif value in ["word char"]:
textview.set_wrap_mode(gtk.WRAP_WORD_CHAR)
textview.set_wrap_mode(Gtk.WrapMode.WORD_CHAR)
else:
raise ValueError(
"Unknown wrap mode: '%s': use 0,1,'char' or 'word char')"
@ -275,7 +275,7 @@ class Gramplet(object):
"""
The main interface for running the main method.
"""
import gobject
from gi.repository import GObject
if ((not self.active or
self.gui.gstate in ["closed", "minimized"] or
not self.dbstate.open) and
@ -294,8 +294,8 @@ class Gramplet(object):
self.interrupt()
self._generator = self.main()
self._pause = False
self._idle_id = gobject.idle_add(self._updater,
priority=gobject.PRIORITY_LOW - 10)
self._idle_id = GObject.idle_add(self._updater,
priority=GObject.PRIORITY_LOW - 10)
def _updater(self):
"""
@ -345,10 +345,10 @@ class Gramplet(object):
"""
Resume the main method that has previously paused.
"""
import gobject
from gi.repository import GObject
self._pause = False
self._idle_id = gobject.idle_add(self._updater,
priority=gobject.PRIORITY_LOW - 10)
self._idle_id = GObject.idle_add(self._updater,
priority=GObject.PRIORITY_LOW - 10)
def update_all(self, *args):
"""
@ -363,10 +363,10 @@ class Gramplet(object):
"""
Force the generator to stop running.
"""
import gobject
from gi.repository import GObject
self._pause = True
if self._idle_id == 0:
gobject.source_remove(self._idle_id)
GObject.source_remove(self._idle_id)
self._idle_id = 0
def _db_changed(self, db):

View File

@ -549,7 +549,7 @@ class BasePluginManager(object):
@param option: the option class
@type option: class that inherits from gen.plug.menu.Option
@param guioption: the gui-option class
@type guioption: class that inherits from gtk.Widget.
@type guioption: class that inherits from Gtk.Widget.
"""
self.__external_opt_dict[option] = guioption;

View File

@ -94,7 +94,7 @@ elif operating_system == 'FreeBSD':
try:
gettext.bindtextdomain(TransUtils.LOCALEDOMAIN, TransUtils.LOCALEDIR)
except locale.Error:
print 'No translation in some gtk.Builder strings, '
print 'No translation in some Gtk.Builder strings, '
elif operating_system == 'OpenBSD':
pass
else: # normal case
@ -102,7 +102,7 @@ else: # normal case
locale.bindtextdomain(TransUtils.LOCALEDOMAIN, TransUtils.LOCALEDIR)
#locale.textdomain(TransUtils.LOCALEDOMAIN)
except locale.Error:
print 'No translation in some gtk.Builder strings, '
print 'No translation in some Gtk.Builder strings, '
#-------------------------------------------------------------------------
#
@ -110,7 +110,7 @@ else: # normal case
#
#-------------------------------------------------------------------------
MIN_PYTHON_VERSION = (2, 6, 0, '', 0)
MIN_PYTHON_VERSION = (2, 7, 0, '', 0)
if not sys.version_info >= MIN_PYTHON_VERSION :
print (_("Your Python version does not meet the "
"requirements. At least python %(v1)d.%(v2)d.%(v3)d is needed to"
@ -193,28 +193,23 @@ def show_settings():
"""
py_str = '%d.%d.%d' % sys.version_info[:3]
try:
import gtk
from gi.repository import Gtk
try:
gtkver_str = '%d.%d.%d' % gtk.gtk_version
gtkver_str = '%d.%d.%d' % (Gtk.get_major_version(),
Gtk.get_minor_version(), Gtk.get_micro_version())
except : # any failure to 'get' the version
gtkver_str = 'unknown version'
try:
pygtkver_str = '%d.%d.%d' % gtk.pygtk_version
except :# any failure to 'get' the version
pygtkver_str = 'unknown version'
except ImportError:
gtkver_str = 'not found'
pygtkver_str = 'not found'
# no DISPLAY is a RuntimeError in an older pygtk (e.g. 2.17 in Fedora 14)
except RuntimeError:
gtkver_str = 'DISPLAY not set'
pygtkver_str = 'DISPLAY not set'
#exept TypeError: To handle back formatting on version split
try:
import gobject
from gi.repository import GObject
try:
gobjectver_str = '%d.%d.%d' % gobject.pygobject_version
gobjectver_str = '%d.%d.%d' % GObject.pygobject_version
except :# any failure to 'get' the version
gobjectver_str = 'unknown version'
@ -306,7 +301,6 @@ def show_settings():
print ' python : %s' % py_str
print ' gramps : %s' % gramps_str
print ' gtk++ : %s' % gtkver_str
print ' pygtk : %s' % pygtkver_str
print ' gobject : %s' % gobjectver_str
if usebsddb3:
print ' Using bsddb3'

View File

@ -44,7 +44,8 @@ except ImportError:
# Gtk modules
#
#-------------------------------------------------------------------------
import gtk
from gi.repository import Gtk
from gi.repository import GdkPixbuf
#-------------------------------------------------------------------------
#
@ -73,11 +74,11 @@ CONTRIB_HEADER = _('\n==== Contributors ====\n')
# GrampsAboutDialog
#
#-------------------------------------------------------------------------
class GrampsAboutDialog(gtk.AboutDialog):
class GrampsAboutDialog(Gtk.AboutDialog):
"""Create an About dialog with all fields set."""
def __init__(self, parent):
"""Setup all the fields shown in the About dialog."""
gtk.AboutDialog.__init__(self)
GObject.GObject.__init__(self)
self.set_transient_for(parent)
self.set_modal(True)
@ -111,7 +112,7 @@ class GrampsAboutDialog(gtk.AboutDialog):
self.set_translator_credits(trans_credits)
self.set_documenters(const.DOCUMENTERS)
self.set_logo(gtk.gdk.pixbuf_new_from_file(const.SPLASH))
self.set_logo(GdkPixbuf.Pixbuf.new_from_file(const.SPLASH))
def get_versions(self):
"""
@ -243,5 +244,6 @@ def _show_url(dialog, link, prefix):
link = prefix + link
display_url(link)
gtk.about_dialog_set_url_hook(_show_url, None)
gtk.about_dialog_set_email_hook(_show_url, 'mailto:')
#TODO GTK3: is there an alternative for these:
#Gtk.about_dialog_set_url_hook(_show_url, None)
#Gtk.about_dialog_set_email_hook(_show_url, 'mailto:')

View File

@ -36,14 +36,14 @@ import locale
# GNOME modules
#
#-------------------------------------------------------------------------
import gtk
import gobject
from gi.repository import Gtk
from gi.repository import GObject
def fill_combo(combo, data_list):
"""
Fill a combo box with completion data
"""
store = gtk.ListStore(gobject.TYPE_STRING)
store = Gtk.ListStore(GObject.TYPE_STRING)
for data in data_list:
if data:
@ -51,24 +51,24 @@ def fill_combo(combo, data_list):
combo.set_model(store)
combo.set_text_column(0)
completion = gtk.EntryCompletion()
completion = Gtk.EntryCompletion()
completion.set_model(store)
completion.set_minimum_key_length(1)
completion.set_text_column(0)
combo.child.set_completion(completion)
combo.get_child().set_completion(completion)
def fill_entry(entry, data_list):
"""
Fill a entry with completion data
"""
store = gtk.ListStore(gobject.TYPE_STRING)
store = Gtk.ListStore(GObject.TYPE_STRING)
for data in data_list:
if data:
store.append(row=[data])
completion = gtk.EntryCompletion()
completion = Gtk.EntryCompletion()
completion.set_model(store)
completion.set_minimum_key_length(1)
completion.set_text_column(0)
@ -115,7 +115,7 @@ class StandardCustomSelector(object):
Constructor for the StandardCustomSelector class.
:param cbe: Existing ComboBoxEntry widget to use.
:type cbe: gtk.ComboBoxEntry
:type cbe: Gtk.ComboBoxEntry
:param mapping: The mapping between integer and string constants.
:type mapping: dict
:param custom_key: The key corresponding to the custom string entry
@ -132,7 +132,7 @@ class StandardCustomSelector(object):
self.additional = additional
# make model
self.store = gtk.ListStore(gobject.TYPE_INT, gobject.TYPE_STRING)
self.store = Gtk.ListStore(GObject.TYPE_INT, GObject.TYPE_STRING)
# fill it up using mapping
self.fill()
@ -141,18 +141,24 @@ class StandardCustomSelector(object):
if cbe:
self.selector = cbe
self.selector.set_model(self.store)
self.selector.set_text_column(1)
renderer = Gtk.CellRendererText()
self.selector.pack_start(renderer, True)
self.selector.add_attribute(renderer, 'text', 1)
else:
self.selector = gtk.ComboBoxEntry(self.store, 1)
self.selector = Gtk.ComboBox(has_entry=True)
self.selector.set_model(self.store)
renderer = Gtk.CellRendererText()
self.selector.pack_start(renderer, True)
self.selector.add_attribute(renderer, 'text', 1)
if self.active_key is not None:
self.selector.set_active(self.active_index)
# make autocompletion work
completion = gtk.EntryCompletion()
completion = Gtk.EntryCompletion()
completion.set_model(self.store)
completion.set_minimum_key_length(1)
completion.set_text_column(1)
self.selector.child.set_completion(completion)
self.selector.get_child().set_completion(completion)
def fill(self):
"""
@ -201,10 +207,10 @@ class StandardCustomSelector(object):
int_val = self.store.get_value(active_iter, 0)
str_val = self.store.get_value(active_iter, 1)
if str_val != self.mapping[int_val]:
str_val = self.selector.child.get_text().strip()
str_val = self.selector.get_child().get_text().strip()
else:
int_val = self.custom_key
str_val = self.selector.child.get_text().strip()
str_val = self.selector.get_child().get_text().strip()
if str_val in self.mapping.itervalues():
for key in self.mapping:
if str_val == self.mapping[key]:
@ -225,7 +231,7 @@ class StandardCustomSelector(object):
if key in self.mapping and key != self.custom_key:
self.store.foreach(self.set_int_value, key)
elif self.custom_key is not None:
self.selector.child.set_text(text)
self.selector.get_child().set_text(text)
else:
print "StandardCustomSelector.set(): Option not available:", val

View File

@ -36,8 +36,9 @@ from time import strftime as strftime
# GTK/Gnome modules
#
#-------------------------------------------------------------------------
import gtk
from gtk.gdk import ACTION_COPY, BUTTON1_MASK, ACTION_MOVE
from gi.repository import Gtk
from gi.repository import Gdk
from gi.repository import GdkPixbuf
#-------------------------------------------------------------------------
#
@ -73,7 +74,7 @@ WIKI_HELP_SEC = _('manual|Using_the_Clipboard')
#-------------------------------------------------------------------------
_stock_image = os.path.join(const.IMAGE_DIR,'stock_link.png')
LINK_PIC = gtk.gdk.pixbuf_new_from_file(_stock_image)
LINK_PIC = GdkPixbuf.Pixbuf.new_from_file(_stock_image)
ICONS = {}
for (name, file) in (
("media", "gramps-media.png"),
@ -94,7 +95,7 @@ for (name, file) in (
('url', 'gramps-geo.png'),
):
_image = os.path.join(const.IMAGE_DIR, '16x16', file)
ICONS[name] = gtk.gdk.pixbuf_new_from_file(_image)
ICONS[name] = GdkPixbuf.Pixbuf.new_from_file(_image)
#-------------------------------------------------------------------------
#
@ -171,7 +172,7 @@ def model_contains(model, data):
#
#-------------------------------------------------------------------------
class ClipWrapper(object):
UNAVAILABLE_ICON = gtk.STOCK_DIALOG_ERROR
UNAVAILABLE_ICON = Gtk.STOCK_DIALOG_ERROR
def __init__(self, dbstate, obj):
dbstate.connect('database-changed', self.database_changed)
@ -870,10 +871,10 @@ class ClipDropHandleList(ClipDropList):
# ClipboardListModel class
#
#-------------------------------------------------------------------------
class ClipboardListModel(gtk.ListStore):
class ClipboardListModel(Gtk.ListStore):
def __init__(self):
gtk.ListStore.__init__(self,
GObject.GObject.__init__(self,
str, # 0: object type
object, # 1: object
object, # 2: tooltip callback
@ -891,7 +892,7 @@ class ClipboardListModel(gtk.ListStore):
#-------------------------------------------------------------------------
class ClipboardListView(object):
LOCAL_DRAG_TARGET = ('MY_TREE_MODEL_ROW', gtk.TARGET_SAME_WIDGET, 0)
LOCAL_DRAG_TARGET = ('MY_TREE_MODEL_ROW', Gtk.TargetFlags.SAME_WIDGET, 0)
LOCAL_DRAG_TYPE = 'MY_TREE_MODEL_ROW'
def __init__(self, dbstate, widget):
@ -905,16 +906,16 @@ class ClipboardListView(object):
self._previous_drop_time = 0
# Create the tree columns
self._col1 = gtk.TreeViewColumn(_("Type"))
self._col1 = Gtk.TreeViewColumn(_("Type"))
self._col1.set_property("resizable", True)
self._col1.set_sort_column_id(0)
self._col2 = gtk.TreeViewColumn(_("Title"))
self._col2 = Gtk.TreeViewColumn(_("Title"))
self._col2.set_property("resizable", True)
self._col2.set_sort_column_id(3)
self._col3 = gtk.TreeViewColumn(_("Value"))
self._col3 = Gtk.TreeViewColumn(_("Value"))
self._col3.set_property("resizable", True)
self._col3.set_sort_column_id(4)
self._col4 = gtk.TreeViewColumn(_("Family Tree"))
self._col4 = Gtk.TreeViewColumn(_("Family Tree"))
self._col4.set_property("resizable", True)
self._col4.set_sort_column_id(6)
@ -925,14 +926,14 @@ class ClipboardListView(object):
self._widget.append_column(self._col4)
# Create cell renders
self._col1_cellpb = gtk.CellRendererPixbuf()
self._col1_cell = gtk.CellRendererText()
self._col2_cell = gtk.CellRendererText()
self._col3_cell = gtk.CellRendererText()
self._col4_cell = gtk.CellRendererText()
self._col1_cellpb = Gtk.CellRendererPixbuf()
self._col1_cell = Gtk.CellRendererText()
self._col2_cell = Gtk.CellRendererText()
self._col3_cell = Gtk.CellRendererText()
self._col4_cell = Gtk.CellRendererText()
# Add cells to view
self._col1.pack_start(self._col1_cellpb, False)
self._col1.pack_start(self._col1_cellpb, False, True, 0)
self._col1.pack_start(self._col1_cell, True)
self._col2.pack_start(self._col2_cell, True)
self._col3.pack_start(self._col3_cell, True)
@ -949,10 +950,10 @@ class ClipboardListView(object):
self._widget.set_enable_search(True)
#self._widget.set_search_column(3)
self._widget.drag_dest_set(gtk.DEST_DEFAULT_ALL,
self._widget.drag_dest_set(Gtk.DestDefaults.ALL,
(ClipboardListView.LOCAL_DRAG_TARGET,) + \
DdTargets.all_targets(),
ACTION_COPY)
Gdk.DragAction.COPY)
self._widget.connect('drag_data_get', self.object_drag_data_get)
self._widget.connect('drag_begin', self.object_drag_begin)
@ -1116,7 +1117,7 @@ class ClipboardListView(object):
tree_selection = self._widget.get_selection()
model, paths = tree_selection.get_selected_rows()
if len(paths) > 1:
targets = [(DdTargets.RAW_LIST.drag_type, gtk.TARGET_SAME_WIDGET, 0),
targets = [(DdTargets.RAW_LIST.drag_type, Gtk.TargetFlags.SAME_WIDGET, 0),
ClipboardListView.LOCAL_DRAG_TARGET]
else:
targets = [ClipboardListView.LOCAL_DRAG_TARGET]
@ -1126,8 +1127,8 @@ class ClipboardListView(object):
o = model.get_value(node,1)
targets += [target.target() for target in o.__class__.DROP_TARGETS]
self._widget.enable_model_drag_source(BUTTON1_MASK, targets,
ACTION_COPY | ACTION_MOVE)
self._widget.enable_model_drag_source(Gdk.ModifierType.BUTTON1_MASK, targets,
Gdk.DragAction.COPY | Gdk.DragAction.MOVE)
def object_drag_begin(self, context, a):
""" Handle the beginning of a drag operation. """
@ -1222,14 +1223,14 @@ class ClipboardListView(object):
data = [o.__class__.DRAG_TARGET.drag_type, o, None,
o._type, o._value, o._dbid, o._dbname]
contains = model_contains(model, data)
if context.action != ACTION_MOVE and contains:
if context.action != Gdk.DragAction.MOVE and contains:
continue
drop_info = widget.get_dest_row_at_pos(x, y)
if drop_info:
path, position = drop_info
node = model.get_iter(path)
if (position == gtk.TREE_VIEW_DROP_BEFORE
or position == gtk.TREE_VIEW_DROP_INTO_OR_BEFORE):
if (position == Gtk.TreeViewDropPosition.BEFORE
or position == Gtk.TreeViewDropPosition.INTO_OR_BEFORE):
model.insert_before(node, data)
else:
model.insert_after(node, data)
@ -1239,7 +1240,7 @@ class ClipboardListView(object):
# FIXME: there is one bug here: if you multi-select and drop
# on self, then it moves the first, and copies the rest.
if context.action == ACTION_MOVE:
if context.action == Gdk.DragAction.MOVE:
context.finish(True, True, time)
# remember time for double drop workaround.
@ -1251,7 +1252,7 @@ class ClipboardListView(object):
def set_model(self,model=None):
self._widget.set_model(model)
self._widget.get_selection().connect('changed',self.on_object_select_row)
self._widget.get_selection().set_mode(gtk.SELECTION_MULTIPLE)
self._widget.get_selection().set_mode(Gtk.SelectionMode.MULTIPLE)
def get_model(self):
return self._widget.get_model()
@ -1318,7 +1319,7 @@ class ClipboardWindow(ManagedWindow):
self.object_list = ClipboardListView(self.dbstate, mtv)
self.object_list.get_selection().connect('changed',
self.set_clear_btn_sensitivity)
self.object_list.get_selection().set_mode(gtk.SELECTION_MULTIPLE)
self.object_list.get_selection().set_mode(Gtk.SelectionMode.MULTIPLE)
self.set_clear_btn_sensitivity(sel=self.object_list.get_selection())
if not ClipboardWindow.otree:
@ -1343,7 +1344,7 @@ class ClipboardWindow(ManagedWindow):
"on_help_clicked": self.on_help_clicked,
})
self.clear_all_btn.connect_object('clicked', gtk.ListStore.clear,
self.clear_all_btn.connect_object('clicked', Gtk.ListStore.clear,
ClipboardWindow.otree)
self.db.connect('database-changed', lambda x: ClipboardWindow.otree.clear())
@ -1387,7 +1388,7 @@ class ClipboardWindow(ManagedWindow):
# MultiTreeView class
#
#-------------------------------------------------------------------------
class MultiTreeView(gtk.TreeView):
class MultiTreeView(Gtk.TreeView):
'''
TreeView that captures mouse events to make drag and drop work properly
'''
@ -1402,8 +1403,8 @@ class MultiTreeView(gtk.TreeView):
self.defer_select = False
def key_press_event(self, widget, event):
if event.type == gtk.gdk.KEY_PRESS:
if event.keyval == gtk.keysyms.Delete:
if event.type == Gdk.KEY_PRESS:
if event.keyval == Gdk.KEY_Delete:
model, paths = self.get_selection().get_selected_rows()
# reverse, to delete from the end
paths.sort(key=lambda x:-x[0])
@ -1428,7 +1429,7 @@ class MultiTreeView(gtk.TreeView):
o = None
if node:
o = store.get_value(node, 1)
popup = gtk.Menu()
popup = Gtk.Menu()
# ---------------------------
if o:
objclass, handle = o._objclass, o._handle
@ -1436,13 +1437,13 @@ class MultiTreeView(gtk.TreeView):
objclass, handle = None, None
if objclass in ['Person', 'Event', 'Media', 'Source',
'Repository', 'Family', 'Note', 'Place']:
menu_item = gtk.MenuItem(_("the object|See %s details") % trans_objclass(objclass))
menu_item = Gtk.MenuItem(_("the object|See %s details") % trans_objclass(objclass))
menu_item.connect("activate",
lambda widget: self.edit_obj(objclass, handle))
popup.append(menu_item)
menu_item.show()
# ---------------------------
menu_item = gtk.MenuItem(_("the object|Make %s active") % trans_objclass(objclass))
menu_item = Gtk.MenuItem(_("the object|Make %s active") % trans_objclass(objclass))
menu_item.connect("activate",
lambda widget: self.uistate.set_active(handle, objclass))
popup.append(menu_item)
@ -1458,7 +1459,7 @@ class MultiTreeView(gtk.TreeView):
obj = self.dbstate.db.get_table_metadata(objclass)["handle_func"](my_handle)
if obj:
gids.add(obj.gramps_id)
menu_item = gtk.MenuItem(_("the object|Create Filter from %s selected...") % trans_objclass(objclass))
menu_item = Gtk.MenuItem(_("the object|Create Filter from %s selected...") % trans_objclass(objclass))
menu_item.connect("activate",
lambda widget: make_filter(self.dbstate, self.uistate,
objclass, gids, title=self.title))
@ -1467,7 +1468,7 @@ class MultiTreeView(gtk.TreeView):
# Show the popup menu:
popup.popup(None, None, None, 3, event.time)
return True
elif event.type == gtk.gdk._2BUTTON_PRESS and event.button == 1:
elif event.type == Gdk.EventType._2BUTTON_PRESS and event.button == 1:
model, paths = self.get_selection().get_selected_rows()
for path in paths:
node = model.get_iter(path)
@ -1479,8 +1480,8 @@ class MultiTreeView(gtk.TreeView):
return True
# otherwise:
if (target
and event.type == gtk.gdk.BUTTON_PRESS
and not (event.state & (gtk.gdk.CONTROL_MASK|gtk.gdk.SHIFT_MASK))
and event.type == Gdk.EventType.BUTTON_PRESS
and not (event.get_state() & (Gdk.ModifierType.CONTROL_MASK|Gdk.ModifierType.SHIFT_MASK))
and self.get_selection().path_is_selected(target[0])):
# disable selection
self.get_selection().set_select_function(lambda *ignore: False)

View File

@ -40,8 +40,8 @@ import logging
# GTK modules
#
#-------------------------------------------------------------------------
import gtk
import gobject
from gi.repository import Gtk
from gi.repository import GObject
#-------------------------------------------------------------------------
#
@ -60,7 +60,7 @@ from gui.glade import Glade
#-------------------------------------------------------------------------
__LOG = logging.getLogger(".ColumnOrder")
class ColumnOrder(gtk.VBox):
class ColumnOrder(Gtk.VBox):
"""
Column ordering selection widget
"""
@ -76,62 +76,62 @@ class ColumnOrder(gtk.VBox):
tree: are the columns for a treeview, if so, the first columns is not
changable
"""
gtk.VBox.__init__(self)
GObject.GObject.__init__(self)
self.treeview = tree
self.colnames = column_names
self.config = config
self.on_apply = on_apply
self.pack_start(gtk.Label(' '), expand=False, fill=False)
self.pack_start(Gtk.Label(' ', True, True, 0), expand=False, fill=False)
self.startrow = 0
if self.treeview:
label = gtk.Label(
label = Gtk.Label(label=
_('Tree View: first column "%s" cannot be changed') %
column_names[0])
self.startrow = 1
self.pack_start(label, expand=False, fill=False)
self.pack_start(gtk.Label(' '), expand=False, fill=False)
self.pack_start(Gtk.Label(' ', True, True, 0), expand=False, fill=False)
self.pack_start(gtk.Label(_('Drag and drop the columns to change'
' the order')), expand=False, fill=False)
self.pack_start(gtk.Label(' '), expand=False, fill=False)
hbox = gtk.HBox()
self.pack_start(Gtk.Label(_('Drag and drop the columns to change'
' the order', True, True, 0)), expand=False, fill=False)
self.pack_start(Gtk.Label(' ', True, True, 0), expand=False, fill=False)
hbox = Gtk.HBox()
hbox.set_spacing(10)
hbox.pack_start(gtk.Label(' '))
scroll = gtk.ScrolledWindow()
hbox.pack_start(Gtk.Label(' ', True, True, 0))
scroll = Gtk.ScrolledWindow()
scroll.set_size_request(300,300)
hbox.pack_start(scroll)
self.tree = gtk.TreeView()
hbox.pack_start(scroll, True, True, 0)
self.tree = Gtk.TreeView()
self.tree.set_reorderable(True)
scroll.add(self.tree)
self.apply_button = gtk.Button(stock='gtk-apply')
btns = gtk.HButtonBox()
btns.set_layout(gtk.BUTTONBOX_END)
btns.pack_start(self.apply_button)
hbox.pack_start(btns, expand=False)
self.pack_start(hbox)
self.apply_button = Gtk.Button(stock='gtk-apply')
btns = Gtk.HButtonBox()
btns.set_layout(Gtk.ButtonBoxStyle.END)
btns.pack_start(self.apply_button, True, True, 0)
hbox.pack_start(btns, False, True, 0)
self.pack_start(hbox, True, True, 0)
#Model holds:
# bool: column visible or not
# str : name of the column
# int : order of the column
# int : size (width) of the column
self.model = gtk.ListStore(gobject.TYPE_BOOLEAN, gobject.TYPE_STRING,
gobject.TYPE_INT, gobject.TYPE_INT)
self.model = Gtk.ListStore(GObject.TYPE_BOOLEAN, GObject.TYPE_STRING,
GObject.TYPE_INT, GObject.TYPE_INT)
self.tree.set_model(self.model)
checkbox = gtk.CellRendererToggle()
checkbox = Gtk.CellRendererToggle()
checkbox.connect('toggled', toggled, self.model)
renderer = gtk.CellRendererText()
renderer = Gtk.CellRendererText()
column_n = gtk.TreeViewColumn(_('Display'), checkbox, active=0)
column_n = Gtk.TreeViewColumn(_('Display'), checkbox, active=0)
column_n.set_min_width(50)
self.tree.append_column(column_n)
column_n = gtk.TreeViewColumn(_('Column Name'), renderer, text=1)
column_n = Gtk.TreeViewColumn(_('Column Name'), renderer, text=1)
column_n.set_min_width(225)
self.tree.append_column(column_n)

View File

@ -38,8 +38,8 @@ from xml.sax.saxutils import escape
# GTK/Gnome modules
#
#-------------------------------------------------------------------------
import gtk
import gobject
from gi.repository import Gtk
from gi.repository import GObject
#-------------------------------------------------------------------------
#
@ -92,12 +92,11 @@ class DisplayNameEditor(ManagedWindow):
self.dialog = dialog
self.dbstate = dbstate
self.set_window(
gtk.Dialog(_('Display Name Editor'),
flags=gtk.DIALOG_NO_SEPARATOR,
buttons=(gtk.STOCK_CLOSE, gtk.RESPONSE_CLOSE)),
Gtk.Dialog(_('Display Name Editor'),
buttons=(Gtk.STOCK_CLOSE, Gtk.ResponseType.CLOSE)),
None, _('Display Name Editor'), None)
table = self.dialog._build_custom_name_ui()
label = gtk.Label(_("""The following keywords are replaced with the appropriate name parts:
label = Gtk.Label(label=_("""The following keywords are replaced with the appropriate name parts:
<tt>
<b>Given</b> - given name (first name) <b>Surname</b> - surnames (with prefix and connectors)
<b>Title</b> - title (Dr., Mrs.) <b>Suffix</b> - suffix (Jr., Sr.)
@ -118,8 +117,8 @@ UPPERCASE keyword forces uppercase. Extra parentheses, commas are removed. Other
<i>Underhills</i> family nick name, <i>Jose</i> callname.
"""))
label.set_use_markup(True)
self.window.vbox.pack_start(label, expand=False)
self.window.vbox.pack_start(table)
self.window.vbox.pack_start(label, False, True, 0)
self.window.vbox.pack_start(table, True, True, 0)
self.window.set_default_size(600, 550)
self.window.connect('response', self.close)
self.show()
@ -152,7 +151,7 @@ class ConfigureDialog(ManagedWindow):
:param uistate: a DisplayState instance
:param dbstate: a DbState instance
:param configure_page_funcs: a list of function that return a tuple
(str, gtk.Widget). The string is used as label for the
(str, Gtk.Widget). The string is used as label for the
configuration page, and the widget as the content of the
configuration page
:param configobj: the unique object that is configured, it must be
@ -169,10 +168,10 @@ class ConfigureDialog(ManagedWindow):
self.__config = configmanager
ManagedWindow.__init__(self, uistate, [], configobj)
self.set_window(
gtk.Dialog(dialogtitle, flags=gtk.DIALOG_NO_SEPARATOR,
buttons=(gtk.STOCK_CLOSE, gtk.RESPONSE_CLOSE)),
Gtk.Dialog(dialogtitle, flags=Gtk.DialogFlags.NO_SEPARATOR,
buttons=(Gtk.STOCK_CLOSE, Gtk.ResponseType.CLOSE)),
None, dialogtitle, None)
self.panel = gtk.Notebook()
self.panel = Gtk.Notebook()
self.panel.set_scrollable(True)
self.window.vbox.add(self.panel)
self.__on_close = on_close
@ -261,7 +260,7 @@ class ConfigureDialog(ManagedWindow):
config=None, extra_callback=None):
if not config:
config = self.__config
checkbox = gtk.CheckButton(label)
checkbox = Gtk.CheckButton(label)
checkbox.set_active(config.get(constant))
checkbox.connect('toggled', self.update_checkbox, constant, config)
if extra_callback:
@ -272,7 +271,7 @@ class ConfigureDialog(ManagedWindow):
config=None):
if not config:
config = self.__config
radiobox = gtk.RadioButton(group,label)
radiobox = Gtk.RadioButton(group,label)
if config.get(constant) == True:
radiobox.set_active(True)
radiobox.connect('toggled', self.update_radiobox, constant)
@ -282,7 +281,7 @@ class ConfigureDialog(ManagedWindow):
def add_text(self, table, label, index, config=None):
if not config:
config = self.__config
text = gtk.Label()
text = Gtk.Label()
text.set_line_wrap(True)
text.set_alignment(0.,0.)
text.set_text(label)
@ -298,20 +297,20 @@ class ConfigureDialog(ManagedWindow):
if not config:
config = self.__config
lwidget = BasicLabel("%s: " %label)
hbox = gtk.HBox()
hbox = Gtk.HBox()
if path:
entry.set_text(path)
entry.connect('changed', callback_label)
btn = gtk.Button()
btn = Gtk.Button()
btn.connect('clicked', callback_sel)
image = gtk.Image()
image.set_from_stock(gtk.STOCK_OPEN, gtk.ICON_SIZE_BUTTON)
image = Gtk.Image()
image.set_from_stock(Gtk.STOCK_OPEN, Gtk.IconSize.BUTTON)
image.show()
btn.add(image)
hbox.pack_start(entry, expand=True, fill=True)
hbox.pack_start(btn, expand=False, fill=False)
table.attach(lwidget, 1, 2, index, index+1, yoptions=0,
xoptions=gtk.FILL)
xoptions=Gtk.AttachOptions.FILL)
table.attach(hbox, 2, 3, index, index+1, yoptions=0)
def add_entry(self, table, label, index, constant, callback=None,
@ -321,11 +320,11 @@ class ConfigureDialog(ManagedWindow):
if not callback:
callback = self.update_entry
lwidget = BasicLabel("%s: " % label)
entry = gtk.Entry()
entry = Gtk.Entry()
entry.set_text(config.get(constant))
entry.connect('changed', callback, constant)
table.attach(lwidget, 0, 1, index, index+1, yoptions=0,
xoptions=gtk.FILL)
xoptions=Gtk.AttachOptions.FILL)
table.attach(entry, 1, 2, index, index+1, yoptions=0)
def add_pos_int_entry(self, table, label, index, constant, callback=None,
@ -335,12 +334,12 @@ class ConfigureDialog(ManagedWindow):
if not config:
config = self.__config
lwidget = BasicLabel("%s: " % label)
entry = gtk.Entry()
entry = Gtk.Entry()
entry.set_text(str(config.get(constant)))
if callback:
entry.connect('changed', callback, constant)
table.attach(lwidget, col_attach, col_attach+1, index, index+1,
yoptions=0, xoptions=gtk.FILL)
yoptions=0, xoptions=Gtk.AttachOptions.FILL)
table.attach(entry, col_attach+1, col_attach+2, index, index+1,
yoptions=0)
@ -349,12 +348,12 @@ class ConfigureDialog(ManagedWindow):
config = self.__config
lwidget = BasicLabel("%s: " % label)
hexval = config.get(constant)
color = gtk.gdk.color_parse(hexval)
entry = gtk.ColorButton(color=color)
color = Gdk.color_parse(hexval)
entry = Gtk.ColorButton(color=color)
color_hex_label = BasicLabel(hexval)
entry.connect('color-set', self.update_color, constant, color_hex_label)
table.attach(lwidget, 0, 1, index, index+1, yoptions=0,
xoptions=gtk.FILL)
xoptions=Gtk.AttachOptions.FILL)
table.attach(entry, 1, 2, index, index+1, yoptions=0, xoptions=0)
table.attach(color_hex_label, 2, 3, index, index+1, yoptions=0)
return entry
@ -371,17 +370,17 @@ class ConfigureDialog(ManagedWindow):
if not callback:
callback = self.update_combo
lwidget = BasicLabel("%s: " % label)
store = gtk.ListStore(int, str)
store = Gtk.ListStore(int, str)
for item in opts:
store.append(item)
combo = gtk.ComboBox(store)
cell = gtk.CellRendererText()
combo = Gtk.ComboBox(store)
cell = Gtk.CellRendererText()
combo.pack_start(cell, True)
combo.add_attribute(cell, 'text', 1)
combo.set_active(config.get(constant))
combo.connect('changed', callback, constant)
table.attach(lwidget, 1, 2, index, index+1, yoptions=0,
xoptions=gtk.FILL)
xoptions=Gtk.AttachOptions.FILL)
table.attach(combo, 2, 3, index, index+1, yoptions=0)
return combo
@ -396,14 +395,14 @@ class ConfigureDialog(ManagedWindow):
if not callback:
callback = self.update_slider
lwidget = BasicLabel("%s: " % label)
adj = gtk.Adjustment(config.get(constant), range[0], range[1], 1, 0, 0)
slider = gtk.HScale(adj)
slider.set_update_policy(gtk.UPDATE_DISCONTINUOUS)
adj = Gtk.Adjustment(config.get(constant), range[0], range[1], 1, 0, 0)
slider = Gtk.HScale(adj)
slider.set_update_policy(Gtk.UPDATE_DISCONTINUOUS)
slider.set_digits(0)
slider.set_value_pos(gtk.POS_BOTTOM)
slider.set_value_pos(Gtk.PositionType.BOTTOM)
slider.connect('value-changed', callback, constant)
table.attach(lwidget, 1, 2, index, index+1, yoptions=0,
xoptions=gtk.FILL)
xoptions=Gtk.AttachOptions.FILL)
table.attach(slider, 2, 3, index, index+1, yoptions=0)
return slider
@ -418,11 +417,11 @@ class ConfigureDialog(ManagedWindow):
if not callback:
callback = self.update_spinner
lwidget = BasicLabel("%s: " % label)
adj = gtk.Adjustment(config.get(constant), range[0], range[1], 1, 0, 0)
spinner = gtk.SpinButton(adj)
adj = Gtk.Adjustment(config.get(constant), range[0], range[1], 1, 0, 0)
spinner = Gtk.SpinButton(adj)
spinner.connect('value-changed', callback, constant)
table.attach(lwidget, 1, 2, index, index+1, yoptions=0,
xoptions=gtk.FILL)
xoptions=Gtk.AttachOptions.FILL)
table.attach(spinner, 2, 3, index, index+1, yoptions=0)
return spinner
@ -449,7 +448,7 @@ class GrampsPreferences(ConfigureDialog):
on_close=update_constants)
def add_researcher_panel(self, configdialog):
table = gtk.Table(3, 8)
table = Gtk.Table(3, 8)
table.set_border_width(12)
table.set_col_spacings(6)
table.set_row_spacings(6)
@ -468,7 +467,7 @@ class GrampsPreferences(ConfigureDialog):
"""
Add the ID prefix tab to the preferences.
"""
table = gtk.Table(3, 8)
table = Gtk.Table(3, 8)
table.set_border_width(12)
table.set_col_spacings(6)
table.set_row_spacings(6)
@ -493,7 +492,7 @@ class GrampsPreferences(ConfigureDialog):
return _('ID Formats'), table
def add_advanced_panel(self, configdialog):
table = gtk.Table(4, 8)
table = Gtk.Table(4, 8)
table.set_border_width(12)
table.set_col_spacings(6)
table.set_row_spacings(6)
@ -520,10 +519,10 @@ class GrampsPreferences(ConfigureDialog):
"""
Create a common model for ComboBox and TreeView
"""
name_format_model = gtk.ListStore(gobject.TYPE_INT,
gobject.TYPE_STRING,
gobject.TYPE_STRING,
gobject.TYPE_STRING)
name_format_model = Gtk.ListStore(GObject.TYPE_INT,
GObject.TYPE_STRING,
GObject.TYPE_STRING,
GObject.TYPE_STRING)
index = 0
the_index = 0
for num, name, fmt_str, act in _nd.get_name_format():
@ -711,15 +710,15 @@ class GrampsPreferences(ConfigureDialog):
UI to manage the custom name formats
"""
table = gtk.Table(2, 3)
table = Gtk.Table(2, 3)
table.set_border_width(6)
table.set_col_spacings(6)
table.set_row_spacings(6)
# make a treeview for listing all the name formats
format_tree = gtk.TreeView(self.fmt_model)
name_renderer = gtk.CellRendererText()
name_column = gtk.TreeViewColumn(_('Format'),
format_tree = Gtk.TreeView(self.fmt_model)
name_renderer = Gtk.CellRendererText()
name_column = Gtk.TreeViewColumn(_('Format'),
name_renderer,
text=COL_NAME)
name_renderer.set_property('editable', False)
@ -728,8 +727,8 @@ class GrampsPreferences(ConfigureDialog):
name_renderer.connect('editing-canceled', self.__cancel_change)
self.name_renderer = name_renderer
format_tree.append_column(name_column)
example_renderer = gtk.CellRendererText()
example_column = gtk.TreeViewColumn(_('Example'),
example_renderer = Gtk.CellRendererText()
example_column = Gtk.TreeViewColumn(_('Example'),
example_renderer,
text=COL_EXPL)
format_tree.append_column(example_column)
@ -738,24 +737,24 @@ class GrampsPreferences(ConfigureDialog):
format_tree.set_rules_hint(True)
# ... and put it into a scrolled win
format_sw = gtk.ScrolledWindow()
format_sw.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
format_sw = Gtk.ScrolledWindow()
format_sw.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)
format_sw.add(format_tree)
format_sw.set_shadow_type(gtk.SHADOW_IN)
table.attach(format_sw, 0, 3, 0, 1, yoptions=gtk.FILL|gtk.EXPAND)
format_sw.set_shadow_type(Gtk.ShadowType.IN)
table.attach(format_sw, 0, 3, 0, 1, yoptions=Gtk.AttachOptions.FILL|Gtk.AttachOptions.EXPAND)
# to hold the values of the selected row of the tree and the iter
self.selected_fmt = ()
self.iter = None
self.insert_button = gtk.Button(stock=gtk.STOCK_ADD)
self.insert_button = Gtk.Button(stock=Gtk.STOCK_ADD)
self.insert_button.connect('clicked', self.__new_name)
self.edit_button = gtk.Button(stock=gtk.STOCK_EDIT)
self.edit_button = Gtk.Button(stock=Gtk.STOCK_EDIT)
self.edit_button.connect('clicked', self.__edit_name)
self.edit_button.set_sensitive(False)
self.remove_button = gtk.Button(stock=gtk.STOCK_REMOVE)
self.remove_button = Gtk.Button(stock=Gtk.STOCK_REMOVE)
self.remove_button.connect('clicked', self.cb_del_fmt_str)
self.remove_button.set_sensitive(False)
@ -830,7 +829,7 @@ class GrampsPreferences(ConfigureDialog):
def add_formats_panel(self, configdialog):
row = 0
table = gtk.Table(4, 4)
table = Gtk.Table(4, 4)
table.set_border_width(12)
table.set_col_spacings(6)
table.set_row_spacings(6)
@ -861,8 +860,8 @@ class GrampsPreferences(ConfigureDialog):
active = _nd.get_default_format()
self.fmt_model, active = self._build_name_format_model(active)
# set up the combo to choose the preset format
self.fmt_obox = gtk.ComboBox()
cell = gtk.CellRendererText()
self.fmt_obox = Gtk.ComboBox()
cell = Gtk.CellRendererText()
self.fmt_obox.pack_start(cell, True)
self.fmt_obox.add_attribute(cell, 'text', 1)
self.fmt_obox.set_model(self.fmt_model)
@ -873,8 +872,8 @@ class GrampsPreferences(ConfigureDialog):
lwidget = BasicLabel("%s: " % _('Name format'))
lwidget.set_use_underline(True)
lwidget.set_mnemonic_widget(self.fmt_obox)
hbox = gtk.HBox()
btn = gtk.Button("%s..." % _('Edit') )
hbox = Gtk.HBox()
btn = Gtk.Button("%s..." % _('Edit') )
btn.connect('clicked', self.cb_name_dialog)
hbox.pack_start(self.fmt_obox, expand=True, fill=True)
hbox.pack_start(btn, expand=False, fill=False)
@ -890,7 +889,7 @@ class GrampsPreferences(ConfigureDialog):
row += 1
# Date format:
obox = gtk.combo_box_new_text()
obox = Gtk.ComboBoxText()
formats = gen.datehandler.get_date_formats()
map(obox.append_text, formats)
active = config.get('preferences.date-format')
@ -905,7 +904,7 @@ class GrampsPreferences(ConfigureDialog):
# Age precision:
# precision=1 for "year", 2: "year, month" or 3: "year, month, days"
obox = gtk.combo_box_new_text()
obox = Gtk.ComboBoxText()
age_precision = [_("Years"),
_("Years, Months"),
_("Years, Months, Days")]
@ -926,7 +925,7 @@ class GrampsPreferences(ConfigureDialog):
row += 1
# Calendar format on report:
obox = gtk.combo_box_new_text()
obox = Gtk.ComboBoxText()
map(obox.append_text, gen.lib.Date.ui_calendar_names)
active = config.get('preferences.calendar-format-report')
if active >= len(formats):
@ -939,7 +938,7 @@ class GrampsPreferences(ConfigureDialog):
row += 1
# Surname guessing:
obox = gtk.combo_box_new_text()
obox = Gtk.ComboBoxText()
formats = _surname_styles
map(obox.append_text, formats)
obox.set_active(config.get('behavior.surname-guessing'))
@ -952,7 +951,7 @@ class GrampsPreferences(ConfigureDialog):
row += 1
# Default Family Relationship
obox = gtk.combo_box_new_text()
obox = Gtk.ComboBoxText()
formats = gen.lib.FamilyRelType().get_standard_names()
map(obox.append_text, formats)
obox.set_active(config.get('preferences.family-relation-type'))
@ -972,7 +971,7 @@ class GrampsPreferences(ConfigureDialog):
row += 1
# Status bar:
obox = gtk.combo_box_new_text()
obox = Gtk.ComboBoxText()
formats = [_("Active person's name and ID"),
_("Relationship to home person")]
map(obox.append_text, formats)
@ -997,7 +996,7 @@ class GrampsPreferences(ConfigureDialog):
def add_text_panel(self, configdialog):
row = 0
table = gtk.Table(6, 8)
table = Gtk.Table(6, 8)
table.set_border_width(12)
table.set_col_spacings(6)
table.set_row_spacings(6)
@ -1055,7 +1054,7 @@ class GrampsPreferences(ConfigureDialog):
config.set('preferences.calendar-format-report', obj.get_active())
def add_date_panel(self, configdialog):
table = gtk.Table(2, 7)
table = Gtk.Table(2, 7)
table.set_border_width(12)
table.set_col_spacings(6)
table.set_row_spacings(6)
@ -1088,7 +1087,7 @@ class GrampsPreferences(ConfigureDialog):
return _('Dates'), table
def add_behavior_panel(self, configdialog):
table = gtk.Table(3, 6)
table = Gtk.Table(3, 6)
table.set_border_width(12)
table.set_col_spacings(6)
table.set_row_spacings(6)
@ -1108,14 +1107,14 @@ class GrampsPreferences(ConfigureDialog):
self.add_spinner(table,
_('Max generations for relationships'),
4, 'behavior.generation-depth', (5, 50), self.update_gendepth)
self.path_entry = gtk.Entry()
self.path_entry = Gtk.Entry()
self.add_path_box(table,
_('Base path for relative media paths'),
5, self.path_entry, self.dbstate.db.get_mediapath(),
self.set_mediapath, self.select_mediapath)
# Check for updates:
obox = gtk.combo_box_new_text()
obox = Gtk.ComboBoxText()
formats = [_("Never"),
_("Once a month"),
_("Once a week"),
@ -1129,7 +1128,7 @@ class GrampsPreferences(ConfigureDialog):
table.attach(lwidget, 1, 2, 6, 7, yoptions=0)
table.attach(obox, 2, 3, 6, 7, yoptions=0)
self.whattype_box = gtk.combo_box_new_text()
self.whattype_box = Gtk.ComboBoxText()
formats = [_("Updated addons only"),
_("New addons only"),
_("New and updated addons"),]
@ -1146,13 +1145,13 @@ class GrampsPreferences(ConfigureDialog):
table.attach(lwidget, 1, 2, 7, 8, yoptions=0)
table.attach(self.whattype_box, 2, 3, 7, 8, yoptions=0)
checkbutton = gtk.CheckButton(
checkbutton = Gtk.CheckButton(
_("Do not ask about previously notified addons"))
checkbutton.set_active(config.get('behavior.do-not-show-previously-seen-updates'))
checkbutton.connect("toggled", self.toggle_hide_previous_addons)
table.attach(checkbutton, 0, 3, 8, 9, yoptions=0)
button = gtk.Button(_("Check now"))
button = Gtk.Button(_("Check now"))
button.connect("clicked", lambda obj: \
self.uistate.viewmanager.check_for_updates(force=True))
table.attach(button, 3, 4, 8, 9, yoptions=0)
@ -1160,7 +1159,7 @@ class GrampsPreferences(ConfigureDialog):
return _('General'), table
def add_famtree_panel(self, configdialog):
table = gtk.Table(2, 2)
table = Gtk.Table(2, 2)
table.set_border_width(12)
table.set_col_spacings(6)
table.set_row_spacings(6)
@ -1181,20 +1180,20 @@ class GrampsPreferences(ConfigureDialog):
self.dbstate.db.set_mediapath(None)
def select_mediapath(self, *obj):
f = gtk.FileChooserDialog(
f = Gtk.FileChooserDialog(
_("Select media directory"),
action=gtk.FILE_CHOOSER_ACTION_SELECT_FOLDER,
buttons=(gtk.STOCK_CANCEL,
gtk.RESPONSE_CANCEL,
gtk.STOCK_APPLY,
gtk.RESPONSE_OK))
action=Gtk.FileChooserAction.SELECT_FOLDER,
buttons=(Gtk.STOCK_CANCEL,
Gtk.ResponseType.CANCEL,
Gtk.STOCK_APPLY,
Gtk.ResponseType.OK))
mpath = self.dbstate.db.get_mediapath()
if not mpath:
mpath = const.HOME_DIR
f.set_current_folder(os.path.dirname(mpath))
status = f.run()
if status == gtk.RESPONSE_OK:
if status == Gtk.ResponseType.OK:
val = Utils.get_unicode_path_from_file_chooser(f.get_filename())
if val:
self.path_entry.set_text(val)
@ -1244,9 +1243,9 @@ class GrampsPreferences(ConfigureDialog):
# FIXME: is this needed?
def _set_button(self, stock):
button = gtk.Button()
image = gtk.Image()
image.set_from_stock(stock, gtk.ICON_SIZE_BUTTON)
button = Gtk.Button()
image = Gtk.Image()
image.set_from_stock(stock, Gtk.IconSize.BUTTON)
image.show()
button.add(image)
button.show()

View File

@ -46,8 +46,8 @@ _LOG = logging.getLogger(".")
# GTK+ modules
#
#-------------------------------------------------------------------------
import gtk
import gobject
from gi.repository import Gtk
from gi.repository import GObject
#-------------------------------------------------------------------------
#
@ -128,11 +128,11 @@ class DbLoader(CLIDbLoader):
pmgr = GuiPluginManager.get_instance()
import_dialog = gtk.FileChooserDialog(_('Gramps: Import database'),
import_dialog = Gtk.FileChooserDialog(_('Gramps: Import database'),
self.uistate.window,
gtk.FILE_CHOOSER_ACTION_OPEN,
(gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL,
'gramps-import', gtk.RESPONSE_OK))
Gtk.FileChooserAction.OPEN,
(Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL,
'gramps-import', Gtk.ResponseType.OK))
import_dialog.set_local_only(False)
# Always add automatic (match all files) filter
@ -140,7 +140,7 @@ class DbLoader(CLIDbLoader):
# Add more file type selections for available importers
for plugin in pmgr.get_import_plugins():
file_filter = gtk.FileFilter()
file_filter = Gtk.FileFilter()
name = "%s (.%s)" % (plugin.get_name(), plugin.get_extension())
file_filter.set_name(name)
file_filter.add_pattern("*.%s" % plugin.get_extension())
@ -159,9 +159,9 @@ class DbLoader(CLIDbLoader):
import_dialog.set_current_folder(default_dir)
while True:
response = import_dialog.run()
if response == gtk.RESPONSE_CANCEL:
if response == Gtk.ResponseType.CANCEL:
break
elif response == gtk.RESPONSE_OK:
elif response == Gtk.ResponseType.OK:
filename = Utils.get_unicode_path_from_file_chooser(import_dialog.get_filename())
if self.check_errors(filename):
# displays errors if any
@ -362,7 +362,7 @@ def add_all_files_filter(chooser):
"""
Add an all-permitting filter to the file chooser dialog.
"""
mime_filter = gtk.FileFilter()
mime_filter = Gtk.FileFilter()
mime_filter.set_name(_('All files'))
mime_filter.add_pattern('*')
chooser.add_filter(mime_filter)
@ -372,15 +372,15 @@ def add_all_files_filter(chooser):
# Format selectors: explictly set the format of the file
#
#-------------------------------------------------------------------------
class GrampsFormatWidget(gtk.ComboBox):
class GrampsFormatWidget(Gtk.ComboBox):
def __init__(self):
gtk.ComboBox.__init__(self, model=None)
GObject.GObject.__init__(self, model=None)
def set(self, format_list):
self.store = gtk.ListStore(gobject.TYPE_STRING)
self.store = Gtk.ListStore(GObject.TYPE_STRING)
self.set_model(self.store)
cell = gtk.CellRendererText()
cell = Gtk.CellRendererText()
self.pack_start(cell, True)
self.add_attribute(cell, 'text', 0)
self.format_list = format_list
@ -412,8 +412,8 @@ def format_maker():
type_selector = GrampsFormatWidget()
type_selector.set(format_list)
box = gtk.HBox()
label = gtk.Label(_('Select file _type:'))
box = Gtk.HBox()
label = Gtk.Label(label=_('Select file _type:'))
label.set_use_underline(True)
label.set_mnemonic_widget(type_selector)
box.pack_start(label, expand=False, fill=False, padding=6)

View File

@ -37,8 +37,7 @@ import time
import copy
import subprocess
import urlparse
from gen.ggettext import gettext as _
from gui.user import User
#-------------------------------------------------------------------------
#
# set up logging
@ -61,15 +60,17 @@ else:
# GTK/Gnome modules
#
#-------------------------------------------------------------------------
import gtk
from gtk.gdk import ACTION_COPY
import pango
from gi.repository import Gdk
from gi.repository import Gtk
from gi.repository import Pango
#-------------------------------------------------------------------------
#
# gramps modules
#
#-------------------------------------------------------------------------
from gen.ggettext import gettext as _
from gui.user import User
from gui.dialog import ErrorDialog, QuestionDialog, QuestionDialog2
from gen.db import DbBsddb
from gui.pluginmanager import GuiPluginManager
@ -82,8 +83,8 @@ from gen.db.exceptions import DbException
from Utils import get_unicode_path_from_env_var
_RETURN = gtk.gdk.keyval_from_name("Return")
_KP_ENTER = gtk.gdk.keyval_from_name("KP_Enter")
_RETURN = Gdk.keyval_from_name("Return")
_KP_ENTER = Gdk.keyval_from_name("KP_Enter")
#-------------------------------------------------------------------------
@ -112,9 +113,9 @@ class DbManager(CLIDbManager):
"""
ICON_MAP = {
CLIDbManager.ICON_NONE : '',
CLIDbManager.ICON_RECOVERY : gtk.STOCK_DIALOG_ERROR,
CLIDbManager.ICON_RECOVERY : Gtk.STOCK_DIALOG_ERROR,
CLIDbManager.ICON_LOCK : 'gramps-lock',
CLIDbManager.ICON_OPEN : gtk.STOCK_OPEN,
CLIDbManager.ICON_OPEN : Gtk.STOCK_OPEN,
}
ERROR = ErrorDialog
@ -152,7 +153,8 @@ class DbManager(CLIDbManager):
Connects the signals to the buttons on the interface.
"""
ddtargets = [ DdTargets.URI_LIST.target() ]
self.top.drag_dest_set(gtk.DEST_DEFAULT_ALL, ddtargets, ACTION_COPY)
self.top.drag_dest_set(Gtk.DestDefaults.ALL, ddtargets,
Gdk.DragAction.COPY)
self.remove.connect('clicked', self.__remove_db)
self.new.connect('clicked', self.__new_db)
@ -174,9 +176,9 @@ class DbManager(CLIDbManager):
treat a double click as if it was OK button press. However, we have
to make sure that an item was selected first.
"""
if event.type == gtk.gdk._2BUTTON_PRESS and event.button == 1:
if event.type == Gdk.EventType._2BUTTON_PRESS and event.button == 1:
if self.connect.get_property('sensitive'):
self.top.response(gtk.RESPONSE_OK)
self.top.response(Gtk.ResponseType.OK)
return True
return False
@ -187,7 +189,7 @@ class DbManager(CLIDbManager):
"""
if event.keyval in (_RETURN, _KP_ENTER):
if self.connect.get_property('sensitive'):
self.top.response(gtk.RESPONSE_OK)
self.top.response(Gtk.ResponseType.OK)
return True
return False
@ -222,10 +224,10 @@ class DbManager(CLIDbManager):
if path is None:
return
is_rev = len(path) > 1
is_rev = len(path.get_indices()) > 1
self.rcs.set_label(RCS_BUTTON[is_rev])
if store.get_value(node, STOCK_COL) == gtk.STOCK_OPEN:
if store.get_value(node, STOCK_COL) == Gtk.STOCK_OPEN:
self.connect.set_sensitive(False)
if _RCS_FOUND:
self.rcs.set_sensitive(True)
@ -236,7 +238,7 @@ class DbManager(CLIDbManager):
else:
self.rcs.set_sensitive(False)
if store.get_value(node, STOCK_COL) == gtk.STOCK_DIALOG_ERROR:
if store.get_value(node, STOCK_COL) == Gtk.STOCK_DIALOG_ERROR:
path = get_unicode_path_from_env_var(store.get_value(node, PATH_COL))
backup = os.path.join(path, "person.gbkp")
self.repair.set_sensitive(os.path.isfile(backup))
@ -264,12 +266,12 @@ class DbManager(CLIDbManager):
"""
# build the database name column
render = gtk.CellRendererText()
render.set_property('ellipsize', pango.ELLIPSIZE_END)
render = Gtk.CellRendererText()
render.set_property('ellipsize', Pango.EllipsizeMode.END)
render.connect('edited', self.__change_name)
render.connect('editing-canceled', self.__stop_edit)
render.connect('editing-started', self.__start_edit)
self.column = gtk.TreeViewColumn(_('Family tree name'), render,
self.column = Gtk.TreeViewColumn(_('Family tree name'), render,
text=NAME_COL)
self.column.set_sort_column_id(NAME_COL)
self.column.set_resizable(True)
@ -278,14 +280,14 @@ class DbManager(CLIDbManager):
self.name_renderer = render
# build the icon column
render = gtk.CellRendererPixbuf()
icon_column = gtk.TreeViewColumn(_('Status'), render,
render = Gtk.CellRendererPixbuf()
icon_column = Gtk.TreeViewColumn(_('Status'), render,
stock_id=STOCK_COL)
self.dblist.append_column(icon_column)
# build the last accessed column
render = gtk.CellRendererText()
column = gtk.TreeViewColumn(_('Last accessed'), render, text=DATE_COL)
render = Gtk.CellRendererText()
column = Gtk.TreeViewColumn(_('Last accessed'), render, text=DATE_COL)
column.set_sort_column_id(DSORT_COL)
self.dblist.append_column(column)
@ -303,7 +305,7 @@ class DbManager(CLIDbManager):
"""
Builds the display model.
"""
self.model = gtk.TreeStore(str, str, str, str, int, bool, str)
self.model = Gtk.TreeStore(str, str, str, str, int, bool, str)
#use current names to set up the model
for items in self.current_names:
@ -322,12 +324,12 @@ class DbManager(CLIDbManager):
iter = self.model.get_iter_first()
while (iter):
path = self.model.get_path(iter)
iter = self.model.iter_next(iter)
if path == skippath:
continue
itername = self.model.get_value(iter, NAME_COL)
if itername.strip() == name.strip():
return True
iter = self.model.iter_next(iter)
return False
def run(self):
@ -337,14 +339,14 @@ class DbManager(CLIDbManager):
"""
while True:
value = self.top.run()
if value == gtk.RESPONSE_OK:
if value == Gtk.ResponseType.OK:
store, node = self.selection.get_selected()
# don't open a locked file
if store.get_value(node, STOCK_COL) == 'gramps-lock':
self.__ask_to_break_lock(store, node)
continue
# don't open a version
if len(store.get_path(node)) > 1:
if len(store.get_path(node).get_indices()) > 1:
continue
if node:
self.top.destroy()
@ -415,12 +417,13 @@ class DbManager(CLIDbManager):
If the new string is empty, do nothing. Otherwise, renaming the
database is simply changing the contents of the name file.
"""
#path is a string, convert to TreePath first
path = Gtk.TreePath(path=path)
if len(new_text) > 0:
node = self.model.get_iter(path)
old_text = self.model.get_value(node, NAME_COL)
if not old_text.strip() == new_text.strip():
#If there is a ":" in path, then it as revision
if ":" in path :
if len(path.get_indices()) > 1 :
self.__rename_revision(path, new_text)
else:
self.__rename_database(path, new_text)
@ -482,7 +485,7 @@ class DbManager(CLIDbManager):
"""
store, node = self.selection.get_selected()
tree_path = store.get_path(node)
if len(tree_path) > 1:
if len(tree_path.get_indices()) > 1:
parent_node = store.get_iter((tree_path[0],))
parent_name = store.get_value(parent_node, NAME_COL)
name = store.get_value(node, NAME_COL)
@ -524,7 +527,7 @@ class DbManager(CLIDbManager):
path = store.get_path(node)
self.data_to_delete = store[path]
if len(path) == 1:
if len(path.get_indices()) == 1:
QuestionDialog(
_("Remove the '%s' family tree?") % self.data_to_delete[0],
_("Removing this family tree will permanently destroy the data."),
@ -687,9 +690,9 @@ class DbManager(CLIDbManager):
message
"""
self.msg.set_label(msg)
self.top.window.set_cursor(gtk.gdk.Cursor(gtk.gdk.WATCH))
while (gtk.events_pending()):
gtk.main_iteration()
self.top.window.set_cursor(Gdk.Cursor.new(Gdk.CursorType.WATCH))
while (Gtk.events_pending()):
Gtk.main_iteration()
def __end_cursor(self):
"""
@ -750,7 +753,7 @@ def drag_motion(wid, context, xpos, ypos, time_stamp):
"""
DND callback that is called on a DND drag motion begin
"""
context.drag_status(gtk.gdk.ACTION_COPY, time_stamp)
context.drag_status(Gdk.DragAction.COPY, time_stamp)
return True
def drop_cb(wid, context, xpos, ypos, time_stamp):

View File

@ -41,9 +41,9 @@
from gui.ddtargets import DdTargets
drag_dest_set(gtk.DEST_DEFAULT_ALL,
drag_dest_set(Gtk.DestDefaults.ALL,
DdTargets.all_targets(),
ACTION_COPY)
Gdk.DragAction.COPY)
"""
@ -55,6 +55,7 @@
import logging
log = logging.getLogger(".DdTargets")
from gi.repository import Gtk
class _DdType:
"""Represents the fields needed by a drag and drop target."""
@ -85,11 +86,9 @@ class _DdType:
"""
Return the full target information in the format required by the
Gtk functions.
"""
return (self.drag_type, self.target_flags, self.app_id)
return Gtk.TargetEntry.new(self.drag_type, self.target_flags,
self.app_id)
class _DdTargets(object):
"""A single class that manages all the drag and drop targets."""

View File

@ -32,8 +32,9 @@ import sys
# GNOME/GTK+ modules
#
#-------------------------------------------------------------------------
import gtk
from gtk.gdk import pixbuf_new_from_file
from gi.repository import GObject
from gi.repository import Gtk
from gi.repository import GdkPixbuf
#-------------------------------------------------------------------------
#
@ -46,7 +47,7 @@ from gui.glade import Glade
from gen.ggettext import gettext as _
try:
ICON = pixbuf_new_from_file(const.ICON)
ICON = GdkPixbuf.Pixbuf.new_from_file(const.ICON)
except:
ICON = None
@ -73,9 +74,9 @@ class SaveDialog(object):
self.top.set_transient_for(parent)
self.top.show()
response = self.top.run()
if response == gtk.RESPONSE_NO:
if response == Gtk.ResponseType.NO:
self.task1()
elif response == gtk.RESPONSE_YES:
elif response == Gtk.ResponseType.YES:
self.task2()
config.set('interface.dont-ask', self.dontask.get_active())
@ -104,7 +105,7 @@ class QuestionDialog(object):
self.top.show()
response = self.top.run()
self.top.destroy()
if response == gtk.RESPONSE_ACCEPT:
if response == Gtk.ResponseType.ACCEPT:
task()
class QuestionDialog2(object):
@ -135,7 +136,7 @@ class QuestionDialog2(object):
def run(self):
response = self.top.run()
self.top.destroy()
return (response == gtk.RESPONSE_ACCEPT)
return (response == Gtk.ResponseType.ACCEPT)
class OptionDialog(object):
def __init__(self, msg1, msg2, btnmsg1, task1, btnmsg2, task2, parent=None):
@ -159,7 +160,7 @@ class OptionDialog(object):
self.top.set_transient_for(parent)
self.top.show()
self.response = self.top.run()
if self.response == gtk.RESPONSE_NO:
if self.response == Gtk.ResponseType.NO:
if task1:
task1()
else:
@ -170,13 +171,13 @@ class OptionDialog(object):
def get_response(self):
return self.response
class ErrorDialog(gtk.MessageDialog):
class ErrorDialog(Gtk.MessageDialog):
def __init__(self, msg1, msg2="", parent=None):
gtk.MessageDialog.__init__(self, parent,
flags=gtk.DIALOG_MODAL,
type=gtk.MESSAGE_ERROR,
buttons=gtk.BUTTONS_CLOSE)
Gtk.MessageDialog.__init__(self, parent,
flags=Gtk.DialogFlags.MODAL,
type=Gtk.MessageType.ERROR,
buttons=Gtk.ButtonsType.CLOSE)
self.set_markup('<span weight="bold" size="larger">%s</span>' % msg1)
self.format_secondary_text(msg2)
self.set_icon(ICON)
@ -208,13 +209,13 @@ class DBErrorDialog(ErrorDialog):
"the Family Tree Manager. Select the database and "
'click on the Repair button') + '\n\n' + msg, parent)
class WarningDialog(gtk.MessageDialog):
class WarningDialog(Gtk.MessageDialog):
def __init__(self, msg1, msg2="", parent=None):
gtk.MessageDialog.__init__(self, parent,
flags=gtk.DIALOG_MODAL,
type=gtk.MESSAGE_WARNING,
buttons=gtk.BUTTONS_CLOSE)
Gtk.MessageDialog.__init__(self, parent,
flags=Gtk.DialogFlags.MODAL,
type=Gtk.MessageType.WARNING,
buttons=Gtk.ButtonsType.CLOSE)
self.set_markup('<span weight="bold" size="larger">%s</span>' % msg1)
self.format_secondary_markup(msg2)
self.set_icon(ICON)
@ -223,13 +224,13 @@ class WarningDialog(gtk.MessageDialog):
self.run()
self.destroy()
class OkDialog(gtk.MessageDialog):
class OkDialog(Gtk.MessageDialog):
def __init__(self, msg1, msg2="", parent=None):
gtk.MessageDialog.__init__(self, parent,
flags=gtk.DIALOG_MODAL,
type=gtk.MESSAGE_INFO,
buttons=gtk.BUTTONS_CLOSE)
Gtk.MessageDialog.__init__(self, parent,
flags=Gtk.DialogFlags.MODAL,
type=Gtk.MessageType.INFO,
buttons=Gtk.ButtonsType.CLOSE)
self.set_markup('<span weight="bold" size="larger">%s</span>' % msg1)
self.format_secondary_text(msg2)
self.set_icon(ICON)
@ -254,7 +255,7 @@ class InfoDialog(object):
label.set_use_markup(True)
infoview = self.xml.get_object('infoview')
infobuffer = gtk.TextBuffer()
infobuffer = Gtk.TextBuffer()
infobuffer.set_text(infotext)
if monospaced:
startiter, enditer = infobuffer.get_bounds()
@ -297,12 +298,12 @@ class MissingMediaDialog(object):
self.top.set_transient_for(parent)
self.top.show()
self.top.connect('delete_event', self.warn)
response = gtk.RESPONSE_DELETE_EVENT
response = Gtk.ResponseType.DELETE_EVENT
# Need some magic here, because an attempt to close the dialog
# with the X button not only emits the 'delete_event' signal
# but also exits with the RESPONSE_DELETE_EVENT
while response == gtk.RESPONSE_DELETE_EVENT:
while response == Gtk.ResponseType.DELETE_EVENT:
response = self.top.run()
if response == 1:

View File

@ -45,8 +45,9 @@ _LOG = logging.getLogger(".DisplayState")
# GNOME python modules
#
#-------------------------------------------------------------------------
import gtk
import gobject
from gi.repository import Gdk
from gi.repository import Gtk
from gi.repository import GObject
#-------------------------------------------------------------------------
#
@ -241,7 +242,7 @@ import os
class RecentDocsMenu(object):
def __init__(self, uistate, state, fileopen):
self.action_group = gtk.ActionGroup('RecentFiles')
self.action_group = Gtk.ActionGroup('RecentFiles')
self.active = DISABLED
self.uistate = uistate
self.uimanager = uistate.uimanager
@ -262,14 +263,14 @@ class RecentDocsMenu(object):
if self.active != DISABLED:
self.uimanager.remove_ui(self.active)
self.uimanager.remove_action_group(self.action_group)
self.action_group = gtk.ActionGroup('RecentFiles')
self.action_group = Gtk.ActionGroup('RecentFiles')
self.active = DISABLED
actions = []
rfiles = gramps_rf.gramps_recent_files
rfiles.sort(by_time)
new_menu = gtk.Menu()
new_menu = Gtk.Menu()
for item in rfiles:
try:
@ -279,7 +280,7 @@ class RecentDocsMenu(object):
buf.write('<menuitem action="%s"/>' % action_id)
actions.append((action_id, None, title, None, None,
make_callback(item, self.load)))
mitem = gtk.MenuItem(title)
mitem = Gtk.MenuItem(label=title)
mitem.connect('activate', make_callback(item, self.load))
mitem.show()
new_menu.append(mitem)
@ -320,7 +321,7 @@ class WarnHandler(RotateHandler):
def emit(self, record):
if self.timer is None:
#check every 3 minutes if warn button can disappear
self.timer = gobject.timeout_add(3*60*1000, self._check_clear)
self.timer = GObject.timeout_add(3*60*1000, self._check_clear)
RotateHandler.emit(self, record)
self.button.show()
@ -517,9 +518,10 @@ class DisplayState(gen.utils.Callback):
else:
self.busy = value
if value:
self.window.window.set_cursor(gtk.gdk.Cursor(gtk.gdk.WATCH))
self.window.get_root_window().set_cursor(Gdk.Cursor.new(
Gdk.CursorType.WATCH))
else:
self.window.window.set_cursor(None)
self.window.get_root_window().set_cursor(None)
process_pending_events()
def set_open_widget(self, widget):
@ -530,7 +532,7 @@ class DisplayState(gen.utils.Callback):
def push_message(self, dbstate, text):
self.status_text(text)
gobject.timeout_add(5000, self.modify_statusbar, dbstate)
GObject.timeout_add(5000, self.modify_statusbar, dbstate)
def show_filter_results(self, dbstate, matched, total):
#nav_type = self.viewmanager.active_page.navigation_type()

View File

@ -43,7 +43,7 @@ from gen.ggettext import gettext as _
# GTK/Gnome modules
#
#-------------------------------------------------------------------------
import gtk
from gi.repository import GdkPixbuf
#-------------------------------------------------------------------------
#
@ -224,14 +224,14 @@ def scale_image(path, size):
'This may be caused by a corrupt file.')
try:
image1 = gtk.gdk.pixbuf_new_from_file(path)
image1 = GdkPixbuf.Pixbuf.new_from_file(path)
width = image1.get_width()
height = image1.get_height()
scale = size / float(max(width, height))
return image1.scale_simple(int(scale*width), int(scale*height),
gtk.gdk.INTERP_BILINEAR)
GdkPixbuf.InterpType.BILINEAR)
except:
WarningDialog(title_msg, detail_msg)
return gtk.gdk.pixbuf_new_from_file(const.ICON)
return GdkPixbuf.Pixbuf.new_from_file(const.ICON)

View File

@ -30,7 +30,7 @@ Address List display tab.
#
#-------------------------------------------------------------------------
from gen.ggettext import gettext as _
import gobject
from gi.repository import GObject
#-------------------------------------------------------------------------
#
@ -122,7 +122,7 @@ class AddrEmbedList(EmbeddedList):
data = self.get_data()
data.append(name)
self.rebuild()
gobject.idle_add(self.tree.scroll_to_cell, len(data) - 1)
GObject.idle_add(self.tree.scroll_to_cell, len(data) - 1)
def edit_button_clicked(self, obj):
"""

View File

@ -29,7 +29,7 @@ The TreeModel for the Address list in the Address Tab.
# GTK libraries
#
#-------------------------------------------------------------------------
import gtk
from gi.repository import Gtk
#-------------------------------------------------------------------------
#
@ -43,7 +43,7 @@ import gen.datehandler
# AddressModel
#
#-------------------------------------------------------------------------
class AddressModel(gtk.ListStore):
class AddressModel(Gtk.ListStore):
"""
AddressModel derives from the ListStore, defining te items in the list
"""
@ -52,7 +52,7 @@ class AddressModel(gtk.ListStore):
"""
AddressModel derives from the ListStore, defining te items in the list
"""
gtk.ListStore.__init__(self, str, str, str, str, str, str, object)
GObject.GObject.__init__(self, str, str, str, str, str, str, object)
self.db = dbase
for obj in obj_list:
self.append(row=[

View File

@ -26,7 +26,7 @@
#
#-------------------------------------------------------------------------
from gen.ggettext import gettext as _
import gobject
from gi.repository import GObject
#-------------------------------------------------------------------------
#
@ -100,7 +100,7 @@ class AttrEmbedList(EmbeddedList):
data.append(name)
self.changed = True
self.rebuild()
gobject.idle_add(self.tree.scroll_to_cell, len(data)-1)
GObject.idle_add(self.tree.scroll_to_cell, len(data)-1)
def edit_button_clicked(self, obj):
attr = self.get_selected()

View File

@ -25,7 +25,7 @@
# GTK libraries
#
#-------------------------------------------------------------------------
import gtk
from gi.repository import Gtk
#-------------------------------------------------------------------------
#
@ -39,10 +39,10 @@ import gtk
# AttrModel
#
#-------------------------------------------------------------------------
class AttrModel(gtk.ListStore):
class AttrModel(Gtk.ListStore):
def __init__(self, attr_list, db):
gtk.ListStore.__init__(self, str, str, object)
GObject.GObject.__init__(self, str, str, object)
self.db = db
for attr in attr_list:
self.append(row=[

View File

@ -34,7 +34,7 @@ from gen.ggettext import gettext as _
# GTK libraries
#
#-------------------------------------------------------------------------
import gtk
from gi.repository import Gtk
#-------------------------------------------------------------------------
#
@ -96,14 +96,14 @@ class BackRefList(EmbeddedList):
This button box is then appended hbox (self).
Method has signature of, and overrides create_buttons from _ButtonTab.py
"""
self.edit_btn = SimpleButton(gtk.STOCK_EDIT, self.edit_button_clicked)
self.edit_btn = SimpleButton(Gtk.STOCK_EDIT, self.edit_button_clicked)
self.edit_btn.set_tooltip_text(_('Edit reference'))
hbox = gtk.HBox()
hbox = Gtk.HBox()
hbox.set_spacing(6)
hbox.pack_start(self.edit_btn, False)
hbox.pack_start(self.edit_btn, False, True, 0)
hbox.show_all()
self.pack_start(hbox, False)
self.pack_start(hbox, False, True, 0)
self.add_btn = None
self.del_btn = None

View File

@ -26,8 +26,8 @@
# GTK libraries
#
#-------------------------------------------------------------------------
import gobject
import gtk
from gi.repository import GObject
from gi.repository import Gtk
from gen.ggettext import gettext as _
@ -44,25 +44,25 @@ import Utils
# BackRefModel
#
#-------------------------------------------------------------------------
class BackRefModel(gtk.ListStore):
class BackRefModel(Gtk.ListStore):
dispstr = _('%(part1)s - %(part2)s')
def __init__(self, sref_list, db):
gtk.ListStore.__init__(self, str, str, str, str, str)
GObject.GObject.__init__(self, str, str, str, str, str)
self.db = db
self.sref_list = sref_list
self.count = 0
self.idle = gobject.idle_add(self.load_model().next)
self.idle = GObject.idle_add(self.load_model().next)
def destroy(self):
gobject.source_remove(self.idle)
GObject.source_remove(self.idle)
def load_model(self):
"""
Objects can have very large backreferences. To avoid blocking the
interface up to the moment that the model is created, this method is
called via gobject.idle_add.
called via GObject.idle_add.
WARNING: a consequence of above is that loading can still be happening
while the GUI using this model is no longer used. Disconnect any
methods before closing the GUI.

View File

@ -33,7 +33,8 @@ from gen.ggettext import gettext as _
# GTK libraries
#
#-------------------------------------------------------------------------
import gtk
from gi.repository import Gtk
from gi.repository import Gdk
#-------------------------------------------------------------------------
#
@ -44,13 +45,13 @@ from gui.widgets import SimpleButton
from grampstab import GrampsTab
from gen.errors import WindowActiveError
_KP_ENTER = gtk.gdk.keyval_from_name("KP_Enter")
_RETURN = gtk.gdk.keyval_from_name("Return")
_DEL = gtk.gdk.keyval_from_name("Delete")
_ADD = gtk.gdk.keyval_from_name("Insert")
_OPEN = gtk.gdk.keyval_from_name("o")
_LEFT = gtk.gdk.keyval_from_name("Left")
_RIGHT = gtk.gdk.keyval_from_name("Right")
_KP_ENTER = Gdk.keyval_from_name("KP_Enter")
_RETURN = Gdk.keyval_from_name("Return")
_DEL = Gdk.keyval_from_name("Delete")
_ADD = Gdk.keyval_from_name("Insert")
_OPEN = Gdk.keyval_from_name("o")
_LEFT = Gdk.keyval_from_name("Left")
_RIGHT = Gdk.keyval_from_name("Right")
#-------------------------------------------------------------------------
#
@ -118,13 +119,13 @@ class ButtonTab(GrampsTab):
Note: some ButtonTab subclasses override this method.
"""
if top_label:
self.top_label = gtk.Label(top_label)
self.top_label = Gtk.Label(label=top_label)
self.top_label.set_use_markup(True)
self.track_ref_for_deletion("top_label")
self.add_btn = SimpleButton(gtk.STOCK_ADD, self.add_button_clicked)
self.edit_btn = SimpleButton(gtk.STOCK_EDIT, self.edit_button_clicked)
self.del_btn = SimpleButton(gtk.STOCK_REMOVE, self.del_button_clicked)
self.add_btn = SimpleButton(Gtk.STOCK_ADD, self.add_button_clicked)
self.edit_btn = SimpleButton(Gtk.STOCK_EDIT, self.edit_button_clicked)
self.del_btn = SimpleButton(Gtk.STOCK_REMOVE, self.del_button_clicked)
self.track_ref_for_deletion("add_btn")
self.track_ref_for_deletion("edit_btn")
self.track_ref_for_deletion("del_btn")
@ -134,16 +135,16 @@ class ButtonTab(GrampsTab):
self.del_btn.set_tooltip_text(self._MSG['del'])
if share_button:
self.share_btn = SimpleButton(gtk.STOCK_INDEX, self.share_button_clicked)
self.share_btn = SimpleButton(Gtk.STOCK_INDEX, self.share_button_clicked)
self.share_btn.set_tooltip_text(self._MSG['share'])
self.track_ref_for_deletion("share_btn")
else:
self.share_btn = None
if move_buttons:
self.up_btn = SimpleButton(gtk.STOCK_GO_UP, self.up_button_clicked)
self.up_btn = SimpleButton(Gtk.STOCK_GO_UP, self.up_button_clicked)
self.up_btn.set_tooltip_text(self._MSG['up'])
self.down_btn = SimpleButton(gtk.STOCK_GO_DOWN,
self.down_btn = SimpleButton(Gtk.STOCK_GO_DOWN,
self.down_button_clicked)
self.down_btn.set_tooltip_text(self._MSG['down'])
self.track_ref_for_deletion("up_btn")
@ -153,29 +154,29 @@ class ButtonTab(GrampsTab):
self.down_btn = None
if jump_button:
self.jump_btn = SimpleButton(gtk.STOCK_JUMP_TO, self.jump_button_clicked)
self.jump_btn = SimpleButton(Gtk.STOCK_JUMP_TO, self.jump_button_clicked)
self.track_ref_for_deletion("jump_btn")
self.jump_btn.set_tooltip_text(self._MSG['jump'])
else:
self.jump_btn = None
hbox = gtk.HBox()
hbox = Gtk.HBox()
hbox.set_spacing(6)
if top_label:
hbox.pack_start(self.top_label, False)
hbox.pack_start(self.add_btn, False)
hbox.pack_start(self.top_label, False, True, 0)
hbox.pack_start(self.add_btn, False, True, 0)
if share_button:
hbox.pack_start(self.share_btn, False)
hbox.pack_start(self.edit_btn, False)
hbox.pack_start(self.del_btn, False)
hbox.pack_start(self.share_btn, False, True, 0)
hbox.pack_start(self.edit_btn, False, True, 0)
hbox.pack_start(self.del_btn, False, True, 0)
if move_buttons:
hbox.pack_start(self.up_btn, False)
hbox.pack_start(self.down_btn, False)
hbox.pack_start(self.up_btn, False, True, 0)
hbox.pack_start(self.down_btn, False, True, 0)
if self.jump_btn:
hbox.pack_start(self.jump_btn, False)
hbox.pack_start(self.jump_btn, False, True, 0)
hbox.show_all()
self.pack_start(hbox, False)
self.pack_start(hbox, False, True, 0)
if self.dbstate.db.readonly:
self.add_btn.set_sensitive(False)
@ -193,7 +194,7 @@ class ButtonTab(GrampsTab):
Handles the double click on list. If the double click occurs,
the Edit button handler is called
"""
if event.type == gtk.gdk._2BUTTON_PRESS and event.button == 1:
if event.type == Gdk.EventType._2BUTTON_PRESS and event.button == 1:
try:
self.edit_button_clicked(obj)
except WindowActiveError:
@ -204,8 +205,8 @@ class ButtonTab(GrampsTab):
Handles the return key being pressed on list. If the key is pressed,
the Edit button handler is called
"""
if event.type == gtk.gdk.KEY_PRESS:
#print 'key pressed', event.keyval, event.state, _ADD
if event.type == Gdk.KEY_PRESS:
#print 'key pressed', event.keyval, event.get_state(), _ADD
if event.keyval in (_RETURN, _KP_ENTER):
try:
self.edit_button_clicked(obj)
@ -220,13 +221,13 @@ class ButtonTab(GrampsTab):
return
self.add_button_clicked(obj)
elif event.keyval in (_OPEN,) and self.share_btn and \
(event.state & gtk.gdk.CONTROL_MASK):
(event.get_state() & Gdk.ModifierType.CONTROL_MASK):
self.share_button_clicked(obj)
elif event.keyval in (_LEFT,) and \
(event.state & gtk.gdk.MOD1_MASK):
(event.get_state() & Gdk.ModifierType.MOD1_MASK):
self.prev_page()
elif event.keyval in (_RIGHT,) and \
(event.state & gtk.gdk.MOD1_MASK):
(event.get_state() & Gdk.ModifierType.MOD1_MASK):
self.next_page()
else:
return

View File

@ -25,7 +25,7 @@
# GTK libraries
#
#-------------------------------------------------------------------------
import gtk
from gi.repository import Gtk
import cgi
#-------------------------------------------------------------------------
@ -44,10 +44,10 @@ from gen.utils import get_birth_or_fallback, get_death_or_fallback
# ChildModel
#
#-------------------------------------------------------------------------
class ChildModel(gtk.ListStore):
class ChildModel(Gtk.ListStore):
def __init__(self, child_ref_list, db):
gtk.ListStore.__init__(self, int, str, str, str, str, str,
GObject.GObject.__init__(self, int, str, str, str, str, str,
str, str, str, str, str, str, str, object)
self.db = db
for index, child_ref in enumerate(child_ref_list):

View File

@ -35,7 +35,7 @@ LOG = logging.getLogger(".citation")
# GTK/Gnome modules
#
#-------------------------------------------------------------------------
import gobject
from gi.repository import GObject
#-------------------------------------------------------------------------
#
@ -150,7 +150,7 @@ class CitationEmbedList(EmbeddedList, DbGUIElement):
self.callman.register_handles({'citation': [value]})
self.changed = True
self.rebuild()
gobject.idle_add(self.tree.scroll_to_cell, len(data) - 1)
GObject.idle_add(self.tree.scroll_to_cell, len(data) - 1)
def share_button_clicked(self, obj):
SelectCitation = SelectorFactory('Citation')

View File

@ -26,17 +26,17 @@
# GTK libraries
#
#-------------------------------------------------------------------------
import gtk
from gi.repository import Gtk
#-------------------------------------------------------------------------
#
# CitationModel
#
#-------------------------------------------------------------------------
class CitationRefModel(gtk.ListStore):
class CitationRefModel(Gtk.ListStore):
def __init__(self, citation_list, db):
gtk.ListStore.__init__(self, str, str, str, str, object)
GObject.GObject.__init__(self, str, str, str, str, object)
self.db = db
for handle in citation_list:
citation = self.db.get_citation_from_handle(handle)

View File

@ -25,7 +25,7 @@
# GTK libraries
#
#-------------------------------------------------------------------------
import gtk
from gi.repository import Gtk
#-------------------------------------------------------------------------
#
@ -39,10 +39,10 @@ import gtk
# DataModel
#
#-------------------------------------------------------------------------
class DataModel(gtk.ListStore):
class DataModel(Gtk.ListStore):
def __init__(self, attr_list, db):
gtk.ListStore.__init__(self, str, str)
GObject.GObject.__init__(self, str, str)
self.db = db
for key,value in attr_list.items():

View File

@ -34,9 +34,9 @@ import cPickle as pickle
# GTK libraries
#
#-------------------------------------------------------------------------
import gobject
import gtk
import pango
from gi.repository import GObject
from gi.repository import Gtk
from gi.repository import Pango
#-------------------------------------------------------------------------
#
@ -55,7 +55,7 @@ class EmbeddedList(ButtonTab):
"""
This class provides the base class for all the list tabs.
It maintains a gtk.TreeView, including the selection and button sensitivity.
It maintains a Gtk.TreeView, including the selection and button sensitivity.
"""
_HANDLE_COL = -1
@ -102,7 +102,7 @@ class EmbeddedList(ButtonTab):
ref = self.get_selected()
if ref:
self.right_click(obj, event)
elif event.type == gtk.gdk.BUTTON_PRESS and event.button == 2:
elif event.type == Gdk.EventType.BUTTON_PRESS and event.button == 2:
fun = self.get_middle_click()
if fun:
fun()
@ -120,16 +120,16 @@ class EmbeddedList(ButtonTab):
"""
if self.share_btn:
itemlist = [
(True, True, gtk.STOCK_ADD, self.add_button_clicked),
(True, True, Gtk.STOCK_ADD, self.add_button_clicked),
(True, False, _('Share'), self.share_button_clicked),
(False,True, gtk.STOCK_EDIT, self.edit_button_clicked),
(True, True, gtk.STOCK_REMOVE, self.del_button_clicked),
(False,True, Gtk.STOCK_EDIT, self.edit_button_clicked),
(True, True, Gtk.STOCK_REMOVE, self.del_button_clicked),
]
else:
itemlist = [
(True, True, gtk.STOCK_ADD, self.add_button_clicked),
(False,True, gtk.STOCK_EDIT, self.edit_button_clicked),
(True, True, gtk.STOCK_REMOVE, self.del_button_clicked),
(True, True, Gtk.STOCK_ADD, self.add_button_clicked),
(False,True, Gtk.STOCK_EDIT, self.edit_button_clicked),
(True, True, Gtk.STOCK_REMOVE, self.del_button_clicked),
]
return itemlist
@ -141,19 +141,19 @@ class EmbeddedList(ButtonTab):
On right click show a popup menu.
This is populated with get_popup_menu_items
"""
menu = gtk.Menu()
menu = Gtk.Menu()
for (needs_write_access, image, title, func) in self.get_popup_menu_items():
if image:
if isinstance(title, tuple):
img_stock, txt = title
item = gtk.ImageMenuItem(txt)
img = gtk.Image()
img.set_from_stock(img_stock, gtk.ICON_SIZE_MENU)
item = Gtk.ImageMenuItem(txt)
img = Gtk.Image()
img.set_from_stock(img_stock, Gtk.IconSize.MENU)
item.set_image(img)
else:
item = gtk.ImageMenuItem(stock_id=title)
item = Gtk.ImageMenuItem(stock_id=title)
else:
item = gtk.MenuItem(title)
item = Gtk.MenuItem(title)
item.connect('activate', func)
if needs_write_access and self.dbstate.db.readonly:
item.set_sensitive(False)
@ -180,10 +180,10 @@ class EmbeddedList(ButtonTab):
dnd_types = [ self._DND_TYPE.target() ]
self.tree.enable_model_drag_dest(dnd_types,
gtk.gdk.ACTION_COPY)
self.tree.enable_model_drag_source(gtk.gdk.BUTTON1_MASK,
Gdk.DragAction.COPY)
self.tree.enable_model_drag_source(Gdk.ModifierType.BUTTON1_MASK,
[self._DND_TYPE.target()],
gtk.gdk.ACTION_COPY)
Gdk.DragAction.COPY)
self.tree.connect('drag_data_get', self.drag_data_get)
if not self.dbstate.db.readonly:
self.tree.connect('drag_data_received', self.drag_data_received)
@ -258,8 +258,8 @@ class EmbeddedList(ButtonTab):
if row is None:
return len(self.get_data())
else:
if row[1] in (gtk.TREE_VIEW_DROP_BEFORE,
gtk.TREE_VIEW_DROP_INTO_OR_BEFORE):
if row[1] in (Gtk.TreeViewDropPosition.BEFORE,
Gtk.TreeViewDropPosition.INTO_OR_BEFORE):
return row[0][0]
else:
return row[0][0]+1
@ -294,9 +294,9 @@ class EmbeddedList(ButtonTab):
#select the row
path = '%d' % (row_from-1)
self.tree.get_selection().select_path(path)
# The height/location of gtk.treecells is calculated in an idle handler
# The height/location of Gtk.treecells is calculated in an idle handler
# so use idle_add to scroll cell into view.
gobject.idle_add(self.tree.scroll_to_cell, path)
GObject.idle_add(self.tree.scroll_to_cell, path)
def _move_down(self, row_from, obj, selmethod=None):
"""
@ -314,7 +314,7 @@ class EmbeddedList(ButtonTab):
#select the row
path = '%d' % (row_from+1)
self.tree.get_selection().select_path(path)
gobject.idle_add(self.tree.scroll_to_cell, path)
GObject.idle_add(self.tree.scroll_to_cell, path)
def get_icon_name(self):
"""
@ -323,7 +323,7 @@ class EmbeddedList(ButtonTab):
STOCK_JUSTIFY_FILL icon, which in the default GTK style
looks kind of like a list.
"""
return gtk.STOCK_JUSTIFY_FILL
return Gtk.STOCK_JUSTIFY_FILL
def del_button_clicked(self, obj):
ref = self.get_selected()
@ -349,14 +349,14 @@ class EmbeddedList(ButtonTab):
def build_interface(self):
"""
Builds the interface, instantiating a gtk.TreeView in a
gtk.ScrolledWindow.
Builds the interface, instantiating a Gtk.TreeView in a
Gtk.ScrolledWindow.
"""
# create the tree, turn on rule hinting and connect the
# button press to the double click function.
self.tree = gtk.TreeView()
self.tree = Gtk.TreeView()
self.tree.set_reorderable(True)
self.tree.set_rules_hint(True)
self.tree.connect('button_press_event', self.double_click)
@ -364,9 +364,9 @@ class EmbeddedList(ButtonTab):
self.track_ref_for_deletion("tree")
# create the scrolled window, and attach the treeview
scroll = gtk.ScrolledWindow()
scroll.set_shadow_type(gtk.SHADOW_IN)
scroll.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
scroll = Gtk.ScrolledWindow()
scroll.set_shadow_type(Gtk.ShadowType.IN)
scroll.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)
scroll.add(self.tree)
self.pack_end(scroll, True)
@ -434,12 +434,12 @@ class EmbeddedList(ButtonTab):
# assign it to the column name. The text value is extracted
# from the model column specified in pair[1]
name = self._column_names[pair[1]][0]
renderer = gtk.CellRendererText()
renderer.set_property('ellipsize', pango.ELLIPSIZE_END)
renderer = Gtk.CellRendererText()
renderer.set_property('ellipsize', Pango.EllipsizeMode.END)
if self._column_names[pair[1]][3] == 0:
column = gtk.TreeViewColumn(name, renderer, text=pair[1])
column = Gtk.TreeViewColumn(name, renderer, text=pair[1])
else:
column = gtk.TreeViewColumn(name, renderer, markup=pair[1])
column = Gtk.TreeViewColumn(name, renderer, markup=pair[1])
if not self._column_names[pair[1]][4] == -1:
#apply weight attribute
column.add_attribute(renderer, "weight",
@ -448,7 +448,7 @@ class EmbeddedList(ButtonTab):
# insert the colum into the tree
column.set_resizable(True)
column.set_clickable(True)
column.set_sizing(gtk.TREE_VIEW_COLUMN_FIXED)
column.set_sizing(Gtk.TreeViewColumnSizing.FIXED)
#column.set_min_width(self._column_names[pair[1]][2])
column.set_fixed_width(self._column_names[pair[1]][2])
@ -496,8 +496,8 @@ class EmbeddedList(ButtonTab):
#model and tree are reset, allow _selection_changed again, and force it
self.dirty_selection = False
self._selection_changed()
if self.tree.flags() & gtk.REALIZED:
gobject.idle_add(self.tree.scroll_to_point, offset.x, offset.y)
if self.tree.get_realized():
GObject.idle_add(self.tree.scroll_to_point, offset.x, offset.y)
self.post_rebuild(selectedpath)
def post_rebuild(self, prebuildpath):

View File

@ -27,8 +27,8 @@
#
#-------------------------------------------------------------------------
from gen.ggettext import gettext as _
import gtk
import gobject
from gi.repository import Gtk
from gi.repository import GObject
#-------------------------------------------------------------------------
#
@ -284,7 +284,7 @@ class EventEmbedList(DbGUIElement, GroupEmbeddedList):
self.callman.register_handles({'event': [primary.handle]})
self.changed = True
self.rebuild()
gobject.idle_add(self.tree.scroll_to_cell,
GObject.idle_add(self.tree.scroll_to_cell,
(self._WORKGROUP, len(data) - 1))
def object_edited(self, ref, event):
@ -302,8 +302,8 @@ class EventEmbedList(DbGUIElement, GroupEmbeddedList):
return GroupEmbeddedList.get_popup_menu_items(self)
else:
return [
(True, True, gtk.STOCK_ADD, self.add_button_clicked),
(False,True, gtk.STOCK_EDIT, self.edit_button_clicked),
(True, True, Gtk.STOCK_ADD, self.add_button_clicked),
(False,True, Gtk.STOCK_EDIT, self.edit_button_clicked),
]
def _non_native_change(self):

View File

@ -33,8 +33,11 @@ from gen.ggettext import gettext as _
# GTK libraries
#
#-------------------------------------------------------------------------
import gtk
from pango import WEIGHT_NORMAL, WEIGHT_BOLD
from gi.repository import Gtk
from gi.repository import Pango
WEIGHT_NORMAL = Pango.Weight.NORMAL
WEIGHT_BOLD = Pango.Weight.BOLD
import cgi
#-------------------------------------------------------------------------
@ -42,6 +45,7 @@ import cgi
# GRAMPS classes
#
#-------------------------------------------------------------------------
from gui.widgets.undoablebuffer import UndoableBuffer
import gen.datehandler
from gen.config import config
@ -58,7 +62,7 @@ age_precision = config.get('preferences.age-display-precision')
# EventRefModel
#
#-------------------------------------------------------------------------
class EventRefModel(gtk.TreeStore):
class EventRefModel(Gtk.TreeStore):
#index of the working group
_ROOTINDEX = 0
_GROUPSTRING = _('%(groupname)s - %(groupnumber)d')
@ -90,7 +94,7 @@ class EventRefModel(gtk.TreeStore):
"""
self.start_date = kwargs.get("start_date", None)
typeobjs = (x[1] for x in self.COLS)
gtk.TreeStore.__init__(self, *typeobjs)
GObject.GObject.__init__(self, *typeobjs)
self.db = db
self.groups = groups
for index, group in enumerate(event_list):

View File

@ -35,12 +35,12 @@ import urlparse
# GTK libraries
#
#-------------------------------------------------------------------------
import gtk
import pango
from gi.repository import Gtk
from gi.repository import Pango
import os
import sys
import urllib
import gobject
from gi.repository import GObject
#-------------------------------------------------------------------------
#
@ -79,7 +79,7 @@ class GalleryTab(ButtonTab, DbGUIElement):
_DND_EXTRA = DdTargets.URI_LIST
def __init__(self, dbstate, uistate, track, media_list, update=None):
self.iconlist = gtk.IconView()
self.iconlist = Gtk.IconView()
ButtonTab.__init__(self, dbstate, uistate, track, _('_Gallery'), True)
DbGUIElement.__init__(self, dbstate.db)
self.track_ref_for_deletion("iconlist")
@ -109,7 +109,7 @@ class GalleryTab(ButtonTab, DbGUIElement):
Handle the button press event: double click or right click on iconlist.
If the double click occurs, the Edit button handler is called.
"""
if event.type == gtk.gdk._2BUTTON_PRESS and event.button == 1:
if event.type == Gdk.EventType._2BUTTON_PRESS and event.button == 1:
self.edit_button_clicked(obj)
return True
elif gui.utils.is_right_click(event):
@ -122,38 +122,38 @@ class GalleryTab(ButtonTab, DbGUIElement):
def right_click(self, obj, event):
itemlist = [
(True, True, gtk.STOCK_ADD, self.add_button_clicked),
(True, True, Gtk.STOCK_ADD, self.add_button_clicked),
(True, False, _('Share'), self.share_button_clicked),
(False,True, gtk.STOCK_EDIT, self.edit_button_clicked),
(True, True, gtk.STOCK_REMOVE, self.del_button_clicked),
(False,True, Gtk.STOCK_EDIT, self.edit_button_clicked),
(True, True, Gtk.STOCK_REMOVE, self.del_button_clicked),
]
menu = gtk.Menu()
menu = Gtk.Menu()
ref_obj = self.dbstate.db.get_object_from_handle(obj.ref)
media_path = Utils.media_path_full(self.dbstate.db, ref_obj.get_path())
if media_path:
item = gtk.ImageMenuItem(_('View'))
img = gtk.Image()
img.set_from_stock("gramps-viewmedia", gtk.ICON_SIZE_MENU)
item = Gtk.ImageMenuItem(_('View'))
img = Gtk.Image()
img.set_from_stock("gramps-viewmedia", Gtk.IconSize.MENU)
item.set_image(img)
item.connect('activate', make_launcher(media_path))
item.show()
menu.append(item)
mfolder, mfile = os.path.split(media_path)
item = gtk.MenuItem(_('Open Containing _Folder'))
item = Gtk.MenuItem(_('Open Containing _Folder'))
item.connect('activate', make_launcher(mfolder))
item.show()
menu.append(item)
item = gtk.SeparatorMenuItem()
item = Gtk.SeparatorMenuItem()
item.show()
menu.append(item)
for (needs_write_access, image, title, func) in itemlist:
if image:
item = gtk.ImageMenuItem(stock_id=title)
item = Gtk.ImageMenuItem(stock_id=title)
else:
item = gtk.MenuItem(title)
item = Gtk.MenuItem(title)
item.connect('activate', func)
if needs_write_access and self.dbstate.db.readonly:
item.set_sensitive(False)
@ -168,7 +168,7 @@ class GalleryTab(ButtonTab, DbGUIElement):
return len(self.media_list)==0
def _build_icon_model(self):
self.iconmodel = gtk.ListStore(gtk.gdk.Pixbuf, gobject.TYPE_STRING,
self.iconmodel = Gtk.ListStore(GdkPixbuf.Pixbuf, GObject.TYPE_STRING,
object)
self.track_ref_for_deletion("iconmodel")
@ -193,10 +193,10 @@ class GalleryTab(ButtonTab, DbGUIElement):
self.iconlist.set_pixbuf_column(0)
self.iconlist.set_item_width(int(const.THUMBSCALE) + padding * 2)
# set custom text cell renderer for better control
text_renderer = gtk.CellRendererText()
text_renderer.set_property('wrap-mode', pango.WRAP_WORD_CHAR)
text_renderer = Gtk.CellRendererText()
text_renderer.set_property('wrap-mode', Pango.WrapMode.WORD_CHAR)
text_renderer.set_property('wrap-width', const.THUMBSCALE)
text_renderer.set_property('alignment', pango.ALIGN_CENTER)
text_renderer.set_property('alignment', Pango.Alignment.CENTER)
self.iconlist.pack_end(text_renderer)
self.iconlist.set_attributes(text_renderer, text=1)
@ -204,7 +204,7 @@ class GalleryTab(ButtonTab, DbGUIElement):
self.iconlist.set_margin(padding)
self.iconlist.set_column_spacing(padding)
self.iconlist.set_reorderable(True)
self.iconlist.set_selection_mode(gtk.SELECTION_SINGLE)
self.iconlist.set_selection_mode(Gtk.SelectionMode.SINGLE)
# connect the signals
self.iconlist.connect('selection-changed', self._selection_changed)
@ -213,8 +213,8 @@ class GalleryTab(ButtonTab, DbGUIElement):
self._connect_icon_model()
# create the scrolled window
scroll = gtk.ScrolledWindow()
scroll.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
scroll = Gtk.ScrolledWindow()
scroll.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)
# put everything together
scroll.add(self.iconlist)
@ -289,7 +289,7 @@ class GalleryTab(ButtonTab, DbGUIElement):
itr_last = model.iter_nth_child(None, len(data) - 1)
if itr_last:
path = model.get_path(itr_last)
gobject.idle_add(self.iconlist.scroll_to_path, path, False,
GObject.idle_add(self.iconlist.scroll_to_path, path, False,
0.0, 0.0)
def __blocked_text(self):
@ -398,10 +398,10 @@ class GalleryTab(ButtonTab, DbGUIElement):
DdTargets.MEDIAOBJ.target()]
self.iconlist.enable_model_drag_dest(dnd_types,
gtk.gdk.ACTION_MOVE|gtk.gdk.ACTION_COPY)
self.iconlist.enable_model_drag_source(gtk.gdk.BUTTON1_MASK,
Gdk.DragAction.MOVE|Gdk.DragAction.COPY)
self.iconlist.enable_model_drag_source(Gdk.ModifierType.BUTTON1_MASK,
[self._DND_TYPE.target()],
gtk.gdk.ACTION_COPY)
Gdk.DragAction.COPY)
self.iconlist.connect('drag_data_get', self.drag_data_get)
if not self.dbstate.db.readonly:
self.iconlist.connect('drag_data_received', self.drag_data_received)
@ -460,11 +460,11 @@ class GalleryTab(ButtonTab, DbGUIElement):
(path, pos) = data
row = path[0]
if pos == gtk.ICON_VIEW_DROP_LEFT:
if pos == Gtk.ICON_VIEW_DROP_LEFT:
row = max(row, 0)
elif pos == gtk.ICON_VIEW_DROP_RIGHT:
elif pos == Gtk.ICON_VIEW_DROP_RIGHT:
row = min(row, len(self.get_data()))
elif pos == gtk.ICON_VIEW_DROP_INTO:
elif pos == Gtk.ICON_VIEW_DROP_INTO:
row = min(row+1, len(self.get_data()))
else:
row = len(self.get_data())

View File

@ -26,10 +26,12 @@
# GTK libraries
#
#-------------------------------------------------------------------------
import gtk
from gi.repository import GObject
from gi.repository import Gdk
from gi.repository import Gtk
_LEFT = gtk.gdk.keyval_from_name("Left")
_RIGHT = gtk.gdk.keyval_from_name("Right")
_LEFT = Gdk.keyval_from_name("Left")
_RIGHT = Gdk.keyval_from_name("Right")
#-------------------------------------------------------------------------
#
@ -37,13 +39,13 @@ _RIGHT = gtk.gdk.keyval_from_name("Right")
#
#-------------------------------------------------------------------------
class GrampsTab(gtk.VBox):
class GrampsTab(Gtk.VBox):
"""
This class provides the base level class for 'tabs', which are used to
fill in notebook tabs for GRAMPS edit dialogs.
Each tab returns a gtk container widget which can be inserted into a
gtk.Notebook by the instantiating object.
Gtk.Notebook by the instantiating object.
All tab classes should inherit from GrampsTab
"""
@ -64,7 +66,7 @@ class GrampsTab(gtk.VBox):
@param name: Notebook label name
@type name: str/unicode
"""
gtk.VBox.__init__(self)
GObject.GObject.__init__(self)
# store information to pass to child windows
self.dbstate = dbstate
@ -102,26 +104,26 @@ class GrampsTab(gtk.VBox):
by the derived class. Creates an container that has the label and
the icon in it.
@returns: widget to be used for the notebook label.
@rtype: gtk.HBox
@rtype: Gtk.HBox
"""
hbox = gtk.HBox()
hbox = Gtk.HBox()
icon = self.get_icon_name()
if isinstance(icon, tuple):
if icon[0] == 0:
func = gtk.image_new_from_icon_name
func = Gtk.Image.new_from_icon_name
else:
func = gtk.image_new_from_stock
func = Gtk.Image.new_from_stock
name = icon[1]
else:
func = gtk.image_new_from_stock
func = Gtk.Image.new_from_stock
name = icon
self.tab_image = func(name, gtk.ICON_SIZE_MENU)
self.tab_image = func(name, Gtk.IconSize.MENU)
self.track_ref_for_deletion("tab_image")
self.label = gtk.Label(self.tab_name)
self.label = Gtk.Label(label=self.tab_name)
self.track_ref_for_deletion("label")
hbox.pack_start(self.tab_image)
hbox.pack_start(self.tab_image, True, True, 0)
hbox.set_spacing(6)
hbox.add(self.label)
hbox.show_all()
@ -135,7 +137,7 @@ class GrampsTab(gtk.VBox):
@returns: stock icon name
@rtype: str
"""
return gtk.STOCK_NEW
return Gtk.STOCK_NEW
def get_tab_widget(self):
"""
@ -143,7 +145,7 @@ class GrampsTab(gtk.VBox):
container class is provided, and the object may manipulate the
child widgets contained in the container.
@returns: gtk widget
@rtype: gtk.HBox
@rtype: Gtk.HBox
"""
return self.label_container
@ -153,12 +155,12 @@ class GrampsTab(gtk.VBox):
The inheriting object must contain a widget that connects at mimimum
to this method, eg an eventbox, tree, ...
"""
if event.type == gtk.gdk.KEY_PRESS:
if event.type == Gdk.KEY_PRESS:
if event.keyval in (_LEFT,) and \
(event.state & gtk.gdk.MOD1_MASK):
(event.get_state() & Gdk.ModifierType.MOD1_MASK):
self.prev_page()
elif event.keyval in (_RIGHT,) and \
(event.state & gtk.gdk.MOD1_MASK):
(event.get_state() & Gdk.ModifierType.MOD1_MASK):
self.next_page()
else:
return
@ -187,7 +189,7 @@ class GrampsTab(gtk.VBox):
"""
Builds the interface for the derived class. This function should be
overridden in the derived class. Since the classes are derived from
gtk.HBox, the self.pack_start, self.pack_end, and self.add functions
Gtk.HBox, the self.pack_start, self.pack_end, and self.add functions
can be used to add widgets to the interface.
"""
pass

View File

@ -33,9 +33,9 @@ import cPickle as pickle
# GTK libraries
#
#-------------------------------------------------------------------------
import gtk
import pango
import gobject
from gi.repository import Gtk
from gi.repository import Pango
from gi.repository import GObject
#-------------------------------------------------------------------------
#
# GRAMPS classes
@ -54,7 +54,7 @@ class GroupEmbeddedList(EmbeddedList):
This class provides the base class for all the list tabs that show
grouped data.
It maintains a gtk.TreeView, including the selection and button sensitivity.
It maintains a Gtk.TreeView, including the selection and button sensitivity.
"""
_WORKGROUP = 0
@ -92,7 +92,7 @@ class GroupEmbeddedList(EmbeddedList):
"""
The group column is clicked, sort it as it was
"""
self.columns[0].set_sort_order(gtk.SORT_ASCENDING)
self.columns[0].set_sort_order(Gtk.SortType.ASCENDING)
self.rebuild()
self.dbsort = True
@ -108,7 +108,7 @@ class GroupEmbeddedList(EmbeddedList):
if obj and obj[1]:
self._tmpgroup = obj[0]
self.right_click(obj[1], event)
elif event.type == gtk.gdk.BUTTON_PRESS and event.button == 2:
elif event.type == Gdk.EventType.BUTTON_PRESS and event.button == 2:
fun = self.get_middle_click()
if fun:
fun()
@ -216,7 +216,7 @@ class GroupEmbeddedList(EmbeddedList):
wgroup = dest[0][0]
if len(dest[0]) == 1:
# On a heading
if dest[1] == gtk.TREE_VIEW_DROP_BEFORE:
if dest[1] == Gtk.TreeViewDropPosition.BEFORE:
if wgroup != 0:
# If before then put at end of previous group
return (wgroup-1, len(self.get_data()[wgroup-1]))
@ -226,8 +226,8 @@ class GroupEmbeddedList(EmbeddedList):
else:
return (wgroup, 0)
else:
if dest[1] in (gtk.TREE_VIEW_DROP_BEFORE,
gtk.TREE_VIEW_DROP_INTO_OR_BEFORE):
if dest[1] in (Gtk.TreeViewDropPosition.BEFORE,
Gtk.TreeViewDropPosition.INTO_OR_BEFORE):
return (wgroup, dest[0][1])
else:
return (wgroup, dest[0][1]+1)
@ -297,7 +297,7 @@ class GroupEmbeddedList(EmbeddedList):
#select the row
path = (self._WORKGROUP, row_from[1]-1)
self.tree.get_selection().select_path(path)
gobject.idle_add(self.tree.scroll_to_cell, path)
GObject.idle_add(self.tree.scroll_to_cell, path)
else:
self._move_up_notwork(row_from, obj, selmethod)
@ -330,7 +330,7 @@ class GroupEmbeddedList(EmbeddedList):
#select the row
path = (self._WORKGROUP, row_from[1]+1)
self.tree.get_selection().select_path(path)
gobject.idle_add(self.tree.scroll_to_cell, path)
GObject.idle_add(self.tree.scroll_to_cell, path)
else:
self._move_down_notwork(row_from, obj, selmethod)
@ -353,7 +353,7 @@ class GroupEmbeddedList(EmbeddedList):
STOCK_JUSTIFY_FILL icon, which in the default GTK style
looks kind of like a list.
"""
return gtk.STOCK_JUSTIFY_FILL
return Gtk.STOCK_JUSTIFY_FILL
def del_button_clicked(self, obj):
ref = self.get_selected()

View File

@ -26,7 +26,7 @@
#
#-------------------------------------------------------------------------
from gen.ggettext import gettext as _
import gobject
from gi.repository import GObject
#-------------------------------------------------------------------------
#
@ -95,7 +95,7 @@ class LdsEmbedList(EmbeddedList):
data = self.get_data()
data.append(name)
self.rebuild()
gobject.idle_add(self.tree.scroll_to_cell, len(data) - 1)
GObject.idle_add(self.tree.scroll_to_cell, len(data) - 1)
def edit_button_clicked(self, obj):
lds = self.get_selected()

View File

@ -31,7 +31,7 @@
# GTK libraries
#
#-------------------------------------------------------------------------
import gtk
from gi.repository import Gtk
#-------------------------------------------------------------------------
#
@ -46,12 +46,12 @@ import LdsUtils
# LdsModel
#
#-------------------------------------------------------------------------
class LdsModel(gtk.ListStore):
class LdsModel(Gtk.ListStore):
_HANDLE_COL = 5
def __init__(self, lds_list, db):
gtk.ListStore.__init__(self, str, str, str, str, str, object)
GObject.GObject.__init__(self, str, str, str, str, str, object)
self.db = db
for lds_ord in lds_list:

View File

@ -26,7 +26,7 @@
#
#-------------------------------------------------------------------------
from gen.ggettext import gettext as _
import gobject
from gi.repository import GObject
#-------------------------------------------------------------------------
#
@ -85,7 +85,7 @@ class LocationEmbedList(EmbeddedList):
data = self.get_data()
data.append(name)
self.rebuild()
gobject.idle_add(self.tree.scroll_to_cell, len(data) - 1)
GObject.idle_add(self.tree.scroll_to_cell, len(data) - 1)
def edit_button_clicked(self, obj):
loc = self.get_selected()

View File

@ -25,7 +25,7 @@
# GTK libraries
#
#-------------------------------------------------------------------------
import gtk
from gi.repository import Gtk
#-------------------------------------------------------------------------
#
@ -39,10 +39,10 @@ import gtk
# LocationModel
#
#-------------------------------------------------------------------------
class LocationModel(gtk.ListStore):
class LocationModel(Gtk.ListStore):
def __init__(self, obj_list, db):
gtk.ListStore.__init__(self, str, str, str, str, str, str, object)
GObject.GObject.__init__(self, str, str, str, str, str, str, object)
self.db = db
for obj in obj_list:
self.append(row=[obj.street, obj.locality, obj.city, obj.county,

View File

@ -26,8 +26,8 @@
# Python classes
#
#-------------------------------------------------------------------------
import gtk
import gobject
from gi.repository import Gtk
from gi.repository import GObject
#-------------------------------------------------------------------------
#
@ -117,15 +117,15 @@ class NameEmbedList(GroupEmbeddedList):
def get_popup_menu_items(self):
if self._tmpgroup == self._WORKGROUP:
return [
(True, True, gtk.STOCK_ADD, self.add_button_clicked),
(False,True, gtk.STOCK_EDIT, self.edit_button_clicked),
(True, True, gtk.STOCK_REMOVE, self.del_button_clicked),
(True, True, Gtk.STOCK_ADD, self.add_button_clicked),
(False,True, Gtk.STOCK_EDIT, self.edit_button_clicked),
(True, True, Gtk.STOCK_REMOVE, self.del_button_clicked),
(True, False, _('Set as default name'), self.name_button_clicked),
]
else:
return [
(True, True, gtk.STOCK_ADD, self.add_button_clicked),
(False,True, gtk.STOCK_EDIT, self.edit_button_clicked),
(True, True, Gtk.STOCK_ADD, self.add_button_clicked),
(False,True, Gtk.STOCK_EDIT, self.edit_button_clicked),
]
def name_button_clicked(self, obj):
@ -167,7 +167,7 @@ class NameEmbedList(GroupEmbeddedList):
data = self.get_data()[self._WORKGROUP]
data.append(name)
self.rebuild()
gobject.idle_add(self.tree.scroll_to_cell,
GObject.idle_add(self.tree.scroll_to_cell,
(self._WORKGROUP, len(data) - 1))
def edit_button_clicked(self, obj):

View File

@ -34,14 +34,17 @@ from gen.ggettext import gettext as _
# GTK libraries
#
#-------------------------------------------------------------------------
import gtk
from pango import WEIGHT_NORMAL, WEIGHT_BOLD
from gi.repository import Gtk
from gi.repository import Pango
WEIGHT_NORMAL = Pango.Weight.NORMAL
WEIGHT_BOLD = Pango.Weight.BOLD
#-------------------------------------------------------------------------
#
# GRAMPS classes
#
#-------------------------------------------------------------------------
from gui.widgets.undoablebuffer import UndoableBuffer
from gen.display.name import displayer as name_displayer
#-------------------------------------------------------------------------
@ -53,7 +56,7 @@ from gen.display.name import displayer as name_displayer
YES = _('Yes')
NO = _('No')
class NameModel(gtk.TreeStore):
class NameModel(Gtk.TreeStore):
#tree groups defined
DEFINDEX = 0
DEFNAME = _('Preferred name')
@ -83,7 +86,7 @@ class NameModel(gtk.TreeStore):
that might be used. name is the name for the group.
"""
typeobjs = (x[1] for x in self.COLS)
gtk.TreeStore.__init__(self, *typeobjs)
GObject.GObject.__init__(self, *typeobjs)
self.db = db
self.groups = groups
for index, group in enumerate(obj_list):

View File

@ -25,17 +25,17 @@
# GTK libraries
#
#-------------------------------------------------------------------------
import gtk
from gi.repository import Gtk
#-------------------------------------------------------------------------
#
# NoteModel
#
#-------------------------------------------------------------------------
class NoteModel(gtk.ListStore):
class NoteModel(Gtk.ListStore):
def __init__(self, note_list, db):
gtk.ListStore.__init__(self, str, str, object)
GObject.GObject.__init__(self, str, str, object)
self.db = db
for handle in note_list:
note = self.db.get_note_from_handle(handle)

View File

@ -32,7 +32,7 @@ from gen.ggettext import gettext as _
# GTK/Gnome modules
#
#-------------------------------------------------------------------------
import gobject
from gi.repository import GObject
#-------------------------------------------------------------------------
#
@ -147,7 +147,7 @@ class NoteTab(EmbeddedList, DbGUIElement):
self.callman.register_handles({'note': [name]})
self.changed = True
self.rebuild()
gobject.idle_add(self.tree.scroll_to_cell, len(data) - 1)
GObject.idle_add(self.tree.scroll_to_cell, len(data) - 1)
def edit_button_clicked(self, obj):
"""

View File

@ -27,7 +27,7 @@
#
#-------------------------------------------------------------------------
from gen.ggettext import gettext as _
import gobject
from gi.repository import GObject
#-------------------------------------------------------------------------
#
@ -155,7 +155,7 @@ class PersonEventEmbedList(EventEmbedList):
# New index is index-1 but for path, add another 1 for person events.
path = (index,)
self.tree.get_selection().select_path(path)
gobject.idle_add(self.tree.scroll_to_cell, path)
GObject.idle_add(self.tree.scroll_to_cell, path)
def _move_down_group(self, groupindex):
"""
@ -183,4 +183,4 @@ class PersonEventEmbedList(EventEmbedList):
# New index is index+1 but for path, add another 1 for person events.
path = (index + 2,)
self.tree.get_selection().select_path(path)
gobject.idle_add(self.tree.scroll_to_cell, path)
GObject.idle_add(self.tree.scroll_to_cell, path)

View File

@ -26,7 +26,7 @@
#
#-------------------------------------------------------------------------
from gen.ggettext import gettext as _
import gobject
from gi.repository import GObject
#-------------------------------------------------------------------------
#
@ -96,7 +96,7 @@ class PersonRefEmbedList(EmbeddedList):
data = self.get_data()
data.append(obj)
self.rebuild()
gobject.idle_add(self.tree.scroll_to_cell, len(data) - 1)
GObject.idle_add(self.tree.scroll_to_cell, len(data) - 1)
def edit_button_clicked(self, obj):
from gui.editors import EditPersonRef

View File

@ -25,7 +25,7 @@
# GTK libraries
#
#-------------------------------------------------------------------------
import gtk
from gi.repository import Gtk
#-------------------------------------------------------------------------
#
@ -39,10 +39,10 @@ from gen.display.name import displayer as name_displayer
# PersonRefModel
#
#-------------------------------------------------------------------------
class PersonRefModel(gtk.ListStore):
class PersonRefModel(Gtk.ListStore):
def __init__(self, obj_list, db):
gtk.ListStore.__init__(self, str, str, str, object)
GObject.GObject.__init__(self, str, str, str, object)
self.db = db
for obj in obj_list:
p = self.db.get_person_from_handle(obj.ref)

View File

@ -26,7 +26,7 @@
#
#-------------------------------------------------------------------------
from gen.ggettext import gettext as _
import gobject
from gi.repository import GObject
#-------------------------------------------------------------------------
#
@ -151,7 +151,7 @@ class RepoEmbedList(EmbeddedList, DbGUIElement):
self.callman.register_handles({'repository': [value[1].handle]})
self.changed = True
self.rebuild()
gobject.idle_add(self.tree.scroll_to_cell, len(data) - 1)
GObject.idle_add(self.tree.scroll_to_cell, len(data) - 1)
def edit_button_clicked(self, obj):
ref = self.get_selected()

View File

@ -25,7 +25,7 @@
# GTK libraries
#
#-------------------------------------------------------------------------
import gtk
from gi.repository import Gtk
#-------------------------------------------------------------------------
#
@ -39,10 +39,10 @@ import gtk
# RepoRefModel
#
#-------------------------------------------------------------------------
class RepoRefModel(gtk.ListStore):
class RepoRefModel(Gtk.ListStore):
def __init__(self, ref_list, db):
gtk.ListStore.__init__(self, str, str, str, str, object)
GObject.GObject.__init__(self, str, str, str, str, object)
self.db = db
for ref in ref_list:
repo = self.db.get_repository_from_handle(ref.ref)

View File

@ -26,8 +26,8 @@
# GTK libraries
#
#-------------------------------------------------------------------------
import gtk
import gobject
from gi.repository import Gtk
from gi.repository import GObject
#-------------------------------------------------------------------------
#
@ -41,11 +41,11 @@ import gobject
# SurnamModel
#
#-------------------------------------------------------------------------
class SurnameModel(gtk.ListStore):
class SurnameModel(Gtk.ListStore):
def __init__(self, surn_list, db):
#setup model for the treeview
gtk.ListStore.__init__(self, str, str, str, str,
GObject.GObject.__init__(self, str, str, str, str,
bool, object)
for surn in surn_list:
# fill the liststore

View File

@ -34,11 +34,12 @@ import locale
# GTK classes
#
#-------------------------------------------------------------------------
import gtk
import gobject
import pango
_TAB = gtk.gdk.keyval_from_name("Tab")
_ENTER = gtk.gdk.keyval_from_name("Enter")
from gi.repository import Gtk
from gi.repository import Gdk
from gi.repository import GObject
from gi.repository import Pango
_TAB = Gdk.keyval_from_name("Tab")
_ENTER = Gdk.keyval_from_name("Enter")
#-------------------------------------------------------------------------
#
@ -106,11 +107,11 @@ class SurnameTab(EmbeddedList):
# combobox for type
colno = len(self.columns)
name = self._column_combo[0]
renderer = gtk.CellRendererCombo()
renderer.set_property('ellipsize', pango.ELLIPSIZE_END)
renderer = Gtk.CellRendererCombo()
renderer.set_property('ellipsize', Pango.EllipsizeMode.END)
# set up the comboentry editable
no = NameOriginType()
self.cmborig = gtk.ListStore(gobject.TYPE_INT, gobject.TYPE_STRING)
self.cmborig = Gtk.ListStore(GObject.TYPE_INT, GObject.TYPE_STRING)
self.cmborigmap = no.get_map().copy()
keys = sorted(self.cmborigmap, self.by_value)
for key in keys:
@ -128,7 +129,7 @@ class SurnameTab(EmbeddedList):
renderer.connect('editing_started', self.on_edit_start_cmb, colno)
renderer.connect('edited', self.on_orig_edited, self._column_combo[3])
# add to treeview
column = gtk.TreeViewColumn(name, renderer, text=self._column_combo[3])
column = Gtk.TreeViewColumn(name, renderer, text=self._column_combo[3])
column.set_resizable(True)
column.set_sort_column_id(self._column_combo[1])
column.set_min_width(self._column_combo[2])
@ -138,14 +139,14 @@ class SurnameTab(EmbeddedList):
# toggle box for primary
colno += 1
name = self._column_toggle[0]
renderer = gtk.CellRendererToggle()
renderer = Gtk.CellRendererToggle()
renderer.set_property('activatable', True)
renderer.set_property('radio', True)
renderer.connect( 'toggled', self.on_prim_toggled, self._column_toggle[3])
# add to treeview
column = gtk.TreeViewColumn(name, renderer, active=self._column_toggle[3])
column = Gtk.TreeViewColumn(name, renderer, active=self._column_toggle[3])
column.set_resizable(False)
column.set_sizing(gtk.TREE_VIEW_COLUMN_FIXED)
column.set_sizing(Gtk.TreeViewColumnSizing.FIXED)
column.set_alignment(0.5)
column.set_sort_column_id(self._column_toggle[1])
column.set_min_width(self._column_toggle[2])
@ -238,11 +239,11 @@ class SurnameTab(EmbeddedList):
"""
self.on_edit_start(cellr, celle, path, colnr)
#set up autocomplete
completion = gtk.EntryCompletion()
completion = Gtk.EntryCompletion()
completion.set_model(self.cmborig)
completion.set_minimum_key_length(1)
completion.set_text_column(1)
celle.child.set_completion(completion)
celle.get_child().set_completion(completion)
#
celle.connect('changed', self.on_origcmb_change, path, colnr)
@ -321,12 +322,12 @@ class SurnameTab(EmbeddedList):
Here we make sure tab moves to next or previous value in row on TAB
"""
if not EmbeddedList.key_pressed(self, obj, event):
if event.type == gtk.gdk.KEY_PRESS and event.keyval in (_TAB,):
if not (event.state & (gtk.gdk.SHIFT_MASK |
gtk.gdk.CONTROL_MASK)):
if event.type == Gdk.KEY_PRESS and event.keyval in (_TAB,):
if not (event.get_state() & (Gdk.ModifierType.SHIFT_MASK |
Gdk.ModifierType.CONTROL_MASK)):
return self.next_cell()
elif (event.state & (gtk.gdk.SHIFT_MASK |
gtk.gdk.CONTROL_MASK)):
elif (event.get_state() & (Gdk.ModifierType.SHIFT_MASK |
Gdk.ModifierType.CONTROL_MASK)):
return self.prev_cell()
else:
return

View File

@ -26,8 +26,8 @@
#
#-------------------------------------------------------------------------
from gen.ggettext import gettext as _
import gtk
import gobject
from gi.repository import Gtk
from gi.repository import GObject
#-------------------------------------------------------------------------
#
@ -94,7 +94,7 @@ class WebEmbedList(EmbeddedList):
data = self.get_data()
data.append(url)
self.rebuild()
gobject.idle_add(self.tree.scroll_to_cell, len(data) - 1)
GObject.idle_add(self.tree.scroll_to_cell, len(data) - 1)
def edit_button_clicked(self, obj):
from gui.editors import EditUrl
@ -111,10 +111,10 @@ class WebEmbedList(EmbeddedList):
def get_popup_menu_items(self):
return [
(True, True, gtk.STOCK_ADD, self.add_button_clicked),
(False, True, gtk.STOCK_EDIT, self.edit_button_clicked),
(True, True, gtk.STOCK_REMOVE, self.del_button_clicked),
(True, True, gtk.STOCK_JUMP_TO, self.jump_button_clicked),
(True, True, Gtk.STOCK_ADD, self.add_button_clicked),
(False, True, Gtk.STOCK_EDIT, self.edit_button_clicked),
(True, True, Gtk.STOCK_REMOVE, self.del_button_clicked),
(True, True, Gtk.STOCK_JUMP_TO, self.jump_button_clicked),
]
def jump_button_clicked(self, obj):

View File

@ -29,20 +29,20 @@ The TreeModel for the URL list in the Url Tab.
# GTK libraries
#
#-------------------------------------------------------------------------
import gtk
from gi.repository import Gtk
#-------------------------------------------------------------------------
#
# WebModel
#
#-------------------------------------------------------------------------
class WebModel(gtk.ListStore):
class WebModel(Gtk.ListStore):
"""
WebModel derives from the ListStore, defining te items in the list
"""
def __init__(self, obj_list, dbase):
gtk.ListStore.__init__(self, str, str, str, object)
GObject.GObject.__init__(self, str, str, str, object)
self.db = dbase
for obj in obj_list:
self.append(row=[str(obj.type), obj.path, obj.desc, obj])

View File

@ -40,7 +40,7 @@ from gen.ggettext import gettext as _
# GTK/Gnome modules
#
#-------------------------------------------------------------------------
import gtk
from gi.repository import Gtk
#-------------------------------------------------------------------------
#
@ -133,7 +133,7 @@ class EditAddress(EditSecondary):
window.
"""
notebook = gtk.Notebook()
notebook = Gtk.Notebook()
self.srcref_list = CitationEmbedList(self.dbstate,
self.uistate,

View File

@ -39,7 +39,7 @@ from gen.ggettext import gettext as _
# GTK/Gnome modules
#
#-------------------------------------------------------------------------
import gtk
from gi.repository import Gtk
#-------------------------------------------------------------------------
#
@ -107,7 +107,7 @@ class EditAttribute(EditSecondary):
)
def _create_tabbed_pages(self):
notebook = gtk.Notebook()
notebook = Gtk.Notebook()
self.srcref_list = CitationEmbedList(self.dbstate,
self.uistate,
self.track,

View File

@ -39,7 +39,8 @@ from gen.ggettext import gettext as _
# GTK/Gnome modules
#
#-------------------------------------------------------------------------
import gtk
from gi.repository import Gdk
from gi.repository import Gtk
#-------------------------------------------------------------------------
#
@ -60,8 +61,8 @@ from gen.display.name import displayer as name_displayer
#
#-------------------------------------------------------------------------
_RETURN = gtk.gdk.keyval_from_name("Return")
_KP_ENTER = gtk.gdk.keyval_from_name("KP_Enter")
_RETURN = Gdk.keyval_from_name("Return")
_KP_ENTER = Gdk.keyval_from_name("KP_Enter")
_LEFT_BUTTON = 1
_RIGHT_BUTTON = 3
@ -143,7 +144,7 @@ class EditChildRef(EditSecondary):
Create the notebook tabs and inserts them into the main
window.
"""
notebook = gtk.Notebook()
notebook = Gtk.Notebook()
self.srcref_list = CitationEmbedList(self.dbstate,
self.uistate,
@ -205,9 +206,9 @@ class EditChildRef(EditSecondary):
self.close()
def button_activated(event, mouse_button):
if (event.type == gtk.gdk.BUTTON_PRESS and
if (event.type == Gdk.EventType.BUTTON_PRESS and
event.button == mouse_button) or \
(event.type == gtk.gdk.KEY_PRESS and
(event.type == Gdk.KEY_PRESS and
event.keyval in (_RETURN, _KP_ENTER)):
return True
else:

View File

@ -54,7 +54,7 @@ __LOG = logging.getLogger(".EditDate")
# GNOME modules
#
#-------------------------------------------------------------------------
import gtk
from gi.repository import Gtk
#-------------------------------------------------------------------------
#
@ -205,13 +205,13 @@ class EditDate(ManagedWindow):
while True:
response = self.window.run()
if response == gtk.RESPONSE_HELP:
if response == Gtk.ResponseType.HELP:
display_help(webpage=WIKI_HELP_PAGE,
section=WIKI_HELP_SEC)
elif response == gtk.RESPONSE_DELETE_EVENT:
elif response == Gtk.ResponseType.DELETE_EVENT:
break
else:
if response == gtk.RESPONSE_OK:
if response == Gtk.ResponseType.OK:
(the_quality, the_modifier, the_calendar, the_value,
the_text, the_newyear) = self.build_date_from_ui()
self.return_date = Date(self.date)

View File

@ -34,7 +34,7 @@ from gen.ggettext import sgettext as _
# GTK/Gnome modules
#
#-------------------------------------------------------------------------
import gtk
from gi.repository import Gtk
#-------------------------------------------------------------------------
#
@ -171,7 +171,7 @@ class EditEvent(EditPrimary):
Create the notebook tabs and inserts them into the main
window.
"""
notebook = gtk.Notebook()
notebook = Gtk.Notebook()
self.citation_list = CitationEmbedList(self.dbstate,
self.uistate,

View File

@ -50,10 +50,10 @@ log = logging.getLogger(".")
#-------------------------------------------------------------------------
from gen.ggettext import gettext as _
from gui.ddtargets import DdTargets
import gtk
from gtk import gdk
import pango
import gobject
from gi.repository import Gtk
from gi.repository import Gdk
from gi.repository import Pango
from gi.repository import GObject
#-------------------------------------------------------------------------
#
@ -87,8 +87,8 @@ from Utils import preset_name
SelectPerson = SelectorFactory('Person')
_RETURN = gdk.keyval_from_name("Return")
_KP_ENTER = gdk.keyval_from_name("KP_Enter")
_RETURN = Gdk.keyval_from_name("Return")
_KP_ENTER = Gdk.keyval_from_name("KP_Enter")
_LEFT_BUTTON = 1
_RIGHT_BUTTON = 3
@ -135,14 +135,14 @@ class ChildEmbedList(EmbeddedList):
def get_popup_menu_items(self):
return [
(False, True, (gtk.STOCK_EDIT, _('Edit child')),
(False, True, (Gtk.STOCK_EDIT, _('Edit child')),
self.edit_child_button_clicked),
(True, True, gtk.STOCK_ADD, self.add_button_clicked),
(True, True, Gtk.STOCK_ADD, self.add_button_clicked),
(True, False, _('Add an existing child'),
self.share_button_clicked),
(False, True, (gtk.STOCK_EDIT, _('Edit relationship')),
(False, True, (Gtk.STOCK_EDIT, _('Edit relationship')),
self.edit_button_clicked),
(True, True, gtk.STOCK_REMOVE, self.del_button_clicked),
(True, True, Gtk.STOCK_REMOVE, self.del_button_clicked),
]
def get_middle_click(self):
@ -194,7 +194,7 @@ class ChildEmbedList(EmbeddedList):
ref.ref = person.get_handle()
self.family.add_child_ref(ref)
self.rebuild()
gobject.idle_add(self.tree.scroll_to_cell,
GObject.idle_add(self.tree.scroll_to_cell,
len(self.family.get_child_ref_list()) - 1)
self.call_edit_childref(ref)
@ -216,7 +216,7 @@ class ChildEmbedList(EmbeddedList):
ref.ref = person.get_handle()
self.family.add_child_ref(ref)
self.rebuild()
gobject.idle_add(self.tree.scroll_to_cell,
GObject.idle_add(self.tree.scroll_to_cell,
len(self.family.get_child_ref_list()) - 1)
self.call_edit_childref(ref)
@ -616,7 +616,7 @@ class EditFamily(EditPrimary):
def _create_tabbed_pages(self):
notebook = gtk.Notebook()
notebook = Gtk.Notebook()
self.child_list = ChildEmbedList(self.dbstate,
self.uistate,
@ -1093,9 +1093,9 @@ class EditFamily(EditPrimary):
return name
def button_activated(event, mouse_button):
if (event.type == gtk.gdk.BUTTON_PRESS and
if (event.type == Gdk.EventType.BUTTON_PRESS and
event.button == mouse_button) or \
(event.type == gtk.gdk.KEY_PRESS and
(event.type == Gdk.KEY_PRESS and
event.keyval in (_RETURN, _KP_ENTER)):
return True
else:

View File

@ -38,7 +38,7 @@ from gen.ggettext import gettext as _
# GTK/Gnome modules
#
#-------------------------------------------------------------------------
import gtk
from gi.repository import Gtk
#-------------------------------------------------------------------------
#
@ -239,7 +239,7 @@ class EditLdsOrd(EditSecondary):
self.status_menu.change_menu(new_data)
def _create_tabbed_pages(self):
notebook = gtk.Notebook()
notebook = Gtk.Notebook()
self.citation_list = CitationEmbedList(self.dbstate, self.uistate,
self.track,
self.obj.get_citation_list())
@ -405,7 +405,7 @@ class EditFamilyLdsOrd(EditSecondary):
self.track_ref_for_deletion('status_menu')
def _create_tabbed_pages(self):
notebook = gtk.Notebook()
notebook = Gtk.Notebook()
self.srcref_list = CitationEmbedList(self.dbstate,self.uistate,
self.track,
self.obj.get_citation_list())

View File

@ -25,7 +25,7 @@
# python modules
#
#-------------------------------------------------------------------------
import gtk
from gi.repository import Gtk
import re
#-------------------------------------------------------------------------
@ -76,7 +76,7 @@ class EditLink(ManagedWindow):
self.top.get_object("title"),
_('Link Editor'))
self.table = self.top.get_object('table27')
self.uri_list = gtk.combo_box_new_text()
self.uri_list = Gtk.ComboBoxText()
for text in [_("Internet Address"), # 0 this order range above
_("Event"), # 1
_("Family"), # 2

View File

@ -35,7 +35,7 @@ from gen.ggettext import gettext as _
# GTK/Gnome modules
#
#-------------------------------------------------------------------------
import gtk
from gi.repository import Gtk
#-------------------------------------------------------------------------
#
@ -190,7 +190,7 @@ class EditMedia(EditPrimary):
self.select.connect('clicked', self.select_file)
def _create_tabbed_pages(self):
notebook = gtk.Notebook()
notebook = Gtk.Notebook()
self.citation_tab = CitationEmbedList(self.dbstate,
self.uistate,
@ -231,7 +231,7 @@ class EditMedia(EditPrimary):
return (_('Edit Media Object'), self.get_menu_title())
def button_press_event(self, obj, event):
if event.button == 1 and event.type == gtk.gdk._2BUTTON_PRESS:
if event.button == 1 and event.type == Gdk.EventType._2BUTTON_PRESS:
self.view_media(obj)
def view_media(self, obj):

View File

@ -36,7 +36,7 @@ from gen.ggettext import sgettext as _
# GTK/Gnome modules
#
#-------------------------------------------------------------------------
import gtk
from gi.repository import GdkPixbuf
#-------------------------------------------------------------------------
#
@ -162,8 +162,8 @@ class EditMediaRef(EditReference):
ebox_ref.connect('button-release-event',
self.button_release_event_ref)
ebox_ref.connect('motion-notify-event', self.motion_notify_event_ref)
ebox_ref.add_events(gtk.gdk.BUTTON_PRESS_MASK)
ebox_ref.add_events(gtk.gdk.BUTTON_RELEASE_MASK)
ebox_ref.add_events(Gdk.EventMask.BUTTON_PRESS_MASK)
ebox_ref.add_events(Gdk.EventMask.BUTTON_RELEASE_MASK)
self.pixmap = self.top.get_object("pixmap")
self.mimetext = self.top.get_object("type")
@ -395,7 +395,7 @@ class EditMediaRef(EditReference):
else:
try:
fullpath = Utils.media_path_full(self.db, path)
pixbuf = gtk.gdk.pixbuf_new_from_file(fullpath)
pixbuf = GdkPixbuf.Pixbuf.new_from_file(fullpath)
width = pixbuf.get_width()
height = pixbuf.get_height()
upper_x = min(self.rectangle[0], self.rectangle[2])/100.
@ -414,7 +414,7 @@ class EditMediaRef(EditReference):
scale = const.THUMBSCALE / ratio
x = int(scale * width)
y = int(scale * height)
pixbuf = pixbuf.scale_simple(x, y, gtk.gdk.INTERP_BILINEAR)
pixbuf = pixbuf.scale_simple(x, y, GdkPixbuf.InterpType.BILINEAR)
self.subpixmap.set_from_pixbuf(pixbuf)
self.subpixmap.show()
except:
@ -432,7 +432,7 @@ class EditMediaRef(EditReference):
return (_('Media Reference Editor'),submenu_label)
def button_press_event(self, obj, event):
if event.button==1 and event.type == gtk.gdk._2BUTTON_PRESS:
if event.button==1 and event.type == Gdk.EventType._2BUTTON_PRESS:
photo_path = Utils.media_path_full(self.db, self.source.get_path())
open_file_with_default_application(photo_path)
@ -447,10 +447,10 @@ class EditMediaRef(EditReference):
# prepare drawing of a feedback rectangle
self.rect_pixbuf = self.subpixmap.get_pixbuf()
w,h = self.rect_pixbuf.get_width(), self.rect_pixbuf.get_height()
self.rect_pixbuf_render = gtk.gdk.Pixbuf(gtk.gdk.COLORSPACE_RGB, False, 8, w, h)
cm = gtk.gdk.colormap_get_system()
color = cm.alloc_color(gtk.gdk.Color("blue"))
self.rect_pixmap = gtk.gdk.Pixmap(None, w, h, cm.get_visual().depth)
self.rect_pixbuf_render = GdkPixbuf.Pixbuf(GdkPixbuf.Colorspace.RGB, False, 8, w, h)
cm = Gdk.colormap_get_system()
color = cm.alloc_color(Gdk.Color("blue"))
self.rect_pixmap = Gdk.Pixmap(None, w, h, cm.get_visual().depth)
self.rect_pixmap.set_colormap(cm)
self.rect_gc = self.rect_pixmap.new_gc()
self.rect_gc.set_foreground(color)
@ -479,7 +479,7 @@ class EditMediaRef(EditReference):
x1, y1, width, height)
self.rect_pixbuf_render.get_from_drawable(self.rect_pixmap,
gtk.gdk.colormap_get_system(),
Gdk.colormap_get_system(),
0,0,0,0, w, h)
self.subpixmap.set_from_pixbuf(self.rect_pixbuf_render)
@ -490,8 +490,8 @@ class EditMediaRef(EditReference):
"""
# reset the crop on double-click or click+CTRL
if (event.button==1 and event.type == gtk.gdk._2BUTTON_PRESS) or \
(event.button==1 and (event.state & gtk.gdk.CONTROL_MASK) ):
if (event.button==1 and event.type == Gdk.EventType._2BUTTON_PRESS) or \
(event.button==1 and (event.get_state() & Gdk.ModifierType.CONTROL_MASK) ):
self.corner1_x_spinbutton.set_value(0)
self.corner1_y_spinbutton.set_value(0)
self.corner2_x_spinbutton.set_value(100)

View File

@ -29,7 +29,7 @@
# Standard python modules
#
#-------------------------------------------------------------------------
import gobject
from gi.repository import GObject
from gen.ggettext import gettext as _
from copy import copy
@ -38,7 +38,7 @@ from copy import copy
# GTK/Gnome modules
#
#-------------------------------------------------------------------------
import gtk
from gi.repository import Gtk
#-------------------------------------------------------------------------
#
@ -85,9 +85,9 @@ class GeneralNameTab(GrampsTab):
@type widge: gtk widget
"""
GrampsTab.__init__(self, dbstate, uistate, track, name)
eventbox = gtk.EventBox()
eventbox = Gtk.EventBox()
eventbox.add(widget)
self.pack_start(eventbox)
self.pack_start(eventbox, True, True, 0)
self._set_label(show_image=False)
widget.connect('key_press_event', self.key_pressed)
self.show_all()

View File

@ -38,9 +38,9 @@ _LOG = logging.getLogger(".gui.editors.EditNote")
# GTK libraries
#
#-------------------------------------------------------------------------
import gtk
import gobject
import pango
from gi.repository import Gtk
from gi.repository import GObject
from gi.repository import Pango
#-------------------------------------------------------------------------
#
@ -88,9 +88,9 @@ class NoteTab(GrampsTab):
@type widget: gtk widget
"""
GrampsTab.__init__(self, dbstate, uistate, track, name)
eventbox = gtk.EventBox()
eventbox = Gtk.EventBox()
eventbox.add(widget)
self.pack_start(eventbox)
self.pack_start(eventbox, True, True, 0)
self._set_label(show_image=False)
eventbox.connect('key_press_event', self.key_pressed)
self.show_all()
@ -259,12 +259,12 @@ class EditNote(EditPrimary):
def build_interface(self):
self.texteditor = self.top.get_object('texteditor')
self.texteditor.set_editable(not self.dbstate.db.readonly)
self.texteditor.set_wrap_mode(gtk.WRAP_WORD)
self.texteditor.set_wrap_mode(Gtk.WrapMode.WORD)
# create a formatting toolbar
if not self.dbstate.db.readonly:
vbox = self.top.get_object('container')
vbox.pack_start(self.texteditor.get_toolbar(),
vbox.pack_start(label=self.texteditor.get_toolbar(),
expand=False, fill=False)
# setup initial values for textview and textbuffer

View File

@ -41,8 +41,8 @@ from gen.ggettext import sgettext as _
# GTK/Gnome modules
#
#-------------------------------------------------------------------------
import gtk
import pango
from gi.repository import Gtk
from gi.repository import Pango
#-------------------------------------------------------------------------
#
@ -206,7 +206,7 @@ class EditPerson(EditPrimary):
self.load_person_image()
self.given.grab_focus()
self._changed_name(None)
self.top.get_object("hboxmultsurnames").pack_start(self.surntab)
self.top.get_object("hboxmultsurnames").pack_start(self.surntab, True, True, 0)
if len(self.obj.get_primary_name().get_surname_list()) > 1:
self.multsurnfr.set_size_request(-1,
@ -419,7 +419,7 @@ class EditPerson(EditPrimary):
obj.connect('changed', self._changed_name)
self.preview_name = self.top.get_object("full_name")
self.preview_name.modify_font(pango.FontDescription('sans bold 12'))
self.preview_name.modify_font(Pango.FontDescription('sans bold 12'))
def get_start_date(self):
"""
@ -433,7 +433,7 @@ class EditPerson(EditPrimary):
"""
Create the notebook tabs and insert them into the main window.
"""
notebook = gtk.Notebook()
notebook = Gtk.Notebook()
notebook.set_scrollable(True)
self.event_list = PersonEventEmbedList(
@ -589,7 +589,7 @@ class EditPerson(EditPrimary):
main form.
"""
if event.type == gtk.gdk._2BUTTON_PRESS and event.button == 1:
if event.type == Gdk.EventType._2BUTTON_PRESS and event.button == 1:
media_list = self.obj.get_media_list()
if media_list:
@ -617,7 +617,7 @@ class EditPerson(EditPrimary):
available actions.
"""
menu = gtk.Menu()
menu = Gtk.Menu()
menu.set_title(_("Media Object"))
obj = self.db.get_object_from_handle(photo.get_reference_handle())
if obj:
@ -656,17 +656,17 @@ class EditPerson(EditPrimary):
Override from base class, the menuitems and actiongroups for the top
of context menu.
"""
self.all_action = gtk.ActionGroup("/PersonAll")
self.home_action = gtk.ActionGroup("/PersonHome")
self.all_action = Gtk.ActionGroup("/PersonAll")
self.home_action = Gtk.ActionGroup("/PersonHome")
self.track_ref_for_deletion("all_action")
self.track_ref_for_deletion("home_action")
self.all_action.add_actions([
('ActivePerson', gtk.STOCK_APPLY, _("Make Active Person"),
('ActivePerson', Gtk.STOCK_APPLY, _("Make Active Person"),
None, None, self._make_active),
])
self.home_action.add_actions([
('HomePerson', gtk.STOCK_HOME, _("Make Home Person"),
('HomePerson', Gtk.STOCK_HOME, _("Make Home Person"),
None, None, self._make_home_person),
])
@ -910,7 +910,7 @@ class EditPerson(EditPrimary):
self.obj.get_primary_name())
self.multsurnfr.set_size_request(-1,
int(config.get('interface.surname-box-height')))
msurhbox.pack_start(self.surntab)
msurhbox.pack_start(self.surntab, True, True, 0)
def load_person_image(self):
"""
@ -1053,12 +1053,12 @@ class EditPerson(EditPrimary):
#config.save()
class GenderDialog(gtk.MessageDialog):
class GenderDialog(Gtk.MessageDialog):
def __init__(self, parent=None):
gtk.MessageDialog.__init__(self,
GObject.GObject.__init__(self,
parent,
flags=gtk.DIALOG_MODAL,
type=gtk.MESSAGE_QUESTION,
flags=Gtk.DialogFlags.MODAL,
type=Gtk.MessageType.QUESTION,
)
self.set_icon(ICON)
self.set_title('')

View File

@ -39,7 +39,7 @@ from gen.ggettext import gettext as _
# GTK/Gnome modules
#
#-------------------------------------------------------------------------
import gtk
from gi.repository import Gtk
#-------------------------------------------------------------------------
#
@ -140,7 +140,7 @@ class EditPersonRef(EditSecondary):
window.
"""
notebook = gtk.Notebook()
notebook = Gtk.Notebook()
self.srcref_list = CitationEmbedList(self.dbstate, self.uistate,
self.track,

View File

@ -37,7 +37,7 @@ log = logging.getLogger(".")
# GTK/Gnome modules
#
#-------------------------------------------------------------------------
import gtk
from gi.repository import Gtk
#-------------------------------------------------------------------------
#
@ -85,9 +85,9 @@ class MainLocTab(GrampsTab):
@type widge: gtk widget
"""
GrampsTab.__init__(self, dbstate, uistate, track, name)
eventbox = gtk.EventBox()
eventbox = Gtk.EventBox()
eventbox.add(widget)
self.pack_start(eventbox)
self.pack_start(eventbox, True, True, 0)
self._set_label(show_image=False)
eventbox.connect('key_press_event', self.key_pressed)
self.show_all()

View File

@ -33,7 +33,7 @@ from gen.ggettext import gettext as _
# GTK modules
#
#-------------------------------------------------------------------------
import gtk
from gi.repository import Gtk
#-------------------------------------------------------------------------
#
@ -305,7 +305,7 @@ class EditPrimary(ManagedWindow, DbGUIElement):
"""
from gui.plug.quick import create_quickreport_menu
self.popupmanager = gtk.UIManager()
self.popupmanager = Gtk.UIManager()
#add custom actions
(ui_top, action_groups) = self._top_contextmenu()
for action in action_groups :
@ -316,7 +316,7 @@ class EditPrimary(ManagedWindow, DbGUIElement):
(ui_qr, reportactions) = create_quickreport_menu(self.QR_CATEGORY,
self.dbstate, self.uistate,
self.obj.get_handle())
self.report_action = gtk.ActionGroup("/PersonReport")
self.report_action = Gtk.ActionGroup("/PersonReport")
self.report_action.add_actions(reportactions)
self.report_action.set_visible(True)
self.popupmanager.insert_action_group(self.report_action, -1)

View File

@ -26,7 +26,7 @@
# GTK/Gnome modules
#
#-------------------------------------------------------------------------
import gtk
from gi.repository import Gtk
#-------------------------------------------------------------------------
#
@ -68,9 +68,9 @@ class RefTab(GrampsTab):
@type widge: gtk widget
"""
GrampsTab.__init__(self, dbstate, uistate, track, name)
eventbox = gtk.EventBox()
eventbox = Gtk.EventBox()
eventbox.add(widget)
self.pack_start(eventbox)
self.pack_start(eventbox, True, True, 0)
self._set_label(show_image=False)
widget.connect('key_press_event', self.key_pressed)
self.show_all()

View File

@ -33,7 +33,7 @@ from gen.ggettext import gettext as _
# GTK/Gnome modules
#
#-------------------------------------------------------------------------
import gtk
from gi.repository import Gtk
#-------------------------------------------------------------------------
#
@ -105,7 +105,7 @@ class EditRepository(EditPrimary):
def _create_tabbed_pages(self):
notebook = gtk.Notebook()
notebook = Gtk.Notebook()
self.addr_tab = AddrEmbedList(self.dbstate,
self.uistate,
@ -140,7 +140,7 @@ class EditRepository(EditPrimary):
self._setup_notebook_tabs(notebook)
notebook.show_all()
self.glade.get_object("vbox").pack_start(notebook, True, True)
self.glade.get_object("vbox").pack_start(notebook, True, True, 0)
def _connect_signals(self):
self.define_help_button(self.glade.get_object('help'))

View File

@ -37,7 +37,7 @@ LOG = logging.getLogger(".citation")
# GTK/Gnome modules
#
#-------------------------------------------------------------------------
import gtk
from gi.repository import Gtk
#-------------------------------------------------------------------------
#
@ -128,7 +128,7 @@ class EditSource(EditPrimary):
self.db.readonly)
def _create_tabbed_pages(self):
notebook = gtk.Notebook()
notebook = Gtk.Notebook()
self.note_tab = NoteTab(self.dbstate,
self.uistate,

View File

@ -26,7 +26,7 @@ Tag editing module for Gramps.
# GNOME modules
#
#-------------------------------------------------------------------------
import gtk
from gi.repository import Gtk
#-------------------------------------------------------------------------
#
@ -79,13 +79,13 @@ class EditTagList(ManagedWindow):
while True:
response = self.window.run()
if response == gtk.RESPONSE_HELP:
if response == Gtk.ResponseType.HELP:
display_help(webpage=WIKI_HELP_PAGE,
section=WIKI_HELP_SEC)
elif response == gtk.RESPONSE_DELETE_EVENT:
elif response == Gtk.ResponseType.DELETE_EVENT:
break
else:
if response == gtk.RESPONSE_OK:
if response == Gtk.ResponseType.OK:
self.return_list = [(row[0], row[2])
for row in self.namemodel.model
if row[1]]
@ -98,7 +98,7 @@ class EditTagList(ManagedWindow):
"""
# pylint: disable-msg=E1101
title = _("%(title)s - Gramps") % {'title': _("Edit Tags")}
top = gtk.Dialog(title)
top = Gtk.Dialog(title)
top.set_default_size(360, 400)
top.set_modal(True)
top.set_has_separator(False)
@ -107,17 +107,17 @@ class EditTagList(ManagedWindow):
columns = [('', -1, 300),
(' ', -1, 25, TOGGLE, True, None),
(_('Tag'), -1, 300)]
view = gtk.TreeView()
view = Gtk.TreeView()
self.namemodel = ListModel(view, columns)
slist = gtk.ScrolledWindow()
slist = Gtk.ScrolledWindow()
slist.add_with_viewport(view)
slist.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
slist.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)
top.vbox.pack_start(slist, 1, 1, 5)
top.add_button(gtk.STOCK_HELP, gtk.RESPONSE_HELP)
top.add_button(gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL)
top.add_button(gtk.STOCK_OK, gtk.RESPONSE_OK)
top.add_button(Gtk.STOCK_HELP, Gtk.ResponseType.HELP)
top.add_button(Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL)
top.add_button(Gtk.STOCK_OK, Gtk.ResponseType.OK)
top.show_all()
return top

View File

@ -45,8 +45,8 @@ log = logging.getLogger(".filtereditor")
# GTK/GNOME
#
#-------------------------------------------------------------------------
import gtk
import gobject
from gi.repository import Gtk
from gi.repository import GObject
#-------------------------------------------------------------------------
#
@ -117,10 +117,10 @@ def by_rule_name(f, s):
# MyBoolean - check button with standard interface
#
#-------------------------------------------------------------------------
class MyBoolean(gtk.CheckButton):
class MyBoolean(Gtk.CheckButton):
def __init__(self, label=None):
gtk.CheckButton.__init__(self, label)
GObject.GObject.__init__(self, label)
self.show()
def get_text(self):
@ -147,11 +147,11 @@ class MyBoolean(gtk.CheckButton):
# MyInteger - spin button with standard interface
#
#-------------------------------------------------------------------------
class MyInteger(gtk.SpinButton):
class MyInteger(Gtk.SpinButton):
def __init__(self, min, max):
gtk.SpinButton.__init__(self)
self.set_adjustment(gtk.Adjustment(min, min, max, 1))
GObject.GObject.__init__(self)
self.set_adjustment(Gtk.Adjustment(min, min, max, 1))
self.show()
def get_text(self):
@ -165,7 +165,7 @@ class MyInteger(gtk.SpinButton):
# MyFilters - Combo box with list of filters with a standard interface
#
#-------------------------------------------------------------------------
class MyFilters(gtk.ComboBox):
class MyFilters(Gtk.ComboBox):
"""
Class to present a combobox of selectable filters.
"""
@ -177,10 +177,10 @@ class MyFilters(gtk.ComboBox):
If filter_name is given, it will be excluded from the dropdown box.
"""
gtk.ComboBox.__init__(self)
store = gtk.ListStore(gobject.TYPE_STRING)
GObject.GObject.__init__(self)
store = Gtk.ListStore(GObject.TYPE_STRING)
self.set_model(store)
cell = gtk.CellRendererText()
cell = Gtk.CellRendererText()
self.pack_start(cell, True)
self.add_attribute(cell, 'text', 0)
#remove own name from the list if given.
@ -208,13 +208,13 @@ class MyFilters(gtk.ComboBox):
# MyList - Combo box to allow entries
#
#-------------------------------------------------------------------------
class MyList(gtk.ComboBox):
class MyList(Gtk.ComboBox):
def __init__(self, clist, clist_trans, default=0):
gtk.ComboBox.__init__(self)
store = gtk.ListStore(gobject.TYPE_STRING)
GObject.GObject.__init__(self)
store = Gtk.ListStore(GObject.TYPE_STRING)
self.set_model(store)
cell = gtk.CellRendererText()
cell = Gtk.CellRendererText()
self.pack_start(cell, True)
self.add_attribute(cell, 'text', 0)
self.clist = clist
@ -236,13 +236,13 @@ class MyList(gtk.ComboBox):
# MyLesserEqualGreater - Combo box to allow selection of "<", "=", or ">"
#
#-------------------------------------------------------------------------
class MyLesserEqualGreater(gtk.ComboBox):
class MyLesserEqualGreater(Gtk.ComboBox):
def __init__(self, default=0):
gtk.ComboBox.__init__(self)
store = gtk.ListStore(gobject.TYPE_STRING)
GObject.GObject.__init__(self)
store = Gtk.ListStore(GObject.TYPE_STRING)
self.set_model(store)
cell = gtk.CellRendererText()
cell = Gtk.CellRendererText()
self.pack_start(cell, True)
self.add_attribute(cell, 'text', 0)
self.clist = ['lesser than', 'equal to', 'greater than']
@ -270,10 +270,10 @@ class MyLesserEqualGreater(gtk.ComboBox):
# a standard interface
#
#-------------------------------------------------------------------------
class MyPlaces(gtk.Entry):
class MyPlaces(Gtk.Entry):
def __init__(self, places):
gtk.Entry.__init__(self)
GObject.GObject.__init__(self)
fill_entry(self, places)
self.show()
@ -283,7 +283,7 @@ class MyPlaces(gtk.Entry):
# MyID - Person/GRAMPS ID selection box with a standard interface
#
#-------------------------------------------------------------------------
class MyID(gtk.HBox):
class MyID(Gtk.HBox):
_invalid_id_txt = _('Not a valid ID')
_empty_id_txt = _invalid_id_txt
@ -300,20 +300,20 @@ class MyID(gtk.HBox):
}
def __init__(self, dbstate, uistate, track, namespace='Person'):
gtk.HBox.__init__(self, False, 6)
GObject.GObject.__init__(self, False, 6)
self.dbstate = dbstate
self.db = dbstate.db
self.uistate = uistate
self.track = track
self.namespace = namespace
self.entry = gtk.Entry()
self.entry = Gtk.Entry()
self.entry.show()
self.button = gtk.Button()
self.button = Gtk.Button()
self.button.set_label(_('Select...'))
self.button.connect('clicked', self.button_press)
self.button.show()
self.pack_start(self.entry)
self.pack_start(self.entry, True, True, 0)
self.add(self.button)
self.button.set_tooltip_text(_('Select %s from a list')
% self.obj_name[namespace])
@ -393,10 +393,11 @@ class MySource(MyID):
# MySelect
#
#-------------------------------------------------------------------------
class MySelect(gtk.ComboBoxEntry):
class MySelect(Gtk.ComboBox):
def __init__(self, type_class):
gtk.ComboBoxEntry.__init__(self)
#we need to inherit and have an combobox with an entry
Gtk.Combobox.__init__(self, has_entry=True)
self.type_class = type_class
self.sel = StandardCustomSelector(type_class._I2SMAP, self,
type_class._CUSTOM,
@ -416,10 +417,10 @@ class MySelect(gtk.ComboBoxEntry):
# MyEntry
#
#-------------------------------------------------------------------------
class MyEntry(gtk.Entry):
class MyEntry(Gtk.Entry):
def __init__(self):
gtk.Entry.__init__(self)
GObject.GObject.__init__(self)
self.show()
#-------------------------------------------------------------------------
@ -450,7 +451,7 @@ class EditRule(ManagedWindow):
self.rname = self.get_widget('ruletree')
self.rule_name = self.get_widget('rulename')
self.notebook = gtk.Notebook()
self.notebook = Gtk.Notebook()
self.notebook.set_show_tabs(0)
self.notebook.set_show_border(0)
self.notebook.show()
@ -485,24 +486,24 @@ class EditRule(ManagedWindow):
tlist = []
self.page.append((class_obj, vallist, tlist))
pos = 0
l2 = gtk.Label(class_obj.name)
l2 = Gtk.Label(label=class_obj.name)
l2.set_alignment(0, 0.5)
l2.show()
c = gtk.TreeView()
c = Gtk.TreeView()
c.set_data('d', pos)
c.show()
the_map[class_obj] = c
# Only add a table with parameters if there are any parameters
if arglist:
table = gtk.Table(3, len(arglist))
table = Gtk.Table(3, len(arglist))
else:
table = gtk.Table(1, 1)
table = Gtk.Table(1, 1)
table.set_border_width(6)
table.set_col_spacings(6)
table.set_row_spacings(6)
table.show()
for v in arglist:
l = gtk.Label(v)
l = Gtk.Label(label=v)
l.set_alignment(1, 0.5)
l.show()
if v == _('Place:'):
@ -555,21 +556,21 @@ class EditRule(ManagedWindow):
else:
t = MyEntry()
tlist.append(t)
table.attach(l, 1, 2, pos, pos+1, gtk.FILL, 0, 5, 5)
table.attach(t, 2, 3, pos, pos+1, gtk.EXPAND|gtk.FILL, 0, 5, 5)
table.attach(l, 1, 2, pos, pos+1, Gtk.AttachOptions.FILL, 0, 5, 5)
table.attach(t, 2, 3, pos, pos+1, Gtk.AttachOptions.EXPAND|Gtk.AttachOptions.FILL, 0, 5, 5)
pos += 1
# put the table into a scrollable area:
scrolled_win = gtk.ScrolledWindow()
scrolled_win = Gtk.ScrolledWindow()
scrolled_win.add_with_viewport(table)
scrolled_win.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
scrolled_win.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)
scrolled_win.show()
self.notebook.append_page(scrolled_win, gtk.Label(class_obj.name))
self.notebook.append_page(scrolled_win, Gtk.Label(label=class_obj.name))
self.class2page[class_obj] = self.page_num
self.page_num = self.page_num + 1
self.page_num = 0
self.store = gtk.TreeStore(gobject.TYPE_STRING, gobject.TYPE_PYOBJECT)
self.store = Gtk.TreeStore(GObject.TYPE_STRING, GObject.TYPE_PYOBJECT)
self.selection = self.rname.get_selection()
col = gtk.TreeViewColumn(_('Rule Name'), gtk.CellRendererText(),
col = Gtk.TreeViewColumn(_('Rule Name'), Gtk.CellRendererText(),
text=0)
self.rname.append_column(col)
self.rname.set_model(self.store)
@ -640,11 +641,11 @@ class EditRule(ManagedWindow):
self.selection.select_iter(iter)
def _button_press(self, obj, event):
if event.type == gtk.gdk._2BUTTON_PRESS and event.button == 1:
if event.type == Gdk.EventType._2BUTTON_PRESS and event.button == 1:
return self.expand_collapse()
def _key_press(self, obj, event):
if event.keyval in (gtk.keysyms.Return, gtk.keysyms.KP_Enter):
if event.keyval in (Gdk.KEY_Return, Gdk.KEY_KP_Enter):
return self.expand_collapse()
return False
@ -886,16 +887,16 @@ class ShowResults(ManagedWindow):
self.get_widget('test_title'),
_('Filter Test'))
render = gtk.CellRendererText()
render = Gtk.CellRendererText()
tree = self.get_widget('list')
model = gtk.ListStore(gobject.TYPE_STRING, gobject.TYPE_STRING)
model = Gtk.ListStore(GObject.TYPE_STRING, GObject.TYPE_STRING)
tree.set_model(model)
column_n = gtk.TreeViewColumn(_('Name'), render, text=0)
column_n = Gtk.TreeViewColumn(_('Name'), render, text=0)
tree.append_column(column_n)
column_n = gtk.TreeViewColumn(_('ID'), render, text=1)
column_n = Gtk.TreeViewColumn(_('ID'), render, text=1)
tree.append_column(column_n)
self.get_widget('test_close').connect('clicked', self.close)

View File

@ -36,8 +36,8 @@ _LOG = logging.getLogger(".objectentries")
# GTK/Gnome modules
#
#-------------------------------------------------------------------------
import gtk
from pango import ELLIPSIZE_END
from gi.repository import Gtk
from gi.repository import Pango
#-------------------------------------------------------------------------
#
@ -73,13 +73,13 @@ class ObjEntry(object):
def __init__(self, dbstate, uistate, track, label, set_val,
get_val, add_edt, share):
"""Pass the dbstate and uistate and present track.
label is a gtk.Label that shows the persent value
label is a Gtk.Label that shows the persent value
set_val is function that is called when handle changes, use it
to update the calling module
get_val is function that is called to obtain handle from calling
module
share is the gtk.Button to call the object selector or del connect
add_edt is the gtk.Button with add or edit value. Pass None if
share is the Gtk.Button to call the object selector or del connect
add_edt is the Gtk.Button with add or edit value. Pass None if
this button should not be present.
"""
self.label = label
@ -133,7 +133,7 @@ class ObjEntry(object):
self.label.set_use_markup(True)
else:
self.label.set_text(name)
self.label.set_ellipsize(ELLIPSIZE_END)
self.label.set_ellipsize(Pango.ELLIPSIZE_END)
def _init_dnd(self):
"""inheriting objects must set this
@ -217,26 +217,26 @@ class ObjEntry(object):
self.share.remove(i)
if use_add:
image = gtk.Image()
image.set_from_stock(gtk.STOCK_REMOVE, gtk.ICON_SIZE_BUTTON)
image = Gtk.Image()
image.set_from_stock(Gtk.STOCK_REMOVE, Gtk.IconSize.BUTTON)
image.show()
self.share.add(image)
self.share.set_tooltip_text(self.DEL_STR)
if self.add_edt is not None:
image = gtk.Image()
image.set_from_stock(gtk.STOCK_EDIT, gtk.ICON_SIZE_BUTTON)
image = Gtk.Image()
image.set_from_stock(Gtk.STOCK_EDIT, Gtk.IconSize.BUTTON)
image.show()
self.add_edt.add(image)
self.add_edt.set_tooltip_text(self.EDIT_STR)
else:
image = gtk.Image()
image.set_from_stock(gtk.STOCK_INDEX, gtk.ICON_SIZE_BUTTON)
image = Gtk.Image()
image.set_from_stock(Gtk.STOCK_INDEX, Gtk.IconSize.BUTTON)
image.show()
self.share.add(image)
self.share.set_tooltip_text(self.SHARE_STR)
if self.add_edt is not None:
image = gtk.Image()
image.set_from_stock(gtk.STOCK_ADD, gtk.ICON_SIZE_BUTTON)
image = Gtk.Image()
image.set_from_stock(Gtk.STOCK_ADD, Gtk.IconSize.BUTTON)
image.show()
self.add_edt.add(image)
self.add_edt.set_tooltip_text(self.ADD_STR)
@ -262,8 +262,8 @@ class PlaceEntry(ObjEntry):
def _init_dnd(self):
"""connect drag and drop of places
"""
self.label.drag_dest_set(gtk.DEST_DEFAULT_ALL, [DdTargets.PLACE_LINK.target()],
gtk.gdk.ACTION_COPY)
self.label.drag_dest_set(Gtk.DestDefaults.ALL, [DdTargets.PLACE_LINK.target()],
Gdk.DragAction.COPY)
self.label.connect('drag_data_received', self.drag_data_received)
def get_from_handle(self, handle):
@ -313,8 +313,8 @@ class MediaEntry(ObjEntry):
def _init_dnd(self):
"""connect drag and drop of places
"""
self.label.drag_dest_set(gtk.DEST_DEFAULT_ALL, [DdTargets.MEDIAOBJ.target()],
gtk.gdk.ACTION_COPY)
self.label.drag_dest_set(Gtk.DestDefaults.ALL, [DdTargets.MEDIAOBJ.target()],
Gdk.DragAction.COPY)
self.label.connect('drag_data_received', self.drag_data_received)
def get_from_handle(self, handle):
@ -375,8 +375,8 @@ class NoteEntry(ObjEntry):
def _init_dnd(self):
"""connect drag and drop of places
"""
self.label.drag_dest_set(gtk.DEST_DEFAULT_ALL, [DdTargets.NOTE_LINK.target()],
gtk.gdk.ACTION_COPY)
self.label.drag_dest_set(Gtk.DestDefaults.ALL, [DdTargets.NOTE_LINK.target()],
Gdk.DragAction.COPY)
self.label.connect('drag_data_received', self.drag_data_received)
def get_from_handle(self, handle):

View File

@ -29,8 +29,8 @@ Package providing filtering framework for GRAMPS.
# GTK
#
#-------------------------------------------------------------------------
import gtk
import gobject
from gi.repository import Gtk
from gi.repository import GObject
#-------------------------------------------------------------------------
#
@ -44,12 +44,12 @@ from gen.filters import CustomFilters
# FilterComboBox
#
#-------------------------------------------------------------------------
class FilterComboBox(gtk.ComboBox):
class FilterComboBox(Gtk.ComboBox):
def set(self,local_filters,default=""):
self.store = gtk.ListStore(gobject.TYPE_STRING)
self.store = Gtk.ListStore(GObject.TYPE_STRING)
self.set_model(self.store)
cell = gtk.CellRendererText()
cell = Gtk.CellRendererText()
self.pack_start(cell,True)
self.add_attribute(cell,'text',0)

View File

@ -25,8 +25,8 @@
# GTK
#
#-------------------------------------------------------------------------
import gtk
import gobject
from gi.repository import Gtk
from gi.repository import GObject
#-------------------------------------------------------------------------
#
@ -36,7 +36,7 @@ import gobject
def build_filter_model(space, local = []):
from gen.filters import CustomFilters
model = gtk.ListStore(gobject.TYPE_STRING, object)
model = Gtk.ListStore(GObject.TYPE_STRING, object)
if isinstance(space, basestring):
flist = local + CustomFilters.get_filters(space)

View File

@ -29,7 +29,7 @@ Package providing filtering framework for GRAMPS.
# GTK
#
#-------------------------------------------------------------------------
import gtk
from gi.repository import Gtk
from gen.ggettext import gettext as _
#-------------------------------------------------------------------------
@ -44,10 +44,10 @@ from gen.filters import CustomFilters
# FilterStore
#
#-------------------------------------------------------------------------
class FilterStore(gtk.ListStore):
class FilterStore(Gtk.ListStore):
def __init__(self, local_filters=[], namespace="generic", default=""):
gtk.ListStore.__init__(self, str)
GObject.GObject.__init__(self, str)
self.list_map = []
self.def_index = 0

View File

@ -17,7 +17,7 @@
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
import gobject
from gi.repository import GObject
# $Id$
@ -30,11 +30,12 @@ Package providing filtering framework for GRAMPS.
# GTK
#
#-------------------------------------------------------------------------
import gtk
from gi.repository import Gdk
from gi.repository import Gtk
from gen.ggettext import gettext as _
_RETURN = gtk.gdk.keyval_from_name("Return")
_KP_ENTER = gtk.gdk.keyval_from_name("KP_Enter")
_RETURN = Gdk.keyval_from_name("Return")
_KP_ENTER = Gdk.keyval_from_name("KP_Enter")
#-------------------------------------------------------------------------
#
@ -50,14 +51,14 @@ class SearchBar(object):
self.apply_text = ''
self.visible = False
self.filterbar = gtk.HBox()
self.filter_text = gtk.Entry()
self.filter_button = gtk.Button(stock=gtk.STOCK_FIND)
self.clear_button = gtk.Button(stock=gtk.STOCK_CLEAR)
self.filter_list = gtk.ComboBox()
self.filter_model = gtk.ListStore(gobject.TYPE_STRING,
gobject.TYPE_INT,
gobject.TYPE_BOOLEAN)
self.filterbar = Gtk.HBox()
self.filter_text = Gtk.Entry()
self.filter_button = Gtk.Button(stock=Gtk.STOCK_FIND)
self.clear_button = Gtk.Button(stock=Gtk.STOCK_CLEAR)
self.filter_list = Gtk.ComboBox()
self.filter_model = Gtk.ListStore(GObject.TYPE_STRING,
GObject.TYPE_INT,
GObject.TYPE_BOOLEAN)
def destroy(self):
"""Unset all things that can block garbage collection.
@ -80,10 +81,10 @@ class SearchBar(object):
self.clear_button.connect( 'clicked', self.apply_clear)
self.clear_button.set_sensitive(False)
self.filterbar.pack_start(self.filter_list, False)
self.filterbar.pack_start(self.filter_text, True)
self.filterbar.pack_end(self.clear_button, False)
self.filterbar.pack_end(self.filter_button, False)
self.filterbar.pack_start(self.filter_list, False, True, 0)
self.filterbar.pack_start(self.filter_text, True, True, 0)
self.filterbar.pack_end(self.clear_button, False, True, 0)
self.filterbar.pack_end(self.filter_button, False, True, 0)
return self.filterbar
@ -95,7 +96,7 @@ class SearchBar(object):
self.filter_model.clear()
old_value = self.filter_list.get_active()
cell = gtk.CellRendererText()
cell = Gtk.CellRendererText()
self.filter_list.clear()
self.filter_list.pack_start(cell, True)
self.filter_list.add_attribute(cell, 'text', 0)
@ -138,7 +139,7 @@ class SearchBar(object):
self.clear_button.set_sensitive(True)
def key_press(self, obj, event):
if not (event.state & gtk.gdk.CONTROL_MASK):
if not (event.get_state() & Gdk.ModifierType.CONTROL_MASK):
if event.keyval in (_RETURN, _KP_ENTER):
self.filter_button.set_sensitive(False)
self.clear_button.set_sensitive(True)

View File

@ -33,7 +33,7 @@ from gen.ggettext import gettext as _
# gtk
#
#-------------------------------------------------------------------------
import gtk
from gi.repository import Gtk
#-------------------------------------------------------------------------
#
@ -59,34 +59,34 @@ class CitationSidebarFilter(SidebarFilter):
def __init__(self, dbstate, uistate, clicked):
self.clicked_func = clicked
self.filter_id = gtk.Entry()
self.filter_page = gtk.Entry()
self.filter_date = gtk.Entry()
self.filter_id = Gtk.Entry()
self.filter_page = Gtk.Entry()
self.filter_date = Gtk.Entry()
self.filter_conf = gtk.ComboBox()
model = gtk.ListStore(str)
self.filter_conf = Gtk.ComboBox()
model = Gtk.ListStore(str)
for conf_value in sorted(confidence.keys()):
model.append((confidence[conf_value],))
self.filter_conf.set_model(model)
self.filter_conf.set_active(2) # gen.lib.Citation.CONF_NORMAL
self.filter_note = gtk.Entry()
self.filter_note = Gtk.Entry()
self.filter_regex = gtk.CheckButton(_('Use regular expressions'))
self.filter_regex = Gtk.CheckButton(_('Use regular expressions'))
self.generic = gtk.ComboBox()
self.generic = Gtk.ComboBox()
SidebarFilter.__init__(self, dbstate, uistate, "Citation")
def create_widget(self):
cell = gtk.CellRendererText()
cell = Gtk.CellRendererText()
cell.set_property('width', self._FILTER_WIDTH)
cell.set_property('ellipsize', self._FILTER_ELLIPSIZE)
self.generic.pack_start(cell, True)
self.generic.add_attribute(cell, 'text', 0)
self.on_filters_changed('Citation')
cell = gtk.CellRendererText()
cell = Gtk.CellRendererText()
cell.set_property('width', self._FILTER_WIDTH)
cell.set_property('ellipsize', self._FILTER_ELLIPSIZE)
self.filter_conf.pack_start(cell, True)

View File

@ -32,7 +32,7 @@ from gen.ggettext import gettext as _
# gtk
#
#-------------------------------------------------------------------------
import gtk
from gi.repository import Gtk
#-------------------------------------------------------------------------
#
@ -62,7 +62,7 @@ class EventSidebarFilter(SidebarFilter):
self.filter_desc = widgets.BasicEntry()
self.filter_event = gen.lib.Event()
self.filter_event.set_type((gen.lib.EventType.CUSTOM, u''))
self.etype = gtk.ComboBoxEntry()
self.etype = Gtk.ComboBox(has_entry=True)
self.event_menu = widgets.MonitoredDataType(
self.etype,
@ -74,21 +74,21 @@ class EventSidebarFilter(SidebarFilter):
self.filter_place = widgets.BasicEntry()
self.filter_note = widgets.BasicEntry()
self.filter_regex = gtk.CheckButton(_('Use regular expressions'))
self.filter_regex = Gtk.CheckButton(_('Use regular expressions'))
self.generic = gtk.ComboBox()
self.generic = Gtk.ComboBox()
SidebarFilter.__init__(self, dbstate, uistate, "Event")
def create_widget(self):
cell = gtk.CellRendererText()
cell = Gtk.CellRendererText()
cell.set_property('width', self._FILTER_WIDTH)
cell.set_property('ellipsize', self._FILTER_ELLIPSIZE)
self.generic.pack_start(cell, True)
self.generic.add_attribute(cell, 'text', 0)
self.on_filters_changed('Event')
self.etype.child.set_width_chars(5)
self.etype.get_child().set_width_chars(5)
self.add_text_entry(_('ID'), self.filter_id)
self.add_text_entry(_('Description'), self.filter_desc)
@ -107,7 +107,7 @@ class EventSidebarFilter(SidebarFilter):
self.filter_date.set_text(u'')
self.filter_place.set_text(u'')
self.filter_note.set_text(u'')
self.etype.child.set_text(u'')
self.etype.get_child().set_text(u'')
self.generic.set_active(0)
def get_filter(self):

View File

@ -33,7 +33,7 @@ from gen.ggettext import gettext as _
# gtk
#
#-------------------------------------------------------------------------
import gtk
from gi.repository import Gtk
#-------------------------------------------------------------------------
#
@ -69,11 +69,11 @@ class FamilySidebarFilter(SidebarFilter):
self.filter_event = gen.lib.Event()
self.filter_event.set_type((gen.lib.EventType.CUSTOM, u''))
self.etype = gtk.ComboBoxEntry()
self.etype = Gtk.ComboBox(has_entry=True)
self.family_stub = gen.lib.Family()
self.family_stub.set_relationship((gen.lib.FamilyRelType.CUSTOM, u''))
self.rtype = gtk.ComboBoxEntry()
self.rtype = Gtk.ComboBox(has_entry=True)
self.event_menu = widgets.MonitoredDataType(
self.etype,
@ -87,29 +87,29 @@ class FamilySidebarFilter(SidebarFilter):
self.filter_note = widgets.BasicEntry()
self.filter_regex = gtk.CheckButton(_('Use regular expressions'))
self.filter_regex = Gtk.CheckButton(_('Use regular expressions'))
self.tag = gtk.ComboBox()
self.generic = gtk.ComboBox()
self.tag = Gtk.ComboBox()
self.generic = Gtk.ComboBox()
SidebarFilter.__init__(self, dbstate, uistate, "Family")
def create_widget(self):
cell = gtk.CellRendererText()
cell = Gtk.CellRendererText()
cell.set_property('width', self._FILTER_WIDTH)
cell.set_property('ellipsize', self._FILTER_ELLIPSIZE)
self.generic.pack_start(cell, True)
self.generic.add_attribute(cell, 'text', 0)
self.on_filters_changed('Family')
cell = gtk.CellRendererText()
cell = Gtk.CellRendererText()
cell.set_property('width', self._FILTER_WIDTH)
cell.set_property('ellipsize', self._FILTER_ELLIPSIZE)
self.tag.pack_start(cell, True)
self.tag.add_attribute(cell, 'text', 0)
self.etype.child.set_width_chars(5)
self.rtype.child.set_width_chars(5)
self.etype.get_child().set_width_chars(5)
self.rtype.get_child().set_width_chars(5)
self.add_text_entry(_('ID'), self.filter_id)
self.add_text_entry(_('Father'), self.filter_father)
@ -128,8 +128,8 @@ class FamilySidebarFilter(SidebarFilter):
self.filter_mother.set_text(u'')
self.filter_child.set_text(u'')
self.filter_note.set_text(u'')
self.etype.child.set_text(u'')
self.rtype.child.set_text(u'')
self.etype.get_child().set_text(u'')
self.rtype.get_child().set_text(u'')
self.tag.set_active(0)
self.generic.set_active(0)
@ -223,7 +223,7 @@ class FamilySidebarFilter(SidebarFilter):
"""
Update the list of tags in the tag filter.
"""
model = gtk.ListStore(str)
model = Gtk.ListStore(str)
model.append(('',))
for tag_name in tag_list:
model.append((tag_name,))

View File

@ -33,7 +33,7 @@ from gen.ggettext import gettext as _
# gtk
#
#-------------------------------------------------------------------------
import gtk
from gi.repository import Gtk
#-------------------------------------------------------------------------
#
@ -65,22 +65,22 @@ class MediaSidebarFilter(SidebarFilter):
self.filter_date = widgets.BasicEntry()
self.filter_note = widgets.BasicEntry()
self.filter_regex = gtk.CheckButton(_('Use regular expressions'))
self.filter_regex = Gtk.CheckButton(_('Use regular expressions'))
self.tag = gtk.ComboBox()
self.generic = gtk.ComboBox()
self.tag = Gtk.ComboBox()
self.generic = Gtk.ComboBox()
SidebarFilter.__init__(self, dbstate, uistate, "Media")
def create_widget(self):
cell = gtk.CellRendererText()
cell = Gtk.CellRendererText()
cell.set_property('width', self._FILTER_WIDTH)
cell.set_property('ellipsize', self._FILTER_ELLIPSIZE)
self.generic.pack_start(cell, True)
self.generic.add_attribute(cell, 'text', 0)
self.on_filters_changed('Media')
cell = gtk.CellRendererText()
cell = Gtk.CellRendererText()
cell.set_property('width', self._FILTER_WIDTH)
cell.set_property('ellipsize', self._FILTER_ELLIPSIZE)
self.tag.pack_start(cell, True)
@ -169,7 +169,7 @@ class MediaSidebarFilter(SidebarFilter):
"""
Update the list of tags in the tag filter.
"""
model = gtk.ListStore(str)
model = Gtk.ListStore(str)
model.append(('',))
for tag_name in tag_list:
model.append((tag_name,))

View File

@ -33,7 +33,7 @@ from gen.ggettext import gettext as _
# gtk
#
#-------------------------------------------------------------------------
import gtk
from gi.repository import Gtk
#-------------------------------------------------------------------------
#
@ -63,34 +63,34 @@ class NoteSidebarFilter(SidebarFilter):
self.note = Note()
self.note.set_type((NoteType.CUSTOM,''))
self.ntype = gtk.ComboBoxEntry()
self.ntype = Gtk.ComboBox(has_entry=True)
self.event_menu = widgets.MonitoredDataType(
self.ntype,
self.note.set_type,
self.note.get_type)
self.filter_regex = gtk.CheckButton(_('Use regular expressions'))
self.filter_regex = Gtk.CheckButton(_('Use regular expressions'))
self.tag = gtk.ComboBox()
self.generic = gtk.ComboBox()
self.tag = Gtk.ComboBox()
self.generic = Gtk.ComboBox()
SidebarFilter.__init__(self, dbstate, uistate, "Note")
def create_widget(self):
cell = gtk.CellRendererText()
cell = Gtk.CellRendererText()
cell.set_property('width', self._FILTER_WIDTH)
cell.set_property('ellipsize', self._FILTER_ELLIPSIZE)
self.generic.pack_start(cell, True)
self.generic.add_attribute(cell, 'text', 0)
self.on_filters_changed('Note')
cell = gtk.CellRendererText()
cell = Gtk.CellRendererText()
cell.set_property('width', self._FILTER_WIDTH)
cell.set_property('ellipsize', self._FILTER_ELLIPSIZE)
self.tag.pack_start(cell, True)
self.tag.add_attribute(cell, 'text', 0)
self.ntype.child.set_width_chars(5)
self.ntype.get_child().set_width_chars(5)
self.add_text_entry(_('ID'), self.filter_id)
self.add_text_entry(_('Text'), self.filter_text)
@ -102,7 +102,7 @@ class NoteSidebarFilter(SidebarFilter):
def clear(self, obj):
self.filter_id.set_text('')
self.filter_text.set_text('')
self.ntype.child.set_text('')
self.ntype.get_child().set_text('')
self.tag.set_active(0)
self.generic.set_active(0)
@ -158,7 +158,7 @@ class NoteSidebarFilter(SidebarFilter):
"""
Update the list of tags in the tag filter.
"""
model = gtk.ListStore(str)
model = Gtk.ListStore(str)
model.append(('',))
for tag_name in tag_list:
model.append((tag_name,))

View File

@ -34,7 +34,7 @@ import locale
# gtk
#
#-------------------------------------------------------------------------
import gtk
from gi.repository import Gtk
#-------------------------------------------------------------------------
#
@ -79,40 +79,40 @@ class PersonSidebarFilter(SidebarFilter):
self.filter_death = widgets.BasicEntry()
self.filter_event = gen.lib.Event()
self.filter_event.set_type((gen.lib.EventType.CUSTOM, u''))
self.etype = gtk.ComboBoxEntry()
self.etype = Gtk.ComboBox(has_entry=True)
self.event_menu = widgets.MonitoredDataType(
self.etype,
self.filter_event.set_type,
self.filter_event.get_type)
self.filter_note = widgets.BasicEntry()
self.filter_gender = gtk.combo_box_new_text()
self.filter_gender = Gtk.ComboBoxText()
map(self.filter_gender.append_text,
[ _('any'), _('male'), _('female'), _('unknown') ])
self.filter_gender.set_active(0)
self.filter_regex = gtk.CheckButton(_('Use regular expressions'))
self.filter_regex = Gtk.CheckButton(_('Use regular expressions'))
self.tag = gtk.ComboBox()
self.generic = gtk.ComboBox()
self.tag = Gtk.ComboBox()
self.generic = Gtk.ComboBox()
SidebarFilter.__init__(self, dbstate, uistate, "Person")
def create_widget(self):
cell = gtk.CellRendererText()
cell = Gtk.CellRendererText()
cell.set_property('width', self._FILTER_WIDTH)
cell.set_property('ellipsize', self._FILTER_ELLIPSIZE)
self.generic.pack_start(cell, True)
self.generic.add_attribute(cell, 'text', 0)
self.on_filters_changed('Person')
cell = gtk.CellRendererText()
cell = Gtk.CellRendererText()
cell.set_property('width', self._FILTER_WIDTH)
cell.set_property('ellipsize', self._FILTER_ELLIPSIZE)
self.tag.pack_start(cell, True)
self.tag.add_attribute(cell, 'text', 0)
self.etype.child.set_width_chars(5)
self.etype.get_child().set_width_chars(5)
exdate1 = gen.lib.Date()
exdate2 = gen.lib.Date()
@ -145,7 +145,7 @@ class PersonSidebarFilter(SidebarFilter):
self.filter_death.set_text(u'')
self.filter_note.set_text(u'')
self.filter_gender.set_active(0)
self.etype.child.set_text(u'')
self.etype.get_child().set_text(u'')
self.tag.set_active(0)
self.generic.set_active(0)
@ -262,7 +262,7 @@ class PersonSidebarFilter(SidebarFilter):
"""
Update the list of tags in the tag filter.
"""
model = gtk.ListStore(str)
model = Gtk.ListStore(str)
model.append(('',))
for tag_name in tag_list:
model.append((tag_name,))

View File

@ -34,7 +34,7 @@ from gen.ggettext import gettext as _
# gtk
#
#-------------------------------------------------------------------------
import gtk
from gi.repository import Gtk
#-------------------------------------------------------------------------
#
@ -72,13 +72,13 @@ class PlaceSidebarFilter(SidebarFilter):
self.filter_parish = widgets.BasicEntry()
self.filter_note = widgets.BasicEntry()
self.filter_regex = gtk.CheckButton(_('Use regular expressions'))
self.generic = gtk.ComboBox()
self.filter_regex = Gtk.CheckButton(_('Use regular expressions'))
self.generic = Gtk.ComboBox()
SidebarFilter.__init__(self, dbstate, uistate, "Place")
def create_widget(self):
cell = gtk.CellRendererText()
cell = Gtk.CellRendererText()
cell.set_property('width', self._FILTER_WIDTH)
cell.set_property('ellipsize', self._FILTER_ELLIPSIZE)
self.generic.pack_start(cell, True)

View File

@ -32,7 +32,7 @@ from gen.ggettext import gettext as _
# gtk
#
#-------------------------------------------------------------------------
import gtk
from gi.repository import Gtk
#-------------------------------------------------------------------------
#
@ -65,7 +65,7 @@ class RepoSidebarFilter(SidebarFilter):
self.repo = Repository()
self.repo.set_type((RepositoryType.CUSTOM,''))
self.rtype = gtk.ComboBoxEntry()
self.rtype = Gtk.ComboBox(has_entry=True)
self.event_menu = widgets.MonitoredDataType(
self.rtype,
self.repo.set_type,
@ -73,21 +73,21 @@ class RepoSidebarFilter(SidebarFilter):
self.filter_note = widgets.BasicEntry()
self.filter_regex = gtk.CheckButton(_('Use regular expressions'))
self.filter_regex = Gtk.CheckButton(_('Use regular expressions'))
self.generic = gtk.ComboBox()
self.generic = Gtk.ComboBox()
SidebarFilter.__init__(self, dbstate, uistate, "Repository")
def create_widget(self):
cell = gtk.CellRendererText()
cell = Gtk.CellRendererText()
cell.set_property('width', self._FILTER_WIDTH)
cell.set_property('ellipsize', self._FILTER_ELLIPSIZE)
self.generic.pack_start(cell, True)
self.generic.add_attribute(cell, 'text', 0)
self.on_filters_changed('Repository')
self.rtype.child.set_width_chars(5)
self.rtype.get_child().set_width_chars(5)
self.add_text_entry(_('ID'), self.filter_id)
self.add_text_entry(_('Name'), self.filter_title)
@ -103,7 +103,7 @@ class RepoSidebarFilter(SidebarFilter):
self.filter_title.set_text('')
self.filter_address.set_text('')
self.filter_url.set_text('')
self.rtype.child.set_text('')
self.rtype.get_child().set_text('')
self.filter_note.set_text('')
self.generic.set_active(0)

View File

@ -23,19 +23,20 @@
from gen.ggettext import gettext as _
from bisect import insort_left
import gtk
import pango
from gi.repository import Gdk
from gi.repository import Gtk
from gi.repository import Pango
from gui import widgets
from gui.dbguielement import DbGUIElement
from gen.config import config
_RETURN = gtk.gdk.keyval_from_name("Return")
_KP_ENTER = gtk.gdk.keyval_from_name("KP_Enter")
_RETURN = Gdk.keyval_from_name("Return")
_KP_ENTER = Gdk.keyval_from_name("KP_Enter")
class SidebarFilter(DbGUIElement):
_FILTER_WIDTH = 20
_FILTER_ELLIPSIZE = pango.ELLIPSIZE_END
_FILTER_ELLIPSIZE = Pango.EllipsizeMode.END
def __init__(self, dbstate, uistate, namespace):
self.signal_map = {
@ -47,15 +48,15 @@ class SidebarFilter(DbGUIElement):
DbGUIElement.__init__(self, dbstate.db)
self.position = 1
self.vbox = gtk.VBox()
self.table = gtk.Table(4, 11)
self.vbox.pack_start(self.table, False, False)
self.vbox = Gtk.VBox()
self.table = Gtk.Table(4, 11)
self.vbox.pack_start(self.table, False, False, 0)
self.table.set_border_width(6)
self.table.set_row_spacings(6)
self.table.set_col_spacing(0, 6)
self.table.set_col_spacing(1, 6)
self.apply_btn = gtk.Button(stock=gtk.STOCK_FIND)
self.clear_btn = gtk.Button()
self.apply_btn = Gtk.Button(stock=Gtk.STOCK_FIND)
self.clear_btn = Gtk.Button()
self._init_interface()
uistate.connect('filters-changed', self.on_filters_changed)
@ -71,28 +72,28 @@ class SidebarFilter(DbGUIElement):
self.apply_btn.connect('clicked', self.clicked)
hbox = gtk.HBox()
hbox = Gtk.HBox()
hbox.show()
image = gtk.Image()
image.set_from_stock(gtk.STOCK_UNDO, gtk.ICON_SIZE_BUTTON)
image = Gtk.Image()
image.set_from_stock(Gtk.STOCK_UNDO, Gtk.IconSize.BUTTON)
image.show()
label = gtk.Label(_('Reset'))
label = Gtk.Label(label=_('Reset'))
label.show()
hbox.pack_start(image, False, False)
hbox.pack_start(image, False, False, 0)
hbox.pack_start(label, False, True)
hbox.set_spacing(4)
self.clear_btn.add(hbox)
self.clear_btn.connect('clicked', self.clear)
hbox = gtk.HButtonBox()
hbox.set_layout(gtk.BUTTONBOX_START)
hbox = Gtk.HButtonBox()
hbox.set_layout(Gtk.ButtonBoxStyle.START)
hbox.set_spacing(6)
hbox.set_border_width(12)
hbox.add(self.apply_btn)
hbox.add(self.clear_btn)
hbox.show()
self.vbox.pack_start(hbox, False, False)
self.vbox.pack_start(hbox, False, False, 0)
self.vbox.show()
def get_widget(self):
@ -116,9 +117,9 @@ class SidebarFilter(DbGUIElement):
pass
def add_regex_entry(self, widget):
hbox = gtk.HBox()
hbox = Gtk.HBox()
hbox.pack_start(widget, False, False, 12)
self.vbox.pack_start(hbox, False, False)
self.vbox.pack_start(hbox, False, False, 0)
def add_text_entry(self, name, widget, tooltip=None):
self.add_entry(name, widget)
@ -127,7 +128,7 @@ class SidebarFilter(DbGUIElement):
widget.set_tooltip_text(tooltip)
def key_press(self, obj, event):
if not (event.state & gtk.gdk.CONTROL_MASK):
if not (event.get_state() & Gdk.ModifierType.CONTROL_MASK):
if event.keyval in (_RETURN, _KP_ENTER):
self.clicked(obj)
return False
@ -136,9 +137,9 @@ class SidebarFilter(DbGUIElement):
if name:
self.table.attach(widgets.BasicLabel(name),
1, 2, self.position, self.position+1,
xoptions=gtk.FILL, yoptions=0)
xoptions=Gtk.AttachOptions.FILL, yoptions=0)
self.table.attach(widget, 2, 4, self.position, self.position+1,
xoptions=gtk.FILL|gtk.EXPAND, yoptions=0)
xoptions=Gtk.AttachOptions.FILL|Gtk.AttachOptions.EXPAND, yoptions=0)
self.position += 1
def on_filters_changed(self, namespace):
@ -216,9 +217,9 @@ class SidebarFilter(DbGUIElement):
"""
Adds the text and widget to GUI, with an Edit button.
"""
hbox = gtk.HBox()
hbox.pack_start(widget, True, True)
hbox.pack_start(widgets.SimpleButton(gtk.STOCK_EDIT, self.edit_filter), False, False)
hbox = Gtk.HBox()
hbox.pack_start(widget, True, True, 0)
hbox.pack_start(widgets.SimpleButton(Gtk.STOCK_EDIT, self.edit_filter), False, False)
self.add_entry(text, hbox)
def edit_filter(self, obj):

View File

@ -32,7 +32,7 @@ from gen.ggettext import gettext as _
# gtk
#
#-------------------------------------------------------------------------
import gtk
from gi.repository import Gtk
#-------------------------------------------------------------------------
#
@ -64,14 +64,14 @@ class SourceSidebarFilter(SidebarFilter):
self.filter_pub = widgets.BasicEntry()
self.filter_note = widgets.BasicEntry()
self.filter_regex = gtk.CheckButton(_('Use regular expressions'))
self.filter_regex = Gtk.CheckButton(_('Use regular expressions'))
self.generic = gtk.ComboBox()
self.generic = Gtk.ComboBox()
SidebarFilter.__init__(self, dbstate, uistate, "Source")
def create_widget(self):
cell = gtk.CellRendererText()
cell = Gtk.CellRendererText()
cell.set_property('width', self._FILTER_WIDTH)
cell.set_property('ellipsize', self._FILTER_ELLIPSIZE)
self.generic.pack_start(cell, True)

View File

@ -40,7 +40,8 @@ This module exports the Glade class.
#------------------------------------------------------------------------
import sys
import os
import gtk
from gi.repository import GObject
from gi.repository import Gtk
#------------------------------------------------------------------------
#
@ -52,13 +53,13 @@ import TransUtils
#------------------------------------------------------------------------
#
# Glade class. Derived from gtk.Builder
# Glade class. Derived from Gtk.Builder
#
#------------------------------------------------------------------------
class Glade(gtk.Builder):
class Glade(Gtk.Builder):
"""
Glade class: Manage glade files as gtk.Builder objects
Glade class: Manage glade files as Gtk.Builder objects
"""
__slots__ = ['__toplevel', '__filename', '__dirname']
@ -79,7 +80,7 @@ class Glade(gtk.Builder):
:rtype: object reference
:returns: reference to the newly-created Glade instance
"""
gtk.Builder.__init__(self)
GObject.GObject.__init__(self)
self.set_translation_domain(TransUtils.LOCALEDOMAIN)
filename_given = filename is not None
@ -212,7 +213,7 @@ class Glade(gtk.Builder):
queue = [toplevel]
while queue:
obj = queue.pop(0)
obj_id = gtk.Buildable.get_name(obj)
obj_id = Gtk.Buildable.get_name(obj)
if obj_id == value:
return obj
if hasattr(obj, 'get_children'):

View File

@ -21,16 +21,16 @@
# glade/catalog/grampswidgets.py
# $Id$
import gtk
from gi.repository import Gtk
class ValidatableMaskedEntry(gtk.Entry):
class ValidatableMaskedEntry(Gtk.Entry):
__gtype_name__ = 'ValidatableMaskedEntry'
class UndoableEntry(gtk.Entry):
class UndoableEntry(Gtk.Entry):
__gtype_name__ = 'UndoableEntry'
class StyledTextEditor(gtk.TextView):
class StyledTextEditor(Gtk.TextView):
__gtype_name__ = 'StyledTextEditor'
class UndoableBuffer(gtk.TextBuffer):
class UndoableBuffer(Gtk.TextBuffer):
__gtype_name__ = 'UndoableBuffer'

View File

@ -1,5 +1,6 @@
<glade-catalog name="grampswidgets" library="gladepython"
domain="glade-3" depends="gtk+">
<?xml version="1.0" encoding="UTF-8"?>
<glade-catalog name="grampswidgets" library="gladepython"
domain="glade" depends="gtk+">
<init-function>glade_python_init</init-function>
<glade-widget-classes>
<glade-widget-class

View File

@ -1,31 +1,105 @@
<?xml version="1.0" encoding="UTF-8"?>
<interface>
<!-- interface-requires gtk+ 2.12 -->
<!-- interface-requires grampswidgets 0.0 -->
<!-- interface-naming-policy toplevel-contextual -->
<!-- interface-requires gtk+ 3.0 -->
<object class="GtkDialog" id="editperson">
<property name="can_focus">False</property>
<property name="has_focus">True</property>
<property name="default_height">500</property>
<property name="type_hint">dialog</property>
<signal name="delete_event" handler="on_delete_event"/>
<signal name="delete-event" handler="on_delete_event" swapped="no"/>
<child internal-child="vbox">
<object class="GtkVBox" id="vbox">
<object class="GtkBox" id="vbox">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="orientation">vertical</property>
<child internal-child="action_area">
<object class="GtkButtonBox" id="hbuttonbox1">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="layout_style">end</property>
<child>
<object class="GtkButton" id="button15">
<property name="label">gtk-cancel</property>
<property name="use_action_appearance">False</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="can_default">True</property>
<property name="receives_default">False</property>
<property name="tooltip_text" translatable="yes">Abandon changes and close window</property>
<property name="use_action_appearance">False</property>
<property name="use_stock">True</property>
<signal name="clicked" handler="destroy_passed_object" object="editperson" swapped="yes"/>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkButton" id="ok">
<property name="label">gtk-ok</property>
<property name="use_action_appearance">False</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="can_default">True</property>
<property name="receives_default">False</property>
<property name="tooltip_text" translatable="yes">Accept changes and close window</property>
<property name="use_action_appearance">False</property>
<property name="use_stock">True</property>
<signal name="clicked" handler="on_apply_person_clicked" object="editperson" swapped="yes"/>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">1</property>
</packing>
</child>
<child>
<object class="GtkButton" id="button134">
<property name="label">gtk-help</property>
<property name="use_action_appearance">False</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="can_default">True</property>
<property name="receives_default">False</property>
<property name="use_action_appearance">False</property>
<property name="use_stock">True</property>
<signal name="clicked" handler="on_help_person_clicked" swapped="no"/>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">2</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="pack_type">end</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkEventBox" id="eventboxtop">
<property name="visible">True</property>
<property name="can_focus">False</property>
<child>
<object class="GtkVBox" id="vbox1">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="border_width">3</property>
<child>
<object class="GtkTable" id="table3">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="n_rows">8</property>
<property name="n_columns">9</property>
<child>
<object class="GtkLabel" id="label21">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="xalign">0</property>
<property name="xpad">3</property>
<property name="ypad">3</property>
@ -68,6 +142,7 @@
<child>
<object class="GtkLabel" id="label444">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">C_all:</property>
<property name="use_underline">True</property>
@ -103,6 +178,7 @@
<child>
<object class="GtkLabel" id="titlelabel">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="xalign">0</property>
<property name="xpad">3</property>
<property name="ypad">3</property>
@ -164,6 +240,7 @@
<child>
<object class="GtkLabel" id="label6">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="xalign">0</property>
<property name="xpad">3</property>
<property name="label" translatable="yes">_Nick:</property>
@ -201,6 +278,7 @@
<property name="width_request">114</property>
<property name="height_request">114</property>
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label_xalign">2.2351741291171123e-10</property>
<child internal-child="accessible">
<object class="AtkObject" id="frame5-atkobject">
@ -210,9 +288,11 @@
<child>
<object class="GtkEventBox" id="eventbox1">
<property name="visible">True</property>
<property name="can_focus">False</property>
<child>
<object class="GtkImage" id="personPix">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="yalign">0</property>
</object>
</child>
@ -221,6 +301,7 @@
<child type="label">
<object class="GtkLabel" id="label270">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">&lt;b&gt;Image&lt;/b&gt;</property>
<property name="use_markup">True</property>
</object>
@ -236,6 +317,7 @@
<child>
<object class="GtkLabel" id="label269">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="xalign">0</property>
<property name="xpad">3</property>
<property name="ypad">3</property>
@ -255,10 +337,17 @@
</packing>
</child>
<child>
<object class="GtkComboBoxEntry" id="ntype">
<object class="GtkComboBox" id="ntype">
<property name="width_request">100</property>
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="tooltip_text" translatable="yes">An identification of what type of Name this is, eg. Birth Name, Married Name.</property>
<property name="has_entry">True</property>
<child internal-child="entry">
<object class="GtkEntry" id="ntype-entry">
<property name="can_focus">False</property>
</object>
</child>
</object>
<packing>
<property name="left_attach">7</property>
@ -273,6 +362,7 @@
<child>
<object class="GtkHBox" id="hboxmultsurnames">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="tooltip_text" translatable="yes">Click on a table cell to edit.</property>
<child>
<placeholder/>
@ -292,11 +382,13 @@
</child>
<child>
<object class="GtkButton" id="multsurnamebtn">
<property name="use_action_appearance">False</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="tooltip_text" translatable="yes">Use Multiple Surnames
Indicate that the surname consists of different parts. Every surname has its own prefix and a possible connector to the next surname. Eg., the surname Ramón y Cajal can be stored as Ramón, which is inherited from the father, the connector y, and Cajal, which is inherited from the mother.</property>
<property name="use_action_appearance">False</property>
<property name="image">image2</property>
<property name="use_underline">True</property>
<accelerator key="a" signal="activate" modifiers="GDK_CONTROL_MASK"/>
@ -318,9 +410,11 @@ Indicate that the surname consists of different parts. Every surname has its own
<child>
<object class="GtkHBox" id="hbox1">
<property name="visible">True</property>
<property name="can_focus">False</property>
<child>
<object class="GtkLabel" id="label3">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="xalign">0</property>
<property name="ypad">3</property>
<property name="label" translatable="yes">&lt;b&gt;General&lt;/b&gt;</property>
@ -328,15 +422,18 @@ Indicate that the surname consists of different parts. Every surname has its own
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkToggleButton" id="private">
<property name="use_action_appearance">False</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="tooltip_text" translatable="yes">Set person as private data</property>
<property name="use_action_appearance">False</property>
<property name="relief">none</property>
<property name="xalign">1</property>
<accelerator key="p" signal="activate" modifiers="GDK_CONTROL_MASK"/>
@ -348,6 +445,7 @@ Indicate that the surname consists of different parts. Every surname has its own
<child>
<object class="GtkImage" id="image3">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="pixel_size">16</property>
<property name="icon_name">gtk-dialog-authentication</property>
<child internal-child="accessible">
@ -378,15 +476,19 @@ Indicate that the surname consists of different parts. Every surname has its own
<child>
<object class="GtkHBox" id="hbox3">
<property name="visible">True</property>
<property name="can_focus">False</property>
<child>
<object class="GtkLabel" id="label2">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="xalign">0</property>
<property name="ypad">3</property>
<property name="label" translatable="yes">&lt;b&gt;Preferred Name &lt;/b&gt;</property>
<property name="use_markup">True</property>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
@ -404,10 +506,12 @@ Indicate that the surname consists of different parts. Every surname has its own
<child>
<object class="GtkHBox" id="hbox4">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="spacing">6</property>
<child>
<object class="GtkLabel" id="surnamelabel">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">_Surname:</property>
<property name="use_underline">True</property>
@ -415,6 +519,7 @@ Indicate that the surname consists of different parts. Every surname has its own
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="padding">3</property>
<property name="position">0</property>
</packing>
@ -434,6 +539,7 @@ Indicate that the surname consists of different parts. Every surname has its own
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
@ -449,6 +555,8 @@ Indicate that the surname consists of different parts. Every surname has its own
</accessibility>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">2</property>
</packing>
</child>
@ -465,6 +573,7 @@ Indicate that the surname consists of different parts. Every surname has its own
<child>
<object class="GtkLabel" id="full_name">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="xalign">0</property>
<property name="xpad">3</property>
<property name="ypad">3</property>
@ -482,10 +591,12 @@ Indicate that the surname consists of different parts. Every surname has its own
</child>
<child>
<object class="GtkButton" id="editnamebtn">
<property name="use_action_appearance">False</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="tooltip_text" translatable="yes">Go to Name Editor to add more information about this name</property>
<property name="use_action_appearance">False</property>
<property name="image">image1</property>
<accelerator key="e" signal="activate" modifiers="GDK_CONTROL_MASK"/>
<child internal-child="accessible">
@ -493,7 +604,7 @@ Indicate that the surname consists of different parts. Every surname has its own
<property name="AtkObject::accessible-name" translatable="yes">Edit</property>
</object>
</child>
<signal name="clicked" handler="on_edit_name_clicked"/>
<signal name="clicked" handler="on_edit_name_clicked" swapped="no"/>
</object>
<packing>
<property name="left_attach">8</property>
@ -507,10 +618,12 @@ Indicate that the surname consists of different parts. Every surname has its own
<child>
<object class="GtkHBox" id="hbox5">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="spacing">6</property>
<child>
<object class="GtkLabel" id="originlabel">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">O_rigin:</property>
<property name="use_underline">True</property>
@ -518,16 +631,26 @@ Indicate that the surname consists of different parts. Every surname has its own
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkComboBoxEntry" id="cmborigin">
<object class="GtkComboBox" id="cmborigin">
<property name="width_request">75</property>
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="tooltip_text" translatable="yes">The origin of this family name for this family, eg 'Inherited' or 'Patronymic'.</property>
<property name="has_entry">True</property>
<child internal-child="entry">
<object class="GtkEntry" id="cmborigin-entry">
<property name="can_focus">False</property>
</object>
</child>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
@ -544,10 +667,12 @@ Indicate that the surname consists of different parts. Every surname has its own
<child>
<object class="GtkHBox" id="hbox6">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="spacing">6</property>
<child>
<object class="GtkLabel" id="label436">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="xalign">0</property>
<property name="xpad">6</property>
<property name="label" translatable="yes">G_ender:</property>
@ -556,12 +681,14 @@ Indicate that the surname consists of different parts. Every surname has its own
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkComboBox" id="gender">
<property name="visible">True</property>
<property name="can_focus">False</property>
<child>
<object class="GtkCellRendererText" id="cellrenderertext2"/>
<attributes>
@ -571,12 +698,14 @@ Indicate that the surname consists of different parts. Every surname has its own
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="label437">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">_ID:</property>
<property name="use_underline">True</property>
@ -585,6 +714,7 @@ Indicate that the surname consists of different parts. Every surname has its own
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">2</property>
</packing>
</child>
@ -599,12 +729,14 @@ Indicate that the surname consists of different parts. Every surname has its own
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">3</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="label1">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="xalign">0</property>
<property name="xpad">6</property>
<property name="label" translatable="yes">_Tags:</property>
@ -613,22 +745,28 @@ Indicate that the surname consists of different parts. Every surname has its own
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">4</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="tag_label">
<property name="visible">True</property>
<property name="can_focus">False</property>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">5</property>
</packing>
</child>
<child>
<object class="GtkButton" id="tag_button">
<property name="use_action_appearance">False</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="use_action_appearance">False</property>
<property name="xalign">1</property>
<accessibility>
<relation type="labelled-by" target="label1"/>
@ -668,6 +806,8 @@ Indicate that the surname consists of different parts. Every surname has its own
</child>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="padding">2</property>
<property name="position">0</property>
</packing>
@ -684,67 +824,6 @@ Indicate that the surname consists of different parts. Every surname has its own
<property name="position">1</property>
</packing>
</child>
<child internal-child="action_area">
<object class="GtkHButtonBox" id="hbuttonbox1">
<property name="visible">True</property>
<property name="layout_style">end</property>
<child>
<object class="GtkButton" id="button15">
<property name="label">gtk-cancel</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="can_default">True</property>
<property name="receives_default">False</property>
<property name="tooltip_text" translatable="yes">Abandon changes and close window</property>
<property name="use_stock">True</property>
<signal name="clicked" handler="destroy_passed_object" object="editperson"/>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkButton" id="ok">
<property name="label">gtk-ok</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="can_default">True</property>
<property name="receives_default">False</property>
<property name="tooltip_text" translatable="yes">Accept changes and close window</property>
<property name="use_stock">True</property>
<signal name="clicked" handler="on_apply_person_clicked" object="editperson"/>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">1</property>
</packing>
</child>
<child>
<object class="GtkButton" id="button134">
<property name="label">gtk-help</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="can_default">True</property>
<property name="receives_default">False</property>
<property name="use_stock">True</property>
<signal name="clicked" handler="on_help_person_clicked"/>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">2</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="pack_type">end</property>
<property name="position">0</property>
</packing>
</child>
</object>
</child>
<action-widgets>
@ -755,6 +834,7 @@ Indicate that the surname consists of different parts. Every surname has its own
</object>
<object class="GtkImage" id="image1">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="stock">gtk-edit</property>
<child internal-child="accessible">
<object class="AtkObject" id="image1-atkobject">
@ -764,6 +844,7 @@ Indicate that the surname consists of different parts. Every surname has its own
</object>
<object class="GtkImage" id="image2">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="stock">gtk-add</property>
<child internal-child="accessible">
<object class="AtkObject" id="image2-atkobject">

View File

@ -38,7 +38,8 @@ import os
# GNOME modules
#
#-------------------------------------------------------------------------
import gtk
from gi.repository import GObject
from gi.repository import Gtk
#-------------------------------------------------------------------------
#
@ -73,12 +74,12 @@ NL = "\n"
# GrampsBar class
#
#-------------------------------------------------------------------------
class GrampsBar(gtk.Notebook):
class GrampsBar(Gtk.Notebook):
"""
A class which defines the graphical representation of the GrampsBar.
"""
def __init__(self, dbstate, uistate, pageview, configfile, defaults):
gtk.Notebook.__init__(self)
GObject.GObject.__init__(self)
self.dbstate = dbstate
self.uistate = uistate
@ -88,7 +89,7 @@ class GrampsBar(gtk.Notebook):
self.detached_gramplets = []
self.empty = False
self.set_group_id(1)
self.set_group_name("grampsbar")
self.set_show_border(False)
self.set_scrollable(True)
self.connect('switch-page', self.__switch_page)
@ -302,10 +303,10 @@ class GrampsBar(gtk.Notebook):
"""
Create an empty tab to be displayed when the GrampsBar is empty.
"""
tab_label = gtk.Label(_('Gramps Bar'))
tab_label = Gtk.Label(label=_('Gramps Bar'))
tab_label.show()
msg = _('Right-click to the right of the tab to add a gramplet.')
content = gtk.Label(msg)
content = Gtk.Label(label=msg)
content.show()
self.append_page(content, tab_label)
return content
@ -325,7 +326,7 @@ class GrampsBar(gtk.Notebook):
"""
Create a tab label.
"""
label = gtk.Label()
label = Gtk.Label()
if hasattr(gramplet.pui, "has_data"):
if gramplet.pui.has_data:
label.set_text("<b>%s</b>" % gramplet.title)
@ -416,9 +417,9 @@ class GrampsBar(gtk.Notebook):
Called when a button is pressed in the tabs section of the GrampsBar.
"""
if gui.utils.is_right_click(event):
menu = gtk.Menu()
menu = Gtk.Menu()
ag_menu = gtk.MenuItem(_('Add a gramplet'))
ag_menu = Gtk.MenuItem(_('Add a gramplet'))
nav_type = self.pageview.navigation_type()
skip = self.all_gramplets()
gramplet_list = GET_GRAMPLET_LIST(nav_type, skip)
@ -428,7 +429,7 @@ class GrampsBar(gtk.Notebook):
menu.append(ag_menu)
if not self.empty:
rg_menu = gtk.MenuItem(_('Remove a gramplet'))
rg_menu = Gtk.MenuItem(_('Remove a gramplet'))
gramplet_list = [(gramplet.title, gramplet.gname)
for gramplet in self.get_children() +
self.detached_gramplets]
@ -438,7 +439,7 @@ class GrampsBar(gtk.Notebook):
rg_menu.show()
menu.append(rg_menu)
rd_menu = gtk.MenuItem(_('Restore default gramplets'))
rd_menu = Gtk.MenuItem(_('Restore default gramplets'))
rd_menu.connect("activate", self.__restore_clicked)
rd_menu.show()
menu.append(rd_menu)
@ -454,9 +455,9 @@ class GrampsBar(gtk.Notebook):
"""
if main_menu:
submenu = main_menu.get_submenu()
submenu = gtk.Menu()
submenu = Gtk.Menu()
for entry in gramplet_list:
item = gtk.MenuItem(entry[0])
item = Gtk.MenuItem(entry[0])
item.connect("activate", callback_func, entry[1])
item.show()
submenu.append(item)
@ -513,7 +514,7 @@ class GrampsBar(gtk.Notebook):
# TabGramplet class
#
#-------------------------------------------------------------------------
class TabGramplet(gtk.ScrolledWindow, GuiGramplet):
class TabGramplet(Gtk.ScrolledWindow, GuiGramplet):
"""
Class that handles the plugin interfaces for the GrampletBar.
"""
@ -521,18 +522,18 @@ class TabGramplet(gtk.ScrolledWindow, GuiGramplet):
"""
Internal constructor for GUI portion of a gramplet.
"""
gtk.ScrolledWindow.__init__(self)
GObject.GObject.__init__(self)
GuiGramplet.__init__(self, pane, dbstate, uistate, title, **kwargs)
self.scrolledwindow = self
self.textview = gtk.TextView()
self.textview = Gtk.TextView()
self.textview.set_editable(False)
self.textview.set_wrap_mode(gtk.WRAP_WORD)
self.textview.set_wrap_mode(Gtk.WrapMode.WORD)
self.buffer = UndoableBuffer()
self.text_length = 0
self.textview.set_buffer(self.buffer)
self.textview.connect("key-press-event", self.on_key_press_event)
self.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
self.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)
self.add(self.textview)
self.show_all()
self.track = []
@ -565,18 +566,18 @@ class DetachedWindow(ManagedWindow):
ManagedWindow.__init__(self, gramplet.uistate, [],
self.title)
self.set_window(gtk.Dialog("", gramplet.uistate.window,
gtk.DIALOG_DESTROY_WITH_PARENT,
(gtk.STOCK_CLOSE, gtk.RESPONSE_CLOSE)),
self.set_window(Gtk.Dialog("", gramplet.uistate.window,
Gtk.DialogFlags.DESTROY_WITH_PARENT,
(Gtk.STOCK_CLOSE, Gtk.ResponseType.CLOSE)),
None,
self.title)
self.window.move(x_pos, y_pos)
self.window.set_size_request(gramplet.detached_width,
gramplet.detached_height)
self.window.add_button(gtk.STOCK_HELP, gtk.RESPONSE_HELP)
self.window.add_button(Gtk.STOCK_HELP, Gtk.ResponseType.HELP)
self.window.connect('response', self.handle_response)
self.notebook = gtk.Notebook()
self.notebook = Gtk.Notebook()
self.notebook.set_show_tabs(False)
self.notebook.set_show_border(False)
self.notebook.show()
@ -587,9 +588,9 @@ class DetachedWindow(ManagedWindow):
"""
Callback for taking care of button clicks.
"""
if response in [gtk.RESPONSE_CLOSE, gtk.STOCK_CLOSE]:
if response in [Gtk.ResponseType.CLOSE, Gtk.STOCK_CLOSE]:
self.close()
elif response == gtk.RESPONSE_HELP:
elif response == Gtk.ResponseType.HELP:
# translated name:
if self.gramplet.help_url:
if self.gramplet.help_url.startswith("http://"):

View File

@ -34,22 +34,39 @@ LOG = logging.getLogger(".grampsgui")
#-------------------------------------------------------------------------
#
# pygtk
# Miscellaneous initialization
#
#-------------------------------------------------------------------------
try:
import pygtk
pygtk.require('2.0')
except ImportError:
pass
import gi
gi.require_version('Gtk', '3.0')
#It is important to import Pango before Gtk, or some things start to go
#wrong in GTK3 !
from gi.repository import Pango
from gi.repository import Gtk, Gdk
except ImportError, ValueError:
print (_("Gtk typelib not installed. Install Gnome Introspection, and "
"pygobject version 3.3.2 or later.\n\n"
"Gramps will terminate now."))
sys.exit(0)
#-------------------------------------------------------------------------
#
# Miscellaneous initialization
#
#-------------------------------------------------------------------------
import gtk
import gobject
from gi.repository import GObject
MIN_PYGOBJECT_VERSION = (3, 3, 2)
if not GObject.pygobject_version >= MIN_PYGOBJECT_VERSION :
print (_("Your pygobject version does not meet the "
"requirements. At least pygobject %d.%d.%d is needed to"
" start Gramps with a GUI.\n\n"
"Gramps will terminate now.") % (
MIN_PYGOBJECT_VERSION[0],
MIN_PYGOBJECT_VERSION[1],
MIN_PYGOBJECT_VERSION[2]))
sys.exit(0)
#-------------------------------------------------------------------------
#
@ -91,75 +108,75 @@ def register_stock_icons ():
#add to the back of this list to overrule images set at beginning of list
extraiconsize = [
(os.path.join(const.IMAGE_DIR, '22x22'),
gtk.ICON_SIZE_LARGE_TOOLBAR),
Gtk.IconSize.LARGE_TOOLBAR),
(os.path.join(const.IMAGE_DIR, '16x16'),
gtk.ICON_SIZE_MENU),
Gtk.IconSize.MENU),
(os.path.join(const.IMAGE_DIR, '22x22'),
gtk.ICON_SIZE_BUTTON),
Gtk.IconSize.BUTTON),
]
items = [
('gramps-db', _('Family Trees'), gtk.gdk.CONTROL_MASK, 0, ''),
('gramps-address', _('Address'), gtk.gdk.CONTROL_MASK, 0, ''),
('gramps-attribute', _('Attribute'), gtk.gdk.CONTROL_MASK, 0, ''),
#('gramps-bookmark', _('Bookmarks'), gtk.gdk.CONTROL_MASK, 0, ''),
#('gramps-bookmark-delete', _('Delete bookmark'), gtk.gdk.CONTROL_MASK, 0, ''),
('gramps-bookmark-new', _('_Add bookmark'), gtk.gdk.CONTROL_MASK, 0, ''),
('gramps-bookmark-edit', _('Organize Bookmarks'), gtk.gdk.CONTROL_MASK, 0, ''),
('gramps-config', _('Configure'), gtk.gdk.CONTROL_MASK, 0, ''),
('gramps-date', _('Date'), gtk.gdk.CONTROL_MASK, 0, ''),
('gramps-date-edit', _('Edit Date'), gtk.gdk.CONTROL_MASK, 0, ''),
('gramps-event', _('Events'), gtk.gdk.CONTROL_MASK, 0, ''),
('gramps-family', _('Family'), gtk.gdk.CONTROL_MASK, 0, ''),
('gramps-fanchart', _('Fan Chart'), gtk.gdk.CONTROL_MASK, 0, ''),
('gramps-font', _('Font'), gtk.gdk.CONTROL_MASK, 0, ''),
('gramps-font-color', _('Font Color'), gtk.gdk.CONTROL_MASK, 0, ''),
('gramps-font-bgcolor', _('Font Background Color'), gtk.gdk.CONTROL_MASK, 0, ''),
('gramps-gramplet', _('Gramplets'), gtk.gdk.CONTROL_MASK, 0, ''),
('gramps-geo', _('Geography'), gtk.gdk.CONTROL_MASK, 0, ''),
('gramps-geo-mainmap', _('Geography'), gtk.gdk.CONTROL_MASK, 0, ''),
('gramps-geo-altmap', _('Geography'), gtk.gdk.CONTROL_MASK, 0, ''),
('geo-show-person', _('GeoPerson'), gtk.gdk.CONTROL_MASK, 0, ''),
('geo-show-family', _('GeoFamily'), gtk.gdk.CONTROL_MASK, 0, ''),
('geo-show-event', _('GeoEvents'), gtk.gdk.CONTROL_MASK, 0, ''),
('geo-show-place', _('GeoPlaces'), gtk.gdk.CONTROL_MASK, 0, ''),
('gramps-lock', _('Public'), gtk.gdk.CONTROL_MASK, 0, ''),
('gramps-media', _('Media'), gtk.gdk.CONTROL_MASK, 0, ''),
('gramps-merge', _('Merge'), gtk.gdk.CONTROL_MASK, 0, ''),
('gramps-notes', _('Notes'), gtk.gdk.CONTROL_MASK, 0, ''),
('gramps-parents', _('Parents'), gtk.gdk.CONTROL_MASK, 0, ''),
('gramps-parents-add', _('Add Parents'), gtk.gdk.CONTROL_MASK, 0, ''),
('gramps-parents-open', _('Select Parents'), gtk.gdk.CONTROL_MASK, 0, ''),
('gramps-pedigree', _('Pedigree'), gtk.gdk.CONTROL_MASK, 0, ''),
('gramps-person', _('Person'), gtk.gdk.CONTROL_MASK, 0, ''),
('gramps-place', _('Places'), gtk.gdk.CONTROL_MASK, 0, ''),
('gramps-relation', _('Relationships'), gtk.gdk.CONTROL_MASK, 0, ''),
('gramps-reports', _('Reports'), gtk.gdk.CONTROL_MASK, 0, ''),
('gramps-repository', _('Repositories'), gtk.gdk.CONTROL_MASK, 0, ''),
('gramps-source', _('Sources'), gtk.gdk.CONTROL_MASK, 0, ''),
('gramps-spouse', _('Add Spouse'), gtk.gdk.CONTROL_MASK, 0, ''),
('gramps-tag', _('Tag'), gtk.gdk.CONTROL_MASK, 0, ''),
('gramps-tag-new', _('New Tag'), gtk.gdk.CONTROL_MASK, 0, ''),
('gramps-tools', _('Tools'), gtk.gdk.CONTROL_MASK, 0, ''),
('gramps-tree-group', _('Grouped List'), gtk.gdk.CONTROL_MASK, 0, ''),
('gramps-tree-list', _('List'), gtk.gdk.CONTROL_MASK, 0, ''),
('gramps-tree-select', _('Select'), gtk.gdk.CONTROL_MASK, 0, ''),
('gramps-unlock', _('Private'), gtk.gdk.CONTROL_MASK, 0, ''),
('gramps-view', _('View'), gtk.gdk.CONTROL_MASK, 0, ''),
('gramps-viewmedia', _('View'), gtk.gdk.CONTROL_MASK, 0, ''),
('gramps-zoom-in', _('Zoom In'), gtk.gdk.CONTROL_MASK, 0, ''),
('gramps-zoom-out', _('Zoom Out'), gtk.gdk.CONTROL_MASK, 0, ''),
('gramps-zoom-fit-width', _('Fit Width'), gtk.gdk.CONTROL_MASK, 0, ''),
('gramps-zoom-best-fit', _('Fit Page'), gtk.gdk.CONTROL_MASK, 0, ''),
('gramps-citation', _('Citations'), gtk.gdk.CONTROL_MASK, 0, ''),
('gramps-db', _('Family Trees'), Gdk.ModifierType.CONTROL_MASK, 0, ''),
('gramps-address', _('Address'), Gdk.ModifierType.CONTROL_MASK, 0, ''),
('gramps-attribute', _('Attribute'), Gdk.ModifierType.CONTROL_MASK, 0, ''),
#('gramps-bookmark', _('Bookmarks'), Gdk.ModifierType.CONTROL_MASK, 0, ''),
#('gramps-bookmark-delete', _('Delete bookmark'), Gdk.ModifierType.CONTROL_MASK, 0, ''),
('gramps-bookmark-new', _('_Add bookmark'), Gdk.ModifierType.CONTROL_MASK, 0, ''),
('gramps-bookmark-edit', _('Organize Bookmarks'), Gdk.ModifierType.CONTROL_MASK, 0, ''),
('gramps-config', _('Configure'), Gdk.ModifierType.CONTROL_MASK, 0, ''),
('gramps-date', _('Date'), Gdk.ModifierType.CONTROL_MASK, 0, ''),
('gramps-date-edit', _('Edit Date'), Gdk.ModifierType.CONTROL_MASK, 0, ''),
('gramps-event', _('Events'), Gdk.ModifierType.CONTROL_MASK, 0, ''),
('gramps-family', _('Family'), Gdk.ModifierType.CONTROL_MASK, 0, ''),
('gramps-fanchart', _('Fan Chart'), Gdk.ModifierType.CONTROL_MASK, 0, ''),
('gramps-font', _('Font'), Gdk.ModifierType.CONTROL_MASK, 0, ''),
('gramps-font-color', _('Font Color'), Gdk.ModifierType.CONTROL_MASK, 0, ''),
('gramps-font-bgcolor', _('Font Background Color'), Gdk.ModifierType.CONTROL_MASK, 0, ''),
('gramps-gramplet', _('Gramplets'), Gdk.ModifierType.CONTROL_MASK, 0, ''),
('gramps-geo', _('Geography'), Gdk.ModifierType.CONTROL_MASK, 0, ''),
('gramps-geo-mainmap', _('Geography'), Gdk.ModifierType.CONTROL_MASK, 0, ''),
('gramps-geo-altmap', _('Geography'), Gdk.ModifierType.CONTROL_MASK, 0, ''),
('geo-show-person', _('GeoPerson'), Gdk.ModifierType.CONTROL_MASK, 0, ''),
('geo-show-family', _('GeoFamily'), Gdk.ModifierType.CONTROL_MASK, 0, ''),
('geo-show-event', _('GeoEvents'), Gdk.ModifierType.CONTROL_MASK, 0, ''),
('geo-show-place', _('GeoPlaces'), Gdk.ModifierType.CONTROL_MASK, 0, ''),
('gramps-lock', _('Public'), Gdk.ModifierType.CONTROL_MASK, 0, ''),
('gramps-media', _('Media'), Gdk.ModifierType.CONTROL_MASK, 0, ''),
('gramps-merge', _('Merge'), Gdk.ModifierType.CONTROL_MASK, 0, ''),
('gramps-notes', _('Notes'), Gdk.ModifierType.CONTROL_MASK, 0, ''),
('gramps-parents', _('Parents'), Gdk.ModifierType.CONTROL_MASK, 0, ''),
('gramps-parents-add', _('Add Parents'), Gdk.ModifierType.CONTROL_MASK, 0, ''),
('gramps-parents-open', _('Select Parents'), Gdk.ModifierType.CONTROL_MASK, 0, ''),
('gramps-pedigree', _('Pedigree'), Gdk.ModifierType.CONTROL_MASK, 0, ''),
('gramps-person', _('Person'), Gdk.ModifierType.CONTROL_MASK, 0, ''),
('gramps-place', _('Places'), Gdk.ModifierType.CONTROL_MASK, 0, ''),
('gramps-relation', _('Relationships'), Gdk.ModifierType.CONTROL_MASK, 0, ''),
('gramps-reports', _('Reports'), Gdk.ModifierType.CONTROL_MASK, 0, ''),
('gramps-repository', _('Repositories'), Gdk.ModifierType.CONTROL_MASK, 0, ''),
('gramps-source', _('Sources'), Gdk.ModifierType.CONTROL_MASK, 0, ''),
('gramps-spouse', _('Add Spouse'), Gdk.ModifierType.CONTROL_MASK, 0, ''),
('gramps-tag', _('Tag'), Gdk.ModifierType.CONTROL_MASK, 0, ''),
('gramps-tag-new', _('New Tag'), Gdk.ModifierType.CONTROL_MASK, 0, ''),
('gramps-tools', _('Tools'), Gdk.ModifierType.CONTROL_MASK, 0, ''),
('gramps-tree-group', _('Grouped List'), Gdk.ModifierType.CONTROL_MASK, 0, ''),
('gramps-tree-list', _('List'), Gdk.ModifierType.CONTROL_MASK, 0, ''),
('gramps-tree-select', _('Select'), Gdk.ModifierType.CONTROL_MASK, 0, ''),
('gramps-unlock', _('Private'), Gdk.ModifierType.CONTROL_MASK, 0, ''),
('gramps-view', _('View'), Gdk.ModifierType.CONTROL_MASK, 0, ''),
('gramps-viewmedia', _('View'), Gdk.ModifierType.CONTROL_MASK, 0, ''),
('gramps-zoom-in', _('Zoom In'), Gdk.ModifierType.CONTROL_MASK, 0, ''),
('gramps-zoom-out', _('Zoom Out'), Gdk.ModifierType.CONTROL_MASK, 0, ''),
('gramps-zoom-fit-width', _('Fit Width'), Gdk.ModifierType.CONTROL_MASK, 0, ''),
('gramps-zoom-best-fit', _('Fit Page'), Gdk.ModifierType.CONTROL_MASK, 0, ''),
('gramps-citation', _('Citations'), Gdk.ModifierType.CONTROL_MASK, 0, ''),
]
# the following icons are not yet in new directory structure
# they should be ported in the near future
items_legacy = [
('gramps-export', _('Export'), gtk.gdk.CONTROL_MASK, 0, ''),
('gramps-import', _('Import'), gtk.gdk.CONTROL_MASK, 0, ''),
('gramps-undo-history', _('Undo History'), gtk.gdk.CONTROL_MASK, 0, ''),
('gramps-url', _('URL'), gtk.gdk.CONTROL_MASK, 0, ''),
('gramps-export', _('Export'), Gdk.ModifierType.CONTROL_MASK, 0, ''),
('gramps-import', _('Import'), Gdk.ModifierType.CONTROL_MASK, 0, ''),
('gramps-undo-history', _('Undo History'), Gdk.ModifierType.CONTROL_MASK, 0, ''),
('gramps-url', _('URL'), Gdk.ModifierType.CONTROL_MASK, 0, ''),
]
base_reg_stock_icons(iconpaths, extraiconsize, items+items_legacy)
@ -253,19 +270,19 @@ class Gramps(object):
def __startgramps(errors, argparser):
"""
Main startup function started via gobject.timeout_add
Main startup function started via GObject.timeout_add
First action inside the gtk loop
"""
from gui.dialog import ErrorDialog
#handle first existing errors in GUI fashion
if errors:
ErrorDialog(errors[0], errors[1])
gtk.main_quit()
Gtk.main_quit()
sys.exit(1)
if argparser.errors:
ErrorDialog(argparser.errors[0], argparser.errors[1])
gtk.main_quit()
Gtk.main_quit()
sys.exit(1)
# add gui logger
@ -317,7 +334,7 @@ def __startgramps(errors, argparser):
if quit_now:
#stop gtk loop and quit
gtk.main_quit()
Gtk.main_quit()
sys.exit(exit_code)
#function finished, return False to stop the timeout_add function calls
@ -326,9 +343,9 @@ def __startgramps(errors, argparser):
def startgtkloop(errors, argparser):
""" We start the gtk loop and run the function to start up GRAMPS
"""
gobject.threads_init()
GObject.threads_init()
gobject.timeout_add(100, __startgramps, errors, argparser, priority=100)
GObject.timeout_add(100, __startgramps, errors, argparser, priority=100)
if os.path.exists(os.path.join(const.DATA_DIR, "gramps.accel")):
gtk.accel_map_load(os.path.join(const.DATA_DIR, "gramps.accel"))
gtk.main()
Gtk.AccelMap.load(os.path.join(const.DATA_DIR, "gramps.accel"))
Gtk.main()

View File

@ -29,8 +29,8 @@ Provide the basic functionality for a list view
# GTK
#
#-------------------------------------------------------------------------
import gtk
import pango
from gi.repository import Gtk
from gi.repository import Pango
import const
#-------------------------------------------------------------------------
@ -81,7 +81,7 @@ class ListModel(object):
"""
def __init__(self, tree, dlist, select_func=None, event_func=None,
mode=gtk.SELECTION_SINGLE, list_mode="list"):
mode=Gtk.SelectionMode.SINGLE, list_mode="list"):
self.tree = tree
self.tree.set_fixed_height_mode(True)
@ -101,7 +101,7 @@ class ListModel(object):
if col_type == TOGGLE:
self.mylist.append(bool)
elif col_type == IMAGE:
self.mylist.append(gtk.gdk.Pixbuf)
self.mylist.append(GdkPixbuf.Pixbuf)
elif col_type == INTEGER:
self.mylist.append(int)
elif col_type == COLOR:
@ -132,8 +132,8 @@ class ListModel(object):
self.tree.connect('event', self.__button_press)
def __build_image_column(self, cnum, name, renderer, column):
renderer = gtk.CellRendererPixbuf()
column = gtk.TreeViewColumn(name[0], renderer)
renderer = Gtk.CellRendererPixbuf()
column = Gtk.TreeViewColumn(name[0], renderer)
column.add_attribute(renderer, 'pixbuf', cnum)
renderer.set_property('height', const.THUMBSCALE / 2)
return renderer, column
@ -165,11 +165,11 @@ class ListModel(object):
name = (name[0], name[1], name[2], name[3], name[4], None)
if name[0] and name[3] == TOGGLE:
renderer = gtk.CellRendererToggle()
renderer = Gtk.CellRendererToggle()
if visible_col is not None:
column = gtk.TreeViewColumn(name[0], renderer, visible=visible_col)
column = Gtk.TreeViewColumn(name[0], renderer, visible=visible_col)
else:
column = gtk.TreeViewColumn(name[0], renderer)
column = Gtk.TreeViewColumn(name[0], renderer)
column.add_attribute(renderer, 'active', cnum)
if name[4]:
renderer.set_property('activatable', True)
@ -181,16 +181,16 @@ class ListModel(object):
elif name[0] and name[3] == IMAGE:
renderer, column = self.__build_image_column(cnum, name, renderer, column)
elif name[0] and name[3] == COLOR:
renderer = gtk.CellRendererText()
renderer = Gtk.CellRendererText()
if visible_col is not None:
column = gtk.TreeViewColumn(name[0], renderer, background=cnum,
column = Gtk.TreeViewColumn(name[0], renderer, background=cnum,
visible=visible_col)
else:
column = gtk.TreeViewColumn(name[0], renderer, background=cnum)
column = Gtk.TreeViewColumn(name[0], renderer, background=cnum)
else:
renderer = gtk.CellRendererText()
renderer = Gtk.CellRendererText()
renderer.set_fixed_height_from_font(True)
renderer.set_property('ellipsize', pango.ELLIPSIZE_END)
renderer.set_property('ellipsize', Pango.EllipsizeMode.END)
if name[4]:
renderer.set_property('editable', True)
renderer.connect('edited', self.__edited_cb, cnum)
@ -199,9 +199,9 @@ class ListModel(object):
else:
renderer.set_property('editable', False)
if visible_col is not None:
column = gtk.TreeViewColumn(name[0], renderer, text=cnum, visible=visible_col)
column = Gtk.TreeViewColumn(name[0], renderer, text=cnum, visible=visible_col)
else:
column = gtk.TreeViewColumn(name[0], renderer, text=cnum)
column = Gtk.TreeViewColumn(name[0], renderer, text=cnum)
column.set_reorderable(True)
column.set_min_width(name[2])
@ -215,7 +215,7 @@ class ListModel(object):
column.set_clickable(True)
column.set_sort_column_id(name[1])
column.set_sizing(gtk.TREE_VIEW_COLUMN_FIXED)
column.set_sizing(Gtk.TreeViewColumnSizing.FIXED)
column.set_fixed_width(name[2])
cnum += 1
@ -262,9 +262,9 @@ class ListModel(object):
del self.selection
self.count = 0
if self.list_mode == "list":
self.model = gtk.ListStore(*self.mylist)
self.model = Gtk.ListStore(*self.mylist)
elif self.list_mode == "tree":
self.model = gtk.TreeStore(*self.mylist)
self.model = Gtk.TreeStore(*self.mylist)
self.selection = self.tree.get_selection()
self.selection.set_mode(self.mode)
self.sel_iter = None
@ -332,7 +332,7 @@ class ListModel(object):
"""
if self.count == 0:
return []
elif self.mode == gtk.SELECTION_SINGLE:
elif self.mode == Gtk.SelectionMode.SINGLE:
store, node = self.selection.get_selected()
if node:
return [self.model.get_value(node, self.data_index)]
@ -347,7 +347,7 @@ class ListModel(object):
"""
Return an icon to be used for Drag and drop.
"""
if self.mode == gtk.SELECTION_SINGLE:
if self.mode == Gtk.SelectionMode.SINGLE:
store, node = self.selection.get_selected()
path = self.model.get_path(node)
else:
@ -476,7 +476,7 @@ class ListModel(object):
"""
Called when a button press is executed
"""
if event.type == gtk.gdk._2BUTTON_PRESS and event.button == 1:
if event.type == Gdk.EventType._2BUTTON_PRESS and event.button == 1:
self.double_click(obj)
return True
return False

View File

@ -60,7 +60,7 @@ Usage:
except:
l.error(log_message,exc_info=True)
gtk.main()
Gtk.main()
"""

View File

@ -27,8 +27,10 @@
#
#-------------------------------------------------------------------------
from gen.ggettext import gettext as _
import gtk
import gobject
from gi.repository import Gdk
from gi.repository import Gtk
from gi.repository import GdkPixbuf
from gi.repository import GObject
import cairo
import sys, os
@ -59,13 +61,13 @@ SPLASH_JPG = os.path.join(const.IMAGE_DIR, "splash.jpg")
# ErrorReportAssistant
#
#-------------------------------------------------------------------------
class ErrorReportAssistant(gtk.Assistant):
class ErrorReportAssistant(Gtk.Assistant):
"""
Give the user an opportunity to report an error on the Gramps bug
reporting system.
"""
def __init__(self, error_detail, rotate_handler, ownthread=False):
gtk.Assistant.__init__(self)
GObject.GObject.__init__(self)
self._error_detail = error_detail
self._rotate_handler = rotate_handler
@ -75,8 +77,8 @@ class ErrorReportAssistant(gtk.Assistant):
self._error_details_text_buffer = None
self._final_report_text_buffer = None
self.logo = gtk.gdk.pixbuf_new_from_file(GRAMPS_PNG)
self.splash = gtk.gdk.pixbuf_new_from_file(SPLASH_JPG)
self.logo = GdkPixbuf.Pixbuf.new_from_file(GRAMPS_PNG)
self.splash = GdkPixbuf.Pixbuf.new_from_file(SPLASH_JPG)
self.set_title(_("Error Report Assistant"))
self.connect('close', self.close)
@ -95,7 +97,7 @@ class ErrorReportAssistant(gtk.Assistant):
self.ownthread = ownthread
if self.ownthread:
gtk.main()
Gtk.main()
def close(self, *obj):
"""
@ -103,7 +105,7 @@ class ErrorReportAssistant(gtk.Assistant):
"""
self.hide()
if self.ownthread:
gtk.main_quit()
Gtk.main_quit()
def prepare(self, assistant, page):
"""
@ -116,17 +118,19 @@ class ErrorReportAssistant(gtk.Assistant):
"""
Copy the bug report to the clipboard.
"""
clipboard = gtk.Clipboard()
#TODO GTK3 Is this clipboard copy working ??
clipboard = Gtk.Clipboard.get_for_display(Gdk.Display.get_default(),
Gdk.SELECTION_CLIPBOARD)
clipboard.set_text(
self._final_report_text_buffer.get_text(
self._final_report_text_buffer.get_start_iter(),
self._final_report_text_buffer.get_end_iter()))
self._final_report_text_buffer.get_end_iter(), True), -1)
clipboard = gtk.Clipboard(selection="PRIMARY")
clipboard = t = Gtk.Clipboard.get(Gdk.SELECTION_PRIMARY)
clipboard.set_text(
self._final_report_text_buffer.get_text(
self._final_report_text_buffer.get_start_iter(),
self._final_report_text_buffer.get_end_iter()))
self._final_report_text_buffer.get_end_iter(), True), -1)
def _start_email_client(self, obj=None):
"""
@ -135,8 +139,8 @@ class ErrorReportAssistant(gtk.Assistant):
display_url('mailto:gramps-bugs@lists.sourceforge.net?subject='
'"bug report"&body="%s"' \
% self._final_report_text_buffer.get_text(
self._final_report_text_buffer.get_start_iter(),
self._final_report_text_buffer.get_end_iter()))
self._final_report_text_buffer.get_start_iter(),
self._final_report_text_buffer.get_end_iter(), True))
def _start_gramps_bts_in_browser(self, obj=None):
"""
@ -162,7 +166,6 @@ class ErrorReportAssistant(gtk.Assistant):
"OS: %s\n"\
"Distribution: %s\n\n"\
"GTK version : %s\n"\
"pygtk version : %s\n"\
"gobject version: %s\n"\
"cairo version : %s"\
% (str(sys.version).replace('\n',''),
@ -171,9 +174,9 @@ class ErrorReportAssistant(gtk.Assistant):
os.environ.get('LANG',''),
operatingsystem,
distribution,
gtk.gtk_version,
gtk.pygtk_version,
gobject.pygobject_version,
'%d.%d.%d' % (Gtk.get_major_version(),
Gtk.get_minor_version(), Gtk.get_micro_version()),
'%d.%d.%d' % GObject.pygobject_version,
cairo.version_info)
def _reset_error_details(self, obj=None):
@ -220,15 +223,15 @@ class ErrorReportAssistant(gtk.Assistant):
"""
Create the introduction page.
"""
label = gtk.Label(self.get_intro_text())
label = Gtk.Label(label=self.get_intro_text())
label.set_line_wrap(True)
# Using set_page_side_image causes window sizing problems, so put the
# image in the main page instead.
image = gtk.Image()
image = Gtk.Image()
image.set_from_file(SPLASH_JPG)
hbox = gtk.HBox()
hbox = Gtk.HBox()
hbox.pack_start(image, False, False, 0)
hbox.pack_start(label, True, True, 0)
@ -239,7 +242,7 @@ class ErrorReportAssistant(gtk.Assistant):
self.set_page_header_image(page, self.logo)
#self.set_page_side_image(page, self.splash)
self.set_page_title(page, _('Report a bug'))
self.set_page_type(page, gtk.ASSISTANT_PAGE_INTRO)
self.set_page_type(page, Gtk.AssistantPageType.INTRO)
def get_intro_text(self):
"""
@ -262,56 +265,56 @@ class ErrorReportAssistant(gtk.Assistant):
"""
Build the error details page.
"""
label = gtk.Label(_("If you can see that there is any personal "
label = Gtk.Label(label=_("If you can see that there is any personal "
"information included in the error please remove "
"it."))
label.set_alignment(0.01, 0.5)
label.set_padding(0, 4)
label.set_line_wrap(True)
swin = gtk.ScrolledWindow()
swin.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
swin = Gtk.ScrolledWindow()
swin.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)
textview = gtk.TextView()
textview = Gtk.TextView()
self._error_details_text_buffer = textview.get_buffer()
self._reset_error_details()
swin.add(textview)
sw_frame = gtk.Frame()
sw_frame = Gtk.Frame()
sw_frame.add(swin)
reset = gtk.Button("Reset")
reset = Gtk.Button("Reset")
reset.connect('clicked', self._reset_error_details)
clear = gtk.Button("Clear")
clear = Gtk.Button("Clear")
clear.connect('clicked', self._clear_error_details)
button_box = gtk.HButtonBox()
button_box = Gtk.HButtonBox()
button_box.set_border_width(6)
button_box.set_spacing(6)
button_box.set_layout(gtk.BUTTONBOX_END)
button_box.set_layout(Gtk.ButtonBoxStyle.END)
button_box.pack_end(reset, False, False)
button_box.pack_end(clear, False, False)
button_box.pack_end(reset, False, False, 0)
button_box.pack_end(clear, False, False, 0)
error_details_box = gtk.VBox()
error_details_box.pack_start(label, False, False)
error_details_box.pack_start(sw_frame, True, True)
error_details_box.pack_start(button_box, False, False)
error_details_box = Gtk.VBox()
error_details_box.pack_start(label, False, False, 0)
error_details_box.pack_start(sw_frame, True, True, 0)
error_details_box.pack_start(button_box, False, False, 0)
error_details_align = gtk.Alignment(0, 0, 1, 1)
error_details_align = Gtk.Alignment.new(0, 0, 1, 1)
error_details_align.set_padding(0, 0, 11, 0)
error_details_align.add(error_details_box)
error_details_frame = gtk.Frame()
error_details_frame = Gtk.Frame()
error_details_frame.set_border_width(3)
error_details_frame.set_label("<b>%s</b>" % _("Error Details"))
error_details_frame.get_label_widget().set_use_markup(True)
error_details_frame.add(error_details_align)
side_label = gtk.Label(_("This is the detailed Gramps error "
side_label = Gtk.Label(_("This is the detailed Gramps error "
"information, don't worry if you do not "
"understand it. You will have the opportunity "
"to add further detail about the error "
@ -320,9 +323,9 @@ class ErrorReportAssistant(gtk.Assistant):
side_label.set_line_wrap(True)
side_label.set_size_request(124, -1)
box = gtk.HBox()
box = Gtk.HBox()
box.pack_start(side_label, False, False, 5)
box.pack_start(error_details_frame)
box.pack_start(error_details_frame, True, True, 0)
page = box
@ -330,13 +333,13 @@ class ErrorReportAssistant(gtk.Assistant):
self.append_page(page)
self.set_page_header_image(page, self.logo)
self.set_page_title(page, _("Report a bug: Step 1 of 5"))
self.set_page_type(page, gtk.ASSISTANT_PAGE_CONTENT)
self.set_page_type(page, Gtk.AssistantPageType.CONTENT)
def build_page2(self):
"""
Build the system information page.
"""
label = gtk.Label(_("Please check the information below and correct "
label = Gtk.Label(label=_("Please check the information below and correct "
"anything that you know to be wrong or remove "
"anything that you would rather not have included "
"in the bug report."))
@ -344,59 +347,59 @@ class ErrorReportAssistant(gtk.Assistant):
label.set_padding(0, 4)
label.set_line_wrap(True)
swin = gtk.ScrolledWindow()
swin.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
swin = Gtk.ScrolledWindow()
swin.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)
textview = gtk.TextView()
textview = Gtk.TextView()
self._sys_information_text_buffer = textview.get_buffer()
self._reset_sys_information()
swin.add(textview)
sw_frame = gtk.Frame()
sw_frame = Gtk.Frame()
sw_frame.add(swin)
reset = gtk.Button("Reset")
reset = Gtk.Button("Reset")
reset.connect('clicked', self._reset_sys_information)
clear = gtk.Button("Clear")
clear = Gtk.Button("Clear")
clear.connect('clicked', self._clear_sys_information)
button_box = gtk.HButtonBox()
button_box = Gtk.HButtonBox()
button_box.set_border_width(6)
button_box.set_spacing(6)
button_box.set_layout(gtk.BUTTONBOX_END)
button_box.set_layout(Gtk.ButtonBoxStyle.END)
button_box.pack_end(reset, False, False)
button_box.pack_end(clear, False, False)
button_box.pack_end(reset, False, False, 0)
button_box.pack_end(clear, False, False, 0)
sys_information_box = gtk.VBox()
sys_information_box.pack_start(label, False, False)
sys_information_box.pack_start(sw_frame, True, True)
sys_information_box.pack_start(button_box, False, False)
sys_information_box = Gtk.VBox()
sys_information_box.pack_start(label, False, False, 0)
sys_information_box.pack_start(sw_frame, True, True, 0)
sys_information_box.pack_start(button_box, False, False, 0)
sys_information_align = gtk.Alignment(0, 0, 1, 1)
sys_information_align = Gtk.Alignment.new(0, 0, 1, 1)
sys_information_align.set_padding(0, 0, 11, 0)
sys_information_align.add(sys_information_box)
sys_information_frame = gtk.Frame()
sys_information_frame = Gtk.Frame()
sys_information_frame.set_border_width(3)
sys_information_frame.set_label("<b>%s</b>" % _("System Information"))
sys_information_frame.get_label_widget().set_use_markup(True)
sys_information_frame.add(sys_information_align)
side_label = gtk.Label(_("This is the information about your system "
side_label = Gtk.Label(label=_("This is the information about your system "
"that will help the developers to fix the "
"bug."))
side_label.set_line_wrap(True)
side_label.set_size_request(124, -1)
box = gtk.HBox()
box = Gtk.HBox()
box.pack_start(side_label, False, False, 5)
box.pack_start(sys_information_frame)
box.pack_start(sys_information_frame, True, True, 0)
page = box
@ -404,66 +407,66 @@ class ErrorReportAssistant(gtk.Assistant):
self.append_page(page)
self.set_page_header_image(page, self.logo)
self.set_page_title(page, _("Report a bug: Step 2 of 5"))
self.set_page_type(page, gtk.ASSISTANT_PAGE_CONTENT)
self.set_page_type(page, Gtk.AssistantPageType.CONTENT)
def build_page3(self):
"""
Build the further information page.
"""
label = gtk.Label(_("Please provide as much information as you can "
label = Gtk.Label(label=_("Please provide as much information as you can "
"about what you were doing when the error "
"occured."))
label.set_alignment(0.01, 0.5)
label.set_padding(0, 4)
label.set_line_wrap(True)
swin = gtk.ScrolledWindow()
swin.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
swin = Gtk.ScrolledWindow()
swin.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)
textview = gtk.TextView()
textview = Gtk.TextView()
self._user_information_text_buffer = textview.get_buffer()
swin.add(textview)
sw_frame = gtk.Frame()
sw_frame = Gtk.Frame()
sw_frame.add(swin)
clear = gtk.Button("Clear")
clear = Gtk.Button("Clear")
clear.connect('clicked', self._clear_user_information)
button_box = gtk.HButtonBox()
button_box = Gtk.HButtonBox()
button_box.set_border_width(6)
button_box.set_spacing(6)
button_box.set_layout(gtk.BUTTONBOX_END)
button_box.set_layout(Gtk.ButtonBoxStyle.END)
button_box.pack_end(clear, False, False)
button_box.pack_end(clear, False, False, 0)
user_information_box = gtk.VBox()
user_information_box.pack_start(label, False, False)
user_information_box.pack_start(sw_frame, True, True)
user_information_box.pack_start(button_box, False, False)
user_information_box = Gtk.VBox()
user_information_box.pack_start(label, False, False, 0)
user_information_box.pack_start(sw_frame, True, True, 0)
user_information_box.pack_start(button_box, False, False, 0)
user_information_align = gtk.Alignment(0, 0, 1, 1)
user_information_align = Gtk.Alignment.new(0, 0, 1, 1)
user_information_align.set_padding(0, 0, 11, 0)
user_information_align.add(user_information_box)
user_information_frame = gtk.Frame()
user_information_frame = Gtk.Frame()
user_information_frame.set_border_width(3)
user_information_frame.set_label("<b>%s</b>" % _("Further Information"))
user_information_frame.get_label_widget().set_use_markup(True)
user_information_frame.add(user_information_align)
side_label = gtk.Label(_("This is your opportunity to describe what "
side_label = Gtk.Label(label=_("This is your opportunity to describe what "
"you were doing when the error occured."))
side_label.set_line_wrap(True)
side_label.set_size_request(124, -1)
box = gtk.HBox()
box = Gtk.HBox()
box.pack_start(side_label, False, False, 5)
box.pack_start(user_information_frame)
box.pack_start(user_information_frame, True, True, 0)
page = box
@ -471,13 +474,13 @@ class ErrorReportAssistant(gtk.Assistant):
self.append_page(page)
self.set_page_header_image(page, self.logo)
self.set_page_title(page, _("Report a bug: Step 3 of 5"))
self.set_page_type(page, gtk.ASSISTANT_PAGE_CONTENT)
self.set_page_type(page, Gtk.AssistantPageType.CONTENT)
def build_page4(self):
"""
Build the bug report summary page.
"""
label = gtk.Label(_("Please check that the information is correct, "
label = Gtk.Label(_("Please check that the information is correct, "
"do not worry if you don't understand the detail "
"of the error information. Just make sure that it "
"does not contain anything that you do not want "
@ -486,10 +489,10 @@ class ErrorReportAssistant(gtk.Assistant):
label.set_padding(0, 4)
label.set_line_wrap(True)
swin = gtk.ScrolledWindow()
swin.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
swin = Gtk.ScrolledWindow()
swin.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)
textview = gtk.TextView()
textview = Gtk.TextView()
textview.set_editable(False)
textview.set_cursor_visible(False)
@ -497,25 +500,25 @@ class ErrorReportAssistant(gtk.Assistant):
swin.add(textview)
sw_frame = gtk.Frame()
sw_frame = Gtk.Frame()
sw_frame.add(swin)
summary_box = gtk.VBox()
summary_box.pack_start(label, False, False)
summary_box.pack_start(sw_frame, True, True)
summary_box = Gtk.VBox()
summary_box.pack_start(label, False, False, 0)
summary_box.pack_start(sw_frame, True, True, 0)
summary_align = gtk.Alignment(0, 0, 1, 1)
summary_align = Gtk.Alignment.new(0, 0, 1, 1)
summary_align.set_padding(0, 0, 11, 0)
summary_align.add(summary_box)
summary_frame = gtk.Frame()
summary_frame = Gtk.Frame()
summary_frame.set_border_width(3)
summary_frame.set_label("<b>%s</b>" % _("Bug Report Summary"))
summary_frame.get_label_widget().set_use_markup(True)
summary_frame.add(summary_align)
side_label = gtk.Label(_("This is the completed bug report. The next "
side_label = Gtk.Label(label=_("This is the completed bug report. The next "
"page of the assistant will help you to file "
"a bug on the Gramps bug tracking system "
"website."))
@ -523,9 +526,9 @@ class ErrorReportAssistant(gtk.Assistant):
side_label.set_line_wrap(True)
side_label.set_size_request(124, -1)
box = gtk.HBox()
box = Gtk.HBox()
box.pack_start(side_label, False, False, 5)
box.pack_start(summary_frame)
box.pack_start(summary_frame, True, True, 0)
page = box
@ -533,13 +536,13 @@ class ErrorReportAssistant(gtk.Assistant):
self.append_page(page)
self.set_page_header_image(page, self.logo)
self.set_page_title(page, _("Report a bug: Step 4 of 5"))
self.set_page_type(page, gtk.ASSISTANT_PAGE_CONTENT)
self.set_page_type(page, Gtk.AssistantPageType.CONTENT)
def build_page5(self):
"""
Build the send bug report page.
"""
label = gtk.Label(
label = Gtk.Label(label=
"%s <i>%s</i>" %
(_("Use the two buttons below to first copy the bug report to the "
"clipboard and then open a webbrowser to file a bug report at "),
@ -550,31 +553,31 @@ class ErrorReportAssistant(gtk.Assistant):
label.set_use_markup(True)
url_label = gtk.Label(_("Use this button to start a web browser and "
url_label = Gtk.Label(label=_("Use this button to start a web browser and "
"file a bug report on the Gramps bug tracking "
"system."))
url_label.set_alignment(0.01, 0.5)
url_label.set_padding(0, 4)
url_label.set_line_wrap(True)
url_button = gtk.Button("File bug report")
url_button = Gtk.Button("File bug report")
url_button.connect('clicked', self._start_gramps_bts_in_browser)
url_button_vbox = gtk.VBox()
url_button_vbox.pack_start(url_button, True, False)
url_button_vbox = Gtk.VBox()
url_button_vbox.pack_start(url_button, True, False, 0)
url_box = gtk.HBox()
url_box.pack_start(url_label, True, True)
url_box.pack_start(url_button_vbox, False, False)
url_box = Gtk.HBox()
url_box.pack_start(url_label, True, True, 0)
url_box.pack_start(url_button_vbox, False, False, 0)
url_align = gtk.Alignment(0, 0, 1, 1)
url_align = Gtk.Alignment.new(0, 0, 1, 1)
url_align.set_padding(0, 0, 11, 0)
url_align.add(url_box)
url_frame = gtk.Frame()
url_frame = Gtk.Frame()
url_frame.add(url_align)
clip_label = gtk.Label(_("Use this button "
clip_label = Gtk.Label(_("Use this button "
"to copy the bug report onto the clipboard. "
"Then go to the bug tracking website by using "
"the button below, paste the report and click "
@ -583,41 +586,41 @@ class ErrorReportAssistant(gtk.Assistant):
clip_label.set_padding(0, 4)
clip_label.set_line_wrap(True)
clip_button = gtk.Button("Copy to clipboard")
clip_button = Gtk.Button("Copy to clipboard")
clip_button.connect('clicked', self._copy_to_clipboard)
clip_button_vbox = gtk.VBox()
clip_button_vbox.pack_start(clip_button, True, False)
clip_button_vbox = Gtk.VBox()
clip_button_vbox.pack_start(clip_button, True, False, 0)
clip_box = gtk.HBox()
clip_box.pack_start(clip_label, True, True)
clip_box.pack_start(clip_button_vbox, False, False)
clip_box = Gtk.HBox()
clip_box.pack_start(clip_label, True, True, 0)
clip_box.pack_start(clip_button_vbox, False, False, 0)
clip_align = gtk.Alignment(0, 0, 1, 1)
clip_align = Gtk.Alignment.new(0, 0, 1, 1)
clip_align.set_padding(0, 0, 11, 0)
clip_align.add(clip_box)
clip_frame = gtk.Frame()
clip_frame = Gtk.Frame()
clip_frame.add(clip_align)
inner_box = gtk.VBox()
inner_box.pack_start(label, False, False)
inner_box.pack_start(clip_frame, False, False)
inner_box.pack_start(url_frame, False, False)
inner_box = Gtk.VBox()
inner_box.pack_start(label, False, False, 0)
inner_box.pack_start(clip_frame, False, False, 0)
inner_box.pack_start(url_frame, False, False, 0)
inner_align = gtk.Alignment(0, 0, 1, 1)
inner_align = Gtk.Alignment.new(0, 0, 1, 1)
inner_align.set_padding(0, 0, 11, 0)
inner_align.add(inner_box)
outer_frame = gtk.Frame()
outer_frame = Gtk.Frame()
outer_frame.set_border_width(3)
outer_frame.set_label("<b>%s</b>" % _("Send Bug Report"))
outer_frame.get_label_widget().set_use_markup(True)
outer_frame.add(inner_align)
side_label = gtk.Label(_("This is the final step. Use the buttons on "
side_label = Gtk.Label(label=_("This is the final step. Use the buttons on "
"this page to start a web browser and file a "
"bug report on the Gramps bug tracking "
"system."))
@ -625,9 +628,9 @@ class ErrorReportAssistant(gtk.Assistant):
side_label.set_line_wrap(True)
side_label.set_size_request(124, -1)
box = gtk.HBox()
box = Gtk.HBox()
box.pack_start(side_label, False, False, 5)
box.pack_start(outer_frame)
box.pack_start(outer_frame, True, True, 0)
page = box
@ -635,7 +638,7 @@ class ErrorReportAssistant(gtk.Assistant):
self.append_page(page)
self.set_page_header_image(page, self.logo)
self.set_page_title(page, _("Report a bug: Step 5 of 5"))
self.set_page_type(page, gtk.ASSISTANT_PAGE_CONTENT)
self.set_page_type(page, Gtk.AssistantPageType.CONTENT)
def create_page_summary(self):
"""
@ -644,15 +647,15 @@ class ErrorReportAssistant(gtk.Assistant):
text = _('Gramps is an Open Source project. Its success '
'depends on its users. User feedback is important. '
'Thank you for taking the time to submit a bug report.')
label = gtk.Label(text)
label = Gtk.Label(label=text)
label.set_line_wrap(True)
# Using set_page_side_image causes window sizing problems, so put the
# image in the main page instead.
image = gtk.Image()
image = Gtk.Image()
image.set_from_file(SPLASH_JPG)
hbox = gtk.HBox()
hbox = Gtk.HBox()
hbox.pack_start(image, False, False, 0)
hbox.pack_start(label, True, True, 0)
@ -663,7 +666,7 @@ class ErrorReportAssistant(gtk.Assistant):
self.set_page_header_image(page, self.logo)
#self.set_page_side_image(page, self.splash)
self.set_page_title(page, _('Complete'))
self.set_page_type(page, gtk.ASSISTANT_PAGE_SUMMARY)
self.set_page_type(page, Gtk.AssistantPageType.SUMMARY)
def page4_update(self):
"""
@ -674,19 +677,19 @@ class ErrorReportAssistant(gtk.Assistant):
"===================\n\n" +
self._user_information_text_buffer.get_text(
self._user_information_text_buffer.get_start_iter(),
self._user_information_text_buffer.get_end_iter()) +
self._user_information_text_buffer.get_end_iter(), True) +
"\n\n\nError Details: \n" +
"===================\n\n" +
self._error_details_text_buffer.get_text(
self._error_details_text_buffer.get_start_iter(),
self._error_details_text_buffer.get_end_iter()) +
self._error_details_text_buffer.get_end_iter(), True) +
"\n\nSystem Information: \n" +
"===================\n\n" +
self._sys_information_text_buffer.get_text(
self._sys_information_text_buffer.get_start_iter(),
self._sys_information_text_buffer.get_end_iter())
self._sys_information_text_buffer.get_end_iter(), True)
)

View File

@ -25,7 +25,7 @@
# GNOME modules
#
#-------------------------------------------------------------------------
import gtk
from gi.repository import Gtk
#-------------------------------------------------------------------------
#
@ -62,17 +62,17 @@ class ErrorView(object):
self.run()
def run(self):
response = gtk.RESPONSE_HELP
while response == gtk.RESPONSE_HELP:
response = Gtk.ResponseType.HELP
while response == Gtk.ResponseType.HELP:
response = self.top.run()
if response == gtk.RESPONSE_HELP:
if response == Gtk.ResponseType.HELP:
self.help_clicked()
elif response == gtk.RESPONSE_YES:
elif response == Gtk.ResponseType.YES:
self.top.destroy()
ErrorReportAssistant(error_detail = self._error_detail,
rotate_handler = self._rotate_handler,
ownthread=True)
elif response == gtk.RESPONSE_CANCEL:
elif response == Gtk.ResponseType.CANCEL:
self.top.destroy()
def help_clicked(self):
@ -82,25 +82,24 @@ class ErrorView(object):
def draw_window(self):
title = "%s - Gramps" % _("Error Report")
self.top = gtk.Dialog(title)
#self.top.set_default_size(400,350)
self.top.set_has_separator(False)
self.top.vbox.set_spacing(5)
self.top = Gtk.Dialog(title)
vbox = self.top.get_content_area()
vbox.set_spacing(5)
self.top.set_border_width(12)
hbox = gtk.HBox()
hbox = Gtk.HBox()
hbox.set_spacing(12)
image = gtk.Image()
image.set_from_stock(gtk.STOCK_DIALOG_ERROR, gtk.ICON_SIZE_DIALOG)
label = gtk.Label('<span size="larger" weight="bold">%s</span>'
image = Gtk.Image()
image.set_from_stock(Gtk.STOCK_DIALOG_ERROR, Gtk.IconSize.DIALOG)
label = Gtk.Label(label='<span size="larger" weight="bold">%s</span>'
% _("Gramps has experienced an unexpected error"))
label.set_use_markup(True)
hbox.pack_start(image,False)
hbox.pack_start(image, False, True, 0)
hbox.add(label)
self.top.vbox.pack_start(hbox,False,False,5)
vbox.pack_start(hbox, False, False, 5)
instructions_label = gtk.Label(
instructions_label = Gtk.Label(label=
_("Your data will be safe but it would be advisable to restart Gramps immediately. "\
"If you would like to report the problem to the Gramps team "\
"please click Report and the Error Reporting Wizard will help you "\
@ -108,31 +107,31 @@ class ErrorView(object):
instructions_label.set_line_wrap(True)
instructions_label.set_use_markup(True)
self.top.vbox.pack_start(instructions_label,False,False,5)
vbox.pack_start(instructions_label, False, False, 5)
tb_frame = gtk.Frame(_("Error Detail"))
tb_frame = Gtk.Frame(label=_("Error Detail"))
tb_frame.set_border_width(6)
tb_label = gtk.TextView()
tb_label = Gtk.TextView()
tb_label.get_buffer().set_text(self._error_detail.get_formatted_log())
tb_label.set_border_width(6)
tb_label.set_editable(False)
scroll = gtk.ScrolledWindow()
scroll.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
scroll = Gtk.ScrolledWindow()
scroll.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)
scroll.set_size_request(-1, 60)
tb_frame.add(scroll)
scroll.add_with_viewport(tb_label)
tb_expander = gtk.Expander('<span weight="bold">%s</span>' % _("Error Detail"))
tb_expander = Gtk.Expander(label='<span weight="bold">%s</span>' % _("Error Detail"))
tb_expander.set_use_markup(True)
tb_expander.add(tb_frame)
self.top.vbox.pack_start(tb_expander,True,True,5)
vbox.pack_start(tb_expander, True, True, 5)
self.top.add_button(gtk.STOCK_CANCEL,gtk.RESPONSE_CANCEL)
self.top.add_button(_("Report"),gtk.RESPONSE_YES)
self.top.add_button(gtk.STOCK_HELP,gtk.RESPONSE_HELP)
self.top.add_button(Gtk.STOCK_CANCEL,Gtk.ResponseType.CANCEL)
self.top.add_button(_("Report"),Gtk.ResponseType.YES)
self.top.add_button(Gtk.STOCK_HELP,Gtk.ResponseType.HELP)
self.top.show_all()

Some files were not shown because too many files have changed in this diff Show More