Skip to content

Commit

Permalink
🔀️ Merge pull request #1 from sergius02/development
Browse files Browse the repository at this point in the history
  • Loading branch information
sergius02 committed Oct 4, 2020
2 parents 4ce1248 + 8288f57 commit ec36d3f
Show file tree
Hide file tree
Showing 17 changed files with 230 additions and 26 deletions.
10 changes: 7 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)

<p align="center">
<img src="screenshots/xana.png" alt="Icon" />
</p>

|![Xana light theme](screenshots/xana.png) |
|------------------------------------------|
![Xana dark theme](screenshots/xana2.png)|

A web browser made by and for developers 🤓️

Expand All @@ -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 🎉️
Expand Down Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions data/com.github.sergius02.xana.appdata.xml.in
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@
<caption>Normal variant</caption>
<image>https://github.com/sergius02/Xana/raw/main/screenshots/xana.png</image>
</screenshot>
<screenshot>
<caption>Dark variant</caption>
<image>https://github.com/sergius02/Xana/raw/main/screenshots/xana2.png</image>
</screenshot>
</screenshots>
<content_rating type="oars-1.1">
<content_attribute id="violence-cartoon">none</content_attribute>
Expand Down
11 changes: 11 additions & 0 deletions data/com.github.sergius02.xana.gschema.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<schemalist>
<schema id="com.github.sergius02.xana" path="/com/github/sergius02/xana/">

<key name="dark-mode" type="b">
<default>false</default>
<summary>Is dark mode enabled?</summary>
<description>State of the dark mode</description>
</key>

</schema>
</schemalist>
5 changes: 5 additions & 0 deletions data/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
1 change: 1 addition & 0 deletions resources/com.github.sergius02.xana.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
<file>ui/application_window.ui</file>
<file>ui/notebook_tabs.ui</file>
<file>ui/dialog_about.ui</file>
<file>ui/settings_view.ui</file>

<file>css/xana.css</file>

Expand Down
9 changes: 9 additions & 0 deletions resources/css/xana.css
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
35 changes: 34 additions & 1 deletion resources/ui/application_window.ui
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,11 @@
<property name="can-focus">False</property>
<property name="icon-name">view-refresh-symbolic</property>
</object>
<object class="GtkImage" id="image_settings">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="icon-name">preferences-system-symbolic</property>
</object>
<object class="GtkImage" id="image_stoprefresh">
<property name="visible">True</property>
<property name="can-focus">False</property>
Expand All @@ -55,7 +60,7 @@
<property name="can-focus">False</property>
<property name="show-close-button">True</property>
<child type="title">
<object class="GtkBox">
<object class="GtkBox" id="box_header_right">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="hexpand">True</property>
Expand Down Expand Up @@ -96,6 +101,19 @@
<property name="position">1</property>
</packing>
</child>
<child>
<object class="GtkButton" id="button_settings">
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="receives-default">True</property>
<property name="image">image_settings</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">2</property>
</packing>
</child>
</object>
</child>
<child>
Expand Down Expand Up @@ -203,6 +221,21 @@
<property name="authors">Sergio Fernández Celorio</property>
<property name="logo-icon-name">image-missing</property>
<property name="license-type">gpl-3-0</property>
<child internal-child="vbox">
<object class="GtkBox">
<property name="can-focus">False</property>
<child internal-child="action_area">
<object class="GtkButtonBox">
<property name="can-focus">False</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">0</property>
</packing>
</child>
</object>
</child>
</object>
<object class="GtkPopover" id="popover_tools">
<property name="can-focus">False</property>
Expand Down
68 changes: 68 additions & 0 deletions resources/ui/settings_view.ui
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- Generated with glade 3.39.0 -->
<interface>
<requires lib="gtk+" version="3.22"/>
<template class="XanaSettingsView" parent="GtkBox">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="orientation">vertical</property>
<child>
<object class="GtkLabel">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="margin-top">15</property>
<property name="label" translatable="yes">UI settings</property>
<style>
<class name="settings-section-title"/>
</style>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkBox">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="valign">start</property>
<property name="margin-top">15</property>
<child>
<object class="GtkLabel">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="halign">end</property>
<property name="margin-end">10</property>
<property name="label" translatable="yes">Activate dark mode</property>
<style>
<class name="setting-title"/>
</style>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkSwitch" id="switch_dark_mode">
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="halign">start</property>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
</template>
</interface>
Binary file modified screenshots/xana.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added screenshots/xana2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions src/Application.vala
Original file line number Diff line number Diff line change
@@ -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;

Expand All @@ -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");
Expand Down
30 changes: 22 additions & 8 deletions src/ApplicationWindow.vala
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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 ();
Expand All @@ -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";
}
}

}
1 change: 1 addition & 0 deletions src/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,5 @@ sources = files (
'widgets/Notebook.vala',
'widgets/WebView.vala',
'widgets/AboutDialog.vala',
'widgets/SettingsView.vala'
)
9 changes: 7 additions & 2 deletions src/utils/QRUtils.vala
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
50 changes: 40 additions & 10 deletions src/widgets/Notebook.vala
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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) {
Expand Down
Loading

0 comments on commit ec36d3f

Please sign in to comment.