Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions src/Library/demos/Source View/main.blp
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
using Gtk 4.0;
using Adw 1;
using GtkSource 5;

Adw.StatusPage {
title: "Source View";
description: _("Widget that enables text-editing with advanced features like syntax highlighting");

Box {
orientation: vertical;
halign: center;

ScrolledWindow source_view {
height-request: 180;
width-request: 600;
has-frame: true;
}

LinkButton {
label: "API Reference";
uri: "https://gnome.pages.gitlab.gnome.org/gtksourceview/gtksourceview5/class.View.html";
}
}
}
25 changes: 25 additions & 0 deletions src/Library/demos/Source View/main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import GtkSource from "gi://GtkSource";

// Strictly speaking we don't _have_ to do this here since WorkBench does this for us.
// However, you _have_ to call this once during the startup in your application - e.g. in GApplication::startup
GtkSource.init();

// Get the language we want to use
const language_manager = GtkSource.LanguageManager.get_default();
const language = language_manager.get_language("js");

// Create the buffer - this holds the text that's used in the SourceView
const buffer = GtkSource.Buffer.new_with_language(language);
buffer.set_text('console.log("Hello World!");', -1);

// Create the SourceView which displays the buffer's display
const source_view = GtkSource.View.new({
auto_indent: true,
indent_width: 4,
buffer,
show_line_numbers: true,
});

// Add the SourceView to our ScrolledView so its displayed
const scrolled_window = workbench.builder.get_object("scrolled_window");
scrolled_window.set_child(source_view);
7 changes: 7 additions & 0 deletions src/Library/demos/Source View/main.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"name": "Source View",
"category": "controls",
"description": "Widget that enables text-editing with advanced features like syntax highlighting",
"panels": ["code", "preview"],
"autorun": true
}
23 changes: 23 additions & 0 deletions src/Library/demos/Source View/main.vala
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/usr/bin/env -S vala workbench.vala --pkg gtk4 --pkg libadwaita-1 --pkg gtksourceview-5

public void main () {
Gtk.init ();
GtkSource.init ();

// Get the language we want to use
var language_manager = GtkSource.LanguageManager.get_default();
var language = language_manager.get_language("js");
// Create the buffer - this holds the text that's used in the SourceView
var buffer = new GtkSource.Buffer.with_language(language);
buffer.set_text("console.log(\"Hello World!\");");

// Create the SourceView which displays the buffer's display
var source_view = new GtkSource.View.with_buffer(buffer);
source_view.auto_indent = true;
source_view.indent_width = 4;
source_view.show_line_numbers = true;

// Add the SourceView to our ScrolledView so its displayed
var scrolled_window = workbench.builder.get_object ("scrolled_window") as Gtk.ScrolledWindow;
scrolled_window.child = source_view;
}
1 change: 1 addition & 0 deletions src/about.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ ${getBlueprintVersion()}
"JCWasmx86 https://github.com/JCWasmx86",
"Alex (PaladinDev) https://github.com/SpikedPaladin",
"Diego Iván M.E https://github.com/Diego-Ivan",
"Rasmus Thomsen <oss@cogitri.dev>",
"Marvin W https://github.com/mar-v-in",
// Add yourself as
// "John Doe",
Expand Down