Added back moo_editor_create_doc() for embedded editor users
This commit is contained in:
parent
2ccf2904c2
commit
f994764467
@ -518,6 +518,8 @@ _moo_editor_get_file_watch (MooEditor *editor)
|
|||||||
/**
|
/**
|
||||||
* moo_editor_create_instance: (static-method-of MooEditor) (moo.lua 0)
|
* moo_editor_create_instance: (static-method-of MooEditor) (moo.lua 0)
|
||||||
*
|
*
|
||||||
|
* @embedded: (default TRUE):
|
||||||
|
*
|
||||||
* Returns: (transfer full)
|
* Returns: (transfer full)
|
||||||
*/
|
*/
|
||||||
MooEditor *
|
MooEditor *
|
||||||
@ -2231,6 +2233,53 @@ moo_editor_open_path (MooEditor *editor,
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* moo_editor_create_doc: (moo.lua 0)
|
||||||
|
*
|
||||||
|
* @editor:
|
||||||
|
* @filename: (type const-filename) (allow-none) (default NULL)
|
||||||
|
* @encoding: (type const-utf8) (allow-none) (default NULL)
|
||||||
|
* @error:
|
||||||
|
*
|
||||||
|
* Create a document instance which can be embedded into arbitrary
|
||||||
|
* widget.
|
||||||
|
*
|
||||||
|
* This method may not be used in medit (use moo_editor_new_doc(),
|
||||||
|
* moo_editor_new_file(), moo_editor_open_file(), moo_editor_open_files(),
|
||||||
|
* moo_editor_open_uri(), moo_editor_open_path() instead).
|
||||||
|
*/
|
||||||
|
MooEdit *
|
||||||
|
moo_editor_create_doc (MooEditor *editor,
|
||||||
|
const char *filename,
|
||||||
|
const char *encoding,
|
||||||
|
GError **error)
|
||||||
|
{
|
||||||
|
MooEdit *doc;
|
||||||
|
MooEditView *view;
|
||||||
|
GFile *file = NULL;
|
||||||
|
|
||||||
|
moo_return_error_if_fail_p (MOO_IS_EDITOR (editor));
|
||||||
|
|
||||||
|
if (filename)
|
||||||
|
file = g_file_new_for_path (filename);
|
||||||
|
|
||||||
|
doc = g_object_new (get_doc_type (editor), "editor", editor, (const char*) NULL);
|
||||||
|
view = moo_edit_get_view (doc);
|
||||||
|
|
||||||
|
if (file == NULL || _moo_edit_load_file (doc, file, encoding, NULL, error))
|
||||||
|
{
|
||||||
|
moo_editor_add_doc (editor, NULL, doc);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
g_object_unref (doc);
|
||||||
|
doc = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
moo_file_free (file);
|
||||||
|
return doc;
|
||||||
|
}
|
||||||
|
|
||||||
// MooEdit *
|
// MooEdit *
|
||||||
// moo_editor_open_file (MooEditor *editor,
|
// moo_editor_open_file (MooEditor *editor,
|
||||||
// MooEditWindow *window,
|
// MooEditWindow *window,
|
||||||
|
@ -88,6 +88,10 @@ MooEditor *moo_editor_create_instance (gboolean emb
|
|||||||
MooEditWindow *moo_editor_new_window (MooEditor *editor);
|
MooEditWindow *moo_editor_new_window (MooEditor *editor);
|
||||||
MooEdit *moo_editor_new_doc (MooEditor *editor,
|
MooEdit *moo_editor_new_doc (MooEditor *editor,
|
||||||
MooEditWindow *window);
|
MooEditWindow *window);
|
||||||
|
MooEdit *moo_editor_create_doc (MooEditor *editor,
|
||||||
|
const char *path,
|
||||||
|
const char *encoding,
|
||||||
|
GError **error);
|
||||||
|
|
||||||
MooEdit *moo_editor_new_file (MooEditor *editor,
|
MooEdit *moo_editor_new_file (MooEditor *editor,
|
||||||
MooOpenInfo *info,
|
MooOpenInfo *info,
|
||||||
|
@ -146,7 +146,9 @@ moo_edit_view_focus_in (GtkWidget *widget,
|
|||||||
retval = GTK_WIDGET_CLASS (moo_edit_view_parent_class)->focus_in_event (widget, event);
|
retval = GTK_WIDGET_CLASS (moo_edit_view_parent_class)->focus_in_event (widget, event);
|
||||||
|
|
||||||
_moo_edit_set_active_view (view->priv->doc, view);
|
_moo_edit_set_active_view (view->priv->doc, view);
|
||||||
_moo_edit_tab_set_focused_view (moo_edit_view_get_tab (view), view);
|
|
||||||
|
if (view->priv->tab)
|
||||||
|
_moo_edit_tab_set_focused_view (view->priv->tab, view);
|
||||||
|
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user