Code

Win32 post-GSoC fixups.
[inkscape.git] / src / jabber_whiteboard / dialog / choose-desktop.cpp
1 /**
2  * \brief Choose Desktop dialog
3  *
4  * Authors:
5  *   Dale Harvey <harveyd@gmail.com>
6  *
7  * Copyright (C) 2006 Authors
8  *
9  * Released under GNU GPL.  Read the file 'COPYING' for more information.
10  */
12 #include "choose-desktop.h"
14 #include "document.h"
15 #include "desktop-handles.h"
16 #include "inkscape.h"
18 namespace Inkscape {
19 namespace Whiteboard {
21 void ChooseDesktop::okCallback()
22 {
23     response(Gtk::RESPONSE_OK);
24     hide();
25 }
27 void ChooseDesktop::cancelCallback()
28 {
29     response(Gtk::RESPONSE_CANCEL);
30     hide();
31 }
33 void ChooseDesktop::doubleClickCallback(
34                    const Gtk::TreeModel::Path & /*path*/,
35                    Gtk::TreeViewColumn * /*col*/)
36 {
37     response(Gtk::RESPONSE_OK);
38     hide();
39 }
42 SPDesktop* ChooseDesktop::getDesktop()
43 {
44     Glib::RefPtr<Gtk::TreeModel> model = desktopView.get_model();
45     Glib::RefPtr<Gtk::TreeSelection> sel = desktopView.get_selection();
46     Gtk::TreeModel::iterator iter = sel->get_selected();
47     return iter->get_value(desktopColumns.desktopColumn);
48 }
51 bool ChooseDesktop::doSetup()
52 {
53     set_title("Choose Desktop");
54     set_size_request(300,400);
56     add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);
57     add_button(Gtk::Stock::OPEN,   Gtk::RESPONSE_OK);
59     desktopView.signal_row_activated().connect(
60         sigc::mem_fun(*this, &ChooseDesktop::doubleClickCallback) );
62     std::list< SPDesktop* > desktops;
63     inkscape_get_all_desktops(desktops);
65     desktopListStore = Gtk::ListStore::create(desktopColumns);
66     desktopView.set_model(desktopListStore);
68     std::list< SPDesktop* >::iterator p = desktops.begin();
69     while(p != desktops.end())
70     {
71         SPDesktop *desktop = (SPDesktop *)*p;
73         Gtk::TreeModel::Row row = *(desktopListStore->append());
74         row[desktopColumns.nameColumn] = desktop->doc()->getName();
75         row[desktopColumns.desktopColumn] = (SPDesktop *)*p;
76         p++;
77     }
79     Gtk::TreeModel::Row row = *(desktopListStore->append());
80     row[desktopColumns.nameColumn] = "Blank Document";
81     row[desktopColumns.desktopColumn] = NULL;
83     desktopView.append_column("Desktop", desktopColumns.nameColumn);
85     desktopScroll.add(desktopView);
86     desktopScroll.set_policy(Gtk::POLICY_ALWAYS, Gtk::POLICY_ALWAYS);
88     get_vbox()->pack_start(desktopScroll);
90     show_all_children();
92     return true;
93 }
95 }
96 }
98 /*
99   Local Variables:
100   mode:c++
101   c-file-style:"stroustrup"
102   c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
103   indent-tabs-mode:nil
104   fill-column:99
105   End:
106 */
107 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :