synfig::String Action::Base::get_layer_descriptions(const std::list<std::pair<synfig::Layer::Handle,int> > layers, synfig::String singular_prefix, synfig::String plural_prefix) { String ret; bool first = true; if (plural_prefix.empty()) plural_prefix = singular_prefix; if (layers.empty()) return plural_prefix; if (layers.size() == 1) ret = singular_prefix; else ret = plural_prefix; if (!ret.empty()) ret.push_back(' '); for(std::list<std::pair<synfig::Layer::Handle,int> >::const_iterator iter=layers.begin(); iter!=layers.end(); ++iter) { if (first) first = false; else ret += ", "; ret += strprintf("'%s'", iter->first->get_non_empty_description().c_str()); } return ret; }
bool IPC::process_command(const synfig::String& command_line) { if(command_line.empty()) return false; char cmd = command_line[0]; String args(command_line.begin()+1,command_line.end()); // erase leading spaces while (!args.empty() && args[0] == ' ') args.erase(args.begin()); // erase trailing newlines and spaces while (!args.empty() && (args[args.size()-1] == '\n' || args[args.size()-1] == ' ')) args.erase(args.end()-1); switch(toupper(cmd)) { case 'F': // Focus/Foreground App::signal_present_all()(); break; case 'N': // New file App::signal_present_all()(); App::new_instance(); break; case 'O': // Open <arg> App::signal_present_all()(); App::open(args); break; case 'X': // Quit case 'Q': // Quit App::quit(); break; default: synfig::warning("Received unknown command '%c' with arg '%s'",cmd,args.c_str()); break; } return true; }
bool DialogSettings::set_value(const synfig::String& key,const synfig::String& value) { int screen_w(Gdk::screen_width()); int screen_h(Gdk::screen_height()); if(value.empty()) return false; if(key=="pos") { int x,y; if(!strscanf(value,"%d %d",&x, &y)) return false; if (x > screen_w) x = screen_w - 150; if (x < 0) x = 0; if (y > screen_h) y = screen_h - 150; if (y < 0) y = 0; window->move(x,y); return true; } if(key=="size") { int x,y; if(!strscanf(value,"%d %d",&x, &y)) return false; if (x > screen_w) x = 150; if (x < 0) x = 0; if (y > screen_h) y = 150; if (y < 0) y = 0; window->set_default_size(x,y); return true; } if(key=="x") { int x,y; window->get_position(x,y); x=atoi(value.c_str()); window->move(x,y); return true; } if(key=="y") { int x,y; window->get_position(x,y); y=atoi(value.c_str()); window->move(x,y); return true; } if(key=="w") { int x,y; window->get_size(x,y); x=atoi(value.c_str()); window->set_default_size(x,y); return true; } if(key=="h") { int x,y; window->get_size(x,y); y=atoi(value.c_str()); window->set_default_size(x,y); return true; } if(key=="visible") { if(value=="0") window->hide(); else window->present(); return true; } return synfigapp::Settings::set_value(key,value); }