Ejemplo n.º 1
0
static void
mex_telepathy_channel_on_contact_fetched (TpConnection     *connection,
                                          guint             n_contacts,
                                          TpContact *const *contacts,
                                          guint             n_failed,
                                          const TpHandle   *failed,
                                          const GError     *fetched_error,
                                          gpointer          user_data,
                                          GObject          *weak_object)
{
  MexTelepathyChannel *self = MEX_TELEPATHY_CHANNEL (user_data);

  int i = 0;

  if (self->priv->channel)
    {
      for (i = 0; i < n_contacts; ++i)
        {
          gchar *text;
          const gchar *alias;
          TpContact *current;
          GFile *file;

          // Get the contacts.
          current = contacts[i];

          // Connect to alias change signal.
          // Add the alias to the label.
          alias = tp_contact_get_alias (current);
          mx_label_set_text (MX_LABEL (self->priv->title_label),
                             alias);

          if (tp_channel_get_requested(self->priv->channel))
            text = g_strdup_printf ("Calling %s", alias);
          else
            text = g_strdup_printf ("Setting up call with %s", alias);
          mx_label_set_text (MX_LABEL (self->priv->busy_label), text);
          g_free (text);

          file = tp_contact_get_avatar_file (current);
          if (file)
            {
              gchar *filename = g_file_get_path (file);
              GError *error = NULL;
              MEX_DEBUG ("setting new avatar filename to %s", filename);
              mx_image_set_from_file (MX_IMAGE(self->priv->avatar_image),
                                      filename,
                                      &error);
              if (error)
                {
                  MEX_ERROR ("ERROR %s loading avatar from file %s\n",
                             error->message, filename);
                  g_clear_error (&error);
                }
              if (filename)
                g_free (filename);
            }
        }
    }
}
Ejemplo n.º 2
0
static void
mex_media_controls_update_header (MexMediaControls *self)
{
    MexMediaControlsPrivate *priv = self->priv;
    ClutterActor *label, *image;
    const gchar *logo_url;
    GError *err = NULL;

    label = (ClutterActor*) clutter_script_get_object (priv->script,
            "title-label");
    image = (ClutterActor*) clutter_script_get_object (priv->script, "logo");

    mx_label_set_text (MX_LABEL (label),
                       mex_content_get_metadata (priv->content,
                               MEX_CONTENT_METADATA_TITLE));

    logo_url = mex_content_get_metadata (priv->content,
                                         MEX_CONTENT_METADATA_STATION_LOGO);
    if (!logo_url)
    {
        clutter_actor_hide (image);
    }
    else
    {
        clutter_actor_show (image);

        if (g_str_has_prefix (logo_url, "file://"))
            logo_url = logo_url + 7;

        mx_image_set_from_file (MX_IMAGE (image), logo_url, &err);
        if (err)
        {
            g_warning ("Could not load logo: %s", err->message);
            g_clear_error (&err);
        }
    }
}
Ejemplo n.º 3
0
static void
mex_telepathy_channel_create_toolbar (MexTelepathyChannel *self)
{
  MexTelepathyChannelPrivate *priv = MEX_TELEPATHY_CHANNEL (self)->priv;

  gchar *static_image_path;
  ClutterActor *toolbar;

  MxAction *end_action;
  MxAction *camera_action;
  MxAction *mute_action;
  GError *error = NULL;

  // Create the user label
  priv->avatar_image = mx_image_new ();
  static_image_path = g_build_filename (mex_get_data_dir (),
                                        "style",
                                        "thumb-call-avatar-small.png",
                                        NULL);
  mx_image_set_from_file (MX_IMAGE (priv->avatar_image),
                          static_image_path,
                          &error);

  if (error)
  {
    g_warning ("Error loading texture %s", error->message);
    g_clear_error (&error);
  }

  if (static_image_path)
    g_free (static_image_path);

  priv->title_label = mx_label_new ();
  mx_label_set_y_align (MX_LABEL (priv->title_label), MX_ALIGN_MIDDLE);
  mx_label_set_x_align (MX_LABEL (priv->title_label), MX_ALIGN_MIDDLE);

  end_action =
    mx_action_new_full ("End",
                        "Hang Up",
                        G_CALLBACK (mex_telepathy_channel_on_hangup),
                        self);

  priv->end_button = mex_action_button_new (end_action);
  mx_stylable_set_style_class (MX_STYLABLE (priv->end_button), "EndCall");

  camera_action =
    mx_action_new_full("Camera",
                       "Camera Off",
                       G_CALLBACK (mex_telepathy_channel_toggle_camera),
                       self);

  priv->camera_button = mex_action_button_new (camera_action);
  /* off by default */
  mex_telepathy_channel_set_camera_state (self, FALSE);

  mute_action =
    mx_action_new_full("Mute",
                       "Mic Off",
                       G_CALLBACK (mex_telepathy_channel_toggle_mute),
                       self);

  priv->mute_button = mex_action_button_new (mute_action);
  mx_stylable_set_style_class (MX_STYLABLE (priv->mute_button), "MediaMute");

  toolbar = mx_box_layout_new ();
  clutter_actor_set_width (toolbar, 980);
  clutter_actor_set_height (toolbar, 48);
  mx_stylable_set_style_class (MX_STYLABLE (toolbar),
                               "MexCallControlsTitle");
  // Put the buttons in the toolbar
  mx_box_layout_add_actor_with_properties (MX_BOX_LAYOUT (toolbar),
                                           priv->avatar_image,
                                           0,
                                           "expand",
                                           FALSE,
                                           "x-align",
                                           MX_ALIGN_END,
                                           "x-fill",
                                           FALSE,
                                           NULL);

  mx_box_layout_add_actor_with_properties (MX_BOX_LAYOUT (toolbar),
                                           priv->title_label,
                                           1,
                                           "expand",
                                           TRUE,
                                           NULL);

  mx_box_layout_add_actor_with_properties (MX_BOX_LAYOUT (toolbar),
                                           priv->camera_button,
                                           2,
                                           "expand",
                                           TRUE,
                                           NULL);

  mx_box_layout_add_actor_with_properties (MX_BOX_LAYOUT (toolbar),
                                           priv->mute_button,
                                           3,
                                           "expand",
                                           TRUE,
                                           NULL);

  mx_box_layout_add_actor_with_properties (MX_BOX_LAYOUT (toolbar),
                                           priv->end_button,
                                           4,
                                           "expand",
                                           TRUE,
                                           NULL);

  priv->toolbar_area = mx_frame_new ();
  mx_bin_set_child (MX_BIN (priv->toolbar_area), toolbar);
  mx_stylable_set_style_class (MX_STYLABLE (priv->toolbar_area),
                               "ToolbarArea");
}
Ejemplo n.º 4
0
static gboolean
_create_settings_dialog (MexInfoBar *self)
{
  MexInfoBarPrivate *priv = self->priv;

  ClutterActor *dialog, *network_graphic;
  ClutterActor *network_tile, *dialog_layout, *dialog_label;
  ClutterActor *network_button;

  MxAction *close_dialog, *network_settings;

  dialog = mx_dialog_new ();
  mx_stylable_set_style_class (MX_STYLABLE (dialog), "MexInfoBarDialog");

  dialog_label = mx_label_new_with_text (_("Settings"));
  mx_stylable_set_style_class (MX_STYLABLE (dialog_label), "DialogHeader");

  /* Create actions for settings dialog */
  network_settings =
    _action_new_from_desktop_file ("mex-networks.desktop");

  close_dialog = mx_action_new_full ("close", _("Close"),
                                     G_CALLBACK (_close_dialog_cb), self);

  dialog_layout = mx_table_new ();
  mx_table_set_column_spacing (MX_TABLE (dialog_layout), 10);
  mx_table_set_row_spacing (MX_TABLE (dialog_layout), 30);

  mx_table_insert_actor (MX_TABLE (dialog_layout),
                         CLUTTER_ACTOR (dialog_label), 0, 0);

  if (network_settings)
    {
      gchar *tmp;
      network_graphic = mx_image_new ();
      mx_stylable_set_style_class (MX_STYLABLE (network_graphic),
                                   "NetworkGraphic");

      tmp = g_build_filename (mex_get_data_dir (), "style",
                              "graphic-network.png", NULL);
      mx_image_set_from_file (MX_IMAGE (network_graphic), tmp, NULL);
      g_free (tmp);

      network_tile = mex_tile_new ();
      mex_tile_set_label (MEX_TILE (network_tile), _("Network"));
      mex_tile_set_important (MEX_TILE (network_tile), TRUE);

      network_button = mx_button_new ();

      mx_button_set_action (MX_BUTTON (network_button), network_settings);

      mx_bin_set_child (MX_BIN (network_tile), network_button);
      mx_bin_set_child (MX_BIN (network_button), network_graphic);

      mx_table_insert_actor (MX_TABLE (dialog_layout),
                             CLUTTER_ACTOR (network_tile), 1, 1);
    }

  if (!network_settings)
    {
      ClutterActor *no_settings;
      no_settings = mx_label_new_with_text (_("No settings helpers installed"));

      clutter_actor_destroy (priv->settings_button);

      mx_table_insert_actor (MX_TABLE (dialog_layout),
                             CLUTTER_ACTOR (no_settings), 1, 0);
    }


  mx_bin_set_child (MX_BIN (dialog), dialog_layout);
  mx_dialog_add_action (MX_DIALOG (dialog), close_dialog);

  priv->settings_dialog = g_object_ref (dialog);

  return TRUE;
}
Ejemplo n.º 5
0
int
main (int argc, char **argv)
{
  const ClutterColor grey = { 0x40, 0x40, 0x40, 0xff };

  ClutterActor *stage, *tile, *tile2, *image, *image2, *dialog, *tiles;
  MxApplication *app;
  ClutterConstraint *constraint;

  mex_init (&argc, &argv);

  app = mx_application_new (&argc, &argv, "mex-tile-controls-test", 0);
  mex_style_load_default ();

  stage = clutter_stage_get_default ();
  clutter_stage_set_color (CLUTTER_STAGE (stage), &grey);
  clutter_stage_set_user_resizable (CLUTTER_STAGE (stage), TRUE);

  image = mx_image_new ();
  mx_image_set_from_file (MX_IMAGE (image), "/home/michael/dev/mex-info-bar/graphic-mapButtons.png", NULL);

  image2 = mx_image_new ();
  mx_image_set_from_file (MX_IMAGE (image2), "/home/michael/dev/mex-info-bar/graphic-network.png", NULL);

  tile = mex_tile_new ();
  mex_tile_set_label (tile, "Remote mapping");
  mex_tile_set_important (tile, TRUE);

  ClutterActor *button;
  button = mx_button_new ();

  mx_bin_set_child (MX_BIN (tile), button);
  mx_bin_set_child (MX_BIN (button), image);

  tile2 = mex_tile_new ();
  mex_tile_set_label (tile2, "Network");
  mex_tile_set_important (tile2, TRUE);

  ClutterActor *button2;
  button2 = mx_button_new ();

  mx_bin_set_child (MX_BIN (tile2), button2);
  mx_bin_set_child (MX_BIN (button2), image2);

  tiles = mx_box_layout_new ();
  mx_box_layout_set_spacing (tiles, 10);
  mx_box_layout_set_orientation (tiles, MX_ORIENTATION_HORIZONTAL);
  mx_box_layout_add_actor (tiles, tile, 0);
  mx_box_layout_add_actor (tiles, tile2, 1);


  g_print (clutter_actor_get_reactive (tile) ? "reactive" : "notreactive");
  dialog = mx_dialog_new ();
  mx_dialog_set_transient_parent (dialog, stage);

  g_signal_connect (button2, "clicked", G_CALLBACK (focus_in_cb), NULL);
  g_signal_connect (button, "clicked", G_CALLBACK (focus_in_cb), NULL);

  clutter_container_add_actor (CLUTTER_CONTAINER (dialog), tiles);

  clutter_actor_show (dialog);

  clutter_actor_set_size (stage, 1024, 768);
  clutter_actor_show (stage);

  clutter_main ();

  return 0;
}