Esempio n. 1
0
static void
mpd_computer_tile_init (MpdComputerTile *self)
{
  MpdComputerTilePrivate *priv;
  ClutterActor      *tile, *label;
  MpdDisplayDevice  *display;
  bool               show_brightness_tile;
  int                row;

  self->priv = priv = COMPUTER_TILE_PRIVATE (self);

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

  /* Let's reserve some room (rows) for the different "radios", we need:
   * WiFi (0)
   * Wimax (1)
   * Bluetooth (2)
   * 3G (3)
   * Air plane mode (4) */

  create_network_row (self, _("Wifi"), RADIO_WIFI);
  create_network_row (self, _("Wimax"), RADIO_WIMAX);
  create_network_row (self, _("Bluetooth"), RADIO_BLUETOOTH);
  create_network_row (self, _("3G"), RADIO_3G);
  create_network_row (self, _("Offline mode"), OFFLINE_MODE);

  show_tech (self, RADIO_WIFI, FALSE);
  show_tech (self, RADIO_WIMAX, FALSE);
  show_tech (self, RADIO_BLUETOOTH, FALSE);
  show_tech (self, RADIO_3G, FALSE);
  show_airplane_mode (self, FALSE);

  row = 5;

  /* Volume */
  /* Note to translators, volume here is sound volume */
  label = mx_label_new_with_text (_("Volume"));
  mx_table_add_actor_with_properties (MX_TABLE (self), label,
                                      row, 0,
                                      "y-align", MX_ALIGN_MIDDLE,
                                      "y-fill", FALSE,
                                      NULL);

  tile = mpd_volume_tile_new ();
  mx_table_add_actor_with_properties (MX_TABLE (self), tile,
                                      row, 1,
                                      "y-expand", FALSE,
                                      "y-align", MX_ALIGN_MIDDLE,
                                      "y-fill", FALSE,
                                      "x-expand", TRUE,
                                      NULL);
  row++;

  /* Brightness */
  display = mpd_display_device_new ();
  show_brightness_tile = mpd_display_device_is_enabled (display);
  if (show_brightness_tile)
    {
      label = mx_label_new_with_text (_("Brightness"));
      mx_table_add_actor_with_properties (MX_TABLE (self), label,
                                          row, 0,
                                          "y-align", MX_ALIGN_MIDDLE,
                                          "y-fill", FALSE,
                                          NULL);

      tile = mpd_brightness_tile_new ();
      mx_table_add_actor_with_properties (MX_TABLE (self), tile,
                                          row, 1,
                                          "x-expand", TRUE,
                                          NULL);
      row++;
    }

  /* Battery */
  label = mx_label_new_with_text (_("Battery"));
  mx_table_add_actor_with_properties (MX_TABLE (self), label,
                                      row, 0,
                                      "y-align", MX_ALIGN_MIDDLE,
                                      "y-fill", FALSE,
                                      NULL);
  tile = mpd_battery_tile_new ();
  g_signal_connect (tile, "show-me", G_CALLBACK (_show_me), self);
  mx_table_add_actor_with_properties (MX_TABLE (self), tile,
                                      row, 1,
                                      "x-expand", TRUE,
                                      NULL);
  priv->battery_label = label;
  priv->battery_tile = tile;
  row++;

  /* FIXME: Makes crash when unref'd.
   * GpmBrightnessXRandR doesn't remove filter from root window in ::finalize()
   * but doesn't seem to be it.
   * g_object_unref (display); */
}
Esempio n. 2
0
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
}