Revision: 2950 http://geany.svn.sourceforge.net/geany/?rev=2950&view=rev Author: ntrel Date: 2008-09-16 15:21:46 +0000 (Tue, 16 Sep 2008)
Log Message: ----------- Add editor_create_widget() to the API; remove editor_create(), editor_destroy().
Modified Paths: -------------- branches/split-window-plugin/ChangeLog branches/split-window-plugin/plugins/splitwindow.c branches/split-window-plugin/src/editor.c branches/split-window-plugin/src/editor.h branches/split-window-plugin/src/plugindata.h branches/split-window-plugin/src/plugins.c
Modified: branches/split-window-plugin/ChangeLog =================================================================== --- branches/split-window-plugin/ChangeLog 2008-09-16 12:21:14 UTC (rev 2949) +++ branches/split-window-plugin/ChangeLog 2008-09-16 15:21:46 UTC (rev 2950) @@ -5,6 +5,10 @@ Fix Doxygen 1.5.4 undocumented parameter warnings. Improve dox for sciwrappers.c. 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>
Modified: branches/split-window-plugin/plugins/splitwindow.c =================================================================== --- branches/split-window-plugin/plugins/splitwindow.c 2008-09-16 12:21:14 UTC (rev 2949) +++ branches/split-window-plugin/plugins/splitwindow.c 2008-09-16 15:21:46 UTC (rev 2950) @@ -58,7 +58,7 @@ menu_items;
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) @@ -193,9 +193,9 @@ gtk_paned_add1(GTK_PANED(pane), notebook); g_object_unref(notebook);
- our_editor = p_editor->create(doc); - sci = our_editor->sci; - sync_to_current(doc->editor->sci, sci); + our_editor = doc->editor; + sci = p_editor->create_widget(our_editor); + sync_to_current(our_editor->sci, sci); gtk_paned_add2(GTK_PANED(pane), GTK_WIDGET(sci));
gtk_paned_set_position(GTK_PANED(pane), width); @@ -217,7 +217,6 @@ g_object_ref(notebook); gtk_container_remove(GTK_CONTAINER(pane), notebook); gtk_widget_destroy(pane); - p_editor->destroy(our_editor); our_editor = NULL; gtk_container_add(GTK_CONTAINER(parent), notebook); g_object_unref(notebook);
Modified: branches/split-window-plugin/src/editor.c =================================================================== --- branches/split-window-plugin/src/editor.c 2008-09-16 12:21:14 UTC (rev 2949) +++ branches/split-window-plugin/src/editor.c 2008-09-16 15:21:46 UTC (rev 2950) @@ -3753,6 +3753,7 @@
/* Create new editor widget (scintilla). * @note The @c "sci-notify" signal is connected separately. */ +/* TODO: change to use GeanyEditor */ static ScintillaObject *create_new_sci(GeanyDocument *doc) { ScintillaObject *sci; @@ -3793,6 +3794,29 @@ }
+/** 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) { const GeanyIndentPrefs *iprefs = get_default_indent_prefs(); @@ -3800,14 +3824,12 @@
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->line_wrapping = editor_prefs.line_wrapping; editor->scroll_percent = -1.0F; editor->line_breaking = FALSE; + + editor->sci = editor_create_widget(editor); return editor; }
Modified: branches/split-window-plugin/src/editor.h =================================================================== --- branches/split-window-plugin/src/editor.h 2008-09-16 12:21:14 UTC (rev 2949) +++ branches/split-window-plugin/src/editor.h 2008-09-16 15:21:46 UTC (rev 2950) @@ -143,6 +143,8 @@
void editor_destroy(GeanyEditor *editor);
+ScintillaObject *editor_create_widget(GeanyEditor *editor); + void on_editor_notification(GtkWidget* editor, gint scn, gpointer lscn, gpointer user_data);
gboolean editor_start_auto_complete(GeanyDocument *doc, gint pos, gboolean force);
Modified: branches/split-window-plugin/src/plugindata.h =================================================================== --- branches/split-window-plugin/src/plugindata.h 2008-09-16 12:21:14 UTC (rev 2949) +++ branches/split-window-plugin/src/plugindata.h 2008-09-16 15:21:46 UTC (rev 2950) @@ -41,13 +41,13 @@ enum { /** The Application Programming Interface (API) version, incremented * 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 * 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 * 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. @@ -455,8 +455,7 @@ void (*clear_indicators) (struct GeanyEditor *editor);
const struct GeanyIndentPrefs* (*get_indent_prefs)(struct GeanyEditor *editor); - struct GeanyEditor* (*create)(struct GeanyDocument *doc); - void (*destroy)(struct GeanyEditor *editor); + struct _ScintillaObject* (*create_widget)(struct GeanyEditor *editor); /* Remember to convert any GeanyDocument or ScintillaObject pointers in any * appended functions to GeanyEditor pointers. */ }
Modified: branches/split-window-plugin/src/plugins.c =================================================================== --- branches/split-window-plugin/src/plugins.c 2008-09-16 12:21:14 UTC (rev 2949) +++ branches/split-window-plugin/src/plugins.c 2008-09-16 15:21:46 UTC (rev 2950) @@ -116,8 +116,7 @@ &editor_set_indicator_on_line, &editor_clear_indicators, &editor_get_indent_prefs, - &editor_create, - &editor_destroy + &editor_create_widget };
static ScintillaFuncs sci_funcs = {
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.