Fawkes API  Fawkes Development Version
service_chooser_dialog.h
1 
2 /***************************************************************************
3  * service_chooser_dialog.cpp - Dialog for choosing a network service
4  *
5  * Created: Sun Oct 12 17:06:06 2008 (split from lasergui_hildon.cpp)
6  * Copyright 2008 Tim Niemueller [www.niemueller.de]
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_SERVICE_CHOOSER_DIALOG_H_
25 #define __LIBS_GUI_UTILS_SERVICE_CHOOSER_DIALOG_H_
26 
27 #include <gui_utils/service_model.h>
28 
29 #include <gtkmm/dialog.h>
30 #include <gtkmm/treeview.h>
31 #include <gtkmm/entry.h>
32 #include <gtkmm/expander.h>
33 #include <gtkmm/scrolledwindow.h>
34 
35 #include <sys/types.h>
36 #include <sys/socket.h>
37 
38 namespace fawkes {
39 
40 class FawkesNetworkClient;
41 class ServiceModel;
42 
44  : public Gtk::Dialog
45 {
46  public:
47  ServiceChooserDialog(Gtk::Window &parent,
48  FawkesNetworkClient *client,
49  Glib::ustring title = "Select Service",
50  const char *service = "_fawkes._tcp");
51 
52  ServiceChooserDialog(Gtk::Window &parent,
53  Glib::ustring title = "Select Service",
54  const char *service = "_fawkes._tcp");
55 
56  virtual ~ServiceChooserDialog();
57 
58  void get_selected_service(Glib::ustring &name, Glib::ustring &hostname,
59  Glib::ustring &ipaddr, unsigned short int &port);
60  void get_raw_address(struct sockaddr *addr, socklen_t addr_size);
61 
62  void run_and_connect();
63 
64  protected:
65  virtual void on_expander_changed();
66 
67  private:
68  void ctor();
70 
71  Gtk::Window &__parent;
72  Gtk::TreeView __treeview;
73  Gtk::Entry __entry;
74  Gtk::Expander __expander;
75  Gtk::ScrolledWindow __scrollwin;
76 
77  ServiceModel *__service_model;
78 };
79 
80 } // end of namespace fawkes
81 
82 #endif
Abstract base class for widgets that allow to view the detected services of a certain type...
Definition: service_model.h:34
virtual void on_expander_changed()
Signal handler for expander event.
Simple Fawkes network client.
Definition: client.h:51
Fawkes library namespace.
ServiceChooserDialog(Gtk::Window &parent, FawkesNetworkClient *client, Glib::ustring title="Select Service", const char *service="_fawkes._tcp")
Constructor.
void run_and_connect()
Run dialog and try to connect.
void get_raw_address(struct sockaddr *addr, socklen_t addr_size)
Get raw address.
virtual ~ServiceChooserDialog()
Destructor.
void get_selected_service(Glib::ustring &name, Glib::ustring &hostname, Glib::ustring &ipaddr, unsigned short int &port)
Get selected service.