Skip to content

Commit

Permalink
2.5.1 - Backport a fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Lains committed Aug 25, 2020
1 parent c6d4a55 commit 4e07c03
Show file tree
Hide file tree
Showing 7 changed files with 165 additions and 201 deletions.
8 changes: 8 additions & 0 deletions data/com.github.lainsce.quilter.appdata.xml.in
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,14 @@
<content_attribute id="money-gambling">none</content_attribute>
</content_rating>
<releases>
<release version="2.5.1" date="2020-08-28">
<description>
<p>Release: Power Up Two</p>
<ul>
<li>Urgent Fix: Major error crashing the app while in Preview.</li>
</ul>
</description>
</release>
<release version="2.5.0" date="2020-07-24">
<description>
<p>Release: Power Up</p>
Expand Down
30 changes: 10 additions & 20 deletions data/com.github.lainsce.quilter.gschema.xml
Original file line number Diff line number Diff line change
@@ -1,25 +1,15 @@
<schemalist>
<schema id="com.github.lainsce.quilter" path="/com/github/lainsce/quilter/">
<key name="window-x" type="i">
<default>-1</default>
<summary>Window position</summary>
<description>The x axis of window position</description>
</key>
<key name="window-y" type="i">
<default>-1</default>
<summary>Window position</summary>
<description>The y axis of window position</description>
</key>
<key name="window-height" type="i">
<default>800</default>
<summary>Window position</summary>
<description>The height of the window</description>
</key>
<key name="window-width" type="i">
<default>920</default>
<summary>Window position</summary>
<description>The width of the window</description>
</key>
<key name="window-position" type="(ii)">
<default>(-1,-1)</default>
<summary>Window position</summary>
<description>The x axis of window position</description>
</key>
<key name="window-size" type="(ii)">
<default>(870,690)</default>
<summary>Window position</summary>
<description>The height of the window</description>
</key>
<key name="focus-mode" type="b">
<default>false</default>
<summary>Focus Mode</summary>
Expand Down
4 changes: 2 additions & 2 deletions meson.build
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
project('com.github.lainsce.quilter', 'vala', 'c', version: '2.2.4')
project('com.github.lainsce.quilter', 'vala', 'c', version: '2.5.1')

gnome = import('gnome')
i18n = import('i18n')
Expand Down Expand Up @@ -65,4 +65,4 @@ executable(
meson.add_install_script('meson/post_install.py', join_paths(get_option('prefix'), get_option('datadir')))

subdir('data')
subdir('po')
subdir('po')
86 changes: 25 additions & 61 deletions src/MainWindow.vala
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ using Granite.Services;

namespace Quilter {
public class MainWindow : Gtk.ApplicationWindow {
public Gtk.Adjustment eadj;
public Widgets.StatusBar statusbar;
public Widgets.SideBar sidebar;
public Widgets.SearchBar searchbar;
Expand Down Expand Up @@ -98,6 +99,11 @@ namespace Quilter {

on_settings_changed ();

eadj = edit_view.get_vadjustment ();
eadj.notify["value"].connect (() => {
scroll_to ();
});

Quilter.Application.gsettings.changed.connect (() => {
on_settings_changed ();
});
Expand Down Expand Up @@ -235,6 +241,14 @@ namespace Quilter {
provider2.load_from_resource ("/com/github/lainsce/quilter/app-font-stylesheet.css");
Gtk.StyleContext.add_provider_for_screen (Gdk.Screen.get_default (), provider2, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION);

int window_x, window_y, width, height;
Quilter.Application.gsettings.get ("window-position", "(ii)", out window_x, out window_y);
Quilter.Application.gsettings.get ("window-size", "(ii)", out width, out height);
if (window_x != -1 || window_y != -1) {
this.move (window_x, window_y);
}
this.resize (width, height);

toolbar = new Widgets.Headerbar (this);
toolbar.open.connect (on_open);
toolbar.save.connect (on_save);
Expand Down Expand Up @@ -295,9 +309,8 @@ namespace Quilter {
edit_view.add (edit_view_content);

preview_view = new Gtk.ScrolledWindow (null, null);
preview_view_content = new Widgets.Preview (this, edit_view_content.buffer);
preview_view_content = new Widgets.Preview (this, edit_view_content);
preview_view.add (preview_view_content);
((Gtk.Viewport) preview_view.get_child ()).set_vscroll_policy (Gtk.ScrollablePolicy.NATURAL);
var preview_view_context = preview_view.get_style_context ();
preview_view_context.add_class ("quilter-preview-view");

Expand Down Expand Up @@ -342,7 +355,6 @@ namespace Quilter {
toolbar.pack_end (view_mode);

paned = new Gtk.Paned (Gtk.Orientation.HORIZONTAL);
paned.set_position (Quilter.Application.gsettings.get_int("window-width")/2);

main_stack = new Gtk.Stack ();
main_stack.hexpand = true;
Expand All @@ -357,7 +369,7 @@ namespace Quilter {
insert_action_group ("win", actions);

statusbar = new Widgets.StatusBar (edit_view_content.buffer);
sidebar = new Widgets.SideBar (this);
sidebar = new Widgets.SideBar (this, edit_view_content);
sidebar.save_as.connect (() => on_save_as ());
searchbar = new Widgets.SearchBar (this);

Expand Down Expand Up @@ -399,36 +411,13 @@ namespace Quilter {

add (overlay);

int x = Quilter.Application.gsettings.get_int("window-x");
int y = Quilter.Application.gsettings.get_int("window-y");
int w = Quilter.Application.gsettings.get_int("window-width");
int h = Quilter.Application.gsettings.get_int("window-height");

if (x != -1 && y != -1) {
this.move (x, y);
}
if (w != 0 && h != 0) {
this.resize (w, h);
}

update_title ();

Gtk.Adjustment eadj = edit_view.get_vadjustment ();
Gtk.Adjustment padj = preview_view.get_vadjustment ();
eadj.value_changed.connect (() => {
scroll_to ();
});
padj.value_changed.connect (() => {
scroll_to_fix ();
});
padj.set_lower(1);

if (!Granite.Services.System.history_is_enabled ()) {
edit_view_content.buffer.text = "";
Services.FileManager.file = null;
toolbar.set_subtitle (_("No Documents Open"));
sidebar.store.clear ();
sidebar.delete_row ();
statusbar.readtimecount_label.set_text((_("Reading Time: ")) + "0m");
}

Expand Down Expand Up @@ -460,14 +449,12 @@ namespace Quilter {
}

public override bool delete_event (Gdk.EventAny event) {
int x, y, w, h;
get_position (out x, out y);
int w, h;
get_size (out w, out h);

Quilter.Application.gsettings.set_int("window-x", x);
Quilter.Application.gsettings.set_int("window-y", y);
Quilter.Application.gsettings.set_int("window-width", w);
Quilter.Application.gsettings.set_int("window-height", h);
Quilter.Application.gsettings.set ("window-size", "(ii)", w, h);
int root_x, root_y;
this.get_position (out root_x, out root_y);
Quilter.Application.gsettings.set ("window-position", "(ii)", root_x, root_y);

string[] files = {};
foreach (unowned Widgets.SideBarBox row in sidebar.get_rows ()) {
Expand All @@ -489,33 +476,10 @@ namespace Quilter {
}

public void scroll_to () {
Gtk.Adjustment eadj = edit_view.get_vadjustment ();
Gtk.Adjustment padj = preview_view.get_vadjustment ();
var value = eadj.get_value();
var psize_edit = eadj.get_page_size();
var psize_prev = padj.get_page_size();
var upper_edit = eadj.get_upper();
var upper_prev = padj.get_upper();

if (value >= (upper_edit - psize_edit)) {
padj.set_value(upper_prev - psize_prev);
} else {
padj.set_value(value / upper_edit * upper_prev);
}

padj.value_changed.connect (() => {
scroll_to_fix ();
});
}

public void scroll_to_fix () {
Gtk.Adjustment adj = preview_view.get_vadjustment ();
var value = adj.get_value();
if (value == 0) {
scroll_to ();
} else {
// pass
}
Gtk.Adjustment vap = edit_view.get_vadjustment ();
var upper = vap.get_upper();
var value = vap.get_value();
preview_view_content.scroll_value = value/upper;
}

private static void widget_unparent (Gtk.Widget widget) {
Expand Down
Loading

0 comments on commit 4e07c03

Please sign in to comment.