~ubuntu-branches/ubuntu/natty/bamf/natty-proposed

« back to all changes in this revision

Viewing changes to lib/libbamf/bamf-application.c

  • Committer: Bazaar Package Importer
  • Author(s): Didier Roche
  • Date: 2010-11-11 18:37:42 UTC
  • mfrom: (1.1.18 upstream)
  • Revision ID: james.westby@ubuntu.com-20101111183742-jc2ep9nyyjbdej5g
Tags: 0.2.60-0ubuntu1
* new upstream release
* debian/libbamf0.symbols:
  - add the new symbols

Show diffs side-by-side

added added

removed removed

Lines of Context:
37
37
#include "bamf-application.h"
38
38
#include "bamf-window.h"
39
39
#include "bamf-factory.h"
 
40
#include "bamf-view-private.h"
40
41
 
 
42
#include <gio/gdesktopappinfo.h>
41
43
#include <dbus/dbus.h>
42
44
#include <dbus/dbus-glib.h>
43
45
#include <dbus/dbus-glib-lowlevel.h>
79
81
  
80
82
  if (priv->desktop_file)
81
83
    return priv->desktop_file;
 
84
    
 
85
  if (!bamf_view_remote_ready (BAMF_VIEW (application)))
 
86
    return NULL;
82
87
 
83
88
  if (!dbus_g_proxy_call (priv->proxy,
84
89
                          "DesktopFile",
109
114
 
110
115
  if (priv->application_type)
111
116
    return priv->application_type;
 
117
  
 
118
  if (!bamf_view_remote_ready (BAMF_VIEW (application)))
 
119
    return NULL;
112
120
 
113
121
  if (!dbus_g_proxy_call (priv->proxy,
114
122
                          "ApplicationType",
136
144
 
137
145
  g_return_val_if_fail (BAMF_IS_APPLICATION (application), FALSE);
138
146
  priv = application->priv;
 
147
  
 
148
  if (!bamf_view_remote_ready (BAMF_VIEW (application)))
 
149
    return NULL;
139
150
 
140
151
  if (!dbus_g_proxy_call (priv->proxy,
141
152
                          "Xids",
161
172
  BamfView *view;
162
173
 
163
174
  g_return_val_if_fail (BAMF_IS_APPLICATION (application), NULL);
164
 
 
 
175
  
165
176
  children = bamf_view_get_children (BAMF_VIEW (application));
166
177
 
167
178
  for (l = children; l; l = l->next)
187
198
  g_return_val_if_fail (BAMF_IS_APPLICATION (application), TRUE);
188
199
 
189
200
  priv = application->priv;
 
201
  
 
202
  if (!bamf_view_remote_ready (BAMF_VIEW (application)))
 
203
    return TRUE;
190
204
 
191
205
  if (priv->show_stubs == -1)
192
206
    {
212
226
  return priv->show_stubs;
213
227
}
214
228
 
 
229
static BamfClickBehavior
 
230
bamf_application_get_click_suggestion (BamfView *view)
 
231
{
 
232
  if (!bamf_view_is_running (view))
 
233
    return BAMF_CLICK_BEHAVIOR_OPEN;
 
234
  return 0;
 
235
}
 
236
 
215
237
static void
216
238
bamf_application_on_window_added (DBusGProxy *proxy, char *path, BamfApplication *self)
217
239
{
274
296
}
275
297
 
276
298
static void
277
 
bamf_application_constructed (GObject *object)
 
299
bamf_application_set_path (BamfView *view, const char *path)
278
300
{
279
301
  BamfApplication *self;
280
302
  BamfApplicationPrivate *priv;
281
 
  char *path;
282
303
 
283
 
  if (G_OBJECT_CLASS (bamf_application_parent_class)->constructed)
284
 
    G_OBJECT_CLASS (bamf_application_parent_class)->constructed (object);
285
 
  
286
 
  self = BAMF_APPLICATION (object);
 
304
  self = BAMF_APPLICATION (view);
287
305
  priv = self->priv;
288
306
  
289
 
  g_object_get (object, "path", &path, NULL);
290
 
  
291
307
  priv->proxy = dbus_g_proxy_new_for_name (priv->connection,
292
308
                                           "org.ayatana.bamf",
293
309
                                           path,
321
337
}
322
338
 
323
339
static void
 
340
bamf_application_load_data_from_file (BamfApplication *self)
 
341
{
 
342
  GDesktopAppInfo *desktop_info;
 
343
  GIcon *gicon;
 
344
  const char *name;
 
345
  char *icon;
 
346
  
 
347
  desktop_info = g_desktop_app_info_new_from_filename (self->priv->desktop_file);
 
348
  
 
349
  if (!desktop_info)
 
350
    return;
 
351
  
 
352
  name = g_app_info_get_name (G_APP_INFO (desktop_info));
 
353
  bamf_view_set_name (BAMF_VIEW (self), name);
 
354
 
 
355
  gicon = g_app_info_get_icon (G_APP_INFO (desktop_info));
 
356
  icon = g_icon_to_string (gicon);
 
357
  
 
358
  bamf_view_set_icon (BAMF_VIEW (self), icon);
 
359
  g_free (icon);
 
360
}
 
361
 
 
362
static void
324
363
bamf_application_class_init (BamfApplicationClass *klass)
325
364
{
326
365
  GObjectClass *obj_class = G_OBJECT_CLASS (klass);
 
366
  BamfViewClass *view_class = BAMF_VIEW_CLASS (klass);
327
367
  
328
 
  obj_class->constructed = bamf_application_constructed;
329
368
  obj_class->dispose     = bamf_application_dispose;
 
369
  view_class->set_path   = bamf_application_set_path;
 
370
  view_class->click_behavior = bamf_application_get_click_suggestion;
330
371
 
331
372
  g_type_class_add_private (obj_class, sizeof (BamfApplicationPrivate));
332
373
 
374
415
bamf_application_new (const char * path)
375
416
{
376
417
  BamfApplication *self;
377
 
  self = g_object_new (BAMF_TYPE_APPLICATION, "path", path, NULL);
378
 
 
 
418
  self = g_object_new (BAMF_TYPE_APPLICATION, NULL);
 
419
  
 
420
  bamf_view_set_path (BAMF_VIEW (self), path);
 
421
 
 
422
  return self;
 
423
}
 
424
 
 
425
BamfApplication *
 
426
bamf_application_new_favorite (const char * favorite_path)
 
427
{
 
428
  BamfApplication *self;
 
429
  self = g_object_new (BAMF_TYPE_APPLICATION, NULL);
 
430
  
 
431
  self->priv->desktop_file = g_strdup (favorite_path);
 
432
  bamf_application_load_data_from_file (self);
 
433
  
379
434
  return self;
380
435
}