1 #include "cpluscommon.h"
6 #include <Gtk_LdapItem.h>
7 #include <Gtk_LdapServer.h>
11 target_drag_leave(GdkDragContext *context, guint time) {
14 int main(int argc, char **argv) {
16 Gtk_LdapItem *treeresult;
17 Gtk_Tree *tree = NULL, *subtree = NULL;
18 Gtk_Tree *machine, *machinetree;
19 Gtk_LdapServer *server;
20 Gtk_Viewport *viewport;
21 char *host = NULL, *prt = NULL;
28 //hosts = new G_List<char>();
29 while ((c = getopt(argc, argv, "d:s:p:h")) != -1) {
32 debug_level = atoi(optarg);
36 hosts = g_list_append(hosts, (strdup(optarg)));
39 port = atoi(optarg); break;
42 fprintf(stderr, "Usage: %s [-d level] [-s server[:port]]*\n", argv[0]);
47 debug("%i hosts\n", g_list_length(hosts));
48 if (g_list_length(hosts) == 0) {
50 ldap_get_option(NULL, LDAP_OPT_HOST_NAME, host);
51 #endif /* LDAP_GET_OPT */
53 hosts = g_list_append(hosts, host);
54 debug("Default host: %s\n", host);
57 fprintf(stderr,"Why isn't your LDAP_OPT_HOST_NAME defined?\n");
59 fprintf(stderr,"Supply me with a host please (hint: use -s)\n");
62 for (int f=0; f<g_list_length(hosts); f++) {
63 debug("%s\n", g_list_nth(hosts,f)->data);
66 if (port == 0) port = LDAP_PORT;
68 Gtk_Main m(&argc, &argv);
70 window = new My_Window(GTK_WINDOW_TOPLEVEL);
73 tree = new Gtk_Tree();
74 window->viewport->add(*tree);
75 for (int f=0; f<g_list_length(hosts); f++) {
76 host = strtok((char*)g_list_nth(hosts, f)->data, ":");
77 prt = strtok(NULL, "\0");
78 if (prt != NULL) port = atoi(prt);
79 else port = LDAP_PORT;
80 server = new Gtk_LdapServer(window, host, port);
81 subtree = server->getSubtree();
82 tree->append(*server);
83 server->set_subtree(*subtree);
86 //window->viewport->add(*tree);
90 // window->viewport->show();
91 // window->scroller->show();
95 Gtk_LdapTree::ItemList &items = tree->tree();
96 Gtk_LdapTree::ItemList::iterator i = items.begin();
97 server = (Gtk_LdapServer *)(* i);
98 // server->select_impl();
101 window->set_title("gtk-tool");
103 window->set_usize(600, 500);
105 window->set_events(window->get_events()|GDK_ALL_EVENTS_MASK);
106 window->drag_dest_set(GTK_DEST_DEFAULT_ALL, target_table, n_targets, static_cast <GdkDragAction> (GDK_ACTION_COPY|GDK_ACTION_MOVE));
107 window->drag_source_set(static_cast<GdkModifierType>(GDK_BUTTON1_MASK|GDK_BUTTON3_MASK), target_table, n_targets, static_cast<GdkDragAction>(GDK_ACTION_COPY|GDK_ACTION_MOVE));
108 window->drag_leave.connect(window->slot(window,target_drag_leave));