static gboolean
_notification_timeout_cb (gpointer userdata)
{
  MexDummyNotificationSource *source = MEX_DUMMY_NOTIFICATION_SOURCE (userdata);
  MexNotification *notification;

  notification = mex_notification_source_new_notification (MEX_NOTIFICATION_SOURCE (source),
                                                           _("Snow?"),
                                                           "weather-snow",
                                                           8);

  mex_notification_source_emit_notification_added (MEX_NOTIFICATION_SOURCE (source),
                                                   notification);
  mex_notification_free (notification);

  return TRUE;
}
Пример #2
0
static void
mex_info_bar_init (MexInfoBar *self)
{
  ClutterScript *script;
  ClutterActor *notification_area;
  GError *err = NULL;
  gchar *tmp;

  MexInfoBarPrivate *priv = self->priv = INFO_BAR_PRIVATE (self);

  priv->script = script = clutter_script_new ();

  tmp = g_build_filename (mex_get_data_dir (), "json", "info-bar.json", NULL);
  clutter_script_load_from_file (script, tmp, &err);
  g_free (tmp);

  if (err)
    g_error ("Could not load info bar: %s", err->message);

  priv->group =
    CLUTTER_ACTOR (clutter_script_get_object (script, "main-group"));

  clutter_actor_set_parent (priv->group, CLUTTER_ACTOR (self));


  priv->settings_button =
    CLUTTER_ACTOR (clutter_script_get_object (script, "settings-button"));

  priv->power_button =
    CLUTTER_ACTOR (clutter_script_get_object (script, "power-button"));

  priv->back_button =
    CLUTTER_ACTOR (clutter_script_get_object (script, "back-button"));

  priv->notification_source = mex_generic_notification_source_new ();

  notification_area =
    CLUTTER_ACTOR (clutter_script_get_object (priv->script,
                                              "notification-area"));

  mex_notification_area_add_source (MEX_NOTIFICATION_AREA (notification_area),
                                    MEX_NOTIFICATION_SOURCE (priv->notification_source));

  g_signal_connect (priv->settings_button,
                    "clicked",
                    G_CALLBACK (_show_settings_dialog_cb), self);

  g_signal_connect (priv->power_button,
                    "clicked",
                    G_CALLBACK (_show_power_dialog_cb), self);

  g_signal_connect (priv->back_button,
                    "clicked",
                    G_CALLBACK (_back_button_cb), self);

  _create_power_dialog (MEX_INFO_BAR (self));
  _create_settings_dialog (MEX_INFO_BAR (self));
}
void
mex_generic_notification_new_notification (MexGenericNotificationSource *sourcein,
                                           const gchar *message,
                                           gint timeout)
{
  MexGenericNotificationSource *source =
    MEX_GENERIC_NOTIFICATION_SOURCE (sourcein);

  MexNotification *notification;

  notification =
    mex_notification_source_new_notification (MEX_NOTIFICATION_SOURCE (source),
                                              message,
                                              "icon-notifications",
                                              timeout);

  mex_notification_source_emit_notification_added (MEX_NOTIFICATION_SOURCE (source),
                                                   notification);
  mex_notification_free (notification);
}
static void
_online_notify_cb (gboolean online,
                   gpointer userdata)
{
  MexNotificationSource *source = MEX_NOTIFICATION_SOURCE (userdata);
  MexNetworkNotificationSourcePrivate *priv;
  MexNotification *n;

  priv = MEX_NETWORK_NOTIFICATION_SOURCE (source)->priv;

  if (online)
    {
      if (priv->offline_notification)
        {
          /* Remove old notification */
          mex_notification_source_emit_notification_remove (source,
                                                            priv->offline_notification);
          mex_notification_free (priv->offline_notification);
          priv->offline_notification = NULL;
        }

      n = mex_notification_source_new_notification (source,
                                                    _("Network connection established"),
                                                    "icon-notifications",
                                                    30);
      mex_notification_source_emit_notification_added (source, n);

      mex_notification_free (n);
    } else {
        if (!priv->offline_notification)
          {
            n = mex_notification_source_new_notification (source,
                                                          _("Network connection lost"),
                                                          "icon-notifications",
                                                          -1);

            priv->offline_notification = n;
            mex_notification_source_emit_notification_added (source, n);
          }
    }
}
Пример #5
0
static void
mex_info_bar_init (MexInfoBar *self)
{
  ClutterScript *script;
  ClutterActor *notification_area;
  GError *err = NULL;
  gchar *tmp;
  GSettings *settings;

  MexInfoBarPrivate *priv = self->priv = INFO_BAR_PRIVATE (self);

  priv->script = script = clutter_script_new ();

  tmp = g_build_filename (mex_get_data_dir (), "json", "info-bar.json", NULL);
  clutter_script_load_from_file (script, tmp, &err);
  g_free (tmp);

  if (err)
    g_error ("Could not load info bar: %s", err->message);

  priv->group =
    CLUTTER_ACTOR (clutter_script_get_object (script, "main-group"));

  clutter_actor_set_parent (priv->group, CLUTTER_ACTOR (self));


  priv->settings_button =
    CLUTTER_ACTOR (clutter_script_get_object (script, "settings-button"));

  priv->power_button =
    CLUTTER_ACTOR (clutter_script_get_object (script, "power-button"));

  priv->back_button =
    CLUTTER_ACTOR (clutter_script_get_object (script, "back-button"));

  priv->notification_source = mex_generic_notification_source_new ();

  notification_area =
    CLUTTER_ACTOR (clutter_script_get_object (priv->script,
                                              "notification-area"));

  /* ensure the notification area is above any other actors */
  clutter_actor_set_child_above_sibling (clutter_actor_get_parent (notification_area),
                                         notification_area, NULL);

  mex_notification_area_add_source (MEX_NOTIFICATION_AREA (notification_area),
                                    MEX_NOTIFICATION_SOURCE (priv->notification_source));

  g_signal_connect (priv->settings_button,
                    "clicked",
                    G_CALLBACK (_show_settings_dialog_cb), self);

  g_signal_connect (priv->power_button,
                    "clicked",
                    G_CALLBACK (_close_request_cb), self);

  g_signal_connect (priv->back_button,
                    "clicked",
                    G_CALLBACK (_back_button_cb), self);

  _create_settings_dialog (MEX_INFO_BAR (self));

  settings = g_settings_new ("org.media-explorer.Shell");
  if (!g_settings_get_boolean (settings, "close-button-visible"))
    clutter_actor_hide (priv->power_button);
  g_clear_object (&settings);
}