~azzar1/bamf/fix-highdpi-actionmenu

« back to all changes in this revision

Viewing changes to src/bamf-view.c

  • Committer: CI Train Bot
  • Author(s): Andrea Azzarone
  • Date: 2016-03-21 15:35:36 UTC
  • mfrom: (624.2.10 bamf-sn)
  • Revision ID: ci-train-bot@canonical.com-20160321153536-j0hw7a7rxs2rdkmo
BamfView: add "starting" property which is true when an application has been launched Fixes: #676457
Approved by: Marco Trevisan (Treviño), PS Jenkins bot

Show diffs side-by-side

added added

removed removed

Lines of Context:
28
28
                         G_IMPLEMENT_INTERFACE (BAMF_DBUS_ITEM_TYPE_VIEW,
29
29
                                                bamf_view_dbus_view_iface_init));
30
30
 
 
31
#define STARTING_MAX_WAIT 15
 
32
 
31
33
enum
32
34
{
33
35
  PROP_0,
35
37
  PROP_NAME,
36
38
  PROP_ICON,
37
39
  PROP_ACTIVE,
 
40
  PROP_STARTING,
38
41
  PROP_RUNNING,
39
42
  PROP_URGENT,
40
43
  PROP_USER_VISIBLE,
57
60
  /* FIXME: temporary cache these properties until we don't export the view
58
61
   * to the bus, we need this until the skeleton won't be smart enough to emit
59
62
   * signals as soon as the object is exported */
 
63
  gboolean starting;
60
64
  gboolean running;
61
65
  gboolean user_visible;
62
66
  gboolean urgent;
74
78
  GList * children;
75
79
  GList * parents;
76
80
  gboolean closed;
 
81
  guint starting_timeout;
77
82
 
78
83
  /* FIXME: remove this as soon as we move to properties on library as well */
79
84
  guint active_changed_idle;
144
149
    g_signal_emit_by_name (view, "user-visible-changed", user_visible);
145
150
}
146
151
 
 
152
static gboolean
 
153
on_starting_timeout (gpointer data)
 
154
{
 
155
  BamfView *view = data;
 
156
 
 
157
  bamf_view_set_starting (view, FALSE);
 
158
  view->priv->starting_timeout = 0;
 
159
 
 
160
  return FALSE;
 
161
}
 
162
 
 
163
static void
 
164
bamf_view_starting_changed (BamfView *view, gboolean starting)
 
165
{
 
166
  BamfViewPrivate *priv;
 
167
 
 
168
  g_return_if_fail (BAMF_IS_VIEW (view));
 
169
 
 
170
  priv = view->priv;
 
171
 
 
172
  if (BAMF_VIEW_GET_CLASS (view)->starting_changed)
 
173
    {
 
174
      BAMF_VIEW_GET_CLASS (view)->starting_changed (view, starting);
 
175
    }
 
176
 
 
177
  if (priv->starting_timeout)
 
178
    {
 
179
      g_source_remove (priv->starting_timeout);
 
180
      priv->starting_timeout = 0;
 
181
    }
 
182
 
 
183
  if (starting)
 
184
    priv->starting_timeout = g_timeout_add_seconds (STARTING_MAX_WAIT, on_starting_timeout, view);
 
185
}
 
186
 
147
187
static void
148
188
bamf_view_running_changed (BamfView *view, gboolean running)
149
189
{
157
197
 
158
198
  if (emit)
159
199
    g_signal_emit_by_name (view, "running-changed", running);
 
200
 
 
201
  if (running)
 
202
    bamf_view_set_starting (view, FALSE);
160
203
}
161
204
 
162
205
static void
421
464
}
422
465
 
423
466
gboolean
 
467
bamf_view_is_starting (BamfView *view)
 
468
{
 
469
 BAMF_VIEW_GET_PROPERTY (view, starting, FALSE);
 
470
}
 
471
 
 
472
void
 
473
bamf_view_set_starting (BamfView *view,
 
474
                        gboolean starting)
 
475
{
 
476
  BAMF_VIEW_SET_BOOL_PROPERTY (view, starting);
 
477
}
 
478
 
 
479
gboolean
424
480
bamf_view_is_running (BamfView *view)
425
481
{
426
482
 BAMF_VIEW_GET_PROPERTY (view, running, FALSE);
516
572
  bamf_view_set_name (view, cache->name);
517
573
  bamf_view_set_icon (view, cache->icon);
518
574
  bamf_view_set_active (view, cache->active);
 
575
  bamf_view_set_starting (view, cache->starting);
519
576
  bamf_view_set_running (view, cache->running);
520
577
  bamf_view_set_user_visible (view, cache->user_visible);
521
578
  bamf_view_set_urgent (view, cache->urgent);
785
842
      priv->parents = NULL;
786
843
    }
787
844
 
 
845
  if (priv->starting_timeout)
 
846
    {
 
847
      g_source_remove (priv->starting_timeout);
 
848
      priv->starting_timeout = 0;
 
849
    }
 
850
 
788
851
  if (priv->active_changed_idle)
789
852
    {
790
853
      g_source_remove (priv->active_changed_idle);
829
892
      case PROP_USER_VISIBLE:
830
893
        g_value_set_boolean (value, bamf_view_is_user_visible (view));
831
894
        break;
 
895
      case PROP_STARTING:
 
896
        g_value_set_boolean (value, bamf_view_is_starting (view));
 
897
        break;
832
898
      case PROP_RUNNING:
833
899
        g_value_set_boolean (value, bamf_view_is_running (view));
834
900
        break;
923
989
  g_object_class_override_property (object_class, PROP_ICON, "icon");
924
990
  g_object_class_override_property (object_class, PROP_ACTIVE, "active");
925
991
  g_object_class_override_property (object_class, PROP_URGENT, "urgent");
 
992
  g_object_class_override_property (object_class, PROP_STARTING, "starting");
926
993
  g_object_class_override_property (object_class, PROP_RUNNING, "running");
927
994
  g_object_class_override_property (object_class, PROP_USER_VISIBLE, "user-visible");
928
995