~jbicha/hud/build-depend-on-valac-not-gir

« back to all changes in this revision

Viewing changes to src/hudsource.c

  • Committer: Tarmac
  • Author(s): Ted Gould, Pete Woods, Antti Kaijanmäki, Ted Gould, Albert Astals, Ryan Lortie, Łukasz 'sil2100' Zemczak, Albert Astals Cid, Mathieu Trudel-Lapierre, Kaleo, Tarmac, Ricardo Salveti de Araujo, Michael Terry, Automatic PS uploader
  • Date: 2013-04-10 16:04:51 UTC
  • mfrom: (227.3.148 phablet)
  • Revision ID: tarmac-20130410160451-o3owpv3zaxulm5of
HUD 2.0 Merge.

Approved by PS Jenkins bot, Mathieu Trudel-Lapierre.

Show diffs side-by-side

added added

removed removed

Lines of Context:
106
106
 
107
107
  g_debug ("use on %s %p", G_OBJECT_TYPE_NAME (source), source);
108
108
 
109
 
  HUD_SOURCE_GET_IFACE (source)
110
 
    ->use (source);
 
109
  HudSourceInterface * iface = HUD_SOURCE_GET_IFACE (source);
 
110
  if (iface->use != NULL) {
 
111
    return iface->use(source);
 
112
  }
111
113
}
112
114
 
113
115
/**
126
128
 
127
129
  g_debug ("unuse on %s %p", G_OBJECT_TYPE_NAME (source), source);
128
130
 
129
 
  HUD_SOURCE_GET_IFACE (source)
130
 
    ->unuse (source);
 
131
  HudSourceInterface * iface = HUD_SOURCE_GET_IFACE (source);
 
132
  if (iface->unuse != NULL) {
 
133
    return iface->unuse(source);
 
134
  }
131
135
}
132
136
 
133
137
/**
145
149
 **/
146
150
void
147
151
hud_source_search (HudSource    *source,
148
 
                   GPtrArray    *results_array,
149
 
                   HudTokenList *search_string)
 
152
                   HudTokenList *search_string,
 
153
                   void        (*append_func) (HudResult * result, gpointer user_data),
 
154
                   gpointer      user_data)
150
155
{
151
156
  g_debug ("search on %s %p", G_OBJECT_TYPE_NAME (source), source);
152
157
 
153
 
  HUD_SOURCE_GET_IFACE (source)
154
 
    ->search (source, results_array, search_string);
 
158
  HudSourceInterface * iface = HUD_SOURCE_GET_IFACE (source);
 
159
  if (iface->unuse != NULL) {
 
160
    return iface->search(source, search_string, append_func, user_data);
 
161
  }
 
162
}
 
163
 
 
164
void
 
165
hud_source_list_applications (HudSource    *source,
 
166
                              HudTokenList *search_tokens,
 
167
                              void        (*append_func) (const gchar *application_id, const gchar *application_icon, HudSourceItemType type, gpointer user_data),
 
168
                              gpointer      user_data)
 
169
{
 
170
  g_debug ("list_applications on %s %p", G_OBJECT_TYPE_NAME (source), source);
 
171
 
 
172
  HudSourceInterface * iface = HUD_SOURCE_GET_IFACE (source);
 
173
  if (iface->list_applications != NULL) {
 
174
    return iface->list_applications(source, search_tokens, append_func, user_data);
 
175
  }
 
176
}
 
177
 
 
178
/**
 
179
 * hud_source_get:
 
180
 * @source; a #HudSource
 
181
 *
 
182
 * Mark a #HudSource as "in use" (ie: actively being queried).
 
183
 *
 
184
 * Gets the last source that is responsible of giving results for application_id
 
185
 **/
 
186
HudSource *
 
187
hud_source_get (HudSource   *source,
 
188
                const gchar *application_id)
 
189
{
 
190
  g_return_val_if_fail (HUD_IS_SOURCE (source), NULL);
 
191
 
 
192
  g_debug ("get on %s %p", G_OBJECT_TYPE_NAME (source), source);
 
193
 
 
194
  HudSourceInterface * iface = HUD_SOURCE_GET_IFACE (source);
 
195
  if (iface->get != NULL) {
 
196
    return iface->get(source, application_id);
 
197
  }
 
198
 
 
199
  return NULL;
 
200
}
 
201
 
 
202
/**
 
203
 * hud_source_activate_toolbar:
 
204
 * @source; a #HudSource
 
205
 *
 
206
 * Activate a toolbar item on a source
 
207
 **/
 
208
void
 
209
hud_source_activate_toolbar (HudSource * source, HudClientQueryToolbarItems item, GVariant *platform_data)
 
210
{
 
211
  g_return_if_fail (HUD_IS_SOURCE (source));
 
212
 
 
213
  g_debug ("activate toolbar on %s %p", G_OBJECT_TYPE_NAME (source), source);
 
214
 
 
215
  HudSourceInterface * iface = HUD_SOURCE_GET_IFACE (source);
 
216
  if (iface->activate_toolbar != NULL) {
 
217
    return iface->activate_toolbar(source, item, platform_data);
 
218
  }
 
219
 
 
220
  return;
 
221
}
 
222
 
 
223
/**
 
224
 * hud_source_get_items:
 
225
 * @collector: a #HudDbusmenuCollector
 
226
 *
 
227
 * Gets the items that have been collected at any point in time.
 
228
 *
 
229
 * Return Value: (element-type HudItem) (transfer full) A list of #HudItem
 
230
 * objects.  Free with g_list_free_full(g_object_unref)
 
231
 */
 
232
GList *
 
233
hud_source_get_items (HudSource *source)
 
234
{
 
235
  g_return_val_if_fail(HUD_IS_SOURCE(source), NULL);
 
236
 
 
237
  g_debug ("get_items on %s %p", G_OBJECT_TYPE_NAME (source), source);
 
238
 
 
239
  HudSourceInterface * iface = HUD_SOURCE_GET_IFACE (source);
 
240
  if (iface->get_items != NULL) {
 
241
    return iface->get_items(source);
 
242
  }
 
243
 
 
244
  return NULL;
155
245
}
156
246
 
157
247
/**
167
257
void
168
258
hud_source_changed (HudSource *source)
169
259
{
170
 
  g_debug ("%s %p changed", G_OBJECT_TYPE_NAME (source), source);
171
 
 
172
260
  g_signal_emit (source, hud_source_changed_signal, 0);
173
261
}
 
262
 
 
263
/**
 
264
 * hud_source_get_app_id:
 
265
 * @source: a #HudSource
 
266
 *
 
267
 * Get the application ID.  Shouldn't be implemented by list
 
268
 * sources.
 
269
 *
 
270
 * Return value: The ID of the application
 
271
 */
 
272
const gchar *
 
273
hud_source_get_app_id (HudSource * source)
 
274
{
 
275
  g_return_val_if_fail(HUD_IS_SOURCE(source), NULL);
 
276
 
 
277
  HudSourceInterface * iface = HUD_SOURCE_GET_IFACE (source);
 
278
  if (iface->get_app_id != NULL) {
 
279
    return iface->get_app_id(source);
 
280
  }
 
281
 
 
282
  return NULL;
 
283
}
 
284
 
 
285
/**
 
286
 * hud_source_get_app_icon:
 
287
 * @source: a #HudSource
 
288
 *
 
289
 * Get the application icon.  Shouldn't be implemented by list
 
290
 * sources.
 
291
 *
 
292
 * Return value: The icon of the application
 
293
 */
 
294
const gchar *
 
295
hud_source_get_app_icon (HudSource * source)
 
296
{
 
297
  g_return_val_if_fail(HUD_IS_SOURCE(source), NULL);
 
298
 
 
299
  HudSourceInterface * iface = HUD_SOURCE_GET_IFACE (source);
 
300
  if (iface->get_app_icon != NULL) {
 
301
    return iface->get_app_icon(source);
 
302
  }
 
303
 
 
304
  return NULL;
 
305
}