gjs

Getting list of contacts with Gnome-Shell JS interface

匆匆过客 提交于 2020-01-23 17:19:28
问题 I've just started fiddling with writing gnome-shell extensions, and would like to know how to get a list of contacts a user has. I've tracked down some likely files: gnome-shell/js/ui/contactDisplay.js and gnome-shell/src/shell_contact_system.c . Now I notice in shell_contact_system.c the following function: /** * shell_contact_system_get_all: * @self: A #ShellContactSystem * * Returns: (transfer none): All individuals */ GeeMap * shell_contact_system_get_all (ShellContactSystem *self) {

unpacking GVariant in javascript

我怕爱的太早我们不能终老 提交于 2020-01-06 08:16:17
问题 I have an array stored as a GVariant of type a(ss) in GSettings, that I want to use in a Cinnamon Applet. I can retrieve the value successfully using the following code: let schema = schema_source.lookup(SCHEMA_NAME, false); let settings = new Gio.Settings({ settings_schema: schema }); let my_value = settings.get_value('myvalue'); but I can't unpack it. As far as I can see, I will probably need to unpack it using a GVariantIter structure, but the documentation is limited, and I can't find the

Consume a webservice with basic authentication using Soup

好久不见. 提交于 2019-12-25 07:05:54
问题 As part of a gnome-shell extension, I try to consume a webservice using xmlrpc. The webservice expects a basic authentication header. Using Soup, I got the following code (basically a blueprint from the great openweather extension): function load_json_async() { if (_httpSession === undefined) { _httpSession = new Soup.Session(); } else { // abort previous requests. _httpSession.abort(); } let message = Soup.xmlrpc_message_new ( "https://api.sipgate.net/RPC2", "samurai.BalanceGet", new GLib

gjs How to read a socket stream in Gnome Shell Extension using g_data_input_stream_read_line_async

百般思念 提交于 2019-12-24 15:03:58
问题 I'm trying to write a Gnome-Shell extension that communicates with Arduino through a Socket Server. The Server and Arduino are running fine, but I'm stuck at the extension code that listens for incoming Server messages. Since I need a non blocking approach, using read_line_async seems perfect. However I can't manage to get it to work. Here's what i got so far (relevant part): let sockClient, sockConnection, output_reader, receivedline; // connect to socket sockClient = new Gio.SocketClient();

Can't change dconf-entry with GSettings

元气小坏坏 提交于 2019-12-23 13:27:18
问题 I'm currently building a simple application on Gjs, which should change the background-image of my gnome-shell. A solution on how this can be done using the gsettings -tool can be found here. Since I want to build a desktop-application around it, I want to change the org.gnome.desktop.background.picture-uri -key by using Gio's GSettings-class. But using the set_X() -method does not change the value of the key. This is my code to change the gsettings value: var gio = imports.gi.Gio; // Get the

Create a dynamic rescheduling GSource in JavaScript

会有一股神秘感。 提交于 2019-12-11 04:24:37
问题 GLib's main loop supports scheduling callback functions for periodic intervals, using g_timemout_source_new and related functions. The callback will repeatedly be called after the scheduled interval, until it returns false . I now want to modify this process with a dynamic interval. Instead of just true or false , the callback should be able to return a time value that should pass until its next invocation. Doing this in C is quite straightforward: A new GSource Type can be created, that only

Is it possible to import the Gvc typelib outside of the Gnome Shell environment?

允我心安 提交于 2019-12-11 00:45:18
问题 I'd like to use Gvc (libgnome-volume-control) as used in Gnome Shell GIR in GJS, but can't find a way to access it except within the Gnome Shell environment (eg. a Gnome Shell extension). Actually, I can't even figure out where it is. Is this possible? UPDATE In line with Philip Withnall's comment (about a hacky workaround), I have found it's possible to import like so: const GIRepository = imports.gi.GIRepository; GIRepository.Repository.prepend_search_path("/usr/lib/gnome-shell");

Including binary components in a GNOME Shell extension

早过忘川 提交于 2019-12-08 08:36:29
Developing extensions for the GNOME Shell mostly involves the use of C APIs through GObject Introspection. This means that most things achievable with C can be done in JavaScript, too. But there are some cases, where features of the C APIs cannot (yet) be reproduced through the introspection bindings. It would be useful to be able to bridge these gaps with native C code. Can a GNOME Shell extension include binary components created from C code? If so, how are they integrated? I'm having the very same question. Haven't found a good way to do so yet. Currently I'm trying 2 non ideal approaches

Including binary components in a GNOME Shell extension

≯℡__Kan透↙ 提交于 2019-12-08 03:33:25
问题 Developing extensions for the GNOME Shell mostly involves the use of C APIs through GObject Introspection. This means that most things achievable with C can be done in JavaScript, too. But there are some cases, where features of the C APIs cannot (yet) be reproduced through the introspection bindings. It would be useful to be able to bridge these gaps with native C code. Can a GNOME Shell extension include binary components created from C code? If so, how are they integrated? 回答1: I'm having

Anjuta configuration for GNOME Javascript application development

无人久伴 提交于 2019-12-08 01:36:58
问题 I trying to run a GNOME JavaScript application tutorial in Anjuta.: const GLib = imports.gi.GLib; const Gtk = imports.gi.Gtk; const Gda = imports.gi.Gda; const Lang = imports.lang; function Demo () { this._init (); } Demo.prototype = { _init: function () { this.setupWindow (); this.setupDatabase (); this.selectData (); }, setupWindow: function () { this.window = new Gtk.Window ({title: "Data Access Demo", height_request: 350}); this.window.connect ("delete-event", function () { Gtk.main_quit(