Scrolled window problem

hi all,
           I am using GTK2.0 for my application. i have a list box which i want to scroll. i used scrolled window (viewport)for that. but its not working.
my code is like this,
int main (int argc, char *argv[])
/* GtkWidget is the storage type for widgets */
GtkWidget *window;
GtkWidget *listbox;
GtkWidget *item;
GtkWidget *vbox;
GtkWidget *vbox1;
GtkWidget *scroll;
GtkWidget *button;
GtkWidget *frame;
GtkWidget *label;
gint i = 0, j = 0;
gchar *p[100];
DIR *dp;
stopFlg = 0;
MpengineStatus mpStatus_s;
struct dirent *ep;
/* This is the Window color code (blue) */
GdkColor col = {0, 0x0000, 0x0000, 0xffff};
GtkStyle *style;
pthread_t athread;
pthread_t bthread;
pthread_t cthread;
MpengineRet mpengine_ret;
/* Opening mediafiles directory and copied to Buffer */
dp = opendir ("./mediafiles");
if (dp != NULL) {
while (ep = readdir (dp)) {
//puts (ep->d_name);
p[i] = (char *)malloc (50);
strcpy (p[i], ep->d_name);
perror ("could not open directory\n");
/* calling MPEngine */
/* This is initialization of GTK */
gtk_init (&argc, &argv);
gtk_rc_parse ("pkm");
/* Creating new Window, setting title and size */
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
gtk_window_set_title (GTK_WINDOW (window), "PlayList");
gtk_window_set_default_size (GTK_WINDOW (window), 320, 240);
gtk_widget_set_usize (window, 320, 240);
gtk_widget_set_size_request (window, 320, 240);
gtk_widget_set_name (window, "main_window");
/* Creating Listbox (playlist) & setting selection mode */
listbox = gtk_list_new ();
gtk_widget_set_name (listbox, "playlist");
gtk_list_set_selection_mode (GTK_LIST (listbox), GTK_SELECTION_BROWSE);
vbox = gtk_vbox_new (FALSE, 0);
scroll = gtk_scrolled_window_new (NULL, NULL);
frame = gtk_frame_new (NULL);
label = gtk_label_new ("Press S17 To Exit");
gtk_widget_set_name (label, "exit_label");
gtk_container_add (GTK_CONTAINER (frame), label);
gtk_label_set_markup (GTK_LABEL (label), "<b>Press S17 To Exit</b>");
j = i;
/* Adding files to the Listbox */
for (i = 2; i < j; i++) {
item = gtk_list_item_new_with_label (p[i]);
gtk_container_add (GTK_CONTAINER (listbox), item);
gtk_signal_connect (GTK_OBJECT (item), "toggle",
GTK_SIGNAL_FUNC (mpengine_opensource), p[i]);
gtk_signal_connect (GTK_OBJECT (item), "toggle",
GTK_SIGNAL_FUNC (listitem_selected), p[i]);
/* These are the signals */
gtk_signal_connect (GTK_OBJECT (window), "delete_event",
GTK_SIGNAL_FUNC (gtk_main_quit), NULL);
/*style = gtk_widget_get_style (window) ;
style->bg[GTK_STATE_NORMAL] = col;
gtk_widget_set_style (window, style);*/
gtk_scrolled_window_add_with_viewport (GTK_SCROLLED_WINDOW (scroll), listbox);
gtk_container_add (GTK_CONTAINER (vbox), scroll);
//gtk_box_pack_start (GTK_BOX (vbox), scroll,TRUE, TRUE, 0);
//gtk_box_pack_start (GTK_BOX (vbox), listbox, FALSE, TRUE, 0);
gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, TRUE, 0);
gtk_widget_set_usize (vbox, 320, 240);
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scroll),
//gtk_scrolled_window_add_with_viewport (GTK_SCROLLED_WINDOW (scroll), listbox);
gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (scroll), GTK_SHADOW_OUT);
/*button = gtk_button_new_with_label ("Close");
gtk_container_add (GTK_CONTAINER (vbox), button);
gtk_box_pack_start (GTK_BOX(GTK_DIALOG (window)->action_area),button, TRUE, TRUE, 0);*/
gtk_container_add (GTK_CONTAINER (window), vbox);
/* Showing all widgets at the end */
gtk_widget_show_all (window).
Please help me.

Talk is cheap. Use Yahoo! Messenger to make PC-to-Phone calls. Great rates starting at 1¢/min.

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