CList and CTree problems
- From: Tero Pulkkinen <terop students cc tut fi>
- To: gtk-devel-list redhat com
- Cc: Todd Dukes <tdukes ibmoto com>, terop modeemi cs tut fi
- Subject: CList and CTree problems
- Date: 12 Nov 1998 02:00:36 +0200
I think we have some problems with GtkCTree's and GtkCList's interface
conserning about selections.
A piece of code from testgtk.c illustrates this:
In CTree example, remove_selection function:
GList *selection;
GtkCTreeNode *work;
selection = GTK_CLIST (ctree)->selection;
...
work = selection->data; /* uses implicit cast from gpointer to GtkCTreeNode* */
In CList example, we have the following (select_clist):
GList *list;
list = GTK_CLIST (widget)->selection;
g_print (" %d ", GPOINTER_TO_INT (list->data)); /* uses explicit cast from gpointer to int */
Now, GtkCTree is derived GtkCList. Do you now start to see the
problem? Inheritance "promises" users that same algorithms that you
use for a base class object can be used for the derived class object
too, still we're getting a runtime casting error(clist selection gives
out integers, ctree gives out GtkCTreeItem*'s) if we try handle list
of selections with same algorithm(originally made for clist) for both
clist and ctree.
The right thing to do would probably be to fix both clist and ctree use the
same kind of items inside the selection -GList... (==easy solution)
What do you think?
(alternative (==harder solution) would be to
not derive CTree from CList at all but from some other non-concrete widget
and implement selections separately for clist/ctree...
-- it might be better to do the same for ctree/clist that was done in editable,
i.e. change the class hierarchy:
container <- clist <- ctree
to
container <- common_stuffs_for_clist_and_ctree <- clist
container <- common_stuffs_for_clist_and_ctree <- ctree
)
(oh, please keep the cc: fields as they are when replying...)
--
-- Tero Pulkkinen -- terop@modeemi.cs.tut.fi --
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]