summaryrefslogtreecommitdiffstats
path: root/src/ClientWindow.cc
blob: 014095b9e3b048c884f96ab0dc9303483114acbf (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#include <iostream>

#include "paman.hh"
#include "ClientWindow.hh"

#define GLADE_NAME "clientWindow"

ClientWindow::ClientWindow(BaseObjectType* cobject, const Glib::RefPtr<Gnome::Glade::Xml>& refGlade) :
    Gtk::Window(cobject),
    nameLabel(NULL),
    typeidLabel(NULL),
    indexLabel(NULL),
    ownerModuleLabel(NULL),
    closeButton(NULL),
    toOwnerModuleButton(NULL),
    killButton(NULL) {

    refGlade->get_widget("nameLabel", nameLabel);
    refGlade->get_widget("typeidLabel", typeidLabel);
    refGlade->get_widget("indexLabel", indexLabel);
    refGlade->get_widget("ownerModuleLabel", ownerModuleLabel);
    refGlade->get_widget("closeButton", closeButton);
    refGlade->get_widget("toOwnerModuleButton", toOwnerModuleButton);
    refGlade->get_widget("killButton", killButton);

    closeButton->signal_clicked().connect(sigc::mem_fun(*this, &ClientWindow::onCloseButton));
    toOwnerModuleButton->signal_clicked().connect(sigc::mem_fun(*this, &ClientWindow::onToOwnerModuleButton));
    killButton->signal_clicked().connect(sigc::mem_fun(*this, &ClientWindow::onKillButton));
}

ClientWindow* ClientWindow::create() {
    ClientWindow *w = NULL;
    Glib::RefPtr<Gnome::Glade::Xml> refXml = Gnome::Glade::Xml::create(GLADE_FILE, GLADE_NAME);
    refXml->get_widget_derived(GLADE_NAME, w);
    return w;
}

void ClientWindow::updateInfo(const ClientInfo &i) {
    char t[20];

    nameLabel->set_text(i.name);

    typeidLabel->set_text(pa_typeid_to_string(i._typeid, t, sizeof(t)));
    snprintf(t, sizeof(t), "#%u", i.index);
    indexLabel->set_text(t);

    snprintf(t, sizeof(t), "#%u", i.owner_module);
    ownerModuleLabel->set_text(t);

    set_title("Client: "+i.name);
    
    owner_module = i.owner_module;
    toOwnerModuleButton->set_sensitive(owner_module != (uint32_t) -1);

    index = i.index;
}

void ClientWindow::onCloseButton() {
    hide();
}

void ClientWindow::onToOwnerModuleButton() {
    if (owner_module != (uint32_t) -1)
        serverInfoManager->showModuleWindow(owner_module);
}

bool ClientWindow::on_delete_event(GdkEventAny*) {
    hide();
    return false;
}

void ClientWindow::onKillButton() {
    serverInfoManager->killClient(index);
}