geany  1.38
About: Geany is a text editor (using GTK2) with basic features of an integrated development environment (syntax highlighting, code folding, symbol name auto-completion, ...). F: office T: editor programming GTK+ IDE
  Fossies Dox: geany-1.38.tar.bz2  ("unofficial" and yet experimental doxygen-generated source code documentation)  

libmain.c File Reference
#include "main.h"
#include "app.h"
#include "build.h"
#include "callbacks.h"
#include "dialogs.h"
#include "document.h"
#include "encodingsprivate.h"
#include "filetypes.h"
#include "geanyobject.h"
#include "highlighting.h"
#include "keybindings.h"
#include "keyfile.h"
#include "log.h"
#include "msgwindow.h"
#include "navqueue.h"
#include "notebook.h"
#include "plugins.h"
#include "prefs.h"
#include "printing.h"
#include "sidebar.h"
#include "support.h"
#include "symbols.h"
#include "templates.h"
#include "toolbar.h"
#include "tools.h"
#include "ui_utils.h"
#include "utils.h"
#include "vte.h"
#include "win32.h"
#include "osx.h"
#include <signal.h>
#include <time.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <errno.h>
#include <string.h>
#include <stdlib.h>
#include <gtk/gtk.h>
#include <glib/gstdio.h>
Include dependency graph for libmain.c:

Go to the source code of this file.


static void setup_window_position (void)
static void apply_settings (void)
static void on_window_active_changed (GtkWindow *window, GParamSpec *pspec, gpointer data)
static void main_init (void)
const gchar * main_get_version_string (void)
gchar * main_get_argv_filename (const gchar *filename)
static void get_line_and_column_from_filename (gchar *filename, gint *line, gint *column)
static void setup_paths (void)
gboolean main_is_realized (void)
 Checks whether the main window has been realized. More...
void main_locale_init (const gchar *locale_dir, const gchar *package)
 Initialises the gettext translation system. More...
static void print_filetypes (void)
static void wait_for_input_on_windows (void)
static void parse_command_line_options (gint *argc, gchar ***argv)
static gint create_config_dir (void)
static gint setup_config_dir (void)
gboolean main_handle_filename (const gchar *locale_filename)
static void open_cl_files (gint argc, gchar **argv)
static void load_session_project_file (void)
static void load_settings (void)
void main_load_project_from_command_line (const gchar *locale_filename, gboolean use_session)
static void load_startup_files (gint argc, gchar **argv)
static gboolean send_startup_complete (gpointer data)
static const gchar * get_locale (void)
GEANY_EXPORT_SYMBOL gint main_lib (gint argc, gchar **argv)
static void queue_free (GQueue *queue)
static gboolean do_main_quit (void)
static gboolean check_no_unsaved (void)
gboolean main_quit (void)
void main_reload_configuration (void)
 Reloads most of Geany's configuration files without restarting. More...


gboolean ignore_callback
GeanyStatus main_status
CommandLineOptions cl_options
static gchar * original_cwd = NULL
static const gchar geany_lib_versions [] = "GTK %u.%u.%u, GLib %u.%u.%u"
static gboolean want_plugins
static gboolean verbose_mode = FALSE
static gboolean ignore_global_tags = FALSE
static gboolean no_msgwin = FALSE
static gboolean show_version = FALSE
static gchar * alternate_config = NULL
static gboolean generate_tags = FALSE
static gboolean no_preprocessing = FALSE
static gboolean ft_names = FALSE
static gboolean print_prefix = FALSE
static gboolean no_plugins = FALSE
static gboolean dummy = FALSE
static GOptionEntry entries []

Function Documentation

◆ apply_settings()

◆ check_no_unsaved()

static gboolean check_no_unsaved ( void  )

Definition at line 1367 of file libmain.c.

References documents, and documents_array.

Referenced by main_quit().

◆ create_config_dir()

◆ do_main_quit()

static gboolean do_main_quit ( void  )

Definition at line 1255 of file libmain.c.

References app, GeanyToolPrefs::browser_cmd, build_finalize(), GeanyEditorPrefs::color_scheme, GeanyEditorPrefs::comment_toggle_mark, GeanyTemplatePrefs::company, GeanyApp::configdir, configuration_finalize(), configuration_save(), GeanyToolPrefs::context_action_cmd, GeanyPrefs::custom_plugin_path, GeanyApp::datadir, GeanyPrefs::default_open_path, GeanyTemplatePrefs::developer, GeanyApp::docdir, document_close_all(), document_finalize(), editor_finalize(), GeanyInterfacePrefs::editor_font, GeanyMainWidgets::editor_menu, editor_prefs, editor_snippets_free(), encodings_finalize(), PrintingPrefs::external_print_cmd, filetypes_free_types(), geany_debug(), geany_object, GeanyToolPrefs::grep_cmd, highlighting_free_styles(), GeanyTemplatePrefs::initials, interface_prefs, keybindings_free(), log_finalize(), GeanyEditorPrefs::long_line_color, GeanyTemplatePrefs::mail, main_status, main_widgets, msgwin_finalize(), GeanyInterfacePrefs::msgwin_font, msgwindow, navqueue_free(), notebook_free(), NULL, original_cwd, PrintingPrefs::page_header_datefmt, plugins_finalize(), prefs, printing_prefs, GeanyApp::project, project_close, project_finalize(), queue_free(), search_finalize(), sidebar_finalize(), socket_finalize(), symbols_finalize(), GeanyInterfacePrefs::tagbar_font, template_prefs, templates_free_templates(), GeanyToolPrefs::term_cmd, tm_workspace_free(), tool_prefs, toolbar_finalize(), ui_finalize_builder(), ui_prefs, ui_widgets, GeanyTemplatePrefs::version, and GeanyMainWidgets::window.

Referenced by main_quit().

◆ get_line_and_column_from_filename()

static void get_line_and_column_from_filename ( gchar *  filename,
gint *  line,
gint *  column 

Definition at line 343 of file libmain.c.

References EMPTY, filename, and line.

Referenced by main_handle_filename().

◆ get_locale()

static const gchar * get_locale ( void  )

Definition at line 999 of file libmain.c.

References NULL.

Referenced by main_lib().

◆ load_session_project_file()

static void load_session_project_file ( void  )

Definition at line 897 of file libmain.c.

References EMPTY, NULL, project_load_file(), project_prefs, and utils_get_locale_from_utf8().

Referenced by load_startup_files().

◆ load_settings()

static void load_settings ( void  )

Definition at line 913 of file libmain.c.

References configuration_load(), GeanyPrefs::load_plugins, no_msgwin, no_plugins, prefs, ui_prefs, and want_plugins.

Referenced by main_lib().

◆ load_startup_files()

◆ main_get_argv_filename()

gchar * main_get_argv_filename ( const gchar *  filename)

Definition at line 317 of file libmain.c.

References filename, NULL, original_cwd, and utils_is_uri().

Referenced by load_startup_files(), and open_cl_files().

◆ main_get_version_string()

const gchar * main_get_version_string ( void  )

Definition at line 304 of file libmain.c.

References utils_str_equal().

Referenced by create_dialog(), main_lib(), and parse_command_line_options().

◆ main_handle_filename()

◆ main_init()

◆ main_is_realized()

gboolean main_is_realized ( void  )

Checks whether the main window has been realized.

This is an easy indicator whether Geany is right now starting up (main window is not yet realized) or whether it has finished the startup process (main window is realized). This is because the main window is realized (i.e. actually drawn on the screen) at the end of the startup process.

Maybe you want to use the "geany-startup-complete" signal to get notified about the completed startup process.
TRUE if the Geany main window has been realized or FALSE otherwise.

Definition at line 458 of file libmain.c.

References main_status.

◆ main_lib()

GEANY_EXPORT_SYMBOL gint main_lib ( gint  argc,
gchar **  argv 

Definition at line 1010 of file libmain.c.

References _, app, apply_settings(), build_init(), build_menu_update(), cl_options, GeanyApp::configdir, configuration_apply_settings(), configuration_init(), GeanyApp::datadir, GeanyApp::docdir, document_get_current(), document_grab_focus(), document_init_doclist(), document_new_file_if_non_open(), editor_init(), editor_snippets_init(), encodings_init(), file_prefs, filetypes_init(), geany_debug(), geany_lib_versions, geany_object, geany_object_new(), get_locale(), GETTEXT_PACKAGE, SocketInfo::ignore_socket, interface_prefs, keybindings_init(), keybindings_load_keyfile(), load_settings(), load_startup_files(), SocketInfo::lock_socket, SocketInfo::lock_socket_tag, log_handlers_init(), main_get_version_string(), main_init(), main_locale_init(), main_status, main_widgets, msgwin_init(), navqueue_init(), notebook_init(), NULL, parse_command_line_options(), plugins_init(), plugins_load_active(), prefs, project_init(), SocketInfo::read_ioc, search_init(), search_prefs, send_startup_complete(), setup_config_dir(), setup_paths(), setup_window_position(), sidebar_init(), GeanyMainWidgets::sidebar_notebook, sidebar_select_openfiles_item(), sidebar_update_tag_list(), socket_finalize(), socket_info, socket_init(), socket_lock_input_cb(), symbols_init(), template_prefs, templates_init(), tm_get_workspace(), GeanyApp::tm_workspace, tool_prefs, toolbar_prefs, tools_create_insert_custom_command_menu_items(), ui_create_insert_date_menu_items(), ui_create_insert_menu_items(), ui_create_recent_menus(), ui_document_buttons_update(), ui_init_prefs(), ui_prefs, ui_save_buttons_toggle(), ui_set_statusbar(), ui_sidebar_show_hide(), ui_widgets, utils_get_os_info_string(), utils_get_utf8_from_locale(), utils_resource_dir(), want_plugins, and GeanyMainWidgets::window.

Referenced by main().

◆ main_load_project_from_command_line()

void main_load_project_from_command_line ( const gchar *  locale_filename,
gboolean  use_session 

◆ main_locale_init()

void main_locale_init ( const gchar *  locale_dir,
const gchar *  package 

Initialises the gettext translation system.

This is a convenience function to set up gettext for internationalisation support in external plugins. You should call this function early in plugin_init(). If the macro HAVE_LOCALE_H is defined, setlocale(LC_ALL, "") is called. The codeset for the message translations is set to UTF-8.

Note that this function only setups the gettext textdomain for you. You still have to adjust the build system of your plugin to get internationalisation support working properly.

If you have already used PLUGIN_SET_TRANSLATABLE_INFO() you don't need to call main_locale_init() again as it has already been done.

locale_dirThe location where the translation files should be searched. This is usually the LOCALEDIR macro, defined by the build system. E.g. $prefix/share/locale. Only used on non-Windows systems. On Windows, the directory is determined by g_win32_get_package_installation_directory().
packageThe package name, usually this is the GETTEXT_PACKAGE macro, defined by the build system.

Definition at line 489 of file libmain.c.

References bind_textdomain_codeset, bindtextdomain, and utils_resource_dir().

Referenced by geany_load_module(), and main_lib().

◆ main_quit()

◆ main_reload_configuration()

void main_reload_configuration ( void  )

Reloads most of Geany's configuration files without restarting.

Currently the following files are reloaded: all template files, also new file templates and the 'New (with template)' menus will be updated, Snippets (snippets.conf), filetype extensions (filetype_extensions.conf), and 'settings' and 'build_settings' sections of the filetype definition files.

Plugins may call this function if they changed any of these files (e.g. a configuration file editor plugin).


Definition at line 1417 of file libmain.c.

References _, editor_snippets_free(), editor_snippets_init(), filetypes_reload(), filetypes_reload_extensions(), symbols_reload_config_files(), templates_free_templates(), templates_init(), and ui_set_statusbar().

Referenced by on_menu_reload_configuration1_activate().

◆ on_window_active_changed()

static void on_window_active_changed ( GtkWindow *  window,
GParamSpec *  pspec,
gpointer  data 

Definition at line 235 of file libmain.c.

References document_check_disk_status(), and document_get_current().

Referenced by main_init().

◆ open_cl_files()

static void open_cl_files ( gint  argc,
gchar **  argv 

◆ parse_command_line_options()

◆ print_filetypes()

static void print_filetypes ( void  )

◆ queue_free()

static void queue_free ( GQueue *  queue)

Definition at line 1245 of file libmain.c.

Referenced by do_main_quit().

◆ send_startup_complete()

static gboolean send_startup_complete ( gpointer  data)

Definition at line 992 of file libmain.c.

References geany_object.

Referenced by main_lib().

◆ setup_config_dir()

static gint setup_config_dir ( void  )

Definition at line 778 of file libmain.c.

References _, app, GeanyApp::configdir, create_config_dir(), dialogs_show_question(), SETPTR, and utils_get_real_path().

Referenced by main_lib().

◆ setup_paths()

static void setup_paths ( void  )

Definition at line 435 of file libmain.c.

References app, GeanyApp::datadir, GeanyApp::docdir, utils_get_locale_from_utf8(), and utils_resource_dir().

Referenced by main_lib().

◆ setup_window_position()

static void setup_window_position ( void  )

◆ wait_for_input_on_windows()

static void wait_for_input_on_windows ( void  )

Definition at line 521 of file libmain.c.

References geany_debug(), and verbose_mode.

Referenced by parse_command_line_options().

Variable Documentation

◆ alternate_config

gchar* alternate_config = NULL

Definition at line 103 of file libmain.c.

Referenced by create_config_dir(), and parse_command_line_options().

◆ app

GeanyApp* app

Definition at line 86 of file libmain.c.

Referenced by add_color_scheme_file(), add_css_config_file_item(), build_replace_placeholder(), cb_func_project_action(), check_plugin_path(), configuration_clear_default_session(), configuration_load(), configuration_reload_default_session(), configuration_save(), configuration_save_default_session(), create_config_dir(), create_dialog(), create_fif_file_mode_combo(), create_project(), destroy_project(), detect_filetype_conf_file(), dialogs_show_open_file(), do_main_quit(), document_highlight_tags(), document_update_tags(), documents_menu_update(), editor_get_long_line_column(), editor_get_long_line_type(), editor_init(), editor_snippets_init(), filetypes_get_filename(), filetypes_init_types(), geany_data_init(), get_default_indent_prefs(), get_doc_folder(), handle_current_session(), handler_log(), init_css_styles(), init_user_tags(), keybindings_write_to_file(), load_all_plugins(), load_c_ignore_tags(), load_config(), load_named_styles(), load_startup_files(), load_user_kb(), main_init(), main_lib(), on_color_scheme_changed(), on_config_file_clicked(), on_document_save(), on_menu_open_selected_file1_activate(), on_menu_project1_activate(), on_new_with_file_template(), on_set_build_commands_activate(), open_file_dialog_handle_response(), parse_command_line_options(), prefs_init_dialog(), project_ask_close(), project_close(), project_get_base_path(), project_get_file_prefs(), project_load_file(), project_open(), project_save_prefs(), read_filetype_config(), read_template(), recent_project_activate_cb(), register_legacy_plugin(), run_new_dialog(), run_open_dialog(), save_configuration_cb(), search_show_find_in_files_dialog_full(), setup_config_dir(), setup_config_file_menus(), setup_paths(), show_project_properties(), show_save_as_gtk(), symbols_find_typenames_as_string(), symbols_global_tags_loaded(), symbols_init(), tb_editor_write_markup(), templates_replace_common(), toolbar_reload(), ui_init_builder(), ui_set_window_title(), ui_update_recent_project_menu(), update_config(), update_fif_file_mode_combo(), update_file_patterns(), utils_get_config_files(), utils_get_default_dir_utf8(), utils_get_help_url(), and write_config().

◆ cl_options

◆ dummy

gboolean dummy = FALSE

Definition at line 115 of file libmain.c.

Referenced by asprintf(), get_tag_icon(), handle_strv_setting(), mio_vprintf(), and tm_tag_is_anon().

◆ entries

GOptionEntry entries[]
Initial value:
{ "column", 0, 0, G_OPTION_ARG_INT, &cl_options.goto_column, "Set initial column number to COLUMN for the first opened file (useful in conjunction with --line)" , "COLUMN" },
{ "config", 'c', 0, G_OPTION_ARG_FILENAME, &alternate_config, "Use alternate configuration directory DIR" , "DIR" },
{ "ft-names", 0, 0, G_OPTION_ARG_NONE, &ft_names, "Print internal filetype names" , NULL },
{ "generate-tags", 'g', 0, G_OPTION_ARG_NONE, &generate_tags, "Generate global tags file (see documentation)" , NULL },
{ "no-preprocessing", 'P', 0, G_OPTION_ARG_NONE, &no_preprocessing, "Don't preprocess C/C++ files when generating tags file" , NULL },
{ "line", 'l', 0, G_OPTION_ARG_INT, &cl_options.goto_line, "Set initial line number to LINE for the first opened file" , "LINE" },
{ "no-msgwin", 'm', 0, G_OPTION_ARG_NONE, &no_msgwin, "Don't show message window at startup" , NULL },
{ "no-ctags", 'n', 0, G_OPTION_ARG_NONE, &ignore_global_tags, "Don't load auto completion data (see documentation)" , NULL },
{ "no-plugins", 'p', 0, G_OPTION_ARG_NONE, &no_plugins, "Don't load plugins" , NULL },
{ "print-prefix", 0, 0, G_OPTION_ARG_NONE, &print_prefix, "Print Geany's installation prefix" , NULL },
{ "read-only", 'r', 0, G_OPTION_ARG_NONE, &cl_options.readonly, "Open all FILES in read-only mode (see documentation)" , NULL },
{ "no-session", 's', G_OPTION_FLAG_REVERSE, G_OPTION_ARG_NONE, &cl_options.load_session, "Don't load the previous session's files" , NULL },
{ "verbose", 'v', 0, G_OPTION_ARG_NONE, &verbose_mode, "Be verbose" , NULL },
{ "version", 'V', 0, G_OPTION_ARG_NONE, &show_version, "Show version and exit" , NULL },
{ NULL, 0, 0, 0, NULL, NULL, NULL }
static gboolean verbose_mode
Definition: libmain.c:99
static gboolean no_plugins
Definition: libmain.c:113
CommandLineOptions cl_options
Definition: libmain.c:90
static gboolean print_prefix
Definition: libmain.c:111
static gboolean ignore_global_tags
Definition: libmain.c:100
static gboolean no_preprocessing
Definition: libmain.c:109
static gboolean generate_tags
Definition: libmain.c:108
static gboolean show_version
Definition: libmain.c:102
static gboolean dummy
Definition: libmain.c:115
static gboolean no_msgwin
Definition: libmain.c:101
static gboolean ft_names
Definition: libmain.c:110
static gchar * alternate_config
Definition: libmain.c:103
#define NULL
Definition: rbtree.h:150

Definition at line 118 of file libmain.c.

Referenced by hasScopeActionInRegex(), hasScopeActionInRegex0(), parse_command_line_options(), printfcmds(), and read_row().

◆ ft_names

gboolean ft_names = FALSE

Definition at line 110 of file libmain.c.

Referenced by build_save_menu(), and parse_command_line_options().

◆ geany_lib_versions

const gchar geany_lib_versions[] = "GTK %u.%u.%u, GLib %u.%u.%u"

Definition at line 94 of file libmain.c.

Referenced by main_lib(), and parse_command_line_options().

◆ generate_tags

gboolean generate_tags = FALSE

Definition at line 108 of file libmain.c.

Referenced by parse_command_line_options().

◆ ignore_callback

◆ ignore_global_tags

gboolean ignore_global_tags = FALSE

Definition at line 100 of file libmain.c.

Referenced by parse_command_line_options().

◆ main_status

◆ no_msgwin

gboolean no_msgwin = FALSE

Definition at line 101 of file libmain.c.

Referenced by load_settings().

◆ no_plugins

gboolean no_plugins = FALSE

Definition at line 113 of file libmain.c.

Referenced by load_settings().

◆ no_preprocessing

gboolean no_preprocessing = FALSE

Definition at line 109 of file libmain.c.

Referenced by parse_command_line_options().

◆ original_cwd

gchar* original_cwd = NULL

Definition at line 92 of file libmain.c.

Referenced by do_main_quit(), and main_get_argv_filename().

◆ print_prefix

gboolean print_prefix = FALSE

Definition at line 111 of file libmain.c.

Referenced by parse_command_line_options().

◆ show_version

gboolean show_version = FALSE

Definition at line 102 of file libmain.c.

Referenced by parse_command_line_options().

◆ verbose_mode

gboolean verbose_mode = FALSE

Definition at line 99 of file libmain.c.

Referenced by parse_command_line_options(), and wait_for_input_on_windows().

◆ want_plugins

gboolean want_plugins

Definition at line 96 of file libmain.c.

Referenced by load_settings(), and main_lib().