Пример #1
0
static gboolean
_enter_event_cb (ClutterActor         *actor,
                 ClutterCrossingEvent *event,
                 gpointer              data)
{
  MxFocusable *focusable;
  MxFocusManager *f_manager;

  f_manager =
    mx_focus_manager_get_for_stage (CLUTTER_STAGE (clutter_actor_get_stage (actor)));

  focusable = mx_focus_manager_get_focused (f_manager);

  /* hide the hover state on a button that has accepted focus via the default
   * focus as we're navigating by mouse and not keys we don't want to move
   * the focus as we may still want it in the place e.g. search bar
   */
  if ((focusable) &&
      (MNB_IS_LAUNCHER_BUTTON (focusable)) &&
      (CLUTTER_ACTOR (focusable) != actor))
    mx_stylable_set_style_pseudo_class (MX_STYLABLE (focusable), NULL);

  mx_stylable_set_style_pseudo_class (MX_STYLABLE (actor), "hover");

  return FALSE;
}
Пример #2
0
void
mx_toggle_set_active (MxToggle *toggle,
                      gboolean  active)
{
  MxTogglePrivate *priv;

  g_return_if_fail (MX_IS_TOGGLE (toggle));

  priv = toggle->priv;

  if (priv->active != active
      || (priv->position > 0 && priv->position < 1))
    {
      ClutterTimeline *timeline;

      priv->active = active;

      if (active)
        mx_stylable_set_style_pseudo_class (MX_STYLABLE (toggle), "checked");
      else
        mx_stylable_set_style_pseudo_class (MX_STYLABLE (toggle), NULL);

      g_object_notify (G_OBJECT (toggle), "active");


      /* don't run an animation if the actor is not mapped */
      if (!CLUTTER_ACTOR_IS_MAPPED (CLUTTER_ACTOR (toggle)))
        {
          priv->position = (active) ? 1 : 0;
          return;
        }

      timeline = clutter_alpha_get_timeline (priv->alpha);

      if (active)
        clutter_timeline_set_direction (timeline, CLUTTER_TIMELINE_FORWARD);
      else
        clutter_timeline_set_direction (timeline, CLUTTER_TIMELINE_BACKWARD);

      if (clutter_timeline_is_playing (timeline))
        return;

      clutter_timeline_rewind (timeline);

      if (priv->drag_offset > -1)
        {
          clutter_alpha_set_mode (priv->alpha, CLUTTER_LINEAR);
          clutter_timeline_advance (timeline, priv->position * 300);
        }
      else
        {
          clutter_alpha_set_mode (priv->alpha, CLUTTER_EASE_IN_OUT_CUBIC);
        }

      clutter_timeline_start (timeline);
    }
}
Пример #3
0
static gboolean
mnb_launcher_button_key_release_event (ClutterActor       *actor,
                                       ClutterKeyEvent    *event)
{
  if (event->keyval == CLUTTER_KEY_Return ||
      event->keyval == CLUTTER_KEY_KP_Enter ||
      event->keyval == CLUTTER_KEY_ISO_Enter)
    {
      MnbLauncherButton *self = MNB_LAUNCHER_BUTTON (actor);

      if (!self->priv->is_pressed)
        return FALSE;

      clutter_ungrab_keyboard ();
      self->priv->is_pressed = FALSE;
      g_signal_emit (self, _signals[ACTIVATED], 0);

      mx_stylable_set_style_pseudo_class (MX_STYLABLE (self), NULL);
      mx_widget_hide_tooltip (MX_WIDGET (self));

      return TRUE;
    }

  return FALSE;
}
Пример #4
0
static void
mex_search_text_style_changed (MxStylable *text,
                               GParamSpec *pspec,
                               MxStylable *header)
{
  /* ensure the text entry and header pseudo class match for styling purposes */
  mx_stylable_set_style_pseudo_class (header,
                                      mx_stylable_get_style_pseudo_class (text));
}
Пример #5
0
static MxFocusable *
mx_combo_box_accept_focus (MxFocusable *focusable, MxFocusHint hint)
{
  mx_stylable_set_style_pseudo_class (MX_STYLABLE (focusable), "focus");

  clutter_actor_grab_key_focus (CLUTTER_ACTOR (focusable));

  return focusable;
}
Пример #6
0
static MxFocusable *
mnb_launcher_button_accept_focus (MxFocusable *focusable,
                                  MxFocusHint hint)
{
  clutter_ungrab_pointer ();
  clutter_actor_grab_key_focus (CLUTTER_ACTOR (focusable));
  mx_stylable_set_style_pseudo_class (MX_STYLABLE (focusable), "hover");

  return focusable;
}
Пример #7
0
static MxFocusable *
mx_combo_box_move_focus (MxFocusable      *focusable,
                         MxFocusDirection  direction,
                         MxFocusable      *from)
{
  if (focusable == from)
    {
      mx_stylable_set_style_pseudo_class (MX_STYLABLE (focusable), "");
    }

  return NULL;
}
Пример #8
0
static void
mx_combo_box_action_activated_cb (ClutterActor *menu,
                                  MxAction     *action,
                                  MxComboBox   *box)
{
  gint index;

  index = GPOINTER_TO_INT (g_object_get_data ((GObject*) action, "index"));
  mx_combo_box_set_index (box, index);

  /* reset the combobox style */
  mx_stylable_set_style_pseudo_class (MX_STYLABLE (box), NULL);
}
Пример #9
0
static gboolean
on_handle_capture_event (ClutterActor *trough,
                         ClutterEvent *event,
                         MxSlider     *bar)
{
  MxSliderPrivate *priv = bar->priv;

  if (clutter_event_type (event) == CLUTTER_MOTION)
    {
      drag_handle (bar,
                   ((ClutterMotionEvent*)event)->x,
                   ((ClutterMotionEvent*)event)->y);
    }
  else if (clutter_event_type (event) == CLUTTER_BUTTON_RELEASE
           && ((ClutterButtonEvent*)event)->button == 1)
    {
      ClutterActor *stage, *target;

      stage = clutter_actor_get_stage(priv->trough);

      if (priv->capture_handler)
        {
          g_signal_handler_disconnect (stage, priv->capture_handler);
          priv->capture_handler = 0;

          /* update the handle position */
          mx_slider_allocate_fill_handle (bar, NULL, 0);
          clutter_actor_queue_redraw (CLUTTER_ACTOR (bar));
        }

      clutter_stage_set_motion_events_enabled (CLUTTER_STAGE (stage), TRUE);

      /* check if the mouse pointer has left the handle during the drag and
       * remove the hover state if it has */
      target =
        clutter_stage_get_actor_at_pos ((ClutterStage*) stage,
                                        CLUTTER_PICK_REACTIVE,
                                        ((ClutterButtonEvent*) event)->x,
                                        ((ClutterButtonEvent*) event)->y);
      if (target != priv->handle)
        {
          mx_stylable_set_style_pseudo_class (MX_STYLABLE (priv->handle),
                                            NULL);
        }

      /* emit the stop signal */
      g_signal_emit (bar, signals[SLIDE_STOP], 0);
    }

  return FALSE;
}
Пример #10
0
static void
mx_expander_style_changed (MxStylable *stylable)
{
  MxExpander *expander = MX_EXPANDER (stylable);
  MxExpanderPrivate *priv = expander->priv;
  const gchar *pseudo_class;

  pseudo_class = mx_stylable_get_style_pseudo_class (stylable);

  mx_stylable_set_style_pseudo_class (MX_STYLABLE (expander->priv->arrow),
                                      pseudo_class);

  mx_stylable_apply_clutter_text_attributes (stylable,
                                             CLUTTER_TEXT (priv->label));
}
Пример #11
0
static gboolean
penge_interesting_tile_leave_event (ClutterActor         *actor,
                                    ClutterCrossingEvent *event)
{
    /* If we are just leaving to a child then don't unset the hover */
    if (event->related &&
            clutter_actor_get_parent (event->related) == actor)
    {
        return FALSE;
    }

    mx_stylable_set_style_pseudo_class (MX_STYLABLE (actor), "");

    return FALSE;
}
static gboolean
handle_capture_event_cb (ClutterActor *trough,
                         ClutterEvent *event,
                         MxScrollBar  *bar)
{
  if (clutter_event_type (event) == CLUTTER_MOTION)
    {
      move_slider (bar,
                   ((ClutterMotionEvent*) event)->x,
                   ((ClutterMotionEvent*) event)->y);
    }
  else if (clutter_event_type (event) == CLUTTER_BUTTON_RELEASE
           && ((ClutterButtonEvent*) event)->button == 1)
    {
      ClutterActor *stage, *target;

      stage = clutter_actor_get_stage(bar->priv->trough);

      if (bar->priv->capture_handler)
        {
          g_signal_handler_disconnect (stage, bar->priv->capture_handler);
          bar->priv->capture_handler = 0;
        }

      clutter_set_motion_events_enabled (TRUE);
      g_signal_emit (bar, signals[SCROLL_STOP], 0);

      /* check if the mouse pointer has left the handle during the drag and
       * remove the hover state if it has */
      target = clutter_stage_get_actor_at_pos ((ClutterStage*) stage,
                                               CLUTTER_PICK_REACTIVE,
                                               ((ClutterButtonEvent*) event)->x,
                                               ((ClutterButtonEvent*) event)->y);
      if (target != bar->priv->handle)
        {
          mx_stylable_set_style_pseudo_class (MX_STYLABLE (bar->priv->handle),
                                              NULL);
        }
      else
        {
          /* allow the release event to continue to the handle for processing */
          return FALSE;
        }
    }

  return TRUE;
}
Пример #13
0
static ClutterActor*
dawati_bt_shell_add_device (DawatiBtShell *shell, const char *name, const char *device_path)
{
  DawatiBtShellPrivate *priv = GET_PRIVATE (shell);
  ClutterActor *w;

  w = dawati_bt_device_new (name, device_path);
  if (g_hash_table_size (priv->devices) == 0)
    mx_stylable_set_style_pseudo_class (MX_STYLABLE (w), "first-child");
  g_signal_connect (w, "disconnect",
                    G_CALLBACK (_device_widget_disconnect_cb), shell);

  mx_box_layout_insert_actor (MX_BOX_LAYOUT (priv->device_box), w, -1);
  g_hash_table_insert (priv->devices, g_strdup (device_path), w);

  return w;
}
Пример #14
0
/* Accept focus handles setting hover pseudo style class and leave events
 * handle unsetting the hover pseudo style class
 */
static gboolean
_leave_event_cb (ClutterActor         *actor,
                 ClutterCrossingEvent *event,
                 gpointer              data)
{
  MnbLauncherButton *self = MNB_LAUNCHER_BUTTON (actor);

  mx_stylable_set_style_pseudo_class (MX_STYLABLE (self), NULL);

  if (self->priv->is_pressed)
    {
      clutter_ungrab_pointer ();
      clutter_ungrab_keyboard ();
      self->priv->is_pressed = FALSE;
    }

  return FALSE;
}
Пример #15
0
static gboolean
mnb_launcher_button_button_release_event (ClutterActor       *actor,
                                          ClutterButtonEvent *event)
{
  if (event->button == 1)
    {
      MnbLauncherButton *self = MNB_LAUNCHER_BUTTON (actor);

      if (!self->priv->is_pressed)
        return FALSE;

      clutter_ungrab_pointer ();
      self->priv->is_pressed = FALSE;
      g_signal_emit (self, _signals[ACTIVATED], 0);

      mx_stylable_set_style_pseudo_class (MX_STYLABLE (self), NULL);
      mx_widget_hide_tooltip (MX_WIDGET (self));

      return TRUE;
    }

  return FALSE;
}
Пример #16
0
static void
dawati_bt_shell_update (DawatiBtShell *shell)
{
  DawatiBtShellPrivate *priv = GET_PRIVATE (shell);
  gboolean showinfo;

  showinfo = g_hash_table_size (priv->devices) == 0;

  g_signal_handler_block (priv->kill_toggle, priv->kill_handler);
  mx_toggle_set_active (MX_TOGGLE (priv->kill_toggle), priv->enabled);
  g_signal_handler_unblock (priv->kill_toggle, priv->kill_handler);

  /* Now way to know from Connman:
  mx_widget_set_disabled (MX_WIDGET (priv->kill_toggle), disabled);
  */
  g_object_set (priv->info_label, "visible", showinfo, NULL);
  if (priv->enabled) {
    if (!clutter_actor_get_parent (priv->device_panelbox))
      mx_box_layout_insert_actor (MX_BOX_LAYOUT (priv->content),
                                  priv->device_panelbox,
                                  2);
    clutter_actor_show (priv->add_button);
    clutter_actor_animate (priv->add_button,
                           CLUTTER_LINEAR, 300, "opacity", 0xff,
                           NULL);
    clutter_actor_show (priv->send_button);
    clutter_actor_animate (priv->send_button,
                           CLUTTER_LINEAR, 300, "opacity", 0xff,
                           NULL);
    mx_stylable_set_style_pseudo_class (MX_STYLABLE (priv->button_box), NULL);
  } else {
    if (clutter_actor_get_parent (priv->device_panelbox))
      clutter_actor_remove_child (priv->content, priv->device_panelbox);
    clutter_actor_animate (priv->add_button,
                           CLUTTER_LINEAR, 300, "opacity", 0x00,
                           NULL);
    clutter_actor_animate (priv->send_button,
                           CLUTTER_LINEAR, 300, "opacity", 0x00,
                           "signal::completed", fadeout_completed_cb, shell,
                           NULL);
    mx_stylable_set_style_pseudo_class (MX_STYLABLE (priv->button_box), "state-off");
  }

  if (priv->panel_client) {
    g_object_set (priv->kill_toggle, "disabled", FALSE, NULL);
    if (!priv->available) {
      mpl_panel_client_request_button_state (priv->panel_client,
                                             MNB_BUTTON_HIDDEN);
    } else {
      mpl_panel_client_request_button_state (priv->panel_client,
                                             MNB_BUTTON_NORMAL);
      if (priv->enabled)
          mpl_panel_client_request_button_style (priv->panel_client,
                                                 "state-idle");
      else
          mpl_panel_client_request_button_style (priv->panel_client,
                                                 "state-off");
    }
  } else {
    g_object_set (priv->kill_toggle, "disabled", !priv->available, NULL);
  }
}
Пример #17
0
static void
penge_event_tile_update (PengeEventTile *tile)
{
  PengeEventTilePrivate *priv = GET_PRIVATE (tile);
  gchar *time_str;
  gchar *summary_str;
  JanaTime *t;
  gchar *p;

  if (!priv->event)
    return;

  if (priv->time)
  {
    t = jana_event_get_start (priv->event);

    /* Translate this time into local time */
    jana_time_set_offset (t, jana_time_get_offset (priv->time));

    if (jana_time_get_day (priv->time) != jana_time_get_day (t))
    {
      gchar *tmp_str;
      gchar *day_str;
      ClutterActor *tmp_text;

      tmp_str = jana_utils_strftime (t, "%a");
      day_str = g_utf8_strup (tmp_str, -1);
      g_free (tmp_str);

      time_str = jana_utils_strftime (t, "%H:%M");
      tmp_str = g_strdup_printf ("%s <span size=\"xx-small\">%s</span>",
                                 time_str,
                                 day_str);
      g_free (time_str);
      g_free (day_str);

      tmp_text = mx_label_get_clutter_text (MX_LABEL (priv->time_label));
      clutter_text_set_markup (CLUTTER_TEXT (tmp_text), tmp_str);
      g_free (tmp_str);
    } else {
      time_str = jana_utils_strftime (t, "%H:%M");
      mx_label_set_text (MX_LABEL (priv->time_label), time_str);
      g_free (time_str);
    }

    if (jana_time_get_day (priv->time) != jana_time_get_day (t))
    {
      mx_stylable_set_style_pseudo_class (MX_STYLABLE (priv->time_label),
                                          "past");
    } else {
      mx_stylable_set_style_pseudo_class (MX_STYLABLE (priv->time_label),
                                          NULL);
    }

    g_object_unref (t);
  }

  summary_str = jana_event_get_summary (priv->event);
  if (summary_str)
  {
    /* this hack is courtesy of Chris Lord, we look for a new line character
     * and if we find it replace it with \0. We need this because otherwise
     * new lines in our labels look funn
     */
    p = strchr (summary_str, '\n');
    if (p)
      *p = '\0';
    mx_label_set_text (MX_LABEL (priv->summary_label), summary_str);
    g_free (summary_str);
  } else {
    mx_label_set_text (MX_LABEL (priv->summary_label), "");
  }
}