diff --git a/io.github.nokse22.teleprompter.json b/io.github.nokse22.teleprompter.json
index 9488858..7829a67 100644
--- a/io.github.nokse22.teleprompter.json
+++ b/io.github.nokse22.teleprompter.json
@@ -1,7 +1,7 @@
{
"app-id" : "io.github.nokse22.teleprompter",
"runtime" : "org.gnome.Platform",
- "runtime-version" : "47",
+ "runtime-version" : "master",
"sdk" : "org.gnome.Sdk",
"command" : "teleprompter",
"finish-args" : [
diff --git a/src/gtk/help-overlay.ui b/src/gtk/help-overlay.ui
index ef55568..9da9f7a 100644
--- a/src/gtk/help-overlay.ui
+++ b/src/gtk/help-overlay.ui
@@ -27,6 +27,11 @@
app.quit
+
+
+
+
diff --git a/src/gtk/window.ui b/src/gtk/window.ui
index b598a0c..6e25c64 100644
--- a/src/gtk/window.ui
+++ b/src/gtk/window.ui
@@ -8,6 +8,7 @@
360
294
Teleprompter
+
max-width: 480px
diff --git a/src/main.py b/src/main.py
index c46b05d..10d1d65 100644
--- a/src/main.py
+++ b/src/main.py
@@ -56,38 +56,47 @@ def __init__(self):
theme_action.connect("activate", self.on_theme_setting_changed)
self.add_action(theme_action)
- vmirror_action = Gio.SimpleAction.new_stateful(
+ self.vmirror_action = Gio.SimpleAction.new_stateful(
"vmirror",
None,
- GLib.Variant("b", self.saved_settings.get_boolean("vmirror")),
+ GLib.Variant("b", self.saved_settings.get_boolean("vmirror"))
)
- vmirror_action.connect("activate", self.on_v_mirror)
- self.add_action(vmirror_action)
+ self.vmirror_action.connect("activate", self.on_vmirror)
+ self.set_accels_for_action("app.vmirror", ['V'])
+ self.add_action(self.vmirror_action)
- hmirror_action = Gio.SimpleAction.new_stateful(
+ self.hmirror_action = Gio.SimpleAction.new_stateful(
"hmirror",
None,
- GLib.Variant("b", self.saved_settings.get_boolean("hmirror")),
+ GLib.Variant("b", self.saved_settings.get_boolean("hmirror"))
)
- hmirror_action.connect("activate", self.on_h_mirror)
- self.add_action(hmirror_action)
+ self.hmirror_action.connect("activate", self.on_hmirror)
+ self.set_accels_for_action("app.hmirror", ['H'])
+ self.add_action(self.hmirror_action)
+
+ self.create_action(
+ 'reset-mirrors', self.on_reset_mirrors, ['R'])
self.update_theme()
- def on_v_mirror(self, action, state):
+ def on_vmirror(self, action, state):
new_state = not action.get_state().get_boolean()
action.set_state(GLib.Variant.new_boolean(new_state))
self.saved_settings.set_boolean("vmirror", new_state)
self.win.scroll_text_view.vmirror = new_state
- def on_h_mirror(self, action, state):
+ def on_hmirror(self, action, state):
new_state = not action.get_state().get_boolean()
action.set_state(GLib.Variant.new_boolean(new_state))
self.saved_settings.set_boolean("hmirror", new_state)
self.win.scroll_text_view.hmirror = new_state
+ def on_reset_mirrors(self, *_args):
+ self.vmirror_action.set_state(GLib.Variant.new_boolean(False))
+ self.hmirror_action.set_state(GLib.Variant.new_boolean(False))
+
def on_theme_setting_changed(self, action, state):
action.set_state(state)
self.saved_settings.set_string("theme", state.get_string())
@@ -140,8 +149,7 @@ def on_preferences_action(self, *args):
pref = Adw.PreferencesDialog()
- preferences_page = Adw.PreferencesPage(
- title=_("Generals"))
+ preferences_page = Adw.PreferencesPage(title=_("Generals"))
preferences_page.set_icon_name("applications-system-symbolic")
pref.add(preferences_page)
@@ -166,14 +174,14 @@ def on_preferences_action(self, *args):
text_group.add(highlight_color_picker_row)
highlight_color_picker = Gtk.ColorButton(valign=Gtk.Align.CENTER)
- highlight_color_picker.set_rgba(self.win.settings.highlightColor)
+ highlight_color_picker.set_rgba(self.win.settings.highlight_color)
highlight_color_picker_row.add_suffix(highlight_color_picker)
bold_highlight_row = Adw.ActionRow(title=_("Bold Highlight"))
text_group.add(bold_highlight_row)
bold_highlight_switch = Gtk.Switch(valign=Gtk.Align.CENTER)
- bold_highlight_switch.set_active(self.win.settings.bold_highlight_row)
+ bold_highlight_switch.set_active(self.win.settings.bold_highlight)
bold_highlight_row.add_suffix(bold_highlight_switch)
@@ -220,11 +228,9 @@ def create_action(self, name, callback, shortcuts=None):
self.set_accels_for_action(f"app.{name}", shortcuts)
def on_background_color_changed(self, colorWidget):
- # print("background color changed")
self.win.settings.backgroundColor = colorWidget.get_rgba()
def on_text_color_changed(self, colorWidget):
- # print("font color changed")
self.win.settings.textColor = colorWidget.get_rgba()
self.win.apply_text_tags()
@@ -233,7 +239,6 @@ def on_text_color_changed(self, colorWidget):
self.win.save_app_settings(self.win.settings)
def on_highlight_color_changed(self, colorWidget):
- # print("highlight color changed")
self.win.settings.highlightColor = colorWidget.get_rgba()
self.win.apply_text_tags()
@@ -242,7 +247,6 @@ def on_highlight_color_changed(self, colorWidget):
self.win.save_app_settings(self.win.settings)
def on_font_changed(self, fontWidget):
- # print("font changed")
font_properties = fontWidget.get_font().split()
font_size = font_properties[-1]
@@ -251,10 +255,8 @@ def on_font_changed(self, fontWidget):
else:
new_font_size = 10
- # Update the font size in the font properties list
font_properties[-1] = str(new_font_size)
- # Construct the updated font string
self.win.settings.font = ' '.join(font_properties)
self.win.update_font()
diff --git a/src/scroll_text_view.py b/src/scroll_text_view.py
index f9cd3b5..58f9c97 100644
--- a/src/scroll_text_view.py
+++ b/src/scroll_text_view.py
@@ -103,4 +103,4 @@ def get_scrolled_window(self):
return self.scrolled_window
def get_width(self):
- return self.text_view.get_allocation().width
+ return self.text_view._text_view.get_allocation().width
diff --git a/src/window.py b/src/window.py
index 9c28cc0..66a2966 100644
--- a/src/window.py
+++ b/src/window.py
@@ -29,9 +29,9 @@ def __init__(self):
self.textColor = Gdk.RGBA()
self.textColor.parse("#62A0EA")
self.speed = 150
- self.highlightColor = Gdk.RGBA()
- self.highlightColor.parse("#ED333B")
- self.boldHighlight = True
+ self.highlight_color = Gdk.RGBA()
+ self.highlight_color.parse("#ED333B")
+ self.bold_highlight = True
@Gtk.Template(resource_path='/io/github/nokse22/teleprompter/gtk/window.ui')
@@ -45,7 +45,6 @@ class TeleprompterWindow(Adw.ApplicationWindow):
sidebar_controls = Gtk.Template.Child()
playing = False
- fullscreened = False
def __init__(self, **kwargs):
super().__init__(**kwargs)
@@ -62,7 +61,6 @@ def __init__(self, **kwargs):
self.scroll_text_view.vmirror = self.saved_settings.get_boolean("vmirror")
self.text_buffer.connect("paste-done", self.on_text_pasted)
-
self.text_buffer.connect("changed", self.on_text_inserted, "", 0, 0)
start = self.text_buffer.get_start_iter()
@@ -96,7 +94,7 @@ def save_app_settings(self, settings):
self.saved_settings.set_string(
"text", self.color_to_hex(settings.textColor))
self.saved_settings.set_string(
- "highlight", self.color_to_hex(settings.highlightColor))
+ "highlight", self.color_to_hex(settings.highlight_color))
self.saved_settings.set_string(
"font", settings.font)
@@ -105,7 +103,7 @@ def save_app_settings(self, settings):
"speed", settings.speed * 10)
self.saved_settings.set_boolean(
- "bold-highlight", settings.boldHighlight)
+ "bold-highlight", settings.bold_highlight)
def show_file_chooser_dialog(self):
dialog = Gtk.FileDialog(
@@ -144,20 +142,19 @@ def load_app_settings(self):
settings = AppSettings()
color1 = Gdk.RGBA()
- color2 = Gdk.RGBA()
color3 = Gdk.RGBA()
color1.parse(self.saved_settings.get_string("text"))
settings.textColor = color1
color3.parse(self.saved_settings.get_string("highlight"))
- settings.highlightColor = color3
+ settings.highlight_color = color3
settings.font = self.saved_settings.get_string("font")
settings.speed = self.saved_settings.get_int("speed") / 10
- settings.boldHighlight = self.saved_settings.get_boolean(
+ settings.bold_highlight = self.saved_settings.get_boolean(
"bold-highlight")
return settings
@@ -191,7 +188,7 @@ def apply_text_tags(self):
tag_color2 = Gtk.TextTag()
tag_color2.set_property(
- "foreground", self.color_to_hex(self.settings.highlightColor))
+ "foreground", self.color_to_hex(self.settings.highlight_color))
self.text_buffer.get_tag_table().add(tag_color2)
start_iter = self.text_buffer.get_start_iter()
@@ -205,9 +202,9 @@ def search_and_mark_highlight(self, start):
tag_color2 = Gtk.TextTag()
tag_color2.set_property(
- "foreground", self.color_to_hex(self.settings.highlightColor))
+ "foreground", self.color_to_hex(self.settings.highlight_color))
- if self.settings.boldHighlight:
+ if self.settings.bold_highlight:
tag_color2.set_property("weight", Pango.Weight.BOLD)
self.text_buffer.get_tag_table().add(tag_color2)
@@ -225,10 +222,7 @@ def search_and_mark_highlight(self, start):
def search_end_highlight(self, start):
end = self.text_buffer.get_end_iter()
- # Perform forward search for "]" from the starting position
match_right = start.forward_search("]", Gtk.TextSearchFlags(0), end)
-
- # Perform forward search for "[" from the starting position
match_left = start.forward_search("[", Gtk.TextSearchFlags(0), end)
if match_right is not None:
@@ -246,9 +240,10 @@ def update_font(self):
tag = self.text_buffer.create_tag(
None, font_desc=Pango.FontDescription(self.settings.font))
- # Apply the tag to the entire text buffer
self.text_buffer.apply_tag(
- tag, self.text_buffer.get_start_iter(), self.text_buffer.get_end_iter())
+ tag,
+ self.text_buffer.get_start_iter(),
+ self.text_buffer.get_end_iter())
def wpm_to_speed(self, speed):
font_properties = self.settings.font.split()
@@ -264,7 +259,6 @@ def wpm_to_speed(self, speed):
return speed
def change_font_size(self, amount):
- # Split the font string into font properties and size
font_properties = self.settings.font.split()
font_size = font_properties[-1]
@@ -273,15 +267,12 @@ def change_font_size(self, amount):
else:
new_font_size = 10
- # Update the font size in the font properties list
font_properties[-1] = str(new_font_size)
- # Construct the updated font string
self.settings.font = ' '.join(font_properties)
@Gtk.Template.Callback("play_button_clicked")
def play(self, *args):
- # print("play")
if not self.playing:
self.start_button1.set_icon_name("media-playback-pause-symbolic")
self.playing = True
@@ -346,14 +337,10 @@ def increase_font_button_clicked(self, *args):
@Gtk.Template.Callback("fullscreen_button_clicked")
def toggle_fullscreen(self, *args):
- if self.fullscreened:
+ if self.is_fullscreen():
self.unfullscreen()
- self.fullscreen_button.set_icon_name("view-fullscreen-symbolic")
- self.fullscreened = False
else:
self.fullscreen()
- self.fullscreen_button.set_icon_name("view-restore-symbolic")
- self.fullscreened = True
@Gtk.Template.Callback("on_apply_breakpoint")
def on_apply_breakpoint(self, *args):
@@ -364,3 +351,10 @@ def on_apply_breakpoint(self, *args):
def on_unapply_breakpoint(self, *args):
self.sidebar_controls.add_css_class("card")
self.sidebar_controls.add_css_class("overlay_toolbar")
+
+ @Gtk.Template.Callback("on_fullscreened_changed")
+ def on_fullscreened_changed(self, *_args):
+ if self.is_fullscreen():
+ self.fullscreen_button.set_icon_name("view-restore-symbolic")
+ else:
+ self.fullscreen_button.set_icon_name("view-fullscreen-symbolic")