~noskcaj/ubuntu/saucy/sflphone/merge-1.2.3-2

« back to all changes in this revision

Viewing changes to gnome/src/contacts/history.c

  • Committer: Jackson Doak
  • Date: 2013-07-10 21:04:46 UTC
  • mfrom: (20.1.3 sid)
  • Revision ID: noskcaj@ubuntu.com-20130710210446-y8f587vza807icr9
Properly merged from upstream.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/*
2
 
 *  Copyright (C) 2004, 2005, 2006, 2008, 2009, 2010, 2011 Savoir-Faire Linux Inc.
 
2
 *  Copyright (C) 2004-2012 Savoir-Faire Linux Inc.
3
3
 *  Author: Julien Bonjean <julien.bonjean@savoirfairelinux.com>
4
4
 *
5
5
 *  This program is free software; you can redistribute it and/or modify
14
14
 *
15
15
 *  You should have received a copy of the GNU General Public License
16
16
 *  along with this program; if not, write to the Free Software
17
 
 *   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 
17
 *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301 USA.
18
18
 *
19
19
 *  Additional permission under GNU GPL version 3 section 7:
20
20
 *
30
30
 
31
31
#include <string.h>
32
32
#include "history.h"
 
33
#include "calltree.h"
33
34
#include "searchbar.h"
34
35
#include "calltab.h"
35
 
#include "unused.h"
36
36
 
37
37
static GtkTreeModel *history_filter;
38
38
static GtkEntry *history_searchbar_widget;
52
52
    }
53
53
}
54
54
 
55
 
static gboolean history_is_visible(GtkTreeModel* model, GtkTreeIter* iter, gpointer data UNUSED)
 
55
static gboolean
 
56
history_is_visible(GtkTreeModel* model, GtkTreeIter* iter, G_GNUC_UNUSED gpointer data)
56
57
{
57
 
    /* Skip conferences */
58
 
    if (is_conference(model, iter))
59
 
        return TRUE;
60
 
 
 
58
    gboolean visible = TRUE;
61
59
    // Fetch the call description
62
60
    const gchar *text = NULL;
63
61
    const gchar *id = NULL;
64
62
    gtk_tree_model_get(model, iter, COLUMN_ACCOUNT_DESC, &text, COLUMN_ID, &id, -1);
 
63
    if (!id)
 
64
        return visible;
65
65
    callable_obj_t *history_entry = calllist_get_call(history_tab, id);
66
66
 
67
 
    gboolean ret = TRUE;
68
67
    if (text && history_entry) {
69
68
        // Filter according to the type of call
70
69
        // MISSED, INCOMING, OUTGOING, ALL
74
73
            return TRUE;
75
74
 
76
75
        SearchType search_type = get_current_history_search_type();
77
 
        ret = g_regex_match_simple(search, text, G_REGEX_CASELESS, 0);
 
76
        visible = g_regex_match_simple(search, text, G_REGEX_CASELESS, 0);
78
77
 
79
78
        if (search_type == SEARCH_ALL)
80
 
            return ret;
 
79
            return visible;
81
80
        else // We need a match on the history_state and the current search type
82
 
            ret = ret && search_type_matches_state(search_type, history_entry->_history_state);
 
81
            visible = visible && search_type_matches_state(search_type, history_entry->_history_state);
83
82
    }
84
83
 
85
 
    return ret;
 
84
    return visible;
86
85
}
87
86
 
88
87
static GtkTreeModel* history_create_filter(GtkTreeModel* child)
92
91
    return GTK_TREE_MODEL(ret);
93
92
}
94
93
 
95
 
void history_search(void)
 
94
void history_search()
96
95
{
97
96
    if (history_filter != NULL)
98
97
        gtk_tree_model_filter_refilter(GTK_TREE_MODEL_FILTER(history_filter));