Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 5998275
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T00:22:58+00:00 2026-05-23T00:22:58+00:00

I am trying to write the interface for my music manager using GTK+. The

  • 0

I am trying to write the interface for my music manager using GTK+. The program was compiled successfully. However, when I executed it, the machine returned errors:

(dingo_draft:6462): Gtk-WARNING **: Can't set a parent on widget which has a parent


(dingo_draft:6462): Gtk-CRITICAL **: gtk_widget_realize: assertion `GTK_WIDGET_ANCHORED (widget) || GTK_IS_INVISIBLE (widget)' failed
**
Gtk:ERROR:/build/buildd/gtk+2.0-2.20.1/gtk/gtkwidget.c:8760:gtk_widget_real_map: assertion failed: (gtk_widget_get_realized (widget))
Aborted

Here is the source code of the program. Please note that this is just the interface written in GTK+. I did not add any signals in yet. I think there might be some problems with the GTK+ functions, but I could not locate where the errors occured:

/* This is the interface design draft for the media player
/* This does not include the signals for widgets. Just a plain draft */

#include <gtk/gtk.h>
#include <gst/gst.h>

int main(int argc, char *argv[]) {
  /* Initialize gtk+ & gstreamer */
  gtk_init(&argc, &argv);
  gst_init(&argc, &argv);

  /* Create mainwindow (mainwindow) */
  GtkWidget *mainwindow;

  mainwindow = gtk_window_new(GTK_WINDOW_TOPLEVEL);
  gtk_window_set_title(GTK_WINDOW(mainwindow), "Music Manager");

  /* Create the vbox containing searchbox & song list (treevbox) */
  GtkWidget *searchbox, *treesong, *scrollsong, *treevbox;
  /* GtkWidget *colname, *coltime; */
  GtkCellRenderer *namerender, *timerender;

  treesong = gtk_tree_view_new();
  gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(treesong), FALSE);

  namerender = gtk_cell_renderer_text_new();
  gtk_tree_view_insert_column_with_attributes(GTK_TREE_VIEW(treesong), -1, "Songs", namerender, "text", 0, NULL);

  timerender = gtk_cell_renderer_text_new();
  gtk_tree_view_insert_column_with_attributes(GTK_TREE_VIEW(treesong), -1, "Time", timerender, "text", 1, NULL);

  scrollsong = gtk_scrolled_window_new(NULL, NULL);
  gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrollsong), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);

  gtk_container_add(GTK_CONTAINER(scrollsong), treesong);

  searchbox = gtk_entry_new();

  treevbox = gtk_vbox_new(TRUE, 0);
  gtk_box_pack_start_defaults(GTK_BOX(treevbox), searchbox);
  gtk_box_pack_start_defaults(GTK_BOX(treevbox), scrollsong);

  /* Create the song info section (infohbox) */
  GtkWidget *songname, *songinfo, *coverart;
  GtkWidget *infohbox, *imagevbox;

  coverart = gtk_image_new_from_file("music-notes.png");
  songname = gtk_label_new("<i>Song Name</i>");
  songinfo = gtk_label_new("<b>Artist:</b> \n <b>Track</b> \n <b>Album</b> \n <b>Year</b> \n <b>Genre</b> \n <b>Rating</b>");

  infohbox = gtk_hbox_new(TRUE, 0);
  imagevbox = gtk_vbox_new(TRUE, 0);

  gtk_box_pack_start_defaults(GTK_BOX(imagevbox), coverart);
  gtk_box_pack_start_defaults(GTK_BOX(imagevbox), songname);
  gtk_box_pack_start_defaults(GTK_BOX(infohbox), imagevbox);
  gtk_box_pack_start_defaults(GTK_BOX(infohbox), songinfo);

  /* Create drawing area for video display (previewarea) */
  GtkWidget *previewarea;

  previewarea = gtk_drawing_area_new();
  gtk_widget_set_size_request(previewarea, 300, 200);

  /* Create actions tree view (ltreeview) */
  enum {
    COL_ICON = 0,
    COL_ACTION,
    NUM_COLS
  };

  GtkCellRenderer *lrenderer;
  GtkTreeModel *lmodel;
  GtkWidget *ltreeview;
  GtkListStore *lliststore;
  GtkTreeIter liter;

  ltreeview = gtk_tree_view_new();

  lrenderer = gtk_cell_renderer_pixbuf_new();
  gtk_tree_view_insert_column_with_attributes(GTK_TREE_VIEW(ltreeview), -1, "Icon", lrenderer, "pixbuf", COL_ICON, NULL);

  lrenderer = gtk_cell_renderer_text_new();
  gtk_tree_view_insert_column_with_attributes(GTK_TREE_VIEW(ltreeview), -1, "Actions", lrenderer, "text", COL_ACTION, NULL);

  lliststore = gtk_list_store_new(NUM_COLS, GDK_TYPE_PIXBUF, G_TYPE_STRING);

  gtk_list_store_append(lliststore, &liter);
  gtk_list_store_set(lliststore, &liter, COL_ICON, gdk_pixbuf_new_from_file("now-playing.png", NULL), COL_ACTION, "Now Playing", -1);

  gtk_list_store_append(lliststore, &liter);
  gtk_list_store_set(lliststore, &liter, COL_ICON, gdk_pixbuf_new_from_file("music.png", NULL), COL_ACTION, "Music", -1);

  gtk_list_store_append(lliststore, &liter);
  gtk_list_store_set(lliststore, &liter, COL_ICON, gdk_pixbuf_new_from_file("video.png", NULL), COL_ACTION, "Videos", -1);

  gtk_list_store_append(lliststore, &liter);
  gtk_list_store_set(lliststore, &liter, COL_ICON, gdk_pixbuf_new_from_file("playlist.png", NULL), COL_ACTION, "Playlists", -1);

  lmodel = GTK_TREE_MODEL(lliststore);

  gtk_tree_view_set_model(GTK_TREE_VIEW(ltreeview), lmodel);

  /* g_object_unref(lmodel); */

  /* Create the top control bar (controlhbox) */
  GtkWidget *prevbutton, *nextbutton, *hscale, *cursong;
  GtkWidget *curpos, *duration, *volumebutton, *playbutton;
  GtkAdjustment *progress, *volumeadj;
  GtkWidget *buttonhbox, *proghbox, *infovbox, *controlhbox;

  prevbutton = gtk_button_new();
  gtk_button_set_image(GTK_BUTTON(prevbutton), gtk_image_new_from_stock(GTK_STOCK_MEDIA_PREVIOUS, GTK_ICON_SIZE_SMALL_TOOLBAR));

  playbutton = gtk_button_new();
  gtk_button_set_image(GTK_BUTTON(playbutton), gtk_image_new_from_stock(GTK_STOCK_MEDIA_PLAY, GTK_ICON_SIZE_DND));

  nextbutton = gtk_button_new();
  gtk_button_set_image(GTK_BUTTON(nextbutton), gtk_image_new_from_stock(GTK_STOCK_MEDIA_PLAY, GTK_ICON_SIZE_SMALL_TOOLBAR));

  progress = GTK_ADJUSTMENT(gtk_adjustment_new(0.00, 0.00, 0.00, 0.00, 0.00, 0.00));
  hscale = gtk_hscale_new(progress);
  gtk_scale_set_draw_value(GTK_SCALE(hscale), FALSE);
  gtk_widget_set_size_request(hscale, 500, NULL);

  cursong = gtk_label_new("Song's Name");
  curpos = gtk_label_new("0:00");
  duration = gtk_label_new("0:00");

  volumebutton = gtk_volume_button_new();
  volumeadj = GTK_ADJUSTMENT(gtk_adjustment_new(0.70, 0.00, 1.00, 0.01, 0.00, 0.00));
  gtk_scale_button_set_adjustment(GTK_SCALE_BUTTON(volumebutton), volumeadj);
  gtk_widget_set_size_request(volumebutton, 32, 32);

  buttonhbox = gtk_hbox_new(TRUE, 0);
  gtk_box_pack_start_defaults(GTK_BOX(buttonhbox), prevbutton);
  gtk_box_pack_start_defaults(GTK_BOX(buttonhbox), playbutton);
  gtk_box_pack_start_defaults(GTK_BOX(buttonhbox), nextbutton);

  proghbox = gtk_hbox_new(TRUE, 0);
  gtk_box_pack_start_defaults(GTK_BOX(proghbox), curpos);
  gtk_box_pack_start_defaults(GTK_BOX(proghbox), hscale);
  gtk_box_pack_start_defaults(GTK_BOX(proghbox), duration);

  controlhbox = gtk_hbox_new(TRUE, 0);
  gtk_box_pack_start_defaults(GTK_BOX(controlhbox), buttonhbox);
  gtk_box_pack_start_defaults(GTK_BOX(controlhbox), proghbox);
  gtk_box_pack_start_defaults(GTK_BOX(controlhbox), volumebutton);

  /* Create panes (tophpaned) and pack widgets into this (tophpaned)*/
  GtkWidget *tophpaned, *subhpaned, *vpaned;

  vpaned = gtk_vpaned_new();
  gtk_paned_add1(GTK_PANED(vpaned), songinfo);
  gtk_paned_add2(GTK_PANED(vpaned), previewarea);

  subhpaned = gtk_hpaned_new();
  gtk_paned_pack1(GTK_PANED(subhpaned), vpaned, TRUE, TRUE);
  gtk_paned_pack2(GTK_PANED(subhpaned), treevbox, TRUE, TRUE);

  tophpaned = gtk_hpaned_new();
  gtk_paned_pack1(GTK_PANED(tophpaned), ltreeview, TRUE, TRUE);
  gtk_paned_pack2(GTK_PANED(tophpaned), subhpaned, TRUE, TRUE);

  /* Create an topvbox to pack all the above stuffs in, */
  /* then add topvbox to window */
  GtkWidget *topvbox;

  topvbox = gtk_vbox_new(TRUE, 0);
  gtk_box_pack_start_defaults(GTK_BOX(topvbox), controlhbox);
  gtk_box_pack_start_defaults(GTK_BOX(topvbox), tophpaned);

  gtk_container_add(GTK_CONTAINER(mainwindow), topvbox);

  /* Show all widgets & draw the interface */ 
  gtk_widget_show_all(mainwindow);

  gtk_main();

  return 0;
}

Thank you for answering my question! I appreciate your helps!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T00:22:59+00:00Added an answer on May 23, 2026 at 12:22 am

    You are trying to put songinfo into two different containers: into infohbox and into vpaned.

    As Havoc says, gdb can help you find the exact code that is giving you a warning. I can offer two additional suggestions:

    • Build your interface in Glade. This will help you to see what’s going on with it as you build it. It will also make it more maintainable, and help you avoid these kinds of errors.
    • Before you ask a question on Stack Overflow with a big code dump, try and make a minimal program that reproduces the problem. Often you will have solved the problem yourself by the time you have done this.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to write an interface around my program (using qt). Basically I have
I am trying to write a small media player using GTK+ and GStreamer and
I am trying to write an interface between RSPEC (ruby flavoured BDD) and a
I'm trying to write a script to retrieve a WOEID and interface with the
I'm trying to write a dead-simple interface for an IRC library, like so: import
I'm trying to write a simple web interface to allow users to install one
Trying to write Unit test for Silverlight 4.0 using Moq 4.0.10531.7 public delegate void
I trying to write an application that has a collection of students using different
I'm trying to write a jquery interface which requires me to pass a couple
I am trying to write a MATLAB GUI that uses the XBee-API interface to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.