コード例 #1
0
void open_file(gchar *utf8_name)
{
	gchar *name;
	GeanyDocument *doc;

	name = utils_get_locale_from_utf8(utf8_name);
	doc = document_find_by_filename(utf8_name);

	if (!doc)
		doc = document_open_file(name, FALSE, NULL, NULL);
	else
	{
		gtk_notebook_set_current_page(GTK_NOTEBOOK(geany->main_widgets->notebook),
			document_get_notebook_page(doc));
	}
	
	if (doc)
		gtk_widget_grab_focus(GTK_WIDGET(doc->editor->sci));

	g_free(name);
}
コード例 #2
0
static void
on_view_row_activated (GtkTreeView       *view,
                       GtkTreePath       *path,
                       GtkTreeViewColumn *column,
                       gpointer           dummy)
{
  GtkTreeModel *model = gtk_tree_view_get_model (view);
  GtkTreeIter   iter;
  
  if (gtk_tree_model_get_iter (model, &iter, path)) {
    gint type;
    
    gtk_tree_model_get (model, &iter, COL_TYPE, &type, -1);
    
    switch (type) {
      case COL_TYPE_FILE: {
        GeanyDocument  *doc;
        gint            page;
        
        gtk_tree_model_get (model, &iter, COL_DOCUMENT, &doc, -1);
        page = document_get_notebook_page (doc);
        gtk_notebook_set_current_page (GTK_NOTEBOOK (geany_data->main_widgets->notebook),
                                       page);
        break;
      }
      
      case COL_TYPE_MENU_ITEM: {
        GtkMenuItem *item;
        
        gtk_tree_model_get (model, &iter, COL_WIDGET, &item, -1);
        gtk_menu_item_activate (item);
        g_object_unref (item);
        
        break;
      }
    }
    gtk_widget_hide (plugin_data.panel);
  }
}
コード例 #3
0
ファイル: document.c プロジェクト: ndbroadbent/geanypy
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;
	}
}