Re: [gnome-db] libgnomedb: GnomeDbGrid column headings
- From: "Vivien Malerba" <vmalerba gmail com>
- To: "Murray Cumming" <murrayc murrayc com>
- Cc: gnome-db-list <gnome-db-list gnome org>
- Subject: Re: [gnome-db] libgnomedb: GnomeDbGrid column headings
- Date: Fri, 1 Dec 2006 09:54:20 +0100
On 11/30/06, Murray Cumming <murrayc murrayc com> wrote:
So, a GnomeDbGrid can show a GdaDataModel, I believe, and just shows it
appropriately. But how can I influence things such as
- What human-readable text is used for the column headings.
- How numbers are formatted.
- What drop-down choices are available for fields.
There isn't much in the documentation to give me clues:
http://www.openismus.com/temp/libgnomedb_3_0_docs/html/GnomeDbGrid.html
As mentionned in
http://www.openismus.com/temp/libgnomedb_3_0_docs/html/viewchanges.html,
the GnomeDbGrid is composed of a GnomeDbRawGrid (which inherits
GtkTreeView) and of a GnomeDbDataWidgetInfo (which is responsible for
displaying the navigation buttons at the bottom of the grid).
So for your first question, you can modify the headers of the grid in
the same way as you modify the headers of a GtkTreeView.
Now for the second and 3rd question let me first detail the process
used to creare the columns of a GnomeDbRawGrid (which is the same as
when the entry widgets are created for the GnomeDbBasicForm widget).
Here is the process:
* create a GdaDataProxy object from the GdaDataModel containing data
to display, to store temporary modifications made but not yet written
* create a GdaDataModelIter object as an iterator in the proxy (which
is also a GdaDataModel)
* for each parameter contained in that iterator (which is also a
GdaParameterList), create a column. So the default behaviour is to
display data as-is, with one free-fill column for each column of the
data model to display. If you change the properties of that iterator
(which is public, obtained using gnome_db_data_widget_get_current_data
(GnomeDbRawGrid)), the columns are re-created.
So for your 3rd question, if you want a drop down instead of a
free-fill, then all you have to do is restrict the values of the
parameter corresponding to the column you want a drop down choice, for
example:
"
iter = gnome_db_data_widget_get_current_data (data_widget);
param = gda_parameter_list_find_param (GDA_PARAMETER_LIST (iter), "SalesRep");
gda_parameter_restrict_values (param, restrict_with, restrict_col, NULL));
"
(code copied from the extra/demos/linked_grid_form.c file)
Now for the 2nd question, the short answer is: you can't, but there
are two solutions to make it possible to control the exact formatting
of the individual cells:
1- improve the default cell renderers used in libgnomedb, which will
benefit all the applications using libgnomedb
2- write a custom cell renderer as a plugin, and use it by setting the
"entry_plugin" property of the parameter you want.
The GtkCellRenderer used in the GnomeDbRawGrid is done in the
gnome_db_util_new_cell_renderer() function (there is also a
gnome_db_util_new_data_entry() function for the same purpose but for
data entry widgets used in forms), in the gnome-db-tools.c file.
Cheers,
Vivien
[Date Prev][
Date Next] [Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]