Compare commits
23 Commits
deb-packag
...
master
Author | SHA1 | Date | |
---|---|---|---|
8a86a99413 | |||
![]() |
b8f4ea365c | ||
7d364e0a27 | |||
eee4191db9 | |||
95dc0eb8cb | |||
8312087ec9 | |||
2a7a5041c3 | |||
2c93de931b | |||
![]() |
5b1e88c995 | ||
![]() |
4c2be78f58 | ||
![]() |
d10d4081a2 | ||
e680afb059 | |||
ac04997301 | |||
![]() |
58e67738b7 | ||
cccffacf55 | |||
708de8f0ae | |||
0436c4ae95 | |||
7a12af3c11 | |||
f0d601f98c | |||
78a23713cf | |||
9ba47ba191 | |||
67b6198b5e | |||
c0c8775c3a |
@ -35,4 +35,4 @@ script:
|
|||||||
|
|
||||||
branches:
|
branches:
|
||||||
only:
|
only:
|
||||||
- master
|
- deb-packaging
|
||||||
|
12
README.md
@ -1,10 +1,16 @@
|
|||||||
# Write.as GTK App
|
# Write.as GTK App
|
||||||
|
|
||||||
|
[](https://write.as/apps/desktop)
|
||||||
|
[](https://appcenter.elementary.io/com.github.writeas.writeas-gtk)
|
||||||
|
|
||||||
A Write.as desktop app that targets all freedesktop.org compliant desktops, e.g.
|
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
|
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/).
|
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.
|
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
|
## Usage
|
||||||
|
|
||||||
See the [User Guide](https://code.as/writeas/writeas-gtk/src/branch/master/USER_GUIDE.md).
|
See the [User Guide](https://code.as/writeas/writeas-gtk/src/branch/master/USER_GUIDE.md).
|
||||||
@ -18,9 +24,9 @@ any FreeDesktop.Org compatible system using:
|
|||||||
# Either via pip:
|
# Either via pip:
|
||||||
pip3 install meson
|
pip3 install meson
|
||||||
# Or, if you need to build the .deb:
|
# Or, if you need to build the .deb:
|
||||||
sudo add-apt-repository ppa:jonathonf/meson
|
sudo apt install meson ninja-build
|
||||||
sudo apt update
|
# You might also need some of these dependencies to successfully build the app:
|
||||||
sudo apt install meson
|
sudo apt install build-essential valac libgtk-3-dev libgtksourceview-3.0-dev
|
||||||
|
|
||||||
# Build
|
# Build
|
||||||
meson build && cd build
|
meson build && cd build
|
||||||
|
Before Width: | Height: | Size: 2.9 KiB |
Before Width: | Height: | Size: 3.1 KiB |
@ -1,10 +1,8 @@
|
|||||||
install_data('icons/write-as.png',
|
install_data('icons/write-as.png',
|
||||||
install_dir: join_paths(get_option('datadir'), 'icons', 'hicolor', '128x128', 'apps')
|
install_dir: join_paths(get_option('datadir'), 'icons', 'hicolor', '128x128', 'apps')
|
||||||
)
|
)
|
||||||
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_data('writeas-gtk.desktop',
|
||||||
install_dir: join_paths(get_option('datadir'), 'applications'))
|
install_dir: join_paths(get_option('datadir'), 'applications'))
|
||||||
install_data('com.github.writeas.writeas-gtk.appdata.xml',
|
install_data('writeas-gtk.appdata.xml',
|
||||||
install_dir: join_paths(get_option('datadir'), 'metainfo'))
|
install_dir: join_paths(get_option('datadir'), 'metainfo'))
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8" ?>
|
<?xml version="1.0" encoding="UTF-8" ?>
|
||||||
<component type="desktop-application">
|
<component type="desktop-application">
|
||||||
<id>com.github.writeas.writeas-gtk</id>
|
<id>writeas-gtk</id>
|
||||||
<project_license>GPL-3.0+</project_license>
|
<project_license>GPL-3.0+</project_license>
|
||||||
<metadata_license>CC0</metadata_license>
|
<metadata_license>CC0</metadata_license>
|
||||||
<name>Write.as</name>
|
<name>Write.as</name>
|
||||||
@ -28,7 +28,7 @@
|
|||||||
<update_contact>hello@write.as</update_contact>
|
<update_contact>hello@write.as</update_contact>
|
||||||
|
|
||||||
<provides>
|
<provides>
|
||||||
<binary>com.github.writeas.writeas-gtk</binary>
|
<binary>writeas-gtk</binary>
|
||||||
</provides>
|
</provides>
|
||||||
|
|
||||||
<screenshots>
|
<screenshots>
|
||||||
@ -69,7 +69,7 @@
|
|||||||
<content_attribute id="language-humor">none</content_attribute>
|
<content_attribute id="language-humor">none</content_attribute>
|
||||||
<content_attribute id="language-discrimination">none</content_attribute>
|
<content_attribute id="language-discrimination">none</content_attribute>
|
||||||
<content_attribute id="social-chat">none</content_attribute>
|
<content_attribute id="social-chat">none</content_attribute>
|
||||||
<content_attribute id="social-info">none</content_attribute>
|
<content_attribute id="social-info">moderate</content_attribute>
|
||||||
<content_attribute id="social-audio">none</content_attribute>
|
<content_attribute id="social-audio">none</content_attribute>
|
||||||
<content_attribute id="social-location">none</content_attribute>
|
<content_attribute id="social-location">none</content_attribute>
|
||||||
<content_attribute id="social-contacts">none</content_attribute>
|
<content_attribute id="social-contacts">none</content_attribute>
|
||||||
@ -77,6 +77,24 @@
|
|||||||
<content_attribute id="money-gambling">none</content_attribute>
|
<content_attribute id="money-gambling">none</content_attribute>
|
||||||
</content_rating>
|
</content_rating>
|
||||||
<releases>
|
<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">
|
<release version="1.0.0" date="2018-10-01">
|
||||||
<description>
|
<description>
|
||||||
<p>Initial release</p>
|
<p>Initial release</p>
|
14
debian/changelog
vendored
@ -1,3 +1,17 @@
|
|||||||
|
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
|
writeas-gtk (1.0.0-1) xenial; urgency=medium
|
||||||
|
|
||||||
* Initial Release.
|
* Initial Release.
|
||||||
|
4
debian/control
vendored
@ -1,4 +1,4 @@
|
|||||||
Source: com.github.writeas.writeas-gtk
|
Source: writeas-gtk
|
||||||
Section: x11
|
Section: x11
|
||||||
Priority: extra
|
Priority: extra
|
||||||
Maintainer: Write.as <hello@write.as>
|
Maintainer: Write.as <hello@write.as>
|
||||||
@ -9,7 +9,7 @@ Build-Depends: meson,
|
|||||||
valac (>= 0.36)
|
valac (>= 0.36)
|
||||||
Standards-Version: 3.9.3
|
Standards-Version: 3.9.3
|
||||||
|
|
||||||
Package: com.github.writeas.writeas-gtk
|
Package: writeas-gtk
|
||||||
Architecture: any
|
Architecture: any
|
||||||
Depends: ${misc:Depends}, ${shlibs:Depends}, writeas-cli
|
Depends: ${misc:Depends}, ${shlibs:Depends}, writeas-cli
|
||||||
Recommends: fonts-lora, fonts-open-sans, fonts-hack
|
Recommends: fonts-lora, fonts-open-sans, fonts-hack
|
||||||
|
2
debian/copyright
vendored
@ -1,5 +1,5 @@
|
|||||||
Format: http://dep.debian.net/deps/dep5
|
Format: http://dep.debian.net/deps/dep5
|
||||||
Upstream-Name: com.github.writeas.writeas-gtk
|
Upstream-Name: writeas-gtk
|
||||||
Source: https://code.as/writeas/writeas-gtk/
|
Source: https://code.as/writeas/writeas-gtk/
|
||||||
|
|
||||||
Files: *
|
Files: *
|
||||||
|
2
debian/rules
vendored
@ -28,4 +28,4 @@ override_dh_auto_test:
|
|||||||
cd debian/build && ninja test
|
cd debian/build && ninja test
|
||||||
|
|
||||||
override_dh_auto_install:
|
override_dh_auto_install:
|
||||||
cd debian/build && DESTDIR=${CURDIR}/debian/com.github.writeas.writeas-gtk ninja install
|
cd debian/build && DESTDIR=${CURDIR}/debian/writeas-gtk ninja install
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
project('com.github.writeas.writeas-gtk', ['vala', 'c'],
|
project('writeas-gtk', ['vala', 'c'],
|
||||||
version: '1.0.0',
|
version: '1.0.2',
|
||||||
license: 'GPL',
|
license: 'GPL',
|
||||||
meson_version: '>=0.40.1')
|
meson_version: '>=0.40.1')
|
||||||
|
|
||||||
|
Before Width: | Height: | Size: 49 KiB After Width: | Height: | Size: 52 KiB |
Before Width: | Height: | Size: 44 KiB After Width: | Height: | Size: 46 KiB |
Before Width: | Height: | Size: 50 KiB After Width: | Height: | Size: 49 KiB |
Before Width: | Height: | Size: 50 KiB After Width: | Height: | Size: 49 KiB |
136
src/Granite/Accels.vala
Normal file
@ -0,0 +1,136 @@
|
|||||||
|
// 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);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
157
src/Granite/ModeSwitch.vala
Normal file
@ -0,0 +1,157 @@
|
|||||||
|
// 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;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -22,7 +22,7 @@ public class WriteAs.Application : Gtk.Application {
|
|||||||
Intl.setlocale(LocaleCategory.ALL, "");
|
Intl.setlocale(LocaleCategory.ALL, "");
|
||||||
Intl.textdomain("write.as");
|
Intl.textdomain("write.as");
|
||||||
|
|
||||||
application_id = "com.github.writeas.writeas-gtk.desktop";
|
application_id = "writeas-gtk.desktop";
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void activate() {
|
public override void activate() {
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
executable('com.github.writeas.writeas-gtk',
|
executable('writeas-gtk',
|
||||||
'application.vala',
|
'application.vala',
|
||||||
'window.vala',
|
'window.vala',
|
||||||
|
'Granite/Accels.vala',
|
||||||
|
'Granite/ModeSwitch.vala',
|
||||||
|
|
||||||
c_args: ['-include', 'config.h'],
|
c_args: ['-include', 'config.h'],
|
||||||
link_args: '-lm',
|
link_args: '-lm',
|
||||||
|
@ -19,12 +19,15 @@
|
|||||||
public class WriteAs.MainWindow : Gtk.ApplicationWindow {
|
public class WriteAs.MainWindow : Gtk.ApplicationWindow {
|
||||||
private Gtk.TextView canvas;
|
private Gtk.TextView canvas;
|
||||||
private Gtk.HeaderBar header;
|
private Gtk.HeaderBar header;
|
||||||
private Gtk.ToggleButton darkmode_button;
|
private Granite.ModeSwitch darkmode_switch;
|
||||||
|
private Gtk.RadioMenuItem font_serif_option;
|
||||||
|
private Gtk.RadioMenuItem font_sans_option;
|
||||||
|
private Gtk.RadioMenuItem font_wrap_option;
|
||||||
|
|
||||||
private static string data_dir = ".writeas";
|
private static string data_dir = ".writeas";
|
||||||
private static string version = "1.0.0";
|
private static string version = "1.0.2";
|
||||||
|
|
||||||
private int font_size = 12;
|
private int font_size = 16;
|
||||||
private bool dark_mode = false;
|
private bool dark_mode = false;
|
||||||
private string font = "Lora, 'Palatino Linotype',"
|
private string font = "Lora, 'Palatino Linotype',"
|
||||||
+ "'Book Antiqua', 'New York', 'DejaVu serif', serif";
|
+ "'Book Antiqua', 'New York', 'DejaVu serif', serif";
|
||||||
@ -83,7 +86,7 @@ public class WriteAs.MainWindow : Gtk.ApplicationWindow {
|
|||||||
init_folder();
|
init_folder();
|
||||||
try {
|
try {
|
||||||
open_file(draft_file());
|
open_file(draft_file());
|
||||||
} catch (Error err) {canvas.buffer.text = err.message;}
|
} catch (Error err) {}
|
||||||
restore_styles();
|
restore_styles();
|
||||||
|
|
||||||
set_default_size(800, 600);
|
set_default_size(800, 600);
|
||||||
@ -134,6 +137,10 @@ public class WriteAs.MainWindow : Gtk.ApplicationWindow {
|
|||||||
|
|
||||||
var publish_button = new Gtk.Button.from_icon_name("document-send",
|
var publish_button = new Gtk.Button.from_icon_name("document-send",
|
||||||
Gtk.IconSize.SMALL_TOOLBAR);
|
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(() => {
|
publish_button.clicked.connect(() => {
|
||||||
canvas.buffer.text += "\n\n" + publish();
|
canvas.buffer.text += "\n\n" + publish();
|
||||||
|
|
||||||
@ -141,24 +148,23 @@ public class WriteAs.MainWindow : Gtk.ApplicationWindow {
|
|||||||
});
|
});
|
||||||
header.pack_end(publish_button);
|
header.pack_end(publish_button);
|
||||||
|
|
||||||
darkmode_button = new Gtk.ToggleButton();
|
darkmode_switch = new Granite.ModeSwitch.from_icon_name ("display-brightness-symbolic", "weather-clear-night-symbolic");
|
||||||
darkmode_button.tooltip_text = _("Toggle dark theme");
|
darkmode_switch.primary_icon_tooltip_text = ("Light theme");
|
||||||
// NOTE the fallback icon is a bit of a meaning stretch, but it works.
|
darkmode_switch.secondary_icon_tooltip_text = ("Dark theme");
|
||||||
var icon_theme = Gtk.IconTheme.get_default();
|
darkmode_switch.tooltip_markup = Granite.markup_accel_tooltip (
|
||||||
darkmode_button.image = new Gtk.Image.from_icon_name(
|
{"<Ctrl>T"},
|
||||||
icon_theme.has_icon("writeas-bright-dark") ?
|
_("Toggle light/dark theme")
|
||||||
"writeas-bright-dark" : "weather-clear-night",
|
);
|
||||||
Gtk.IconSize.SMALL_TOOLBAR);
|
darkmode_switch.valign = Gtk.Align.CENTER;
|
||||||
darkmode_button.draw_indicator = false;
|
|
||||||
var settings = Gtk.Settings.get_default();
|
var settings = Gtk.Settings.get_default();
|
||||||
darkmode_button.toggled.connect(() => {
|
darkmode_switch.notify["active"].connect(() => {
|
||||||
settings.gtk_application_prefer_dark_theme = darkmode_button.active;
|
settings.gtk_application_prefer_dark_theme = darkmode_switch.active;
|
||||||
dark_mode = darkmode_button.active;
|
dark_mode = darkmode_switch.active;
|
||||||
if (!is_initializing) theme_save();
|
if (!is_initializing) theme_save();
|
||||||
|
|
||||||
canvas.grab_focus();
|
canvas.grab_focus();
|
||||||
});
|
});
|
||||||
if (supports_dark_theme()) header.pack_end(darkmode_button);
|
if (supports_dark_theme()) header.pack_end(darkmode_switch);
|
||||||
|
|
||||||
var fonts = new Gtk.MenuButton();
|
var fonts = new Gtk.MenuButton();
|
||||||
fonts.tooltip_text = _("Change document font");
|
fonts.tooltip_text = _("Change document font");
|
||||||
@ -166,16 +172,16 @@ public class WriteAs.MainWindow : Gtk.ApplicationWindow {
|
|||||||
fonts.popup = new Gtk.Menu();
|
fonts.popup = new Gtk.Menu();
|
||||||
header.pack_start(fonts);
|
header.pack_start(fonts);
|
||||||
|
|
||||||
build_fontoption(fonts.popup, _("Serif"), "serif", font);
|
font_serif_option = build_fontoption(fonts.popup, _("Serif"), "serif", font);
|
||||||
build_fontoption(fonts.popup, _("Sans-serif"), "sans",
|
font_sans_option = build_fontoption(fonts.popup, _("Sans-serif"), "sans",
|
||||||
"'Open Sans', 'Segoe UI', Tahoma, Arial, sans-serif");
|
"'Open Sans', 'Segoe UI', Tahoma, Arial, sans-serif");
|
||||||
build_fontoption(fonts.popup, _("Monospace"), "wrap", "Hack, consolas," +
|
font_wrap_option = build_fontoption(fonts.popup, _("Monospace"), "wrap", "Hack, consolas," +
|
||||||
"Menlo-Regular, Menlo, Monaco, 'ubuntu mono', monospace");
|
"Menlo-Regular, Menlo, Monaco, 'ubuntu mono', monospace");
|
||||||
fonts.popup.show_all();
|
fonts.popup.show_all();
|
||||||
}
|
}
|
||||||
|
|
||||||
private unowned SList<Gtk.RadioMenuItem>? font_options = null;
|
private unowned SList<Gtk.RadioMenuItem>? font_options = null;
|
||||||
private void build_fontoption(Gtk.Menu menu,
|
private Gtk.RadioMenuItem build_fontoption(Gtk.Menu menu,
|
||||||
string label, string fontstyle, string families) {
|
string label, string fontstyle, string families) {
|
||||||
var option = new Gtk.RadioMenuItem.with_label(font_options, label);
|
var option = new Gtk.RadioMenuItem.with_label(font_options, label);
|
||||||
font_options = option.get_group();
|
font_options = option.get_group();
|
||||||
@ -190,13 +196,15 @@ public class WriteAs.MainWindow : Gtk.ApplicationWindow {
|
|||||||
var styles = option.get_style_context();
|
var styles = option.get_style_context();
|
||||||
var provider = new Gtk.CssProvider();
|
var provider = new Gtk.CssProvider();
|
||||||
try {
|
try {
|
||||||
provider.load_from_data("* {font: %s;}".printf(families));
|
provider.load_from_data("* {font-family: %s;}".printf(families));
|
||||||
styles.add_provider(provider, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION);
|
styles.add_provider(provider, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION);
|
||||||
} catch (Error e) {
|
} catch (Error e) {
|
||||||
warning(e.message);
|
warning(e.message);
|
||||||
}
|
}
|
||||||
|
|
||||||
menu.add(option);
|
menu.add(option);
|
||||||
|
|
||||||
|
return option;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void grab_focus() {
|
public override void grab_focus() {
|
||||||
@ -211,12 +219,21 @@ public class WriteAs.MainWindow : Gtk.ApplicationWindow {
|
|||||||
theme.load_from_file(get_data_dir() + "/prefs.ini", KeyFileFlags.NONE);
|
theme.load_from_file(get_data_dir() + "/prefs.ini", KeyFileFlags.NONE);
|
||||||
|
|
||||||
dark_mode = theme.get_boolean("Theme", "darkmode");
|
dark_mode = theme.get_boolean("Theme", "darkmode");
|
||||||
darkmode_button.set_active(dark_mode);
|
darkmode_switch.active = dark_mode;
|
||||||
Gtk.Settings.get_default().gtk_application_prefer_dark_theme = dark_mode;
|
Gtk.Settings.get_default().gtk_application_prefer_dark_theme = dark_mode;
|
||||||
font_size = theme.get_integer("Theme", "fontsize");
|
font_size = theme.get_integer("Theme", "fontsize");
|
||||||
font = theme.get_string("Post", "font");
|
font = theme.get_string("Post", "font");
|
||||||
fontstyle = theme.get_string("Post", "fontstyle");
|
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);
|
adjust_text_style(false);
|
||||||
} catch (Error err) {/* No biggy... */}
|
} catch (Error err) {/* No biggy... */}
|
||||||
}
|
}
|
||||||
@ -230,16 +247,16 @@ public class WriteAs.MainWindow : Gtk.ApplicationWindow {
|
|||||||
Gtk.StyleContext.remove_provider_for_screen(Gdk.Screen.get_default(), cur_styles);
|
Gtk.StyleContext.remove_provider_for_screen(Gdk.Screen.get_default(), cur_styles);
|
||||||
|
|
||||||
var padding = canvas.get_allocated_width()*0.10;
|
var padding = canvas.get_allocated_width()*0.10;
|
||||||
var css = ("GtkTextView {font: %s; font-size: %dpx; padding: 20px;" +
|
var css = ("textview {font-family: %s; font-size: %dpx; padding: 20px 0;" +
|
||||||
" padding-left: %ipx; padding-right: %ipx;" +
|
" caret-color: #5ac4ee;}").printf(font, font_size);
|
||||||
" -GtkWidget-cursor-color: #5ac4ee;}").printf(font, font_size,
|
|
||||||
(int) padding, (int) padding);
|
|
||||||
cur_styles = new Gtk.CssProvider();
|
cur_styles = new Gtk.CssProvider();
|
||||||
cur_styles.load_from_data(css);
|
cur_styles.load_from_data(css);
|
||||||
|
|
||||||
Gtk.StyleContext.add_provider_for_screen(Gdk.Screen.get_default(),
|
Gtk.StyleContext.add_provider_for_screen(Gdk.Screen.get_default(),
|
||||||
cur_styles, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION);
|
cur_styles, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION);
|
||||||
|
|
||||||
|
canvas.left_margin = canvas.right_margin = (int) padding;
|
||||||
|
|
||||||
if (save_theme) theme_save();
|
if (save_theme) theme_save();
|
||||||
} catch (Error e) {
|
} catch (Error e) {
|
||||||
warning(e.message);
|
warning(e.message);
|
||||||
@ -337,7 +354,7 @@ public class WriteAs.MainWindow : Gtk.ApplicationWindow {
|
|||||||
|
|
||||||
// Toggle theme with Ctrl+T
|
// Toggle theme with Ctrl+T
|
||||||
accels.connect(Gdk.Key.T, Gdk.ModifierType.CONTROL_MASK, Gtk.AccelFlags.VISIBLE | Gtk.AccelFlags.LOCKED, (g,a,k,m) => {
|
accels.connect(Gdk.Key.T, Gdk.ModifierType.CONTROL_MASK, Gtk.AccelFlags.VISIBLE | Gtk.AccelFlags.LOCKED, (g,a,k,m) => {
|
||||||
darkmode_button.set_active(!darkmode_button.get_active());
|
darkmode_switch.active = !darkmode_switch.active;
|
||||||
return true;
|
return true;
|
||||||
});
|
});
|
||||||
|
|
||||||
|