Main Page   Namespace List   Class Hierarchy   Compound List   File List   Namespace Members   Compound Members   File Members  

PrefWindow Class Reference

#include <PrefWindow.h>

Inheritance diagram for PrefWindow:

Inheritance graph
[legend]
Collaboration diagram for PrefWindow:

Collaboration graph
[legend]
List of all members.

Public Methods

 PrefWindow (Config &config_)
 ~PrefWindow ()
bool run ()
virtual void apply_impl ()
virtual void close_impl ()
void changed_cb ()
void ok_cb ()
void apply_cb ()
void cancel_cb ()
const char * get_project_name () const
const char * get_project_path () const
const char * get_A_prefix () const
const char * get_B_prefix () const
const char * get_A_dir () const
const char * get_B_dir () const

Private Methods

void stop ()
void dump () const

Private Attributes

Gnome::UI::FileEntry * m_path_entry
Gtk::Entry * m_proj_name
Gtk::Entry * m_A_prefix
Gtk::Entry * m_B_prefix
Gtk::Entry * m_A_dir
Gtk::Entry * m_B_dir
Configm_config
MergeMapPref m_merge_map_pref
bool m_ignore_callbacks
bool m_changed

Constructor & Destructor Documentation

PrefWindow::PrefWindow Config   config_
 

Definition at line 34 of file PrefWindow.cpp.

References MyPropertyBox::append_page, changed_cb, Config::get_post_delay, Config::get_pre_delay, MergeMapPref::get_vbox, m_A_dir, m_A_prefix, m_B_dir, m_B_prefix, m_config, m_merge_map_pref, m_path_entry, m_proj_name, MergeMapPref::set_post_delay, MergeMapPref::set_pre_delay, and MergeMapPref::show_all.

00035     : MyPropertyBox ("Preferences"),
00036       m_config (config_),
00037       m_merge_map_pref (*this),
00038       m_ignore_callbacks (true),
00039       m_changed (false)
00040 {
00041     trace("PrefWindow::PrefWindow");
00042 
00043     Gtk::VBox*   vbox       = manage (new Gtk::VBox ());
00044     Gtk::Label*  tab1_label = manage (new Gtk::Label ("Project Settings"));
00045     Gtk::Label*  tab2_label = manage (new Gtk::Label ("Merge Map"));
00046 
00047     // Name/Path table
00048 
00049     Gtk::Label* label;
00050     Gtk::Table*  table = manage (new Gtk::Table (2, 2, FALSE));
00051 
00052     label  = manage (new Gtk::Label ("Project Name"));
00053     label->set_justify (Gtk::JUSTIFY_LEFT);
00054     table->attach (*label, 0, 1, 0, 1);
00055     m_proj_name = manage (new Gtk::Entry ());
00056     table->attach (*m_proj_name, 1, 2, 0, 1);
00057     
00058     label  = manage (new Gtk::Label ("Project Path"));
00059     label->set_justify (Gtk::JUSTIFY_LEFT);
00060     table->attach (*label, 0, 1, 1, 2);
00061     m_path_entry = manage (new Gnome::UI::FileEntry ("PathSel", 
00062                                                      "Select Project Path"));
00063     table->attach (*m_path_entry, 1, 2, 1, 2);
00064     vbox->pack_start (*table);
00065 
00066     // Prefixes & directories table
00067     table = manage (new Gtk::Table (2, 4, FALSE));
00068 
00069     label = manage (new Gtk::Label ("Directory A"));
00070     label->set_justify (Gtk::JUSTIFY_LEFT);
00071     table->attach (*label, 0, 1, 0, 1);
00072     m_A_dir = manage (new Gtk::Entry ());
00073     table->attach (*m_A_dir, 1, 2, 0, 1);
00074 
00075     label = manage (new Gtk::Label ("Prefix A"));
00076     label->set_justify (Gtk::JUSTIFY_LEFT);
00077     table->attach (*label, 0, 1, 1, 2);
00078     m_A_prefix = manage (new Gtk::Entry ());
00079     table->attach (*m_A_prefix, 1, 2, 1, 2);
00080 
00081     label = manage (new Gtk::Label ("Directory B"));
00082     label->set_justify (Gtk::JUSTIFY_LEFT);
00083     table->attach (*label, 0, 1, 2, 3);
00084     m_B_dir = manage (new Gtk::Entry ());
00085     table->attach (*m_B_dir, 1, 2, 2, 3);
00086     
00087     label  = manage (new Gtk::Label ("Prefix B"));
00088     label->set_justify (Gtk::JUSTIFY_LEFT);
00089     table->attach (*label, 0, 1, 3, 4);
00090     m_B_prefix = manage (new Gtk::Entry ());
00091     table->attach (*m_B_prefix, 1, 2, 3, 4);
00092     vbox->pack_start (*table);
00093 
00096     m_proj_name->signal_changed().connect (
00097         SigC::slot (*this, &PrefWindow::changed_cb));
00098     m_A_prefix ->signal_changed().connect (
00099         SigC::slot (*this, &PrefWindow::changed_cb));
00100     m_B_prefix ->signal_changed().connect (
00101         SigC::slot (*this, &PrefWindow::changed_cb));
00102     m_A_dir    ->signal_changed().connect (
00103         SigC::slot (*this, &PrefWindow::changed_cb));
00104     m_B_dir    ->signal_changed().connect (
00105         SigC::slot (*this, &PrefWindow::changed_cb));
00106 
00107     Gtk::Entry* entry = 
00108         dynamic_cast<Gtk::Entry*> (m_path_entry->gtk_entry ());
00109     entry->signal_changed().connect (
00110         SigC::slot (*this, &PrefWindow::changed_cb));
00111 
00114     m_merge_map_pref.set_pre_delay (m_config.get_pre_delay ().c_str ());
00115     m_merge_map_pref.set_post_delay (m_config.get_post_delay ().c_str ());
00116 
00119     vbox->show_all ();
00120     m_merge_map_pref.show_all ();
00121 
00122     set_title ("Preferences");
00123     append_page (*vbox, "Project Settings");
00124     append_page (m_merge_map_pref.get_vbox (), "Merge Map");
00125 }

PrefWindow::~PrefWindow   [inline]
 

Definition at line 73 of file PrefWindow.h.

00074 {
00075     trace("PrefWindow::~PrefWindow");
00076     /* no-op */
00077 }


Member Function Documentation

void PrefWindow::apply_cb  
 

void PrefWindow::apply_impl   [virtual]
 

Called in response to pressing Apply button if any changes were reported prior by the derived class.

Implements MyPropertyBox.

Definition at line 173 of file PrefWindow.cpp.

References MergeMapPref::dump, Config::dump, dump, Config::get_A_dir, Config::get_A_prefix, Config::get_B_dir, Config::get_B_prefix, Config::get_post_delay, MergeMapPref::get_post_delay, Config::get_pre_delay, MergeMapPref::get_pre_delay, Config::get_proj_name, Config::get_proj_path, m_A_dir, m_A_prefix, m_B_dir, m_B_prefix, m_changed, m_config, m_merge_map_pref, m_path_entry, m_proj_name, Config::set_A_dir, Config::set_A_prefix, Config::set_B_dir, Config::set_B_prefix, Config::set_post_delay, Config::set_pre_delay, Config::set_proj_name, and Config::set_proj_path.

00174 {
00175     trace("PrefWindow::apply_impl");
00176 
00177     DL((APP,"Preferences(view) state:\n"));
00178     dump ();
00179 
00180     string s = m_proj_name->get_text ();
00181     if (m_config.get_proj_name () != s) {
00182         m_config.set_proj_name (s);
00183         m_changed = true;
00184     }
00185 
00186     s = m_path_entry->get_full_path (true);
00187 #if 0
00188     /* remove bogus last segment of the path */
00189     {
00190         std::string::size_type idx;
00191         idx = s.rfind ("/");
00192         if (idx != std::string::npos) {
00193             s.resize (idx);
00194         }
00195     }
00196 #endif
00197     if (m_config.get_proj_path () != s) {
00198         m_config.set_proj_path (s);
00199         m_changed = true;
00200     }
00201 
00202     s = m_A_prefix->get_text ();
00203     if (m_config.get_A_prefix () != s) {
00204         m_config.set_A_prefix (s);
00205         m_changed = true;
00206     }
00207 
00208     s = m_B_prefix->get_text ();
00209     if (m_config.get_B_prefix () != s) { 
00210         m_config.set_B_prefix  (s);
00211         m_changed = true;
00212     }
00213 
00214     s = m_A_dir->get_text ();
00215     if (m_config.get_A_dir () != s) {
00216         m_config.set_A_dir (s);
00217         m_changed = true;
00218     }
00219 
00220     s = m_B_dir->get_text ();
00221     if (m_config.get_B_dir () != s) {
00222         m_config.set_B_dir (s);
00223         m_changed = true;
00224     }
00225     
00226     m_config.dump ();
00227     m_merge_map_pref.dump ();
00228     
00229     s = m_merge_map_pref.get_pre_delay ();
00230     if (m_config.get_pre_delay () != s) {
00231         m_config.set_pre_delay (s);
00232         m_changed = true;
00233     }
00234 
00235     s = m_merge_map_pref.get_post_delay ();
00236     if (m_config.get_post_delay () != s) {
00237         m_config.set_post_delay (s);
00238         m_changed = true;
00239     }
00240 
00241     DL((APP,"Config(model) state:\n"));
00242     m_config.dump ();
00243 }

void PrefWindow::cancel_cb  
 

void PrefWindow::changed_cb   [inline]
 

Definition at line 153 of file PrefWindow.h.

References MyPropertyBox::changed, and m_ignore_callbacks.

Referenced by PrefWindow.

00154 {
00155     trace("PrefWindow::changed_cb");
00156     if (!m_ignore_callbacks) {
00157         changed ();
00158     }
00159 }

void PrefWindow::close_impl   [inline, virtual]
 

Called in response to pressing Close button.

Implements MyPropertyBox.

Definition at line 163 of file PrefWindow.h.

References stop.

00164 {
00165     trace("PrefWindow::close_impl");
00166     stop ();
00167 }

void PrefWindow::dump   const [private]
 

Definition at line 247 of file PrefWindow.cpp.

References m_A_dir, m_A_prefix, m_B_dir, m_B_prefix, m_path_entry, and m_proj_name.

Referenced by apply_impl.

00248 {
00249     DL((TRACE,"proj_name : \"%s\"\n", m_proj_name->get_text ().c_str ()));
00250     DL((TRACE,"proj_path : \"%s\"\n", 
00251         m_path_entry->get_full_path (true).c_str ()));
00252     DL((TRACE,"A_prefix  : \"%s\"\n", m_A_prefix->get_text ().c_str ()));
00253     DL((TRACE,"B_prefix  : \"%s\"\n", m_B_prefix->get_text ().c_str ()));
00254     DL((TRACE,"A_dir     : \"%s\"\n", m_A_dir->get_text ().c_str ()));
00255     DL((TRACE,"B_dir     : \"%s\"\n", m_B_dir->get_text ().c_str ()));
00256 }

const char * PrefWindow::get_A_dir   const [inline]
 

Definition at line 109 of file PrefWindow.h.

References m_A_dir.

00110 { 
00111     return m_A_dir->get_text ().c_str (); 
00112 }

const char * PrefWindow::get_A_prefix   const [inline]
 

Definition at line 95 of file PrefWindow.h.

References m_A_prefix.

00096 { 
00097     return m_A_prefix->get_text ().c_str (); 
00098 }

const char * PrefWindow::get_B_dir   const [inline]
 

Definition at line 116 of file PrefWindow.h.

References m_B_dir.

00117 { 
00118     return m_B_dir->get_text ().c_str (); 
00119 }

const char * PrefWindow::get_B_prefix   const [inline]
 

Definition at line 102 of file PrefWindow.h.

References m_B_prefix.

00103 { 
00104     return m_B_prefix->get_text ().c_str (); 
00105 }

const char * PrefWindow::get_project_name   const [inline]
 

Definition at line 81 of file PrefWindow.h.

References m_proj_name.

00082 { 
00083     return m_proj_name->get_text ().c_str (); 
00084 }

const char * PrefWindow::get_project_path   const [inline]
 

Definition at line 88 of file PrefWindow.h.

References m_path_entry.

00089 { 
00090     return m_path_entry->get_full_path (false).c_str (); 
00091 }

void PrefWindow::ok_cb  
 

bool PrefWindow::run  
 

Apply project setting to the window and show the dialog. Enter recursive event loop.

NOTE: Modifying Gtk::Entry fields would trigger a callback changed_cb() in gtk2. It wasn't so in gtk1.2. To cope with this *feature*, we block off callback actions for the duration of the widgets' initalization.

Return: an indication if any of the preferences were changed.

Definition at line 141 of file PrefWindow.cpp.

References Config::get_A_dir, Config::get_A_prefix, Config::get_B_dir, Config::get_B_prefix, Config::get_proj_name, Config::get_proj_path, m_A_dir, m_A_prefix, MyPropertyBox::m_apply_button, m_B_dir, m_B_prefix, m_changed, m_config, m_ignore_callbacks, m_path_entry, and m_proj_name.

Referenced by MainWindow::change_preferences.

00142 {
00143     trace("PrefWindow::run");
00144 
00145     m_ignore_callbacks = true;  
00146     m_changed = false;
00147 
00148     m_proj_name->set_text (m_config.get_proj_name ());
00149 
00150     m_path_entry->set_directory_entry ();
00151     m_path_entry->set_default_path (m_config.get_proj_path ());
00152 
00153     Gtk::Entry* entry = 
00154         dynamic_cast<Gtk::Entry*> (m_path_entry->gtk_entry ());
00155     entry->set_text (m_config.get_proj_path ());
00156 
00157     m_A_prefix->set_text (m_config.get_A_prefix ());
00158     m_B_prefix->set_text (m_config.get_B_prefix ());
00159 
00160     m_A_dir->set_text (m_config.get_A_dir ());
00161     m_B_dir->set_text (m_config.get_B_dir ());
00162 
00163     m_ignore_callbacks = false;
00164     m_apply_button->set_sensitive (false);
00165 
00166     show ();
00167     Gtk::Main::run ();
00168     return m_changed;
00169 }

void PrefWindow::stop   [inline, private]
 

Definition at line 133 of file PrefWindow.h.

Referenced by close_impl.

00134 {
00135     trace("PrefWindow::stop");
00136     hide ();
00137     Gtk::Main::quit ();
00138 }


Member Data Documentation

Gtk::Entry* PrefWindow::m_A_dir [private]
 

Definition at line 62 of file PrefWindow.h.

Referenced by apply_impl, dump, get_A_dir, PrefWindow, and run.

Gtk::Entry* PrefWindow::m_A_prefix [private]
 

Definition at line 60 of file PrefWindow.h.

Referenced by apply_impl, dump, get_A_prefix, PrefWindow, and run.

Gtk::Entry* PrefWindow::m_B_dir [private]
 

Definition at line 63 of file PrefWindow.h.

Referenced by apply_impl, dump, get_B_dir, PrefWindow, and run.

Gtk::Entry* PrefWindow::m_B_prefix [private]
 

Definition at line 61 of file PrefWindow.h.

Referenced by apply_impl, dump, get_B_prefix, PrefWindow, and run.

bool PrefWindow::m_changed [private]
 

Definition at line 68 of file PrefWindow.h.

Referenced by apply_impl, and run.

Config& PrefWindow::m_config [private]
 

Definition at line 65 of file PrefWindow.h.

Referenced by apply_impl, PrefWindow, and run.

bool PrefWindow::m_ignore_callbacks [private]
 

Definition at line 67 of file PrefWindow.h.

Referenced by changed_cb, and run.

MergeMapPref PrefWindow::m_merge_map_pref [private]
 

Definition at line 66 of file PrefWindow.h.

Referenced by apply_impl, and PrefWindow.

Gnome::UI::FileEntry* PrefWindow::m_path_entry [private]
 

Definition at line 57 of file PrefWindow.h.

Referenced by apply_impl, dump, get_project_path, PrefWindow, and run.

Gtk::Entry* PrefWindow::m_proj_name [private]
 

Definition at line 59 of file PrefWindow.h.

Referenced by apply_impl, dump, get_project_name, PrefWindow, and run.


The documentation for this class was generated from the following files:
Generated on Tue Feb 11 23:05:34 2003 for gwavmerger by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002