Exemple #1
0
int
main (int   argc,
      char *argv[])
{
    GdkGLConfig *glconfig;
    gint major, minor;

    GtkWidget *window;
    GtkWidget *vbox;
    GtkWidget *drawing_area;
    GtkWidget *button;

    /*
     * Init GTK.
     */

    gtk_init (&argc, &argv);

    /*
     * Init GtkGLExt.
     */

    gtk_gl_init (&argc, &argv);

    /*
     * Query OpenGL extension version.
     */

    gdk_gl_query_version (&major, &minor);
    g_print ("\nOpenGL extension version - %d.%d\n",
             major, minor);

    /*
     * Configure OpenGL-capable visual.
     */

    /* Try single-buffered visual */
    glconfig = gdk_gl_config_new_by_mode (GDK_GL_MODE_RGB    |
                                          GDK_GL_MODE_DEPTH  |
                                          GDK_GL_MODE_SINGLE);
    if (glconfig == NULL)
    {
        g_print ("*** No appropriate OpenGL-capable visual found.\n");
        exit (1);
    }

    examine_gl_config_attrib (glconfig);

    /*
     * Top-level window.
     */

    window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
    gtk_window_set_title (GTK_WINDOW (window), "simple");

    /* Get automatically redrawn if any of their children changed allocation. */
    gtk_container_set_reallocate_redraws (GTK_CONTAINER (window), TRUE);

    g_signal_connect (G_OBJECT (window), "delete_event",
                      G_CALLBACK (gtk_main_quit), NULL);

    /*
     * VBox.
     */

    vbox = gtk_vbox_new (FALSE, 0);
    gtk_container_add (GTK_CONTAINER (window), vbox);
    gtk_widget_show (vbox);

    /*
     * Drawing area for drawing OpenGL scene.
     */

    drawing_area = gtk_drawing_area_new ();
    gtk_widget_set_size_request (drawing_area, 200, 200);

    /* Set OpenGL-capability to the widget. */
    gtk_widget_set_gl_capability (drawing_area,
                                  glconfig,
                                  NULL,
                                  TRUE,
                                  GDK_GL_RGBA_TYPE);

    g_signal_connect_after (G_OBJECT (drawing_area), "realize",
                            G_CALLBACK (realize), NULL);
    g_signal_connect (G_OBJECT (drawing_area), "configure_event",
                      G_CALLBACK (configure_event), NULL);
    g_signal_connect (G_OBJECT (drawing_area), "expose_event",
                      G_CALLBACK (expose_event), NULL);

    gtk_box_pack_start (GTK_BOX (vbox), drawing_area, TRUE, TRUE, 0);

    gtk_widget_show (drawing_area);

    /*
     * Simple quit button.
     */

    button = gtk_button_new_with_label ("Quit");

    g_signal_connect (G_OBJECT (button), "clicked",
                      G_CALLBACK (gtk_main_quit), NULL);

    gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0);

    gtk_widget_show (button);

    /*
     * Show window.
     */

    gtk_widget_show (window);

    /*
     * Main loop.
     */

    gtk_main ();

    return 0;
}
Exemple #2
0
int
main (int   argc,
      char *argv[])
{
  GdkGLConfig *glconfig;
  GtkWidget *window;
  GtkWidget *vbox;
  GtkWidget *drawing_area;
  GtkWidget *button;
  int i;

  /*
   * Init GTK.
   */

  gtk_init (&argc, &argv);

  /*
   * Init GtkGLExt.
   */

  gtk_gl_init (&argc, &argv);

  /*
   * Command line options.
   */

  for (i = 0; i < argc; i++)
    {
      if (strcmp (argv[i], "--async") == 0)
        is_sync = FALSE;
    }

  /*
   * Configure OpenGL-capable visual.
   */

  /* Try double-buffered visual */
  glconfig = gdk_gl_config_new_by_mode (GDK_GL_MODE_RGB    |
					GDK_GL_MODE_DEPTH  |
					GDK_GL_MODE_DOUBLE);
  if (glconfig == NULL)
    {
      g_print ("*** Cannot find the double-buffered visual.\n");
      g_print ("*** Trying single-buffered visual.\n");

      /* Try single-buffered visual */
      glconfig = gdk_gl_config_new_by_mode (GDK_GL_MODE_RGB   |
					    GDK_GL_MODE_DEPTH);
      if (glconfig == NULL)
	{
	  g_print ("*** No appropriate OpenGL-capable visual found.\n");
	  exit (1);
	}
    }

  /*
   * Top-level window.
   */

  window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
  gtk_window_set_title (GTK_WINDOW (window), "gears");

  /* Get automatically redrawn if any of their children changed allocation. */
  gtk_container_set_reallocate_redraws (GTK_CONTAINER (window), TRUE);

  g_signal_connect (G_OBJECT (window), "delete_event",
		    G_CALLBACK (gtk_main_quit), NULL);

  /*
   * VBox.
   */

  vbox = gtk_vbox_new (FALSE, 0);
  gtk_container_add (GTK_CONTAINER (window), vbox);
  gtk_widget_show (vbox);

  /*
   * Drawing area for drawing OpenGL scene.
   */

  drawing_area = gtk_drawing_area_new ();
  gtk_widget_set_size_request (drawing_area, 300, 300);

  /* Set OpenGL-capability to the widget. */
  gtk_widget_set_gl_capability (drawing_area,
				glconfig,
				NULL,
				TRUE,
				GDK_GL_RGBA_TYPE);

  gtk_widget_add_events (drawing_area,
			 GDK_VISIBILITY_NOTIFY_MASK);

  g_signal_connect_after (G_OBJECT (drawing_area), "realize",
                          G_CALLBACK (init), NULL);
  g_signal_connect (G_OBJECT (drawing_area), "configure_event",
		    G_CALLBACK (reshape), NULL);
  g_signal_connect (G_OBJECT (drawing_area), "expose_event",
		    G_CALLBACK (draw), NULL);
  g_signal_connect (G_OBJECT (drawing_area), "map_event",
		    G_CALLBACK (map), NULL);
  g_signal_connect (G_OBJECT (drawing_area), "unmap_event",
		    G_CALLBACK (unmap), NULL);
  g_signal_connect (G_OBJECT (drawing_area), "visibility_notify_event",
		    G_CALLBACK (visible), NULL);

  g_signal_connect_swapped (G_OBJECT (window), "key_press_event",
			    G_CALLBACK (key), drawing_area);

  gtk_box_pack_start (GTK_BOX (vbox), drawing_area, TRUE, TRUE, 0);

  gtk_widget_show (drawing_area);

  /*
   * Simple quit button.
   */

  button = gtk_button_new_with_label ("Quit");

  g_signal_connect (G_OBJECT (button), "clicked",
		    G_CALLBACK (gtk_main_quit), NULL);

  gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0);

  gtk_widget_show (button);

  /*
   * Show window.
   */

  gtk_widget_show (window);

  /*
   * Main loop.
   */
//idle_add (drawing_area);
  gtk_main ();

  return 0;
}
Exemple #3
0
MimeView *mimeview_create(void)
{
	MimeView *mimeview;

	GtkWidget *paned;
	GtkWidget *scrolledwin;
	GtkWidget *treeview;
	GtkTreeStore *store;
	GtkTreeSelection *selection;
	GtkTreeViewColumn *column;
	GtkCellRenderer *renderer;
	GtkWidget *mime_vbox;
	GtkWidget *popupmenu;
	GtkItemFactory *popupfactory;
	gint n_entries;
	GtkWidget *reply_separator;
	GtkWidget *reply_menuitem;
	GList *child;

	debug_print(_("Creating MIME view...\n"));
	mimeview = g_new0(MimeView, 1);

	scrolledwin = gtk_scrolled_window_new(NULL, NULL);
	gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolledwin),
				       GTK_POLICY_AUTOMATIC,
				       GTK_POLICY_ALWAYS);
	gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(scrolledwin),
					    GTK_SHADOW_IN);
	gtk_widget_set_size_request(scrolledwin, -1, 80);

	store = gtk_tree_store_new(N_COLS, G_TYPE_STRING, G_TYPE_STRING,
				   G_TYPE_STRING, G_TYPE_POINTER);

	treeview = gtk_tree_view_new_with_model(GTK_TREE_MODEL(store));
	g_object_unref(G_OBJECT(store));
	gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(treeview), TRUE);
	gtk_tree_view_set_rules_hint(GTK_TREE_VIEW(treeview), TRUE);
	gtk_tree_view_set_search_column(GTK_TREE_VIEW(treeview), COL_NAME);
	gtk_tree_view_set_reorderable(GTK_TREE_VIEW(treeview), FALSE);

	selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(treeview));
	gtk_tree_selection_set_mode(selection, GTK_SELECTION_BROWSE);

	gtk_container_add(GTK_CONTAINER(scrolledwin), treeview);

	renderer = gtk_cell_renderer_text_new();
	g_object_set(renderer, "ypad", 0, NULL);
	column = gtk_tree_view_column_new_with_attributes
		(_("Data type"), renderer, "text", COL_MIMETYPE, NULL);
	gtk_tree_view_column_set_sizing(column, GTK_TREE_VIEW_COLUMN_AUTOSIZE);
	gtk_tree_view_column_set_resizable(column, TRUE);
	gtk_tree_view_append_column(GTK_TREE_VIEW(treeview), column);

	renderer = gtk_cell_renderer_text_new();
	g_object_set(renderer, "xalign", 1.0, "ypad", 0, NULL);
	column = gtk_tree_view_column_new_with_attributes
		(_("Size"), renderer, "text", COL_SIZE, NULL);
	gtk_tree_view_column_set_alignment(column, 1.0);
	gtk_tree_view_column_set_sizing(column, GTK_TREE_VIEW_COLUMN_AUTOSIZE);
	gtk_tree_view_column_set_resizable(column, TRUE);
	gtk_tree_view_append_column(GTK_TREE_VIEW(treeview), column);

	renderer = gtk_cell_renderer_text_new();
	g_object_set(renderer, "ypad", 0, NULL);
	column = gtk_tree_view_column_new_with_attributes
		(_("Name"), renderer, "text", COL_NAME, NULL);
	gtk_tree_view_column_set_sizing(column, GTK_TREE_VIEW_COLUMN_AUTOSIZE);
	gtk_tree_view_column_set_resizable(column, TRUE);
	gtk_tree_view_append_column(GTK_TREE_VIEW(treeview), column);

	gtk_tree_view_enable_model_drag_source
		(GTK_TREE_VIEW(treeview), GDK_BUTTON1_MASK,
		 mimeview_mime_types, 1, GDK_ACTION_COPY);

	g_signal_connect(G_OBJECT(selection), "changed",
			 G_CALLBACK(mimeview_selection_changed), mimeview);
	g_signal_connect(G_OBJECT(treeview), "button_press_event",
			 G_CALLBACK(mimeview_button_pressed), mimeview);
	g_signal_connect(G_OBJECT(treeview), "key_press_event",
			 G_CALLBACK(mimeview_key_pressed), mimeview);

	g_signal_connect_after(G_OBJECT (treeview),"drag-begin",
			       G_CALLBACK (mimeview_drag_begin), mimeview);
	g_signal_connect(G_OBJECT (treeview),"drag-end",
			 G_CALLBACK (mimeview_drag_end), mimeview);
	g_signal_connect(G_OBJECT(treeview), "drag-data-get",
			 G_CALLBACK(mimeview_drag_data_get), mimeview);
    
	mime_vbox = gtk_vbox_new(FALSE, 0);
	gtk_container_set_reallocate_redraws(GTK_CONTAINER(mime_vbox), TRUE);

	paned = gtk_vpaned_new();
	gtk_paned_add1(GTK_PANED(paned), scrolledwin);
	gtk_paned_add2(GTK_PANED(paned), mime_vbox);

	n_entries = sizeof(mimeview_popup_entries) /
		sizeof(mimeview_popup_entries[0]);
	popupmenu = menu_create_items(mimeview_popup_entries, n_entries,
				      "<MimeView>", &popupfactory, mimeview);

	reply_menuitem = gtk_item_factory_get_item(popupfactory, "/Reply");
	child = g_list_find(GTK_MENU_SHELL(popupmenu)->children,
			    reply_menuitem);
	reply_separator = GTK_WIDGET(child->prev->data);

	mimeview->paned        = paned;
	mimeview->scrolledwin  = scrolledwin;
	mimeview->treeview     = treeview;
	mimeview->store        = store;
	mimeview->selection    = selection;
	mimeview->mime_vbox    = mime_vbox;
	mimeview->popupmenu    = popupmenu;
	mimeview->popupfactory = popupfactory;
	mimeview->reply_separator = reply_separator;
	mimeview->reply_menuitem  = reply_menuitem;
	mimeview->type         = -1;

	return mimeview;
}
Exemple #4
0
int
main (int   argc,
      char *argv[])
{
    GdkGLConfig *glconfig;
    GladeXML *xml;
    GtkWidget *window;
    GtkWidget *drawingarea;

    /*
     * Init GTK+ and GtkGLExt.
     */

    gtk_init (&argc, &argv);
    gtk_gl_init (&argc, &argv);

    /*
     * Configure OpenGL-capable visual.
     */

    /* Try double-buffered visual */
    glconfig = gdk_gl_config_new_by_mode (GDK_GL_MODE_RGB    |
                                          GDK_GL_MODE_DEPTH  |
                                          GDK_GL_MODE_DOUBLE);
    if (glconfig == NULL)
    {
        g_print ("*** Cannot find the double-buffered visual.\n");
        g_print ("*** Trying single-buffered visual.\n");

        /* Try single-buffered visual */
        glconfig = gdk_gl_config_new_by_mode (GDK_GL_MODE_RGB   |
                                              GDK_GL_MODE_DEPTH);
        if (glconfig == NULL)
        {
            g_print ("*** No appropriate OpenGL-capable visual found.\n");
            exit (1);
        }
    }

    /*
     * Load the interface.
     */

    xml = glade_xml_new ("simple.glade", NULL, NULL);

    /*
     * Connect the signals in the interface.
     */

    glade_xml_signal_autoconnect (xml);

    /*
     * Top-level window.
     */

    window = glade_xml_get_widget (xml, "window1");

    gtk_container_set_reallocate_redraws (GTK_CONTAINER (window), TRUE);

    /*
     * Drawing area.
     */

    drawingarea = glade_xml_get_widget (xml, "drawingarea1");

    /* Add OpenGL-capability to drawingarea1. */
    gtk_widget_set_gl_capability (drawingarea,
                                  glconfig,
                                  NULL,
                                  TRUE,
                                  GDK_GL_RGBA_TYPE);

    /*
     * Show top-level window, then run.
     */

    gtk_widget_show (window);

    gtk_main ();

    return 0;
}
Exemple #5
0
void GtkGui::setUpGTK()
{
	GdkGLConfig *glconfig;
	GtkBuilder  *builder;
	GError      *error = NULL;

	gtk_init(0, NULL);
	gtk_gl_init(0, NULL);

	//Try double-buffered visual
	glconfig = gdk_gl_config_new_by_mode (static_cast<GdkGLConfigMode> (GDK_GL_MODE_RGB | GDK_GL_MODE_DEPTH | GDK_GL_MODE_DOUBLE));

	if (glconfig == NULL)
	{
		g_print ("*** Cannot find the double-buffered visual.\n");
		g_print ("*** Trying single-buffered visual.\n");

		// Try single-buffered visual
		glconfig = gdk_gl_config_new_by_mode (static_cast<GdkGLConfigMode> (GDK_GL_MODE_RGB | GDK_GL_MODE_DEPTH));

		if (glconfig == NULL)
			g_print ("*** No appropriate OpenGL-capable visual found.\n");
	}

	// Create new GtkBuilder object
	builder = gtk_builder_new();
	if( ! gtk_builder_add_from_file(builder, "../../carmen/data/gui/laslam.glade", &error ) )
	{
		g_warning( "%s", error->message );
		g_free( error );
	}

	controls_.winMain  = GTK_WIDGET(gtk_builder_get_object(builder, "winMain" ));
	controls_.drawArea = GTK_WIDGET(gtk_builder_get_object(builder, "drawArea"));

	controls_.btnDrawRobot = GTK_TOGGLE_BUTTON(gtk_builder_get_object(builder, "btnDrawRobot"));
	controls_.btnDrawVisualOdometryPath = GTK_TOGGLE_BUTTON(gtk_builder_get_object(builder, "btnDrawVisualOdometry"));
	controls_.btnDrawCorrectedPath = GTK_TOGGLE_BUTTON(gtk_builder_get_object(builder, "btnDrawCorrectedPath"));
	controls_.btnDrawLandmarkPoints = GTK_TOGGLE_BUTTON(gtk_builder_get_object(builder, "btnDrawLandmarks"));
	controls_.btnDrawDistanceInformation = GTK_TOGGLE_BUTTON(gtk_builder_get_object(builder, "btnDrawDistanceInformation"));
	controls_.btnDrawParticles = GTK_TOGGLE_BUTTON(gtk_builder_get_object(builder, "btnDrawParticles"));

	controls_.rdbStaticCamera = GTK_TOGGLE_BUTTON(gtk_builder_get_object(builder, "rdbStaticCamera"));
	controls_.rdbFollowCamera = GTK_TOGGLE_BUTTON(gtk_builder_get_object(builder, "rdbFollowCamera"));
	controls_.rdbDriverCamera = GTK_TOGGLE_BUTTON(gtk_builder_get_object(builder, "rdbDriverCamera"));

	controls_.frameCamera         = GTK_WIDGET(gtk_builder_get_object(builder, "frameCamera"));
	controls_.frame3DMapOptions   = GTK_WIDGET(gtk_builder_get_object(builder, "frame3DMapOptions"));
	controls_.frame3DOtherOptions = GTK_WIDGET(gtk_builder_get_object(builder, "frame3DOtherOptions"));

	controls_.txtCamPosX = GTK_ENTRY(gtk_builder_get_object(builder, "txtCamPosX"));
	controls_.txtCamPosY = GTK_ENTRY(gtk_builder_get_object(builder, "txtCamPosY"));
	controls_.txtCamPosZ = GTK_ENTRY(gtk_builder_get_object(builder, "txtCamPosZ"));

	controls_.txtCamLookX = GTK_ENTRY(gtk_builder_get_object(builder, "txtCamLookX"));
	controls_.txtCamLookY = GTK_ENTRY(gtk_builder_get_object(builder, "txtCamLookY"));
	controls_.txtCamLookZ = GTK_ENTRY(gtk_builder_get_object(builder, "txtCamLookZ"));

	controls_.lblX = GTK_LABEL(gtk_builder_get_object(builder, "lblX"));
	controls_.lblY = GTK_LABEL(gtk_builder_get_object(builder, "lblY"));
	controls_.lblZ = GTK_LABEL(gtk_builder_get_object(builder, "lblZ"));
	controls_.lblYaw = GTK_LABEL(gtk_builder_get_object(builder, "lblYaw"));
	controls_.lblPitch = GTK_LABEL(gtk_builder_get_object(builder, "lblPitch"));
	controls_.lblRoll = GTK_LABEL(gtk_builder_get_object(builder, "lblRoll"));

	// Connect signals
	gtk_builder_connect_signals(builder, this);

	// Redraws
	gtk_container_set_reallocate_redraws (GTK_CONTAINER(controls_.winMain), TRUE);

	// Add OpenGL-capability to drawArea.
	if(!gtk_widget_set_gl_capability (controls_.drawArea, glconfig, NULL, TRUE, GDK_GL_RGBA_TYPE))
		return;

	// Register idle function
	g_idle_add (on_drawArea_idle, this);

	// Destroy builder, since we don't need it anymore
	g_object_unref( G_OBJECT( builder ) );

	// Show window. All other widgets are automatically shown by GtkBuilder
	gtk_widget_show(controls_.winMain);
}
Exemple #6
0
int
main(int   argc,
     char *argv[])
{
  GdkGLConfig *glconfig;
  gint major, minor;

  GtkWidget *window;
  GtkWidget *vbox;
  GtkWidget *drawing_area;
  GtkWidget *menu;
  GtkWidget *button;

  int i;
  gboolean arg_count = FALSE;

  /*
   * Init GTK.
   */

  gtk_init (&argc, &argv);

  /*
   * Init GtkGLExt.
   */

  gtk_gl_init (&argc, &argv);

  /*
   * Parse arguments.
   */

  for (i = 1; i < argc; i++)
    {
      if (arg_count)
	rot_count = atoi (argv[i]);

      if (strcmp (argv[i], "--help") == 0 ||
	  strcmp (argv[i], "-h") == 0)
	{
	  g_print ("Usage: %s [--count num] [--no-anim] [--help]\n", argv[0]);
	  exit (0);
	}

      if (strcmp (argv[i], "--count") == 0)
	arg_count = TRUE;

      if (strcmp (argv[i], "--no-anim") == 0)
	animate = FALSE;
    }

  /*
   * Query OpenGL extension version.
   */

  gdk_gl_query_version (&major, &minor);
  g_print ("\nOpenGL extension version - %d.%d\n",
           major, minor);

  /*
   * Configure OpenGL-capable visual.
   */

  /* Try double-buffered visual */
  glconfig = gdk_gl_config_new_by_mode (GDK_GL_MODE_RGB    |
					GDK_GL_MODE_DEPTH  |
					GDK_GL_MODE_DOUBLE);
  if (glconfig == NULL)
    {
      g_print ("*** Cannot find the double-buffered visual.\n");
      g_print ("*** Trying single-buffered visual.\n");

      /* Try single-buffered visual */
      glconfig = gdk_gl_config_new_by_mode (GDK_GL_MODE_RGB   |
					    GDK_GL_MODE_DEPTH);
      if (glconfig == NULL)
	{
	  g_print ("*** No appropriate OpenGL-capable visual found.\n");
	  exit (1);
	}
    }

  examine_gl_config_attrib (glconfig);

  /*
   * Top-level window.
   */

  window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
  gtk_window_set_title (GTK_WINDOW (window), "logo");

  /* Get automatically redrawn if any of their children changed allocation. */
  gtk_container_set_reallocate_redraws (GTK_CONTAINER (window), TRUE);

  g_signal_connect (G_OBJECT (window), "delete_event",
		    G_CALLBACK (gtk_main_quit), NULL);

  /*
   * VBox.
   */

  vbox = gtk_vbox_new (FALSE, 0);
  gtk_container_add (GTK_CONTAINER (window), vbox);
  gtk_widget_show (vbox);

  /*
   * Drawing area for drawing OpenGL scene.
   */

  drawing_area = gtk_drawing_area_new ();
  gtk_widget_set_size_request (drawing_area, 300, 300);

  /* Set OpenGL-capability to the widget. */
  gtk_widget_set_gl_capability (drawing_area,
				glconfig,
				NULL,
				TRUE,
				GDK_GL_RGBA_TYPE);

  gtk_widget_add_events (drawing_area,
			 GDK_BUTTON1_MOTION_MASK    |
			 GDK_BUTTON2_MOTION_MASK    |
			 GDK_BUTTON_PRESS_MASK      |
			 GDK_VISIBILITY_NOTIFY_MASK);

  g_signal_connect_after (G_OBJECT (drawing_area), "realize",
                          G_CALLBACK (realize), NULL);
  g_signal_connect (G_OBJECT (drawing_area), "configure_event",
		    G_CALLBACK (configure_event), NULL);
  g_signal_connect (G_OBJECT (drawing_area), "expose_event",
		    G_CALLBACK (expose_event), NULL);

  g_signal_connect (G_OBJECT (drawing_area), "button_press_event",
		    G_CALLBACK (button_press_event), NULL);
  g_signal_connect (G_OBJECT (drawing_area), "motion_notify_event",
		    G_CALLBACK (motion_notify_event), NULL);

  g_signal_connect (G_OBJECT (drawing_area), "map_event",
		    G_CALLBACK (map_event), NULL);
  g_signal_connect (G_OBJECT (drawing_area), "unmap_event",
		    G_CALLBACK (unmap_event), NULL);
  g_signal_connect (G_OBJECT (drawing_area), "visibility_notify_event",
		    G_CALLBACK (visibility_notify_event), NULL);

  g_signal_connect_swapped (G_OBJECT (window), "key_press_event",
			    G_CALLBACK (key_press_event), drawing_area);

  gtk_box_pack_start (GTK_BOX (vbox), drawing_area, TRUE, TRUE, 0);

  gtk_widget_show (drawing_area);

  /*
   * Popup menu.
   */

  menu = create_popup_menu (drawing_area);

  /* Signal handler */
  g_signal_connect_swapped (G_OBJECT (drawing_area), "button_press_event",
                            G_CALLBACK (button_press_event_popup_menu), menu);

  /*
   * Simple quit button.
   */

  button = gtk_button_new_with_label ("Quit");

  g_signal_connect (G_OBJECT (button), "clicked",
                    G_CALLBACK (gtk_main_quit), NULL);

  gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0);

  gtk_widget_show (button);

  /*
   * Show window.
   */

  gtk_widget_show (window);

  /*
   * Main loop.
   */

  gtk_main ();

  return 0;
}
SludgeApplication::SludgeApplication(const char * gladeFileName, const char * iconName, const char * configFile)
{
	configfile = configFile;
	GError *err = NULL;

	initSuccess = TRUE;

	char buf[1000];
	GdkPixbuf *pixbuf16, *pixbuf32, *pixbuf128, *pixbuf256;
	GList *list = NULL;

	sprintf(buf, "%s%s_16x16x32.png", DATADIR, iconName);
	pixbuf16 = gdk_pixbuf_new_from_file (buf, &err);

	if (err == NULL) {
		sprintf(buf, "%s%s_32x32x32.png", DATADIR, iconName);
		pixbuf32 = gdk_pixbuf_new_from_file (buf, &err);
	}
	if (err == NULL) {
		sprintf(buf, "%s%s_128x128x32.png", DATADIR, iconName);
		pixbuf128 = gdk_pixbuf_new_from_file (buf, &err);
	}
	if (err == NULL) {
		sprintf(buf, "%s%s_256x256x32.png", DATADIR, iconName);
		pixbuf256 = gdk_pixbuf_new_from_file (buf, &err);
	}

	if (err != NULL)
	{
		fprintf (stderr, "Unable to open icon file: %s\n", err->message);
		g_error_free (err);
	} else {
		list = g_list_append (list, pixbuf16);
		list = g_list_append (list, pixbuf32);
		list = g_list_append (list, pixbuf128);
		list = g_list_append (list, pixbuf256);
		gtk_window_set_default_icon_list(list);
	}

	/*
	 * Load the GTK interface.
	 */
	theXml = gtk_builder_new ();

	if (!gtk_builder_add_from_file (theXml, gladeFileName, NULL))
	{
		g_critical ("Failed to load the GTK file.\n");
		errorBox("Error!", joinTwoStrings("Failed to load resource file:\n", gladeFileName));
		initSuccess = FALSE;
		return;
	}

	/*
	 * Get the top-level window reference from loaded Glade file.
	 */
	theWindow = GTK_WIDGET (gtk_builder_get_object (theXml, "window1"));

	if (theWindow == NULL)
	{
		g_critical ("Failed to get the window from the builder.\n");
		initSuccess = FALSE;
		return;
	}

	// Set unassigned widgets to get handled automatically by the window manager.
	gtk_container_set_reallocate_redraws (GTK_CONTAINER (theWindow), TRUE);

	char folderFile[300];
	sprintf(folderFile, "%s/sludge-devkit/%s", g_get_user_config_dir(), configfile);
	FILE * fp = fopen (folderFile, "r");
	if (fp) {
		char readChar = ' ';
		for (int i = 0; i < 300; i++) {
			readChar = fgetc(fp);
			if (readChar != '\n') {
				currentFolder[i] = readChar;
			} else {
				currentFolder[i] = 0;
				break;
			}
		}
		fclose (fp);
	} else {
		sprintf (currentFolder, "%s", g_get_home_dir());
	}
	fileChanged = FALSE;

	currentFilename[0] = 0;
	currentShortname[0] = 0;
}
Exemple #8
0
void GTKGui::setUpGTK()
{
  GdkGLConfig *glconfig;
  GtkBuilder  *builder;
  GError      *error = NULL;

  gtk_init(0, NULL);
  gtk_gl_init(0, NULL);

  //Try double-buffered visual
  glconfig = gdk_gl_config_new_by_mode (static_cast<GdkGLConfigMode> (
								                      GDK_GL_MODE_RGB    |
                                      GDK_GL_MODE_DEPTH  |
                                      GDK_GL_MODE_DOUBLE));
  if (glconfig == NULL)
  {
   	g_print ("*** Cannot find the double-buffered visual.\n");
   	g_print ("*** Trying single-buffered visual.\n");

    // Try single-buffered visual
   	glconfig = gdk_gl_config_new_by_mode (static_cast<GdkGLConfigMode> (
									                        GDK_GL_MODE_RGB   |
                                          GDK_GL_MODE_DEPTH));
    if (glconfig == NULL)
	    g_print ("*** No appropriate OpenGL-capable visual found.\n");
  }

  // Create new GtkBuilder object
  builder = gtk_builder_new();
  if( ! gtk_builder_add_from_file(builder, "../../carmen/data/gui/cvis.glade", &error ) )
  {
    g_warning( "%s", error->message );
    g_free( error );
  }

  sleep(1.0);

  controls_.winMain  = GTK_WIDGET(gtk_builder_get_object(builder, "winMain" ));
  controls_.drawArea = GTK_WIDGET(gtk_builder_get_object(builder, "drawArea"));


  controls_.btnView2D = GTK_TOGGLE_BUTTON(gtk_builder_get_object(builder, "btnView2D"));
  controls_.btnView3D = GTK_TOGGLE_BUTTON(gtk_builder_get_object(builder, "btnView3D"));

  controls_.btnEfeito1 = GTK_TOGGLE_BUTTON(gtk_builder_get_object(builder, "btnEfeito1"));
  controls_.btnEfeito2 = GTK_TOGGLE_BUTTON(gtk_builder_get_object(builder, "btnEfeito2"));
  controls_.btnEfeito3 = GTK_TOGGLE_BUTTON(gtk_builder_get_object(builder, "btnEfeito3"));
  controls_.btnEfeito4 = GTK_TOGGLE_BUTTON(gtk_builder_get_object(builder, "btnEfeito4"));
  controls_.btnEfeito5 = GTK_TOGGLE_BUTTON(gtk_builder_get_object(builder, "btnEfeito5"));
  controls_.btnEfeito10 = GTK_TOGGLE_BUTTON(gtk_builder_get_object(builder, "btnEfeito10"));

  controls_.frameCamera         = GTK_WIDGET(gtk_builder_get_object(builder, "frameCamera"));
  controls_.frame3DMapOptions   = GTK_WIDGET(gtk_builder_get_object(builder, "frame3DMapOptions"));
  controls_.frame3DOtherOptions = GTK_WIDGET(gtk_builder_get_object(builder, "frame3DOtherOptions"));

  controls_.vboxRawOptions           = GTK_WIDGET(gtk_builder_get_object(builder, "vboxRawOptions" ));
  controls_.vboxObstacleOptions      = GTK_WIDGET(gtk_builder_get_object(builder, "vboxObstacleOptions" ));
  controls_.vboxColorByHeightOptions = GTK_WIDGET(gtk_builder_get_object(builder, "vboxColorByHeightOptions" ));

  controls_.ntbkViewOptions = GTK_NOTEBOOK(gtk_builder_get_object(builder, "ntbkViewOptions"));

  controls_.txtCamPosX = GTK_ENTRY(gtk_builder_get_object(builder, "txtCamPosX"));
  controls_.txtCamPosY = GTK_ENTRY(gtk_builder_get_object(builder, "txtCamPosY"));
  controls_.txtCamPosZ = GTK_ENTRY(gtk_builder_get_object(builder, "txtCamPosZ"));

  controls_.txtCamLookX = GTK_ENTRY(gtk_builder_get_object(builder, "txtCamLookX"));
  controls_.txtCamLookY = GTK_ENTRY(gtk_builder_get_object(builder, "txtCamLookY"));
  controls_.txtCamLookZ = GTK_ENTRY(gtk_builder_get_object(builder, "txtCamLookZ"));

  controls_.tbxCloudR = GTK_ENTRY(gtk_builder_get_object(builder, "tbxCloudR"));
  controls_.tbxCloudG = GTK_ENTRY(gtk_builder_get_object(builder, "tbxCloudG"));
  controls_.tbxCloudB = GTK_ENTRY(gtk_builder_get_object(builder, "tbxCloudB"));

  controls_.tbxBackgroundR = GTK_ENTRY(gtk_builder_get_object(builder, "tbxBackgroundR"));
  controls_.tbxBackgroundG = GTK_ENTRY(gtk_builder_get_object(builder, "tbxBackgroundG"));
  controls_.tbxBackgroundB = GTK_ENTRY(gtk_builder_get_object(builder, "tbxBackgroundB"));

  controls_.tbxCor1R = GTK_ENTRY(gtk_builder_get_object(builder, "tbxCor1R"));
  controls_.tbxCor1G = GTK_ENTRY(gtk_builder_get_object(builder, "tbxCor1G"));
  controls_.tbxCor1B = GTK_ENTRY(gtk_builder_get_object(builder, "tbxCor1B"));

  controls_.tbxCor2R = GTK_ENTRY(gtk_builder_get_object(builder, "tbxCor2R"));
  controls_.tbxCor2G = GTK_ENTRY(gtk_builder_get_object(builder, "tbxCor2G"));
  controls_.tbxCor2B = GTK_ENTRY(gtk_builder_get_object(builder, "tbxCor2B"));

  controls_.tbxCor3R = GTK_ENTRY(gtk_builder_get_object(builder, "tbxCor3R"));
  controls_.tbxCor3G = GTK_ENTRY(gtk_builder_get_object(builder, "tbxCor3G"));
  controls_.tbxCor3B = GTK_ENTRY(gtk_builder_get_object(builder, "tbxCor3B"));

  controls_.spbChangeSpeed = GTK_SPIN_BUTTON(gtk_builder_get_object(builder, "spbChangeSpeed"));
  controls_.spbForeRange = GTK_SPIN_BUTTON(gtk_builder_get_object(builder, "spbForeRange"));
  controls_.spbBackRange = GTK_SPIN_BUTTON(gtk_builder_get_object(builder, "spbBackRange"));

  controls_.spbCloudDensity = GTK_SPIN_BUTTON(gtk_builder_get_object(builder, "spbCloudDensity"));
  controls_.spbPointSize = GTK_SPIN_BUTTON(gtk_builder_get_object(builder, "spbPointSize"));

  controls_.spbVelTranslation = GTK_SPIN_BUTTON(gtk_builder_get_object(builder, "spbVelTranslation"));
  controls_.spbVelZoom = GTK_SPIN_BUTTON(gtk_builder_get_object(builder, "spbVelZoom"));

  controls_.btnAutoZoom = GTK_TOGGLE_BUTTON(gtk_builder_get_object(builder, "btnAutoZoom"));

  // Connect signals
  gtk_builder_connect_signals(builder, this);

  // Redraws
  gtk_container_set_reallocate_redraws (GTK_CONTAINER(controls_.winMain), TRUE);

  // Add OpenGL-capability to drawArea.
  if(!gtk_widget_set_gl_capability (controls_.drawArea, glconfig, NULL, TRUE, GDK_GL_RGBA_TYPE))
	  return;

  // Register idle function
  g_idle_add (on_drawArea_idle, this);

  // Destroy builder, since we don't need it anymore
  g_object_unref( G_OBJECT( builder ) );

  // Show window. All other widgets are automatically shown by GtkBuilder
  gtk_widget_show(controls_.winMain);
}
Exemple #9
0
static void
ide_omni_bar_init (IdeOmniBar *self)
{
  gtk_widget_init_template (GTK_WIDGET (self));

  G_GNUC_BEGIN_IGNORE_DEPRECATIONS;
  gtk_container_set_reallocate_redraws (GTK_CONTAINER (self), TRUE);
  G_GNUC_END_IGNORE_DEPRECATIONS;

  gtk_widget_set_direction (GTK_WIDGET (self->branch_box), GTK_TEXT_DIR_LTR);

  g_signal_connect_object (self->build_button,
                           "query-tooltip",
                           G_CALLBACK (ide_omni_bar__build_button__query_tooltip),
                           self,
                           G_CONNECT_SWAPPED);

  /*
   * IdeBuildManager bindings and signals.
   */

  self->build_manager_bindings = dzl_binding_group_new ();

  dzl_binding_group_bind (self->build_manager_bindings,
                          "busy",
                          self->cancel_button,
                          "visible",
                          G_BINDING_SYNC_CREATE);

  dzl_binding_group_bind (self->build_manager_bindings,
                          "busy",
                          self->build_button,
                          "visible",
                          G_BINDING_SYNC_CREATE | G_BINDING_INVERT_BOOLEAN);

  dzl_binding_group_bind (self->build_manager_bindings,
                          "has-diagnostics",
                          self->build_result_diagnostics_image,
                          "visible",
                          G_BINDING_SYNC_CREATE);

  dzl_binding_group_bind (self->build_manager_bindings, "error-count",
                          self->popover_errors_label, "label",
                          G_BINDING_SYNC_CREATE);

  dzl_binding_group_bind (self->build_manager_bindings, "warning-count",
                          self->popover_warnings_label, "label",
                          G_BINDING_SYNC_CREATE);

  dzl_binding_group_bind_full (self->build_manager_bindings,
                               "last-build-time",
                               self->popover_last_build_time_label,
                               "label",
                               G_BINDING_SYNC_CREATE,
                               date_time_to_label,
                               NULL,
                               NULL,
                               NULL);

  self->build_manager_signals = dzl_signal_group_new (IDE_TYPE_BUILD_MANAGER);

  dzl_signal_group_connect_object (self->build_manager_signals,
                                   "build-started",
                                   G_CALLBACK (ide_omni_bar__build_manager__build_started),
                                   self,
                                   G_CONNECT_SWAPPED);

  dzl_signal_group_connect_object (self->build_manager_signals,
                                   "build-failed",
                                   G_CALLBACK (ide_omni_bar__build_manager__build_failed),
                                   self,
                                   G_CONNECT_SWAPPED);

  dzl_signal_group_connect_object (self->build_manager_signals,
                                   "build-finished",
                                   G_CALLBACK (ide_omni_bar__build_manager__build_finished),
                                   self,
                                   G_CONNECT_SWAPPED);

  /*
   * Project bindings.
   */

  self->project_bindings = dzl_binding_group_new ();

  dzl_binding_group_bind (self->project_bindings, "name",
                          self->popover_project_label, "label",
                          G_BINDING_SYNC_CREATE);

  /*
   * IdeVcs bindings and signals.
   */

  self->vcs_bindings = dzl_binding_group_new ();

  dzl_binding_group_bind (self->vcs_bindings,
                          "branch-name",
                          self->branch_label,
                          "label",
                          G_BINDING_SYNC_CREATE);

  dzl_binding_group_bind (self->vcs_bindings,
                          "branch-name",
                          self->popover_branch_label,
                          "label",
                          G_BINDING_SYNC_CREATE);

  /*
   * IdeConfigurationManager bindings and signals.
   */

  self->config_manager_bindings = dzl_binding_group_new ();

  dzl_binding_group_bind (self->config_manager_bindings,
                          "current-display-name",
                          self->config_name_label,
                          "label",
                          G_BINDING_SYNC_CREATE);

  self->config_manager_signals = dzl_signal_group_new (IDE_TYPE_CONFIGURATION_MANAGER);

  dzl_signal_group_connect_object (self->config_manager_signals,
                                   "notify::current",
                                   G_CALLBACK (ide_omni_bar__config_manager__notify_current),
                                   self,
                                   G_CONNECT_SWAPPED);

  /*
   * Enable various events for state tracking.
   */

  gtk_widget_add_events (GTK_WIDGET (self->event_box), GDK_BUTTON_PRESS_MASK);

  g_signal_connect_object (self->event_box,
                           "enter-notify-event",
                           G_CALLBACK (event_box_enter_notify),
                           self,
                           G_CONNECT_SWAPPED);

  g_signal_connect_object (self->event_box,
                           "leave-notify-event",
                           G_CALLBACK (event_box_leave_notify),
                           self,
                           G_CONNECT_SWAPPED);

  g_signal_connect_object (self->popover,
                           "closed",
                           G_CALLBACK (ide_omni_bar_popover_closed),
                           self,
                           G_CONNECT_SWAPPED);

  self->gesture = gtk_gesture_multi_press_new (GTK_WIDGET (self->event_box));
  g_signal_connect (self->gesture, "pressed", G_CALLBACK (multipress_pressed_cb), self);

  /*
   * Register to be notified of IdeWorkbench:context set.
   */
  ide_widget_set_context_handler (self, ide_omni_bar_context_set);
}
Exemple #10
0
/*
 * main
 */
int main (int argc, char *argv[])
{

	GdkGLConfig *glConfig;
	GtkWidget *mainWindow;
	GtkWidget *copterDrawingArea;

	extern int optind;
	extern int optopt;
	extern int opterr;
	extern int optreset;

	char *optstr="d:m:s:h";
	char *sdev = NULL;
	int sspeed = -1;
	int opt = 0;

	/*
	 * Init argument control
	 */
	opt = getopt( argc, argv, optstr);
	while( opt != -1 ) {
		switch( opt ) {
		case 'd':
			sdev = optarg;
			break;
		case 'm':
			copter_filename = optarg;
		case 's':
			sspeed = atoi(optarg);
			break;
		case 'h':
			usage();
			return 0;
		default:
			break;
		}
		opt = getopt(argc, argv, optstr);
	}

	if (!g_thread_supported ()) { 
		g_thread_init (NULL); 
	}
	gdk_threads_init ();
	gdk_threads_enter ();

	/*
	 * Init GTK+ and GtkGLExt.
	 */
	gtk_init (&argc, &argv);
	gtk_gl_init (&argc, &argv);

	/*
	 * Configure a OpenGL-capable context.
	 */
	// Try to make it double-buffered.
	glConfig = gdk_gl_config_new_by_mode (GDK_GL_MODE_RGB | GDK_GL_MODE_DEPTH | GDK_GL_MODE_ALPHA | GDK_GL_MODE_DOUBLE);
	if (glConfig == NULL)
	{
		g_print ("Cannot configure a double-buffered context.\n");
		g_print ("Will try a single-buffered context.\n");

		// If we can't configure a double-buffered context, try for single-buffered.
		glConfig = gdk_gl_config_new_by_mode (GDK_GL_MODE_RGB | GDK_GL_MODE_DEPTH | GDK_GL_MODE_ALPHA);
		if (glConfig == NULL)
		{
			g_critical ("Aargh!  Cannot configure any type of OpenGL-capable context.  Exiting.\n");
			return -1;
		}
	}
	/*
	 * Load the GTK interface.
	 */
	theXml = gtk_builder_new ();
	gtk_builder_add_from_file (theXml, "amcc.glade", NULL);
	if (theXml == NULL)
	{
		g_critical ("Failed to load an initialise the GTK file.\n");
		return -1;
	}

	/*
	 * Get the top-level window reference from loaded Glade file.
	 */
	mainWindow = GTK_WIDGET (gtk_builder_get_object (theXml, "windowMain"));

	// Set unassigned widgets to get handled automatically by the window manager.
	gtk_container_set_reallocate_redraws (GTK_CONTAINER (mainWindow), TRUE);
	/*
	 * Get the drawing area's reference from the loaded Glade file which we are going to use for OpenGL rendering.
	 */
	copterDrawingArea = GTK_WIDGET (gtk_builder_get_object (theXml, "copter"));

	// Add OpenGL-capability to the drawing area.
	gtk_widget_set_gl_capability (copterDrawingArea, glConfig, NULL, TRUE, GDK_GL_RGBA_TYPE);

	// Initialise the render mutex.
	pthread_mutex_init (&copter_render_mutex, NULL);

	/*
	 * Get the window manager to connect any assigned signals in the loaded Glade file to our coded functions.
	 */
	gtk_builder_connect_signals (theXml, NULL);

	/*
	 * Init channel graph
	 */
	graph_init(&acc_graph, mainWindow, 3, 0, acc_graph_callback);
	graph_set_channel_name(&acc_graph, 1, "Acc_X");
	graph_set_channel_color(&acc_graph, 1, "#FF0000");
	graph_set_channel_name(&acc_graph, 2, "Acc_Y");
	graph_set_channel_color(&acc_graph, 2, "#00FF00");
	graph_set_channel_name(&acc_graph, 3, "Acc_Z");
	graph_set_channel_color(&acc_graph, 3, "#0000FF");
	gtk_box_pack_start (GTK_BOX(GTK_WIDGET (gtk_builder_get_object (theXml, "vbox2"))), 
			    graph_get_widget(&acc_graph),
			    TRUE, TRUE, 0);	graph_set_data(&acc_graph, 0, 3300);

	graph_init(&gyro_graph, mainWindow, 3, 0, gyro_graph_callback);
	graph_set_channel_name(&gyro_graph, 1, "Gyro_X");
	graph_set_channel_color(&gyro_graph, 1, "#FF0000");
	graph_set_channel_name(&gyro_graph, 2, "Gyro_Y");
	graph_set_channel_color(&gyro_graph, 2, "#00FF00");
	graph_set_channel_name(&gyro_graph, 3, "Gyro_Z");
	graph_set_channel_color(&gyro_graph, 3, "#0000FF");
	gtk_box_pack_start (GTK_BOX(GTK_WIDGET (gtk_builder_get_object (theXml, "vbox3"))), 
			    graph_get_widget(&gyro_graph),
			    TRUE, TRUE, 0);	graph_set_data(&gyro_graph, 0, 3300);

	mx_init(&mx, serial_tx_data, (void*)&serial);
	serial_init(&serial, mx_rx_data, &mx);
	if (!sdev)
		sdev = DEFAULT_SERIAL_DEV; 
	if (sspeed == -1)
		sspeed = 57600;
	serial_open(&serial, sdev, sspeed);

	/*
	 * Show main window.
	 */
	gtk_widget_show (mainWindow);
	// attitude init;
	attitude_init(&attitude);
	// Start the render timer.
	g_timeout_add (1000 / 10, render_timer_event, copterDrawingArea);
	g_timeout_add (1000 / 10, update_accs_graph, &acc_graph);
	g_timeout_add (1000 / 10, update_gyros_graph, &gyro_graph);

	// Run the window manager loop.
	gtk_main ();

	gdk_threads_leave ();

	return 0;
}
Exemple #11
0
static gint
show_lwobject(const char *lwobject_name)
{
  GtkWidget *window, *frame, *glarea;
  mesh_info *info;
  lwObject *lwobject;

  /* read lightwave object */
  if (!lw_is_lwobject(lwobject_name))
    {
      g_print("%s is not a LightWave 3D object\n", lwobject_name);
      return FALSE;
    }
  lwobject = lw_object_read(lwobject_name);
  if (lwobject == NULL)
    {
      g_print("Can't read LightWave 3D object %s\n", lwobject_name);
      return FALSE;
    }
  lw_object_scale(lwobject, 10.0 / lw_object_radius(lwobject));


  /* create aspect frame */
  frame = gtk_aspect_frame_new(NULL, 0.5,0.5, VIEW_ASPECT, FALSE);

  /* create new OpenGL widget */
  glarea = gtk_drawing_area_new();
  if (glarea == NULL)
    {
      lw_object_free(lwobject);
      g_print("Can't create GtkDrawingArea widget\n");
      return FALSE;
    }

  /* Set OpenGL-capability to the widget. */
  gtk_widget_set_gl_capability(GTK_WIDGET (glarea),
                               glconfig,
                               NULL,
                               TRUE,
                               GDK_GL_RGBA_TYPE);

  /* set up events and signals for OpenGL widget */
  gtk_widget_set_events(glarea,
     			GDK_EXPOSURE_MASK|
     			GDK_BUTTON_PRESS_MASK|
     			GDK_BUTTON_RELEASE_MASK|
     			GDK_POINTER_MOTION_MASK|
     			GDK_POINTER_MOTION_HINT_MASK);

  g_signal_connect(G_OBJECT(glarea), "draw",
                   G_CALLBACK(draw), NULL);
  g_signal_connect(G_OBJECT(glarea), "motion_notify_event",
                   G_CALLBACK(motion_notify), NULL);
  g_signal_connect(G_OBJECT(glarea), "button_press_event",
                   G_CALLBACK(button_press), NULL);
  g_signal_connect(G_OBJECT(glarea), "button_release_event",
                   G_CALLBACK(button_release), NULL);
  g_signal_connect(G_OBJECT(glarea), "configure_event",
                   G_CALLBACK(configure), NULL);
  g_signal_connect(G_OBJECT (glarea), "map_event",
		   G_CALLBACK (map_event), NULL);
  g_signal_connect(G_OBJECT (glarea), "unmap_event",
		   G_CALLBACK (unmap_event), NULL);
  g_signal_connect(G_OBJECT (glarea), "visibility_notify_event",
		   G_CALLBACK (visibility_notify_event), NULL);
  g_signal_connect(G_OBJECT(glarea), "destroy",
                   G_CALLBACK(destroy), NULL);

  gtk_widget_set_size_request(glarea, 200,200/VIEW_ASPECT); /* minimum size */

  /* set up mesh info */
  info = (mesh_info*)g_malloc(sizeof(mesh_info));
  info->do_init = TRUE;
  info->lwobject = lwobject;
  info->beginx = 0;
  info->beginy = 0;
  info->dx = 0;
  info->dy = 0;
  info->quat[0] = 0;  info->quat[1] = 0;  info->quat[2] = 0;  info->quat[3] = 1;
  info->dquat[0] = 0; info->dquat[1] = 0; info->dquat[2] = 0; info->dquat[3] = 1;
  info->zoom   = 45;
  info->animate = FALSE;
  info->timeout_id = 0;
  trackball(info->quat , 0.0, 0.0, 0.0, 0.0);
  g_object_set_data(G_OBJECT(glarea), "mesh_info", info);


  /* create new top level window */
  window = gtk_window_new( GTK_WINDOW_TOPLEVEL);
  gtk_window_set_title(GTK_WINDOW(window), lwobject_name);
  gtk_container_set_border_width(GTK_CONTAINER(window), 10);
  gtk_container_set_reallocate_redraws(GTK_CONTAINER (window), TRUE);
  create_popup_menu(window); /* add popup menu to window */
  /* key_press_event handler for top-level window */
  g_signal_connect_swapped(G_OBJECT (window), "key_press_event",
                           G_CALLBACK (key_press_event), glarea);
  g_signal_connect(G_OBJECT(window), "destroy",
                   G_CALLBACK(window_destroy), NULL);
  window_count++;

  /* put glarea into window and show it all */
  gtk_container_add(GTK_CONTAINER(window), frame);
  gtk_container_add(GTK_CONTAINER(frame),glarea);
  gtk_widget_show(glarea);
  gtk_widget_show(frame);
  gtk_widget_show(window);

  return TRUE;
}
Exemple #12
0
/***
 *** Creates the simple application window with one
 *** drawing area that has an OpenGL-capable visual.
 ***/
static GtkWidget *
create_window (GdkGLConfig *glconfig)
{
  GtkWidget *window;
  GtkWidget *drawing_area;
  GtkWidget *menu;

  /*
   * Top-level window.
   */

  window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
  gtk_window_set_title (GTK_WINDOW (window), DEFAULT_TITLE);

  /* Get automatically redrawn if any of their children changed allocation. */
  gtk_container_set_reallocate_redraws (GTK_CONTAINER (window), TRUE);

  /* Connect signal handlers to the window */
  g_signal_connect (G_OBJECT (window), "delete_event",
		    G_CALLBACK (gtk_main_quit), NULL);

  /*
   * Drawing area to draw OpenGL scene.
   */

  drawing_area = gtk_drawing_area_new ();
  gtk_widget_set_size_request (drawing_area, DEFAULT_WIDTH, DEFAULT_HEIGHT);

  /* Set OpenGL-capability to the widget */
  gtk_widget_set_gl_capability (drawing_area,
				glconfig,
				NULL,
				TRUE,
				GDK_GL_RGBA_TYPE);

  gtk_widget_add_events (drawing_area,
			 GDK_BUTTON1_MOTION_MASK    |
			 GDK_BUTTON2_MOTION_MASK    |
			 GDK_BUTTON_PRESS_MASK      |
			 GDK_VISIBILITY_NOTIFY_MASK);

  /* Connect signal handlers to the drawing area */
  g_signal_connect_after (G_OBJECT (drawing_area), "realize",
                          G_CALLBACK (realize), NULL);
  g_signal_connect (G_OBJECT (drawing_area), "configure_event",
		    G_CALLBACK (configure_event), NULL);
  g_signal_connect (G_OBJECT (drawing_area), "draw",
		    G_CALLBACK (draw), NULL);

  g_signal_connect (G_OBJECT (drawing_area), "motion_notify_event",
		    G_CALLBACK (motion_notify_event), NULL);
  g_signal_connect (G_OBJECT (drawing_area), "button_press_event",
		    G_CALLBACK (button_press_event), NULL);
  g_signal_connect (G_OBJECT (drawing_area), "unrealize",
		    G_CALLBACK (unrealize), NULL);

  /* key_press_event handler for top-level window */
  g_signal_connect_swapped (G_OBJECT (window), "key_press_event",
			    G_CALLBACK (key_press_event), drawing_area);

  /* For timeout function. */
  g_signal_connect (G_OBJECT (drawing_area), "map_event",
		    G_CALLBACK (map_event), NULL);
  g_signal_connect (G_OBJECT (drawing_area), "unmap_event",
		    G_CALLBACK (unmap_event), NULL);
  g_signal_connect (G_OBJECT (drawing_area), "visibility_notify_event",
		    G_CALLBACK (visibility_notify_event), NULL);

  gtk_container_add (GTK_CONTAINER (window), drawing_area);
  gtk_widget_show (drawing_area);

  /*
   * Popup menu.
   */

  menu = create_popup_menu (window, drawing_area);

  g_signal_connect_swapped (G_OBJECT (drawing_area), "button_press_event",
			    G_CALLBACK (button_press_event_popup_menu), menu);

  return window;
}
Exemple #13
0
int
main (int   argc,
      char *argv[])
{
  gint major, minor;

  GtkWidget *window;
  GtkWidget *vbox;
  GtkWidget *drawing_area;
  GtkWidget *button;

  /*
   * Init GTK.
   */

  gtk_init (&argc, &argv);

  /*
   * Init GdkGLExt.
   */

  gdk_gl_init (&argc, &argv);

  /*
   * Query OpenGL extension version.
   */

  gdk_gl_query_version (&major, &minor);
  g_print ("\nOpenGL extension version - %d.%d\n",
           major, minor);

  /*
   * Configure OpenGL-capable visual.
   */

  /* Try double-buffered visual */
  glconfig = gdk_gl_config_new (&config_attributes[0]);
  if (glconfig == NULL)
    {
      g_print ("*** Cannot find the double-buffered visual.\n");
      g_print ("*** Trying single-buffered visual.\n");

      /* Try single-buffered visual */
      glconfig = gdk_gl_config_new (&config_attributes[1]);
      if (glconfig == NULL)
        {
          g_print ("*** No appropriate OpenGL-capable visual found.\n");
          exit (1);
        }
    }

  examine_gl_config_attrib (glconfig);

  /*
   * Top-level window.
   */

  window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
  gtk_window_set_title (GTK_WINDOW (window), "low-level");

  /*
   * If window manager doesn't watch the WM_COLORMAP_WINDOWS property on
   * the top-level window, we have to set OpenGL window's colormap to the
   * top-level window.
   */
  gtk_widget_set_colormap (window,
                           gdk_gl_config_get_colormap (glconfig));

  /* Get automatically redrawn if any of their children changed allocation. */
  gtk_container_set_reallocate_redraws (GTK_CONTAINER (window), TRUE);

  g_signal_connect (G_OBJECT (window), "delete_event",
                    G_CALLBACK (gtk_main_quit), NULL);

  /*
   * VBox.
   */

  vbox = gtk_vbox_new (FALSE, 0);
  gtk_container_add (GTK_CONTAINER (window), vbox);
  gtk_widget_show (vbox);

  /*
   * Drawing area for drawing OpenGL scene.
   */

  drawing_area = gtk_drawing_area_new ();
  gtk_widget_set_size_request (drawing_area, 200, 200);

  /* Set OpenGL-capable colormap. */
  gtk_widget_set_colormap (drawing_area,
                           gdk_gl_config_get_colormap (glconfig));

  /* Disable backing store feature of the widget. */
  gtk_widget_set_double_buffered (drawing_area, FALSE);

  g_signal_connect_after (G_OBJECT (drawing_area), "realize",
                          G_CALLBACK (realize), NULL);
  g_signal_connect (G_OBJECT (drawing_area), "size_allocate",
                    G_CALLBACK (size_allocate), NULL);
  g_signal_connect (G_OBJECT (drawing_area), "configure_event",
		    G_CALLBACK (configure_event), NULL);
  g_signal_connect (G_OBJECT (drawing_area), "expose_event",
		    G_CALLBACK (expose_event), NULL);
  g_signal_connect (G_OBJECT (drawing_area), "unrealize",
		    G_CALLBACK (unrealize), NULL);

  gtk_box_pack_start (GTK_BOX (vbox), drawing_area, TRUE, TRUE, 0);

  gtk_widget_show (drawing_area);

  /*
   * Simple quit button.
   */

  button = gtk_button_new_with_label ("Quit");

  g_signal_connect (G_OBJECT (button), "clicked",
                    G_CALLBACK (gtk_main_quit), NULL);

  gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0);

  gtk_widget_show (button);

  /*
   * Show window.
   */

  gtk_widget_show (window);

  /*
   * Main loop.
   */

  /* Destroy the GLX context explicitly when application is terminated. */
  gtk_quit_add_destroy (gtk_main_level () + 1,
			GTK_OBJECT (drawing_area));

  gtk_main ();

  return 0;
}
int
main (int   argc,
      char *argv[])
{
  GdkGLConfig *glconfig;
  gint major, minor;

  GtkWidget *window;
  GtkWidget *vbox;
  GtkWidget *drawing_area;
  GtkWidget *button;

  /*
   * Init GTK.
   */

  gtk_init (&argc, &argv);

  /*
   * Init GtkGLExt.
   */

  gtk_gl_init (&argc, &argv);

  /*
   * Query OpenGL extension version.
   */

  gdk_gl_query_version (&major, &minor);
  g_print ("\nOpenGL extension version - %d.%d\n\n",
           major, minor);

  /*
   * Configure OpenGL-capable visual.
   */

  /* Try double-buffered visual */
  glconfig = gdk_gl_config_new_by_mode (GDK_GL_MODE_RGB |
                                        GDK_GL_MODE_DEPTH |
                                        GDK_GL_MODE_DOUBLE);
  if (glconfig == NULL)
    {
      g_print ("*** Cannot find the double-buffered visual.\n");
      g_print ("*** Trying single-buffered visual.\n");

      /* Try single-buffered visual */
      glconfig = gdk_gl_config_new_by_mode (GDK_GL_MODE_RGB |
                                            GDK_GL_MODE_DEPTH);
      if (glconfig == NULL)
        {
          g_print ("*** No appropriate OpenGL-capable visual found.\n");
          exit (1);
        }
    }

  /*
   * GLX extensions.
   */

  if (!gdk_x11_gl_query_glx_extension (glconfig, "GLX_SGIX_fbconfig"))
    {
      g_print ("GLX_SGIX_fbconfig extension is not supported.\n");
      exit (1);
    }

  GetFBConfigFromVisualSGIX =
    (GLXFBConfigSGIX (APIENTRY *)(Display*, XVisualInfo*))
      gdk_gl_get_proc_address ("glXGetFBConfigFromVisualSGIX");

  if (!gdk_x11_gl_query_glx_extension (glconfig, "GLX_SGIX_pbuffer"))
    {
      g_print ("GLX_SGIX_pbuffer extension is not supported.\n");
      exit (1);
    }

  CreateGLXPbufferSGIX  =
    (GLXPbufferSGIX (APIENTRY *)(Display*, GLXFBConfigSGIX, unsigned int, unsigned int, int*))
      gdk_gl_get_proc_address ("glXCreateGLXPbufferSGIX");
  DestroyGLXPbufferSGIX =
    (void (APIENTRY *)(Display*, GLXPbufferSGIX))
      gdk_gl_get_proc_address ("glXDestroyGLXPbufferSGIX");

  /*
   * Top-level window.
   */

  window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
  gtk_window_set_title (GTK_WINDOW (window), "simple");

  /* Get automatically redrawn if any of their children changed allocation. */
  gtk_container_set_reallocate_redraws (GTK_CONTAINER (window), TRUE);

  g_signal_connect (G_OBJECT (window), "delete_event",
                    G_CALLBACK (gtk_main_quit), NULL);

  /*
   * VBox.
   */

  vbox = gtk_vbox_new (FALSE, 0);
  gtk_container_add (GTK_CONTAINER (window), vbox);
  gtk_widget_show (vbox);

  /*
   * Drawing area for drawing OpenGL scene.
   */

  drawing_area = gtk_drawing_area_new ();
  gtk_widget_set_size_request (drawing_area, 200, 200);

  /* Set OpenGL-capability to the widget. */
  gtk_widget_set_gl_capability (drawing_area,
                                glconfig,
                                NULL,
                                TRUE,
                                GDK_GL_RGBA_TYPE);

  gtk_box_pack_start (GTK_BOX (vbox), drawing_area, TRUE, TRUE, 0);

  gtk_widget_set_events (drawing_area,
                         GDK_EXPOSURE_MASK |
                         GDK_BUTTON_PRESS_MASK);

  g_signal_connect_after (G_OBJECT (drawing_area), "realize",
                          G_CALLBACK (realize), NULL);
  g_signal_connect (G_OBJECT (drawing_area), "configure_event",
		    G_CALLBACK (configure_event), NULL);
  g_signal_connect (G_OBJECT (drawing_area), "draw",
		    G_CALLBACK (draw), NULL);

  gtk_widget_show (drawing_area);

  /*
   * Render button.
   */

  button = gtk_button_new_with_label ("Render to file");
  gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0);

  g_signal_connect (G_OBJECT (button), "clicked",
                    G_CALLBACK (render_to_file), drawing_area);

  gtk_widget_show (button);

  /*
   * Simple quit button.
   */

  button = gtk_button_new_with_label ("Quit");
  gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0);

  g_signal_connect (G_OBJECT (button), "clicked",
                    G_CALLBACK (gtk_main_quit), NULL);

  gtk_widget_show (button);

  /*
   * Show window.
   */

  gtk_widget_show (window);

  /*
   * Main loop.
   */

  gtk_main ();

  return 0;
}
Exemple #15
0
int main(int argc, char *argv[])
{
	printf("%s \nPlease report any bug to %s\n", PACKAGE_STRING, PACKAGE_BUGREPORT);	
	//printf("number of arg = %d, argv = %s\n", argc, argv[1]);
	/*printf("argc = %d\n", argc);
	if (argv[1] != NULL) {
		if (strstr (argv[1],"debug") != NULL) {
		debug = TRUE;
		printf("debug = TRUE\n");
			}  
		}
	DEBUG("debug is true\n");*/
	gchar *filename;
	int i = 0;
	gint initialWindowHeight = 170;
	guint timeoutEvent, intervalDisplaySpectro;
	GtkWidget *pVBox[4], *pHBox[13], *menuBar, *menu, *submenu, *menuItem, *submenuItem, *button, *frame, *image, *label, *widget;
	GdkColor color;
	Spectrum3dGui spectrum3dGui;
	GSList *radio_menu_group;
	GError **error;

#if defined (GTKGLEXT3) || defined (GTKGLEXT1)
	GdkGLConfig *glconfig;
#endif 
	
	gst_init (NULL, NULL);
	gtk_init (&argc, &argv);

	get_saved_values();
	intervalDisplaySpectro = (guint)spectrum3d.interval_display;

#if defined (GTKGLEXT3) || defined (GTKGLEXT1)
	gtk_gl_init(NULL, NULL);
	glconfig = gdk_gl_config_new_by_mode (GDK_GL_MODE_RGB    |
					GDK_GL_MODE_DEPTH  |
					GDK_GL_MODE_DOUBLE);
	  if (glconfig == NULL)
	    {
	      g_print ("\n*** Cannot find the double-buffered visual.\n");
	      g_print ("\n*** Trying single-buffered visual.\n");

	      /* Try single-buffered visual */
	      glconfig = gdk_gl_config_new_by_mode (GDK_GL_MODE_RGB   |
						    GDK_GL_MODE_DEPTH);
	      if (glconfig == NULL)
		{
		  g_print ("*** No appropriate OpenGL-capable visual found.\n");
		  exit (1);
		}
	    }
#endif

	initGstreamer();
	init_audio_values();
	init_display_values(&spectrum3dGui);
	
	spectrum3dGui.mainWindow = gtk_window_new (GTK_WINDOW_TOPLEVEL);
	gtk_widget_set_size_request (spectrum3dGui.mainWindow, 700, initialWindowHeight);
	gtk_widget_realize(spectrum3dGui.mainWindow);
	gtk_window_set_title(GTK_WINDOW(spectrum3dGui.mainWindow), PACKAGE_NAME);
	filename = g_build_filename (G_DIR_SEPARATOR_S, DATADIR, "icons", "spectrum3d.png", NULL);
	gtk_window_set_icon(GTK_WINDOW(spectrum3dGui.mainWindow), gdk_pixbuf_new_from_file (filename, error));
	g_signal_connect (G_OBJECT (spectrum3dGui.mainWindow), "destroy", G_CALLBACK (quit_spectrum3d), NULL);

#ifdef GTK3
	gtk_container_set_reallocate_redraws (GTK_CONTAINER (spectrum3dGui.mainWindow), TRUE);
#endif

#ifdef GTK3
	for (i = 0; i < 4; i++) {
		pVBox[i] = gtk_box_new(GTK_ORIENTATION_VERTICAL, 0);
		}
	pHBox[0] = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0);
	for (i = 1; i < 12; i++) {
		pHBox[i] = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0);
		}
	pHBox[12] = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0);
#elif defined GTK2
	for (i = 0; i < 4; i++) {
		pVBox[i] = gtk_vbox_new(FALSE, 0);
		}
	pHBox[0] = gtk_hbox_new(TRUE, 0);
	for (i = 1; i < 12; i++) {
		pHBox[i] = gtk_hbox_new(FALSE, 0);
		}
	pHBox[12] = gtk_hbox_new(TRUE, 0);
#endif
	
	gtk_container_add(GTK_CONTAINER(spectrum3dGui.mainWindow), pVBox[1]); 
	gtk_box_pack_start(GTK_BOX(pVBox[1]), pHBox[0], FALSE, FALSE, 0);
		
/* Menu */
	menuBar = gtk_menu_bar_new();

	menu = gtk_menu_new(); // 'Quit' submenu
	menuItem = gtk_menu_item_new_with_label("Quit");
	gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuItem);    
	g_signal_connect(G_OBJECT(menuItem), "activate", G_CALLBACK(gtk_main_quit), NULL); 
	menuItem = gtk_menu_item_new_with_label("Quit");
	gtk_menu_item_set_submenu(GTK_MENU_ITEM(menuItem), menu);
	gtk_menu_shell_append(GTK_MENU_SHELL(menuBar), menuItem);

	menu = gtk_menu_new(); // 'Edit' submenu
        menuItem = gtk_menu_item_new_with_label("Preferences");
	g_signal_connect(G_OBJECT(menuItem), "activate", G_CALLBACK(onPreferences), &spectrum3dGui);
	gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuItem);
	menuItem = gtk_menu_item_new_with_label("Edit");
	gtk_menu_item_set_submenu(GTK_MENU_ITEM(menuItem), menu);
	gtk_menu_shell_append(GTK_MENU_SHELL(menuBar), menuItem);

	menu = gtk_menu_new(); // 'Sound' submenu
	menuItem = gtk_menu_item_new_with_label("Sound");
	gtk_menu_item_set_submenu(GTK_MENU_ITEM(menuItem), menu);
	gtk_menu_shell_append(GTK_MENU_SHELL(menuBar), menuItem);

		submenu = gtk_menu_new();// 'Play test sound' sub-submenu
		spectrum3dGui.checkMenuTestSound = gtk_check_menu_item_new_with_label("Test Sound");
		gtk_menu_shell_append(GTK_MENU_SHELL(menu), spectrum3dGui.checkMenuTestSound);
		g_signal_connect(G_OBJECT(spectrum3dGui.checkMenuTestSound), "activate", G_CALLBACK(menu_check_test_sound), &spectrum3dGui);

	menu = gtk_menu_new(); // 'View' submenu
	menuItem = gtk_menu_item_new_with_label("View");
	gtk_menu_item_set_submenu(GTK_MENU_ITEM(menuItem), menu);
	gtk_menu_shell_append(GTK_MENU_SHELL(menuBar), menuItem);
	
		submenu = gtk_menu_new();// 'viewType' sub-submenu
		menuItem = gtk_menu_item_new_with_label("Perspective");
		gtk_menu_item_set_submenu (GTK_MENU_ITEM (menuItem), submenu);
		gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuItem);	
			
			spectrum3dGui.radio3D = gtk_radio_menu_item_new_with_label(NULL, "3D (D)");
			radio_menu_group = gtk_radio_menu_item_get_group(GTK_RADIO_MENU_ITEM(spectrum3dGui.radio3D));
			g_signal_connect(G_OBJECT(spectrum3dGui.radio3D), "toggled", G_CALLBACK(change_perspective), spectrum3dGui.radio3D);
			gtk_menu_shell_append(GTK_MENU_SHELL(submenu), spectrum3dGui.radio3D);

			spectrum3dGui.radio3Dflat = gtk_radio_menu_item_new_with_label(radio_menu_group, "3D flat (F)");
			radio_menu_group = gtk_radio_menu_item_get_group(GTK_RADIO_MENU_ITEM(spectrum3dGui.radio3Dflat));
			g_signal_connect(G_OBJECT(spectrum3dGui.radio3Dflat), "toggled", G_CALLBACK(change_perspective), spectrum3dGui.radio3Dflat);
			gtk_menu_shell_append(GTK_MENU_SHELL(submenu), spectrum3dGui.radio3Dflat);

			spectrum3dGui.radio2D = gtk_radio_menu_item_new_with_label(radio_menu_group, "2D (D)");
			radio_menu_group = gtk_radio_menu_item_get_group(GTK_RADIO_MENU_ITEM(spectrum3dGui.radio2D));
			g_signal_connect(G_OBJECT(spectrum3dGui.radio2D), "toggled", G_CALLBACK(change_perspective), spectrum3dGui.radio2D);
			gtk_menu_shell_append(GTK_MENU_SHELL(submenu), spectrum3dGui.radio2D);

		submenu = gtk_menu_new();// 'Scale' sub-submenu
		menuItem = gtk_menu_item_new_with_label("Scale");
		gtk_menu_item_set_submenu (GTK_MENU_ITEM (menuItem), submenu);
		gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuItem);	
	
			spectrum3dGui.checkMenuText = gtk_check_menu_item_new_with_label("Text (T)");
			gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(spectrum3dGui.checkMenuText), TRUE);
			g_signal_connect(G_OBJECT(spectrum3dGui.checkMenuText), "activate", G_CALLBACK(check_menu_text), &spectrum3dGui);
			gtk_menu_shell_append(GTK_MENU_SHELL(submenu), spectrum3dGui.checkMenuText);
	
			spectrum3dGui.checkMenuLines = gtk_check_menu_item_new_with_label("Lines (L)");
			gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(spectrum3dGui.checkMenuLines), TRUE);
			g_signal_connect(G_OBJECT(spectrum3dGui.checkMenuLines), "activate", G_CALLBACK(check_menu_lines), &spectrum3dGui);
			gtk_menu_shell_append(GTK_MENU_SHELL(submenu), spectrum3dGui.checkMenuLines);

			spectrum3dGui.checkMenuPointer = gtk_check_menu_item_new_with_label("Pointer (P)");
			g_signal_connect(G_OBJECT(spectrum3dGui.checkMenuPointer), "activate", G_CALLBACK(check_menu_pointer), &spectrum3dGui);
			gtk_menu_shell_append(GTK_MENU_SHELL(submenu), spectrum3dGui.checkMenuPointer);

		submenu = gtk_menu_new();// 'Change/reset view' sub-submenu
		menuItem = gtk_menu_item_new_with_label("Change/reset view");
		gtk_menu_item_set_submenu (GTK_MENU_ITEM (menuItem), submenu);
		gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuItem);	
			
			spectrum3dGui.reset = gtk_menu_item_new_with_label("Reset view (R)");
			gtk_widget_set_tooltip_text (spectrum3dGui.reset, "Reset the view as if Spectrum3d was just started");
			g_signal_connect(G_OBJECT(spectrum3dGui.reset), "activate", G_CALLBACK(reset_view), spectrum3dGui.reset);
			gtk_menu_shell_append(GTK_MENU_SHELL(submenu), spectrum3dGui.reset);

			spectrum3dGui.front = gtk_menu_item_new_with_label("Front view (O)");
			gtk_widget_set_tooltip_text (spectrum3dGui.front, "2D view showing frequency versus intensity of the sound; shows a snapshot of the harmonics at a given time");
			g_signal_connect(G_OBJECT(spectrum3dGui.front), "activate", G_CALLBACK(front_view), spectrum3dGui.front);
			gtk_menu_shell_append(GTK_MENU_SHELL(submenu), spectrum3dGui.front);

			submenuItem = gtk_menu_item_new_with_label("Preset view");
			gtk_widget_set_tooltip_text (submenuItem, "Set the view with the chosen preset values");
			g_signal_connect(G_OBJECT(submenuItem), "activate", G_CALLBACK(set_view_from_preset), submenuItem);
			gtk_menu_shell_append(GTK_MENU_SHELL(submenu), submenuItem);

	menu = gtk_menu_new(); // 'Help...' submenu
	menuItem = gtk_menu_item_new_with_label("Shortcuts"); 
	g_signal_connect(G_OBJECT(menuItem), "activate", G_CALLBACK(onShortcuts), (GtkWidget*) spectrum3dGui.mainWindow);
	gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuItem);
#ifdef HAVE_LIBGEIS
	menuItem = gtk_menu_item_new_with_label("Gestures Shortcuts");
	g_signal_connect(G_OBJECT(menuItem), "activate", G_CALLBACK(onGesturesShortcuts), (GtkWidget*) spectrum3dGui.mainWindow);
	gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuItem);
#endif 
	menuItem = gtk_menu_item_new_with_label("About...");
	g_signal_connect(G_OBJECT(menuItem), "activate", G_CALLBACK(onAbout), (GtkWidget*) spectrum3dGui.mainWindow);
	gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuItem);
	menuItem = gtk_menu_item_new_with_label("Quick start");
	g_signal_connect(G_OBJECT(menuItem), "activate", G_CALLBACK(onQuickStart), (GtkWidget*) spectrum3dGui.mainWindow);
	gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuItem);
	menuItem = gtk_menu_item_new_with_label("Help");
	gtk_menu_item_set_submenu(GTK_MENU_ITEM(menuItem), menu);
	gtk_menu_shell_append(GTK_MENU_SHELL(menuBar), menuItem);
	gtk_box_pack_start(GTK_BOX(pHBox[0]), menuBar, FALSE, TRUE, 0);

/* SourceButtons to set type of source (none, audio file, microphone) */
	spectrum3dGui.stop = gtk_button_new();
	filename = g_build_filename (G_DIR_SEPARATOR_S, DATADIR, "icons", "stop.png", NULL);
	image = gtk_image_new_from_file(filename);
	gtk_button_set_image(GTK_BUTTON(spectrum3dGui.stop),image);
	gdk_color_parse ("gold",&color);
	gtk_widget_set_name(spectrum3dGui.stop, "stop");
	gtk_widget_modify_bg(GTK_WIDGET(spectrum3dGui.stop), GTK_STATE_NORMAL, &color);
	gtk_widget_modify_bg(GTK_WIDGET(spectrum3dGui.stop), GTK_STATE_PRELIGHT, &color);
	gtk_widget_set_tooltip_text (spectrum3dGui.stop, "Stop playing everything; no source of playing");
	gtk_box_pack_start(GTK_BOX(pVBox[1]), pHBox[1], FALSE, TRUE, 2);
	gtk_box_pack_start(GTK_BOX(pHBox[1]), spectrum3dGui.stop, FALSE, TRUE, 2);
	g_signal_connect(G_OBJECT(spectrum3dGui.stop), "clicked", G_CALLBACK(change_source_button), &spectrum3dGui);

	filename = g_build_filename (G_DIR_SEPARATOR_S, DATADIR, "icons", "microphone_grey.png", NULL);
	image = gtk_image_new_from_file(filename);
	spectrum3dGui.mic = gtk_button_new();
	gtk_button_set_image (GTK_BUTTON(spectrum3dGui.mic), image);
	gtk_widget_set_name(spectrum3dGui.mic, "mic");
	gtk_widget_set_tooltip_text (spectrum3dGui.mic, "Source is microphone; select this to record something and then load it");
	gtk_box_pack_start(GTK_BOX(pHBox[1]), spectrum3dGui.mic, FALSE, TRUE, 2);
	g_signal_connect(G_OBJECT(spectrum3dGui.mic), "clicked", G_CALLBACK(change_source_button), &spectrum3dGui);

	spectrum3dGui.file = gtk_button_new();
	filename = g_build_filename (G_DIR_SEPARATOR_S, DATADIR, "icons", "file_grey.png", NULL);
	image = gtk_image_new_from_file(filename);
	gtk_button_set_image(GTK_BUTTON(spectrum3dGui.file),image);
	gtk_widget_set_name(spectrum3dGui.file, "file");
	gtk_widget_set_tooltip_text (spectrum3dGui.file, "Source is an audio file");
	gtk_box_pack_start(GTK_BOX(pHBox[1]), spectrum3dGui.file, FALSE, FALSE, 2);
	g_signal_connect(G_OBJECT(spectrum3dGui.file), "clicked", G_CALLBACK(change_source_button), &spectrum3dGui);

	spectrum3dGui.reload = gtk_button_new();
	image = gtk_image_new_from_stock (GTK_STOCK_REFRESH, GTK_ICON_SIZE_LARGE_TOOLBAR);
	gtk_button_set_image(GTK_BUTTON(spectrum3dGui.reload),image);
	gtk_widget_set_sensitive (spectrum3dGui.reload, FALSE);
	gtk_widget_set_tooltip_text (spectrum3dGui.reload, "Reload audio file (usefull if some audio parameters like equalizer or filters have been changed)");
	gtk_box_pack_start(GTK_BOX(pHBox[1]), spectrum3dGui.reload, FALSE, FALSE, 2);
	g_signal_connect(G_OBJECT(spectrum3dGui.reload), "clicked", G_CALLBACK(load_audio_file), NULL);

	widget = gtk_check_button_new_with_label("Analyse in\nrealtime");
	gtk_widget_set_tooltip_text (GTK_WIDGET(widget), "If checked, harmonics will be analysed and displayed at the same time; if unchecked, harmonics will be analysed first, then displayed for the whole audio file, then it can be played afterwards");
	gtk_box_pack_start(GTK_BOX(pHBox[1]), widget, FALSE, FALSE, 0);
	gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON(widget), TRUE);
	g_signal_connect(G_OBJECT(widget), "toggled", G_CALLBACK(set_analyse_in_rt), &spectrum3dGui);

/* separator */
#ifdef GTK3
	widget = gtk_separator_new(GTK_ORIENTATION_VERTICAL);
#elif defined GTK2
	widget = gtk_vseparator_new();
#endif
	gtk_box_pack_start(GTK_BOX(pHBox[1]), widget, FALSE, FALSE, 5);
	
/* "Play/Pause" button */
	playButton = gtk_button_new();
	gtk_widget_set_tooltip_text (playButton, "Play/Pause the audio stream");
	setPlayButtonIcon();
	gtk_widget_set_size_request (playButton, 50, 20);
	gtk_box_pack_start(GTK_BOX(pHBox[1]), playButton, FALSE, FALSE, 2);
	g_signal_connect(G_OBJECT(playButton), "clicked", G_CALLBACK(playFromSource), "NO_MESSAGE");
	
/* "Stop" button */
	button = gtk_button_new();
	gtk_widget_set_tooltip_text (button, "Stop playing audio stream");
	image = gtk_image_new_from_stock (GTK_STOCK_MEDIA_STOP, GTK_ICON_SIZE_SMALL_TOOLBAR);
	gtk_button_set_image(GTK_BUTTON(button),image);
	gtk_box_pack_start(GTK_BOX(pHBox[1]), button, FALSE, FALSE, 2);
	g_signal_connect(G_OBJECT(button), "clicked", G_CALLBACK(on_stop), NULL);

/* "Record" button */
	spectrum3dGui.record = gtk_button_new();
	gtk_widget_set_tooltip_text (spectrum3dGui.record, "Record from microphone");
	image = gtk_image_new_from_stock (GTK_STOCK_MEDIA_RECORD, GTK_ICON_SIZE_SMALL_TOOLBAR);
	gtk_button_set_image(GTK_BUTTON(spectrum3dGui.record),image);
	gtk_widget_set_sensitive (spectrum3dGui.record, FALSE);
	gtk_box_pack_start(GTK_BOX(pHBox[1]), spectrum3dGui.record, FALSE, FALSE, 2);
	g_signal_connect(G_OBJECT(spectrum3dGui.record), "clicked", G_CALLBACK(record_window), NULL);

/* separator */
#ifdef GTK3
	widget = gtk_separator_new(GTK_ORIENTATION_VERTICAL);
#elif defined GTK2
	widget = gtk_vseparator_new();
#endif	
	gtk_box_pack_start(GTK_BOX(pHBox[1]), widget, FALSE, FALSE, 5);

/* JACK check button */
	filename = g_build_filename (G_DIR_SEPARATOR_S, DATADIR, "icons", "qjackctl.png", NULL);
	image = gtk_image_new_from_file(filename);
	widget = gtk_check_button_new ();
	gtk_button_set_image (GTK_BUTTON(widget), image);
	gtk_widget_set_tooltip_text (widget, "Use Jack-Audio-Connection-Kit (JACK)");
	gtk_box_pack_start(GTK_BOX(pHBox[1]), widget, FALSE, FALSE, 2);
	g_signal_connect(G_OBJECT(widget), "toggled", G_CALLBACK(use_jack), &spectrum3dGui);

/* separator */
#ifdef GTK3
	widget = gtk_separator_new(GTK_ORIENTATION_VERTICAL);
#elif defined GTK2
	widget = gtk_vseparator_new();
#endif	
	gtk_box_pack_start(GTK_BOX(pHBox[1]), widget, FALSE, FALSE, 5);

/* Button to open the Filter and Equalizer window */
	// create effectsWindow first without showing it
	effects_window(&spectrum3dGui);
	// then create a button that will call its display when clicked
	filename = g_build_filename (G_DIR_SEPARATOR_S, DATADIR, "icons", "equalizer.png", NULL);
	image = gtk_image_new_from_file(filename);
	widget = gtk_button_new();  
	gtk_button_set_image (GTK_BUTTON(widget), image);
	gtk_widget_set_tooltip_text (widget, "Show/Hide the filter and equalizer window");
	gtk_box_pack_start(GTK_BOX(pHBox[1]), widget, FALSE, FALSE, 0);
	g_signal_connect(G_OBJECT(widget), "clicked", G_CALLBACK(show_effects_window), &spectrum3dGui);

/* Time label */
	label=gtk_label_new("Time : ");
	gtk_box_pack_start(GTK_BOX(pHBox[5]), label, FALSE, FALSE, 0);
	gtk_box_pack_start(GTK_BOX(pVBox[1]), pHBox[5], FALSE, FALSE, 2);

/* Progress & seek scale */
#ifdef GTK3
	scaleSeek = gtk_scale_new_with_range (GTK_ORIENTATION_HORIZONTAL, 0.0, 100.0, 1);
#elif defined GTK2
	scaleSeek = gtk_hscale_new_with_range (0.0, 100.0, 1);
#endif
	gtk_scale_set_draw_value (GTK_SCALE (scaleSeek), FALSE);
	//gtk_scale_set_value_pos (GTK_SCALE (pScaleSeek), GTK_POS_TOP);
	gtk_range_set_value (GTK_RANGE (scaleSeek), 0);
	gtk_widget_set_size_request (scaleSeek, 500, 20);
	gtk_box_pack_start(GTK_BOX(pHBox[5]), scaleSeek, FALSE, FALSE, 0);
	g_signal_connect(G_OBJECT(scaleSeek), "value-changed", G_CALLBACK(on_seek), NULL);
	
	timeLabel=gtk_label_new("           0:00 / 0:00           ");
	gtk_box_pack_start(GTK_BOX(pHBox[5]), timeLabel, FALSE, FALSE, 0);

/* Create drawing area */
	if (externalWindow == FALSE){
		/* Resize spectrum3dGui.mainWindow to contain drawing_area; using gtk_window_set_defaut() allows to shrink the window (gtk_widget_set_size_request() does not allow to shrink the window below the requested size); */
		gtk_window_set_default_size (GTK_WINDOW(spectrum3dGui.mainWindow), (gint)spectrum3d.width, initialWindowHeight + (gint)spectrum3d.height);
		
		//gtk_widget_realize(spectrum3dGui.mainWindow);

		spectrum3dGui.drawing_area = gtk_drawing_area_new ();
		
#if defined (GTKGLEXT3) || defined (GTKGLEXT1)
		/* Set OpenGL-capability to the widget */
	  	gtk_widget_set_gl_capability (spectrum3dGui.drawing_area,
					glconfig,
					NULL,
					TRUE,
					GDK_GL_RGBA_TYPE);		
#endif	
		
		/* drawing_area has to be put in vBox AFTER the call to gtk_widget_set_gl_capability() (if GtkGlExt is used) and BEFORE the call to the sdl-gtk hack (if sdl is used)*/ 
		gtk_box_pack_start (GTK_BOX (pVBox[1]), spectrum3dGui.drawing_area, TRUE, TRUE, 0);	
		
#ifdef HAVE_LIBSDL 
		/* Hack to get SDL to use GTK window */
		{ char SDL_windowhack[32];
			sprintf(SDL_windowhack,"SDL_WINDOWID=%ld",
				GDK_WINDOW_XID(gtk_widget_get_window(spectrum3dGui.drawing_area)));
				// GDK_WINDOW_XID( spectrum3dGui.drawing_area->window))); pour GTK2??
			putenv(SDL_windowhack);
		printf("%s\n", SDL_windowhack);
		}

		if (SDL_Init(SDL_INIT_VIDEO) < 0) {
			fprintf(stderr, "Unable to init SDL: %s\n", SDL_GetError());
			exit(1);
			}
#endif

		g_signal_connect (spectrum3dGui.mainWindow, "key-press-event", G_CALLBACK (on_key_press), &spectrum3dGui);
		g_signal_connect (spectrum3dGui.mainWindow, "key-release-event", G_CALLBACK (on_key_release), &spectrum3dGui);
		g_signal_connect (spectrum3dGui.mainWindow, "motion-notify-event", G_CALLBACK (on_mouse_motion), NULL);
		g_signal_connect (spectrum3dGui.mainWindow, "scroll-event", G_CALLBACK (on_mouse_scroll), NULL);
		g_signal_connect (G_OBJECT (spectrum3dGui.drawing_area), "configure_event", G_CALLBACK (configure_event), NULL);
		gtk_widget_add_events (spectrum3dGui.mainWindow, gtk_widget_get_events (spectrum3dGui.mainWindow) | GDK_KEY_PRESS_MASK | GDK_KEY_RELEASE_MASK | GDK_POINTER_MOTION_MASK | GDK_SCROLL_MASK);
	}
	else {
		create_external_window_drawing_area(&spectrum3dGui);
		}	

/* Starting value of the display */
	frame = gtk_frame_new("Start value of display (in Hz)");
	gtk_widget_set_tooltip_text (frame, "The lower displayed frequency (in herz)");
	spectrum3dGui.adjustStart = gtk_adjustment_new(0, 0, 9000, ((gdouble)hzStep * (gdouble)zoomFactor), (((gdouble)hzStep * (gdouble)zoomFactor) * 10), 0);
#ifdef GTK3
	pScaleStart = gtk_scale_new(GTK_ORIENTATION_HORIZONTAL, GTK_ADJUSTMENT(spectrum3dGui.adjustStart));
#elif defined GTK2
	pScaleStart = gtk_hscale_new(GTK_ADJUSTMENT(spectrum3dGui.adjustStart));
#endif
	gtk_scale_set_digits (GTK_SCALE(pScaleStart), 0);
	gtk_scale_set_value_pos(GTK_SCALE(pScaleStart), GTK_POS_RIGHT);
	gtk_box_pack_start(GTK_BOX(pVBox[1]), pHBox[11], FALSE, FALSE, 0);
	gtk_box_pack_start(GTK_BOX(pHBox[11]), frame, FALSE, FALSE, 0);
	gtk_container_add(GTK_CONTAINER(frame), pScaleStart);
	g_signal_connect(G_OBJECT(pScaleStart), "value-changed", G_CALLBACK(change_start), &spectrum3dGui);
	g_signal_connect(G_OBJECT(pScaleStart), "format-value", G_CALLBACK(format_value_start), NULL);
	g_signal_connect(G_OBJECT(pScaleStart), "value-changed", G_CALLBACK(getTextDisplayLabel), &spectrum3dGui);

/* Range of display */
	frame = gtk_frame_new("Range of display (in Hz)");
	gtk_widget_set_tooltip_text (frame, "The range of the displayed frequency (in herz)");
	spectrum3dGui.adjustBands = gtk_adjustment_new(1000, 20, 1000, 10, 50, 0);
#ifdef GTK3
	spectrum3dGui.scaleBands = gtk_scale_new(GTK_ORIENTATION_HORIZONTAL, GTK_ADJUSTMENT(spectrum3dGui.adjustBands));
#elif defined GTK2
	spectrum3dGui.scaleBands = gtk_hscale_new(GTK_ADJUSTMENT(spectrum3dGui.adjustBands));
#endif
	gtk_scale_set_digits (GTK_SCALE(spectrum3dGui.scaleBands), 0);
	gtk_scale_set_value_pos(GTK_SCALE(spectrum3dGui.scaleBands), GTK_POS_RIGHT);
	gtk_container_add(GTK_CONTAINER(frame), spectrum3dGui.scaleBands);
	gtk_box_pack_start(GTK_BOX(pHBox[11]), frame, FALSE, FALSE, 0);
	g_signal_connect(G_OBJECT(spectrum3dGui.scaleBands), "value-changed", G_CALLBACK(change_bands), &spectrum3dGui);
	g_signal_connect(G_OBJECT(spectrum3dGui.scaleBands), "format-value", G_CALLBACK(format_value_bands), NULL);
	g_signal_connect(G_OBJECT(spectrum3dGui.scaleBands), "value-changed", G_CALLBACK(getTextDisplayLabel), &spectrum3dGui);
	
/* "x" label */
	label=gtk_label_new("x");
	gtk_container_add(GTK_CONTAINER(pHBox[11]), label);

/* Factor that multiplies the range of display */
	frame = gtk_frame_new("");
	gtk_widget_set_tooltip_text (frame, "Factor that multiplies the frequency range, to make it larger");
	spectrum3dGui.cbRange = gtk_combo_box_text_new();
	gtk_container_add(GTK_CONTAINER(frame), spectrum3dGui.cbRange);
	gtk_box_pack_start(GTK_BOX(pHBox[11]), frame, FALSE, FALSE, 0);
	for (i = 1; i <= 20; i++){
		gchar text[4];
		sprintf(text, "%d", i);
		gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(spectrum3dGui.cbRange), text);
		}
	gtk_combo_box_set_active(GTK_COMBO_BOX(spectrum3dGui.cbRange), 0);
	g_signal_connect( G_OBJECT(spectrum3dGui.cbRange), "changed", G_CALLBACK( cb_range_changed ), &spectrum3dGui );
	g_signal_connect( G_OBJECT(spectrum3dGui.cbRange), "changed", G_CALLBACK(getTextDisplayLabel), &spectrum3dGui );
	
/* Label that shows starting value, ending value and range of display */
	frame = gtk_frame_new("Values displayed");
	gtk_widget_set_tooltip_text (frame, "The lower and the highest displayed value (in herz), and their range");
	displayLabel=gtk_label_new(""); 
	gtk_container_add(GTK_CONTAINER(frame), displayLabel);
	getTextDisplayLabel(NULL, &spectrum3dGui);
	gtk_box_pack_start(GTK_BOX(pHBox[11]), frame, FALSE, FALSE, 0);

/* 'Gain' Gtk Scale */
	frame = gtk_frame_new("Display Gain");
	gtk_box_pack_start(GTK_BOX(pHBox[11]), frame, FALSE, FALSE, 10);
	filename = g_build_filename (G_DIR_SEPARATOR_S, DATADIR, "icons", "gain.png", NULL);
	image = gtk_image_new_from_file(filename);

	spectrum3dGui.scaleGain = gtk_scale_button_new (GTK_ICON_SIZE_LARGE_TOOLBAR, 0, 1, 0.01, NULL);
	gtk_button_set_image(GTK_BUTTON(spectrum3dGui.scaleGain),image);
	//gtk_button_set_label (GTK_BUTTON(spectrum3dGui.scaleGain), "GAIN");
	gtk_container_add(GTK_CONTAINER(frame), spectrum3dGui.scaleGain);
	//gtk_box_pack_start(GTK_BOX(pHBox[11]), pScaleGain, FALSE, FALSE, 0);
	//gtk_widget_set_size_request (pScaleGain, 200, 20);
	//gtk_scale_set_value_pos(GTK_SCALE(pScaleGain), GTK_POS_RIGHT);
	gtk_widget_set_tooltip_text (spectrum3dGui.scaleGain, "Adjust the displayed level of the intensity of the sound");
	gtk_scale_button_set_value(GTK_SCALE_BUTTON(spectrum3dGui.scaleGain), 0.2);
	// FIXME error message here with the previous line : gtk_image_set_from_stock: assertion `GTK_IS_IMAGE (image)' failed; it could be a bug in Gtk
	//g_object_set (pScaleGain, "update-policy", GTK_UPDATE_DISCONTINUOUS, NULL);
	g_signal_connect(G_OBJECT(spectrum3dGui.scaleGain), "value-changed", G_CALLBACK(change_gain), NULL);

#ifdef HAVE_LIBGEIS
	setupGeis();
#endif

	gtk_widget_show_all (spectrum3dGui.mainWindow);

	//timeoutEvent = g_timeout_add (100, (GSourceFunc)sdl_event, &spectrum3dGui);
	spectrum3d.timeoutExpose = g_timeout_add (intervalDisplaySpectro, (GSourceFunc)display_spectro, &spectrum3dGui);

	printf("Showing Gtk GUI\n");
	gtk_main ();

/* Quit everything */

#ifdef HAVE_LIBGEIS
	geisQuit();
#endif
	on_stop();
	g_source_remove(spectrum3d.timeoutExpose);
#ifdef HAVE_LIBSDL
	//g_source_remove(timeoutEvent);
	SDL_Quit();
#endif

	print_rc_file();

	printf("Quit everything\nGood Bye!\n");
	
	return 0;
}
Exemple #16
0
int view_orb(GtkWidget* Parent,int argc, char **argv)
{
	GtkWidget* vboxwin;
	GtkWidget* hboxwin;
	GtkWidget* handleBoxColorMapGrid;
	GtkWidget* handleBoxColorMapContours;
	GtkWidget* handleBoxColorMapPlanesMapped;

	static gboolean first = TRUE;


	init_dipole();
	if(!first)
	{
		if(PrincipalWindow)
		{
			gtk_widget_hide(GTK_WIDGET(PrincipalWindow));
			gtk_widget_show(GTK_WIDGET(PrincipalWindow));
			/* if(argc>1) read_any_file(argv[1]);*/
			return 0;
		}
	}
	/* initialisation */
	initialise_global_orbitals_variables();
	read_opengl_file();

	/* Create new top level window. */
	PrincipalWindow = gtk_window_new( GTK_WINDOW_TOPLEVEL);
	gtk_window_set_title(GTK_WINDOW(PrincipalWindow), _("Gabedit : Orbitals/Density/Vibration"));
	 gtk_container_set_reallocate_redraws (GTK_CONTAINER (PrincipalWindow), TRUE);
  	gtk_window_set_default_size (GTK_WINDOW(PrincipalWindow),(gint)(ScreenWidth*0.5),(gint)(ScreenHeight*0.69));
	gtk_container_set_border_width(GTK_CONTAINER(PrincipalWindow), 1);
	init_child(PrincipalWindow,gtk_widget_destroy," Draw Dens. Orb. ");
	/* g_signal_connect(G_OBJECT(PrincipalWindow),"delete_event",(GCallback)close_window_orb,NULL);*/
	g_signal_connect(G_OBJECT(PrincipalWindow), "delete-event",G_CALLBACK(gtk_widget_hide_on_delete), NULL);
	gtk_window_set_transient_for(GTK_WINDOW(PrincipalWindow),GTK_WINDOW(Parent));

	vboxwin = create_vbox(PrincipalWindow);
	gtk_widget_realize(PrincipalWindow);
	hboxwin = gtk_hbox_new (FALSE, 0);
	gtk_box_pack_start (GTK_BOX(vboxwin), hboxwin, TRUE, TRUE, 2);
	gtk_widget_show (hboxwin);

	
	if (!NewGLArea(hboxwin)) return 0;

	create_status_bar_orb(vboxwin);
	create_status_progress_bar_orb(vboxwin);

	handleBoxColorMapGrid = create_color_map_show(vboxwin,NULL," Grid ");
	g_object_set_data(G_OBJECT(PrincipalWindow), "HandleboxColorMapGrid ", handleBoxColorMapGrid);

	handleBoxColorMapContours = create_color_map_show(vboxwin,NULL, "Contours ");
	g_object_set_data(G_OBJECT(PrincipalWindow), "HandleboxColorMapContours", handleBoxColorMapContours);

	handleBoxColorMapPlanesMapped = create_color_map_show(vboxwin,NULL," Planes colorcoded");
	g_object_set_data(G_OBJECT(PrincipalWindow), "HandleboxColorMapPlanesMapped", handleBoxColorMapPlanesMapped);

	set_icone(PrincipalWindow);
	gtk_widget_show(GTK_WIDGET(PrincipalWindow));
	color_map_hide(handleBoxColorMapGrid);
	color_map_hide(handleBoxColorMapContours);
	color_map_hide(handleBoxColorMapPlanesMapped);
	/* if(argc>1) read_any_file(argv[1]);*/

	first = FALSE;

	gtk_window_move(GTK_WINDOW(PrincipalWindow),0,0);
	InitializeAll();
	/*printCoefZlm();*/

	return 0;
}
Exemple #17
0
/***
 *** Creates the simple application window with one
 *** drawing area that has an OpenGL-capable visual.
 ***/
static GtkWidget *
create_window (GdkGLConfig *glconfig)
{
  GtkWidget *window;
  GtkWidget *vbox;
  GtkWidget *drawing_area;
  GtkWidget *button;

  /*
   * Top-level window.
   */

  window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
  gtk_window_set_title (GTK_WINDOW (window), DEFAULT_TITLE);

  /* Get automatically redrawn if any of their children changed allocation. */
  gtk_container_set_reallocate_redraws (GTK_CONTAINER (window), TRUE);

  /* Connect signal handlers to the window */
  g_signal_connect (G_OBJECT (window), "delete_event",
		    G_CALLBACK (quit_cb), NULL);

  /*
   * VBox.
   */

  vbox = gtk_vbox_new (FALSE, 0);
  gtk_container_add (GTK_CONTAINER (window), vbox);
  gtk_widget_show (vbox);

  /*
   * Drawing area to draw OpenGL scene.
   */

  drawing_area = gtk_drawing_area_new ();
  gtk_widget_set_size_request (drawing_area, DEFAULT_WIDTH, DEFAULT_HEIGHT);

  /* Set OpenGL-capability to the widget */
  gtk_widget_set_gl_capability (drawing_area,
				glconfig,
				NULL,
				TRUE,
				GDK_GL_RGBA_TYPE);

  gtk_widget_add_events (drawing_area,
			 GDK_BUTTON1_MOTION_MASK    |
			 GDK_BUTTON_PRESS_MASK);

  /* Connect signal handlers to the drawing area */
  g_signal_connect_after (G_OBJECT (drawing_area), "realize",
                          G_CALLBACK (realize), NULL);
  g_signal_connect (G_OBJECT (drawing_area), "configure_event",
		    G_CALLBACK (configure_event), NULL);
  g_signal_connect (G_OBJECT (drawing_area), "expose_event",
		    G_CALLBACK (expose_event), NULL);

  g_signal_connect (G_OBJECT (drawing_area), "motion_notify_event",
		    G_CALLBACK (motion_notify_event), NULL);
  g_signal_connect (G_OBJECT (drawing_area), "button_press_event",
		    G_CALLBACK (button_press_event), NULL);

  gtk_box_pack_start (GTK_BOX (vbox), drawing_area, TRUE, TRUE, 0);

  gtk_widget_show (drawing_area);

  /*
   * Simple quit button.
   */

  button = gtk_button_new_with_label ("Quit");

  g_signal_connect (G_OBJECT (button), "clicked",
                    G_CALLBACK (quit_cb), NULL);

  gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0);

  gtk_widget_show (button);

  return window;
}
int
main (int   argc,
      char *argv[])
{
  GdkGLConfig *glconfig;
  GtkWidget *window;
  GtkWidget *button;

  /*
   * Init GTK.
   */

  gtk_init (&argc, &argv);

  /*
   * Init GtkGLExt.
   */

  gtk_gl_init (&argc, &argv);

  /*
   * Configure OpenGL-capable visual.
   */

  /* Try double-buffered visual */
  glconfig = gdk_gl_config_new_by_mode (GDK_GL_MODE_RGB    |
                                        GDK_GL_MODE_DEPTH  |
                                        GDK_GL_MODE_DOUBLE);
  if (glconfig == NULL)
    {
      g_print ("*** Cannot find the double-buffered visual.\n");
      g_print ("*** Trying single-buffered visual.\n");

      /* Try single-buffered visual */
      glconfig = gdk_gl_config_new_by_mode (GDK_GL_MODE_RGB   |
                                            GDK_GL_MODE_DEPTH);
      if (glconfig == NULL)
        {
          g_print ("*** No appropriate OpenGL-capable visual found.\n");
          exit (1);
        }
    }

  /*
   * Top-level window.
   */

  window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
  gtk_window_set_title (GTK_WINDOW (window), "button");

  /* Get automatically redrawn if any of their children changed allocation. */
  gtk_container_set_reallocate_redraws (GTK_CONTAINER (window), TRUE);
  /* Set border width. */
  gtk_container_set_border_width (GTK_CONTAINER (window), 10);

  g_signal_connect (G_OBJECT (window), "delete_event",
                    G_CALLBACK (gtk_main_quit), NULL);

  /*
   * Toggle button which contains an OpenGL scene.
   */

  button = create_gl_toggle_button (glconfig);
  gtk_widget_show (button);
  gtk_container_add (GTK_CONTAINER (window), button);

  /*
   * Show window.
   */

  gtk_widget_show (window);

  /*
   * Main loop.
   */

  gtk_main ();

  return 0;
}