示例#1
0
static gboolean on_editor_notify(GObject *geany_object, GeanyEditor *editor, SCNotification *nt, SignalManager *man)
{
	gboolean res = FALSE;
	PyObject *py_ed, *py_notif;
	py_ed = (PyObject *) Editor_create_new_from_geany_editor(editor);
	py_notif = (PyObject *) Notification_create_new_from_scintilla_notification(nt);
	g_signal_emit_by_name(man->obj, "editor-notify", py_ed, py_notif, &res);
	Py_XDECREF(py_ed);
	Py_XDECREF(py_notif);
	return res;
}
示例#2
0
static PyObject *
Document_get_property(Document *self, const gchar *prop_name)
{
	g_return_val_if_fail(self != NULL, NULL);
	g_return_val_if_fail(prop_name != NULL, NULL);

	if (!self->doc)
	{
		PyErr_SetString(PyExc_RuntimeError,
			"Document instance not initialized properly");
		return NULL;
	}

	if (!DOC_VALID(self->doc))
	{
		PyErr_SetString(PyExc_RuntimeError, "Document is invalid");
		return NULL;
	}

	if (g_str_equal(prop_name, "basename_for_display"))
	{
		PyObject *py_str = NULL;
		gchar *res_string;
		res_string = document_get_basename_for_display(self->doc, -1);
		if (!res_string)
		{
			PyErr_SetString(PyExc_RuntimeError,
				"Geany API failed to return a string");
			Py_RETURN_NONE;
		}
		py_str = PyString_FromString(res_string);
		g_free(res_string);
		return py_str;
	}
	else if (g_str_equal(prop_name, "notebook_page"))
		return Py_BuildValue("i", document_get_notebook_page(self->doc));
	else if (g_str_equal(prop_name, "status_color"))
	{
		const GdkColor *color = document_get_status_color(self->doc);
		if (!color)
			Py_RETURN_NONE;
		return Py_BuildValue("iii", color->red, color->green, color->blue);
	}
	else if (g_str_equal(prop_name, "editor")  && self->doc->editor)
	{
		Editor *editor;
		if (self->doc->editor != NULL)
		{
			editor = Editor_create_new_from_geany_editor(self->doc->editor);
			return (PyObject *) editor;
		}
		Py_RETURN_NONE;
	}
	else if (g_str_equal(prop_name, "encoding") && self->doc->encoding)
		return PyString_FromString(self->doc->encoding);
	else if (g_str_equal(prop_name, "file_name") && self->doc->file_name)
		return PyString_FromString(self->doc->file_name);
	else if (g_str_equal(prop_name, "file_type") && self->doc->file_type)
		return (PyObject *) Filetype_create_new_from_geany_filetype(self->doc->file_type);
	else if (g_str_equal(prop_name, "has_bom"))
	{
		if (self->doc->has_bom)
			Py_RETURN_TRUE;
		else
			Py_RETURN_FALSE;
	}
	else if (g_str_equal(prop_name, "has_tags"))
	{
		if (self->doc->has_tags)
			Py_RETURN_TRUE;
		else
			Py_RETURN_FALSE;
	}
	else if (g_str_equal(prop_name, "index"))
		return Py_BuildValue("i", self->doc->index);
	else if (g_str_equal(prop_name, "is_valid"))
	{
		if (self->doc->is_valid)
			Py_RETURN_TRUE;
		else
			Py_RETURN_FALSE;
	}
	else if (g_str_equal(prop_name, "readonly"))
	{
		if (self->doc->readonly)
			Py_RETURN_TRUE;
		else
			Py_RETURN_FALSE;
	}
	else if (g_str_equal(prop_name, "real_path"))
	{
		if (self->doc->real_path)
			return PyString_FromString(self->doc->real_path);
		Py_RETURN_NONE;
	}
	else if (g_str_equal(prop_name, "text_changed"))
	{
		if (self->doc->changed)
			Py_RETURN_NONE;
		else
			Py_RETURN_NONE;
	}
}