Skip to content

Commit

Permalink
Use libadwaita
Browse files Browse the repository at this point in the history
  • Loading branch information
sonnyp committed Nov 7, 2021
1 parent 3414db1 commit 4ac14bb
Show file tree
Hide file tree
Showing 8 changed files with 88 additions and 47 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ test:
./node_modules/.bin/eslint --cache .
flatpak run org.freedesktop.appstream-glib validate data/re.sonny.Junction.metainfo.xml
flatpak run --command="desktop-file-validate" --file-forwarding org.gnome.Sdk//41 --no-hints @@ data/re.sonny.Junction.desktop @@
gtk4-builder-tool validate src/*.ui
# gtk4-builder-tool validate src/*.ui
# gjs -m test/*.test.js
flatpak-builder --show-manifest re.sonny.Junction.json
find po/ -type f -name "*.po" -print0 | xargs -0 -n1 msgfmt -o /dev/null --check
Expand Down
37 changes: 36 additions & 1 deletion re.sonny.Junction.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,41 @@
"--filesystem=/var/lib/flatpak:ro"
],
"modules": [
{
"name": "libsass",
"buildsystem": "meson",
"sources": [
{
"type": "git",
"url": "https://github.com/lazka/libsass.git",
"commit": "302397c0c8ae2d7ab02f45ea461c2c3d768f248e"
}
]
},
{
"name": "sassc",
"buildsystem": "meson",
"sources": [
{
"type": "git",
"url": "https://github.com/lazka/sassc.git",
"commit": "82803377c33247265d779af034eceb5949e78354"
}
]
},
{
"name": "libadwaita",
"buildsystem": "meson",
"config-opts": ["-Dtests=false", "-Dexamples=false", "-Dvapi=false"],
"cleanup": ["/include", "/lib/pkgconfig"],
"sources": [
{
"type": "git",
"url": "https://gitlab.gnome.org/GNOME/libadwaita.git",
"tag": "1.0.0.alpha.3"
}
]
},
{
"name": "glib",
"buildsystem": "meson",
Expand All @@ -33,7 +68,7 @@
},
{
"type": "patch",
"path": "data-aux/flatpak/glib-desktopappinfo.patch"
"path": "build-aux/flatpak/glib-desktopappinfo.patch"
}
]
},
Expand Down
6 changes: 3 additions & 3 deletions src/application.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
import Gtk from "gi://Gtk";
import Gio from "gi://Gio";
import Adw from "gi://Adw";

import Window from "./window.js";
import Welcome from "./welcome.js";
import About from "./about.js";
import ShortcutsWindow from "./ShortcutsWindow.js";

export default function Application({ version }) {
const application = new Gtk.Application({
const application = new Adw.Application({
application_id: "re.sonny.Junction",
flags: Gio.ApplicationFlags.HANDLES_OPEN,
});

Gtk.Settings.get_default()["gtk-application-prefer-dark-theme"] = true;
Adw.StyleManager.get_default().set_color_scheme(Adw.ColorScheme.FORCE_DARK);

// FIXME: Cannot deal with mailto:, xmpp:, ... URIs
// GFile mess the URI if the scheme separator does not include "//" like about:blank or mailto:[email protected]
Expand Down
2 changes: 0 additions & 2 deletions src/main.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import Gtk from "gi://Gtk?version=4.0";
import Gio from "gi://Gio";
import GLib from "gi://GLib";
import { programInvocationName } from "system";
Expand All @@ -8,7 +7,6 @@ import Application from "./application.js";

GLib.set_prgname("re.sonny.Junction");
GLib.set_application_name("Junction");
Gtk.init();

export default function main(argv, { version, datadir }) {
bindtextdomain(
Expand Down
73 changes: 40 additions & 33 deletions src/welcome.ui
Original file line number Diff line number Diff line change
@@ -1,52 +1,59 @@
<?xml version="1.0" encoding="UTF-8" ?>
<interface>
<object class="GtkApplicationWindow" id="welcome">
<object class="AdwApplicationWindow" id="welcome">
<property name="title">Junction</property>
<property name="default-width">480</property>
<property name="default-height">480</property>
<child type="titlebar">
<object class="GtkHeaderBar">
<child type="end">
<object class="GtkMenuButton" id="button_menu">
<property name="menu-model">menu_app</property>
<property name="icon-name">open-menu-symbolic</property>
</object>
</child>
</object>
</child>
<child>
<property name="content">
<object class="GtkBox">
<property name="orientation">vertical</property>
<property name="valign">center</property>
<property name="halign">center</property>
<property name="spacing">14</property>
<child>
<object class="GtkImage">
<property name="icon-name">re.sonny.Junction</property>
<property name="pixel-size">128</property>
</object>
</child>
<child>
<object class="GtkLabel">
<property
name="label"
translatable="yes"
>Junction has been set as default application for Web</property>
<object class="AdwHeaderBar">
<child type="end">
<object class="GtkMenuButton" id="button_menu">
<property name="menu-model">menu_app</property>
<property name="icon-name">open-menu-symbolic</property>
</object>
</child>
</object>
</child>
<child>
<object class="GtkLinkButton" id="test_button">
<property
name="label"
translatable="yes"
>Click here to test</property>
<object class="GtkBox">
<property name="orientation">vertical</property>
<property name="valign">center</property>
<property name="halign">center</property>
<property name="uri">https://github.com/sonnyp/Junction</property>
<property name="vexpand">true</property>
<property name="hexpand">true</property>
<property name="spacing">14</property>
<child>
<object class="GtkImage">
<property name="icon-name">re.sonny.Junction</property>
<property name="pixel-size">128</property>
</object>
</child>
<child>
<object class="GtkLabel">
<property
name="label"
translatable="yes"
>Junction has been set as default application for Web</property>
</object>
</child>
<child>
<object class="GtkLinkButton" id="test_button">
<property
name="label"
translatable="yes"
>Click here to test</property>
<property name="valign">center</property>
<property name="halign">center</property>
<property name="uri">https://github.com/sonnyp/Junction</property>
</object>
</child>
</object>
</child>
</object>
</child>
</property>
<style>
<class name="welcome" />
</style>
Expand Down
2 changes: 1 addition & 1 deletion src/window.css
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
window.main {
.main {
border-radius: 18px;
background: none;
background-color: rgba(20, 20, 20, 0.95);
Expand Down
4 changes: 1 addition & 3 deletions src/window.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,12 @@ export default function Window({ application, file }) {
value = file.get_path();
try {
const info = file.query_info(
"standard::content-type,standard::display-name",
"standard::content-type",
Gio.FileQueryInfoFlags.NONE,
null,
);
content_type = info.get_content_type();
// display_name = info.get_display_name();
} catch (err) {
// display_name = file.get_basename();
logError(err);
}
}
Expand Down
9 changes: 6 additions & 3 deletions src/window.ui
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<?xml version="1.0" encoding="UTF-8" ?>
<interface>
<object class="GtkApplicationWindow" id="window">
<object class="AdwApplicationWindow" id="window">
<property name="resizable">False</property>
<property name="decorated">False</property>
<child>
<property name="content">
<object class="GtkBox">
<property name="orientation">vertical</property>
<child>
Expand Down Expand Up @@ -50,8 +50,11 @@
</child>
</object>
</child>
<style>
<class name="content" />
</style>
</object>
</child>
</property>
<style>
<class name="main" />
</style>
Expand Down

0 comments on commit 4ac14bb

Please sign in to comment.