2 * plugindata.h - this file is part of Geany, a fast and lightweight IDE
4 * Copyright 2007-2012 Enrico Tröger <enrico(dot)troeger(at)uvena(dot)de>
5 * Copyright 2007-2012 Nick Treleaven <nick(dot)treleaven(at)btinternet(dot)com>
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License along
18 * with this program; if not, write to the Free Software Foundation, Inc.,
19 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
24 * This file defines the plugin API, the interface between Geany and its plugins.
25 * For detailed documentation of the plugin system please read the plugin
28 /* Note: Remember to increment GEANY_API_VERSION (and GEANY_ABI_VERSION if necessary)
29 * when making changes (see 'Keeping the plugin ABI stable' in the HACKING file). */
32 #ifndef GEANY_PLUGIN_DATA_H
33 #define GEANY_PLUGIN_DATA_H 1
35 #include "build.h" /* GeanyBuildGroup, GeanyBuildSource, GeanyBuildCmdEntries enums */
36 #include "document.h" /* GeanyDocument */
37 #include "editor.h" /* GeanyEditor, GeanyIndentType */
38 #include "filetypes.h" /* GeanyFiletype */
40 #include "gtkcompat.h"
44 /* Compatibility for sharing macros between API and core.
45 * First include geany.h, then plugindata.h, then other API headers. */
47 #define GEANY(symbol_name) geany->symbol_name
50 /** The Application Programming Interface (API) version, incremented
51 * whenever any plugin data types are modified or appended to.
53 * You can protect code that needs a higher API than e.g. 200 with:
54 * @code #if GEANY_API_VERSION >= 200
55 * some_newer_function();
58 * @warning You should not test for values below 200 as previously
59 * @c GEANY_API_VERSION was defined as an enum value, not a macro.
61 #define GEANY_API_VERSION 221
63 /* hack to have a different ABI when built with GTK3 because loading GTK2-linked plugins
64 * with GTK3-linked Geany leads to crash */
65 #if GTK_CHECK_VERSION(3, 0, 0)
66 # define GEANY_ABI_SHIFT 8
68 # define GEANY_ABI_SHIFT 0
70 /** The Application Binary Interface (ABI) version, incremented whenever
71 * existing fields in the plugin data types have to be changed or reordered.
72 * Changing this forces all plugins to be recompiled before Geany can load them. */
73 /* This should usually stay the same if fields are only appended, assuming only pointers to
74 * structs and not structs themselves are declared by plugins. */
75 #define GEANY_ABI_VERSION (70 << GEANY_ABI_SHIFT)
78 /** Defines a function to check the plugin is safe to load.
79 * This performs runtime checks that try to ensure:
80 * - Geany ABI data types are compatible with this plugin.
81 * - Geany sources provide the required API for this plugin.
82 * @param api_required The minimum API number your plugin requires.
83 * Look at the source for the value of @c GEANY_API_VERSION to use if you
84 * want your plugin to require the current Geany version on your machine.
85 * You should update this value when using any new API features. */
86 #define PLUGIN_VERSION_CHECK(api_required) \
87 gint plugin_version_check(gint abi_ver) \
89 if (abi_ver != GEANY_ABI_VERSION) \
91 return (api_required); \
95 /** Basic information about a plugin available to Geany without loading the plugin.
96 * The fields are set in plugin_set_info(), usually with the PLUGIN_SET_INFO() macro. */
97 typedef struct PluginInfo
99 /** The name of the plugin. */
101 /** The description of the plugin. */
102 const gchar
*description
;
103 /** The version of the plugin. */
104 const gchar
*version
;
105 /** The author of the plugin. */
111 /** Basic information for the plugin and identification.
112 * @see geany_plugin. */
113 typedef struct GeanyPlugin
115 PluginInfo
*info
; /**< Fields set in plugin_set_info(). */
117 struct GeanyPluginPrivate
*priv
; /* private */
122 /** Sets the plugin name and some other basic information about a plugin.
124 * @note If you want some of the arguments to be translated, see @ref PLUGIN_SET_TRANSLATABLE_INFO()
127 * @code PLUGIN_SET_INFO("Cool Feature", "Adds cool feature support.", "0.1", "Joe Author") @endcode */
128 /* plugin_set_info() could be written manually for plugins if we want to add any
129 * extra PluginInfo features (such as an icon), so we don't need to break API
130 * compatibility. Alternatively just add a new macro, PLUGIN_SET_INFO_FULL(). -ntrel */
131 #define PLUGIN_SET_INFO(p_name, p_description, p_version, p_author) \
132 void plugin_set_info(PluginInfo *info) \
134 info->name = (p_name); \
135 info->description = (p_description); \
136 info->version = (p_version); \
137 info->author = (p_author); \
140 /** Sets the plugin name and some other basic information about a plugin.
141 * This macro is like @ref PLUGIN_SET_INFO() but allows the passed information to be translated
142 * by setting up the translation mechanism with @ref main_locale_init().
143 * You therefore don't need to call it manually in plugin_init().
146 * @code PLUGIN_SET_TRANSLATABLE_INFO(LOCALEDIR, GETTEXT_PACKAGE, _("Cool Feature"), _("Adds a cool feature."), "0.1", "John Doe") @endcode
149 #define PLUGIN_SET_TRANSLATABLE_INFO(localedir, package, p_name, p_description, p_version, p_author) \
150 void plugin_set_info(PluginInfo *info) \
152 main_locale_init((localedir), (package)); \
153 info->name = (p_name); \
154 info->description = (p_description); \
155 info->version = (p_version); \
156 info->author = (p_author); \
160 /** @deprecated - use plugin_set_key_group() instead.
161 * @see PLUGIN_KEY_GROUP() macro. */
162 typedef struct GeanyKeyGroupInfo
164 const gchar
*name
; /**< Group name used in the configuration file, such as @c "html_chars" */
165 gsize count
; /**< The number of keybindings the group will hold */
169 /** @deprecated - use plugin_set_key_group() instead.
170 * Declare and initialise a keybinding group.
171 * @code GeanyKeyGroup *plugin_key_group; @endcode
172 * You must then set the @c plugin_key_group::keys[] entries for the group in plugin_init(),
173 * normally using keybindings_set_item().
174 * The @c plugin_key_group::label field is set by Geany after @c plugin_init()
175 * is called, to the name of the plugin.
176 * @param group_name A unique group name (without quotes) to be used in the
177 * configuration file, such as @c html_chars.
178 * @param key_count The number of keybindings the group will hold. */
179 #define PLUGIN_KEY_GROUP(group_name, key_count) \
180 /* We have to declare this as a single element array.
181 * Declaring as a pointer to a struct doesn't work with g_module_symbol(). */ \
182 GeanyKeyGroupInfo plugin_key_group_info[1] = \
184 {G_STRINGIFY(group_name), key_count} \
186 GeanyKeyGroup *plugin_key_group = NULL;
189 /** Callback array entry type used with the @ref plugin_callbacks symbol. */
190 typedef struct PluginCallback
192 /** The name of signal, must be an existing signal. For a list of available signals,
193 * please see the @link pluginsignals.c Signal documentation @endlink. */
194 const gchar
*signal_name
;
195 /** A callback function which is called when the signal is emitted. */
197 /** Set to TRUE to connect your handler with g_signal_connect_after(). */
199 /** The user data passed to the signal handler. */
205 /** @deprecated Use @ref ui_add_document_sensitive() instead.
206 * Flags to be set by plugins in PluginFields struct. */
209 /** Whether a plugin's menu item should be disabled when there are no open documents */
210 PLUGIN_IS_DOCUMENT_SENSITIVE
= 1 << 0
214 /** @deprecated Use @ref ui_add_document_sensitive() instead.
215 * Fields set and owned by the plugin. */
216 typedef struct PluginFields
218 /** Bitmask of @c PluginFlags. */
220 /** Pointer to a plugin's menu item which will be automatically enabled/disabled when there
221 * are no open documents and @c PLUGIN_IS_DOCUMENT_SENSITIVE is set.
222 * This is required if using @c PLUGIN_IS_DOCUMENT_SENSITIVE, ignored otherwise */
223 GtkWidget
*menu_item
;
228 /** This contains pointers to global variables owned by Geany for plugins to use.
229 * Core variable pointers can be appended when needed by plugin authors, if appropriate. */
230 typedef struct GeanyData
232 struct GeanyApp
*app
; /**< Geany application data fields */
233 struct GeanyMainWidgets
*main_widgets
; /**< Important widgets in the main window */
234 GPtrArray
*documents_array
; /**< See document.h#documents_array. */
235 GPtrArray
*filetypes_array
; /**< Dynamic array of GeanyFiletype pointers */
236 struct GeanyPrefs
*prefs
; /**< General settings */
237 struct GeanyInterfacePrefs
*interface_prefs
; /**< Interface settings */
238 struct GeanyToolbarPrefs
*toolbar_prefs
; /**< Toolbar settings */
239 struct GeanyEditorPrefs
*editor_prefs
; /**< Editor settings */
240 struct GeanyFilePrefs
*file_prefs
; /**< File-related settings */
241 struct GeanySearchPrefs
*search_prefs
; /**< Search-related settings */
242 struct GeanyToolPrefs
*tool_prefs
; /**< Tool settings */
243 struct GeanyTemplatePrefs
*template_prefs
; /**< Template settings */
244 struct GeanyBuildInfo
*build_info
; /**< Current build information */
245 GSList
*filetypes_by_title
; /**< See filetypes.h#filetypes_by_title. */
249 #define geany geany_data /**< Simple macro for @c geany_data that reduces typing. */
252 #ifndef GEANY_PRIVATE
254 /* Prototypes for building plugins with -Wmissing-prototypes
255 * Also allows the compiler to check if the signature of the plugin's
256 * symbol properly matches what we expect. */
257 gint
plugin_version_check(gint abi_ver
);
258 void plugin_set_info(PluginInfo
*info
);
260 void plugin_init(GeanyData
*data
);
261 GtkWidget
*plugin_configure(GtkDialog
*dialog
);
262 void plugin_configure_single(GtkWidget
*parent
);
263 void plugin_help(void);
264 void plugin_cleanup(void);
269 /** This contains pointers to functions owned by Geany for plugins to use.
270 * Functions from the core can be appended when needed by plugin authors, but may
271 * require some changes. */
272 typedef struct GeanyFunctions
274 struct DocumentFuncs
*p_document
; /**< See document.h */
275 struct SciFuncs
*p_sci
; /**< See sciwrappers.h */
276 struct TemplateFuncs
*p_templates
; /**< See templates.h */
277 struct UtilsFuncs
*p_utils
; /**< See utils.h */
278 struct UIUtilsFuncs
*p_ui
; /**< See ui_utils.h */
279 /** @deprecated Use ui_lookup_widget() instead. */
280 struct SupportFuncs
*p_support
;
281 struct DialogFuncs
*p_dialogs
; /**< See dialogs.h */
282 /** @deprecated Use @ref GeanyFunctions::p_msgwin instead. */
283 struct MsgWinFuncs
*p_msgwindow
;
284 struct EncodingFuncs
*p_encodings
; /**< See encodings.h */
285 struct KeybindingFuncs
*p_keybindings
; /**< See keybindings.h */
286 struct TagManagerFuncs
*p_tm
; /**< See tagmanager/src */
287 struct SearchFuncs
*p_search
; /**< See search.h */
288 struct HighlightingFuncs
*p_highlighting
; /**< See highlighting.h */
289 struct FiletypeFuncs
*p_filetypes
; /**< See filetypes.h */
290 struct NavQueueFuncs
*p_navqueue
; /**< See navqueue.h */
291 struct EditorFuncs
*p_editor
; /**< See editor.h */
292 struct MainFuncs
*p_main
; /**< See main.h */
293 struct PluginFuncs
*p_plugin
; /**< See pluginutils.c */
294 struct ScintillaFuncs
*p_scintilla
; /**< See ScintillaFuncs */
295 struct MsgWinFuncs
*p_msgwin
; /**< See msgwindow.h */
296 struct StashFuncs
*p_stash
; /**< See stash.h */
297 struct SymbolsFuncs
*p_symbols
; /**< See symbols.h */
298 struct BuildFuncs
*p_build
; /**< See build.h */
299 struct ProjectFuncs
*p_project
; /**< See project.h */
304 /* For more information about these functions, see the main source code.
305 * E.g. for p_document->new_file(), see document_new_file() in document.c. */
308 typedef struct DocumentFuncs
310 struct GeanyDocument
* (*document_new_file
) (const gchar
*utf8_filename
, struct GeanyFiletype
*ft
,
312 struct GeanyDocument
* (*document_get_current
) (void);
313 struct GeanyDocument
* (*document_get_from_page
) (guint page_num
);
314 struct GeanyDocument
* (*document_find_by_filename
) (const gchar
*utf8_filename
);
315 struct GeanyDocument
* (*document_find_by_real_path
) (const gchar
*realname
);
316 gboolean (*document_save_file
) (struct GeanyDocument
*doc
, gboolean force
);
317 struct GeanyDocument
* (*document_open_file
) (const gchar
*locale_filename
, gboolean readonly
,
318 struct GeanyFiletype
*ft
, const gchar
*forced_enc
);
319 void (*document_open_files
) (const GSList
*filenames
, gboolean readonly
,
320 struct GeanyFiletype
*ft
, const gchar
*forced_enc
);
321 gboolean (*document_remove_page
) (guint page_num
);
322 gboolean (*document_reload_force
) (struct GeanyDocument
*doc
, const gchar
*forced_enc
);
323 void (*document_set_encoding
) (struct GeanyDocument
*doc
, const gchar
*new_encoding
);
324 void (*document_set_text_changed
) (struct GeanyDocument
*doc
, gboolean changed
);
325 void (*document_set_filetype
) (struct GeanyDocument
*doc
, struct GeanyFiletype
*type
);
326 gboolean (*document_close
) (struct GeanyDocument
*doc
);
327 struct GeanyDocument
* (*document_index
)(gint idx
);
328 gboolean (*document_save_file_as
) (struct GeanyDocument
*doc
, const gchar
*utf8_fname
);
329 void (*document_rename_file
) (struct GeanyDocument
*doc
, const gchar
*new_filename
);
330 const GdkColor
* (*document_get_status_color
) (struct GeanyDocument
*doc
);
331 gchar
* (*document_get_basename_for_display
) (struct GeanyDocument
*doc
, gint length
);
332 gint (*document_get_notebook_page
) (struct GeanyDocument
*doc
);
333 gint (*document_compare_by_display_name
) (gconstpointer a
, gconstpointer b
);
334 gint (*document_compare_by_tab_order
) (gconstpointer a
, gconstpointer b
);
335 gint (*document_compare_by_tab_order_reverse
) (gconstpointer a
, gconstpointer b
);
336 GeanyDocument
* (*document_find_by_id
)(guint id
);
341 struct _ScintillaObject
;
343 /** See http://scintilla.org for the full documentation. */
344 typedef struct ScintillaFuncs
346 /** Send Scintilla a message. */
347 long int (*scintilla_send_message
) (struct _ScintillaObject
*sci
, unsigned int iMessage
,
348 long unsigned int wParam
, long int lParam
);
349 /** Create a new ScintillaObject widget. */
350 GtkWidget
* (*scintilla_new
)(void);
355 /** Wrapper functions for Scintilla messages.
356 * See sciwrappers.h for the list of functions. */
357 typedef struct SciFuncs
359 /** @deprecated Use @c scintilla_send_message() instead. */
360 long int (*sci_send_message
) (struct _ScintillaObject
*sci
, unsigned int iMessage
,
361 long unsigned int wParam
, long int lParam
);
362 void (*sci_send_command
) (struct _ScintillaObject
*sci
, gint cmd
);
364 void (*sci_start_undo_action
) (struct _ScintillaObject
*sci
);
365 void (*sci_end_undo_action
) (struct _ScintillaObject
*sci
);
366 void (*sci_set_text
) (struct _ScintillaObject
*sci
, const gchar
*text
);
367 void (*sci_insert_text
) (struct _ScintillaObject
*sci
, gint pos
, const gchar
*text
);
368 void (*sci_get_text
) (struct _ScintillaObject
*sci
, gint len
, gchar
*text
);
369 gint (*sci_get_length
) (struct _ScintillaObject
*sci
);
370 gint (*sci_get_current_position
) (struct _ScintillaObject
*sci
);
371 void (*sci_set_current_position
) (struct _ScintillaObject
*sci
, gint position
,
372 gboolean scroll_to_caret
);
373 gint (*sci_get_col_from_position
) (struct _ScintillaObject
*sci
, gint position
);
374 gint (*sci_get_line_from_position
) (struct _ScintillaObject
*sci
, gint position
);
375 gint (*sci_get_position_from_line
) (struct _ScintillaObject
*sci
, gint line
);
376 void (*sci_replace_sel
) (struct _ScintillaObject
*sci
, const gchar
*text
);
377 void (*sci_get_selected_text
) (struct _ScintillaObject
*sci
, gchar
*text
);
378 gint (*sci_get_selected_text_length
) (struct _ScintillaObject
*sci
);
379 gint (*sci_get_selection_start
) (struct _ScintillaObject
*sci
);
380 gint (*sci_get_selection_end
) (struct _ScintillaObject
*sci
);
381 gint (*sci_get_selection_mode
) (struct _ScintillaObject
*sci
);
382 void (*sci_set_selection_mode
) (struct _ScintillaObject
*sci
, gint mode
);
383 void (*sci_set_selection_start
) (struct _ScintillaObject
*sci
, gint position
);
384 void (*sci_set_selection_end
) (struct _ScintillaObject
*sci
, gint position
);
385 void (*sci_get_text_range
) (struct _ScintillaObject
*sci
, gint start
, gint end
, gchar
*text
);
386 gchar
* (*sci_get_line
) (struct _ScintillaObject
*sci
, gint line_num
);
387 gint (*sci_get_line_length
) (struct _ScintillaObject
*sci
, gint line
);
388 gint (*sci_get_line_count
) (struct _ScintillaObject
*sci
);
389 gboolean (*sci_get_line_is_visible
) (struct _ScintillaObject
*sci
, gint line
);
390 void (*sci_ensure_line_is_visible
) (struct _ScintillaObject
*sci
, gint line
);
391 void (*sci_scroll_caret
) (struct _ScintillaObject
*sci
);
392 gint (*sci_find_matching_brace
) (struct _ScintillaObject
*sci
, gint pos
);
393 gint (*sci_get_style_at
) (struct _ScintillaObject
*sci
, gint position
);
394 gchar (*sci_get_char_at
) (struct _ScintillaObject
*sci
, gint pos
);
395 gint (*sci_get_current_line
) (struct _ScintillaObject
*sci
);
396 gboolean (*sci_has_selection
) (struct _ScintillaObject
*sci
);
397 gint (*sci_get_tab_width
) (struct _ScintillaObject
*sci
);
398 void (*sci_indicator_clear
) (struct _ScintillaObject
*sci
, gint start
, gint end
);
399 void (*sci_indicator_set
) (struct _ScintillaObject
*sci
, gint indic
);
400 gchar
* (*sci_get_contents
) (struct _ScintillaObject
*sci
, gint len
);
401 gchar
* (*sci_get_contents_range
) (struct _ScintillaObject
*sci
, gint start
, gint end
);
402 gchar
* (*sci_get_selection_contents
) (struct _ScintillaObject
*sci
);
403 void (*sci_set_font
) (struct _ScintillaObject
*sci
, gint style
, const gchar
*font
, gint size
);
404 gint (*sci_get_line_end_position
) (struct _ScintillaObject
*sci
, gint line
);
405 void (*sci_set_target_start
) (struct _ScintillaObject
*sci
, gint start
);
406 void (*sci_set_target_end
) (struct _ScintillaObject
*sci
, gint end
);
407 gint (*sci_replace_target
) (struct _ScintillaObject
*sci
, const gchar
*text
, gboolean regex
);
408 void (*sci_set_marker_at_line
) (struct _ScintillaObject
*sci
, gint line_number
, gint marker
);
409 void (*sci_delete_marker_at_line
) (struct _ScintillaObject
*sci
, gint line_number
, gint marker
);
410 gboolean (*sci_is_marker_set_at_line
) (struct _ScintillaObject
*sci
, gint line
, gint marker
);
411 void (*sci_goto_line
) (struct _ScintillaObject
*sci
, gint line
, gboolean unfold
);
412 gint (*sci_find_text
) (struct _ScintillaObject
*sci
, gint flags
, struct Sci_TextToFind
*ttf
);
413 void (*sci_set_line_indentation
) (struct _ScintillaObject
*sci
, gint line
, gint indent
);
414 gint (*sci_get_line_indentation
) (struct _ScintillaObject
*sci
, gint line
);
415 gint (*sci_get_lexer
) (struct _ScintillaObject
*sci
);
420 /* See templates.h */
421 typedef struct TemplateFuncs
423 gchar
* (*templates_get_template_fileheader
) (gint filetype_idx
, const gchar
*fname
);
429 typedef struct UtilsFuncs
431 gboolean (*utils_str_equal
) (const gchar
*a
, const gchar
*b
);
432 guint (*utils_string_replace_all
) (GString
*haystack
, const gchar
*needle
,
433 const gchar
*replacement
);
434 GSList
* (*utils_get_file_list
) (const gchar
*path
, guint
*length
, GError
**error
);
435 gint (*utils_write_file
) (const gchar
*filename
, const gchar
*text
);
436 gchar
* (*utils_get_locale_from_utf8
) (const gchar
*utf8_text
);
437 gchar
* (*utils_get_utf8_from_locale
) (const gchar
*locale_text
);
438 gchar
* (*utils_remove_ext_from_filename
) (const gchar
*filename
);
439 gint (*utils_mkdir
) (const gchar
*path
, gboolean create_parent_dirs
);
440 gboolean (*utils_get_setting_boolean
) (GKeyFile
*config
, const gchar
*section
, const gchar
*key
,
441 const gboolean default_value
);
442 gint (*utils_get_setting_integer
) (GKeyFile
*config
, const gchar
*section
, const gchar
*key
,
443 const gint default_value
);
444 gchar
* (*utils_get_setting_string
) (GKeyFile
*config
, const gchar
*section
, const gchar
*key
,
445 const gchar
*default_value
);
446 gboolean (*utils_spawn_sync
) (const gchar
*dir
, gchar
**argv
, gchar
**env
, GSpawnFlags flags
,
447 GSpawnChildSetupFunc child_setup
, gpointer user_data
, gchar
**std_out
,
448 gchar
**std_err
, gint
*exit_status
, GError
**error
);
449 gboolean (*utils_spawn_async
) (const gchar
*dir
, gchar
**argv
, gchar
**env
, GSpawnFlags flags
,
450 GSpawnChildSetupFunc child_setup
, gpointer user_data
, GPid
*child_pid
,
452 gint (*utils_str_casecmp
) (const gchar
*s1
, const gchar
*s2
);
453 gchar
* (*utils_get_date_time
) (const gchar
*format
, time_t *time_to_use
);
454 void (*utils_open_browser
) (const gchar
*uri
);
455 guint (*utils_string_replace_first
) (GString
*haystack
, const gchar
*needle
,
456 const gchar
*replace
);
457 gchar
* (*utils_str_middle_truncate
) (const gchar
*string
, guint truncate_length
);
458 gchar
* (*utils_str_remove_chars
) (gchar
*string
, const gchar
*chars
);
459 GSList
* (*utils_get_file_list_full
)(const gchar
*path
, gboolean full_path
, gboolean sort
,
461 gchar
** (*utils_copy_environment
)(const gchar
**exclude_vars
, const gchar
*first_varname
, ...);
462 gchar
* (*utils_find_open_xml_tag
) (const gchar sel
[], gint size
);
463 const gchar
* (*utils_find_open_xml_tag_pos
) (const gchar sel
[], gint size
);
469 typedef struct MainFuncs
471 void (*main_reload_configuration
) (void);
472 void (*main_locale_init
) (const gchar
*locale_dir
, const gchar
*package
);
473 gboolean (*main_is_realized
) (void);
479 typedef struct UIUtilsFuncs
481 GtkWidget
* (*ui_dialog_vbox_new
) (GtkDialog
*dialog
);
482 GtkWidget
* (*ui_frame_new_with_alignment
) (const gchar
*label_text
, GtkWidget
**alignment
);
483 void (*ui_set_statusbar
) (gboolean log
, const gchar
*format
, ...) G_GNUC_PRINTF (2, 3);
484 void (*ui_table_add_row
) (GtkTable
*table
, gint row
, ...) G_GNUC_NULL_TERMINATED
;
485 GtkWidget
* (*ui_path_box_new
) (const gchar
*title
, GtkFileChooserAction action
, GtkEntry
*entry
);
486 GtkWidget
* (*ui_button_new_with_image
) (const gchar
*stock_id
, const gchar
*text
);
487 void (*ui_add_document_sensitive
) (GtkWidget
*widget
);
488 void (*ui_widget_set_tooltip_text
) (GtkWidget
*widget
, const gchar
*text
);
489 GtkWidget
* (*ui_image_menu_item_new
) (const gchar
*stock_id
, const gchar
*label
);
490 GtkWidget
* (*ui_lookup_widget
) (GtkWidget
*widget
, const gchar
*widget_name
);
491 void (*ui_progress_bar_start
) (const gchar
*text
);
492 void (*ui_progress_bar_stop
) (void);
493 void (*ui_entry_add_clear_icon
) (GtkEntry
*entry
);
494 void (*ui_menu_add_document_items
) (GtkMenu
*menu
, struct GeanyDocument
*active
,
496 void (*ui_widget_modify_font_from_string
) (GtkWidget
*widget
, const gchar
*str
);
497 gboolean (*ui_is_keyval_enter_or_return
) (guint keyval
);
498 gint (*ui_get_gtk_settings_integer
) (const gchar
*property_name
, gint default_value
);
499 void (*ui_combo_box_add_to_history
) (GtkComboBoxText
*combo_entry
,
500 const gchar
*text
, gint history_len
);
501 void (*ui_menu_add_document_items_sorted
) (GtkMenu
*menu
, struct GeanyDocument
*active
,
502 GCallback callback
, GCompareFunc compare_func
);
503 const gchar
* (*ui_lookup_stock_label
)(const gchar
*stock_id
);
509 typedef struct DialogFuncs
511 gboolean (*dialogs_show_question
) (const gchar
*text
, ...) G_GNUC_PRINTF (1, 2);
512 void (*dialogs_show_msgbox
) (GtkMessageType type
, const gchar
*text
, ...) G_GNUC_PRINTF (2, 3);
513 gboolean (*dialogs_show_save_as
) (void);
514 gboolean (*dialogs_show_input_numeric
) (const gchar
*title
, const gchar
*label_text
,
515 gdouble
*value
, gdouble min
, gdouble max
, gdouble step
);
516 gchar
* (*dialogs_show_input
)(const gchar
*title
, GtkWindow
*parent
, const gchar
*label_text
,
517 const gchar
*default_text
);
522 /* @deprecated Use ui_lookup_widget() instead. */
523 typedef struct SupportFuncs
525 GtkWidget
* (*support_lookup_widget
) (GtkWidget
*widget
, const gchar
*widget_name
);
530 /* See msgwindow.h */
531 typedef struct MsgWinFuncs
533 /* status_add() does not set the status bar - use ui->set_statusbar() instead. */
534 void (*msgwin_status_add
) (const gchar
*format
, ...) G_GNUC_PRINTF (1, 2);
535 void (*msgwin_compiler_add
) (gint msg_color
, const gchar
*format
, ...) G_GNUC_PRINTF (2, 3);
536 void (*msgwin_msg_add
) (gint msg_color
, gint line
, struct GeanyDocument
*doc
,
537 const gchar
*format
, ...) G_GNUC_PRINTF (4, 5);
538 void (*msgwin_clear_tab
) (gint tabnum
);
539 void (*msgwin_switch_tab
) (gint tabnum
, gboolean show
);
540 void (*msgwin_set_messages_dir
) (const gchar
*messages_dir
);
545 /* See encodings.h */
546 typedef struct EncodingFuncs
548 gchar
* (*encodings_convert_to_utf8
) (const gchar
*buffer
, gssize size
, gchar
**used_encoding
);
549 gchar
* (*encodings_convert_to_utf8_from_charset
) (const gchar
*buffer
, gssize size
,
550 const gchar
*charset
, gboolean fast
);
551 const gchar
* (*encodings_get_charset_from_index
) (gint idx
);
556 struct GeanyKeyGroup
;
557 /* avoid including keybindings.h */
558 typedef void (*_GeanyKeyCallback
) (guint key_id
);
560 /* See keybindings.h */
561 typedef struct KeybindingFuncs
563 void (*keybindings_send_command
) (guint group_id
, guint key_id
);
564 struct GeanyKeyBinding
* (*keybindings_set_item
) (struct GeanyKeyGroup
*group
, gsize key_id
,
565 _GeanyKeyCallback callback
, guint key
, GdkModifierType mod
,
566 const gchar
*name
, const gchar
*label
, GtkWidget
*menu_item
);
567 struct GeanyKeyBinding
* (*keybindings_get_item
)(struct GeanyKeyGroup
*group
, gsize key_id
);
573 /* See highlighting.h */
574 typedef struct HighlightingFuncs
576 const struct GeanyLexerStyle
* (*highlighting_get_style
) (gint ft_id
, gint style_id
);
577 void (*highlighting_set_styles
) (struct _ScintillaObject
*sci
, struct GeanyFiletype
*ft
);
578 gboolean (*highlighting_is_string_style
) (gint lexer
, gint style
);
579 gboolean (*highlighting_is_comment_style
) (gint lexer
, gint style
);
580 gboolean (*highlighting_is_code_style
) (gint lexer
, gint style
);
585 /* See filetypes.h */
586 typedef struct FiletypeFuncs
588 GeanyFiletype
* (*filetypes_detect_from_file
) (const gchar
*utf8_filename
);
589 GeanyFiletype
* (*filetypes_lookup_by_name
) (const gchar
*name
);
590 GeanyFiletype
* (*filetypes_index
)(gint idx
);
591 const gchar
* (*filetypes_get_display_name
)(GeanyFiletype
*ft
);
592 const GSList
* (*filetypes_get_sorted_by_name
)(void);
593 /* Remember to convert any filetype_id arguments to GeanyFiletype pointers in any
594 * appended functions */
600 typedef struct SearchFuncs
602 void (*search_show_find_in_files_dialog
) (const gchar
*dir
);
607 /* See tagmanager/include */
608 typedef struct TagManagerFuncs
610 gchar
* (*tm_get_real_path
) (const gchar
*file_name
);
611 TMSourceFile
* (*tm_source_file_new
) (const char *file_name
, const char *name
);
612 void (*tm_source_file_free
) (TMSourceFile
*source_file
);
613 void (*tm_workspace_add_source_file
) (TMSourceFile
*source_file
);
614 void (*tm_workspace_remove_source_file
) (TMSourceFile
*source_file
);
615 void (*tm_workspace_add_source_files
) (GPtrArray
*source_files
);
616 void (*tm_workspace_remove_source_files
) (GPtrArray
*source_files
);
622 typedef struct NavQueueFuncs
624 gboolean (*navqueue_goto_line
) (struct GeanyDocument
*old_doc
, struct GeanyDocument
*new_doc
,
633 typedef struct EditorFuncs
635 const struct GeanyIndentPrefs
* (*editor_get_indent_prefs
)(struct GeanyEditor
*editor
);
636 struct _ScintillaObject
* (*editor_create_widget
)(struct GeanyEditor
*editor
);
638 void (*editor_indicator_set_on_range
) (struct GeanyEditor
*editor
, gint indic
, gint start
, gint end
);
639 void (*editor_indicator_set_on_line
) (struct GeanyEditor
*editor
, gint indic
, gint line
);
640 void (*editor_indicator_clear
) (struct GeanyEditor
*editor
, gint indic
);
642 void (*editor_set_indent_type
)(struct GeanyEditor
*editor
, GeanyIndentType type
);
643 gchar
* (*editor_get_word_at_pos
) (struct GeanyEditor
*editor
, gint pos
, const gchar
*wordchars
);
645 const gchar
* (*editor_get_eol_char_name
) (struct GeanyEditor
*editor
);
646 gint (*editor_get_eol_char_len
) (struct GeanyEditor
*editor
);
647 const gchar
* (*editor_get_eol_char
) (struct GeanyEditor
*editor
);
649 void (*editor_insert_text_block
) (struct GeanyEditor
*editor
, const gchar
*text
,
650 gint insert_pos
, gint cursor_index
, gint newline_indent_size
,
651 gboolean replace_newlines
);
653 gint (*editor_get_eol_char_mode
) (struct GeanyEditor
*editor
);
654 gboolean (*editor_goto_pos
) (struct GeanyEditor
*editor
, gint pos
, gboolean mark
);
656 const gchar
* (*editor_find_snippet
) (struct GeanyEditor
*editor
, const gchar
*snippet_name
);
657 void (*editor_insert_snippet
) (struct GeanyEditor
*editor
, gint pos
, const gchar
*snippet
);
662 /* avoid including keybindings.h */
663 typedef gboolean (*_GeanyKeyGroupCallback
) (guint key_id
);
665 /* See pluginutils.c */
666 typedef struct PluginFuncs
668 void (*plugin_add_toolbar_item
)(GeanyPlugin
*plugin
, GtkToolItem
*item
);
669 void (*plugin_module_make_resident
) (GeanyPlugin
*plugin
);
670 void (*plugin_signal_connect
) (GeanyPlugin
*plugin
,
671 GObject
*object
, const gchar
*signal_name
, gboolean after
,
672 GCallback callback
, gpointer user_data
);
673 struct GeanyKeyGroup
* (*plugin_set_key_group
)(GeanyPlugin
*plugin
,
674 const gchar
*section_name
, gsize count
, _GeanyKeyGroupCallback callback
);
675 void (*plugin_show_configure
)(GeanyPlugin
*plugin
);
676 guint (*plugin_timeout_add
) (GeanyPlugin
*plugin
, guint interval
, GSourceFunc function
,
678 guint (*plugin_timeout_add_seconds
) (GeanyPlugin
*plugin
, guint interval
,
679 GSourceFunc function
, gpointer data
);
680 guint (*plugin_idle_add
) (GeanyPlugin
*plugin
, GSourceFunc function
, gpointer data
);
681 void (*plugin_builder_connect_signals
) (GeanyPlugin
*plugin
, GtkBuilder
*builder
, gpointer user_data
);
689 typedef struct StashFuncs
691 struct StashGroup
*(*stash_group_new
)(const gchar
*name
);
692 void (*stash_group_add_boolean
)(struct StashGroup
*group
, gboolean
*setting
,
693 const gchar
*key_name
, gboolean default_value
);
694 void (*stash_group_add_integer
)(struct StashGroup
*group
, gint
*setting
,
695 const gchar
*key_name
, gint default_value
);
696 void (*stash_group_add_string
)(struct StashGroup
*group
, gchar
**setting
,
697 const gchar
*key_name
, const gchar
*default_value
);
698 void (*stash_group_add_string_vector
)(struct StashGroup
*group
, gchar
***setting
,
699 const gchar
*key_name
, const gchar
**default_value
);
700 void (*stash_group_load_from_key_file
)(struct StashGroup
*group
, GKeyFile
*keyfile
);
701 void (*stash_group_save_to_key_file
)(struct StashGroup
*group
, GKeyFile
*keyfile
);
702 void (*stash_group_free
)(struct StashGroup
*group
);
703 gboolean (*stash_group_load_from_file
)(struct StashGroup
*group
, const gchar
*filename
);
704 gint (*stash_group_save_to_file
)(struct StashGroup
*group
, const gchar
*filename
,
705 GKeyFileFlags flags
);
706 void (*stash_group_add_toggle_button
)(struct StashGroup
*group
, gboolean
*setting
,
707 const gchar
*key_name
, gboolean default_value
, gconstpointer widget_id
);
708 void (*stash_group_add_radio_buttons
)(struct StashGroup
*group
, gint
*setting
,
709 const gchar
*key_name
, gint default_value
,
710 gconstpointer widget_id
, gint enum_id
, ...) G_GNUC_NULL_TERMINATED
;
711 void (*stash_group_add_spin_button_integer
)(struct StashGroup
*group
, gint
*setting
,
712 const gchar
*key_name
, gint default_value
, gconstpointer widget_id
);
713 void (*stash_group_add_combo_box
)(struct StashGroup
*group
, gint
*setting
,
714 const gchar
*key_name
, gint default_value
, gconstpointer widget_id
);
715 void (*stash_group_add_combo_box_entry
)(struct StashGroup
*group
, gchar
**setting
,
716 const gchar
*key_name
, const gchar
*default_value
, gconstpointer widget_id
);
717 void (*stash_group_add_entry
)(struct StashGroup
*group
, gchar
**setting
,
718 const gchar
*key_name
, const gchar
*default_value
, gconstpointer widget_id
);
719 void (*stash_group_add_widget_property
)(struct StashGroup
*group
, gpointer setting
,
720 const gchar
*key_name
, gpointer default_value
, gconstpointer widget_id
,
721 const gchar
*property_name
, GType type
);
722 void (*stash_group_display
)(struct StashGroup
*group
, GtkWidget
*owner
);
723 void (*stash_group_update
)(struct StashGroup
*group
, GtkWidget
*owner
);
724 void (*stash_group_free_settings
)(struct StashGroup
*group
);
730 typedef struct SymbolsFuncs
732 const gchar
* (*symbols_get_context_separator
)(gint ft_id
);
737 typedef struct BuildFuncs
739 void (*build_activate_menu_item
)(const GeanyBuildGroup grp
, const guint cmd
);
740 const gchar
*(*build_get_current_menu_item
)(const GeanyBuildGroup grp
, const guint cmd
,
741 const GeanyBuildCmdEntries field
);
742 void (*build_remove_menu_item
)(const GeanyBuildSource src
, const GeanyBuildGroup grp
,
744 void (*build_set_menu_item
)(const GeanyBuildSource src
, const GeanyBuildGroup grp
,
745 const guint cmd
, const GeanyBuildCmdEntries field
, const gchar
*value
);
746 guint (*build_get_group_count
)(const GeanyBuildGroup grp
);
751 typedef struct ProjectFuncs
753 void (*project_write_config
)(void);
757 /* Deprecated aliases */
758 #ifndef GEANY_DISABLE_DEPRECATED
760 #define document_reload_file document_reload_force
762 /** @deprecated - copy into your plugin code if needed.
763 * @c NULL-safe way to get the index of @a doc_ptr in the documents array. */
764 #define DOC_IDX(doc_ptr) \
765 (doc_ptr ? doc_ptr->index : -1)
766 #define DOC_IDX_VALID(doc_idx) \
767 ((doc_idx) >= 0 && (guint)(doc_idx) < documents_array->len && documents[doc_idx]->is_valid)
769 #define GEANY_WINDOW_MINIMAL_WIDTH 550
770 #define GEANY_WINDOW_MINIMAL_HEIGHT GEANY_DEFAULT_DIALOG_HEIGHT
772 #endif /* GEANY_DISABLE_DEPRECATED */
776 #endif /* GEANY_PLUGIN_DATA_H */