genie

The Button.connect syntax in Genie

孤者浪人 提交于 2019-12-06 15:36:35
I want to apply a certain behaviour to a label. When a lateral button is clicked, the corresponding label should rotate 90 degrees. It can be easily done in vala, but I can't discover the particular syntax on genie. The vala code I am trying to reproduce comes from elementary OS getting started guide : hello_button.clicked.connect(() => { hello_label.label = "Hello World!"; hello_button.sensitive = false; }); rotate_button.clicked.connect(() => { rotate_label.angle = 90; rotate_label.label = "Verbal"; rotate_button.sensitive = false; }); I actually managed to reproduce almost entirely the code

How to pack a button in a HeaderBar using Genie?

有些话、适合烂在心里 提交于 2019-12-02 10:14:28
问题 Background My aim is to improve a little text editor as an exercise. It is running fine after the HeaderBar was added, however I can't find a way to pack buttons in it. Code uses Granite.Widgets Gtk init Gtk.init (ref args) var app = new Application () app.show_all () Gtk.main () // This class holds all the elements from the GUI class Application : Gtk.Window _view:Gtk.TextView construct () // Prepare Gtk.Window: this.window_position = Gtk.WindowPosition.CENTER this.destroy.connect (Gtk.main

Listing the records on a SQL lite database with Genie

梦想与她 提交于 2019-12-02 07:57:26
问题 Now that I have created the SQL database (1, 2), I want to do something with it. I have started a small function to handle the printing of the dataset contents, however I am unable to figure out how to: adjust space between strings on a print command, in order to it become properly justified? One can do it in python using ljust(), but how to make something similar with Genie? iterate across all entries on the dataset? As far as I understand there is no equivalent of a cursor in Genie (maybe I

How to pack a button in a HeaderBar using Genie?

ぐ巨炮叔叔 提交于 2019-12-02 05:48:44
Background My aim is to improve a little text editor as an exercise. It is running fine after the HeaderBar was added, however I can't find a way to pack buttons in it. Code uses Granite.Widgets Gtk init Gtk.init (ref args) var app = new Application () app.show_all () Gtk.main () // This class holds all the elements from the GUI class Application : Gtk.Window _view:Gtk.TextView construct () // Prepare Gtk.Window: this.window_position = Gtk.WindowPosition.CENTER this.destroy.connect (Gtk.main_quit) this.set_default_size (400, 400) // Headerbar definition headerbar:Gtk.HeaderBar = new Gtk

Why this function return an (owned) value?

旧时模样 提交于 2019-12-01 22:50:06
问题 the code from: Genie howto repeat a string N times as an string arrayGenie howto repeat a string N times as an string array def repeatwithsep (e: string, n: int, separator: string): string var elen = e.length; var slen = separator.length; var a = new StringBuilder.sized ((elen * n) + (slen * (n - 1)) + 1); for var i = 0 to (n - 1) if i != 0 a.append_len (separator, slen) a.append_len (e, elen) return (owned) a.str var a is a local variable, when a goes out of scope, it will be destroyed. why

Why this function return an (owned) value?

≯℡__Kan透↙ 提交于 2019-12-01 20:53:19
the code from: Genie howto repeat a string N times as an string array Genie howto repeat a string N times as an string array def repeatwithsep (e: string, n: int, separator: string): string var elen = e.length; var slen = separator.length; var a = new StringBuilder.sized ((elen * n) + (slen * (n - 1)) + 1); for var i = 0 to (n - 1) if i != 0 a.append_len (separator, slen) a.append_len (e, elen) return (owned) a.str var a is a local variable, when a goes out of scope, it will be destroyed. why this function return (owned) a.str what is the difference between return a.str return (owned) a.str

Flatpak Meson Not Finding Vala Libraries From Gnome Builder

随声附和 提交于 2019-12-01 06:59:26
From Linux, I'm using Meson (0.44.0) within Gnome Builder (3.26.4) for a console program that will use Gee and GXml. My intent is to write this in Genie. When I use Meson within Gnome Builder it fails but the same succeeds when invoked from the command line using valac (0.38.8) as follows: valac --pkg=gtk+-3.0 --pkg=gee-0.8 --pkg=gxml-0.16 main.gs There is no error from the above. I've tried setting up meson.build with gee and gxml as dependency and alternatively as vala_args . Same error. Checking pkg-config, I get the following: $ pkg-config --libs gxml-0.16 -L/usr/local/lib64 -lgxml-0.16

Flatpak Meson Not Finding Vala Libraries From Gnome Builder

元气小坏坏 提交于 2019-12-01 05:24:04
问题 From Linux, I'm using Meson (0.44.0) within Gnome Builder (3.26.4) for a console program that will use Gee and GXml. My intent is to write this in Genie. When I use Meson within Gnome Builder it fails but the same succeeds when invoked from the command line using valac (0.38.8) as follows: valac --pkg=gtk+-3.0 --pkg=gee-0.8 --pkg=gxml-0.16 main.gs There is no error from the above. I've tried setting up meson.build with gee and gxml as dependency and alternatively as vala_args . Same error.

How do Valas closures map to Genie?

*爱你&永不变心* 提交于 2019-11-30 20:53:31
The Vala Tutorial has an example about DBus using anonymous methods . Bus.own_name (BusType.SESSION, "org.example.DemoService", /* name to register */ BusNameOwnerFlags.NONE, /* flags */ on_bus_aquired, /* callback function on registration succeeded */ () => {}, /* callback on name register succeeded */ () => stderr.printf ("Could not acquire name\n")); /* callback on name lost */ I am trying to rewrite this code in Genie, but could not manage to convert the two last lines. The Genie Tutorial only has an example on how to use a closure to define an event handler . f.my_event += def (t, a)

Avoiding global variables in Genie

柔情痞子 提交于 2019-11-29 17:28:26
Below is a working code of a ToolbarButton in Genie. The objective is to get the uri for the chosen file and return it back to the construct/init of the class. The problem is that in all examples I’ve come across global _variables are used (as shown in the code below). It looks unintuitive and I fear that whenever the code gets larger, it will become more difficult to remove bugs, since these variables will start to accumulate. Is any other way of making the function openfile return the uri to a regular variable within the construct/init of the class? Here is the code: uses Granite.Widgets Gtk