Saturday, February 12, 2011

Customizing GNOME screensaver's lock dialog

Using bleeding edge Linux there are absolutely no guarantees that something doesn't go wrong. Several days ago I updated my Debian GNU/Linux "Testing" [branch] installation in the way I usually do using aptitude upgrade. Some things got broken some didn't. After this update I found that appearance of GNOME screensaver's lock dialog had changed: it became collapsed in it's total width. So, how to return the dialog's previous appearance and geometry back?

Google says nothing regarding this issue. But nothing tells us that it is impossible to solve it out:
  • GNOME Screensaver's lock dialog appearance is not "hardcoded" to the executable binary;
  • The dialog's appearance is built up before showing to the user from Glade's UI file located in /usr/share/gnome-screensaver directory; the default one is called lock-dialog-default.ui.
  • There could be several different .ui files:
    • The text between "lock-dilalog-" and ".ui" in the file's name called "name of the dialog's theme";
    • Switching between available themes of GNOME Screensaver's lock dialog is made using /apps/gnome-screensaver/lock_dialog_theme key in gconf.
Glade UI file is an ordinary XML file which describes declaratively the appearance and layout of some dialogs or widgets shown to the end-user. This one looks like:

<?xml version="1.0"?>
<!--*- mode: xml -*-->
<interface>
      <object class="GtkFrame" id="lock-dialog">
        <property name="visible">True</property>
        <property name="label_xalign">0</property>
        <property name="label_yalign">0.5</property>
        <property name="shadow_type">GTK_SHADOW_OUT</property>
        <child>
          ...
          <object class="GtkAlignment" id="alignment1">
          ...
        </child>
        <child>
          <placeholder/>
        </child>
      </object>
</interface>

So having known these things now it is possible for us to fix the original problem out:
  1. Make a copy of lock-dialog-default.ui to the same dir; name it, say, lock-dialog-extended-default.ui; the next step is made with the newly copied file;
  2. Add a new property called width_request to GtkFrame object with ID lock-dialog; the value must be set to the number of preferred pixels;
  3. Set /apps/gnome-screensaver/lock_dialog_theme value to extended-default since we have created a new dialog's theme.
Gotcha! The dialog looks in the way we like it now.

And some related remarks:
  1. Actually it is not a hack way; it is absolutely official one;
  2. It is possible to use any text editor to extend UI file as well as to use Glade application (usually it is not included to the default system's installation) for such purposes;
  3. There are already "ready-to-use" themes for GNOME screensaver's lock dialog. Just google for "GNOME screensaver lock dialog theme" and you may find something out you really like.

No comments:

Post a Comment