How to fix a keyboard indicator (in GNOME 3.8)

Recently and occasionally I have discovered a tiny issue, which I was forced to observe, every time I was looking at my desktop. This has happen after I have decided to add a keyboard layout for russian language, which was based on german phonetics. So this is what I ended with:

Quickly I have got slightly frustrated, because I started to mix up things a little bit, so I started to look at gnome’s source code, especially searching for a xml database in gnome-control-center and gnome-desktop, and gave up it this idea, as I was not able to find anything particular useful and started to ask around in the IRC channels. Lucky, as people sometimes say that any initiative can be hardly punished, I have got a response from Rui Matos, one of the GNOME developers working on gnome-desktop. He pointed me out to the right direction:

rtcm, I mean, how this names “de1″ and “de2″ or “ru” are generated, where can I find the corresponding code?
ibqn: the code is in the gnome-desktop module, but it’s just simply getting what’s defined in xkeyboard-config’s data, see http://cgit.freedesktop.org/xkeyboard-config/tree/rules/base.xml.in#n3223
rtcm, so why is it called “de2″ and not “ru” instead? looks like a bug
ibqn: those labels are the elements, if you believe that specific layout should have ‘ru’ as its short description, file a bug (preferably with a patch) in freedesktop’s bugzilla
rtcm, thank you for making it clear to me.
ibqn: no prob, I hope I helped :-)

The following procedure was almost straightforward, I simply cloned their git repository, modified the corresponding file, I believe should be right, committed it locally and finally created a trivial one liner patch:

From 2cbb166e05eae603a2e640eeb3558942a89ecd7e Mon Sep 17 00:00:00 2001
From: Evgeny Bobkin <evgen.ibqn@gmail.com>
Date: Thu, 16 May 2013 14:15:26 +0200
Subject: [PATCH] Fix keyboard indicator for russian (germany, phonetic)

---
 rules/base.xml.in | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/rules/base.xml.in b/rules/base.xml.in
index 5996738..2735723 100644
--- a/rules/base.xml.in
+++ b/rules/base.xml.in
@@ -3223,6 +3223,8 @@
         <variant>
           <configItem>
             <name>ru</name>
+            <!-- Keyboard indicator for Russian layouts -->
+            <_shortDescription>ru</_shortDescription>
             <_description>Russian (Germany, phonetic)</_description>
             <languageList>
               <iso639Id>rus</iso639Id>
-- 
1.8.1.5

As a gentoo user I also have the ability to test every particular package and change its source code without risking or being afraid of irreparably breaking my system, because, due to this modifications, all broken libraries can be easily tracked down and fixed by recreating their reverse dependencies (with revdep-rebuild for example). Therefore I have copied the xkeyboard-config ebuild to my local overlay and included the created patch to it, so I was able to test it and thus fixed the issue. Afterwards, I have filed a bug report and shortly this patch was included upstream. One more success story.

So, what can you do if you have no ability to apply the patch or use the latest version, or even if you want to fix the similar issue locally on your computer? There is also an easy way: you should try to modify the base.xml file accordingly, probably located here:

$ vim /usr/share/X11/xkb/rules/base.xml

And in the case of a new issue, please also open a bug report (with an attached patch to it), so that other people can also profit from your work done.
Enjoy!!!

PS: By the way my stand alone research was not that vain as I have described above, I finally found after years of looking for it, the source code of the Cyrillic (Transliterated) input method plugin, you observe every time when you right-click the mouse pointing on the text field (or entry box), followed by selecting the bottom menu item “Input Methods”

Emacs: How to use white spaces instead of tabs when writing C or Vala code

Many projects have their own policy regarding the code style, so it can happen to you that while working on one of them it is required to use white spaces as indentation instead of commonly used tabs. To activate this feature within the emacs editor only when working with C or Vala source code you can place this in your ~/.emacs file:

(add-hook 'c-mode-hook (lambda () (setq indent-tabs-mode nil)))
(add-hook 'vala-mode-hook (lambda () (setq indent-tabs-mode nil)))

A small note: If it should be applicable for a specific project one can combine the above feature with Directory Variables.

Additional references: spaces instead of tabs

GNOME 3.8 is underway

During the sources of the one of the most beautiful graphical desktop environments are landing on the official gnome server, I would like to forward the message to everyone that GNOME 3.8 is going to be released officially in the coming weeks.gnome 3.6 desktop It will have for sure a lot of new and great features, which increase the pleasure of computer usage. One the features I have discovered already is the integrated MTP support (via libmtp) in gvfs. It allows you in nautilus an out of the box connection, transfer and managing of you files with new Android devices, like tabs and smartphones, respectively. Enjoy!!!

Вышла новая версия файлового менаджера Thunar 1.6.1

Совсем недавно, пару дней назад вышла в свет новая версия осень быстрого и использующего мало системных ресурсов файлового менеджера thunar версии 1.6.1. Одна из основных добавленных функций в новой версии это возможность использования вкладок, что иллюстрированно на картинке. thunar входит с состав программ быстрой и современной графической поверхности Xfce. Так что если у вас есть старый компьютер пятилетней давности, то у вас появляется уникальная возможность установить на него совершенно бесплатную операционную систему xubuntu, разрабатывающуюся многими тысячами программистов по всему земному шару и конечно при поддержки обширного ряда крупных компаний. Так что не удивляйтесь, если ваш старый компьютер с установленным xubuntu будет работать быстрее, только что купленного ноутбука с Windows 8!!! Добро пожаловать в мир неисчерпанных возможностей))

Turorial for OpenGL and Gtk3+ combined, written in Vala

This post is still work in progress!
The main target of this code sample, even if it’s trivial one, is to run a openGL based application on top of the modern window library Gtk+3 on Gnu/Linux. It must be possible to run this openGL code combined with Gtk+ on windows, but I personally do not know how to do it, as I rarely use windows myself. Well, actually, I use it only to set up it for my girlfriend or to solve the endless number of issues my girlfriend has ran into. If you, by the way, know howto extend this simple example, written in vala, so it can be launched on windows, please share it with me.)) The reason for this incompatibility is that here the X11 related functions calls are used to establish the incorporation between Gtk3, Gdk and OpenGL on the other side.

This sample code for simplicity reasons covers only the openGL 1 API. The example with vertex and fragment shaders, respectively, will be considered in the succeeding posts.
Here, therefore we first create a new custom window by inheriting the Gtk window class functionality and add a drawing area to it. The drawing area afterwards will be responsible for the GL context. Below you can find a class template, which includes the step by step recipe, needed yet to be implemented.

/* here the opengl and X related libraries are included */
using GLX;
using GL;

class GLXSample : Gtk.Window {
    public GLXSample( ) {
        /* 1. adding custom setting for the newly created window */

        /* 2. preparing and intializing the opengl context */

        /* 3. creating the drawing area and adding it to the window */
        var drawing_area = new Gtk.DrawingArea( );
        /* adjusting the drawing area parameters */

        /* adding two events listeners: */
        /* the first handles the opengl content on window resize events */
        /* followed by the event which is responsible for the drawing */
        drawing_area.configure_event.connect( on_configure_event );
        drawing_area.draw.connect( on_draw );

        this.add( drawing_area );
    }

    private bool on_configure_event( Gtk.Widget widget, Gdk.EventConfigure event ) {
        /* adapting the opengl content on window size change */
        return true;
    }

    private bool on_draw( Gtk.Widget widget, Cairo.Context cr ) {
        /* drawing the opengl content here */
        return true;
    }
}

void main( string[] args ) {
    Gtk.init( ref args );

    var sample = new GLXSample( );
    sample.show_all( );

    Gtk.main( );
}

So, after implementing all the introduced steps will result in the following working code sample:

using GLX;
using GL;

class GLXSample : Gtk.Window {

    private unowned X.Display xdisplay;
    private GLX.Context context;
    private GLX.XVisualInfo xvinfo;

    public GLXSample( ) {
        this.title = "OpenGL with GLX";
        this.set_reallocate_redraws( true );
        this.destroy.connect( Gtk.main_quit );

        int[] attrlist = {
            GLX_RGBA,
            GLX_RED_SIZE, 1,
            GLX_GREEN_SIZE, 1,
            GLX_BLUE_SIZE, 1,
            GLX_DOUBLEBUFFER, 0
        };

        this.xdisplay = Gdk.x11_get_default_xdisplay( );
        
        if( !glXQueryExtension( xdisplay, null, null ) ) {
            stderr.printf( "OpenGL not supported\n" );
        }

        this.xvinfo = glXChooseVisual( xdisplay, Gdk.x11_get_default_screen( ), attrlist );
        
        if( xvinfo == null ) {
            stderr.printf( "Error configuring OpenGL\n" );
        }

        var drawing_area = new Gtk.DrawingArea( );
        drawing_area.set_size_request( 300, 300 );
        drawing_area.set_double_buffered( false );

        this.context = glXCreateContext( xdisplay, xvinfo, null, true );

        drawing_area.configure_event.connect( on_configure_event );
        drawing_area.draw.connect( on_draw );

        add( drawing_area );
    }

    private bool on_configure_event( Gtk.Widget widget, Gdk.EventConfigure event ) {
        if( !glXMakeCurrent( xdisplay, Gdk.X11Window.get_xid( widget.get_window( ) ), context ) )
            return false;

        GLsizei width = widget.get_allocated_width( );
        GLsizei height = widget.get_allocated_height( );
        GLsizei size = int.min( width, height );
		
        glViewport( (width - size ) / 2, (height - size ) / 2, size , size );

        return true;
    }

    private bool on_draw( Gtk.Widget widget, Cairo.Context cr ) {
        if( !glXMakeCurrent( xdisplay, Gdk.X11Window.get_xid( widget.get_window( ) ), context ) )
            return false;

        glClear( GL_COLOR_BUFFER_BIT );

        glBegin( GL_TRIANGLES );
            glIndexi( 0 );
            glColor3f( 1.0f, 0.0f, 0.0f );
            glVertex2i( 0, 1 );
            glIndexi( 0 );
            glColor3f( 0.0f, 1.0f, 0.0f );
            glVertex2i( -1, -1 );
            glIndexi( 0 );
            glColor3f( 0.0f, 0.0f, 1.0f );
            glVertex2i( 1, -1 );
        glEnd( );

        glXSwapBuffers( xdisplay, Gdk.X11Window.get_xid( widget.get_window( ) ) );

        return true;
    }
}

void main( string[] args ) {
    Gtk.init( ref args );

    var sample = new GLXSample( );
    sample.show_all( );

    Gtk.main( );
}

Here you can find a working makefile, which should make the compilation process easier.

all:
	valac --pkg gtk+-3.0 --pkg gdk-x11-3.0 --vapidir ../vapi --pkg gl --pkg glx glx-sample.vala -o glx-sample

Öfnen von ISO Image-Dateien in Ubuntu GNU/Linux

Um in Gnu/Linux Image-Dateien, inbesondere mit der ISO-Endung, zu öffnen, benötigt man, im Gegensatz zu Windows, keine externe kostenpflichtige Anwendungen, wie zum Beispiel DEAMON Tools. Die auf Gnu/Linux basierende und Windows weit überlegende Betriebssysteme, wie das frei verfügbare Ubuntu bieten auch in diesem Fall sehr einfache Lösungen an.
Man erstellt dafür einen neuen Ordner, falls noch nicht vorhanden, mit dem Befehl:

sudo mkdir /media/iso_image

und bindet die Image-Datei, hier genannt als filename.iso

sudo mount filename.iso /media/iso_image -t iso9660 -o loop

Dieser Prozess wird als Mount bezeichnet. Schon, es ist erledigt. Man braucht nun nur zu diesem Ordner zu navigieren, um den Inhalt der gerade eingebundenen ISO-Datei anzuschauen.
Wenn der Inhalt der Image-Datei nicht mehr benötigt wird, lässt sich diese mit dem ausführen vom Befehl

sudo umount /media/iso

wieder schließen.

Syntaxunterstützung für die Programmiersprache Vala in Emacs-Editor

Vala ist eine sehr moderne und eine auf Open-Source-Konzepte bassierende Programmiersprache mit einer sehr vergleichbaren mit Java- bzw. C#-Syntax und ist damit immer eine gute Wahl für jeden Programmierer. Jedoch ist deren Synteaxunterstützung noch nicht in vielen bekannten Editoren wie Emacs standartmäßig eingerichtet. Manuell aber lässt sich das sehr leicht beheben.

Seit Version 24 kommt Emacs mit dem preintallierten Packet “package.el” und bietet somit die Option andere Funktionserweiterungen aus den verschiedenen Repositorien nachzurüsten. Marmalade ist zum Beispiel so ein Package-Archieve, welches auch die Erweiterung “vala-mode” enthält. Um diese zu aktivieren benötigt man folgende Schritte:

  1. Die “~/.emacs“-Datei wird mit dem folgenden Inhalt bereichert:
    (require 'package)
    (add-to-list 'package-archives
        '("marmalade" . "http://marmalade-repo.org/packages/"))
    (package-initialize)
  2. Danach werden die eben hinzugefügte Funktionen mit dem Befehl “M-x eval-buffer” ausgeführt und die Liste der Erweterungen mit dem Befehl “M-x package-refresh-contents” aktualisiert.
  3. Anschließend kann man die Unterstützung von Vala-Syntax mit dem Befehl “M-x package-install vala-mode” freischalten.

Für die älteren Versionen von Emacs kann man entweder das Packet “package.el” nachinstallieren, um die oben erwähneten Schritte machen zu können oder die vala-mode-Datei manuall in den Ordner “~/.emacs.d/” zu verschieben und die “~/.emacs“-Datei mit den folgenden Funktionen zu erweitern.

 (add-to-list 'load-path (expand-file-name "~/.emacs.d"))
(autoload 'vala-mode "vala-mode" "Major mode for editing Vala code." t)
(add-to-list 'auto-mode-alist '("\\.vala$" . vala-mode))
(add-to-list 'auto-mode-alist '("\\.vapi$" . vala-mode))
(add-to-list 'file-coding-system-alist '("\\.vala$" . utf-8))
(add-to-list 'file-coding-system-alist '("\\.vapi$" . utf-8))

Nun sollte einem erfolgreichen Vala-Projekt nichts im Wege stehen!

Referenz: Vala syntax support for Emacs