~ubuntu-branches/ubuntu/saucy/hud/saucy-proposed

« back to all changes in this revision

Viewing changes to tests/app-list-dummy.c

  • Committer: Package Import Robot
  • Author(s): Ubuntu daily release
  • Date: 2013-06-05 12:33:44 UTC
  • mto: This revision was merged to the branch mainline in revision 5.
  • Revision ID: package-import@ubuntu.com-20130605123344-cpp4to647tyfv7kr
Tags: upstream-13.10.1daily13.06.05.1
Import upstream version 13.10.1daily13.06.05.1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Copyright © 2013 Canonical Ltd.
 
3
 *
 
4
 * This program is free software: you can redistribute it and/or modify it
 
5
 * under the terms of the GNU General Public License version 3, as
 
6
 * published by the Free Software Foundation.
 
7
 *
 
8
 * This program is distributed in the hope that it will be useful, but
 
9
 * WITHOUT ANY WARRANTY; without even the implied warranties of
 
10
 * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
 
11
 * PURPOSE.  See the GNU General Public License for more details.
 
12
 *
 
13
 * You should have received a copy of the GNU General Public License along
 
14
 * with this program.  If not, see <http://www.gnu.org/licenses/>.
 
15
 */
 
16
 
 
17
#ifdef HAVE_CONFIG_H
 
18
#include "config.h"
 
19
#endif
 
20
 
 
21
#include "app-list-dummy.h"
 
22
 
 
23
typedef struct _AppListDummyPrivate AppListDummyPrivate;
 
24
 
 
25
struct _AppListDummyPrivate {
 
26
        HudSource * focused_source;
 
27
};
 
28
 
 
29
#define APP_LIST_DUMMY_GET_PRIVATE(o) \
 
30
(G_TYPE_INSTANCE_GET_PRIVATE ((o), APP_LIST_DUMMY_TYPE, AppListDummyPrivate))
 
31
 
 
32
static void app_list_dummy_class_init (AppListDummyClass *klass);
 
33
static void app_list_dummy_init       (AppListDummy *self);
 
34
static void app_list_dummy_dispose    (GObject *object);
 
35
static void app_list_dummy_finalize   (GObject *object);
 
36
static HudSource * get_focused_app (HudApplicationList * list);
 
37
static void matching_setup (HudApplicationList * list);
 
38
 
 
39
G_DEFINE_TYPE (AppListDummy, app_list_dummy, HUD_TYPE_APPLICATION_LIST);
 
40
 
 
41
static void
 
42
app_list_dummy_class_init (AppListDummyClass *klass)
 
43
{
 
44
        GObjectClass *object_class = G_OBJECT_CLASS (klass);
 
45
 
 
46
        g_type_class_add_private (klass, sizeof (AppListDummyPrivate));
 
47
 
 
48
        object_class->dispose = app_list_dummy_dispose;
 
49
        object_class->finalize = app_list_dummy_finalize;
 
50
 
 
51
        HudApplicationListClass * appclass = HUD_APPLICATION_LIST_CLASS(klass);
 
52
        appclass->get_focused_app = get_focused_app;
 
53
 
 
54
        appclass->matching_setup = matching_setup;
 
55
 
 
56
        return;
 
57
}
 
58
 
 
59
static void
 
60
app_list_dummy_init (AppListDummy *self)
 
61
{
 
62
        return;
 
63
}
 
64
 
 
65
static void
 
66
app_list_dummy_dispose (GObject *object)
 
67
{
 
68
        AppListDummyPrivate * priv = APP_LIST_DUMMY_GET_PRIVATE(object);
 
69
 
 
70
        g_clear_object(&priv->focused_source);
 
71
 
 
72
        G_OBJECT_CLASS (app_list_dummy_parent_class)->dispose (object);
 
73
        return;
 
74
}
 
75
 
 
76
static void
 
77
app_list_dummy_finalize (GObject *object)
 
78
{
 
79
 
 
80
        G_OBJECT_CLASS (app_list_dummy_parent_class)->finalize (object);
 
81
        return;
 
82
}
 
83
 
 
84
AppListDummy *
 
85
app_list_dummy_new (HudSource * focused_source)
 
86
{
 
87
        g_return_val_if_fail(HUD_IS_SOURCE(focused_source), NULL);
 
88
 
 
89
        AppListDummy * dummy = g_object_new(APP_LIST_DUMMY_TYPE, NULL);
 
90
        AppListDummyPrivate * priv = APP_LIST_DUMMY_GET_PRIVATE(dummy);
 
91
 
 
92
        priv->focused_source = g_object_ref(focused_source);
 
93
        return dummy;
 
94
}
 
95
 
 
96
static HudSource *
 
97
get_focused_app (HudApplicationList * list)
 
98
{
 
99
        g_return_val_if_fail(IS_APP_LIST_DUMMY(list), NULL);
 
100
 
 
101
        AppListDummyPrivate * priv = APP_LIST_DUMMY_GET_PRIVATE(list);
 
102
 
 
103
        return priv->focused_source;
 
104
}
 
105
 
 
106
static void
 
107
matching_setup (HudApplicationList * list)
 
108
{
 
109
        /* Wow, this is super-performant! */
 
110
        g_debug("Setting up matching");
 
111
        return;
 
112
}
 
113
 
 
114
void
 
115
app_list_dummy_set_focus (AppListDummy * dummy, HudSource * focused_source)
 
116
{
 
117
        g_return_if_fail(IS_APP_LIST_DUMMY(dummy));
 
118
 
 
119
        AppListDummyPrivate * priv = APP_LIST_DUMMY_GET_PRIVATE(dummy);
 
120
        g_clear_object(&priv->focused_source);
 
121
        priv->focused_source = g_object_ref(focused_source);
 
122
 
 
123
        hud_source_changed(HUD_SOURCE(dummy));
 
124
 
 
125
        return;
 
126
}