Creating/Destroying/Hide? uhm... how can I?



Hello!

I'm building an application. In a window, there is a mini plugins browser. With
a GtkCtree, I can see and browse the whole plugins (a list...). ok.
When a plugin (one from the list) is selected, it is drawn some information of
the plugin, and some extra information and preferences. All these widgets (labels,
combo, text inputs, etc...) are drawn by these plugins thierselves! (ok?), not
by the main program.
By this reason, the right side of the window in diferent from one plugin to another.

The problem comes when... how can I delete/erase the whole widgets created by 
a plugin and draw in the same position the other widgets.

My first aproach is this:


/******** IN THE MAIN BROWSER ******************/
//   Callback when a row is selected!!!
void on_Plugin_tree_select_row (GtkWidget *widget, GtkCTreeNode *node)
{
 GtkWidget *last=NULL;
 PLUGIN_INFO_STRUCT *plugin=NULL;
 PLUGIN_INTERFACE_CONFIG_STRUCT config_interface;
 GtkWidget *(*interface_config_plugin)();

 plugin = gtk_ctree_node_get_row_data (GTK_CTREE(Plugin_tree), node);

 /*
  *  Information interface
  */ 
 gtk_label_set_text (GTK_LABEL(info_name),plugin->name);
 gtk_label_set_text (GTK_LABEL(info_type),PLUGIN_TYPE_2_str(plugin->type));
 gtk_label_set_text (GTK_LABEL(info_description),plugin->description);
 ugin->copyright);
 
 /*
  *  Refresh Config interface
  */ 
 config_interface.config_container = viewport_config;  // CONTAINER of the right side
 if (!plugin->handle)
        {
        return;
        }
 interface_config_plugin = dlsym(plugin->handle, "interface_plugin_config");     // CALL THE ROUTINE IN THE 
PLUGIN
 
 if ( dlerror() != NULL)
        {
        return;
        }
                
 last = (*interface_config_plugin)( (PLUGIN_INTERFACE_CONFIG_STRUCT *) &config_interface );
        
}

//   Callback when a row is UNselected!!!
void on_Plugin_tree_unselect_row (GtkWidget *widget, GtkCTreeNode *node)
{
 PLUGIN_INFO_STRUCT *plugin = NULL;
 PLUGIN_INTERFACE_CONFIG_STRUCT config_interface;
 void *(*interface_plugin_destroy)();

 plugin = gtk_ctree_node_get_row_data (GTK_CTREE(Plugin_tree), node);

 /*
  *  Information interface
  */ 
 gtk_label_set_text (GTK_LABEL(info_name),"");
 gtk_label_set_text (GTK_LABEL(info_type),"");
 gtk_label_set_text (GTK_LABEL(info_description),"");
 
 config_interface.config_container = viewport_config;   // CONTAINER of the right side
 /*
  *  Destroy Config interface
  */ 
 if (!plugin->handle)
        {
        return;
        }
 interface_plugin_destroy = dlsym(plugin->handle, "interface_plugin_destroy"); // CALL THE ROUTINE IN THE 
PLUGIN
 
 if ( dlerror() != NULL)
        {
        printf("dlerror\n");
        return;
        }
                
 (*interface_plugin_destroy)((PLUGIN_INTERFACE_CONFIG_STRUCT *) &config_interface );
}

/******** IN THE PLUGIN CODE ******************/

void interface_plugin_destroy ( PLUGIN_INTERFACE_CONFIG_STRUCT  *interface )
{
 if (vbox)  // VBOX is the VERTICAL BOX, that is contained in the container passed from the main browser 
        {
        gtk_container_remove ( GTK_CONTAINER(interface->config_container) ,vbox);
        }
 else   printf("No parent (v4l)\n");
}


GtkWidget * interface_plugin_config (PLUGIN_INTERFACE_CONFIG_STRUCT *interface)
{

 if (vbox) // If VBOX is already created... only container add... isn't it?
        {
        gtk_container_add (GTK_CONTAINER(interface->config_container), vbox);
        printf("gtk_container_add\n");
        return (vbox);
        }
 
 vbox = gtk_vbox_new (FALSE, 2);
 gtk_widget_ref (vbox);
 gtk_object_set_data_full (GTK_OBJECT (interface->config_container), "vbox", vbox,
                            (GtkDestroyNotify) gtk_widget_unref);
 gtk_widget_show (vbox);
 gtk_container_add (GTK_CONTAINER (interface->config_container), vbox);
....
creating the widgets...
....


 
... uhmmmm I think it should work... but I hangs... It doen't work...
does anyone have an idea about how to do it?

Thanks!

Regards

-- 
David Rivera Pericás

Ing.Técnico de Telecomunicaciones (esp. Telemática).
http://www.ctv.es/USERS/davidrivera/



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