00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
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
00041
00042 void new_cb ();
00043 void open_cb ();
00044 void open_recent_cb (guint index_);
00045 void save_cb ();
00046 void save_as_cb ();
00047 void close_cb ();
00048 void exit_cb ();
00049
00050
00051 void pref_cb ();
00052
00053
00054
00055
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 () { }
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
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
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;
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;
00117
00118 string m_app_title;
00119 string m_A_selection;
00120 string m_B_selection;
00121 gint m_row;
00122 pid_t m_players_pid;
00123 bool m_no_gaps;
00124
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
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
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