Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Looking for advice on how to develop applets for Gnome / Ubuntu

I am a linux (mostly ubuntu) user with a reasonable understanding of how the system works (although I am certainly not a linux guru!). In the past I have developed small cross-platform desktop applications in python/GTK and I delivered them to clients as self-contained filetrees, so that the only dependencies were Python itself and GTK.

Now I would like to develop a small applet for ubuntu, that I would like to release under GPL 2 or 3.

In particular these are the new steps I know I must learn in order to achieve my goal (it is very possible there are a few more that I am unaware of, though!):

  • Integrating with gnome: I want my application to be available as an applet in the taskbar.
  • Using D-bus: In particular I want my applet to use the new osd-notification framework for ubuntu, but communication with other applets is also a possible feature for a second iteration.
  • Packaging: I would like to setup a public PPA as soon as the application will reach alpha stage, but I also would like to use dependencies from existing packages in the official repos, rather than include the libraries again in my own package.

Of course official documentation will be my first source of knowledge, but - basing my judgment on the very useful answers that I received on another topic here on SO - I decided to turn to the SO community to collect additional advice like for example:

  1. Are there additional steps to those I outlined before, that I have to learn in order to be able to implement my project?
  2. Based on your own experience, would you advise me to learn those steps in advance (as the knowledge of those will influence my way of coding the core functionality) or would you consider integration with gnome / d-bus and packaging as "higher encapsulating levels" that can be added on top of core functionality afterwards (note: D-bus will be used at first just for pushing data. Input data will be retrieved with a webservice)?
  3. Would you advise me to separate my application in two packages (back-end and front-end) or to keep it together in a single package?,
  4. Do you know of any useful resource that you would advise me to look at, for learning any of the things that I have to?
  5. Are you aware of any common "beginner's mistakes" that I should be aware of?

These questions are not meant to be exhaustive, though: if you feel that I am missing something from the general picture, you are more than welcomed to point me in the right direction!

PS: Should I have failed in explaining my final goal, take a look at project hamster: what I want to achieve is similar in terms of user interface (meaning: the applet should display the status and clicking on it should open the application itself, from which you could both configure the applet and perform various operations).

like image 424
mac Avatar asked Dec 02 '09 10:12

mac


2 Answers

Well, you list python, so you'll want to have pynotify in your arsenal. It wraps DBus, and gives you a direct api for manipulating the osd-notification system.

>>> import pynotify
>>> pynotify.init("Lil' Applet")
True
>>> note = pynotify.Notification(
...            pynotify.get_app_name(), 
...            "Lil' Applet wants you to know something's up.", 
...            "/usr/share/icons/Human/48x48/status/dialog-information.png")
>>> note.show()
True

This displays a notification that looks like this:

[    ] **Lil' Applet**
[ICON]
[    ] Lil' Applet wants you to know something's up.
like image 97
jcdyer Avatar answered Nov 11 '22 16:11

jcdyer


As you already know, your first and best friend will be the code written by others - copy, paste, dissect, understand. Luckily there are a few projects that do what you intend to achieve. I can recommend conduit's code as a prime reference how to do things in a clean fashion. I think they also have stuff on dbus. Others to keep an eye on, would be deskbar-applet, hamster (heh), and any other app you remember having feature X. Sometimes it might require some C code deciphering though (like the applet button bit - i suggest you better take it from hamster as i was having some major time getting the thing straight)

Then the "devhelp" app will be of great assistance - it allows you to read and search in man pages fast and easy. Make sure that you also have the -doc packages for all the modules you intend to use. For user interface i strongly suggest using glade, as that will allow you to change interface later much easier. Where you can't use glade - add and alignment box and add the widget in the box in the code. There certainly will be quirks and things that you will learn the hard way. Should not be too hard though!

The packaging, especially the autotools will be bit of a struggle, but you will get it right. For how to do debians (and from there to PPA), you can dig in the hamster's repository history. There was once a "debian" folder.

I would suggest to start small - see if you can get a window. Then put a button on it. You don't have to do it "right" the first time. For first time it will be ok, if something works at all.

As for the separation - i would not bother about it until you get there. Splitting up into two parts and have a core, should not be too hard later. But that all depends on your priorities.

Last thing - getting friends who know the field helps too. And one way to get new friends, is by taking part in other projects, heh.

like image 3
tm_lv Avatar answered Nov 11 '22 16:11

tm_lv