Ejemplo n.º 1
0
static PyObject *
Editor_create_widget(Editor *self)
{
	ScintillaObject *sci;
	PyObject *pysci;

	if (self->editor == NULL)
		Py_RETURN_NONE;

	sci = editor_create_widget(self->editor);
	if (!sci)
		Py_RETURN_NONE;

	pysci = pygobject_new(G_OBJECT(sci));
	if (!pysci)
	{
		gtk_widget_destroy(GTK_WIDGET(sci));
		Py_RETURN_NONE;
	}

	return pysci;
}
Ejemplo n.º 2
0
static void set_editor(EditWindow *editwin, GeanyEditor *editor)
{
    editwin->editor = editor;

    /* first destroy any widget, otherwise its signals will have an
     * invalid document as user_data */
    if (editwin->sci != NULL)
        gtk_widget_destroy(GTK_WIDGET(editwin->sci));

    editwin->sci = editor_create_widget(editor);
    gtk_widget_show(GTK_WIDGET(editwin->sci));
    gtk_box_pack_start(GTK_BOX(editwin->vbox), GTK_WIDGET(editwin->sci), TRUE, TRUE, 0);

    sync_to_current(editwin->sci, editor->sci);

    scintilla_send_message(editwin->sci, SCI_USEPOPUP, 1, 0);
    /* for margin events */
    g_signal_connect(editwin->sci, "sci-notify",
                     G_CALLBACK(on_sci_notify), NULL);

    gtk_label_set_text(GTK_LABEL(editwin->name_label), DOC_FILENAME(editor->document));
}
Ejemplo n.º 3
0
static void begin_print(GtkPrintOperation *operation, GtkPrintContext *context, gpointer user_data)
{
	DocInfo *dinfo = user_data;
	PangoFontDescription *desc;

	if (dinfo == NULL)
		return;

	gtk_widget_show(main_widgets.progressbar);

	/* init dinfo fields */

	/* setup printing scintilla object */
	dinfo->sci = editor_create_widget(dinfo->doc->editor);
	scintilla_send_message(dinfo->sci, SCI_SETDOCPOINTER, 0,
			scintilla_send_message(dinfo->doc->editor->sci, SCI_GETDOCPOINTER, 0, 0));
	highlighting_set_styles(dinfo->sci, dinfo->doc->file_type);
	sci_set_line_numbers(dinfo->sci, printing_prefs.print_line_numbers, 0);
	scintilla_send_message(dinfo->sci, SCI_SETVIEWWS, SCWS_INVISIBLE, 0);
	scintilla_send_message(dinfo->sci, SCI_SETVIEWEOL, FALSE, 0);
	scintilla_send_message(dinfo->sci, SCI_SETEDGEMODE, EDGE_NONE, 0);
	scintilla_send_message(dinfo->sci, SCI_SETPRINTMAGNIFICATION, (uptr_t) -2, 0); /* WTF? */
	scintilla_send_message(dinfo->sci, SCI_SETPRINTCOLOURMODE, SC_PRINT_COLOURONWHITE, 0);

	dinfo->pages = g_array_new(FALSE, FALSE, sizeof(gint));

	dinfo->print_time = time(NULL);
	/* create a PangoLayout to be commonly used in add_page_header() and draw_page() */
	desc = pango_font_description_from_string(interface_prefs.editor_font);
	dinfo->layout = setup_pango_layout(context, desc);
	pango_font_description_free(desc);
	get_text_dimensions(dinfo->layout, "|XMfjgq_" /* reasonably representative character set */,
		NULL, &dinfo->line_height);
	get_text_dimensions(dinfo->layout, "99999 " /* Scintilla resets the margin to the width of "99999" when printing */,
		&dinfo->margin_width, NULL);
	/* setup dinfo->fr */
	setup_range(dinfo, context);
}