Notebook and listbox problems.



Hi Developing GURUS,

I have been struggling with this little teaser for a while, to no
avail.....

The problem...

I want to place 2 listboxes into a frame of a Notebook page. I then want
to attach a list to that listbox and be able to move elements from the
left list into the right list and vica versa...

The program list appears at the end of this message (compiled with
command line 

gcc -o testnotebook -L/usr/X11R6.1/lib/ -lgtk -lm -lXext main.c

)

Basically this code does exactly the same as the code I have been trying
to write. When I try and place a listbox in anything but the first
frame  of a Notebook, all I get is the following output on the command
line. The scrolled window and list in the first frame is OK. (Listbox1)
but the second one (imaginatively called Listbox2) doesn't get created
properly!.

This output is generated during the creation of the second listbox!

>** WARNING **: file gdkwindow.c: line 412 (gdk_window_move_resize): >"window != NULL"

I can't find why this error is generated in the first place!

Can anyone help with this, please......... I can't finish my GIMP
plug-in until I sort this out - GIF/(whatever follows GIF) animator!.

Another thing, and I haven't checked seen as though I've just knocked
this together, is why does the "close" button simply destroy itself and
not the window ?????? - probably a typo, but I can't see it immediately.


Thanks guys,

Mike



-- 
"We've been looking for home and keep finding the sandpit,
 Maybe if we look for the sandpit we'll find home."
 	- Winnie The Pooh


/*
  test program to check for the creation of a list box within a Notebook
page frame.
  */
#include <stdio.h>
#include <stdlib.h>
#include "gtk/gtk.h"

void create_main_window();
void close_callback(GtkWidget *widget, gpointer data);

void main(int argc, char **argv) {
  
  gtk_init(&argc, &argv);
  
  create_main_window();

  gtk_main();

  return;
}

void create_main_window() {
  GtkWidget *window;
  GtkWidget *hbox;
  GtkWidget *vbox;
  GtkWidget *button;
  GtkWidget *Notebook;
  GtkWidget *frame, *label;
  GtkWidget *list, *listbox;

  window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
  gtk_widget_set_name(window, "Notebook");
  gtk_widget_set_uposition(window, 20, 20);
  
  vbox = gtk_vbox_new(FALSE, 0);
  gtk_container_add(GTK_CONTAINER(window), vbox);
  gtk_widget_show(vbox);

  hbox = gtk_hbox_new(FALSE, 0);
  gtk_container_border_width(GTK_CONTAINER(hbox), 10);
  gtk_box_pack_start(GTK_BOX(vbox), hbox, TRUE, TRUE, 0);
  gtk_widget_show(hbox);
  
  /* add close button - well...... */
  button = gtk_button_new_with_label("Close");
  /* This doesn't seem to work either..... must have typed wrong  */
  gtk_signal_connect(GTK_OBJECT(button), "clicked",
(GtkSignalFunc)    						gtk_widget_destroy, GTK_OBJECT(window));
  gtk_box_pack_start(GTK_BOX(vbox), button, TRUE, TRUE, 0);
  gtk_widget_show(button);

  /* lets have the Notebook */
  Notebook = gtk_notebook_new();
  gtk_notebook_set_tab_pos(GTK_NOTEBOOK(Notebook), GTK_POS_TOP);
  gtk_box_pack_start(GTK_BOX(hbox), Notebook, TRUE, TRUE, 0);
  gtk_widget_show(Notebook);
  
  /* Add a page with a listbox to the notebook. */
  frame = gtk_frame_new("listbox - no box");
  gtk_container_border_width(GTK_CONTAINER(frame), 10);
  gtk_widget_set_usize(frame, 200, 150);
  gtk_widget_show(frame);
  
  listbox = gtk_scrolled_window_new(NULL, NULL);
  gtk_widget_set_usize(listbox, 180, 120);
  gtk_container_add(GTK_CONTAINER(frame), listbox);

  list = gtk_list_new();
  gtk_container_add(GTK_CONTAINER(listbox), list);
  gtk_list_set_selection_mode(GTK_LIST(list), GTK_SELECTION_BROWSE);
  gtk_widget_show(list);
  gtk_widget_show(listbox);

  label = gtk_label_new("Listbox1");
  
  gtk_notebook_append_page (GTK_NOTEBOOK (Notebook), frame, label);
  /* Add a page with a listbox to the notebook. */
  frame = gtk_frame_new("listbox - another one");
  gtk_container_border_width(GTK_CONTAINER(frame), 10);
  gtk_widget_set_usize(frame, 200, 150);
  gtk_widget_show(frame);
  
  listbox = gtk_scrolled_window_new(NULL, NULL);
  gtk_widget_set_usize(listbox, 180, 120);
  gtk_container_add(GTK_CONTAINER(frame), listbox);

  list = gtk_list_new();
  gtk_container_add(GTK_CONTAINER(listbox), list);
  gtk_list_set_selection_mode(GTK_LIST(list), GTK_SELECTION_BROWSE);
  gtk_widget_show(list);
  gtk_widget_show(listbox);

  label = gtk_label_new("Listbox2");
  
  gtk_notebook_append_page (GTK_NOTEBOOK (Notebook), frame, label);


  gtk_widget_show(window);

}



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