aboutsummaryrefslogtreecommitdiffstats
path: root/lib/ephy-autocompletion.h
blob: 7a31c0c9f0964687c3c057995b3aa7e0859e39d4 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
/*
 *  Copyright (C) 2002  Ricardo Fernández Pascual
 *
 *  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 2, 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 */

#ifndef EPHY_AUTOCOMPLETION_H
#define EPHY_AUTOCOMPLETION_H

#include <glib-object.h>
#include "ephy-autocompletion-source.h"

G_BEGIN_DECLS

/* object forward declarations */

typedef struct _EphyAutocompletion EphyAutocompletion;
typedef struct _EphyAutocompletionClass EphyAutocompletionClass;
typedef struct _EphyAutocompletionPrivate EphyAutocompletionPrivate;
typedef struct _EphyAutocompletionMatch EphyAutocompletionMatch;

/**
 * EphyAutocompletion object
 */

#define EPHY_TYPE_AUTOCOMPLETION        (ephy_autocompletion_get_type())
#define EPHY_AUTOCOMPLETION(object)     (G_TYPE_CHECK_INSTANCE_CAST((object), \
                         EPHY_TYPE_AUTOCOMPLETION,\
                         EphyAutocompletion))
#define EPHY_AUTOCOMPLETION_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST((klass), \
                         EPHY_TYPE_AUTOCOMPLETION,\
                         EphyAutocompletionClass))
#define EPHY_IS_AUTOCOMPLETION(object)      (G_TYPE_CHECK_INSTANCE_TYPE((object), \
                         EPHY_TYPE_AUTOCOMPLETION))
#define EPHY_IS_AUTOCOMPLETION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), \
                         EPHY_TYPE_AUTOCOMPLETION))
#define EPHY_AUTOCOMPLETION_GET_CLASS(obj)  (G_TYPE_INSTANCE_GET_CLASS((obj), \
                         EPHY_TYPE_AUTOCOMPLETION,\
                         EphyAutocompletionClass))

struct _EphyAutocompletionClass
{
    GObjectClass parent_class;

    /* signals */
    void    (*sources_changed)  (EphyAutocompletion *ac);
};

/* Remember: fields are public read-only */
struct _EphyAutocompletion
{
    GObject parent_object;

    EphyAutocompletionPrivate *priv;
};

struct _EphyAutocompletionMatch
{
    const char *match;
    const char *title;
    const char *target;
    guint offset;
    gint32 score;
    gboolean is_action;
    gboolean substring;
};

/* this is a set of usual prefixes for web browsing */
#define EPHY_AUTOCOMPLETION_USUAL_WEB_PREFIXES \
    "http://www.", \
    "http://", \
    "https://www.", \
    "https://", \
    "file://", \
    "www."

GType               ephy_autocompletion_get_type        (void);
EphyAutocompletion *        ephy_autocompletion_new         (void);
void                ephy_autocompletion_add_source      (EphyAutocompletion *ac,
                                     EphyAutocompletionSource *s);
void                ephy_autocompletion_set_prefixes    (EphyAutocompletion *ac,
                                     const gchar **prefixes);
void                ephy_autocompletion_set_key     (EphyAutocompletion *ac,
                                     const gchar *key);
const EphyAutocompletionMatch  *ephy_autocompletion_get_matches     (EphyAutocompletion *ac);
const EphyAutocompletionMatch  *ephy_autocompletion_get_matches_sorted_by_score
                                    (EphyAutocompletion *ac,
                                     gboolean *changed);
guint               ephy_autocompletion_get_num_matches (EphyAutocompletion *ac);
guint               ephy_autocompletion_get_num_action_matches (EphyAutocompletion *ac);

G_END_DECLS

#endif