Пример #1
0
static void
mex_menu_notify_focused_cb (MxFocusManager *manager,
                            GParamSpec     *pspec,
                            MexMenu        *self)
{
  MxBoxLayout *layout;
  ClutterActor *focused;
  MexMenuPrivate *priv = self->priv;
  gint depth;

  focused = (ClutterActor *)mx_focus_manager_get_focused (manager);

  /* Check if our child received focus and store which child it was,
   * or lose focus.
   */
  if (focused)
    {
      ClutterActor *parent = clutter_actor_get_parent (focused);
      while (parent)
        {
          if (MX_IS_BOX_LAYOUT (focused))
            layout = (MxBoxLayout *)focused;

          if (parent == (ClutterActor *)self)
            {
              /* We have focus, check what depth we should be at */
              depth =
                GPOINTER_TO_INT (g_object_get_qdata (G_OBJECT (layout),
                                                     mex_menu_depth_quark));

              if ((priv->depth > 0) && (depth < priv->depth))
                while (mex_menu_pop (self) != depth);
              else if ((priv->depth < 0) && (depth > priv->depth))
                while (mex_menu_push (self) != depth);

              if (priv->has_focus)
                priv->focus_on_add = FALSE;
              else
                priv->has_focus = TRUE;

              return;
            }

          focused = parent;
          parent = clutter_actor_get_parent (focused);
        }
    }

  /* We don't have focus, switch to the root depth */
  priv->has_focus = priv->focus_on_add = FALSE;
  if (priv->depth > 0)
    while (mex_menu_pop (self));
  else if (priv->depth < 0)
    while (mex_menu_push (self));
}
Пример #2
0
static void
toggle_editable_cb (MxPathBar *bar)
{
  ClutterActor *parent = clutter_actor_get_parent (CLUTTER_ACTOR (bar));
  gboolean editable = !mx_path_bar_get_editable (bar);
  mx_path_bar_set_editable (bar, editable);
  if (MX_IS_BIN (parent))
    mx_bin_set_fill (MX_BIN (parent), editable, FALSE);
  else if (MX_IS_BOX_LAYOUT (parent))
    clutter_container_child_set (CLUTTER_CONTAINER (parent),
                                 CLUTTER_ACTOR (bar),
                                 "x-fill", editable,
                                 NULL);
}