Skip to content

Commit

Permalink
Add undo functionality (fixes #19)
Browse files Browse the repository at this point in the history
  • Loading branch information
innir committed Jan 3, 2023
1 parent ea6d99c commit d4ba34b
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 10 deletions.
1 change: 1 addition & 0 deletions README
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ Homepage: https://github.com/innir/gtranscribe
- python3-gi
- python3-dbus
- gir1.2-gtk-3.0
- gir1.2-gtksource-3.0
- gir1.2-glib-2.0
- gir1.2-gspell-1
- gir1.2-gstreamer-1.0
Expand Down
9 changes: 6 additions & 3 deletions bin/gtranscribe
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,9 @@ import dbus
from dbus.mainloop.glib import DBusGMainLoop
import gi
gi.require_version('Gtk', '3.0')
from gi.repository import GLib, Gtk, Gdk, GdkPixbuf
from gi.repository import GLib, Gtk, Gdk, GdkPixbuf, GObject
gi.require_version('GtkSource', '3.0')
from gi.repository import GtkSource
gi.require_version('Gspell', '1')
from gi.repository import Gspell

Expand All @@ -52,7 +54,7 @@ locale.setlocale(locale.LC_ALL, '')
gettext.textdomain('gTranscribe')
DBusGMainLoop(set_as_default=True)


# pylint: disable=invalid-name
class gTranscribeWindow:

def __init__(self, audiofile):
Expand Down Expand Up @@ -103,6 +105,7 @@ class gTranscribeWindow:
GLib.idle_add(self.open_file, audiofile)

def _init_ui(self):
GObject.type_register(GtkSource.View)
builder = Gtk.Builder()
builder.set_translation_domain('gTranscribe')
builder.add_from_file(get_data_file(PROJECT_ROOT_DIRECTORY, 'ui',
Expand Down Expand Up @@ -385,7 +388,7 @@ class gTranscribeWindow:
self.text_buffer.get_iter_at_offset(line_start))
logger.debug('Set position')

# pylint: disable=unused-argument,no-self-use
# pylint: disable=unused-argument
def on_scale_speed_format_value(self, widget, value, data=None):
return f"{locale.format_string('%.1f', value)}\xd7"

Expand Down
2 changes: 1 addition & 1 deletion data/ui/gTranscribe.glade
Original file line number Diff line number Diff line change
Expand Up @@ -484,7 +484,7 @@ audio-volume-medium</property>
<property name="vexpand">True</property>
<property name="shadow_type">in</property>
<child>
<object class="GtkTextView" id="text_view">
<object class="GtkSourceView" id="text_view">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="has_focus">True</property>
Expand Down
3 changes: 1 addition & 2 deletions gtranscribe/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
from gi.repository import Gtk
gettext.textdomain('gTranscribe')


# pylint: disable=invalid-name
class duration:
"""
Stores a time duration in hours, minutes, seconds and microseconds.
Expand Down Expand Up @@ -86,7 +86,6 @@ def trim(timestring, digits=1):
return timestring[:pos + 1 + digits]
return timestring


def ns_to_time(ns):
"""
Convert nanoseconds to a duration object.
Expand Down
8 changes: 4 additions & 4 deletions gtranscribe/player.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
logger = logging.getLogger('player')
Gst.init(None)


# pylint: disable=invalid-name
class gTranscribePlayer(Gst.Bin):
"""Class to play audio files with Gstreamer."""

Expand All @@ -39,7 +39,7 @@ def __init__(self):

self._rate = 1
self._duration = None
self._messageType = Gst.MessageType.UNKNOWN
self._message_type = Gst.MessageType.UNKNOWN
self.init_pipeline()

def init_pipeline(self):
Expand Down Expand Up @@ -91,7 +91,7 @@ def filename(self):
def duration(self):
"""Return the duration of the current stream."""
success = False
if self._duration is None or self._messageType == Gst.MessageType.DURATION_CHANGED:
if self._duration is None or self._message_type == Gst.MessageType.DURATION_CHANGED:
success, self._duration = self.pipeline.query_duration(Gst.Format.TIME)
if not success:
self._duration = 0
Expand Down Expand Up @@ -180,7 +180,7 @@ def on_new_decoded_pad(self, element, pad):
# pylint: disable=unused-argument
def on_message(self, bus, message):
"""Handle message and react accordingly."""
self._messageType = message.type
self._message_type = message.type
if message.type == Gst.MessageType.EOS:
self.state = Gst.State.NULL
self.emit('ended')
Expand Down

0 comments on commit d4ba34b

Please sign in to comment.