diff --git a/README.md b/README.md
index 4559469..4480570 100644
--- a/README.md
+++ b/README.md
@@ -7,9 +7,10 @@
![Build Status](https://img.shields.io/travis/sergius02/Xana/main?style=for-the-badge)
![License](https://img.shields.io/github/license/sergius02/Xana?style=for-the-badge)
-
-
-
+
+|![Xana light theme](screenshots/xana.png) |
+|------------------------------------------|
+![Xana dark theme](screenshots/xana2.png)|
A web browser made by and for developers 🤓️
@@ -21,6 +22,8 @@ For the moment this is a VERY, VERY (really VERY 😹️) simple web browser, as
It's based on Webkit, and inspired in other great browsers like [Midori](https://github.com/midori-browser?type=source)😻️ and [Ephemereal](https://github.com/cassidyjames/ephemeral)😻️.
+Developed for [Elementary OS](https://elementary.io/es/).
+
## Contribute
This is a project that i'm going improve in my free time, if you think you can help the development, the pull request are open 🎉️
@@ -57,6 +60,7 @@ Ensure you have these dependencies installed
* glib-2.0
* gtk+-3.0
* webkit2gtk-4.0
+* libgranite-dev
* [qrencode](https://fukuchi.org/works/qrencode/)
## Install, build and run
diff --git a/data/com.github.sergius02.xana.appdata.xml.in b/data/com.github.sergius02.xana.appdata.xml.in
index 30e3e63..a009601 100644
--- a/data/com.github.sergius02.xana.appdata.xml.in
+++ b/data/com.github.sergius02.xana.appdata.xml.in
@@ -23,6 +23,10 @@
Normal variant
https://github.com/sergius02/Xana/raw/main/screenshots/xana.png
+
+ Dark variant
+ https://github.com/sergius02/Xana/raw/main/screenshots/xana2.png
+
none
diff --git a/data/com.github.sergius02.xana.gschema.xml b/data/com.github.sergius02.xana.gschema.xml
new file mode 100644
index 0000000..57b0f24
--- /dev/null
+++ b/data/com.github.sergius02.xana.gschema.xml
@@ -0,0 +1,11 @@
+
+
+
+
+ false
+ Is dark mode enabled?
+ State of the dark mode
+
+
+
+
\ No newline at end of file
diff --git a/data/meson.build b/data/meson.build
index c41d03a..4f933ba 100644
--- a/data/meson.build
+++ b/data/meson.build
@@ -12,6 +12,11 @@ foreach i : icon_sizes
)
endforeach
+install_data(
+ 'com.github.sergius02.xana.gschema.xml',
+ install_dir: join_paths(get_option('datadir'), 'glib-2.0', 'schemas')
+)
+
# Translate and install our .desktop file so the Applications Menu will see it
i18n.merge_file (
input: meson.project_name () + '.desktop.in',
diff --git a/resources/com.github.sergius02.xana.xml b/resources/com.github.sergius02.xana.xml
index f17eb48..02a526e 100644
--- a/resources/com.github.sergius02.xana.xml
+++ b/resources/com.github.sergius02.xana.xml
@@ -4,6 +4,7 @@
ui/application_window.ui
ui/notebook_tabs.ui
ui/dialog_about.ui
+ ui/settings_view.ui
css/xana.css
diff --git a/resources/css/xana.css b/resources/css/xana.css
index f237b01..fc8eb4e 100644
--- a/resources/css/xana.css
+++ b/resources/css/xana.css
@@ -9,4 +9,13 @@
.zoom-increase {
border-left: 1px solid lightgray;
+}
+
+.settings-section-title {
+ font-weight: bold;
+ font-size: 1.5em;
+}
+
+.setting-title {
+ font-weight: lighter;
}
\ No newline at end of file
diff --git a/resources/ui/application_window.ui b/resources/ui/application_window.ui
index 60a45b7..7385e7e 100644
--- a/resources/ui/application_window.ui
+++ b/resources/ui/application_window.ui
@@ -37,6 +37,11 @@
False
view-refresh-symbolic
+
+ True
+ False
+ preferences-system-symbolic
+
True
False
@@ -55,7 +60,7 @@
False
True
-
+
+
+
+ True
+ True
+ True
+ image_settings
+
+
+ False
+ True
+ 2
+
+
@@ -203,6 +221,21 @@
Sergio Fernández Celorio
image-missing
gpl-3-0
+
+
+ False
+
+
+ False
+
+
+ False
+ False
+ 0
+
+
+
+
False
diff --git a/resources/ui/settings_view.ui b/resources/ui/settings_view.ui
new file mode 100644
index 0000000..4a35c01
--- /dev/null
+++ b/resources/ui/settings_view.ui
@@ -0,0 +1,68 @@
+
+
+
+
+
+ True
+ False
+ vertical
+
+
+ True
+ False
+ 15
+ UI settings
+
+
+
+ False
+ True
+ 0
+
+
+
+
+ True
+ False
+ start
+ 15
+
+
+ True
+ False
+ end
+ 10
+ Activate dark mode
+
+
+
+ True
+ True
+ 0
+
+
+
+
+ True
+ True
+ start
+
+
+ True
+ True
+ 1
+
+
+
+
+ False
+ True
+ 1
+
+
+
+
diff --git a/screenshots/xana.png b/screenshots/xana.png
index 294e73c..7872f08 100644
Binary files a/screenshots/xana.png and b/screenshots/xana.png differ
diff --git a/screenshots/xana2.png b/screenshots/xana2.png
new file mode 100644
index 0000000..d91b6c3
Binary files /dev/null and b/screenshots/xana2.png differ
diff --git a/src/Application.vala b/src/Application.vala
index dd07dda..6b2094e 100644
--- a/src/Application.vala
+++ b/src/Application.vala
@@ -1,5 +1,7 @@
public class Xana.Application : Gtk.Application {
+ public static Settings xana_settings = new Settings ("com.github.sergius02.xana");
+
public string cache_folder;
public Gtk.CssProvider css_provider;
@@ -12,6 +14,7 @@ public class Xana.Application : Gtk.Application {
protected override void activate () {
create_cache_folder ();
+ new Xana.SettingsView (); // Force to load the settings at the launch, specially the dark mode
this.css_provider = new Gtk.CssProvider ();
css_provider.load_from_resource ("/com/github/sergius02/xana/css/xana.css");
diff --git a/src/ApplicationWindow.vala b/src/ApplicationWindow.vala
index bc63c38..614bd84 100644
--- a/src/ApplicationWindow.vala
+++ b/src/ApplicationWindow.vala
@@ -46,6 +46,9 @@ public class Xana.ApplicationWindow : Gtk.ApplicationWindow {
[GtkChild]
private Gtk.Button button_reset_zoom;
+ [GtkChild]
+ private Gtk.Button button_settings;
+
private Xana.Notebook notebook;
public ApplicationWindow (Xana.Application application) {
@@ -81,6 +84,10 @@ public class Xana.ApplicationWindow : Gtk.ApplicationWindow {
button_reset_zoom.label = "%.0f%%".printf (notebook.reset_zoom () * 100);
});
+ button_settings.clicked.connect (() => {
+ notebook.open_settings_tab ();
+ });
+
modelbutton_about.clicked.connect ( () => {
Xana.AboutDialog about_dialog = new Xana.AboutDialog (this);
about_dialog.present ();
@@ -98,17 +105,24 @@ public class Xana.ApplicationWindow : Gtk.ApplicationWindow {
});
}
- public void update_navigation_buttons () {
- this.button_go_back.clicked.connect (notebook.back);
- this.button_go_back.sensitive = notebook.can_go_back ();
+ public void update_navigation_buttons (bool is_webview) {
+ if (is_webview) {
+ this.button_go_back.clicked.connect (notebook.back);
+ this.button_go_back.sensitive = notebook.can_go_back ();
- this.button_go_forward.clicked.connect (notebook.forward);
- this.button_go_forward.sensitive = notebook.can_go_forward ();
+ this.button_go_forward.clicked.connect (notebook.forward);
+ this.button_go_forward.sensitive = notebook.can_go_forward ();
- this.button_refresh.clicked.connect (notebook.reload);
- this.button_stop_refresh.clicked.connect (notebook.stop_reload);
+ this.button_refresh.clicked.connect (notebook.reload);
+ this.button_stop_refresh.clicked.connect (notebook.stop_reload);
- this.entry_url_to_go.text = notebook.current_uri ();
+ this.entry_url_to_go.text = notebook.current_uri ();
+ } else {
+ this.button_go_back.sensitive = false;
+ this.button_go_forward.sensitive = false;
+ this.button_go_forward.sensitive = false;
+ this.entry_url_to_go.text = "xana://settings";
+ }
}
}
diff --git a/src/meson.build b/src/meson.build
index 794c61f..2b7c7e9 100644
--- a/src/meson.build
+++ b/src/meson.build
@@ -9,4 +9,5 @@ sources = files (
'widgets/Notebook.vala',
'widgets/WebView.vala',
'widgets/AboutDialog.vala',
+ 'widgets/SettingsView.vala'
)
diff --git a/src/utils/QRUtils.vala b/src/utils/QRUtils.vala
index e379abb..4e69e33 100644
--- a/src/utils/QRUtils.vala
+++ b/src/utils/QRUtils.vala
@@ -4,8 +4,13 @@ public class QRUtils {
string command = "qrencode"; // Base command
command += " -s 4"; // QR image size
command += " -t PNG"; // QR format image
- command += " --foreground=000000"; // QR foreground color
- command += " --background=F5F5F5"; // QR background color
+ if (Gtk.Settings.get_default ().gtk_application_prefer_dark_theme) {
+ command += " --foreground=fafafa"; // QR foreground color dark theme
+ command += " --background=3D3D3D"; // QR background color dark theme
+ } else {
+ command += " --foreground=000000"; // QR foreground color light theme
+ command += " --background=F5F5F5"; // QR background color light theme
+ }
command += " -o " + cache_folder + "/site_qr.png "; // QR result path
command += qr_content; // QR content
try {
diff --git a/src/widgets/Notebook.vala b/src/widgets/Notebook.vala
index c1d5df6..111d841 100644
--- a/src/widgets/Notebook.vala
+++ b/src/widgets/Notebook.vala
@@ -17,19 +17,18 @@ public class Xana.Notebook : Gtk.Notebook {
button_add_tab.clicked.connect (() => {
new_tab ();
- show_all ();
- set_current_page (get_n_pages () - 1);
});
- switch_page.connect_after (() => {
- application.update_navigation_buttons ();
+ switch_page.connect_after ((page) => {
+ application.update_navigation_buttons (page is Xana.WebView);
});
+
}
- private void new_tab () {
+ private void create_tab (string tab_title, Gtk.Widget tab_content) {
Gtk.Box tab_box = new Gtk.Box (Gtk.Orientation.HORIZONTAL, 0);
- Gtk.Label tab_label = new Gtk.Label ("New tab");
+ Gtk.Label tab_label = new Gtk.Label (tab_title);
Gtk.Button tab_button_close = new Gtk.Button.from_icon_name ("window-close-symbolic", Gtk.IconSize.BUTTON);
tab_button_close.relief = Gtk.ReliefStyle.NONE;
@@ -38,16 +37,47 @@ public class Xana.Notebook : Gtk.Notebook {
tab_box.show_all ();
- Xana.WebView web_view = new Xana.WebView (application, tab_label);
- append_page (web_view, tab_box);
+ append_page (tab_content, tab_box);
tab_button_close.clicked.connect (() => {
// Little tricky, but it works. Probably must be other method to do this
- reorder_child (web_view, -1); // Move the tab to the end, reordening every tab
+ reorder_child (tab_content, -1); // Move the tab to the end, reordening every tab
remove_page (-1); // And then close the last tab
});
- web_view.load_home ();
+ show_all ();
+
+ if (tab_content is Xana.WebView) {
+ Xana.WebView tab_webview = tab_content as Xana.WebView;
+ tab_webview.set_tab_label (tab_label);
+ tab_webview.load_home ();
+ }
+
+ set_current_page (get_n_pages () - 1);
+ }
+
+ public void open_settings_tab () {
+ bool is_settings_open = false;
+ int settings_tab_position = -1;
+
+ this.foreach ((child) => {
+ if (child is Xana.SettingsView) {
+ is_settings_open = true;
+ settings_tab_position = page_num (child);
+ }
+ });
+
+ if (!is_settings_open) {
+ Xana.SettingsView settings_view = new Xana.SettingsView ();
+ create_tab ("Xana settings", settings_view);
+ } else {
+ set_current_page (settings_tab_position);
+ }
+ }
+
+ private void new_tab () {
+ Xana.WebView web_view = new Xana.WebView (application);
+ create_tab ("New tab", web_view);
}
public void load (string uri) {
diff --git a/src/widgets/SettingsView.vala b/src/widgets/SettingsView.vala
new file mode 100644
index 0000000..dffdf4b
--- /dev/null
+++ b/src/widgets/SettingsView.vala
@@ -0,0 +1,13 @@
+[GtkTemplate (ui = "/com/github/sergius02/xana/ui/settings_view.ui")]
+public class Xana.SettingsView : Gtk.Box{
+
+ [GtkChild]
+ private Gtk.Switch switch_dark_mode;
+
+ public SettingsView () {
+ switch_dark_mode.valign = Gtk.Align.CENTER;
+ switch_dark_mode.bind_property ("active", Gtk.Settings.get_default (), "gtk_application_prefer_dark_theme");
+ Application.xana_settings.bind ("dark-mode", switch_dark_mode, "active", GLib.SettingsBindFlags.DEFAULT);
+ }
+
+}
\ No newline at end of file
diff --git a/src/widgets/WebView.vala b/src/widgets/WebView.vala
index b14b820..d7fcdf4 100644
--- a/src/widgets/WebView.vala
+++ b/src/widgets/WebView.vala
@@ -8,9 +8,8 @@ public class Xana.WebView : WebKit.WebView {
web_context = new Xana.WebContext ();
}
- public WebView (Xana.ApplicationWindow application, Gtk.Label tab_label) {
+ public WebView (Xana.ApplicationWindow application) {
this.application = application;
- this.tab_label = tab_label;
this.home = "https://duckduckgo.com/";
get_settings ().enable_developer_extras = true;
@@ -44,4 +43,8 @@ public class Xana.WebView : WebKit.WebView {
load_uri (home);
}
+ public void set_tab_label (Gtk.Label tab_label) {
+ this.tab_label = tab_label;
+ }
+
}