Added API for common tasks like displaying a message. Fixed hangup button.

Added alignment property (as percentage).


git-svn-id: http://voip.null.ro/svn/yate@665 acf43c95-373e-0410-b603-e72c3f656dc1
This commit is contained in:
paulc 2006-01-26 00:00:36 +00:00
parent 4f5a7b2b4a
commit 0d6fc5c02f
4 changed files with 47 additions and 11 deletions

View File

@ -684,7 +684,7 @@ void Widget::destroyCb(GtkObject* obj, gpointer dat)
}
GTKWindow::GTKWindow(const char* id, Layout layout)
GTKWindow::GTKWindow(const char* id, bool decorated, Layout layout)
: Window(id), m_widget(0), m_filler(0), m_layout(layout), m_state(0),
m_posX(INVALID_POS), m_posY(INVALID_POS), m_sizeW(0), m_sizeH(0)
{
@ -692,7 +692,7 @@ GTKWindow::GTKWindow(const char* id, Layout layout)
g_object_set_data((GObject*)m_widget,"Yate::Window",this);
gtk_window_set_role((GtkWindow*)m_widget,id);
// gtk_window_set_type_hint((GtkWindow*)m_widget,GDK_WINDOW_TYPE_HINT_DIALOG);
gtk_window_set_decorated((GtkWindow*)m_widget,FALSE);
gtk_window_set_decorated((GtkWindow*)m_widget,decorated);
// gtk_window_set_resizable((GtkWindow*)m_widget,FALSE);
gtk_widget_add_events(m_widget,GDK_BUTTON_PRESS_MASK);
gtk_widget_add_events(m_widget,GDK_BUTTON_RELEASE_MASK);
@ -819,12 +819,12 @@ void GTKWindow::populate()
return;
s_radioGroup = 0;
GtkWidget* containerStack[MAX_CONTAINER_DEPTH];
GtkWidget* lastWidget = 0;
GtkTooltips* tips = 0;
int depth = 0;
if (m_layout == Unknown)
m_layout = (Layout)sect->getIntValue("layout",s_layoutNames,GTKWindow::Unknown);
gtk_widget_set_size_request(filler(),sect->getIntValue("width",-1),sect->getIntValue("height",-1));
GtkWidget* lastWidget = filler();
gtk_widget_set_size_request(lastWidget,sect->getIntValue("width",-1),sect->getIntValue("height",-1));
int n = sect->length();
for (int i = 0; i < n; i++) {
NamedString* p = sect->getParam(i);
@ -894,6 +894,8 @@ void GTKWindow::populate()
g_object_set(G_OBJECT(lastWidget),tmp.c_str(),p->safe(),NULL);
else if (tmp.startSkip("pos:",false) && tmp)
g_object_set(G_OBJECT(lastWidget),tmp.c_str(),p->toInteger(s_directions),NULL);
else if (tmp.startSkip("align:",false) && tmp)
g_object_set(G_OBJECT(lastWidget),tmp.c_str(),(gfloat)p->toInteger(50)*0.01,NULL);
else if (tmp.startSkip("relief:",false) && tmp)
g_object_set(G_OBJECT(lastWidget),tmp.c_str(),p->toInteger(s_reliefs),NULL);
else if (tmp.startSkip("shadow:",false) && tmp)
@ -1499,7 +1501,7 @@ bool GTKClient::createWindow(const String& name)
if (f)
w = f->build();
else
w = new GTKWindow(name);
w = new GTKWindow(name,s_cfg.getBoolValue(name,"decorated"));
if (!w) {
Debug(GTKDriver::self(),DebugGoOn,"Could not create window '%s'",name.c_str());
return false;

View File

@ -115,7 +115,7 @@ public:
Framed,
Scroll,
};
GTKWindow(const char* id = 0, Layout layout = Unknown);
GTKWindow(const char* id = 0, bool decorated = false, Layout layout = Unknown);
virtual ~GTKWindow();
virtual void title(const String& text);
virtual bool setParams(const NamedList& params);

View File

@ -352,11 +352,15 @@ void Client::initWindows()
void Client::initClient()
{
m_multiLines =
bool tmp =
getWindow("channels") || hasElement("channels") ||
getWindow("lines") || hasElement("lines");
m_multiLines = Engine::config().getBoolValue("client","multilines",tmp);
tmp = false;
getCheck("autoanswer",tmp);
m_autoAnswer = Engine::config().getBoolValue("client","autoanswer",tmp);
setCheck("multilines",m_multiLines);
getCheck("autoanswer",m_autoAnswer);
setCheck("autoanswer",m_autoAnswer);
}
void Client::moveRelated(const Window* wnd, int dx, int dy)
@ -388,6 +392,20 @@ bool Client::openPopup(const String& name, const NamedList* params, const Window
return true;
}
bool Client::openMessage(const char* text, const Window* parent)
{
NamedList params("");
params.addParam("text",text);
return openPopup("message",&params,parent);
}
bool Client::openConfirm(const char* text, const Window* parent)
{
NamedList params("");
params.addParam("text",text);
return openPopup("confirm",&params,parent);
}
bool Client::hasElement(const String& name, Window* wnd, Window* skip)
{
if (needProxy()) {
@ -849,12 +867,12 @@ bool Client::callIncoming(const String& caller, const String& dest, Message* msg
String tmp("Call from:");
tmp << " " << caller;
setStatus(tmp);
setText("incoming",tmp);
if (m_autoAnswer) {
cc->callAnswer();
setChannelInternal(cc);
}
else {
setText("incoming",tmp);
if (!(m_multiLines && setVisible("channels")))
setVisible("incoming");
}
@ -875,7 +893,7 @@ bool Client::callRouting(const String& caller, const String& called, Message* ms
void Client::clearActive(const String& id)
{
if (id == m_activeId)
m_activeId.clear();
updateFrom(0);
}
void Client::addChannel(ClientChannel* chan)
@ -897,7 +915,9 @@ void Client::setChannelInternal(ClientChannel* chan)
if (!setUrgent(chan->id(),chan->flashing()) && chan->flashing())
tmp << " <<<";
setText(chan->id(),tmp);
if (getSelect("channels",tmp) && (tmp == chan->id()))
bool upd = !m_multiLines;
upd = upd || (getSelect("channels",tmp) && (tmp == chan->id()));
if (upd)
updateFrom(chan);
}
@ -983,6 +1003,18 @@ bool UIHandler::received(Message &msg)
Window* wnd = Client::getWindow(msg.getValue("window"));
if (action == "set_status")
return Client::self()->setStatusLocked(msg.getValue("status"),wnd);
else if (action == "show_message") {
Client::self()->lockOther();
bool ok = Client::openMessage(msg.getValue("text"),Client::getWindow(msg.getValue("parent")));
Client::self()->unlockOther();
return ok;
}
else if (action == "show_confirm") {
Client::self()->lockOther();
bool ok = Client::openConfirm(msg.getValue("text"),Client::getWindow(msg.getValue("parent")));
Client::self()->unlockOther();
return ok;
}
String name(msg.getValue("name"));
if (name.null())
return false;

View File

@ -171,6 +171,8 @@ public:
static bool setVisible(const String& name, bool show = true);
static bool getVisible(const String& name);
static bool openPopup(const String& name, const NamedList* params = 0, const Window* parent = 0);
static bool openMessage(const char* text, const Window* parent = 0);
static bool openConfirm(const char* text, const Window* parent = 0);
static ObjList* listWindows();
void idleActions();
protected: