2005-09-06 09:21:05 -07:00
|
|
|
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4; coding: utf-8 -*-
|
2005-09-09 02:54:58 -07:00
|
|
|
*
|
2005-09-06 09:21:05 -07:00
|
|
|
* mooedit.h
|
2005-06-22 11:20:32 -07:00
|
|
|
*
|
|
|
|
* Copyright (C) 2004-2005 by Yevgen Muntyan <muntyan@math.tamu.edu>
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* See COPYING file that comes with this distribution.
|
|
|
|
*/
|
|
|
|
|
2005-09-06 09:21:05 -07:00
|
|
|
#ifndef __MOO_EDIT_H__
|
|
|
|
#define __MOO_EDIT_H__
|
2005-06-22 11:20:32 -07:00
|
|
|
|
2005-10-13 07:08:18 -07:00
|
|
|
#include <mooedit/mootextview.h>
|
|
|
|
#include <mooedit/moolang.h>
|
|
|
|
#include <mooutils/mooprefs.h>
|
2005-06-22 11:20:32 -07:00
|
|
|
|
|
|
|
G_BEGIN_DECLS
|
|
|
|
|
|
|
|
|
|
|
|
#define MOO_TYPE_EDIT (moo_edit_get_type ())
|
|
|
|
#define MOO_TYPE_EDIT_ON_EXTERNAL_CHANGES (moo_edit_on_external_changes_get_type ())
|
2005-10-13 07:08:18 -07:00
|
|
|
#define MOO_TYPE_EDIT_STATUS (moo_edit_status_get_type ())
|
2005-06-22 11:20:32 -07:00
|
|
|
#define MOO_TYPE_EDIT_FILE_INFO (moo_edit_file_info_get_type ())
|
2005-11-06 22:56:33 -08:00
|
|
|
#define MOO_TYPE_EDIT_VAR_DEP (moo_edit_var_dep_get_type ())
|
2005-06-22 11:20:32 -07:00
|
|
|
|
|
|
|
#define MOO_EDIT(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), MOO_TYPE_EDIT, MooEdit))
|
|
|
|
#define MOO_EDIT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), MOO_TYPE_EDIT, MooEditClass))
|
|
|
|
#define MOO_IS_EDIT(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), MOO_TYPE_EDIT))
|
|
|
|
#define MOO_IS_EDIT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), MOO_TYPE_EDIT))
|
|
|
|
#define MOO_EDIT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), MOO_TYPE_EDIT, MooEditClass))
|
|
|
|
|
|
|
|
|
2005-11-03 17:35:22 -08:00
|
|
|
typedef enum {
|
|
|
|
MOO_EDIT_VAR_DEP_NONE = 0,
|
2005-11-24 06:14:48 -08:00
|
|
|
MOO_EDIT_VAR_DEP_FILENAME = 1,
|
|
|
|
MOO_EDIT_VAR_DEP_AUTO = 2
|
2005-11-03 17:35:22 -08:00
|
|
|
} MooEditVarDep;
|
|
|
|
|
2005-11-24 06:14:48 -08:00
|
|
|
#define MOO_EDIT_VAR_LANG "lang"
|
|
|
|
#define MOO_EDIT_VAR_INDENT "indent"
|
|
|
|
#define MOO_EDIT_VAR_STRIP "strip"
|
2005-11-03 17:35:22 -08:00
|
|
|
|
|
|
|
|
2005-06-22 11:20:32 -07:00
|
|
|
typedef enum {
|
|
|
|
MOO_EDIT_DONT_WATCH_FILE = 0,
|
|
|
|
MOO_EDIT_ALWAYS_ALERT,
|
|
|
|
MOO_EDIT_ALWAYS_RELOAD,
|
|
|
|
MOO_EDIT_RELOAD_IF_SAFE
|
|
|
|
} MooEditOnExternalChanges;
|
|
|
|
|
|
|
|
typedef enum {
|
2005-09-02 16:27:25 -07:00
|
|
|
MOO_EDIT_MODIFIED_ON_DISK = 1 << 0,
|
|
|
|
MOO_EDIT_DELETED = 1 << 1,
|
|
|
|
MOO_EDIT_CHANGED_ON_DISK = MOO_EDIT_MODIFIED_ON_DISK | MOO_EDIT_DELETED,
|
|
|
|
MOO_EDIT_MODIFIED = 1 << 2,
|
|
|
|
MOO_EDIT_CLEAN = 1 << 3 /* doesn't prompt if it's closed, even if it's modified*/
|
|
|
|
} MooEditStatus;
|
|
|
|
|
|
|
|
#define MOO_EDIT_IS_MODIFIED(edit) (moo_edit_get_status (edit) & MOO_EDIT_MODIFIED)
|
|
|
|
#define MOO_EDIT_IS_CLEAN(edit) (moo_edit_get_status (edit) & MOO_EDIT_CLEAN)
|
2005-06-22 11:20:32 -07:00
|
|
|
|
|
|
|
struct _MooEditFileInfo {
|
|
|
|
char *filename;
|
|
|
|
char *encoding;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
typedef struct _MooEditFileInfo MooEditFileInfo;
|
|
|
|
typedef struct _MooEdit MooEdit;
|
|
|
|
typedef struct _MooEditPrivate MooEditPrivate;
|
|
|
|
typedef struct _MooEditClass MooEditClass;
|
|
|
|
|
|
|
|
struct _MooEdit
|
|
|
|
{
|
2005-09-09 02:40:10 -07:00
|
|
|
MooTextView parent;
|
2005-06-22 11:20:32 -07:00
|
|
|
|
|
|
|
MooEditPrivate *priv;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct _MooEditClass
|
|
|
|
{
|
2005-09-09 02:40:10 -07:00
|
|
|
MooTextViewClass parent_class;
|
2005-06-22 11:20:32 -07:00
|
|
|
|
|
|
|
/* emitted when filename, modified status, or file on disk
|
|
|
|
are changed. for use in editor to adjust title bar, etc. */
|
2005-11-23 03:10:03 -08:00
|
|
|
void (* doc_status_changed) (MooEdit *edit);
|
2005-06-22 11:20:32 -07:00
|
|
|
|
2005-11-23 03:10:03 -08:00
|
|
|
void (* filename_changed) (MooEdit *edit,
|
|
|
|
const char *new_filename);
|
2005-06-22 11:20:32 -07:00
|
|
|
|
2005-11-23 03:10:03 -08:00
|
|
|
void (* lang_changed) (MooEdit *edit);
|
2005-11-03 17:35:22 -08:00
|
|
|
|
2005-11-23 03:10:03 -08:00
|
|
|
void (* variable_changed) (MooEdit *edit,
|
2005-11-24 06:14:48 -08:00
|
|
|
const char *name);
|
2005-11-23 03:10:03 -08:00
|
|
|
|
|
|
|
void (* save_before) (MooEdit *edit);
|
|
|
|
void (* save_after) (MooEdit *edit);
|
2005-06-22 11:20:32 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2005-09-09 02:40:10 -07:00
|
|
|
GType moo_edit_get_type (void) G_GNUC_CONST;
|
2005-10-13 07:08:18 -07:00
|
|
|
GType moo_edit_status_get_type (void) G_GNUC_CONST;
|
2005-09-09 02:40:10 -07:00
|
|
|
GType moo_edit_on_external_changes_get_type (void) G_GNUC_CONST;
|
|
|
|
GType moo_edit_file_info_get_type (void) G_GNUC_CONST;
|
2005-11-06 22:56:33 -08:00
|
|
|
GType moo_edit_var_dep_get_type (void) G_GNUC_CONST;
|
2005-06-22 11:20:32 -07:00
|
|
|
|
2005-09-09 02:40:10 -07:00
|
|
|
const char *moo_edit_get_filename (MooEdit *edit);
|
|
|
|
const char *moo_edit_get_basename (MooEdit *edit);
|
|
|
|
const char *moo_edit_get_display_filename (MooEdit *edit);
|
|
|
|
const char *moo_edit_get_display_basename (MooEdit *edit);
|
2005-06-22 11:20:32 -07:00
|
|
|
|
2005-09-09 02:40:10 -07:00
|
|
|
const char *moo_edit_get_encoding (MooEdit *edit);
|
2005-06-22 11:20:32 -07:00
|
|
|
|
2005-09-09 02:40:10 -07:00
|
|
|
gboolean moo_edit_is_empty (MooEdit *edit);
|
|
|
|
void moo_edit_set_modified (MooEdit *edit,
|
|
|
|
gboolean modified);
|
|
|
|
gboolean moo_edit_get_clean (MooEdit *edit);
|
|
|
|
void moo_edit_set_clean (MooEdit *edit,
|
|
|
|
gboolean clean);
|
|
|
|
MooEditStatus moo_edit_get_status (MooEdit *edit);
|
|
|
|
void moo_edit_status_changed (MooEdit *edit);
|
2005-06-22 11:20:32 -07:00
|
|
|
|
2005-09-09 02:40:10 -07:00
|
|
|
gboolean moo_edit_get_readonly (MooEdit *edit);
|
|
|
|
void moo_edit_set_readonly (MooEdit *edit,
|
|
|
|
gboolean readonly);
|
2005-06-22 11:20:32 -07:00
|
|
|
|
2005-09-09 02:40:10 -07:00
|
|
|
MooEditFileInfo *moo_edit_file_info_new (const char *filename,
|
|
|
|
const char *encoding);
|
|
|
|
MooEditFileInfo *moo_edit_file_info_copy (const MooEditFileInfo *info);
|
|
|
|
void moo_edit_file_info_free (MooEditFileInfo *info);
|
2005-09-06 09:21:05 -07:00
|
|
|
|
2005-09-09 02:40:10 -07:00
|
|
|
void moo_edit_set_highlight (MooEdit *edit,
|
|
|
|
gboolean highlight);
|
2005-10-13 07:08:18 -07:00
|
|
|
gboolean moo_edit_get_highlight (MooEdit *edit);
|
|
|
|
|
|
|
|
void moo_edit_set_var (MooEdit *edit,
|
|
|
|
const char *name,
|
2005-11-24 06:14:48 -08:00
|
|
|
const GValue *value,
|
|
|
|
MooEditVarDep dep);
|
|
|
|
gboolean moo_edit_get_var (MooEdit *edit,
|
|
|
|
const char *name,
|
|
|
|
GValue *value);
|
|
|
|
|
|
|
|
char *moo_edit_get_string (MooEdit *edit,
|
|
|
|
const char *name);
|
|
|
|
gboolean moo_edit_get_bool (MooEdit *edit,
|
|
|
|
const char *name,
|
|
|
|
gboolean default_val);
|
|
|
|
int moo_edit_get_int (MooEdit *edit,
|
|
|
|
const char *name,
|
|
|
|
int default_val);
|
|
|
|
guint moo_edit_get_uint (MooEdit *edit,
|
|
|
|
const char *name,
|
|
|
|
guint default_val);
|
|
|
|
void moo_edit_set_string (MooEdit *edit,
|
2005-11-03 17:35:22 -08:00
|
|
|
const char *name,
|
|
|
|
const char *value,
|
|
|
|
MooEditVarDep dep);
|
2005-11-24 06:14:48 -08:00
|
|
|
|
|
|
|
void moo_edit_register_var (GParamSpec *pspec);
|
|
|
|
void moo_edit_register_var_alias (const char *name,
|
|
|
|
const char *alias);
|
2005-09-08 10:08:31 -07:00
|
|
|
|
2005-11-11 12:04:17 -08:00
|
|
|
gboolean moo_edit_save (MooEdit *edit);
|
|
|
|
gboolean moo_edit_save_as (MooEdit *edit,
|
|
|
|
const char *filename,
|
|
|
|
const char *encoding);
|
|
|
|
gboolean moo_edit_save_copy (MooEdit *edit,
|
|
|
|
const char *filename,
|
|
|
|
const char *encoding,
|
|
|
|
GError **error);
|
|
|
|
|
2005-06-22 11:20:32 -07:00
|
|
|
|
|
|
|
G_END_DECLS
|
|
|
|
|
2005-09-06 09:21:05 -07:00
|
|
|
#endif /* __MOO_EDIT_H__ */
|