[gnome-love] How many GnomeApp windows I can have in one application?



Hello list, 

I am wondering if GnomeApp window can only be used as a top level
window. If I create a GnomeApp window from main, by clicking a menu
item, a FileSelection widget pops up, when a file is chosen, I need
another GnomeApp window... Here is the problem: I get segmentation
fault always!

In gnome_app_new(gchar *app_id, gchar *title), I used different app_id
in these two calls. Since app_id should be the same as the app_id
passed to gnome_init(), I have to call gnome_init() in the function
calling to create the second GnomeApp window. I doubt if it is right to
do so or it is a potential trouble-maker. 

I traced the function making the second GnomeApp window, I found it is
the   "gnome_app_*" that cause the problem. Code follows: ( Sorry, it
is a little bit too long.)

/* create the project editor window */
gint
create_prj_editor(GNode *node)
{
  GtkWidget *prj_edt;
  GtkWidget *w1, *w2;
  GtkWidget *box;
  GtkWidget *label1, *label2;
  Project *project;
  gchar *text[2];
  gchar *titles[] = {"Name", "Type"};

  /* create project editor window */
  prj_edt = gnome_app_new("Project_Editor",
                      "Project_Editor");


  gtk_signal_connect(GTK_OBJECT(prj_edt), "delete_event", 
                     GTK_SIGNAL_FUNC(gtk_widget_destroy),
                     NULL);
  /* set default size for this window */
  gtk_widget_set_usize(prj_edt, 600, 370.8);

  /* add menus to the main window */
  gnome_app_create_menus(GNOME_APP(prj_edt), prj_menu);

  g_print("pass through menu creation\n");

  /* set up status bar */
  w1 = gnome_appbar_new(FALSE, TRUE, GNOME_PREFERENCES_USER);
  
  g_print("w1 created\n");

  /************Can't go through, I have to comment out*********
  gnome_app_set_statusbar(GNOME_APP(prj_edit), w1);
  
  gnome_app_install_menu_hints(GNOME_APP(prj_edit), prj_menu);*/

  /* get the passed project information */
  project = node->data;

  text[0] = g_strdup(project->name);
  text[1] = g_strdup(project->type);

  /* create a vbox to pack stuffs */
  box = gtk_vbox_new(FALSE, 10);

  /* packed two labels into vbox , some omissions here*/
  
  /* make a scrolled window for clist */
  w2 = gtk_scrolled_window_new(NULL, NULL);

  clist = gtk_clist_new_with_titles(2, titles);

  /* when a selection is made, we connect signal to get_selection */
  gtk_signal_connect(GTK_OBJECT(clist), "select_row",
                     GTK_SIGNAL_FUNC(prj_get_selection),
                     NULL);

  /* add clist to scrolled window */
  gtk_container_add(GTK_CONTAINER(w2), clist);

  /* pack scrolled window into vbox */
  gtk_box_pack_start(GTK_BOX(box), w2, TRUE, TRUE, 0);

  g_print("almost reach the end\n");

  /**************Can't get through********************************/
  gnome_app_set_contents(GNOME_APP(prj_edit), w2);

  /* show the project editor */
  gtk_widget_show_all(prj_edt);

  return GPOINTER_TO_INT(prj_edt);
}

Does anyone see where the problem is? Thanks a lot. 

regards,

Yuan Peng



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]