Re: [Vala] Application Menu
Nor Jaidi, Thank you very much for the response! I do have that attribute set as you suggested. Here is my gresources.xml file: https://github.com/steveno/balistica/blob/master/ui/menu.ui And here is where I create the menu using Vala (lines 69 and 117 - 125): https://github.com/steveno/balistica/blob/master/src/BalisticaApplication.vala Steven N. Oliver On Sun, Jan 21, 2018 at 9:17 PM, Nor Jaidi Tuahwrote: > >> var menu = builder.get_object ("appmenu") as MenuModel ; >> set_app_menu (menu) ; > > Have you set the scope as in > > "app.quit" > > Nice day > Nor Jaidi Tuah > > ps. Sorry for the previous empty message. Don't know > what went wrong. > > > > > PRIVILEGED/CONFIDENTIAL information may be contained in this message. If you > are neither the addressee (intended recipient) nor an authorised recipient of > the addressee, and have received this message in error, please destroy this > message (including attachments) and notify the sender immediately. STRICT > PROHIBITION: This message, whether in part or in whole, should not be > reviewed, retained, copied, reused, disclosed, distributed or used for any > purpose whatsoever. Such unauthorised use may be unlawful and may contain > material protected by the Official Secrets Act (Cap 153) of the Laws of > Brunei Darussalam. DISCLAIMER: We/This Department/The Government of Brunei > Darussalam, accept[s] no responsibility for loss or damage arising from the > use of this message in any manner whatsoever. Our messages are checked for > viruses but we do not accept liability for any viruses which may be > transmitted in or with this message. > ___ > vala-list mailing list > vala-list@gnome.org > https://mail.gnome.org/mailman/listinfo/vala-list ___ vala-list mailing list vala-list@gnome.org https://mail.gnome.org/mailman/listinfo/vala-list
Re: [Vala] compiler warning for Variant.strv()
> On Thursday, 25 January 2018, 10:32:07 GMT, Yasushi SHOJIwrote: > void main () { > Variant ary = new Variant.strv({"foo", "bar", "baz"}); > } > In file included from /usr/include/glib-2.0/glib/gmessages.h:35:0, > from /usr/include/glib-2.0/glib.h:62, > from /tmp/a.vala.c:5: > /usr/include/glib-2.0/glib/gvariant.h:118:33: note: expected ‘const > gchar * const* {aka const char * const*}’ but argument is of type > ‘gchar ** {aka char **}’ > GVariant * g_variant_new_strv > (const gchar * const *strv, You can use Vala's implicit conversion module to create a string array.I've figured out how to do this for string arrays, not just basic types. Itdoesn't produce the C warnings when compiling: void main () { string[] my_array = {"foo", "bar", "baz"}; test (my_array); Variant my_variant = my_array; test (my_variant); } void test (Variant variant) { print (@"$(variant.get_type_string ())\n"); print (@"$(variant.print (true))\n"); } The implicit conversion is invoked when assigning the array to a variable of type Variant. It is also invoked when passing the string array as an argumentto a function that expects a Variant type parameter. This also works for GLib HashTable, which is a dictionary over D-Bus. This should be very useful for using DBusConnection. Code snippet: var a = new HashTable of string, Variant ( str_hash, str_equal ); a.insert( "first", 1 ); a.insert( "second", "test" ); b:Variant = a; A couple of references for anyone interested:https://wiki.gnome.org/Projects/Vala/DBusServerSample#Type_Table https://valadoc.org/gio-2.0/GLib.DBusConnection.html All the best, Al ___ vala-list mailing list vala-list@gnome.org https://mail.gnome.org/mailman/listinfo/vala-list
Re: [Vala] Need help to scroll a textview using a scale
void scale_moved (Gtk.Range range) { int i; Gtk.TextIter iter = new Gtk. TextIter(); view.get_iter_at_position(out iter, out i, 0, 0); iter.set_line(iter.get_line() + 10); view.scroll_to_iter(iter, 0, false, 0, 0); } GtkTextView implements GtkScrollable, which means you can get a GtkAdjustment for the vertical range. Something like: range.adjustment = text_view.vadjustment; Hi Christian, Tx for replying. I got it to work by initializing the iterator from the buffer, not the view: view.buffer.get_iter_at_line(). I do not know why it does not work the other round too -- I hope to learn someday : - ) It is all working nicely now. Vala and valadoc sites have excellent documentation - which is a boon for newbies like me. For the first time, I am beginning to enjoy putting up GUI's -- this used to be such a pain earlier. Regards Manish Jain ___ vala-list mailing list vala-list@gnome.org https://mail.gnome.org/mailman/listinfo/vala-list
Re: [Vala] Need help to scroll a textview using a scale
On 01/24/2018 10:03 AM, Manish Jain wrote: My last effort at the event handler is below (it is of no use, really): void scale_moved (Gtk.Range range) { int i; Gtk.TextIter iter = new Gtk. TextIter(); view.get_iter_at_position(out iter, out i, 0, 0); iter.set_line(iter.get_line() + 10); view.scroll_to_iter(iter, 0, false, 0, 0); } GtkTextView implements GtkScrollable, which means you can get a GtkAdjustment for the vertical range. Something like: range.adjustment = text_view.vadjustment; You can also just add the textview to a GtkScrolledWindow. -- Christian ___ vala-list mailing list vala-list@gnome.org https://mail.gnome.org/mailman/listinfo/vala-list
[Vala] Need help to scroll a textview using a scale
Hi, I am new to vala and am trying to pick up the fundamentals. I was trying to create a a GTK application with 3 components: Gtk.ScrolledWindow scrolled; Gtk.TextView view; Gtk.Scale v_scale; The scrolled view widget is to display a text file read at run time. I would like to the view's current contents to be controlled by the v_scale: when v_scale slider is 0, the view shows the beginning of the file, and when v_scale slider is close to 100, the view shows the last few characters/lines in the file. Despite a lot of effort to write an event handler, I still cannot get the scale to tell the view to scroll. Can somebody please tell me how to control the view's position with the scale in Vala ? My last effort at the event handler is below (it is of no use, really): void scale_moved (Gtk.Range range) { int i; Gtk.TextIter iter = new Gtk. TextIter(); view.get_iter_at_position(out iter, out i, 0, 0); iter.set_line(iter.get_line() + 10); view.scroll_to_iter(iter, 0, false, 0, 0); } -- Thanks & Regards, Manish Jain ___ vala-list mailing list vala-list@gnome.org https://mail.gnome.org/mailman/listinfo/vala-list
Re: [Vala] Package `Gee-0.8' not found
> On Thursday, 25 January 2018, 16:41:31 GMT, Ralf Ganswindtwrote: > I'm experimenting with Vala and so far I like how it works. However, I > tried to compile a basic gee example from the sample programs and I get the > following: > $ valac --pkg Gee-0.8 list.vala > error: Package `Gee-0.8' not found in specified Vala API directories or It should be --pkg gee-0.8 It is case sensitive! You also need the development files installed. For Ubuntu that would be something likeapt install libgee-dev > GIR files: You want to avoid GIR files to start with. They are GObject Introspection Repository (GIR)files that contain enough information about a C library's interface to generate bindings forvarious languages, including Vala. The Vala tool vapigen can then be used to generate aVala Application Programming Interface (VAPI) file from the GIR. valac can do this automaticallyif a VAPI is not found. By using the capitalized version, --pkg Gee-0.8, valac tried to generate the VAPI for you by searching for the relevant GIR. It looks like that wasn't found either, probably because youdon't have the development files installed. If you look at the files in the dev package youshould see the difference in filenames. When starting out you want to focus on using VAPI files for interfacing with libraries. All the best, Al ___ vala-list mailing list vala-list@gnome.org https://mail.gnome.org/mailman/listinfo/vala-list
[Vala] Package `Gee-0.8' not found
I'm experimenting with Vala and so far I like how it works. However, I tried to compile a basic gee example from the sample programs and I get the following: $ valac --pkg Gee-0.8 list.vala error: Package `Gee-0.8' not found in specified Vala API directories or GObject-Introspection GIR directories Compilation failed: 1 error(s), 0 warning(s) A search of /usr/... reveals no gir or vapi files for Gee-0.8, only gir1.2-gee-0.8 and libgee-0.8 related files and binaries. I have attempted to manually install the files using the synaptic package manager and it didn't throw any exceptions. $ apt show -a gir1.2-gee-0.8 Package: gir1.2-gee-0.8 Version: 0.20.0-0ubuntu1~16.04~valateam0 Priority: optional Section: introspection Source: libgee-0.8 Maintainer: Ubuntu DevelopersOriginal-Maintainer: Maintainers of Vala packages < pkg-vala-maintain...@lists.alioth.debian.org> Installed-Size: 99.3 kB Depends: gir1.2-glib-2.0, libgirepository-1.0-1 (>= 1.41.4-1) Download-Size: 21.8 kB APT-Manual-Installed: yes APT-Sources: http://ppa.launchpad.net/vala-team/ppa/ubuntu xenial/main amd64 Packages Description: GObject based collection and utility library (GObject-Introspection) This package contains introspection data for libgee, which can be used to generate dynamic bindings. . libgee is a collection and utility library providing GObject-based interfaces and classes for commonly used data structures. Package: gir1.2-gee-0.8 Version: 0.18.0-1 Priority: optional Section: introspection Source: libgee-0.8 Origin: Ubuntu Maintainer: Ubuntu Developers Original-Maintainer: Maintainers of Vala packages < pkg-vala-maintain...@lists.alioth.debian.org> Bugs: https://bugs.launchpad.net/ubuntu/+filebug Installed-Size: 137 kB Depends: gir1.2-glib-2.0, libgirepository-1.0-1 (>= 1.41.4-1) Homepage: https://wiki.gnome.org/Projects/Libgee Task: ubuntu-touch-core, ubuntu-touch, ubuntu-sdk Supported: 9m Download-Size: 22.5 kB APT-Sources: http://us.archive.ubuntu.com/ubuntu xenial/main amd64 Packages Description: GObject based collection and utility library (GObject-Introspection) This package contains introspection data for libgee, which can be used to generate dynamic bindings. . libgee is a collection and utility library providing GObject-based interfaces and classes for commonly used data structures. GIR files: $ ls -R /usr/share/gir* /usr/share/gir-1.0: Atk-1.0.gir Gdk-3.0.gir GModule-2.0.gir PangoCairo-1.0.gir Atspi-2.0.gir GdkPixbuf-2.0.gir GObject-2.0.gir PangoFT2-1.0.gir cairo-1.0.gir GdkX11-2.0.girGtk-2.0.gir PangoXft-1.0.gir DBus-1.0.girGdkX11-3.0.girGtk-3.0.girwin32-1.0.gir DBusGLib-1.0.girGio-2.0.gir GtkSource-3.0.gir xfixes-4.0.gir fontconfig-2.0.gir GIRepository-2.0.gir HarfBuzz-0.0.gir xft-2.0.gir freetype2-2.0.gir GL-1.0.girlibxml2-2.0.girxlib-2.0.gir Gdk-2.0.gir GLib-2.0.gir Pango-1.0.gir xrandr-1.3.gir What am I missing? Before I try to back engineer myself into a disaster. Thanks, Ralf Ganswindt ralfganswi...@gmail.com ___ vala-list mailing list vala-list@gnome.org https://mail.gnome.org/mailman/listinfo/vala-list
Re: [Vala] Confusing issue with static struct method: too many arguments to function
Hello, On Mon, 22 Jan 2018, 23:00 Michael Murphy,wrote: > I have the following which is automatically generated by bindgen. > > ```c > DistinstSector distinst_sector_megabyte(uint64_t value); > ``` > If the struct is returned (and passed as a parameter) like this in C, it should be a simple type in vala. The annotation is [SimpleType] HTH, Abderrahim ___ vala-list mailing list vala-list@gnome.org https://mail.gnome.org/mailman/listinfo/vala-list
Re: [Vala] compiler warning for Variant.strv()
> On Thursday, 25 January 2018, 10:32:07 GMT, Yasushi SHOJIwrote: > void main () { > Variant ary = new Variant.strv({"foo", "bar", "baz"}); > } > /usr/include/glib-2.0/glib/gvariant.h:118:33: note: expected ‘const > gchar * const* {aka const char * const*}’ but argument is of type > ‘gchar ** {aka char **}’ > GVariant * g_variant_new_strv > (const gchar * const *strv, > ^~ Vala does have implicit conversion for Variant types, e.g.: Variant a = "a string";Variant b = 10; I've not figure out how well this works with collections, but there is this patch:https://mail.gnome.org/archives/commits-list/2010-October/msg08428.html I've tried: Variant test = {"foo", "bar", "bax"};but get "error: initializer list used for `GLib.Variant?', which is neither array nor struct" I also tried explicit casting:string[] test = {"foo", "bar", "baz"}; Variant result = (Variant) test; This compiles without C warnings, but I get a runtime critical from GLib:GLib-CRITICAL **: g_variant_ref: assertion 'value->ref_count > 0' failed So it looks like some development is needed in that area, if someone wants to take up the challenge! Al ___ vala-list mailing list vala-list@gnome.org https://mail.gnome.org/mailman/listinfo/vala-list
Re: [Vala] Newbie help requested for scrolling a TextView
On 01/25/18 16:11, Al Thomas wrote: > On Thursday, 25 January 2018, 01:00:05 GMT, Manish Jainwrote: > Despite a lot of effort to write an event handler, I still cannot get > the scale to tell the view to scroll. I have tried scrolling with the > scroll_to_iter() method, but the iterator always lands me at the top of > the file, whereas I want the view to move south. Have you tried moving the TextIter with something like: https://valadoc.org/gtk+-3.0/Gtk.TextIter.set_line.html It sounds like you want a TextIter instance for your vscale widget that you can then move about the document and then scroll to it. It may be your almost there, just missing the last piece of the puzzle! Regards, Al Hi Al/others, The scrolling is beginning to happen, but not in the way I would expect. Here is my event handler for the scale (which I am using a normal command widget) : void scale_moved (Gtk.Range range) { TextIter iter = TextIter(); view.get_iter_at_location(out iter, 0, ypos); view.scroll_to_iter(iter, 0, false, 0, 0); view.place_cursor_onscreen(); ypos++; } The ypos counter is initialized as 0, and then gets incremented each time the scale is used. Effectively, each time the uses clicks the scale, the view should move south one line. That is the behaviour I would expect. But the scrolling is almost negligible unless I jack up ypos argument to get_iter_at_location() as 25*ypos - at which point the view moves south sometimes one line or sometimes two lines. I must be missing something: is the view scrolling somehow dependent on window geometry and/or line lengths ? I would normally think the ypos argument is just the number of newlines (minus one) to be skipped when readjusting the view. Thanks for any help. Manish Jain ___ vala-list mailing list vala-list@gnome.org https://mail.gnome.org/mailman/listinfo/vala-list
Re: [Vala] Newbie help requested for scrolling a TextView
> On Thursday, 25 January 2018, 11:37:49 GMT, Manish Jainwrote: > I was filling up the view> with text += . And I think Vala> removes the trailing newline, so essentially my buffer always had> just one line! By using += with the text property of the buffer you are re-writing the wholebuffer on each change. You should probably be looking at one of the insertfunctions of Gtk.TextBuffer. I doubt Vala is removing trailing newlines unless you are telling your program to, even if unintentionally! Your Vala program is using library functions so lookcarefully at these library functions' documentation and what they are returning. > At runtime, both textview and scale occupy 50% of the grid's> real-estate. > Can I tell the grid to give 75% coverage to the view> and 25% to the scale, > or is there some way I can size the widgets> myself from within my code? You would want a 4 column grid and to make the width of the view3 and the width of the scale 1. A nice example (Python):http://python-gtk-3-tutorial.readthedocs.io/en/latest/layout.html#id1 Regards, Al ___ vala-list mailing list vala-list@gnome.org https://mail.gnome.org/mailman/listinfo/vala-list
Re: [Vala] Newbie help requested for scrolling a TextView
Hi Al, Tx for replying. As part of my teething struggles, I discovered what I think was essentially wrong. I was filling up the view with text += . And I think Vala removes the trailing newline, so essentially my buffer always had just one line! Let me see if I can get my code to work now. There is another woe that afflicts me. I am adding both widgets (TextView - embedded in ScrolledWindow - and a vertical scale at RHS) to a grid. At runtime, both textview and scale occupy 50% of the grid's real-estate. Can I tell the grid to give 75% coverage to the view and 25% to the scale, or is there some way I can size the widgets myself from within my code? Thanks again. Manish Jain On 01/25/18 16:11, Al Thomas wrote: > On Thursday, 25 January 2018, 01:00:05 GMT, Manish Jainwrote: > Despite a lot of effort to write an event handler, I still cannot get > the scale to tell the view to scroll. I have tried scrolling with the > scroll_to_iter() method, but the iterator always lands me at the top of > the file, whereas I want the view to move south. Have you tried moving the TextIter with something like: https://valadoc.org/gtk+-3.0/Gtk.TextIter.set_line.html It sounds like you want a TextIter instance for your vscale widget that you can then move about the document and then scroll to it. It may be your almost there, just missing the last piece of the puzzle! Regards, Al ___ vala-list mailing list vala-list@gnome.org https://mail.gnome.org/mailman/listinfo/vala-list
Re: [Vala] compiler warning for Variant.strv()
> On Thursday, 25 January 2018, 11:19:44 GMT, Abderrahim Kitouni >wrote: > You can try to use the latest development version of Vala. Most of those > warnings should go away. Unfortunately that isn't fixed in this case. The g_variant_new_strv has a C type signature for the array of strings as:const gchar * const *strv See https://developer.gnome.org/glib/stable/glib-GVariant.html#g-variant-new-strv and Vala is generating the type as gchar**. Still two levels of indirection, but not similarenough for the compiler. I'm not aware of a way of explicitly setting the C type of an array in a Vala binding. The "Legacy Bindings" document references array lengthsa lot, but not the type of array: https://wiki.gnome.org/Projects/Vala/LegacyBindings On Thu, 25 Jan 2018, 11:32 Yasushi SHOJI, wrote: > Is there anyway to fix this except "-Wno-incompatible-pointer-types"? > > > $ cat a.vala > using Gee; > > void main () { > Variant ary = new Variant.strv({"foo", "bar", "baz"}); > } > > > $ valac --pkg gee-0.8 a.vala --no-color > a.vala:4.11-4.55: warning: local variable `ary' declared but never used > Variant ary = new Variant.strv({"foo", "bar", "baz"}); > ^ > /tmp/a.vala.c: In function ‘_vala_main’: > /tmp/a.vala.c:38:31: warning: passing argument 1 of > ‘g_variant_new_strv’ from incompatible pointer type > [-Wincompatible-pointer-types] > _tmp5_ = g_variant_new_strv (_tmp4_, 3); > ^~ > In file included from /usr/include/glib-2.0/glib/gmessages.h:35:0, > from /usr/include/glib-2.0/glib.h:62, > from /tmp/a.vala.c:5: > /usr/include/glib-2.0/glib/gvariant.h:118:33: note: expected ‘const > gchar * const* {aka const char * const*}’ but argument is of type > ‘gchar ** {aka char **}’ > GVariant * g_variant_new_strv > (const gchar * const *strv, > ^~ > Compilation succeeded - 1 warning(s) > -- ___ vala-list mailing list vala-list@gnome.org https://mail.gnome.org/mailman/listinfo/vala-list
Re: [Vala] compiler warning for Variant.strv()
Hello, You can try to use the latest development version of Vala. Most of those warnings should go away. https://blogs.gnome.org/despinosa/2018/01/09/vala-warnings-output-improvements/ HTH, Abderrahim On Thu, 25 Jan 2018, 11:32 Yasushi SHOJI,wrote: > Hi, > > I have a code snippet which gets incompatible pointer type warning > from gcc. > > Is there anyway to fix this except "-Wno-incompatible-pointer-types"? > > > $ cat a.vala > using Gee; > > void main () { > Variant ary = new Variant.strv({"foo", "bar", "baz"}); > } > > > $ valac --pkg gee-0.8 a.vala --no-color > a.vala:4.11-4.55: warning: local variable `ary' declared but never used > Variant ary = new Variant.strv({"foo", "bar", "baz"}); > ^ > /tmp/a.vala.c: In function ‘_vala_main’: > /tmp/a.vala.c:38:31: warning: passing argument 1 of > ‘g_variant_new_strv’ from incompatible pointer type > [-Wincompatible-pointer-types] > _tmp5_ = g_variant_new_strv (_tmp4_, 3); >^~ > In file included from /usr/include/glib-2.0/glib/gmessages.h:35:0, > from /usr/include/glib-2.0/glib.h:62, > from /tmp/a.vala.c:5: > /usr/include/glib-2.0/glib/gvariant.h:118:33: note: expected ‘const > gchar * const* {aka const char * const*}’ but argument is of type > ‘gchar ** {aka char **}’ > GVariant * g_variant_new_strv > (const gchar * const *strv, > ^~ > Compilation succeeded - 1 warning(s) > -- > yashi > ___ > vala-list mailing list > vala-list@gnome.org > https://mail.gnome.org/mailman/listinfo/vala-list > ___ vala-list mailing list vala-list@gnome.org https://mail.gnome.org/mailman/listinfo/vala-list
Re: [Vala] Newbie help requested for scrolling a TextView
> On Thursday, 25 January 2018, 01:00:05 GMT, Manish Jainwrote: > Despite a lot of effort to write an event handler, I still cannot get > the > scale to tell the view to scroll. I have tried scrolling with the > scroll_to_iter() method, but the iterator always lands me at the top of > the file, whereas I want the view to move south. Have you tried moving the TextIter with something like:https://valadoc.org/gtk+-3.0/Gtk.TextIter.set_line.html It sounds like you want a TextIter instance for your vscale widget that you can then moveabout the document and then scroll to it. It may be your almost there, just missing the last piece of the puzzle! Regards, Al ___ vala-list mailing list vala-list@gnome.org https://mail.gnome.org/mailman/listinfo/vala-list
[Vala] compiler warning for Variant.strv()
Hi, I have a code snippet which gets incompatible pointer type warning from gcc. Is there anyway to fix this except "-Wno-incompatible-pointer-types"? $ cat a.vala using Gee; void main () { Variant ary = new Variant.strv({"foo", "bar", "baz"}); } $ valac --pkg gee-0.8 a.vala --no-color a.vala:4.11-4.55: warning: local variable `ary' declared but never used Variant ary = new Variant.strv({"foo", "bar", "baz"}); ^ /tmp/a.vala.c: In function ‘_vala_main’: /tmp/a.vala.c:38:31: warning: passing argument 1 of ‘g_variant_new_strv’ from incompatible pointer type [-Wincompatible-pointer-types] _tmp5_ = g_variant_new_strv (_tmp4_, 3); ^~ In file included from /usr/include/glib-2.0/glib/gmessages.h:35:0, from /usr/include/glib-2.0/glib.h:62, from /tmp/a.vala.c:5: /usr/include/glib-2.0/glib/gvariant.h:118:33: note: expected ‘const gchar * const* {aka const char * const*}’ but argument is of type ‘gchar ** {aka char **}’ GVariant * g_variant_new_strv (const gchar * const *strv, ^~ Compilation succeeded - 1 warning(s) -- yashi ___ vala-list mailing list vala-list@gnome.org https://mail.gnome.org/mailman/listinfo/vala-list