encodings: move private stuff into private header

encodings.h had a pretty large GEANY_PRIVATE part so it's worthwhile to
separate that into its own header (as per HACKING). What's left is used by the
plugin API.
This commit is contained in:
Thomas Martitz 2015-12-17 09:31:06 +01:00
parent 27628c0028
commit 6098f55032
12 changed files with 96 additions and 72 deletions

View File

@ -5,6 +5,7 @@ EXTRA_DIST = \
gb.c \ gb.c \
plugindata.h \ plugindata.h \
documentprivate.h \ documentprivate.h \
encodingsprivate.h \
filetypesprivate.h \ filetypesprivate.h \
keybindingsprivate.h \ keybindingsprivate.h \
pluginprivate.h \ pluginprivate.h \

View File

@ -33,6 +33,7 @@
#include "build.h" #include "build.h"
#include "document.h" #include "document.h"
#include "encodings.h" #include "encodings.h"
#include "encodingsprivate.h"
#include "filetypes.h" #include "filetypes.h"
#include "main.h" #include "main.h"
#include "support.h" #include "support.h"

View File

@ -35,6 +35,7 @@
#include "dialogs.h" #include "dialogs.h"
#include "documentprivate.h" #include "documentprivate.h"
#include "encodings.h" #include "encodings.h"
#include "encodingsprivate.h"
#include "filetypesprivate.h" #include "filetypesprivate.h"
#include "geany.h" /* FIXME: why is this needed for DOC_FILENAME()? should come from documentprivate.h/document.h */ #include "geany.h" /* FIXME: why is this needed for DOC_FILENAME()? should come from documentprivate.h/document.h */
#include "geanyobject.h" #include "geanyobject.h"

View File

@ -35,6 +35,7 @@
#endif #endif
#include "encodings.h" #include "encodings.h"
#include "encodingsprivate.h"
#include "app.h" #include "app.h"
#include "callbacks.h" #include "callbacks.h"

View File

@ -40,19 +40,6 @@
G_BEGIN_DECLS G_BEGIN_DECLS
typedef enum
{
NONE = 0,
WESTEUROPEAN,
EASTEUROPEAN,
EASTASIAN,
ASIAN,
MIDDLEEASTERN,
UNICODE,
GEANY_ENCODING_GROUPS_MAX
} GeanyEncodingGroup;
/* /*
* The original versions of the following tables are taken from profterm * The original versions of the following tables are taken from profterm
* *
@ -139,23 +126,8 @@ typedef enum
GEANY_ENCODING_CP_932, GEANY_ENCODING_CP_932,
GEANY_ENCODINGS_MAX GEANY_ENCODINGS_MAX
} GeanyEncodingIndex; }
GeanyEncodingIndex;
/** Structure to represent an encoding to be used in Geany. */
typedef struct
{
/** The index of the encoding, must be one of GeanyEncodingIndex. */
gint idx;
/** Internally used member for grouping */
gint order;
/** Internally used member for grouping */
GeanyEncodingGroup group;
/** String representation of the encoding, e.g. "ISO-8859-3" */
const gchar *charset;
/** Translatable and descriptive name of the encoding, e.g. "South European" */
const gchar *name;
} GeanyEncoding;
gchar *encodings_convert_to_utf8(const gchar *buffer, gssize size, gchar **used_encoding); gchar *encodings_convert_to_utf8(const gchar *buffer, gssize size, gchar **used_encoding);
@ -166,44 +138,6 @@ gchar *encodings_convert_to_utf8_from_charset(const gchar *buffer, gssize size,
const gchar* encodings_get_charset_from_index(gint idx); const gchar* encodings_get_charset_from_index(gint idx);
#ifdef GEANY_PRIVATE
const GeanyEncoding* encodings_get_from_charset(const gchar *charset);
const GeanyEncoding* encodings_get_from_index(gint idx);
gchar* encodings_to_string(const GeanyEncoding* enc);
const gchar* encodings_get_charset(const GeanyEncoding* enc);
void encodings_select_radio_item(const gchar *charset);
void encodings_init(void);
void encodings_finalize(void);
GtkTreeStore *encodings_encoding_store_new(gboolean has_detect);
gint encodings_encoding_store_get_encoding(GtkTreeStore *store, GtkTreeIter *iter);
gboolean encodings_encoding_store_get_iter(GtkTreeStore *store, GtkTreeIter *iter, gint enc);
void encodings_encoding_store_cell_data_func(GtkCellLayout *cell_layout, GtkCellRenderer *cell,
GtkTreeModel *tree_model, GtkTreeIter *iter, gpointer data);
gboolean encodings_is_unicode_charset(const gchar *string);
gboolean encodings_convert_to_utf8_auto(gchar **buf, gsize *size, const gchar *forced_enc,
gchar **used_encoding, gboolean *has_bom, gboolean *partial);
extern GeanyEncoding encodings[GEANY_ENCODINGS_MAX];
GeanyEncodingIndex encodings_scan_unicode_bom(const gchar *string, gsize len, guint *bom_len);
GeanyEncodingIndex encodings_get_idx_from_charset(const gchar *charset);
#endif /* GEANY_PRIVATE */
G_END_DECLS G_END_DECLS
#endif /* GEANY_ENCODINGS_H */ #endif /* GEANY_ENCODINGS_H */

84
src/encodingsprivate.h Normal file
View File

@ -0,0 +1,84 @@
/*
* encodingsprivate.h - this file is part of Geany, a fast and lightweight IDE
*
* Copyright 2005-2012 Enrico Tröger <enrico(dot)troeger(at)uvena(dot)de>
* Copyright 2006-2012 Nick Treleaven <nick(dot)treleaven(at)btinternet(dot)com>
*
* 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.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#ifndef ENCODINGSPRIVATE_H
#define ENCODINGSPRIVATE_H
#include "encodings.h"
/* Groups of encodings */
typedef enum
{
NONE = 0,
WESTEUROPEAN,
EASTEUROPEAN,
EASTASIAN,
ASIAN,
MIDDLEEASTERN,
UNICODE,
GEANY_ENCODING_GROUPS_MAX
}
GeanyEncodingGroup;
/* Structure to represent an encoding to be used in Geany. */
typedef struct GeanyEncoding
{
GeanyEncodingIndex idx; /* The index of the encoding inside globa encodes array.*/
gint order; /* Internally used member for grouping */
GeanyEncodingGroup group; /* Internally used member for grouping */
const gchar *charset; /* String representation of the encoding, e.g. "ISO-8859-3" */
const gchar *name; /* Translatable and descriptive name of the encoding, e.g. "South European" */
}
GeanyEncoding;
const GeanyEncoding* encodings_get_from_charset(const gchar *charset);
const GeanyEncoding* encodings_get_from_index(gint idx);
gchar* encodings_to_string(const GeanyEncoding* enc);
const gchar* encodings_get_charset(const GeanyEncoding* enc);
void encodings_select_radio_item(const gchar *charset);
void encodings_init(void);
void encodings_finalize(void);
GtkTreeStore *encodings_encoding_store_new(gboolean has_detect);
gint encodings_encoding_store_get_encoding(GtkTreeStore *store, GtkTreeIter *iter);
gboolean encodings_encoding_store_get_iter(GtkTreeStore *store, GtkTreeIter *iter, gint enc);
void encodings_encoding_store_cell_data_func(GtkCellLayout *cell_layout, GtkCellRenderer *cell,
GtkTreeModel *tree_model, GtkTreeIter *iter, gpointer data);
gboolean encodings_is_unicode_charset(const gchar *string);
gboolean encodings_convert_to_utf8_auto(gchar **buf, gsize *size, const gchar *forced_enc,
gchar **used_encoding, gboolean *has_bom, gboolean *partial);
GeanyEncodingIndex encodings_scan_unicode_bom(const gchar *string, gsize len, guint *bom_len);
GeanyEncodingIndex encodings_get_idx_from_charset(const gchar *charset);
extern GeanyEncoding encodings[GEANY_ENCODINGS_MAX];
#endif /* ENCODINGSPRIVATE_H */

View File

@ -38,6 +38,7 @@
#include "build.h" #include "build.h"
#include "document.h" #include "document.h"
#include "encodings.h" #include "encodings.h"
#include "encodingsprivate.h"
#include "filetypes.h" #include "filetypes.h"
#include "geanyobject.h" #include "geanyobject.h"
#include "main.h" #include "main.h"

View File

@ -36,7 +36,7 @@
#include "callbacks.h" #include "callbacks.h"
#include "dialogs.h" #include "dialogs.h"
#include "document.h" #include "document.h"
#include "encodings.h" #include "encodingsprivate.h"
#include "filetypes.h" #include "filetypes.h"
#include "geanyobject.h" #include "geanyobject.h"
#include "highlighting.h" #include "highlighting.h"

View File

@ -39,7 +39,7 @@
#include "dialogs.h" #include "dialogs.h"
#include "documentprivate.h" #include "documentprivate.h"
#include "editor.h" #include "editor.h"
#include "encodings.h" #include "encodingsprivate.h"
#include "filetypes.h" #include "filetypes.h"
#include "geanywraplabel.h" #include "geanywraplabel.h"
#include "keybindingsprivate.h" #include "keybindingsprivate.h"

View File

@ -33,6 +33,7 @@
#include "app.h" #include "app.h"
#include "document.h" #include "document.h"
#include "encodings.h" #include "encodings.h"
#include "encodingsprivate.h"
#include "keyfile.h" #include "keyfile.h"
#include "msgwindow.h" #include "msgwindow.h"
#include "prefs.h" #include "prefs.h"

View File

@ -32,7 +32,7 @@
#include "app.h" #include "app.h"
#include "document.h" #include "document.h"
#include "encodings.h" #include "encodingsprivate.h"
#include "filetypes.h" #include "filetypes.h"
#include "geany.h" #include "geany.h"
#include "geanymenubuttonaction.h" #include "geanymenubuttonaction.h"

View File

@ -34,7 +34,7 @@
#include "callbacks.h" #include "callbacks.h"
#include "dialogs.h" #include "dialogs.h"
#include "documentprivate.h" #include "documentprivate.h"
#include "encodings.h" #include "encodingsprivate.h"
#include "filetypes.h" #include "filetypes.h"
#include "geanymenubuttonaction.h" #include "geanymenubuttonaction.h"
#include "keyfile.h" #include "keyfile.h"