⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 main.cpp

📁 linux pritner GUI
💻 CPP
📖 第 1 页 / 共 2 页
字号:
	  temp.append(init, start, init.size() - start);	  start = end;	}	prog_config.parms.push_back(temp);      }    }        else {      prog_config.parms.push_back("-iZ");      prog_config.parms.push_back("-i&FE&D2S7=120");      prog_config.parms.push_back("-i&C0");      prog_config.parms.push_back("-iM1L0");          }        if (!reset.empty()) {      std::string::size_type start = 0;      std::string::size_type end;          while (start != std::string::npos) {	temp = "-k";	end = reset.find_first_of(" \t", start);	if (end != std::string::npos) {	  temp.append(reset, start, end - start);	  start = reset.find_first_not_of(" \t", end); // prepare for the next iteration	}	else {	  temp.append(reset, start, reset.size() - start);	  start = end;	}	prog_config.parms.push_back(temp);      }    }    else prog_config.parms.push_back("-kZ");        if (!modem_class.empty()) {      temp = "-o";      if (!modem_class.compare("2.0")) temp += '0';      else if (!modem_class.compare("1")) temp += '1';      else if (!modem_class.compare("2")) temp += '2';      else {	return_val += gettext("Invalid modem class specified\n"			      "Adopting default of Class 2\n");        temp += '2';      }      prog_config.parms.push_back(temp);    }          if (device.empty()) {      if (access("/dev/modem", F_OK) == -1) {	return_val += gettext("No serial port device specified in " RC_FILE " configuration file\n"			      "and /dev/modem does not exist\n");      }            else {	return_val += gettext("No serial port device specified in " RC_FILE " configuration file\n"			      "Using default of /dev/modem\n");	device = "modem";      }    }    if (!device.empty()) {      std::string locale_device;      try {	locale_device = Glib::locale_from_utf8(device);      }      catch (Glib::ConvertError&) {	write_error("UTF-8 conversion error in configure_prog() - device\n");      }      if (!locale_device.empty()) {	if (lock_file.empty()) {	  prog_config.lock_file = "/var/lock";	}	else {	  try {	    prog_config.lock_file = Glib::filename_from_utf8(lock_file);	  }	  catch (Glib::ConvertError&) {	    write_error("UTF-8 conversion error in configure_prog() - lock file\n");	    write_error("Defaulting to /var/lock\n");	    prog_config.lock_file = "/var/lock";	  }	}		prog_config.lock_file += "/LCK..";	prog_config.lock_file += device;		temp = "-d/dev/";	temp += locale_device;	prog_config.parms.push_back(temp);	temp = "-x";	temp += prog_config.lock_file;	prog_config.parms.push_back(temp);      }    }    if (!capabilities.empty()) {      temp = "-c";      temp += capabilities;      prog_config.parms.push_back(temp);    }    if (prog_config.resolution.empty()) {      return_val += gettext("Adopting default fax resolution of 204x196\n");      prog_config.resolution = "204x196";    }    else {      temp = prog_config.resolution.lowercase();      if (!temp.compare("fine")) prog_config.resolution = "204x196";      else if (!temp.compare("standard")) prog_config.resolution = "204x98";      else {	return_val += gettext("Invalid fax resolution specified\n"			      "Adopting default fax resolution of 204x196\n");	prog_config.resolution = "204x196";      }    }        if (rings.empty()) prog_config.rings = '1';    else if (rings.size() > 1 || rings[0] < '1' || rings[0] > '9') {      return_val += gettext("Invalid ring number specified\n"			    "Will answer after one ring\n");      prog_config.rings = '1';    }    else prog_config.rings = rings[0];    if (prog_config.page_size.empty()) {      return_val += gettext("Adopting default page size of a4\n");      prog_config.page_size = "a4";      prog_config.page_dim = "210x297mm";    }    else {      prog_config.page_size = prog_config.page_size.lowercase();      if (!prog_config.page_size.compare("a4")) prog_config.page_dim = "210x297mm";      else if (!prog_config.page_size.compare("letter")) prog_config.page_dim = "216x279mm";      else if (!prog_config.page_size.compare("legal")) prog_config.page_dim = "216x356mm";      else {	return_val += gettext("Invalid page size specified\n"			      "Adopting default page size of a4\n");	prog_config.page_size = "a4";	prog_config.page_dim = "210x297mm";      }    }        if (dialmode.empty()) prog_config.tone_dial = true;    else {      temp = dialmode.lowercase();      if (!temp.compare("tone")) prog_config.tone_dial = true;      else if (!temp.compare("pulse")) prog_config.tone_dial = false;      else {	return_val += gettext("Invalid dialmode specified\n"			      "Adopting default of tone dialling\n");	prog_config.tone_dial = true;      }    }    if (!extra_parms.empty()) {      std::string::size_type start = 0;      std::string::size_type end;          while (start != std::string::npos) {	end = extra_parms.find_first_of(" \t", start);	if (end != std::string::npos) {	  temp.assign(extra_parms, start, end - start);	  start = extra_parms.find_first_not_of(" \t", end); // prepare for the next iteration	}	else {	  temp.assign(extra_parms, start, extra_parms.size() - start);	  start = end;	}	prog_config.parms.push_back(temp);      }    }    if (prog_config.print_cmd.empty()) {      return_val += gettext("Adopting default printer command of 'lpr'\n");      prog_config.print_cmd = "lpr";    }        if (prog_config.print_shrink.empty()) {      prog_config.print_shrink = "100";    }    else if (std::atoi(prog_config.print_shrink.c_str()) < 50 || std::atoi(prog_config.print_shrink.c_str()) > 100) {      return_val += gettext("Invalid print shrink specified: adopting default value of 100\n");      prog_config.print_shrink = "100";    }        temp = print_popup.lowercase();    if (!temp.compare("no")) prog_config.print_popup = false;    else prog_config.print_popup = true;    if (prog_config.ps_view_cmd.empty()) {      return_val += gettext("Adopting default postscript view command of 'gv'\n");      prog_config.ps_view_cmd = "gv";    }    temp = sock_server.lowercase();    if (!temp.compare("yes")) prog_config.sock_server = true;    else prog_config.sock_server = false;    temp = sock_popup.lowercase();    if (!temp.compare("yes")) prog_config.sock_popup = true;    else prog_config.sock_popup = false;    if (prog_config.sock_server_port.empty()) {      if (prog_config.sock_server) 	return_val += gettext("No port for the socket server has been specified, "			      "so the server will not be started\n");    }    else if (std::atoi(prog_config.sock_server_port.c_str()) < 1024	     || std::atoi(prog_config.sock_server_port.c_str()) > 65535) {      return_val += gettext("Invalid port for the socket server has been specified, "			    "so the server will not be started.  It needs to be between "			    "1024 and 65535\n");      prog_config.sock_server_port = "";    }    temp = sock_client_address.lowercase();    if (!temp.compare("other")) prog_config.other_sock_client_address = true;    else prog_config.other_sock_client_address = false;    if (!sock_other_addresses.empty()) {      std::string::size_type start = 0;      std::string::size_type end;          while (start != std::string::npos) {	end = sock_other_addresses.find_first_of(" \t", start);	if (end != std::string::npos) {	  temp.assign(sock_other_addresses, start, end - start);	  start = sock_other_addresses.find_first_not_of(" \t", end); // prepare for the next iteration	}	else {	  temp.assign(sock_other_addresses, start, sock_other_addresses.size() - start);	  start = end;	}	prog_config.permitted_clients_list.push_back(temp);      }    }    temp = fax_received_popup.lowercase();    if (!temp.compare("yes")) prog_config.fax_received_popup = true;    else prog_config.fax_received_popup = false;    temp = fax_received_exec.lowercase();    if (!temp.compare("yes")) prog_config.fax_received_exec = true;    else prog_config.fax_received_exec = false;    if (!reread) {  // prog_config.working_dir and prog_config.GPL_flag are not                    // affected by the settings dialog and so not re-configurable                    // after the program has initialised itself for the first time      // CMV 24-07-04      if (!work_subdir.empty()) {	prog_config.working_dir += '/';	prog_config.working_dir += Glib::filename_from_utf8(work_subdir);	if (mkdir_with_parent(prog_config.working_dir) && errno != EEXIST) {	  return_val += gettext("Invalid WORK_SUBDIR: directory specified. "				"WORK_SUBDIR: will be ignored\n");	  prog_config.working_dir = prog_config.homedir;	}      }      std::string file_name(prog_config.working_dir + "/" MAINWIN_SAVE_FILE);      int result = access(file_name.c_str(), F_OK);        if (!result) prog_config.GPL_flag = true;      else prog_config.GPL_flag = false;    }  }  return return_val;}void get_fonts(void) {  // this will get a suitable fixed font for GplDialog and HelpDialog to use with Pango  const int MAX_FONTS = 10000;  int num_fonts;  char** fonts = XListFonts(GDK_DISPLAY(), "-*", MAX_FONTS, &num_fonts);  if (fonts) {    int count;    std::string inspect_name;    prog_config.fixed_font = "";    //try for courier font    for (count = 0; count < num_fonts; count++) {      inspect_name = fonts[count];      std::string::size_type pos = pos = inspect_name.find("courier-medium-r-normal-");      if (pos != std::string::npos) {	prog_config.fixed_font = "courier";	break;      }    }    // unsuccessful -- go for the generic "fixed" font    if (prog_config.fixed_font.empty()) prog_config.fixed_font = "fixed";  }  XFreeFontNames(fonts);}bool get_prog_parm(const char* name, std::string& line, Glib::ustring& result,		   Glib::ustring(*convert_func)(const std::string&)) {// This function looks for a setting named `name' in the string `line'// and returns the values stated after it in string `result'.  It returns// `true' if the setting was found.  If there are trailing spaces or tabs,// string `line' will be modified.  string `result' is only modified if// the `name' setting is found.  Anything extracted from `line' will be// converted (when placed into `result') to UTF-8 as maintained by// Glib::ustring, using the function assigned to function pointer// convert_func (you would normally use Glib::locale_to_utf8() or// Glib::filename_to_utf8(), and there is a default inline function// using Glib::locale_to_utf8()  const std::string::size_type length = std::strlen(name);  // we have to use std::string::substr() because libstdc++-2  // doesn't support the Std-C++ std::string::compare() functions  if (!line.substr(0, length).compare(name)) {    // erase any trailing space or tab    while (line.find_last_of(" \t") == line.size() - 1) line.resize(line.size() - 1);    if (line.size() > length) {      // ignore any preceding space or tab from the setting value given      std::string::size_type pos = line.find_first_not_of(" \t", length); // pos now is set to beginning of setting value      if (pos != std::string::npos) {	try {	  result.assign(convert_func(line.substr(pos)));	}	catch (Glib::ConvertError&) {	  result = "";	  write_error("UTF-8 conversion error in get_prog_parm()\n");	}      }    }    return true;  }  return false;}void beep(void) {  XBell(GDK_DISPLAY(), 0);}void get_window_icon(void) {  bool have_icon = false;#if GTKMM_VERSION >= 24  Glib::RefPtr<Gtk::IconTheme> icon_theme_r = Gtk::IconTheme::get_default();  // use the C function to look-up the icon - the gtkmm wrapper does not  // check whether look-up succeeded.  In addition, Gtk::IconInfo::get_filename()  // incorrectly returns a Glib::ustring object instead of a std::string object,  // without converting its contents to a valid UTF-8 encoded string  Gtk_icon_info_scoped_handle icon_info_h(			      gtk_icon_theme_lookup_icon(icon_theme_r->gobj(),							 "stock_send-fax",							 24, GtkIconLookupFlags(0)));  if (icon_info_h.get()) {          // we could use Glib::convert_const_gchar_ptr_to_stdstring, but this is not    // part of the publicly documented interface    const char* icon_path_p = (const char*)gtk_icon_info_get_filename(icon_info_h.get());    if (icon_path_p) {      try {	prog_config.window_icon_r = Gdk::Pixbuf::create_from_file(std::string(icon_path_p));	have_icon = true;      }      catch (Gdk::PixbufError&) {	write_error("Pixbuf error in get_window_icon()\n");      }    }  }#endif  if (!have_icon) {    prog_config.window_icon_r = Gdk::Pixbuf::create_from_xpm_data(window_icon_xpm);  }}int mkdir_with_parent(const std::string& dir) {  // this function must be passed an absolute path name  // on success it returns 0, and on failure it returns -1.  If -1 is returned  // for any reason other than that an absolute pathname was not passed  // then errno will be set by Unix mkdir()  // function provided by CMV 24-07-04  int return_val = 0;  if (dir[0] != '/') return_val = -1;  else {    std::string::size_type pos = 0;    while (pos != std::string::npos && (!return_val || errno == EEXIST)) {      pos = dir.find('/', ++pos);      if (pos != std::string::npos) {	return_val = mkdir(dir.substr(0, pos).c_str(), S_IRUSR | S_IWUSR | S_IXUSR);      }      else {	return_val = mkdir(dir.c_str(), S_IRUSR | S_IWUSR | S_IXUSR);      }    }  }  return return_val;}bool is_arg(const char* arg, int argc, char* argv[]) {  bool return_val;  int count;  for (return_val = false, count = 1; !return_val && count < argc; count++) {    if (!std::strcmp(argv[count], arg)) return_val = true;  }  return return_val;}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -