GtkTreeView column-chooser dialog



Proposal:
=========

I'd like to add a new dialog to GTK+.  This dialog would give a
consistent way to change the layout of a multi-columned GtkTreeView
widget.  There's an implementation in libegg that currently looks like
this:

http://people.redhat.com/jrb/files/Screenshot-Test-tree-column.png

The basic idea is that we provide a dialog to modify the
order/visibility of columns on a complicated view.  I feel like
something like this is common enough that it warrants going into GTK+.
Still, if people feel it's inappropriate, we can put it elsewhere.

API:
====

The API that currently exists is a little limited, and would need
extending.  Still, the basic form would exist.  We would have three
objects available: GtkColumnChooser, GtkColumnChooserDialog, and
GtkColumnModel.  GtkColumnChooserDialog would be similar to
GtkFontSelectionDialog, in that it would just hold a GtkColumnChooser
inside a dialog.

There's some API in libegg, but I'd prefer to see some changes to it
first.  Note that I didn't check in these proposed changes b/c I'd
rather have a working copy people can work with.  Here's what I'd like
to do:

-- gtkcolumnchooser.h --

GType           gtk_column_chooser_get_type        (void);
GtkWidget      *gtk_column_chooser_new             (GtkTreeView      *tree_view);
GtkColumnModel *gtk_column_chooser_get_model       (GtkColumnChooser *column_chooser);

GType           gtk_column_chooser_dialog_get_type (void);
GtkWidget      *gtk_column_chooser_dialog_new      (GtkTreeView      *tree_view);


-- gtkcolumnmodel.h --
enum
{
  GTK_COLUMN_MODEL_COLUMN_VISIBLE,
  GTK_COLUMN_MODEL_COLUMN_NAME,
  GTK_COLUMN_MODEL_COLUMN_ID,
  GTK_COLUMN_MODEL_COLUMN_OBJECT,
  GTK_COLUMN_MODEL_N_COLUMNS
};

GType              gtk_column_model_get_type        (void);
GtkColumnModel *   gtk_column_model_new             (GtkTreeView       *tree_view);
void               gtk_column_model_set_column_id   (GtkColumnModel    *model,
						     GtkTreeViewColumn *column,
						     const gchar       *id);
gchar             *gtk_column_model_order_to_string (GtkColumnModel    *model);
void               gtk_column_model_string_to_order (GtkColumnModel    *model,
						     const char        *order_string);
--

I removed all of the column/tree manipulations from the model as I feel
that centralizing the manipulation in GtkTreeView makes sense.  Instead,
I made the columns available.

Other Issues:
=============

 * I'm not totally sold on the Object names.  Perhaps
   GtkTreeViewColumnChooser/GtkTreeViewColumnChooserDialog would be more
   consistent, though much more cumbersome.

 * What is the best way to bring up this dialog?  Should I add a
   gtk_column_chooser_dialog_set_context_menu, or something like that
   such that you can right click on the column and get a context menu.
   ETable currently has a context menu that lets you customize it.
   A screenshot is available at:
        http://people.redhat.com/jrb/files/Screenshot-ETable-context.png

   I'd expect three different ways to present this information to
   users.  Firstly through the provided dialog.  Secondly, by embeding
   the chooser widget in a preferences dialog somewhere.  Thirdly, by
   using the provided model in a custom view somewhere.

 * I'd really like a way to serialize the current columns to a string so
   that their order can be stored/restored to/from disk.  Unfortunately,
   we currently have no way of uniquely identifying columns beyond their
   titles (which is completely fragile.)  So we need a way to identify
   them uniquely, and turn them into a string.  That is the indended
   purpose of gtk_column_model_set_column_id.  However, this isn't ideal
   as it is cumbersome to implement, and has to be done when setting up
   the dialog.  The alternative is to add an "id" property to
   GtkTreeViewColumn that can be used here.

I'll probably start moving the libegg code over to this API tonight.
I'd appreciate any feedback about getting this in for 2.4.

Thanks,
-Jonathan



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]