*** empty log message ***
git-svn-id: http://voip.null.ro/svn/yate@443 acf43c95-373e-0410-b603-e72c3f656dc1
This commit is contained in:
parent
c581a7803a
commit
65a8b0eab1
|
@ -226,24 +226,44 @@ static gboolean widgetCbAction(GtkWidget* wid, gpointer dat)
|
|||
return wnd && wnd->action(wid);
|
||||
}
|
||||
|
||||
static gboolean widgetCbToggle(GtkToggleButton* btn, gpointer dat)
|
||||
static gboolean widgetCbToggle(GtkWidget* wid, gpointer dat)
|
||||
{
|
||||
Debug(GTKDriver::self(),DebugAll,"widgetCbToggle data %p",dat);
|
||||
if (GTKClient::changing())
|
||||
return FALSE;
|
||||
GTKWindow* wnd = getWidgetWindow((GtkWidget*)btn);
|
||||
return wnd && wnd->toggle(btn,gtk_toggle_button_get_active(btn));
|
||||
GTKWindow* wnd = getWidgetWindow(wid);
|
||||
if (!wnd)
|
||||
wnd = static_cast<GTKWindow*>(dat);
|
||||
if (!wnd)
|
||||
return FALSE;
|
||||
gboolean active = FALSE;
|
||||
if (GTK_IS_TOGGLE_BUTTON(wid))
|
||||
active = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(wid));
|
||||
else if (GTK_IS_CHECK_MENU_ITEM(wid))
|
||||
active = gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(wid));
|
||||
return wnd->toggle(wid,active);
|
||||
}
|
||||
|
||||
static gboolean widgetCbSelected(GtkOptionMenu* opt, gpointer dat)
|
||||
{
|
||||
Debug(GTKDriver::self(),DebugAll,"widgetCbChanged data %p",dat);
|
||||
Debug(GTKDriver::self(),DebugAll,"widgetCbSelected data %p",dat);
|
||||
if (GTKClient::changing())
|
||||
return FALSE;
|
||||
GTKWindow* wnd = getWidgetWindow((GtkWidget*)opt);
|
||||
return wnd && wnd->select(opt,gtk_option_menu_get_history(opt));
|
||||
}
|
||||
|
||||
static gboolean widgetCbSelection(GtkList* lst, gpointer dat)
|
||||
{
|
||||
Debug(GTKDriver::self(),DebugAll,"widgetCbSelection data %p",dat);
|
||||
if (GTKClient::changing())
|
||||
return FALSE;
|
||||
GTKWindow* wnd = getWidgetWindow((GtkWidget*)lst);
|
||||
// FIXME
|
||||
return false;
|
||||
// return wnd && wnd->select(opt,gtk_option_menu_get_history(opt));
|
||||
}
|
||||
|
||||
static gboolean widgetCbMinimize(GtkWidget* wid, gpointer dat)
|
||||
{
|
||||
DDebug(GTKDriver::self(),DebugAll,"widgetCbMinimize data %p",dat);
|
||||
|
@ -352,6 +372,26 @@ static GtkWidget* gtkOptionMenuNew(const gchar* text)
|
|||
return opt;
|
||||
}
|
||||
|
||||
static GtkWidget* gtkListNew(const gchar* text)
|
||||
{
|
||||
GtkWidget* lst = gtk_list_new();
|
||||
if (lst) {
|
||||
GList* list = 0;
|
||||
String tmp(text);
|
||||
ObjList* l = tmp.split(',');
|
||||
for (ObjList* i = l; i; i = i->next()) {
|
||||
String* s = static_cast<String*>(i->get());
|
||||
if (s && *s)
|
||||
list = g_list_append(list,gtk_list_item_new_with_label(s->c_str()));
|
||||
}
|
||||
if (l)
|
||||
l->destruct();
|
||||
if (list)
|
||||
gtk_list_append_items(GTK_LIST(lst),list);
|
||||
}
|
||||
return lst;
|
||||
}
|
||||
|
||||
static WidgetMaker s_widgetMakers[] = {
|
||||
{ "label", gtkLeftLabelNew, 0, 0 },
|
||||
{ "editor", gtkEntryNewWithText, "activate", G_CALLBACK(widgetCbAction) },
|
||||
|
@ -360,6 +400,7 @@ static WidgetMaker s_widgetMakers[] = {
|
|||
{ "check", gtk_check_button_new_with_label, "toggled", G_CALLBACK(widgetCbToggle) },
|
||||
{ "combo", gtkComboNewWithText, 0, 0 },
|
||||
{ "option", gtkOptionMenuNew, "changed", G_CALLBACK(widgetCbSelected) },
|
||||
{ "list", gtkListNew, "selection-changed", G_CALLBACK(widgetCbSelection) },
|
||||
{ "frame", gtk_frame_new, 0, 0 },
|
||||
{ "image", gtk_image_new_from_file, 0, 0 },
|
||||
{ "hseparator", (GBuilder)gtk_hseparator_new, 0, 0 },
|
||||
|
@ -448,6 +489,30 @@ static TokenDict s_layoutNames[] = {
|
|||
{ 0, 0 },
|
||||
};
|
||||
|
||||
static TokenDict s_directions[] = {
|
||||
{ "left", GTK_POS_LEFT },
|
||||
{ "right", GTK_POS_RIGHT },
|
||||
{ "top", GTK_POS_TOP },
|
||||
{ "bottom", GTK_POS_BOTTOM },
|
||||
{ 0, 0 },
|
||||
};
|
||||
|
||||
static TokenDict s_shadows[] = {
|
||||
{ "none", GTK_SHADOW_NONE },
|
||||
{ "in", GTK_SHADOW_IN },
|
||||
{ "out", GTK_SHADOW_OUT },
|
||||
{ "etched_in", GTK_SHADOW_ETCHED_IN },
|
||||
{ "etched_out", GTK_SHADOW_ETCHED_OUT },
|
||||
{ 0, 0 },
|
||||
};
|
||||
|
||||
static TokenDict s_reliefs[] = {
|
||||
{ "full", GTK_RELIEF_NORMAL },
|
||||
{ "half", GTK_RELIEF_HALF },
|
||||
{ "none", GTK_RELIEF_NONE },
|
||||
{ 0, 0 },
|
||||
};
|
||||
|
||||
Widget::Widget()
|
||||
: m_widget(0)
|
||||
{
|
||||
|
@ -589,6 +654,9 @@ void GTKWindow::insert(GtkWidget* wid, int x, int y, int w, int h)
|
|||
gtk_box_pack_start(GTK_BOX(filler()),wid,(x > 0),true,y);
|
||||
else
|
||||
gtk_container_add(GTK_CONTAINER(filler()),wid);
|
||||
if (GTK_IS_NOTEBOOK(filler()) && m_tabName)
|
||||
gtk_notebook_set_tab_label_text(GTK_NOTEBOOK(m_filler),wid,m_tabName.c_str());
|
||||
m_tabName.clear();
|
||||
}
|
||||
|
||||
GtkWidget* GTKWindow::build(const String& type, const String& text)
|
||||
|
@ -615,6 +683,7 @@ void GTKWindow::populate()
|
|||
if (!sect)
|
||||
return;
|
||||
GtkWidget* containerStack[MAX_CONTAINER_DEPTH];
|
||||
GtkWidget* lastWidget = 0;
|
||||
int depth = 0;
|
||||
if (m_layout == Unknown)
|
||||
m_layout = (Layout)sect->getIntValue("layout",s_layoutNames,GTKWindow::Unknown);
|
||||
|
@ -638,6 +707,7 @@ void GTKWindow::populate()
|
|||
}
|
||||
GtkWidget* wid = build(p->name(),s.safe());
|
||||
if (wid) {
|
||||
lastWidget = wid;
|
||||
attachDebug(wid);
|
||||
if (act)
|
||||
gtk_widget_set_name(wid,act);
|
||||
|
@ -645,6 +715,7 @@ void GTKWindow::populate()
|
|||
continue;
|
||||
}
|
||||
if (p->name() == "leave") {
|
||||
lastWidget = 0;
|
||||
if (depth > 0) {
|
||||
Debug(GTKDriver::self(),DebugAll,"Popping container off stack of depth %d",depth);
|
||||
depth--;
|
||||
|
@ -652,10 +723,35 @@ void GTKWindow::populate()
|
|||
}
|
||||
continue;
|
||||
}
|
||||
else if (p->name() == "tabname") {
|
||||
m_tabName = *p;
|
||||
continue;
|
||||
}
|
||||
else if (p->name().startsWith("property:")) {
|
||||
if (!lastWidget)
|
||||
continue;
|
||||
String tmp = p->name();
|
||||
tmp >> "property:";
|
||||
Debug(GTKDriver::self(),DebugAll,"Setting property '%s' to '%s' in %p",
|
||||
tmp.c_str(),p->c_str(),lastWidget);
|
||||
if (tmp.startSkip("int:",false) && tmp)
|
||||
g_object_set(G_OBJECT(lastWidget),tmp.c_str(),p->toInteger(),NULL);
|
||||
else if (tmp.startSkip("bool:",false) && tmp)
|
||||
g_object_set(G_OBJECT(lastWidget),tmp.c_str(),p->toBoolean(),NULL);
|
||||
else if (tmp.startSkip("str:",false) && tmp)
|
||||
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("relief:",false) && tmp)
|
||||
g_object_set(G_OBJECT(lastWidget),tmp.c_str(),p->toInteger(s_reliefs),NULL);
|
||||
else if (tmp.startSkip("shadow:",false) && tmp)
|
||||
g_object_set(G_OBJECT(lastWidget),tmp.c_str(),p->toInteger(s_shadows),NULL);
|
||||
}
|
||||
if (depth >= MAX_CONTAINER_DEPTH)
|
||||
continue;
|
||||
wid = container(p->name());
|
||||
if (wid) {
|
||||
lastWidget = wid;
|
||||
attachDebug(wid);
|
||||
if (act)
|
||||
gtk_widget_set_name(wid,act);
|
||||
|
@ -668,9 +764,15 @@ void GTKWindow::populate()
|
|||
}
|
||||
}
|
||||
|
||||
void GTKWindow::title(const String& text)
|
||||
{
|
||||
Window::title(text);
|
||||
gtk_window_set_title((GtkWindow*)m_widget,m_title.safe());
|
||||
}
|
||||
|
||||
void GTKWindow::init()
|
||||
{
|
||||
gtk_window_set_title((GtkWindow*)m_widget,s_cfg.getValue(m_id,"title",m_id));
|
||||
title(s_cfg.getValue(m_id,"title",m_id));
|
||||
m_master = s_cfg.getBoolValue(m_id,"master");
|
||||
if (!m_master)
|
||||
gtk_window_set_type_hint((GtkWindow*)m_widget,GDK_WINDOW_TYPE_HINT_TOOLBAR);
|
||||
|
@ -791,11 +893,11 @@ bool GTKWindow::action(GtkWidget* wid)
|
|||
return GTKClient::self() && GTKClient::self()->action(this,name);
|
||||
}
|
||||
|
||||
bool GTKWindow::toggle(GtkToggleButton* btn, gboolean active)
|
||||
bool GTKWindow::toggle(GtkWidget* wid, gboolean active)
|
||||
{
|
||||
const gchar* name = gtk_widget_get_name((GtkWidget*)btn);
|
||||
Debug(GTKDriver::self(),DebugAll,"toggle '%s' btn=%p active=%s [%p]",
|
||||
name,btn,String::boolText(active),this);
|
||||
const gchar* name = gtk_widget_get_name(wid);
|
||||
Debug(GTKDriver::self(),DebugAll,"toggle '%s' wid=%p active=%s [%p]",
|
||||
name,wid,String::boolText(active),this);
|
||||
return GTKClient::self() && GTKClient::self()->toggle(this,name,active);
|
||||
}
|
||||
|
||||
|
@ -1015,8 +1117,22 @@ bool GTKWindow::getCheck(GtkWidget* wid, bool& checked)
|
|||
void GTKWindow::menu(int x, int y)
|
||||
{
|
||||
GtkWidget* mnu = gtk_menu_new();
|
||||
GtkWidget* item = gtk_check_menu_item_new_with_label("123");
|
||||
gtk_menu_shell_append((GtkMenuShell*)mnu,item);
|
||||
ObjList* wnds = GTKClient::listWindows();
|
||||
for (ObjList* l = wnds; l; l = l->next()) {
|
||||
String* s = static_cast<String*>(l->get());
|
||||
if (!s || s->null())
|
||||
continue;
|
||||
Window* w = GTKClient::getWindow(*s);
|
||||
if (!w || w->master())
|
||||
continue;
|
||||
GtkWidget* item = gtk_check_menu_item_new_with_label(w->title().safe());
|
||||
gtk_widget_set_name(item,s->c_str());
|
||||
gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(item),w->visible());
|
||||
g_signal_connect(G_OBJECT(item),"toggled",G_CALLBACK(widgetCbToggle),this);
|
||||
gtk_menu_shell_append((GtkMenuShell*)mnu,item);
|
||||
}
|
||||
delete wnds;
|
||||
gtk_widget_show_all(mnu);
|
||||
gtk_menu_popup((GtkMenu*)mnu,NULL,NULL,NULL,NULL,3,gtk_get_current_event_time());
|
||||
}
|
||||
|
||||
|
|
|
@ -111,6 +111,7 @@ public:
|
|||
};
|
||||
GTKWindow(const char* id = 0, Layout layout = Unknown);
|
||||
virtual ~GTKWindow();
|
||||
virtual void title(const String& text);
|
||||
virtual bool setActive(const String& name, bool active);
|
||||
virtual bool setShow(const String& name, bool visible);
|
||||
virtual bool setText(const String& name, const String& text);
|
||||
|
@ -135,7 +136,7 @@ public:
|
|||
GtkWidget* find(const String& name) const;
|
||||
virtual void insert(GtkWidget* wid, int x = 0, int y = 0, int w = -1, int h = -1);
|
||||
virtual bool action(GtkWidget* wid);
|
||||
virtual bool toggle(GtkToggleButton* btn, gboolean active);
|
||||
virtual bool toggle(GtkWidget* wid, gboolean active);
|
||||
virtual bool select(GtkOptionMenu* opt, gint selected);
|
||||
virtual void menu(int x, int y);
|
||||
inline GtkWidget* widget() const
|
||||
|
@ -156,6 +157,7 @@ public:
|
|||
protected:
|
||||
GtkWidget* m_widget;
|
||||
GtkWidget* m_filler;
|
||||
String m_tabName;
|
||||
int m_layout;
|
||||
int m_state;
|
||||
gint m_posX;
|
||||
|
|
|
@ -58,6 +58,11 @@ const String& Window::toString() const
|
|||
return m_id;
|
||||
}
|
||||
|
||||
void Window::title(const String& text)
|
||||
{
|
||||
m_title = text;
|
||||
}
|
||||
|
||||
bool Window::related(const Window* wnd) const
|
||||
{
|
||||
if ((wnd == this) || !wnd || wnd->master())
|
||||
|
@ -120,6 +125,22 @@ Window* Client::getWindow(const String& name)
|
|||
return static_cast<Window*>(l ? l->get() : 0);
|
||||
}
|
||||
|
||||
ObjList* Client::listWindows()
|
||||
{
|
||||
if (!s_client)
|
||||
return 0;
|
||||
ObjList* lst = 0;
|
||||
for (ObjList* l = &s_client->m_windows; l; l = l->next()) {
|
||||
Window* w = static_cast<Window*>(l->get());
|
||||
if (w) {
|
||||
if (!lst)
|
||||
lst = new ObjList;
|
||||
lst->append(new String(w->id()));
|
||||
}
|
||||
}
|
||||
return lst;
|
||||
}
|
||||
|
||||
bool Client::setVisible(const String& name, bool show)
|
||||
{
|
||||
Window* w = getWindow(name);
|
||||
|
@ -375,6 +396,8 @@ bool Client::action(Window* wnd, const String& name)
|
|||
}
|
||||
}
|
||||
Message* m = new Message("ui.event");
|
||||
if (wnd)
|
||||
m->addParam("window",wnd->id());
|
||||
m->addParam("event","action");
|
||||
m->addParam("name",name);
|
||||
Engine::enqueue(m);
|
||||
|
@ -389,6 +412,8 @@ bool Client::toggle(Window* wnd, const String& name, bool active)
|
|||
return true;
|
||||
setCheck(name,active,0,wnd);
|
||||
Message* m = new Message("ui.event");
|
||||
if (wnd)
|
||||
m->addParam("window",wnd->id());
|
||||
m->addParam("event","toggle");
|
||||
m->addParam("name",name);
|
||||
m->addParam("active",String::boolText(active));
|
||||
|
@ -402,6 +427,8 @@ bool Client::select(Window* wnd, const String& name, const String& item)
|
|||
name.c_str(),item.c_str(),wnd);
|
||||
setSelect(name,item,0,wnd);
|
||||
Message* m = new Message("ui.event");
|
||||
if (wnd)
|
||||
m->addParam("window",wnd->id());
|
||||
m->addParam("event","select");
|
||||
m->addParam("name",name);
|
||||
m->addParam("item",item);
|
||||
|
|
|
@ -1031,10 +1031,11 @@ void YateH323Connection::OnCleared()
|
|||
{
|
||||
int reason = GetCallEndReason();
|
||||
const char* rtext = CallEndReasonText(reason);
|
||||
Debug(m_chan,DebugInfo,"YateH323Connection::OnCleared() reason: %s (%d) [%p]",
|
||||
rtext,reason,this);
|
||||
const char* error = lookup(reason,dict_errors);
|
||||
Debug(m_chan,DebugInfo,"YateH323Connection::OnCleared() error: '%s' reason: %s (%d) [%p]",
|
||||
error,rtext,reason,this);
|
||||
if (m_chan)
|
||||
m_chan->disconnect(rtext);
|
||||
m_chan->disconnect(error ? error : rtext);
|
||||
}
|
||||
|
||||
BOOL YateH323Connection::OnAlerting(const H323SignalPDU &alertingPDU, const PString &user)
|
||||
|
|
|
@ -888,8 +888,9 @@ void YateSIPConnection::hangup()
|
|||
if (m_hungup)
|
||||
return;
|
||||
m_hungup = true;
|
||||
DDebug(this,DebugAll,"YateSIPConnection::hangup() state=%d trans=%p code=%d reason='%s' [%p]",
|
||||
m_state,m_tr,m_reasonCode,m_reason.c_str(),this);
|
||||
const char* error = lookup(m_reasonCode,dict_errors);
|
||||
Debug(this,DebugAll,"YateSIPConnection::hangup() state=%d trans=%p error='%s' code=%d reason='%s' [%p]",
|
||||
m_state,m_tr,error,m_reasonCode,m_reason.c_str(),this);
|
||||
Message* m = message("chan.hangup");
|
||||
if (m_reason)
|
||||
m->addParam("reason",m_reason);
|
||||
|
@ -935,7 +936,9 @@ void YateSIPConnection::hangup()
|
|||
plugin.ep()->engine()->addMessage(m);
|
||||
m->deref();
|
||||
}
|
||||
disconnect(m_reason);
|
||||
if (!error)
|
||||
error = m_reason.c_str();
|
||||
disconnect(error);
|
||||
}
|
||||
|
||||
// Creates a new message in an existing dialog
|
||||
|
@ -1357,8 +1360,13 @@ void YateSIPConnection::doCancel(SIPTransaction* t)
|
|||
void YateSIPConnection::disconnected(bool final, const char *reason)
|
||||
{
|
||||
Debug(this,DebugAll,"YateSIPConnection::disconnected() '%s' [%p]",reason,this);
|
||||
if (reason)
|
||||
setReason(reason);
|
||||
int code = lookup(reason,dict_errors);
|
||||
if (reason) {
|
||||
if (code)
|
||||
setReason(lookup(code,SIPResponses,reason),code);
|
||||
else
|
||||
setReason(reason);
|
||||
}
|
||||
Channel::disconnected(final,reason);
|
||||
}
|
||||
|
||||
|
|
|
@ -48,6 +48,7 @@ public:
|
|||
Window(const char* id = 0);
|
||||
virtual ~Window();
|
||||
virtual const String& toString() const;
|
||||
virtual void title(const String& text);
|
||||
virtual bool setActive(const String& name, bool active) = 0;
|
||||
virtual bool setShow(const String& name, bool visible) = 0;
|
||||
virtual bool setText(const String& name, const String& text) = 0;
|
||||
|
@ -68,6 +69,8 @@ public:
|
|||
virtual void menu(int x, int y) = 0;
|
||||
inline const String& id() const
|
||||
{ return m_id; }
|
||||
inline const String& title() const
|
||||
{ return m_title; }
|
||||
inline bool visible() const
|
||||
{ return m_visible; }
|
||||
inline void visible(bool yes)
|
||||
|
@ -76,6 +79,7 @@ public:
|
|||
{ return m_master; }
|
||||
protected:
|
||||
String m_id;
|
||||
String m_title;
|
||||
bool m_visible;
|
||||
bool m_master;
|
||||
};
|
||||
|
@ -141,6 +145,7 @@ public:
|
|||
static Window* getWindow(const String& name);
|
||||
static bool setVisible(const String& name, bool show = true);
|
||||
static bool getVisible(const String& name);
|
||||
static ObjList* listWindows();
|
||||
protected:
|
||||
virtual void loadWindows() = 0;
|
||||
virtual void initWindows();
|
||||
|
|
Loading…
Reference in New Issue