CGI Room.nu

Programming, Scripting and Graphics

Roxen Application Launcher 1.2.1

22 November, 2011 by Jakob

There’s a new release of Roxen Application Launcher (come again?) for Linux.

Although the previous release, using GTK3, came quite recently this release has some new things.

GSettings

I dumped the “keyfile” solution for the application settings in favour to GSettings. So the settings is no longer stored in a file in the application directory but rather in the system’s application settings backend. GSettings is part of GIO – the GNOME networking library – and since RAL depends on GIO no new dependency is needed. The upside is that I could put a file of source code in the bin! Plus, it’s fun learning new stuff!

Editors and content types

Previously I have kept an editor – name and command line – for every content type. Anders at Roxen thought it’d be better if editors and content types were separated. I’ve thought about that before but never bothered to do anything about it.

But now, along with GTK3, there’s a new (I think) AppInfo class and the new AppChooserButton and AppChooserDialog widgets so I thought it’d be cool to use those. So selecting an editor for a new content type is way more simple now, and it also looks nicer. Plus we get the icon for the editor in the content type list under the “Applications” tab ;)

Simple logging

I also implemented some simple logging which can be viewed under the new “Logging” tab. This will be worked upon and at the moment not very useful information is written to the log, but at least it’s a start.

Default icons

The icons in the notification popup – which only are three to the number – is now fetched from the user’s default icon theme. They we’re bundled before.

SOUP all the way

Previously I have used a little hack for saving downloaded files to disk. The problem was that the Vapi bindings for libsoup casted the data to a string which totally scrambled binary content like images and such. My solution was to write a simple C-function which took a SoupMessageBody struct as argument and then wrote that to diskt always keeping the uint8[] type of the content.

I bug reported this way back and it’s now fixed in Vala so I dumped my solution and am now using Vala all the way. Gone is one C and one Vapi file.

While at it I changed from using blocking functions in libsoup to the async ones. You never really noticed blocking calls was used before, but right is right. Right?

And that’s that for this time I think!

Roxen Application Launcher 1.2.1

Sources is available at the Roxen Application Launcher Github repository

Filed Under: Applications, Linux, Programming, Roxen Tagged With: gsettings, GTK3, Linux, RAL, Roxen, SOUP, Vala

GTK TreeViewColumn with icon and text

21 November, 2011 by Jakob

The other day I wanted to put both an icon and text in the same GTK+ TreeViewColumn, and I had absolutely no idea how to do that. So I Google’d and Google’d but had trouble finding any examples. I even downloaded the source code of the Gnome System Monitor – where exactly what I wanted exist – but that was mostly written in C++ which I know very little of.

But I’m stubborn, and after a while I found and example in Python which I managed to interpret. Even though I know very little Python it’s not that hard to follow, and the example was short.

In short what’s needed is packing two CellRenderers in the same TreeViewColumn. Quite logical when you know about it. The example below is in Vala:

15 lines of Vala
  1. var tree_view = new TreeView ();
  2. var col = new TreeViewColumn ();
  3. col.title = title;
  4. col.resizable = true;
  5. var crp = new CellRendererPixbuf ();
  6. col.pack_start (crp, false);
  7. col.add_attribute (crp, “pixbuf”, 0);
  8. var crt = new CellRendererText ();
  9. col.pack_start (crt, false);
  10. col.add_attribute (crt, “text”, 1);
  11. tree_view.insert_column (col, –1);

I hacked up a simple application that shows all installed programs – that has a .desktop entry I guess – in a list (the screenshot above). The sources is available at my Github repository.

Happy coding!

Filed Under: Linux, Programming Tagged With: CellRenderer, Gnome, GTK, GTK3, Linux, Python, TreeViewColumn, Vala

Variable length argument segfaults valac

26 October, 2010 by Jakob

Hm, found a bug in valac (the Vala compiler) today. If an abstract or virtual method contains a variable length argument (va_list) valac will segmentation fault.

19 lines of Vala
  1. // valac -o test sample.vala
  2. int main(string[] args)
  3. {
  4. return 0;
  5. }
  6. public abstract class Base : Object
  7. {
  8. public abstract int query(string query, ... );
  9. }
  10. public class Child : Base
  11. {
  12. public override int query(string query, ... )
  13. {
  14. return 1;
  15. }
  16. }

I’ve filed a bug about it so we’ll see what the problem is and if it can be fixed rapidly.

Filed Under: Programming Tagged With: Bug, Vala

Pike project – module stub creator

20 August, 2010 by Jakob

 

I recently began learning how to create Pike modules in C. The Pike module C API seems great and once you’ve sorted things out the modules are easy to build and install. Non the less, when creating a C module from scratch there’s a couple of files you need and some configurations of those before everything is set for go. And here comes “pike-project” into play.

Pike-project is a simple GTK program (works as command line tool also) written in Pike it self. The program will create the basics for a running Pike C module, or a plain installable Pike module. Then it’s just starting programming.

The program is available at my Github repository.

BTW! At the moment it only works on Linux I suppose.

Filed Under: Programming Tagged With: GTK, Pike

GTK hacking in Pike

19 January, 2010 by Jakob

Tweepi, the Twitter client written in PikeI’ve found out that it’s great fun programming desktop applications and of course it gets more fun the more you learn. Now I’m doing a Twitter client in Pike – my favorite programming language – mostly because I wanted to try out GTK programming in Pike. I use the good Twitter client Pino – written in Vala – and I have borrowed the concept and layout from it. I call it Tweepi.

The only major difference between Tweepi and Pino – besides they are written in different programming languages – is that Pino uses WebKit to draw the status messages where I am using good old GTK widgets – and I guess there are no bindings to WebKit in Pike for that matter ;)

One thing I noticed is that the Gtk.Label widget sucks at displaying longer texts that line wraps. Since the label widget handles some HTML formatting I thought that it would be suitable for displaying the status messages, but the text looked like shit, line wrapping where ever it felt like. And the Gtk.TextView widget doesn’t handle formatting per default so I Googled some and found that you can format text in Gtk.TextViews by inserting Gtk.TextTags at desired positions. And since Pike has the most awesome HTML parser It was just a matter of sending the text through the parser and create some Gtk.TextTags and inserting them at the same position in the text buffer. (Well, actually it wasn’t that easy but with some help from a Python class I found on the web it was doable).

So now I have a start at something that is a Gtk.HtmlTextView – actually it inherits Gtk.TextView but has an additional method insert_html_text(string text) – and albeit quite simple at the moment it’s worth continuing on. The code for the HtmlTextView is available at my Github repository.

In general I find the GTK implementation in Pike to be pretty OK, but there exist some verbose, and tedious, stuff like getting the text from a Gtk.TextView:

2 lines of Pike
  1. Gtk.TextBuffer b = my_textview–>get_buffer();
  2. string text = b–>get_text(b–>get_start_iter(), b–>get_end_iter(), 0);

which in Vala and C# would be done like:

5 lines of Vala
  1. // Vala
  2. string text = my_textview.get_buffer().text;
  3. // C#
  4. string text = myTextView.Buffer.Text;

Anyway! Tweepi isn’t done yet but I think I have solved the most tedious stuff and it’s starting to become useful. It’ll probably be done in a couple of weeks and I will of course release the sources then.

Filed Under: Applications, Linux, Programming Tagged With: Gnome, GTK, Pike

  • 1
  • 2
  • 3
  • …
  • 6
  • Next Page »

Categories

  • Action Script 3
  • Applications
  • Flash Animation
  • Linux
  • Misc
  • News
  • Programming
  • Roxen
  • Tutorials
  • User Science
  • Web Development
  • Xsl/Xslt
Copyright © 2021 CGI Room.nu