Commit 2b2af4a2 authored by Alexandre Savard's avatar Alexandre Savard
Browse files

Search history restored

parent d0d40cb8
......@@ -231,8 +231,9 @@ gboolean sflphone_init()
{
dbus_register(getpid(), "Gtk+ Client");
current_calls = calltab_init(NULL);
history = calltab_init("history");
// history = calltab_init("history");
contacts = calltab_init("contacts");
history = calltab_init("history");
histfilter = create_filter(GTK_TREE_MODEL(history->store));
init();
account_list_init ();
......@@ -295,6 +296,7 @@ sflphone_hang_up()
void
sflphone_pick_up()
{
call_t * selectedCall = call_get_selected(active_calltree);
if(selectedCall)
{
......@@ -529,7 +531,7 @@ process_dialing(call_t * c, guint keyval, gchar * key)
call_t *
sflphone_new_call()
{
call_t *c;
gchar *from, *to;
......@@ -680,9 +682,10 @@ sflphone_keypad( guint keyval, gchar * key)
sflphone_place_call ( call_t * c )
{
if(c->state == CALL_STATE_DIALING && strcmp(c->to, "") != 0)
{
//format_phone_number (&c->to);
if( account_list_get_size() == 0 )
......@@ -699,19 +702,26 @@ sflphone_place_call ( call_t * c )
else
{
account_t * current;
if(c->accountID != 0)
if(c->accountID != 0){
current = account_list_get_by_id(c->accountID);
else
}
else {
current = account_list_get_current();
}
// printf("sflphone_place_call :: c->accountID : %i \n",c->accountID);
// account_t * current = c->accountID;
if( current )
{
if(g_strcasecmp(g_hash_table_lookup( current->properties, "Status"),"REGISTERED")==0)
{
// OK, everything alright - the call is made with the current account
......@@ -734,6 +744,7 @@ sflphone_place_call ( call_t * c )
}
else
{
// No current accounts have been setup.
// So we place a call with the first registered account
// and we change the current account
......@@ -756,6 +767,7 @@ sflphone_place_call ( call_t * c )
void
sflphone_display_selected_codec (const gchar* codecName)
{
call_t * selectedCall = call_get_selected(current_calls);
gchar* msg;
account_t* acc;
......
......@@ -120,6 +120,7 @@ typedef struct {
GtkWidget* tree;
GtkWidget* searchbar;
// GtkTreeModel* histfilter;
// Calllist vars
GQueue* callQueue;
......
......@@ -36,6 +36,7 @@ calltab_init(gchar* searchbar_type)
ret->searchbar = NULL;
ret->callQueue = NULL;
ret->selectedCall = NULL;
// ret->histfilter = NULL;
create_call_tree(ret, searchbar_type);
call_list_init(ret);
......
......@@ -25,6 +25,7 @@
#include <actions.h>
#include <calltree.h>
#include <calllist.h>
#include <calltab.h>
#include <menus.h>
#include <dbus.h>
#include <contactlist/eds.h>
......@@ -95,6 +96,7 @@ button_pressed(GtkWidget* widget, GdkEventButton *event, gpointer user_data UNUS
static void
call_button( GtkWidget *widget UNUSED, gpointer data UNUSED)
{
g_print("------ call_button ----- \n");
call_t * selectedCall;
call_t* new_call;
gchar *to, *from;
......@@ -377,6 +379,7 @@ toolbar_update_buttons ()
static void
selected(GtkTreeSelection *sel, void* data UNUSED )
{
g_print("---- selected --- \n");
GtkTreeIter iter;
GValue val;
GtkTreeModel *model = (GtkTreeModel*)active_calltree->store;
......@@ -666,11 +669,10 @@ reset_call_tree (calltab_t* tab)
gtk_box_pack_start(GTK_BOX(tab->tree), sw, TRUE, TRUE, 0);
// no search bar if tab is either "history" or "addressbook"
if(searchbar_type){
create_searchbar(tab,searchbar_type);
gtk_box_pack_start(GTK_BOX(tab->tree), tab->searchbar, FALSE, TRUE, 0);
}
gtk_widget_show(tab->tree);
......@@ -842,29 +844,14 @@ void
create_searchbar(calltab_t* tab, gchar* searchbar_type)
{
// g_strcmp0 returns 0 if str1 == str2
if(g_strcmp0(searchbar_type,"history") == 0){
// GtkTreeIter *iter;
// GtkTreeModel *model = (GtkTreeModel*)history->store;
// create_filter (model);
// gtk_tree_model_get_iter_first (history->store, iter);
// gtk_tree_model_get_iter (model, &iter, NULL);
if(g_strcmp0(searchbar_type,"history") == 0){
// create_filter (model);
tab->searchbar = create_filter_entry_history();
// is_visible(model, iter);
tab->searchbar = create_filter_entry();
gtk_tree_view_set_model(GTK_TREE_VIEW(history->view), GTK_TREE_MODEL(histfilter));
}
else if(g_strcmp0(searchbar_type,"contacts") == 0)
tab->searchbar = create_filter_entry();
tab->searchbar = create_filter_entry_contact();
}
......
......@@ -31,7 +31,8 @@
* @brief The GtkTreeView that list calls in the main window.
*/
GtkWidget * filter_entry;
GtkWidget * filter_entry_contact;
GtkWidget * filter_entry_history;
calltab_t* active_calltree;
......
......@@ -178,7 +178,7 @@ create_main_window ()
/* dont't show the contact list */
gtk_widget_hide(contacts->tree);
//gtk_tree_view_set_model(GTK_TREE_VIEW(history->view), GTK_TREE_MODEL(histfilter));
gtk_tree_view_set_model(GTK_TREE_VIEW(history->view), GTK_TREE_MODEL(histfilter));
// Configuration wizard
if (account_list_get_size() == 0)
{
......
......@@ -45,7 +45,7 @@ gboolean is_visible (GtkTreeModel* model, GtkTreeIter* iter, gpointer data UNUSE
GValue val;
gchar* text = NULL;
gchar* search = (gchar*)gtk_entry_get_text(GTK_ENTRY(filter_entry));
gchar* search = (gchar*)gtk_entry_get_text(GTK_ENTRY(filter_entry_history));
memset (&val, 0, sizeof(val));
gtk_tree_model_get_value(GTK_TREE_MODEL(model), iter, 1, &val);
if(G_VALUE_HOLDS_STRING(&val)){
......@@ -113,8 +113,8 @@ void filter_entry_changed (GtkEntry* entry, gchar* arg1 UNUSED, gpointer data UN
AddressBook_Config *addressbook_config;
/* Switch to the address book when the focus is on the search bar */
if (active_calltree != contacts)
display_calltree (contacts);
// if (active_calltree != contacts)
// display_calltree (contacts);
/* We want to search in the contact list */
......@@ -136,27 +136,41 @@ void filter_entry_changed (GtkEntry* entry, gchar* arg1 UNUSED, gpointer data UN
}
void clear_filter_entry_if_default (GtkWidget* widget UNUSED, gpointer user_data UNUSED) {
void
filter_entry_changed_history(GtkEntry* entry UNUSED, gchar* arg1 UNUSED, gpointer data UNUSED)
{
g_print("--- filter_entry_changed_history --- \n");
if(g_ascii_strncasecmp(gtk_entry_get_text(GTK_ENTRY(filter_entry)), _("Search"), 6) == 0)
gtk_entry_set_text(GTK_ENTRY(filter_entry), "");
if (active_calltree != history)
display_calltree (history);
// gtk_toggle_tool_button_set_active(GTK_TOGGLE_TOOL_BUTTON(historyButton), TRUE);
gtk_tree_model_filter_refilter(GTK_TREE_MODEL_FILTER(histfilter));
// gtk_tree_view_set_model(GTK_TREE_VIEW(history->view), GTK_TREE_MODEL(histfilter));
}
GtkWidget* create_filter_entry() {
void clear_filter_entry_if_default (GtkWidget* widget, gpointer user_data UNUSED) {
if(g_ascii_strncasecmp(gtk_entry_get_text(GTK_ENTRY(widget)), _("Search"), 6) == 0)
gtk_entry_set_text(GTK_ENTRY(widget), "");
}
GtkWidget* create_filter_entry_contact() {
GtkWidget* image;
GtkWidget* ret = gtk_hbox_new(FALSE, 0);
filter_entry = sexy_icon_entry_new();
filter_entry_contact = sexy_icon_entry_new();
image = gtk_image_new_from_stock( GTK_STOCK_FIND , GTK_ICON_SIZE_SMALL_TOOLBAR);
sexy_icon_entry_set_icon( SEXY_ICON_ENTRY(filter_entry), SEXY_ICON_ENTRY_PRIMARY , GTK_IMAGE(image) );
sexy_icon_entry_add_clear_button( SEXY_ICON_ENTRY(filter_entry) );
gtk_entry_set_text(GTK_ENTRY(filter_entry), _("Search"));
g_signal_connect(GTK_ENTRY(filter_entry), "changed", G_CALLBACK(filter_entry_changed), NULL);
g_signal_connect(GTK_ENTRY(filter_entry), "grab-focus", G_CALLBACK(clear_filter_entry_if_default), NULL);
sexy_icon_entry_set_icon( SEXY_ICON_ENTRY(filter_entry_contact), SEXY_ICON_ENTRY_PRIMARY , GTK_IMAGE(image) );
sexy_icon_entry_add_clear_button( SEXY_ICON_ENTRY(filter_entry_contact) );
gtk_entry_set_text(GTK_ENTRY(filter_entry_contact), _("Search"));
g_signal_connect(GTK_ENTRY(filter_entry_contact), "changed", G_CALLBACK(filter_entry_changed), NULL);
g_signal_connect(GTK_ENTRY(filter_entry_contact), "grab-focus", G_CALLBACK(clear_filter_entry_if_default), NULL);
gtk_box_pack_start(GTK_BOX(ret), filter_entry, TRUE, TRUE, 0);
gtk_box_pack_start(GTK_BOX(ret), filter_entry_contact, TRUE, TRUE, 0);
// Create waiting icon
waitingPixOn = gdk_pixbuf_animation_new_from_file(ICONS_DIR "/wait-on.gif", NULL);
......@@ -169,6 +183,36 @@ GtkWidget* create_filter_entry() {
}
GtkWidget* create_filter_entry_history() {
g_print("--- create_filter_entry_history --- \n");
GtkWidget* image;
GtkWidget* ret = gtk_hbox_new(FALSE, 0);
filter_entry_history = sexy_icon_entry_new();
image = gtk_image_new_from_stock( GTK_STOCK_FIND , GTK_ICON_SIZE_SMALL_TOOLBAR);
sexy_icon_entry_set_icon( SEXY_ICON_ENTRY(filter_entry_history), SEXY_ICON_ENTRY_PRIMARY , GTK_IMAGE(image) );
sexy_icon_entry_add_clear_button( SEXY_ICON_ENTRY(filter_entry_history) );
gtk_entry_set_text(GTK_ENTRY(filter_entry_history), _("Search"));
g_signal_connect(GTK_ENTRY(filter_entry_history), "changed", G_CALLBACK(filter_entry_changed_history), NULL);
g_signal_connect(GTK_ENTRY(filter_entry_history), "grab-focus", G_CALLBACK(clear_filter_entry_if_default), NULL);
gtk_box_pack_start(GTK_BOX(ret), filter_entry_history, TRUE, TRUE, 0);
// Create waiting icon
//waitingPixOn = gdk_pixbuf_animation_new_from_file(ICONS_DIR "/wait-on.gif", NULL);
//waitingPixOff = gdk_pixbuf_new_from_file(ICONS_DIR "/wait-off.gif", NULL);
//waitingLayer = gtk_image_new_from_pixbuf(waitingPixOff);
//gtk_box_pack_end(GTK_BOX(ret), waitingLayer, TRUE, TRUE, 0);
return ret;
}
void activateWaitingLayer() {
gtk_image_set_from_animation(GTK_IMAGE(waitingLayer),waitingPixOn);
}
......
......@@ -36,7 +36,9 @@ GtkTreeModel* create_filter(GtkTreeModel* child);
gboolean is_visible(GtkTreeModel* model, GtkTreeIter* iter, gpointer data);
GtkWidget* create_filter_entry();
GtkWidget* create_filter_entry_contact();
GtkWidget* create_filter_entry_history();
void activateWaitingLayer();
......
Supports Markdown
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