75#include <glib/gstdio.h>
78# include <glib-unix.h>
105static gboolean no_vte = FALSE;
106static gchar *lib_vte =
NULL;
120 {
"column", 0, 0, G_OPTION_ARG_INT, &
cl_options.goto_column,
N_(
"Set initial column number to COLUMN for the first opened file (useful in conjunction with --line)"),
N_(
"COLUMN") },
121 {
"config",
'c', 0, G_OPTION_ARG_FILENAME, &
alternate_config,
N_(
"Use alternate configuration directory DIR"),
N_(
"DIR") },
122 {
"ft-names", 0, 0, G_OPTION_ARG_NONE, &
ft_names,
N_(
"Print internal filetype names"),
NULL },
123 {
"generate-tags",
'g', 0, G_OPTION_ARG_NONE, &
generate_tags,
N_(
"Generate global tags file (see documentation)"),
NULL },
124 {
"no-preprocessing",
'P', 0, G_OPTION_ARG_NONE, &
no_preprocessing,
N_(
"Don't preprocess C/C++ files when generating tags file"),
NULL },
126 {
"new-instance",
'i', 0, G_OPTION_ARG_NONE, &
cl_options.new_instance,
N_(
"Don't open files in a running instance, force opening a new instance"),
NULL },
127 {
"socket-file", 0, 0, G_OPTION_ARG_FILENAME, &
cl_options.socket_filename,
N_(
"Use socket filename FILE for communication with a running Geany instance"),
N_(
"FILE") },
128 {
"list-documents", 0, 0, G_OPTION_ARG_NONE, &
cl_options.list_documents,
N_(
"Return a list of open documents in a running Geany instance"),
NULL },
130 {
"line",
'l', 0, G_OPTION_ARG_INT, &
cl_options.goto_line,
N_(
"Set initial line number to LINE for the first opened file"),
N_(
"LINE") },
131 {
"no-msgwin",
'm', 0, G_OPTION_ARG_NONE, &
no_msgwin,
N_(
"Don't show message window at startup"),
NULL },
132 {
"no-ctags",
'n', 0, G_OPTION_ARG_NONE, &
ignore_global_tags,
N_(
"Don't load auto completion data (see documentation)"),
NULL },
134 {
"no-plugins",
'p', 0, G_OPTION_ARG_NONE, &
no_plugins,
N_(
"Don't load plugins"),
NULL },
136 {
"print-prefix", 0, 0, G_OPTION_ARG_NONE, &
print_prefix,
N_(
"Print Geany's installation prefix"),
NULL },
137 {
"read-only",
'r', 0, G_OPTION_ARG_NONE, &
cl_options.readonly,
N_(
"Open all FILES in read-only mode (see documentation)"),
NULL },
138 {
"no-session",
's', G_OPTION_FLAG_REVERSE, G_OPTION_ARG_NONE, &
cl_options.load_session,
N_(
"Don't load the previous session's files"),
NULL },
140 {
"no-terminal",
't', 0, G_OPTION_ARG_NONE, &no_vte,
N_(
"Don't load terminal support"),
NULL },
141 {
"vte-lib", 0, 0, G_OPTION_ARG_FILENAME, &lib_vte,
N_(
"Use FILE as the dynamically-linked VTE library"),
N_(
"FILE") },
144 {
"version",
'V', 0, G_OPTION_ARG_NONE, &
show_version,
N_(
"Show version and exit"),
NULL },
145 {
"dummy", 0, G_OPTION_FLAG_HIDDEN, G_OPTION_ARG_NONE, &
dummy,
NULL,
NULL },
220 if (! vte_info.have_vte)
223 gtk_widget_set_sensitive(
239 if (doc && gtk_window_is_active(window))
247 gtk_icon_theme_append_search_path(gtk_icon_theme_get_default(),
utils_resource_dir(RESOURCE_DIR_ICON));
264 ui_prefs.recent_queue = g_queue_new();
265 ui_prefs.recent_projects_queue = g_queue_new();
273 ui_widgets.recent_projects_menu_menubar = gtk_menu_new();
274 gtk_menu_item_set_submenu(GTK_MENU_ITEM(
ui_widgets.recent_projects_menuitem),
288#ifdef MAC_INTEGRATION
294 gtk_widget_set_name(
ui_widgets.toolbar_menu,
"GeanyToolbarMenu");
306 static gchar full[] = VERSION
" (git >= " REVISION
")";
326 gchar *cur_dir =
NULL;
328 cur_dir = g_get_current_dir();
346 gint colon_count = 0;
347 gboolean have_number = FALSE;
350 g_assert(*
line == -1 && *column == -1);
356 if (g_file_test(
filename, G_FILE_TEST_EXISTS))
360 for (i = len - 1; i >= 1; i--)
362 gboolean is_colon =
filename[i] ==
':';
363 gboolean is_digit = g_ascii_isdigit(
filename[i]);
365 if (! is_colon && ! is_digit)
370 if (++colon_count > 1)
379 if (is_colon && have_number)
381 gint number = atoi(&
filename[i + 1]);
397static gint get_windows_socket_port(
void)
402 GKeyFile *config = g_key_file_new();
405 g_key_file_load_from_file(config, configfile, G_KEY_FILE_NONE,
NULL);
408 geany_debug(
"Using TCP port number %d for IPC", port_number);
410 g_key_file_free(config);
411 g_return_val_if_fail(port_number >= 1024 && port_number <= (gint)G_MAXUINT16,
417static void change_working_directory_on_windows(
void)
419 gchar *install_dir = win32_get_installation_dir();
428 win32_set_working_directory(install_dir);
492 setlocale(LC_ALL,
"");
505 const GSList *
list, *node;
508 printf(
"Geany's filetype names:\n");
515 printf(
"%s\n", ft->
name);
536 GOptionContext *context;
538 CommandLineOptions def_clo = {FALSE,
NULL, TRUE, -1, -1, FALSE, FALSE, FALSE};
545 for (i = 1; i < (*argc); i++)
547 if ((*argv)[i][0] !=
'+')
551 (*argv)[i] = (gchar *)
"--dummy";
554 context = g_option_context_new(
_(
"[FILES...]"));
556 g_option_context_set_summary(context,
_(
"A fast and lightweight IDE."));
557 g_option_context_set_description(context,
_(
"Report bugs to https://github.com/geany/geany/issues."));
559 g_option_group_set_translation_domain(g_option_context_get_main_group(context),
GETTEXT_PACKAGE);
560 g_option_context_add_group(context, gtk_get_option_group(FALSE));
561 g_option_context_parse(context, argc, argv, &
error);
562 g_option_context_free(context);
566 g_printerr(
"Geany: %s\n",
error->message);
577 g_setenv(
"G_MESSAGES_DEBUG",
"all", FALSE);
581 win32_init_debug_code();
590 printf(
_(
"built on %s with "), build_date);
592 GTK_MAJOR_VERSION, GTK_MINOR_VERSION, GTK_MICRO_VERSION,
593 GLIB_MAJOR_VERSION, GLIB_MINOR_VERSION, GLIB_MICRO_VERSION);
602 printf(
"%s\n", GEANY_PREFIX);
603 printf(
"%s\n", GEANY_DATADIR);
604 printf(
"%s\n", GEANY_LIBDIR);
605 printf(
"%s\n", GEANY_LOCALEDIR);
612 geany_debug(
"Using alternate configuration directory");
647 vte_info.lib_vte = lib_vte;
653 g_printerr(
"Geany: cannot open display\n");
657#ifdef MAC_INTEGRATION
659 gtkosx_application_get();
666 gint saved_errno = 0;
667 gchar *conf_file =
NULL;
668 gchar *filedefs_dir =
NULL;
669 gchar *templates_dir =
NULL;
678 gchar *old_dir = g_build_filename(g_get_home_dir(),
".geany",
NULL);
680 if (g_file_test(old_dir, G_FILE_TEST_EXISTS))
683 GTK_STOCK_YES, GTK_STOCK_QUIT,
_(
"Move it now?"),
685 _(
"Geany needs to move your old configuration directory before starting.")))
694 _(
"Your configuration directory has been successfully moved from \"%s\" to \"%s\"."),
704 _(
"Your old configuration directory \"%s\" could not be moved to \"%s\" (%s). "
705 "Please move manually the directory to the new location."),
720 if (saved_errno == 0 && ! g_file_test(conf_file, G_FILE_TEST_EXISTS))
726 if (saved_errno == 0)
728 gchar *filedefs_readme = g_build_filename(
app->
configdir,
731 if (! g_file_test(filedefs_dir, G_FILE_TEST_EXISTS))
735 if (saved_errno == 0 && ! g_file_test(filedefs_readme, G_FILE_TEST_EXISTS))
737 gchar *
text = g_strconcat(
738"Copy files from ",
app->
datadir,
"/filedefs to this directory to overwrite "
739"them. To use the defaults, just delete the file in this directory.\nFor more information read "
744 g_free(filedefs_readme);
748 if (saved_errno == 0)
751 "templates.README",
NULL);
753 if (! g_file_test(templates_dir, G_FILE_TEST_EXISTS))
757 if (saved_errno == 0 && ! g_file_test(templates_readme, G_FILE_TEST_EXISTS))
759 gchar *
text = g_strconcat(
760"There are several template files in this directory. For these templates you can use wildcards.\n\
761For more information read the documentation (in ",
app->
docdir, G_DIR_SEPARATOR_S
"index.html or visit " GEANY_HOMEPAGE ").",
766 g_free(templates_readme);
769 g_free(filedefs_dir);
770 g_free(templates_dir);
780 gint mkdir_result = 0;
783 if (mkdir_result != 0)
786 _(
"Configuration directory could not be created (%s).\nThere could be some problems "
787 "using Geany without a configuration directory.\nStart Geany anyway?"),
788 g_strerror(mkdir_result)))
802static gboolean signal_cb(gpointer user_data)
804 gint sig = GPOINTER_TO_INT(user_data);
810 return G_SOURCE_REMOVE;
820 gint
line = -1, column = -1;
823 g_return_val_if_fail(locale_filename, FALSE);
836 if (g_file_test(
filename, G_FILE_TEST_IS_REGULAR))
856 g_free(utf8_filename);
870 for (i = 1; i < argc; i++)
874 if (g_file_test(
filename, G_FILE_TEST_IS_DIR))
886 const gchar *msg =
_(
"Could not find file '%s'.");
899 gchar *locale_filename;
905 if (G_LIKELY(!
EMPTY(locale_filename)))
908 g_free(locale_filename);
916 vte_info.load_vte_cmdline = !no_vte;
921 vte_info.have_vte = vte_info.load_vte && vte_info.load_vte_cmdline;
950 gboolean load_session = FALSE;
952 if (argc > 1 && g_str_has_suffix(argv[1],
".geany"))
994 g_signal_emit_by_name(
geany_object,
"geany-startup-complete");
1001 const gchar *locale =
"unknown";
1003 locale = setlocale(LC_CTYPE,
NULL);
1013 gint config_dir_result;
1014 const gchar *locale;
1015 gchar *utf8_configdir;
1018#if ! GLIB_CHECK_VERSION(2, 36, 0)
1033 memset(&
ui_prefs, 0,
sizeof(UIPrefs));
1045#if ! GLIB_CHECK_VERSION(2, 32, 0)
1048 if (!g_thread_supported())
1049 g_thread_init(
NULL);
1053 g_unix_signal_add(SIGTERM, signal_cb, GINT_TO_POINTER(SIGTERM));
1056 signal(SIGPIPE, SIG_IGN);
1064 gushort socket_port = 0;
1066 socket_port = (gushort) get_windows_socket_port();
1077 gdk_notify_startup_complete();
1097 change_working_directory_on_windows();
1105 gtk_major_version, gtk_minor_version, gtk_micro_version,
1106 glib_major_version, glib_minor_version, glib_micro_version);
1109 if (os_info !=
NULL)
1117 geany_debug(
"User config dir: %s", utf8_configdir);
1118 g_free(utf8_configdir);
1159 if (config_dir_result != 0)
1161 const gchar *message =
_(
"Configuration directory could not be created (%s).");
1163 g_warning(message, g_strerror(config_dir_result));
1168 const gchar *message =
1169 _(
"IPC socket could not be created, see Help->Debug Messages for details.");
1171 g_warning(
"%s", message);
1235#ifdef MAC_INTEGRATION
1237 gtkosx_application_ready(gtkosx_application_get());
1247 while (! g_queue_is_empty(queue))
1249 g_free(g_queue_pop_tail(queue));
1251 g_queue_free(queue);
1306 g_free(
ui_prefs.custom_date_format);
1307 g_free(
ui_prefs.color_picker_palette);
1325 g_strfreev(
ui_prefs.custom_commands);
1326 g_strfreev(
ui_prefs.custom_commands_labels);
1335 if (vte_info.have_vte) vte_close();
1336 g_free(vte_info.lib_vte);
1337 g_free(vte_info.dir);
1347 gtk_widget_destroy(
msgwindow.popup_status_menu);
1349 gtk_widget_destroy(
msgwindow.popup_msg_menu);
1351 gtk_widget_destroy(
msgwindow.popup_compiler_menu);
1395 _(
"Do you really want to quit?")))
void build_menu_update(GeanyDocument *doc)
void build_finalize(void)
Interface to the Build menu functionality.
gboolean dialogs_show_question_full(GtkWidget *parent, const gchar *yes_btn, const gchar *no_btn, const gchar *extra_text, const gchar *main_text,...)
gboolean dialogs_show_question(const gchar *text,...)
Shows a question message box with text and Yes/No buttons.
void dialogs_show_msgbox(GtkMessageType type, const gchar *text,...)
Shows a message box of the type type with text.
File related dialogs, miscellaneous dialogs, font dialog.
GeanyDocument * document_get_current(void)
Finds the current document.
void document_init_doclist(void)
gboolean document_close_all(void)
GeanyDocument * document_new_file_if_non_open(void)
void document_grab_focus(GeanyDocument *doc)
void document_show_tab(GeanyDocument *doc)
gboolean document_check_disk_status(GeanyDocument *doc, gboolean force)
GeanyDocument * document_find_by_filename(const gchar *utf8_filename)
Finds a document with the given filename.
GeanyFilePrefs file_prefs
GeanyDocument * document_open_file(const gchar *locale_filename, gboolean readonly, GeanyFiletype *ft, const gchar *forced_enc)
Opens a document specified by locale_filename.
GPtrArray * documents_array
GeanyDocument * document_new_file(const gchar *utf8_filename, GeanyFiletype *ft, const gchar *text)
Creates a new document.
void document_finalize(void)
Document related actions: new, save, open, etc.
#define documents
Wraps GeanyData::documents_array so it can be used with C array syntax.
void editor_snippets_init(void)
void editor_finalize(void)
void editor_snippets_free(void)
GeanyEditorPrefs editor_prefs
void encodings_finalize(void)
void encodings_init(void)
void error(const errorSelection selection, const char *const format,...)
Filetype detection, file extensions and filetype menu items.
#define GEANY_TEMPLATES_SUBDIR
#define GEANY_FILEDEFS_SUBDIR
#define GEANY_WINDOW_DEFAULT_WIDTH
#define GEANY_WINDOW_DEFAULT_HEIGHT
GObject * geany_object_new(void)
void highlighting_free_styles(void)
Syntax highlighting for the different filetypes, using the Scintilla lexers.
void keybindings_load_keyfile(void)
Reloads keybinding settings from configuration file.
void keybindings_init(void)
void keybindings_free(void)
Configurable keyboard shortcuts.
void configuration_save(void)
void configuration_apply_settings(void)
void configuration_init(void)
gboolean configuration_load(void)
void configuration_open_files(void)
void configuration_finalize(void)
void main_load_project_from_command_line(const gchar *locale_filename, gboolean use_session)
static gboolean verbose_mode
static void wait_for_input_on_windows(void)
static gboolean no_plugins
static void setup_paths(void)
static void load_startup_files(gint argc, gchar **argv)
const gchar * main_get_version_string(void)
CommandLineOptions cl_options
void main_reload_configuration(void)
Reloads most of Geany's configuration files without restarting.
static gboolean print_prefix
static gboolean do_main_quit(void)
static gboolean ignore_global_tags
static void queue_free(GQueue *queue)
static gboolean no_preprocessing
gboolean main_handle_filename(const gchar *locale_filename)
GEANY_EXPORT_SYMBOL gint main_lib(gint argc, gchar **argv)
static gboolean generate_tags
gboolean main_is_realized(void)
Checks whether the main window has been realized.
static gboolean show_version
void main_locale_init(const gchar *locale_dir, const gchar *package)
Initialises the gettext translation system.
static void print_filetypes(void)
static GOptionEntry entries[]
static void get_line_and_column_from_filename(gchar *filename, gint *line, gint *column)
static gboolean want_plugins
static const gchar * get_locale(void)
static gint create_config_dir(void)
static gchar * original_cwd
static gint setup_config_dir(void)
static gboolean check_no_unsaved(void)
static void load_settings(void)
static void parse_command_line_options(gint *argc, gchar ***argv)
static void setup_window_position(void)
static gboolean no_msgwin
static void load_session_project_file(void)
static void on_window_active_changed(GtkWindow *window, GParamSpec *pspec, gpointer data)
gchar * main_get_argv_filename(const gchar *filename)
static gchar * alternate_config
static gboolean send_startup_complete(gpointer data)
static const gchar geany_lib_versions[]
static void apply_settings(void)
static void open_cl_files(gint argc, gchar **argv)
static void main_init(void)
void log_handlers_init(void)
void geany_debug(gchar const *format,...)
Main program-related commands.
void msgwin_finalize(void)
Message window functions (status, compiler, messages windows).
void plugins_finalize(void)
void plugins_load_active(void)
signal void(* project_close)(GObject *obj, gpointer user_data)
Sent after a project is closed.
GeanyToolPrefs tool_prefs
PrintingPrefs printing_prefs
void project_finalize(void)
gboolean project_load_file_with_session(const gchar *locale_file_name)
gboolean project_load_file(const gchar *locale_file_name)
ProjectPrefs project_prefs
void search_finalize(void)
GeanySearchPrefs search_prefs
gint socket_finalize(void)
struct SocketInfo socket_info
gint socket_init(gint argc, gchar **argv, gushort socket_port)
gboolean socket_lock_input_cb(GIOChannel *source, GIOCondition condition, gpointer data)
#define SOCKET_WINDOWS_REMOTE_CMD_PORT
void filetypes_reload(void)
const GSList * filetypes_get_sorted_by_name(void)
Gets a list of filetype pointers sorted by name.
void filetypes_init_types(void)
void filetypes_reload_extensions(void)
void filetypes_init(void)
void filetypes_free_types(void)
Important application fields.
struct GeanyProject * project
Currently active project or NULL if none is open.
const TMWorkspace * tm_workspace
TagManager workspace/session tags.
gchar * configdir
User configuration directory, usually ~/.config/geany.
gboolean debug_mode
TRUE if debug messages should be printed.
Structure for representing an open tab with all its properties.
gchar * comment_toggle_mark
gboolean tab_order_beside
gboolean cmdline_new_files
gchar * name
Untranslated short name, such as "C", "None".
gint tab_pos_editor
positions of editor's tabs
gboolean statusbar_visible
whether the status bar is visible
gint sidebar_pos
position of the sidebar (left or right)
gint tab_pos_sidebar
positions of sidebar's tabs
gchar * editor_font
editor font
gchar * msgwin_font
message window font
gboolean show_notebook_tabs
whether editor tabs are visible
gint tab_pos_msgwin
positions of message window's tabs
gint msgwin_orientation
orientation of the message window
gchar * tagbar_font
symbol sidebar font
GtkWidget * window
Main window.
GtkWidget * notebook
Document notebook.
GtkWidget * message_window_notebook
Message Window notebook.
GtkWidget * editor_menu
Popup editor menu.
GtkWidget * toolbar
Main toolbar.
GtkWidget * project_menu
Plugins modifying the project can add their items to the Project menu.
GtkWidget * tools_menu
Most plugins add menu items to the Tools menu.
GtkWidget * sidebar_notebook
Sidebar notebook.
General Preferences dialog settings.
gchar * custom_plugin_path
gchar * default_open_path
Default path to look for files when no other path is appropriate.
gchar * initials
Initials.
gchar * version
Initial version.
gchar * external_print_cmd
gchar * page_header_datefmt
Defines internationalization macros.
#define bindtextdomain(Domain, Dir)
#define bind_textdomain_codeset(Domain, Codeset)
void symbols_reload_config_files(void)
int symbols_generate_global_tags(int argc, char **argv, gboolean want_preprocess)
void symbols_finalize(void)
void templates_init(void)
GeanyTemplatePrefs template_prefs
void templates_free_templates(void)
void tm_workspace_free(void)
const TMWorkspace * tm_get_workspace(void)
void ui_init_builder(void)
void ui_create_insert_menu_items(void)
void ui_sidebar_show_hide(void)
GtkWidget * create_toolbar_popup_menu1(void)
void ui_create_recent_menus(void)
GtkWidget * create_edit_menu1(void)
void ui_update_popup_copy_items(GeanyDocument *doc)
void ui_save_buttons_toggle(gboolean enable)
void ui_swap_sidebar_pos(void)
GeanyMainWidgets main_widgets
void ui_set_statusbar(gboolean log, const gchar *format,...)
Displays text on the statusbar.
void ui_update_view_editor_menu_items(void)
void ui_add_recent_document(GeanyDocument *doc)
void ui_document_buttons_update(void)
void ui_update_fold_items(void)
GtkWidget * create_window1(void)
GtkWidget * ui_lookup_widget(GtkWidget *widget, const gchar *widget_name)
Returns a widget from a name in a component, usually created by Glade.
void ui_init_stock_items(void)
void ui_finalize_builder(void)
void ui_update_popup_reundo_items(GeanyDocument *doc)
GeanyInterfacePrefs interface_prefs
void ui_create_insert_date_menu_items(void)
User Interface general utility functions.
gchar * utils_get_path_from_uri(const gchar *uri)
gint utils_write_file(const gchar *filename, const gchar *text)
Writes text into a file named filename.
gchar * utils_get_os_info_string(void)
gchar * utils_parse_and_format_build_date(const gchar *input)
gint utils_get_setting_integer(GKeyFile *config, const gchar *section, const gchar *key, const gint default_value)
Wraps g_key_file_get_integer() to add a default value argument.
gchar * utils_get_utf8_from_locale(const gchar *locale_text)
Converts the given string (in locale encoding) into UTF-8 encoding.
const gchar * utils_resource_dir(GeanyResourceDirType type)
gint utils_mkdir(const gchar *path, gboolean create_parent_dirs)
Creates a directory if it doesn't already exist.
gboolean utils_is_uri(const gchar *uri)
gboolean utils_str_equal(const gchar *a, const gchar *b)
NULL-safe string comparison.
gchar * utils_get_user_config_dir(void)
gint utils_is_file_writable(const gchar *locale_filename)
gchar * utils_get_real_path(const gchar *file_name)
Get a link-dereferenced, absolute version of a file name.
gchar * utils_get_locale_from_utf8(const gchar *utf8_text)
Converts the given UTF-8 encoded string into locale encoding.
General utility functions, non-GTK related.
#define foreach_slist(node, list)
Iterates all the nodes in list.
#define SETPTR(ptr, result)
Assigns result to ptr, then frees the old value.
#define EMPTY(ptr)
Returns TRUE if ptr is NULL or *ptr is FALSE.