~om26er/unity/fix-778256-stable

« back to all changes in this revision

Viewing changes to services/panel-service.c

  • Committer: Marco Trevisan (Treviño)
  • Date: 2011-09-04 12:11:22 UTC
  • mto: This revision was merged to the branch mainline in revision 1521.
  • Revision ID: mail@3v1n0.net-20110904121122-vyqh34ea319dz7i3
Make unity to remove the indicators when the panel service has been closed

Not killed, that needs to update the unity side.

Show diffs side-by-side

added added

removed removed

Lines of Context:
76
76
  ENTRY_ACTIVATE_REQUEST,
77
77
  ENTRY_SHOW_NOW_CHANGED,
78
78
  GEOMETRIES_CHANGED,
 
79
  INDICATORS_CLEARED,
79
80
 
80
81
  LAST_SIGNAL
81
82
};
111
112
static void load_indicators (PanelService    *self);
112
113
static void sort_indicators (PanelService    *self);
113
114
 
 
115
static void notify_object (IndicatorObject *object);
 
116
 
114
117
static GdkFilterReturn event_filter (GdkXEvent    *ev,
115
118
                                     GdkEvent     *gev,
116
119
                                     PanelService *self);
202
205
                  panel_marshal_VOID__STRING_BOOLEAN,
203
206
                  G_TYPE_NONE, 2, G_TYPE_STRING, G_TYPE_BOOLEAN);
204
207
 
 
208
  _service_signals[INDICATORS_CLEARED] =
 
209
    g_signal_new ("indicators-cleared",
 
210
                  G_OBJECT_CLASS_TYPE (obj_class),
 
211
                  G_SIGNAL_RUN_LAST,
 
212
                  0,
 
213
                  NULL, NULL,
 
214
                  g_cclosure_marshal_VOID__VOID,
 
215
                  G_TYPE_NONE, 0);
 
216
 
205
217
 
206
218
  g_type_class_add_private (obj_class, sizeof (PanelServicePrivate));
207
219
}
277
289
  priv->initial_sync_id = g_idle_add ((GSourceFunc)initial_resync, self);
278
290
}
279
291
 
 
292
static gboolean
 
293
panel_service_check_cleared (PanelService *self)
 
294
{
 
295
  if (self->priv->indicators == NULL)
 
296
    {
 
297
      g_signal_emit (self, _service_signals[INDICATORS_CLEARED], 0);
 
298
      return FALSE;
 
299
    }
 
300
 
 
301
  return TRUE;
 
302
}
 
303
 
280
304
PanelService *
281
305
panel_service_get_default ()
282
306
{
335
359
  return NULL;
336
360
}
337
361
 
 
362
void
 
363
panel_service_remove_indicator (PanelService *self, IndicatorObject *indicator)
 
364
{
 
365
  g_return_if_fail (PANEL_IS_SERVICE (self));
 
366
  g_return_if_fail (INDICATOR_IS_OBJECT (indicator));
 
367
 
 
368
  g_object_set_data (G_OBJECT (indicator), "remove", GINT_TO_POINTER (TRUE));
 
369
  notify_object (indicator);
 
370
}
 
371
 
 
372
void
 
373
panel_service_clear_indicators (PanelService *self)
 
374
{
 
375
  g_return_if_fail (PANEL_IS_SERVICE (self));
 
376
  GSList *l = self->priv->indicators;
 
377
 
 
378
  while (l)
 
379
    {
 
380
      IndicatorObject *ind = l->data;
 
381
      l = l->next;
 
382
      panel_service_remove_indicator (self, ind);
 
383
    }
 
384
 
 
385
  g_idle_add ((GSourceFunc)panel_service_check_cleared, self);
 
386
}
 
387
 
338
388
/*
339
389
 * Private Methods
340
390
 */
775
825
 
776
826
static void
777
827
indicator_entry_null_to_variant (const gchar     *indicator_id,
778
 
                                 GVariantBuilder *b, int prio)
 
828
                                 GVariantBuilder *b)
779
829
{
780
830
  g_variant_builder_add (b, "(ssssbbusbbi)",
781
831
                         indicator_id,
788
838
                         "",
789
839
                         FALSE,
790
840
                         FALSE,
791
 
                         prio);
 
841
                         -1);
792
842
}
793
843
 
794
844
static void
825
875
  else
826
876
    {
827
877
      /* Add a null entry to indicate that there is an indicator here, it's just empty */
828
 
      indicator_entry_null_to_variant (indicator_id, b, parent_prio);
 
878
      indicator_entry_null_to_variant (indicator_id, b);
829
879
    }
830
880
  g_list_free (entries);
831
881
}
915
965
          position = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (i->data), "position"));
916
966
          self->priv->timeouts[position] = SYNC_NEUTRAL;
917
967
 
918
 
          indicator_object_to_variant (i->data, indicator_id, &b);
 
968
          if (GPOINTER_TO_INT (g_object_get_data (G_OBJECT (i->data), "remove")) != TRUE)
 
969
            {
 
970
              indicator_object_to_variant (i->data, indicator_id, &b);
 
971
            }
 
972
          else
 
973
            {
 
974
              GList *entries, *l;
 
975
              entries = indicator_object_get_entries (INDICATOR_OBJECT (i->data));
 
976
 
 
977
              for (l = entries; l; l = l->next)
 
978
                {
 
979
                  gchar *id = g_strdup_printf ("%p", l->data);
 
980
                  g_hash_table_remove (self->priv->id2entry_hash, id);
 
981
                  g_hash_table_remove (self->priv->entry2indicator_hash, l->data);
 
982
                  g_free (id);
 
983
                }
 
984
 
 
985
              indicator_entry_null_to_variant (indicator_id, &b);
 
986
 
 
987
              g_list_free (entries);
 
988
              self->priv->indicators = g_slist_remove (self->priv->indicators, i->data);
 
989
              g_object_unref (G_OBJECT (i->data));
 
990
            }
 
991
 
919
992
          break;
920
993
        }
921
994
    }
1035
1108
            }
1036
1109
          else
1037
1110
            {
1038
 
              values = ll->prev ? ll->prev->data : g_list_last (ordered_entries)->data;
 
1111
              values = ll->prev ? ll->prev->data : g_list_last(ordered_entries)->data;
1039
1112
            }
1040
1113
 
1041
1114
          new_entry = values[0];