Back to index

unity  6.0.0
Classes | Functions
test_service_lens.c File Reference
#include "test_service_lens.h"
#include <unity.h>

Go to the source code of this file.

Classes

struct  _ServiceLensPrivate

Functions

 G_DEFINE_TYPE (ServiceLens, service_lens, G_TYPE_OBJECT)
static void add_categories (ServiceLens *self)
static void add_filters (ServiceLens *self)
static void on_search_changed (UnityScope *scope, UnityLensSearch *lens_search, UnitySearchType search_type, GCancellable *canc, ServiceLens *self)
static UnityActivationResponse * on_activate_uri (UnityScope *scope, const char *uri, ServiceLens *self)
static UnityPreview * on_preview_uri (UnityScope *scope, const char *uri, ServiceLens *self)
static void service_lens_dispose (GObject *object)
static void service_lens_class_init (ServiceLensClass *klass)
static void service_lens_init (ServiceLens *self)
ServiceLens * service_lens_new ()

Class Documentation

struct _ServiceLensPrivate

Definition at line 13 of file test_service_lens.c.

Class Members
UnityLens * lens
UnityScope * scope

Function Documentation

static void add_categories ( ServiceLens *  self) [static]

Definition at line 76 of file test_service_lens.c.

{
  GList *cats = NULL;
  GIcon *icon;

  icon = g_themed_icon_new("gtk-apply");
  cats = g_list_append (cats, unity_category_new("Category1", icon,
                                                 UNITY_CATEGORY_RENDERER_VERTICAL_TILE));
  g_object_unref (icon);
  
  icon = g_themed_icon_new("gtk-cancel");
  cats = g_list_append (cats, unity_category_new("Category2", icon,
                                                 UNITY_CATEGORY_RENDERER_HORIZONTAL_TILE));
  g_object_unref (icon);

  icon = g_themed_icon_new("gtk-close");
  cats = g_list_append (cats, unity_category_new("Category3", icon,
                                                 UNITY_CATEGORY_RENDERER_FLOW));
  g_object_unref (icon);


  unity_lens_set_categories(self->priv->lens, cats);
  g_list_free_full (cats, (GDestroyNotify) g_object_unref);
}

Here is the caller graph for this function:

static void add_filters ( ServiceLens *  self) [static]

Definition at line 102 of file test_service_lens.c.

{
  GList       *filters = NULL;
  UnityFilter *filter;
  GIcon       *icon;

  filter = UNITY_FILTER (unity_radio_option_filter_new("when", "When",
                                                       NULL, FALSE));
  unity_options_filter_add_option(UNITY_OPTIONS_FILTER (filter),
                                  "today", "Today", NULL);
  unity_options_filter_add_option(UNITY_OPTIONS_FILTER (filter),
                                  "yesterday", "Yesterday", NULL);
  unity_options_filter_add_option(UNITY_OPTIONS_FILTER (filter),
                                  "lastweek", "Last Week", NULL);
  filters = g_list_append (filters, filter);

  filter = UNITY_FILTER (unity_check_option_filter_new("type", "Type",
                                                       NULL, FALSE));
  icon = g_themed_icon_new ("gtk-apps");
  unity_options_filter_add_option(UNITY_OPTIONS_FILTER (filter),
                                  "apps", "Apps", icon);
  g_object_unref (icon);
  icon = g_themed_icon_new ("gtk-files");
  unity_options_filter_add_option(UNITY_OPTIONS_FILTER (filter),
                                  "files", "Files", icon);
  g_object_unref (icon);
  icon = g_themed_icon_new ("gtk-music");
  unity_options_filter_add_option(UNITY_OPTIONS_FILTER (filter),
                                  "music", "Music", icon);
  g_object_unref (icon);
  filters = g_list_append (filters, filter);

  filters = g_list_append (filters, unity_ratings_filter_new("ratings",
                                                             "Ratings",
                                                             NULL, FALSE));

  filter = UNITY_FILTER (unity_multi_range_filter_new("size", "Size", NULL, TRUE));
  unity_options_filter_add_option(UNITY_OPTIONS_FILTER(filter), "1MB", "1MB", NULL);
  unity_options_filter_add_option(UNITY_OPTIONS_FILTER(filter), "10MB", "10MB", NULL);
  unity_options_filter_add_option(UNITY_OPTIONS_FILTER(filter), "100MB", "100MB", NULL);
  unity_options_filter_add_option(UNITY_OPTIONS_FILTER(filter), "1000MB", "1000MB", NULL);
  filters = g_list_append (filters, filter);
 

  unity_lens_set_filters(self->priv->lens, filters);
  g_list_free_full (filters, (GDestroyNotify) g_object_unref);
}

Here is the caller graph for this function:

G_DEFINE_TYPE ( ServiceLens  ,
service_lens  ,
G_TYPE_OBJECT   
)
static UnityActivationResponse * on_activate_uri ( UnityScope *  scope,
const char *  uri,
ServiceLens *  self 
) [static]

Definition at line 181 of file test_service_lens.c.

{
  return unity_activation_response_new(UNITY_HANDLED_TYPE_HIDE_DASH, "");
}

Here is the caller graph for this function:

static UnityPreview * on_preview_uri ( UnityScope *  scope,
const char *  uri,
ServiceLens *  self 
) [static]

Definition at line 187 of file test_service_lens.c.

{
  return NULL;
  // FIXME: update when the new preview types are well defined
  /*
  return (UnityPreview*)unity_generic_preview_new(
      "Animus Vox", "The Glitch Mob - Drink The Sea", NULL);
  */
}

Here is the caller graph for this function:

static void on_search_changed ( UnityScope *  scope,
UnityLensSearch *  lens_search,
UnitySearchType  search_type,
GCancellable *  canc,
ServiceLens *  self 
) [static]

Definition at line 151 of file test_service_lens.c.

{
  int i = 0;
  // to differentiate global and non-global searches, we'll return more items
  // in the case of global search
  int num_items = search_type == UNITY_SEARCH_TYPE_GLOBAL ? 10 : 5;

  DeeModel* model = (DeeModel*)unity_lens_search_get_results_model(search);

  for (i = 0; i < num_items; i++)
  {
    gchar* name = g_strdup_printf("%s%d",
                                  unity_lens_search_get_search_string(search),
                                  i);
    dee_model_append(model,
                     "file:///test",
                     "gtk-apply",
                     i,
                     "text/html",
                     name,
                     "kamstrup likes ponies",
                     "file:///test");
    g_free(name);
  }

  g_signal_emit_by_name (search, "finished");
}

Here is the caller graph for this function:

static void service_lens_class_init ( ServiceLensClass *  klass) [static]

Definition at line 29 of file test_service_lens.c.

{
  G_OBJECT_CLASS(klass)->dispose = service_lens_dispose;

       g_type_class_add_private (klass, sizeof (ServiceLensPrivate));
}

Here is the call graph for this function:

static void service_lens_dispose ( GObject *  object) [static]

Definition at line 20 of file test_service_lens.c.

{
  ServiceLens* self = SERVICE_LENS(object);

  g_object_unref(self->priv->lens);
  g_object_unref(self->priv->scope);
}

Here is the caller graph for this function:

static void service_lens_init ( ServiceLens *  self) [static]

Definition at line 37 of file test_service_lens.c.

{
  ServiceLensPrivate* priv;
  GError* error = NULL;

  priv = self->priv = G_TYPE_INSTANCE_GET_PRIVATE(self, SERVICE_TYPE_LENS, ServiceLensPrivate);

  /* Setup Lens */
  priv->lens = unity_lens_new("/com/canonical/unity/testlens", "testlens");
  g_object_set(priv->lens,
               "search-hint", "Search Test Lens",
               "visible", TRUE,
               "search-in-global", TRUE,
               NULL);
  add_categories(self);
  add_filters(self);

  /* Scope */
  priv->scope = unity_scope_new("/com/canonical/unity/testscope");
  unity_scope_set_search_in_global(priv->scope, TRUE);

  g_signal_connect(priv->scope, "search-changed",
                   G_CALLBACK(on_search_changed), self);
  g_signal_connect(priv->scope, "activate-uri",
                   G_CALLBACK(on_activate_uri), self);
  g_signal_connect(priv->scope, "preview-uri",
                   G_CALLBACK(on_preview_uri), self);

  /* Get ready to export and export */
  unity_lens_add_local_scope(priv->lens, priv->scope);
  unity_lens_export(priv->lens, &error);
  if (error)
  {
    g_error ("Unable to export Lens: %s", error->message);
    g_error_free (error);
  }
}

Here is the call graph for this function:

ServiceLens* service_lens_new ( void  )

Definition at line 198 of file test_service_lens.c.

{
  return g_object_new(SERVICE_TYPE_LENS, NULL);
}

Here is the caller graph for this function: