~timo-jyrinki/bamf/ubuntu-0.2.124.1

« back to all changes in this revision

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

  • Committer: Timo Jyrinki
  • Date: 2012-11-14 07:15:04 UTC
  • mfrom: (235.1.49)
  • Revision ID: timo.jyrinki@canonical.com-20121114071504-s8umq349iaf7lwq6
* New upstream release.
  - Includes all previous cherry-picks
  - remerge libbamf, Makefile: don't export private symbols (factory 
    and matcher)
  - BamfMatcher: force a view as closed or not-closed on proper 
    signals. This avoids that a view that is opened is actually 
    marked as closed when really it's running. (LP: #925421)
  - Daemon, BamfApplication: Use the default icon if there is not 
    one defined in the desktop file. (LP: #886778)
  - BamfMatcher: don't reopen windows when iterating on view's 
    list, add tests.
  - Build fixes, including enabling introspection.
  - BamfMatcher: add support for libreoffice Base, and libreoffice 
    matching tests (LP: #1063862)

Show diffs side-by-side

added added

removed removed

Lines of Context:
142
142
  return priv->set_flags & flag;
143
143
}
144
144
 
 
145
/**
 
146
 * bamf_view_get_children:
 
147
 * @view: a #BamfView
 
148
 *
 
149
 * Note: Makes sever dbus calls the first time this is called on a view. Dbus messaging is reduced afterwards.
 
150
 *
 
151
 * Returns: (element-type Bamf.View) (transfer container): Returns a list of #BamfView which must be
 
152
 *           freed after usage. Elements of the list are owned by bamf and should not be unreffed.
 
153
 */
145
154
GList *
146
155
bamf_view_get_children (BamfView *view)
147
156
{
156
165
  if (BAMF_VIEW_GET_CLASS (view)->get_children)
157
166
    return BAMF_VIEW_GET_CLASS (view)->get_children (view);
158
167
 
159
 
  if (!bamf_view_remote_ready (view))
 
168
  if (!_bamf_view_remote_ready (view))
160
169
    return NULL;
161
170
 
162
171
  priv = view->priv;
183
192
 
184
193
  for (i = len-1; i >= 0; i--)
185
194
    {
186
 
      view = bamf_factory_view_for_path (bamf_factory_get_default (), children[i]);
 
195
      view = _bamf_factory_view_for_path (_bamf_factory_get_default (), children[i]);
187
196
      results = g_list_prepend (results, g_object_ref (view));
188
197
    }
189
198
 
204
213
  if (bamf_view_flag_is_set (self, flag))
205
214
    return bamf_view_get_flag (self, flag);
206
215
 
207
 
  if (!bamf_view_remote_ready (self))
 
216
  if (!_bamf_view_remote_ready (self))
208
217
    return FALSE;
209
218
 
210
219
  if (!dbus_g_proxy_call (priv->proxy,
224
233
  return result;
225
234
}
226
235
 
 
236
/**
 
237
 * bamf_view_is_closed:
 
238
 * @view: a #BamfView
 
239
 *
 
240
 * Determines if the view is closed or not.
 
241
 */
227
242
gboolean
228
243
bamf_view_is_closed (BamfView *view)
229
244
{
232
247
  return view->priv->is_closed;
233
248
}
234
249
 
 
250
/**
 
251
 * bamf_view_is_active:
 
252
 * @view: a #BamfView
 
253
 *
 
254
 * Determines if the view is currently active and focused by the user. Useful for an active window indicator. 
 
255
 */
235
256
gboolean
236
257
bamf_view_is_active (BamfView *view)
237
258
{
244
265
 
245
266
}
246
267
 
247
 
gboolean          
 
268
/**
 
269
 * bamf_view_user_visible:
 
270
 * @view: a #BamfView
 
271
 *
 
272
 * Returns a boolean useful for determining if a particular view is "user visible". User visible
 
273
 * is a concept relating to whether or not a window should be shown in a launcher tasklist.
 
274
 */
 
275
gboolean
248
276
bamf_view_user_visible (BamfView *self)
249
277
{
250
278
  g_return_val_if_fail (BAMF_IS_VIEW (self), FALSE);
253
281
 
254
282
}
255
283
 
 
284
/**
 
285
 * bamf_view_is_running:
 
286
 * @view: a #BamfView
 
287
 *
 
288
 * Determines if the view is currently running. Useful for a running window indicator. 
 
289
 */
256
290
gboolean
257
291
bamf_view_is_running (BamfView *self)
258
292
{
264
298
  return bamf_view_get_boolean (self, "IsRunning", BAMF_VIEW_RUNNING_FLAG);
265
299
}
266
300
 
 
301
/**
 
302
 * bamf_view_is_urgent:
 
303
 * @view: a #BamfView
 
304
 *
 
305
 * Determines if the view is currently requiring attention. Useful for a running window indicator. 
 
306
 */
267
307
gboolean
268
308
bamf_view_is_urgent (BamfView *self)
269
309
{
276
316
}
277
317
 
278
318
void
279
 
bamf_view_set_name (BamfView *view, const char *name)
 
319
_bamf_view_set_name (BamfView *view, const char *name)
280
320
{
281
321
  g_return_if_fail (BAMF_IS_VIEW (view));
282
322
  
296
336
}
297
337
 
298
338
void
299
 
bamf_view_set_icon (BamfView *view, const char *icon)
 
339
_bamf_view_set_icon (BamfView *view, const char *icon)
300
340
{
301
341
  g_return_if_fail (BAMF_IS_VIEW (view));
302
342
 
336
376
    g_object_unref (view);
337
377
}
338
378
 
 
379
/**
 
380
 * bamf_view_get_icon:
 
381
 * @view: a #BamfView
 
382
 *
 
383
 * Gets the icon of a view. This icon is used to visually represent the view. 
 
384
 */
339
385
gchar *
340
386
bamf_view_get_icon (BamfView *self)
341
387
{
349
395
  if (BAMF_VIEW_GET_CLASS (self)->get_icon)
350
396
    return BAMF_VIEW_GET_CLASS (self)->get_icon (self);
351
397
 
352
 
  if (!bamf_view_remote_ready (self))
 
398
  if (!_bamf_view_remote_ready (self))
353
399
    return g_strdup (priv->local_icon);
354
400
 
355
401
  if (!dbus_g_proxy_call (priv->proxy,
374
420
  return icon;
375
421
}
376
422
 
 
423
/**
 
424
 * bamf_view_get_name:
 
425
 * @view: a #BamfView
 
426
 *
 
427
 * Gets the name of a view. This name is a short name best used to represent the view with text. 
 
428
 */
377
429
gchar *
378
430
bamf_view_get_name (BamfView *self)
379
431
{
387
439
  if (BAMF_VIEW_GET_CLASS (self)->get_name)
388
440
    return BAMF_VIEW_GET_CLASS (self)->get_name (self);
389
441
 
390
 
  if (!bamf_view_remote_ready (self))
 
442
  if (!_bamf_view_remote_ready (self))
391
443
    return g_strdup (priv->local_name);
392
444
    
393
445
  if (!dbus_g_proxy_call (priv->proxy,
413
465
}
414
466
 
415
467
gboolean 
416
 
bamf_view_remote_ready (BamfView *view)
 
468
_bamf_view_remote_ready (BamfView *view)
417
469
{
418
470
  if (BAMF_IS_VIEW (view) && view->priv->proxy)
419
471
    return !view->priv->is_closed;
421
473
  return FALSE;
422
474
}
423
475
 
 
476
/**
 
477
 * bamf_view_get_view_type:
 
478
 * @view: a #BamfView
 
479
 *
 
480
 * The view type of a window is a short string used to represent all views of the same class. These
 
481
 * descriptions should not be used to do casting as they are not considered stable.
 
482
 *
 
483
 * Virtual: view_type
 
484
 */
424
485
const gchar *
425
486
bamf_view_get_view_type (BamfView *self)
426
487
{
470
531
  BamfView *view;
471
532
  BamfViewPrivate *priv;
472
533
 
473
 
  view = bamf_factory_view_for_path (bamf_factory_get_default (), path);
 
534
  view = _bamf_factory_view_for_path (_bamf_factory_get_default (), path);
474
535
  priv = self->priv;
475
536
 
476
537
  if (priv->cached_children)
487
548
{
488
549
  BamfView *view;
489
550
  BamfViewPrivate *priv;
490
 
  view = bamf_factory_view_for_path (bamf_factory_get_default (), path);
 
551
  view = _bamf_factory_view_for_path (_bamf_factory_get_default (), path);
491
552
  priv = self->priv;
492
553
 
493
554
  if (priv->cached_children)
586
647
  _bamf_view_set_closed (self, TRUE);
587
648
 
588
649
  g_object_ref (self);
589
 
 
590
650
  g_signal_emit (G_OBJECT (self), view_signals[CLOSED], 0);
591
651
  g_object_unref (self);
592
652
}
731
791
  G_OBJECT_CLASS (bamf_view_parent_class)->dispose (object);
732
792
}
733
793
 
734
 
const char * 
735
 
bamf_view_get_path (BamfView *view)
 
794
const char *
 
795
_bamf_view_get_path (BamfView *view)
736
796
{
737
797
  g_return_val_if_fail (BAMF_IS_VIEW (view), NULL);
738
798
 
740
800
}
741
801
 
742
802
void
743
 
bamf_view_reset_flags (BamfView *view)
 
803
_bamf_view_reset_flags (BamfView *view)
744
804
{
745
805
  BamfViewPrivate *priv;
746
806
  g_return_if_fail (BAMF_IS_VIEW (view));
774
834
}
775
835
 
776
836
void
777
 
bamf_view_set_path (BamfView *view, const char *path)
 
837
_bamf_view_set_path (BamfView *view, const char *path)
778
838
{
779
839
  BamfViewPrivate *priv;
780
840
 
898
958
 
899
959
  if (bamf_view_is_sticky (view))
900
960
    {
901
 
      bamf_view_reset_flags (view);
 
961
      _bamf_view_reset_flags (view);
902
962
    }
903
963
 
904
964
  if (BAMF_VIEW_GET_CLASS (view)->set_path)
1014
1074
                      G_OBJECT_CLASS_TYPE (klass),
1015
1075
                      0,
1016
1076
                      0, NULL, NULL,
1017
 
                      bamf_marshal_VOID__STRING_STRING,
 
1077
                      _bamf_marshal_VOID__STRING_STRING,
1018
1078
                      G_TYPE_NONE, 2,
1019
1079
                      G_TYPE_STRING,
1020
1080
                      G_TYPE_STRING);