From 0d6fc5c02fe0831e57941578e4209d1525331356 Mon Sep 17 00:00:00 2001 From: paulc Date: Thu, 26 Jan 2006 00:00:36 +0000 Subject: [PATCH] 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 --- contrib/gtk2/gtk2client.cpp | 12 ++++++----- contrib/gtk2/gtk2client.h | 2 +- engine/Client.cpp | 42 ++++++++++++++++++++++++++++++++----- yatecbase.h | 2 ++ 4 files changed, 47 insertions(+), 11 deletions(-) diff --git a/contrib/gtk2/gtk2client.cpp b/contrib/gtk2/gtk2client.cpp index cf878ebe..89836154 100644 --- a/contrib/gtk2/gtk2client.cpp +++ b/contrib/gtk2/gtk2client.cpp @@ -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; diff --git a/contrib/gtk2/gtk2client.h b/contrib/gtk2/gtk2client.h index 8ec9e54d..53db697d 100644 --- a/contrib/gtk2/gtk2client.h +++ b/contrib/gtk2/gtk2client.h @@ -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); diff --git a/engine/Client.cpp b/engine/Client.cpp index bc39bcb0..6174dde7 100644 --- a/engine/Client.cpp +++ b/engine/Client.cpp @@ -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",¶ms,parent); +} + +bool Client::openConfirm(const char* text, const Window* parent) +{ + NamedList params(""); + params.addParam("text",text); + return openPopup("confirm",¶ms,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; diff --git a/yatecbase.h b/yatecbase.h index fe923aac..6f9ac24e 100644 --- a/yatecbase.h +++ b/yatecbase.h @@ -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: