/* name should be in UTF-8, and can have a path. */ static void show_output(const gchar * std_output, const gchar * name, const gchar * force_encoding, gint filetype_new_file) { gint page; GtkNotebook *book; GeanyDocument *doc, *cur_doc; if (std_output) { cur_doc = document_get_current(); doc = document_find_by_filename(name); if (doc == NULL) { doc = document_new_file(name, filetypes[filetype_new_file], std_output); } else { sci_set_text(doc->editor->sci, std_output); book = GTK_NOTEBOOK(geany->main_widgets->notebook); page = gtk_notebook_page_num(book, GTK_WIDGET(doc->editor->sci)); gtk_notebook_set_current_page(book, page); } document_set_text_changed(doc, FALSE); document_set_encoding(doc, (force_encoding ? force_encoding : "UTF-8")); navqueue_goto_line(cur_doc, document_get_current(), 1); } else { ui_set_statusbar(FALSE, _("Could not parse the output of command")); } }
static int Document_set_property(Document *self, PyObject *value, const gchar *prop_name) { g_return_val_if_fail(self != NULL, -1); g_return_val_if_fail(value != NULL, -1); g_return_val_if_fail(prop_name != NULL, -1); if (!self->doc) { PyErr_SetString(PyExc_RuntimeError, "Document instance not initialized properly"); return -1; } if (g_str_equal(prop_name, "encoding")) { gchar *encoding = PyString_AsString(value); if (encoding) { document_set_encoding(self->doc, encoding); return 0; } } else if (g_str_equal(prop_name, "filetype")) { Filetype *filetype = (Filetype *) value; if (filetype->ft) { document_set_filetype(self->doc, filetype->ft); return 0; } } else if (g_str_equal(prop_name, "text_changed")) { long v = PyInt_AsLong(value); if (v == -1 && PyErr_Occurred()) { PyErr_Print(); return -1; } document_set_text_changed(self->doc, (gboolean) v); return 0; } PyErr_SetString(PyExc_AttributeError, "can't set property"); return -1; }
static void encodings_radio_item_change_cb(GtkCheckMenuItem *menuitem, gpointer user_data) { GeanyDocument *doc = document_get_current(); guint i = GPOINTER_TO_INT(user_data); if (ignore_callback || doc == NULL || encodings[i].charset == NULL || ! gtk_check_menu_item_get_active(menuitem) || utils_str_equal(encodings[i].charset, doc->encoding)) return; if (doc->readonly) { utils_beep(); return; } document_undo_add(doc, UNDO_ENCODING, g_strdup(doc->encoding)); document_set_encoding(doc, encodings[i].charset); }