Xfce

Subdomains
 

Xfce Clipman Plugin 1.0.0

  • April 16, 2009
  • Mike Massonnet
This post is about the latest release of Xfce Clipman Plugin, a Clipboard Manager for the Xfce desktop. I turn it more technical than for end-users. I hope people interested into GTK+, GObjects or Xfce panel plugins will like to read it. The release is going to happen very soon now.

The first major change concerns the plugin being entirely rewritten by using GObjects and Xfconf, this means cleaner, better understandable, maintainable code, etc. There is the "main function" (for sack of clarity) and four objects. A collector which listens to clipboard changes and put them in the history, the history is also an object, a menu (on top of GtkMenu) that displays the history and allows to clear it, and finally another object which is part of a new feature for the clipboard manager.

Now having my objects it's just about instantiating them in the main function and binding them to Xfconf. If there is something missing in an object it is just about modifying a particular aspect of it.

The goal of using Xfconf is to have a less cluttered code for settings, and to make good use of property bindings against the objects. For instance, the object History has a maximum count of items, and being bind against Xfconf, it is possible to run an external command with xfconf-query to change that setting, without having to call a public setter function. Binding a property is a one function call.

Following this major change is the settings dialog. I have written it from scratch with Glade, a UI designer for GTK+, by which I can easily modify and beautify the dialog without having to fight with lines of code several hours a day. In fact it takes a few seconds to change a label and up to 5 minutes to design a goddamn dialog. Glade makes an increased use of memory however, but stop thinking of this when you know you have 1MB times 1000 installed on your system — I have currently 1GB on a netbook and 2GB on a quite-fanless Atom-based workstation but I use only around 300MB in general. If you still fear about having an application that uses only 2 but 5MB with Glade, well I can't help you! From what I have read, the built-in UI designer of GTK+, named GtkBuilder, needs less memory, but the Glade to GtkBuilder conversions are going to happen with Xfce 4.8.

Now about the new feature introduced into this major release. It is called "Actions" which is the fourth object by the way. An action is a match between a text selection and regexes to let you execute specific commands. For example the action "Image" can match text with image filenames and let you choose commands between "View with Ristretto" and "Edit with Gimp". I wrote something simple in the settings dialog to add new actions that is inspired from the Thunar User Custom Actions interface.

Finally, I made other changes that are more geeky than useful, like I made a bundle out of the plugin. The plugin is now installed under the binary directory instead of the common place holder for panel plugins but can still be added inside a panel with the "Add Item" menu action. As you might understand, it can be executed as well now, and if you do so it will run inside the notification area. An item is installed in the applications menu to be able to start it (under the category Utility), and as it is possible to run outside the panel, I added a autostart file.

That's it already. If you have questions, don't mind. If you wanna discuss the Actions/regex feature go ahead. More importantly, I hope you'll take a glimpse at the code.

If you are interested into panel plugins, have a look at the wiki. The panel plugins amongst the goodies are a good way to get to know code and start with something.

Update: ANN: xfce4-clipman-plugin version 1.0.0 released

Refresh the Xfce background

  • March 11, 2009
  • Mike Massonnet
In Xfce 4.4 there was a little hack that worked to refresh the background. I managed to get the same result for Xfce 4.6 with the following "hack":
#!/bin/sh
if [ -z "${DBUS_SESSION_BUS_ADDRESS}" ] ; then
. ${HOME}/.dbus/session-bus/`ls -rt ${HOME}/.dbus/session-bus/ | tail -1`
export DBUS_SESSION_BUS_ADDRESS
fi
PATH=/usr/local/bin:${PATH}
MONITOR=${1:-0}
PROPERTY="/backdrop/screen0/monitor${MONITOR}/image-path"
IMAGE_PATH=`xfconf-query -c xfce4-desktop -p ${PROPERTY}`
xfconf-query -c xfce4-desktop -p ${PROPERTY} -s ""
xfconf-query -c xfce4-desktop -p ${PROPERTY} -s "${IMAGE_PATH}"
Now when will this be useful? Barely never. Still enjoy it :-)

Update: script snipped updated to run within a cronjob.

Vala Notes Plugin

  • March 11, 2009
  • Mike Massonnet
Or better, there is Vala in the Notes plugin. It's been a long time I thought about a hypertext view widget for the notes plugin, so it can highlight links and open them on click, and doing this in pure C/GObject is quite a PITA because there is a lot to take care about (more lines of code), and then you didn't start thinking about the whole functions of the object. Now this is retro with the presence of Vala. I played with Vala some time ago, doing some very rudimentary hello worlds, and I never had a chance to really write something in Vala, untill two days ago. I started to write a very dummy object on top of GtkTextView that implements the simple undo/redo feature I wrote inside notes.c and it was very fast and easy to backport from the C code to Vala, and this gave me a very good start with Vala (now that was one Vala too much, wasn't it? anyway...). Yesterday I added skel functions to support hyperlinks which I finished today. Finally I integrated the Vala object inside the notes plugin in a way that it compiles to C code when you are in MAINTAINER_MODE, which means for end-users they won't need Vala but only gcc.

Now for those interested into Vala, here is the file I played with: hypertext.vala. This source contains at the end of the HypertextView class, another class that contains a main function so it can be compiled to a binary. This proves how easy it is to test a class, and all you need to do is to run the following command: valac --pkg=gtk+-2.0 hypertextview.vala && ./hypertextview.
There are many samples available with the source of Vala and on Gnome Live. The tutorial covers important points, the FAQ too, but the documentation is a little less interesting if you already know GObject IMHO.
One important thing I learned about Vala was the difference between the out and ref arguments.

If you have a hard time at finding the right method definitions, look into /usr/share/vala/vapi/gtk+-2.0.vapi for instance for GTK+. There you can quickly find any function name you now from the C API, for instance if you want to have a look at gtk_text_view_get_iter_at_location search for get_iter_at_location. By scrolling up you will see that you are in the class Gtk.TextView. Vapis are very easy to read.

I am very interested into porting the objects of the Xfmpc project to Vala, and then start trying out the plugin sample (loading modules during runtime)... I hope my fellow will like that idea :-)

Now for the people interested to develop Vala classes with VIM I have some tips. First follow these instructions in order to get Vala syntax. Then I suggest you install the Tag List plugin, and to get it working with Vala you will need to add the following lines to your vimrc configuration:
" Work-around Tag List
let tlist_vala_settings='c#;d:macro;t:typedef;n:namespace;c:class;'.
\ 'E:event;g:enum;s:struct;i:interface;'.
\ 'p:properties;m:method'
If you don't know about folding then you miss a lot of VIM culture, in fact you can fold/unfold brackets by going over a bracket and typing zf% in command mode. And that's all folk, thanks for reading til here.

./shoutcast-radio

  • March 5, 2009
  • Mike Massonnet
Just like my older post about a "./jamendo-player", this time I am definitely more interested into good online radio stations. And SHOUTcast is the best that comes to my mind! It's been there for years, Winamp is the best music experience ever, and both have been promoting each other even though I don't know/remember what their relation are.

The good things about their widget is that it saves the recent radios and it also has a list of favorites but this one isn't working as-is with the code. It is possible to search for radios and to browse by genre. All of this stuff is saved under ~/.macromedia/Flash_Player/#SharedObjects/<random>/ct.yourminis.com/.



So of course I couldn't resist but embed their available Flash widget inside a window :-) Again the code is very short, it's just about loading — well not a URL this time — an HTML string cause the Flash application all alone doesn't work out, it needs parameters passed outside. I didn't include the callbacks to handle "_blank" links, which means it is not possible to open any links, but this is useless as the widget is fully functionnal.

You can download the source code here.

Here are some installation instructions:
  1. Look into main.c
  2. The first line of main.c is a comment with a command to compile
  3. If you want a menu item in you desktop menu:
    1. Edit the Exec keys in shoutcast-radio.desktop
    2. Copy the desktop file to ${XDG_DATA_HOME:-~/.local/share}/applications
  4. If you don't have a gnome-radio icon, copy gnome-radio.png to ~/.icons/
By the way, I'm linking on the Xfce blog. Why? Cause there might be Xfce users interested into a simple to compile radio application. At least I hope some of you will enjoy it, more than the jamendo thingy :)

Update: The favorites actually do work, it just that the favorite button isn't always clickable.

Colored Notes

  • February 19, 2009
  • Mike Massonnet
I passed the last night to hack on a gtkrc snippet for the Notes plugin, because I couldn't find my sleep well. So being borred I killed a little bit the time to have a colored notes window :-) I know it was possible since always, I just never carred to do it. Using colors showed one annoying problem which are the icons. They don't fit always once you go away from the default gtk theme colors. In consequence I switched them to bold text labels with minus, plus and times. One other thing I didn't succeed with was to theme the menu that is available on the top right corner or Ctrl+M.

Finally the result is nice.

The snippet is the following:
gtk_color_scheme = "notes_fg_color:#E8E58C\nnotes_bg_color:#77741D\nnotes_base_color:#EBE88C\nnotes_text_color:#6B6A4A\nnotes_selected_bg_color:#ACA94E\nnotes_selected_fg_color:#E8E58C"

style "notes-default"
{
xthickness = 2
ythickness = 2

fg[NORMAL] = @notes_fg_color
fg[ACTIVE] = @notes_fg_color
fg[PRELIGHT] = @notes_fg_color
fg[SELECTED] = @notes_selected_fg_color
fg[INSENSITIVE] = shade (3.0,@notes_fg_color)

bg[NORMAL] = @notes_bg_color
bg[ACTIVE] = shade (1.0233,@notes_bg_color)
bg[PRELIGHT] = mix(0.90, shade (1.1,@notes_bg_color), @notes_selected_bg_color)
bg[SELECTED] = @notes_selected_bg_color
bg[INSENSITIVE] = shade (1.03,@notes_bg_color)

base[NORMAL] = @notes_base_color
base[ACTIVE] = shade (0.65,@notes_base_color)
base[PRELIGHT] = @notes_base_color
base[SELECTED] = @notes_selected_bg_color
base[INSENSITIVE] = shade (1.025,@notes_bg_color)

text[NORMAL] = @notes_text_color
text[ACTIVE] = shade (0.95,@notes_base_color)
text[PRELIGHT] = @notes_text_color
text[SELECTED] = @notes_selected_fg_color
text[INSENSITIVE] = mix (0.675,shade (0.95,@notes_bg_color),@notes_fg_color)
}

widget "xfce4-notes-plugin*" style:highest "notes-default"
widget "xfce4-notes-plugin*.*GtkMenu*" style:highest "notes-default"
widget "xfce4-notes-plugin*.*GtkMenuItem*" style:highest "notes-default"
# TODO Set the colors for the menu
The shade() and mix() functions are specific to either Clearlooks or Aurora. But this can be fixed. Actually I didn't include a default rc style inside the notes plugin, in fact this snippet can be saved for instance as notesrc inside your current theme and you add include "notesrc" in the gtkrc file.

All for the sharing, please enjoy.

Update: The shade() and mix() functions are a feature from GTK+ 2.10 just like gtk_color_scheme.

Update: I released a new version 1.6.4 that has a configurable background color setting.

Fix bitmap^Whorrible fonts

  • January 19, 2009
  • Mike Massonnet
You have horrible fonts in Firefox and don't know how to fix it? It is fairy simple:
cd /etc/fonts/conf.d
cp ../conf.avail/70-no-bitmaps.conf .
And this is it. Restart X.

./jamendo-player

  • January 9, 2009
  • Mike Massonnet
I was enough bored from my (small) music collection that I wanted to listen to something new, without actually caring what it is. I know Jamendo has a big load of music with artists uploading music under creative commons licence. So I went on their website to have a look, and they have "widgets". They are a small flash application not bigger than 200x300, but I actually didn't find any link to open such a widget inside an external window, except some lost links on some pages. In conclusion it was enough annoying to get an external player that I fired up vim and wrote a 20 lines C program.

/* gcc `pkg-config --cflags --libs webkit-1.0` main.c -o jamendo-player */

#include <gtk/gtk.h>
#include <webkit/webkit.h>

#define URL_FORMAT "http://widgets.jamendo.com/fr/playlist/?playertype=2008&playlist_id=%s"

int main (int argc, char *argv[])
{
GtkWidget *window;
GtkWidget *webview;
gchar *url;
gchar *playlist_id = argv[1];
if (argc < 2)
{
playlist_id = g_strdup ("65196");
g_message ("Loading the default playlist %s", playlist_id);
}
url = g_strdup_printf (URL_FORMAT, playlist_id);
gtk_init (&argc, &argv);
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
g_signal_connect (window, "delete-event", G_CALLBACK (gtk_main_quit), NULL);
gtk_window_set_icon_name (GTK_WINDOW (window), "multimedia-player");
gtk_window_set_title (GTK_WINDOW (window), "Jamendo Player");
gtk_window_set_resizable (GTK_WINDOW (window), FALSE);
webview = webkit_web_view_new ();
gtk_widget_set_size_request (webview, 200, 300);
gtk_container_add (GTK_CONTAINER (window), webview);
webkit_web_view_open (WEBKIT_WEB_VIEW (webview), url);
gtk_widget_show_all (window);
gtk_main ();
return 0;
}


The result is pleasing, the flash application has nice colors, and is something I would never be able to do with GTK+ :-)

If you like the code, feel free to extend it and send patches, I will enjoy any contribution. For now I will just leave a desktop file inside my applications directory to open it when I am bored again of my music :-p

Update: I hacked a little on the program to handle the links inside the Flash application. This means it is possible to change the playlist, which was one the thing that started to annoy me very much.

However, this update requires WebKit 1.0.3 and GLib 2.16.



This time I'm making the code available here instead of pasting it as it has grown up to 120 lines.

Prospective work on Xfce

  • November 13, 2008
  • Mike Massonnet
As Xfce 4.6 is coming it might be good to throw updates for the panel plugins I maintain at the same time.

The panel plugins I maintain are:
  • The notes plugin
  • The FS guard plugin
  • The clipman plugin (this one is prolly the most wanted)

For the notes plugin I got already most features I was thinking of in, except formatting (which I doubt that I will work on), so the release going on here will be minor.

For the FS guard plugin I was asked to reverse the progress bar so that it shows the capacity remaining and not the free space... well something like that :-) Now I'm confused and don't remember what it really displays.

The clipman plugin needs a rewrite. To my taste it features too many options, and I will split most none-obvious options to an "Advanced..." tab. The first release will most probably be the rewrite, than will follow another release for a long asked feature that is action on pattern matching — open a web page automatically, display a menu, and so forth.

Other than plugins I maintain applications.

The applications I maintain are:
  • Xfmpc
  • Eatmonkey

Sadly for Xfmpc — a client for MPD — I no longer run MPD to listen to my music, so this hacking is freezed at the moment. My current favorite player is Audacious.

Eatmonkey is a small application where I learn to use new frameworks. There won't be an official release before very long.


Hopefully I will get the clipman plugin out before end of December!

Mount remote file systems (Tape #2)

  • September 3, 2008
  • Mike Massonnet
I once wrote about sshfs.sh, a shell script to mount a remote file system with sshfs. This is now deprecated!

Now I'm giving a try to gvfs-mount. Currently I can mount a volume and list it with gvfs-mount --list, but I cannot browse inside it because it isn't mounted. I played with the --mountable argument, but it must be a joke. I think I need a something fuse daemon from gvfs... I'll keep this up to date.

Update: Everything is alright now. The output of ps ax | grep gvfs shows the following process: /usr/lib/gvfs/gvfs-fuse-daemon. All your mount operations will be available at $HOME/.gvfs.

The recent GTK+2.14 release introduces a widget to ask a password thats called GtkMountOperation (have a look at the GTK+ blog). It might be interesting to start a Thunar plugin, and release it officially with Xfce 4.8.

Update 2: And on a fresh Debian install (or in general anyway) don't forget to install the fuse-utils package (/usr/bin/fusermount)!

Marihela update

  • November 12, 2007
  • Mike Massonnet
Today I was working around Marihela, and I already had the idea of what to do. It is incredibly awe-some to work with an external display. There was enough space for a well sized xzoom, gimp, and full sized terminal (shade/unshade ^_~). You can check out on my gallery.


If you wonder what the GTK+ theme is, it is Aurora-Midnight.

Download Marihela.tar.bz2.

Update: The most recent version of Marihela can be snapshotted from my gitweb interface.