Skip to content

Commit

Permalink
Add bookmarks
Browse files Browse the repository at this point in the history
  • Loading branch information
sonnyp committed Mar 1, 2022
1 parent 9261710 commit c1a40f1
Show file tree
Hide file tree
Showing 3 changed files with 125 additions and 7 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ Features:
- Syntax highlighting
- Opens `.js`, `.css` and `.ui` files
- Auto format
- Auto save and restore
- Console logs
- Dark mode switcher
- [More to come](https://github.com/sonnyp/Workbench/issues)

Workbench is a work in progress, [feedback and help welcome](https://github.com/sonnyp/Workbench/discussions/new).
Expand Down
15 changes: 15 additions & 0 deletions src/js/actions.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import Gtk from "gi://Gtk";
import Gio from "gi://Gio";
import GLib from "gi://GLib";
import Gdk from "gi://Gdk";

import About from "./about.js";
import ShortcutsWindow from "./ShortcutsWindow.js";
Expand Down Expand Up @@ -62,4 +64,17 @@ export default function Actions({ application, datadir, version }) {
file_chooser.show();
});
application.add_action(action_open_file);

const open_uri = new Gio.SimpleAction({
name: "open_uri",
parameter_type: new GLib.VariantType("s"),
});
open_uri.connect("activate", (self, target) => {
Gtk.show_uri(
application.get_active_window(),
target.unpack(),
Gdk.CURRENT_TIME
);
});
application.add_action(open_uri);
}
114 changes: 107 additions & 7 deletions src/window.ui
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,15 @@
</style>
</object>
</child>
<child type="start">
<object class="GtkMenuButton">
<property name="label" translatable="yes">Bookmarks</property>
<property name="menu_model">menu_bookmarks</property>
<style>
<class name="flat" />
</style>
</object>
</child>
<child type="title">
<object class="GtkBox">
<property name="spacing">6</property>
Expand Down Expand Up @@ -143,14 +152,18 @@
<object class="GtkMenuButton" id="button_menu">
<property name="menu-model">menu_app</property>
<property name="icon-name">open-menu-symbolic</property>
<property name="primary">true</property>
</object>
</child>
<child type="end">
<object class="GtkButton" id="button_style_mode">
<property
name="icon-name"
>weather-clear-night-symbolic</property>
<property name="label">Toggle dark mode</property>
<property
name="label"
translatable="yes"
>Toggle dark mode</property>
</object>
</child>
</object>
Expand All @@ -167,7 +180,10 @@
<object class="GtkBox">
<child>
<object class="GtkButton">
<property name="label">JavaScript</property>
<property
name="label"
translatable="yes"
>JavaScript</property>
<property name="sensitive">false</property>
<style>
<class name="flat" />
Expand Down Expand Up @@ -214,7 +230,7 @@
<object class="GtkBox">
<child>
<object class="GtkButton">
<property name="label">CSS</property>
<property name="label" translatable="yes">CSS</property>
<property name="sensitive">false</property>
<style>
<class name="flat" />
Expand Down Expand Up @@ -261,7 +277,7 @@
<object class="GtkBox">
<child>
<object class="GtkButton">
<property name="label">XML</property>
<property name="label" translatable="yes">XML</property>
<property name="sensitive">false</property>
<style>
<class name="flat" />
Expand Down Expand Up @@ -315,18 +331,18 @@
<object class="GtkActionBar">
<child type="start">
<object class="GtkToggleButton" id="button_devtools">
<property name="label">Console</property>
<property name="label" translatable="yes">Console</property>
<property name="active">true</property>
</object>
</child>
<child type="start">
<object class="GtkButton" id="button_inspector">
<property name="label">Inspector</property>
<property name="label" translatable="yes">Inspector</property>
</object>
</child>
<child type="end">
<object class="GtkButton" id="button_clear">
<property name="label">Clear</property>
<property name="label" translatable="yes">Clear</property>
<property name="action-name">win.clear</property>
<property name="tooltip-text">&lt;Primary&gt;K</property>
</object>
Expand Down Expand Up @@ -382,4 +398,88 @@
<pattern>*.css</pattern>
</patterns>
</object>
<menu id="menu_bookmarks">
<section>
<attribute name="label" translatable="yes">Learn</attribute>
<item>
<attribute
name="label"
translatable="yes"
>GNOME JavaScript (GJS)</attribute>
<attribute name="action">app.open_uri</attribute>
<attribute name="target">https://gjs.guide/</attribute>
</item>
<item>
<attribute
name="label"
translatable="yes"
>Human Interface Guidelines (HIG)</attribute>
<attribute name="action">app.open_uri</attribute>
<attribute name="target">https://developer.gnome.org/hig/</attribute>
</item>
<item>
<attribute name="label" translatable="yes">UI components</attribute>
<attribute name="action">app.open_uri</attribute>
<attribute
name="target"
>https://developer.gnome.org/documentation/tutorials/beginners/components.html</attribute>
</item>
<item>
<attribute
name="label"
translatable="yes"
>Platform components</attribute>
<attribute name="action">app.open_uri</attribute>
<attribute
name="target"
>https://developer.gnome.org/documentation/introduction/components.html</attribute>
</item>
</section>
<section>
<attribute name="label" translatable="yes">Reference</attribute>
<item>
<attribute name="label" translatable="yes">GJS</attribute>
<attribute name="action">app.open_uri</attribute>
<attribute name="target">https://gjs-docs.gnome.org/</attribute>
</item>
<item>
<attribute name="label" translatable="yes">Gtk</attribute>
<attribute name="action">app.open_uri</attribute>
<attribute name="target">https://docs.gtk.org/gtk4/</attribute>
</item>
<item>
<attribute name="label" translatable="yes">Adwaita</attribute>
<attribute name="action">app.open_uri</attribute>
<attribute
name="target"
>https://gnome.pages.gitlab.gnome.org/libadwaita/</attribute>
</item>
</section>
<section>
<attribute name="label" translatable="yes">Get help</attribute>
<item>
<attribute name="label" translatable="yes">Discourse</attribute>
<attribute name="action">app.open_uri</attribute>
<attribute
name="target"
>https://discourse.gnome.org/c/platform/5</attribute>
</item>
<item>
<attribute name="label" translatable="yes">Stack Overflow</attribute>
<attribute name="action">app.open_uri</attribute>
<attribute
name="target"
>https://stackoverflow.com/questions/tagged/gjs</attribute>
</item>
<item>
<attribute name="label" translatable="yes">Matrix</attribute>
<attribute name="action">app.open_uri</attribute>
<attribute name="icon-name">external-link-symbolic</attribute>
<attribute
name="target"
>hhttps://matrix.to/#/#javascript:gnome.org</attribute>
</item>

</section>
</menu>
</interface>

0 comments on commit c1a40f1

Please sign in to comment.