Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 3 additions & 7 deletions odmlui/__main__.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,14 @@
#!/usr/bin/env python
import os

import pygtkcompat

import gtk
import gi
gi.require_version("Gtk", "3.0")
from gi.repository import Gtk as gtk

import odmlui

from .editor import register_stock_icons, EditorWindow
from .helpers import path_to_uri

pygtkcompat.enable()
pygtkcompat.enable_gtk(version='3.0')


def main(filenames=None, debug=False):
"""
Expand Down
8 changes: 1 addition & 7 deletions odmlui/attribute_view.py
Original file line number Diff line number Diff line change
@@ -1,20 +1,14 @@
import pygtkcompat

try: # Python 3
from html import escape as html_escape
except ImportError: # Python 2
from cgi import escape as html_escape

from odml import format as ofmt

import gtk
from gi.repository import Gtk as gtk

from . import commands
from .tree_view import TreeView

pygtkcompat.enable()
pygtkcompat.enable_gtk(version='3.0')

COL_KEY = 0
COL_VALUE = 1

Expand Down
7 changes: 1 addition & 6 deletions odmlui/chooser_dialog.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,7 @@
"""
'chooser_dialog' contains odML specific file chooser widget classes.
"""

import pygtkcompat
import gtk

pygtkcompat.enable()
pygtkcompat.enable_gtk(version='3.0')
from gi.repository import Gtk as gtk


class ChooserDialog(gtk.FileChooserDialog):
Expand Down
6 changes: 1 addition & 5 deletions odmlui/drag_provider.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
import pygtkcompat
import gtk
from gi.repository import Gtk as gtk

from .dnd.drag import DragTarget
from .dnd.drop import DropTarget

pygtkcompat.enable()
pygtkcompat.enable_gtk(version='3.0')


class DragProvider(object):
"""
Expand Down
16 changes: 5 additions & 11 deletions odmlui/editor.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@

import time
import threading
from gi.repository import GLib, GObject

import pygtkcompat
from gi.repository import GLib
from gi.repository import GObject
from gi.repository import Gtk as gtk

from odml.property import BaseProperty
import odml.terminology as terminology
Expand All @@ -19,9 +19,6 @@
from odmlui.info import AUTHOR, CONTACT, COPYRIGHT, HOMEPAGE, VERSION, ODMLTABLES_VERSION
from odmlui.treemodel import section_model, value_model

import gtk
import gobject

from .attribute_view import AttributeView
from .chooser_dialog import OdmlChooserDialog
from .document_registry import DocumentRegistry
Expand All @@ -36,9 +33,6 @@
from .section_view import SectionView
from .wizard import DocumentWizard

pygtkcompat.enable()
pygtkcompat.enable_gtk(version='3.0')

GObject.threads_init()

UI_INFO = \
Expand Down Expand Up @@ -234,7 +228,7 @@ def __init__(self, parent=None):

try:
mergeid = merge.add_ui_from_string(UI_INFO)
except gobject.GError as msg:
except GObject.GError as msg:
print("building menus failed: %s" % msg)
menu_bar = merge.get_widget("/MenuBar")
menu_bar.show()
Expand Down Expand Up @@ -1243,7 +1237,7 @@ def register_stock_icons():

factory.add(icon_name, icon_set)

except gobject.GError as error:
except GObject.GError as error:
print('[Warning] Failed to load icon', icon_name, error)


Expand Down
9 changes: 2 additions & 7 deletions odmlui/info_bar.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,8 @@
"""
The 'info_bar' module provides a class for the app specific message bar.
"""

import pygtkcompat
import glib
import gtk

pygtkcompat.enable()
pygtkcompat.enable_gtk(version='3.0')
from gi.repository import Gtk as gtk
from gi.repository import GLib as glib


class EditorInfoBar(gtk.InfoBar):
Expand Down
7 changes: 1 addition & 6 deletions odmlui/message_dialog.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,4 @@
import pygtkcompat

import gtk

pygtkcompat.enable()
pygtkcompat.enable_gtk(version='3.0')
from gi.repository import Gtk as gtk


class MessageDialog(gtk.MessageDialog):
Expand Down
8 changes: 1 addition & 7 deletions odmlui/navigation_bar.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,7 @@
This class provides functionality to browse from
a currently selected model object to the document root.
"""

import pygtkcompat

import gtk

pygtkcompat.enable()
pygtkcompat.enable_gtk(version='3.0')
from gi.repository import Gtk as gtk


class NavigationBar(gtk.Label):
Expand Down
8 changes: 1 addition & 7 deletions odmlui/property_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,14 @@
The 'property_view' module provides a class to display and edit odml.Properties
and their attributes and Values.
"""

import pygtkcompat
from gi.repository import Gtk as gtk

import odml
import odml.dtypes as dtypes

from odml import DType
from odml.property import BaseProperty

import gtk

from . import commands
from . import text_editor
from .drag_provider import DragProvider
Expand All @@ -24,9 +21,6 @@
from .dnd.text import TextDrag, TextDrop, TextGenericDropForPropertyTV
from .message_dialog import DecisionDialog

pygtkcompat.enable()
pygtkcompat.enable_gtk(version='3.0')


class PropertyView(TerminologyPopupTreeView):
"""
Expand Down
7 changes: 1 addition & 6 deletions odmlui/scrolled_window.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,4 @@
import pygtkcompat

import gtk

pygtkcompat.enable()
pygtkcompat.enable_gtk(version='3.0')
from gi.repository import Gtk as gtk


class ScrolledWindow(gtk.ScrolledWindow):
Expand Down
5 changes: 0 additions & 5 deletions odmlui/section_view.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import pygtkcompat

import odml

from odml.section import BaseSection
Expand All @@ -12,9 +10,6 @@
from .helpers import handle_section_import
from .tree_view import TerminologyPopupTreeView

pygtkcompat.enable()
pygtkcompat.enable_gtk(version='3.0')


class SectionView(TerminologyPopupTreeView):
"""
Expand Down
8 changes: 1 addition & 7 deletions odmlui/text_editor.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,12 @@
"""
'text_editor' provides a simple TextEditor Window class.
"""

import pygtkcompat

import gtk
from gi.repository import Gtk as gtk

from .commands import ChangeValue
from .scrolled_window import ScrolledWindow
from .treemodel.value_model import Value

pygtkcompat.enable()
pygtkcompat.enable_gtk(version='3.0')


class TextEditor(gtk.Window):
"""
Expand Down
8 changes: 1 addition & 7 deletions odmlui/tree_view.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,7 @@
import heapq
import pygtkcompat

import gtk

from gi.repository import Gtk as gtk
from . import commands

pygtkcompat.enable()
pygtkcompat.enable_gtk(version='3.0')


class TreeView(object):
"""
Expand Down
5 changes: 0 additions & 5 deletions odmlui/treemodel/property_model.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,10 @@
import pygtkcompat

from odml.property import BaseProperty
from odml.section import BaseSection

from .tree_iters import PropIter, ValueIter, SectionPropertyIter
from .tree_model import TreeModel, ColumnMapper
from . import value_model

pygtkcompat.enable()
pygtkcompat.enable_gtk(version='3.0')


COL_MAPPER = ColumnMapper({"Name": (0, "name"),
"Value": (1, "pseudo_values"),
Expand Down
8 changes: 1 addition & 7 deletions odmlui/validation_window.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,11 @@
"""

import sys

import pygtkcompat

import gtk
from gi.repository import Gtk as gtk

from .scrolled_window import ScrolledWindow
from .tree_view import TreeView

pygtkcompat.enable()
pygtkcompat.enable_gtk(version='3.0')

COL_PATH = 0
COL_INDEX = 1
COL_DESC = 2
Expand Down
7 changes: 1 addition & 6 deletions odmlui/wizard.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,16 @@

from collections import OrderedDict

import pygtkcompat

import odml
import odml.terminology as terminology

import gtk
from gi.repository import Gtk as gtk

from .helpers import handle_property_import, get_username
from .treemodel.section_model import SectionModel
from .section_view import SectionView
from .scrolled_window import ScrolledWindow

pygtkcompat.enable()
pygtkcompat.enable_gtk(version='3.0')


class Table(object):
"""
Expand Down
8 changes: 3 additions & 5 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,9 @@ class PackageNotFoundError(Exception):
dep_str = "Non-Python dependency missing, please check the %s file." % README
try:
import gi
import pygtkcompat
pygtkcompat.enable()
pygtkcompat.enable_gtk(version="3.0")
import gtk
import gobject
gi.require_version("Gtk", "3.0")
from gi.repository import Gtk
from gi.repository import GObject
except (ImportError, ValueError) as err:
err_str = ("\n Error: %s\n\n %s" % (err, dep_str))
raise PackageNotFoundError(err_str)
Expand Down