static void
mex_clock_bin_init (MexClockBin *self)
{
  MexClockBinPrivate *priv = self->priv = CLOCK_BIN_PRIVATE (self);

  priv->clock_hbox = mx_box_layout_new ();
  mx_stylable_set_style_class (MX_STYLABLE (priv->clock_hbox),
                               "MexClockBin");
  clutter_actor_set_parent (priv->clock_hbox, CLUTTER_ACTOR (self));

  priv->time_label = mx_label_new ();
  priv->icon = mx_icon_new ();

  mx_box_layout_insert_actor_with_properties (MX_BOX_LAYOUT (priv->clock_hbox),
                                              priv->time_label, 0,
                                              "x-align", MX_ALIGN_START,
                                              "expand", TRUE,
                                              NULL);
  mx_box_layout_insert_actor_with_properties (MX_BOX_LAYOUT (priv->clock_hbox),
                                              priv->icon, 1,
                                              NULL);

  g_signal_connect (self, "actor-added",
                    G_CALLBACK (mex_clock_bin_actor_added), NULL);
  g_signal_connect (self, "actor-removed",
                    G_CALLBACK (mex_clock_bin_actor_removed), NULL);

  mex_clock_update_cb (self);
}
static void
dawati_bt_device_init (DawatiBtDevice *device)
{
  ClutterActor *button;
  DawatiBtDevicePrivate *priv = GET_PRIVATE (device);

  mx_stylable_set_style_class (MX_STYLABLE (device), "BtDevice");

  priv->label = mx_label_new ();
  mx_stylable_set_style_class (MX_STYLABLE (priv->label), "BtTitle");
  mx_box_layout_insert_actor_with_properties (MX_BOX_LAYOUT (device), priv->label, -1,
                                              "expand", TRUE,
                                              "x-fill", FALSE,
                                              "y-fill", FALSE,
                                              "x-align", MX_ALIGN_START,
                                              "y-align", MX_ALIGN_MIDDLE,
                                              NULL);

  button = mx_button_new ();
  mx_stylable_set_style_class (MX_STYLABLE (button), "BtCloseButton");
  mx_bin_set_child (MX_BIN (button), mx_icon_new ());
  g_signal_connect (button, "clicked",
                    G_CALLBACK (_disconnect_clicked_cb), device);
  mx_box_layout_insert_actor (MX_BOX_LAYOUT (device), button, -1);
}
static void
mex_grid_view_init (MexGridView *self)
{
  MexGridViewPrivate *priv = self->priv = GRID_VIEW_PRIVATE (self);
  ClutterActor *scroll_view;

  priv->state = STATE_CLOSED;

  /* Create the menu */
  priv->menu_layout = mex_menu_new ();
  mex_resizing_hbox_set_max_depth (MEX_RESIZING_HBOX (priv->menu_layout), 1);

  /* Add a title/icon */
  priv->menu_title = mx_label_new ();

  mx_stylable_set_style_class (MX_STYLABLE (priv->menu_title), "Header");
  clutter_actor_set_name (priv->menu_title, "menu-header");

  priv->menu = (ClutterActor*) mex_menu_get_layout (MEX_MENU (priv->menu_layout));

  clutter_actor_set_width (priv->menu, MENU_MIN_WIDTH);
  clutter_actor_insert_child_at_index (priv->menu, priv->menu_title, 0);


  /* Add the grid */
  priv->grid_layout = mx_box_layout_new ();
  mx_box_layout_set_orientation (MX_BOX_LAYOUT (priv->grid_layout),
                                 MX_ORIENTATION_VERTICAL);

  /* header */
  priv->grid_title = mx_label_new ();
  mx_stylable_set_style_class (MX_STYLABLE (priv->grid_title), "Header");
  clutter_actor_add_child (priv->grid_layout, priv->grid_title);

  /* scroll view */
  scroll_view = mex_scroll_view_new ();
  mx_kinetic_scroll_view_set_scroll_policy (MX_KINETIC_SCROLL_VIEW (scroll_view),
                                            MX_SCROLL_POLICY_VERTICAL);
  mx_stylable_set_style_class (MX_STYLABLE (scroll_view), "Grid");
  mx_box_layout_insert_actor_with_properties (MX_BOX_LAYOUT (priv->grid_layout),
                                              scroll_view, 1,
                                              "expand", TRUE, NULL);

  /* grid */
  priv->grid = mex_grid_new ();
  mx_bin_set_child (MX_BIN (scroll_view), priv->grid);
  clutter_actor_set_opacity (priv->grid, 0);


  /* Name actors so we can style */
  clutter_actor_set_name (CLUTTER_ACTOR (self), "grid-page");
  clutter_actor_set_name (priv->grid_layout, "content");

  clutter_actor_push_internal (CLUTTER_ACTOR (self));

  clutter_actor_set_parent (priv->menu_layout, CLUTTER_ACTOR (self));
  clutter_actor_set_parent (priv->grid_layout, CLUTTER_ACTOR (self));

  clutter_actor_pop_internal (CLUTTER_ACTOR (self));


  /* timeline for animations */
  priv->timeline = clutter_timeline_new (ANIMATION_DURATION);
  priv->alpha = clutter_alpha_new_full (priv->timeline, CLUTTER_EASE_IN_OUT_CUBIC);
  g_signal_connect (priv->timeline, "new-frame",
                    G_CALLBACK (mex_grid_view_timeline_cb), self);
  g_signal_connect (priv->timeline, "completed",
                    G_CALLBACK (mex_grid_view_timeline_complete_cb), self);
}
static void
dawati_bt_shell_init (DawatiBtShell *shell)
{
  ClutterActor *label, *active_label, *active_box, *settings_button;
  DawatiBtShellPrivate *priv = GET_PRIVATE (shell);

  priv->devices = g_hash_table_new_full (g_str_hash, g_str_equal,
                                         g_free, NULL);
  priv->requests = g_hash_table_new_full (g_str_hash, g_str_equal,
                                         g_free, NULL);

  priv->notification = notify_notification_new ("", NULL, icon);
  notify_notification_set_timeout (priv->notification,
                                   NOTIFY_EXPIRES_NEVER);
  /* TRANSLATORS: button in a notification, will open the
   * bluetooth panel */
  notify_notification_add_action (priv->notification,
                                  "show",
                                  _("Show"),
                                  (NotifyActionCallback)_notify_action_cb,
                                  shell, NULL);

  mx_box_layout_set_orientation (MX_BOX_LAYOUT (shell),
                                 MX_ORIENTATION_VERTICAL);

  label = mx_label_new_with_text (_("Bluetooth"));
  mx_stylable_set_style_class (MX_STYLABLE (label), "titleBar");
  mx_box_layout_insert_actor_with_properties (MX_BOX_LAYOUT (shell),
                                              label, -1,
                                              "expand", TRUE,
                                              "x-fill", TRUE,
                                              "x-align", MX_ALIGN_START,
                                              NULL);

  priv->content = mx_box_layout_new ();
  clutter_actor_set_name (priv->content, "bt-panel-content");
  mx_box_layout_set_enable_animations (MX_BOX_LAYOUT (priv->content), TRUE);
  mx_box_layout_set_orientation (MX_BOX_LAYOUT (priv->content), MX_ORIENTATION_VERTICAL);
  mx_box_layout_insert_actor (MX_BOX_LAYOUT (shell), priv->content, -1);

  active_box = mx_box_layout_new ();
  clutter_actor_set_name (active_box, "bt-panel-active-box");
  mx_box_layout_insert_actor (MX_BOX_LAYOUT (priv->content), active_box, -1);

  /* TRANSLATORS: Label for bluetooth enable/disable toggle */
  active_label = mx_label_new_with_text (_("Active"));
  mx_stylable_set_style_class (MX_STYLABLE (active_label), "BtTitle");
  mx_box_layout_insert_actor_with_properties (MX_BOX_LAYOUT (active_box),
                                              active_label, -1,
                                              "expand", TRUE,
                                              "x-fill", TRUE,
                                              "x-align", MX_ALIGN_START,
                                              "y-fill", FALSE,
                                              "y-align", MX_ALIGN_MIDDLE,
                                              NULL);

  priv->kill_toggle = mx_toggle_new ();
  priv->kill_handler = g_signal_connect (priv->kill_toggle, "notify::active",
                                         G_CALLBACK (_toggle_active_cb), shell);
  mx_box_layout_insert_actor (MX_BOX_LAYOUT (active_box),
                              priv->kill_toggle, -1);

  /* devices that are requesting something go here */
  priv->request_box = mx_box_layout_new ();
  mx_box_layout_set_orientation (MX_BOX_LAYOUT (priv->request_box),
                                 MX_ORIENTATION_VERTICAL);
  mx_box_layout_set_enable_animations (MX_BOX_LAYOUT (priv->request_box),
                                       TRUE);
  mx_box_layout_insert_actor (MX_BOX_LAYOUT (priv->content),
                              priv->request_box, -1);


  /* connected devices go here */
  priv->device_panelbox = g_object_ref (mx_box_layout_new ());
  mx_box_layout_set_orientation (MX_BOX_LAYOUT (priv->device_panelbox),
                                 MX_ORIENTATION_VERTICAL);
  mx_stylable_set_style_class (MX_STYLABLE (priv->device_panelbox),
                               "contentPanel");

  priv->info_label = mx_label_new_with_text (_("Nothing connected"));
  mx_stylable_set_style_class (MX_STYLABLE (priv->info_label), "BtTitle");
  clutter_actor_hide (priv->info_label);
  mx_box_layout_insert_actor (MX_BOX_LAYOUT (priv->device_panelbox),
                              priv->info_label, -1);

  priv->device_box = mx_box_layout_new ();
  mx_box_layout_set_orientation (MX_BOX_LAYOUT (priv->device_box),
                                 MX_ORIENTATION_VERTICAL);

  mx_box_layout_set_enable_animations (MX_BOX_LAYOUT (priv->device_box),
                                       TRUE);
  mx_box_layout_insert_actor (MX_BOX_LAYOUT (priv->device_panelbox),
                              priv->device_box, -1);

  /* button row */
  priv->button_box = mx_box_layout_new ();
  clutter_actor_set_name (priv->button_box, "bt-panel-button-box");
  mx_box_layout_set_enable_animations (MX_BOX_LAYOUT (priv->button_box), TRUE);
  mx_box_layout_insert_actor_with_properties (MX_BOX_LAYOUT (priv->content),
                                              priv->button_box, -1,
                                              "expand", TRUE,
                                              "x-fill", TRUE,
                                              NULL);

  mx_box_layout_insert_actor_with_properties (MX_BOX_LAYOUT (priv->button_box),
                                              mx_box_layout_new (), 0,
                                              "expand", TRUE,
                                              NULL);

  priv->send_button = mx_button_new_with_label (_("Send file"));
  g_signal_connect (priv->send_button, "clicked",
                    G_CALLBACK (_send_clicked_cb), shell);
  mx_box_layout_insert_actor (MX_BOX_LAYOUT (priv->button_box),
                              priv->send_button, 1);

  priv->add_button = mx_button_new_with_label (_("Add new"));
  g_signal_connect (priv->add_button, "clicked",
                    G_CALLBACK (_add_clicked_cb), shell);
  mx_box_layout_insert_actor (MX_BOX_LAYOUT (priv->button_box),
                              priv->add_button, 2);

  settings_button = mx_button_new_with_label (_("Settings"));
  g_signal_connect (settings_button, "clicked",
                    G_CALLBACK (_settings_clicked_cb), shell);
  mx_box_layout_insert_actor (MX_BOX_LAYOUT (priv->button_box), settings_button, 3);

  dawati_bt_shell_init_applet (shell);

  priv->cm = carrick_connman_manager_new ();
  g_signal_connect (priv->cm, "notify::available-technologies",
                    G_CALLBACK (_available_techs_changed), shell);
  g_signal_connect (priv->cm, "notify::enabled-technologies",
                    G_CALLBACK (_enabled_techs_changed), shell);

#ifdef TEST_WITH_BOGUS_DATA
  g_debug ("TEST_WITH_BOGUS_DATA: Adding false devices & requests, "
           "and setting Bluetooth available even if connman is not there");
  /* Dummies for quick testing without bluetooth devices or connman */
  dawati_bt_shell_add_device (shell, "TestDeviceA", "a");
  dawati_bt_shell_add_device (shell, "TestDeviceB", "b");
  dawati_bt_shell_add_request (shell, "TestDeviceC", "c", DAWATI_BT_REQUEST_TYPE_PIN, NULL);
  dawati_bt_shell_add_request (shell, "TestDeviceD", "d", DAWATI_BT_REQUEST_TYPE_CONFIRM, "001234");
  dawati_bt_shell_add_request (shell, "TestDeviceE", "e", DAWATI_BT_REQUEST_TYPE_AUTH, "0000111f-0000-1000-8000-00805f9b34fb");
  priv->enabled = priv->available = TRUE;
  dawati_bt_shell_update (shell);
#endif
}