Add editor_create_widget() to the API; remove editor_create(),

editor_destroy().


git-svn-id: https://geany.svn.sourceforge.net/svnroot/geany/branches/split-window-plugin@2950 ea778897-0a13-0410-b9d1-a72fbfd435f5
This commit is contained in:
Nick Treleaven 2008-09-16 15:21:46 +00:00
parent 363de46002
commit 186e366348
6 changed files with 40 additions and 15 deletions

View File

@ -5,6 +5,10 @@
Fix Doxygen 1.5.4 undocumented parameter warnings. Fix Doxygen 1.5.4 undocumented parameter warnings.
Improve dox for sciwrappers.c. Improve dox for sciwrappers.c.
Correct sci_grap_focus() misspelling. Correct sci_grap_focus() misspelling.
* src/plugindata.h, src/plugins.c, src/editor.c, src/editor.h,
plugins/splitwindow.c:
Add editor_create_widget() to the API; remove editor_create(),
editor_destroy().
2008-09-15 Nick Treleaven <nick(dot)treleaven(at)btinternet(dot)com> 2008-09-15 Nick Treleaven <nick(dot)treleaven(at)btinternet(dot)com>

View File

@ -58,7 +58,7 @@ static struct
menu_items; menu_items;
static enum State plugin_state; static enum State plugin_state;
static GeanyEditor *our_editor = NULL; static GeanyEditor *our_editor = NULL; /* original editor for split view */
static gint sci_get_value(ScintillaObject *sci, gint message_id, gint param) static gint sci_get_value(ScintillaObject *sci, gint message_id, gint param)
@ -193,9 +193,9 @@ static void on_split_view(GtkMenuItem *menuitem, gpointer user_data)
gtk_paned_add1(GTK_PANED(pane), notebook); gtk_paned_add1(GTK_PANED(pane), notebook);
g_object_unref(notebook); g_object_unref(notebook);
our_editor = p_editor->create(doc); our_editor = doc->editor;
sci = our_editor->sci; sci = p_editor->create_widget(our_editor);
sync_to_current(doc->editor->sci, sci); sync_to_current(our_editor->sci, sci);
gtk_paned_add2(GTK_PANED(pane), GTK_WIDGET(sci)); gtk_paned_add2(GTK_PANED(pane), GTK_WIDGET(sci));
gtk_paned_set_position(GTK_PANED(pane), width); gtk_paned_set_position(GTK_PANED(pane), width);
@ -217,7 +217,6 @@ static void on_unsplit(GtkMenuItem *menuitem, gpointer user_data)
g_object_ref(notebook); g_object_ref(notebook);
gtk_container_remove(GTK_CONTAINER(pane), notebook); gtk_container_remove(GTK_CONTAINER(pane), notebook);
gtk_widget_destroy(pane); gtk_widget_destroy(pane);
p_editor->destroy(our_editor);
our_editor = NULL; our_editor = NULL;
gtk_container_add(GTK_CONTAINER(parent), notebook); gtk_container_add(GTK_CONTAINER(parent), notebook);
g_object_unref(notebook); g_object_unref(notebook);

View File

@ -3753,6 +3753,7 @@ static void setup_sci_keys(ScintillaObject *sci)
/* Create new editor widget (scintilla). /* Create new editor widget (scintilla).
* @note The @c "sci-notify" signal is connected separately. */ * @note The @c "sci-notify" signal is connected separately. */
/* TODO: change to use GeanyEditor */
static ScintillaObject *create_new_sci(GeanyDocument *doc) static ScintillaObject *create_new_sci(GeanyDocument *doc)
{ {
ScintillaObject *sci; ScintillaObject *sci;
@ -3793,6 +3794,29 @@ static ScintillaObject *create_new_sci(GeanyDocument *doc)
} }
/** Create a new Scintilla @c GtkWidget based on the settings for @a editor.
* @param editor Editor settings.
* @return The new widget. */
ScintillaObject *editor_create_widget(GeanyEditor *editor)
{
const GeanyIndentPrefs *iprefs = get_default_indent_prefs();
ScintillaObject *old, *sci;
/* temporarily change editor to use the new sci widget */
old = editor->sci;
sci = create_new_sci(editor->document);
editor->sci = sci;
editor_set_indent_type(editor, iprefs->type);
editor_set_font(editor, interface_prefs.editor_font);
/* if editor already had a widget, restore it */
if (old)
editor->sci = old;
return sci;
}
GeanyEditor *editor_create(GeanyDocument *doc) GeanyEditor *editor_create(GeanyDocument *doc)
{ {
const GeanyIndentPrefs *iprefs = get_default_indent_prefs(); const GeanyIndentPrefs *iprefs = get_default_indent_prefs();
@ -3800,14 +3824,12 @@ GeanyEditor *editor_create(GeanyDocument *doc)
editor->document = doc; editor->document = doc;
editor->sci = create_new_sci(doc);
editor_set_indent_type(editor, iprefs->type);
editor_set_font(editor, interface_prefs.editor_font);
editor->auto_indent = (iprefs->auto_indent_mode != GEANY_AUTOINDENT_NONE); editor->auto_indent = (iprefs->auto_indent_mode != GEANY_AUTOINDENT_NONE);
editor->line_wrapping = editor_prefs.line_wrapping; editor->line_wrapping = editor_prefs.line_wrapping;
editor->scroll_percent = -1.0F; editor->scroll_percent = -1.0F;
editor->line_breaking = FALSE; editor->line_breaking = FALSE;
editor->sci = editor_create_widget(editor);
return editor; return editor;
} }

View File

@ -143,6 +143,8 @@ GeanyEditor *editor_create(GeanyDocument *doc);
void editor_destroy(GeanyEditor *editor); void editor_destroy(GeanyEditor *editor);
ScintillaObject *editor_create_widget(GeanyEditor *editor);
void on_editor_notification(GtkWidget* editor, gint scn, gpointer lscn, gpointer user_data); void on_editor_notification(GtkWidget* editor, gint scn, gpointer lscn, gpointer user_data);
gboolean editor_start_auto_complete(GeanyDocument *doc, gint pos, gboolean force); gboolean editor_start_auto_complete(GeanyDocument *doc, gint pos, gboolean force);

View File

@ -41,13 +41,13 @@
enum { enum {
/** The Application Programming Interface (API) version, incremented /** The Application Programming Interface (API) version, incremented
* whenever any plugin data types are modified or appended to. */ * whenever any plugin data types are modified or appended to. */
GEANY_API_VERSION = 90, GEANY_API_VERSION = 91,
/** The Application Binary Interface (ABI) version, incremented whenever /** The Application Binary Interface (ABI) version, incremented whenever
* existing fields in the plugin data types have to be changed or reordered. */ * existing fields in the plugin data types have to be changed or reordered. */
/* This should usually stay the same if fields are only appended, assuming only pointers to /* This should usually stay the same if fields are only appended, assuming only pointers to
* structs and not structs themselves are declared by plugins. */ * structs and not structs themselves are declared by plugins. */
GEANY_ABI_VERSION = 44 GEANY_ABI_VERSION = 45
}; };
/** Check the plugin can be loaded by Geany. /** Check the plugin can be loaded by Geany.
@ -455,8 +455,7 @@ typedef struct EditorFuncs
void (*clear_indicators) (struct GeanyEditor *editor); void (*clear_indicators) (struct GeanyEditor *editor);
const struct GeanyIndentPrefs* (*get_indent_prefs)(struct GeanyEditor *editor); const struct GeanyIndentPrefs* (*get_indent_prefs)(struct GeanyEditor *editor);
struct GeanyEditor* (*create)(struct GeanyDocument *doc); struct _ScintillaObject* (*create_widget)(struct GeanyEditor *editor);
void (*destroy)(struct GeanyEditor *editor);
/* Remember to convert any GeanyDocument or ScintillaObject pointers in any /* Remember to convert any GeanyDocument or ScintillaObject pointers in any
* appended functions to GeanyEditor pointers. */ * appended functions to GeanyEditor pointers. */
} }

View File

@ -116,8 +116,7 @@ static EditorFuncs editor_funcs = {
&editor_set_indicator_on_line, &editor_set_indicator_on_line,
&editor_clear_indicators, &editor_clear_indicators,
&editor_get_indent_prefs, &editor_get_indent_prefs,
&editor_create, &editor_create_widget
&editor_destroy
}; };
static ScintillaFuncs sci_funcs = { static ScintillaFuncs sci_funcs = {