3 My_Window::My_Window(GtkWindowType t) : Gtk_Window(t) {
4 debug("My_Window(t)\n");
8 Gtk_Menu *menu, *sub_menu;
9 Gtk_MenuItem *new_menu, *file_menu, *options_menu, *menuitem;
10 Gtk_CheckMenuItem *check_menuitem;
12 pane = new Gtk_HPaned();
13 this->scroller = new Gtk_ScrolledWindow();
14 this->viewport = new Gtk_Viewport();
15 this->scroller->set_policy(GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
16 this->scroller->add(*this->viewport);
17 pane->add1(*this->scroller);
18 this->scroller->show();
19 this->viewport->show();
21 this->scroller2 = new Gtk_ScrolledWindow();
22 this->viewport2 = new Gtk_Viewport();
23 this->scroller2->set_policy(GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
24 this->scroller2->add(*this->viewport2);
25 pane->add2(*this->scroller2);
26 this->scroller2->show();
27 this->viewport2->show();
29 top_hbox = new Gtk_HBox();
31 menu = new Gtk_Menu();
33 sub_menu = new Gtk_Menu();
34 menuitem = new Gtk_MenuItem("Server");
35 menuitem->activate.connect(slot(this,&My_Window::addServer));
36 //connect_to_method(menuitem->activate, this, &addServer);
37 sub_menu->append(*menuitem);
39 new_menu = new Gtk_MenuItem("New...");
40 new_menu->set_submenu(*sub_menu);
42 menu->append(*new_menu);
45 menuitem = new Gtk_MenuItem("Quit");
46 menuitem->activate.connect(Gtk_Main::quit.slot());
47 menu->append(*menuitem);
49 this->menubar = new Gtk_MenuBar();
50 file_menu = new Gtk_MenuItem("File (?)");
51 file_menu->set_submenu(*menu);
52 this->menubar->append(*file_menu);
55 menu = new Gtk_Menu();
56 check_menuitem = new Gtk_CheckMenuItem("Show Debug Info");
57 check_menuitem->toggled.connect(slot(this,&My_Window::setDebug));
58 //connect_to_method(check_menuitem->toggled, this, &setDebug);
59 menu->append(*check_menuitem);
60 check_menuitem->show();
61 options_menu = new Gtk_MenuItem("Options");
62 options_menu->set_submenu(*menu);
63 this->menubar->append(*options_menu);
67 // options_menu->show();
69 // top_hbox->pack_start(*this->menubar, TRUE, TRUE, 1);
70 // this->menubar->show();
71 this->urlfield = new Gtk_Entry();
72 top_hbox->pack_start(*this->urlfield, TRUE, TRUE, 1);
73 // this->urlfield->show();
74 this->display_button = new Gtk_Button("Query Server");
75 this->display_button->clicked.connect(slot(this, &My_Window::getHost));
76 //connect_to_method(this->display_button->clicked, this, &getHost);
77 top_hbox->pack_end(*this->display_button, FALSE, FALSE, 1);
78 // this->display_button->show();
80 this->status = new Gtk_Statusbar();
81 // this->progress = new Gtk_ProgressBar();
82 // this->status->add(*progress);
83 // this->progress->show();
85 bottom_hbox = new Gtk_VBox();
86 bottom_hbox->pack_start(*pane, TRUE, TRUE, 1);
87 bottom_hbox->pack_end(*status, FALSE, TRUE, 1);
91 main_hbox = new Gtk_VBox();
92 main_hbox->pack_start(*this->menubar, FALSE, FALSE, 1);
93 main_hbox->pack_start(*top_hbox, FALSE, TRUE, 1);
94 main_hbox->pack_end(*bottom_hbox, TRUE, TRUE, 1);
97 this->add(*main_hbox);
98 this->destroy.connect(Gtk_Main::quit.slot());
103 My_Window::~My_Window() {
104 cout << "~My_Window()" << endl;
108 int My_Window::debug(const char *format,...) {
109 if (debug_level > 1) {
114 unsigned int m_context_id;
115 va_start(args, format);
116 ret = vprintf(format, args);
117 /* if (this->status != NULL) {
118 m_context_id = this->status->get_context_id("gtk-tool");
119 ret = vsprintf(c, format, args);
120 g_snprintf(buff, 50, "Action: %s", c);
121 this->status->push(m_context_id, buff);
128 void My_Window::do_display() {
129 cout << this->urlfield->get_text() << endl;
132 void My_Window::getHost() {
133 debug("My_Window::getHost()\n");
134 Gtk_Tree *tree, *subtree;
135 Gtk_LdapServer *treeitem;
139 // viewport = (Gtk_Viewport *) GTK_VIEWPORT(this->scroller->children()->nth_data(1));
140 // viewport = (Gtk_Viewport *)this->scroller->children()->nth_data(1);
141 if (this->viewport->get_child()!=NULL) {
142 tree = (Gtk_Tree *)(this->viewport->get_child());
145 tree = new Gtk_Tree();
148 thing = this->urlfield->get_text();
150 c = g_strsplit(thing.c_str(), ":", 2);
152 prt = c[1]; //strtok(NULL, "\0");
153 if (prt != NULL) port = atoi(prt);
154 else port = LDAP_PORT;
155 treeitem = new Gtk_LdapServer(this, host, port);
156 subtree = treeitem->getSubtree();
157 tree->append(*treeitem);
158 treeitem->set_subtree(*subtree);
160 this->viewport->add(*tree);
162 this->viewport->show();
163 this->scroller->show();
167 void My_Window::setDebug() {
168 if (debug_level > 0) debug_level = 0;
169 else debug_level = 1;
172 void My_Window::addServer() {
173 debug("%s\n", "Creating new server");
174 Gtk_Entry *entry = new Gtk_Entry();
175 // entry->connect(slot(entry->activate, this, &getHost));
176 entry->activate.connect(slot(this,&My_Window::getHost));
177 this->dialog = new Gtk_InputDialog();
178 // this->dialog->add(*entry);
180 this->dialog->show();
184 gint My_Window::delete_event_impl(GdkEventAny*) {
185 //Gtk_Main::instance()->quit();