Example #1
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));
}
Example #2
0
static void
mex_info_bar_dispose (GObject *object)
{
  MexInfoBar *self = MEX_INFO_BAR (object);
  MexInfoBarPrivate *priv = self->priv;

  if (priv->settings_dialog)
    {
      clutter_actor_destroy (priv->settings_dialog);
      priv->settings_dialog = NULL;
    }

  if (priv->group)
    {
      clutter_actor_destroy (priv->group);
      priv->group = NULL;
    }

  if (priv->script)
    {
      g_object_unref (priv->script);
      priv->script = NULL;
    }

  G_OBJECT_CLASS (mex_info_bar_parent_class)->dispose (object);
}
Example #3
0
static MxFocusable *
mex_info_bar_accept_focus (MxFocusable *focusable,
                           MxFocusHint  hint)
{
  MexInfoBarPrivate *priv = MEX_INFO_BAR (focusable)->priv;

  return mx_focusable_accept_focus (MX_FOCUSABLE (priv->group),
                                    MX_FOCUS_HINT_FIRST);
}
Example #4
0
static void
mex_info_bar_unmap (ClutterActor *actor)
{
  MexInfoBarPrivate *priv = MEX_INFO_BAR (actor)->priv;

  clutter_actor_unmap (priv->group);

  CLUTTER_ACTOR_CLASS (mex_info_bar_parent_class)->unmap (actor);
}
Example #5
0
static void
mex_info_bar_pick (ClutterActor       *actor,
                   const ClutterColor *color)
{
  MexInfoBarPrivate *priv = MEX_INFO_BAR (actor)->priv;

  CLUTTER_ACTOR_CLASS (mex_info_bar_parent_class)->pick (actor, color);

  clutter_actor_paint (priv->group);
}
Example #6
0
static void
mex_info_bar_allocate (ClutterActor           *actor,
                       const ClutterActorBox  *box,
                       ClutterAllocationFlags  flags)
{
  ClutterActorBox child_box;
  MexInfoBarPrivate *priv = MEX_INFO_BAR (actor)->priv;

  CLUTTER_ACTOR_CLASS (mex_info_bar_parent_class)->
    allocate (actor, box, flags);

  mx_widget_get_available_area (MX_WIDGET (actor), box, &child_box);
  clutter_actor_allocate (priv->group, &child_box, flags);
}
Example #7
0
static void
mex_info_bar_get_preferred_width (ClutterActor *actor,
                                  gfloat        for_height,
                                  gfloat       *min_width_p,
                                  gfloat       *nat_width_p)
{
  MxPadding padding;
  MexInfoBarPrivate *priv = MEX_INFO_BAR (actor)->priv;

  mx_widget_get_padding (MX_WIDGET (actor), &padding);
  if (for_height >= 0)
    for_height = MAX (0, for_height - padding.top - padding.bottom);

  clutter_actor_get_preferred_width (priv->group,
                                     for_height,
                                     min_width_p,
                                     nat_width_p);

  if (min_width_p)
    *min_width_p += padding.left + padding.right;
  if (nat_width_p)
    *nat_width_p += padding.left + padding.right;
}
Example #8
0
static MxFocusable *
mex_info_bar_accept_focus (MxFocusable *focusable,
                           MxFocusHint  hint)
{
  MexInfoBarPrivate *priv = MEX_INFO_BAR (focusable)->priv;

  MxFocusable *result;

  ClutterActor *buttons_area;

 buttons_area =
    CLUTTER_ACTOR (clutter_script_get_object (priv->script, "buttons-area"));

  /* try the previous focusable first */
  result = mx_focusable_accept_focus (MX_FOCUSABLE (buttons_area),
                                      MX_FOCUS_HINT_PRIOR);

  if (!result)
    result = mx_focusable_accept_focus (MX_FOCUSABLE (buttons_area),
                                        MX_FOCUS_HINT_FIRST);

  return result;
}
Example #9
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);
}