From 56e89cd8fa5844ba2f76de87ee225fe40bc864bb Mon Sep 17 00:00:00 2001 From: daleharvey Date: Thu, 20 Jul 2006 01:19:09 +0000 Subject: [PATCH] added choose desktop dialog during intialising a whiteboard session --- src/jabber_whiteboard/Makefile_insert | 2 + .../dialog/choose-desktop.cpp | 107 ++++++++++++++++++ src/jabber_whiteboard/dialog/choose-desktop.h | 66 +++++++++++ src/jabber_whiteboard/session-manager.cpp | 38 +++++-- 4 files changed, 205 insertions(+), 8 deletions(-) create mode 100644 src/jabber_whiteboard/dialog/choose-desktop.cpp create mode 100644 src/jabber_whiteboard/dialog/choose-desktop.h diff --git a/src/jabber_whiteboard/Makefile_insert b/src/jabber_whiteboard/Makefile_insert index b5d1941ed..e3966086e 100644 --- a/src/jabber_whiteboard/Makefile_insert +++ b/src/jabber_whiteboard/Makefile_insert @@ -34,6 +34,8 @@ jabber_whiteboard_SOURCES = \ jabber_whiteboard/session-file-selector.cpp \ jabber_whiteboard/session-file-selector.h \ jabber_whiteboard/session-manager.cpp \ + jabber_whiteboard/dialog/choose-desktop.cpp \ + jabber_whiteboard/dialog/choose-desktop.h \ jabber_whiteboard/session-manager.h \ jabber_whiteboard/tracker-node.h \ jabber_whiteboard/pedrogui.cpp \ diff --git a/src/jabber_whiteboard/dialog/choose-desktop.cpp b/src/jabber_whiteboard/dialog/choose-desktop.cpp new file mode 100644 index 000000000..862b6cb33 --- /dev/null +++ b/src/jabber_whiteboard/dialog/choose-desktop.cpp @@ -0,0 +1,107 @@ +/** + * \brief Choose Desktop dialog + * + * Authors: + * Dale Harvey + * + * Copyright (C) 2006 Authors + * + * Released under GNU GPL. Read the file 'COPYING' for more information. + */ + +#include "choose-desktop.h" + +#include "document.h" +#include "desktop-handles.h" +#include "inkscape.h" + +namespace Inkscape { +namespace Whiteboard { + +void ChooseDesktop::okCallback() +{ + response(Gtk::RESPONSE_OK); + hide(); +} + +void ChooseDesktop::cancelCallback() +{ + response(Gtk::RESPONSE_CANCEL); + hide(); +} + +void ChooseDesktop::doubleClickCallback( + const Gtk::TreeModel::Path &path, + Gtk::TreeViewColumn *col) +{ + response(Gtk::RESPONSE_OK); + hide(); +} + + +SPDesktop* ChooseDesktop::getDesktop() +{ + Glib::RefPtr model = desktopView.get_model(); + Glib::RefPtr sel = desktopView.get_selection(); + Gtk::TreeModel::iterator iter = sel->get_selected(); + return iter->get_value(desktopColumns.desktopColumn); +} + + +bool ChooseDesktop::doSetup() +{ + set_title("Choose Desktop"); + set_size_request(300,400); + + add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL); + add_button(Gtk::Stock::OPEN, Gtk::RESPONSE_OK); + + desktopView.signal_row_activated().connect( + sigc::mem_fun(*this, &ChooseDesktop::doubleClickCallback) ); + + std::list< SPDesktop* > desktops; + inkscape_get_all_desktops(desktops); + + desktopListStore = Gtk::ListStore::create(desktopColumns); + desktopView.set_model(desktopListStore); + + std::list< SPDesktop* >::iterator p = desktops.begin(); + while(p != desktops.end()) + { + SPDesktop *desktop = (SPDesktop *)*p; + + Gtk::TreeModel::Row row = *(desktopListStore->append()); + row[desktopColumns.nameColumn] = (desktop->doc())->name; + row[desktopColumns.desktopColumn] = (SPDesktop *)*p; + p++; + } + + Gtk::TreeModel::Row row = *(desktopListStore->append()); + row[desktopColumns.nameColumn] = "Blank Document"; + row[desktopColumns.desktopColumn] = NULL; + + desktopView.append_column("Desktop", desktopColumns.nameColumn); + + desktopScroll.add(desktopView); + desktopScroll.set_policy(Gtk::POLICY_ALWAYS, Gtk::POLICY_ALWAYS); + + get_vbox()->pack_start(desktopScroll); + + show_all_children(); + + return true; +} + +} +} + +/* + Local Variables: + mode:c++ + c-file-style:"stroustrup" + c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) + indent-tabs-mode:nil + fill-column:99 + End: +*/ +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 : diff --git a/src/jabber_whiteboard/dialog/choose-desktop.h b/src/jabber_whiteboard/dialog/choose-desktop.h new file mode 100644 index 000000000..8b26a5545 --- /dev/null +++ b/src/jabber_whiteboard/dialog/choose-desktop.h @@ -0,0 +1,66 @@ +/** + * \brief Choose Desktop dialog + * + * Authors: + * Dale Harvey + * + * Copyright (C) 2006 Authors + * + * Released under GNU GPL. Read the file 'COPYING' for more information. + */ + +#include + +#include "desktop.h" + +namespace Inkscape { +namespace Whiteboard { + +class ChooseDesktop : public Gtk::Dialog +{ +public: + + ChooseDesktop() + { doSetup(); } + + virtual ~ChooseDesktop() + {} + + SPDesktop* getDesktop(); + +private: + + void okCallback(); + void cancelCallback(); + + void doubleClickCallback( + const Gtk::TreeModel::Path &path, + Gtk::TreeViewColumn *col); + + bool doSetup(); + + class DesktopColumns : public Gtk::TreeModel::ColumnRecord + { + public: + DesktopColumns() + { + add(nameColumn); + add(desktopColumn); + } + + Gtk::TreeModelColumn nameColumn; + Gtk::TreeModelColumn desktopColumn; + }; + + DesktopColumns desktopColumns; + + Gtk::ScrolledWindow desktopScroll; + Gtk::TreeView desktopView; + + Glib::RefPtr desktopListStore; + +}; + +} +} + diff --git a/src/jabber_whiteboard/session-manager.cpp b/src/jabber_whiteboard/session-manager.cpp index f8ca94612..c8b2420e6 100644 --- a/src/jabber_whiteboard/session-manager.cpp +++ b/src/jabber_whiteboard/session-manager.cpp @@ -19,6 +19,8 @@ #include "xml/node-observer.h" +#include "pedro/pedrodom.h" + #include "document.h" #include "desktop.h" #include "desktop-handles.h" @@ -28,6 +30,8 @@ #include "jabber_whiteboard/inkboard-document.h" #include "jabber_whiteboard/new-inkboard-document.h" +#include "jabber_whiteboard/dialog/choose-desktop.h" + #define INKBOARD_XMLNS "http://inkscape.org/inkboard" namespace Inkscape { @@ -81,7 +85,7 @@ SessionManager::send(const Glib::ustring &destJid, Pedro::DOMString xmlData = Pedro::Parser::encode(data); char *fmt= "" - "%s" "" ""; @@ -214,13 +218,31 @@ SessionManager::processXmppEvent(const Pedro::XmppEvent &event) void SessionManager::doShare(Glib::ustring const& to, SessionType type) { - SPDesktop* dt = createInkboardDesktop(to, type); - if (dt != NULL) { - InkboardDocument* doc = dynamic_cast< InkboardDocument* >(sp_desktop_document(dt)->rdoc); - if (doc != NULL) { - doc->startSessionNegotiation(); - } - } + ChooseDesktop dialog; + int result = dialog.run(); + + if(result == Gtk::RESPONSE_OK) + { + InkboardDocument* doc; + SPDesktop *desktop = dialog.getDesktop(); + + if(desktop == NULL) + { + SPDesktop* dt = createInkboardDesktop(to, type); + if (dt != NULL) + { + doc = dynamic_cast< InkboardDocument* >(sp_desktop_document(dt)->rdoc); + } + }else + { + doc = dynamic_cast< InkboardDocument* >(sp_desktop_document(desktop)->rdoc); + } + + if (doc != NULL) + { + doc->startSessionNegotiation(); + } + } } /** -- 2.30.2