3 My_Window::My_Window(GtkWindowType t) : Gtk_Window(t) {
4 debug("My_Window(t)\n");
9 Gtk_MenuItem *file_menu, *menuitem;
11 pane = new Gtk_HPaned();
12 this->scroller = new Gtk_ScrolledWindow();
13 this->viewport = new Gtk_Viewport();
14 this->scroller->set_policy(GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
15 this->scroller->add(*this->viewport);
16 pane->add1(*this->scroller);
17 this->scroller->show();
18 this->viewport->show();
20 this->scroller2 = new Gtk_ScrolledWindow();
21 this->viewport2 = new Gtk_Viewport();
22 this->scroller2->set_policy(GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
23 this->scroller2->add(*this->viewport2);
24 pane->add2(*this->scroller2);
25 this->scroller2->show();
26 this->viewport2->show();
28 top_hbox = new Gtk_HBox();
29 menu = new Gtk_Menu();
30 menuitem = new Gtk_MenuItem("Quit");
31 menu->append(*menuitem);
32 this->menubar = new Gtk_MenuBar();
33 file_menu = new Gtk_MenuItem("File");
34 file_menu->set_submenu(*menu);
35 this->menubar->append(*file_menu);
39 // top_hbox->pack_start(*this->menubar, TRUE, TRUE, 1);
40 this->menubar->show();
41 this->urlfield = new Gtk_Entry();
42 top_hbox->pack_start(*this->urlfield, TRUE, TRUE, 1);
43 this->urlfield->show();
44 this->display_button = new Gtk_Button("Query Server");
45 connect_to_method(this->display_button->clicked, this, &getHost);
46 top_hbox->pack_end(*this->display_button, FALSE, FALSE, 1);
47 this->display_button->show();
49 this->status = new Gtk_Statusbar();
51 bottom_hbox = new Gtk_VBox();
52 bottom_hbox->pack_start(*pane, TRUE, TRUE, 1);
53 bottom_hbox->pack_end(*status, FALSE, TRUE, 1);
57 main_hbox = new Gtk_VBox();
58 main_hbox->pack_start(*this->menubar, FALSE, FALSE, 1);
59 main_hbox->pack_start(*top_hbox, FALSE, TRUE, 1);
60 main_hbox->pack_end(*bottom_hbox, TRUE, TRUE, 1);
67 My_Window::~My_Window() {
68 cout << "~My_Window()" << endl;
72 int My_Window::debug(const char *format,...) {
78 unsigned int m_context_id;
79 va_start(args, format);
80 ret = vprintf(format, args);
81 /* if (this->status != NULL) {
82 m_context_id = this->status->get_context_id("gtk-tool");
83 ret = vsprintf(c, format, args);
84 g_snprintf(buff, 50, "Action: %s", c);
85 this->status->push(m_context_id, buff);
92 void My_Window::do_display() {
93 cout << this->urlfield->get_text() << endl;
96 void My_Window::getHost() {
97 debug("My_Window::getHost()\n");
98 Gtk_Tree *tree, *subtree;
99 Gtk_LdapServer *treeitem;
103 // viewport = (Gtk_Viewport *) GTK_VIEWPORT(this->scroller->children()->nth_data(1));
104 // viewport = (Gtk_Viewport *)this->scroller->children()->nth_data(1);
105 if (this->viewport->get_child()!=NULL) {
106 tree = (Gtk_Tree *)(this->viewport->get_child());
109 tree = new Gtk_Tree();
112 thing = this->urlfield->get_text();
114 c = g_strsplit(thing.c_str(), ":", 2);
116 prt = c[1]; //strtok(NULL, "\0");
117 if (prt != NULL) port = atoi(prt);
118 else port = LDAP_PORT;
119 treeitem = new Gtk_LdapServer(this, host, port);
120 subtree = treeitem->getSubtree();
121 tree->append(*treeitem);
122 treeitem->set_subtree(*subtree);
124 this->viewport->add(tree);
126 this->viewport->show();
127 this->scroller->show();
130 gint My_Window::delete_event_impl(GdkEventAny*) {
131 Gtk_Main::instance()->quit();