Tidy up Gtk constructors

This commit is contained in:
Nick Hall
2015-09-07 21:43:13 +01:00
parent dee5d46be5
commit d877d02187
31 changed files with 54 additions and 71 deletions

View File

@@ -458,7 +458,7 @@ def add_all_files_filter(chooser):
class GrampsFormatWidget(Gtk.ComboBox):
def __init__(self):
GObject.GObject.__init__(self, model=None)
Gtk.ComboBox.__init__(self, model=None)
def set(self, format_list):
self.store = Gtk.ListStore(GObject.TYPE_STRING)

View File

@@ -117,7 +117,7 @@ _name2typeclass = {
class MyBoolean(Gtk.CheckButton):
def __init__(self, label=None):
GObject.GObject.__init__(self)
Gtk.CheckButton.__init__(self)
self.set_label(label)
self.show()
@@ -148,7 +148,7 @@ class MyBoolean(Gtk.CheckButton):
class MyInteger(Gtk.SpinButton):
def __init__(self, min, max):
GObject.GObject.__init__(self)
Gtk.SpinButton.__init__(self)
self.set_adjustment(Gtk.Adjustment(value=min, lower=min, upper=max,
step_increment=1))
self.show()
@@ -176,7 +176,7 @@ class MyFilters(Gtk.ComboBox):
If filter_name is given, it will be excluded from the dropdown box.
"""
GObject.GObject.__init__(self)
Gtk.ComboBox.__init__(self)
store = Gtk.ListStore(GObject.TYPE_STRING)
self.set_model(store)
cell = Gtk.CellRendererText()
@@ -210,7 +210,7 @@ class MyFilters(Gtk.ComboBox):
class MyList(Gtk.ComboBox):
def __init__(self, clist, clist_trans, default=0):
GObject.GObject.__init__(self)
Gtk.ComboBox.__init__(self)
store = Gtk.ListStore(GObject.TYPE_STRING)
self.set_model(store)
cell = Gtk.CellRendererText()
@@ -238,7 +238,7 @@ class MyList(Gtk.ComboBox):
class MyLesserEqualGreater(Gtk.ComboBox):
def __init__(self, default=0):
GObject.GObject.__init__(self)
Gtk.ComboBox.__init__(self)
store = Gtk.ListStore(GObject.TYPE_STRING)
self.set_model(store)
cell = Gtk.CellRendererText()
@@ -272,7 +272,7 @@ class MyLesserEqualGreater(Gtk.ComboBox):
class MyPlaces(Gtk.Entry):
def __init__(self, places):
GObject.GObject.__init__(self)
Gtk.Entry.__init__(self)
fill_entry(self, places)
self.show()
@@ -299,7 +299,7 @@ class MyID(Gtk.Box):
}
def __init__(self, dbstate, uistate, track, namespace='Person'):
GObject.GObject.__init__(self)
Gtk.Box.__init__(self)
self.set_orientation(Gtk.Orientation.HORIZONTAL)
self.set_homogeneous(False)
self.set_spacing(6)
@@ -424,7 +424,7 @@ class MySelect(Gtk.ComboBox):
class MyEntry(Gtk.Entry):
def __init__(self):
GObject.GObject.__init__(self)
Gtk.Entry.__init__(self)
self.show()
#-------------------------------------------------------------------------

View File

@@ -27,7 +27,7 @@ Package providing filtering framework for GRAMPS.
# GTK
#
#-------------------------------------------------------------------------
from gi.repository import Gtk, GObject
from gi.repository import Gtk
from gramps.gen.const import GRAMPS_LOCALE as glocale
_ = glocale.translation.gettext
@@ -46,7 +46,7 @@ from gramps.gen.filters import CustomFilters
class FilterStore(Gtk.ListStore):
def __init__(self, local_filters=[], namespace="generic", default=""):
GObject.GObject.__init__(self, str)
Gtk.ListStore.__init__(self, str)
self.list_map = []
self.def_index = 0

View File

@@ -38,7 +38,6 @@ This module exports the Glade class.
#------------------------------------------------------------------------
import sys
import os
from gi.repository import GObject
from gi.repository import Gtk
#------------------------------------------------------------------------
@@ -77,7 +76,7 @@ class Glade(Gtk.Builder):
:rtype: object reference
:returns: reference to the newly-created Glade instance
"""
GObject.GObject.__init__(self)
Gtk.Builder.__init__(self)
self.set_translation_domain(glocale.get_localedomain())
filename_given = filename is not None

View File

@@ -60,7 +60,7 @@ class ErrorReportAssistant(Gtk.Assistant):
reporting system.
"""
def __init__(self, error_detail, rotate_handler, ownthread=False):
GObject.GObject.__init__(self)
Gtk.Assistant.__init__(self)
try:
# did we get a handler wrapping the error detail?

View File

@@ -170,7 +170,7 @@ class GuiStringOption(Gtk.Entry):
@type option: gen.plug.menu.StringOption
@return: nothing
"""
GObject.GObject.__init__(self)
Gtk.Entry.__init__(self)
self.__option = option
self.set_text( self.__option.get_value() )
@@ -309,7 +309,7 @@ class GuiNumberOption(Gtk.SpinButton):
import math
decimals = int(math.log10(step) * -1)
GObject.GObject.__init__(self, adjustment=adj, climb_rate=1, digits=decimals)
Gtk.SpinButton.__init__(self, adjustment=adj, climb_rate=1, digits=decimals)
Gtk.SpinButton.set_numeric(self, True)
self.set_value(self.__option.get_value())
@@ -368,7 +368,7 @@ class GuiTextOption(Gtk.ScrolledWindow):
"""
def __init__(self, option, dbstate, uistate, track, override):
self.__option = option
GObject.GObject.__init__(self)
Gtk.ScrolledWindow.__init__(self)
self.set_shadow_type(Gtk.ShadowType.IN)
self.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)
self.set_vexpand(True)
@@ -453,7 +453,7 @@ class GuiBooleanOption(Gtk.CheckButton):
"""
def __init__(self, option, dbstate, uistate, track, override):
self.__option = option
GObject.GObject.__init__(self)
Gtk.CheckButton.__init__(self)
self.set_label(self.__option.get_label())
self.set_active(self.__option.get_value())

View File

@@ -699,7 +699,7 @@ class PluginTrace(ManagedWindow):
#-------------------------------------------------------------------------
class LinkTag(Gtk.TextTag):
def __init__(self, link, buffer):
GObject.GObject.__init__(self, name=link)
Gtk.TextTag.__init__(self, name=link)
tag_table = buffer.get_tag_table()
self.set_property('foreground', "#0000ff")
self.set_property('underline', Pango.Underline.SINGLE)

View File

@@ -867,7 +867,7 @@ class _BookFormatComboBox(Gtk.ComboBox):
def __init__(self, active):
GObject.GObject.__init__(self)
Gtk.ComboBox.__init__(self)
pmgr = GuiPluginManager.get_instance()
self.__bookdoc_plugins = []

View File

@@ -48,7 +48,7 @@ class _DrawFormatComboBox(Gtk.ComboBox):
"""
def __init__(self, active):
GObject.GObject.__init__(self)
Gtk.ComboBox.__init__(self)
pmgr = GuiPluginManager.get_instance()
self.__drawdoc_plugins = []

View File

@@ -52,7 +52,7 @@ from ...glade import Glade
class PaperComboBox(Gtk.ComboBox):
def __init__(self,default_name):
GObject.GObject.__init__(self)
Gtk.ComboBox.__init__(self)
self.set_wrap_width(4)
self.store = Gtk.ListStore(GObject.TYPE_STRING)
@@ -94,7 +94,7 @@ class PaperComboBox(Gtk.ComboBox):
class OrientationComboBox(Gtk.ComboBox):
def __init__(self,default=PAPER_PORTRAIT):
GObject.GObject.__init__(self)
Gtk.ComboBox.__init__(self)
self.store = Gtk.ListStore(GObject.TYPE_STRING)
self.set_model(self.store)

View File

@@ -40,7 +40,7 @@ class StyleComboBox(Gtk.ComboBox):
"""
Initialize the combobox, building the display column.
"""
GObject.GObject.__init__(self)
Gtk.ComboBox.__init__(self)
self.set_model(model)
cell = Gtk.CellRendererText()
self.pack_start(cell,True)

View File

@@ -49,7 +49,7 @@ class _TextFormatComboBox(Gtk.ComboBox):
"""
def __init__(self, active):
GObject.GObject.__init__(self)
Gtk.ComboBox.__init__(self)
pmgr = GuiPluginManager.get_instance()
self.__textdoc_plugins = []

View File

@@ -33,7 +33,6 @@ _LOG = logging.getLogger(".widgets.basicentry")
# GTK/Gnome modules
#
#-------------------------------------------------------------------------
from gi.repository import GObject
from gi.repository import Gtk
#-------------------------------------------------------------------------
@@ -44,6 +43,6 @@ from gi.repository import Gtk
class BasicEntry(Gtk.Entry):
def __init__(self):
GObject.GObject.__init__(self)
Gtk.Entry.__init__(self)
self.set_width_chars(5)
self.show()

View File

@@ -36,7 +36,6 @@ _LOG = logging.getLogger(".widgets.buttons")
# GTK/Gnome modules
#
#-------------------------------------------------------------------------
from gi.repository import GObject
from gi.repository import Gdk
from gi.repository import Gtk
@@ -48,7 +47,7 @@ from gi.repository import Gtk
class IconButton(Gtk.Button):
def __init__(self, func, handle, icon='gtk-edit', size=Gtk.IconSize.MENU):
GObject.GObject.__init__(self)
Gtk.Button.__init__(self)
image = Gtk.Image()
image.set_from_icon_name(icon, size)
image.show()
@@ -73,7 +72,7 @@ class IconButton(Gtk.Button):
#-------------------------------------------------------------------------
class WarnButton(Gtk.Button):
def __init__(self):
GObject.GObject.__init__(self)
Gtk.Button.__init__(self)
image = Gtk.Image()
image.set_from_icon_name('dialog-information', Gtk.IconSize.MENU)
@@ -108,7 +107,7 @@ class WarnButton(Gtk.Button):
class SimpleButton(Gtk.Button):
def __init__(self, image, func):
GObject.GObject.__init__(self)
Gtk.Button.__init__(self)
self.set_relief(Gtk.ReliefStyle.NONE)
self.add(Gtk.Image.new_from_icon_name(image, Gtk.IconSize.BUTTON))
self.connect('clicked', func)

View File

@@ -36,7 +36,6 @@ _LOG = logging.getLogger(".widgets.expandcollapsearrow")
# GTK/Gnome modules
#
#-------------------------------------------------------------------------
from gi.repository import GObject
from gi.repository import Gtk
from gi.repository import Gdk
from gramps.gen.constfunc import has_display
@@ -79,7 +78,7 @@ class ExpandCollapseArrow(Gtk.EventBox):
:type onbuttonpress: callback
:param pair: user param for onbuttonpress function
"""
GObject.GObject.__init__(self)
Gtk.EventBox.__init__(self)
if collapsed :
self.arrow = Gtk.Arrow(arrow_type=Gtk.ArrowType.RIGHT,
shadow_type=Gtk.ShadowType.OUT)

View File

@@ -35,7 +35,6 @@
#
#-------------------------------------------------------------------------
from gi.repository import Pango
from gi.repository import GObject
from gi.repository import Gdk
from gi.repository import Gtk
from gi.repository import PangoCairo
@@ -119,7 +118,7 @@ class FanChartBaseWidget(Gtk.DrawingArea):
CENTER = 50 # pixel radius of center, changes per fanchart
def __init__(self, dbstate, uistate, callback_popup=None):
GObject.GObject.__init__(self)
Gtk.DrawingArea.__init__(self)
self.radialtext = True
st_cont = self.get_style_context()
col = st_cont.lookup_color('text_color')

View File

@@ -49,7 +49,6 @@ import io
# GNOME modules
#
#-------------------------------------------------------------------------
from gi.repository import GObject
from gi.repository import Gtk
#-------------------------------------------------------------------------
@@ -91,7 +90,7 @@ class GrampletBar(Gtk.Notebook):
A class which defines the graphical representation of the GrampletBar.
"""
def __init__(self, dbstate, uistate, pageview, configfile, defaults):
GObject.GObject.__init__(self)
Gtk.Notebook.__init__(self)
self.dbstate = dbstate
self.uistate = uistate
@@ -566,7 +565,7 @@ class TabGramplet(Gtk.ScrolledWindow, GuiGramplet):
"""
Internal constructor for GUI portion of a gramplet.
"""
GObject.GObject.__init__(self)
Gtk.ScrolledWindow.__init__(self)
GuiGramplet.__init__(self, pane, dbstate, uistate, title, **kwargs)
self.scrolledwindow = self

View File

@@ -28,7 +28,6 @@ GrampletView interface.
# Python modules
#
#-------------------------------------------------------------------------
from gi.repository import GObject
from gi.repository import Gdk
from gi.repository import Gtk
from gi.repository import Pango
@@ -206,7 +205,7 @@ class LinkTag(Gtk.TextTag):
def __init__(self, buffer):
LinkTag.lid += 1
GObject.GObject.__init__(self, name=str(LinkTag.lid))
Gtk.TextTag.__init__(self, name=str(LinkTag.lid))
tag_table = buffer.get_tag_table()
self.set_property('foreground', self.linkcolor)
#self.set_property('underline', Pango.Underline.SINGLE)
@@ -972,7 +971,7 @@ class GrampletPane(Gtk.ScrolledWindow):
def __init__(self, configfile, pageview, dbstate, uistate, **kwargs):
self._config = Configuration(self)
self.track = []
GObject.GObject.__init__(self)
Gtk.ScrolledWindow.__init__(self)
self.configfile = os.path.join(VERSION_DIR, "%s.ini" % configfile)
# default for new user; may be overridden in config:
self.column_count = kwargs.get("column_count", 2)

View File

@@ -38,7 +38,6 @@ _LOG = logging.getLogger(".widgets.labels")
# GTK/Gnome modules
#
#-------------------------------------------------------------------------
from gi.repository import GObject
from gi.repository import Gdk
from gi.repository import Gtk
from gi.repository import Pango
@@ -78,7 +77,7 @@ class LinkLabel(Gtk.EventBox):
self.theme = theme
self.emph = emph
GObject.GObject.__init__(self)
Gtk.EventBox.__init__(self)
st_cont = self.get_style_context()
col = st_cont.lookup_color('link_color')
@@ -204,7 +203,7 @@ class EditLabel(Gtk.Box):
class BasicLabel(Gtk.Label):
def __init__(self, text, ellipsize=Pango.EllipsizeMode.NONE):
GObject.GObject.__init__(self, label=text)
Gtk.Label.__init__(self, label=text)
self.set_halign(Gtk.Align.START)
self.set_ellipsize(ellipsize)
self.show()
@@ -217,7 +216,7 @@ class BasicLabel(Gtk.Label):
class GenderLabel(Gtk.Label):
def __init__(self, text):
GObject.GObject.__init__(self, label=text)
Gtk.Label.__init__(self, label=text)
self.set_halign(Gtk.Align.START)
if win():
pangoFont = Pango.FontDescription('Arial')
@@ -232,7 +231,7 @@ class GenderLabel(Gtk.Label):
class MarkupLabel(Gtk.Label):
def __init__(self, text, halign=Gtk.Align.START):
GObject.GObject.__init__(self, label=text)
Gtk.Label.__init__(self, label=text)
self.set_halign(halign)
self.set_use_markup(True)
self.show_all()

View File

@@ -51,7 +51,7 @@ class MenuItemWithData(Gtk.MenuItem):
data = GObject.Property(type=object)
def __init__(self, label=''):
GObject.GObject.__init__(self, label=label)
Gtk.MenuItem.__init__(self, label=label)
def set_data(self, data):
self.data = data

View File

@@ -22,7 +22,6 @@
# GTK/Gnome modules
#
#-------------------------------------------------------------------------
from gi.repository import GObject
from gi.repository import Gdk
from gi.repository import Gtk
@@ -47,7 +46,7 @@ class Photo(Gtk.EventBox):
Displays an image and allows it to be viewed in an external image viewer.
"""
def __init__(self, use_small_size=False):
GObject.GObject.__init__(self)
Gtk.EventBox.__init__(self)
self.full_path = None
self.uistate = None
self.handle = None

View File

@@ -38,7 +38,6 @@ log = logging.getLogger("gen.progressdialog")
# GTK modules
#
#-------------------------------------------------------------------------
from gi.repository import GObject
from gi.repository import Gtk
#-------------------------------------------------------------------------
@@ -494,8 +493,7 @@ class GtkProgressDialog(Gtk.Dialog):
:param title: The title to display on the top of the window.
:type title: string
"""
#GObject.GObject.__init__(self, *window_params)
GObject.GObject.__init__(self)
Gtk.Dialog.__init__(self)
if len(window_params) >= 2:
self.set_transient_for(window_params[1])
if len(window_params) >= 3:

View File

@@ -35,7 +35,6 @@ _LOG = logging.getLogger(".widgets.springseparator")
# GTK modules
#
#-------------------------------------------------------------------------
from gi.repository import GObject
from gi.repository import Gtk
#-------------------------------------------------------------------------
@@ -53,7 +52,7 @@ class SpringSeparatorToolItem(Gtk.SeparatorToolItem):
__gtype_name__ = "SpringSeparatorToolItem"
def __init__(self):
GObject.GObject.__init__(self)
Gtk.SeparatorToolItem.__init__(self)
self.set_draw(False)
self.set_expand(True)
@@ -69,8 +68,8 @@ class SpringSeparatorAction(Gtk.Action):
__gtype_name__ = "SpringSeparatorAction"
def __init__(self, name, label, tooltip, stock_id):
GObject.GObject.__init__(self, name=name, label=label,
tooltip=tooltip, stock_id=stock_id)
Gtk.Action.__init__(self, name=name, label=label,
tooltip=tooltip, stock_id=stock_id)
## TODO GTK3, How to connect these? Used in styledtexteditor
##SpringSeparatorToolItem.set_related_action(SpringSeparatorAction)

View File

@@ -100,7 +100,7 @@ class LinkTag(Gtk.TextTag):
def __init__(self, buffer, data, **properties):
LinkTag.lid += 1
self.data = data
GObject.GObject.__init__(self, name="link-%d" % LinkTag.lid)
Gtk.TextTag.__init__(self, name="link-%d" % LinkTag.lid)
tag_table = buffer.get_tag_table()
for property in properties:
self.set_property(property, properties[property])

View File

@@ -180,7 +180,7 @@ class StyledTextEditor(Gtk.TextView):
self.undo_disabled = self.textbuffer.undo_disabled # see bug 7097
self.textbuffer.connect('style-changed', self._on_buffer_style_changed)
self.textbuffer.connect('changed', self._on_buffer_changed)
GObject.GObject.__init__(self)
Gtk.TextView.__init__(self)
self.set_buffer(self.textbuffer)
st_cont = self.get_style_context()

View File

@@ -29,7 +29,6 @@ __all__ = ["UndoableBuffer"]
# http://bitbucket.org/tiax/gtk-textbuffer-with-undo/
# Please send bugfixes and comments upstream to Florian
from gi.repository import GObject
from gi.repository import Gtk
class Stack(list):
@@ -95,7 +94,7 @@ class UndoableBuffer(Gtk.TextBuffer):
"""
we'll need empty stacks for undo/redo and some state keeping
"""
GObject.GObject.__init__(self)
Gtk.TextBuffer.__init__(self)
self.undo_stack = Stack(self.undo_stack_size)
self.redo_stack = []
self.not_undoable_action = False

View File

@@ -39,7 +39,6 @@ _LOG = logging.getLogger(".widgets.undoableentry")
# GTK/Gnome modules
#
#-------------------------------------------------------------------------
from gi.repository import GObject
from gi.repository import Gdk
from gi.repository import Gtk
@@ -100,7 +99,7 @@ class UndoableEntry(Gtk.Entry):
undo_stack_size = 50
def __init__(self):
GObject.GObject.__init__(self)
Gtk.Entry.__init__(self)
self.undo_stack = Stack(self.undo_stack_size)
self.redo_stack = []
self.not_undoable_action = False

View File

@@ -35,7 +35,6 @@ _LOG = logging.getLogger(".widgets.validatedcomboentry")
# GTK modules
#
#-------------------------------------------------------------------------
from gi.repository import GObject
from gi.repository import Gdk
from gi.repository import Gtk
@@ -66,7 +65,6 @@ class ValidatedComboEntry(Gtk.ComboBox):
__gtype_name__ = "ValidatedComboEntry"
def __init__(self, datatype, model=None, column=-1, validator=None, width=-1):
#GObject.GObject.__init__(self, model)
Gtk.ComboBox.__init__(self, model=model)
self._entry = Gtk.Entry()

View File

@@ -82,8 +82,8 @@ class ValueAction(Gtk.Action):
at creation. see: :meth:`do_create_tool_item`
:type args: list
"""
GObject.GObject.__init__(self, name=name, label='', tooltip=tooltip,
stock_id=None)
Gtk.Action.__init__(self, name=name, label='', tooltip=tooltip,
stock_id=None)
self._value = default
self._data_type = type(default)

View File

@@ -60,7 +60,7 @@ class ValueToolItem(Gtk.ToolItem):
}
def __init__(self, data_type, args):
GObject.GObject.__init__(self)
Gtk.ToolItem.__init__(self)
self._data_type = data_type

View File

@@ -37,7 +37,6 @@ import pickle
# GTK/Gnome modules
#
#-------------------------------------------------------------------------
from gi.repository import GObject
from gi.repository import Gdk
from gi.repository import Gtk
from gi.repository import GdkPixbuf
@@ -92,7 +91,7 @@ class _PersonWidgetBase(Gtk.DrawingArea):
"""
def __init__(self, view, format_helper, person):
GObject.GObject.__init__(self)
Gtk.DrawingArea.__init__(self)
self.view = view
self.format_helper = format_helper
self.person = person
@@ -336,7 +335,7 @@ class LineWidget(Gtk.DrawingArea):
Draw lines linking Person boxes - Types A and C.
"""
def __init__(self, child, father, frel, mother, mrel, direction):
GObject.GObject.__init__(self)
Gtk.DrawingArea.__init__(self)
self.child_box = child
self.father_box = father
@@ -428,7 +427,7 @@ class LineWidget2(Gtk.DrawingArea):
Draw lines linking Person boxes - Type B.
"""
def __init__(self, male, rela, direction):
GObject.GObject.__init__(self)
Gtk.DrawingArea.__init__(self)
self.male = male
self.rela = rela