implement view switching from world tree
This commit is contained in:
parent
27390fa5b4
commit
3cef018c96
|
@ -48,7 +48,7 @@ void view_init(void)
|
|||
INIT_LIST_HEAD(&g_views);
|
||||
}
|
||||
|
||||
bool create_view(const char * name, const char * service, const char * object, graph_view_handle * handle_ptr)
|
||||
bool create_view(const char * name, const char * service, const char * object, bool force_activate, graph_view_handle * handle_ptr)
|
||||
{
|
||||
struct graph_view * view_ptr;
|
||||
|
||||
|
@ -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((graph_view_handle)view_ptr);
|
||||
world_tree_add((graph_view_handle)view_ptr, force_activate);
|
||||
|
||||
*handle_ptr = (graph_view_handle)view_ptr;
|
||||
|
||||
|
|
|
@ -32,7 +32,7 @@
|
|||
typedef struct graph_view_tag { int unused; } * graph_view_handle;
|
||||
|
||||
void view_init(void);
|
||||
bool create_view(const char * name, const char * service, const char * object, graph_view_handle * handle_ptr);
|
||||
bool create_view(const char * name, const char * service, const char * object, bool force_activate, 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);
|
||||
|
|
|
@ -860,13 +860,11 @@ graph_view_handle g_studio_view = NULL;
|
|||
|
||||
void control_proxy_on_studio_appeared(void)
|
||||
{
|
||||
if (!create_view("Studio", SERVICE_NAME, STUDIO_OBJECT_PATH, &g_studio_view))
|
||||
if (!create_view("Studio", SERVICE_NAME, STUDIO_OBJECT_PATH, false, &g_studio_view))
|
||||
{
|
||||
lash_error("create_view() failed for studio");
|
||||
return;
|
||||
}
|
||||
|
||||
activate_view(g_studio_view);
|
||||
}
|
||||
|
||||
void control_proxy_on_studio_disappeared(void)
|
||||
|
@ -892,7 +890,7 @@ void jack_appeared(void)
|
|||
{
|
||||
lash_info("JACK appeared");
|
||||
|
||||
if (!create_view("Raw JACK", JACKDBUS_SERVICE_NAME, JACKDBUS_OBJECT_PATH, &g_jack_view))
|
||||
if (!create_view("Raw JACK", JACKDBUS_SERVICE_NAME, JACKDBUS_OBJECT_PATH, true, &g_jack_view))
|
||||
{
|
||||
lash_error("create_view() failed for jack");
|
||||
return;
|
||||
|
@ -908,8 +906,6 @@ void jack_disappeared(void)
|
|||
destroy_view(g_jack_view);
|
||||
g_jack_view = NULL;
|
||||
}
|
||||
|
||||
activate_view(g_jack_view);
|
||||
}
|
||||
|
||||
int main(int argc, char** argv)
|
||||
|
|
|
@ -389,10 +389,36 @@ enum
|
|||
GtkWidget * g_world_tree_widget;
|
||||
GtkTreeStore * g_treestore;
|
||||
|
||||
static
|
||||
gboolean
|
||||
on_select(
|
||||
GtkTreeSelection * selection,
|
||||
GtkTreeModel * model,
|
||||
GtkTreePath * path,
|
||||
gboolean path_currently_selected,
|
||||
gpointer data)
|
||||
{
|
||||
GtkTreeIter iter;
|
||||
graph_view_handle view;
|
||||
|
||||
if (gtk_tree_model_get_iter(model, &iter, path))
|
||||
{
|
||||
gtk_tree_model_get(model, &iter, COL_VIEW, &view, -1);
|
||||
//lash_info("%s is going to be %s.", get_view_name(view), path_currently_selected ? "unselected" : "selected");
|
||||
if (!path_currently_selected)
|
||||
{
|
||||
activate_view(view);
|
||||
}
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void world_tree_init(void)
|
||||
{
|
||||
GtkTreeViewColumn * col;
|
||||
GtkCellRenderer * renderer;
|
||||
GtkTreeSelection * selection;
|
||||
|
||||
g_world_tree_widget = get_glade_widget("world_tree");
|
||||
gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(g_world_tree_widget), FALSE);
|
||||
|
@ -406,14 +432,23 @@ void world_tree_init(void)
|
|||
|
||||
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));
|
||||
|
||||
selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(g_world_tree_widget));
|
||||
gtk_tree_selection_set_select_function(selection, on_select, NULL, NULL);
|
||||
}
|
||||
|
||||
void world_tree_add(graph_view_handle view)
|
||||
void world_tree_add(graph_view_handle view, bool force_activate)
|
||||
{
|
||||
GtkTreeIter iter;
|
||||
|
||||
gtk_tree_store_append(g_treestore, &iter, NULL);
|
||||
gtk_tree_store_set(g_treestore, &iter, COL_VIEW, view, COL_NAME, get_view_name(view), -1);
|
||||
|
||||
/* select the first top level item */
|
||||
if (force_activate || gtk_tree_model_iter_n_children(GTK_TREE_MODEL(g_treestore), NULL) == 1)
|
||||
{
|
||||
gtk_tree_selection_select_iter(gtk_tree_view_get_selection(GTK_TREE_VIEW(g_world_tree_widget)), &iter);
|
||||
}
|
||||
}
|
||||
|
||||
void world_tree_remove(graph_view_handle view)
|
||||
|
|
|
@ -31,7 +31,7 @@
|
|||
|
||||
void world_tree_init(void);
|
||||
|
||||
void world_tree_add(graph_view_handle view);
|
||||
void world_tree_add(graph_view_handle view, bool force_activate);
|
||||
void world_tree_remove(graph_view_handle view);
|
||||
|
||||
#endif // #ifndef WORLD_TREE_H__D786489B_E400_4E92_85C7_2BAE606DE56D__INCLUDED
|
||||
|
|
Loading…
Reference in New Issue