Commit b7221a68 authored by Andreas Traczyk's avatar Andreas Traczyk

videowidget: use device friendly name in context menu

Change-Id: I5a9faafb49dd47fad1df5b03ec1b9c4ea37469da
parent d6d2bb6a
......@@ -386,17 +386,11 @@ set_video_device(MediaSettingsView* self)
MediaSettingsViewPrivate *priv = MEDIA_SETTINGS_VIEW_GET_PRIVATE(self);
auto* device_name = gtk_combo_box_text_get_active_text(GTK_COMBO_BOX_TEXT(priv->combobox_device));
if (device_name) {
auto devices = priv->cpp->avModel_->getDevices();
auto iter = std::find_if(devices.begin(), devices.end(),
[device_name, &priv](const std::string& d) {
auto settings = priv->cpp->avModel_->getDeviceSettings(d);
return settings.name == device_name;
});
if (iter == devices.end()) {
auto device_id = priv->cpp->avModel_->getDeviceIdFromName(device_name);
if (device_id.empty()) {
g_warning("set_video_device couldn't find device: %s", device_name);
return;
}
auto& device_id = *iter;
auto currentDevice = priv->cpp->avModel_->getDefaultDevice();
if (currentDevice == device_id) return;
priv->cpp->avModel_->setDefaultDevice(device_id);
......
......@@ -411,8 +411,14 @@ switch_video_input(GtkWidget *widget, GtkWidget *parent)
auto* label = gtk_menu_item_get_label(GTK_MENU_ITEM(widget));
g_return_if_fail(label);
if (priv->avModel_)
priv->avModel_->switchInputTo(label);
if (priv->avModel_) {
auto device_id = priv->avModel_->getDeviceIdFromName(label);
if (device_id.empty()) {
g_warning("switch_video_input couldn't find device: %s", label);
return;
}
priv->avModel_->switchInputTo(device_id);
}
}
static void
......@@ -532,8 +538,11 @@ video_widget_on_button_press_in_screen_event(VideoWidget *self, GdkEventButton
auto active_device = priv->avModel_->getCurrentRenderedDevice(
priv->remote->v_renderer->getId());
g_debug("active_device.name: %s", active_device.name.c_str());
for (auto device : device_list) {
GtkWidget *item = gtk_check_menu_item_new_with_mnemonic(device.c_str());
auto settings = priv->avModel_->getDeviceSettings(device);
GtkWidget *item = gtk_check_menu_item_new_with_mnemonic(settings.name.c_str());
gtk_menu_shell_append(GTK_MENU_SHELL(menu), item);
gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(item),
device == active_device.name
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment