Fawkes API Fawkes Development Version
interface_chooser_dialog.h
1/***************************************************************************
2 * interface_chooser_dialog.h - Dialog for choosing a blackboard interface
3 *
4 * Created: Sat Mar 19 12:18:43 2011
5 * Copyright 2008-2011 Tim Niemueller [www.niemueller.de]
6 * Copyright 2011 Christoph Schwering
7 *
8 ****************************************************************************/
9
10/* This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version. A runtime exception applies to
14 * this software (see LICENSE.GPL_WRE file mentioned below for details).
15 *
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU Library General Public License for more details.
20 *
21 * Read the full text in the LICENSE.GPL_WRE file in the doc directory.
22 */
23
24#ifndef _LIBS_GUI_UTILS_INTERFACE_CHOOSER_DIALOG_H_
25#define _LIBS_GUI_UTILS_INTERFACE_CHOOSER_DIALOG_H_
26
27#include <gtkmm/dialog.h>
28#include <gtkmm/entry.h>
29#include <gtkmm/expander.h>
30#include <gtkmm/liststore.h>
31#include <gtkmm/scrolledwindow.h>
32#include <gtkmm/treeview.h>
33
34namespace fawkes {
35
36class Interface;
37class BlackBoard;
38class InterfaceInfo;
39
40class InterfaceChooserDialog : public Gtk::Dialog
41{
42public:
43 static const char *const DEFAULT_TITLE;
44
45 static InterfaceChooserDialog *create(Gtk::Window & parent,
46 BlackBoard * blackboard,
47 const char * type_pattern,
48 const char * id_pattern,
49 const Glib::ustring &title = DEFAULT_TITLE);
50
52
53 void get_selected_interface(Glib::ustring &type, Glib::ustring &id);
54
56
57protected:
58 class Record : public Gtk::TreeModelColumnRecord
59 {
60 public:
61 Record();
62
63 Gtk::TreeModelColumn<Glib::ustring> type; /**< The type of the interface */
64 Gtk::TreeModelColumn<Glib::ustring> id; /**< The ID of the interface */
65 Gtk::TreeModelColumn<bool> has_writer; /**< Writer exists? */
66 Gtk::TreeModelColumn<unsigned int> num_readers; /**< Number of readers */
67 };
68
69 InterfaceChooserDialog(Gtk::Window &parent, const Glib::ustring &title);
70
71 void init(BlackBoard *blackboard, const char *type_pattern, const char *id_pattern);
72
73 virtual const Record &record() const;
74 virtual int init_columns();
75 virtual void init_row(Gtk::TreeModel::Row &row, const InterfaceInfo &ii);
76
77 Gtk::TreeView treeview_; /**< Tree widget for interfaces. */
78 Glib::RefPtr<Gtk::ListStore> model_; /**< Data model of the tree. */
79
80private:
83
84 BlackBoard *bb_;
85
86 Gtk::Window & parent_;
87 Gtk::ScrolledWindow scrollwin_;
88
89 const Record *record_; /**< Should only be accessed by record(). */
90};
91
92} // end of namespace fawkes
93
94#endif
InterfaceInfo representation for JSON transfer.
Definition: InterfaceInfo.h:31
The BlackBoard abstract class.
Definition: blackboard.h:46
Gtk::TreeModelColumn< bool > has_writer
Writer exists?
Gtk::TreeModelColumn< Glib::ustring > id
The ID of the interface.
Gtk::TreeModelColumn< Glib::ustring > type
The type of the interface.
Gtk::TreeModelColumn< unsigned int > num_readers
Number of readers.
Blackboard interface chooser dialog.
virtual int init_columns()
Initializes the columns GUI-wise.
Gtk::TreeView treeview_
Tree widget for interfaces.
static const char *const DEFAULT_TITLE
Default title of interface chooser dialogs.
void init(BlackBoard *blackboard, const char *type_pattern, const char *id_pattern)
Initialization method.
void get_selected_interface(Glib::ustring &type, Glib::ustring &id)
Get selected interface type and ID.
virtual void init_row(Gtk::TreeModel::Row &row, const InterfaceInfo &ii)
Initializes a row with the given interface.
virtual const Record & record() const
Returns the Record of this chooser dialog.
Glib::RefPtr< Gtk::ListStore > model_
Data model of the tree.
InterfaceChooserDialog(Gtk::Window &parent, const Glib::ustring &title)
Constructor for subclasses.
static InterfaceChooserDialog * create(Gtk::Window &parent, BlackBoard *blackboard, const char *type_pattern, const char *id_pattern, const Glib::ustring &title=DEFAULT_TITLE)
Factory method.
fawkes::Interface * run_and_open_for_reading()
Run dialog and try to connect.
Interface info.
Base class for all Fawkes BlackBoard interfaces.
Definition: interface.h:80
Fawkes library namespace.