~jtojnar/libunity/libunity

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
/* -*- mode: vala; c-basic-offset: 2; indent-tabs-mode: nil -*- */

class Scope1: Unity.AbstractScope
{
  public Scope1 ()
  {
  }

  public override Unity.ScopeSearchBase create_search_for_query (Unity.SearchContext ctx)
  {
    var search = new Scope1Search ();
    search.set_search_context (ctx);
    return search;
  }

  public override Unity.ResultPreviewer create_previewer (Unity.ScopeResult result, Unity.SearchMetadata metadata)
  {
    return null;
  }

  public override Unity.CategorySet get_categories ()
  {
    return new Unity.CategorySet ();
  }

  public override Unity.FilterSet get_filters ()
  {
    return new Unity.FilterSet ();
  }

  public override Unity.Schema get_schema ()
  {
    return new Unity.Schema ();
  }

  public override string get_group_name ()
  {
    return "org.example.Scope.One";
  }

  public override string get_unique_name ()
  {
    return "/org/example/Scope/One";
  }
}

class Scope1Search: Unity.ScopeSearchBase
{
  public Scope1Search ()
  {
  }

  public override void run ()
  {
    var result = Unity.ScopeResult ();
    result.uri = "test:uri";
    result.icon_hint = "";
    result.category = 0;
    result.result_type = Unity.ResultType.DEFAULT;
    result.mimetype = "inode/folder";
    result.title = "Scope 1 result";
    result.comment = "";
    result.dnd_uri = "test::uri";
    result.metadata = new HashTable<string, Variant> (str_hash, str_equal);
    search_context.result_set.add_result (result);
  }
}

public int unity_scope_module_get_version ()
{
  return Unity.SCOPE_API_VERSION;
}

public List<Unity.AbstractScope> unity_scope_module_load_scopes () throws Error
{
  List<Unity.AbstractScope> scopes = null;
  var scope = new Scope1();
  scopes.append(scope);
  return scopes;
}