static void
_enabled_techs_changed (CarrickConnmanManager *cm,
                        GParamSpec            *pspec,
                        MpdComputerTile       *tile)
{
  MpdComputerTilePrivate *priv = tile->priv;
  gboolean enabled_techs[N_RADIO_TECHS];
  char **techs, **iter;
  int i;

  memset (enabled_techs, 0, N_RADIO_TECHS * sizeof (gboolean));

  g_object_get (cm, "enabled-technologies", &techs, NULL);
  iter = techs;

  while (*iter) {
      for (i = 0; i < N_RADIO_TECHS; i++)
        if (g_strcmp0 (*iter, radio_tech_to_connman_tech (i)) == 0)
          enabled_techs[i] = TRUE;
    iter++;
  }

  for (i = 0; i < N_RADIO_TECHS; i++)
    {
      g_signal_handlers_block_by_func (priv->rows[i].toggle,
                                       on_switch_toggled,
                                       &priv->toggled_data[i]);
      mx_toggle_set_active (MX_TOGGLE (priv->rows[i].toggle), enabled_techs[i]);
      g_signal_handlers_unblock_by_func (priv->rows[i].toggle,
                                         on_switch_toggled,
                                         &priv->toggled_data[i]);
    }

  g_strfreev (techs);
}
Example #2
0
static void
mx_toggle_paint (ClutterActor *actor)
{
  CLUTTER_ACTOR_CLASS (mx_toggle_parent_class)->paint (actor);

  clutter_actor_paint (MX_TOGGLE (actor)->priv->handle);
}
Example #3
0
File: mx-toggle.c Project: jlec/mx
static void
mx_toggle_apply_style (MxWidget *widget,
                       MxStyle  *style)
{
  MxTogglePrivate *priv = MX_TOGGLE (widget)->priv;

  if (priv->handle != NULL)
    mx_stylable_set_style (MX_STYLABLE (priv->handle), style);
}
Example #4
0
File: mx-toggle.c Project: jlec/mx
static void
mx_toggle_unmap (ClutterActor *actor)
{
  MxTogglePrivate *priv = MX_TOGGLE (actor)->priv;

  clutter_actor_unmap (priv->handle);

  CLUTTER_ACTOR_CLASS (mx_toggle_parent_class)->unmap (actor);
}
Example #5
0
static MxFocusable*
mx_toggle_accept_focus (MxFocusable *focusable, MxFocusHint hint)
{
  MxTogglePrivate *priv = MX_TOGGLE (focusable)->priv;

  mx_stylable_style_pseudo_class_add (MX_STYLABLE (focusable), "focus");
  mx_stylable_style_pseudo_class_add (MX_STYLABLE (priv->handle), "focus");

  clutter_actor_grab_key_focus (CLUTTER_ACTOR (focusable));

  return focusable;
}
Example #6
0
static gboolean
mx_toggle_button_release_event (ClutterActor       *actor,
                                ClutterButtonEvent *event)
{
  MxToggle *toggle = MX_TOGGLE (actor);

  if (mx_widget_get_disabled (MX_WIDGET (actor)))
    return FALSE;

  mx_toggle_set_active (toggle, !toggle->priv->active);

  return FALSE;
}
Example #7
0
File: mx-toggle.c Project: jlec/mx
static void
mx_toggle_dispose (GObject *object)
{
  MxTogglePrivate *priv = MX_TOGGLE (object)->priv;

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

  G_OBJECT_CLASS (mx_toggle_parent_class)->dispose (object);
}
Example #8
0
static MxFocusable*
mx_toggle_move_focus (MxFocusable      *focusable,
                      MxFocusDirection  direction,
                      MxFocusable      *from)
{
  /* check if focus is being moved from us */
  if (focusable == from)
    {
      MxTogglePrivate *priv = MX_TOGGLE (focusable)->priv;

      mx_stylable_style_pseudo_class_remove (MX_STYLABLE (focusable), "focus");
      mx_stylable_style_pseudo_class_remove (MX_STYLABLE (priv->handle), "focus");
    }

  return NULL;
}
Example #9
0
static void
mx_toggle_allocate (ClutterActor          *actor,
                    const ClutterActorBox *box,
                    ClutterAllocationFlags flags)
{
  MxTogglePrivate *priv = MX_TOGGLE (actor)->priv;
  ClutterActorBox handle_box, child_box;
  CoglHandle background;
  gfloat handle_w;
  gfloat toggle_pos;

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

  mx_widget_get_available_area (MX_WIDGET (actor), box, &child_box);

  /* background-image don't get stretched, so adjust the child box so that the
   * handle appears in the correct place.
   */
  background = mx_widget_get_background_texture (MX_WIDGET (actor));
  if (background)
    {
      gfloat width;
      MxPadding padding;

      mx_widget_get_padding (MX_WIDGET (actor), &padding);
      width = cogl_texture_get_width (background);
      width -= padding.left + padding.right;

      child_box.x1 += (child_box.x2 - child_box.x1) / 2.f;
      child_box.x1 -= width / 2.f;
      child_box.x2 = child_box.x1 + width;
    }

  clutter_actor_get_preferred_width (priv->handle, -1, NULL, &handle_w);
  toggle_pos = child_box.x2 - handle_w - child_box.x1;
  priv->slide_length = toggle_pos;

  toggle_pos = toggle_pos * priv->position;

  handle_box.x1 = (gint) (child_box.x1 + toggle_pos);
  handle_box.y1 = child_box.y1;
  handle_box.x2 = handle_box.x1 + handle_w;
  handle_box.y2 = child_box.y2;

  clutter_actor_allocate (priv->handle, &handle_box, flags);
}
Example #10
0
static void
mx_toggle_set_property (GObject      *object,
                        guint         property_id,
                        const GValue *value,
                        GParamSpec   *pspec)
{
  MxToggle *toggle = MX_TOGGLE (object);

  switch (property_id)
    {
    case PROP_ACTIVE:
      mx_toggle_set_active (toggle, g_value_get_boolean (value));
      break;

    default:
      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
    }
}
Example #11
0
static void
mx_toggle_get_property (GObject    *object,
                        guint       property_id,
                        GValue     *value,
                        GParamSpec *pspec)
{
  MxTogglePrivate *priv = MX_TOGGLE (object)->priv;

  switch (property_id)
    {
    case PROP_ACTIVE:
      g_value_set_boolean (value, priv->active);
      break;

    default:
      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
    }
}
Example #12
0
static void
_toggle_active_cb (MxToggle      *toggle,
                   GParamSpec    *pspec,
                   DawatiBtShell *shell)
{
  DawatiBtShellPrivate *priv = GET_PRIVATE (shell);
  gboolean active;

  active = mx_toggle_get_active (MX_TOGGLE (toggle));

  if (!priv->available ||
      (active && priv->enabled) ||
      (!active && !priv->enabled)) {
    return;
  }

  carrick_connman_manager_set_technology_state (priv->cm, "bluetooth", active);
}
static void
_offline_mode_changed (CarrickConnmanManager *cm,
                       GParamSpec            *pspec,
                       MpdComputerTile       *tile)
{
  MpdComputerTilePrivate *priv = tile->priv;
  gboolean offline_mode;

  offline_mode = carrick_connman_manager_get_offline_mode (cm);

  g_signal_handlers_block_by_func (priv->rows[OFFLINE_MODE].toggle,
                                   on_switch_toggled,
                                   &priv->toggled_data[OFFLINE_MODE]);

  mx_toggle_set_active (MX_TOGGLE (priv->rows[OFFLINE_MODE].toggle),
                        offline_mode);

  g_signal_handlers_unblock_by_func (priv->rows[OFFLINE_MODE].toggle,
                                     on_switch_toggled,
                                     &priv->toggled_data[OFFLINE_MODE]);
}
Example #14
0
static void
startup_cb (MxApplication *app)
{
    MxWindow *window;
    ClutterActor *stage, *toggle, *label, *table, *button, *icon;

    window = mx_application_create_window (app, "Test Window");
    stage = (ClutterActor *)mx_window_get_clutter_stage (window);
    mx_window_set_icon_name (window, "window-new");

    clutter_actor_set_size (stage, 480, 320);

    table = mx_table_new ();
    mx_table_set_column_spacing (MX_TABLE (table), 8);
    mx_table_set_row_spacing (MX_TABLE (table), 12);
    mx_window_set_child (window, table);

    toggle = mx_toggle_new ();
    label = mx_label_new_with_text ("Toggle small-screen mode");
    g_signal_connect (toggle, "notify::active",
                      G_CALLBACK (small_screen_cb), window);
    mx_table_insert_actor_with_properties (MX_TABLE (table),
                                           toggle,
                                           0, 0,
                                           "x-expand", TRUE,
                                           "x-align", MX_ALIGN_END,
                                           "x-fill", FALSE,
                                           NULL);
    mx_table_insert_actor_with_properties (MX_TABLE (table),
                                           label,
                                           0, 1,
                                           "x-expand", TRUE,
                                           "x-align", MX_ALIGN_START,
                                           "y-fill", FALSE,
                                           "x-fill", FALSE,
                                           NULL);

    toggle = mx_toggle_new ();
    label = mx_label_new_with_text ("Toggle full-screen mode");
    g_signal_connect (toggle, "notify::active",
                      G_CALLBACK (fullscreen_cb), stage);
    mx_table_insert_actor_with_properties (MX_TABLE (table),
                                           toggle,
                                           1, 0,
                                           "x-expand", TRUE,
                                           "x-align", MX_ALIGN_END,
                                           "x-fill", FALSE,
                                           NULL);
    mx_table_insert_actor_with_properties (MX_TABLE (table),
                                           label,
                                           1, 1,
                                           "x-expand", TRUE,
                                           "x-align", MX_ALIGN_START,
                                           "y-fill", FALSE,
                                           "x-fill", FALSE,
                                           NULL);

    toggle = mx_toggle_new ();
    label = mx_label_new_with_text ("Toggle custom window icon");
    g_signal_connect (toggle, "notify::active",
                      G_CALLBACK (icon_cb), window);
    mx_table_insert_actor_with_properties (MX_TABLE (table),
                                           toggle,
                                           2, 0,
                                           "x-expand", TRUE,
                                           "x-align", MX_ALIGN_END,
                                           "x-fill", FALSE,
                                           NULL);
    mx_table_insert_actor_with_properties (MX_TABLE (table),
                                           label,
                                           2, 1,
                                           "x-expand", TRUE,
                                           "x-align", MX_ALIGN_START,
                                           "y-fill", FALSE,
                                           "x-fill", FALSE,
                                           NULL);

    toggle = mx_toggle_new ();
    mx_toggle_set_active (MX_TOGGLE (toggle), TRUE);
    label = mx_label_new_with_text ("Toggle user-resizable");
    g_signal_connect (toggle, "notify::active",
                      G_CALLBACK (resizable_cb), stage);
    mx_table_insert_actor_with_properties (MX_TABLE (table),
                                           toggle,
                                           3, 0,
                                           "x-expand", TRUE,
                                           "x-align", MX_ALIGN_END,
                                           "x-fill", FALSE,
                                           NULL);
    mx_table_insert_actor_with_properties (MX_TABLE (table),
                                           label,
                                           3, 1,
                                           "x-expand", TRUE,
                                           "x-align", MX_ALIGN_START,
                                           "y-fill", FALSE,
                                           "x-fill", FALSE,
                                           NULL);

    toggle = mx_toggle_new ();
    mx_toggle_set_active (MX_TOGGLE (toggle), TRUE);
    label = mx_label_new_with_text ("Toggle toolbar");
    g_signal_connect (toggle, "notify::active",
                      G_CALLBACK (toolbar_cb), window);
    mx_table_insert_actor_with_properties (MX_TABLE (table),
                                           toggle,
                                           4, 0,
                                           "x-expand", TRUE,
                                           "x-align", MX_ALIGN_END,
                                           "x-fill", FALSE,
                                           NULL);
    mx_table_insert_actor_with_properties (MX_TABLE (table),
                                           label,
                                           4, 1,
                                           "x-expand", TRUE,
                                           "x-align", MX_ALIGN_START,
                                           "y-fill", FALSE,
                                           "x-fill", FALSE,
                                           NULL);

    icon = mx_icon_new ();
    mx_icon_set_icon_name (MX_ICON (icon), "object-rotate-right");
    mx_icon_set_icon_size (MX_ICON (icon), 16);
    button = mx_button_new ();
    mx_bin_set_child (MX_BIN (button), icon);
    g_signal_connect (button, "clicked", G_CALLBACK (rotate_clicked_cb), window);
    clutter_container_add_actor (
        CLUTTER_CONTAINER (mx_window_get_toolbar (window)), button);
    mx_bin_set_alignment (MX_BIN (mx_window_get_toolbar (window)),
                          MX_ALIGN_END, MX_ALIGN_MIDDLE);

    clutter_actor_show (stage);
}
Example #15
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);
  }
}