00001 /*************************************************************************** 00002 * Copyright (C) 2001 by Rick L. Vinyard, Jr. * 00003 * rvinyard@cs.nmsu.edu * 00004 * * 00005 * This file is part of the conexus library. * 00006 * * 00007 * The conexus library is free software; you can redistribute it and/or * 00008 * modify it under the terms of the GNU General Public License * 00009 * version 3 as published by the Free Software Foundation. * 00010 * * 00011 * The conexus library is distributed in the hope that it will be * 00012 * useful, but WITHOUT ANY WARRANTY; without even the implied warranty * 00013 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * 00014 * General Public License for more details. * 00015 * * 00016 * You should have received a copy of the GNU General Public License * 00017 * along with this software. If not see <http://www.gnu.org/licenses/>. * 00018 ***************************************************************************/ 00019 #ifndef CONEXUSGTKMMENDPOINTSTARTSTOPBUTTON_H 00020 #define CONEXUSGTKMMENDPOINTSTARTSTOPBUTTON_H 00021 00022 #include <map> 00023 #include <gtkmm.h> 00024 00025 #include <conexus/conexus-config.h> 00026 #include <conexus/endpoint.h> 00027 00028 #ifdef CONEXUS_HAVE_DBUS 00029 #include <conexus-dbus.h> 00030 #endif 00031 00032 namespace Conexus 00033 { 00034 namespace Gtk 00035 { 00036 00042 class EndpointStartStopButton : public ::Gtk::CheckButton 00043 { 00044 public: 00045 00051 EndpointStartStopButton ( Conexus::Endpoint::pointer endpoint = Conexus::Endpoint::pointer(), 00052 bool show_text = true, 00053 bool show_image = true ); 00054 00055 #ifdef CONEXUS_HAVE_DBUS 00056 00057 EndpointStartStopButton ( Conexus::DBus::EndpointProxy::pointer proxy, 00058 bool show_text = true, 00059 bool show_image = true ); 00060 #endif 00061 00063 ~EndpointStartStopButton(); 00064 00075 void set_endpoint( Conexus::Endpoint::pointer endpoint ); 00076 00078 void unset_endpoint(); 00079 00081 Conexus::Endpoint::pointer endpoint(); 00082 00083 #ifdef CONEXUS_HAVE_DBUS 00084 00093 void set_proxy ( Conexus::DBus::EndpointProxy::pointer proxy ); 00094 00098 Conexus::DBus::EndpointProxy::pointer proxy(); 00099 #endif 00100 00102 const Glib::ustring& start_text(); 00103 00105 const Glib::ustring& stop_text(); 00106 00111 void set_start_text ( const Glib::ustring& text ); 00112 00116 void set_start_text_to_default(); 00117 00122 void set_stop_text ( const Glib::ustring& text ); 00123 00127 void set_stop_text_to_default(); 00128 00130 bool is_text_visible(); 00131 00133 void show_text( ); 00134 00136 void hide_text(); 00137 00139 const ::Gtk::Image& start_image(); 00140 00142 const ::Gtk::Image& stop_image(); 00143 00145 void set_start_image ( ::Gtk::Image& image ); 00146 00148 void set_start_image_to_default(); 00149 00151 void set_stop_image ( ::Gtk::Image& image ); 00152 00154 void set_stop_image_to_default(); 00155 00157 bool is_image_visible(); 00158 00160 void show_image( ); 00161 00163 void hide_image( ); 00164 00165 protected: 00167 Conexus::Endpoint::pointer m_endpoint; 00168 00169 #ifdef CONEXUS_HAVE_DBUS 00170 00171 Conexus::DBus::EndpointProxy::pointer m_proxy; 00172 #endif 00173 00175 ::Gtk::HBox m_hbox; 00176 00178 ::Gtk::EventBox m_imagebox; 00179 00181 ::Gtk::Label m_text; 00182 00184 Glib::ustring m_start_text; 00185 00187 Glib::ustring m_stop_text; 00188 00190 ::Gtk::Image* m_start_image; 00191 00193 ::Gtk::Image m_default_start_image; 00194 00196 ::Gtk::Image* m_stop_image; 00197 00199 ::Gtk::Image m_default_stop_image; 00200 00205 sigc::connection m_endpoint_start_stop_connection; 00206 00208 void on_button_toggled(); 00209 00211 void update_display( ); 00212 00216 void on_external_start_stop( StartStop ); 00217 00219 void initialize(bool show_text, bool show_image); 00220 00221 }; 00222 00223 } 00224 00225 } 00226 00227 #endif