Esempio n. 1
0
    def _on_export_image_activate(self, *args):
        """Export document as an image file."""
        dialog = nfoview.ExportImageDialog(self)
        directory = os.path.dirname(self.path)
        dialog.set_current_folder(directory)
        basename = os.path.basename(self.path)
        dialog.set_current_name("{}.png".format(basename))
        response = dialog.run()
        path = dialog.get_filename()
        dialog.destroy()
        if response != Gtk.ResponseType.OK: return
        if not path: return
        view = nfoview.TextView()
        view.set_text(self.view.get_text())
        window = Gtk.OffscreenWindow()
        window.nfoview_path = path
        window.add(view)

        def on_damage_event(window, *args):
            pixbuf = window.get_pixbuf()
            pixbuf.savev(window.nfoview_path, "png", [], [])

        window.connect("damage-event", on_damage_event)
        window.show_all()
        while Gtk.events_pending():
            Gtk.main_iteration()
Esempio n. 2
0
 def __init__(self, path=None):
     GObject.GObject.__init__(self)
     self._about_dialog = None
     self.path = path
     self._preferences_dialog = None
     self.view = nfoview.TextView()
     self._init_properties()
     self._init_titlebar()
     self._init_contents()
     self._init_view()
     self._init_actions()
     if self.path is not None:
         self.open_file(self.path)
     self.resize_to_text()
     self._update_actions_enabled()
Esempio n. 3
0
 def __init__(self, path=None):
     """Initialize a :class:`Window` instance and open file at `path`."""
     GObject.GObject.__init__(self)
     self._about_dialog = None
     self.path = path
     self._preferences_dialog = None
     self.view = nfoview.TextView()
     self._init_properties()
     self._init_titlebar()
     self._init_contents()
     self._init_view()
     self._init_actions()
     if self.path is not None:
         self.open_file(self.path)
     self.resize_to_text()
     self._update_actions_enabled()
Esempio n. 4
0
 def __init__(self, path=None):
     """Initialize a :class:`Window` instance and open file at `path`."""
     GObject.GObject.__init__(self)
     self._about_dialog = None
     self._actions = []
     self.path = path
     self._preferences_dialog = None
     self._uim = Gtk.UIManager()
     self.view = nfoview.TextView()
     self._init_uim()
     self._init_properties()
     self._init_keys()
     self._init_contents()
     self._init_view()
     if self.path is not None:
         self.open_file(self.path)
     self.resize_to_text()
     self._update_action_sensitivities()
Esempio n. 5
0
 def setup_method(self, method):
     self.view = nfoview.TextView()
     text = "testing...\nhttps://otsaloma.io/nfoview/"
     self.view.set_text(text)
Esempio n. 6
0
 def setup_method(self, method):
     self.view = nfoview.TextView()
     text = "testing...\nhttp://home.gna.org/nfoview"
     self.view.set_text(text)