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

/home/vlg/develop/gwavmerger/src/MainWindow.h

Go to the documentation of this file.
00001 // -*- c++ -*-
00002 //------------------------------------------------------------------------------
00003 //                             MainWindow.h
00004 //------------------------------------------------------------------------------
00005 // $Id: MainWindow.h,v 1.6 2003/02/07 05:15:09 vlg Exp $
00006 //------------------------------------------------------------------------------
00007 //  Copyright (c) 2001-2003 by Vladislav Grinchenko
00008 //
00009 //  This program is free software; you can redistribute it and/or
00010 //  modify it under the terms of the GNU General Public License
00011 //  as published by the Free Software Foundation; either version
00012 //  2 of the License, or (at your option) any later version.
00013 //------------------------------------------------------------------------------
00014 #ifndef MAIN_WINDOW_H
00015 #define MAIN_WINDOW_H
00016 
00017 #include <gtkmm/window.h>
00018 #include <gtkmm/scrolledwindow.h>
00019 #include <gtkmm/menubar.h>
00020 
00021 #include <libgnomeuimm/app.h>
00022 #include <libgnomeuimm/appbar.h>
00023 #include <libgnomeuimm/about.h>
00024 
00025 #include <assa/Fork.h>
00026 
00027 #include "Config.h"
00028 #include "MergeDialog.h"
00029 #include "TopMenuBar.h"
00030 #include "ModelColumns.h"
00031 
00032 class PrefWindow;
00033 
00034 class MainWindow : public Gnome::UI::App
00035 {
00036 public:
00037     MainWindow ();
00038     ~MainWindow ();
00039 
00040     // -*- Toolbar -*-
00041     // [File] Menu
00042     void new_cb     ();
00043     void open_cb    ();
00044     void open_recent_cb (guint index_); // set in TopMenuBar
00045     void save_cb    ();
00046     void save_as_cb ();
00047     void close_cb   ();
00048     void exit_cb    ();
00049 
00050     // [Preference] Menu
00051     void pref_cb    ();
00052 
00053     // -*- End Toolbar -*-
00054 
00055     // [Actions]
00056     void reload_cb  ();
00057     void merge_cb   ();
00058 
00059     void selection_made_cb ();
00060     void help_contents_cb ();
00061     void about_cb ();
00062     gint about_close_cb ();
00063 
00064     void null_cb    () { /* do-nothing callback */ }
00065     void go_prev_row_cb ();
00066     void go_next_row_cb ();
00067     void stop_cb    ();
00068 
00069     virtual int delete_event_impl (GdkEventAny* event);
00070 
00071     void set_mw_name ();
00072     void play_sound (Column column_);
00073 
00074     Config& get_config () { return m_config; }
00075     gint    get_row () const { return m_row; }
00076     string  get_A_selection () { return m_A_selection; }
00077     string  get_B_selection () { return m_B_selection; }
00078     string  make_selected_file_name (Column column_);
00079 
00080     typedef vector<string> ColList; 
00081 
00082     ColList get_clist (Column column_, bool filter_gaps_ = false);
00083 
00084 private:
00085     // Utilities
00086     void install_menus_and_toolbar ();
00087     void print_state (void) const;
00088     int  read_dir (const string& subdir_, 
00089                    const string& prefix_,
00090                    vector<string>& file_list_);
00091     void print_wav_list (const char* name_, const vector<string>& list_);
00092     void go_state (WMState state_);
00093     
00094     // Internal actions
00095     bool change_preferences  ();
00096     void discard_preferences ();
00097     int  open_config_file    ();
00098     void save_config_file    ();
00099     void save_config_file_as ();
00100 
00101     void dump_list_store ();
00102 
00103 private:
00104     static const char* titles [];
00105     static const char* states [];
00106 
00107     WMState              m_state;            // Object's state
00108 
00109     Gtk::ScrolledWindow  m_scrolled_window;
00110     Gnome::UI::About*    m_about;
00111     PrefWindow*          m_pref_window;
00112     Config               m_config;
00113     MergeDialog*         m_merge_dialog;
00114     TopMenuBar           m_top_menu_bar;
00115 
00116     Gtk::Widget*         m_open_item;    // Pointers to Toolbar Menu Items
00117 
00118     string               m_app_title;    // Title displayed in title area of WM
00119     string               m_A_selection;
00120     string               m_B_selection;
00121     gint                 m_row;          // Row currently selected
00122     pid_t                m_players_pid;
00123     bool                 m_no_gaps;      // If true, there are no gaps in
00124                                          // the loaded sequence.
00125 private:
00126     typedef Gtk::TreeModel::Row row_t;
00127     typedef Gtk::TreeModel::Children children_t;
00128     typedef children_t::iterator children_iterator_t;
00129     typedef std::pair<Glib::ustring, Glib::ustring> RowPair_t;
00130     typedef std::vector<RowPair_t > VecRow_t;
00131 
00133     void add_columns ();
00134 
00135     void liststore_add_item (const RowPair_t& elem_);
00136 
00138     const ModelColumns m_columns;
00139 
00141     VecRow_t m_vec_rows;
00142 
00144     Gtk::TreeView m_tree_view;
00145 
00147     Glib::RefPtr<Gtk::ListStore> m_list_store_ref; 
00148 
00150     Glib::RefPtr<Gtk::TreeSelection> m_tree_sel_ref; 
00151 };
00152 
00153 //==============================================================================
00154 // Inline members
00155 //==============================================================================
00156 
00157 
00158 inline void
00159 
00160 MainWindow::discard_preferences ()
00161 {
00162     trace("MainWindow::discard_preferences");
00163     DL((ASSA::APP,"-*- no-op -*-\n"));
00164 }
00165 
00166 inline void
00167 
00168 MainWindow::save_config_file ()
00169 {
00170     trace("MainWindow::save");
00171     m_config.save_project ();
00172 }
00173 
00174 inline void
00175 
00176 MainWindow::save_config_file_as ()
00177 {
00178     trace("MainWindow::save_config_file_as");
00179     Gtk::MessageDialog emsg ("'Save As' is not\nyet implemented",MESSAGE_ERROR);
00180     emsg.run ();
00181 }
00182 
00183 //==============================================================================
00184 // Utilities
00185 //==============================================================================
00186 
00187 inline void
00188 
00189 MainWindow::print_state (void) const
00190 {
00191     DL((APP,"Current state: \"%s\"\n", states [m_state]));
00192 }
00193 
00194 inline void
00195 
00196 MainWindow::go_state (WMState state_)
00197 {
00198     DL((APP,"Changing state \"%s\" => \"%s\"\n", 
00199         states [m_state], states [state_]));
00200     m_state = state_;
00201     m_top_menu_bar.set_sensitivity (state_);
00202 }
00203 
00204 inline void
00205 
00206 MainWindow::add_columns ()
00207 {
00208     m_tree_view.append_column ("Russian", m_columns.row_a);
00209     m_tree_view.append_column ("English", m_columns.row_b);
00210 }
00211 
00212 #endif /* MAIN_WINDOW_H */

Generated on Tue Feb 11 23:05:19 2003 for gwavmerger by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002