r1267@localhost: muntyan | 2005-12-04 08:13:31 -0600
Made api more pida-friendly
This commit is contained in:
parent
e20f0ef89e
commit
fbf7a49554
@ -1166,14 +1166,15 @@ moo_app_run_real (MooApp *app)
|
||||
}
|
||||
|
||||
|
||||
static gboolean moo_app_try_quit_real (MooApp *app)
|
||||
static gboolean
|
||||
moo_app_try_quit_real (MooApp *app)
|
||||
{
|
||||
GSList *l, *list;
|
||||
|
||||
if (!app->priv->running)
|
||||
return FALSE;
|
||||
|
||||
if (!moo_editor_close_all (app->priv->editor))
|
||||
if (!moo_editor_close_all (app->priv->editor, TRUE))
|
||||
return TRUE;
|
||||
|
||||
list = g_slist_copy (app->priv->terminals);
|
||||
@ -1232,7 +1233,7 @@ static void moo_app_quit_real (MooApp *app)
|
||||
app->priv->terminals = NULL;
|
||||
app->priv->term_window = NULL;
|
||||
|
||||
moo_editor_close_all (app->priv->editor);
|
||||
moo_editor_close_all (app->priv->editor, TRUE);
|
||||
g_object_unref (app->priv->editor);
|
||||
app->priv->editor = NULL;
|
||||
|
||||
|
@ -935,20 +935,31 @@ moo_edit_filename_changed (MooEdit *edit,
|
||||
|
||||
|
||||
gboolean
|
||||
moo_edit_save (MooEdit *edit)
|
||||
moo_edit_close (MooEdit *edit,
|
||||
gboolean ask_confirm)
|
||||
{
|
||||
g_return_val_if_fail (MOO_IS_EDIT (edit), FALSE);
|
||||
return _moo_editor_save (edit->priv->editor, edit);
|
||||
return moo_editor_close_doc (edit->priv->editor, edit, ask_confirm);
|
||||
}
|
||||
|
||||
|
||||
gboolean
|
||||
moo_edit_save (MooEdit *edit,
|
||||
GError **error)
|
||||
{
|
||||
g_return_val_if_fail (MOO_IS_EDIT (edit), FALSE);
|
||||
return _moo_editor_save (edit->priv->editor, edit, error);
|
||||
}
|
||||
|
||||
|
||||
gboolean
|
||||
moo_edit_save_as (MooEdit *edit,
|
||||
const char *filename,
|
||||
const char *encoding)
|
||||
const char *encoding,
|
||||
GError **error)
|
||||
{
|
||||
g_return_val_if_fail (MOO_IS_EDIT (edit), FALSE);
|
||||
return _moo_editor_save_as (edit->priv->editor, edit, filename, encoding);
|
||||
return _moo_editor_save_as (edit->priv->editor, edit, filename, encoding, error);
|
||||
}
|
||||
|
||||
|
||||
|
@ -168,10 +168,14 @@ void moo_edit_register_var (GParamSpec *pspec);
|
||||
void moo_edit_register_var_alias (const char *name,
|
||||
const char *alias);
|
||||
|
||||
gboolean moo_edit_save (MooEdit *edit);
|
||||
gboolean moo_edit_close (MooEdit *edit,
|
||||
gboolean ask_confirm);
|
||||
gboolean moo_edit_save (MooEdit *edit,
|
||||
GError **error);
|
||||
gboolean moo_edit_save_as (MooEdit *edit,
|
||||
const char *filename,
|
||||
const char *encoding);
|
||||
const char *encoding,
|
||||
GError **error);
|
||||
gboolean moo_edit_save_copy (MooEdit *edit,
|
||||
const char *filename,
|
||||
const char *encoding,
|
||||
|
@ -74,7 +74,8 @@ static void do_close_window (MooEditor *editor,
|
||||
static void do_close_doc (MooEditor *editor,
|
||||
MooEdit *doc);
|
||||
static gboolean close_docs_real (MooEditor *editor,
|
||||
GSList *docs);
|
||||
GSList *docs,
|
||||
gboolean ask_confirm);
|
||||
static GSList *find_modified (GSList *docs);
|
||||
static MooEditLoader*get_loader (MooEditor *editor,
|
||||
MooEdit *doc);
|
||||
@ -103,6 +104,7 @@ struct _MooEditorPrivate {
|
||||
|
||||
gboolean save_backups;
|
||||
gboolean strip_whitespace;
|
||||
gboolean silent;
|
||||
|
||||
GType window_type;
|
||||
GType doc_type;
|
||||
@ -128,7 +130,8 @@ enum {
|
||||
PROP_ALLOW_EMPTY_WINDOW,
|
||||
PROP_SINGLE_WINDOW,
|
||||
PROP_SAVE_BACKUPS,
|
||||
PROP_STRIP_WHITESPACE
|
||||
PROP_STRIP_WHITESPACE,
|
||||
PROP_SILENT
|
||||
};
|
||||
|
||||
enum {
|
||||
@ -192,6 +195,14 @@ static void moo_editor_class_init (MooEditorClass *klass)
|
||||
FALSE,
|
||||
G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
|
||||
|
||||
g_object_class_install_property (gobject_class,
|
||||
PROP_SILENT,
|
||||
g_param_spec_boolean ("silent",
|
||||
"silent",
|
||||
"silent",
|
||||
FALSE,
|
||||
G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
|
||||
|
||||
signals[ALL_WINDOWS_CLOSED] =
|
||||
moo_signal_new_cb ("all-windows-closed",
|
||||
G_OBJECT_CLASS_TYPE (klass),
|
||||
@ -266,6 +277,11 @@ static void moo_editor_set_property (GObject *object,
|
||||
g_object_notify (object, "strip-whitespace");
|
||||
break;
|
||||
|
||||
case PROP_SILENT:
|
||||
editor->priv->silent = g_value_get_boolean (value);
|
||||
g_object_notify (object, "silent");
|
||||
break;
|
||||
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||
break;
|
||||
@ -301,6 +317,10 @@ static void moo_editor_get_property (GObject *object,
|
||||
g_value_set_boolean (value, editor->priv->strip_whitespace);
|
||||
break;
|
||||
|
||||
case PROP_SILENT:
|
||||
g_value_set_boolean (value, editor->priv->silent);
|
||||
break;
|
||||
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||
break;
|
||||
@ -799,17 +819,29 @@ moo_editor_new_window (MooEditor *editor)
|
||||
|
||||
/* this creates MooEdit instance which can not be put into a window */
|
||||
MooEdit*
|
||||
moo_editor_create_doc (MooEditor *editor)
|
||||
moo_editor_create_doc (MooEditor *editor,
|
||||
const char *filename,
|
||||
const char *encoding,
|
||||
GError **error)
|
||||
{
|
||||
MooEdit *doc;
|
||||
MooEditLoader *loader;
|
||||
MooEditSaver *saver;
|
||||
|
||||
g_return_val_if_fail (MOO_IS_EDITOR (editor), NULL);
|
||||
|
||||
doc = g_object_new (get_doc_type (editor), "editor", editor, NULL);
|
||||
loader = moo_edit_loader_get_default ();
|
||||
saver = moo_edit_saver_get_default ();
|
||||
|
||||
moo_editor_add_doc (editor, NULL, doc,
|
||||
moo_edit_loader_get_default (),
|
||||
moo_edit_saver_get_default ());
|
||||
if (filename && !moo_edit_loader_load (loader, doc, filename, encoding, error))
|
||||
{
|
||||
gtk_object_sink (g_object_ref (doc));
|
||||
g_object_unref (doc);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
moo_editor_add_doc (editor, NULL, doc, loader, saver);
|
||||
_moo_doc_attach_plugins (NULL, doc);
|
||||
|
||||
return doc;
|
||||
@ -1026,7 +1058,8 @@ moo_editor_set_active_doc (MooEditor *editor,
|
||||
|
||||
gboolean
|
||||
moo_editor_close_window (MooEditor *editor,
|
||||
MooEditWindow *window)
|
||||
MooEditWindow *window,
|
||||
gboolean ask_confirm)
|
||||
{
|
||||
WindowInfo *info;
|
||||
MooEditDialogResponse response;
|
||||
@ -1041,7 +1074,7 @@ moo_editor_close_window (MooEditor *editor,
|
||||
|
||||
modified = find_modified (info->docs);
|
||||
|
||||
if (!modified)
|
||||
if (!modified || !ask_confirm)
|
||||
{
|
||||
do_close = TRUE;
|
||||
}
|
||||
@ -1055,7 +1088,7 @@ moo_editor_close_window (MooEditor *editor,
|
||||
switch (response)
|
||||
{
|
||||
case MOO_EDIT_RESPONSE_SAVE:
|
||||
if (_moo_editor_save (editor, modified->data))
|
||||
if (_moo_editor_save (editor, modified->data, NULL))
|
||||
do_close = TRUE;
|
||||
break;
|
||||
|
||||
@ -1078,7 +1111,7 @@ moo_editor_close_window (MooEditor *editor,
|
||||
{
|
||||
case MOO_EDIT_RESPONSE_SAVE:
|
||||
for (l = to_save; l != NULL; l = l->next)
|
||||
if (!_moo_editor_save (editor, l->data))
|
||||
if (!_moo_editor_save (editor, l->data, NULL))
|
||||
{
|
||||
saved = FALSE;
|
||||
break;
|
||||
@ -1154,13 +1187,14 @@ do_close_doc (MooEditor *editor,
|
||||
|
||||
gboolean
|
||||
moo_editor_close_doc (MooEditor *editor,
|
||||
MooEdit *doc)
|
||||
MooEdit *doc,
|
||||
gboolean ask_confirm)
|
||||
{
|
||||
gboolean result;
|
||||
GSList *list;
|
||||
|
||||
list = g_slist_prepend (NULL, doc);
|
||||
result = moo_editor_close_docs (editor, list);
|
||||
result = moo_editor_close_docs (editor, list, ask_confirm);
|
||||
|
||||
g_slist_free (list);
|
||||
return result;
|
||||
@ -1169,7 +1203,8 @@ moo_editor_close_doc (MooEditor *editor,
|
||||
|
||||
gboolean
|
||||
moo_editor_close_docs (MooEditor *editor,
|
||||
GSList *list)
|
||||
GSList *list,
|
||||
gboolean ask_confirm)
|
||||
{
|
||||
WindowInfo *info;
|
||||
GSList *l;
|
||||
@ -1188,7 +1223,7 @@ moo_editor_close_docs (MooEditor *editor,
|
||||
info = window_list_find_doc (editor, list->data);
|
||||
g_return_val_if_fail (info != NULL, FALSE);
|
||||
|
||||
if (close_docs_real (editor, list))
|
||||
if (close_docs_real (editor, list, ask_confirm))
|
||||
{
|
||||
if (info->window &&
|
||||
!moo_edit_window_num_docs (info->window) &&
|
||||
@ -1213,7 +1248,8 @@ moo_editor_close_docs (MooEditor *editor,
|
||||
|
||||
static gboolean
|
||||
close_docs_real (MooEditor *editor,
|
||||
GSList *docs)
|
||||
GSList *docs,
|
||||
gboolean ask_confirm)
|
||||
{
|
||||
MooEditDialogResponse response;
|
||||
GSList *modified, *l;
|
||||
@ -1221,7 +1257,7 @@ close_docs_real (MooEditor *editor,
|
||||
|
||||
modified = find_modified (docs);
|
||||
|
||||
if (!modified)
|
||||
if (!modified || !ask_confirm)
|
||||
{
|
||||
do_close = TRUE;
|
||||
}
|
||||
@ -1238,7 +1274,7 @@ close_docs_real (MooEditor *editor,
|
||||
switch (response)
|
||||
{
|
||||
case MOO_EDIT_RESPONSE_SAVE:
|
||||
if (_moo_editor_save (editor, modified->data))
|
||||
if (_moo_editor_save (editor, modified->data, NULL))
|
||||
do_close = TRUE;
|
||||
break;
|
||||
|
||||
@ -1261,7 +1297,7 @@ close_docs_real (MooEditor *editor,
|
||||
{
|
||||
case MOO_EDIT_RESPONSE_SAVE:
|
||||
for (l = to_save; l != NULL; l = l->next)
|
||||
if (!_moo_editor_save (editor, l->data))
|
||||
if (!_moo_editor_save (editor, l->data, NULL))
|
||||
{
|
||||
saved = FALSE;
|
||||
break;
|
||||
@ -1303,7 +1339,8 @@ find_modified (GSList *docs)
|
||||
|
||||
|
||||
gboolean
|
||||
moo_editor_close_all (MooEditor *editor)
|
||||
moo_editor_close_all (MooEditor *editor,
|
||||
gboolean ask_confirm)
|
||||
{
|
||||
GSList *windows, *l;
|
||||
|
||||
@ -1313,7 +1350,7 @@ moo_editor_close_all (MooEditor *editor)
|
||||
|
||||
for (l = windows; l != NULL; l = l->next)
|
||||
{
|
||||
if (!moo_editor_close_window (editor, l->data))
|
||||
if (!moo_editor_close_window (editor, l->data, ask_confirm))
|
||||
{
|
||||
g_slist_free (windows);
|
||||
return FALSE;
|
||||
@ -1403,11 +1440,12 @@ moo_editor_open_uri (MooEditor *editor,
|
||||
|
||||
void
|
||||
_moo_editor_reload (MooEditor *editor,
|
||||
MooEdit *doc)
|
||||
MooEdit *doc,
|
||||
GError **error)
|
||||
{
|
||||
WindowInfo *info;
|
||||
MooEditLoader *loader;
|
||||
GError *error = NULL;
|
||||
GError *error_here = NULL;
|
||||
int cursor_line, cursor_offset;
|
||||
GtkTextIter iter;
|
||||
|
||||
@ -1422,20 +1460,23 @@ _moo_editor_reload (MooEditor *editor,
|
||||
/* XXX */
|
||||
g_return_if_fail (moo_edit_get_filename (doc) != NULL);
|
||||
|
||||
if (!MOO_EDIT_IS_CLEAN (doc) && MOO_EDIT_IS_MODIFIED (doc) &&
|
||||
if (!editor->priv->silent &&
|
||||
!MOO_EDIT_IS_CLEAN (doc) &&
|
||||
MOO_EDIT_IS_MODIFIED (doc) &&
|
||||
!moo_edit_reload_modified_dialog (doc))
|
||||
return;
|
||||
return;
|
||||
|
||||
moo_text_view_get_cursor (MOO_TEXT_VIEW (doc), &iter);
|
||||
cursor_line = gtk_text_iter_get_line (&iter);
|
||||
cursor_offset = gtk_text_iter_get_line_offset (&iter);
|
||||
|
||||
if (!moo_edit_loader_reload (loader, doc, &error))
|
||||
if (!moo_edit_loader_reload (loader, doc, &error_here))
|
||||
{
|
||||
moo_edit_reload_error_dialog (GTK_WIDGET (doc),
|
||||
error ? error->message : NULL);
|
||||
if (error)
|
||||
g_error_free (error);
|
||||
if (!editor->priv->silent)
|
||||
moo_edit_reload_error_dialog (GTK_WIDGET (doc), error_here->message);
|
||||
else
|
||||
g_propagate_error (error, error_here);
|
||||
|
||||
g_object_set_data (G_OBJECT (doc), "moo-scroll-to", NULL);
|
||||
return;
|
||||
}
|
||||
@ -1484,11 +1525,12 @@ do_save (MooEditor *editor,
|
||||
|
||||
gboolean
|
||||
_moo_editor_save (MooEditor *editor,
|
||||
MooEdit *doc)
|
||||
MooEdit *doc,
|
||||
GError **error)
|
||||
{
|
||||
WindowInfo *info;
|
||||
MooEditSaver *saver;
|
||||
GError *error = NULL;
|
||||
GError *error_here = NULL;
|
||||
char *filename;
|
||||
char *encoding;
|
||||
gboolean result = FALSE;
|
||||
@ -1502,21 +1544,29 @@ _moo_editor_save (MooEditor *editor,
|
||||
g_return_val_if_fail (saver != NULL, FALSE);
|
||||
|
||||
if (!moo_edit_get_filename (doc))
|
||||
return _moo_editor_save_as (editor, doc, NULL, NULL);
|
||||
return _moo_editor_save_as (editor, doc, NULL, NULL, error);
|
||||
|
||||
filename = g_strdup (moo_edit_get_filename (doc));
|
||||
encoding = g_strdup (moo_edit_get_encoding (doc));
|
||||
|
||||
if ((moo_edit_get_status (doc) & MOO_EDIT_MODIFIED_ON_DISK) &&
|
||||
if (!editor->priv->silent &&
|
||||
(moo_edit_get_status (doc) & MOO_EDIT_MODIFIED_ON_DISK) &&
|
||||
!moo_edit_overwrite_modified_dialog (doc))
|
||||
goto out;
|
||||
|
||||
if (!do_save (editor, saver, doc, filename, encoding, &error))
|
||||
if (!do_save (editor, saver, doc, filename, encoding, &error_here))
|
||||
{
|
||||
moo_edit_save_error_dialog (GTK_WIDGET (doc), filename,
|
||||
error ? error->message : NULL);
|
||||
if (error)
|
||||
g_error_free (error);
|
||||
if (!editor->priv->silent)
|
||||
{
|
||||
moo_edit_save_error_dialog (GTK_WIDGET (doc), filename,
|
||||
error_here->message);
|
||||
g_error_free (error_here);
|
||||
}
|
||||
else
|
||||
{
|
||||
g_propagate_error (error, error_here);
|
||||
}
|
||||
|
||||
goto out;
|
||||
}
|
||||
|
||||
@ -1535,11 +1585,12 @@ gboolean
|
||||
_moo_editor_save_as (MooEditor *editor,
|
||||
MooEdit *doc,
|
||||
const char *filename,
|
||||
const char *encoding)
|
||||
const char *encoding,
|
||||
GError **error)
|
||||
{
|
||||
WindowInfo *info;
|
||||
MooEditSaver *saver;
|
||||
GError *error = NULL;
|
||||
GError *error_here = NULL;
|
||||
MooEditFileInfo *file_info = NULL;
|
||||
gboolean result = FALSE;
|
||||
|
||||
@ -1563,12 +1614,20 @@ _moo_editor_save_as (MooEditor *editor,
|
||||
file_info = moo_edit_file_info_new (filename, encoding);
|
||||
}
|
||||
|
||||
if (!do_save (editor, saver, doc, file_info->filename, file_info->encoding, &error))
|
||||
if (!do_save (editor, saver, doc, file_info->filename, file_info->encoding, &error_here))
|
||||
{
|
||||
moo_edit_save_error_dialog (GTK_WIDGET (doc), file_info->filename,
|
||||
error ? error->message : NULL);
|
||||
if (error)
|
||||
g_error_free (error);
|
||||
if (!editor->priv->silent)
|
||||
{
|
||||
moo_edit_save_error_dialog (GTK_WIDGET (doc),
|
||||
file_info->filename,
|
||||
error_here->message);
|
||||
g_error_free (error_here);
|
||||
}
|
||||
else
|
||||
{
|
||||
g_propagate_error (error, error_here);
|
||||
}
|
||||
|
||||
goto out;
|
||||
}
|
||||
|
||||
|
@ -52,7 +52,10 @@ GType moo_editor_get_type (void) G_GNUC_CONST;
|
||||
MooEditor *moo_editor_instance (void);
|
||||
|
||||
/* this creates 'windowless' MooEdit instance */
|
||||
MooEdit *moo_editor_create_doc (MooEditor *editor);
|
||||
MooEdit *moo_editor_create_doc (MooEditor *editor,
|
||||
const char *filename,
|
||||
const char *encoding,
|
||||
GError **error);
|
||||
|
||||
MooEditWindow *moo_editor_new_window (MooEditor *editor);
|
||||
MooEdit *moo_editor_new_doc (MooEditor *editor,
|
||||
@ -89,12 +92,16 @@ void moo_editor_present (MooEditor *editor);
|
||||
GSList *moo_editor_list_windows (MooEditor *editor);
|
||||
|
||||
gboolean moo_editor_close_window (MooEditor *editor,
|
||||
MooEditWindow *window);
|
||||
MooEditWindow *window,
|
||||
gboolean ask_confirm);
|
||||
gboolean moo_editor_close_doc (MooEditor *editor,
|
||||
MooEdit *doc);
|
||||
MooEdit *doc,
|
||||
gboolean ask_confirm);
|
||||
gboolean moo_editor_close_docs (MooEditor *editor,
|
||||
GSList *list);
|
||||
gboolean moo_editor_close_all (MooEditor *editor);
|
||||
GSList *list,
|
||||
gboolean ask_confirm);
|
||||
gboolean moo_editor_close_all (MooEditor *editor,
|
||||
gboolean ask_confirm);
|
||||
|
||||
void moo_editor_set_app_name (MooEditor *editor,
|
||||
const char *name);
|
||||
@ -133,13 +140,16 @@ void _moo_edit_window_remove_doc (MooEditWindow *window,
|
||||
|
||||
gpointer _moo_editor_get_file_watch (MooEditor *editor);
|
||||
void _moo_editor_reload (MooEditor *editor,
|
||||
MooEdit *doc);
|
||||
MooEdit *doc,
|
||||
GError **error);
|
||||
gboolean _moo_editor_save (MooEditor *editor,
|
||||
MooEdit *doc);
|
||||
MooEdit *doc,
|
||||
GError **error);
|
||||
gboolean _moo_editor_save_as (MooEditor *editor,
|
||||
MooEdit *doc,
|
||||
const char *filename,
|
||||
const char *encoding);
|
||||
const char *encoding,
|
||||
GError **error);
|
||||
#endif /* MOOEDIT_COMPILATION */
|
||||
|
||||
|
||||
|
@ -800,7 +800,7 @@ apply_styles (MooEditWindow *window,
|
||||
|
||||
static gboolean moo_edit_window_close (MooEditWindow *window)
|
||||
{
|
||||
moo_editor_close_window (window->priv->editor, window);
|
||||
moo_editor_close_window (window->priv->editor, window, TRUE);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
@ -827,7 +827,7 @@ static void moo_edit_window_reload (MooEditWindow *window)
|
||||
{
|
||||
MooEdit *edit = moo_edit_window_get_active_doc (window);
|
||||
g_return_if_fail (edit != NULL);
|
||||
_moo_editor_reload (window->priv->editor, edit);
|
||||
_moo_editor_reload (window->priv->editor, edit, NULL);
|
||||
}
|
||||
|
||||
|
||||
@ -835,7 +835,7 @@ static void moo_edit_window_save (MooEditWindow *window)
|
||||
{
|
||||
MooEdit *edit = moo_edit_window_get_active_doc (window);
|
||||
g_return_if_fail (edit != NULL);
|
||||
_moo_editor_save (window->priv->editor, edit);
|
||||
_moo_editor_save (window->priv->editor, edit, NULL);
|
||||
}
|
||||
|
||||
|
||||
@ -843,7 +843,7 @@ static void moo_edit_window_save_as (MooEditWindow *window)
|
||||
{
|
||||
MooEdit *edit = moo_edit_window_get_active_doc (window);
|
||||
g_return_if_fail (edit != NULL);
|
||||
_moo_editor_save_as (window->priv->editor, edit, NULL, NULL);
|
||||
_moo_editor_save_as (window->priv->editor, edit, NULL, NULL, NULL);
|
||||
}
|
||||
|
||||
|
||||
@ -851,14 +851,14 @@ static void moo_edit_window_close_tab (MooEditWindow *window)
|
||||
{
|
||||
MooEdit *edit = moo_edit_window_get_active_doc (window);
|
||||
g_return_if_fail (edit != NULL);
|
||||
moo_editor_close_doc (window->priv->editor, edit);
|
||||
moo_editor_close_doc (window->priv->editor, edit, TRUE);
|
||||
}
|
||||
|
||||
|
||||
static void moo_edit_window_close_all (MooEditWindow *window)
|
||||
{
|
||||
GSList *docs = moo_edit_window_list_docs (window);
|
||||
moo_editor_close_docs (window->priv->editor, docs);
|
||||
moo_editor_close_docs (window->priv->editor, docs, TRUE);
|
||||
g_slist_free (docs);
|
||||
}
|
||||
|
||||
@ -1445,7 +1445,7 @@ static void close_activated (GtkWidget *item,
|
||||
MooEdit *edit = g_object_get_data (G_OBJECT (item), "moo-edit");
|
||||
g_return_if_fail (MOO_IS_EDIT_WINDOW (window));
|
||||
g_return_if_fail (MOO_IS_EDIT (edit));
|
||||
moo_editor_close_doc (window->priv->editor, edit);
|
||||
moo_editor_close_doc (window->priv->editor, edit, TRUE);
|
||||
}
|
||||
|
||||
|
||||
@ -1461,7 +1461,7 @@ static void close_others_activated (GtkWidget *item,
|
||||
list = moo_edit_window_list_docs (window);
|
||||
list = g_slist_remove (list, edit);
|
||||
|
||||
moo_editor_close_docs (window->priv->editor, list);
|
||||
moo_editor_close_docs (window->priv->editor, list, TRUE);
|
||||
|
||||
g_slist_free (list);
|
||||
}
|
||||
|
@ -722,7 +722,7 @@ drop_untitled (MooFileSelector *filesel,
|
||||
if (!name)
|
||||
return FALSE;
|
||||
|
||||
result = moo_edit_save_as (doc, name, NULL);
|
||||
result = moo_edit_save_as (doc, name, NULL, NULL);
|
||||
|
||||
if (result)
|
||||
select_file (filesel, name, destdir);
|
||||
@ -746,7 +746,7 @@ doc_save_as (MooFileSelector *filesel,
|
||||
|
||||
if (filename)
|
||||
{
|
||||
if (moo_edit_save_as (doc, filename, moo_edit_get_encoding (doc)))
|
||||
if (moo_edit_save_as (doc, filename, moo_edit_get_encoding (doc), NULL))
|
||||
select_file (filesel, filename, destdir);
|
||||
g_free (filename);
|
||||
}
|
||||
@ -788,7 +788,7 @@ doc_move (MooFileSelector *filesel,
|
||||
|
||||
if (filename)
|
||||
{
|
||||
if (moo_edit_save_as (doc, filename, moo_edit_get_encoding (doc)))
|
||||
if (moo_edit_save_as (doc, filename, moo_edit_get_encoding (doc), NULL))
|
||||
{
|
||||
moo_unlink (old_filename);
|
||||
select_file (filesel, filename, destdir);
|
||||
|
@ -1,4 +1,18 @@
|
||||
"""moo.edit module"""
|
||||
"""moo.edit module
|
||||
|
||||
Contains text editor and stuff.
|
||||
|
||||
To get an instance of Editor, the object which manages document instances,
|
||||
use editor_instance().
|
||||
To create new or open existing document, use Editor.create_doc().
|
||||
To save or close document use Edit.save() and Edit.close().
|
||||
To find out status of document (unsaved, deleted from disk, etc.) use
|
||||
Edit.get_status, it returns flags from EditStatus class.
|
||||
|
||||
Note that by default Editor shows alerts in various places, like when
|
||||
user tries to close document with unsaved changes. To disable this,
|
||||
use 'silent' property: editor.set_property("silent", True).
|
||||
"""
|
||||
from _moo_edit import *
|
||||
|
||||
class Plugin(object):
|
||||
|
@ -376,35 +376,69 @@
|
||||
;; )
|
||||
;; )
|
||||
|
||||
(define-method close
|
||||
(of-object "MooEdit")
|
||||
(c-name "moo_edit_close")
|
||||
(parameters
|
||||
'("gboolean" "ask_confirm" (null-ok) (default "TRUE"))
|
||||
)
|
||||
(return-type "gboolean")
|
||||
(docstring "close(ask_confirm=True) -> bool - closes document.\n"
|
||||
"\n"
|
||||
"If ask_confirm is False, closes document. Otherwise, checks\n"
|
||||
"whether document is saved, and ask user confirmation if needed.")
|
||||
)
|
||||
|
||||
(define-method save
|
||||
(of-object "MooEdit")
|
||||
(c-name "moo_edit_save")
|
||||
(return-type "gboolean")
|
||||
(parameters
|
||||
'("GError**" "error")
|
||||
)
|
||||
(return-type "none")
|
||||
(docstring "save() -> None - saves document.\n"
|
||||
"\n"
|
||||
"Saves document and raises gobject.GError on error.\n"
|
||||
"Note that document must have filename, i.e. it should have \n"
|
||||
"been saved before or opened from disk. Otherwise it will present\n"
|
||||
"Save As dialog."
|
||||
)
|
||||
)
|
||||
|
||||
(define-method save_as
|
||||
(of-object "MooEdit")
|
||||
(c-name "moo_edit_save_as")
|
||||
(return-type "gboolean")
|
||||
(return-type "none")
|
||||
(parameters
|
||||
'("const-char*" "filename" (null-ok) (default "NULL"))
|
||||
'("const-char*" "encoding" (null-ok) (default "NULL"))
|
||||
'("GError**" "error")
|
||||
)
|
||||
(docstring "save_as([filename, encoding]) -> None - saves document with new name.\n"
|
||||
"\n"
|
||||
"Saves document and raises gobject.GError on error.\n"
|
||||
"If filename is not specified, then it presents Save As \n"
|
||||
"dialog asking user for name to use."
|
||||
)
|
||||
)
|
||||
|
||||
(define-method save_copy
|
||||
(of-object "MooEdit")
|
||||
(c-name "moo_edit_save_copy")
|
||||
(return-type "gboolean")
|
||||
(return-type "none")
|
||||
(parameters
|
||||
'("const-char*" "filename")
|
||||
'("const-char*" "encoding" (null-ok) (default "NULL"))
|
||||
'("GError**" "error")
|
||||
)
|
||||
(docstring "save_copy(filename, [encoding]) -> None - saves copy of document.\n"
|
||||
"\n"
|
||||
"Saves document contents with given name, and raises gobject.GError on\n"
|
||||
"error."
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
|
||||
;; From mooeditprefs.h
|
||||
|
||||
(define-function moo_edit_prefs_page_new
|
||||
|
@ -22,6 +22,14 @@
|
||||
(of-object "MooEditor")
|
||||
(c-name "moo_editor_create_doc")
|
||||
(return-type "MooEdit*")
|
||||
(parameters
|
||||
'("const-char*" "filename" (null-ok) (default "NULL"))
|
||||
'("const-char*" "encoding" (null-ok) (default "NULL"))
|
||||
'("GError**" "error")
|
||||
)
|
||||
(docstring "create_doc([filename, encoding]) -> moo.Edit. \n"
|
||||
"\n"
|
||||
"Opens or creates a new document. Raises gobject.GError if open fails.")
|
||||
)
|
||||
|
||||
(define-method open
|
||||
@ -104,6 +112,7 @@
|
||||
(return-type "gboolean")
|
||||
(parameters
|
||||
'("MooEditWindow*" "window")
|
||||
'("gboolean" "ask_confirm")
|
||||
)
|
||||
)
|
||||
|
||||
@ -113,6 +122,7 @@
|
||||
(return-type "gboolean")
|
||||
(parameters
|
||||
'("MooEdit*" "doc")
|
||||
'("gboolean" "ask_confirm")
|
||||
)
|
||||
)
|
||||
|
||||
@ -122,6 +132,7 @@
|
||||
(return-type "gboolean")
|
||||
(parameters
|
||||
'("GSList*" "list")
|
||||
'("gboolean" "ask_confirm")
|
||||
)
|
||||
)
|
||||
|
||||
@ -129,6 +140,9 @@
|
||||
(of-object "MooEditor")
|
||||
(c-name "moo_editor_close_all")
|
||||
(return-type "gboolean")
|
||||
(parameters
|
||||
'("gboolean" "ask_confirm")
|
||||
)
|
||||
)
|
||||
|
||||
(define-method set_app_name
|
||||
|
Loading…
x
Reference in New Issue
Block a user