Skip to content
Snippets Groups Projects
Commit c5312379 authored by Emmanuel Milou's avatar Emmanuel Milou
Browse files

clean up history/contacts - restore history

parent 0fc7dfab
No related branches found
No related tags found
No related merge requests found
......@@ -233,7 +233,7 @@ gboolean sflphone_init()
current_calls = calltab_init();
history = calltab_init();
contacts = calltab_init();
if(SHOW_SEARCHBAR) histfilter = create_filter(GTK_TREE_MODEL(history->store));
//if(SHOW_SEARCHBAR) histfilter = create_filter(GTK_TREE_MODEL(history->store));
init();
account_list_init ();
codec_list_init();
......
......@@ -23,7 +23,7 @@
#include <calllist.h>
#include <gtk/gtk.h>
GtkTreeModel* histfilter;
//GtkTreeModel* histfilter;
calltab_t* calltab_init();
......
/*
* Copyright (C) 2008 Savoir-Faire Linux inc.
* Author: Antoine Reversat <antoine.reversat@savoirfairelinux.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include <string.h>
#include <historyfilter.h>
#include <calltree.h>
GtkWidget * filter_entry;
GtkTreeModel*
create_filter(GtkTreeModel* child)
{
GtkTreeModel* ret = gtk_tree_model_filter_new(child, NULL);
gtk_tree_model_filter_set_visible_func(GTK_TREE_MODEL_FILTER(ret), is_visible, NULL, NULL);
return GTK_TREE_MODEL(ret);
}
gboolean
is_visible(GtkTreeModel* model, GtkTreeIter* iter, gpointer data UNUSED)
{
if( SHOW_SEARCHBAR )
{
GValue val;
gchar* text = NULL;
gchar* search = (gchar*)gtk_entry_get_text(GTK_ENTRY(filter_entry));
memset (&val, 0, sizeof(val));
gtk_tree_model_get_value(GTK_TREE_MODEL(model), iter, 1, &val);
if(G_VALUE_HOLDS_STRING(&val)){
text = (gchar *)g_value_get_string(&val);
}
if(text != NULL && g_ascii_strncasecmp(search, _("Search"), 6) != 0){
return g_regex_match_simple(search, text, G_REGEX_CASELESS, 0);
}
g_value_unset (&val);
return TRUE;
}
return TRUE;
}
void
filter_entry_changed(GtkEntry* entry UNUSED, gchar* arg1 UNUSED, gpointer data UNUSED)
{
gtk_toggle_tool_button_set_active(GTK_TOGGLE_TOOL_BUTTON(historyButton), TRUE);
gtk_tree_model_filter_refilter(GTK_TREE_MODEL_FILTER(histfilter));
}
void
clear_filter_entry_if_default(GtkWidget* widget UNUSED, gpointer user_data UNUSED)
{
if(g_ascii_strncasecmp(gtk_entry_get_text(GTK_ENTRY(filter_entry)), _("Search"), 6) == 0)
gtk_entry_set_text(GTK_ENTRY(filter_entry), "");
}
GtkWidget*
create_filter_entry()
{
GtkWidget* image;
GtkWidget* ret = gtk_hbox_new(FALSE, 0);
filter_entry = sexy_icon_entry_new();
//filter_entry = gtk_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);
gtk_box_pack_start(GTK_BOX(ret), filter_entry, TRUE, TRUE, 0);
return ret;
}
/*
* Copyright (C) 2007 Savoir-Faire Linux inc.
* Author: Antoine Reversat <antoine.reversat@savoirfairelinux.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#ifndef __HFILTER_H__
#define __HFILTER_H__
#include <calllist.h>
#include <gtk/gtk.h>
#include <libsexy/sexy-icon-entry.h>
GtkTreeModel* create_filter(GtkTreeModel* child);
gboolean is_visible(GtkTreeModel* model, GtkTreeIter* iter, gpointer data);
GtkWidget* create_filter_entry();
#endif
......@@ -172,7 +172,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)
{
......
......@@ -87,6 +87,7 @@ static void handler_async_search (GList *hits, gpointer user_data) {
entry = i->data;
if (entry)
{
g_print ("%s\n", entry->name);
/* Get the photo */
if (addressbook_display (addressbook_config, ADDRESSBOOK_DISPLAY_CONTACT_PHOTO))
photo = entry->photo;
......@@ -106,12 +107,12 @@ static void handler_async_search (GList *hits, gpointer user_data) {
}
void filter_entry_changed (GtkEntry* entry UNUSED, gchar* arg1 UNUSED, gpointer data UNUSED) {
void filter_entry_changed (GtkEntry* entry, gchar* arg1 UNUSED, gpointer data UNUSED) {
AddressBook_Config *addressbook_config;
/* Switch to the address book when the focus is on the search bar */
if (active_calltree == current_calls)
if (active_calltree != contacts)
display_calltree (contacts);
......@@ -120,7 +121,12 @@ void filter_entry_changed (GtkEntry* entry UNUSED, gchar* arg1 UNUSED, gpointer
// Load the address book parameters
addressbook_load_parameters (&addressbook_config);
// Start the asynchronous search as soon as we have an entry */
search_async (gtk_entry_get_text (GTK_ENTRY (filter_entry)), addressbook_config->max_results, &handler_async_search, addressbook_config);
search_async (gtk_entry_get_text (GTK_ENTRY (entry)), addressbook_config->max_results, &handler_async_search, addressbook_config);
}
else if (active_calltree == history) {
// Filter the displayed calls
}
}
......@@ -138,7 +144,6 @@ GtkWidget* create_filter_entry() {
GtkWidget* ret = gtk_hbox_new(FALSE, 0);
filter_entry = sexy_icon_entry_new();
//filter_entry = gtk_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) );
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment