summaryrefslogtreecommitdiff
path: root/gi/overrides/Gtk.py
diff options
context:
space:
mode:
Diffstat (limited to 'gi/overrides/Gtk.py')
-rw-r--r--gi/overrides/Gtk.py524
1 files changed, 282 insertions, 242 deletions
diff --git a/gi/overrides/Gtk.py b/gi/overrides/Gtk.py
index 831401c..2c0e870 100644
--- a/gi/overrides/Gtk.py
+++ b/gi/overrides/Gtk.py
@@ -53,6 +53,7 @@ python module to use with Gtk 2.0"
class PyGTKDeprecationWarning(PyGIDeprecationWarning):
pass
+
__all__.append('PyGTKDeprecationWarning')
@@ -69,6 +70,7 @@ def _construct_target_list(targets):
target_entries.append(entry)
return target_entries
+
__all__.append('_construct_target_list')
@@ -202,210 +204,209 @@ Editable = override(Editable)
__all__.append("Editable")
-class Action(Gtk.Action):
- __init__ = deprecated_init(Gtk.Action.__init__,
- arg_names=('name', 'label', 'tooltip', 'stock_id'),
- category=PyGTKDeprecationWarning)
-
-Action = override(Action)
-__all__.append("Action")
-
-
-class RadioAction(Gtk.RadioAction):
- __init__ = deprecated_init(Gtk.RadioAction.__init__,
- arg_names=('name', 'label', 'tooltip', 'stock_id', 'value'),
- category=PyGTKDeprecationWarning)
-
-RadioAction = override(RadioAction)
-__all__.append("RadioAction")
+if Gtk._version in ("2.0", "3.0"):
+ class Action(Gtk.Action):
+ __init__ = deprecated_init(Gtk.Action.__init__,
+ arg_names=('name', 'label', 'tooltip', 'stock_id'),
+ category=PyGTKDeprecationWarning)
+
+ Action = override(Action)
+ __all__.append("Action")
+
+ class RadioAction(Gtk.RadioAction):
+ __init__ = deprecated_init(Gtk.RadioAction.__init__,
+ arg_names=('name', 'label', 'tooltip', 'stock_id', 'value'),
+ category=PyGTKDeprecationWarning)
+
+ RadioAction = override(RadioAction)
+ __all__.append("RadioAction")
+
+ class ActionGroup(Gtk.ActionGroup):
+ __init__ = deprecated_init(Gtk.ActionGroup.__init__,
+ arg_names=('name',),
+ category=PyGTKDeprecationWarning)
+
+ def add_actions(self, entries, user_data=None):
+ """
+ The add_actions() method is a convenience method that creates a number
+ of gtk.Action objects based on the information in the list of action
+ entry tuples contained in entries and adds them to the action group.
+ The entry tuples can vary in size from one to six items with the
+ following information:
+
+ * The name of the action. Must be specified.
+ * The stock id for the action. Optional with a default value of None
+ if a label is specified.
+ * The label for the action. This field should typically be marked
+ for translation, see the set_translation_domain() method. Optional
+ with a default value of None if a stock id is specified.
+ * The accelerator for the action, in the format understood by the
+ gtk.accelerator_parse() function. Optional with a default value of
+ None.
+ * The tooltip for the action. This field should typically be marked
+ for translation, see the set_translation_domain() method. Optional
+ with a default value of None.
+ * The callback function invoked when the action is activated.
+ Optional with a default value of None.
+
+ The "activate" signals of the actions are connected to the callbacks and
+ their accel paths are set to <Actions>/group-name/action-name.
+ """
+ try:
+ iter(entries)
+ except (TypeError):
+ raise TypeError('entries must be iterable')
+
+ def _process_action(name, stock_id=None, label=None, accelerator=None, tooltip=None, callback=None):
+ action = Action(name=name, label=label, tooltip=tooltip, stock_id=stock_id)
+ if callback is not None:
+ if user_data is None:
+ action.connect('activate', callback)
+ else:
+ action.connect('activate', callback, user_data)
+
+ self.add_action_with_accel(action, accelerator)
+
+ for e in entries:
+ # using inner function above since entries can leave out optional arguments
+ _process_action(*e)
+
+ def add_toggle_actions(self, entries, user_data=None):
+ """
+ The add_toggle_actions() method is a convenience method that creates a
+ number of gtk.ToggleAction objects based on the information in the list
+ of action entry tuples contained in entries and adds them to the action
+ group. The toggle action entry tuples can vary in size from one to seven
+ items with the following information:
+
+ * The name of the action. Must be specified.
+ * The stock id for the action. Optional with a default value of None
+ if a label is specified.
+ * The label for the action. This field should typically be marked
+ for translation, see the set_translation_domain() method. Optional
+ with a default value of None if a stock id is specified.
+ * The accelerator for the action, in the format understood by the
+ gtk.accelerator_parse() function. Optional with a default value of
+ None.
+ * The tooltip for the action. This field should typically be marked
+ for translation, see the set_translation_domain() method. Optional
+ with a default value of None.
+ * The callback function invoked when the action is activated.
+ Optional with a default value of None.
+ * A flag indicating whether the toggle action is active. Optional
+ with a default value of False.
+
+ The "activate" signals of the actions are connected to the callbacks and
+ their accel paths are set to <Actions>/group-name/action-name.
+ """
+ try:
+ iter(entries)
+ except (TypeError):
+ raise TypeError('entries must be iterable')
+
+ def _process_action(name, stock_id=None, label=None, accelerator=None, tooltip=None, callback=None, is_active=False):
+ action = Gtk.ToggleAction(name=name, label=label, tooltip=tooltip, stock_id=stock_id)
+ action.set_active(is_active)
+ if callback is not None:
+ if user_data is None:
+ action.connect('activate', callback)
+ else:
+ action.connect('activate', callback, user_data)
+
+ self.add_action_with_accel(action, accelerator)
+
+ for e in entries:
+ # using inner function above since entries can leave out optional arguments
+ _process_action(*e)
+
+ def add_radio_actions(self, entries, value=None, on_change=None, user_data=None):
+ """
+ The add_radio_actions() method is a convenience method that creates a
+ number of gtk.RadioAction objects based on the information in the list
+ of action entry tuples contained in entries and adds them to the action
+ group. The entry tuples can vary in size from one to six items with the
+ following information:
+
+ * The name of the action. Must be specified.
+ * The stock id for the action. Optional with a default value of None
+ if a label is specified.
+ * The label for the action. This field should typically be marked
+ for translation, see the set_translation_domain() method. Optional
+ with a default value of None if a stock id is specified.
+ * The accelerator for the action, in the format understood by the
+ gtk.accelerator_parse() function. Optional with a default value of
+ None.
+ * The tooltip for the action. This field should typically be marked
+ for translation, see the set_translation_domain() method. Optional
+ with a default value of None.
+ * The value to set on the radio action. Optional with a default
+ value of 0. Should be specified in applications.
+
+ The value parameter specifies the radio action that should be set
+ active. The "changed" signal of the first radio action is connected to
+ the on_change callback (if specified and not None) and the accel paths
+ of the actions are set to <Actions>/group-name/action-name.
+ """
+ try:
+ iter(entries)
+ except (TypeError):
+ raise TypeError('entries must be iterable')
-class ActionGroup(Gtk.ActionGroup):
- __init__ = deprecated_init(Gtk.ActionGroup.__init__,
- arg_names=('name',),
- category=PyGTKDeprecationWarning)
+ first_action = None
- def add_actions(self, entries, user_data=None):
- """
- The add_actions() method is a convenience method that creates a number
- of gtk.Action objects based on the information in the list of action
- entry tuples contained in entries and adds them to the action group.
- The entry tuples can vary in size from one to six items with the
- following information:
-
- * The name of the action. Must be specified.
- * The stock id for the action. Optional with a default value of None
- if a label is specified.
- * The label for the action. This field should typically be marked
- for translation, see the set_translation_domain() method. Optional
- with a default value of None if a stock id is specified.
- * The accelerator for the action, in the format understood by the
- gtk.accelerator_parse() function. Optional with a default value of
- None.
- * The tooltip for the action. This field should typically be marked
- for translation, see the set_translation_domain() method. Optional
- with a default value of None.
- * The callback function invoked when the action is activated.
- Optional with a default value of None.
-
- The "activate" signals of the actions are connected to the callbacks and
- their accel paths are set to <Actions>/group-name/action-name.
- """
- try:
- iter(entries)
- except (TypeError):
- raise TypeError('entries must be iterable')
+ def _process_action(group_source, name, stock_id=None, label=None, accelerator=None, tooltip=None, entry_value=0):
+ action = RadioAction(name=name, label=label, tooltip=tooltip, stock_id=stock_id, value=entry_value)
- def _process_action(name, stock_id=None, label=None, accelerator=None, tooltip=None, callback=None):
- action = Action(name=name, label=label, tooltip=tooltip, stock_id=stock_id)
- if callback is not None:
- if user_data is None:
- action.connect('activate', callback)
- else:
- action.connect('activate', callback, user_data)
+ # FIXME: join_group is a patch to Gtk+ 3.0
+ # otherwise we can't effectively add radio actions to a
+ # group. Should we depend on 3.0 and error out here
+ # or should we offer the functionality via a compat
+ # C module?
+ if hasattr(action, 'join_group'):
+ action.join_group(group_source)
- self.add_action_with_accel(action, accelerator)
+ if value == entry_value:
+ action.set_active(True)
- for e in entries:
- # using inner function above since entries can leave out optional arguments
- _process_action(*e)
+ self.add_action_with_accel(action, accelerator)
+ return action
- def add_toggle_actions(self, entries, user_data=None):
- """
- The add_toggle_actions() method is a convenience method that creates a
- number of gtk.ToggleAction objects based on the information in the list
- of action entry tuples contained in entries and adds them to the action
- group. The toggle action entry tuples can vary in size from one to seven
- items with the following information:
-
- * The name of the action. Must be specified.
- * The stock id for the action. Optional with a default value of None
- if a label is specified.
- * The label for the action. This field should typically be marked
- for translation, see the set_translation_domain() method. Optional
- with a default value of None if a stock id is specified.
- * The accelerator for the action, in the format understood by the
- gtk.accelerator_parse() function. Optional with a default value of
- None.
- * The tooltip for the action. This field should typically be marked
- for translation, see the set_translation_domain() method. Optional
- with a default value of None.
- * The callback function invoked when the action is activated.
- Optional with a default value of None.
- * A flag indicating whether the toggle action is active. Optional
- with a default value of False.
-
- The "activate" signals of the actions are connected to the callbacks and
- their accel paths are set to <Actions>/group-name/action-name.
- """
+ for e in entries:
+ # using inner function above since entries can leave out optional arguments
+ action = _process_action(first_action, *e)
+ if first_action is None:
+ first_action = action
- try:
- iter(entries)
- except (TypeError):
- raise TypeError('entries must be iterable')
-
- def _process_action(name, stock_id=None, label=None, accelerator=None, tooltip=None, callback=None, is_active=False):
- action = Gtk.ToggleAction(name=name, label=label, tooltip=tooltip, stock_id=stock_id)
- action.set_active(is_active)
- if callback is not None:
+ if first_action is not None and on_change is not None:
if user_data is None:
- action.connect('activate', callback)
+ first_action.connect('changed', on_change)
else:
- action.connect('activate', callback, user_data)
-
- self.add_action_with_accel(action, accelerator)
-
- for e in entries:
- # using inner function above since entries can leave out optional arguments
- _process_action(*e)
-
- def add_radio_actions(self, entries, value=None, on_change=None, user_data=None):
- """
- The add_radio_actions() method is a convenience method that creates a
- number of gtk.RadioAction objects based on the information in the list
- of action entry tuples contained in entries and adds them to the action
- group. The entry tuples can vary in size from one to six items with the
- following information:
-
- * The name of the action. Must be specified.
- * The stock id for the action. Optional with a default value of None
- if a label is specified.
- * The label for the action. This field should typically be marked
- for translation, see the set_translation_domain() method. Optional
- with a default value of None if a stock id is specified.
- * The accelerator for the action, in the format understood by the
- gtk.accelerator_parse() function. Optional with a default value of
- None.
- * The tooltip for the action. This field should typically be marked
- for translation, see the set_translation_domain() method. Optional
- with a default value of None.
- * The value to set on the radio action. Optional with a default
- value of 0. Should be specified in applications.
-
- The value parameter specifies the radio action that should be set
- active. The "changed" signal of the first radio action is connected to
- the on_change callback (if specified and not None) and the accel paths
- of the actions are set to <Actions>/group-name/action-name.
- """
- try:
- iter(entries)
- except (TypeError):
- raise TypeError('entries must be iterable')
-
- first_action = None
-
- def _process_action(group_source, name, stock_id=None, label=None, accelerator=None, tooltip=None, entry_value=0):
- action = RadioAction(name=name, label=label, tooltip=tooltip, stock_id=stock_id, value=entry_value)
-
- # FIXME: join_group is a patch to Gtk+ 3.0
- # otherwise we can't effectively add radio actions to a
- # group. Should we depend on 3.0 and error out here
- # or should we offer the functionality via a compat
- # C module?
- if hasattr(action, 'join_group'):
- action.join_group(group_source)
-
- if value == entry_value:
- action.set_active(True)
-
- self.add_action_with_accel(action, accelerator)
- return action
-
- for e in entries:
- # using inner function above since entries can leave out optional arguments
- action = _process_action(first_action, *e)
- if first_action is None:
- first_action = action
-
- if first_action is not None and on_change is not None:
- if user_data is None:
- first_action.connect('changed', on_change)
- else:
- first_action.connect('changed', on_change, user_data)
+ first_action.connect('changed', on_change, user_data)
-ActionGroup = override(ActionGroup)
-__all__.append('ActionGroup')
+ ActionGroup = override(ActionGroup)
+ __all__.append('ActionGroup')
+ class UIManager(Gtk.UIManager):
+ def add_ui_from_string(self, buffer):
+ if not isinstance(buffer, _basestring):
+ raise TypeError('buffer must be a string')
-class UIManager(Gtk.UIManager):
- def add_ui_from_string(self, buffer):
- if not isinstance(buffer, _basestring):
- raise TypeError('buffer must be a string')
+ length = len(buffer.encode('UTF-8'))
- length = len(buffer.encode('UTF-8'))
+ return Gtk.UIManager.add_ui_from_string(self, buffer, length)
- return Gtk.UIManager.add_ui_from_string(self, buffer, length)
+ def insert_action_group(self, buffer, length=-1):
+ return Gtk.UIManager.insert_action_group(self, buffer, length)
- def insert_action_group(self, buffer, length=-1):
- return Gtk.UIManager.insert_action_group(self, buffer, length)
-
-UIManager = override(UIManager)
-__all__.append('UIManager')
+ UIManager = override(UIManager)
+ __all__.append('UIManager')
class ComboBox(Gtk.ComboBox, Container):
get_active_iter = strip_boolean_result(Gtk.ComboBox.get_active_iter)
+
ComboBox = override(ComboBox)
__all__.append('ComboBox')
@@ -415,6 +416,7 @@ class Box(Gtk.Box):
arg_names=('homogeneous', 'spacing'),
category=PyGTKDeprecationWarning)
+
Box = override(Box)
__all__.append('Box')
@@ -425,6 +427,7 @@ class SizeGroup(Gtk.SizeGroup):
deprecated_defaults={'mode': Gtk.SizeGroupMode.VERTICAL},
category=PyGTKDeprecationWarning)
+
SizeGroup = override(SizeGroup)
__all__.append('SizeGroup')
@@ -434,6 +437,7 @@ class MenuItem(Gtk.MenuItem):
arg_names=('label',),
category=PyGTKDeprecationWarning)
+
MenuItem = override(MenuItem)
__all__.append('MenuItem')
@@ -469,6 +473,7 @@ class Builder(Gtk.Builder):
return Gtk.Builder.add_objects_from_string(self, buffer, length, object_ids)
+
Builder = override(Builder)
__all__.append('Builder')
@@ -482,6 +487,7 @@ class Window(Gtk.Window):
arg_names=('type',),
category=PyGTKDeprecationWarning)
+
Window = override(Window)
__all__.append('Window')
@@ -568,6 +574,7 @@ class Dialog(Gtk.Dialog, Container):
except (IndexError):
raise TypeError('Must pass an even number of arguments')
+
Dialog = override(Dialog)
__all__.append('Dialog')
@@ -588,17 +595,19 @@ class MessageDialog(Gtk.MessageDialog, Dialog):
self.set_property('secondary-use-markup', True)
self.set_property('secondary-text', message_format)
+
MessageDialog = override(MessageDialog)
__all__.append('MessageDialog')
-class ColorSelectionDialog(Gtk.ColorSelectionDialog):
- __init__ = deprecated_init(Gtk.ColorSelectionDialog.__init__,
- arg_names=('title',),
- category=PyGTKDeprecationWarning)
+if Gtk._version in ("2.0", "3.0"):
+ class ColorSelectionDialog(Gtk.ColorSelectionDialog):
+ __init__ = deprecated_init(Gtk.ColorSelectionDialog.__init__,
+ arg_names=('title',),
+ category=PyGTKDeprecationWarning)
-ColorSelectionDialog = override(ColorSelectionDialog)
-__all__.append('ColorSelectionDialog')
+ ColorSelectionDialog = override(ColorSelectionDialog)
+ __all__.append('ColorSelectionDialog')
class FileChooserDialog(Gtk.FileChooserDialog):
@@ -606,17 +615,19 @@ class FileChooserDialog(Gtk.FileChooserDialog):
arg_names=('title', 'parent', 'action', 'buttons'),
category=PyGTKDeprecationWarning)
+
FileChooserDialog = override(FileChooserDialog)
__all__.append('FileChooserDialog')
-class FontSelectionDialog(Gtk.FontSelectionDialog):
- __init__ = deprecated_init(Gtk.FontSelectionDialog.__init__,
- arg_names=('title',),
- category=PyGTKDeprecationWarning)
+if Gtk._version in ("2.0", "3.0"):
+ class FontSelectionDialog(Gtk.FontSelectionDialog):
+ __init__ = deprecated_init(Gtk.FontSelectionDialog.__init__,
+ arg_names=('title',),
+ category=PyGTKDeprecationWarning)
-FontSelectionDialog = override(FontSelectionDialog)
-__all__.append('FontSelectionDialog')
+ FontSelectionDialog = override(FontSelectionDialog)
+ __all__.append('FontSelectionDialog')
class RecentChooserDialog(Gtk.RecentChooserDialog):
@@ -627,6 +638,7 @@ class RecentChooserDialog(Gtk.RecentChooserDialog):
deprecated_aliases={'recent_manager': 'manager'},
category=PyGTKDeprecationWarning)
+
RecentChooserDialog = override(RecentChooserDialog)
__all__.append('RecentChooserDialog')
@@ -640,6 +652,7 @@ class IconView(Gtk.IconView):
get_visible_range = strip_boolean_result(Gtk.IconView.get_visible_range)
get_dest_item_at_pos = strip_boolean_result(Gtk.IconView.get_dest_item_at_pos)
+
IconView = override(IconView)
__all__.append('IconView')
@@ -649,6 +662,7 @@ class ToolButton(Gtk.ToolButton):
arg_names=('stock_id',),
category=PyGTKDeprecationWarning)
+
ToolButton = override(ToolButton)
__all__.append('ToolButton')
@@ -656,6 +670,7 @@ __all__.append('ToolButton')
class IMContext(Gtk.IMContext):
get_surrounding = strip_boolean_result(Gtk.IMContext.get_surrounding)
+
IMContext = override(IMContext)
__all__.append('IMContext')
@@ -663,6 +678,7 @@ __all__.append('IMContext')
class RecentInfo(Gtk.RecentInfo):
get_application_info = strip_boolean_result(Gtk.RecentInfo.get_application_info)
+
RecentInfo = override(RecentInfo)
__all__.append('RecentInfo')
@@ -750,6 +766,7 @@ class TextBuffer(Gtk.TextBuffer):
get_selection_bounds = strip_boolean_result(Gtk.TextBuffer.get_selection_bounds, fail_ret=())
+
TextBuffer = override(TextBuffer)
__all__.append('TextBuffer')
@@ -758,6 +775,7 @@ class TextIter(Gtk.TextIter):
forward_search = strip_boolean_result(Gtk.TextIter.forward_search)
backward_search = strip_boolean_result(Gtk.TextIter.backward_search)
+
TextIter = override(TextIter)
__all__.append('TextIter')
@@ -924,6 +942,7 @@ class TreeSortable(Gtk.TreeSortable, ):
def set_default_sort_func(self, sort_func, user_data=None):
super(TreeSortable, self).set_default_sort_func(sort_func, user_data)
+
TreeSortable = override(TreeSortable)
__all__.append('TreeSortable')
@@ -933,6 +952,7 @@ class TreeModelSort(Gtk.TreeModelSort):
arg_names=('model',),
category=PyGTKDeprecationWarning)
+
TreeModelSort = override(TreeModelSort)
__all__.append('TreeModelSort')
@@ -1017,6 +1037,7 @@ class ListStore(Gtk.ListStore, TreeModel, TreeSortable):
else:
raise TypeError('Argument list must be in the form of (column, value, ...), ((columns,...), (values, ...)) or {column: value}. No -1 termination is needed.')
+
ListStore = override(ListStore)
__all__.append('ListStore')
@@ -1123,6 +1144,7 @@ class TreeModelRow(object):
child_iter = self.model.iter_children(self.iter)
return TreeModelRowIter(self.model, child_iter)
+
__all__.append('TreeModelRow')
@@ -1145,6 +1167,7 @@ class TreeModelRowIter(object):
def __iter__(self):
return self
+
__all__.append('TreeModelRowIter')
@@ -1196,6 +1219,7 @@ class TreePath(Gtk.TreePath):
def __getitem__(self, index):
return self.get_indices()[index]
+
TreePath = override(TreePath)
__all__.append('TreePath')
@@ -1275,6 +1299,7 @@ class TreeStore(Gtk.TreeStore, TreeModel, TreeSortable):
else:
raise TypeError('Argument list must be in the form of (column, value, ...), ((columns,...), (values, ...)) or {column: value}. No -1 termination is needed.')
+
TreeStore = override(TreeStore)
__all__.append('TreeStore')
@@ -1321,6 +1346,7 @@ class TreeView(Gtk.TreeView, Container):
self.insert_column(column, position)
column.set_attributes(cell, **kwargs)
+
TreeView = override(TreeView)
__all__.append('TreeView')
@@ -1402,6 +1428,7 @@ class Button(Gtk.Button, Container):
else:
self._init(*args, **kwargs)
+
Button = override(Button)
__all__.append('Button')
@@ -1411,6 +1438,7 @@ class LinkButton(Gtk.LinkButton):
arg_names=('uri', 'label'),
category=PyGTKDeprecationWarning)
+
LinkButton = override(LinkButton)
__all__.append('LinkButton')
@@ -1420,6 +1448,7 @@ class Label(Gtk.Label):
arg_names=('label',),
category=PyGTKDeprecationWarning)
+
Label = override(Label)
__all__.append('Label')
@@ -1442,21 +1471,23 @@ class Adjustment(Gtk.Adjustment):
if 'value' in kwargs:
self.set_value(kwargs['value'])
+
Adjustment = override(Adjustment)
__all__.append('Adjustment')
-class Table(Gtk.Table, Container):
- __init__ = deprecated_init(Gtk.Table.__init__,
- arg_names=('n_rows', 'n_columns', 'homogeneous'),
- deprecated_aliases={'n_rows': 'rows', 'n_columns': 'columns'},
- category=PyGTKDeprecationWarning)
+if Gtk._version in ("2.0", "3.0"):
+ class Table(Gtk.Table, Container):
+ __init__ = deprecated_init(Gtk.Table.__init__,
+ arg_names=('n_rows', 'n_columns', 'homogeneous'),
+ deprecated_aliases={'n_rows': 'rows', 'n_columns': 'columns'},
+ category=PyGTKDeprecationWarning)
- def attach(self, child, left_attach, right_attach, top_attach, bottom_attach, xoptions=Gtk.AttachOptions.EXPAND | Gtk.AttachOptions.FILL, yoptions=Gtk.AttachOptions.EXPAND | Gtk.AttachOptions.FILL, xpadding=0, ypadding=0):
- Gtk.Table.attach(self, child, left_attach, right_attach, top_attach, bottom_attach, xoptions, yoptions, xpadding, ypadding)
+ def attach(self, child, left_attach, right_attach, top_attach, bottom_attach, xoptions=Gtk.AttachOptions.EXPAND | Gtk.AttachOptions.FILL, yoptions=Gtk.AttachOptions.EXPAND | Gtk.AttachOptions.FILL, xpadding=0, ypadding=0):
+ Gtk.Table.attach(self, child, left_attach, right_attach, top_attach, bottom_attach, xoptions, yoptions, xpadding, ypadding)
-Table = override(Table)
-__all__.append('Table')
+ Table = override(Table)
+ __all__.append('Table')
class ScrolledWindow(Gtk.ScrolledWindow):
@@ -1464,26 +1495,27 @@ class ScrolledWindow(Gtk.ScrolledWindow):
arg_names=('hadjustment', 'vadjustment'),
category=PyGTKDeprecationWarning)
+
ScrolledWindow = override(ScrolledWindow)
__all__.append('ScrolledWindow')
-class HScrollbar(Gtk.HScrollbar):
- __init__ = deprecated_init(Gtk.HScrollbar.__init__,
- arg_names=('adjustment',),
- category=PyGTKDeprecationWarning)
-
-HScrollbar = override(HScrollbar)
-__all__.append('HScrollbar')
+if Gtk._version in ("2.0", "3.0"):
+ class HScrollbar(Gtk.HScrollbar):
+ __init__ = deprecated_init(Gtk.HScrollbar.__init__,
+ arg_names=('adjustment',),
+ category=PyGTKDeprecationWarning)
+ HScrollbar = override(HScrollbar)
+ __all__.append('HScrollbar')
-class VScrollbar(Gtk.VScrollbar):
- __init__ = deprecated_init(Gtk.VScrollbar.__init__,
- arg_names=('adjustment',),
- category=PyGTKDeprecationWarning)
+ class VScrollbar(Gtk.VScrollbar):
+ __init__ = deprecated_init(Gtk.VScrollbar.__init__,
+ arg_names=('adjustment',),
+ category=PyGTKDeprecationWarning)
-VScrollbar = override(VScrollbar)
-__all__.append('VScrollbar')
+ VScrollbar = override(VScrollbar)
+ __all__.append('VScrollbar')
class Paned(Gtk.Paned):
@@ -1493,35 +1525,36 @@ class Paned(Gtk.Paned):
def pack2(self, child, resize=True, shrink=True):
super(Paned, self).pack2(child, resize, shrink)
+
Paned = override(Paned)
__all__.append('Paned')
-class Arrow(Gtk.Arrow):
- __init__ = deprecated_init(Gtk.Arrow.__init__,
- arg_names=('arrow_type', 'shadow_type'),
- category=PyGTKDeprecationWarning)
+if Gtk._version in ("2.0", "3.0"):
+ class Arrow(Gtk.Arrow):
+ __init__ = deprecated_init(Gtk.Arrow.__init__,
+ arg_names=('arrow_type', 'shadow_type'),
+ category=PyGTKDeprecationWarning)
-Arrow = override(Arrow)
-__all__.append('Arrow')
+ Arrow = override(Arrow)
+ __all__.append('Arrow')
+ class IconSet(Gtk.IconSet):
+ def __new__(cls, pixbuf=None):
+ if pixbuf is not None:
+ warnings.warn('Gtk.IconSet(pixbuf) has been deprecated. Please use: '
+ 'Gtk.IconSet.new_from_pixbuf(pixbuf)',
+ PyGTKDeprecationWarning, stacklevel=2)
+ iconset = Gtk.IconSet.new_from_pixbuf(pixbuf)
+ else:
+ iconset = Gtk.IconSet.__new__(cls)
+ return iconset
-class IconSet(Gtk.IconSet):
- def __new__(cls, pixbuf=None):
- if pixbuf is not None:
- warnings.warn('Gtk.IconSet(pixbuf) has been deprecated. Please use: '
- 'Gtk.IconSet.new_from_pixbuf(pixbuf)',
- PyGTKDeprecationWarning, stacklevel=2)
- iconset = Gtk.IconSet.new_from_pixbuf(pixbuf)
- else:
- iconset = Gtk.IconSet.__new__(cls)
- return iconset
-
- def __init__(self, *args, **kwargs):
- return super(IconSet, self).__init__()
+ def __init__(self, *args, **kwargs):
+ return super(IconSet, self).__init__()
-IconSet = override(IconSet)
-__all__.append('IconSet')
+ IconSet = override(IconSet)
+ __all__.append('IconSet')
class Viewport(Gtk.Viewport):
@@ -1529,6 +1562,7 @@ class Viewport(Gtk.Viewport):
arg_names=('hadjustment', 'vadjustment'),
category=PyGTKDeprecationWarning)
+
Viewport = override(Viewport)
__all__.append('Viewport')
@@ -1542,6 +1576,7 @@ class TreeModelFilter(Gtk.TreeModelFilter):
iter = self.convert_iter_to_child_iter(iter)
self.get_model().set_value(iter, column, value)
+
TreeModelFilter = override(TreeModelFilter)
__all__.append('TreeModelFilter')
@@ -1559,8 +1594,13 @@ _Gtk_main_quit = Gtk.main_quit
def main_quit(*args):
_Gtk_main_quit()
-stock_lookup = strip_boolean_result(Gtk.stock_lookup)
-__all__.append('stock_lookup')
-initialized, argv = Gtk.init_check(sys.argv)
-sys.argv = list(argv)
+if Gtk._version in ("2.0", "3.0"):
+ stock_lookup = strip_boolean_result(Gtk.stock_lookup)
+ __all__.append('stock_lookup')
+
+if Gtk._version == "4.0":
+ Gtk.init_check()
+else:
+ initialized, argv = Gtk.init_check(sys.argv)
+ sys.argv = list(argv)