1
0
Fork 0
mirror of https://gitlab.gnome.org/GNOME/calls.git synced 2024-12-12 07:37:35 +00:00

BestMatch: remove BestMatchView to reduce vala code

This commit is contained in:
Julian Sparber 2021-01-28 15:17:30 +01:00 committed by Evangelos Ribeiro Tzaras
parent 2a85b60f7c
commit f1946aff79
5 changed files with 10 additions and 56 deletions

View file

@ -1,49 +0,0 @@
/*
* Copyright (C) 2019 Purism SPC
*
* This file is part of Calls.
*
* Calls 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.
*
* Calls 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 Calls. If not, see <http://www.gnu.org/licenses/>.
*
* Author: Bob Ham <bob.ham@puri.sm>
*
* SPDX-License-Identifier: GPL-3.0-or-later
*
*/
public class Calls.BestMatchView : Folks.SearchView
{
public Folks.Individual? best_match
{
get;
private set;
}
private void update ()
{
best_match =
individuals.is_empty ? null : individuals.first ();
}
public BestMatchView (Folks.IndividualAggregator aggregator,
Folks.Query query)
{
base (aggregator, query);
this.individuals_changed_detailed.connect
((sv, p) => { update (); });
update();
}
}

View file

@ -24,6 +24,7 @@
#include "calls-best-match.h"
#include "calls-contacts-provider.h"
#include "calls-vala.h"
#include "util.h"
#include <glib/gi18n.h>
@ -33,7 +34,7 @@ struct _CallsBestMatch
{
GObject parent_instance;
CallsBestMatchView *view;
FolksSearchView *view;
FolksIndividual *best_match;
gchar *phone_number;
};
@ -80,7 +81,11 @@ notify_avatar (CallsBestMatch *self)
static void
update_best_match (CallsBestMatch *self)
{
FolksIndividual *best_match = calls_best_match_view_get_best_match (self->view);
g_autoptr (GeeSortedSet) individuals = folks_search_view_get_individuals (self->view);
FolksIndividual *best_match = NULL;
if (!gee_collection_get_is_empty (GEE_COLLECTION (individuals)))
best_match = gee_sorted_set_first (individuals);
if (best_match == self->best_match)
return;
@ -266,10 +271,10 @@ calls_best_match_set_phone_number (CallsBestMatch *self,
g_warning ("Failed to convert %s to a phone number: %s", phone_number, error->message);
} else {
query = calls_phone_number_query_new (number);
self->view = calls_best_match_view_new (folks_individual_aggregator_dup (), FOLKS_QUERY (query));
self->view = folks_search_view_new (folks_individual_aggregator_dup (), FOLKS_QUERY (query));
g_signal_connect_swapped (self->view,
"notify::best-match",
"individuals-changed-detailed",
G_CALLBACK (update_best_match),
self);

View file

@ -25,8 +25,6 @@
#ifndef CALLS_BEST_MATCH_H__
#define CALLS_BEST_MATCH_H__
#include "calls-vala.h"
#include <gdk/gdk.h>
G_BEGIN_DECLS

View file

@ -37,6 +37,7 @@ G_BEGIN_DECLS
G_DEFINE_AUTOPTR_CLEANUP_FUNC (GeeMap, g_object_unref)
G_DEFINE_AUTOPTR_CLEANUP_FUNC (GeeSet, g_object_unref)
G_DEFINE_AUTOPTR_CLEANUP_FUNC (GeeSortedSet, g_object_unref)
G_DEFINE_AUTOPTR_CLEANUP_FUNC (GeeCollection, g_object_unref)
G_DEFINE_AUTOPTR_CLEANUP_FUNC (EPhoneNumber, e_phone_number_free)

View file

@ -53,7 +53,6 @@ calls_vala_deps = [
calls_vala_sources = files (
[
'calls-phone-number-query.vala',
'calls-best-match-view.vala',
]
)