Back to index

indicator-appmenu  12.10.0
Defines | Typedefs | Functions
hudquery.h File Reference
#include "hudsource.h"
#include "hudresult.h"
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Defines

#define HUD_TYPE_QUERY   (hud_query_get_type ())
#define HUD_QUERY(inst)
#define HUD_IS_QUERY(inst)

Typedefs

typedef struct _HudQuery

Functions

GType hud_query_get_type (void)
HudQuery * hud_query_new (HudSource *source, const gchar *search_string, gint num_results)
 hud_query_new: : the #HudSource against which to search : the string to search for : the maximum number of results to report
GVariant * hud_query_get_query_key (HudQuery *query)
 hud_query_get_query_key: : a #HudQuery
HudResult * hud_query_get_result_by_index (HudQuery *query, guint i)
 hud_query_get_result_by_index: : a #HudQuery : the index of the result
guint hud_query_get_n_results (HudQuery *query)
 hud_query_get_n_results: : a #HudQuery
void hud_query_close (HudQuery *query)
 hud_query_close: : a #HudQuery
HudQuery * hud_query_lookup (GVariant *query_key)
 hud_query_lookup: : a query key

Define Documentation

#define HUD_IS_QUERY (   inst)
Value:
(G_TYPE_CHECK_INSTANCE_TYPE ((inst),                     \
                                                             HUD_TYPE_QUERY))

Definition at line 28 of file hudquery.h.

#define HUD_QUERY (   inst)
Value:
(G_TYPE_CHECK_INSTANCE_CAST ((inst),                     \
                                                             HUD_TYPE_QUERY, HudQuery))

Definition at line 26 of file hudquery.h.

Definition at line 25 of file hudquery.h.


Typedef Documentation

typedef struct _HudQuery

Definition at line 31 of file hudquery.h.


Function Documentation

void hud_query_close ( HudQuery *  query)

hud_query_close: : a #HudQuery

Closes a #HudQuery.

This drops the query from the internal list of queries. Future use of hud_query_lookup() to find this query will fail.

You must still release your own reference on , if you have one. This only drops the internal reference.

Definition at line 282 of file hudquery.c.

{
  if (query == last_created_query)
    g_clear_object (&last_created_query);
}

Here is the caller graph for this function:

guint hud_query_get_n_results ( HudQuery *  query)

hud_query_get_n_results: : a #HudQuery

Gets the number of results in .

Returns: the number of results

Definition at line 297 of file hudquery.c.

{
  return query->results->len;
}

Here is the caller graph for this function:

GVariant* hud_query_get_query_key ( HudQuery *  query)

hud_query_get_query_key: : a #HudQuery

Returns the query key for .

Each #HudQuery has a unique identifying key that is assigned when the query is created.

FIXME: This is a lie.

Returns: (transfer none): the query key for

Definition at line 245 of file hudquery.c.

{
  static GVariant *query_key;

  if (query_key == NULL)
    query_key = g_variant_ref_sink (g_variant_new_string ("query key"));

  return query_key;
}

Here is the caller graph for this function:

HudResult* hud_query_get_result_by_index ( HudQuery *  query,
guint  i 
)

hud_query_get_result_by_index: : a #HudQuery : the index of the result

Gets the result from .

must be less than the number of results in the query. See hud_query_get_n_results().

Returns: (transfer none): the #HudResult at position

Definition at line 315 of file hudquery.c.

{
  return query->results->pdata[i];
}

Here is the caller graph for this function:

GType hud_query_get_type ( void  )
HudQuery* hud_query_lookup ( GVariant *  query_key)

hud_query_lookup: : a query key

Finds the query that has the given .

Returns: (transfer none): the query, or NULL if no such query exists

Definition at line 264 of file hudquery.c.

{
  return last_created_query;
}

Here is the caller graph for this function:

HudQuery* hud_query_new ( HudSource *  source,
const gchar *  search_string,
gint  num_results 
)

hud_query_new: : the #HudSource against which to search : the string to search for : the maximum number of results to report

Creates a #HudQuery.

A #HudQuery is a stateful search for against a .

Each #HudQuery is assigned a "query key" when it is created. This can be used to lookup the hud query later using hud_query_lookup(). Because of this, an internal reference is held on the query and the query won't be completely freed until you call hud_query_close() on it in addition to releasing your ref.

Returns: the new #HudQuery

Definition at line 204 of file hudquery.c.

{
  HudQuery *query;

  g_debug ("Created query '%s'", search_string);

  query = g_object_new (HUD_TYPE_QUERY, NULL);
  query->source = g_object_ref (source);
  query->results = g_ptr_array_new_with_free_func (g_object_unref);
  query->search_string = g_strdup (search_string);
  query->token_list = hud_token_list_new_from_string (query->search_string);
  query->num_results = num_results;

  hud_source_use (query->source);

  hud_query_refresh (query);

  g_signal_connect_object (source, "changed", G_CALLBACK (hud_query_source_changed), query, 0);

  g_clear_object (&last_created_query);
  last_created_query = g_object_ref (query);

  return query;
}

Here is the call graph for this function:

Here is the caller graph for this function: