Glib::ustring Information::getParametre(Glib::ustring u){
	Glib::ustring par = "";
	if(start_time != 0){
		std::cout<<start_time<<std::endl;
		par += " -ss "+Glib::ustring::format(start_time);
	}
	if(end_time != -1){
		std::cout<<end_time - start_time<<std::endl;
		par += " -t "+Glib::ustring::format(end_time - start_time);
	}
	if(u.compare(CUSTOMVIDEO)==0 && yup+ydown+xright+xleft != 0){
		if(yup != 0){
			par += " -croptop "+Glib::ustring::format(yup);
		}
		if(ydown != 0){
			par += " -cropbottom "+Glib::ustring::format(ydown);
		}
		if(xright != 0){
			par += " -cropright "+Glib::ustring::format(xright);
		}
		if(xleft != 0){
			par += " -cropleft "+Glib::ustring::format(xleft);
		}
	}
	if(u.compare(CUSTOMVIDEO)==0 && deinter == true){
		par+= " -deinterlace";
	}
	return par;
}
void Parser::Parse(const xmlpp::Node* node, CatConfig *conf) {
    const xmlpp::TextNode* nodeText =
            dynamic_cast<const xmlpp::TextNode*>(node);
    const xmlpp::CommentNode* nodeComment =
            dynamic_cast<const xmlpp::CommentNode*>(node);
    if((nodeText && nodeText->is_white_space()))
        return;
    Glib::ustring nodename = node->get_name();

  	if(!nodeText && !nodeComment && !nodename.empty()) {
	    const Glib::ustring namespace_prefix = node->get_namespace_prefix();
		if(namespace_prefix.empty()){

            if(nodename.compare(tag_)==0) {
                std::vector<std::string> vTemp = ReadInfo(node);
                conf->AddInfo(vTemp);
            } else {
    			xmlpp::Node::NodeList list = node->get_children();
			    if (list.size() > 1) {
				    for(xmlpp::Node::NodeList::iterator iter = list.begin();
                            iter != list.end(); ++iter)
                        Parse(*iter, conf);
			    }
			}
		}
  	}
}
示例#3
0
	Priority priority_from_string(const Glib::ustring& s) {
		if (s.compare(to_string(Priority::INVALID)) == 0)
			return Priority::INVALID;
        else if (s.empty())
            return Priority::INVALID;
		else if (s.compare(to_string(Priority::LOW)) == 0)
			return Priority::LOW;
		else if (s.compare(to_string(Priority::MEDIUM)) == 0)
			return Priority::MEDIUM;
		else if (s.compare(to_string(Priority::HIGH)) == 0)
			return Priority::HIGH;
		else {
			std::cerr << "Error: Unknown Priority (" << s << ")" << std::endl;
			return Priority::INVALID;
		}
	}
示例#4
0
bool PreferencesFrame::get_formatted_bool_dynamic_value(Glib::ustring value)
{
	if (value.compare("true")==0)
		return true ;
	else
		return false ;
}
示例#5
0
文件: tree.cpp 项目: bhesh/Programs
void Tree::deleteclass() {

	Gtk::TreeModel::iterator iter = get_selection()->get_selected();
	if( *iter ) {
	
		Glib::ustring str = (*iter)[m_Columns.m_col_crn];
		std::ifstream coursefile( course_file );
		std::ofstream tempfile( course_temp );
		if( coursefile.is_open() && tempfile.is_open() ) {
			while( true ) {
				char buf[10], line[256];
				coursefile >> buf; // Get crn
				coursefile.getline( line, 255 ); // Get rest of line
				if( coursefile.eof() ) break;
				if( str.compare( buf ) == 0 ) // Skip if crns are equal
					continue;
				tempfile << buf << line << std::endl; // Write to temp
			}
			coursefile.close();
			tempfile.close();
			std::remove( course_file ); // Remove and rename file
			std::rename( course_temp, course_file );
		}
		m_refTreeModel->erase( iter ); // Erase from tree
	}
}
示例#6
0
FunctionDeclare::FunctionDeclare(std::vector<XCubeSatToken*> *tokens, Terminal *term, std::unordered_map<std::string, Function*> *var) throw(std::bad_typeid*):Function(term, variables)
{
    if(tokens->empty() || tokens->size() < 2) throw new std::bad_typeid();

    XCubeSatToken *t = tokens->front();

    tokens->erase(tokens->begin());

    Function *f;
    Glib::ustring *type;

    switch(t->get_type()) {
        case STRING:
        case VARIABLE:
            type = t->get_value_str();
            type->uppercase();
            if(!type->compare("BOOL")) {
                f = new FunctionVariableBool(false);}
            else if(!type->compare("DATA")) {
                f = new FunctionVariableData(NULL, NULL, 0);}
            else if(!type->compare("INT")) {
                f = new FunctionVariableInt(0);}
            else if(!type->compare("STRING")) {
                f = new FunctionVariableString(NULL); }
            else {
                throw new std::bad_typeid();}
            break;
        default:
            throw new std::bad_typeid();
    }
    this->params.push_back(f);

    if(tokens->empty()) throw new std::bad_typeid();
    t = tokens->front();
    tokens->erase(tokens->begin());

    std::pair<std::string, Function*> *p;
    switch(t->get_type()) {
        case VARIABLE:
            p = new std::pair<std::string, Function*>(*t->get_value_str(), f);
            var->insert(*p);
            break;
        default:
            throw new std::bad_typeid();
    }
}
示例#7
0
bool is_in_svect(const std::vector<std::string>& vect, Glib::ustring value)
{
	std::vector<string>::const_iterator it ;
	for (it=vect.begin(); it!=vect.end(); it++) {
		if (value.compare(*it)==0)
			return true ;
	}
	return false ;
}
示例#8
0
bool is_in_list(const std::list<string>& list, Glib::ustring value)
{
	std::list<string>::const_iterator it ;
	for (it=list.begin(); it!=list.end(); it++) {
		if (value.compare(*it)==0)
			return true ;
	}
	return false ;
}
示例#9
0
void UXWindow::on_combo_arms_changed() {
  Glib::ustring selected = combo_arms_.get_active_text();
  if (selected.compare( Glib::ustring("Both")) == 0){
    app_.SetHanded(BOTH_ARMS);
  } else if (selected.compare( Glib::ustring("Left Arm Track, No Mirror")) == 0){
    app_.SetHanded(LEFT_ARM_RIGHT_FROZEN);
  } else if (selected.compare( Glib::ustring("Right Arm Track, No Mirror")) == 0) {
    app_.SetHanded(RIGHT_ARM_LEFT_FROZEN);
  }  else if (selected.compare( Glib::ustring("Left Arm Track, Mirrored Right")) == 0) {
    app_.SetHanded(LEFT_ARM_RIGHT_MIRROR);
  } else if (selected.compare( Glib::ustring("Right Arm Track, Mirrored Left")) == 0) {
    app_.SetHanded(RIGHT_ARM_LEFT_MIRROR);
  }/* else if (selected.compare( Glib::ustring("Left Arm, Copied Right")) == 0) {
    app_.SetHanded(LEFT_ARM_COPY);
  } else if (selected.compare( Glib::ustring("Right Arm, Copied Left")) == 0) {
    app_.SetHanded(RIGHT_ARM_COPY);
  }*/
}
示例#10
0
int is_valid_filename(Glib::ustring file_name)
{
	guint max = 256 ;
	int res = 1 ;

	//> CHECK NULL
	if( file_name.compare("")==0 ||  file_name.compare(" ")==0 )
		res=-1 ;
	//> CHECK LENGTH
	else if (file_name.length() >= max)
		res=-2 ;
	//> CHECK CHAR
	bool correct = StringOps::check_string(STRING_OPS_FORBIDDEN_FILE, file_name) ;
	if (correct && res>0)
		res = 1 ;
	else if (!correct)
		res = -3 ;

	return res ;
}
示例#11
0
/**
 * Set the string value of a key/name registry entry
 */ 
bool RegistryTool::setStringValue(const Glib::ustring &keyNameArg,
                                  const Glib::ustring &valueName,
                                  const Glib::ustring &value)
{
    Glib::ustring keyName = keyNameArg;
    bool ret = false;

    HKEY rootKey = HKEY_LOCAL_MACHINE; //default root
    //Trim out the root key if necessary
    for (KeyTableEntry *entry = keyTable; entry->key; entry++)
        {
        if (keyName.compare(0, entry->strlen, entry->str)==0)
            {
            rootKey = entry->key;
            keyName = keyName.substr(entry->strlen);
            }
        }
    //printf("trimmed string: '%s'\n", keyName.c_str());

    //Get or create the key
    gunichar2 *keyw       = g_utf8_to_utf16(keyName.data(), -1, 0,0,0);
    gunichar2 *valuenamew = g_utf8_to_utf16(valueName.data(), -1, 0,0,0);

    HKEY key;
    if (RegCreateKeyExW(rootKey, (WCHAR*) keyw,
                       0, NULL, REG_OPTION_NON_VOLATILE,
                       KEY_WRITE, NULL, &key, NULL))
    {
       fprintf(stderr, "RegistryTool: Could not create the registry key '%s'\n", keyName.c_str());
       goto fail;
    }

    // Set the value
    if (RegSetValueExW(key, (WCHAR*) valuenamew,
          0,  REG_SZ, (LPBYTE) value.data(), (DWORD) (value.size() + 1)))
    {
       fprintf(stderr, "RegistryTool: Could not set the value '%s'\n", value.c_str());
       goto failkey;
    }

    ret = true;
    
    failkey:
    RegCloseKey(key);
    
    fail:
    g_free(keyw);
    g_free(valuenamew);
    return ret;
}
示例#12
0
/* --------------------------------------------------------------*/
void Modem::update_modem_name()
{
    size_t i;
    Glib::ustring modemName = this->modemNameCombobox->get_active_text();

    for (i = 0; modemName.compare(modems[i]->name()) && i < modems.size(); ++i) {
        currentModem = static_cast<modemModel_t>(i);
    }
    currentModem = static_cast<modemModel_t>(i);

    if(i >= modemName.size()) {
        Log::LogWarn(LEVEL_LOG_WARNING, "wrong modem configuration, setting to default", __FILE__, __LINE__);
        this->currentModem = DEFAULT;
    }

    this->populate_mode_combobox();
}
示例#13
0
    /* compressed utf-8 table */
        0x20ac, /* 80 Euro. CP1252 from here on... */
        0x81,   /* 81 NA */
        0x201a, /* 82 */
        0x192,  /* 83 */
        0x201e, /* 84 */
        0x2026, /* 85 */
        0x2020, /* 86 */
        0x2021, /* 87 */
        0x2c6,  /* 88 */
        0x2030, /* 89 */
        0x160,  /* 8a */
        0x2039, /* 8b */
        0x152,  /* 8c */
        0x8d,   /* 8d NA */
        0x17d,  /* 8e */
        0x8f,   /* 8f NA */
        0x90,   /* 90 NA */
        0x2018, /* 91 */
        0x2019, /* 92 */
        0x201c, /* 93 */
        0x201d, /* 94 */
        0x2022, /* 95 */
        0x2013, /* 96 */
        0x2014, /* 97 */
        0x2dc,  /* 98 */
        0x2122, /* 99 */
        0x161,  /* 9a */
        0x203a, /* 9b */
        0x153,  /* 9c */
        0x9d,   /* 9d NA */
        0x17e,  /* 9e */
        0x178,  /* 9f */
        0xa0,   /* a0 */
        0xa1,   /* a1 */
        0xa2,   /* a2 */
        0xa3,   /* a3 */
        0x20ac  /* a4 ISO-8859-15 Euro. */
    };

    while (len) {
        if (G_UNLIKELY(*text >= 0x80) && G_UNLIKELY(*text <= 0xa4)) {
            int idx = *text - 0x80;
            output += lowtable[idx];
        } else {
            output += (gunichar)*text;    /* ascii/iso88591 maps directly */
        }

        text++;
        len--;
    }
    return output;
}/*}}}*/
void set_charset(Glib::ustring charset) {/*{{{*/
    charset = charset.uppercase();

    if (charset.find(' ') != Glib::ustring::npos)
        charset = charset.erase(charset.find(' '));

    if (charset.empty() || !charset.compare("SYSTEM")) {
        charset.clear();
    } else {
        try {
            Glib::IConv test("UTF-8", charset);
        } catch (...) {
            fprintf(stderr, "Charset '%s' isn't supported by your system - using system locale\n", charset.c_str());
            charset.clear();
        }
    }

    serverCharset = charset;
}/*}}}*/
示例#14
0
/**
 * Set the string value of a key/name registry entry
 */ 
bool RegistryTool::setStringValue(const Glib::ustring &keyNameArg,
                                  const Glib::ustring &valueName,
                                  const Glib::ustring &value)
{
    Glib::ustring keyName = keyNameArg;

    HKEY rootKey = HKEY_LOCAL_MACHINE; //default root
    //Trim out the root key if necessary
    for (KeyTableEntry *entry = keyTable; entry->key; entry++)
        {
        if (keyName.compare(0, entry->strlen, entry->str)==0)
            {
            rootKey = entry->key;
            keyName = keyName.substr(entry->strlen);
            }
        }
    //printf("trimmed string: '%s'\n", keyName.c_str());

    //Get or create the key
    HKEY key;
    if (RegCreateKeyEx(rootKey, keyName.c_str(),
                       0, NULL, REG_OPTION_NON_VOLATILE,
                       KEY_WRITE, NULL, &key, NULL))
       {
       fprintf(stderr, "RegistryTool: Could not create the registry key '%s'\n", keyName.c_str());
       return false;
       }

    //Set the value
    if (RegSetValueEx(key, valueName.c_str(),
          0,  REG_SZ, (LPBYTE) value.c_str(), (DWORD) value.size()))
       {
       fprintf(stderr, "RegistryTool: Could not set the value '%s'\n", value.c_str());
       RegCloseKey(key);
       return false;
       }


    RegCloseKey(key);

    return true;
}
示例#15
0
void Doc::LaunchInstalledBrowser_ALLOS(Glib::ustring path, Gtk::Window* parent, Glib::ustring default_browser)
{
	std::vector<Glib::ustring> browsers ;

	//> default browser will be tried first
	if (!default_browser.empty())
		browsers.insert(browsers.end(), default_browser) ;

	#ifdef __APPLE__
	browsers.insert(browsers.end(), "/Applications/Safari.app/Contents/MacOS/Safari");
	#endif
	#ifdef WIN32
	browsers.insert(browsers.end(), "C:\\Program Files\\Internet Explorer\\iexplore.exe");
	browsers.insert(browsers.end(), "C:\\Program Files\\Mozilla Firefox\\firefox.exe");
	#endif
	browsers.insert(browsers.end(), "firefox") ;
	browsers.insert(browsers.end(), "seamonkey") ;
	browsers.insert(browsers.end(), "opera") ;
	browsers.insert(browsers.end(), "mozilla") ;
	browsers.insert(browsers.end(), "konqueror") ;
	browsers.insert(browsers.end(), "netscape") ;
	browsers.insert(browsers.end(), "epiphany") ;

	//> 1 - Find available browser in path
	Glib::ustring browser = "" ;
	for (guint i = 0; i<browsers.size() && browser.compare("")==0 ; i++)
	{
		char* brow = g_find_program_in_path( browsers[i].c_str() ) ;
		if (brow)
			browser = browsers[i] ;
	}

	//> 2 - Launch
	Glib::ustring error = "" ;
	Glib::ustring command = "" ;
	if (browser.compare("")!=0)
	{
#ifndef WIN32
		command = browser + " " + path ;
#else
		command = "\"" +  browser + "\"" ;
		command = command + " \"" + replace_in_string(path, "/", "\\") + "\"" ;
#endif

		try
		{
			Glib::spawn_command_line_async( command );
		}
		catch (Glib::SpawnError e)
		{
			Log::err() << TRANSAG_DISPLAY_NAME << " --> Glibmm SpawnError : " << e.what() << std::endl ;
			Glib::ustring s1 = _("An error occured while launching documentation browser") ;
			Glib::ustring s2 = _("Please check your default browser in preferences") ;
			s1 = s1 + "\n" + s2 ;
			if (parent)
				Explorer_dialog::msg_dialog_error(s1, parent, true) ;
		}
	}
	else
		error = _("No browser found") ;

	if (error.compare("")!=0 && parent)
		Explorer_dialog::msg_dialog_error(error, parent, true) ;
}
示例#16
0
void font_factory::GetUIFamiliesAndStyles(FamilyToStylesMap *map)
{
    g_assert(map);

    if (map) {

        // Gather the family names as listed by Pango
        PangoFontFamily**  families = NULL;
        int numFamilies = 0;
        pango_font_map_list_families(fontServer, &families, &numFamilies);

        for (int currentFamily=0; currentFamily < numFamilies; currentFamily++) {

            // Gather the styles for this family
            PangoFontFace** faces = NULL;
            int numFaces = 0;
            pango_font_family_list_faces(families[currentFamily], &faces, &numFaces);

            for (int currentFace=0; currentFace < numFaces; currentFace++) {

                // If the face has a name, describe it, and then use the
                // description to get the UI family and face strings

                const gchar* displayName = pango_font_face_get_face_name(faces[currentFace]);
                if (displayName == NULL) {
                    continue;
                }

                PangoFontDescription *faceDescr = pango_font_face_describe(faces[currentFace]);
                if (faceDescr) {
                    Glib::ustring familyUIName = GetUIFamilyString(faceDescr);
                    Glib::ustring styleUIName = GetUIStyleString(faceDescr);

                    // Disable synthesized (faux) font faces except for CSS generic faces
                    if (pango_font_face_is_synthesized(faces[currentFace]) ) {
                        if( familyUIName.compare( "sans-serif" ) != 0 &&
                            familyUIName.compare( "serif"      ) != 0 &&
                            familyUIName.compare( "monospace"  ) != 0 &&
                            familyUIName.compare( "fantasy"    ) != 0 &&
                            familyUIName.compare( "cursive"    ) != 0 ) {
                            //std::cout << "faux: " << familyUIName << "  |  " << styleUIName << std::endl;
                            continue;
                        }
                    } 

                    if (!familyUIName.empty() && !styleUIName.empty()) {

                        // Find the right place to put the style information, adding
                        // a map entry for the family name if it doesn't yet exist

                        FamilyToStylesMap::iterator iter = map->find(familyUIName);

                        // Insert new family
                        if (iter == map->end()) {
                            map->insert(std::make_pair(familyUIName, std::list<StyleNames>()));
                        }

                        // Insert into the style list and save the info in the reference maps
                        // only if the style does not yet exist

                        bool exists = false;
                        std::list<StyleNames> &styleList = (*map)[familyUIName];

                        for (std::list<StyleNames>::iterator it=styleList.begin();
                                 it != styleList.end();
                                 ++it) {
                            if ( (*it).CssName == styleUIName) {
                                exists = true;
                                break;
                            }
                        }

                        if (!exists) {
                            styleList.push_back( StyleNames(styleUIName,displayName) );

                            // Add the string info needed in the reference maps
                            fontStringMap.insert(
                                    std::make_pair(
                                            Glib::ustring(familyUIName) + Glib::ustring(styleUIName),
                                            ConstructFontSpecification(faceDescr)));
                            fontInstanceMap.insert(
                                    std::make_pair(ConstructFontSpecification(faceDescr), faceDescr));

                        } else {
                            pango_font_description_free(faceDescr);
                        }
                    } else {
                        pango_font_description_free(faceDescr);
                    }
                }
            }
            g_free(faces);
            faces = 0;
        }
        g_free(families);
        families = 0;

        // Sort the style lists
        for (FamilyToStylesMap::iterator iter = map->begin() ; iter != map->end(); ++iter) {
            (*iter).second.sort(StyleNameCompareInternal);
        }
    }
}
示例#17
0
SPDocument *
GdkpixbufInput::open(Inkscape::Extension::Input *mod, char const *uri)
{
    // Determine whether the image should be embedded
    Inkscape::Preferences *prefs = Inkscape::Preferences::get();
    bool ask = prefs->getBool("/dialogs/import/ask");
    Glib::ustring link  = prefs->getString("/dialogs/import/link");
    bool forcexdpi = prefs->getBool("/dialogs/import/forcexdpi");
    Glib::ustring scale = prefs->getString("/dialogs/import/scale");
    // std::cout << "GkdpixbufInput::open: "
    //           << " ask: " << ask
    //           << ", link: " << link
    //           << ", forcexdpi: " << forcexdpi
    //           << ", scale: " << scale << std::endl;
    // std::cout << "     in  preferences: "
    //           << " ask: " << !mod->get_param_bool("do_not_ask")
    //           << ", link: " << mod->get_param_optiongroup("link")
    //           << ", mod_dpi: " << mod->get_param_optiongroup("dpi")
    //           << ", scale: " << mod->get_param_optiongroup("scale") << std::endl;
    if( ask ) {
        Glib::ustring mod_link = mod->get_param_optiongroup("link");
        Glib::ustring mod_dpi = mod->get_param_optiongroup("dpi");
        bool mod_forcexdpi = ( mod_dpi.compare( "from_default" ) == 0 );
        Glib::ustring mod_scale = mod->get_param_optiongroup("scale");
        if( link.compare( mod_link ) != 0 ) {
            link = mod_link;
        }
        prefs->setString("/dialogs/import/link", link );
        if( forcexdpi != mod_forcexdpi ) {
            forcexdpi = mod_forcexdpi;
        }
        prefs->setBool("/dialogs/import/forcexdpi", forcexdpi );
        if( scale.compare( mod_scale ) != 0 ) {
            scale = mod_scale;
        }
        prefs->setString("/dialogs/import/scale", scale );
        prefs->setBool("/dialogs/import/ask", !mod->get_param_bool("do_not_ask") );
    }
    bool embed = ( link.compare( "embed" ) == 0 );

    SPDocument *doc = NULL;
    boost::scoped_ptr<Inkscape::Pixbuf> pb(Inkscape::Pixbuf::create_from_file(uri));

    // TODO: the pixbuf is created again from the base64-encoded attribute in SPImage.
    // Find a way to create the pixbuf only once.

    if (pb) {
        doc = SPDocument::createNewDoc(NULL, TRUE, TRUE);
        bool saved = DocumentUndo::getUndoSensitive(doc);
        DocumentUndo::setUndoSensitive(doc, false); // no need to undo in this temporary document

        double width = pb->width();
        double height = pb->height();
        double defaultxdpi = prefs->getDouble("/dialogs/import/defaultxdpi/value", Inkscape::Util::Quantity::convert(1, "in", "px"));
        //bool forcexdpi = prefs->getBool("/dialogs/import/forcexdpi");
        ImageResolution *ir = 0;
        double xscale = 1;
        double yscale = 1;


        if (!ir && !forcexdpi) {
            ir = new ImageResolution(uri);
        }
        if (ir && ir->ok()) {
            xscale = 900.0 / floor(10.*ir->x() + .5);  // round-off to 0.1 dpi
            yscale = 900.0 / floor(10.*ir->y() + .5);
        } else {
            xscale = 90.0 / defaultxdpi;
            yscale = 90.0 / defaultxdpi;
        }

        width *= xscale;
        height *= yscale;

        delete ir; // deleting NULL is safe

        // Create image node
        Inkscape::XML::Document *xml_doc = doc->getReprDoc();
        Inkscape::XML::Node *image_node = xml_doc->createElement("svg:image");
        sp_repr_set_svg_double(image_node, "width", width);
        sp_repr_set_svg_double(image_node, "height", height);

        // Added 11 Feb 2014 as we now honor "preserveAspectRatio" and this is
        // what Inkscaper's expect.
        image_node->setAttribute("preserveAspectRatio", "none");

        if( scale.compare( "auto" ) != 0 ) {
            SPCSSAttr *css = sp_repr_css_attr_new();
            sp_repr_css_set_property(css, "image-rendering", scale.c_str());
            sp_repr_css_set(image_node, css, "style");
            sp_repr_css_attr_unref( css );
        }

        if (embed) {
            sp_embed_image(image_node, pb.get());
        } else {
            // convert filename to uri
            gchar* _uri = g_filename_to_uri(uri, NULL, NULL);
            if(_uri) {
                image_node->setAttribute("xlink:href", _uri);
                g_free(_uri);
            } else {
                image_node->setAttribute("xlink:href", uri);
            }
        }

        // Add it to the current layer
        doc->getRoot()->appendChildRepr(image_node);
        Inkscape::GC::release(image_node);
        fit_canvas_to_drawing(doc);

        // Set viewBox if it doesn't exist
        if (!doc->getRoot()->viewBox_set) {
            //std::cout << "Viewbox not set, setting" << std::endl;
            doc->setViewBox(Geom::Rect::from_xywh(0, 0, doc->getWidth().value(doc->getDefaultUnit()), doc->getHeight().value(doc->getDefaultUnit())));
        }

        // restore undo, as now this document may be shown to the user if a bitmap was opened
        DocumentUndo::setUndoSensitive(doc, saved);
    } else {
        printf("GdkPixbuf loader failed\n");
    }

    return doc;
}
示例#18
0
void File_convert::run(Glib::ustring u) {
	Zberac* zb = new Zberac();
	File_load* file = new File_load(u);
	if (file->isOK() == true) {
		Udaje* udaj = new Udaje();
		bool nekoniec = true;
		bool video = true;
		bool audio = true;
		int cis;
		zb->typ = file->getType();
		zb->meno = file->getName();
		zb->resolX = file->getResX();
		zb->resolY = file->getResY();
		if(file->getVBitrate().size() != 0){
			zb->bitrateV = file->getVBitrate();
		}
		if(file->getAbitrate().size() != 0){
			zb->bitrateA = file->getAbitrate();
		}
//		std::cout<<u<<std::endl;
		/////////////////////////////////////////////
		if (nekoniec && (cis = udaj->getVResolution(file->getResolution()))	!= -1) {
			zb->pomer = cis;
//			std::cout<<"Res "<<cis<<std::endl;
		} else {
			video = false;
		}
		if (nekoniec && (cis = udaj->getVFrame(file->getFramerate())) != -1) {
			zb->framerate = cis;
//			std::cout<<"fra "<<cis<<std::endl;
		} else {
			video = false;
		}
		BasicKon *kon = new BasicKon();
		VideoPrekladac *vidPrek = new VideoPrekladac();
		bool mozno = true;
		if (nekoniec && (cis = kon->getNumber(file->getContainer())) != -1) {
			zb->kontainer = cis;
		} else {
			nekoniec = false;
		}
		if (nekoniec && (cis = vidPrek->getX264Num(file->getX264())) != -1) {
			zb->x264 = cis;
		} else {
			mozno = false;
		}
//		std::cout<<"x264 "<<cis<<std::endl;
		Glib::ustring nazov = vidPrek->getByKodek(file->getVCodec());
		if (nazov.compare(X264) == 0 && mozno == false) {
			video = false;
		}

		if (nekoniec && (cis = kon->getKontainer(zb->kontainer)->getVKodekNum(nazov)) != -1) {
			zb->kodekV = cis;
		} else {
			video = false;
//			std::cout<<"err"<<nazov<<std::endl;
		}
//		std::cout<<"kodV "<<nazov<<" "<<zb->kontainer<<std::endl;


		if (nekoniec && (cis = udaj->getVOptions(file->getVideo())) != -1) {
			if((cis == 1 || cis == 2) && video == false){
				nekoniec = true;
			}else{
				if(video){
					nekoniec = true;
				}else{
					nekoniec = false;
				}
			}
			zb->nastav = cis;
		} else {
//			std::cout<<kon->getKontainer(zb->kontainer)->getVKodeky().size()<<std::endl;
			if(kon->getKontainer(zb->kontainer)->getVKodeky().size()!=0){
				nekoniec = false;
			}
			else{
				nekoniec = true;
			}
		}
		////////////////////////////////////////////////////

		if (nekoniec && (cis = udaj->getAChannels(file->getChannels())) != -1) {
			zb->channelA = cis;
		} else {
			audio = false;
		}
		if (nekoniec && (cis = udaj->getAVzorkovanie(file->getRate())) != -1) {
			zb->frekvenciaA = cis;
		} else {
			audio = false;
		}

		/////////////////////////////////////////////////////

		AudioPrekladac *audPrek = new AudioPrekladac();
		Glib::ustring audionazov = audPrek->getByKodek(file->getAcodec());
		if (nekoniec && (cis = kon->getKontainer(zb->kontainer)->getAKodekNum(
				audionazov)) != -1) {
			zb->kodekA = cis;
		} else {
			audio = false;
		}
//		std::cout<<"Akod: "<<cis<<std::endl;
		if (nekoniec && (cis = udaj->getAOptions(file->getAudio())) != -1) {
			if((cis == 1 || cis == 2) && audio == false){
				nekoniec = true;
			}else
				if(audio){
					nekoniec = true;
				}else{
					nekoniec = false;
				}
			zb->nastavA = cis;
		} else {
			if(kon->getKontainer(zb->kontainer)->getAKodeky().size()!=0){
				nekoniec = false;
			}
			else{
				nekoniec = true;
			}
		}

		delete audPrek;
		delete vidPrek;
		delete kon;

		if (nekoniec) {
			zb->file = u;
//			std::cout<<"koniec"<<std::endl;
			zberac.push_back(zb);
		} else {
			delete zb;
		}
		delete udaj;
	}else{
		delete zb;
	}
	delete file;
}
示例#19
0
/**
 * \return   A new document created from the filename passed in
 * \brief    This is a generic function to use the open function of
 *           a module (including Autodetect)
 * \param    key       Identifier of which module to use
 * \param    filename  The file that should be opened
 *
 * First things first, are we looking at an autodetection?  Well if that's the case then the module
 * needs to be found, and that is done with a database lookup through the module DB.  The foreach
 * function is called, with the parameter being a gpointer array.  It contains both the filename
 * (to find its extension) and where to write the module when it is found.
 *
 * If there is no autodetection, then the module database is queried with the key given.
 *
 * If everything is cool at this point, the module is loaded, and there is possibility for
 * preferences.  If there is a function, then it is executed to get the dialog to be displayed.
 * After it is finished the function continues.
 *
 * Lastly, the open function is called in the module itself.
 */
SPDocument *open(Extension *key, gchar const *filename)
{
    Input *imod = NULL;

    if (key == NULL) {
        gpointer parray[2];
        parray[0] = (gpointer)filename;
        parray[1] = (gpointer)&imod;
        db.foreach(open_internal, (gpointer)&parray);
    } else {
        imod = dynamic_cast<Input *>(key);
    }

    bool last_chance_svg = false;
    if (key == NULL && imod == NULL) {
        last_chance_svg = true;
        imod = dynamic_cast<Input *>(db.get(SP_MODULE_KEY_INPUT_SVG));
    }

    if (imod == NULL) {
        throw Input::no_extension_found();
    }

    // Hide pixbuf extensions depending on user preferences.
    //g_warning("Extension: %s", imod->get_id());

    bool show = true;
    if (strlen(imod->get_id()) > 27) {
        Inkscape::Preferences *prefs = Inkscape::Preferences::get();
        bool ask = prefs->getBool("/dialogs/import/ask");
        Glib::ustring id = Glib::ustring(imod->get_id(), 28);
        if (!ask && id.compare( "org.inkscape.input.gdkpixbuf") == 0) {
            show = false;
            imod->set_gui(false);
        }
    }
    imod->set_state(Extension::STATE_LOADED);

    if (!imod->loaded()) {
        throw Input::open_failed();
    }

    if (!imod->prefs(filename)) {
        return NULL;
    }

    SPDocument *doc = imod->open(filename);

    if (!doc) {
        throw Input::open_failed();
    }

    if (last_chance_svg) {
        if ( inkscape_use_gui() ) {
            sp_ui_error_dialog(_("Format autodetect failed. The file is being opened as SVG."));
        } else {
            g_warning("%s", _("Format autodetect failed. The file is being opened as SVG."));
        }
    }

    doc->setUri(filename);
    if (!show) {
        imod->set_gui(true);
    }

    return doc;
}