From 28a615deeaba5b07658426ea55b54cec125ccf3b Mon Sep 17 00:00:00 2001
From: Sylvain Berfini <Sylvain.Berfini@Belledonne-Communications.com>
Date: Tue, 20 Dec 2011 16:44:49 +0100
Subject: [PATCH] Disabled add call button when useful, removed history
 callback button

---
 gtk/calllogs.c | 12 ++++++++----
 gtk/main.c     |  6 +++++-
 gtk/main.ui    | 32 +++++++++++++-------------------
 3 files changed, 26 insertions(+), 24 deletions(-)

diff --git a/gtk/calllogs.c b/gtk/calllogs.c
index 734496da35..5ff2a08eb5 100644
--- a/gtk/calllogs.c
+++ b/gtk/calllogs.c
@@ -44,8 +44,8 @@ void linphone_gtk_call_log_update(GtkWidget *w){
 		gtk_tree_view_set_model(v,GTK_TREE_MODEL(store));
 		g_object_unref(G_OBJECT(store));
 		fill_renderers(GTK_TREE_VIEW(linphone_gtk_get_widget(w,"logs_view")));
-		gtk_button_set_image(GTK_BUTTON(linphone_gtk_get_widget(w,"call_back_button")),
-		                     create_pixmap (linphone_gtk_get_ui_config("callback_button","status-green.png")));
+//		gtk_button_set_image(GTK_BUTTON(linphone_gtk_get_widget(w,"call_back_button")),
+//		                     create_pixmap (linphone_gtk_get_ui_config("callback_button","status-green.png")));
 	}
 	gtk_list_store_clear (store);
 
@@ -119,6 +119,10 @@ void linphone_gtk_history_row_activated(GtkWidget *treeview){
 	}
 }
 
+void linphone_gtk_history_row_selected(GtkWidget *treeview){
+	put_selection_to_uribar(treeview);
+}
+
 void linphone_gtk_clear_call_logs(GtkWidget *button){
 	linphone_core_clear_call_logs (linphone_gtk_get_core());
 	linphone_gtk_call_log_update(gtk_widget_get_toplevel(button));
@@ -152,8 +156,8 @@ GtkWidget * linphone_gtk_show_call_logs(void){
 	GtkWidget *w=(GtkWidget*)g_object_get_data(G_OBJECT(linphone_gtk_get_main_window()),"call_logs");
 	if (w==NULL){
 		w=linphone_gtk_create_window("call_logs");
-		gtk_button_set_image(GTK_BUTTON(linphone_gtk_get_widget(w,"call_back_button")),
-		                     create_pixmap (linphone_gtk_get_ui_config("callback_button","status-green.png")));
+//		gtk_button_set_image(GTK_BUTTON(linphone_gtk_get_widget(w,"call_back_button")),
+//		                     create_pixmap (linphone_gtk_get_ui_config("callback_button","status-green.png")));
 		g_object_set_data(G_OBJECT(mw),"call_logs",w);
 		g_signal_connect(G_OBJECT(w),"response",(GCallback)linphone_gtk_call_log_response,NULL);
 		gtk_widget_show(w);
diff --git a/gtk/main.c b/gtk/main.c
index 4c918b18d3..73e99cc964 100644
--- a/gtk/main.c
+++ b/gtk/main.c
@@ -681,7 +681,11 @@ static void linphone_gtk_update_call_buttons(LinphoneCall *call){
 	gtk_widget_set_visible(button,!add_call);
 	
 	button=linphone_gtk_get_widget(mw,"add_call");
-	gtk_widget_set_sensitive(button,start_active);
+	if (linphone_core_sound_resources_locked(lc) || (call && linphone_call_get_state(call)==LinphoneCallIncomingReceived)) {
+		gtk_widget_set_sensitive(button,FALSE);
+	} else {
+		gtk_widget_set_sensitive(button,start_active);
+	}
 	gtk_widget_set_visible(button,add_call);
 	
 	gtk_widget_set_sensitive(linphone_gtk_get_widget(mw,"terminate_call"),stop_active);
diff --git a/gtk/main.ui b/gtk/main.ui
index a94f5e55f0..2cfe555e7d 100644
--- a/gtk/main.ui
+++ b/gtk/main.ui
@@ -1,6 +1,7 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <interface>
   <requires lib="gtk+" version="2.22"/>
+  <!-- interface-naming-policy toplevel-contextual -->
   <object class="GtkWindow" id="dummy_conf_window">
     <property name="can_focus">False</property>
     <child>
@@ -651,6 +652,8 @@
                                     <property name="invisible_char">●</property>
                                     <property name="primary_icon_activatable">False</property>
                                     <property name="secondary_icon_activatable">False</property>
+                                    <property name="primary_icon_sensitive">True</property>
+                                    <property name="secondary_icon_sensitive">True</property>
                                     <signal name="activate" handler="linphone_gtk_uri_bar_activate" swapped="no"/>
                                   </object>
                                   <packing>
@@ -742,6 +745,8 @@
                                     <property name="invisible_char_set">True</property>
                                     <property name="primary_icon_activatable">False</property>
                                     <property name="secondary_icon_activatable">False</property>
+                                    <property name="primary_icon_sensitive">True</property>
+                                    <property name="secondary_icon_sensitive">True</property>
                                     <signal name="changed" handler="linphone_gtk_show_friends" swapped="no"/>
                                   </object>
                                   <packing>
@@ -807,9 +812,6 @@
                                     <signal name="cursor-changed" handler="linphone_gtk_contact_clicked" swapped="no"/>
                                     <signal name="row-activated" handler="linphone_gtk_contact_activated" swapped="no"/>
                                     <signal name="popup-menu" handler="linphone_gtk_popup_contact_menu" swapped="no"/>
-                                    <child internal-child="selection">
-                                      <object class="GtkTreeSelection" id="treeview-selection1"/>
-                                    </child>
                                   </object>
                                 </child>
                               </object>
@@ -835,6 +837,8 @@
                                         <property name="invisible_char_set">True</property>
                                         <property name="primary_icon_activatable">False</property>
                                         <property name="secondary_icon_activatable">False</property>
+                                        <property name="primary_icon_sensitive">True</property>
+                                        <property name="secondary_icon_sensitive">True</property>
                                         <signal name="activate" handler="linphone_gtk_directory_search_activate" swapped="no"/>
                                         <signal name="icon-press" handler="linphone_gtk_directory_search_activate" swapped="no"/>
                                         <signal name="focus-in-event" handler="linphone_gtk_directory_search_focus_in" swapped="no"/>
@@ -1008,19 +1012,7 @@
                                   </packing>
                                 </child>
                                 <child>
-                                  <object class="GtkButton" id="call_back_button">
-                                    <property name="label" translatable="yes">Call</property>
-                                    <property name="visible">True</property>
-                                    <property name="can_focus">True</property>
-                                    <property name="receives_default">True</property>
-                                    <property name="use_action_appearance">False</property>
-                                    <signal name="clicked" handler="linphone_gtk_call_log_callback" swapped="no"/>
-                                  </object>
-                                  <packing>
-                                    <property name="expand">False</property>
-                                    <property name="fill">False</property>
-                                    <property name="position">1</property>
-                                  </packing>
+                                  <placeholder/>
                                 </child>
                                 <child>
                                   <placeholder/>
@@ -1043,10 +1035,8 @@
                                     <property name="visible">True</property>
                                     <property name="can_focus">True</property>
                                     <property name="headers_visible">False</property>
+                                    <signal name="cursor-changed" handler="linphone_gtk_history_row_selected" swapped="no"/>
                                     <signal name="row-activated" handler="linphone_gtk_history_row_activated" swapped="no"/>
-                                    <child internal-child="selection">
-                                      <object class="GtkTreeSelection" id="treeview-selection2"/>
-                                    </child>
                                   </object>
                                 </child>
                               </object>
@@ -1550,6 +1540,8 @@
                                         <property name="invisible_char">●</property>
                                         <property name="primary_icon_activatable">False</property>
                                         <property name="secondary_icon_activatable">False</property>
+                                        <property name="primary_icon_sensitive">True</property>
+                                        <property name="secondary_icon_sensitive">True</property>
                                       </object>
                                       <packing>
                                         <property name="left_attach">1</property>
@@ -1564,6 +1556,8 @@
                                         <property name="invisible_char">●</property>
                                         <property name="primary_icon_activatable">False</property>
                                         <property name="secondary_icon_activatable">False</property>
+                                        <property name="primary_icon_sensitive">True</property>
+                                        <property name="secondary_icon_sensitive">True</property>
                                       </object>
                                       <packing>
                                         <property name="left_attach">1</property>
-- 
GitLab