Exemplo n.º 1
0
static VALUE
rg_insert_text(VALUE self, VALUE position, VALUE text)
{
    gtk_combo_box_insert_text(_SELF(self), NUM2INT(position), RVAL2CSTR(text));
    return self;
}
Exemplo n.º 2
0
void
gtk_combo_box_text_insert_text (GtkComboBoxText *combo_box, gint position, const gchar *text) {
    gtk_combo_box_insert_text (combo_box, position, text);
}
Exemplo n.º 3
0
void create_image_window( void )
{
  /* Image display main window */
  /* ------------------------- */
  int k;

  printf("Creating the Video window.\n");

  // Image main window
  ihm_ImageWin = gtk_window_new( GTK_WINDOW_TOPLEVEL);
  gtk_container_set_border_width(GTK_CONTAINER(ihm_ImageWin), 10);
  gtk_window_set_title(GTK_WINDOW(ihm_ImageWin), ihm_ImageTitle);
  gtk_signal_connect(GTK_OBJECT(ihm_ImageWin), "destroy", G_CALLBACK(ihm_ImageWinDestroy), NULL );

  // Boxes
  ihm_ImageVBox = gtk_vbox_new(FALSE, 0);
  ihm_VideoStream_VBox = gtk_vbox_new(FALSE, 0);
  ihm_ImageVBoxPT = gtk_vbox_new(FALSE, 0);

  //hBox_vision_state = gtk_hbox_new(FALSE, 0);
  for (k=0; k<NB_IMAGES_H_BOXES; k++)  ihm_ImageHBox[k] = gtk_hbox_new(FALSE, 0);
  // Frames
  for (k=0; k<NB_IMAGES_FRAMES; k++)  ihm_ImageFrames[k] = gtk_frame_new( ihm_ImageFrameCaption[k] );
  // Entries
  for (k=0; k<NB_IMAGES_ENTRIES; k++) {
    ihm_ImageEntry[k] = gtk_entry_new();
    gtk_widget_set_size_request(ihm_ImageEntry[k], 80, 20);
  }
  // Video Stream

  for (k=0; k<NB_VIDEO_STREAM_WIDGET; k++)  ihm_VideoStreamLabel[k] = gtk_label_new( ihm_ImageVideoStreamCaption[k] );

  video_bitrateEntry =   gtk_entry_new();
  gtk_widget_set_size_request(video_bitrateEntry, 150, 20);

  video_codecList = gtk_combo_box_new_text();
  gtk_combo_box_insert_text( (GtkComboBox*)video_codecList, 0, (const gchar*)"UVLC");
  gtk_combo_box_insert_text( (GtkComboBox*)video_codecList, 1, (const gchar*)"P264");
  gtk_widget_set_size_request(video_codecList, 150, 20);

  video_bitrateModeList = gtk_combo_box_new_text();
  gtk_combo_box_insert_text( (GtkComboBox*)video_bitrateModeList, 0, (const gchar*)"None");
  gtk_combo_box_insert_text( (GtkComboBox*)video_bitrateModeList, 1, (const gchar*)"Adaptative");
  gtk_combo_box_insert_text( (GtkComboBox*)video_bitrateModeList, 2, (const gchar*)"Manual");
  gtk_widget_set_size_request(video_codecList, 150, 20);

  for (k=0; k<NB_IMAGES_ENTRIES; k++)  ihm_ImageLabel[k] = gtk_label_new( ihm_ImageEntryCaption[k] );

  /* Creates buttons and links them to callbacks */
  for (k=0; k<NB_IMAGES_BUTTONS; k++)
  {
    ihm_ImageButton[k] = gtk_button_new();// ihm_ImageButtonCaption[k] );
    gtk_button_set_label((GtkButton*)ihm_ImageButton[k] ,ihm_ImageButtonCaption[k]);

    switch (k)
    {
      case UPDATE_VISION_PARAMS_BUTTON:
        g_signal_connect( G_OBJECT(ihm_ImageButton[k]), "clicked", G_CALLBACK(ihm_sendVisionConfigParams), (gpointer)k );
        break;
      case RAW_CAPTURE_BUTTON:
        g_signal_connect( G_OBJECT(ihm_ImageButton[k]), "clicked", G_CALLBACK(ihm_RAWCapture), (gpointer)k );
        break;
      case ZAPPER_BUTTON:
        g_signal_connect( G_OBJECT(ihm_ImageButton[k]), "clicked", G_CALLBACK(ihm_Zapper), (gpointer)k );
        break;
      case FULLSCREEN_BUTTON:
        g_signal_connect( G_OBJECT(ihm_ImageButton[k]), "clicked", G_CALLBACK(ihm_VideoFullScreen), (gpointer)k );
        break;
      default:
        g_signal_connect( G_OBJECT(ihm_ImageButton[k]), "clicked", G_CALLBACK(ihm_ImageButtonCB), (gpointer)k );
      }
  }

  GdkColor color;
  gdk_color_parse ("red", &color);
  gtk_widget_modify_text (ihm_ImageLabel[RAW_CAPTURE_BUTTON], GTK_STATE_NORMAL, &color);

  video_bitrateButton = gtk_button_new_with_label( "Send" );
  g_signal_connect(G_OBJECT(video_bitrateButton), "clicked", G_CALLBACK(ihm_send_VideoBitrate), 0 );
  g_signal_connect(G_OBJECT(video_codecList), "changed", G_CALLBACK(ihm_send_VideoCodec), 0 );
  g_signal_connect(G_OBJECT(video_bitrateModeList), "changed", G_CALLBACK(ihm_send_VideoBitrateMode), 0 );

  /* Creates input boxes (aka. entries) */
  char label_vision_default_val[NB_IMAGES_ENTRIES] ;
  tab_vision_config_params[0] = DEFAULT_CS;
  tab_vision_config_params[1] = DEFAULT_NB_PAIRS;
  tab_vision_config_params[2] = DEFAULT_LOSS_PER;
  tab_vision_config_params[3] = DEFAULT_NB_TRACKERS_WIDTH;
  tab_vision_config_params[4] = DEFAULT_NB_TRACKERS_HEIGHT;
  tab_vision_config_params[5] = DEFAULT_SCALE;
  tab_vision_config_params[6] = DEFAULT_TRANSLATION_MAX;
  tab_vision_config_params[7] = DEFAULT_MAX_PAIR_DIST;
  tab_vision_config_params[8] = DEFAULT_NOISE;

  for (k=0; k<NB_IMAGES_ENTRIES; k++)  {
    if (k==FAKE_ENTRY) continue;
    sprintf(label_vision_default_val, "%d", tab_vision_config_params[k]);
    gtk_entry_set_text( GTK_ENTRY(ihm_ImageEntry[k]), label_vision_default_val);
  }
  gtk_entry_set_text( GTK_ENTRY(video_bitrateEntry), "frame size (bytes)");

  /* Builds the vision state frame */
  vp_os_memset(label_vision_state_value, 0, sizeof(label_vision_state_value));
  strcat(label_vision_state_value, "Not Connected");
  label_vision_values = (GtkLabel*) gtk_label_new(label_vision_state_value);

  gtk_container_add( GTK_CONTAINER(ihm_ImageFrames[STATE_FRAME]), (GtkWidget*) label_vision_values );

  /* Builds the vision parameters frame */

  /* First line of parameters */
  for (k=CS_ENTRY; k<NB_TH_ENTRY; k++)  {
    gtk_box_pack_start(GTK_BOX(ihm_ImageHBox[TRACKING_PARAM_HBOX1]), ihm_ImageLabel[k], FALSE , FALSE, 0);
    gtk_box_pack_start(GTK_BOX(ihm_ImageHBox[TRACKING_PARAM_HBOX1]), ihm_ImageEntry[k], FALSE , FALSE, 0);
  }
  /* Second line of parameters */
  for (k=NB_TH_ENTRY; k<NB_IMAGES_ENTRIES; k++)  {
    if (k==FAKE_ENTRY) continue;
    gtk_box_pack_start(GTK_BOX(ihm_ImageHBox[TRACKING_PARAM_HBOX2]), ihm_ImageLabel[k], FALSE , FALSE, 0);
    gtk_box_pack_start(GTK_BOX(ihm_ImageHBox[TRACKING_PARAM_HBOX2]), ihm_ImageEntry[k], FALSE , FALSE, 0);
  }

  gtk_box_pack_start(GTK_BOX(ihm_ImageHBox[TRACKING_PARAM_HBOX2]), ihm_ImageLabel[FAKE_ENTRY], FALSE , FALSE, 0); // To fill space
  /* Fuses the two line in a single VBox */
  gtk_box_pack_start(GTK_BOX(ihm_ImageVBoxPT), ihm_ImageHBox[TRACKING_PARAM_HBOX1], FALSE , FALSE, 0);
  gtk_box_pack_start(GTK_BOX(ihm_ImageVBoxPT), ihm_ImageHBox[TRACKING_PARAM_HBOX2], FALSE , FALSE, 0);

  /* Builds the whole parameter block */
  gtk_container_add(GTK_CONTAINER(ihm_ImageFrames[TRACKING_PARAMETERS_FRAME]), ihm_ImageVBoxPT );
  gtk_box_pack_start(GTK_BOX(ihm_ImageHBox[TRACKING_PARAMS_HBOX]), ihm_ImageFrames[TRACKING_PARAMETERS_FRAME], FALSE , FALSE, 0);
  gtk_box_pack_start(GTK_BOX(ihm_ImageHBox[TRACKING_PARAMS_HBOX]), ihm_ImageButton[UPDATE_VISION_PARAMS_BUTTON], TRUE  , FALSE, 5);

  for (k=TZ_KNOWN_BUTTON; k<=SE3_BUTTON; k++)
    gtk_box_pack_start(GTK_BOX( ihm_ImageHBox[TRACKING_OPTION_HBOX]), ihm_ImageButton[k], TRUE , FALSE, 0);
  for (k=PROJ_OVERSCENE_BUTTON; k<=FLAT_GROUND_BUTTON; k++)
    gtk_box_pack_start(GTK_BOX( ihm_ImageHBox[COMPUTING_OPTION_HBOX]), ihm_ImageButton[k], TRUE , FALSE, 0);


  gtk_box_pack_start(GTK_BOX( ihm_ImageHBox[VIDEO_STREAM_HBOX]), ihm_VideoStreamLabel[CODEC_TYPE_LIST], FALSE , FALSE, 0);
  gtk_box_pack_start(GTK_BOX( ihm_ImageHBox[VIDEO_STREAM_HBOX]), video_codecList, TRUE , FALSE, 0);
  gtk_box_pack_start(GTK_BOX( ihm_ImageHBox[VIDEO_STREAM_HBOX]), ihm_VideoStreamLabel[BITRATE_MODE_LIST], FALSE , FALSE, 0);
  gtk_box_pack_start(GTK_BOX( ihm_ImageHBox[VIDEO_STREAM_HBOX]), video_bitrateModeList, TRUE , FALSE, 0);
  gtk_box_pack_start(GTK_BOX( ihm_ImageHBox[VIDEO_STREAM_HBOX]), ihm_VideoStreamLabel[MANUAL_BITRATE_ENTRY], FALSE , FALSE, 0);
  gtk_box_pack_start(GTK_BOX( ihm_ImageHBox[VIDEO_STREAM_HBOX]), video_bitrateEntry, TRUE , FALSE, 0);
  gtk_box_pack_start(GTK_BOX( ihm_ImageHBox[VIDEO_STREAM_HBOX]), video_bitrateButton, TRUE , FALSE, 0);

  /* */
  gtk_container_add(GTK_CONTAINER( ihm_ImageFrames[TRACKING_OPTION_FRAME]) , ihm_ImageHBox[TRACKING_OPTION_HBOX] );
  gtk_container_add(GTK_CONTAINER( ihm_ImageFrames[COMPUTING_OPTION_FRAME]), ihm_ImageHBox[COMPUTING_OPTION_HBOX] );
  gtk_container_add(GTK_CONTAINER( ihm_ImageFrames[VIDEO_STREAM_FRAME])    , ihm_ImageHBox[VIDEO_STREAM_HBOX] );

  /* Frame where to show buttons controlling how the drone video is displayed */
  displayvbox = gtk_vbox_new(FALSE,0);

  gtk_box_pack_start(GTK_BOX(displayvbox), ihm_ImageButton[RAW_CAPTURE_BUTTON], FALSE  , FALSE, 5);
  gtk_box_pack_start(GTK_BOX(displayvbox), ihm_ImageButton[ZAPPER_BUTTON], FALSE  , FALSE, 5);
  gtk_box_pack_start(GTK_BOX(displayvbox), ihm_ImageButton[FULLSCREEN_BUTTON], FALSE  , FALSE, 5);

  gtk_box_pack_start(GTK_BOX(ihm_ImageHBox[VIDEO_DISPLAY_HBOX]),ihm_VideoStream_VBox,FALSE,FALSE,5);
  gtk_box_pack_start(GTK_BOX(ihm_ImageHBox[VIDEO_DISPLAY_HBOX]),displayvbox,FALSE,FALSE,5);

  gtk_container_add(GTK_CONTAINER( ihm_ImageFrames[VIDEO_DISPLAY_FRAME])    , ihm_ImageHBox[VIDEO_DISPLAY_HBOX] );

  /* Builds the final window */
  gtk_box_pack_start(GTK_BOX(ihm_ImageVBox), ihm_ImageFrames[VIDEO_DISPLAY_FRAME], FALSE, FALSE, 5);
  gtk_box_pack_start(GTK_BOX(ihm_ImageVBox), ihm_ImageFrames[STATE_FRAME], FALSE, FALSE, 5);
  gtk_box_pack_start(GTK_BOX(ihm_ImageVBox), ihm_ImageHBox[TRACKING_PARAMS_HBOX], FALSE, FALSE, 5);
  gtk_box_pack_start(GTK_BOX(ihm_ImageVBox), ihm_ImageFrames[TRACKING_OPTION_FRAME], FALSE, FALSE, 5);
  gtk_box_pack_start(GTK_BOX(ihm_ImageVBox), ihm_ImageFrames[COMPUTING_OPTION_FRAME], FALSE, FALSE, 5);
  gtk_box_pack_start(GTK_BOX(ihm_ImageVBox), ihm_ImageFrames[VIDEO_STREAM_FRAME], FALSE, FALSE, 5);

  gtk_container_add(GTK_CONTAINER(ihm_ImageWin), ihm_ImageVBox);
  image_vision_window_view = WINDOW_HIDE;
  image_vision_window_status = WINDOW_OPENED;

  /* Set the callback for the checkbox inside the main application window */
  g_signal_connect(G_OBJECT(button_show_image), "clicked", G_CALLBACK(ihm_showImage), (gpointer) ihm_ImageWin);
  g_signal_connect(G_OBJECT(button_show_image2), "clicked", G_CALLBACK(ihm_showImage), (gpointer) ihm_ImageWin);
}