Commit 4f3b5d1d authored by Hugo Lefeuvre's avatar Hugo Lefeuvre Committed by Hugo Lefeuvre

currentcallview: fix broken peer info panel

+ make sure updateNameAndPhoto() is called at least once in setCallInfo().
  (calling it in in the state changed callback is not sufficient since it
  might never be executed)
+ move various gtk_widget_set_sensitive() calls from updateDetails() to
  updateState(), there is no reason to execute those every second
+ always display bestId (registered name of ring info hash), display alias
  if available
+ do not display quality button and video on/off button in audio only calls

Change-Id: I4127f4a88595ba09bef7696814f0dac7ea38329f
parent 047a66d6
......@@ -766,6 +766,7 @@ CppImpl::setCallInfo()
// change some things depending on call state
updateState();
updateDetails();
updateNameAndPhoto();
g_signal_connect(widgets->video_widget, "button-press-event",
G_CALLBACK(video_widget_on_button_press_in_screen_event), nullptr);
......@@ -1003,12 +1004,6 @@ CppImpl::updateDetails()
gtk_label_set_text(GTK_LABEL(widgets->label_duration),
(*accountInfo)->callModel->getFormattedCallDuration(callRendered).c_str());
auto call = (*accountInfo)->callModel->getCall(callRendered);
gtk_widget_set_sensitive(GTK_WIDGET(widgets->togglebutton_muteaudio),
(call.type != lrc::api::call::Type::CONFERENCE));
gtk_widget_set_sensitive(GTK_WIDGET(widgets->togglebutton_mutevideo),
(call.type != lrc::api::call::Type::CONFERENCE));
}
void
......@@ -1031,18 +1026,30 @@ CppImpl::updateState()
gtk_button_set_image(GTK_BUTTON(pauseBtn), image);
auto audioButton = GTK_TOGGLE_BUTTON(widgets->togglebutton_muteaudio);
gtk_widget_set_sensitive(GTK_WIDGET(widgets->togglebutton_muteaudio),
(call.type != lrc::api::call::Type::CONFERENCE));
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widgets->togglebutton_muteaudio), call.audioMuted);
auto imageMuteAudio = gtk_image_new_from_resource ("/cx/jami/JamiGnome/mute_audio");
if (call.audioMuted)
imageMuteAudio = gtk_image_new_from_resource ("/cx/jami/JamiGnome/unmute_audio");
gtk_button_set_image(GTK_BUTTON(audioButton), imageMuteAudio);
auto videoButton = GTK_TOGGLE_BUTTON(widgets->togglebutton_mutevideo);
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widgets->togglebutton_mutevideo), call.videoMuted);
auto imageMuteVideo = gtk_image_new_from_resource ("/cx/jami/JamiGnome/mute_video");
if (call.videoMuted)
imageMuteVideo = gtk_image_new_from_resource ("/cx/jami/JamiGnome/unmute_video");
gtk_button_set_image(GTK_BUTTON(videoButton), imageMuteVideo);
if (!call.isAudioOnly) {
auto videoButton = GTK_TOGGLE_BUTTON(widgets->togglebutton_mutevideo);
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widgets->togglebutton_mutevideo), call.videoMuted);
auto imageMuteVideo = gtk_image_new_from_resource ("/cx/jami/JamiGnome/mute_video");
if (call.videoMuted)
imageMuteVideo = gtk_image_new_from_resource ("/cx/jami/JamiGnome/unmute_video");
gtk_button_set_image(GTK_BUTTON(videoButton), imageMuteVideo);
gtk_widget_set_sensitive(GTK_WIDGET(widgets->togglebutton_mutevideo),
(call.type != lrc::api::call::Type::CONFERENCE));
gtk_widget_show(widgets->togglebutton_mutevideo);
gtk_widget_show(widgets->scalebutton_quality);
} else {
gtk_widget_hide(widgets->scalebutton_quality);
gtk_widget_hide(widgets->togglebutton_mutevideo);
}
gchar *status = g_strdup_printf("%s", lrc::api::call::to_string(call.status).c_str());
gtk_label_set_text(GTK_LABEL(widgets->label_status), status);
......@@ -1066,14 +1073,22 @@ CppImpl::updateNameAndPhoto()
try {
auto contactInfo = (*accountInfo)->contactModel->getContact(conversation->participants.front());
auto name = contactInfo.profileInfo.alias;
gtk_label_set_text(GTK_LABEL(widgets->label_name), name.c_str());
auto bestId = contactInfo.registeredName;
if (name != bestId) {
gtk_label_set_text(GTK_LABEL(widgets->label_bestId), bestId.c_str());
gtk_widget_show(widgets->label_bestId);
auto alias = contactInfo.profileInfo.alias;
auto bestName = contactInfo.registeredName;
if (bestName.empty())
bestName = contactInfo.profileInfo.uri;
if (bestName == alias)
alias = "";
bestName.erase(std::remove(bestName.begin(), bestName.end(), '\r'), bestName.end());
alias.erase(std::remove(alias.begin(), alias.end(), '\r'), alias.end());
if (alias != "") {
gtk_label_set_text(GTK_LABEL(widgets->label_name), alias.c_str());
gtk_widget_show(widgets->label_name);
}
gtk_label_set_text(GTK_LABEL(widgets->label_bestId), bestName.c_str());
gtk_widget_show(widgets->label_bestId);
} catch (const std::out_of_range&) {
// ContactModel::getContact() exception
}
......
......@@ -147,7 +147,7 @@
<property name="orientation">vertical</property>
<child>
<object class="GtkLabel" id="label_name">
<property name="visible">True</property>
<property name="visible">False</property>
<property name="can_focus">True</property>
<property name="selectable">True</property>
<property name="ellipsize">end</property>
......@@ -164,7 +164,7 @@
</child>
<child>
<object class="GtkLabel" id="label_bestId">
<property name="visible">False</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="selectable">True</property>
<property name="halign">start</property>
......
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