示例#1
0
void ApplicationList::onDragDataGet(const Glib::RefPtr<Gdk::DragContext>& context, 
                             Gtk::SelectionData& data, guint info, guint time)
{
    Glib::RefPtr<Gtk::TreeSelection> refTreeSelection = m_TreeView.get_selection();
    Gtk::TreeModel::iterator iter = refTreeSelection->get_selected();

    if(iter && ((*iter)[m_appColumns.m_col_type] == MODULE))
    {
        Glib::ustring name = (*iter)[m_appColumns.m_col_name];
        data.set(data.get_target(), MODULE,
                (const guchar*)name.c_str(), name.size()+1);  
    }
    else if(iter && ((*iter)[m_appColumns.m_col_type] == RESOURCE))
    {
        Glib::ustring name = (*iter)[m_appColumns.m_col_name];
        data.set(data.get_target(), RESOURCE,
                (const guchar*)name.c_str(), name.size()+1);  
    }
    else if(iter && ((*iter)[m_appColumns.m_col_type] == APPLICATION))
    {
        Glib::ustring name = (*iter)[m_appColumns.m_col_name];
        data.set(data.get_target(), APPLICATION,
                (const guchar*)name.c_str(), name.size()+1);  
    }
}
// A wrapper around set_tooltip_*() for portability across different gtkmm versions.
void app_gtkmm_set_widget_tooltip(Gtk::Widget& widget,
		const Glib::ustring& tooltip_text, bool use_markup)
{
	// set_tooltip_* is available since 2.12
#ifndef APP_GTKMM_OLD_TOOLTIPS
	if (use_markup) {
		widget.set_tooltip_markup(tooltip_text);
	} else {
		widget.set_tooltip_text(tooltip_text);
	}

#else  // use the old tooltips api
	Gtk::Widget* toplevel = widget.get_toplevel();
	if (toplevel && toplevel->is_toplevel()) {  // orphan widgets return themselves, so check toplevelness.
		GtkTooltips* tooltips = static_cast<GtkTooltips*>(toplevel->get_data("window_tooltips"));
		if (tooltips) {
			if (use_markup) {
				// strip markup
				Glib::ustring stripped;
				if (app_pango_strip_markup(tooltip_text, stripped)) {
					gtk_tooltips_set_tip(tooltips, widget.gobj(), stripped.c_str(), "");
				}

			} else {
				gtk_tooltips_set_tip(tooltips, widget.gobj(), tooltip_text.c_str(), "");
			}
		}
	}
#endif
}
示例#3
0
Gtk::TreeIter
ConfigTreeView::search_path( const char* path )
{
  Gtk::TreeModel::Children children = m_config_tree->children();
  Gtk::TreeModel::iterator iter = children.begin();
  
  while ( iter != children.end() )
  {
    Gtk::TreeModel::Row row = *iter;
    Glib::ustring p = row[ m_config_record.path ];
    size_t len = strlen( p.c_str() );

    if ( strncmp( p.c_str(), path, len) == 0 )
    {
      if ( strcmp( p.c_str(), path ) == 0 )
      { return iter; }
      else
      { iter = iter->children().begin(); }
    }
    else
    { ++iter; }
  }

  return m_config_tree->children().end();
}
int File_inport::inport(Glib::ustring file) {
	//convert adress to file name
	int poz = file.rfind("/");
	Glib::ustring subor = Glib::ustring(file.c_str()+poz);
	File_load fil(file);
	if(fil.getType().compare(CUSTOMVIDEO)==0){
		return 1;
	}

	std::fstream vys;
	vys.open((confDir+subor).c_str(), std::fstream::in);
	if(vys.good()){
//		std::cout<<"exist"<<std::endl;
		return -1;
	}
	Glib::ustring command = "cp -n \"" + file + "\" " + confDir;
	if(system(command.c_str())!=0){
		return -2;
	}
	vys.close();
	vys.open(confFile.c_str(), std::fstream::out | std::fstream::app);
	vys<<confDir+subor<<std::endl;
	vys.close();
	return 0;
}
// saving is only supported for png, jpeg and bmp, let's see whether we are allowed
// to save whatever the user is trying to save
Glib::ustring FileManager::filter_save_filename(Glib::ustring filename)
	{
	if( magic_file( cookie, filename.c_str() ) != NULL )
		{
		result = magic_file(cookie, filename.c_str() );
#ifdef DEBUG
		std::cout << result << std::endl;
#endif // DEBUG
		}
	else
		{
		std::cerr << GT( "FILTER_SAVE_FILENAME: The file type could not be determined: " ) << filename << std::endl;
		return "unsupported";
		}

	if( result.find("JPEG") != Glib::ustring::npos )
		return "jpeg";

	else if( result.find("PNG") != Glib::ustring::npos )
		return "png";

	else if( result.find("PC bitmap") != Glib::ustring::npos )
		return "bmp";

	else
		return  "unsupported";
	
	}
/** Run dialog and try to connect.
 * This runs the service chooser dialog and connects to the given service
 * with the attached FawkesNetworkClient. If the connection couldn't be established
 * an error dialog is shown. You should not rely on the connection to be
 * active after calling this method, rather you should use a ConnectionDispatcher
 * to get the "connected" signal.
 */
void
ServiceChooserDialog::run_and_connect()
{
  if (! __client)  throw NullPointerException("FawkesNetworkClient not set");
  if (__client->connected()) throw Exception("Client is already connected");

  if ( run() ) {
    try {
      Glib::ustring name;
      Glib::ustring hostname;
      Glib::ustring ipaddr;
      unsigned short int port;
      get_selected_service(name, hostname, ipaddr, port);
      if ( port == 0 )  port = 1910;

      __client->connect(hostname.c_str(), ipaddr.c_str(), port);
    } catch (Exception &e) {
      Glib::ustring message = *(e.begin());
      Gtk::MessageDialog md(__parent, message, /* markup */ false,
			    Gtk::MESSAGE_ERROR, Gtk::BUTTONS_OK,
			    /* modal */ true);
      md.set_title("Connection failed");
      md.run();
    }
  }
}
示例#7
0
bool
ManglerOSS::open(int type, Glib::ustring device, int rate, int channels) {/*{{{*/
    if ((oss_fd = ::open((device == "") ? "/dev/dsp" : device.c_str(), (type >= AUDIO_OUTPUT) ? O_WRONLY : O_RDONLY)) < 0) {
        fprintf(stderr, "oss: open() %s failed: %s\n", (device == "") ? "/dev/dsp" : device.c_str(), strerror(errno));
        return false;
    }
    int opt;
    opt = AFMT_S16_NE;
    if ((::ioctl(oss_fd, SNDCTL_DSP_SETFMT, &opt) < 0) || opt != AFMT_S16_NE) {
        fprintf(stderr, "oss: ioctl() SNDCTL_DSP_SETFMT failed: %s\n", strerror(errno));
        close();
        return false;
    }
    opt = channels;
    if ((::ioctl(oss_fd, SNDCTL_DSP_CHANNELS, &opt) < 0) || opt != (int)channels) {
        fprintf(stderr, "oss: ioctl() SNDCTL_DSP_CHANNELS failed: %s\n", strerror(errno));
        close();
        return false;
    }
    opt = rate;
    if ((::ioctl(oss_fd, SNDCTL_DSP_SPEED, &opt) < 0) || opt != (int)rate) {
        fprintf(stderr, "oss: ioctl() SNDCTL_DSP_SPEED failed: %s\n", strerror(errno));
        close();
        return false;
    }
    return true;
}/*}}}*/
示例#8
0
文件: path.cpp 项目: myutwo/inkscape
void
PathParam::on_link_button_click()
{
    Inkscape::UI::ClipboardManager *cm = Inkscape::UI::ClipboardManager::get();
    Glib::ustring pathid = cm->getShapeOrTextObjectId(SP_ACTIVE_DESKTOP);

    if (pathid == "") {
        return;
    }

    // add '#' at start to make it an uri.
    pathid.insert(pathid.begin(), '#');
    if ( href && strcmp(pathid.c_str(), href) == 0 ) {
        // no change, do nothing
        return;
    } else {
        // TODO:
        // check if id really exists in document, or only in clipboard document: if only in clipboard then invalid
        // check if linking to object to which LPE is applied (maybe delegated to PathReference

        param_write_to_repr(pathid.c_str());
        DocumentUndo::done(param_effect->getSPDoc(), SP_VERB_DIALOG_LIVE_PATH_EFFECT,
                           _("Link path parameter to path"));
    }
}
示例#9
0
void PlayerKernel::sendCommand(Glib::ustring command) {
    if (playing) {
        if(pause)
            dprintf(toPlayer[1], "%s %s", "pausing",command.c_str());
        else
            dprintf(toPlayer[1], "%s", command.c_str());
    }
}
示例#10
0
void ModulePropertyWindow::onCellEdited(const Glib::ustring& path_string, 
                    const Glib::ustring& new_text)
{
    if(!m_pModule)
        return;

    if(m_pAppWindow)
        m_pAppWindow->setModified();

    ErrorLogger* logger = ErrorLogger::Instance();
    Gtk::TreePath path(path_string);

    //Get the row from the path:
    Gtk::TreeModel::iterator iter = m_refTreeModel->get_iter(path);
    if(iter)
    {
        Gtk::TreeModel::Row row = *iter;
        //Put the new value in the model:
        Glib::ustring strName = Glib::ustring(row[m_Columns.m_col_name]);

        if(strName == "Deployer")
        {
            if(strlen(m_pModule->getHost()) && 
               !compareString(m_pModule->getHost(), "localhost") && 
               (new_text == "local"))
            {
                logger->addWarning("local deployer cannot be used to deploy a module on the remote host.");
                m_pParent->reportErrors();
                return;
            }
        }

        if(strName == "Node")
        {
            if(compareString(m_pModule->getBroker(), "local") &&
               new_text.size() && (new_text != "localhost")) 
            {    
                OSTRINGSTREAM msg;
                msg<<new_text.c_str()<<" cannot be used with local deployer!";
                logger->addWarning(msg);
                m_pParent->reportErrors();
                
                Gtk::TreeModel::Row row;
                if(getRowByName("Deployer", &row))
                {
                    row[m_Columns.m_col_value] = "";
                    updateModule("Deployer", "");
                }
            } 
        }

        row[m_Columns.m_col_value] = new_text;
        updateParamteres();
        updateModule(strName.c_str(), new_text.c_str());

   }
}
示例#11
0
bool createDir(const Glib::ustring& p_path){

	if(g_mkdir_with_parents((p_path).c_str(), 0755)){
		GELIDE_ERROR("Could not create directory " << p_path.c_str());
		return false;
	}
	GELIDE_DEBUG("Successfully created Directory " << p_path.c_str());
	return true;
}
示例#12
0
void
DockItem::set_title(Glib::ustring title)
{
    g_object_set (_gdl_dock_item,
                  "long-name", title.c_str(),
                  NULL);

    gdl_dock_item_set_tablabel(GDL_DOCK_ITEM(_gdl_dock_item),
                               gtk_label_new (title.c_str()));
}
/* Method save_xml */
void ClusterSettings::save_xml (const Glib::ustring& filename)
{
  /* Create xml document */
  TiXmlDocument doc;

  /* XML Declaration */
  TiXmlDeclaration *decl = new TiXmlDeclaration ("0.0", "", "");
  doc.LinkEndChild (decl);

  /* Root element */
  TiXmlElement *root = new TiXmlElement ("SensorsClusterSettings");
  doc.LinkEndChild (root);

  /* Comment */
  Glib::ustring message;
  message.assign (" File created by ComLibSim at [");
  message.append (filename);
  message.append ("] ");
  TiXmlComment *comment = new TiXmlComment ();
  comment->SetValue (message.c_str ());
  root->LinkEndChild (comment);

  /* Cluster element */
  TiXmlElement *cluster = new TiXmlElement ("Cluster");
  root->LinkEndChild (cluster);

  /* Set cluster attribute */
  cluster->SetAttribute ("name", m_Name.c_str ());

  /* Sensors element */
  TiXmlElement *sensorsNode = new TiXmlElement ("Sensors");
  root->LinkEndChild (sensorsNode);

  /* Set sensor element and attributes */
  std::list<SensorSettings>::iterator iter;
  for (iter=m_Sensors.begin (); iter != m_Sensors.end (); iter++)
  {
    const SensorSettings& sensor_iter = *iter;

    /* Sensor element */
    TiXmlElement *sensor = new TiXmlElement ("Sensor");
    sensorsNode->LinkEndChild (sensor);

    /* Set sensor attributes */
    sensor->SetAttribute ("tag", iter->get_tag ().c_str ());
    sensor->SetAttribute ("online", iter->get_online ());
    sensor->SetDoubleAttribute ("x", iter->get_x_coord ());
    sensor->SetDoubleAttribute ("y", iter->get_y_coord ());
    sensor->SetAttribute ("adata", iter->get_amount_data ());
    sensor->SetAttribute ("type", iter->get_type ().c_str ());
  }

  /* Save xml to file */
  doc.SaveFile (filename.c_str ());
}
示例#14
0
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();
}
示例#15
0
void ModulePropertyWindow::updateParamteres()
{
    // updating parameters
    typedef Gtk::TreeModel::Children type_children;
    type_children children = m_refTreeModel->children();
    OSTRINGSTREAM strParams;
    Glib::ustring strName;
    for(type_children::iterator iter = children.begin(); iter!=children.end(); ++iter)
    {
        strName = Glib::ustring((*iter)[m_Columns.m_col_name]);
        if(strName == "Parameters")
        {
            for(type_children::iterator jter = (*iter).children().begin(); 
                jter!=(*iter).children().end(); ++jter)
            {
                Glib::ustring strItem = Glib::ustring((*jter)[m_Columns.m_col_name]);
                Glib::ustring strValue = Glib::ustring((*jter)[m_Columns.m_col_value]);
                for(int i=0; i<m_pModule->argumentCount(); i++) 
                {
                    if(strItem == m_pModule->getArgumentAt(i).getParam())
                    {   
                        if(strValue.size())
                        {
                            if(!m_pModule->getArgumentAt(i).isSwitch())                            
                                strParams<<"--"<<strItem<<" "<<strValue<<" ";
                            else
                            {
                                if(compareString(strValue.c_str(), "on" ))
                                    strParams<<"--"<<strItem<<" ";
                                else
                                    (*jter)[m_Columns.m_col_value] = "off";
                            }
                        }
                        else
                            if(m_pModule->getArgumentAt(i).isSwitch())                            
                                (*jter)[m_Columns.m_col_value] = "off";
                    }    

                    if((strItem == m_pModule->getArgumentAt(i).getParam()) &&
                        m_pModule->getArgumentAt(i).isRequired())
                    {    
                        if(!strValue.size())
                            (*jter)[m_Columns.m_col_color_item] = Gdk::Color("#BF0303");
                        else
                            (*jter)[m_Columns.m_col_color_item] = Gdk::Color("#000000");
                    }
                }
            }
            (*iter)[m_Columns.m_col_value] = strParams.str();
            updateModule(strName.c_str(), strParams.str().c_str());
            break;
        }
    }        
}
示例#16
0
void JAMediaPlayer::load(Glib::ustring track, const gulong ventana_id){
    xid = ventana_id;
    posicion = 0;
    signal_progress_update.emit(posicion);
    //self.emit("loading-buffer", 100)
    if (gst_uri_is_valid(track.c_str())){
        playbin->property_uri() = track.c_str();
        progressbar = false;}
    else {
        playbin->property_uri() = Glib::filename_to_uri(track);
        progressbar = true;}}
示例#17
0
void Widget::change_skin(int model)
{
  Glib::ustring rcfile =GX_LV2_STYLE_DIR;
  rcfile +="/gx_lv2-";
  rcfile += to_string(model);
  rcfile += ".rc";
  gtk_rc_parse(rcfile.c_str());
  //gtk_rc_reparse_all_for_settings(gtk_settings_get_default(),true);
  Glib::ustring o = "widget \"*." + plug_name + "\" style:highest \"gx_lv2-" + to_string(model) + "\"";
  gtk_rc_parse_string(o.c_str());
  gtk_rc_reset_styles(gtk_settings_get_default());
}
示例#18
0
	void on__(){
		switch(argc_){
		/*case 2:
			d_(sh_,on_,code_.c_str(),NULL,2,argv_[0].c_str(),argv_[1].c_str());
			break;*/
		case 3:
			d_(sh_,on_,code_.c_str(),NULL,3,argv_[0].c_str(),argv_[1].c_str(),argv_[2].c_str());
			break;
		case 4:
			d_(sh_,on_,code_.c_str(),NULL,4,argv_[0].c_str(),argv_[1].c_str(),argv_[2].c_str(),argv_[3].c_str());
			break;
		}
	}
示例#19
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;
}
void NoteDirectoryWatcherApplicationAddin::delete_note(const Glib::ustring & note_id)
{
  DBG_OUT("NoteDirectoryWatcher: deleting %s because file deleted.", note_id.c_str());

  Glib::ustring note_uri = make_uri(note_id);

  gnote::NoteBase::Ptr note_to_delete = note_manager().find_by_uri(note_uri);
  if(note_to_delete != 0) {
    note_manager().delete_note(note_to_delete);
  }
  else {
    DBG_OUT("notedirectorywatcher: did not delete %s because note not found.", note_id.c_str());
  }
}
示例#21
0
bool post_office::push_data (Glib::ustring data) {
	
	if(connected)
	{
		/* Send the word to the server */
	    int len = strlen(data.c_str());
	    if (send(sock, data.c_str(), len, 0) != len) {
	      this->set_last_error("Mismatch in number of sent bytes");
	      return false;
	    }
		return true;
	}
	this->set_last_error("Not connected");
	return false;
}
示例#22
0
int main (int argc, char **argv)
{
	Glib::thread_init();
	Gtk::Main kit(argc, argv);

	Glib::ustring ces = argv[0];
	Glib::ustring::size_type vzd = ces.rfind("/");
	ces = Glib::ustring(ces.c_str(), ces.c_str()+vzd);
	int a = chdir(ces.c_str());
	if(a != 0){
		std::cerr<<"ERROR chdir: "<<a<<std::endl;
	}
	Okno *Hl = new Okno();
	delete Hl;
  	return 0;
}
示例#23
0
/* Implementation of Glib::ustring conversion for libxml++.
 * We implement them in the source file to not pollute the header with glib.h
 */
tiny_string::tiny_string(const Glib::ustring& r):buf(_buf_static),stringSize(r.bytes()+1),type(STATIC)
{
	if(stringSize > STATIC_SIZE)
		createBuffer(stringSize);
	memcpy(buf,r.c_str(),stringSize);
	init();
}
示例#24
0
bool
ManglerAlsa::open(int type, Glib::ustring device, int rate, int channels) {/*{{{*/
    if ((alsa_error = snd_pcm_open(
                          &alsa_stream,
                          (device == "") ? "default" : device.c_str(),
                          (type >= AUDIO_OUTPUT) ? SND_PCM_STREAM_PLAYBACK : SND_PCM_STREAM_CAPTURE,
                          0)) < 0) {
        fprintf(stderr, "alsa: snd_pcm_open() failed: %s\n", snd_strerror(alsa_error));
        alsa_stream = NULL;
        return false;
    }
    if ((alsa_error = snd_pcm_set_params(
                          alsa_stream,                      // pcm handle
                          SND_PCM_FORMAT_S16_LE,            // format
                          SND_PCM_ACCESS_RW_INTERLEAVED,    // access
                          channels,                         // channels
                          rate,                             // rate
                          true,                             // soft_resample
                          150000)) < 0) {                   // latency in usec (0.15 sec)
        fprintf(stderr, "alsa: snd_pcm_set_params() failed: %s\n", snd_strerror(alsa_error));
        close();
        return false;
    }
    if ((alsa_error = snd_pcm_prepare(alsa_stream)) < 0) {
        fprintf(stderr, "alsa: snd_pcm_prepare() failed: %s\n", snd_strerror(alsa_error));
        close();
        return false;
    }
    if (type == AUDIO_INPUT && (alsa_error = snd_pcm_start(alsa_stream)) < 0) {
        fprintf(stderr, "alsa: snd_pcm_start() failed: %s\n", snd_strerror(alsa_error));
        close();
        return false;
    }
    return true;
}/*}}}*/
示例#25
0
int runtime::app::onCommand(const Glib::RefPtr<Gio::ApplicationCommandLine> &appCmdLine) {
  auto optDict = appCmdLine->get_options_dict();
  auto cmdOptions = getCmdOptions();
  for (auto &o : *(cmdOptions->getEntries())) {
    if (o.second.value.type == dataTypes::OptionArgumentText ||
        o.second.value.type == dataTypes::OptionArgumentFilename) {
      Glib::ustring tmp;
      if (!optDict->lookup_value(o.second.longName.c_str(), tmp))
        continue;
      o.second.value.textValue = tmp.c_str();
    } else if (o.second.value.type == dataTypes::OptionArgumentLogical) {
      bool tmp;
      if (!optDict->lookup_value(o.second.longName.c_str(), tmp))
        continue;
      o.second.value.logicalValue = tmp;
    } else if (o.second.value.type == dataTypes::OptionArgumentNumeric) {
      int tmp;
      if (!optDict->lookup_value(o.second.longName.c_str(), tmp))
        continue;
      o.second.value.numericValue = tmp;
    }

    if (o.second.callback) {
      int retval = -1; // continue
      if (!o.second.callback(o.second, &retval))
        return retval;
    }
  }

  optDict->lookup_value(G_OPTION_REMAINING, cmdOptions->pathArgs);

  _app->activate();
  return EXIT_SUCCESS;
}
示例#26
0
void DocumentView::save(const unicode& path) {
    L_DEBUG("Saving file: " + path.encode());
    trim_trailing_newlines();
    trim_trailing_whitespace();

    Glib::ustring text = buffer()->get_text();

    if(file_->get_path() == path.encode()) {
        //FIXME: Use entity tag arguments to make sure that the file
        //didn't change since the last time we saved
        file_->replace_contents(std::string(text.c_str()), "", file_etag_);
        connect_file_monitor();
    } else {
        auto file = Gio::File::create_for_path(path.encode());
        if(!os::path::exists(path)) {
            file->create_file();
        }
        file->replace_contents(text, "", file_etag_);
        connect_file_monitor();
    }

    buffer()->set_modified(false);

    apply_settings(guess_mimetype()); //Make sure we update the settings when we've saved the file

    window_.rebuild_open_list();
    run_linters_and_stuff();
}
示例#27
0
void Gxts9GUI::set_skin()
{
  Glib::ustring toparse = "pixmap_path  ";
  toparse +=     " '";
  toparse +=        GX_LV2_STYLE_DIR;
  toparse +=     "/'\n";
  toparse +=     "style \"gx_";
  toparse +=     plug_name;
  toparse +=     "_dark-paintbox\"\n"
                 " { \n"
                 "    GxPaintBox::icon-set =9\n"
                 "    stock['amp_skin'] = {{'";
  toparse +=     plugskin;
  toparse +=     "'}}\n"
                 " }\n"
                 "\n"
                 "style 'gx_head_black_box' \n"
                 " { \n"
                 "    fg[NORMAL] = '#237328' \n"
                 " }\n";
  toparse +=     addKnob;

  toparse +=     " widget '*.amplabel' style:highest 'gx_head_black_box'\n"
                 "widget '*.";
  toparse +=     plug_name;
  toparse +=     "' style 'gx_";
  toparse +=     plug_name;
  toparse +=     "_dark-paintbox' ";

  gtk_rc_parse_string (toparse.c_str());
}
示例#28
0
static void sp_font_selector_set_size_tooltip(SPFontSelector *fsel)
{
    Inkscape::Preferences *prefs = Inkscape::Preferences::get();
    int unit = prefs->getInt("/options/font/unitType", SP_CSS_UNIT_PT);
    Glib::ustring tooltip = Glib::ustring::format("Font size (", sp_style_get_css_unit_string(unit), ")");
    gtk_widget_set_tooltip_text (fsel->size, _(tooltip.c_str()));
}
示例#29
0
static void sp_gvs_rebuild_gui_full(SPGradientVectorSelector *gvs)
{

    gvs->tree_select_connection.block();

    /* Clear old list, if there is any */
    gvs->store->clear();

    /* Pick up all gradients with vectors */
    GSList *gl = NULL;
    if (gvs->gr) {
        const GSList *gradients = gvs->gr->document->getResourceList("gradient");
        for (const GSList *curr = gradients; curr; curr = curr->next) {
            SPGradient* grad = SP_GRADIENT(curr->data);
            if ( grad->hasStops() && (grad->isSwatch() == gvs->swatched) ) {
                gl = g_slist_prepend(gl, curr->data);
            }
        }
    }
    gl = g_slist_reverse(gl);

    /* Get usage count of all the gradients */
    std::map<SPGradient *, gint> usageCount;
    gr_get_usage_counts(gvs->doc, &usageCount);

    if (!gvs->doc) {
        Gtk::TreeModel::Row row = *(gvs->store->append());
        row[gvs->columns->name] = _("No document selected");

    } else if (!gl) {
        Gtk::TreeModel::Row row = *(gvs->store->append());
        row[gvs->columns->name] = _("No gradients in document");

    } else if (!gvs->gr) {
        Gtk::TreeModel::Row row = *(gvs->store->append());
        row[gvs->columns->name] =  _("No gradient selected");

    } else {
        while (gl) {
            SPGradient *gr;
            gr = SP_GRADIENT(gl->data);
            gl = g_slist_remove(gl, gr);

            unsigned long hhssll = sp_gradient_to_hhssll(gr);
            GdkPixbuf *pixb = sp_gradient_to_pixbuf (gr, 64, 18);
            Glib::ustring label = gr_prepare_label(gr);

            Gtk::TreeModel::Row row = *(gvs->store->append());
            row[gvs->columns->name] = label.c_str();
            row[gvs->columns->color] = hhssll;
            row[gvs->columns->refcount] = usageCount[gr];
            row[gvs->columns->data] = gr;
            row[gvs->columns->pixbuf] = Glib::wrap(pixb);

        }
    }

    gvs->tree_select_connection.unblock();

}
示例#30
0
void sp_tref_update_text(SPTRef *tref)
{
    if (tref) {
        // Get the character data that will be used with this tref
        Glib::ustring charData = "";
        build_string_from_root(tref->getObjectReferredTo()->getRepr(), &charData);

        if (tref->stringChild) {
            tref->detach(tref->stringChild);
            tref->stringChild = NULL;
        }

        // Create the node and SPString to be the tref's child
        Inkscape::XML::Document *xml_doc = tref->document->getReprDoc();

        Inkscape::XML::Node *newStringRepr = xml_doc->createTextNode(charData.c_str());
        tref->stringChild = SPFactory::instance().createObject(NodeTraits::get_type_string(*newStringRepr));

        // Add this SPString as a child of the tref
        tref->attach(tref->stringChild, tref->lastChild());
        sp_object_unref(tref->stringChild, NULL);
        (tref->stringChild)->invoke_build(tref->document, newStringRepr, TRUE);

        Inkscape::GC::release(newStringRepr);
    }
}