Category Archives: April 2009

GConf Configuration System Concepts for Developers

Natan Yellin provides an overview for GNOME developers on how the GConf Configuation System works and how it can be used in developing GNOME applications.

Introduction

The GConf Configuration System is a system used by the GNOME desktop to handle user preferences. The motivation to use GConf is to provide system administrators more manageability when deploying desktops and to provide application developers a centralized location for user preferences. This article will explain the fundamental concepts of how GConf works and will demonstrate how developers can use GConf in their applications. The examples in this article are all written in C, however it can be accessed with any supported language that we use in GNOME like C++, Perl, Java, and Python.

Before we begin, there are a few details about GConf that are worth noting:

  • GConf should not be used for crucial application settings (e.g. an address book’s contacts). It should only be used for user preferences ( e.g. the address book’s font).
  • The GConf database is not guaranteed to be constantly running. As we’ll see later on, values fetched from GConf should be checked to make sure that they exist.
  • GConf values are (by definition) user writable. Applications should verify data stored in GConf when necessary.
  • GConf applies settings instantly. In other words, when a setting changes, the change applies immediately without waiting for the user to press an “apply” button.
  • GConfClient wraps the GConfEngine functions in a friendlier object that descends from GObject. For the most part, you won’t want to use GConfEngine directly.

GConf settings are stored in a key-value format. The database itself is stored in set of xml files located under ~/.gconf. You should never read or write to these files directly. If you’d like to manually edit the database without using the GConf API from a program, you can do so graphically using the gconf-editor application. You can also get and set keys from the command line with the gconftool-2 command line tool.

Create a new Gconf Client

Lets begin by looking at some some code to create a new GConfClient:

GConfClient* gconf_client_get_default (void);

The returned engine has a reference count of 1. It should be unreferenced when you’re done using it with g_object_unref().

We can set a key with the following functions:

gboolean gconf_client_set_float (GConfClient *client,
const gchar *key,
gdouble val,
GError **err);

  • client is the GConfClient that we created earlier.
  • key is the name of the key to set.
  • val is the value to set for key.
  • err is the return location for an error or NULL to ignore errors.

Similar functions exist for manipulating integers, booleans, and strings.

gboolean gconf_client_set_int (GConfClient *client,
const gchar *key,
gint val,
GError **err);

gboolean gconf_client_set_bool (GConfClient *client,
const gchar *key,
gboolean val,
GError **err);

gboolean gconf_client_set_string (GConfClient *client,
const gchar *key,
const gchar *val,
GError **err);

There are three additional functions for setting schemas, lists, and pairs. They’re a bit more complicated and much less common, so we’ll leave them for another time.

To get a key’s value use gchar * gconf_client_get_string (GConfClient *client, const gchar *key, GError **err) or the corresponding function for any of the other data types.

The following example is heavily commented, and will explain the bare basics of gconf:

#include <gconf/gconf-client.h>

#include <gtk/gtk.h> // this callback is called whenever the button is pressed void pressed_cb (GtkWidget *widget, GConfClient *config) {

  // gconf_client_get_int () returns 0 if the key does not exist. In
this case, we don't need to bother checking for errors.
  gint clicks = gconf_client_get_int (config, "/apps/gconf-test/clicks", NULL);
  clicks++;
  // set the value so that it will exist next time this function is called
  gconf_client_set_int (config, "/apps/gconf-test/clicks", clicks, NULL);
  g_print ("%d\n", clicks);
}
int main (int argc, char **argv)
{
  GtkWidget *window;
  GtkWidget *button;
  GConfClient *config;
  // common gtk init
  gtk_init (&argc, &argv);
  // create the GConfClient
  config = gconf_client_get_default ();
  // create the window and make it quit when we want it to
  window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
  g_signal_connect (G_OBJECT (window), "destroy", G_CALLBACK
(gtk_main_quit), NULL);
  // and the button...
  button = gtk_button_new_with_label ("Press me");
  // when it is pressed call our callback
  g_signal_connect (G_OBJECT (button), "clicked", G_CALLBACK
(pressed_cb), config);
  gtk_container_add (GTK_CONTAINER (window), button);
  // some more common stuff
  gtk_widget_show_all (window);
  gtk_main ();
  return 0;
}

Compile

You can compile the file with:

gcc -Wall -g gconf-test.c -o gconf-test `pkg-config --cflags gtk+-2.0 gconf-2.0` \ `pkg-config --libs gtk+-2.0 gconf-2.0`

Test it out and play around with it. You’ll notice that the program will “remember” the number of times that it was clicked the last time that it was run.

Associate a GObject property

When you want to associate a particular GObject property (e.g. a window’s opacity) with a gconf key, then things begin to get complicated. The usual method of doing so is as follows:

1) The application starts up and sets the default value from GConf.
2) The application tells gconf that it wants to be notified when the key changes.
3) The user opens the app ’s preferences window and changes a key.
4) A callback gets called to set the GConf value.
5) Setting the GConf value triggers another callback that reads in the key and applies the setting.

For example:


  /* At application startup */
  gconf_client_notify_add(client, key,
update_application_to_reflect_setting, data);
  set_initial_app_state(client);

  /* From preferences dialog */
  gconf_client_set(client, key, value);

However, you should never do the following: gconf_client_set(client, key, value); application_update_to_reflect_setting();

That will break if the user changes a GConf key from out outside of your app.

There are two important functions for notifications. The first is:

void gconf_client_add_dir (GConfClient *client,
const gchar *dir,
GConfClientPreloadType preload,
GError **err);

  • dir should be the directory to watch (e.g. ”/apps/gconf-test”).

GConf can preload the values before you try to read them in order to save time. preload should be either GCONF_CLIENT_PRELOAD_NONE, GCONF_CLIENT_PRELOAD_ONELEVEL, or GCONF_CLIENT_PRELOAD_RECURSIVE.

Once we have added a directory, we can tell GConf which specific keys we want to monitor with:

 guint gconf_client_notify_add (GConfClient *client, const gchar *namespace_section, GConfClientNotifyFunc func, gpointer user_data, GFreeFunc destroy_notify, GError **err); 
  • client is a GConfClient.
  • namespace_section is a directory or key to listen to for changes.
  • func is the function to call when changes occur.
  • user_data is the data to pass to func.
  • destroy_notify is the function to call on user_data when the notify is removed or the GConfClient is destroyed, or NULL for none.
  • err is the return location for an allocated GError, or NULL to ignore errors.

The function return a connection id that can be used to remove the connection.

Finally, lets look at the GConfClientNotifyFunc function signature:

void (*GConfClientNotifyFunc) (GConfClient *client,
guint cnxn_id,
GConfEntry *entry,
gpointer user_data);

  • client is the GConfClient notifying us.
  • cnxn_id is connection ID from gconf_client_notify_add().
  • entry is a GConfEntry.
  • user_data is the user data that we specified with gconf_client_notify_add().

This can get pretty lengthy when you have a few keys to read on startup and then monitor for changes. If you’re going to use GConf for more than one or two prefereces, it’s recommended that you use a wrapper for GConf to reduce your application’s boilerplate code. libgconf-bridge is the most common library that is used to do so. (Note that libgconf-bridge may not be installed on all distributions.)

libgconf-bridge example

Lets take a look at an example with libgconf-bridge. As you’ll notice, by using the gconf_bridge_bind_property function, we can make the code more compact:

#include <gconf/gconf-client.h>

#include <gtk/gtk.h>

#include <libgconf-bridge/gconf-bridge.h>

int main (int argc, char **argv) {

 GtkWidget *window;
 GtkWidget *scale;
 gtk_init (&argc, &argv);
 window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
 g_signal_connect (G_OBJECT (window), "destroy", G_CALLBACK
(gtk_main_quit), NULL);
 gtk_window_set_default_size (GTK_WINDOW (window), 100, 30);
 scale = gtk_hscale_new_with_range (0, 1, 0.1);
 gtk_container_add (GTK_CONTAINER (window), scale);
 gconf_bridge_bind_property (gconf_bridge_get (),
   "/apps/gconf-test/scale",
   G_OBJECT (gtk_range_get_adjustment (GTK_RANGE (scale))), "value");
 gtk_widget_show_all (window);
 gtk_main ();
 return 0;
}

Compile the example (you need to add libgconf-bridge to pkg-config) and watch the value in gconf-editor as you move the slider around. As you’ll notice, the gconf_bridge_bind_property function “binds” a GConf key to a GObject property and automatically updates the key when the property changes.

Schemas

The last topic that we’ll cover is schemas. Schemas are xml files that are installed for all users and contain the default key:value properties for an app. When the app is run for the first time, gconf will set the default values from the schema. Here’s an example schema file:

 <?xml version="1.0" ?> <gconfschemafile>
 <schemalist>
   <schema>
     <key>/schemas/apps/avant-window-navigator/applets/awn-terminal/opacity</key>
     <applyto>/apps/avant-window-navigator/applets/awn-terminal/opacity</applyto>
     <owner>avant-window-navigator</owner>
     <type>float</type>
     < default>0.5</default>
     <locale name="C">
       <short>opacity</short>
       <long>The applet 's opacity level.</long>
     </locale>
   </schema>
   <schema>
     <key>/schemas/apps/avant-window-navigator/applets/awn-terminal/bg_img</key>
     <applyto>/apps/avant-window-navigator/applets/awn-terminal/bg_img</applyto>
     <owner>avant-window-navigator</owner>
     <type>string</type>
     <default>""</default>
     <locale name= "C">
       <short>Background</short>
       <long>The applet's background image.</long>
     </locale>
   </schema>
 </schemalist>
</gconfschemafile>

All of the keys and their values are contained inside and . Each individual key is defined by . Under , is the location of the actual schema and is the location of the key that the schema will set. is the app’s name, is the key’s type, and is the key’s default value. is used to provide a and description of the key’s purpose.

To install a schema with autotools, you need to add something like the following to your Makefile.am:

 schemasdir = GCONF_SCHEMA_FILE_DIR schemas_FILE = awn-terminal.schemas schemas_in_files = $(schemas_FILE).in schemas_DATA = $(schemas_in_files:.schemas.in=.schemas)

INTLTOOL_SCHEMAS_RULE

if GCONF_SCHEMAS_INSTALL install-data-local: $(schemas_DATA) GCONF_CONFIG_SOURCE=$(GCONF_SCHEMA_CONFIG_SOURCE) $(GCONFTOOL)—makefile-install-rule $(schemas_DATA) endif

Conclusion

That’s really all that there is to it. Now go out and add some preferences to your application!

About the Author

Natan Yellin is a high school student in Ra’anana, Israel. He first became involved with GNOME development through Google’s Highly Open Participation contest in 2007. Since then, he helped start GNOME Zeitgeist and several other open source projects. When he’s not coding an open source project or doing freelance development, Natan can be found at his school’s robotics lab, with friends, or practicing one of several styles of Karate. He usually tries to blog about what he’s working on at http://theesylum.com/.

Discuss this story with other readers on the GNOME forums.

Advertisements

GNOME Asia Summit 2008 Report

Emily Chen recaps the first GNOME Asia Summit, held this past October in Beijing, China.

Introduction

The first ever GNOME.Asia Summit was held at Beihang University in Beijing, China this past October 18th and 19th, 2008. The GNOME Foundation was the organizer of GNOME.Asia Summit in collaboration with Sun Microsystems, the Beijing Linux User Group (BLUG) and the China OSS Promotion Union (COPU). This premier event was very well attended: 318 people attended the first day, and 212 people attended the second day. The majority of the attendees, two thirds, were from universities, with the remainder being from companies. Ninety percent of the participants were local (from China) with the remainder from other countries. We had 46 volunteers from the Beijing Linux Users Group, the Beijing OpenSolaris Users Group, OpenParty, Beihang University, Beiyou University and many individual contributors. The volunteers helped us in many ways, including registration, guidance, emcees, photography and video.

This year, there were a total of 42 speakers of which 70% were local speakers and 30% of them were from other countries including the USA, Finland and Singapore. There were 46 talks over the two days of the summit. The talks covered several topics, including: accessibility, mobility, i18n, community, development and deployment. Each day started with a general session in the morning and was followed by 5 tracks in the afternoon. For more details, refer to the schedule on the summit website. Most of the slides have been uploaded to the website, as well as speakers’ bios and photos.

Sponsors

We had many sponsors for the first GNOME.Asia Summit. Sun Microsystems sponsored the summit at the gold level. We had three silver sponsors: Nokia, Motorola and Mozilla. Red Hat sponsored the Summit at the bronze level. We also had one local sponsor, Lemote, who sponsored the summit by providing three Lemote Laptops for the lucky-draw program. Google sponsored the summit by providing gifts to participants. Finally, CSDN and Programmer Magazine were media partners. We are grateful for the great support we received from all of our sponsors.

We had seven booths at the venue: Sun, Motorola, Mozilla, Red Hat, CSDN & Programmer Magazine, Lemote, and the Beijing Linux Users Group. Each booth brought their own booth materials such as laptops, PCs, lab equipment, gifts, posters and fliers. See pictures here and here.

Media

We invited five media reporters to the Summit, and they interviewed important speakers and core contributors to the GNOME community. On the 18th, they interviewed Stormy Peters and Brian Cameron from the GNOME Foundation, Robert O’Dea and Paul Mei from Sun Microsystems, Kate Alhola and Richard Sun from Nokia Finland. On the 19th, CSDN and Programmer magazine interviewed Rafael Camargo from Motorola, Jack Guo from Mozilla Online, Kevin Song from COPU (China OSS Promotion Union), Frederic Muller and Pockey Lam from BLUG (Beijing Linux Users Group). They also interviewed three Chinese input method authors: James Su, Yong Sun and Peng Huang, as well as Funda Wang from the GNOME Chinese translation team. Below are the media reports, in Chinese:

Highlights of the Summit

One of the top three OSS conferences in China, the GNOME.Asia Summit, ranked as one of the top three open source conferences in Beijing this year. The others were the Linux Developer Symposium in February and the OpenOffice organization annual conference in November. All the open source communities think it is time to go to Asia!

Keynote about GNOME Community

Stormy Peters’ keynote, “Community built software is bringing change to the world”, kicked off the summit on the first morning.
(Download Stormy’s slides here) During this speech, Stormy introduced the GNOME project and its strong community. She said that the GNOME community has developed core values including accessibility, internationalization and developer-friendliness that are shared amongst all the volunteers that work on GNOME. Over time, the GNOME project has developed strong foundations such as time-based releases, universal access, and good communication with companies in the industry as well as the community itself. Building on the community’s values and foundations, the GNOME community is now enabling their technologies for the future with initiatives like GNOME Mobile. Finally, she encouraged everyone to join the GNOME community.

Brian Cameron’s keynote about “Building Free Software Asia” was also very interesting. At the start of his talk, Brian played a video made by a contributor in the GNOME community that demonstrated GNOME using animations and cool music. A Flash demo is available here. Next, Brian introduced the concepts of free software, open software, the GNOME community and how to get involved and be active within a free software project.

Accessibility

Accessibility was one of the main topics at the Summit. We were honored to have Will Walker, lead of the GNOME Accessibility project join the summit as well as other accessibility developers, QA engineers, and teachers from the Beijing School for the Blind. On the first day, Will Walker gave an overview of GNOME accessibility. (Will’s slides are available for download here).

Later, Li Yuan introduced the accessibility infrastructure from a developer point of view. During a lightning talk, Ray Wang from Novell China introduced Mono accessibility & UI automation. On the second day, Will Walker gave a second talk, this time about Orca. Tim Miao and Harry Fu also shared their experiences with accessibility testing. We also invited two teachers from the Beijing School for the Blind, who were very interested in the screen reader, Orca, and they made sure to attend Will Walker’s talk. After the talk, they went to Sun’s accessibility booth to watch a demo about accessibility and share their expectations and user experiences with Will Walker and other accessibility developers. There were many accessibility discussions covering topics such as automation testing tools in the GNOME community. Further discussions continue to happen after the summit.

GNOME Mobile

GNOME technologies are used in many of the world’s leading mobile phones. Nokia and Motorola, leaders in the mobile industry, attended the first GNOME.Asia Summit. Nokia representatives from Finland participated in the summit by giving various technical talks which covered the Qt port to GTK+ on Maemo, Tracker, GStreamer and memory management on mobile devices. Rafael Camargo, a director at Motorola, talked about Motorola’s commercial experiences with Linux and how to improve the collaboration between open source communities and commercial enterprises. Finally, he announced that Motorola is joining the GNOME Foundation in 2009. Building on open source technologies enables Motorola not only to get to market faster but also to offer cheaper and more open solutions.

Localization

Localization is very important to non-English speaking GNOME users. This was also one of the main topics of this summit. We invited four authors of the input method sub-system, which included: James Su, leader of the SCIM community ; Peng Huang, author of scim-python and ibus ; Peng Wu, author of Novel Pinyin ; and Yong Sun, maintainer of SunPinyin. They co-hosted a technical talk about the input method frameworks and introduced IIIMF and SCIM. Funda Wang, leader of i18n-zh team, talked about the overall localization infrastructure of the GNOME project, the GTP infrastructure (administrator, team leader, translator, tester), and how to contribute to the GNOME Translation project.

GNOME & Mozilla

Mozilla is a sister community to GNOME. It was great to have Mozilla at the Summit. Jack Guo from Mozilla Online talked about “Mozilla in China”, and shared his experiences promoting Firefox in China. Mozilla Developers Brian Lu and Alfred Peng, from the OpenSolaris community, shared their experiences developing Firefox and Songbird on the OpenSolaris desktop.

Lightning Talks

At the summit, we introduced a new type of talk to China: Lightning talks. A Lightning Talk is a short presentation given at a conference or similar forum. Unlike other presentations, lightning talks only last a few minutes and several will usually be delivered one after the other by different speakers.

At the GNOME.Asia Summit, we had lightning talks on the afternoon of the 18th. The lightning talks session was one hour, with each lightning talk being only 5 minutes, with no Q&A session. We used a gong as timer. Here’s the list of lightning talks:

  1. Richard Sun : Package management
  2. Simon Zheng : New generation of GNOME Display Manager
  3. Coly Li : Quick introduction to grub4ext4
  4. Ray Wang: Mono accessibility & UI Automation
  5. Anthony Fok : Attracting new GNOME contributors with Glade
  6. Jon Philips : The Open Clip Art Library + China Lightning Talk
  7. Funda Wang: Experience Empathy

This was one of the most entertaining parts of the Summit, see a picture here.

Live Summit

Visit the Live Summit here. Thanks to Alfred, Will and Joey’s excellent work, we have successfully built the GNOME.Asia Live Summit.

The Online Summit is a real time aggregation tool for Flickr/Youtube/Twitter.
To join in, you can use any of these services:

  1. Flickr: Upload and tag your GNOME.Asia photos with “gnomeasia”
  2. Youtube: Upload your GNOME.Asia summit videos and tag them with “gnomeasia”
  3. Twitter Send messages on Twitter to ”@gnome_asia”. For example, if you want to say hello, just send this message ”@gnome_asia hello”.

Party and Tour trip

We had a wonderful celebration party on the evening of the last day at the Laoshe Tea House. We invited organizers, sponsors, volunteers, speakers and media representatives. We had 120 people join this party. See a picture here.

On October 20th, the GNOME.Asia Summit arranged a one day tour trip for speakers to the Great Wall and Ming Tomb.

Future Work After Summit

One of the major goals after the GNOME.Asia Summit is building the Beijing GNOME Users Group. There are already some GNOME communities in Beijing including: GNOME-CN and the GNOME learning panel at Tsinghua University. It would be better if we could gather together everyone who is interested in GNOME and host a GNOME Users Group regularly in Beijing. So far, we have recruited about 10 core members of the Beijing GNOME Users Group, notably: Pockey Lam from BLUG, Zhangshen and Da long from Beihang university, Fengyi from Beiyou University and Yanghong from GNOME-CN. We will use the following infrastructure for the Beijing GNOME Users Group:

  1. Website: http://www.gnome-cn.org (Need to add more modules into this website, such as Wiki, BBS etc.)
  2. Mailing List: gnome-cn-list@gnome.org
  3. IRC: BeijingGUG

We started hosting regular weekly meetings in November, 2008.

Another big task after the Summit involves Pockey Lam from the Beijing LUG who is organizing a student study group on GNOME accessibility projects. Since accessibility generated a lot of interest in Beijing, this is a good to time to encourage more people to contribute to GNOME projects. The accessibility project is the first project for the student’s study group. Some local engineers from Sun and Novell China will be mentors for the study group.

GNOME.Asia Summit was a success and we see a lot of things happening during and after the summit! Let’s ride on the momentum and continue to build a strong community in Beijing, in China and in Asia!

About the Author

Emily Chen works at Sun as a Software Engineer in the OpenSolaris desktop team. She is responsible for the quality of the Mozilla products like Firefox and Thunderbird on OpenSolaris. Emily worked in the Google Summer of Code program as a mentor in 2006 and 2007. She organized the first ever GNOME.Asia Summit 2008 in Beijing and founded the Beijing GNOME Users Group in November 2008. She graduated from Beijing Institute of Technology with a masters degree in computer science. In her spare time, she likes snowboarding, hiking and swimming.

Discuss this story with other readers on the GNOME forums.

An Introduction to the Message Indicator

Ken VanDine provides an introduction to the messaging indicator for developers, including code samples in C and Python.

Introduction

The messaging indicator, also known as the indicator-applet, is a central place to keep track of messages that you might need to be concerned about. The focus is on human-to-human messaging, such as instant messaging, e-mail, social networking, etc. By tracking these in a single applet, instead of displaying separate icons in the noticiation area or on the panel, we save a considerable amount of real estate and cut down on the clutter. We also get the benefit of a single place in the panel to find messages waiting review. For more information on the rationale, check out the specification.

Current applications that take advantage of the messaging indicator include:

  • Pidgin, with patches to pidgin-libnotify
  • Evolution, with evolution-indicator
  • Gajim, with patches already excepted upstream
  • Gwibber

To effectively use the messaging indicator with your application, you should keep two things in mind:

  1. Hide your applications icon from the notification area if it is using the indicator
  2. Rely on the indicator for raising/hiding your application as well as quick access to incoming messages

Examples

Lets walk through some examples. The library used to interact with the the messaging indicator is called libindicate, written in C. There are also python bindings to libindicate, which are called python-indicate. At this time the python-bindings only handle application side, not the listener.

Using it is actually pretty simple, you just need to have your application advertise it’s indicators using libindicate. The server object handles all of the DBus interactions so all you have to do is tell it about your indicators. The server registers itself with the indicator, which displays an item in the messaging menu for the application. When selecting the entry in the message menu, it calls the signal on the indicator. This is very useful for access to the application itself, like raising the buddy list in pidgin, etc. Examples included below in Python and you can find examples at the end of the article in C as well.

First we create the server object:

server = indicate.indicate_server_ref_default()

Set the message type and subtype, valid types include

  • “message”—a user level message. This includes e-mail, IM and SMS messages.
  • “system”—a software update or other notification about the system state.
  • “media”—a notification related media the user is listening to in the background

message.instant, message.micro, and message.im

server.set_type("message.im")

We can get some descriptive information to display in the messaging menu from a desktop file provided by the application:

server.set_desktop_file("/usr/share/applications/pidgin.desktop")

Now that all the setup work is done, we just need to connect it to the indicator. The second argument to this method call is the name of the method to call when selecting the entry in the messaging menu. The show method shows the indicator after connecting:

server.connect("server-display", server_display) server.show()

The client tells the server there is a message waiting, and when the message is selected in the the messaging menu it calls the display method for the client.

Setup the message object:

indicator = indicate.IndicatorMessage()

Then we need to set some properties for the message, available properties are: * “subject”—“message” (optional)—This is the subject line of an e-mail or message. * “sender”—“message” (required)—The person who sent the message * “body”—“message” (required)—The body of the message sent to the user
indicator.set_property("subtype", "instant") indicator.set_property("sender", "Test message") indicator.set_property("body", "Test message body") indicator.set_property_time("time", time())

The only things left to do is show the message and connect it to a method. The second argument in the connect method is the method to call when the message is selected:

indicator.show() indicator.connect("user-display", display)

Python Example

Here is a complete python example:

#!/usr/bin/env python

import indicate import gobject import gtk from time import time import os

curdir = os.getcwd() desktop_file = os.path.join(curdir, “example-indicator.desktop”)

def timeout_cb(indicator):

print "Modifying properties"
    indicator.set_property_time("time", time())
    return True

def display(indicator):

print "Ah, my indicator has been displayed"
    indicator.hide()

def server_display(server):

print "Ah, my server has been displayed"

if <i>name</i> == “<i>main</i>”:

    # Setup the server
    server = indicate.indicate_server_ref_default()
    server.set_type("message.im")
    server.set_desktop_file(desktop_file)
    server.connect("server-display", server_display)
    server.show()

    # Setup the message
    indicator = indicate.IndicatorMessage()
    indicator.set_property("subtype", "im")
    indicator.set_property("sender", "Test message")
    indicator.set_property("body", "Test message body")
    indicator.set_property_time("time", time())
    indicator.show()
    indicator.connect("user-display", display)

    # Loop
    gobject.timeout_add_seconds(5, timeout_cb, indicator)
    gtk.main()

C Example

C example:

#include <glib.h>

#include “libindicate/server.h”

#include “libindicate/indicator-message.h”

static gboolean timeout_cb (gpointer data) { g_debug(“Modifying properties”);

IndicateIndicator * indicator = INDICATE_INDICATOR(data);

GTimeVal time; g_get_current_time(&time); indicate_indicator_set_property_time(INDICATE_INDICATOR(indicator), “time”, &time);

return TRUE; }

static void display (IndicateIndicator * indicator, gpointer data) { g_debug(“Ah, my indicator has been displayed”); indicate_indicator_hide(indicator); }

static void server_display (IndicateServer * server, gpointer data) { g_debug(“Ah, my server has been displayed”); }

int main (int argc, char ** argv) { g_type_init();

IndicateServer * server = indicate_server_ref_default(); indicate_server_set_type(server, “message.im”); gchar * path = g_build_filename(g_get_current_dir(), “example-indicator.desktop”, NULL); indicate_server_set_desktop_file(server, path); g_free(path); g_signal_connect(G_OBJECT(server), INDICATE_SERVER_SIGNAL_SERVER_DISPLAY, G_CALLBACK(server_display), NULL);

IndicateIndicatorMessage * indicator;

indicator = indicate_indicator_message_new(); indicate_indicator_set_property(INDICATE_INDICATOR(indicator), “subtype”, “instant”); indicate_indicator_set_property(INDICATE_INDICATOR(indicator), “sender”, “IM Client Test”); GTimeVal time; g_get_current_time(&time); indicate_indicator_set_property_time(INDICATE_INDICATOR(indicator), “time”, &time); indicate_indicator_show(INDICATE_INDICATOR(indicator));

g_get_current_time(&time); indicate_indicator_set_property_time(INDICATE_INDICATOR(indicator), “time”, &time);

g_signal_connect(G_OBJECT(indicator), INDICATE_INDICATOR_SIGNAL_DISPLAY, G_CALLBACK(display), NULL);

g_timeout_add_seconds(5, timeout_cb, indicator);

g_main_loop_run(g_main_loop_new(NULL, FALSE));

return 0; }

.desktop Example

Example desktop file example-indicator.desktop:

[Desktop Entry]
Version=1.0
Name=Example Indicator
Type=Application

Conclusion

Lets clean up the notification area! To do this, we will need everyone’s help. If you maintain an application that could utilize the message indicator, please update it to support the indicator. If you aren’t a maintainer, but have an application you use regularly that could use the indicator and have the skills to create a patch, please do. Maintainers are usualy happy to receive patches, so patch something you care about and submit the patch. Let me also add, if you find bugs (or have suggestions for improvement) in the indicator APIs or the indicator itself, please file bugs in Launchpad.

About the Author

Ken VanDine is an Ubuntu Desktop Integration Engineer at Canonical. As a member of the GNOME Marketing team, Ken has written articles for the GNOME Journal (http://www.gnomejournal.org) and is now the maintainer of the GNOME LiveCD available at http://torrents.gnome.org and the GNOME Developer Kit available at http://live.gnome.org/GnomeDeveloperKit.

Discuss this story with other readers on the GNOME forums.

Letter From the Editor: GNOME 3.0

Join Jim Hodapp as he apologizes for the absence of GNOME Journal, describes his thoughts on the future of GNOME, and asks you, the readers, to start dreaming big for GNOME 3.0.

Let me be the first to say to you, the readers, it’s been a long time since the GNOME Journal has published any new issue and to let me formally apologize … sorry! With that out of the way, let me also welcome any active readers back to the brand new and highly reinvigorated GNOME Journal! As you all know, just like GNOME itself, GNOME Journal is entirely written by volunteers. Nobody gets paid a dime to work on it and so when the number of motivated writers approaches zero, GNOME Journal is very difficult to publish. If you like to write and would like to write a regular column about GNOME, its community, a certain GNOME application, etc., please don’t hesitate to volunteer. If you’d like to write an article once, we’ll gladly accept that as well.

Now on to the real topic for my article, the topic that has been a hot topic among the community blogs lately: GNOME 3.0. Just when you thought GNOME was doomed to forever increasing its 2.x release number, ad infinitum, a real glimmer of dreaming, design and actual working code has surfaced under the label of GNOME 3.0. In my opinion, I don’t care what it’s called, GNOME 2.30.0 or GNOME 3.0.0, it’s time to bring some excitement and re-energize the user base of GNOME with a fresh desktop experience in a sleek and modern looking way. This is not just about a new theme however. There are a lot of new technologies out there that need to be better integrated into an API that will encourage application writers to use. To accomplish this, GNOME needs an API that accomplishes a similar feat to what Cocoa does for Mac OS X programming. I believe that the GNOME project is in a unique position in the open source desktop space to bring the same experience as Cocoa, but in a completely open, and thus more effective manner than Cocoa could ever accomplish. Let me give some specifics examples as to what I am referring to.

Consistency is a large goal of the core GNOME API. This means that the general API needs to feel the same no matter if one is trying to install their application to automatically startup when a user’s session starts, or if one is trying to add a file dialogue to prompt a user to select a file to open. It doesn’t matter what one is doing, it needs to be named similarly, it needs to try and hide as much detail about how the desired functionality needs to work, and it should do this in a very modular way. The fact that the core of GNOME, gtk+ and obviously glib are written primarily in straight C can sometimes hinder this. It is amazing what can be done in an pseudo object-oriented fashion in C and the developers have done an excellent job in this, but I believe that libraries that most application writers for GNOME will use to write their applications need to be written in an object oriented programming language. My personal favorite is C++ since you get the powerful nature of true object oriented programming while still getting much faster speed when compared to a language that requires a underlying virtual machine like Java or C#. But this is a side issue; the language here doesn’t matter as much though as the underlying concept: modular, object oriented design is very important in graphical interface design. Object oriented programming lends itself very well to more naturally describing the data structures, hierarchical structure of a GUI, and reusable, modular nature of GUIs. Functional programming with advanced description capabilities of data types using structs in C only go so far. At some point, the C language reaches its limitations and the cost to benefit ratio swings largely in favor of a slightly higher level language. It might be time to consider writing some of the core GNOME APIs in a real object oriented language.

Apple was able to accomplish this through the use of Objective-C for the Cocoa API. Objective C is an advanced, object oriented programming language that accomplishes the two main things that I mentioned previously. First, it’s a fast system level language that doesn’t add too much overhead to the API calls. It still accomplishes what should be a core goal of any good core API design – speed and efficiency. Second, it gives the modern, rich descriptive nature that only a true object oriented language can give. I don’t believe that GNOME needs to necessarily use Objective-C for the core APIs (though it’d be a large improvement over using straight C), the point is it’s time to move on from C.

Another way that GNOME 3.0 should change is to completely rewrite what it means to be a desktop environment. Maybe the entire desktop need not be a desktop metaphor at all. The community has a lot of bright and creative people. I believe its time for the open source desktop community to bring the best minds together to create something completely new. The general interaction of using a mouse, keyboard, and in some circumstances, using ones hand through a touch screen, hasn’t changed in decades. Sure, some fancy 3D effects and such have been added, but the underlying metaphor has not changed. Maybe this isn’t possible in one large change. Maybe iterative design is the way to go. I hope I’m proven wrong.

Now that I’ve added a few of my opinions on some core things that I think need to shape GNOME 3.0, let me encourage you, the readers, to start dreaming. Like I mentioned in the previous paragraph, I believe now is a unique time in the history of GNOME to take it to the cutting edge of interface design. We need to take into consideration what the interface of a computer means today. Computers are used everywhere, from the average desktop machine used to do word processing, web surfing and email, to the more simple, but advanced interface of a touch screen mobile phone. GNOME is more than just a desktop, it is the interface from the human user to many pieces of cutting edge electronic technology. Let’s take GNOME beyond the simple desktop metaphor that the computer industry has been stuck in since the 1980s. I encourage all of the GNOME Journal readers who are interested to blog about their ideas for GNOME 3.0. After posting a blog entry, go ahead and post an email to the GNOME Journal mailing list with a link to the entry. Let’s get a large discussion going that dreams up what GNOME 3.0 can and should look like.

After posting to the mailing list, if you’re a programmer or you’ve been looking for an excuse to get into programming, I recommend this as the time to put your code where your mouth is. Experiment, starting with simple concepts of what you’d like to see for GNOME 3.0, moving to more complex implementations in an iterative way.

Dreaming and then shaping GNOME 3.0 by contributing ideas and code will not only improve the general GNOME desktop, but it also has the possibility to change the entire computing experience. I believe that if we can succeed in turning GNOME into something new and innovative, it will start to be used more and more by people who find it useful and exciting. As a final thought and as an example of this point, consider what happened to Firefox. It came out of the ashes of Netscape Navigator into something new, lightweight, innovative and useful. It now commands considerable world wide adoption and adoration. The same can happen to GNOME if we, as the core community behind GNOME, come together to design something amazing.

Discuss this story with other readers on the GNOME forums.

Behind the Scenes: Stormy Peters

Jayson Rowe interviews Stormy Peters, the Executive Director of the GNOME Foundation. Stormy discusses how she started in open source, her role in GNOME, her view of GNOME’s future and more.

Stormy Peters

Short Intro

  • Located in: Colorado
  • Profession: Executive Director of the GNOME Foundation
  • Nickname on IRC: stormy
  • Homepage and blog: http://stormyscorner.com
  • Twitter or identi.ca: twitter.com/storming

Interview

Could you tell us a little about yourself and your relationship with GNOME and Open Source in general?

I fell in love with computers at a young age because I loved what they could do. When we finally got a computer class, I was always getting the whole class in trouble because I’d turn my keyboard into a piano or my screen into a bunch of fun graphics. Luckily for me, the teachers always understood and built on that enthusiasm.

In college I was a bit frustrated that the whole class would write an operating system or the whole class would write a compiler. 20 operating systems! 50 compilers! Why didn’t we each write a different part and build something really cool? So when I discovered free and open source software (which had been around for a long time, unknown to me), I thought it was awesome.

At the time I was working in the Unix lab at HP where I managed the desktop team. In 1999 we were using CDE and it still had lots of bugs and it looked old. And here was this new thing called Linux and it had not one but several desktops and they did more than ours did. One thing led to another, and I ended up meeting with Ximian to talk about porting GNOME to HP-UX …

Could you tell us about your role as Executive Director of the GNOME Foundation?

My job is to support the GNOME project. (And the GNOME project’s goal is to provide a free and open source desktop for all. Although it should probably be said a free and open source platform for all, now that we have GNOME Mobile.) I see my job as having 5 major parts. One is being the eyes and ears for GNOME. Being someone the public or the industry can contact when they want to reach out to GNOME. Being the person the sponsor companies can contact when they have questions or ideas. Plus keeping up on opportunities for GNOME. Like with netbooks. The second is money. A major part of my job, at least in the beginning, is fundraising. This includes getting more corporate sponsors as well as raising the awareness around our individual donor program, Friends of GNOME. We want to do things in the future, like hire a system administrator, that take more consistent supplies of money. Which ties well into the third part of my job which is marketing. We want to make sure that people are aware of the good work we are doing so that they support us, join us, and enable us to do more good work. Business development would be the fourth area. Recognizing new opportunities for GNOME and making sure the right people are involved to make it happen. Lastly is what we’ve been calling “housekeeping”, just making sure the Foundation runs well day to day. That good ideas get executed on and that nothing gets dropped.

You have written on your blog recently about GNOME as the “Computing Platform” for the future. What does the GNOME desktop of the future look like too you?

The GNOME of the future will adapt to the way users of the future use their computer. You already see this with GNOME Mobile which runs on devices from smartphones to tablets to netbooks. The discussion that is happening now around the user experience for GNOME 3.0 is really interesting as it’s taking into account that users are using a lot of internet based applications and they think about their files differently than the traditional file system is set up to happen.

In a recent blog post, you wrote about GNOME and KDE working together. Could you elaborate on these collaborations and do you think collaborative efforts like this will help strengthen Open Source desktop systems as a whole?

GNOME and KDE have been working together on a number of fronts from technical projects like D-Bus to efforts like co-locating Akademy and GUADEC next year. I think these efforts will strenghen open source desktops. We’ll collaborate where it makes sense for our users and partners and differentiate where it makes sense to give our users choice.

The Free Software community seems to be a very much male dominated area. What can we do to encourage more women to become involved in the GNOME community, as well as Free Software as a whole?

I’ve found the GNOME project in particular very welcoming to women. I was greeted at my very first GUADEC with “you’re a girl!” GNOME has done some great things, like noticing that none of the GNOME Google Summer of Code applicants were women, so they set up an Outreach program targetted at women and gave them projects and mentors. I think GNOME has been very proactive in this area. I think the big change has to come at the elementary school level and I think as computers reach more people as smartphones and devices like netbooks and XO’s, we’ll reach younger and younger women, before they decide that they don’t want to be in computer science.

We all know that marketing is important for getting the GNOME project properly positioned in the community. Is the marketing strategy different for GNOME than it would be for a product controlled by a large corporation?

Absolutely. GNOME needs marketing to position itself in the industry, the community,the general public, and it’s users. However, in a traditional company, you could look at the roadmap for the next couple of years, figure out a campaign (primarily geared at selling product, making money) and then spend money to reach that group. GNOME’s goals are different – GNOME still wants market share but they give away the product. Marketing is about raising awareness of what’s available and why it’s cool that it’s free and open source software.

I did an interview about GNOME marketing that you can find here, http://www.initmarketing.tv/node/90.

What are some ways that the GNOME community can help with positioning GNOME in the Free/Open Source software community?

I think GNOME is pretty well known in the Free and Open Source Software community. Where we all need to continue to work is to raise awareness in the rest of the world. Show your parents, your friends, use Twitter … we all spend lots of time explaining the benefits of FOSS and GNOME and I think we need to continue. Explaining what it is, why the system works and why it’s good for individuals and society. Tell stories like the breast cancer scanner that uses open source software or the One Laptop per Child project or the schools in Extremadura or the Garmin GPS.

Do you think Cloud Computing and online media content such as micro-blogs and social networks will change the need for a desktop platform?

Absolutely. I think we need to move now to anticipate what people using cloud computing and online apps need from a desktop platform. For example, as netbooks and smartphones grow in popularity they will need desktop technologies that work well on those devices like GNOME Mobile. As they use social networking and online applications, they will need a lot of the new technologies we are building into GNOME 3.0.

Do have any specific goals for GNOME in 2009?

I think this is a question for the community. 🙂 GNOME 3.0 discussions are well underway with a roadmap, new technologies and new user interfaces. We also recently launched a new Friends of GNOME program that includes a monthly subscription to support GNOME. It’s been very successful – we’ve raised almost as much money in the first quarter of 2009 as we did in all of 2008! We hope the continued success of the program will enable us to do things like usability studies, hackfests, and maybe a sys admin if we raise enough. So spread the word!

On the GNOME Foundation side, we are seeing a lot of interest from new potential sponsors, especially in the mobile space.

Now that all of that GNOME stuff is out of the way, could you share a little about yourself personally, such as non-computing related hobbies, talents and passions?

My all time passion is learning, usually through reading. I read a couple of books a week, usually science fiction and nonfiction, and I go a bit crazy if I don’t find time to read! And as anybody who’s spent anytime with me knows, I love watching my kids learn and grow. At 8 and 2, they keep us busy and entertained!

My favorite vacation is sailing. It’s active, yet relaxing, and there’s always new places to be explored. And I really get away from the internet and work as there’s no power for the laptop!

Do you have any closing comments or thoughts you would like to share with our readers?

I’m really excited to be a part of the GNOME community. I want everyone to know I’m here to help the GNOME project and I’d love to meet them, hear their thoughts and ideas and help however I can.

About the author

Jayson Rowe is a Network Administrator from Darlington, SC. His primary interests are Desktop and Server virtualization, and in his spare time enjoys playing Guitar and composing music.

Discuss this story with other readers on the GNOME forums.

Cooking With Gourmet Recipe Manager

In this article, Sriram Ramkrishna takes a look at Gourmet Recipe Manager, a desktop application that creates and manages cooking recipes.

Introduction

Every once in awhile, I get to write about an application that is useful to people who want to use their computer for something other than the usual repertoire of tools that are geared towards social networking, technical graphics, video editing and so on.

Cooking is one of those primal activities that we do on a daily basis that can be as technical or as simple as we want it to be. Some use microwaveable products, and others like to get the raw ingredients and build from scratch. People take pleasure in the endless varieties and tastes that they can come up with. For the latter group, the Net offers an endless variety of cuisines from around the world waiting to be explored. We might even be inspired to make our own dishes or a personal twist on a favorite.

In the old days, we used to collect recipes from books, newspapers, magazines or from other people and write them down in a journal or notebook. My mother has a much abused notebook with hundreds of recipes that she had collected while part of a gourmet cooking group. Now of course we have plenty of websites like Epicurious and Allrecipes that have a plethora of recipes to try.

For the GNOME desktop users the choices are pretty limited on what is out there. In fact, you only have one. Gourmet Recipe Manager.

Gourmet Recipe Manager is, as you’ve guessed, an application written in Python that creates and manages recipes for you. I used the unstable version as I had conferred with the author earlier on a number of issues in the stable version and the author was kind enough to put out another release for my benefit. Most distributions package the stable version and I would recommend using the unstable/latest one.

Adding a Recipe

Installation was simple enough using the python dist tools and installing it in my distribution. Most people should be able to get it through their favorite package manager.

The main screen shows your list of recipes with a search bar that allows for a variety of search options including ingredients, category, cuisine, instructions and so forth with a method to narrow your search options in a fairly intuitive manner.

Let’s start by putting a recipe for “Spicy Peanuts”, a little something I make for an appetizer that goes pretty nicely with a good beer. It has simple enough ingredients to effectively try out the software.

File -> New puts up another dialog box to start publishing our recipe:

The first side tab allows you to type in a recipe description. This proves fairly innocuous allowing you to put the relevant information for the recipe which includes the source and web page you may have gotten it from along with a picture if possible.

The next tab is where you type in your recipe’s ingredients. In my opinion, it would be better if there was some kind of button in the screen to go to the next section in addition to the side tab. Side tabs are hard to notice for me and having an extra navigation point would give it a good sequential flow.

The ingredients tab is an impressive piece of work. You can type all kinds of ingredients in a near English language and Gourmet is able to parse it correctly into the right ingredients. For instance, if you typed in “half an onion” the amount will have 1/2 and “an onion” on the item column. The author has put a lot of attention on making this easy to add ingredients based on common everyday language.

If you make a mistake in anything you can click on the ingredient and edit it inline.

Once you have completed the ingredients, click on the instructions tab and type in your cooking instructions. There is a minimal editor allowing you to add some formatting to your text such as underline, bold and italics.

Throughout the editing process, you can view the recipe as a “recipe card” which will give you a view of your recipe nicely formatted on one page. The page also has an option to allow you to shop for your ingredients. It puts ingredients that you already have in a pantry section and then allows you to shop for the rest, after printing out the shopping list.

Once you’re done adding your recipe, you can save it and it will appear on the main recipe list that appeared when you first ran Gourmet.

Deleting a Recipe

Deleting a recipe was fairly easy with just hitting the delete key. Gourmet could use a good context menu in addition to going to the Actions menu or hitting the delete key. The recipe doesn’t actually get deleted but instead goes into a trash area so you can undo if you wanted to. To actually delete the recipe, you have to go to the trash area from the Tools menu. Gourmet will give you an option to undo immediately after the recipe was deleted or even to delete it permanently.

Miscellaneous

Gourmet has some other features including a plugin feature that lets you add an alternative way to browse recipes or give you the option to mail your recipes to others.

It would be difficult to hand type all the recipes you encounter on the web so Gourmet provides an import feature that allows you to automatically put your recipes into Gourmet from a variety of places. As of this writing importing a web page doesn’t work. Text files and the like are done by a dialog window that allows you to specify which parts of the file are ingredients, instructions, and so forth. Gourmet claims that it can import MealMaster recipes, but I had to manually add the parts instead of it parsing the areas correctly.

Conclusion

Gourmet Recipe Manager was written by someone who loves to cook and has crafted a fine application that can store a variety of recipes and organize them anyway you like. His attention to detail to the important things makes the application easy to use.

My list of improvements includes the following: this would make a great Maemo app, at least from a “I want to look up this receipe” while I’m thinking of something to make while in the kitchen. I could use a laptop as well but that’s just too big and clunky sitting on my kitchen table.

I’d like to see something in the description that allows the user to
describe something about the recipe. Maybe I have a story on how I obtained the recipe. A contextual menu would also be useful since I frequently want to do recipe operations by right-clicking on the recipe, rather than using the menu. A glaring omission is the lack of ability to rename a recipe. I had to delete the recipe in order to rename it.

Since social networking is all the rage having the ability to upload to Flickr (the picture) or perhaps to a cooking website to share with others would be a great addition. As there is a plugin system already in place, this could be a good project for someone to implement exporting recipes to these social sites.

All in all, Gourmet Recipe Manager is a good application and deserves a place on your desktop. Give it a shot!

About the Author

Sriram Ramkrishna has been involved in GNOME for the past 11 years. He resides in Portland, OR with his two wives and one cat. I mean two cats and his wife.

Discuss this story with other readers on the GNOME forums.