HowTo: Pack Gtk CellRenderers vertically in a Gtk TreeView

[...]
var treeview = Gtk.TreeView();
var column = new Gtk.TreeViewColumn();

var cellrenderer_1 = Gtk.CellRendererPixbuf();
var cellrenderer_2 = Gtk.CellRendererText();

column.add_attribute(cellrenderer_1, "pixbuf", 0);
column.add_attribute(cellrenderer_2, "markup", 1);

(column.get_area() as Gtk.Orientable).set_orientation(Gtk.Orientation.VERTICAL);

column.pack_start(cellrenderer_1, false);
column.pack_start(cellrenderer_2, false);

treeview.append_column(column);
[...] 

Cairo Context/Surface to Gdk Pixbuf

Cairo Surface to Gdk Pixbuf

Gdk.pixbuf_get_from_surface(surface, 0, 0, surface.get_width(), surface.get_height());

Cairo Context to Gdk Pixbuf

Gdk.pixbuf_get_from_surface(context.get_target(), 0, 0, context.get_target().get_width(), context.get_target().get_height());

 

That is all…

SlickPanel 0.02 Released!

Hi! After a long wait, SlickPanel 0.02 has been released.

The changes in this release include lots of bug fixes, but most of all the ability to configure your panel. While not all of this is completely finished (some things like changing the background of the panel and its orientation and not fully complete yet), the majority is.

To configure SlickPanel, all you have to do is run:

slickpanel-settings

And you will open the SlickPanel Settings application:

Remember that this is still early days and so SlickPanel is not what I would call stable yet 🙂 However if you do want to try it out, check out the installation instructions here.

Development of SlickPanel : Configuration

I thought since it has been a while since I posted anything on SlickPanel, I would update you on what I am currently doing on it. At the moment I am both creating a configuration backend for SlickPanel and a program to configure it. To do this I am parsing an XML file (with libxml2) which looks something like this:

<slickpanel:settings> <slickpanel:panel > 

All of this code, which is both common to the actual panel, and the settings program is compiled into a static library so that I can call it from both applications.

The settings program itself will look something like this:

Of course all is coded in Vala and GTK3 🙂

Presenting SlickPanel

When I switched to Oneiric, I tried Unity and GNOME Shell however I found I preferred my classic setup of GNOME Panel and used a external application launcher.

However, I was surprised to find that GNOME Panel had not very well maintained in Oneiric. In fact it is buggy and I had to go through some effort to get Indicators working on it.

After looking at GNOME Panel and other options (such as wingpanel) I realised there was not a quick, stable, extensible (and pretty!) desktop panel for GTK.

So I made one 🙂

SlickPanel is a modern panel that provides common tools such as a list of open windows and an indicator bar.

Its goals are:

  • Provide a robust, and quick desktop panel
  • Make it easy to customise and extend, rather than hide options
  • Use modern technologies rather than be backwards-compatible
  • Make it easy to hack on!

Current Status

SlickPanel is not ready for production use, this is an alpha release. Currently it will provide a panel at the top of the screen, containing a list of open windows (which can be minimized, maximized etc.) and the list of indicators.

In the next release I will try to focus on customisability (is that a word?) – making it easy to configure SlickPanel exactly the way you want it (https://blueprints.launchpad.net/slickpanel/+spec/configuration).

How to Install

Add the SlickPanel Daily PPA to your Software Sources and the install the package slickpanel. Then run it using the command slickpanel

More Info

All other information can be found on Launchpad (launchpad.net/slickpanel) and if anyone wants to get involved with developing etc. please get in touch (launchpad.net/~and471)

GtkAction – HowTo and Why

About

A problem that recently arose when I was developing a GTK application was I had a set of actions (New, Save, Open etc.) which needed to be in a ToolBar and a MenuBar.

The issue was keeping all these actions in sync, and it becomes even tricker when certain action are only enabled in certain scenarios.

However Gtk has an easy way to deal with this.

GtkAction

A GtkAction simply represents an action and it gives the opportunity for many widgets to make this action happen.

For example if I had a Save action, I would want my Save item in my Menubar and Toolbar do activate this action.

GtkAction also provides many more useful properties, besides just making the action happen. It can also store a label, tooltip, icon and more, so that each widget that uses the action simply ‘picks up’ this information.

In practice this means there is no need to set the label twice etc.

As well as the normal GtkAction class, there is also GtkToggleAction and GtkRadioAction (to represent actions that can be toggled, or a selection out of one) and GtkActionGroup so you can group together similar actions (i.e. actions that modify a document)

Howto use it

Glade

Create actions by clicking on the buttons under Actions

To set widgets to use them, configure the Related Action field

Code (Vala)


var action_clickme = new Gtk.Action("clickme", "Click Me!", "Why don't you click me?", Gtk.Stock.ABOUT);

// This widget can be anything that implement GtkActivatable
var button = new Gtk.Button();
button.set_related_action(action_clickme);
button.set_use_action_appearance(true);

action_clickme.activate.connect(() => {
stdout.printf("You activated the action!\n");
});