void
on_default_button_clicked              (GtkButton       *button,
                                        gpointer         user_data)
{
	short paper_size_value = GetCurrentnValue(CNCL_PAPERSIZE);
	short margin_type_value = GetCurrentnValue(CNCL_MARGINTYPE);

	FreeDataBase();
	InitDataBase(g_model_name);

	// Initialize the print quality toggle button.
	gtk_toggle_button_set_active(
		GTK_TOGGLE_BUTTON(LookupWidget(UI_DIALOG(g_main_window)->window,
			"quality_standard_button")), TRUE);
	SetQualityCustomValue(g_quality_dialog);



	// Initialize the color adjustment toggle button.
	gtk_toggle_button_set_active(
		GTK_TOGGLE_BUTTON(LookupWidget(UI_DIALOG(g_main_window)->window,
			"color_auto_button")), TRUE);

	// Initialize the print bw toggle button.
	gtk_toggle_button_set_active(
		GTK_TOGGLE_BUTTON(LookupWidget(UI_DIALOG(g_main_window)->window,
			"print_bw_button1")), FALSE);
	gtk_toggle_button_set_active(
		GTK_TOGGLE_BUTTON(LookupWidget(UI_DIALOG(g_main_window)->window,
			"print_bw_button2")), FALSE);

	// Re-create the color adjustment dialog.
	g_color_dialog
		= ReCreateColorDialog( g_color_dialog, UI_DIALOG(g_main_window));

	// Restore paper size and margin type.
	UpdateMenuLink(CNCL_PAPERSIZE, paper_size_value);
	UpdateMenuLink(CNCL_MARGINTYPE, margin_type_value);

	// Update widgets.
	DisableSignal();
	UpdateWidgets(UI_DIALOG(g_main_window)->window, NULL);
	EnableSignal();

	// Update all of window
	UpdateDialog(UI_DIALOG(g_main_window), NULL);
}
Example #2
0
CString CreateDB(void){
	
	CString result;
	char dbName[15];
	if(AWord[2].type!=identifier){
		result="'CREATE DATABASE' 附近有语法错误!漏了数据库名?";//缺少数据库名称
		return result;
	}
	if(AWord[3].type!=semicolon){
		result="SQL语句有语法错误!漏了分号?";//缺少分号
		return result;
	}
	/////////////////

	strcpy(dbName,AWord[2].word);//数据库名称
	InitDataBase(dbName);//初始化数据库

	result="操作成功!";
	return result;

}
Example #3
0
int main(int argc, char *argv[])
{
	int ret = 1;

	g_main_window=NULL;	/* for UpdateMenuLink (check "first call") */
	g_quality_dialog = NULL;	/* for UpdateMenuLink (check "first call") */

	bindtextdomain(PACKAGE, PACKAGE_LOCALE_DIR);
	bind_textdomain_codeset( PACKAGE, "UTF-8" );
	textdomain(PACKAGE);

	gtk_set_locale();

	// Set gtk resource file.
	SetGtkResourceFile();

	gtk_init(&argc, &argv);

#ifdef	USE_LIB_GLADE
	// Initialize the glade library.
	glade_init();
#endif

	// Parse options.
	InitOption(argc, argv);

	// Set the directory name for storing keytext files.
	SetKeyTextDir(PACKAGE_DATA_DIR);

#ifndef	USE_LIB_GLADE
	// Set the directory name for storing xpm files.
	SetPixmapDir(PACKAGE_DATA_DIR);
#endif

	// Load fontset.
	//g_main_font = LoadFontSet();
	g_main_font = NULL;

	// Initialize signal control level.
	InitSignal();

	// Load the glade and keytext file.
	if( LoadResources() )
	{
		// Initialize databases.
		InitDataBase(g_model_name);

		// Initialize printint type table.
		InitPrintingType();

		// Create main dialog, and realize it.
		g_main_window = CreateMainWindow();
		gtk_widget_realize(UI_DIALOG(g_main_window)->window);

		// Create dialogs.
		CreateDialogs();

		// Connect signal handlers.
		ConnectSignalHandlers();

		// Update widgets.
		DisableSignal();
		UpdateWidgets(UI_DIALOG(g_main_window)->window, NULL);
		EnableSignal();

		// Set window title.
		snprintf(g_window_title, sizeof(g_window_title), "Canon %s", GetDispModelName());	//Ver.2.90(s)

		gtk_window_set_title(
			GTK_WINDOW(UI_DIALOG(g_main_window)->window), g_window_title);

		// Show widgets depend on model.
		ShowModelDependWidgets(g_main_window);

		gtk_widget_show(UI_DIALOG(g_main_window)->window);
		gtk_main();

		ret = 0;

		// Dispose dialogs.
		DisposeDialogs();

		// Dispose main dialog.
		DisposeDialog(UI_DIALOG(g_main_window));

		// Free databases.
		FreeDataBase();

		// Free resources.
		FreeResources();
	}
	// Free Gdk resource.
	if( g_main_font )
		gdk_font_unref(g_main_font);

	// Free option strings.
	FreeOption();

	return ret;
}
Example #4
0
int DoInitialize()
{
	cout << "Version:" << XVERSIONNO << endl;

	int iThreadPoolSize = 0;
	char *pThreadPoolSize = NULL;
#ifdef _WIN32
	_CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF);
#else
	signal(SIGCLD, SIG_IGN);
	signal(SIGPIPE, SIG_IGN);
	signal(SIGINT, exit);
	signal(SIGKILL, exit);
	signal(SIGTERM, exit);
	signal(SIGQUIT, exit);
#endif

	char szFileName[256 + 1] = { 0 };
#ifdef _WIN32
	DWORD dwResult = GetModuleFileName(NULL, szFileName, 256);
	if (dwResult <= 0 || dwResult > 256)
	{
		cout << "Windows GetModuleFileName Fail" << endl;
		return X_FAILURE;
	}
	g_xAppConfigInfo.m_strFileName = szFileName;
	int iTemp = g_xAppConfigInfo.m_strFileName.find_last_of("\\") + 1;
	g_xAppConfigInfo.m_strPath = g_xAppConfigInfo.m_strFileName.substr(0, iTemp);
	g_xAppConfigInfo.m_strFile = g_xAppConfigInfo.m_strFileName.substr(iTemp);
#else
	int iPathLen = readlink("/proc/self/exe", szFileName, 256);
	if (iPathLen <= 0 || iPathLen > 256)
	{
		cout << "Linux readlink Fail" << endl;
		return X_FAILURE;
	}
	g_xAppConfigInfo.m_strFileName = szFileName;
	int iTemp = g_xAppConfigInfo.m_strFileName.find_last_of("/") + 1;
	g_xAppConfigInfo.m_strPath = g_xAppConfigInfo.m_strFileName.substr(0, iTemp);
	g_xAppConfigInfo.m_strFile = g_xAppConfigInfo.m_strFileName.substr(iTemp);
#endif
	cout << "FileName:" + g_xAppConfigInfo.m_strFileName << endl;
	cout << "Path:" + g_xAppConfigInfo.m_strPath << endl;
	cout << "File:" + g_xAppConfigInfo.m_strFile << endl;

	int iResult = X_SUCCESS;
	//初始化日志
	iResult = XLogClass::Initialize(g_xAppConfigInfo.m_strPath, g_xAppConfigInfo.m_strFile, log4cpp::Priority::DEBUG);
	if (iResult != X_SUCCESS)
	{
		cout << "XLogClass::Initialize Fail" << endl;
		return X_FAILURE;
	}

	//读取配置
	iResult = XConfig::ReadConfig();
	if (iResult != X_SUCCESS)
	{
		XLogClass::error("XConfig::ReadConfig Fail");
		return X_FAILURE;
	}

	//设置配置中的日志级别
	XLogClass::SetPriority(g_xAppConfigInfo.m_xLoggerInfo.m_iLogPriority);

	//初始化线程池,要环境变量增加 UV_THREADPOOL_SIZE
	pThreadPoolSize = getenv("UV_THREADPOOL_SIZE");
	if (pThreadPoolSize != NULL)
		iThreadPoolSize = atoi(pThreadPoolSize);
	else
		iThreadPoolSize = 0;
	cout << "Before Set ThreadPoolSize:" << iThreadPoolSize << endl;
	if (g_xAppConfigInfo.m_xThreadPoolInfo.m_szSize > 0 && g_xAppConfigInfo.m_xThreadPoolInfo.m_szSize != (size_t)iThreadPoolSize)
	{
		string strSize = "UV_THREADPOOL_SIZE=" + convert<string>(g_xAppConfigInfo.m_xThreadPoolInfo.m_szSize);
		iResult = putenv((char *)strSize.c_str());
		if (iResult != X_SUCCESS)
		{
			XLogClass::error("ThreadPool Initialize Fail");
		}
	}

	pThreadPoolSize = getenv("UV_THREADPOOL_SIZE");
	if (pThreadPoolSize != NULL)
		iThreadPoolSize = atoi(pThreadPoolSize);
	else
		iThreadPoolSize = 0;
	cout << "After Set ThreadPoolSize:" << iThreadPoolSize << endl;

	InitOpensslLocks();
	cout << "InitOpensslLocks OK" << endl;

	//_CrtDumpMemoryLeaks();
	//初始化TcpClient连接
	iResult = InitTcpClientPool();
	if (iResult != X_SUCCESS)
	{
		XLogClass::error("InitTcpClientPool Fail");
	}

	//初始化数据库连接
	iResult = InitDataBase();
	if (iResult != X_SUCCESS)
	{
		XLogClass::error("InitDataBase Fail");
		return X_FAILURE;
	}

	iResult = InitService();
	if (iResult != X_SUCCESS)
	{
		XLogClass::error("InitService Fail");
		return X_FAILURE;
	}

	iResult = InitListener();
	if (iResult != X_SUCCESS)
	{
		XLogClass::error("InitListener Fail");
		return X_FAILURE;
	}

	//ReleaseOpensslLocks();
	return X_SUCCESS;
}