Blame src/nautilus-search-provider.h

Packit a189e0
/*
Packit a189e0
 *  Copyright (C) 2012 Red Hat, Inc.
Packit a189e0
 *
Packit a189e0
 *  This library is free software; you can redistribute it and/or
Packit a189e0
 *  modify it under the terms of the GNU Library General Public
Packit a189e0
 *  License as published by the Free Software Foundation; either
Packit a189e0
 *  version 2 of the License, or (at your option) any later version.
Packit a189e0
 *
Packit a189e0
 *  This library is distributed in the hope that it will be useful,
Packit a189e0
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
Packit a189e0
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
Packit a189e0
 *  Library General Public License for more details.
Packit a189e0
 *
Packit a189e0
 *  You should have received a copy of the GNU Library General Public
Packit a189e0
 *  License along with this library; if not, see <http://www.gnu.org/licenses/>.
Packit a189e0
 */
Packit a189e0
Packit a189e0
#ifndef NAUTILUS_SEARCH_PROVIDER_H
Packit a189e0
#define NAUTILUS_SEARCH_PROVIDER_H
Packit a189e0
Packit a189e0
#include <glib-object.h>
Packit a189e0
#include "nautilus-query.h"
Packit a189e0
#include "nautilus-search-hit.h"
Packit a189e0
Packit a189e0
G_BEGIN_DECLS
Packit a189e0
Packit a189e0
typedef enum {
Packit a189e0
  NAUTILUS_SEARCH_PROVIDER_STATUS_NORMAL,
Packit a189e0
  NAUTILUS_SEARCH_PROVIDER_STATUS_RESTARTING
Packit a189e0
} NautilusSearchProviderStatus;
Packit a189e0
Packit a189e0
Packit a189e0
#define NAUTILUS_TYPE_SEARCH_PROVIDER (nautilus_search_provider_get_type ())
Packit a189e0
Packit a189e0
G_DECLARE_INTERFACE (NautilusSearchProvider, nautilus_search_provider, NAUTILUS, SEARCH_PROVIDER, GObject)
Packit a189e0
Packit a189e0
struct _NautilusSearchProviderInterface {
Packit a189e0
        GTypeInterface g_iface;
Packit a189e0
Packit a189e0
        /* VTable */
Packit a189e0
        void (*set_query) (NautilusSearchProvider *provider, NautilusQuery *query);
Packit a189e0
        void (*start) (NautilusSearchProvider *provider);
Packit a189e0
        void (*stop) (NautilusSearchProvider *provider);
Packit a189e0
Packit a189e0
        /* Signals */
Packit a189e0
        void (*hits_added) (NautilusSearchProvider *provider, GList *hits);
Packit a189e0
        /* This signal has a status parameter because it's necesary to discern
Packit a189e0
         * when the search engine finished normally or wheter it finished in a
Packit a189e0
         * different situation that will cause the engine to do some action after
Packit a189e0
         * finishing.
Packit a189e0
         *
Packit a189e0
         * For example, the search engine restarts itself if the client starts a
Packit a189e0
         * new search before all the search providers finished its current ongoing search.
Packit a189e0
         *
Packit a189e0
         * A real use case of this is when the user change quickly the query of the search,
Packit a189e0
         * the search engine stops all the search providers, but given that each search
Packit a189e0
         * provider has its own thread it will be actually stopped in a unknown time.
Packit a189e0
         * To fix that, the search engine marks itself for restarting if the client
Packit a189e0
         * starts a new search and not all providers finished. Then it will emit
Packit a189e0
         * its finished signal and restart all providers with the new search.
Packit a189e0
         *
Packit a189e0
         * That can cause that when the search engine emits its finished signal,
Packit a189e0
         * it actually relates to old searchs that it stopped and not the one
Packit a189e0
         * the client started lately.
Packit a189e0
         * The client doesn't have a way to know wheter the finished signal
Packit a189e0
         * relates to its current search or with an old search.
Packit a189e0
         *
Packit a189e0
         * To fix this situation, provide with the signal a status parameter, that
Packit a189e0
         * provides a hint of how the search engine stopped or if it is going to realize
Packit a189e0
         * some action afterwards, like restarting.
Packit a189e0
         */
Packit a189e0
        void (*finished) (NautilusSearchProvider       *provider,
Packit a189e0
                          NautilusSearchProviderStatus  status);
Packit a189e0
        void (*error) (NautilusSearchProvider *provider, const char *error_message);
Packit a189e0
        gboolean (*is_running) (NautilusSearchProvider *provider);
Packit a189e0
};
Packit a189e0
Packit a189e0
GType          nautilus_search_provider_get_type        (void) G_GNUC_CONST;
Packit a189e0
Packit a189e0
/* Interface Functions */
Packit a189e0
void           nautilus_search_provider_set_query       (NautilusSearchProvider *provider,
Packit a189e0
                                                         NautilusQuery *query);
Packit a189e0
void           nautilus_search_provider_start           (NautilusSearchProvider *provider);
Packit a189e0
void           nautilus_search_provider_stop            (NautilusSearchProvider *provider);
Packit a189e0
Packit a189e0
void           nautilus_search_provider_hits_added      (NautilusSearchProvider *provider,
Packit a189e0
                                                         GList *hits);
Packit a189e0
void           nautilus_search_provider_finished        (NautilusSearchProvider       *provider,
Packit a189e0
                                                         NautilusSearchProviderStatus  status);
Packit a189e0
void           nautilus_search_provider_error           (NautilusSearchProvider *provider,
Packit a189e0
                                                         const char *error_message);
Packit a189e0
Packit a189e0
gboolean       nautilus_search_provider_is_running      (NautilusSearchProvider *provider);
Packit a189e0
Packit a189e0
G_END_DECLS
Packit a189e0
Packit a189e0
#endif