File: MainWindow.h

package info (click to toggle)
granule 1.4.0-7-9
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, buster
  • size: 5,236 kB
  • ctags: 2,144
  • sloc: cpp: 16,030; makefile: 353
file content (223 lines) | stat: -rw-r--r-- 6,244 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
// -*- c++ -*-
// Generated by assa-genesis
//------------------------------------------------------------------------------
// $Id: MainWindow.h,v 1.42 2008/08/11 12:23:59 vlg Exp $
//------------------------------------------------------------------------------
//                            MainWindow.h
//------------------------------------------------------------------------------
//  Copyright (c) 2004-2007 by Vladislav Grinchenko
//
//  This program is free software; you can redistribute it and/or 
//  modify it under the terms of the GNU General Public License   
//  as published by the Free Software Foundation; either version  
//  2 of the License, or (at your option) any later version.      
//------------------------------------------------------------------------------
//
// Date   : Wed Dec 31 23:18:34 2003
//
//------------------------------------------------------------------------------
#ifndef MAIN_WINDOW_H
#define MAIN_WINDOW_H

#ifdef HAVE_CONFIG_H
#    include "config.h"
#endif

#ifdef IS_HILDON
#  include <gconf/gconf-client.h>
#endif

#include <gtkmm/window.h>
#include <gtkmm/box.h>
#include <gtkmm/menubar.h>

#ifdef IS_HILDON
#    include <hildonmm.h>
#endif

#include "TopMenuBar.h"
#include "DeckManager.h"
#include "CardBox.h"
#include "VDeck.h"

class PrefWindow;
class CardBoxPrefsWindow;
class AboutGRAPP;
class Deck;

/**===========================================================================**
 *                                                                             *
 *   Nokia N8x0 series defines 2 keyboards with properties.                    *
 *                                                                             *
 **===========================================================================**
 */
#ifdef IS_HILDON

class MaemoKeyboard
{
public:
	class BoolProperty
	{
	public:
		BoolProperty (const string& name_, bool value_ = false)	{
			m_name = name_; m_value = value_;
		}
		
	public:
		string   m_name;
		gboolean m_value;
	};

	typedef std::vector<BoolProperty> properties_type;
	typedef properties_type::iterator properties_iterator;

public:
	MaemoKeyboard ();

	/// Initialize global settings.
	static void s_init ();

	/// Retrieve language configuration
	void fetch_language (int index_);

	/** Retrieve and save default system-wide configuration
	 *  for both keyboards.
	 */
	void save_current_config ();

	/** Disable *wide black* word completion toolbar.
	 */
	void disable_word_completion_toolbar ();

	/** Restore original configuration.
	 */
	void restore_settings ();

private:
	/** Keyboard_2 configuration can be undefined.
	 *  If it is not defined, m_enabled is false.
	 */
	bool            m_enabled;

	string          m_language;
	properties_type m_enforced_cfg;
	properties_type m_original_cfg;

private:
	static const string s_basepath;
	static GConfClient* s_gconf_client;
};

#endif	// @end IS_HILDON

/**===========================================================================**
 *                                                                             *
 *   Class MainWindow                                                          *
 *                                                                             *
 **===========================================================================**
 */
#ifdef IS_HILDON
class MainWindow : public Hildon::Window
#else
class MainWindow : public Gtk::Window
#endif
{
public:
    MainWindow ();
    ~MainWindow ();

    /** Post-c'tor initialization
     */
    void init ();

    // -*- Toolbar Callbacks -*-
    void about_cb   ();

    // [File] Menu
    void pref_cb    ();
    void exit_cb    ();

    // [CardFile] Menu
    void new_cb     ();
    void open_cb    ();
    void open_recent_cb (guint index_);	// set in TopMenuBar
    void save_cb    ();
    void save_as_cb ();
    void export_sound_cb ();
    void close_cb   ();
    void play_in_box (int idx_);
	void cardbox_prefs_cb ();

    // [Deck] Menu
    void unselect_deck_cb ();

    /** Remember window size when resized.
     */
    void size_allocate_cb (Gtk::Allocation& size_);

    void set_mw_name ();

	/** The window will be hidden when the window manager's close button is 
	 *  clicked. We override on_delete_event() to stop this and handle
	 *  exit cleanly.
	 */
	bool on_delete_window_clicked (GdkEventAny* event_);

    DeckManager* get_deck_manager () { return &m_deck_manager; }
    DeckList*    get_deck_list    () { return m_deck_list;     }
    CardBox*     get_cardbox      () { return m_cardbox;       }
    TopMenuBar*  get_top_menubar  () { return &m_top_menu_bar; }

    void  set_dnd_source (Deck* deck_) { m_dnd_source = deck_; }
    Deck* get_dnd_source ()            { return m_dnd_source;  }

	// -*- Friends -*- 
    friend void CardBox::add_deck_to_box  (int idx_, Deck* from_deck_);
    friend void CardBox::move_card_to_box (VDeck::cardlist_iterator card_ref_,
										   int from_deck_, 
										   AnswerQuality answer_quality);
    friend int  CardBox::add_cards_to_box (std::vector<CardRef*>& cardlist_);
    friend void CardBox::mark_as_modified ();
	friend void CardBox::normalize_cards ();

    void dump_mw_state () const;

private:
    // -*- Utilities -*-
    void install_menus_and_toolbar ();

    // -*- Internal actions -*-
    int  open_file    ();
    int  save_file    ();
    int  save_file_as ();
    int  export_sound_bits ();
    void close_file   ();
    void go_state (MWState state_);
    bool change_preferences ();

private:
    static const char* states [];

private:

#ifdef IS_HILDON
	Gtk::Menu m_main_menu;
	MaemoKeyboard  m_maemo_keyboard [2];  // Nokia IT N8x0 tablet keyboards.
#endif

    MWState              m_state;		// The state of CardFile.
    Gtk::VBox            m_contents;
    DeckManager          m_deck_manager;
    TopMenuBar           m_top_menu_bar;
    Gtk::Widget*         m_open_item;
    string               m_app_title;
    DeckList*            m_deck_list;
    CardBox*             m_cardbox;	// Tray with cardboxes
    PrefWindow*          m_pref_window;
    CardBoxPrefsWindow*  m_cb_prefs_window;
    AboutGRAPP*          m_about;		// 'About' dialog
    Deck*                m_dnd_source;
};

#endif // MAIN_WINDOW_H