The First Milestone

btb-1

Picture Credits : Bob The Builder

Meet Bob, I am sure most of us remember him from ‘Bob the Builder’.

Bob the Builder and his machine team are ready to tackle any project.

- Renzo null

picked from IMDb

Getting to point - If you have developed using Gtk+ before and are acquainted with the widget system it provides, you know about the kind of digging and hauling it takes to build the UI using C code.)_ with each line as you move ahead.) (DOM) like interface for UI design and javascript like abilities to manipulate the DOM.

Developers : (Summon GtkBuilder) GtkBuilder !

#define BobTheBuilder GtkBuilder

GTK+ supports the separation of user-interface layout from your business logic, by using UI descriptions in an XML format that can be parsed by the GtkBuilder class.

The XML definitions can be generated by Glade, which is a drag-and-drop RAD tool which makes sure What You See Is What You Get (WYSIWYG).

Nautilus Properties Window : Porting to GtkBuilder

GtkDialog vs GtkWindow ?

Dialog boxes are a convenient way to prompt the user for a small amount of input, e.), and is where widgets such as a GtkLabel or a GtkEntry should be packed.

GtkWindow is a toplevel window which can contain other widgets.).

rhel6_filesystem_properties-2 Old Implementation of the Properties Window.

naut-naut-2 Current Implementation of the properties Window.

So now we know that the only reason the properties window is still a GtkDialog is because that is where it’s History has lead it to.

Thanks @alexm for the idea !

Commit cb706825 preserves the current behaviour of properties window and makes it Inherit GtkWindow instead of GtkDialog.

UI Building

Here Comes the part where Bob’s (_aka.) gonna take charge of the applications UI building and rids the code base of some huge complex thickets of UI building code.

We often find ourselves creating controller object classes when we realize that Objects offered natively do not satisfy our specific tailored needs.

cmp

gtk_widget_class_bind_template_child() binds pointers in class with widgets in the UI definition

GtkBuilder supports the use of templates, where the Class Name of the toplevel container is set same as the corresponding Controller Class name in C code.

Commits 4d312be1 and 18cfadc8 Obtain the Toplevel Container GtkWindow, GtkNotebook and Basic Page Containers from the template.

Icon Widget and Name Field Widget:

destroy_dance Name Field is a GtkEntryIcon Widget is a GtkButton

destroy_dance_2 Name Field is a GtkLabelIcon Widget is a GtkImage

So what do you do when you have two widgets which are possible candidates for a given place holder in the UI.

Traditional approach calls for what (@antoniof) calls the gtk_widget_destroy() dance where the business logic determines which kind of Widget is required and packs it into the container.).

Contemporary approach with the use of GtkBuilder provides us with GtkStack which is a widget capable of containing more than one GtkWidget as its children, and makes one of these visible with gtk_stack_set_visible_child().

Commits 2af7f424 and b41d44d1 Obtain Icon Widget and Name Row from template.

Rest of the Rows

grid-4

grid-one

grid-3

grid-box-1 It can be noticed that there is a different set of rows displayed based on the type of file selection the properties window is launched for! It’s also notice-able that each row is a combination of GtkLabel : GtkLabel, all title:value pairs!

Handling Conditional Rows : Each and every widget which could ever find itself in the UI is defined in nautilus-properties-window.) and gtk_widget_hide() on the widgets which are supposed to be shown and hidden accordingly.

Generating each row : The existing code achieves it with the help of an over-engineered hierarchy of function calls, it requsting appednd_title_and_ellipsizing_value() for a row of particular kind which is constructed in the calls which follow that.

func_heir-1 function call chain which generates one row of the basic page grid

While the above mechanism can be conveniently used to generate rows but anything which has to do with debugging this mechanism or imagining the UI structure anywhere midway in the function calls is very difficult, and messed up.

boa-shell credits : UNIX and Linux System Administration Handbook (Nemeth, Snyder, Hein, Whaley)

Easier Solution : An easier solution is to define each and every Row GtkLabel pair in the XML definition and obtaining its reference in the NautilusPropertiesWindow struct members.

Commit 08fbb49b obtains all the rows og the basic grid from template and gets rid of the complex row generating mechanism present currently.

And this is the progress till now ! This was long post : p !