예제 #1
0
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);
			    }
			}
		}
  	}
}
예제 #2
0
	virtual void	on_end_element (
		Glib::Markup::ParseContext& context,
		const Glib::ustring& element)
	{
		if (Glib::str_has_prefix (text_, "<![CDATA[") &&
				Glib::str_has_suffix (text_, "]]>")) {
			text_ = text_.substr (strlen ("<![CDATA["),
				text_.length () - strlen ("<![CDATA[" "]]>"));
		}

		if (element == "doi") {
			bib_.setDoi (text_);
		} else if (element == "article_title") {
			bib_.setTitle (text_);
		/* FIXME: assuming given_name precedes surname */
		} else if (element == "given_name") {
			given_name_ = text_;
		} else if (element == "surname") {
			if (!given_name_.empty()) {
				text_ = text_ + ", " + given_name_;
				given_name_ = "";
			}
			authors_.push_back (text_);
		} else if (element == "journal_title") {
			bib_.setJournal (text_);
		} else if (element == "volume") {
			bib_.setVolume (text_);
		} else if (element == "issue") {
			bib_.setIssue (text_);
		} else if (element == "first_page") {
			bib_.setPages (text_);
		} else if (element == "year") {
			bib_.setYear (text_);
		} else if (element == "volume_title") {
			bib_.addExtra ("BookTitle", text_);
		} else if (element == "body") {
			/* End of entry */
			Glib::ustring authorString;
			std::vector<Glib::ustring>::iterator it = authors_.begin ();
			for (; it != authors_.end(); ++it) {
				if (it != authors_.begin()) {
					authorString += " and ";
				}
				authorString += *it;
			}
			if (!authorString.empty())
				bib_.setAuthors (authorString);
		}
	}
예제 #3
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;
}/*}}}*/
std::string ustring_to_c(Glib::ustring input) {/*{{{*/
    std::string to_charset, converted;

    // check if input is already 7-bit
    if (input.is_ascii())
        return input;

    // try encoding using the selected charset, unless its some utf-8
    if (!serverCharset.empty() && serverCharset.find("UTF-8") == Glib::ustring::npos) {
        try {
            return Glib::convert(input, serverCharset, "UTF-8");
        } catch (...) {}
    }

    // try encoding using the locale charset, unless its some utf-8
    if (Glib::get_charset(to_charset) == true)
        to_charset = "ISO-8859-1";

    try {
        converted = Glib::convert_with_fallback(input, to_charset, "UTF-8", "?");
    } catch (...) {
        converted = input;
    }
    return converted;
}/*}}}*/
예제 #4
0
/*
 * TODO: Is it guaranteed that the returned extension is valid? If so, we can remove the check for
 * filename_extension in sp_file_save_dialog().
 */
Glib::ustring
get_file_save_extension (Inkscape::Extension::FileSaveMethod method) {
    Inkscape::Preferences *prefs = Inkscape::Preferences::get();
    Glib::ustring extension;
    switch (method) {
        case FILE_SAVE_METHOD_SAVE_AS:
        case FILE_SAVE_METHOD_TEMPORARY:
            extension = prefs->getString("/dialogs/save_as/default");
            break;
        case FILE_SAVE_METHOD_SAVE_COPY:
            extension = prefs->getString("/dialogs/save_copy/default");
            break;
        case FILE_SAVE_METHOD_INKSCAPE_SVG:
            extension = SP_MODULE_KEY_OUTPUT_SVG_INKSCAPE;
            break;
        case FILE_SAVE_METHOD_EXPORT:
            /// \todo no default extension set for Export? defaults to SP_MODULE_KEY_OUTPUT_SVG_INKSCAPE is ok?
            break;
    }

    if(extension.empty()) {
        extension = SP_MODULE_KEY_OUTPUT_SVG_INKSCAPE;
    }

    return extension;
}
예제 #5
0
gchar *
sp_repr_css_write_string(SPCSSAttr *css)
{
    Glib::ustring buffer;

    for ( List<AttributeRecord const> iter = css->attributeList() ;
          iter ; ++iter )
    {
        if (iter->value && !strcmp(iter->value, "inkscape:unset")) {
            continue;
        }

        buffer.append(g_quark_to_string(iter->key));
        buffer.push_back(':');
        if (!strcmp(g_quark_to_string(iter->key), "font-family")
                || !strcmp(g_quark_to_string(iter->key), "-inkscape-font-specification")) {
            // we only quote font-family/font-specification, as SPStyle does
            gchar *t = g_strdup (iter->value);
            g_free (t);
            gchar *val_quoted = css2_escape_quote (iter->value);
            if (val_quoted) {
                buffer.append(val_quoted);
                g_free (val_quoted);
            }
        } else {
            buffer.append(iter->value); // unquoted
        }

        if (rest(iter)) {
            buffer.push_back(';');
        }
    }

    return (buffer.empty() ? NULL : g_strdup (buffer.c_str()));
}
예제 #6
0
bool Configuration::get_windowlevel_list(const Glib::ustring& modality, WindowLevelList& list) {

    HKEY hKey;
    DWORD ret;
    int serverIdx = 0;
    char desc[256];

    std::string key = "SOFTWARE\\Aeskulap\\presets\\windowlevel\\" + modality ;
	if(modality.empty()) {
		return false;
	}
    ret = RegOpenKeyEx(HKEY_CURRENT_USER, key.c_str(), 0, KEY_READ | KEY_ENUMERATE_SUB_KEYS, &hKey);
    if( ret != ERROR_SUCCESS )
        return false;

    list.clear();
    while(  RegEnumKey(hKey, serverIdx++, desc, sizeof(desc)) == ERROR_SUCCESS )
    {
        WindowLevel w;
        if(get_windowlevel(modality, Glib::ustring(desc), w)) {
            list[w.description] = w;
        }
    }
    RegCloseKey(hKey);
	return true;
}
예제 #7
0
/**
 * Creates a combobox widget for an enumeration parameter.
 */
Gtk::Widget *ParamComboBox::get_widget(SPDocument * doc, Inkscape::XML::Node * node, sigc::signal<void> * changeSignal)
{
    if (_gui_hidden) {
        return NULL;
    }

    Gtk::HBox * hbox = Gtk::manage(new Gtk::HBox(false, 4));
    Gtk::Label * label = Gtk::manage(new Gtk::Label(_(_text), Gtk::ALIGN_START));
    label->show();
    hbox->pack_start(*label, false, false, _indent);

    ParamComboBoxEntry * combo = Gtk::manage(new ParamComboBoxEntry(this, doc, node, changeSignal));
    // add choice strings:
    Glib::ustring settext;
    for (GSList * list = choices; list != NULL; list = g_slist_next(list)) {
        enumentry * entr = reinterpret_cast<enumentry *>(list->data);
        Glib::ustring text = entr->guitext;
        combo->append(text);

        if ( _value && !entr->value.compare(_value) ) {
            settext = entr->guitext;
        }
    }
    if (!settext.empty()) {
        combo->set_active_text(settext);
    }

    combo->show();
    hbox->pack_start(*combo, true, true);

    hbox->show();

    return dynamic_cast<Gtk::Widget *>(hbox);
}
예제 #8
0
/**
 * A function to set the \c _value.
 *
 * This function sets ONLY the internal value, but it also sets the value
 * in the preferences structure.  To put it in the right place, \c PREF_DIR
 *  and \c pref_name() are used.
 *
 * To copy the data into _value the old memory must be free'd first.
 * It is important to note that \c g_free handles \c NULL just fine.  Then
 * the passed in value is duplicated using \c g_strdup().
 *
 * @param  in   The value to set.
 * @param  doc  A document that should be used to set the value.
 * @param  node The node where the value may be placed.
 */
const gchar *ParamComboBox::set(const gchar * in, SPDocument * /*doc*/, Inkscape::XML::Node * /*node*/)
{
    if (in == NULL) {
        return NULL; /* Can't have NULL string */
    }

    Glib::ustring settext;
    for (GSList * list = choices; list != NULL; list = g_slist_next(list)) {
        enumentry * entr = reinterpret_cast<enumentry *>(list->data);
        if ( !entr->guitext.compare(in) ) {
            settext = entr->value;
            break;  // break out of for loop
        }
    }
    if (!settext.empty()) {
        if (_value != NULL) {
            g_free(_value);
        }
        _value = g_strdup(settext.data());
        gchar * prefname = this->pref_name();
        Inkscape::Preferences *prefs = Inkscape::Preferences::get();
        prefs->setString(extension_pref_root + prefname, _value);
        g_free(prefname);
    }

    return _value;
}
void CalligraphicProfileRename::show(SPDesktop *desktop, const Glib::ustring profile_name)
{
    CalligraphicProfileRename &dial = instance();
    dial._applied=false;
    dial._deleted=false;
    dial.set_modal(true);

    dial._profile_name = profile_name;
    dial._profile_name_entry.set_text(profile_name);

    if (profile_name.empty()) {
        dial.set_title(_("Add profile"));
        dial._delete_button.set_visible(false);

    } else {
        dial.set_title(_("Edit profile"));
        dial._delete_button.set_visible(true);
    }

    desktop->setWindowTransient (dial.gobj());
    dial.property_destroy_with_parent() = true;
    //  dial.Gtk::Dialog::show();
    //dial.present();
    dial.run();
}
예제 #10
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;
}/*}}}*/
std::string ustring_to_c(Glib::ustring input) {/*{{{*/
    std::string to_charset, converted;

    // check if input is already 7-bit
    if (input.is_ascii())
        return input;

    // try encoding using the selected charset, unless its some utf-8
    if (!serverCharset.empty() && serverCharset.find("UTF-8") == Glib::ustring::npos) {
        try {
            return Glib::convert(input, serverCharset, "UTF-8");
        } catch (...) {}
    }

    // try encoding using the locale charset, unless its some utf-8
    if (Glib::get_charset(to_charset) == true)
        to_charset = "ISO-8859-1";

    try {
        converted = Glib::convert_with_fallback(input, to_charset, "UTF-8", "?");
    } catch (...) {
        converted = input;
    }
    return converted;
}/*}}}*/
Glib::ustring c_to_ustring(const char *input) {/*{{{*/
    Glib::ustring converted, input_u;
    // if input is NULL, return an empty string
    if (! input) return "";

    input_u = input;

    // check if input is already valid UTF-8
    if (input_u.validate())
        return input_u;

    // try to convert using the chosen charset
    if (!serverCharset.empty()) {
        try {
            return Glib::convert(input, "UTF-8", serverCharset);
        } catch (...) {}
    }

    // try to convert using the current locale
    try {
        converted = Glib::locale_to_utf8(input);
    } catch (...) {
        // locale conversion failed
        converted = iso_8859_1_to_utf8(input);
    }
    return converted;
}/*}}}*/
예제 #11
0
void ventana::on_medir(){
	Glib::ustring text = sensores->get_active_text();
	string word;
	if(!(text.empty())){
		sensor_elegido=text;
		peticion=preparar_peticion();
		//std::cout << "Peticion: " << peticion << std::endl;
		/* Aqui se debe interacturar con clase que maneje 
		 * la interaccion con el arduino por el puerto USB
		 * elegido
		 * */
		comunicacion enlace;
		string enviar;
		enviar="/dev/";
		enviar+=canal;
		if(enlace.conectar(enviar)){
			enlace.enviar_mensaje(peticion);
			word=enlace.get_mensaje();
			buffer_texto=word;
		}
		else{
			  std::cout << "Error en conexion" << std::endl;
		}
			 
			escribir();
		}
		

}
예제 #12
0
static gchar *
sp_path_description(SPItem * item)
{
    int count = SP_PATH(item)->nodesInPath();
    if (SP_IS_LPE_ITEM(item) && sp_lpe_item_has_path_effect(SP_LPE_ITEM(item))) {

        Glib::ustring s;

        PathEffectList effect_list =  sp_lpe_item_get_effect_list(SP_LPE_ITEM(item));
        for (PathEffectList::iterator it = effect_list.begin(); it != effect_list.end(); ++it)
        {
            LivePathEffectObject *lpeobj = (*it)->lpeobject;
            if (!lpeobj || !lpeobj->get_lpe())
                break;
            if (s.empty())
                s = lpeobj->get_lpe()->getName();
            else
                s = s + ", " + lpeobj->get_lpe()->getName();
        }

        return g_strdup_printf(ngettext("<b>Path</b> (%i node, path effect: %s)",
                                        "<b>Path</b> (%i nodes, path effect: %s)",count), count, s.c_str());
    } else {
        return g_strdup_printf(ngettext("<b>Path</b> (%i node)",
                                        "<b>Path</b> (%i nodes)",count), count);
    }
}
예제 #13
0
void WindowLevelToolButton::update() {
	m_configuration.get_windowlevel_list(m_modality, m_list);

	Glib::ustring a = m_combo->get_active_text();

	m_combo->clear();
	Aeskulap::WindowLevelList::iterator i;

	for(i = m_list.begin(); i != m_list.end(); i++) {
		m_combo->append_text(i->first);
	}

	m_combo->append_text(gettext("Default"));
	m_combo->append_text(gettext("Custom"));

	if(a.empty()) {
		m_combo->set_active_text(gettext("Default"));
	}
	else {
		if(find_windowlevel(a) == m_list.end()) {
			m_combo->set_active_text(gettext("Custom"));
		}
		else {
			m_combo->set_active_text(a);
		}
	}
}
예제 #14
0
int checkStringOffset(Glib::ustring str, int toffset)
{
	//-- Empty string
	if (str.empty() || StringOps(str).trim().empty())
		return -1 ;
	//-- Before text
	if (toffset <= 0)
		return 0 ;
	//-- After text
	else if (toffset >= (str.length()-1) )
		return 1 ;
	else
	{
		const Glib::ustring& tmpBefore = str.substr(0, toffset) ;
		const Glib::ustring& tmpAfter = str.substr(toffset, str.length()-1) ;
		StringOps tmpB(tmpBefore) ;
		StringOps tmpAft(tmpAfter) ;
		//-- Before is only spaces, it's before text :)
		if (tmpB.trim(" \n").empty())
			return 0 ;
		//-- After is only spaces, it's after text :)
		else if (tmpAft.trim(" \n").empty())
			return 1 ;
		//-- Otherwise it's middle :)
		else
			return 2 ;
	}
}
예제 #15
0
Glib::ustring base64decode(Glib::ustring url)
{
	if (url.empty())
		return url ;

	guchar* decoded = NULL ;

	try
	{
		gsize size ;
		decoded = g_base64_decode(url.c_str(), &size) ;

		if (!decoded)
			return "" ;

		std::string result ;

		Log::out() << "base64decode ~~~> decoded size = " << size << std::endl ;
		result.assign((gchar*)decoded, size) ;
		g_free(decoded) ;
		return result ;
	}
	catch (...)
	{
		Log::err() << "base64decode: error." << std::endl ;
		if (decoded)
			g_free(decoded) ;
		return "" ;
	}
}
예제 #16
0
bool Document::matchesSearch (Glib::ustring const &search)
{
    /* This is a bit of a hack, I guess, but it's a low-impact way of 
     * implementing the change. If the search term contains a space, I 
     * iteratively decompose it into substrings and pass those onto
     * this function. If anything doesn't match, we return a failure.
     */
    if (search.find(' ') != Glib::ustring::npos) {
        Glib::ustring::size_type p1 = 0;
        Glib::ustring::size_type p2;

        do {

            /* Find the next space in the string, if any.
             */
            p2 = search.find(' ', p1);

            /* Extract the appropriate substring.
             */
            Glib::ustring const searchTerm = search.substr(p1, p2);

            /* If the term is empty, ignore it and move on. It might just be a 
             * trailing or duplicate space character.
             */
            if (searchTerm.empty()) {
                break;
            }

            /* Now that we have the substring, which is guaranteed to be
             * free of spaces, we can pass it recursively into this function.
             * If the term does NOT match, fail the entire comparison right away.
             */
            if (!matchesSearch(searchTerm)) {
                return false;
            }

            p1 = p2 + 1;		/* +1 to skip over the space */

        } while (p2 != Glib::ustring::npos); /* Terminate at end of string */
        return true;		/* All matched, so OK. */
    }

    Glib::ustring const searchNormalised = search.casefold();

    FieldMap fields = getFields ();
    FieldMap::iterator fieldIter = fields.begin ();
    FieldMap::iterator const fieldEnd = fields.end ();
    for (; fieldIter != fieldEnd; ++fieldIter) {
        if (fieldIter->second.casefold().find(searchNormalised) != Glib::ustring::npos)
            return true;
    }

    if (notes_.casefold().find(searchNormalised) != Glib::ustring::npos)
        return true;

    if (key_.casefold().find(searchNormalised) != Glib::ustring::npos)
        return true;

    return false;
}
Glib::ustring ModelAvailFctAdapterModelImpl::replaceEmpty(
    Glib::ustring TextToCheck)
{
  if (TextToCheck.empty())
    TextToCheck = _("(unknown)");
  return TextToCheck;
}
예제 #18
0
void ProjectSettingsDialog :: save()
{
   Glib::ustring path = _targetText.get_text();
   if (!path.empty()) {
      _project->setTarget(path.c_str());
   }
   else _project->setTarget(NULL);

   path = _argumentsText.get_text();
   _project->setArguments(path.c_str());

   path = _outputText.get_text();
   _project->setOutputPath(path.c_str());

   path = _optionsText.get_text();
   _project->setOptions(path.c_str());

   Glib::ustring name = _namespaceText.get_text();
   _project->setPackage(name.c_str());

   if (_typeCombobox.get_active_id() != -1) {
      name = _typeCombobox.get_active_text();
      _project->setTemplate(name.c_str());
   }

   int index = _modeCombobox.get_active_row_number();
   if (index == 1) {
      _project->setDebugMode(-1);
   }
   else _project->setDebugMode(0);

   _project->setBoolSetting("warn:unresolved", _warningCheckbox.get_active());
}
bool Plugin::main_loop()
{
  // Update view
  if (view.get())
    view->update();

  // Update tooltip
  Glib::ustring tip;
  for (monitor_iter i = monitors.begin(), end = monitors.end(); i != end; ++i) {
    Monitor &mon = **i;

    // Note to translators: %1 is the name of a monitor, e.g. "CPU 1", and %2 is
    // the current measurement, e.g. "78%"
    Glib::ustring next = String::ucompose(_("%1: %2"), mon.get_short_name(),
            mon.format_value(mon.value()));
    if (tip.empty())
      tip = next;
    else
      // Note to translators: this is used for composing a list of monitors; %1
      // is the previous part of the list and %2 is the part to append
      tip = String::ucompose(_("%1\n%2"), tip, next);
  }
  tooltips.set_tip(get_container(), tip);

  return true;
}
예제 #20
0
void SelectInstance::on_avahi_changed() {
    std::vector<Glib::ustring> r;
    av.get_service_names(r);
    if (!win->is_visible()) {
	if (r.size() == 1) {
	    av.invoke_resolver(*r.begin());
	} else {
	    if (splash) {
		splash->hide();
	    }
	    win->show();
	}
    }
    Glib::RefPtr<Gtk::ListStore> ls = Glib::RefPtr<Gtk::ListStore>::cast_dynamic(view->get_model());
    Gtk::TreeIter s = view->get_selection()->get_selected();
    Glib::ustring old;
    if (s) {
	old = s->get_value(cols.name);
    }
    ls->clear();
    for (std::vector<Glib::ustring>::iterator i = r.begin(); i != r.end(); ++i) {
	Gtk::TreeIter j = ls->append();
	j->set_value(cols.name, *i);
	if (old.empty()) {
	    old = *i;
	}
	if (old == *i) {
	    view->get_selection()->select(j);
	}
    }
}
void DBusBrowser::on_select_busname()
{
	Glib::ustring busname = _cb_busnames.get_active_text();
	if (busname.empty()) return;

	_tm_inspect->clear();
	_inspect_append(NULL, "", busname);
}
예제 #22
0
void ventana::seleccion_dispositivo(){
	 Glib::ustring text = mac->get_active_text();
	if(!(text.empty())){
		mac_elegida=text;
	}
	sensores->remove_all();

	
}
void Window::vOnRecentFile()
{
    Glib::ustring sURI = m_poRecentChooserMenu->get_current_uri();

    if (!sURI.empty()) {
        std::string sFileName = Glib::filename_from_uri(sURI);
        bLoadROM(sFileName);
    }
}
예제 #24
0
/** Set the node this window is associated with.
 * This function MUST be called before using this object in any way.
 */
void
PropertiesWindow::set_object(SPtr<const ObjectModel> model)
{
	reset();
	_model = model;

	set_title(model->path() + " Properties - Ingen");

	World* world = _app->world();

	LilvNode* rdfs_range = lilv_new_uri(
		world->lilv_world(), LILV_NS_RDFS "range");
	LilvNode* rdf_type = lilv_new_uri(
		world->lilv_world(), LILV_NS_RDF "type");

	// Populate key combo
	const URISet props = RDFS::properties(world, model);
	for (const auto& p : props) {
		LilvNode*           prop  = lilv_new_uri(world->lilv_world(), p.c_str());
		const Glib::ustring label = RDFS::label(world, prop);
		if (label.empty()) {
			continue;
		}

		// Get all classes in the range of this property (including sub-classes)
		LilvNodes* range = lilv_world_find_nodes(
			world->lilv_world(), prop, rdfs_range, NULL);
		URISet ranges;
		LILV_FOREACH(nodes, r, range) {
			ranges.insert(Raul::URI(lilv_node_as_string(lilv_nodes_get(range, r))));
		}
		RDFS::classes(world, ranges, false);

		bool show = false;
		for (const auto& r : ranges) {
			LilvNode*  range   = lilv_new_uri(world->lilv_world(), r.c_str());
			LilvNodes* objects = lilv_world_find_nodes(
				world->lilv_world(), NULL, rdf_type, range);

			show = lilv_nodes_get_first(objects);

			lilv_nodes_free(objects);
			lilv_node_free(range);
			if (show) {
				break;  // At least one appliable object
			}
		}

		if (show || ranges.empty()) {
			Gtk::ListStore::iterator ki  = _key_store->append();
			Gtk::ListStore::Row      row = *ki;
			row[_combo_columns.uri_col]   = p;
			row[_combo_columns.label_col] = label;
		}

		lilv_node_free(prop);
	}
예제 #25
0
View *View::create(Model *model)
{
  std::vector<std::string> dirs = Platform::getConfigPaths();
  Glib::ustring ui;
  for (std::vector<std::string>::const_iterator i = dirs.begin();
       i != dirs.end(); ++i) {
    std::string f_name = Glib::build_filename (*i, "repsnapper.ui");
    Glib::RefPtr<Gio::File> file = Gio::File::create_for_path(f_name);
    try {
      char *ptr;
      gsize length;
      file->load_contents(ptr, length);
      ui = Glib::ustring(ptr);
      g_free(ptr);
      break;
    } catch(Gio::Error e) {
      switch(e.code()) {
      case Gio::Error::NOT_FOUND:
        continue;

      default:
        Gtk::MessageDialog dialog (_("Error reading UI description!!"), false,
                                  Gtk::MESSAGE_ERROR, Gtk::BUTTONS_CLOSE);
        dialog.set_secondary_text(e.what());
        dialog.run();
        return NULL;
      }
    }
  }

  if(ui.empty()) {
    Gtk::MessageDialog dialog (_("Couldn't find UI description!"), false,
                              Gtk::MESSAGE_ERROR, Gtk::BUTTONS_CLOSE);
    dialog.set_secondary_text (_("Check that repsnapper has been correctly installed."));
    dialog.run();
    return NULL;
  }

  Glib::RefPtr<Gtk::Builder> builder;
  try {
    builder = Gtk::Builder::create_from_string(ui);
  }
  catch(const Gtk::BuilderError& ex)
  {
    Gtk::MessageDialog dialog (_("Error loading UI!"), false,
                              Gtk::MESSAGE_ERROR, Gtk::BUTTONS_CLOSE);
    dialog.set_secondary_text(ex.what());
    dialog.run();
    throw ex;
  }
  View *view = 0;
  builder->get_widget_derived("main_window", view);
  view->setModel (model);

  return view;
}
예제 #26
0
void Gobby::Browser::on_hostname_activate()
{
	Glib::ustring str = m_entry_hostname.get_entry()->get_text();
	if(str.empty()) return;

	m_entry_hostname.commit();
	m_entry_hostname.get_entry()->set_text("");

	m_signal_connect.emit(str);
}
예제 #27
0
void ventana::eleccion(){
	 Glib::ustring text = puertos->get_active_text();
	if(!(text.empty())){
		canal=text;
	}
    mac->remove_all();
	sensores->remove_all();

	
}
예제 #28
0
bool KeySwitcher::process_bank_key(int idx) {
    key_timeout.disconnect();
    Glib::ustring bank = machine.get_bank_name(machine.bank_size() - idx - 1);
    if (bank.empty()) {
        display_empty("--", "--");
        return false;
    }
    last_bank_key = bank;
    display_selected_bank();
    return true;
}
예제 #29
0
char DlgConvertir::getSeparadorDecimal() const
{
	char toret;
	Glib::ustring sep = ((Gtk::Entry *)listaSepDecimal->get_child() )->get_text();

	if ( !sep.empty() )
			toret = sep[ 0 ];
	else	toret = '.';

	return toret;
}
예제 #30
0
파일: dock-item.cpp 프로젝트: GNOME/niepce
DockItem::DockItem(Dock& dock, const Glib::ustring& name, const Glib::ustring& long_name,
                   const Glib::ustring& icon_name, State state) :
    _dock (dock),
    _prev_state (state),
    _prev_position(0),
    _window (NULL),
    _x(0),
    _y(0),
    _grab_focus_on_realize(false),
    _gdl_dock_item(0),
    _dock_item_action_area (NULL)
{

    GdlDockItemBehavior gdl_dock_behavior = GDL_DOCK_ITEM_BEH_CANT_DOCK_CENTER;
// HUB
//        (prefs_get_int_attribute_limited ("options.dock", "cancenterdock", 1, 0, 1) == 0 ?
//         GDL_DOCK_ITEM_BEH_CANT_DOCK_CENTER
//         : GDL_DOCK_ITEM_BEH_NORMAL);

    if (!icon_name.empty()) {
        Glib::RefPtr<Gtk::IconTheme> icon_theme(Application::app()->getIconTheme());
        Glib::RefPtr<Gdk::Pixbuf> icon(icon_theme->load_icon(icon_name, 16, Gtk::ICON_LOOKUP_USE_BUILTIN));

        if (icon) {
            // icon needs to have a ref when 
            // passed to gdl_dock_item_new_with_pixbuf_icon()
            _gdl_dock_item =
                gdl_dock_item_new_with_pixbuf_icon(name.c_str(), 
                                                   long_name.c_str(),
                                                   GDK_PIXBUF(g_object_ref(icon->gobj())), 
                                                   gdl_dock_behavior);
        }
    } else {
        _gdl_dock_item =
            gdl_dock_item_new(name.c_str(), long_name.c_str(), gdl_dock_behavior);
    }

    _frame.set_shadow_type(Gtk::SHADOW_IN);
    gtk_container_add (GTK_CONTAINER (_gdl_dock_item), GTK_WIDGET (_frame.gobj()));
    _frame.add(_dock_item_box);
    _dock_item_box.set_border_width(3);

    signal_drag_begin().connect(sigc::mem_fun(*this, &DockItem::_onDragBegin));
    signal_drag_end().connect(sigc::mem_fun(*this, &DockItem::_onDragEnd));
    signal_hide().connect(sigc::mem_fun(*this, &DockItem::_onHide), false);
    signal_show().connect(sigc::mem_fun(*this, &DockItem::_onShow), false);
    signal_state_changed().connect(sigc::mem_fun(*this, &DockItem::_onStateChanged));
    signal_delete_event().connect(sigc::mem_fun(*this, &DockItem::_onDeleteEvent));
    signal_realize().connect(sigc::mem_fun(*this, &DockItem::_onRealize));

    _dock.addItem(*this, (_prev_state == FLOATING_STATE ? FLOATING : TOP));

    show_all();
}