AboutWindow::AboutWindow() { typedef std::vector<Glib::ustring> UStringList; moApplicationSPtr application( moApplication::Instance() ); #if defined(DEMO_VERSION) || defined(BETA_VERSION) set_name( (application->GetName() + moWCString(" Demo")).c_str() ); #else set_name( application->GetName().c_str() ); #endif set_version( (application->GetVersion() + "." BUILD_VERSION_STRING).c_str() ); set_website( WEBSITE_URL ); set_translator_credits( gettext("translator-credits") ); const char* comments = "A Dungeon Master's Initiative Manager\n\n" #if defined(DEMO_VERSION) "This version of Turn Watcher is a demonstration version only.\n\n" #elif defined(BETA_VERSION) "This version of Turn Watcher is a beta version for demonstration purposes only, " "and is intended solely for registered beta testers. " "If you are not a registered beta tester, please uninstall this application and contact " "Made to Order Software Corporation to purchase a licensed copy.\n\n" #endif "Uses Gtk+ 2.15, Gtkmm 2.12, iconv, intl, PNG and zlib.\n" "Licensed under the GNU Public License v2.\n" "https://sourceforge.net/projects/turnwatcher/\n" ; // TODO: we need to fix the comment for demo versions to work properly #if defined(DEMO_VERSION) || defined(BETA_VERSION) set_comments( comments ); #else set_comments( gettext(comments) ); #endif UStringList authors; authors.push_back( "R. Douglas Barbieri" ); authors.push_back( "Alexis Wilke" ); set_authors( authors ); UStringList artists; artists.push_back( "Nikolai Lokteff" ); set_artists( artists ); // no gettext() for this one, doesn't need translation set_copyright( "Copyright (c) 2005-2013 Made to Order Software Corporation" ); //set_license( gettext(product_license) ); moWCString logopath( Common::GetFullPathnameForImage( ABOUT_IMAGE ) ); if( logopath != "" ) { Glib::RefPtr<Gdk::Pixbuf> logo = Gdk::Pixbuf::create_from_file( logopath.c_str() ); set_logo( logo ); } }
// glade/gtkbuilder needs this constructor GscAboutDialog::GscAboutDialog(BaseObjectType* gtkcobj, const app_ui_res_ref_t& ref_ui) : AppUIResWidget<GscAboutDialog, false, Gtk::AboutDialog>(gtkcobj, ref_ui) { // Connect callbacks // APP_GTKMM_CONNECT_VIRTUAL(delete_event); // make sure the event handler is called APP_GTKMM_CONNECT_VIRTUAL(response); // Note: The dialogs have ESC accelerator attached by default. set_url_hook(sigc::mem_fun(*this, &GscAboutDialog::on_activate_url)); set_email_hook(sigc::mem_fun(*this, &GscAboutDialog::on_activate_email)); // Note: AboutDialog changed "name" property to "program-name" in gtk 2.12. // We don't set either, but rely on Glib::set_application_name() during init, which // works with both older and newer versions. set_version(VERSION); // set these properties here (after setting hooks) to make the links work. set_website("http://gsmartcontrol.berlios.de/"); set_license(LicenseTextResData().get_string()); // spammers go away set_copyright("Copyright (C) 2008 - 2009 Alexander Shaduri " "<ashaduri" "" "@" "" "" "gmail.com>"); std::string authors_str = AuthorsTextResData().get_string(); hz::string_any_to_unix(authors_str); std::list<Glib::ustring> authors; hz::string_split(authors_str, '\n', authors, true); for (std::list<Glib::ustring>::iterator iter = authors.begin(); iter != authors.end(); ++iter) { std::string s = *iter; hz::string_replace(s, " '@' ", "@"); // despammer hz::string_replace(s, " 'at' ", "@"); // despammer *iter = s; } set_authors(authors); set_documenters(authors); // run(); // don't use run - it's difficult to exit it manually. // show(); // shown by the caller to enable setting the parent window. }
MyAboutDialog(): Gtk::AboutDialog(),m_link(PACKAGE_URL,PACKAGE_URL){ set_version(PACKAGE_VERSION); std::vector<Glib::ustring> authors; authors.push_back("Quentin Geissmann<*****@*****.**>"); set_authors(authors); set_license("GPL_3_0"); set_copyright("Quentin Geissmann 2012-2013"); #if defined _WIN64 || defined _WIN32 std::stringstream ss; ss<<ABOUT_TEXT<<std::endl<<PACKAGE_URL; set_comments(ss.str()); #else set_website(PACKAGE_URL); set_website_label("Website"); set_comments(ABOUT_TEXT); #endif set_logo(Gui_PixbufOpener::pixbufOpen(LOGO_IMG)); }
DictInfo& DictInfo::operator=(const DictInfo& dict_info) { clear(); ifo_file_name = dict_info.ifo_file_name; if(dict_info.is_wordcount()) set_wordcount(dict_info.get_wordcount()); if(dict_info.is_filecount()) set_filecount(dict_info.get_filecount()); if(dict_info.is_synwordcount()) set_synwordcount(dict_info.get_synwordcount()); if(dict_info.is_bookname()) set_bookname(dict_info.get_bookname()); if(dict_info.is_author()) set_author(dict_info.get_author()); if(dict_info.is_email()) set_email(dict_info.get_email()); if(dict_info.is_website()) set_website(dict_info.get_website()); if(dict_info.is_date()) set_date(dict_info.get_date()); if(dict_info.is_description()) set_description(dict_info.get_description()); if(dict_info.is_index_file_size()) set_index_file_size(dict_info.get_index_file_size()); if(dict_info.is_sametypesequence()) set_sametypesequence(dict_info.get_sametypesequence()); if(dict_info.is_dicttype()) set_dicttype(dict_info.get_dicttype()); if(dict_info.is_version()) set_version(dict_info.get_version()); if(dict_info.is_infotype()) set_infotype(dict_info.get_infotype()); f_idxoffsetbits = dict_info.f_idxoffsetbits; return *this; }
bool DictInfo::load_from_ifo_file(const std::string& ifofilename, DictInfoType infotype) { clear(); ifo_file_name=ifofilename; set_infotype(infotype); glib::CharStr buffer; glib::Error error; if (!g_file_get_contents(ifo_file_name.c_str(), get_addr(buffer), NULL, get_addr(error))) { g_critical("Load %s failed. Error: %s.", ifo_file_name.c_str(), error->message); return false; } const gchar *p1 = get_impl(buffer); if(g_str_has_prefix(p1, UTF8_BOM)) p1 += 3; if(!g_utf8_validate(p1, -1, NULL)) { g_critical("Load %s failed: Invalid UTF-8 encoded text.", ifo_file_name.c_str()); return false; } lineno = 1; const gchar *magic_data = NULL; if(infotype == DictInfoType_NormDict) magic_data = NORM_DICT_MAGIC_DATA; else if(infotype == DictInfoType_TreeDict) magic_data = TREE_DICT_MAGIC_DATA; else if(infotype == DictInfoType_ResDb) magic_data = RES_DB_MAGIC_DATA; else return false; if (!g_str_has_prefix(p1, magic_data)) { g_critical("Load %s failed: Incorrect magic data.", ifo_file_name.c_str()); if(g_str_has_prefix(p1, NORM_DICT_MAGIC_DATA)) g_message("File '%s' is an index-based dictionary.", ifo_file_name.c_str()); else if(g_str_has_prefix(p1, TREE_DICT_MAGIC_DATA)) g_message("File '%s' is a tree dictionary.", ifo_file_name.c_str()); else if(g_str_has_prefix(p1, RES_DB_MAGIC_DATA)) g_message("File '%s' is a resource database.", ifo_file_name.c_str()); else g_message("File '%s' is not a StarDict dictionary or it's broken.", ifo_file_name.c_str()); return false; } p1 += strlen(magic_data); p1 = skip_new_line(p1); if(!p1) { g_critical("Load %s failed: Incorrect magic data.", ifo_file_name.c_str()); return false; } std::string key, value; while(true) { ++lineno; p1 = get_key_value(p1, key, value); if(!p1) break; // version must the first option if(!is_version()) { if(key != "version") { g_critical("Load %s failed: \"version\" must be the first option.", ifo_file_name.c_str()); return false; } } if(key == "version") { if(!check_option_duplicate(f_version, "version")) continue; set_version(value); if(infotype == DictInfoType_NormDict) { if(version != "2.4.2" && version != "3.0.0") { g_critical("Load %s failed: Unknown version.", ifo_file_name.c_str()); return false; } } else if(infotype == DictInfoType_TreeDict) { if(version != "2.4.2") { g_critical("Load %s failed: Unknown version.", ifo_file_name.c_str()); return false; } } else if(infotype == DictInfoType_ResDb) { if(version != "3.0.0") { g_critical("Load %s failed: Unknown version.", ifo_file_name.c_str()); return false; } } } else if(key == "idxoffsetbits") { if(!check_option_duplicate(f_idxoffsetbits, "idxoffsetbits")) continue; if(value != "32") { // TODO g_critical("Load %s failed: idxoffsetbits != 32 not supported presently.", ifo_file_name.c_str()); return false; } } else if(key == "wordcount" && (infotype == DictInfoType_NormDict || infotype == DictInfoType_TreeDict)) { if(!check_option_duplicate(f_wordcount, "wordcount")) continue; set_wordcount(atol(value.c_str())); } else if(key == "filecount" && infotype == DictInfoType_ResDb) { if(!check_option_duplicate(f_filecount, "filecount")) continue; set_filecount(atol(value.c_str())); } else if(key == "synwordcount" && infotype == DictInfoType_NormDict) { if(!check_option_duplicate(f_synwordcount, "synwordcount")) continue; set_synwordcount(atol(value.c_str())); } else if(key == "tdxfilesize" && infotype == DictInfoType_TreeDict) { if(!check_option_duplicate(f_index_file_size, "tdxfilesize")) continue; set_index_file_size(atol(value.c_str())); } else if(key == "idxfilesize" && infotype == DictInfoType_NormDict) { if(!check_option_duplicate(f_index_file_size, "idxfilesize")) continue; set_index_file_size(atol(value.c_str())); } else if(key == "ridxfilesize" && infotype == DictInfoType_ResDb) { if(!check_option_duplicate(f_index_file_size, "ridxfilesize")) continue; set_index_file_size(atol(value.c_str())); } else if(key == "dicttype" && infotype == DictInfoType_NormDict) { if(!check_option_duplicate(f_dicttype, "dicttype")) continue; set_dicttype(value); } else if(key == "bookname" && (infotype == DictInfoType_NormDict || infotype == DictInfoType_TreeDict)) { if(!check_option_duplicate(f_bookname, "bookname")) continue; set_bookname(value); } else if(key == "author" && (infotype == DictInfoType_NormDict || infotype == DictInfoType_TreeDict)) { if(!check_option_duplicate(f_author, "author")) continue; set_author(value); } else if(key == "email" && (infotype == DictInfoType_NormDict || infotype == DictInfoType_TreeDict)) { if(!check_option_duplicate(f_email, "email")) continue; set_email(value); } else if(key == "website" && (infotype == DictInfoType_NormDict || infotype == DictInfoType_TreeDict)) { if(!check_option_duplicate(f_website, "website")) continue; set_website(value); } else if(key == "date" && (infotype == DictInfoType_NormDict || infotype == DictInfoType_TreeDict)) { if(!check_option_duplicate(f_date, "date")) continue; set_date(value); } else if(key == "description" && (infotype == DictInfoType_NormDict || infotype == DictInfoType_TreeDict)) { if(!check_option_duplicate(f_description, "description")) continue; std::string temp; decode_description(value.c_str(), value.length(), temp); set_description(temp); } else if(key == "sametypesequence" && (infotype == DictInfoType_NormDict || infotype == DictInfoType_TreeDict)) { if(!check_option_duplicate(f_sametypesequence, "sametypesequence")) continue; set_sametypesequence(value); } else { g_message("Load %s warning: unknown option %s.", ifo_file_name.c_str(), key.c_str()); } } // check required options if((!is_wordcount() || wordcount == 0) && ((infotype == DictInfoType_NormDict || infotype == DictInfoType_TreeDict))) { g_critical("Load %s failed: wordcount not specified or 0.", ifo_file_name.c_str()); return false; } if((!is_filecount() || filecount == 0) && infotype == DictInfoType_ResDb) { g_critical("Load %s failed: filecount not specified or 0.", ifo_file_name.c_str()); return false; } if((!is_bookname() || bookname.empty()) && (infotype == DictInfoType_NormDict || infotype == DictInfoType_TreeDict)) { g_critical("Load %s failed: bookname not specified.", ifo_file_name.c_str()); return false; } if(!is_index_file_size() || index_file_size == 0) { const char* kkey; if(infotype == DictInfoType_NormDict) kkey = "idxfilesize"; else if(infotype == DictInfoType_TreeDict) kkey = "tdxfilesize"; else if(infotype == DictInfoType_ResDb) kkey = "ridxfilesize"; else kkey = ""; g_critical("Load %s failed: %s not specified or 0.", ifo_file_name.c_str(), kkey); return false; } return true; }