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
)
602 strncpy(username
, "test", unmaxlen
);
603 strncpy(password
, "test", pwmaxlen
);
606 static char *col_titles
[] = {
607 "Name", "Attributes", "Size", "Modification Date",
613 GtkWidget
*window
, *scrolled_win
, *scrolled_win2
, *tree
;
614 GtkWidget
*subtree
, *item
, *main_hbox
, *r_pane
, *l_pane
;
618 struct smbc_dirent
*dirp
;
620 gtk_init (&argc
, &argv
);
622 /* Init the smbclient library */
624 err
= smbc_init(auth_fn
, 10);
626 /* Print an error response ... */
630 fprintf(stderr
, "smbc_init returned %s (%i)\nDo you have a ~/.smb/smb.conf file?\n", strerror(errno
), errno
);
635 /* a generic toplevel window */
636 window
= gtk_window_new (GTK_WINDOW_TOPLEVEL
);
637 gtk_widget_set_name(window
, "main browser window");
638 gtk_signal_connect (GTK_OBJECT(window
), "delete_event",
639 GTK_SIGNAL_FUNC (gtk_main_quit
), NULL
);
640 gtk_window_set_title(GTK_WINDOW(window
), "The Linux Windows Network Browser");
641 gtk_widget_set_usize(GTK_WIDGET(window
), 750, -1);
642 gtk_container_set_border_width (GTK_CONTAINER(window
), 5);
644 gtk_widget_show (window
);
646 /* A container for the two panes ... */
648 main_hbox
= gtk_hbox_new(FALSE
, 1);
649 gtk_container_border_width(GTK_CONTAINER(main_hbox
), 1);
650 gtk_container_add(GTK_CONTAINER(window
), main_hbox
);
652 gtk_widget_show(main_hbox
);
654 l_pane
= gtk_hpaned_new();
655 gtk_paned_gutter_size(GTK_PANED(l_pane
), (GTK_PANED(l_pane
))->handle_size
);
656 r_pane
= gtk_hpaned_new();
657 gtk_paned_gutter_size(GTK_PANED(r_pane
), (GTK_PANED(r_pane
))->handle_size
);
658 gtk_container_add(GTK_CONTAINER(main_hbox
), l_pane
);
659 gtk_widget_show(l_pane
);
661 /* A generic scrolled window */
662 scrolled_win
= gtk_scrolled_window_new (NULL
, NULL
);
663 gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_win
),
664 GTK_POLICY_AUTOMATIC
,
665 GTK_POLICY_AUTOMATIC
);
666 gtk_widget_set_usize (scrolled_win
, 150, 200);
667 gtk_container_add (GTK_CONTAINER(l_pane
), scrolled_win
);
668 gtk_widget_show (scrolled_win
);
670 /* Another generic scrolled window */
671 scrolled_win2
= gtk_scrolled_window_new (NULL
, NULL
);
672 gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_win2
),
673 GTK_POLICY_AUTOMATIC
,
674 GTK_POLICY_AUTOMATIC
);
675 gtk_widget_set_usize (scrolled_win2
, 150, 200);
676 gtk_paned_add2 (GTK_PANED(l_pane
), scrolled_win2
);
677 gtk_widget_show (scrolled_win2
);
679 /* Create the root tree */
680 tree
= gtk_tree_new();
681 g_print ("root tree is %p\n", tree
);
682 /* connect all GtkTree:: signals */
683 gtk_signal_connect (GTK_OBJECT(tree
), "select_child",
684 GTK_SIGNAL_FUNC(cb_select_child
), tree
);
685 gtk_signal_connect (GTK_OBJECT(tree
), "unselect_child",
686 GTK_SIGNAL_FUNC(cb_unselect_child
), tree
);
687 gtk_signal_connect (GTK_OBJECT(tree
), "selection_changed",
688 GTK_SIGNAL_FUNC(cb_selection_changed
), tree
);
689 /* Add it to the scrolled window */
690 gtk_scrolled_window_add_with_viewport (GTK_SCROLLED_WINDOW(scrolled_win
),
692 /* Set the selection mode */
693 gtk_tree_set_selection_mode (GTK_TREE(tree
),
694 GTK_SELECTION_MULTIPLE
);
696 gtk_widget_show (tree
);
698 /* Now, create a clist and attach it to the second pane */
700 clist
= gtk_clist_new_with_titles(4, col_titles
);
702 gtk_container_add (GTK_CONTAINER(scrolled_win2
), clist
);
704 gtk_widget_show(clist
);
706 /* Now, build the top level display ... */
708 if ((dh
= smbc_opendir("smb://")) < 0) {
710 fprintf(stderr
, "Could not list workgroups: smb://: %s\n",
717 /* Create a tree item for Whole Network */
719 item
= gtk_tree_item_new_with_label ("Whole Network");
720 /* Connect all GtkItem:: and GtkTreeItem:: signals */
721 gtk_signal_connect (GTK_OBJECT(item
), "select",
722 GTK_SIGNAL_FUNC(cb_itemsignal
), "select");
723 gtk_signal_connect (GTK_OBJECT(item
), "deselect",
724 GTK_SIGNAL_FUNC(cb_itemsignal
), "deselect");
725 gtk_signal_connect (GTK_OBJECT(item
), "toggle",
726 GTK_SIGNAL_FUNC(cb_itemsignal
), "toggle");
727 gtk_signal_connect (GTK_OBJECT(item
), "expand",
728 GTK_SIGNAL_FUNC(cb_wholenet
), "expand");
729 gtk_signal_connect (GTK_OBJECT(item
), "collapse",
730 GTK_SIGNAL_FUNC(cb_wholenet
), "collapse");
731 /* Add it to the parent tree */
732 gtk_tree_append (GTK_TREE(tree
), item
);
733 /* Show it - this can be done at any time */
734 gtk_widget_show (item
);
736 subtree
= gtk_tree_new(); /* A subtree for Whole Network */
738 gtk_tree_item_set_subtree(GTK_TREE_ITEM(item
), subtree
);
740 gtk_signal_connect (GTK_OBJECT(subtree
), "select_child",
741 GTK_SIGNAL_FUNC(cb_select_child
), tree
);
742 gtk_signal_connect (GTK_OBJECT(subtree
), "unselect_child",
743 GTK_SIGNAL_FUNC(cb_unselect_child
), tree
);
745 /* Now, get the items in smb:/// and add them to the tree */
747 while ((err
= smbc_getdents(dh
, (struct smbc_dirent
*)dirbuf
,
748 sizeof(dirbuf
))) != 0) {
750 if (err
< 0) { /* Handle the error */
752 fprintf(stderr
, "Could not read directory for smbc:///: %s\n",
759 dirp
= (struct smbc_dirent
*)dirbuf
;
761 fprintf(stdout
, "Dir len: %u\n", err
);
763 while (err
> 0) { /* Extract each entry and make a sub-tree */
764 struct tree_data
*my_data
;
765 int dirlen
= dirp
->dirlen
;
767 my_data
= make_tree_data(dirp
->smbc_type
, dirp
->name
);
769 item
= gtk_tree_item_new_with_label(dirp
->name
);
770 /* Connect all GtkItem:: and GtkTreeItem:: signals */
771 gtk_signal_connect (GTK_OBJECT(item
), "select",
772 GTK_SIGNAL_FUNC(cb_itemsignal
), "select");
773 gtk_signal_connect (GTK_OBJECT(item
), "deselect",
774 GTK_SIGNAL_FUNC(cb_itemsignal
), "deselect");
775 gtk_signal_connect (GTK_OBJECT(item
), "toggle",
776 GTK_SIGNAL_FUNC(cb_itemsignal
), "toggle");
777 gtk_signal_connect (GTK_OBJECT(item
), "expand",
778 GTK_SIGNAL_FUNC(cb_itemsignal
), "expand");
779 gtk_signal_connect (GTK_OBJECT(item
), "collapse",
780 GTK_SIGNAL_FUNC(cb_itemsignal
), "collapse");
781 /* Add it to the parent tree */
782 gtk_tree_append (GTK_TREE(tree
), item
);
783 /* Show it - this can be done at any time */
784 gtk_widget_show (item
);
786 gtk_object_set_user_data(GTK_OBJECT(item
), (gpointer
)my_data
);
788 fprintf(stdout
, "Added: %s, len: %u\n", dirp
->name
, dirlen
);
790 subtree
= gtk_tree_new();
792 gtk_tree_item_set_subtree(GTK_TREE_ITEM(item
), subtree
);
794 gtk_signal_connect (GTK_OBJECT(subtree
), "select_child",
795 GTK_SIGNAL_FUNC(cb_select_child
), tree
);
796 gtk_signal_connect (GTK_OBJECT(subtree
), "unselect_child",
797 GTK_SIGNAL_FUNC(cb_unselect_child
), tree
);
799 dirp
= (struct smbc_dirent
*) ((char *) dirp
+ dirlen
);
806 smbc_closedir(dh
); /* FIXME, check for error :-) */
808 /* Show the window and loop endlessly */