Fawkes API  Fawkes Development Version
service_selector_cbe.h
1 
2 /***************************************************************************
3  * service_selector_cbe.h - Manages list of discovered services of given type
4  *
5  * Created: Mon Sep 29 17:34:58 2008
6  * Copyright 2008 Daniel Beck
7  * 2008 Tim Niemueller [www.niemueller.de]
8  *
9  ****************************************************************************/
10 
11 /* This program is free software; you can redistribute it and/or modify
12  * it under the terms of the GNU General Public License as published by
13  * the Free Software Foundation; either version 2 of the License, or
14  * (at your option) any later version. A runtime exception applies to
15  * this software (see LICENSE.GPL_WRE file mentioned below for details).
16  *
17  * This program is distributed in the hope that it will be useful,
18  * but WITHOUT ANY WARRANTY; without even the implied warranty of
19  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20  * GNU Library General Public License for more details.
21  *
22  * Read the full text in the LICENSE.GPL_WRE file in the doc directory.
23  */
24 
25 #ifndef __LIBS_GUI_UTILS_SERVICE_SELECTOR_CBE_H_
26 #define __LIBS_GUI_UTILS_SERVICE_SELECTOR_CBE_H_
27 
28 #include <netcomm/fawkes/client_handler.h>
29 
30 #include <gtkmm.h>
31 #ifdef HAVE_GLADEMM
32 # include <libglademm/xml.h>
33 #endif
34 
35 namespace fawkes {
36 #if 0 /* just to make Emacs auto-indent happy */
37 }
38 #endif
39 
40 class FawkesNetworkClient;
41 class ServiceModel;
42 class ConnectionDispatcher;
43 
45 {
46  public:
47 #if GTK_VERSION_GE(3,0)
48  ServiceSelectorCBE( Gtk::ComboBox* services,
49  Gtk::Button* connect,
50  Gtk::Window* parent,
51  const char* service = "_fawkes._tcp" );
52  ServiceSelectorCBE( Gtk::ComboBox* services,
53  Gtk::ToolButton* connect,
54  Gtk::Window* parent,
55  const char* service = "_fawkes._tcp" );
56 #else
57  ServiceSelectorCBE( Gtk::ComboBoxEntry* services,
58  Gtk::Button* connect,
59  Gtk::Window* parent,
60  const char* service = "_fawkes._tcp" );
61  ServiceSelectorCBE( Gtk::ComboBoxEntry* services,
62  Gtk::ToolButton* connect,
63  Gtk::Window* parent,
64  const char* service = "_fawkes._tcp" );
65 #endif
66  ServiceSelectorCBE( Glib::RefPtr<Gtk::Builder> builder,
67  const char* cbe_name = "cbeServices",
68  const char* btn_name = "btnConnect",
69  const char* wnd_name = "wndMain",
70  const char* service = "_fawkes._tcp" );
71  virtual ~ServiceSelectorCBE();
72 
74  Glib::ustring get_hostname();
75  Glib::ustring get_name();
76  unsigned int get_port();
77 
78  sigc::signal<void> signal_connected();
79  sigc::signal<void> signal_disconnected();
80 
81  protected:
82  void initialize();
84  void on_service_selected();
85  void on_connected();
86  void on_disconnected();
87 
88  protected:
89 #if GTK_VERSION_GE(3,0)
90  Gtk::ComboBox *m_cbe_services;
91 #else
92  Gtk::ComboBoxEntry *m_cbe_services;
93 #endif
94  Gtk::Button *m_btn_connect;
95  Gtk::ToolButton *m_tbtn_connect;
96  Gtk::Window *m_parent;
97 
100 
101  private:
102  Glib::ustring __hostname;
103  Glib::ustring __servicename;
104  unsigned short __port;
105 };
106 
107 }
108 #endif /* __LIBS_GUI_UTILS_SERVICE_SELECTOR_CBE_H_ */
Abstract base class for widgets that allow to view the detected services of a certain type...
Definition: service_model.h:34
void on_btn_connect_clicked()
Signal handler that is called whenever the connect button is clicked or an entry in the combo box is ...
Simple Fawkes network client.
Definition: client.h:52
Gtk::Window * m_parent
The parent Gtk::Window.
sigc::signal< void > signal_disconnected()
This signal is emitted whenever a network connection is terminated.
void on_disconnected()
Signal handler for the connection terminated signal.
Fawkes library namespace.
void initialize()
Initializer method.
unsigned int get_port()
Returns the currently used port (after connect)
ServiceModel * m_service_model
A liststore which contains information about detected services.
Gtk::ComboBoxEntry * m_cbe_services
A Gtk::ComboBox that lists all available services.
ServiceSelectorCBE(Gtk::ComboBoxEntry *services, Gtk::Button *connect, Gtk::Window *parent, const char *service="_fawkes._tcp")
Construtor.
Glib::ustring get_name()
Returns the currently selected service name (after connect)
void on_service_selected()
Signal handler that is called whenever an entry is selected from the combo box.
Glib::ustring get_hostname()
Returns the currently selected hostname (after connect)
ConnectionDispatcher * m_dispatcher
A ConnectionDispatcher which dispatches connection signals.
FawkesNetworkClient * get_network_client()
Access the current network client.
void on_connected()
Signal handler for the connection established signal.
Gtk::ToolButton * m_tbtn_connect
A Gtk::ToolButton that triggers the connection.
sigc::signal< void > signal_connected()
This signal is emitted whenever a network connection is established.
Gtk::Button * m_btn_connect
A Gtk::Button that triggers the connection.
Watches network client events and dispatches them as signals.
virtual ~ServiceSelectorCBE()
Destructor.
This widget consists of a Gtk::ComboBox and a Gtk::Button.