예제 #1
0
void List::draw_label_helper(const Cairo::RefPtr<Cairo::Context> & cr, ListNode * label, const char * text, int x, int y, LabelArrowPos arrowPos) {
	cr->set_source_rgb(0.0, 0.0, 0.0);
	Pango::FontDescription font;
	font.set_family("Monospace");
	font.set_weight(Pango::WEIGHT_BOLD);
	Glib::RefPtr<Pango::Layout> layout = create_pango_layout(text);
	layout->set_font_description(font);
	int text_w, text_h;
	layout->get_pixel_size(text_w, text_h);
	cr->move_to(x, y);
	layout->show_in_cairo_context(cr);
	if (label != NULL) {
		if (arrowPos == RIGHT) {
		draw_arrow_helper(cr, x + text_w + 10, y + text_h / 2, label->x - 10, label->y + ListNode::field_h);
		} else {
		draw_arrow_helper(cr, x - 10, y + text_h / 2, label->x + ListNode::field_w + 10, label->y + ListNode::field_h);
		}
	} else {
		if (arrowPos == RIGHT) {
			draw_null_arrow(cr, x + text_w + 10, y + text_h / 2, true);
		} else {
			draw_null_arrow(cr, x - 10, y + text_h / 2, false);
		}
	}
}
예제 #2
0
double FontSize(const Pango::FontDescription& dsc)
{
    int sz = dsc.get_size();

    if( dsc.get_size_is_absolute() )
        return sz * (72./GetDpi());
    else
        return pango_units_to_double(sz);
}
예제 #3
0
void DocumentView::apply_settings(const unicode& mimetype) {
    L_INFO(_u("Applying settings for: ") + mimetype);

    view_.set_left_margin(4);
    view_.set_right_margin(4);
    view_.set_show_line_marks(true);
    view_.set_smart_home_end(Gsv::SMART_HOME_END_AFTER);
    view_.set_show_right_margin();
    view_.set_right_margin_position(80);

    //Load any settings from the settings file
    json::JSON default_settings = window_.settings()["default"];

    if(window_.settings().has_key(mimetype)) {
        default_settings.update(window_.settings()[mimetype]);
    }

    view_.set_show_line_numbers(default_settings["show_line_numbers"].get_bool());
    view_.set_auto_indent(default_settings["auto_indent"].get_bool());

    if(!default_settings["detect_indentation"].get_bool()) {
        detect_and_apply_indentation();
    }

    Gsv::DrawSpacesFlags flags;
    if(default_settings["draw_whitespace_spaces"].get_bool()) {
        flags |= Gsv::DRAW_SPACES_SPACE;
    }
    if(default_settings["draw_whitespace_tabs"].get_bool()) {
        flags |= Gsv::DRAW_SPACES_TAB;
    }

    view_.set_draw_spaces(flags);
    view_.set_highlight_current_line(default_settings["highlight_current_line"].get_bool());

    //Load any font setting overrides
    Pango::FontDescription fdesc;

    auto font_details = get_font_name_and_size_from_dconf();
    fdesc.set_family(font_details.first.encode());
    fdesc.set_size(font_details.second);

    if(default_settings.has_key("override_font_family")) {
        fdesc.set_family(default_settings["override_font_family"].get().encode());
    }

    if(default_settings.has_key("override_font_size")) {
        fdesc.set_size(default_settings["override_font_size"].get_number() * PANGO_SCALE);
    }

    view_.override_font(fdesc);
    current_settings_ = default_settings;
}
예제 #4
0
void ListNode::draw_text(const Cairo::RefPtr<Cairo::Context> & cr, int x, int y) {
	char * str = new char[10];
	sprintf(str, "%d", data);

	Pango::FontDescription font;
	font.set_family("Monospace");
	font.set_weight(Pango::WEIGHT_BOLD);
	Glib::RefPtr<Pango::Layout> layout = create_pango_layout(str);
	layout->set_font_description(font);
	int text_w, text_h;
	layout->get_pixel_size(text_w, text_h);
	cr->move_to(x + (field_w - text_w) / 2, y + (field_h - text_h) / 2);
	layout->show_in_cairo_context(cr);
}
예제 #5
0
bool GraficoDeTorta::dibujar(const Cairo::RefPtr<Cairo::Context>& contexto){
	Gdk::Rectangle rect = dibujo->get_allocation();
	Pango::FontDescription font;
	font.set_family("Monospace");
	font.set_weight(Pango::WEIGHT_BOLD);

	if(stock.size() == 0) return false;
	contexto->set_source_rgb(1.0,1.0,1.0);
	contexto->paint();	
	
	int total = 0;
	for(unsigned int i = 0; i < stock.size(); i++){
		total +=  stock[i].second;
	}
	float step = 2*M_PI/total;
	total = 0;
	

	float angulo0=0;
	for(unsigned int i = 0; i < stock.size(); i++){
		float angulo1 = step*stock[i].second + angulo0;
		dibujarArco(contexto,rect.get_width()/2-rect.get_width()/4,rect.get_height()/2,rect.get_width()<rect.get_height()?rect.get_width()/4:rect.get_height()/4,angulo0,angulo1,red[i],green[i],blue[i]);
		angulo0 = angulo1;
	}
	
	Glib::RefPtr<Pango::Layout> layout;
	std::stringstream s;
	for(unsigned int i = 0; i < stock.size(); i++){
		s.str("");
		s << stock[i].first << "\t" << stock[i].second;
		layout = dibujo->create_pango_layout(s.str());
		layout -> set_font_description(font);
		int t_width, t_height;
		layout->get_pixel_size(t_width,t_height);
		contexto->set_source_rgb(0,0,0);	
		contexto -> move_to((rect.get_width())/2,15*(i+1)+5);
		layout -> show_in_cairo_context(contexto);
		contexto -> set_source_rgb(red[i],green[i],blue[i]);
		contexto -> rectangle(rect.get_width()/2+80,15*(i+1)+5,30,15);
		contexto -> fill();
	}
	return true;
}
/**
	Constructor, it will create a new script in order to run
	run the selected script with the given parameters. It will create a temporary M file containing
	- The parameters needed
	- a cd command to go in the right directory
	- a call to the program
	- a final printf to warn that everything is done
	- a 'pause' call so that octave will close when we kill its process.
  
  and then runs the job scheduler on the server.
  
  \param basescript basename of the script (without .m)
  \param currentScript Descriptor of the script you want to launch
  \param p Vector of parameter
  \param session SSH session
*/
ScriptRemoteExecWindow::ScriptRemoteExecWindow(std::string basescript, ScriptDescriptor currentScript, std::vector<Parameter> p, ssh_session session) {
	set_title(currentScript.getName() + " [remote]");
	//set_position(Gtk::WIN_POS_CENTER);
	set_resizable(true);
  set_default_size(500,500);
  set_size_request(500,500);
  
  SSHSession = session;
	
	// Layout
	mainLayout = Gtk::manage(new Gtk::VBox());
	// TextView
	logTextView = Gtk::manage(new Gtk::TextView());
	logBuffer = Gtk::TextBuffer::create();
	logTextView->set_buffer(logBuffer);
	Pango::FontDescription fdesc;
	fdesc.set_family("monospace");
	fdesc.set_size(10 * PANGO_SCALE);
	logTextView->override_font(fdesc);
	logTextView->set_editable(false);
  
	// Buttons
	stopButton = Gtk::manage(new Gtk::Button(Gtk::Stock::OK));

	//Création d'un conteneur ayant des barres de défilement.
	scrolledWindow = Gtk::manage(new Gtk::ScrolledWindow());
	scrolledWindow->set_policy(Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC);
  scrolledWindow->add(*logTextView);
	
	mainLayout->add(*scrolledWindow);
	mainLayout->pack_end(*stopButton, Gtk::PACK_SHRINK);
	
	stopButton->signal_clicked().connect(sigc::mem_fun(*this, &ScriptRemoteExecWindow::stopScript));
	this->signal_hide().connect(sigc::mem_fun(*this, &ScriptRemoteExecWindow::stopScript));
	timer = Glib::signal_timeout().connect(sigc::mem_fun(*this, &ScriptRemoteExecWindow::onTimer), 1000);
	
	add(*mainLayout);
	
	show_all();
	
	// All will be put in an igafemtmp directory
	string base = random_string(10);
	string fname = "igafemtmp/" + base + "/script.m";
	string jname = "igafemtmp/" + base + "/job.sh";
	string xmlname = "igafemtmp/" + base + "/job.xml";
	
	string output = "igafemtmp/" + base + "/output";
	
	createDirectory("igafemtmp");
	createDirectory("igafemtmp/" + base);
	
	ostringstream out("");
	ostringstream sc("");//The script
	ostringstream job(""); //The job
	ostringstream xml(""); //The xml file
	
	xml << "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" << endl;
	xml << "<job>" << endl;
	xml << "\t<script>" << currentScript.getName() << "</script>" << endl;
	xml << "\t<desc>" << currentScript.getDescription() << "</desc>" << endl;
	xml << "\t<submitted>" << getTime() << "</submitted>" << endl;
	xml << "</job>" << endl;
	
	
	job << ""
	"#!/bin/bash --login" << endl << \
	"#BSUB -x                 # give this job exclusive access" << endl << \
	"#BSUB -n 1                         # give this job 1 core" << endl << \
	"#BSUB -o " << output << ".stdout          # put the output stream here" << endl << \
	"#BSUB -e " << output << ".stderr           # put the error stream here" << endl << \
	"#BSUB -J " << base << "                     # give the job a name" << endl << \
	"#BSUB -W 03:00     # run the job for no more than 3 hours" << endl << \
	"#BSUB -R \"span[ptile=12]\"       # fully populate the node" << endl << \
	"#BSUB -q q_cf_htc_work    # run on the cardiff htc system" << endl << \
	"" << endl << \
	"# Load the Environment" << endl << \
	"module purge                   # purge any loaded modules" << endl << \
	"module load lapack/3.4.2-gnu-4.6.2 octave # Loading octave" << endl << \
	"# Run the Program" << endl << \
	"octave ~/" << fname << endl;

	out << "---------------------------------------------" << endl;
	out << "> Exporting the variables to the script" << endl;
	out << "---------------------------------------------" << endl;
	out << "     Name             |          Value       " << endl;
	out << "---------------------------------------------" << endl;
	for(unsigned int i = 0; i < p.size(); i++) {
		out << setw(21) << right << p.at(i).name << right << " |" << setw(21) << p.at(i).value << endl;
	}
	out << "---------------------------------------------" << endl;
	sc << "clear all;" << endl;
	sc << "restoredefaultpath();" << endl;
	sc << "igaoutputroot = '" << executeRemoteCommand("echo -n $HOME") << "/igafemtmp/" << base << "'" << endl;
	//if(currentScript.getGeometryDirectory() != "")
		sc << "cd " + basescript + "/" + currentScript.getGeometryDirectory() << endl;
	if(currentScript.getGeometry() != "")
		sc << currentScript.getGeometry() << endl;
	sc << "cd " + basescript + "/" + currentScript.getDirectory() << endl;
	for(unsigned int i = 0; i < p.size(); i++) { // Export variables !
		sc << p.at(i).name << " = " << p.at(i).value << ";" << endl;
	}
	sc << currentScript.getName() << endl;
	sc << "printf('---------------------------------------------\\n')" << endl;
	sc << "printf('              SCRIPT HAS ENDED               \\n')" << endl;
	sc << "printf('---------------------------------------------\\n')" << endl;
		
	out << "> Writing the script file" << endl;
	createFile(fname, sc.str(), out);
	out << "> Writing the job file" << endl;
	createFile(jname, job.str(), out);
	out << "> Writing the XML job info file" << endl;
	createFile(xmlname, xml.str(), out);
	out << "---------------------------------------------" << endl;
	
	ostringstream cmd("");
	
	cmd << "source /etc/profile.d/lsf.sh && bsub < ";
	cmd << "igafemtmp/" + base + "/job.sh && mv ";
	cmd << "igafemtmp/" + base + "/job.sh ";
	cmd << "igafemtmp/" + base + "/jobSubmitted.sh;" << endl;
	
	out << executeRemoteCommand(cmd.str()) << endl;
	
	logBuffer->set_text(out.str());
	
	
}
예제 #7
0
void Gobby::ViewCommands::on_zoom_out()
{
	Pango::FontDescription desc = m_preferences.appearance.font;
	desc.set_size(desc.get_size() / PANGO_SCALE_LARGE);
	m_preferences.appearance.font = desc;
}
예제 #8
0
void SetFontSize(Pango::FontDescription& dsc, double sz)
{
    dsc.set_size(pango_units_from_double(sz));
}