Compare commits

..

3 Commits

Author SHA1 Message Date
8f79ecdcb4 Create & install 16, 24, 32, 48, 64px icons 2018-09-30 21:52:21 -04:00
8f2ef93db3 Fix Exec field in .desktop 2018-09-30 21:39:15 -04:00
9907cdbbdb Rename icon 2018-09-30 21:37:39 -04:00
27 changed files with 60 additions and 401 deletions

View File

@ -35,4 +35,4 @@ script:
branches:
only:
- deb-packaging
- master

View File

@ -1,16 +1,10 @@
# Write.as GTK App
[![Get the app from Write.as](https://write.as/img/downloadwriteas.png)](https://write.as/apps/desktop)  
[![Get the app on AppCenter](https://write.as/img/appcenter.png)](https://appcenter.elementary.io/com.github.writeas.writeas-gtk)
A Write.as desktop app that targets all freedesktop.org compliant desktops, e.g.
GNU/Linux, FreeBSD, etc; basically everything except Windows, Mac, iOS, and
Android. It lets you compose and publish posts to [Write.as](https://write.as/).
For a UI toolkit it uses GTK, and relies on the [writeas-cli](https://github.com/writeas/writeas-cli) for API calls and post management.
**Write.as GTK is _libre_, not _gratis_, software.** Please try the app free of charge, but [purchase a copy](https://write.as/apps/linux/get) if you continue using it.
## Usage
See the [User Guide](https://code.as/writeas/writeas-gtk/src/branch/master/USER_GUIDE.md).
@ -24,9 +18,9 @@ any FreeDesktop.Org compatible system using:
# Either via pip:
pip3 install meson
# Or, if you need to build the .deb:
sudo apt install meson ninja-build
# You might also need some of these dependencies to successfully build the app:
sudo apt install build-essential valac libgtk-3-dev libgtksourceview-3.0-dev
sudo add-apt-repository ppa:jonathonf/meson
sudo apt update
sudo apt install meson
# Build
meson build && cd build

View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8" ?>
<component type="desktop-application">
<id>writeas-gtk</id>
<id>com.github.writeas.writeas-gtk</id>
<project_license>GPL-3.0+</project_license>
<metadata_license>CC0</metadata_license>
<name>Write.as</name>
@ -28,7 +28,7 @@
<update_contact>hello@write.as</update_contact>
<provides>
<binary>writeas-gtk</binary>
<binary>com.github.writeas.writeas-gtk</binary>
</provides>
<screenshots>
@ -69,7 +69,7 @@
<content_attribute id="language-humor">none</content_attribute>
<content_attribute id="language-discrimination">none</content_attribute>
<content_attribute id="social-chat">none</content_attribute>
<content_attribute id="social-info">moderate</content_attribute>
<content_attribute id="social-info">none</content_attribute>
<content_attribute id="social-audio">none</content_attribute>
<content_attribute id="social-location">none</content_attribute>
<content_attribute id="social-contacts">none</content_attribute>
@ -77,24 +77,6 @@
<content_attribute id="money-gambling">none</content_attribute>
</content_rating>
<releases>
<release version="1.0.2" date="2018-12-20">
<description>
<p>This update fixes a few minor visual issues.</p>
<ul>
<li>Fix black bar that appears in the editor on elementary OS</li>
<li>Fix currently-selected font not reflected in menu when app first loads</li>
</ul>
</description>
</release>
<release version="1.0.1" date="2018-12-14">
<description>
<p>GTK updates and fixes.</p>
<ul>
<li>Fix fonts, padding, cursor color</li>
<li>Increase the default font size</li>
</ul>
</description>
</release>
<release version="1.0.0" date="2018-10-01">
<description>
<p>Initial release</p>

View File

@ -2,8 +2,8 @@
Type=Application
Name=Write.as
Comment=Publish a thought in seconds.
Exec=writeas-gtk
Icon=write-as
Exec=com.github.writeas.writeas-gtk
Icon=com.github.writeas.writeas-gtk
Terminal=false
MimeType=
Categories=GTK;Office;Publishing;

View File

Before

Width:  |  Height:  |  Size: 14 KiB

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 729 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.1 KiB

View File

@ -1,8 +1,17 @@
install_data('icons/write-as.png',
install_dir: join_paths(get_option('datadir'), 'icons', 'hicolor', '128x128', 'apps')
)
icon_sizes = ['16', '24', '32', '48', '64', '128']
install_data('writeas-gtk.desktop',
foreach i : icon_sizes
install_data(
join_paths('icons', i, meson.project_name() + '.png'),
install_dir: join_paths(get_option('datadir'), 'icons', 'hicolor', i + 'x' + i, 'apps'
)
)
endforeach
install_data('icons/writeas-bright-dark.png',
install_dir: join_paths(get_option('datadir'), 'icons', 'hicolor', '16x16', 'actions'))
install_data('com.github.writeas.writeas-gtk.desktop',
install_dir: join_paths(get_option('datadir'), 'applications'))
install_data('writeas-gtk.appdata.xml',
install_data('com.github.writeas.writeas-gtk.appdata.xml',
install_dir: join_paths(get_option('datadir'), 'metainfo'))

14
debian/changelog vendored
View File

@ -1,17 +1,3 @@
writeas-gtk (1.0.2-3) xenial; urgency=medium
* Fix black bar that appears in the editor on elementary OS
* Fix currently-selected font not reflected in menu when app first loads
-- Write.as <hello@write.as> Thu, 20 Dec 2018 14:20:45 -0500
writeas-gtk (1.0.1-2) xenial; urgency=medium
* Fix fonts, padding, cursor color
* Increase the default font size
-- Write.as <hello@write.as> Fri, 14 Dec 2018 15:22:09 -0500
writeas-gtk (1.0.0-1) xenial; urgency=medium
* Initial Release.

4
debian/control vendored
View File

@ -1,4 +1,4 @@
Source: writeas-gtk
Source: com.github.writeas.writeas-gtk
Section: x11
Priority: extra
Maintainer: Write.as <hello@write.as>
@ -9,7 +9,7 @@ Build-Depends: meson,
valac (>= 0.36)
Standards-Version: 3.9.3
Package: writeas-gtk
Package: com.github.writeas.writeas-gtk
Architecture: any
Depends: ${misc:Depends}, ${shlibs:Depends}, writeas-cli
Recommends: fonts-lora, fonts-open-sans, fonts-hack

2
debian/copyright vendored
View File

@ -1,5 +1,5 @@
Format: http://dep.debian.net/deps/dep5
Upstream-Name: writeas-gtk
Upstream-Name: com.github.writeas.writeas-gtk
Source: https://code.as/writeas/writeas-gtk/
Files: *

2
debian/rules vendored
View File

@ -28,4 +28,4 @@ override_dh_auto_test:
cd debian/build && ninja test
override_dh_auto_install:
cd debian/build && DESTDIR=${CURDIR}/debian/writeas-gtk ninja install
cd debian/build && DESTDIR=${CURDIR}/debian/com.github.writeas.writeas-gtk ninja install

View File

@ -1,5 +1,5 @@
project('writeas-gtk', ['vala', 'c'],
version: '1.0.2',
project('com.github.writeas.writeas-gtk', ['vala', 'c'],
version: '1.0.0',
license: 'GPL',
meson_version: '>=0.40.1')

Binary file not shown.

Before

Width:  |  Height:  |  Size: 52 KiB

After

Width:  |  Height:  |  Size: 49 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 46 KiB

After

Width:  |  Height:  |  Size: 44 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 49 KiB

After

Width:  |  Height:  |  Size: 50 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 49 KiB

After

Width:  |  Height:  |  Size: 50 KiB

View File

@ -1,136 +0,0 @@
// From https://github.com/elementary/granite/blob/621f2669f6c8940fe32ac9817ddca92e97d27ae0/lib/Widgets/Utils.vala#L79-L192
/*
* Copyright (C) 2012-2017 Granite Developers
*
* This program or library is free software; you can redistribute it
* and/or modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General
* Public License along with this library; if not, write to the
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301 USA.
*/
namespace Granite {
/**
* Converts a {@link Gtk.accelerator_parse} style accel string to a human-readable string.
*
* @param accel an accelerator label like <Control>a or <Super>Right
*
* @return a human-readable string like "Ctrl + A" or "⌘ + →"
*/
public static string accel_to_string (string accel) {
uint accel_key;
Gdk.ModifierType accel_mods;
Gtk.accelerator_parse (accel, out accel_key, out accel_mods);
string[] arr = {};
if (Gdk.ModifierType.SUPER_MASK in accel_mods) {
arr += "";
}
if (Gdk.ModifierType.SHIFT_MASK in accel_mods) {
arr += _("Shift");
}
if (Gdk.ModifierType.CONTROL_MASK in accel_mods) {
arr += _("Ctrl");
}
if (Gdk.ModifierType.MOD1_MASK in accel_mods) {
arr += _("Alt");
}
switch (accel_key) {
case Gdk.Key.Up:
arr += "";
break;
case Gdk.Key.Down:
arr += "";
break;
case Gdk.Key.Left:
arr += "";
break;
case Gdk.Key.Right:
arr += "";
break;
case Gdk.Key.minus:
case Gdk.Key.KP_Subtract:
///TRANSLATORS: This is a non-symbol representation of the "-" key
arr += _("Minus");
break;
case Gdk.Key.KP_Add:
case Gdk.Key.plus:
///TRANSLATORS: This is a non-symbol representation of the "+" key
arr += _("Plus");
break;
case Gdk.Key.KP_Enter:
case Gdk.Key.Return:
arr += _("Enter");
break;
default:
arr += Gtk.accelerator_get_label (accel_key, 0);
break;
}
return string.joinv (" + ", arr);
}
/**
* Takes a description and an array of accels and returns {@link Pango} markup for use in a {@link Gtk.Tooltip}. This method uses {@link Granite.accel_to_string}.
*
* Example:
*
* Description
* Shortcut 1, Shortcut 2
*
* @param a string array of accelerator labels like {"<Control>a", "<Super>Right"}
*
* @param description a standard tooltip text string
*
* @return {@link Pango} markup with the description label on one line and a list of human-readable accels on a new line
*/
public static string markup_accel_tooltip (string[]? accels, string? description = null) {
string[] parts = {};
if (description != null && description != "") {
parts += description;
}
if (accels != null && accels.length > 0) {
string[] unique_accels = {};
for (int i = 0; i < accels.length; i++) {
if (accels[i] == "") {
continue;
}
var accel_string = accel_to_string (accels[i]);
if (!(accel_string in unique_accels)) {
unique_accels += accel_string;
}
}
if (unique_accels.length > 0) {
///TRANSLATORS: This is a delimiter that separates two keyboard shortcut labels like "⌘ + →, Control + A"
var accel_label = string.joinv (_(", "), unique_accels);
var accel_markup = """<span weight="600" size="smaller" alpha="75%">%s</span>""".printf (accel_label);
parts += accel_markup;
}
}
return string.joinv ("\n", parts);
}
}

View File

@ -1,157 +0,0 @@
// From https://github.com/elementary/granite/blob/2066b377226cf327cb2d5399b6b40a2d36d47b11/lib/Widgets/ModeSwitch.vala
/*
* Copyright (c) 2018 elementary, Inc. (https://elementary.io)
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public
* License along with this program; if not, write to the
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301 USA
*/
/**
* ModeSwitch is a selection control for choosing between two options that can be described with an icon.
*
* ''Example''<<BR>>
* {{{
* var gtk_settings = Gtk.Settings.get_default ();
*
* var mode_switch = new ModeSwitch.from_icon_name ("display-brightness-symbolic", "weather-clear-night-symbolic");
* mode_switch.primary_icon_tooltip_text = _("Light background");
* mode_switch.secondary_icon_tooltip_text = _("Dark background");
* mode_switch.bind_property ("active", gtk_settings, "gtk_application_prefer_dark_theme");
* }}}
*/
public class Granite.ModeSwitch : Gtk.Grid {
/**
* Whether the {@link Gtk.Switch} widget is pointing to the secondary icon or not.
*/
public bool active { get; set; }
/**
* The {@link GLib.Icon} to use for the primary icon for the switch.
*/
public GLib.Icon primary_icon_gicon { get; construct set; }
/**
* The icon name to use for the primary icon for the switch.
*/
public string primary_icon_name { get; construct set; }
/**
* The contents of the tooltip on the primary icon.
*/
public string primary_icon_tooltip_text { get; set; }
/**
* The {@link GLib.Icon} to use for the secondary icon for the switch.
*/
public GLib.Icon secondary_icon_gicon { get; construct set; }
/**
* The icon name to use for the secondary icon for the switch.
*/
public string secondary_icon_name { get; construct set; }
/**
* The contents of the tooltip on the secondary icon.
*/
public string secondary_icon_tooltip_text { get; set; }
/**
* Constructs a new {@link Granite.ModeSwitch} using {@link GLib.Icon}s.
*
* @param primary_icon_gicon The {@link GLib.Icon} to use for the primary icon for the switch.
* @param secondary_icon_gicon The {@link GLib.Icon} to use for the secondary icon for the switch.
*/
public ModeSwitch (GLib.Icon primary_icon_gicon, GLib.Icon secondary_icon_gicon) {
Object (
primary_icon_gicon: primary_icon_gicon,
secondary_icon_gicon: secondary_icon_gicon
);
}
/**
* Constructs a new {@link Granite.ModeSwitch} from icon names.
*
* @param primary_icon_name The icon name to use for the primary icon for the switch.
* @param secondary_icon_name The icon name to use for the secondary icon for the switch.
*/
public ModeSwitch.from_icon_name (string primary_icon_name, string secondary_icon_name) {
Object (
primary_icon_gicon: new ThemedIcon (primary_icon_name),
secondary_icon_gicon: new ThemedIcon (secondary_icon_name),
primary_icon_name: primary_icon_name,
secondary_icon_name: secondary_icon_name
);
}
construct {
var primary_image = new Gtk.Image ();
primary_image.pixel_size = 16;
var primary_icon_box = new Gtk.EventBox ();
primary_icon_box.add_events (Gdk.EventMask.BUTTON_RELEASE_MASK);
primary_icon_box.add (primary_image);
var mode_switch = new Gtk.Switch ();
mode_switch.valign = Gtk.Align.CENTER;
mode_switch.get_style_context ().add_class ("mode-switch");
var secondary_icon = new Gtk.Image ();
secondary_icon.pixel_size = 16;
var secondary_icon_box = new Gtk.EventBox ();
secondary_icon_box.add_events (Gdk.EventMask.BUTTON_RELEASE_MASK);
secondary_icon_box.add (secondary_icon);
column_spacing = 6;
add (primary_icon_box);
add (mode_switch);
add (secondary_icon_box);
bind_property ("primary-icon-gicon", primary_image, "gicon", GLib.BindingFlags.SYNC_CREATE);
bind_property ("primary-icon-name", primary_image, "icon-name", GLib.BindingFlags.SYNC_CREATE);
bind_property ("primary-icon-tooltip-text", primary_image, "tooltip-text");
bind_property ("secondary-icon-gicon", secondary_icon, "gicon", GLib.BindingFlags.SYNC_CREATE);
bind_property ("secondary-icon-name", secondary_icon, "icon_name", GLib.BindingFlags.SYNC_CREATE);
bind_property ("secondary-icon-tooltip-text", secondary_icon, "tooltip-text");
this.notify["active"].connect (() => {
if (Gtk.StateFlags.DIR_RTL in get_state_flags ()) {
mode_switch.active = !active;
} else {
mode_switch.active = active;
}
});
mode_switch.notify["active"].connect (() => {
if (Gtk.StateFlags.DIR_RTL in get_state_flags ()) {
active = !mode_switch.active;
} else {
active = mode_switch.active;
}
});
primary_icon_box.button_release_event.connect (() => {
active = false;
return Gdk.EVENT_STOP;
});
secondary_icon_box.button_release_event.connect (() => {
active = true;
return Gdk.EVENT_STOP;
});
}
}

View File

@ -22,7 +22,7 @@ public class WriteAs.Application : Gtk.Application {
Intl.setlocale(LocaleCategory.ALL, "");
Intl.textdomain("write.as");
application_id = "writeas-gtk.desktop";
application_id = "com.github.writeas.writeas-gtk.desktop";
}
public override void activate() {

View File

@ -1,8 +1,6 @@
executable('writeas-gtk',
executable('com.github.writeas.writeas-gtk',
'application.vala',
'window.vala',
'Granite/Accels.vala',
'Granite/ModeSwitch.vala',
c_args: ['-include', 'config.h'],
link_args: '-lm',

View File

@ -19,15 +19,12 @@
public class WriteAs.MainWindow : Gtk.ApplicationWindow {
private Gtk.TextView canvas;
private Gtk.HeaderBar header;
private Granite.ModeSwitch darkmode_switch;
private Gtk.RadioMenuItem font_serif_option;
private Gtk.RadioMenuItem font_sans_option;
private Gtk.RadioMenuItem font_wrap_option;
private Gtk.ToggleButton darkmode_button;
private static string data_dir = ".writeas";
private static string version = "1.0.2";
private static string version = "1.0.0";
private int font_size = 16;
private int font_size = 12;
private bool dark_mode = false;
private string font = "Lora, 'Palatino Linotype',"
+ "'Book Antiqua', 'New York', 'DejaVu serif', serif";
@ -82,11 +79,11 @@ public class WriteAs.MainWindow : Gtk.ApplicationWindow {
stdout.printf("writeas-gtk v%s\n", version);
set_application(app);
icon_name = "write-as";
icon_name = "com.github.writeas.writeas-gtk";
init_folder();
try {
open_file(draft_file());
} catch (Error err) {}
} catch (Error err) {canvas.buffer.text = err.message;}
restore_styles();
set_default_size(800, 600);
@ -137,10 +134,6 @@ public class WriteAs.MainWindow : Gtk.ApplicationWindow {
var publish_button = new Gtk.Button.from_icon_name("document-send",
Gtk.IconSize.SMALL_TOOLBAR);
publish_button.tooltip_markup = Granite.markup_accel_tooltip (
{"<Ctrl>Return"},
_("Publish to Write.as on the web")
);
publish_button.clicked.connect(() => {
canvas.buffer.text += "\n\n" + publish();
@ -148,23 +141,24 @@ public class WriteAs.MainWindow : Gtk.ApplicationWindow {
});
header.pack_end(publish_button);
darkmode_switch = new Granite.ModeSwitch.from_icon_name ("display-brightness-symbolic", "weather-clear-night-symbolic");
darkmode_switch.primary_icon_tooltip_text = ("Light theme");
darkmode_switch.secondary_icon_tooltip_text = ("Dark theme");
darkmode_switch.tooltip_markup = Granite.markup_accel_tooltip (
{"<Ctrl>T"},
_("Toggle light/dark theme")
);
darkmode_switch.valign = Gtk.Align.CENTER;
darkmode_button = new Gtk.ToggleButton();
darkmode_button.tooltip_text = _("Toggle dark theme");
// NOTE the fallback icon is a bit of a meaning stretch, but it works.
var icon_theme = Gtk.IconTheme.get_default();
darkmode_button.image = new Gtk.Image.from_icon_name(
icon_theme.has_icon("writeas-bright-dark") ?
"writeas-bright-dark" : "weather-clear-night",
Gtk.IconSize.SMALL_TOOLBAR);
darkmode_button.draw_indicator = false;
var settings = Gtk.Settings.get_default();
darkmode_switch.notify["active"].connect(() => {
settings.gtk_application_prefer_dark_theme = darkmode_switch.active;
dark_mode = darkmode_switch.active;
darkmode_button.toggled.connect(() => {
settings.gtk_application_prefer_dark_theme = darkmode_button.active;
dark_mode = darkmode_button.active;
if (!is_initializing) theme_save();
canvas.grab_focus();
});
if (supports_dark_theme()) header.pack_end(darkmode_switch);
if (supports_dark_theme()) header.pack_end(darkmode_button);
var fonts = new Gtk.MenuButton();
fonts.tooltip_text = _("Change document font");
@ -172,16 +166,16 @@ public class WriteAs.MainWindow : Gtk.ApplicationWindow {
fonts.popup = new Gtk.Menu();
header.pack_start(fonts);
font_serif_option = build_fontoption(fonts.popup, _("Serif"), "serif", font);
font_sans_option = build_fontoption(fonts.popup, _("Sans-serif"), "sans",
build_fontoption(fonts.popup, _("Serif"), "serif", font);
build_fontoption(fonts.popup, _("Sans-serif"), "sans",
"'Open Sans', 'Segoe UI', Tahoma, Arial, sans-serif");
font_wrap_option = build_fontoption(fonts.popup, _("Monospace"), "wrap", "Hack, consolas," +
build_fontoption(fonts.popup, _("Monospace"), "wrap", "Hack, consolas," +
"Menlo-Regular, Menlo, Monaco, 'ubuntu mono', monospace");
fonts.popup.show_all();
}
private unowned SList<Gtk.RadioMenuItem>? font_options = null;
private Gtk.RadioMenuItem build_fontoption(Gtk.Menu menu,
private void build_fontoption(Gtk.Menu menu,
string label, string fontstyle, string families) {
var option = new Gtk.RadioMenuItem.with_label(font_options, label);
font_options = option.get_group();
@ -196,15 +190,13 @@ public class WriteAs.MainWindow : Gtk.ApplicationWindow {
var styles = option.get_style_context();
var provider = new Gtk.CssProvider();
try {
provider.load_from_data("* {font-family: %s;}".printf(families));
provider.load_from_data("* {font: %s;}".printf(families));
styles.add_provider(provider, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION);
} catch (Error e) {
warning(e.message);
}
menu.add(option);
return option;
}
public override void grab_focus() {
@ -219,21 +211,12 @@ public class WriteAs.MainWindow : Gtk.ApplicationWindow {
theme.load_from_file(get_data_dir() + "/prefs.ini", KeyFileFlags.NONE);
dark_mode = theme.get_boolean("Theme", "darkmode");
darkmode_switch.active = dark_mode;
darkmode_button.set_active(dark_mode);
Gtk.Settings.get_default().gtk_application_prefer_dark_theme = dark_mode;
font_size = theme.get_integer("Theme", "fontsize");
font = theme.get_string("Post", "font");
fontstyle = theme.get_string("Post", "fontstyle");
// Select the current font in the menu
if (fontstyle == "serif") {
font_serif_option.set_active(true);
} else if (fontstyle == "sans") {
font_sans_option.set_active(true);
} else if (fontstyle == "wrap") {
font_wrap_option.set_active(true);
}
adjust_text_style(false);
} catch (Error err) {/* No biggy... */}
}
@ -247,16 +230,16 @@ public class WriteAs.MainWindow : Gtk.ApplicationWindow {
Gtk.StyleContext.remove_provider_for_screen(Gdk.Screen.get_default(), cur_styles);
var padding = canvas.get_allocated_width()*0.10;
var css = ("textview {font-family: %s; font-size: %dpx; padding: 20px 0;" +
" caret-color: #5ac4ee;}").printf(font, font_size);
var css = ("GtkTextView {font: %s; font-size: %dpx; padding: 20px;" +
" padding-left: %ipx; padding-right: %ipx;" +
" -GtkWidget-cursor-color: #5ac4ee;}").printf(font, font_size,
(int) padding, (int) padding);
cur_styles = new Gtk.CssProvider();
cur_styles.load_from_data(css);
Gtk.StyleContext.add_provider_for_screen(Gdk.Screen.get_default(),
cur_styles, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION);
canvas.left_margin = canvas.right_margin = (int) padding;
if (save_theme) theme_save();
} catch (Error e) {
warning(e.message);
@ -354,7 +337,7 @@ public class WriteAs.MainWindow : Gtk.ApplicationWindow {
// Toggle theme with Ctrl+T
accels.connect(Gdk.Key.T, Gdk.ModifierType.CONTROL_MASK, Gtk.AccelFlags.VISIBLE | Gtk.AccelFlags.LOCKED, (g,a,k,m) => {
darkmode_switch.active = !darkmode_switch.active;
darkmode_button.set_active(!darkmode_button.get_active());
return true;
});