Scribus Tables GSoC — First Steps

Hi all,
This is the first in a series of blog posts detailing my work with bringing proper support for tables to Scribus as part of Summer of Code 2011. I’ll try to keep the posts in roughly the same format as the reports I’m sending off to my mentor Craig each week. This will make it easier for me to reuse some of the material, saving hacking time :) Each post will be divided into the following sections:

  • Work Report, a report on what I’ve been up to since my last report.
  • Project Status, how I’m standing with regard to the schedule in my project proposal.
  • Upcoming Work, a rough outline of my next steps.

As this is the very first blog post about my project, I’ll start with a little introduction with general information about my project.

Introduction

Tables provide a compact way of representing tabular information in a page layout, and is a common design element in books, magazines and advertisements. Scribus currently has a shortcut for creating an automatically grouped table-like array of text frames. These are not proper tables. To stay competitive, Scribus needs better support for tables. Support that enables the user to create and edit tables as distinct items with their own set of properties as commonly found in other table implementations. This is the rationale for my Summer of Code project, in which I’ll add a new table page item to Scribus.

First glimpse of new tables

First glimpse of new tables

The user should be able to perform common table operations such as inserting rows and columns, merging and splitting cells, formatting borders and backgrounds as well as editing the text of the table. The table will represent the text of the cells using standard Scribus text frames.

More information can be found in my project proposal.

So without further ado, here follows my first report.

Work Report

  • Bootstrapping: Drafted an initial design document including some mockups on the Scribus wiki and discussed the ideas in detail on the scribus-dev mailing list. Also set up a development environment (using Qt Creator this time even though I’m a die-hard Vim junkie).
  • Added a skeleton of a table style. This was way back in April, just to see what work is involved in creating a new type of style. The style is the most basic one imaginable. At the moment I think it has a single property for background color. Instances of the new table style can be managed in the Style Manager. It doesn’t do style inheritance yet, though that should be relatively easy to fix.
  • Added class PageItem_Table, a new page item for tables. The class represents a grid of table cells by keeping a few lists with row / column geometries.
  • Added ability to insert a new PageItem_Table from toolbar or Insert menu followed by mouse dragging. Just like the current “tables”.
  • Added API to PageItem_Table for the basic table operations
    • insert and remove rows and columns,
    • resize rows and column.
  • Added support for merging cells to PageItem_Table as well as an accompanying helper class CellArea used when keeping track of areas of merged cells. The CellArea class also comes with what I think is the very first unit tests in Scribus. The tests are in tests/ and can be runned using make test.
  • Added some rudimentary painting to PageItem_Table, just to be able to see the cells. Still a long way to go for proper table / cell painting, which is kind of non-trivial.
  • As scriptability allows me to experiment with tables before any UI is done, I’ve added the following new scripting methods. These have been added to the old scripter, but should be easy enough to port to ScripterNG later on.
    • createTable(x, y, width, height, numRows, numColumns, ["name"])
    • getTableRows(["name"])
    • getTableColumns(["name"])
    • insertTableRows(index, numRows, ["name"])
    • removeTableRows(index, numRows, ["name"])
    • getTableRowHeight(row, ["name"])
    • setTableRowHeight(row, height, ["name"])
    • insertTableColumns(index, numColumns, ["name"])
    • removeTableColumns(index, numColumns, ["name"])
    • getTableColumnWidth(column, ["name"])
    • setTableColumnWidth(column, width, ["name"])
    • mergeTableCells(row, column, numRows, numColumns, ["name"])

Project Status

The goal in the schedule for this first week was simply Data structures for tables. Intentionally a quite moderate goal, as I didn’t know how long it would take to get up to speed. So unsurprisingly, I think I’m a little ahead of schedule. Worth noting though is that the tables are currently only skeletal in their nature; they hold no content and are simply a grid of empty cells. This is all according to plan though, and integration with text frames is scheduled for later.

Upcoming Work

The goals for next week according to the schedule is

  • Basic table layout with fixed column widths and mock content in cells.
  • Insertion/removal of rows/columns.
  • Basic drawing of table.

but as at least some of this has already been done, I think I’ll start looking at other things as well. Right now I’m looking at proper table / cell border painting, as well as fixing a couple of bugs in the code I have so far.

I have an installation of Adobe InDesign CS5.5 running in VirtualBox and I’ve been looking at what border model they’re using and how they’re doing border conflict resolution. It seems to be a variant of the CSS2 collapsing border model, which is probably what I’ll try to go for initially in Scribus as well.

That’s all for now folks! I’ll conclude with a little screencast showing me playing around with a table using the new scripting methods. I highly recommend you download the source OGV instead of watching it here, as the quality turned out quite bad in the blip.tv conversion.

So it seems my…

summer of 2011 will come in a distinct 2009 flavor. Can’t wait to get started ;)

I’ll probably blog my progress here. What do you guys think; OK for me to have it aggregated on p.k.o? Scribus KDE-ish enough for you?


PS. For those of you who didn’t understand or can’t be bothered to click the links; I’ve been accepted into GSoC this year to improve the tables support of Scribus. You might remember me doing the same for KWord as part of GSoC back in 2009. DS.

Call for Help — Styles Widget for Calligra Words

Background

Some of us in the Calligra team recently got together and held an IRC meeting to discuss a redesign of the text styles dock widget in Calligra Words. The meeting was attended by both coders and usability people. A full summary of the meeting is available on the wiki, but some of the conclusions were:

  1. We need two dock widgets: one compact for people who value screen real-estate and one big dock widget for the styles junkies out there who always wants to have the list of text styles available on-screen.
  2. Applying styles should be a one-click operation.
  3. As the styles dock widgets are mostly used to apply styles, styles should be presented in the dock widgets as a simple list, not as a tree showing the inheritance between styles.
  4. Previewing of styles should as much as possible be done in-list. That is, items in the styles lists are previews of themselves.

Apart from that, most of what was decided at the meeting were details regarding the implementation.

Below are some preliminary mock-ups of how we envision the new styles widget to be used in the two dock widgets. Note that the same styles widget will be used in both these dock widgets, so the two dockers will probably share 99% of their code.

Compact Dock Widget Mock-up. Click to enlarge.

Compact Docker Mock-up. Click to enlarge.

Big Dock Widget Mock-up. Click to enlarge.

Big Dock Widget Mock-up. Click to enlarge.

Call for Help!

Some preliminary coding of the styles widget to be used in the two new dockers has been started by Casper, but now we’re looking for someone to finish the work. The task involves implementing the actual list view used in these two new dock widgets. If you feel that you

  • want to help out with making Calligra Words a lot more usable
  • have some experience with the Qt model/view framework
  • want to work with a motivated and friendly team of developers
  • like to have your work shine at a very prominent place in Calligra Words

then you’re the one we’re looking for! If you’re interested in helping out, you’re welcome to contact us in the Calligra Team either in #calligra on irc.freenode.net or on our mailing list.

Spotify Links in Chrome on Linux/KDE

Short tip on how to get this to work:

Create a script /path/to/spotify_open.sh with the following in it:

#!/bin/bash
wine "$HOME/.wine/drive_c/Program Files/Spotify/spotify.exe" /uri "$1"

Create $HOME/.kde4/share/kde4/services/spotify.protocol with the following in it:

[Protocol]
exec=/path/to/spotify_open.sh "%u"
protocol=spotify
input=none
output=none
helper=true
listing=false
reading=false
writing=false
makedir=false
deleting=false

That’s it, spotify:blah style URLs will now open in Spotify launched through Wine. Chrome just uses xdg-open for launching external apps.

HDD fail :/

*From the annoying-like-h**ll department*

After a nice weekend at my parents and hanging out with some old friends, one of which recently came back from a stay in Kunshan, China, I was greeted this morning when coming back home by a crashed hard drive on my laptop :/

It started out with things beginning to act irregular, and then after a reboot I was told the computer had been uncleanly shut down and was dropped into an fsck run that failed in flames with I/O errors and whatnot. I ran a manual fsck and actually got it to a state where I could boot it again, the kernel kept spewing I/O error messages and failing ioctl commands though. I managed to get some of the more important files off the drive and onto my USB stick. They were actually surprisingly few compared to last time I had a hard drive crash, which is a small consolation.

Having been through several hard drive crashes in the past, what pisses me off most about this one is not the loss of data but the fact that it’s just a 1 year old drive that is now failing, which I really think is crappy. But more importantly the annoyance of loosing time having to go hunt for a new drive and set up the system again; I really don’t have time for this right now. What’s also annoying is that for many many years I always had at least two computers at home, but since just a few months ago, the laptop has been all I have. And of course the Kubuntu CD I had laying around was scratched so I had to go to a friend to burn a new one.

Anyway, the machine is back to normal now and sounding like a cat from the make -j4 getting a dev env up again. Lessons learned; as always, keep a backup; make sure you have a working installation media for your OS of choice around, and consider having at least two computers in your home.

At the store, getting the replacement drive, I didn’t really care that much what I was getting and just picked something. On the way back I realize that it’s a 320 GB Wester Digital… I think it might actually be the exact same model that I had.. Stupid? ;)