Deriving from compound widget



Hello there,

At the moment I'm fiddling with creating a compound widget derived from the
standard file selection. In the end this widget lets a user select multiple
files from multiple directories. Due to this I decided to enhance the file
selection with a list of yet selected files (Process: select one or more files
from a directory, click "add", then change directory, repeat, ...), by
double-clicking or selecting (multiple selection possible) then clicking "add"
the user "stores" the selected file(s) in the list (a clist to the right of
the ordinary file selection part).

In order to accomplish this I need to reorder the child widgets from the file
selection a little bit (there has to be an hbox which contains 90% of the
derived file selection in the left half, the aforementioned list in the right
half, this must be at the top of a vbox, at the bottom there are the "ok" and
"cancel" buttons of the file selection). I tried this:

(note: bfilesel is the new widget, type GtkBatchFileSelection (anyone a better
name?), the type consists of the file selection filesel and the
GtkWidget-pointers of the additional widgets)

[...]
static void gtk_batch_file_selection_init(GtkBatchFileSelection *bfilesel)
[...]
  /* Disconnect public widgets of the file selection from parents */
  gtk_widget_hide(bfilesel->filesel.button_area);
  gtk_container_remove(GTK_CONTAINER(bfilesel->filesel.button_area->parent),
                       bfilesel->filesel.button_area);
[...]
  /* Destroy all remaining children of filesel.main_vbox, i.e. the private
   * widgets of the file selection */

  children=gtk_container_children(GTK_CONTAINER(bfilesel->filesel.main_vbox));

  for(node=children;node;node=node->next)
    gtk_widget_destroy(GTK_WIDGET(node->data));

  g_list_free(children);

  /* Rebuild dialog with existing (i.e. from filesel) and additional widgets */
[...]
  /* The horizontal box containing create, rename, etc. buttons */
  gtk_box_pack_start(GTK_BOX(bfilesel->filesel_vbox),
                     (bfilesel->filesel).button_area, FALSE, FALSE, 0);
  gtk_widget_show(bfilesel->filesel.button_area);
[...]

gtk complains right at the gtk_box_pack_start with many "** WARNING **:
invalid cast from `(unknown)' to `GtkObject'" and one '** WARNING **: file
gtkwidget.c: line 2470 (gtk_widget_set_parent): "!GTK_WIDGET_TOPLEVEL
(widget)"', the gtk_widget_show() yields one warning due to invalid cast (same
as above).
When I try to pack the orphaned filesel.history_pulldown into a newly created
hbox, I get lots of "** WARNING **: invalid class type `(unknown)' in cast to
`GtkObject'".
Later on the thingy segfaults.

Anyone got a clue (of course) what I'm doing wrong here? Maybe I need a hint
on correctly reparenting the orphaned widgets...

TIA,
Nils
-- 
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Nils Philippsen                  @college: nils@rhlx01.rz.fht-esslingen.de
Vogelsangstrasse 115             @home:    nils@wombat.dialup.fht-esslingen.de
D 70197 Stuttgart                phone:    +49-711-6599405
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Wer heute an der Bildung spart,          Those who scrimp on education today,
hat morgen noch bloedere Politiker.      get even dumber politicians tomorrow.




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