gui: add/remove room graph views on room appear/disappear
This commit is contained in:
parent
50eb4581ce
commit
e74f5abccb
|
@ -251,6 +251,11 @@ const char * get_view_name(graph_view_handle view)
|
|||
return view_ptr->name;
|
||||
}
|
||||
|
||||
const char * get_view_opath(graph_view_handle view)
|
||||
{
|
||||
return graph_proxy_get_object(view_ptr->graph);
|
||||
}
|
||||
|
||||
bool set_view_name(graph_view_handle view, const char * cname)
|
||||
{
|
||||
char * name;
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
/*
|
||||
* LADI Session Handler (ladish)
|
||||
*
|
||||
* Copyright (C) 2009 Nedko Arnaudov <nedko@arnaudov.name>
|
||||
* Copyright (C) 2009, 2010 Nedko Arnaudov <nedko@arnaudov.name>
|
||||
*
|
||||
**************************************************************************
|
||||
* This file contains interface of the graph view object
|
||||
|
@ -47,6 +47,7 @@ create_view(
|
|||
void destroy_view(graph_view_handle view);
|
||||
void activate_view(graph_view_handle view);
|
||||
const char * get_view_name(graph_view_handle view);
|
||||
const char * get_view_opath(graph_view_handle view);
|
||||
bool set_view_name(graph_view_handle view, const char * name);
|
||||
canvas_handle get_current_canvas();
|
||||
|
||||
|
|
18
gui/main.c
18
gui/main.c
|
@ -1067,12 +1067,30 @@ void jack_disappeared(void)
|
|||
|
||||
static void room_appeared(const char * opath, const char * name, const char * template)
|
||||
{
|
||||
graph_view_handle graph_view;
|
||||
|
||||
log_info("room \"%s\" appeared (%s). template is \"%s\"", name, opath, template);
|
||||
|
||||
if (!create_view(name, SERVICE_NAME, opath, true, false, false, &graph_view))
|
||||
{
|
||||
log_error("create_view() failed for room \"%s\"", name);
|
||||
}
|
||||
}
|
||||
|
||||
static void room_disappeared(const char * opath, const char * name, const char * template)
|
||||
{
|
||||
graph_view_handle graph_view;
|
||||
|
||||
log_info("room \"%s\" disappeared (%s). template is \"%s\"", name, opath, template);
|
||||
|
||||
graph_view = world_tree_find_by_opath(opath);
|
||||
if (graph_view == NULL)
|
||||
{
|
||||
log_error("Unknown room disappeared");
|
||||
return;
|
||||
}
|
||||
|
||||
destroy_view(graph_view);
|
||||
}
|
||||
|
||||
static void room_changed(const char * opath, const char * name, const char * template)
|
||||
|
|
|
@ -465,6 +465,31 @@ void world_tree_add(graph_view_handle view, bool force_activate)
|
|||
}
|
||||
}
|
||||
|
||||
graph_view_handle world_tree_find_by_opath(const char * opath)
|
||||
{
|
||||
gint type;
|
||||
graph_view_handle view;
|
||||
GtkTreeIter iter;
|
||||
|
||||
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_TYPE, &type, COL_VIEW, &view, -1);
|
||||
if (type == entry_type_view)
|
||||
{
|
||||
if (strcmp(get_view_opath(view), opath) == 0)
|
||||
{
|
||||
return view;
|
||||
}
|
||||
}
|
||||
}
|
||||
while (gtk_tree_model_iter_next(GTK_TREE_MODEL(g_treestore), &iter));
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static bool find_view(graph_view_handle view, GtkTreeIter * iter_ptr)
|
||||
{
|
||||
gint type;
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
/*
|
||||
* LADI Session Handler (ladish)
|
||||
*
|
||||
* Copyright (C) 2008, 2009 Nedko Arnaudov <nedko@arnaudov.name>
|
||||
* Copyright (C) 2008, 2009, 2010 Nedko Arnaudov <nedko@arnaudov.name>
|
||||
*
|
||||
**************************************************************************
|
||||
* This file contains the interface of the world tree widget
|
||||
|
@ -33,6 +33,7 @@ void world_tree_init(void);
|
|||
|
||||
void world_tree_add(graph_view_handle view, bool force_activate);
|
||||
void world_tree_remove(graph_view_handle view);
|
||||
graph_view_handle world_tree_find_by_opath(const char * opath);
|
||||
void world_tree_activate(graph_view_handle view);
|
||||
void world_tree_name_changed(graph_view_handle view);
|
||||
void world_tree_add_app(graph_view_handle view, uint64_t id, const char * name, bool running, bool terminal, uint8_t level);
|
||||
|
|
Loading…
Reference in New Issue