42c2655e57c4bfc89098e75b9fe688ff5a8292fe
[mstardict] / src / mstardict.hpp
1 /*
2  *  MStarDict - International dictionary for Maemo.
3  *  Copyright (C) 2010 Roman Moravcik
4  *
5  *  base on code of stardict:
6  *  Copyright (C) 2003-2007 Hu Zheng <huzheng_001@163.com>
7  *
8  *  based on code of sdcv:
9  *  Copyright (C) 2005-2006 Evgeniy <dushistov@mail.ru>
10  *
11  *  This program is free software; you can redistribute it and/or modify
12  *  it under the terms of the GNU General Public License as published by
13  *  the Free Software Foundation; either version 2 of the License, or
14  *  (at your option) any later version.
15  *
16  *  This program is distributed in the hope that it will be useful,
17  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
18  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19  *  GNU General Public License for more details.
20  *
21  *  You should have received a copy of the GNU General Public License
22  *  along with this program; if not, write to the Free Software
23  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
24  */
25
26 #include <gtk/gtk.h>
27 #include <hildon/hildon.h>
28
29 #include "lib/pluginmanager.h"
30
31 extern MStarDict *pMStarDict;
32
33 class Conf;
34 class DictMngr;
35 class Library;
36 class MStarDict;
37
38 class MStarDict {
39   private:
40     GtkWidget *main_window;
41     GtkWidget *label_widget;
42     GtkWidget *results_widget;
43     GtkWidget *search;
44     GtkWidget *results_view;
45     GtkWidget *results_view_scroll;
46
47     GtkListStore *results_list;
48
49     TSearchResultList results;
50
51     static gboolean onResultsViewSelectionChanged(GtkTreeSelection *selection,
52                                                   MStarDict *mStarDict);
53     static gboolean onSearchEntryChanged(GtkEditable *editable,
54                                          MStarDict *mStarDict);
55     static gboolean onDictionariesMenuItemClicked(GtkButton *button,
56                                                   MStarDict *mStarDict);
57     static gboolean onQuitMenuItemClicked(GtkButton *button,
58                                           MStarDict *mStarDict);
59     static gboolean onLookupProgressDialogResponse(GtkDialog *dialog,
60                                                    gint response_id,
61                                                    bool *cancel);
62     static gboolean onMainWindowKeyPressEvent(GtkWidget *window,
63                                               GdkEventKey *event,
64                                               MStarDict *mStarDict);
65
66   public:
67      MStarDict();
68     ~MStarDict();
69
70     Conf *oConf;
71     DictMngr *oDict;
72     Library *oLibs;
73     StarDictPlugins *oStarDictPlugins;
74
75     GtkWidget *CreateLookupProgressDialog(bool *cancel);
76     void DestroyLookupProgressDialog(GtkWidget *dialog);
77     void CreateTranslationWindow(const gchar *bookname,
78                                  const gchar *def,
79                                  const gchar *exp);
80     void CreateMainWindow();
81     void CreateMainMenu();
82
83     void SearchWord();
84
85     void ResultsListClear();
86     void ResultsListInsertLast(const gchar *word);
87     void ResultsReScroll();
88     void ResultsUnselectAll(GtkSelectionMode mode);
89     void ShowNoResults(bool bNoResults);
90     void ShowNoDictionary(bool bNoDictionary);
91     void ShowProgressIndicator(bool bShow);
92     void GrabFocus();
93 };