new vclient and move port functionality
This commit is contained in:
parent
beef6e7d44
commit
f33b58ac85
|
@ -1562,6 +1562,27 @@ ladish_graph_remove_client(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uint64_t
|
||||||
|
ladish_graph_get_client_id(
|
||||||
|
ladish_graph_handle graph_handle,
|
||||||
|
ladish_client_handle client_handle)
|
||||||
|
{
|
||||||
|
struct ladish_graph_client * client_ptr;
|
||||||
|
|
||||||
|
log_info("ladish_graph_get_client_id() called.");
|
||||||
|
|
||||||
|
client_ptr = ladish_graph_find_client(graph_ptr, client_handle);
|
||||||
|
if (client_ptr != NULL)
|
||||||
|
{
|
||||||
|
return client_ptr->id;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ASSERT_NO_PASS;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
ladish_graph_add_port(
|
ladish_graph_add_port(
|
||||||
ladish_graph_handle graph_handle,
|
ladish_graph_handle graph_handle,
|
||||||
|
|
|
@ -165,6 +165,7 @@ ladish_graph_set_link_port_override_uuid(
|
||||||
const uuid_t override_uuid);
|
const uuid_t override_uuid);
|
||||||
|
|
||||||
ladish_client_handle ladish_graph_get_port_client(ladish_graph_handle graph_handle, ladish_port_handle port_handle);
|
ladish_client_handle ladish_graph_get_port_client(ladish_graph_handle graph_handle, ladish_port_handle port_handle);
|
||||||
|
uint64_t ladish_graph_get_client_id(ladish_graph_handle graph_handle, ladish_client_handle client_handle);
|
||||||
const char * ladish_graph_get_client_name(ladish_graph_handle graph_handle, ladish_client_handle client_handle);
|
const char * ladish_graph_get_client_name(ladish_graph_handle graph_handle, ladish_client_handle client_handle);
|
||||||
const char * ladish_graph_get_port_name(ladish_graph_handle graph, ladish_port_handle port);
|
const char * ladish_graph_get_port_name(ladish_graph_handle graph, ladish_port_handle port);
|
||||||
bool ladish_graph_client_is_empty(ladish_graph_handle graph_handle, ladish_client_handle client_handle);
|
bool ladish_graph_client_is_empty(ladish_graph_handle graph_handle, ladish_client_handle client_handle);
|
||||||
|
|
|
@ -170,6 +170,8 @@ static void ladish_graph_manager_dbus_move_port(struct dbus_method_call * call_p
|
||||||
{
|
{
|
||||||
uint64_t port_id;
|
uint64_t port_id;
|
||||||
uint64_t client_id;
|
uint64_t client_id;
|
||||||
|
ladish_port_handle port;
|
||||||
|
ladish_client_handle client;
|
||||||
|
|
||||||
if (!dbus_message_get_args(
|
if (!dbus_message_get_args(
|
||||||
call_ptr->message,
|
call_ptr->message,
|
||||||
|
@ -185,12 +187,30 @@ static void ladish_graph_manager_dbus_move_port(struct dbus_method_call * call_p
|
||||||
|
|
||||||
log_info("move port request, graph '%s', port %"PRIu64", client %"PRIu64, ladish_graph_get_description(graph), port_id, client_id);
|
log_info("move port request, graph '%s', port %"PRIu64", client %"PRIu64, ladish_graph_get_description(graph), port_id, client_id);
|
||||||
|
|
||||||
|
port = ladish_graph_find_port_by_id(graph, port_id);
|
||||||
|
if (port == NULL)
|
||||||
|
{
|
||||||
|
lash_dbus_error(call_ptr, LASH_DBUS_ERROR_INVALID_ARGS, "Cannot move unknown port");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
client = ladish_graph_find_client_by_id(graph, client_id);
|
||||||
|
if (client == NULL)
|
||||||
|
{
|
||||||
|
lash_dbus_error(call_ptr, LASH_DBUS_ERROR_INVALID_ARGS, "Cannot move port to unknown client");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
ladish_graph_move_port(graph, port, client);
|
||||||
|
|
||||||
method_return_new_void(call_ptr);
|
method_return_new_void(call_ptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void ladish_graph_manager_dbus_new_client(struct dbus_method_call * call_ptr)
|
static void ladish_graph_manager_dbus_new_client(struct dbus_method_call * call_ptr)
|
||||||
{
|
{
|
||||||
const char * name;
|
const char * name;
|
||||||
|
ladish_client_handle client;
|
||||||
|
uint64_t client_id;
|
||||||
|
|
||||||
if (!dbus_message_get_args(
|
if (!dbus_message_get_args(
|
||||||
call_ptr->message,
|
call_ptr->message,
|
||||||
|
@ -205,7 +225,22 @@ static void ladish_graph_manager_dbus_new_client(struct dbus_method_call * call_
|
||||||
|
|
||||||
log_info("new client request, graph '%s', name '%s'", ladish_graph_get_description(graph), name);
|
log_info("new client request, graph '%s', name '%s'", ladish_graph_get_description(graph), name);
|
||||||
|
|
||||||
lash_dbus_error(call_ptr, LASH_DBUS_ERROR_GENERIC, "method \"%s\" not implemented yet", call_ptr->method_name);
|
if (!ladish_client_create(NULL, &client))
|
||||||
|
{
|
||||||
|
lash_dbus_error(call_ptr, LASH_DBUS_ERROR_GENERIC, "ladish_client_create() failed.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!ladish_graph_add_client(graph, client, name, false))
|
||||||
|
{
|
||||||
|
lash_dbus_error(call_ptr, LASH_DBUS_ERROR_GENERIC, "ladish_graph_add_client() failed to add client '%s' to virtual graph", name);
|
||||||
|
ladish_client_destroy(client);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
client_id = ladish_graph_get_client_id(graph, client);
|
||||||
|
|
||||||
|
method_return_new_single(call_ptr, DBUS_TYPE_UINT64, &client_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
#undef graph_ptr
|
#undef graph_ptr
|
||||||
|
|
|
@ -332,6 +332,46 @@ canvas_get_selected_modules_count(
|
||||||
return canvas_ptr->get()->selected_items().size();
|
return canvas_ptr->get()->selected_items().size();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool
|
||||||
|
canvas_get_one_selected_module(
|
||||||
|
canvas_handle canvas,
|
||||||
|
void ** module_context_ptr)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
|
||||||
|
std::list<boost::shared_ptr<FlowCanvas::Item> > modules = canvas_ptr->get()->selected_items();
|
||||||
|
if (modules.size() != 1)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
i = 0;
|
||||||
|
for (std::list<boost::shared_ptr<FlowCanvas::Item> >::iterator m = modules.begin(); m != modules.end(); ++m)
|
||||||
|
{
|
||||||
|
boost::shared_ptr<module_cls> module = boost::dynamic_pointer_cast<module_cls>(*m);
|
||||||
|
if (module == NULL)
|
||||||
|
{
|
||||||
|
ASSERT_NO_PASS;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (i == 0)
|
||||||
|
{
|
||||||
|
*module_context_ptr = module->m_context;
|
||||||
|
i++;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (i != 1)
|
||||||
|
{
|
||||||
|
ASSERT_NO_PASS;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
canvas_get_two_selected_modules(
|
canvas_get_two_selected_modules(
|
||||||
canvas_handle canvas,
|
canvas_handle canvas,
|
||||||
|
@ -361,17 +401,20 @@ canvas_get_two_selected_modules(
|
||||||
case 0:
|
case 0:
|
||||||
*module1_context_ptr = module->m_context;
|
*module1_context_ptr = module->m_context;
|
||||||
i++;
|
i++;
|
||||||
break;
|
continue;
|
||||||
case 1:
|
case 1:
|
||||||
*module2_context_ptr = module->m_context;
|
*module2_context_ptr = module->m_context;
|
||||||
i++;
|
i++;
|
||||||
break;
|
continue;
|
||||||
default:
|
|
||||||
ASSERT_NO_PASS;
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (i != 2)
|
||||||
|
{
|
||||||
|
ASSERT_NO_PASS;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -100,6 +100,11 @@ size_t
|
||||||
canvas_get_selected_modules_count(
|
canvas_get_selected_modules_count(
|
||||||
canvas_handle canvas);
|
canvas_handle canvas);
|
||||||
|
|
||||||
|
bool
|
||||||
|
canvas_get_one_selected_module(
|
||||||
|
canvas_handle canvas,
|
||||||
|
void ** module_context_ptr);
|
||||||
|
|
||||||
bool
|
bool
|
||||||
canvas_get_two_selected_modules(
|
canvas_get_two_selected_modules(
|
||||||
canvas_handle canvas,
|
canvas_handle canvas,
|
||||||
|
|
|
@ -237,6 +237,23 @@ static void on_popup_menu_action_port_rename(GtkWidget * menuitem, gpointer port
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void on_popup_menu_action_port_move(GtkWidget * menuitem, gpointer port_context)
|
||||||
|
{
|
||||||
|
struct client * client_ptr;
|
||||||
|
|
||||||
|
log_info("on_popup_menu_action_port_move %"PRIu64, port_ptr->id);
|
||||||
|
|
||||||
|
if (!canvas_get_one_selected_module(port_ptr->graph_canvas->canvas, (void **)&client_ptr))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!graph_proxy_move_port(port_ptr->graph_canvas->graph, port_ptr->id, client_ptr->id))
|
||||||
|
{
|
||||||
|
error_message_box("Port move failed");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static void fill_port_menu(GtkMenu * menu, void * port_context)
|
static void fill_port_menu(GtkMenu * menu, void * port_context)
|
||||||
{
|
{
|
||||||
GtkWidget * menuitem;
|
GtkWidget * menuitem;
|
||||||
|
@ -246,6 +263,13 @@ static void fill_port_menu(GtkMenu * menu, void * port_context)
|
||||||
menuitem = gtk_menu_item_new_with_label(_("Rename"));
|
menuitem = gtk_menu_item_new_with_label(_("Rename"));
|
||||||
g_signal_connect(menuitem, "activate", (GCallback)on_popup_menu_action_port_rename, port_ptr);
|
g_signal_connect(menuitem, "activate", (GCallback)on_popup_menu_action_port_rename, port_ptr);
|
||||||
gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem);
|
gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem);
|
||||||
|
|
||||||
|
if (canvas_get_selected_modules_count(port_ptr->graph_canvas->canvas) == 1)
|
||||||
|
{
|
||||||
|
menuitem = gtk_menu_item_new_with_label(_("Move port"));
|
||||||
|
g_signal_connect(menuitem, "activate", (GCallback)on_popup_menu_action_port_move, port_ptr);
|
||||||
|
gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#undef port_ptr
|
#undef port_ptr
|
||||||
|
@ -268,12 +292,32 @@ static void on_popup_menu_action_join_clients(GtkWidget * menuitem, gpointer can
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void on_popup_menu_action_new_client(GtkWidget * menuitem, gpointer canvas_context)
|
||||||
|
{
|
||||||
|
char * new_name;
|
||||||
|
uint64_t client_id;
|
||||||
|
|
||||||
|
if (name_dialog(_("New client"), _("Client name"), "", &new_name))
|
||||||
|
{
|
||||||
|
if (!graph_proxy_new_client(canvas_ptr->graph, new_name, &client_id))
|
||||||
|
{
|
||||||
|
error_message_box("New client creation failed");
|
||||||
|
}
|
||||||
|
|
||||||
|
free(new_name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static void fill_canvas_menu(GtkMenu * menu, void * canvas_context)
|
static void fill_canvas_menu(GtkMenu * menu, void * canvas_context)
|
||||||
{
|
{
|
||||||
GtkWidget * menuitem;
|
GtkWidget * menuitem;
|
||||||
|
|
||||||
log_info("fill_canvas_menu");
|
log_info("fill_canvas_menu");
|
||||||
|
|
||||||
|
menuitem = gtk_menu_item_new_with_label(_("New client"));
|
||||||
|
g_signal_connect(menuitem, "activate", (GCallback)on_popup_menu_action_new_client, canvas_ptr);
|
||||||
|
gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem);
|
||||||
|
|
||||||
if (canvas_get_selected_modules_count(canvas_ptr->canvas) == 2)
|
if (canvas_get_selected_modules_count(canvas_ptr->canvas) == 2)
|
||||||
{
|
{
|
||||||
menuitem = gtk_menu_item_new_with_label(_("Join clients"));
|
menuitem = gtk_menu_item_new_with_label(_("Join clients"));
|
||||||
|
|
Loading…
Reference in New Issue