In world tree, store graph views not graphs

This commit is contained in:
Nedko Arnaudov 2009-08-22 15:18:03 +03:00
parent d334b76e6a
commit 27390fa5b4
4 changed files with 20 additions and 16 deletions

View File

@ -92,7 +92,7 @@ bool create_view(const char * name, const char * service, const char * object, g
gtk_widget_show(view_ptr->canvas_widget);
world_tree_add(view_ptr->graph, name);
world_tree_add((graph_view_handle)view_ptr);
*handle_ptr = (graph_view_handle)view_ptr;
@ -163,7 +163,7 @@ void destroy_view(graph_view_handle view)
detach_canvas(view_ptr);
world_tree_remove(view_ptr->graph);
world_tree_remove(view);
graph_canvas_detach(view_ptr->graph_canvas);
graph_canvas_destroy(view_ptr->graph_canvas);
@ -176,3 +176,8 @@ void activate_view(graph_view_handle view)
{
activate_view_internal(view_ptr);
}
const char * get_view_name(graph_view_handle view)
{
return view_ptr->name;
}

View File

@ -35,5 +35,6 @@ void view_init(void);
bool create_view(const char * name, const char * service, const char * object, graph_view_handle * handle_ptr);
void destroy_view(graph_view_handle view);
void activate_view(graph_view_handle view);
const char * get_view_name(graph_view_handle view);
#endif /* #ifndef GRAPH_VIEW_H__05B5CE46_5239_43F1_9F31_79F13EBF0DFA__INCLUDED */

View File

@ -381,8 +381,8 @@ project_list::set_lash_availability(
enum
{
COL_NAME = 0,
COL_GRAPH,
COL_VIEW = 0,
COL_NAME,
NUM_COLS
};
@ -404,31 +404,29 @@ void world_tree_init(void)
gtk_tree_view_column_pack_start(col, renderer, TRUE);
gtk_tree_view_column_add_attribute(col, renderer, "text", COL_NAME);
g_treestore = gtk_tree_store_new(NUM_COLS, G_TYPE_STRING, G_TYPE_POINTER);
g_treestore = gtk_tree_store_new(NUM_COLS, G_TYPE_POINTER, G_TYPE_STRING);
gtk_tree_view_set_model(GTK_TREE_VIEW(g_world_tree_widget), GTK_TREE_MODEL(g_treestore));
}
void world_tree_add(graph_handle graph, const char * name)
void world_tree_add(graph_view_handle view)
{
GtkTreeIter iter;
gtk_tree_store_append(g_treestore, &iter, NULL);
gtk_tree_store_set(g_treestore, &iter, COL_NAME, name, COL_GRAPH, graph, -1);
gtk_tree_store_set(g_treestore, &iter, COL_VIEW, view, COL_NAME, get_view_name(view), -1);
}
void world_tree_remove(graph_handle graph)
void world_tree_remove(graph_view_handle view)
{
GtkTreeIter iter;
gchar * name;
graph_handle graph2;
graph_view_handle view2;
if (gtk_tree_model_get_iter_first(GTK_TREE_MODEL(g_treestore), &iter))
{
do
{
gtk_tree_model_get(GTK_TREE_MODEL(g_treestore), &iter, COL_NAME, &name, COL_GRAPH, &graph2, -1);
//lash_info("'%s' %p", name, graph2);
if (graph == graph2)
gtk_tree_model_get(GTK_TREE_MODEL(g_treestore), &iter, COL_VIEW, &view2, -1);
if (view == view2)
{
gtk_tree_store_remove(g_treestore, &iter);
return;

View File

@ -27,11 +27,11 @@
#ifndef WORLD_TREE_H__D786489B_E400_4E92_85C7_2BAE606DE56D__INCLUDED
#define WORLD_TREE_H__D786489B_E400_4E92_85C7_2BAE606DE56D__INCLUDED
#include "../graph_proxy.h"
#include "graph_view.h"
void world_tree_init(void);
void world_tree_add(graph_handle graph, const char * name);
void world_tree_remove(graph_handle graph);
void world_tree_add(graph_view_handle view);
void world_tree_remove(graph_view_handle view);
#endif // #ifndef WORLD_TREE_H__D786489B_E400_4E92_85C7_2BAE606DE56D__INCLUDED