2 Unix SMB/Netbios implementation.
4 SMB client GTK+ tree-based application
5 Copyright (C) Andrew Tridgell 1998
6 Copyright (C) Richard Sharpe 2001
7 Copyright (C) John Terpstra 2001
9 This program is free software; you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation; either version 3 of the License, or
12 (at your option) any later version.
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
19 You should have received a copy of the GNU General Public License
20 along with this program. If not, see <http://www.gnu.org/licenses/>.
23 /* example-gtk+ application, ripped off from the gtk+ tree.c sample */
30 #include "libsmbclient.h"
32 static GtkWidget
*clist
;
36 guint32 type
; /* Type of tree item, an SMBC_TYPE */
37 char name
[256]; /* May need to change this later */
41 void error_message(gchar
*message
) {
43 GtkWidget
*dialog
, *label
, *okay_button
;
45 /* Create the widgets */
47 dialog
= gtk_dialog_new();
48 gtk_window_set_modal(GTK_WINDOW(dialog
), TRUE
);
49 label
= gtk_label_new (message
);
50 okay_button
= gtk_button_new_with_label("Okay");
52 /* Ensure that the dialog box is destroyed when the user clicks ok. */
54 gtk_signal_connect_object (GTK_OBJECT (okay_button
), "clicked",
55 GTK_SIGNAL_FUNC (gtk_widget_destroy
),
57 gtk_container_add (GTK_CONTAINER (GTK_DIALOG(dialog
)->action_area
),
60 /* Add the label, and show everything we've added to the dialog. */
62 gtk_container_add (GTK_CONTAINER (GTK_DIALOG(dialog
)->vbox
),
64 gtk_widget_show_all (dialog
);
68 * We are given a widget, and we want to retrieve its URL so we
69 * can do a directory listing.
71 * We walk back up the tree, picking up pieces until we hit a server or
72 * workgroup type and return a path from there
75 static char path_string
[1024];
77 char *get_path(GtkWidget
*item
)
81 char *comps
[1024]; /* We keep pointers to the components here */
82 int i
= 0, j
, level
,type
;
84 /* Walk back up the tree, getting the private data */
86 level
= GTK_TREE(item
->parent
)->level
;
88 /* Pick up this item's component info */
90 pd
= (struct tree_data
*)gtk_object_get_user_data(GTK_OBJECT(item
));
92 comps
[i
++] = pd
->name
;
95 while (level
> 0 && type
!= SMBC_SERVER
&& type
!= SMBC_WORKGROUP
) {
97 /* Find the parent and extract the data etc ... */
99 p
= GTK_WIDGET(p
->parent
);
100 p
= GTK_WIDGET(GTK_TREE(p
)->tree_owner
);
102 pd
= (struct tree_data
*)gtk_object_get_user_data(GTK_OBJECT(p
));
104 level
= GTK_TREE(item
->parent
)->level
;
106 comps
[i
++] = pd
->name
;
112 * Got a list of comps now, should check that we did not hit a workgroup
113 * when we got other things as well ... Later
115 * Now, build the path
118 snprintf(path_string
, sizeof(path_string
), "smb:/");
120 for (j
= i
- 1; j
>= 0; j
--) {
122 strncat(path_string
, "/", sizeof(path_string
) - strlen(path_string
));
123 strncat(path_string
, comps
[j
], sizeof(path_string
) - strlen(path_string
));
127 fprintf(stdout
, "Path string = %s\n", path_string
);
133 struct tree_data
*make_tree_data(guint32 type
, const char *name
)
135 struct tree_data
*p
= (struct tree_data
*)malloc(sizeof(struct tree_data
));
140 strncpy(p
->name
, name
, sizeof(p
->name
));
148 /* Note that this is called every time the user clicks on an item,
149 whether it is already selected or not. */
150 static void cb_select_child (GtkWidget
*root_tree
, GtkWidget
*child
,
153 gint dh
, err
, dirlen
;
155 struct smbc_dirent
*dirp
;
157 char path
[1024], path1
[1024];
159 g_print ("select_child called for root tree %p, subtree %p, child %p\n",
160 root_tree
, subtree
, child
);
162 /* Now, figure out what it is, and display it in the clist ... */
164 gtk_clist_clear(GTK_CLIST(clist
)); /* Clear the CLIST */
166 /* Now, get the private data for the subtree */
168 strncpy(path
, get_path(child
), 1024);
170 if ((dh
= smbc_opendir(path
)) < 0) { /* Handle error */
172 g_print("cb_select_child: Could not open dir %s, %s\n", path
,
181 while ((err
= smbc_getdents(dh
, (struct smbc_dirent
*)dirbuf
,
182 sizeof(dirbuf
))) != 0) {
186 g_print("cb_select_child: Could not read dir %s, %s\n", path
,
195 dirp
= (struct smbc_dirent
*)dirbuf
;
198 gchar col1
[128], col2
[128], col3
[128], col4
[128];
199 gchar
*rowdata
[4] = {col1
, col2
, col3
, col4
};
201 dirlen
= dirp
->dirlen
;
203 /* Format each of the items ... */
205 strncpy(col1
, dirp
->name
, 128);
207 col2
[0] = col3
[0] = col4
[0] = (char)0;
209 switch (dirp
->smbc_type
) {
217 strncpy(col2
, (dirp
->comment
?dirp
->comment
:""), 128);
221 case SMBC_FILE_SHARE
:
223 strncpy(col2
, (dirp
->comment
?dirp
->comment
:""), 128);
227 case SMBC_PRINTER_SHARE
:
229 strncpy(col2
, (dirp
->comment
?dirp
->comment
:""), 128);
232 case SMBC_COMMS_SHARE
:
243 /* Get stats on the file/dir and see what we have */
245 if ((strcmp(dirp
->name
, ".") != 0) &&
246 (strcmp(dirp
->name
, "..") != 0)) {
248 strncpy(path1
, path
, sizeof(path1
));
249 strncat(path1
, "/", sizeof(path
) - strlen(path
));
250 strncat(path1
, dirp
->name
, sizeof(path
) - strlen(path
));
252 if (smbc_stat(path1
, &st1
) < 0) {
254 if (errno
!= EBUSY
) {
256 g_print("cb_select_child: Could not stat file %s, %s\n", path1
,
266 strncpy(col2
, "Device or resource busy", sizeof(col2
));
271 /* Now format each of the relevant things ... */
273 snprintf(col2
, sizeof(col2
), "%c%c%c%c%c%c%c%c%c(%0X)",
274 (st1
.st_mode
&S_IRUSR
?'r':'-'),
275 (st1
.st_mode
&S_IWUSR
?'w':'-'),
276 (st1
.st_mode
&S_IXUSR
?'x':'-'),
277 (st1
.st_mode
&S_IRGRP
?'r':'-'),
278 (st1
.st_mode
&S_IWGRP
?'w':'-'),
279 (st1
.st_mode
&S_IXGRP
?'x':'-'),
280 (st1
.st_mode
&S_IROTH
?'r':'-'),
281 (st1
.st_mode
&S_IWOTH
?'w':'-'),
282 (st1
.st_mode
&S_IXOTH
?'x':'-'),
284 snprintf(col3
, sizeof(col3
), "%u", st1
.st_size
);
285 snprintf(col4
, sizeof(col4
), "%s", ctime(&st1
.st_mtime
));
296 gtk_clist_append(GTK_CLIST(clist
), rowdata
);
298 dirp
= (struct smbc_dirent
*) ((char *) dirp
+ dirlen
);
307 /* Note that this is never called */
308 static void cb_unselect_child( GtkWidget
*root_tree
,
312 g_print ("unselect_child called for root tree %p, subtree %p, child %p\n",
313 root_tree
, subtree
, child
);
316 /* for all the GtkItem:: and GtkTreeItem:: signals */
317 static void cb_itemsignal( GtkWidget
*item
,
320 GtkWidget
*real_tree
, *aitem
, *subtree
;
323 gint dh
, err
, dirlen
, level
;
325 struct smbc_dirent
*dirp
;
327 label
= GTK_LABEL (GTK_BIN (item
)->child
);
328 /* Get the text of the label */
329 gtk_label_get (label
, &name
);
331 level
= GTK_TREE(item
->parent
)->level
;
333 /* Get the level of the tree which the item is in */
334 g_print ("%s called for item %s->%p, level %d\n", signame
, name
,
335 item
, GTK_TREE (item
->parent
)->level
);
337 real_tree
= GTK_TREE_ITEM_SUBTREE(item
); /* Get the subtree */
339 if (strncmp(signame
, "expand", 6) == 0) { /* Expand called */
342 if ((dh
= smbc_opendir(get_path(item
))) < 0) { /* Handle error */
345 g_print("cb_itemsignal: Could not open dir %s, %s\n", get_path(item
),
348 snprintf(errmsg
, sizeof(errmsg
), "cb_itemsignal: Could not open dir %s, %s\n", get_path(item
), strerror(errno
));
350 error_message(errmsg
);
352 /* gtk_main_quit();*/
358 while ((err
= smbc_getdents(dh
, (struct smbc_dirent
*)dirbuf
,
359 sizeof(dirbuf
))) != 0) {
361 if (err
< 0) { /* An error, report it */
364 g_print("cb_itemsignal: Could not read dir smbc://, %s\n",
367 snprintf(errmsg
, sizeof(errmsg
), "cb_itemsignal: Could not read dir smbc://, %s\n", strerror(errno
));
369 error_message(errmsg
);
371 /* gtk_main_quit();*/
377 dirp
= (struct smbc_dirent
*)dirbuf
;
380 struct tree_data
*my_data
;
382 dirlen
= dirp
->dirlen
;
384 my_data
= make_tree_data(dirp
->smbc_type
, dirp
->name
);
388 g_print("Could not allocate space for tree_data: %s\n",
396 aitem
= gtk_tree_item_new_with_label(dirp
->name
);
398 /* Connect all GtkItem:: and GtkTreeItem:: signals */
399 gtk_signal_connect (GTK_OBJECT(aitem
), "select",
400 GTK_SIGNAL_FUNC(cb_itemsignal
), "select");
401 gtk_signal_connect (GTK_OBJECT(aitem
), "deselect",
402 GTK_SIGNAL_FUNC(cb_itemsignal
), "deselect");
403 gtk_signal_connect (GTK_OBJECT(aitem
), "toggle",
404 GTK_SIGNAL_FUNC(cb_itemsignal
), "toggle");
405 gtk_signal_connect (GTK_OBJECT(aitem
), "expand",
406 GTK_SIGNAL_FUNC(cb_itemsignal
), "expand");
407 gtk_signal_connect (GTK_OBJECT(aitem
), "collapse",
408 GTK_SIGNAL_FUNC(cb_itemsignal
), "collapse");
409 /* Add it to the parent tree */
410 gtk_tree_append (GTK_TREE(real_tree
), aitem
);
412 gtk_widget_show (aitem
);
414 gtk_object_set_user_data(GTK_OBJECT(aitem
), (gpointer
)my_data
);
416 fprintf(stdout
, "Added: %s, len: %u\n", dirp
->name
, dirlen
);
418 if (dirp
->smbc_type
!= SMBC_FILE
&&
419 dirp
->smbc_type
!= SMBC_IPC_SHARE
&&
420 (strcmp(dirp
->name
, ".") != 0) &&
421 (strcmp(dirp
->name
, "..") !=0)){
423 subtree
= gtk_tree_new();
424 gtk_tree_item_set_subtree(GTK_TREE_ITEM(aitem
), subtree
);
426 gtk_signal_connect(GTK_OBJECT(subtree
), "select_child",
427 GTK_SIGNAL_FUNC(cb_select_child
), real_tree
);
428 gtk_signal_connect(GTK_OBJECT(subtree
), "unselect_child",
429 GTK_SIGNAL_FUNC(cb_unselect_child
), real_tree
);
433 dirp
= (struct smbc_dirent
*) ((char *) dirp
+ dirlen
);
443 else if (strncmp(signame
, "collapse", 8) == 0) {
444 GtkWidget
*subtree
= gtk_tree_new();
446 gtk_tree_remove_items(GTK_TREE(real_tree
), GTK_TREE(real_tree
)->children
);
448 gtk_tree_item_set_subtree(GTK_TREE_ITEM(item
), subtree
);
450 gtk_signal_connect (GTK_OBJECT(subtree
), "select_child",
451 GTK_SIGNAL_FUNC(cb_select_child
), real_tree
);
452 gtk_signal_connect (GTK_OBJECT(subtree
), "unselect_child",
453 GTK_SIGNAL_FUNC(cb_unselect_child
), real_tree
);
459 static void cb_selection_changed( GtkWidget
*tree
)
463 g_print ("selection_change called for tree %p\n", tree
);
464 g_print ("selected objects are:\n");
466 i
= GTK_TREE_SELECTION(tree
);
472 /* Get a GtkWidget pointer from the list node */
473 item
= GTK_WIDGET (i
->data
);
474 label
= GTK_LABEL (GTK_BIN (item
)->child
);
475 gtk_label_get (label
, &name
);
476 g_print ("\t%s on level %d\n", name
, GTK_TREE
477 (item
->parent
)->level
);
483 * Expand or collapse the whole network ...
485 static void cb_wholenet(GtkWidget
*item
, gchar
*signame
)
487 GtkWidget
*real_tree
, *aitem
, *subtree
;
490 gint dh
, err
, dirlen
;
492 struct smbc_dirent
*dirp
;
494 label
= GTK_LABEL (GTK_BIN (item
)->child
);
495 gtk_label_get (label
, &name
);
496 g_print ("%s called for item %s->%p, level %d\n", signame
, name
,
497 item
, GTK_TREE (item
->parent
)->level
);
499 real_tree
= GTK_TREE_ITEM_SUBTREE(item
); /* Get the subtree */
501 if (strncmp(signame
, "expand", 6) == 0) { /* Expand called */
503 if ((dh
= smbc_opendir("smb://")) < 0) { /* Handle error */
505 g_print("cb_wholenet: Could not open dir smbc://, %s\n",
514 while ((err
= smbc_getdents(dh
, (struct smbc_dirent
*)dirbuf
,
515 sizeof(dirbuf
))) != 0) {
517 if (err
< 0) { /* An error, report it */
519 g_print("cb_wholenet: Could not read dir smbc://, %s\n",
528 dirp
= (struct smbc_dirent
*)dirbuf
;
531 struct tree_data
*my_data
;
533 dirlen
= dirp
->dirlen
;
535 my_data
= make_tree_data(dirp
->smbc_type
, dirp
->name
);
537 aitem
= gtk_tree_item_new_with_label(dirp
->name
);
539 /* Connect all GtkItem:: and GtkTreeItem:: signals */
540 gtk_signal_connect (GTK_OBJECT(aitem
), "select",
541 GTK_SIGNAL_FUNC(cb_itemsignal
), "select");
542 gtk_signal_connect (GTK_OBJECT(aitem
), "deselect",
543 GTK_SIGNAL_FUNC(cb_itemsignal
), "deselect");
544 gtk_signal_connect (GTK_OBJECT(aitem
), "toggle",
545 GTK_SIGNAL_FUNC(cb_itemsignal
), "toggle");
546 gtk_signal_connect (GTK_OBJECT(aitem
), "expand",
547 GTK_SIGNAL_FUNC(cb_itemsignal
), "expand");
548 gtk_signal_connect (GTK_OBJECT(aitem
), "collapse",
549 GTK_SIGNAL_FUNC(cb_itemsignal
), "collapse");
551 gtk_tree_append (GTK_TREE(real_tree
), aitem
);
552 /* Show it - this can be done at any time */
553 gtk_widget_show (aitem
);
555 gtk_object_set_user_data(GTK_OBJECT(aitem
), (gpointer
)my_data
);
557 fprintf(stdout
, "Added: %s, len: %u\n", dirp
->name
, dirlen
);
559 subtree
= gtk_tree_new();
561 gtk_tree_item_set_subtree(GTK_TREE_ITEM(aitem
), subtree
);
563 gtk_signal_connect(GTK_OBJECT(subtree
), "select_child",
564 GTK_SIGNAL_FUNC(cb_select_child
), real_tree
);
565 gtk_signal_connect(GTK_OBJECT(subtree
), "unselect_child",
566 GTK_SIGNAL_FUNC(cb_unselect_child
), real_tree
);
568 dirp
= (struct smbc_dirent
*) ((char *) dirp
+ dirlen
);
578 else { /* Must be collapse ... FIXME ... */
579 GtkWidget
*subtree
= gtk_tree_new();
581 gtk_tree_remove_items(GTK_TREE(real_tree
), GTK_TREE(real_tree
)->children
);
583 gtk_tree_item_set_subtree(GTK_TREE_ITEM(item
), subtree
);
585 gtk_signal_connect (GTK_OBJECT(subtree
), "select_child",
586 GTK_SIGNAL_FUNC(cb_select_child
), real_tree
);
587 gtk_signal_connect (GTK_OBJECT(subtree
), "unselect_child",
588 GTK_SIGNAL_FUNC(cb_unselect_child
), real_tree
);
595 /* Should put up a dialog box to ask the user for username and password */
598 auth_fn(const char *server
, const char *share
,
599 char *workgroup
, int wgmaxlen
, char *username
, int unmaxlen
,
600 char *password
, int pwmaxlen
)
603 strncpy(username
, "test", unmaxlen
);
604 strncpy(password
, "test", pwmaxlen
);
608 static char *col_titles
[] = {
609 "Name", "Attributes", "Size", "Modification Date",
615 GtkWidget
*window
, *scrolled_win
, *scrolled_win2
, *tree
;
616 GtkWidget
*subtree
, *item
, *main_hbox
, *r_pane
, *l_pane
;
620 struct smbc_dirent
*dirp
;
622 gtk_init (&argc
, &argv
);
624 /* Init the smbclient library */
626 err
= smbc_init(auth_fn
, 10);
628 /* Print an error response ... */
632 fprintf(stderr
, "smbc_init returned %s (%i)\nDo you have a ~/.smb/smb.conf file?\n", strerror(errno
), errno
);
637 /* a generic toplevel window */
638 window
= gtk_window_new (GTK_WINDOW_TOPLEVEL
);
639 gtk_widget_set_name(window
, "main browser window");
640 gtk_signal_connect (GTK_OBJECT(window
), "delete_event",
641 GTK_SIGNAL_FUNC (gtk_main_quit
), NULL
);
642 gtk_window_set_title(GTK_WINDOW(window
), "The Linux Windows Network Browser");
643 gtk_widget_set_usize(GTK_WIDGET(window
), 750, -1);
644 gtk_container_set_border_width (GTK_CONTAINER(window
), 5);
646 gtk_widget_show (window
);
648 /* A container for the two panes ... */
650 main_hbox
= gtk_hbox_new(FALSE
, 1);
651 gtk_container_border_width(GTK_CONTAINER(main_hbox
), 1);
652 gtk_container_add(GTK_CONTAINER(window
), main_hbox
);
654 gtk_widget_show(main_hbox
);
656 l_pane
= gtk_hpaned_new();
657 gtk_paned_gutter_size(GTK_PANED(l_pane
), (GTK_PANED(l_pane
))->handle_size
);
658 r_pane
= gtk_hpaned_new();
659 gtk_paned_gutter_size(GTK_PANED(r_pane
), (GTK_PANED(r_pane
))->handle_size
);
660 gtk_container_add(GTK_CONTAINER(main_hbox
), l_pane
);
661 gtk_widget_show(l_pane
);
663 /* A generic scrolled window */
664 scrolled_win
= gtk_scrolled_window_new (NULL
, NULL
);
665 gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_win
),
666 GTK_POLICY_AUTOMATIC
,
667 GTK_POLICY_AUTOMATIC
);
668 gtk_widget_set_usize (scrolled_win
, 150, 200);
669 gtk_container_add (GTK_CONTAINER(l_pane
), scrolled_win
);
670 gtk_widget_show (scrolled_win
);
672 /* Another generic scrolled window */
673 scrolled_win2
= gtk_scrolled_window_new (NULL
, NULL
);
674 gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_win2
),
675 GTK_POLICY_AUTOMATIC
,
676 GTK_POLICY_AUTOMATIC
);
677 gtk_widget_set_usize (scrolled_win2
, 150, 200);
678 gtk_paned_add2 (GTK_PANED(l_pane
), scrolled_win2
);
679 gtk_widget_show (scrolled_win2
);
681 /* Create the root tree */
682 tree
= gtk_tree_new();
683 g_print ("root tree is %p\n", tree
);
684 /* connect all GtkTree:: signals */
685 gtk_signal_connect (GTK_OBJECT(tree
), "select_child",
686 GTK_SIGNAL_FUNC(cb_select_child
), tree
);
687 gtk_signal_connect (GTK_OBJECT(tree
), "unselect_child",
688 GTK_SIGNAL_FUNC(cb_unselect_child
), tree
);
689 gtk_signal_connect (GTK_OBJECT(tree
), "selection_changed",
690 GTK_SIGNAL_FUNC(cb_selection_changed
), tree
);
691 /* Add it to the scrolled window */
692 gtk_scrolled_window_add_with_viewport (GTK_SCROLLED_WINDOW(scrolled_win
),
694 /* Set the selection mode */
695 gtk_tree_set_selection_mode (GTK_TREE(tree
),
696 GTK_SELECTION_MULTIPLE
);
698 gtk_widget_show (tree
);
700 /* Now, create a clist and attach it to the second pane */
702 clist
= gtk_clist_new_with_titles(4, col_titles
);
704 gtk_container_add (GTK_CONTAINER(scrolled_win2
), clist
);
706 gtk_widget_show(clist
);
708 /* Now, build the top level display ... */
710 if ((dh
= smbc_opendir("smb://")) < 0) {
712 fprintf(stderr
, "Could not list workgroups: smb://: %s\n",
719 /* Create a tree item for Whole Network */
721 item
= gtk_tree_item_new_with_label ("Whole Network");
722 /* Connect all GtkItem:: and GtkTreeItem:: signals */
723 gtk_signal_connect (GTK_OBJECT(item
), "select",
724 GTK_SIGNAL_FUNC(cb_itemsignal
), "select");
725 gtk_signal_connect (GTK_OBJECT(item
), "deselect",
726 GTK_SIGNAL_FUNC(cb_itemsignal
), "deselect");
727 gtk_signal_connect (GTK_OBJECT(item
), "toggle",
728 GTK_SIGNAL_FUNC(cb_itemsignal
), "toggle");
729 gtk_signal_connect (GTK_OBJECT(item
), "expand",
730 GTK_SIGNAL_FUNC(cb_wholenet
), "expand");
731 gtk_signal_connect (GTK_OBJECT(item
), "collapse",
732 GTK_SIGNAL_FUNC(cb_wholenet
), "collapse");
733 /* Add it to the parent tree */
734 gtk_tree_append (GTK_TREE(tree
), item
);
735 /* Show it - this can be done at any time */
736 gtk_widget_show (item
);
738 subtree
= gtk_tree_new(); /* A subtree for Whole Network */
740 gtk_tree_item_set_subtree(GTK_TREE_ITEM(item
), subtree
);
742 gtk_signal_connect (GTK_OBJECT(subtree
), "select_child",
743 GTK_SIGNAL_FUNC(cb_select_child
), tree
);
744 gtk_signal_connect (GTK_OBJECT(subtree
), "unselect_child",
745 GTK_SIGNAL_FUNC(cb_unselect_child
), tree
);
747 /* Now, get the items in smb:/// and add them to the tree */
749 while ((err
= smbc_getdents(dh
, (struct smbc_dirent
*)dirbuf
,
750 sizeof(dirbuf
))) != 0) {
752 if (err
< 0) { /* Handle the error */
754 fprintf(stderr
, "Could not read directory for smbc:///: %s\n",
761 dirp
= (struct smbc_dirent
*)dirbuf
;
763 fprintf(stdout
, "Dir len: %u\n", err
);
765 while (err
> 0) { /* Extract each entry and make a sub-tree */
766 struct tree_data
*my_data
;
767 int dirlen
= dirp
->dirlen
;
769 my_data
= make_tree_data(dirp
->smbc_type
, dirp
->name
);
771 item
= gtk_tree_item_new_with_label(dirp
->name
);
772 /* Connect all GtkItem:: and GtkTreeItem:: signals */
773 gtk_signal_connect (GTK_OBJECT(item
), "select",
774 GTK_SIGNAL_FUNC(cb_itemsignal
), "select");
775 gtk_signal_connect (GTK_OBJECT(item
), "deselect",
776 GTK_SIGNAL_FUNC(cb_itemsignal
), "deselect");
777 gtk_signal_connect (GTK_OBJECT(item
), "toggle",
778 GTK_SIGNAL_FUNC(cb_itemsignal
), "toggle");
779 gtk_signal_connect (GTK_OBJECT(item
), "expand",
780 GTK_SIGNAL_FUNC(cb_itemsignal
), "expand");
781 gtk_signal_connect (GTK_OBJECT(item
), "collapse",
782 GTK_SIGNAL_FUNC(cb_itemsignal
), "collapse");
783 /* Add it to the parent tree */
784 gtk_tree_append (GTK_TREE(tree
), item
);
785 /* Show it - this can be done at any time */
786 gtk_widget_show (item
);
788 gtk_object_set_user_data(GTK_OBJECT(item
), (gpointer
)my_data
);
790 fprintf(stdout
, "Added: %s, len: %u\n", dirp
->name
, dirlen
);
792 subtree
= gtk_tree_new();
794 gtk_tree_item_set_subtree(GTK_TREE_ITEM(item
), subtree
);
796 gtk_signal_connect (GTK_OBJECT(subtree
), "select_child",
797 GTK_SIGNAL_FUNC(cb_select_child
), tree
);
798 gtk_signal_connect (GTK_OBJECT(subtree
), "unselect_child",
799 GTK_SIGNAL_FUNC(cb_unselect_child
), tree
);
801 dirp
= (struct smbc_dirent
*) ((char *) dirp
+ dirlen
);
808 smbc_closedir(dh
); /* FIXME, check for error :-) */
810 /* Show the window and loop endlessly */