Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 86379 | Differences between
and this patch

Collapse All | Expand All

(-)stardict-cur-accepted/src/conf.cpp (+1 lines)
Lines 17-22 Link Here
17
#include "conf.h"
17
#include "conf.h"
18
18
19
std::auto_ptr<AppConf> conf;
19
std::auto_ptr<AppConf> conf;
20
std::string gStarDictDataDir;
20
21
21
inline void free_list(GSList *l){
22
inline void free_list(GSList *l){
22
  if(l!=NULL){
23
  if(l!=NULL){
(-)stardict-cur-accepted/src/conf.h (-26 / +28 lines)
Lines 3-8 Link Here
3
3
4
#include <glib.h>
4
#include <glib.h>
5
#include <memory>
5
#include <memory>
6
#include <string>
6
7
7
#if defined(_WIN32) || defined(WITHOUT_GNOME)
8
#if defined(_WIN32) || defined(WITHOUT_GNOME)
8
struct ConfigLine {
9
struct ConfigLine {
Lines 62-68 Link Here
62
 * all preference of stardict.
63
 * all preference of stardict.
63
*/
64
*/
64
65
65
class AppConf : public TBaseConf {
66
class AppConf : private TBaseConf {
66
private:
67
private:
67
  gint hpaned_pos;
68
  gint hpaned_pos;
68
  gint window_width, window_height;
69
  gint window_width, window_height;
Lines 98-155 Link Here
98
	~AppConf();
99
	~AppConf();
99
  void Load(void);
100
  void Load(void);
100
101
101
  gint get_hpaned_pos(void){return hpaned_pos;}
102
  gint get_hpaned_pos(void) const{return hpaned_pos;}
102
  void set_hpaned_pos(gint value);
103
  void set_hpaned_pos(gint value);
103
  gint get_window_width(void){return window_width;}
104
  gint get_window_width(void) const{return window_width;}
104
  void set_window_width(gint value);
105
  void set_window_width(gint value);
105
  gint get_window_height(void){return window_height;}
106
  gint get_window_height(void) const{return window_height;}
106
  void set_window_height(gint value);
107
  void set_window_height(gint value);
107
  gint get_lock_x(void){return lock_x;}
108
  gint get_lock_x(void) const{return lock_x;}
108
  void set_lock_x(gint value);
109
  void set_lock_x(gint value);
109
  gint get_lock_y(void){return lock_y;}
110
  gint get_lock_y(void) const{return lock_y;}
110
  void set_lock_y(gint value);
111
  void set_lock_y(gint value);
111
  gboolean get_maximized(void){return maximized;}
112
  gboolean get_maximized(void) const{return maximized;}
112
  void set_maximized(gboolean value);
113
  void set_maximized(gboolean value);
113
  gboolean get_use_custom_font(void){return use_custom_font;}
114
  gboolean get_use_custom_font(void) const{return use_custom_font;}
114
  void set_use_custom_font(gboolean value);
115
  void set_use_custom_font(gboolean value);
115
  const gchar *get_custom_font(void){return custom_font;}
116
  const gchar *get_custom_font(void) const{return custom_font;}
116
  void set_custom_font(const gchar *value);
117
  void set_custom_font(const gchar *value);
117
  gboolean get_hide_on_startup(void){return hide_on_startup;}
118
  gboolean get_hide_on_startup(void) const{return hide_on_startup;}
118
  void set_hide_on_startup(gboolean value);
119
  void set_hide_on_startup(gboolean value);
119
  gboolean get_enable_sound_event(void){return enable_sound_event;}
120
  gboolean get_enable_sound_event(void) const{return enable_sound_event;}
120
  void set_enable_sound_event(gboolean value);
121
  void set_enable_sound_event(gboolean value);
121
  gboolean get_hide_list(void){return hide_list;}
122
  gboolean get_hide_list(void) const{return hide_list;}
122
  void set_hide_list(gboolean value);
123
  void set_hide_list(gboolean value);
123
  const GSList *get_search_website_list(void){return search_website_list;}
124
  const GSList *get_search_website_list(void) const{return search_website_list;}
124
  void set_search_website_list(GSList *value);
125
  void set_search_website_list(GSList *value);
125
  gboolean get_scan_selection(void){return scan_selection;}
126
  gboolean get_scan_selection(void) const{return scan_selection;}
126
  void set_scan_selection(gboolean value);
127
  void set_scan_selection(gboolean value);
127
  gboolean get_query_in_floatwin(void){return query_in_floatwin;}
128
  gboolean get_query_in_floatwin(void) const{return query_in_floatwin;}
128
  void set_query_in_floatwin(gboolean value);
129
  void set_query_in_floatwin(gboolean value);
129
  gboolean get_only_scan_while_modifier_key(void){return only_scan_while_modifier_key;}
130
  gboolean get_only_scan_while_modifier_key(void) const{return only_scan_while_modifier_key;}
130
  void set_only_scan_while_modifier_key(gboolean value);
131
  void set_only_scan_while_modifier_key(gboolean value);
131
  gboolean get_hide_floatwin_when_modifier_key_released(void){return hide_floatwin_when_modifier_key_released;}
132
  gboolean get_hide_floatwin_when_modifier_key_released(void) const{return hide_floatwin_when_modifier_key_released;}
132
  void set_hide_floatwin_when_modifier_key_released(gboolean value);
133
  void set_hide_floatwin_when_modifier_key_released(gboolean value);
133
  gint get_scan_modifier_key(void){return scan_modifier_key;}
134
  gint get_scan_modifier_key(void) const{return scan_modifier_key;}
134
  void set_scan_modifier_key(gint value);
135
  void set_scan_modifier_key(gint value);
135
  gboolean get_pronounce_when_popup(void){return pronounce_when_popup;}
136
  gboolean get_pronounce_when_popup(void) const{return pronounce_when_popup;}
136
  void set_pronounce_when_popup(gboolean value);
137
  void set_pronounce_when_popup(gboolean value);
137
  gint get_max_window_width(void){return max_window_width;}
138
  gint get_max_window_width(void) const{return max_window_width;}
138
  void set_max_window_width(gint value);
139
  void set_max_window_width(gint value);
139
  gint get_max_window_height(void){return max_window_height;}
140
  gint get_max_window_height(void) const{return max_window_height;}
140
  void set_max_window_height(gint value);
141
  void set_max_window_height(gint value);
141
  const GSList *get_treedict_order_list(void){return treedict_order_list;}
142
  const GSList *get_treedict_order_list(void) const{return treedict_order_list;}
142
  void set_treedict_order_list(GSList *value);
143
  void set_treedict_order_list(GSList *value);
143
  const GSList *get_treedict_disable_list(void){return treedict_disable_list;}
144
  const GSList *get_treedict_disable_list(void) const{return treedict_disable_list;}
144
  void set_treedict_disable_list(GSList *value);
145
  void set_treedict_disable_list(GSList *value);
145
  const GSList *get_dict_order_list(void){return dict_order_list;}
146
  const GSList *get_dict_order_list(void) const{return dict_order_list;}
146
  void set_dict_order_list(GSList *value);
147
  void set_dict_order_list(GSList *value);
147
  const GSList *get_dict_disable_list(void){return dict_disable_list;}
148
  const GSList *get_dict_disable_list(void) const{return dict_disable_list;}
148
  void set_dict_disable_list(GSList *value);
149
  void set_dict_disable_list(GSList *value);
149
  gboolean get_lock(void){return lock;}
150
  gboolean get_lock(void) const{return lock;}
150
  void set_lock(gboolean value);
151
  void set_lock(gboolean value);
151
};
152
};
152
153
153
extern std::auto_ptr<AppConf> conf;//global exemplar of AppConf class
154
extern std::auto_ptr<AppConf> conf;//global exemplar of AppConf class
155
extern std::string gStarDictDataDir;
154
156
155
#endif
157
#endif
(-)stardict-cur-accepted/src/dictmanagedlg.cpp (-22 / +6 lines)
Lines 12-17 Link Here
12
12
13
#include "stardict.h"
13
#include "stardict.h"
14
#include "conf.h"
14
#include "conf.h"
15
#include "utils.h"
15
16
16
#include "dictmanagedlg.h"
17
#include "dictmanagedlg.h"
17
18
Lines 24-40 Link Here
24
{
25
{
25
	switch (res_id) {
26
	switch (res_id) {
26
		case GTK_RESPONSE_HELP:
27
		case GTK_RESPONSE_HELP:
27
		{
28
    show_help("stardict-dictmanage");
28
#ifdef _WIN32
29
			//gchar *filename = g_strdup_printf(_("file:///%s/help/C/stardict.html#stardict-dictmanage"), stardict_data_dir);
30
			gchar *filename = g_strdup_printf(_("file:///%s/help/C/stardict.html"), stardict_data_dir);
31
			ShellExecute((HWND)(GDK_WINDOW_HWND(gpAppFrame->oAppCore.window->window)), "OPEN", filename, NULL, NULL, SW_SHOWNORMAL);
32
			g_free(filename);
33
#else
34
			gnome_help_display ("stardict.xml", "stardict-dictmanage", NULL);
35
#endif
36
			break;
29
			break;
37
		}
38
		default:
30
		default:
39
			oDictManageDlg->Close();
31
			oDictManageDlg->Close();
40
	}
32
	}
Lines 156-162 Link Here
156
	return true;				
148
	return true;				
157
}
149
}
158
150
159
void DictManageDlg::load_dir(gboolean istreedict, gchar *dirname, const GSList *order_list, const GSList *disable_list, GtkListStore *model)
151
void DictManageDlg::load_dir(gboolean istreedict, const gchar *dirname, const GSList *order_list, const GSList *disable_list, GtkListStore *model)
160
{
152
{
161
	GDir *dir = g_dir_open(dirname, 0, NULL);	
153
	GDir *dir = g_dir_open(dirname, 0, NULL);	
162
	if (dir)
154
	if (dir)
Lines 263-275 Link Here
263
	}
255
	}
264
256
265
#ifdef _WIN32
257
#ifdef _WIN32
266
	gchar *filename; 	
267
	if (istreedict)
268
		filename = g_build_filename(stardict_data_dir, "treedict", NULL);		
269
	else
270
		filename = g_build_filename(stardict_data_dir, "dic", NULL);
271
	load_dir(istreedict, filename, order_list, disable_list, model);
272
	g_free(filename);
273
#else
258
#else
274
	gchar home_dir[256];	
259
	gchar home_dir[256];	
275
	if (istreedict)
260
	if (istreedict)
Lines 277-288 Link Here
277
	else
262
	else
278
		sprintf(home_dir, "%s/.stardict/dic", g_get_home_dir());
263
		sprintf(home_dir, "%s/.stardict/dic", g_get_home_dir());
279
	load_dir(istreedict, home_dir, order_list, disable_list, model);
264
	load_dir(istreedict, home_dir, order_list, disable_list, model);
280
	if (istreedict)
281
		load_dir(istreedict, STARDICT_DATA_DIR "/treedict", order_list, disable_list, model);
282
	else
283
		load_dir(istreedict, STARDICT_DATA_DIR "/dic", order_list, disable_list, model);
284
#endif
265
#endif
266
	std::string filename(gStarDictDataDir+G_DIR_SEPARATOR);
267
	filename += (istreedict) ? "treedict" : "dic";
285
268
269
	load_dir(istreedict, filename.c_str(), order_list, disable_list, model);
286
	return GTK_TREE_MODEL (model);	
270
	return GTK_TREE_MODEL (model);	
287
}
271
}
288
272
(-)stardict-cur-accepted/src/dictmanagedlg.h (-1 / +1 lines)
Lines 13-19 Link Here
13
	GtkWidget *treedict_treeview;
13
	GtkWidget *treedict_treeview;
14
	GtkTreeModel *treedict_tree_model;
14
	GtkTreeModel *treedict_tree_model;
15
15
16
	static void load_dir(gboolean istreedict, gchar *dirname, const GSList *order_list, const GSList *disable_list, GtkListStore *model);
16
	static void load_dir(gboolean istreedict, const gchar *dirname, const GSList *order_list, const GSList *disable_list, GtkListStore *model);
17
	static GtkTreeModel* create_dict_tree_model (gboolean istreedict);
17
	static GtkTreeModel* create_dict_tree_model (gboolean istreedict);
18
	GtkWidget *create_dict_tree(gboolean istreedict);
18
	GtkWidget *create_dict_tree(gboolean istreedict);
19
		
19
		
(-)stardict-cur-accepted/src/docklet.cpp (-1 lines)
Lines 108-114 Link Here
108
108
109
void DockLet::PopupMenu(GdkEventButton *event)
109
void DockLet::PopupMenu(GdkEventButton *event)
110
{
110
{
111
	//gnome_sound_play(STARDICT_DATA_DIR "/sounds/menushow.wav");
112
	if (!menu) {	
111
	if (!menu) {	
113
		menu = gtk_menu_new();
112
		menu = gtk_menu_new();
114
	
113
	
(-)stardict-cur-accepted/src/floatwin.cpp (-71 / +23 lines)
Lines 12-17 Link Here
12
12
13
#include "stardict.h"
13
#include "stardict.h"
14
#include "conf.h"
14
#include "conf.h"
15
#include "utils.h"
15
16
16
#include "floatwin.h"
17
#include "floatwin.h"
17
18
Lines 908-922 Link Here
908
			
909
			
909
			gtk_widget_show_all(oFloatWin->menu);
910
			gtk_widget_show_all(oFloatWin->menu);
910
			gtk_menu_popup(GTK_MENU(oFloatWin->menu), NULL, NULL, NULL, NULL, event->button, event->time);
911
			gtk_menu_popup(GTK_MENU(oFloatWin->menu), NULL, NULL, NULL, NULL, event->button, event->time);
911
			if (conf->get_enable_sound_event()) {
912
			if (conf->get_enable_sound_event())
912
#ifdef _WIN32
913
			  play_wav_file((gStarDictDataDir+G_DIR_SEPARATOR+"sounds"+G_DIR_SEPARATOR+"menushow.wav").c_str());
913
				gchar *filename = g_build_filename(stardict_data_dir, "sounds", "menushow.wav", NULL);
914
			
914
				PlaySound(filename, 0, SND_ASYNC | SND_FILENAME);
915
				g_free(filename);
916
#else
917
				gnome_sound_play(STARDICT_DATA_DIR "/sounds/menushow.wav");
918
#endif
919
			}
920
		}
915
		}
921
		/*else if (event->button == 2) {
916
		/*else if (event->button == 2) {
922
			gint start,end;
917
			gint start,end;
Lines 975-989 Link Here
975
970
976
void FloatWin::on_query_click(GtkWidget *widget, gpointer data)
971
void FloatWin::on_query_click(GtkWidget *widget, gpointer data)
977
{
972
{
978
	if (conf->get_enable_sound_event()) {
973
	if (conf->get_enable_sound_event())
979
#ifdef _WIN32
974
	  play_wav_file((gStarDictDataDir+G_DIR_SEPARATOR+"sounds"+G_DIR_SEPARATOR+"buttonactive.wav").c_str());
980
		gchar *filename = g_build_filename(stardict_data_dir, "sounds", "buttonactive.wav", NULL);
975
	
981
		PlaySound(filename, 0, SND_ASYNC | SND_FILENAME);
982
		g_free(filename);
983
#else
984
		gnome_sound_play(STARDICT_DATA_DIR "/sounds/buttonactive.wav");
985
#endif
986
	}
987
	if (!conf->get_lock())
976
	if (!conf->get_lock())
988
		gpAppFrame->oAppCore.oFloatWin.Hide();
977
		gpAppFrame->oAppCore.oFloatWin.Hide();
989
	gpAppFrame->oAppCore.Query(gpAppFrame->oAppCore.oFloatWin.QueryingWord.c_str());	
978
	gpAppFrame->oAppCore.Query(gpAppFrame->oAppCore.oFloatWin.QueryingWord.c_str());	
Lines 996-1010 Link Here
996
985
997
void FloatWin::on_copy_click(GtkWidget *widget, gpointer data)
986
void FloatWin::on_copy_click(GtkWidget *widget, gpointer data)
998
{
987
{
999
	if (conf->get_enable_sound_event()) {
988
	if (conf->get_enable_sound_event())
1000
#ifdef _WIN32
989
	  play_wav_file((gStarDictDataDir+G_DIR_SEPARATOR+"sounds"+G_DIR_SEPARATOR+"buttonactive.wav").c_str());
1001
		gchar *filename = g_build_filename(stardict_data_dir, "sounds", "buttonactive.wav", NULL);
990
	
1002
		PlaySound(filename, 0, SND_ASYNC | SND_FILENAME);
1003
		g_free(filename);
1004
#else
1005
		gnome_sound_play(STARDICT_DATA_DIR "/sounds/buttonactive.wav");
1006
#endif
1007
	}
1008
	const gchar *text = gtk_label_get_text(GTK_LABEL(gpAppFrame->oAppCore.oFloatWin.label));
991
	const gchar *text = gtk_label_get_text(GTK_LABEL(gpAppFrame->oAppCore.oFloatWin.label));
1009
	GtkClipboard* clipboard = gtk_clipboard_get(GDK_SELECTION_CLIPBOARD);
992
	GtkClipboard* clipboard = gtk_clipboard_get(GDK_SELECTION_CLIPBOARD);
1010
	gtk_clipboard_set_text(clipboard,text,-1);
993
	gtk_clipboard_set_text(clipboard,text,-1);
Lines 1017-1081 Link Here
1017
1000
1018
void FloatWin::on_stop_click(GtkWidget *widget, gpointer data)
1001
void FloatWin::on_stop_click(GtkWidget *widget, gpointer data)
1019
{
1002
{
1020
	if (conf->get_enable_sound_event()) {
1003
	if (conf->get_enable_sound_event())
1021
#ifdef _WIN32
1004
	  play_wav_file((gStarDictDataDir+G_DIR_SEPARATOR+"sounds"+G_DIR_SEPARATOR+"buttonactive.wav").c_str());
1022
		gchar *filename = g_build_filename(stardict_data_dir, "sounds", "buttonactive.wav", NULL);
1005
	
1023
		PlaySound(filename, 0, SND_ASYNC | SND_FILENAME);
1024
		g_free(filename);
1025
#else
1026
		gnome_sound_play(STARDICT_DATA_DIR "/sounds/buttonactive.wav");
1027
#endif
1028
	}
1029
	conf->set_scan_selection(FALSE);
1006
	conf->set_scan_selection(FALSE);
1030
}
1007
}
1031
1008
1032
void FloatWin::on_help_click(GtkWidget *widget, gpointer data)
1009
void FloatWin::on_help_click(GtkWidget *widget, gpointer data)
1033
{
1010
{
1034
	if (conf->get_enable_sound_event()) {
1011
	if (conf->get_enable_sound_event())
1035
#ifdef _WIN32
1012
	  play_wav_file((gStarDictDataDir+G_DIR_SEPARATOR+"sounds"+G_DIR_SEPARATOR+"buttonactive.wav").c_str());
1036
		gchar *filename = g_build_filename(stardict_data_dir, "sounds", "buttonactive.wav", NULL);
1013
	
1037
		PlaySound(filename, 0, SND_ASYNC | SND_FILENAME);
1038
		g_free(filename);
1039
#else
1040
		gnome_sound_play(STARDICT_DATA_DIR "/sounds/buttonactive.wav");
1041
#endif
1042
	}
1043
	if (!conf->get_lock())
1014
	if (!conf->get_lock())
1044
		gpAppFrame->oAppCore.oFloatWin.Hide();
1015
		gpAppFrame->oAppCore.oFloatWin.Hide();
1045
#ifdef _WIN32
1016
	show_help("stardict-scan-selection");
1046
	//gchar *filename = g_strdup_printf(_("file:///%s/help/C/stardict.html#stardict-scan-selection"), stardict_data_dir);
1047
	gchar *filename = g_strdup_printf(_("file:///%s/help/C/stardict.html"), stardict_data_dir);
1048
	ShellExecute((HWND)(GDK_WINDOW_HWND(gpAppFrame->oAppCore.window->window)), "OPEN", filename, NULL, NULL, SW_SHOWNORMAL);
1049
	g_free(filename);
1050
#else
1051
	gnome_help_display ("stardict.xml", "stardict-scan-selection", NULL);
1052
#endif
1053
}
1017
}
1054
1018
1055
void FloatWin::on_quit_click(GtkWidget *widget, gpointer data)
1019
void FloatWin::on_quit_click(GtkWidget *widget, gpointer data)
1056
{
1020
{
1057
	if (conf->get_enable_sound_event()) {
1021
	if (conf->get_enable_sound_event())
1058
#ifdef _WIN32
1022
	  play_wav_file((gStarDictDataDir+G_DIR_SEPARATOR+"sounds"+G_DIR_SEPARATOR+"buttonactive.wav").c_str());
1059
		gchar *filename = g_build_filename(stardict_data_dir, "sounds", "buttonactive.wav", NULL);
1023
	
1060
		PlaySound(filename, 0, SND_ASYNC | SND_FILENAME);
1061
		g_free(filename);
1062
#else
1063
		gnome_sound_play(STARDICT_DATA_DIR "/sounds/buttonactive.wav");
1064
#endif
1065
	}
1066
	gpAppFrame->Quit();
1024
	gpAppFrame->Quit();
1067
}
1025
}
1068
1026
1069
void FloatWin::vLockCallback(GtkWidget *widget, FloatWin *oFloatWin)
1027
void FloatWin::vLockCallback(GtkWidget *widget, FloatWin *oFloatWin)
1070
{
1028
{
1071
	if (conf->get_enable_sound_event()) {
1029
	if (conf->get_enable_sound_event())
1072
#ifdef _WIN32
1030
	  play_wav_file((gStarDictDataDir+G_DIR_SEPARATOR+"sounds"+G_DIR_SEPARATOR+"buttonactive.wav").c_str());
1073
		gchar *filename = g_build_filename(stardict_data_dir, "sounds", "buttonactive.wav", NULL);
1031
	
1074
		PlaySound(filename, 0, SND_ASYNC | SND_FILENAME);
1075
		g_free(filename);
1076
#else
1077
		gnome_sound_play(STARDICT_DATA_DIR "/sounds/buttonactive.wav");
1078
#endif
1079
	}
1080
	conf->set_lock(!conf->get_lock());
1032
	conf->set_lock(!conf->get_lock());
1081
}
1033
}
(-)stardict-cur-accepted/src/lib.cpp (-17 / +8 lines)
Lines 597-603 Link Here
597
	return (oLib[iLib]->LookupWithRule(pspec,aiIndexes,iLen));
599
	return (oLib[iLib]->LookupWithRule(pspec,aiIndexes,iLen));
598
}
600
}
599
601
600
void Libs::LoadDir(gchar *dirname, const GSList *order_list, const GSList *disable_list)
602
void Libs::LoadDir(const gchar *dirname, const GSList *order_list, const GSList *disable_list)
601
{	
603
{	
602
	GDir *dir = g_dir_open(dirname, 0, NULL);	
604
	GDir *dir = g_dir_open(dirname, 0, NULL);	
603
	if (dir)
605
	if (dir)
Lines 656-662 Link Here
656
	}	
658
	}	
657
}
659
}
658
660
659
void Libs::Load(const GSList *order_list, const GSList *disable_list)
661
void Libs::Load(const gchar *dicts_dir, const GSList *order_list, const GSList *disable_list)
660
{
662
{
661
663
662
	gchar *idxfilename;
664
	gchar *idxfilename;
Lines 690-705 Link Here
690
		}					
692
		}					
691
	}
693
	}
692
694
693
#ifdef _WIN32
695
#ifndef _WIN32       
694
	gchar *filename = g_build_filename(stardict_data_dir, "dic", NULL);
695
	LoadDir(filename, order_list, disable_list);
696
	g_free(filename);
697
#else
698
	gchar home_dir[256];
696
	gchar home_dir[256];
699
	sprintf(home_dir, "%s/.stardict/dic", g_get_home_dir());
697
	sprintf(home_dir, "%s/.stardict/dic", g_get_home_dir());
700
	LoadDir(home_dir, order_list, disable_list);
698
	LoadDir(home_dir, order_list, disable_list);
701
	LoadDir(STARDICT_DATA_DIR "/dic", order_list, disable_list);
702
#endif
699
#endif
700
  LoadDir(dicts_dir, order_list, disable_list);
703
}
701
}
704
702
705
gchar *
703
gchar *
Lines 1349-1355 Link Here
1349
	}
1347
	}
1350
}
1348
}
1351
1349
1352
GtkTreeStore* TreeDicts::Load(const GSList *order_list, const GSList *disable_list)
1350
GtkTreeStore* TreeDicts::Load(const gchar *tree_dicts_dir, const GSList *order_list, const GSList *disable_list)
1353
{
1351
{
1354
	GtkTreeStore *model = gtk_tree_store_new (3, G_TYPE_STRING, G_TYPE_LONG, G_TYPE_LONG); //word, offset, size
1352
	GtkTreeStore *model = gtk_tree_store_new (3, G_TYPE_STRING, G_TYPE_LONG, G_TYPE_LONG); //word, offset, size
1355
	
1353
	
Lines 1384-1404 Link Here
1384
		}					
1382
		}					
1385
	}
1383
	}
1386
1384
1387
#ifdef _WIN32	
1385
#ifndef _WIN32		
1388
	gchar *filename = g_build_filename(stardict_data_dir, "treedict", NULL);
1389
	LoadDir(filename, order_list, disable_list, model);
1390
	g_free(filename);
1391
#else
1392
	gchar home_dir[256];
1386
	gchar home_dir[256];
1393
	sprintf(home_dir, "%s/.stardict/treedict", g_get_home_dir());
1387
	sprintf(home_dir, "%s/.stardict/treedict", g_get_home_dir());
1394
	LoadDir(home_dir, order_list, disable_list, model);
1388
	LoadDir(home_dir, order_list, disable_list, model);
1395
	LoadDir(STARDICT_DATA_DIR "/treedict", order_list, disable_list, model);
1396
#endif
1389
#endif
1397
	
1390
	LoadDir(tree_dicts_dir, order_list, disable_list, model);
1398
	return model;
1391
	return model;
1399
}
1392
}
1400
1393
1401
void TreeDicts::LoadDir(gchar *dirname, const GSList *order_list, const GSList *disable_list, GtkTreeStore *model)
1394
void TreeDicts::LoadDir(const gchar *dirname, const GSList *order_list, const GSList *disable_list, GtkTreeStore *model)
1402
{
1395
{
1403
	GDir *dir = g_dir_open(dirname, 0, NULL);	
1396
	GDir *dir = g_dir_open(dirname, 0, NULL);	
1404
	if (dir)
1397
	if (dir)
(-)stardict-cur-accepted/src/lib.h (-10 / +9 lines)
Lines 5-14 Link Here
5
#  include "config.h"
5
#  include "config.h"
6
#endif
6
#endif
7
7
8
#include "dictziplib.h"
9
10
#include <stdio.h>
8
#include <stdio.h>
11
#include <gtk/gtk.h>
9
#include <gtk/gtk.h>
10
#include <string>
11
12
#include "dictziplib.h"
12
13
13
14
14
struct cacheItem
15
struct cacheItem
Lines 81-97 Link Here
81
};
82
};
82
83
83
//============================================================================
84
//============================================================================
84
class Libs
85
class Libs {
85
{
86
private:
86
private:
87
	Lib **oLib; // word library.
87
	Lib **oLib; // word library.
88
	gint libcount;
88
	gint libcount;
89
	
89
	
90
	void LoadDir(gchar *dirname, const GSList *order_list, const GSList *disable_list);
90
  void LoadDir(const gchar *dirname, const GSList *order_list, const GSList *disable_list);
91
public:
91
public:
92
	Libs();
92
	Libs();
93
	~Libs();
93
	~Libs();
94
	void Load(const GSList *order_list, const GSList *disable_list);
94
  void Load(const gchar *dicts_dir, const GSList *order_list, const GSList *disable_list);
95
	glong iLength(int iLib);
95
	glong iLength(int iLib);
96
	gchar* GetBookname(int iLib);
96
	gchar* GetBookname(int iLib);
97
	inline gint total_libs() { return(libcount); }
97
	inline gint total_libs() { return(libcount); }
Lines 117-134 Link Here
117
	gboolean load(const char *ifofilename, GtkTreeStore *model);
117
	gboolean load(const char *ifofilename, GtkTreeStore *model);
118
};
118
};
119
119
120
class TreeDicts
120
class TreeDicts {
121
{
122
public:
121
public:
123
	TreeDicts();
122
	TreeDicts();
124
	~TreeDicts();
123
	~TreeDicts();
125
	GtkTreeStore* Load(const GSList *order_list, const GSList *disable_list);
124
  GtkTreeStore* Load(const gchar *tree_dicts_dir, const GSList *order_list, const GSList *disable_list);
126
	gchar * poGetWordData(glong offset, glong size, int iTreeDict);
125
	gchar * poGetWordData(glong offset, glong size, int iTreeDict);
127
private:
126
private:
128
	TreeDict **oTreeDict;
127
	TreeDict **oTreeDict;
129
	gint treedictcount;
128
	gint treedictcount;
130
	
129
	
131
	void LoadDir(gchar *dirname, const GSList *order_list, const GSList *disable_list, GtkTreeStore *model);	
130
  void LoadDir(const gchar *dirname, const GSList *order_list, const GSList *disable_list, GtkTreeStore *model);	
132
};
131
};
133
132
134
#endif
133
#endif
(-)stardict-cur-accepted/src/mainwin.cpp (-120 / +40 lines)
Lines 16-21 Link Here
16
16
17
#include "stardict.h"
17
#include "stardict.h"
18
#include "conf.h"
18
#include "conf.h"
19
#include "utils.h"
19
20
20
#include "mainwin.h"
21
#include "mainwin.h"
21
22
Lines 207-221 Link Here
207
208
208
void TopWin::ClearCallback(GtkWidget *widget, TopWin *oTopWin)
209
void TopWin::ClearCallback(GtkWidget *widget, TopWin *oTopWin)
209
{
210
{
210
	if (conf->get_enable_sound_event()) {
211
	if (conf->get_enable_sound_event())
211
#ifdef _WIN32
212
	  play_wav_file((gStarDictDataDir+G_DIR_SEPARATOR+"sounds"+G_DIR_SEPARATOR+"buttonactive.wav").c_str());
212
		gchar *filename = g_build_filename(stardict_data_dir, "sounds", "buttonactive.wav", NULL);
213
	
213
		PlaySound(filename, 0, SND_ASYNC | SND_FILENAME);
214
		g_free(filename);
215
#else
216
		gnome_sound_play(STARDICT_DATA_DIR "/sounds/buttonactive.wav");
217
#endif
218
	}
219
	oTopWin->InsertHisList(oTopWin->GetText());
214
	oTopWin->InsertHisList(oTopWin->GetText());
220
	oTopWin->InsertBackList();
215
	oTopWin->InsertBackList();
221
	oTopWin->SetText("");
216
	oTopWin->SetText("");
Lines 224-238 Link Here
224
219
225
void TopWin::GoCallback(GtkWidget *widget, TopWin *oTopWin)
220
void TopWin::GoCallback(GtkWidget *widget, TopWin *oTopWin)
226
{
221
{
227
	if (conf->get_enable_sound_event()) {
222
	if (conf->get_enable_sound_event())
228
#ifdef _WIN32
223
	  play_wav_file((gStarDictDataDir+G_DIR_SEPARATOR+"sounds"+G_DIR_SEPARATOR+"buttonactive.wav").c_str());
229
		gchar *filename = g_build_filename(stardict_data_dir, "sounds", "buttonactive.wav", NULL);
224
	
230
		PlaySound(filename, 0, SND_ASYNC | SND_FILENAME);
231
		g_free(filename);
232
#else
233
		gnome_sound_play(STARDICT_DATA_DIR "/sounds/buttonactive.wav");
234
#endif
235
	}
236
	const gchar *text = oTopWin->GetText();
225
	const gchar *text = oTopWin->GetText();
237
	if (text[0]=='\0')
226
	if (text[0]=='\0')
238
		return;
227
		return;
Lines 276-290 Link Here
276
265
277
void TopWin::BackCallback(GtkWidget *widget, TopWin *oTopWin)
266
void TopWin::BackCallback(GtkWidget *widget, TopWin *oTopWin)
278
{
267
{
279
	if (conf->get_enable_sound_event()) {
268
	if (conf->get_enable_sound_event())
280
#ifdef _WIN32
269
	  play_wav_file((gStarDictDataDir+G_DIR_SEPARATOR+"sounds"+G_DIR_SEPARATOR+"buttonactive.wav").c_str());
281
		gchar *filename = g_build_filename(stardict_data_dir, "sounds", "buttonactive.wav", NULL);
270
	
282
		PlaySound(filename, 0, SND_ASYNC | SND_FILENAME);
283
		g_free(filename);
284
#else
285
		gnome_sound_play(STARDICT_DATA_DIR "/sounds/buttonactive.wav");
286
#endif
287
	}
288
	oTopWin->do_back();
271
	oTopWin->do_back();
289
}
272
}
290
273
Lines 348-362 Link Here
348
331
349
void TopWin::PreviousCallback(GtkWidget *widget, TopWin *oTopWin)
332
void TopWin::PreviousCallback(GtkWidget *widget, TopWin *oTopWin)
350
{	
333
{	
351
	if (conf->get_enable_sound_event()) {
334
	if (conf->get_enable_sound_event())
352
#ifdef _WIN32
335
	  play_wav_file((gStarDictDataDir+G_DIR_SEPARATOR+"sounds"+G_DIR_SEPARATOR+"buttonactive.wav").c_str());
353
		gchar *filename = g_build_filename(stardict_data_dir, "sounds", "buttonactive.wav", NULL);
336
	
354
		PlaySound(filename, 0, SND_ASYNC | SND_FILENAME);
355
		g_free(filename);
356
#else
357
		gnome_sound_play(STARDICT_DATA_DIR "/sounds/buttonactive.wav");
358
#endif
359
	}
360
	oTopWin->do_previous();
337
	oTopWin->do_previous();
361
}
338
}
362
339
Lines 428-442 Link Here
428
405
429
void TopWin::NextCallback(GtkWidget *widget, TopWin *oTopWin)
406
void TopWin::NextCallback(GtkWidget *widget, TopWin *oTopWin)
430
{
407
{
431
	if (conf->get_enable_sound_event()) {
408
	if (conf->get_enable_sound_event())
432
#ifdef _WIN32
409
	  play_wav_file((gStarDictDataDir+G_DIR_SEPARATOR+"sounds"+G_DIR_SEPARATOR+"buttonactive.wav").c_str());
433
		gchar *filename = g_build_filename(stardict_data_dir, "sounds", "buttonactive.wav", NULL);
410
	
434
		PlaySound(filename, 0, SND_ASYNC | SND_FILENAME);
435
		g_free(filename);
436
#else
437
		gnome_sound_play(STARDICT_DATA_DIR "/sounds/buttonactive.wav");
438
#endif
439
	}
440
	oTopWin->do_next();
411
	oTopWin->do_next();
441
}
412
}
442
413
Lines 452-473 Link Here
452
423
453
void TopWin::on_main_menu_newversion_activate(GtkMenuItem *menuitem, TopWin *oTopWin)
424
void TopWin::on_main_menu_newversion_activate(GtkMenuItem *menuitem, TopWin *oTopWin)
454
{
425
{
455
#ifdef _WIN32
426
  show_url("http://stardict.sourceforge.net");
456
	ShellExecute((HWND)(GDK_WINDOW_HWND(gpAppFrame->oAppCore.window->window)), "OPEN", "http://stardict.sourceforge.net", NULL, NULL, SW_SHOWNORMAL);
457
#else
458
	gnome_url_show("http://stardict.sourceforge.net", NULL);
459
#endif
460
}
427
}
461
428
462
void TopWin::on_main_menu_help_activate(GtkMenuItem *menuitem, TopWin *oTopWin)
429
void TopWin::on_main_menu_help_activate(GtkMenuItem *menuitem, TopWin *oTopWin)
463
{
430
{
464
#ifdef _WIN32
431
  show_help(NULL);
465
	gchar *filename = g_strdup_printf(_("file:///%s/help/C/stardict.html"), stardict_data_dir);
466
	ShellExecute((HWND)(GDK_WINDOW_HWND(gpAppFrame->oAppCore.window->window)), "OPEN", filename, NULL, NULL, SW_SHOWNORMAL);
467
	g_free(filename);
468
#else
469
	gnome_help_display ("stardict.xml", NULL, NULL);
470
#endif
471
}
432
}
472
433
473
void TopWin::on_main_menu_about_activate(GtkMenuItem *menuitem, TopWin *oTopWin)
434
void TopWin::on_main_menu_about_activate(GtkMenuItem *menuitem, TopWin *oTopWin)
Lines 510-524 Link Here
510
471
511
void TopWin::do_menu()
472
void TopWin::do_menu()
512
{
473
{
513
	if (conf->get_enable_sound_event()) {
474
	if (conf->get_enable_sound_event())
514
#ifdef _WIN32
475
	  play_wav_file((gStarDictDataDir+G_DIR_SEPARATOR+"sounds"+G_DIR_SEPARATOR+"menushow.wav").c_str());
515
		gchar *filename = g_build_filename(stardict_data_dir, "sounds", "menushow.wav", NULL);
476
	
516
		PlaySound(filename, 0, SND_ASYNC | SND_FILENAME);
517
		g_free(filename);
518
#else
519
		gnome_sound_play(STARDICT_DATA_DIR "/sounds/menushow.wav");
520
#endif
521
	}
522
	if (!MainMenu) {
477
	if (!MainMenu) {
523
		MainMenu = gtk_menu_new();
478
		MainMenu = gtk_menu_new();
524
479
Lines 855-861 Link Here
855
810
856
void TreeWin::Create(GtkWidget *notebook)
811
void TreeWin::Create(GtkWidget *notebook)
857
{
812
{
858
	GtkTreeStore *model = gpAppFrame->oAppCore.oTreeDicts.Load(conf->get_treedict_order_list(),
813
  GtkTreeStore *model = gpAppFrame->oAppCore.oTreeDicts.Load((gStarDictDataDir+G_DIR_SEPARATOR+"treedict").c_str(),
814
							     conf->get_treedict_order_list(),
859
								   conf->get_treedict_disable_list());
815
								   conf->get_treedict_disable_list());
860
	treeview = gtk_tree_view_new_with_model (GTK_TREE_MODEL(model));
816
	treeview = gtk_tree_view_new_with_model (GTK_TREE_MODEL(model));
861
	gtk_widget_show(treeview);
817
	gtk_widget_show(treeview);
Lines 1736-1764 Link Here
1736
1692
1737
void BottomWin::AboutCallback(GtkButton *button, gpointer data)
1693
void BottomWin::AboutCallback(GtkButton *button, gpointer data)
1738
{
1694
{
1739
	if (conf->get_enable_sound_event()) {
1695
	if (conf->get_enable_sound_event())
1740
#ifdef _WIN32
1696
	  play_wav_file((gStarDictDataDir+G_DIR_SEPARATOR+"sounds"+G_DIR_SEPARATOR+"buttonactive.wav").c_str());
1741
		gchar *filename = g_build_filename(stardict_data_dir, "sounds", "buttonactive.wav", NULL);
1697
	
1742
		PlaySound(filename, 0, SND_ASYNC | SND_FILENAME);
1743
		g_free(filename);
1744
#else
1745
		gnome_sound_play(STARDICT_DATA_DIR "/sounds/buttonactive.wav");
1746
#endif
1747
	}
1748
	gpAppFrame->oAppCore.oMidWin.oTextWin.ShowInfo();
1698
	gpAppFrame->oAppCore.oMidWin.oTextWin.ShowInfo();
1749
}
1699
}
1750
1700
1751
void BottomWin::QuitCallback(GtkButton *button, gpointer data)
1701
void BottomWin::QuitCallback(GtkButton *button, gpointer data)
1752
{
1702
{
1753
	if (conf->get_enable_sound_event()) {
1703
	if (conf->get_enable_sound_event())
1754
#ifdef _WIN32
1704
	  play_wav_file((gStarDictDataDir+G_DIR_SEPARATOR+"sounds"+G_DIR_SEPARATOR+"buttonactive.wav").c_str());
1755
		gchar *filename = g_build_filename(stardict_data_dir, "sounds", "buttonactive.wav", NULL);
1705
	
1756
		PlaySound(filename, 0, SND_ASYNC | SND_FILENAME);
1757
		g_free(filename);
1758
#else
1759
		gnome_sound_play(STARDICT_DATA_DIR "/sounds/buttonactive.wav");
1760
#endif
1761
	}
1762
	gpAppFrame->Quit();	
1706
	gpAppFrame->Quit();	
1763
}
1707
}
1764
1708
Lines 1808-1829 Link Here
1808
	const gchar *text;
1752
	const gchar *text;
1809
	text = gtk_entry_get_text(GTK_ENTRY(GTK_COMBO(gpAppFrame->oAppCore.oTopWin.WordCombo)->entry));
1753
	text = gtk_entry_get_text(GTK_ENTRY(GTK_COMBO(gpAppFrame->oAppCore.oTopWin.WordCombo)->entry));
1810
	if (text[0]) {		
1754
	if (text[0]) {		
1811
		gchar *url;	
1755
	  gchar *url = g_strdup_printf(website_searchlink+1,text);
1812
		url = g_strdup_printf(website_searchlink+1,text);
1756
	  show_url(url);
1813
#ifdef _WIN32
1814
		ShellExecute((HWND)(GDK_WINDOW_HWND(gpAppFrame->oAppCore.window->window)), "OPEN", url, NULL, NULL, SW_SHOWNORMAL);
1815
#else
1816
		gnome_url_show(url, NULL);
1817
#endif
1818
		g_free(url);
1757
		g_free(url);
1819
	}
1758
	} else
1820
	else {
1759
	  show_url(website_link+1);
1821
#ifdef _WIN32
1760
	
1822
		ShellExecute((HWND)(GDK_WINDOW_HWND(gpAppFrame->oAppCore.window->window)), "OPEN", website_link+1, NULL, NULL, SW_SHOWNORMAL);
1823
#else
1824
		gnome_url_show(website_link+1, NULL);
1825
#endif
1826
	}
1827
	*website_link = '\t';
1761
	*website_link = '\t';
1828
	*website_searchlink = '\t';
1762
	*website_searchlink = '\t';
1829
}
1763
}
Lines 1846-1878 Link Here
1846
	const gchar *text;
1780
	const gchar *text;
1847
	text = gtk_entry_get_text(GTK_ENTRY(GTK_COMBO(gpAppFrame->oAppCore.oTopWin.WordCombo)->entry));
1781
	text = gtk_entry_get_text(GTK_ENTRY(GTK_COMBO(gpAppFrame->oAppCore.oTopWin.WordCombo)->entry));
1848
	if (text[0]) {		
1782
	if (text[0]) {		
1849
		gchar *url;	
1783
	  gchar *url = g_strdup_printf(website_searchlink+1, text);
1850
		url = g_strdup_printf(website_searchlink+1,text);
1784
	  show_url(url);
1851
#ifdef _WIN32
1852
		ShellExecute((HWND)(GDK_WINDOW_HWND(gpAppFrame->oAppCore.window->window)), "OPEN", url, NULL, NULL, SW_SHOWNORMAL);
1853
#else
1854
		gnome_url_show(url, NULL);
1855
#endif
1856
		g_free(url);
1785
		g_free(url);
1857
	}
1786
	} else
1858
	else {		
1787
	  show_url(website_link+1);
1859
#ifdef _WIN32
1788
1860
		ShellExecute((HWND)(GDK_WINDOW_HWND(gpAppFrame->oAppCore.window->window)), "OPEN", website_link+1, NULL, NULL, SW_SHOWNORMAL);
1861
#else
1862
		gnome_url_show(website_link+1, NULL);
1863
#endif
1864
	}
1865
	*website_link = '\t';
1789
	*website_link = '\t';
1866
	*website_searchlink = '\t';
1790
	*website_searchlink = '\t';
1867
}
1791
}
1868
1792
1869
void BottomWin::NewVersionCallback(GtkButton *button, BottomWin *oBottomWin)
1793
void BottomWin::NewVersionCallback(GtkButton *button, BottomWin *oBottomWin)
1870
{
1794
{
1871
#ifdef _WIN32
1795
  show_url("http://stardict.sourceforge.net");
1872
	ShellExecute((HWND)(GDK_WINDOW_HWND(gpAppFrame->oAppCore.window->window)), "OPEN", "http://stardict.sourceforge.net", NULL, NULL, SW_SHOWNORMAL);
1873
#else
1874
	gnome_url_show("http://stardict.sourceforge.net", NULL);
1875
#endif
1876
}
1796
}
1877
1797
1878
void BottomWin::DictManageCallback(GtkButton *button, BottomWin *oBottomWin)
1798
void BottomWin::DictManageCallback(GtkButton *button, BottomWin *oBottomWin)
(-)stardict-cur-accepted/src/Makefile.am (-1 / +2 lines)
Lines 42-48 Link Here
42
	distance.cpp distance.h	\
42
	distance.cpp distance.h	\
43
	splash.cpp splash.h		\
43
	splash.cpp splash.h		\
44
	dictziplib.c dictziplib.h	\
44
	dictziplib.c dictziplib.h	\
45
	lib.cpp lib.h
45
	lib.cpp lib.h                   \
46
	utils.cpp utils.h
46
47
47
48
48
$(IDL_SOURCES): $(IDL_FILE)
49
$(IDL_SOURCES): $(IDL_FILE)
(-)stardict-cur-accepted/src/prefsdlg.cpp (-10 / +2 lines)
Lines 9-14 Link Here
9
9
10
#include "stardict.h"
10
#include "stardict.h"
11
#include "conf.h"
11
#include "conf.h"
12
#include "utils.h"
12
13
13
#include "prefsdlg.h"
14
#include "prefsdlg.h"
14
15
Lines 91-107 Link Here
91
{
92
{
92
	switch (res_id) {
93
	switch (res_id) {
93
		case GTK_RESPONSE_HELP:
94
		case GTK_RESPONSE_HELP:
94
		{
95
    show_help("stardict-prefs");
95
#ifdef _WIN32
96
			//gchar *filename = g_strdup_printf(_("file:///%s/help/C/stardict.html#stardict-prefs"), stardict_data_dir);
97
			gchar *filename = g_strdup_printf(_("file:///%s/help/C/stardict.html"), stardict_data_dir);
98
			ShellExecute((HWND)(GDK_WINDOW_HWND(gpAppFrame->oAppCore.window->window)), "OPEN", filename, NULL, NULL, SW_SHOWNORMAL);
99
			g_free(filename);
100
#else
101
			gnome_help_display ("stardict.xml", "stardict-prefs", NULL);
102
#endif
103
			break;
96
			break;
104
		}
105
		default:
97
		default:
106
			oPrefsDlg->Close();
98
			oPrefsDlg->Close();
107
	}
99
	}
(-)stardict-cur-accepted/src/skin.cpp (-23 / +23 lines)
Lines 1-11 Link Here
1
#ifdef HAVE_CONFIG_H
1
#ifdef HAVE_CONFIG_H
2
#  include "config.h"
2
#  include "config.h"
3
#endif
3
#endif
4
#include "skin.h"
4
5
#include <stdlib.h>
5
#include <cstdlib>
6
#include <string.h>
6
#include <cstring>
7
7
8
#include "stardict.h"
8
#include "stardict.h"
9
#include "conf.h"
10
11
#include "skin.h"
9
12
10
_Skin_cursor::_Skin_cursor()
13
_Skin_cursor::_Skin_cursor()
11
{
14
{
Lines 41-67 Link Here
41
{		
44
{		
42
	stardict.normal_cursor.cursor=(GdkCursor *)NULL; // NULL is the default cursor.
45
	stardict.normal_cursor.cursor=(GdkCursor *)NULL; // NULL is the default cursor.
43
	stardict.watch_cursor.cursor= gdk_cursor_new(GDK_WATCH);
46
	stardict.watch_cursor.cursor= gdk_cursor_new(GDK_WATCH);
44
47
  std::string pixmaps_dir(gStarDictDataDir+G_DIR_SEPARATOR+"pixmaps"+G_DIR_SEPARATOR);
48
  std::string filename;
45
#ifdef _WIN32			
49
#ifdef _WIN32			
46
	gchar *filename;
50
  filename=pixmaps_dir+"stardict.png";
47
 	filename = g_build_filename(stardict_data_dir, "pixmaps", "stardict.png", NULL);
51
  stardict.icon.p[0] = gdk_pixbuf_new_from_file(filename.c_str(), NULL);
48
	stardict.icon.p[0] = gdk_pixbuf_new_from_file (filename, NULL);
52
  filename=pixmaps_dir+"about_menu.png";
49
	g_free(filename);
53
  stardict.about_menu.p[0] = gdk_pixbuf_new_from_file(filename.c_str(), NULL);
50
	filename = g_build_filename(stardict_data_dir, "pixmaps", "about_menu.png", NULL);
51
	stardict.about_menu.p[0] = gdk_pixbuf_new_from_file (filename, NULL);
52
	g_free(filename);
53
	filename = g_build_filename(stardict_data_dir, "pixmaps", "index_wazard.png", NULL);
54
	stardict.index_wazard.p[0] = gdk_pixbuf_new_from_file (filename, NULL);
55
	g_free(filename);
56
	filename = g_build_filename(stardict_data_dir, "pixmaps", "index_appendix.png", NULL);
57
	stardict.index_appendix.p[0] = gdk_pixbuf_new_from_file (filename, NULL);
58
	g_free(filename);
59
#else
54
#else
60
	stardict.icon.p[0] = gdk_pixbuf_new_from_file (GNOME_ICONDIR "/stardict.png", NULL);
55
  stardict.icon.p[0] = gdk_pixbuf_new_from_file(GNOME_ICONDIR"/stardict.png", NULL);	
61
	stardict.docklet_normal_icon.p[0] = gdk_pixbuf_new_from_file (STARDICT_DATA_DIR "/pixmaps/docklet_normal.png", NULL);
56
  filename=pixmaps_dir+"docklet_normal.png";
62
	stardict.docklet_scan_icon.p[0] = gdk_pixbuf_new_from_file (STARDICT_DATA_DIR "/pixmaps/docklet_scan.png", NULL);
57
  stardict.docklet_normal_icon.p[0] = gdk_pixbuf_new_from_file(filename.c_str(), NULL);
63
	stardict.docklet_stop_icon.p[0] = gdk_pixbuf_new_from_file (STARDICT_DATA_DIR "/pixmaps/docklet_stop.png", NULL);
58
  filename=pixmaps_dir+"docklet_scan.png";
64
	stardict.index_wazard.p[0] = gdk_pixbuf_new_from_file (STARDICT_DATA_DIR "/pixmaps/index_wazard.png", NULL);
59
  stardict.docklet_scan_icon.p[0] = gdk_pixbuf_new_from_file(filename.c_str(), NULL);
65
	stardict.index_appendix.p[0] = gdk_pixbuf_new_from_file (STARDICT_DATA_DIR "/pixmaps/index_appendix.png", NULL);
60
  filename=pixmaps_dir+"docklet_stop.png";
61
  stardict.docklet_stop_icon.p[0] = gdk_pixbuf_new_from_file(filename.c_str(), NULL);
66
#endif
62
#endif
63
  filename=pixmaps_dir+"index_wazard.png";
64
  stardict.index_wazard.p[0] = gdk_pixbuf_new_from_file(filename.c_str(), NULL);
65
  filename=pixmaps_dir+"index_appendix.png";
66
  stardict.index_appendix.p[0] = gdk_pixbuf_new_from_file(filename.c_str(), NULL);
67
}
67
}
(-)stardict-cur-accepted/src/splash.cpp (-10 / +7 lines)
Lines 2-10 Link Here
2
#  include "config.h"
2
#  include "config.h"
3
#endif
3
#endif
4
4
5
#include "splash.h"
6
#include "stardict.h"
7
8
#include <gtk/gtk.h>
5
#include <gtk/gtk.h>
9
#ifndef _WIN32
6
#ifndef _WIN32
10
#  include <libgnome/libgnome.h>
7
#  include <libgnome/libgnome.h>
Lines 14-19 Link Here
14
#  include "win32/intl.h"
11
#  include "win32/intl.h"
15
#endif
12
#endif
16
13
14
#include "stardict.h"
15
#include "conf.h"
16
17
#include "splash.h"
18
17
19
18
// this is the callback which will destroy the splash screen window.
20
// this is the callback which will destroy the splash screen window.
19
static void
21
static void
Lines 26-38 Link Here
26
{		
28
{		
27
	gtk_window_set_auto_startup_notification(false);
29
	gtk_window_set_auto_startup_notification(false);
28
30
29
#ifdef _WIN32
31
	GdkPixbuf *pixbuf = gdk_pixbuf_new_from_file((gStarDictDataDir+G_DIR_SEPARATOR+"pixmaps"+G_DIR_SEPARATOR+"splash.png").c_str(), NULL);
30
	gchar *filename = g_build_filename(stardict_data_dir, "pixmaps", "splash.png", NULL);
32
31
	GdkPixbuf *pixbuf = gdk_pixbuf_new_from_file(filename, NULL);
32
	g_free(filename);
33
#else
34
	GdkPixbuf *pixbuf = gdk_pixbuf_new_from_file(STARDICT_DATA_DIR "/pixmaps/splash.png", NULL);
35
#endif
36
	gint w = gdk_pixbuf_get_width(pixbuf);
33
	gint w = gdk_pixbuf_get_width(pixbuf);
37
	gint h = gdk_pixbuf_get_height(pixbuf);
34
	gint h = gdk_pixbuf_get_height(pixbuf);
38
	
35
	
(-)stardict-cur-accepted/src/stardict.cpp (-54 / +35 lines)
Lines 50-59 Link Here
50
	#include <windows.h>
50
	#include <windows.h>
51
	#include <gdk/gdkkeysyms.h>
51
	#include <gdk/gdkkeysyms.h>
52
	HINSTANCE stardictexe_hInstance;
52
	HINSTANCE stardictexe_hInstance;
53
	gchar stardict_data_dir[256];
54
#endif
53
#endif
55
54
56
#include "conf.h"
55
#include "conf.h"
56
#include "utils.h"
57
57
58
#include "stardict.h"
58
#include "stardict.h"
59
59
Lines 102-108 Link Here
102
102
103
void AppCore::Create(gchar *queryword)
103
void AppCore::Create(gchar *queryword)
104
{		
104
{		
105
	oLibs.Load(conf->get_dict_order_list(), conf->get_dict_disable_list());
105
	oLibs.Load((gStarDictDataDir+G_DIR_SEPARATOR+"dic").c_str(), conf->get_dict_order_list(), conf->get_dict_disable_list());
106
	iCurrentIndex = (glong*)g_malloc0(sizeof(glong) * oLibs.total_libs());
106
	iCurrentIndex = (glong*)g_malloc0(sizeof(glong) * oLibs.total_libs());
107
107
108
	gboolean use_custom_font=conf->get_use_custom_font();
108
	gboolean use_custom_font=conf->get_use_custom_font();
Lines 274-288 Link Here
274
		}
274
		}
275
	}
275
	}
276
	else if (event->keyval==GDK_F1) {
276
	else if (event->keyval==GDK_F1) {
277
		if (event->type==GDK_KEY_PRESS) {
277
		if (event->type==GDK_KEY_PRESS)
278
#ifdef _WIN32
278
		  show_help(NULL);		
279
			gchar *filename = g_strdup_printf(_("file:///%s/help/C/stardict.html"), stardict_data_dir);
280
			ShellExecute((HWND)(GDK_WINDOW_HWND(gpAppFrame->oAppCore.window->window)), "OPEN", filename, NULL, NULL, SW_SHOWNORMAL);
281
			g_free(filename);
282
#else
283
			gnome_help_display ("stardict.xml", NULL, NULL);
284
#endif
285
		}
286
	}
279
	}
287
	else if ((event->keyval==GDK_f || event->keyval==GDK_F) && only_ctrl_pressed) {
280
	else if ((event->keyval==GDK_f || event->keyval==GDK_F) && only_ctrl_pressed) {
288
		if (event->type==GDK_KEY_PRESS)
281
		if (event->type==GDK_KEY_PRESS)
Lines 1309-1323 Link Here
1309
1302
1310
gboolean stardict_on_enter_notify (GtkWidget * widget, GdkEventCrossing * event, gpointer data)
1303
gboolean stardict_on_enter_notify (GtkWidget * widget, GdkEventCrossing * event, gpointer data)
1311
{
1304
{
1312
  if (conf->get_enable_sound_event() && event->mode == GDK_CROSSING_NORMAL) {
1305
  if (conf->get_enable_sound_event() && 
1313
#ifdef _WIN32
1306
      event->mode == GDK_CROSSING_NORMAL)
1314
		gchar *filename = g_build_filename(stardict_data_dir, "sounds", "buttonactive.wav", NULL);
1307
    play_wav_file((gStarDictDataDir+G_DIR_SEPARATOR+"sounds"+G_DIR_SEPARATOR+"buttonactive.wav").c_str());
1315
		PlaySound(filename, 0, SND_ASYNC | SND_FILENAME);
1308
1316
		g_free(filename);
1317
#else
1318
		gnome_sound_play(STARDICT_DATA_DIR "/sounds/buttonactive.wav");
1319
#endif
1320
	}
1321
	return false;
1309
	return false;
1322
}
1310
}
1323
1311
Lines 1419-1441 Link Here
1419
				    gpointer        user_data) {
1407
				    gpointer        user_data) {
1420
	return;
1408
	return;
1421
}
1409
}
1422
1423
static gboolean set_stardict_data_dir(void) {
1424
	HMODULE hmod;
1425
1426
	hmod = GetModuleHandle(NULL);
1427
	if( hmod == 0 ) {
1428
		return true;
1429
	}
1430
	if(GetModuleFileName( hmod, (char*)&stardict_data_dir, 256 ) == 0) {
1431
		return true;
1432
	}
1433
	gchar* buf;
1434
	buf = g_path_get_dirname( stardict_data_dir );
1435
	strcpy( (char*)&stardict_data_dir, buf );
1436
	g_free( buf );
1437
	return false;
1438
}
1439
#endif
1410
#endif
1440
1411
1441
#ifdef _WIN32
1412
#ifdef _WIN32
Lines 1444-1456 Link Here
1444
int main(int argc,char **argv)
1415
int main(int argc,char **argv)
1445
#endif
1416
#endif
1446
{			
1417
{			
1418
  //set gStarDictDataDir;
1447
#ifdef _WIN32
1419
#ifdef _WIN32
1448
	if (set_stardict_data_dir())
1420
  HMODULE hmod;
1449
    return EXIT_SUCCESS;
1421
1450
	gchar *locale_dir;
1422
  if ((hmod = GetModuleHandle(NULL))==0)
1451
	locale_dir = g_strdup_printf("%s" G_DIR_SEPARATOR_S "locale", stardict_data_dir);
1423
    return EXIT_FAILURE;
1452
	bindtextdomain (GETTEXT_PACKAGE, locale_dir);
1424
  char tmp_buf[256];
1453
	g_free(locale_dir);
1425
  if (GetModuleFileName(hmod, tmp_buf, sizeof(tmp_buf))==0)
1426
    return EIXT_FAILURE;
1427
  
1428
  gchar* buf = g_path_get_dirname(tmp_buf);
1429
  gStarDictDataDir=buf;
1430
  g_free(buf);
1431
#else
1432
  gStarDictDataDir=STARDICT_DATA_DIR;
1433
#endif
1434
1435
#ifdef _WIN32  
1436
  bindtextdomain (GETTEXT_PACKAGE, (gStarDictDataDir+G_DIR_SEPARATOR_S+"locale").c_str());
1454
#else
1437
#else
1455
	bindtextdomain (GETTEXT_PACKAGE, STARDICT_LOCALEDIR);
1438
	bindtextdomain (GETTEXT_PACKAGE, STARDICT_LOCALEDIR);
1456
#endif
1439
#endif
Lines 1471-1489 Link Here
1471
    gtk_set_locale ();
1454
    gtk_set_locale ();
1472
    gtk_init (&argc, &argv);
1455
    gtk_init (&argc, &argv);
1473
1456
1474
	g_log_set_handler (NULL, (enum GLogLevelFlags)(G_LOG_LEVEL_MASK | G_LOG_FLAG_FATAL | G_LOG_FLAG_RECURSION),
1457
  g_log_set_handler (NULL, (GLogLevelFlags)(G_LOG_LEVEL_MASK | G_LOG_FLAG_FATAL | G_LOG_FLAG_RECURSION),
1475
			   stardict_dummy_log_handler, NULL);	
1458
			   stardict_dummy_log_handler, NULL);	
1476
	g_log_set_handler ("Gdk", (enum GLogLevelFlags)(G_LOG_LEVEL_MASK | G_LOG_FLAG_FATAL | G_LOG_FLAG_RECURSION),
1459
  g_log_set_handler ("Gdk", (GLogLevelFlags)(G_LOG_LEVEL_MASK | G_LOG_FLAG_FATAL | G_LOG_FLAG_RECURSION),
1477
			   stardict_dummy_log_handler, NULL);
1460
			   stardict_dummy_log_handler, NULL);
1478
	g_log_set_handler ("Gtk", (enum GLogLevelFlags)(G_LOG_LEVEL_MASK | G_LOG_FLAG_FATAL | G_LOG_FLAG_RECURSION),
1461
  g_log_set_handler ("Gtk", (GLogLevelFlags)(G_LOG_LEVEL_MASK | G_LOG_FLAG_FATAL | G_LOG_FLAG_RECURSION),
1479
			   stardict_dummy_log_handler, NULL);
1462
			   stardict_dummy_log_handler, NULL);
1480
	g_log_set_handler ("GLib", (enum GLogLevelFlags)(G_LOG_LEVEL_MASK | G_LOG_FLAG_FATAL | G_LOG_FLAG_RECURSION),
1463
  g_log_set_handler ("GLib", (GLogLevelFlags)(G_LOG_LEVEL_MASK | G_LOG_FLAG_FATAL | G_LOG_FLAG_RECURSION),
1481
			   stardict_dummy_log_handler, NULL);
1464
			   stardict_dummy_log_handler, NULL);
1482
	g_log_set_handler ("GModule", (enum GLogLevelFlags)(G_LOG_LEVEL_MASK | G_LOG_FLAG_FATAL | G_LOG_FLAG_RECURSION),
1465
  g_log_set_handler ("GModule", (GLogLevelFlags)(G_LOG_LEVEL_MASK | G_LOG_FLAG_FATAL | G_LOG_FLAG_RECURSION),
1483
			   stardict_dummy_log_handler, NULL);
1466
			   stardict_dummy_log_handler, NULL);
1484
	g_log_set_handler ("GLib-GObject", (enum GLogLevelFlags)(G_LOG_LEVEL_MASK | G_LOG_FLAG_FATAL | G_LOG_FLAG_RECURSION),
1467
  g_log_set_handler ("GLib-GObject", (GLogLevelFlags)(G_LOG_LEVEL_MASK | G_LOG_FLAG_FATAL | G_LOG_FLAG_RECURSION),
1485
			   stardict_dummy_log_handler, NULL);
1468
			   stardict_dummy_log_handler, NULL);
1486
	g_log_set_handler ("GThread", (enum GLogLevelFlags)(G_LOG_LEVEL_MASK | G_LOG_FLAG_FATAL | G_LOG_FLAG_RECURSION),
1469
  g_log_set_handler ("GThread", (GLogLevelFlags)(G_LOG_LEVEL_MASK | G_LOG_FLAG_FATAL | G_LOG_FLAG_RECURSION),
1487
			   stardict_dummy_log_handler, NULL);
1470
			   stardict_dummy_log_handler, NULL);
1488
	g_set_print_handler( stardict_dummy_print );
1471
	g_set_print_handler( stardict_dummy_print );
1489
1472
Lines 1494-1506 Link Here
1494
			if (strcmp(argv[i], "-h") == 0) {
1477
			if (strcmp(argv[i], "-h") == 0) {
1495
				hide_option = TRUE;
1478
				hide_option = TRUE;
1496
			}
1479
			}
1497
		}
1480
    } else {
1498
		else {
1499
		    if (!queryword) {
1481
		    if (!queryword) {
1500
		    	if (g_utf8_validate (argv[i], -1, NULL)) {
1482
		    	if (g_utf8_validate (argv[i], -1, NULL)) {
1501
		    		queryword= g_strdup(argv[i]);			
1483
		    		queryword= g_strdup(argv[i]);			
1502
	    		}
1484
	} else
1503
	    		else
1504
	    			queryword = g_locale_to_utf8(argv[i],-1,NULL,NULL,NULL);
1485
	    			queryword = g_locale_to_utf8(argv[i],-1,NULL,NULL,NULL);
1505
   			}
1486
   			}
1506
		}
1487
		}
(-)stardict-cur-accepted/src/utils.cpp (+56 lines)
Line 0 Link Here
1
#ifdef HAVE_CONFIG_H
2
#  include "config.h"
3
#endif
4
5
#include <glib.h>
6
#include <cstdlib>
7
8
#if !defined(_WIN32) && !defined(WITHOUT_GNOME)
9
#  include <libgnome/libgnome.h>
10
#  include <libgnomeui/libgnomeui.h>
11
#elif defined(_WIN32)
12
#  include <gdk/gdkwin32.h>
13
#endif
14
15
#include "conf.h"
16
#include "stardict.h"
17
18
#include "utils.h"
19
20
void play_wav_file(const gchar *filename)
21
{
22
#ifdef _WIN32   
23
  PlaySound(filename, 0, SND_ASYNC | SND_FILENAME);
24
#elif !defined(WITHOUT_GNOME)
25
  gnome_sound_play(filename);
26
#else
27
  gchar *wavname=g_strdup(filename);
28
  gchar *argv[]={"play", wavname, NULL};
29
  if (!g_spawn_async(NULL, argv, NULL,
30
		    GSpawnFlags(G_SPAWN_SEARCH_PATH|G_SPAWN_STDOUT_TO_DEV_NULL|G_SPAWN_STDERR_TO_DEV_NULL),
31
		    NULL, NULL, NULL, NULL))
32
    g_message("g_spawn_async failes!\n");
33
  
34
  g_free(wavname);
35
#endif
36
}
37
38
void show_help(const gchar *section)
39
{
40
#ifdef _WIN32
41
  gchar *filename = g_strdup_printf(_("file:///%s/help/C/stardict.html"), gStarDictDataDir.c_str());
42
  ShellExecute((HWND)(GDK_WINDOW_HWND(gpAppFrame->oAppCore.window->window)), "OPEN", filename, NULL, NULL, SW_SHOWNORMAL);
43
  g_free(filename);
44
#elif !defined(WITHOUT_GNOME)
45
  gnome_help_display ("stardict.xml", section, NULL);
46
#endif
47
}
48
49
void show_url(const gchar *url)
50
{
51
#ifdef _WIN32
52
  ShellExecute((HWND)(GDK_WINDOW_HWND(gpAppFrame->oAppCore.window->window)), "OPEN", url, NULL, NULL, SW_SHOWNORMAL);
53
#elif !defined(WITHOUT_GNOME)
54
  gnome_url_show(url, NULL);
55
#endif
56
}
(-)stardict-cur-accepted/src/utils.h (+8 lines)
Line 0 Link Here
1
#ifndef UTILS_H
2
#define UTILS_H
3
4
extern void play_wav_file(const gchar *filename);
5
extern void show_help(const gchar *section);
6
extern void show_url(const gchar *url);
7
8
#endif/*UTILS_H*/
(-)stardict-cur-accepted/src/win32/configfile.cpp (-343 lines)
Lines 1-343 Link Here
1
/*
2
this file is copy form x11amp,i changed it for some place.
3
Õâ¸öÎļþÊÇÎÒ´Óx11amp(ÏÖÔÚ½Ðxmms)¿½À´µÄ,ÔöɾÁ˼¸¸öº¯Êý.
4
*/
5
6
#include <sys/stat.h>
7
#include <unistd.h>
8
#include <stdio.h>
9
#include <string.h>
10
#include <stdlib.h>
11
#include "configfile.h"
12
13
#include <string>
14
15
static ConfigSection *rw_cfg_create_section (ConfigFile * cfg, gchar * name);
16
static ConfigLine *rw_cfg_create_string (ConfigSection * section, gchar * key,
17
					 const gchar * value);
18
static ConfigSection *rw_cfg_find_section (ConfigFile * cfg, gchar * name);
19
static ConfigLine *rw_cfg_find_string (ConfigSection * section, gchar * key);
20
21
ConfigFile *
22
rw_cfg_open_file (gchar * filename)
23
{
24
	ConfigFile *cfg;
25
26
	FILE *file;
27
	gchar *buffer, **lines, *tmp;
28
	gint i;
29
	struct stat stats;
30
	ConfigSection *section = NULL;
31
32
	if (stat (filename, &stats) == -1)
33
		return NULL;
34
	if (!(file = fopen (filename, "rb")))
35
		return NULL;
36
37
	buffer = (gchar *)g_malloc (stats.st_size + 1);
38
	fread (buffer, 1, stats.st_size, file);
39
/*	if (fread (buffer, 1, stats.st_size, file) != stats.st_size)
40
	{
41
		g_free (buffer);
42
		fclose (file);
43
		return NULL;
44
	}
45
*/
46
	fclose (file);
47
	buffer[stats.st_size] = '\0';
48
49
	cfg = (ConfigFile *)g_malloc0 (sizeof (ConfigFile));
50
	cfg->cfgfilename = g_strdup (filename);
51
	cfg->changed = 0;
52
	lines = g_strsplit (buffer, "\n", 0);
53
	g_free (buffer);
54
	i = 0;
55
	while (lines[i])
56
	{
57
		if (lines[i][0] == '[')
58
		{
59
			if ((tmp = strchr (lines[i], ']')))
60
			{
61
				*tmp = '\0';
62
				section =
63
					rw_cfg_create_section (cfg,
64
							       &lines[i][1]);
65
			}
66
		}
67
		else if (lines[i][0] != '#' && section)
68
		{
69
			if ((tmp = strchr (lines[i], '=')))
70
			{
71
				*tmp = '\0';
72
				tmp++;
73
				rw_cfg_create_string (section, lines[i], tmp);
74
			}
75
		}
76
		i++;
77
	}
78
	g_strfreev (lines);
79
	return cfg;
80
}
81
82
83
gboolean
84
rw_cfg_write_file (ConfigFile * cfg, gchar * filename)
85
{
86
	FILE *file;
87
	GList *section_list, *line_list;
88
	ConfigSection *section;
89
	ConfigLine *line;
90
91
	if (!(file = fopen (filename, "wb")))
92
		return FALSE;
93
94
	section_list = cfg->sections;
95
	while (section_list)
96
	{
97
		section = (ConfigSection *) section_list->data;
98
		if (section->lines)
99
		{
100
			fprintf (file, "[%s]\n", section->name);
101
			line_list = section->lines;
102
			while (line_list)
103
			{
104
				line = (ConfigLine *) line_list->data;
105
				fprintf (file, "%s=%s\n", line->key,
106
					 line->value);
107
				line_list = g_list_next (line_list);
108
			}
109
			fprintf (file, "\n");
110
		}
111
		section_list = g_list_next (section_list);
112
	}
113
	fclose (file);
114
	return TRUE;
115
}
116
117
gboolean
118
rw_cfg_read_string (ConfigFile * cfg, gchar * section, gchar * key,
119
		    gchar ** value)
120
{
121
	ConfigSection *sect;
122
	ConfigLine *line;
123
124
	*value = NULL;
125
	if (!(sect = rw_cfg_find_section (cfg, section)))
126
		return FALSE;
127
	if (!(line = rw_cfg_find_string (sect, key)))
128
		return FALSE;
129
	*value = g_strdup (line->value);
130
	return TRUE;
131
}
132
133
gboolean
134
rw_cfg_read_int (ConfigFile * cfg, gchar * section, gchar * key, gint * value)
135
{
136
	gchar *str;
137
138
	if (!rw_cfg_read_string (cfg, section, key, &str))
139
	{
140
		*value = 0;
141
		return FALSE;
142
	}
143
	*value = atoi (str);
144
	g_free (str);
145
146
	return TRUE;
147
}
148
149
gboolean
150
rw_cfg_read_boolean (ConfigFile * cfg, gchar * section, gchar * key,
151
		     gboolean * value)
152
{
153
	gchar *str;
154
155
	if (!rw_cfg_read_string (cfg, section, key, &str))
156
	{
157
		*value = FALSE;
158
		return FALSE;
159
	}
160
	if (!strcmp (str, "0"))
161
		*value = FALSE;
162
	else
163
		*value = TRUE;
164
	g_free (str);
165
	return TRUE;
166
}
167
168
const char STRING_SEP = (const char) 0xff;
169
170
static GSList * str_to_list(gchar *str)
171
{
172
	GSList *list = NULL;
173
	gchar *p;
174
	while ((p = strchr(str, STRING_SEP))!=NULL) {
175
		list = g_slist_append(list, g_strndup(str, p - str));
176
		str = p+1;
177
	}
178
	if (str[0])
179
		list = g_slist_append(list, g_strdup(str));
180
	return list;
181
}
182
183
gboolean
184
rw_cfg_read_strlist (ConfigFile * cfg, gchar * section, gchar * key,
185
		     GSList ** list)
186
{
187
	gchar *str;
188
	
189
	if (!rw_cfg_read_string (cfg, section, key, &str))
190
	{		
191
		*list = NULL;
192
		return FALSE;
193
	}
194
	*list = str_to_list(str);
195
	g_free (str);
196
	return TRUE;
197
}
198
199
void
200
rw_cfg_write_string (ConfigFile * cfg, gchar * section, gchar * key,
201
		     const gchar * value)
202
{
203
	ConfigSection *sect;
204
	ConfigLine *line;
205
206
	cfg->changed = 1;
207
	sect = rw_cfg_find_section (cfg, section);
208
	if (!sect)
209
		sect = rw_cfg_create_section (cfg, section);
210
	if ((line = rw_cfg_find_string (sect, key)))
211
	{
212
		g_free (line->value);
213
		line->value = g_strchug (g_strchomp (g_strdup (value)));
214
	}
215
	else
216
		rw_cfg_create_string (sect, key, value);
217
}
218
219
void
220
rw_cfg_write_int (ConfigFile * cfg, gchar * section, gchar * key, gint value)
221
{
222
	gchar *strvalue;
223
	strvalue = g_strdup_printf ("%d", value);
224
	rw_cfg_write_string (cfg, section, key, strvalue);
225
	g_free (strvalue);
226
}
227
228
void
229
rw_cfg_write_boolean (ConfigFile * cfg, gchar * section, gchar * key,
230
		      gboolean value)
231
{
232
	if (value)
233
		rw_cfg_write_string (cfg, section, key, "1");
234
	else
235
		rw_cfg_write_string (cfg, section, key, "0");
236
}
237
238
void
239
rw_cfg_write_strlist (ConfigFile * cfg, gchar * section, gchar * key,
240
		      GSList * list)
241
{
242
	std::string string;
243
	if (list) {
244
		string += (gchar *)(list->data);
245
		list = list->next;
246
	}
247
	while (list) {
248
		string += STRING_SEP;
249
		string += (gchar *)(list->data);
250
		list = list->next;
251
	}
252
	rw_cfg_write_string (cfg, section, key, string.c_str());
253
}
254
255
void
256
rw_cfg_free (ConfigFile * cfg)
257
{
258
	ConfigSection *section;
259
	ConfigLine *line;
260
	GList *section_list, *line_list;
261
262
	g_free (cfg->cfgfilename);
263
	section_list = cfg->sections;
264
	while (section_list)
265
	{
266
		section = (ConfigSection *) section_list->data;
267
		g_free (section->name);
268
269
		line_list = section->lines;
270
		while (line_list)
271
		{
272
			line = (ConfigLine *) line_list->data;
273
			g_free (line->key);
274
			g_free (line->value);
275
			g_free (line);
276
			line_list = g_list_next (line_list);
277
		}
278
		g_list_free (section->lines);
279
		g_free (section);
280
281
		section_list = g_list_next (section_list);
282
	}
283
	g_list_free (cfg->sections);
284
	cfg->sections = NULL;	/*ÕâÁ½ÐÐÎÒ¼ÓµÄ,rw_cfg_freeºó¿É»Øµ½rw_cfg_new״̬,¿É¼ÌÐøʹÓÃ. */
285
	cfg->cfgfilename = NULL;
286
}
287
288
static ConfigSection *
289
rw_cfg_create_section (ConfigFile * cfg, gchar * name)
290
{
291
	ConfigSection *section;
292
	section = (ConfigSection *)g_malloc0 (sizeof (ConfigSection));
293
	section->name = g_strdup (name);
294
	cfg->sections = g_list_append (cfg->sections, section);
295
296
	return section;
297
}
298
299
static ConfigLine *
300
rw_cfg_create_string (ConfigSection * section, gchar * key, const gchar * value)
301
{
302
	ConfigLine *line;
303
	line = (ConfigLine *)g_malloc0 (sizeof (ConfigLine));
304
	line->key = g_strchug (g_strchomp (g_strdup (key)));
305
	line->value = g_strchug (g_strchomp (g_strdup (value)));
306
	section->lines = g_list_append (section->lines, line);
307
308
	return line;
309
}
310
311
static ConfigSection *
312
rw_cfg_find_section (ConfigFile * cfg, gchar * name)
313
{
314
	ConfigSection *section;
315
	GList *list;
316
317
	list = cfg->sections;
318
	while (list)
319
	{
320
		section = (ConfigSection *) list->data;
321
		if (!strcasecmp (section->name, name))
322
			return section;
323
		list = g_list_next (list);
324
	}
325
	return NULL;
326
}
327
328
static ConfigLine *
329
rw_cfg_find_string (ConfigSection * section, gchar * key)
330
{
331
	ConfigLine *line;
332
	GList *list;
333
334
	list = section->lines;
335
	while (list)
336
	{
337
		line = (ConfigLine *) list->data;
338
		if (!strcasecmp (line->key, key))
339
			return line;
340
		list = g_list_next (list);
341
	}
342
	return NULL;
343
}
(-)stardict-cur-accepted/src/win32/configfile.h (-52 lines)
Lines 1-52 Link Here
1
#ifndef __RW_CONFIGFILE_H__
2
#define __RW_CONFIGFILE_H__
3
4
#include <glib.h>
5
#include <time.h>
6
7
8
	typedef struct
9
	{
10
		gchar *key;
11
		gchar *value;
12
	}
13
	ConfigLine;
14
15
	typedef struct
16
	{
17
		gchar *name;
18
		GList *lines;
19
	}
20
	ConfigSection;
21
22
23
	typedef struct
24
	{
25
		GList *sections;
26
		gchar *cfgfilename;
27
		gboolean changed;
28
	}
29
	ConfigFile;
30
31
	ConfigFile *rw_cfg_open_file (gchar * filename);
32
	gboolean rw_cfg_write_file (ConfigFile * cfg, gchar * filename);
33
	void rw_cfg_free (ConfigFile * cfg);
34
35
	gboolean rw_cfg_read_string (ConfigFile * cfg, gchar * section,
36
				     gchar * key, gchar ** value);
37
	gboolean rw_cfg_read_int (ConfigFile * cfg, gchar * section,
38
				  gchar * key, gint * value);
39
	gboolean rw_cfg_read_boolean (ConfigFile * cfg, gchar * section,
40
				      gchar * key, gboolean * value);
41
	gboolean rw_cfg_read_strlist (ConfigFile * cfg, gchar * section,
42
				     gchar * key, GSList ** list);
43
	void rw_cfg_write_string (ConfigFile * cfg, gchar * section,
44
				  gchar * key, const gchar * value);
45
	void rw_cfg_write_int (ConfigFile * cfg, gchar * section, gchar * key,
46
			       gint value);
47
	void rw_cfg_write_boolean (ConfigFile * cfg, gchar * section,
48
				   gchar * key, gboolean value);
49
	void rw_cfg_write_strlist (ConfigFile * cfg, gchar * section,
50
				  gchar * key, GSList * list);
51
52
#endif
(-)stardict-cur-accepted/src/win32/Makefile.am (-2 / +2 lines)
Lines 1-7 Link Here
1
SUBDIRS = nsis
1
SUBDIRS = nsis
2
2
3
EXTRA_DIST = configfile.cpp configfile.h intl.h MinimizeToTray.cpp \
3
EXTRA_DIST = intl.h MinimizeToTray.cpp \
4
	MinimizeToTray.h resource.h stardictrc.rc StdAfx.h systray.cpp \
4
	MinimizeToTray.h resource.h stardictrc.rc StdAfx.h systray.cpp \
5
	systray.h systray-normal.ico systray-scan.ico systray-stop.ico \
5
	systray.h systray-normal.ico systray-scan.ico systray-stop.ico \
6
	winconf.cpp winconf.h gnome-about.c gnome-about.h about_menu.png \
6
	gnome-about.c gnome-about.h about_menu.png \
7
	clipboard.cpp clipboard.h
7
	clipboard.cpp clipboard.h
(-)stardict-cur-accepted/src/win32/winconf.cpp (-168 lines)
Lines 1-168 Link Here
1
#ifdef HAVE_CONFIG_H
2
#  include "config.h"
3
#endif
4
5
#include "winconf.h"
6
#include "../stardict.h"
7
#include "intl.h"
8
9
#include <cstdio>
10
#include <cstdlib>
11
#include <sys/stat.h>
12
13
// Notice: once you changed this file, try to change src/conf.cpp too.
14
15
ConfigFile *usercfgfile;
16
17
void init_conf()
18
{
19
	struct stat st;
20
	gchar *filename = g_build_filename(stardict_data_dir, "stardict.cfg", NULL);
21
	if (stat (filename, &st))
22
	{
23
		FILE *file;
24
		if ((file = fopen (filename, "wb")) == NULL) {
25
			g_free(filename);
26
			return;
27
		}
28
		fprintf (file, "[preferences/dictionary]\n"
29
  							"scan_selection=1\n"
30
							"only_scan_while_modifier_key=0\n"
31
							"hide_floatwin_when_modifier_key_released=1\n"
32
							"scan_modifier_key=0\n"
33
							"enable_sound_event=1\n"
34
							
35
		);
36
		fprintf (file, _("use_custom_font=1\ncustom_font=sans 8\n"));
37
		fprintf (file, "[preferences/main_window]\n"
38
							"hide_on_startup=0\n"
39
							"search_website_list=\n"
40
							"maximized=0\n"
41
							"hide_list=0\n"
42
		);
43
		fprintf (file, _("window_width=551\nwindow_height=357\nhpaned_pos=165\n"));
44
		fprintf (file, "[preferences/notification_area_icon]\n"
45
							"query_in_floatwin=1\n"
46
		);
47
		fprintf (file, "[preferences/floating_window]\n"
48
							"pronounce_when_popup=0\n"
49
							"max_window_width=320\n"
50
							"max_window_height=240\n"
51
							"lock=0\n"
52
							"lock_x=0\n"
53
							"lock_y=0\n"
54
		);
55
		fprintf (file, "[manage_dictionaries]\n"
56
							"dict_order_list=\n"
57
							"dict_disable_list=\n"
58
							"treedict_order_list=\n"
59
							"treedict_disable_list=\n"
60
		);
61
		fclose (file);
62
	}
63
	usercfgfile = rw_cfg_open_file (filename);
64
	g_free(filename);
65
}
66
67
void save_conf()
68
{
69
	if (usercfgfile->changed)
70
		rw_cfg_write_file(usercfgfile,usercfgfile->cfgfilename);
71
	rw_cfg_free (usercfgfile);
72
	g_free (usercfgfile);
73
}
74
75
void on_conf_dictionary_scan_selection_changed(gboolean scan)
76
{
77
	if (gpAppFrame->oAppCore.oSelection.bEnable == scan)
78
		return;
79
	gpAppFrame->oAppCore.oSelection.bEnable = scan;
80
	gtk_widget_set_sensitive(gpAppFrame->oAppCore.oFloatWin.StopButton, scan);
81
	if 	(scan != gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(gpAppFrame->oAppCore.oBottomWin.ScanSelectionCheckButton))) {
82
		gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(gpAppFrame->oAppCore.oBottomWin.ScanSelectionCheckButton),scan);
83
	}		
84
	if (scan) {
85
		if (!GTK_WIDGET_VISIBLE(gpAppFrame->oAppCore.window)) {
86
			gpAppFrame->oAppCore.oDockLet.SetIcon(DOCKLET_SCAN_ICON);
87
		}
88
		if (gpAppFrame->oAppCore.oFloatWin.bIsLocked && (gpAppFrame->oAppCore.oFloatWin.QueryingWord.c_str())[0]!='\0')
89
			gpAppFrame->oAppCore.oFloatWin.Show();
90
	}
91
	else {
92
		if (!GTK_WIDGET_VISIBLE(gpAppFrame->oAppCore.window)) {
93
			gpAppFrame->oAppCore.oDockLet.SetIcon(DOCKLET_STOP_ICON);
94
		}
95
		gpAppFrame->oAppCore.oFloatWin.Hide();
96
		gpAppFrame->oAppCore.oSelection.LastClipWord.clear();
97
	}
98
}
99
100
void on_conf_dictionary_only_scan_while_modifier_key_changed(gboolean only_scan)
101
{  
102
	gpAppFrame->oAppCore.oSelection.only_scan_while_modifier_key = only_scan;
103
}
104
105
void on_conf_dictionary_hide_floatwin_when_modifier_key_released_changed(gboolean hide)
106
{
107
	gpAppFrame->oAppCore.oFloatWin.hide_floatwin_when_modifier_key_released = hide;
108
}
109
110
void on_conf_dictionary_scan_modifier_key_changed(gint key)
111
{
112
	gpAppFrame->oAppCore.oSelection.scan_modifier_key = key;
113
}
114
115
void on_conf_dictionary_enable_sound_event_changed(gboolean enable)
116
{
117
	gpAppFrame->enable_sound_event = enable;
118
}
119
120
void on_conf_main_window_searchwebsite_list_changed(GSList *list)
121
{
122
	g_slist_foreach (gpAppFrame->oAppCore.oBottomWin.searchwebsite_list, (GFunc)g_free, NULL);
123
	g_slist_free (gpAppFrame->oAppCore.oBottomWin.searchwebsite_list);
124
	gpAppFrame->oAppCore.oBottomWin.searchwebsite_list = list;
125
}
126
127
void on_conf_main_window_hide_list_changed(gboolean hide)
128
{
129
	if (hide) {
130
		gtk_widget_hide(gpAppFrame->oAppCore.oMidWin.oToolWin.HideListButton);
131
		gtk_widget_show(gpAppFrame->oAppCore.oMidWin.oToolWin.ShowListButton);
132
		gtk_widget_hide(gpAppFrame->oAppCore.oMidWin.oIndexWin.vbox);
133
	}
134
	else {
135
		gtk_widget_hide(gpAppFrame->oAppCore.oMidWin.oToolWin.ShowListButton);
136
		gtk_widget_show(gpAppFrame->oAppCore.oMidWin.oToolWin.HideListButton);
137
		gtk_widget_show(gpAppFrame->oAppCore.oMidWin.oIndexWin.vbox);
138
	}
139
}
140
141
void on_conf_notification_area_icon_show_in_floatwin_changed(gboolean query_in_floatwin)
142
{
143
	gpAppFrame->oAppCore.oDockLet.query_in_floatwin = query_in_floatwin;
144
}
145
146
void on_conf_floatwin_pronounce_when_popup_changed(gboolean pronounce_when_popup)
147
{
148
	gpAppFrame->oAppCore.oFloatWin.pronounce_when_popup = pronounce_when_popup;
149
}
150
151
void on_conf_floatwin_max_window_width_changed(gint width)
152
{
153
	gpAppFrame->oAppCore.oFloatWin.Window_max_width = width;
154
}
155
156
void on_conf_floatwin_max_window_height_changed(gint height)
157
{
158
	gpAppFrame->oAppCore.oFloatWin.Window_max_height = height;
159
}
160
161
void on_conf_floatwin_lock_changed(gboolean lock)
162
{
163
	gpAppFrame->oAppCore.oFloatWin.bIsLocked = lock;
164
	if (lock)
165
		gtk_image_set_from_stock(GTK_IMAGE(gpAppFrame->oAppCore.oFloatWin.lock_image),GTK_STOCK_GOTO_LAST,GTK_ICON_SIZE_MENU);
166
	else
167
		gtk_image_set_from_stock(GTK_IMAGE(gpAppFrame->oAppCore.oFloatWin.lock_image),GTK_STOCK_GO_FORWARD,GTK_ICON_SIZE_MENU);
168
}
(-)stardict-cur-accepted/src/win32/winconf.h (-25 lines)
Lines 1-25 Link Here
1
#ifndef __SD_WIN_CONF_H__
2
#define __SD_WIN_CONF_H__
3
4
#include "configfile.h"
5
6
extern ConfigFile *usercfgfile;
7
8
extern void init_conf();
9
extern void save_conf();
10
11
extern void on_conf_dictionary_scan_selection_changed(gboolean scan);
12
extern void on_conf_dictionary_only_scan_while_modifier_key_changed(gboolean only_scan);
13
extern void on_conf_dictionary_hide_floatwin_when_modifier_key_released_changed(gboolean hide);
14
extern void on_conf_dictionary_scan_modifier_key_changed(gint key);
15
extern void on_conf_dictionary_enable_sound_event_changed(gboolean enable);
16
extern void on_conf_main_window_searchwebsite_list_changed(GSList *list);
17
extern void on_conf_main_window_hide_list_changed(gboolean hide);
18
extern void on_conf_notification_area_icon_show_in_floatwin_changed(gboolean query_in_floatwin);
19
extern void on_conf_floatwin_pronounce_when_popup_changed(gboolean pronounce_when_popup);
20
extern void on_conf_floatwin_max_window_width_changed(gint width);
21
extern void on_conf_floatwin_max_window_height_changed(gint height);
22
extern void on_conf_floatwin_lock_changed(gboolean lock);
23
24
#endif
25

Return to bug 86379