Monday, August 27, 2007

Amarok can't play mp3 files

My favorite linux player, Amarok, stopped working (playing mp3 files) after an upgrade! It kept on complaining that the xine engine was not able to play mp3 files. I had checked and all the right packages seemed to have been installed.

However, I found the solution here, you need to install libxine1-plugins package (together with its dependences) and everything comes back to life :-)

Eclipse Fonts in Linux (part 2)

In this previous post, I said I had found a way to adjust the eclipse fonts (that are gtk fonts) in KDE. That was a right solution, but unfortunately, it does no survive logouts from KDE. Each time you should re-run the gnome configuration program.

However, that's an even nicer solution: install the package gtk-qt-engine:


The GTK-Qt Theme Engine is a plugin for GTK that allows GTK applications to use Qt widget styles. Aimed primarily at KDE users, this plugin provides a way to unify the look and feel of the Linux desktop.

this will add the additional menu in the KDE Control Center - Appearance and Themes that will do the trick! Now Eclipse, Firefox and Thunderbird look very nice with the same KDE style.

Saturday, August 25, 2007

Eclipse Fonts in Linux

As you might have guessed I'm using Linux most of the times (Windows only seldom), but I noticed that the Eclipse font layout looked better in Windows: actually, the Eclipse font size in Windows permits fitting much more information in a view. This is even more crucial when I'm using my laptop with a resolution of 1280x800.

Of course, I had tried to adjust the font size using the Eclipse Preferences, and actually managed to reduce the size of the editors and view titles (also for dialogs), but not other fonts, such as menu fonts, and, more importantly, the size of tables and trees (e.g., the Java Package Explorer). That's actually due to the fact that under Linux Eclipse relies on Gtk, and thus inherits the preferences of the Gnome Desktop but I'm using KDE :-)

Fortunately, it's quite easy to adjust Gnome font settings even from KDE, by running gnome-control-center from the command line and then set the font size from there. Now, my eclipse shows much more information due to the reduced font size.

And by the way, this reduced the fonts also for other Gtk based applications I'm using, e.g., Thunderbird and Firefox!

Saturday, August 04, 2007

GNU Gengetopt 2.21

It wasn't long ago since I released version 2.20 of GNU Gengetopt, and here's a new version.

First of all, I switched to version 3 of GPL.

Another novelty is that gengetopt generates doxygen comments in the generated header files. This way, if you use doxygen on your sources, you'll find also the documentation of the code generated by gengetopt.

Some build issues were fixed: parallel makes work again, and the make files do not depend on GNU make specific features (such as %. rules which are not standard - I must admit I didn't know this, but the new version of automake I started to use, i.e., version 1.10, reports a warning when you use such rules in your Makefile.am files, so I got to know about the problem).

Furthermore, the signatures of generated parser functions changed in a crucial way (of course, the previous signatures are still available, but they are deprecated and possibly removed in the future). In particular, besides the default parser functions (i.e., with default options), other versions are generated that accept further options, such as, e.g., initialize the argument structure, perform required options checks, etc. In the previous versions, this additional signature, whose name was the same as the main parser function with a 2 in the end, used to accept these options as single boolean (actually, integers) parameters. There's nothing wrong with this approach but it does not scale to future enhancements of the signature. In fact, a user requested another option (see the list of changes below) and adding that parameter to the signature would break existing code when regenerating the parser functions, since the code using those functions must be manually modified in order to use the new signature (in C++ this might be a small problem thanks to default values for parameters, but in C...). For this reason, the options are passed to the parser function in the shape of a structure: adding a field in the structure will not break existing code since the signature of the parser functions does not change. Notice that the structure object for these options should not be manually created and initialized (again, if a new field is added in future versions, that field might stay uninitialized), but it should be created and initialized by calling the dedicated generated init function. Here's a snippet of the generated header file (notice the new structure, the new signature with the _ext at the end, the deprecated old signature, and the init function for options):

/** @brief The additional parameters to pass to parser functions */
struct cmdline_parser_params
{
int override; /**< @brief whether to override possibly already present options (default 0) */
int initialize; /**< @brief whether to initialize the option structure gengetopt_args_info (default 0) */
int check_required; /**< @brief whether to check that all required options were provided (default 0) */
int check_ambiguity; /**< @brief whether to check for options already specified in the option structure gengetopt_args_info (default 0) */
} ;

/**
* The command line parser
* @param argc the number of command line options
* @param argv the command line options
* @param args_info the structure where option information will be stored
* @return 0 if everything went fine, NON 0 if an error took place
*/
int cmdline_parser (int argc, char * const *argv,
struct gengetopt_args_info *args_info);

/**
* The command line parser (version with additional parameters - deprecated)
* @param argc the number of command line options
* @param argv the command line options
* @param args_info the structure where option information will be stored
* @param override whether to override possibly already present options
* @param initialize whether to initialize the option structure my_args_info
* @param check_required whether to check that all required options were provided
* @return 0 if everything went fine, NON 0 if an error took place
* @deprecated use cmdline_parser_ext() instead
*/
int cmdline_parser2 (int argc, char * const *argv,
struct gengetopt_args_info *args_info,
int override, int initialize, int check_required);

/**
* The command line parser (version with additional parameters)
* @param argc the number of command line options
* @param argv the command line options
* @param args_info the structure where option information will be stored
* @param params additional parameters for the parser
* @return 0 if everything went fine, NON 0 if an error took place
*/
int cmdline_parser_ext (int argc, char * const *argv,
struct gengetopt_args_info *args_info,
struct cmdline_parser_params *params);

/**
* Allocates dynamically a cmdline_parser_params structure and initializes
* all its fields to 0
* @return the initialized cmdline_parser_params structure
*/
struct cmdline_parser_params *cmdline_parser_params_init();

Finally, here's the complete list of the new features:

* a structure for parser function parameters (that might be extended
in future versions)
* a parser parameter to check whether an option that is parsed is
already present in the args_info struct (suggested by
Yegor Yefremov)
* the generated files contain doxygen documentation (suggested by
Yegor Yefremov)
* parallel make works
* generated make files should not depend on GNU make
* fixed a bug with multiple options with back slashes (thanks to
Peter Kovacs)
* updated to version 3 of GPL

Friday, August 03, 2007

"Last Modified" in PHP

This is nothing exciting, but I just wanted to share :-)

If you want to put in your php web page the well known "Last Modified: " you can simply put this code:

<?php
echo "<b>Last modified:</b> " .
date( "F d, Y. H:i:s a", filemtime("YOUR FILENAME") );
?>

where, of course, you must substitute YOUR FILENAME with the filename of your web page.

That's it!