Skip to content
Draft
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
5 changes: 5 additions & 0 deletions data/inscriptions.gschema.xml.in
Original file line number Diff line number Diff line change
Expand Up @@ -69,5 +69,10 @@
<summary>Whether to highlight both source and target</summary>
<description>Highlights alternating colours on both source and target in the TextView</description>
</key>
<key name="language-heatmap" type="as">
<default>["", "", "", "", ""]</default>
<summary>Five last selected language code</summary>
<description>A list of recent selected language codes to make obvious in the UI</description>
</key>
</schema>
</schemalist>
11 changes: 8 additions & 3 deletions data/inscriptions.metainfo.xml.in.in
Original file line number Diff line number Diff line change
Expand Up @@ -79,13 +79,18 @@
</recommends>

<releases>
<release version="1.0.1" date="2026-03-16" urgency="medium">
<release version="1.1.0" date="2026-03-16" urgency="medium">
<description>
<p>Touchups and enhancements</p>
<ul>
<li>Minor design changes. Lets do refined shit.</li>
<li>A cleaner, better thought out UI</li>
<li>Updated and extended screenshots</li>
<li>Some work into cleaner code</li>
<li>Show/hide highlighting moved to target pane</li>
<li>Enable/Disable auto translation moved to gear menu</li>
<li>Display in the language list the currently selected one</li>
<li>Switch source and language moved between both languages</li>
<li>Static pane sizes - makes more sense</li>
<li>Synchronized text zoom for both source and target</li>
</ul>
</description>
</release>
Expand Down
1 change: 1 addition & 0 deletions data/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ if not windows_build
# Inject some variables into the metainfo file before merging in the translations
appstream_conf = configuration_data()
appstream_conf.set('APP_ID', app_id)
appstream_conf.set('APP_NAME', app_name)
appstream_conf.set('GETTEXT_PACKAGE', meson.project_name())
appstream_file_in = configure_file(
input: 'inscriptions.metainfo.xml.in.in',
Expand Down
1 change: 0 additions & 1 deletion po/POTFILES
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ src/Widgets/Buttons/OrientationBox.vala
src/Widgets/Buttons/ToggleHighlight.vala
src/Widgets/Popovers/SettingsPopover.vala
src/Widgets/Popovers/OptionsPopover.vala
src/Widgets/LanguageSelectionBox.vala
src/Widgets/Panes/Pane.vala
src/Widgets/Panes/SourcePane.vala
src/Widgets/Panes/TargetPane.vala
Expand Down
1 change: 1 addition & 0 deletions src/Constants.vala
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ namespace Inscriptions {
public const string KEY_VERTICAL_LAYOUT = "vertical-layout";
public const string KEY_AUTO_TRANSLATE = "auto-translate";
public const string KEY_HIGHLIGHT = "highlight";
public const string KEY_HEATMAP = "language-heatmap";

// Backend
public const string KEY_SOURCE_LANGUAGE = "source-language";
Expand Down
40 changes: 35 additions & 5 deletions src/Objects/DDModel.vala
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,19 @@
*/
public class Inscriptions.DDModel : Object {

static string[] heatmap {get; set;}
static string[] heatmap = Application.settings.get_strv (KEY_HEATMAP);

public GLib.ListStore model {get; set;}
public Gtk.SignalListItemFactory factory_header {get; set;}
public Gtk.SignalListItemFactory factory_list {get; set;}

// Signal emitted by factory_header.bind when a language is selected, which factory_list.bind listens to
public signal void selection_changed (string language_code_selected);
public signal void language_changed (string language_code_selected);
public signal void update_greyout (string language_code_greyout);

public DDModel () {
//heatmap = Application.settings.get_strv (KEY_HEATMAP);

// The Langs will populate this thing
model = new GLib.ListStore(typeof(Lang));

Expand Down Expand Up @@ -49,8 +52,30 @@ public class Inscriptions.DDModel : Object {
var item = list_item.get_child () as Gtk.Label;
item.label = item_language.name;

// We save up a heatmap. It is rebuilt from scratch to avoid redundant language codes
// We could check beforehand and gate this but it would affect lisibility
string[] temp_heatmap = {item_language.code};
foreach (var recent_language_code in heatmap) {
if (recent_language_code != item_language.code) {
temp_heatmap += recent_language_code;
}

if (temp_heatmap.length == 5) {
break;
}
}
heatmap = temp_heatmap;
Application.settings.set_strv (KEY_HEATMAP, heatmap);

//Application.settings.set_strv (KEY_HEATMAP, heatmap);
print ("\n");
foreach (var element in heatmap) {
print (element + " ");
}

// Tell everyone language changed
selection_changed (item_language.code);
// Items are connected to this and get their shit together out of it
language_changed (item_language.code);
//print ("switched to: %s %s\n".printf (item_language.name, item_language.code));
}

Expand All @@ -62,6 +87,11 @@ public class Inscriptions.DDModel : Object {

list_item.child = list_item_child;
list_item.focusable = true;

list_item_child.bind_property ("sensitive", list_item,
"activatable",
GLib.BindingFlags.DEFAULT
);
}

private void on_factory_list_bind (Gtk.SignalListItemFactory f, Object o) {
Expand All @@ -71,9 +101,9 @@ public class Inscriptions.DDModel : Object {
var list_item_child = list_item.get_child() as Inscriptions.LanguageItem;
list_item_child.language_label = item_language.name;
list_item_child.language_code = item_language.code;

// Listen to language change, let every item sort its shit
selection_changed.connect (list_item_child.on_position_changed);
language_changed.connect (list_item_child.on_position_changed);
update_greyout.connect (list_item_child.on_greyout_changed);
//print ("binding: %s\n".printf (item_language.name));
}

Expand Down
71 changes: 54 additions & 17 deletions src/Views/TranslationView.vala
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ public class Inscriptions.TranslationView : Gtk.Box {
Gtk.CenterBox paned {get; set;}
public Inscriptions.SourcePane source_pane;
public Inscriptions.TargetPane target_pane;
private Inscriptions.LanguageSelectionBox language_selection;

// Add a debounce so we aren't requesting the API constantly
public uint debounce_timer_id = 0;
Expand Down Expand Up @@ -65,52 +64,90 @@ public class Inscriptions.TranslationView : Gtk.Box {
vexpand = true
};
paned.start_widget = source_pane;
paned.center_widget = new Gtk.Separator (VERTICAL);

//TRANSLATORS: This is for a button that switches source and target language
var switchlang_button = new Gtk.Button.from_icon_name ("media-playlist-repeat-symbolic") {
action_name = TranslationView.ACTION_PREFIX + TranslationView.ACTION_SWITCH_LANG,
tooltip_markup = Granite.markup_accel_tooltip ({"<Ctrl>I"}, _("Switch languages")),
valign = Gtk.Align.START
};


paned.center_widget = switchlang_button; //new Gtk.Separator (VERTICAL);
paned.end_widget = target_pane;

// paned.start_ (source_pane);
// paned.append (source_pane);
// paned.append (target_pane);

language_selection = new Inscriptions.LanguageSelectionBox ();
append (language_selection);
append (paned);



//TRANSLATORS: This is for a button that switches source and target language
var switchlang_button_actionbar = new Gtk.Button.from_icon_name ("media-playlist-repeat-symbolic") {
action_name = TranslationView.ACTION_PREFIX + TranslationView.ACTION_SWITCH_LANG,
tooltip_markup = Granite.markup_accel_tooltip ({"<Ctrl>I"}, _("Switch languages")),
valign = Gtk.Align.START
};

source_pane.actionbar.set_center_widget (switchlang_button_actionbar);



/* ---------------- CONNECTS AND BINDS ---------------- */

// Logic for toggling the panes/layout
on_orientation_toggled ();
Application.settings.changed["vertical-layout"].connect (on_orientation_toggled);

connect_all (true);

Application.settings.changed["auto-translate"].connect (() => {
if (Application.settings.get_boolean ("auto-translate")) {
on_text_to_translate ();
}
});

// Binds do not seem to work here so we go the manual route
source_pane.selected_language = Application.settings.get_string (KEY_SOURCE_LANGUAGE);
source_pane.greyed_out_language = Application.settings.get_string (KEY_TARGET_LANGUAGE);

target_pane.selected_language = Application.settings.get_string (KEY_TARGET_LANGUAGE);
target_pane.greyed_out_language = Application.settings.get_string (KEY_SOURCE_LANGUAGE);

source_pane.dropdown.language_changed.connect (on_source_language_changed);
target_pane.dropdown.language_changed.connect (on_target_language_changed);

connect_all (true);

// Synchronize scroll and zoom for both panes
source_pane.scrolledwindow.vadjustment.bind_property ("value",
target_pane.scrolledwindow.vadjustment, "value",
GLib.BindingFlags.SYNC_CREATE | GLib.BindingFlags.BIDIRECTIONAL
);
}

public void on_source_language_changed (string code) {
Application.settings.set_string (KEY_SOURCE_LANGUAGE, code);
target_pane.greyed_out_language = code;
}

public void on_target_language_changed (string code) {
Application.settings.set_string (KEY_TARGET_LANGUAGE, code);
source_pane.greyed_out_language = code;
}

private void connect_all (bool if_connect) {
if (if_connect) {
// translate when text is entered or user changes any language or option
source_pane.textview.buffer.changed.connect (on_text_to_translate);
language_selection.source_changed.connect (on_text_to_translate);
language_selection.target_changed.connect (on_text_to_translate);
source_pane.language_changed.connect (on_text_to_translate);
target_pane.language_changed.connect (on_text_to_translate);
Application.settings.changed["context"].connect (on_text_to_translate);
Application.settings.changed["formality"].connect (on_text_to_translate);

} else {
// no
source_pane.textview.buffer.changed.disconnect (on_text_to_translate);
language_selection.source_changed.disconnect (on_text_to_translate);
language_selection.target_changed.disconnect (on_text_to_translate);
source_pane.language_changed.disconnect (on_text_to_translate);
target_pane.language_changed.disconnect (on_text_to_translate);
Application.settings.changed["context"].disconnect (on_text_to_translate);
Application.settings.changed["formality"].disconnect (on_text_to_translate);
}
Expand All @@ -125,17 +162,17 @@ public class Inscriptions.TranslationView : Gtk.Box {
connect_all (false);

// Temp variables
var newtarget = language_selection.selected_source;
var newtarget = source_pane.selected_language;
var newtarget_text = source_pane.text;

var newsource = language_selection.selected_target;
var newsource = target_pane.selected_language;
var newsource_text = target_pane.text;

// Letsgo
language_selection.selected_source = newsource;
source_pane.selected_language = newsource;
source_pane.text = newsource_text;

language_selection.selected_target = newtarget;
target_pane.selected_language = newtarget;
target_pane.text = newtarget_text;

source_pane.textview.refresh ();
Expand Down Expand Up @@ -167,7 +204,7 @@ public class Inscriptions.TranslationView : Gtk.Box {
* Filter not-requests, set or reset debounce_timer
*/
public void on_text_to_translate () {
if (language_selection.selected_source == language_selection.selected_target) {
if (source_pane.selected_language == target_pane.selected_language) {
source_pane.message (_("Target language is the same as source"));
return;
}
Expand Down
2 changes: 1 addition & 1 deletion src/Widgets/Buttons/TranslateButton.vala
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public class Inscriptions.TranslateButton : Granite.Bin {
var translate_button = new Gtk.Button () {
label = _("Translate"),
tooltip_markup = Granite.markup_accel_tooltip (
{"<Control>Return", "<Ctrl>T"},
{"<Control>Return", "<Ctrl>T"},
_("Start translating the entered text")
)
};
Expand Down
6 changes: 2 additions & 4 deletions src/Widgets/HeaderBar.vala
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ public class Inscriptions.HeaderBar : Granite.Bin {
Gtk.StackSwitcher title_switcher;

Gtk.Revealer back_revealer;
Gtk.Button switchlang_button;
Gtk.Revealer toolbar_revealer;
Gtk.MenuButton popover_button;

Expand Down Expand Up @@ -83,7 +82,6 @@ public class Inscriptions.HeaderBar : Granite.Bin {
title_stack.add_child (title_switcher);
title_stack.visible_child = title_label;

//TRANSLATORS: Do not translate the name itself. You can write it in your writing system if that is usually done for your language
headerbar = new Gtk.HeaderBar () {
title_widget = title_stack
};
Expand Down Expand Up @@ -159,11 +157,11 @@ public class Inscriptions.HeaderBar : Granite.Bin {
};

var toolbar_right = new Gtk.Box (Gtk.Orientation.HORIZONTAL, 5);
//toolbar_right.append (translate_revealer);

toolbar_right.append (new TranslateButton ());
toolbar_right.append (popover_button);

headerbar.pack_end (toolbar_right);
headerbar.pack_end (new TranslateButton ());

child = headerbar;

Expand Down
45 changes: 32 additions & 13 deletions src/Widgets/LanguageDropDown.vala
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,24 @@ public class Inscriptions.LanguageDropDown : Granite.Bin {
Gtk.DropDown dropdown;

public string selected {
owned get { return get_selected_language ();}
set { set_selected_language (value);}
owned get { return get_selected_language ();}
set { set_selected_language (value);}
}

public signal void language_changed (string code = "");
/**
* Emitted by the widget for others to update themselves
*/
public signal void language_changed (string code = ""); // Listened to by others

public LanguageDropDown (Lang[] languages) {
/**
* Called by other elements for the DD to update what to grey out
*/
public signal void update_greyout (string code = "");

construct {
hexpand = true;
model = new Inscriptions.DDModel ();

foreach (var language in languages) {
model.model_append (language);
}

var expression = new Gtk.PropertyExpression (typeof (Inscriptions.Lang), null, "both");
dropdown = new Gtk.DropDown (model.model, expression) {
factory = model.factory_header,
Expand All @@ -39,23 +43,38 @@ public class Inscriptions.LanguageDropDown : Granite.Bin {
child = dropdown;

/* ---------------- CONNECTS AND BINDS ---------------- */
dropdown.notify["selected-item"].connect (on_selected_language);
model.language_changed.connect (on_language_changed);
update_greyout.connect (on_update_greyout);
}

private void on_selected_language () {
var selected_lang = dropdown.get_selected_item () as Lang;
print ("\nSELECTED %s\n".printf (selected_lang.code));
language_changed (selected_lang.code);
private void on_language_changed (string language_code) {
//var selected_lang = dropdown.get_selected_item () as Lang;
//print ("\nSELECTED %s\n".printf (selected_lang.code));
//language_changed (selected_lang.code);
language_changed (language_code);
}

private void on_update_greyout (string language_code) {
//var selected_lang = dropdown.get_selected_item () as Lang;
print ("\nUPDATE GREYOUT %s\n".printf (language_code));
//language_changed (selected_lang.code);
model.update_greyout (language_code);
}

private void set_selected_language (string code) {
var position = model.model_where_code (code);
dropdown.set_selected (position);
language_changed (code);
}

private string get_selected_language () {
var selected_lang = dropdown.get_selected_item () as Lang;
return selected_lang.code;
}

public void add_languages (Lang[] languages) {
foreach (var language in languages) {
model.model_append (language);
}
}
}
Loading
Loading