Upgrade time!

Welcome to the latest WordPress.

Posted in Uncategorized | 1 Comment

Glade Catalog Tutorial

For some time now Glade allows to add custom widgets and objects to an interface file by making a catalog. Many people are asking how exactly it can be done. I did not see any hands on guide, step by step howto, or just any plain example of a custom widget catalog yet. Recently I’ve found some spare hours to play with Glade and experiment with the feature. It happens to be not that hard after all, and I decided it would be beneficial to share the experience by writing this little tutorial.

Before anything I must note that sometimes all you need is to “fake” a class in the catalog. To get an idea you can read a little post in the blog of one of the Glade developers. It provides you a tiny example of a catalog. In general though, you need to build a shared library containing all your classes to make them available to Glade at the run time. Let’s take as an example the clock face widget from the ancient Gnome Journal February 16, 2006 issue and try add it to a Glade file. The sources ain’t clearly marked with any license, but I’m sure the author wouldn’t mind.

The first step is to make a working directory, download the files, give the sources appropriate names, and see if all of this works together:

mkdir eggclock
cd eggclock
wget http://www.gnome.org/~davyd/gnome-journal-cairo-article/clock-ex5.c
wget http://www.gnome.org/~davyd/gnome-journal-cairo-article/clock-ex5.h
wget http://www.gnome.org/~davyd/gnome-journal-cairo-article/main-ex5.c
wget http://www.gnome.org/~davyd/gnome-journal-cairo-article/clock-marshallers.list
wget http://www.gnome.org/~davyd/gnome-journal-cairo-article/Makefile
mv clock-ex5.c clock.c
mv clock-ex5.h clock.h
mv main-ex5.c main.c
make

I took the freedom to put it all in a single archive to ease your pain of going through the above steps. Assuming you have all appropriate development libraries installed you should have a working application now, and can run it in usual manner:

./clock

The second step is to modify the Makefile to create a shared library. The widget is named EggClockFace for a reason unclear to me, but whatever this “egg” stands for it is a namespace, so let’s give the library unsophisticated name libegg.so and replace the single rule for making executable with something like this:

clock: main.o libegg.so
gcc -g -rdynamic -o clock `pkg-config --libs gtk+-2.0` $^
main.o: main.c clock.h
gcc -g -c `pkg-config --cflags gtk+-2.0` $<
libegg.so: clock.o clock-marshallers.o
gcc -g -shared -o libegg.so `pkg-config --libs gtk+-2.0` $^
clock.o: clock.c clock.h clock-marshallers.h
gcc -fpic -g -c `pkg-config --cflags gtk+-2.0` $<
clock-marshallers.o: clock-marshallers.c
gcc -fpic -g -c `pkg-config --cflags gtk+-2.0` $<

Don’t forget that all command lines should start with a tab. Actually you should give your library proper soname, install it in in a proper location, and all that stuff, but I’m leaving that for you as an exercise. For the tutorial purposes this quick and dirty approach would do just fine, and it is sufficient to start the application setting the working directory as the library path directly from the command line:

LD_LIBRARY_PATH=. ./clock

The third step is to create the catalog file as simple as this:

<?xml version="1.0" encoding="UTF-8"?>
<glade-catalog name="egg" library="libegg.so" depends="gtk+">

<glade-widget-classes>
<glade-widget-class name="EggClockFace" generic-name="clockface" title="Clock Face" />
</glade-widget-classes>
<glade-widget-group name="egg-widgets" title="Egg Widgets">
<glade-widget-class-ref name="EggClockFace"/>
</glade-widget-group>
</glade-catalog>

Save it again in the working directory and invoke Glade in this manner:

GLADE_CATALOG_PATH=. GLADE_MODULE_PATH=. glade-3

Now you should see “Egg Widgets” group in the palette and a little iconless button under it. That would be our clock face widget. Create a top level window and put it in there:

Custom widget in Glade

All that is left for the final step is to is to save this file and modify the main.c to make use of it. Let’s set the “visible” property for the window to true, set gtk_main_quit as its “delete-event” handler and time_changed_cb as the handler for the clock face “time-changed” signal, give it a simple name clock.ui and replace the code of the main function in the main.c with the following:

GtkBuilder *builder;
gtk_init (&argc, &argv);
builder = gtk_builder_new ();
gtk_builder_add_from_file (builder, "clock.ui", NULL);
gtk_builder_connect_signals (builder, NULL);
g_object_unref (builder);
gtk_main ();
return 0;

Also you’d need to remove “static” from time_changed_cb definition, so GtkBuilder would be able to find the handler. And that’s about it. Now you’re ready to clutter your user interface with multitude of random clocks in all sizes and alignments, and all of them going to be ticking right inside the Glade window. In case you need to see complete sources, just download and extract the final archive.

As you can see, you have to do very little to make your own Glade catalog, so start hacking, file any bugs you have found, and by all means share your work. Feel free to ask any questions on the mailing list, but read the documentation first. Mind though, that with general programming questions you probably would be better off at GTK forums. Any comments regarding this tutorial are also appreciated.

Posted in Linux, Programming | Tagged , | 3 Comments

Spot Light

Pinky…

Spot Light

Spot Light

Posted in Photo | Tagged | Leave a comment

Still Life

That’s how I used to live.

Mess

Mess

I still do live something like that in a different sense. Maybe not much different – you can’t really change the way you live.

By the way, everything in the picture makes perfect sense and belongs wherever it seems to be dumped for one reason or another. I can tell stories about most of the subjects in there. The problem is, do you really want to make any sense out of this mess?

Ah, and by the way again, I’m thinking to rename the category to a “picture of the year” (looking at the pace I’m posting, not at the quality).On the other hand the “picture of the moment” would do as well… but isn’t every picture is a picture of the moment??? I guess I’ll leave it as is.

Posted in Photo | Tagged | Leave a comment

Who the Hell is a Hacker?

I am a hacker. I do like this word. It is neat and sharp. Unfortunately general population understanding of the word is distorted. The narrow meaning of it, as it is commonly used and promoted by the media, describes a person who breaks into other people’s computers. I am nothing like that.

I am a programmer. Some of our kin claim that it is original and the only true meaning of the word hacker. To distinguish the “true hacker” from evil computer intruders they propose to call these wrongdoers “crackers” or something funny like that. I do not support that opinion. These computer security freaks, as evil as they are, can be considered hackers too.

It is like if the word “knife” would be almost exclusively used by public to describe a weapon. Now cooks and chiefs, frustrated by association with bloody murderers, would argue that the proper name for the weapon should be “dagger”. That neither would solve the problem, nor it is true. Knife is a knife and its purpose is to cut things, regardless of what these things are.

So, who the hell is a hacker? Hacker is obviously a person who does hacks. That is the root of all confusion. Average people are simply unaware of the very existence of this noun. The term hack can be defined as a crafty solution to a technical obstacle. Hacker is just a person who is willing to fiddle with things where other people would just give up and turn to other ways.

I would even argue that not all programmers can be considered hackers. Some programmers if not most of them are just that – skilled professionals. Hacking opportunities for a programmer in the closed source world are extremely limited. When some program does not do whatever you want it to do, your only option most of the time is to write another one from scratch. That may be a solution, but hardly a hack, regardless of how much better the new program is. Until you open the source code very little if any hacking is possible.

So to speak, when language is distorted, it leads to misunderstanding. Misunderstanding leads to frustration. Frustration leads to anger. Anger, as we all know, leads to dead kittens. When I use the word hacker and people are thinking about some criminal, it is very frustrating. My point is, however, all attempts to redefine things represent direct path to dead kittens. I am trying to educate people whenever possible instead, one at a time. I do not believe it would change overall situation one day. I just like to make things right at least around myself.

Posted in Programming | Leave a comment

Fedora 10 nvidia again

So, I have upgraded to Fedora 10. At first it worked fine, but after last week’s update to a new snapshot of nouveau it chose to ignore my dual head setup. The second monitor works but only as a clone, no matter what. Hence I’m back to the evil kmod-nvidia. I’ve tried to enable desktop effects only to find out that it is even less stable now. After reboot the window decorations were gone. Disabling desktop effects restores everything to normal, but after that it can’t even enable desktop effects any more.

I also forced to use proprietary driver on my IBM laptop for similar reason. It has ati video card though and runs Ubuntu. The free driver runs fine there until I need to use s-video out. It does turn it on and extends desktop onto it, but when I try to play any video it just shows black framebuffer. Proprietary driver is much less convenient. I have not found a way to turn s-video on on demand other than restarting X. Then it detects load and clones display. I’m not sure if there’s a way span it to a separate desktop either. But it works for the purpose. As I have to relogin anyway, I’ve created a separate user with appropriate screen resolution to watch video. I did not try to connect a separate display though. Maybe that would be pain in the arse.

The only device which works without evil proprietary video drivers is my IBM tablet. That is because it has intel video card. But it is too tiny to my taste for everyday use. I just take it with me when I travel.

Posted in Linux, System Administration | 1 Comment

Fedora 9 nvidia Disaster Relief

Only brave or stupid people (some think this are the synonyms) upgrade on the day of release. It was not even 24 hours since Fedora 9 became available to the general public, and I already had started installation. It took ten minutes to check the media, and another ten to make necessary preparations (whatever it is, I just clicked “next” and stared at various messages). Next half an hour the system was busy installing some 1103 packages and ten more minutes “finishing upgrade process”…

Now fun began. Nvidia driver was not found on boot and cups failed to start. I was presented with somewhat ugly login screen. In comparison to previous version it looks like severe downgrade. On login nothing was right, and the task bar contained two untitled windows, although none of them were visible on screen, and nothing could be done about them. First I tried to open network configuration to change DNS IP. Our DHCP server keeps sending me the wrong one, and it impacts performance of every internet related task. I rather should ask for static IP than do it every reboot, but always postpone it. Anyway – no luck. No window opened.

At this time security updates arrived for cups, libid3tag, bugzilla, and cups-libs. Closer examination also revealed existence of 12 bug fixes, 3 enhancements, and 199 updates. Every try to apply these either resulted with no reaction, or gave me very informative error message: “Failed to update system. The error was: org.freedesktop.packagekit.update-system auth_admin_keep_always”.

Fortunately I was able to open a terminal window, although it contained no window decorations and was immovable sitting at the top left corner of the first screen. The second screen was annoingly blinking. Yes, I had had dual head display with nicely configured compiz on top of nvidia driver just couple of hours ago… Now I had disaster.

Yum update. It wanted to install 15 and update 216 packages totalling 246M. That is paradox. What is the purpose of downloading ISO image, burning it to DVD, and installing from the media, when you immediately have to download half of your system (assuming most of the packages from DVD you do not even need) again and reinstall it all over? Something like apt-get dist-upgrade is much more sane. I know it is also possible to upgrade with yum. I did so last time, because installation DVD was obviously going into infinite loop checking dependencies. But that practice for some reason discouraged: “Although upgrades with yum have been tested and work, live upgrades are not recommended by the Fedora Project” (Yum Upgrade FAQ).

Anyway, I started update and noticed that terminal window is not on the task bar. The task bar was still occupied with two ghost windows, otherwise empty. After some random clicking around, the mouse cursor turned to a crossed arrows, as if I was dragging something, and desktop stopped responding at all. The clock applet also stopped updating, although network applets were showing traffic, and yum kept downloading updates. At this point I got it, that better not touch anything at all.

After an hour of downloading and ten minutes of installing, yum was done. Nothing except mouse cursor was responding to me at that time. Fortunately I was able to switch to a console with Ctrl+Alt+F1 and ordered shutdown -r now. Update fixed cups, and restored window decorations on terminal window, but otherwise did not help much. I still was unable to get most of the graphical programs running, so I rebooted into Live CD and tried to google the way to restore nvidia. The shocking truth was: THERE IS NO NVIDIA DRIVER FOR FEDORA 9!!! Time to throw yourself out of the window (switch to Vista?).

Reboot, rename broken /etc/X11/xorg.conf, yum erase useless kmod-nvidia, turn off blinking second monitor, back to nv. What now? Downgrade X.org and use old driver? It will break to much shit. Downgrade back to Fedora 8? It is too much work.  Wait until nvidia will come up with new driver? But I can’t effectively work without second monitor. I’m screwed… No, wait, what about these nouveau people? I heard a year ago that that driver is in Fedora 7 already. Is not it the time to try it out?

System > Administration > Display. At “Hardware” tab change video card to use nouveau. Works, but no different from nv. Inside the new xorg.conf in the section “Device” add the Option “Randr12” “on”. Wow, the second monitor came to life, but only as a clone. That is not useful to me. Now copy Monitor section from old xorg.conf and paste it into the new one twice, changing identifiers to “DVI-D-0” and “DVI-D-1” respectively, and adding Option “RightOf” “DVI-D-0” to the second one. And Bingo! I am saved!!!

So it seems to be working and I can do my job. I lost compiz, but hey, that’s just an eye candy. It’s cool and useful, but essentially it’s a luxury. I can live without it, at least for some time, until nouveau will come up with stable 3D rendering. Nvidia two thumbs down for being outdated proprietary evil. Fedora one thumb down for not putting in release notes “Nvidia users STOP! Do not upgrade now!”, and one thumb up for hard work. Nouveau two thumbs up for heroic efforts.

I realize that I’m probably just being lucky that my card (NV44 [Quadro NVS 285]) is already supported. Maybe I’ll face problems later on, here or there, but at least I’ll be able to file a bug report, and even participate in resolving it.

Posted in Linux, System Administration | 8 Comments

Bugzilla on Fedora 8

My boss asked me to install Bugzilla on our local server. The task happened to be relatively easy, however Bugzilla needs functioning mail server to be anyhow useful. I tried my SMTP server, but it did not work very well, probably because of our firewall which I have no control of. Sendmail is not functioning too, maybe for the same reason, and I have no clue how to troubleshot that animal. Anyway, mail servers are currently beyond my means, but I find it useful to document basic Bugzilla setup for historical purposes.

First of all I needed functioning web server. Apache already was there, so the only thing I had to do was starting the service:
# /sbin/service httpd start

It was immediately accessible at http://localhost.

Next step was to install MySQL server, since Bugzilla needs one. That went smoothly. The guide I googled up (do not remember which one exactly) instructed first off to secure MySQL with following commands:

$ mysql -u root mysql
mysql> UPDATE user SET password = password('FryWucThyft4') WHERE user = 'root';
mysql> FLUSH PRIVILEGES;

where “FryWucThyft4” is some random password for database root account. To test it, disable anonymous user, and set up bugzilla user with password “WocEfcic5”:

$ mysql -u root -p mysql
mysql> DELETE FROM user WHERE user = '';
mysql> GRANT SELECT, INSERT, UPDATE, DELETE, INDEX, ALTER, CREATE, LOCK TABLES, CREATE TEMPORARY TABLES, DROP, REFERENCES ON bugs.* TO bugs@localhost IDENTIFIED BY 'WocEfcic5';
mysql> FLUSH PRIVILEGES;

After that I’ve edited /etc/my.cnf to add this random stuff:

[mysqld]
# Prevent network access to MySQL.
skip-networking
# Allow packets up to 1M
max_allowed_packet=1M
# Allow small words in full-text indexes
ft_min_word_len=2

At that point I’ve installed Bugzilla per se. When it was there I’ve changed configuration file to accommodate for new fancy password in /etc/bugzilla/localconfig. The variable of interest was $db_pass. When it was done, I was ready to create the database:

# /usr/share/bugzilla/checksetup.pl

It asked to set up administrator email, real name, and password. When the database was created I followed advise to allow the table to grow to 20GB (it is said to be 4GB by default):

$ mysql -u bugs -p
mysql> use bugs
mysql> ALTER TABLE attachments AVG_ROW_LENGTH=1000000, MAX_ROWS=20000;

Finally I had to make bugzilla accessible from our web server, so I made a link in web server’s root:

# ln -s /usr/share/bugzilla/ /var/www/html/bugzilla

and adjusted directory settings in /etc/httpd/conf/httpd.conf to be:

AddHandler cgi-script .cgi
Options +Indexes +ExecCGI +FollowSymLinks
DirectoryIndex index.cgi
AllowOverride Limit

After I’ve restarted the web server to read new configuration:

# /sbin/service httpd restart

new shiny Bugzilla was at http://localhost/bugzilla/.

After first login it asks to change parameters: maintainer, urlbase, cookiepath, utf8, requirelogin, createemailregexp, and mail delivery method. The last one is the problem…

Posted in Linux, Programming, System Administration | Tagged | 3 Comments

Human Rights

You have a right to remain silent…

Posted in Uncategorized | Tagged | Leave a comment

Stump Online

Stump Online

Stump Online

Read no further.

Posted in Photo | Tagged | Comments Off on Stump Online