From 36ac0aa3c0c93b84d47e5e07f04033a5092f7aa1 Mon Sep 17 00:00:00 2001
From: Alexandre Savard <alexandre.savard@savoirfairelinux.com>
Date: Tue, 11 Jan 2011 14:54:35 -0500
Subject: [PATCH] [#4878] Set keyboard focus on searchbar when selecting
 addressbook

---
 sflphone-client-gnome/src/contacts/calltree.c |  3 +++
 .../src/contacts/searchbar.c                  | 10 +++++++---
 .../src/contacts/searchbar.h                  | 19 ++++++++++++++++---
 sflphone-client-gnome/src/mainwindow.h        |  6 ------
 4 files changed, 26 insertions(+), 12 deletions(-)

diff --git a/sflphone-client-gnome/src/contacts/calltree.c b/sflphone-client-gnome/src/contacts/calltree.c
index 8afcee10ed..20993eb799 100644
--- a/sflphone-client-gnome/src/contacts/calltree.c
+++ b/sflphone-client-gnome/src/contacts/calltree.c
@@ -41,6 +41,7 @@
 #include "uimanager.h"
 #include "actions.h"
 #include "../imwindow.h"
+#include "searchbar.h"
 
 GtkWidget *sw;
 GtkCellRenderer *rend;
@@ -1400,6 +1401,8 @@ void calltree_display (calltab_t *tab)
         }
 
         gtk_toggle_tool_button_set_active ( (GtkToggleToolButton*) contactButton, TRUE);
+
+        set_forcus_on_addressbook_searchbar();
     }
 
     else
diff --git a/sflphone-client-gnome/src/contacts/searchbar.c b/sflphone-client-gnome/src/contacts/searchbar.c
index a10ff4461f..3b51168978 100644
--- a/sflphone-client-gnome/src/contacts/searchbar.c
+++ b/sflphone-client-gnome/src/contacts/searchbar.c
@@ -53,7 +53,6 @@ GdkPixbuf *outgoing_pixbuf = NULL;
 GdkPixbuf *missed_pixbuf = NULL;
 
 
-
 void searchbar_addressbook_activated (GtkEntry *entry, gchar *arg1 UNUSED, gpointer data UNUSED)
 {
     DEBUG ("Searchbar: Entry activated");
@@ -86,6 +85,11 @@ static void cbox_changed_cb (GtkWidget *widget, gpointer user_data UNUSED)
     addressbook_search (GTK_ENTRY (addressbookentry));
 }
 
+void set_forcus_on_addressbook_searchbar ()
+{
+    gtk_widget_grab_focus (addressbookentry);
+}
+
 void update_searchbar_addressbook_list()
 {
     gint count;
@@ -263,7 +267,7 @@ GtkWidget *addressbook_menu_new (void)
 void
 focus_on_searchbar_out()
 {
-    DEBUG ("set_focus_on_searchbar_out");
+    DEBUG ("Searchbar: Unset focus from search bar");
     // gtk_widget_grab_focus(GTK_WIDGET(sw));
     focus_is_on_searchbar = FALSE;
 }
@@ -271,7 +275,7 @@ focus_on_searchbar_out()
 void
 focus_on_searchbar_in()
 {
-    DEBUG ("set_focus_on_searchbar_in");
+    DEBUG ("Searchbar: Set focus on search bar");
     // gtk_widget_grab_focus(GTK_WIDGET(sw));
     focus_is_on_searchbar = TRUE;
 }
diff --git a/sflphone-client-gnome/src/contacts/searchbar.h b/sflphone-client-gnome/src/contacts/searchbar.h
index a15ab720c1..10ed938162 100644
--- a/sflphone-client-gnome/src/contacts/searchbar.h
+++ b/sflphone-client-gnome/src/contacts/searchbar.h
@@ -57,15 +57,20 @@ GdkPixbuf *waitingPixOff;
 SearchType HistorySearchType;
 
 /**
- * Create a new search bar with "type" passed in
- * parameter
+ * Create a new search bar for call hostory
  */
 GtkWidget* history_searchbar_new (void);
+
+/**
+ * Create a new search bar for addressbook
+ */
 GtkWidget* contacts_searchbar_new (void);
 
+/**
+ * Get type of call to be search from call history
+ */
 SearchType get_current_history_search_type (void);
 
-
 /**
  * Initialize a specific search bar
  */
@@ -81,11 +86,19 @@ void activateWaitingLayer();
  */
 void deactivateWaitingLayer();
 
+/**
+ * Set focus on addressbook search bar
+ */
+void set_forcus_on_addressbook_searchbar (void);
+
 /**
  * Reload combo box to update list of active addressbook
  */
 void update_searchbar_addressbook_list (void);
 
+/**
+ * Create a new menu listing all system addressbooks
+ */
 GtkWidget *addressbook_menu_new (void);
 
 #endif
diff --git a/sflphone-client-gnome/src/mainwindow.h b/sflphone-client-gnome/src/mainwindow.h
index 83abd42e38..17b30b44af 100644
--- a/sflphone-client-gnome/src/mainwindow.h
+++ b/sflphone-client-gnome/src/mainwindow.h
@@ -112,12 +112,6 @@ void statusbar_pop_message (guint id);
  */
 void statusbar_update_clock (gchar *time);
 
-
-//static gboolean
-//on_key_released (GtkWidget *widget, GdkEventKey *event,
-//                 gpointer user_data);
-// void set_focus_on_mainwindow();
-
 gboolean focus_is_on_calltree;
 
 gboolean focus_is_on_searchbar;
-- 
GitLab