~ubuntu-branches/ubuntu/utopic/inkscape/utopic-proposed

« back to all changes in this revision

Viewing changes to src/extension/implementation/script.cpp

  • Committer: Alex Valavanis
  • Date: 2012-02-16 09:51:14 UTC
  • mto: (63.1.1 fix-933188) (1.4.4) (2.5.4 sid)
  • mto: This revision was merged to the branch mainline in revision 64.
  • Revision ID: valavanisalex@gmail.com-20120216095114-vxo1i071bw0xxxf3
Tags: upstream-0.48.3
ImportĀ upstreamĀ versionĀ 0.48.3

Show diffs side-by-side

added added

removed removed

Lines of Context:
44
44
#include "xml/attribute-record.h"
45
45
 
46
46
#include "util/glib-list-iterators.h"
47
 
 
 
47
#include "path-prefix.h"
48
48
 
49
49
 
50
50
#ifdef WIN32
188
188
    }
189
189
 
190
190
    Glib::ustring reldir = s;
191
 
 
192
191
    for (unsigned int i=0;
193
192
        i < Inkscape::Extension::Extension::search_path.size();
194
193
        i++) {
199
198
           NULL);
200
199
        Glib::ustring filename = fname;
201
200
        g_free(fname);
202
 
 
 
201
        //printf("Filename: %s\n", filename.c_str());
203
202
        if ( Inkscape::IO::file_test(filename.c_str(), G_FILE_TEST_EXISTS) ) {
204
203
            return Glib::filename_from_utf8(filename);
205
204
        }
228
227
*/
229
228
bool Script::check_existence(const std::string &command)
230
229
{
231
 
 
232
230
    // Check the simple case first
233
231
    if (command.empty()) {
234
232
        return false;
235
233
    }
236
234
 
237
235
    //Don't search when it is an absolute path. */
238
 
    if (!Glib::path_is_absolute(command)) {
 
236
    if (Glib::path_is_absolute(command)) {
239
237
        if (Glib::file_test(command, Glib::FILE_TEST_EXISTS)) {
240
238
            return true;
241
239
        } else {
243
241
        }
244
242
    }
245
243
 
246
 
    std::string path = Glib::getenv("PATH");
247
 
    if (path.empty()) {
248
 
       /* There is no `PATH' in the environment.
249
 
           The default search path is the current directory */
250
 
        path = G_SEARCHPATH_SEPARATOR_S;
251
 
    }
 
244
    // First search in the current directory
 
245
    std::string path = G_SEARCHPATH_SEPARATOR_S;
 
246
    path.append(";");
 
247
    // And then in the PATH environment variable.
 
248
    path.append(Glib::getenv("PATH"));
252
249
 
253
250
    std::string::size_type pos  = 0;
254
251
    std::string::size_type pos2 = 0;
378
375
                    if (!command_text.empty()) {
379
376
                        /* I've got the command */
380
377
                        bool existance = check_existence(command_text);
381
 
                        if (!existance)
 
378
                        if (!existance) {
382
379
                            return false;
 
380
                        }
 
381
                    } else {
 
382
                        return false;
383
383
                    }
384
384
                }
385
385
 
725
725
        doc->doc()->emitReconstructionStart();
726
726
        copy_doc(doc->doc()->rroot, mydoc->rroot);
727
727
        doc->doc()->emitReconstructionFinish();
 
728
        SPObject *layer = NULL;
 
729
        SPObject *obj = mydoc->getObjectById("base");
 
730
        // Getting the named view from the document generated by the extension
 
731
        SPNamedView *nv = (SPNamedView *) obj;
 
732
        
 
733
        //Check if it has a default layer set up
 
734
        if ( nv->default_layer_id != 0 ) {
 
735
            SPDocument *document = desktop->doc();
 
736
            //If so, get that layer
 
737
            layer = document->getObjectById(g_quark_to_string(nv->default_layer_id));
 
738
        }
 
739
        
 
740
        sp_namedview_update_layers_from_document(desktop);
 
741
        //If that layer exists,
 
742
        if (layer) {
 
743
            //set the current layer
 
744
            desktop->setCurrentLayer(layer);
 
745
        }
728
746
        mydoc->release();
729
 
        sp_namedview_update_layers_from_document(desktop);
730
747
    }
731
748
 
732
749
    return;
848
865
    scrollwindow->set_policy(Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC);
849
866
    scrollwindow->set_shadow_type(Gtk::SHADOW_IN);
850
867
    scrollwindow->show();
 
868
    scrollwindow->set_size_request(0, 60);
851
869
 
852
870
    vbox->pack_start(*scrollwindow, true, true, 5 /* fix these */);
853
871