2005-11-22 12:26:26 +00:00
/*
* main . c - this file is part of Geany , a fast and lightweight IDE
*
2011-01-19 19:39:09 +00:00
* Copyright 2005 - 2011 Enrico Tröger < enrico ( dot ) troeger ( at ) uvena ( dot ) de >
* Copyright 2006 - 2011 Nick Treleaven < nick ( dot ) treleaven ( at ) btinternet ( dot ) com >
2005-11-22 12:26:26 +00:00
*
* This program is free software ; you can redistribute it and / or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation ; either version 2 of the License , or
* ( at your option ) any later version .
*
* This program is distributed in the hope that it will be useful ,
* but WITHOUT ANY WARRANTY ; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE . See the
* GNU General Public License for more details .
*
* You should have received a copy of the GNU General Public License
* along with this program ; if not , write to the Free Software
2006-05-22 00:25:19 +00:00
* Foundation , Inc . , 51 Franklin Street , Fifth Floor , Boston , MA 02110 - 1301 , USA .
2005-11-22 12:26:26 +00:00
*
2005-11-30 23:33:35 +00:00
* $ Id $
2005-11-22 12:26:26 +00:00
*/
2008-07-23 13:48:13 +00:00
/**
* @ file : main . h
* Main program - related commands .
* Handles program initialization and cleanup .
2007-02-24 11:41:56 +00:00
*/
2005-11-22 12:26:26 +00:00
# include <signal.h>
# include <time.h>
2006-02-10 21:06:41 +00:00
# include <sys/types.h>
# include <sys/stat.h>
# include <errno.h>
# include <string.h>
2006-03-18 17:35:53 +00:00
# include <stdlib.h>
2005-11-27 20:54:28 +00:00
2005-11-22 12:26:26 +00:00
# include "geany.h"
2008-11-13 14:37:47 +00:00
# include <glib/gstdio.h>
2005-11-22 12:26:26 +00:00
2008-06-03 16:30:54 +00:00
# ifdef HAVE_LOCALE_H
2007-06-25 17:49:45 +00:00
# include <locale.h>
# endif
2006-09-04 11:16:07 +00:00
# include "main.h"
2007-12-12 20:04:45 +00:00
# include "prefix.h"
2007-08-23 11:34:06 +00:00
# include "prefs.h"
2005-11-22 12:26:26 +00:00
# include "interface.h"
# include "support.h"
# include "callbacks.h"
2008-08-11 18:16:35 +00:00
# include "log.h"
2006-09-05 14:24:47 +00:00
# include "ui_utils.h"
2005-11-22 12:26:26 +00:00
# include "utils.h"
# include "document.h"
2007-08-15 15:37:21 +00:00
# include "filetypes.h"
2005-11-22 12:26:26 +00:00
# include "keyfile.h"
# include "win32.h"
# include "msgwindow.h"
# include "dialogs.h"
# include "templates.h"
# include "encodings.h"
2009-09-28 11:16:59 +00:00
# include "sidebar.h"
2006-06-16 11:17:52 +00:00
# include "notebook.h"
2006-06-16 19:58:26 +00:00
# include "keybindings.h"
2007-05-28 16:07:30 +00:00
# include "editor.h"
2006-08-11 21:12:49 +00:00
# include "search.h"
2006-10-18 19:35:42 +00:00
# include "build.h"
2006-10-21 11:34:18 +00:00
# include "highlighting.h"
2006-12-15 17:09:05 +00:00
# include "symbols.h"
2007-01-16 15:22:24 +00:00
# include "project.h"
2007-02-25 14:26:55 +00:00
# include "tools.h"
2007-06-02 16:14:07 +00:00
# include "navqueue.h"
2007-06-26 16:17:16 +00:00
# include "plugins.h"
2007-11-17 14:04:27 +00:00
# include "printing.h"
2008-12-06 11:10:06 +00:00
# include "toolbar.h"
2009-01-03 16:31:12 +00:00
# include "geanyobject.h"
2006-06-16 19:58:26 +00:00
2006-09-07 15:51:24 +00:00
# ifdef HAVE_SOCKET
# include "socket.h"
# endif
2006-01-03 12:47:08 +00:00
# ifdef HAVE_VTE
2005-11-27 20:54:28 +00:00
# include "vte.h"
# endif
2005-11-22 12:26:26 +00:00
2007-06-25 17:49:45 +00:00
# ifndef N_
# define N_(String) (String)
# endif
2006-08-20 12:33:09 +00:00
2006-08-30 18:36:17 +00:00
2008-05-22 14:41:28 +00:00
GeanyApp * app ;
gboolean ignore_callback ; /* hack workaround for GTK+ toggle button callback problem */
2007-07-19 11:49:53 +00:00
2007-08-23 11:34:06 +00:00
GeanyStatus main_status ;
2008-02-27 13:17:29 +00:00
CommandLineOptions cl_options ; /* fields initialised in parse_command_line_options */
2006-09-04 11:16:07 +00:00
2007-07-19 11:49:53 +00:00
2010-11-07 17:09:09 +00:00
static const gchar geany_lib_versions [ ] = " GTK %u.%u.%u, GLib %u.%u.%u "
# ifdef HAVE_GIO
" , GIO "
# endif
# ifdef USE_INCLUDED_REGEX
" , built-in regex "
# endif
;
2007-08-16 15:20:38 +00:00
static gboolean want_plugins ;
2008-02-27 13:17:29 +00:00
/* command-line options */
2009-01-15 18:20:19 +00:00
static gboolean verbose_mode = FALSE ;
2005-11-22 12:26:26 +00:00
static gboolean ignore_global_tags = FALSE ;
2006-03-15 23:19:45 +00:00
static gboolean no_msgwin = FALSE ;
2005-11-22 12:26:26 +00:00
static gboolean show_version = FALSE ;
static gchar * alternate_config = NULL ;
2006-01-14 22:38:06 +00:00
# ifdef HAVE_VTE
2006-05-22 00:25:19 +00:00
static gboolean no_vte = FALSE ;
2006-01-06 18:41:01 +00:00
static gchar * lib_vte = NULL ;
2006-01-14 22:38:06 +00:00
# endif
2007-03-21 13:26:16 +00:00
static gboolean generate_tags = FALSE ;
2007-09-28 11:48:55 +00:00
static gboolean no_preprocessing = FALSE ;
2007-06-17 17:56:48 +00:00
static gboolean ft_names = FALSE ;
2007-12-18 17:03:39 +00:00
static gboolean print_prefix = FALSE ;
2007-11-11 09:09:47 +00:00
# ifdef HAVE_PLUGINS
2007-07-05 12:15:54 +00:00
static gboolean no_plugins = FALSE ;
2007-11-11 09:09:47 +00:00
# endif
2008-02-16 11:21:24 +00:00
static gboolean dummy = FALSE ;
2006-08-01 21:07:46 +00:00
2008-02-27 13:17:29 +00:00
/* in alphabetical order of short options */
2005-11-22 12:26:26 +00:00
static GOptionEntry entries [ ] =
{
2007-07-05 12:28:24 +00:00
{ " column " , 0 , 0 , G_OPTION_ARG_INT , & cl_options . goto_column , N_ ( " Set initial column number for the first opened file (useful in conjunction with --line) " ) , NULL } ,
{ " config " , ' c ' , 0 , G_OPTION_ARG_FILENAME , & alternate_config , N_ ( " Use an alternate configuration directory " ) , NULL } ,
{ " ft-names " , 0 , 0 , G_OPTION_ARG_NONE , & ft_names , N_ ( " Print internal filetype names " ) , NULL } ,
{ " generate-tags " , ' g ' , 0 , G_OPTION_ARG_NONE , & generate_tags , N_ ( " Generate global tags file (see documentation) " ) , NULL } ,
2008-10-20 14:48:21 +00:00
{ " no-preprocessing " , ' P ' , 0 , G_OPTION_ARG_NONE , & no_preprocessing , N_ ( " Don't preprocess C/C++ files when generating tags " ) , NULL } ,
2006-08-30 18:36:17 +00:00
# ifdef HAVE_SOCKET
2008-10-20 12:13:27 +00:00
{ " 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 } ,
2009-11-23 21:03:24 +00:00
{ " socket-file " , 0 , 0 , G_OPTION_ARG_FILENAME , & cl_options . socket_filename , N_ ( " Use this socket filename for communication with a running Geany instance " ) , NULL } ,
2010-04-11 21:56:50 +00:00
{ " 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 } ,
2006-02-20 22:59:42 +00:00
# endif
2007-07-05 12:28:24 +00:00
{ " line " , ' l ' , 0 , G_OPTION_ARG_INT , & cl_options . goto_line , N_ ( " Set initial line number for the first opened file " ) , NULL } ,
{ " no-msgwin " , ' m ' , 0 , G_OPTION_ARG_NONE , & no_msgwin , N_ ( " Don't show message window at startup " ) , NULL } ,
{ " no-ctags " , ' n ' , 0 , G_OPTION_ARG_NONE , & ignore_global_tags , N_ ( " Don't load auto completion data (see documentation) " ) , NULL } ,
2007-11-11 09:09:47 +00:00
# ifdef HAVE_PLUGINS
2007-07-05 12:28:24 +00:00
{ " no-plugins " , ' p ' , 0 , G_OPTION_ARG_NONE , & no_plugins , N_ ( " Don't load plugins " ) , NULL } ,
2007-11-11 09:09:47 +00:00
# endif
2007-12-18 17:03:39 +00:00
{ " print-prefix " , 0 , 0 , G_OPTION_ARG_NONE , & print_prefix , N_ ( " Print Geany's installation prefix " ) , NULL } ,
2009-08-12 18:53:35 +00:00
{ " 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 } ,
2006-01-06 18:41:01 +00:00
# ifdef HAVE_VTE
2007-07-05 12:28:24 +00:00
{ " no-terminal " , ' t ' , 0 , G_OPTION_ARG_NONE , & no_vte , N_ ( " Don't load terminal support " ) , NULL } ,
{ " vte-lib " , 0 , 0 , G_OPTION_ARG_FILENAME , & lib_vte , N_ ( " Filename of libvte.so " ) , NULL } ,
2006-01-06 18:41:01 +00:00
# endif
2009-01-15 18:20:19 +00:00
{ " verbose " , ' v ' , 0 , G_OPTION_ARG_NONE , & verbose_mode , N_ ( " Be verbose " ) , NULL } ,
{ " version " , ' V ' , 0 , G_OPTION_ARG_NONE , & show_version , N_ ( " Show version and exit " ) , NULL } ,
2008-02-27 13:17:29 +00:00
{ " dummy " , 0 , G_OPTION_FLAG_HIDDEN , G_OPTION_ARG_NONE , & dummy , NULL , NULL } , /* for +NNN line number arguments */
2006-04-27 18:05:57 +00:00
{ NULL , 0 , 0 , 0 , NULL , NULL , NULL }
2005-11-22 12:26:26 +00:00
} ;
2009-03-27 16:25:57 +00:00
static void setup_window_position ( void )
{
/* interprets the saved window geometry */
2009-04-07 22:08:19 +00:00
if ( prefs . save_winpos & & ui_prefs . geometry [ 0 ] ! = - 1 )
2009-03-27 16:25:57 +00:00
{
gtk_window_move ( GTK_WINDOW ( main_widgets . window ) , ui_prefs . geometry [ 0 ] , ui_prefs . geometry [ 1 ] ) ;
gtk_window_set_default_size ( GTK_WINDOW ( main_widgets . window ) , ui_prefs . geometry [ 2 ] , ui_prefs . geometry [ 3 ] ) ;
if ( ui_prefs . geometry [ 4 ] = = 1 )
gtk_window_maximize ( GTK_WINDOW ( main_widgets . window ) ) ;
}
}
2006-02-10 21:06:41 +00:00
2009-09-16 14:13:38 +00:00
2005-11-22 12:26:26 +00:00
/* special things for the initial setup of the checkboxes and related stuff
2005-12-28 15:42:31 +00:00
* an action on a setting is only performed if the setting is not equal to the program default
2005-11-22 12:26:26 +00:00
* ( all the following code is not perfect but it works for the moment ) */
2006-02-10 21:06:41 +00:00
static void apply_settings ( void )
2005-11-22 12:26:26 +00:00
{
2006-09-05 14:24:47 +00:00
ui_update_fold_items ( ) ;
2006-02-26 18:19:28 +00:00
2008-02-27 13:17:29 +00:00
/* toolbar, message window and sidebar are by default visible, so don't change it if it is true */
2009-07-21 22:10:42 +00:00
toolbar_show_hide ( ) ;
2007-08-23 11:34:06 +00:00
if ( ! ui_prefs . msgwindow_visible )
2006-02-06 06:28:31 +00:00
{
2008-05-22 14:41:28 +00:00
ignore_callback = TRUE ;
2008-12-18 21:21:53 +00:00
gtk_check_menu_item_set_active ( GTK_CHECK_MENU_ITEM ( ui_lookup_widget ( main_widgets . window , " menu_show_messages_window1 " ) ) , FALSE ) ;
gtk_widget_hide ( ui_lookup_widget ( main_widgets . window , " scrolledwindow1 " ) ) ;
2008-05-22 14:41:28 +00:00
ignore_callback = FALSE ;
2006-02-06 06:28:31 +00:00
}
2007-08-23 11:34:06 +00:00
if ( ! ui_prefs . sidebar_visible )
2006-07-21 11:41:33 +00:00
{
2008-05-22 14:41:28 +00:00
ignore_callback = TRUE ;
2008-12-18 21:21:53 +00:00
gtk_check_menu_item_set_active ( GTK_CHECK_MENU_ITEM ( ui_lookup_widget ( main_widgets . window , " menu_show_sidebar1 " ) ) , FALSE ) ;
2008-05-22 14:41:28 +00:00
ignore_callback = FALSE ;
2006-07-21 11:41:33 +00:00
}
2009-04-27 19:30:29 +00:00
2009-06-20 16:51:32 +00:00
toolbar_apply_settings ( ) ;
2009-03-29 16:15:35 +00:00
toolbar_update_ui ( ) ;
2005-11-22 12:26:26 +00:00
2008-12-07 19:12:08 +00:00
ui_update_view_editor_menu_items ( ) ;
2006-02-14 21:58:42 +00:00
2008-02-27 13:17:29 +00:00
/* hide statusbar if desired */
2008-05-16 12:08:39 +00:00
if ( ! interface_prefs . statusbar_visible )
2007-04-10 17:06:57 +00:00
{
2008-05-22 14:41:28 +00:00
gtk_widget_hide ( ui_widgets . statusbar ) ;
2007-04-10 17:06:57 +00:00
}
2008-02-27 13:17:29 +00:00
/* set the tab placements of the notebooks */
2008-05-22 14:41:28 +00:00
gtk_notebook_set_tab_pos ( GTK_NOTEBOOK ( main_widgets . notebook ) , interface_prefs . tab_pos_editor ) ;
2008-05-16 12:08:39 +00:00
gtk_notebook_set_tab_pos ( GTK_NOTEBOOK ( msgwindow . notebook ) , interface_prefs . tab_pos_msgwin ) ;
2008-05-22 14:41:28 +00:00
gtk_notebook_set_tab_pos ( GTK_NOTEBOOK ( main_widgets . sidebar_notebook ) , interface_prefs . tab_pos_sidebar ) ;
2006-07-11 14:15:56 +00:00
2008-02-27 13:17:29 +00:00
/* whether to show notebook tabs or not */
2008-05-22 14:41:28 +00:00
gtk_notebook_set_show_tabs ( GTK_NOTEBOOK ( main_widgets . notebook ) , interface_prefs . show_notebook_tabs ) ;
2009-02-25 23:28:01 +00:00
# ifdef HAVE_VTE
2010-12-07 13:02:46 +00:00
if ( ! vte_info . have_vte )
2009-02-25 23:28:01 +00:00
# endif
2010-12-07 13:25:11 +00:00
{
gtk_widget_set_sensitive (
ui_lookup_widget ( main_widgets . window , " send_selection_to_vte1 " ) , FALSE ) ;
}
2009-10-23 16:18:05 +00:00
if ( interface_prefs . sidebar_pos ! = GTK_POS_LEFT )
ui_swap_sidebar_pos ( ) ;
2005-11-22 12:26:26 +00:00
}
2006-02-26 18:19:28 +00:00
static void main_init ( void )
2005-11-22 12:26:26 +00:00
{
2008-02-27 13:17:29 +00:00
/* inits */
2008-05-22 14:41:28 +00:00
main_widgets . window = NULL ;
2007-01-15 18:12:32 +00:00
app - > project = NULL ;
2007-08-23 11:34:06 +00:00
ui_widgets . open_fontsel = NULL ;
2007-11-20 18:15:46 +00:00
ui_widgets . open_colorsel = NULL ;
2007-08-23 11:34:06 +00:00
ui_widgets . open_filesel = NULL ;
ui_widgets . save_filesel = NULL ;
ui_widgets . prefs_dialog = NULL ;
2009-09-16 14:13:38 +00:00
main_status . main_window_realized = FALSE ;
2008-05-16 12:08:39 +00:00
file_prefs . tab_order_ltr = FALSE ;
2010-05-16 17:45:39 +00:00
file_prefs . tab_order_beside = FALSE ;
2007-08-23 11:34:06 +00:00
main_status . quitting = FALSE ;
2008-05-22 14:41:28 +00:00
ignore_callback = FALSE ;
2007-11-30 17:34:01 +00:00
app - > tm_workspace = tm_get_workspace ( ) ;
2007-08-23 11:34:06 +00:00
ui_prefs . recent_queue = g_queue_new ( ) ;
2009-04-05 14:14:29 +00:00
ui_prefs . recent_projects_queue = g_queue_new ( ) ;
main_status . opening_session_files = FALSE ;
2005-11-22 12:26:26 +00:00
2009-06-20 16:53:28 +00:00
ui_init_stock_items ( ) ;
2008-05-22 14:41:28 +00:00
main_widgets . window = create_window1 ( ) ;
2007-08-23 11:34:06 +00:00
2009-04-05 14:14:29 +00:00
/* add recent projects to the Project menu */
ui_widgets . recent_projects_menuitem = ui_lookup_widget ( main_widgets . window , " recent_projects1 " ) ;
ui_widgets . recent_projects_menu_menubar = gtk_menu_new ( ) ;
gtk_menu_item_set_submenu ( GTK_MENU_ITEM ( ui_widgets . recent_projects_menuitem ) ,
ui_widgets . recent_projects_menu_menubar ) ;
2008-02-27 13:17:29 +00:00
/* store important pointers for later reference */
2008-12-06 11:10:06 +00:00
main_widgets . toolbar = toolbar_init ( ) ;
2008-12-18 21:21:53 +00:00
main_widgets . sidebar_notebook = ui_lookup_widget ( main_widgets . window , " notebook3 " ) ;
main_widgets . notebook = ui_lookup_widget ( main_widgets . window , " notebook1 " ) ;
2008-05-22 14:41:28 +00:00
main_widgets . editor_menu = create_edit_menu1 ( ) ;
2008-12-18 21:21:53 +00:00
main_widgets . tools_menu = ui_lookup_widget ( main_widgets . window , " tools1_menu " ) ;
2010-09-08 12:36:01 +00:00
main_widgets . message_window_notebook = ui_lookup_widget ( main_widgets . window , " notebook_info " ) ;
2010-09-16 15:18:56 +00:00
main_widgets . project_menu = ui_lookup_widget ( main_widgets . window , " menu_project1_menu " ) ;
2008-05-22 14:41:28 +00:00
2007-08-23 11:34:06 +00:00
ui_widgets . toolbar_menu = create_toolbar_popup_menu1 ( ) ;
2007-07-20 12:06:51 +00:00
ui_init ( ) ;
2008-02-27 13:17:29 +00:00
/* set widget names for matching with .gtkrc-2.0 */
2008-05-22 14:41:28 +00:00
gtk_widget_set_name ( main_widgets . window , " GeanyMainWindow " ) ;
2007-08-23 11:34:06 +00:00
gtk_widget_set_name ( ui_widgets . toolbar_menu , " GeanyToolbarMenu " ) ;
2008-05-22 14:41:28 +00:00
gtk_widget_set_name ( main_widgets . editor_menu , " GeanyEditMenu " ) ;
2009-03-31 17:39:17 +00:00
gtk_widget_set_name ( ui_lookup_widget ( main_widgets . window , " menubar1 " ) , " GeanyMenubar " ) ;
gtk_widget_set_name ( main_widgets . toolbar , " GeanyToolbar " ) ;
2007-11-17 14:04:27 +00:00
# if ! GTK_CHECK_VERSION(2, 10, 0)
2008-02-27 13:17:29 +00:00
/* hide Page setup menu item, it isn't supported with non-GTK printing */
2007-11-17 14:04:27 +00:00
gtk_widget_hide ( ui_widgets . print_page_setup ) ;
# endif
2010-03-20 16:20:55 +00:00
/* for some reason we need to set the initial size request,
* otherwise the main window gets crazy dimensions */
gtk_widget_set_size_request ( main_widgets . window , 10 , 10 ) ;
gtk_window_set_default_size ( GTK_WINDOW ( main_widgets . window ) ,
GEANY_WINDOW_DEFAULT_WIDTH , GEANY_WINDOW_DEFAULT_HEIGHT ) ;
2006-01-14 22:38:06 +00:00
}
2008-09-24 12:07:22 +00:00
const gchar * main_get_version_string ( void )
{
static gchar full [ ] = VERSION " (svn >= " REVISION " ) " ;
if ( utils_str_equal ( REVISION , " -1 " ) )
return VERSION ;
else
return full ;
}
2006-07-11 13:48:24 +00:00
/* get the full file path of a command-line argument
* N . B . the result should be freed and may contain ' / . . / ' or ' / . / ' */
2008-09-24 12:07:22 +00:00
gchar * main_get_argv_filename ( const gchar * filename )
2006-07-11 13:48:24 +00:00
{
gchar * result ;
2009-01-09 18:21:12 +00:00
if ( g_path_is_absolute ( filename ) | | utils_is_uri ( filename ) )
2006-07-11 13:48:24 +00:00
result = g_strdup ( filename ) ;
else
{
2008-02-27 13:17:29 +00:00
/* use current dir */
2006-07-11 13:48:24 +00:00
gchar * cur_dir = g_get_current_dir ( ) ;
2007-01-13 12:42:12 +00:00
2006-07-11 13:48:24 +00:00
result = g_strjoin (
G_DIR_SEPARATOR_S , cur_dir , filename , NULL ) ;
g_free ( cur_dir ) ;
}
return result ;
}
2008-02-16 11:21:24 +00:00
/* get a :line:column specifier from the end of a filename (if present),
* return the line / column values , and remove the specifier from the string
* ( Note that * line and * column must both be set to - 1 initially ) */
static void get_line_and_column_from_filename ( gchar * filename , gint * line , gint * column )
{
gsize i ;
gint colon_count = 0 ;
gboolean have_number = FALSE ;
gsize len ;
2009-04-15 22:47:33 +00:00
g_assert ( * line = = - 1 & & * column = = - 1 ) ;
2008-02-16 11:21:24 +00:00
if ( ! NZV ( filename ) )
return ;
2009-10-25 11:52:47 +00:00
/* allow to open files like "test:0" */
if ( g_file_test ( filename , G_FILE_TEST_EXISTS ) )
return ;
2008-02-16 11:21:24 +00:00
len = strlen ( filename ) ;
for ( i = len - 1 ; i > = 1 ; i - - )
{
gboolean is_colon = filename [ i ] = = ' : ' ;
gboolean is_digit = g_ascii_isdigit ( filename [ i ] ) ;
if ( ! is_colon & & ! is_digit )
break ;
if ( is_colon )
{
if ( + + colon_count > 1 )
break ; /* bail on 2+ colons in a row */
}
else
colon_count = 0 ;
if ( is_digit )
have_number = TRUE ;
if ( is_colon & & have_number )
{
gint number = atoi ( & filename [ i + 1 ] ) ;
filename [ i ] = ' \0 ' ;
have_number = FALSE ;
* column = * line ;
* line = number ;
}
if ( * column > = 0 )
break ; /* line and column are set, so we're done */
}
}
2008-02-20 11:24:23 +00:00
static void setup_paths ( void )
2006-01-14 22:38:06 +00:00
{
2006-07-26 17:02:16 +00:00
gchar * data_dir ;
gchar * doc_dir ;
2008-02-27 13:17:29 +00:00
/* set paths */
2006-07-26 17:02:16 +00:00
# ifdef G_OS_WIN32
2008-02-27 13:17:29 +00:00
/* use the installation directory(the one where geany.exe is located) as the base for the
* documentation and data files */
2009-03-26 20:10:47 +00:00
gchar * install_dir = win32_get_installation_dir ( ) ;
2006-07-26 17:02:16 +00:00
2008-02-27 13:17:29 +00:00
data_dir = g_strconcat ( install_dir , " \\ data " , NULL ) ; /* e.g. C:\Program Files\geany\data */
2006-07-26 17:02:16 +00:00
doc_dir = g_strconcat ( install_dir , " \\ doc " , NULL ) ;
g_free ( install_dir ) ;
# else
2010-11-01 15:17:22 +00:00
data_dir = g_strconcat ( GEANY_DATADIR , " /geany " , NULL ) ; /* e.g. /usr/share/geany */
doc_dir = g_strconcat ( GEANY_DOCDIR , " /html " , NULL ) ;
2006-08-17 14:40:43 +00:00
# endif
2008-02-27 13:17:29 +00:00
/* convert path names to locale encoding */
2007-02-12 16:32:56 +00:00
app - > datadir = utils_get_locale_from_utf8 ( data_dir ) ;
app - > docdir = utils_get_locale_from_utf8 ( doc_dir ) ;
g_free ( data_dir ) ;
g_free ( doc_dir ) ;
2006-08-17 14:40:43 +00:00
}
2009-11-29 13:36:26 +00:00
/**
2010-03-15 13:01:16 +00:00
* Checks whether the main window has been realized .
2009-11-29 13:36:26 +00:00
* 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 .
*
2010-06-25 16:50:27 +00:00
* @ note Maybe you want to use the @ link pluginsignals . c @ c " geany-startup-complete " signal @ endlink
* to get notified about the completed startup process .
2010-01-17 15:17:30 +00:00
*
2009-11-29 13:36:26 +00:00
* @ return @ c TRUE if the Geany main window has been realized or @ c FALSE otherwise .
*
* @ since 0.19
* */
gboolean main_is_realized ( void )
{
return main_status . main_window_realized ;
}
2008-10-25 18:56:27 +00:00
/**
* 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 @ ref plugin_init ( ) .
2009-07-21 22:12:13 +00:00
* If the macro HAVE_LOCALE_H is defined , @ c setlocale ( LC_ALL , " " ) is called .
2009-06-22 15:08:44 +00:00
* The codeset for the message translations is set to UTF - 8.
2008-10-25 18:56:27 +00:00
*
2009-06-22 15:08:44 +00:00
* Note that this function only setups the gettext textdomain for you . You still have
2008-10-25 18:56:27 +00:00
* to adjust the build system of your plugin to get internationalisation support
* working properly .
*
* @ param locale_dir The location where the translation files should be searched . This is
2009-07-21 22:12:13 +00:00
* usually the @ c LOCALEDIR macro , defined by the build system .
* E . g . @ c $ prefix / share / locale .
2008-10-25 18:56:27 +00:00
* Only used on non - Windows systems . On Windows , the directory is determined
* by @ c g_win32_get_package_installation_directory ( ) .
2009-07-21 22:12:13 +00:00
* @ param package The package name , usually this is the @ c GETTEXT_PACKAGE macro ,
2008-10-25 18:56:27 +00:00
* defined by the build system .
*
* @ since 0.16
* */
void main_locale_init ( const gchar * locale_dir , const gchar * package )
2006-08-17 14:40:43 +00:00
{
2008-10-25 18:56:27 +00:00
gchar * l_locale_dir = NULL ;
2006-08-17 14:40:43 +00:00
2008-06-03 16:30:54 +00:00
# ifdef HAVE_LOCALE_H
2007-06-25 17:49:45 +00:00
setlocale ( LC_ALL , " " ) ;
# endif
2006-08-17 14:40:43 +00:00
# ifdef G_OS_WIN32
2009-04-05 21:07:40 +00:00
{
gchar * install_dir = win32_get_installation_dir ( ) ;
/* e.g. C:\Program Files\geany\lib\locale */
l_locale_dir = g_strconcat ( install_dir , " \\ share \\ locale " , NULL ) ;
g_free ( install_dir ) ;
}
2006-08-17 14:40:43 +00:00
# else
2008-10-25 18:56:27 +00:00
l_locale_dir = g_strdup ( locale_dir ) ;
2006-07-26 17:02:16 +00:00
# endif
2006-01-14 22:38:06 +00:00
2008-10-25 18:56:27 +00:00
bindtextdomain ( package , l_locale_dir ) ;
bind_textdomain_codeset ( package , " UTF-8 " ) ;
g_free ( l_locale_dir ) ;
2006-08-17 14:40:43 +00:00
}
2008-05-07 11:34:38 +00:00
static void print_filetypes ( void )
{
2011-03-22 17:09:48 +00:00
GSList * node ;
2008-05-07 11:34:38 +00:00
filetypes_init_types ( ) ;
2011-03-22 17:09:48 +00:00
printf ( " Geany's filetype names: \n " ) ;
2008-05-07 11:34:38 +00:00
2011-03-22 17:09:48 +00:00
foreach_slist ( node , filetypes_by_title )
2008-05-07 11:34:38 +00:00
{
2011-03-22 17:09:48 +00:00
GeanyFiletype * ft = node - > data ;
printf ( " %s \n " , ft - > name ) ;
2008-05-07 11:34:38 +00:00
}
filetypes_free_types ( ) ;
}
2006-08-17 14:40:43 +00:00
static void parse_command_line_options ( gint * argc , gchar * * * argv )
{
GError * error = NULL ;
2007-12-23 17:06:11 +00:00
GOptionContext * context ;
2008-02-16 11:21:24 +00:00
gint i ;
2010-04-11 21:56:50 +00:00
CommandLineOptions def_clo = { FALSE , NULL , TRUE , - 1 , - 1 , FALSE , FALSE } ;
2008-02-16 11:21:24 +00:00
2008-02-27 13:17:29 +00:00
/* first initialise cl_options fields with default values */
2008-10-20 12:13:27 +00:00
cl_options = def_clo ;
2008-02-16 11:21:24 +00:00
2008-02-27 13:17:29 +00:00
/* the GLib option parser can't handle the +NNN (line number) option,
* so we grab that here and replace it with a no - op */
2008-02-16 11:21:24 +00:00
for ( i = 1 ; i < ( * argc ) ; i + + )
{
2009-04-15 22:47:33 +00:00
if ( ( * argv ) [ i ] [ 0 ] ! = ' + ' )
2008-02-16 11:21:24 +00:00
continue ;
cl_options . goto_line = atoi ( ( * argv ) [ i ] + 1 ) ;
( * argv ) [ i ] = " --dummy " ;
}
2007-12-23 17:06:11 +00:00
context = g_option_context_new ( _ ( " [FILES...] " ) ) ;
g_option_context_add_main_entries ( context , entries , GETTEXT_PACKAGE ) ;
g_option_group_set_translation_domain ( g_option_context_get_main_group ( context ) , GETTEXT_PACKAGE ) ;
g_option_context_add_group ( context , gtk_get_option_group ( FALSE ) ) ;
g_option_context_parse ( context , argc , argv , & error ) ;
g_option_context_free ( context ) ;
2006-06-12 13:17:11 +00:00
2009-04-15 22:47:33 +00:00
if ( error ! = NULL )
2007-12-19 13:49:59 +00:00
{
g_printerr ( " Geany: %s \n " , error - > message ) ;
g_error_free ( error ) ;
exit ( 1 ) ;
}
2006-01-14 22:38:06 +00:00
2009-04-15 22:47:33 +00:00
if ( show_version )
2006-01-14 22:38:06 +00:00
{
2010-11-07 17:09:09 +00:00
printf ( PACKAGE " %s ( " , main_get_version_string ( ) ) ;
/* note for translators: library versions are printed after this */
printf ( _ ( " built on %s with " ) , __DATE__ ) ;
printf ( geany_lib_versions ,
GTK_MAJOR_VERSION , GTK_MINOR_VERSION , GTK_MICRO_VERSION ,
GLIB_MAJOR_VERSION , GLIB_MINOR_VERSION , GLIB_MICRO_VERSION ) ;
printf ( " ) \n " ) ;
2006-08-17 14:40:43 +00:00
exit ( 0 ) ;
2006-01-14 22:38:06 +00:00
}
2009-04-15 22:47:33 +00:00
if ( print_prefix )
2007-12-18 17:03:39 +00:00
{
2007-12-19 15:37:10 +00:00
printf ( " %s \n " , GEANY_PREFIX ) ;
printf ( " %s \n " , GEANY_DATADIR ) ;
printf ( " %s \n " , GEANY_LIBDIR ) ;
printf ( " %s \n " , GEANY_LOCALEDIR ) ;
2007-12-18 17:03:39 +00:00
exit ( 0 ) ;
}
2009-01-15 18:20:19 +00:00
app - > debug_mode = verbose_mode ;
2006-04-27 18:05:57 +00:00
2007-12-30 15:54:00 +00:00
# ifdef G_OS_WIN32
win32_init_debug_code ( ) ;
# endif
2006-08-17 14:40:43 +00:00
if ( alternate_config )
{
geany_debug ( " alternate config: %s " , alternate_config ) ;
app - > configdir = alternate_config ;
}
else
2007-12-30 20:57:34 +00:00
{
2008-11-13 14:37:47 +00:00
app - > configdir = g_build_filename ( g_get_user_config_dir ( ) , " geany " , NULL ) ;
2007-12-30 20:57:34 +00:00
}
2006-08-17 14:40:43 +00:00
2009-04-15 22:47:33 +00:00
if ( generate_tags )
2007-04-25 15:01:14 +00:00
{
gboolean ret ;
2010-05-08 15:41:00 +00:00
document_init_doclist ( ) ;
2007-04-27 11:00:29 +00:00
filetypes_init_types ( ) ;
2008-11-26 16:09:48 +00:00
filetypes_read_extensions ( ) ; /* needed for *.lang.tags filetype matching */
2007-09-28 11:48:55 +00:00
ret = symbols_generate_global_tags ( * argc , * argv , ! no_preprocessing ) ;
2010-05-08 15:41:00 +00:00
filetypes_free_types ( ) ;
document_finalize ( ) ;
2007-04-25 15:01:14 +00:00
exit ( ret ) ;
}
2009-04-15 22:47:33 +00:00
if ( ft_names )
2007-06-17 17:56:48 +00:00
{
2008-05-07 11:34:38 +00:00
print_filetypes ( ) ;
2007-06-17 17:56:48 +00:00
exit ( 0 ) ;
}
2007-04-25 15:01:14 +00:00
2006-08-30 18:36:17 +00:00
# ifdef HAVE_SOCKET
2008-10-20 12:13:27 +00:00
socket_info . ignore_socket = cl_options . new_instance ;
2009-11-23 21:03:24 +00:00
if ( cl_options . socket_filename )
{
socket_info . file_name = cl_options . socket_filename ;
}
2006-08-17 14:40:43 +00:00
# endif
2009-11-23 21:03:24 +00:00
2006-08-17 14:40:43 +00:00
# ifdef HAVE_VTE
2006-08-19 15:07:11 +00:00
vte_info . lib_vte = lib_vte ;
2006-06-29 17:10:17 +00:00
# endif
2007-08-23 11:34:06 +00:00
cl_options . ignore_global_tags = ignore_global_tags ;
2007-12-23 17:06:11 +00:00
if ( ! gtk_init_check ( NULL , NULL ) )
2008-02-27 13:17:29 +00:00
{ /* check whether we have a valid X display and exit if not */
2007-12-23 17:06:11 +00:00
g_printerr ( " Geany: cannot open display \n " ) ;
exit ( 1 ) ;
}
2006-08-17 14:40:43 +00:00
}
2006-02-26 18:19:28 +00:00
2008-11-13 14:37:47 +00:00
static gint create_config_dir ( void )
{
gint saved_errno = 0 ;
gchar * conf_file = g_build_filename ( app - > configdir , " geany.conf " , NULL ) ;
gchar * filedefs_dir = g_build_filename ( app - > configdir , GEANY_FILEDEFS_SUBDIR , NULL ) ;
gchar * templates_dir = g_build_filename ( app - > configdir , GEANY_TEMPLATES_SUBDIR , NULL ) ;
if ( ! g_file_test ( app - > configdir , G_FILE_TEST_EXISTS ) )
{
2009-02-06 14:15:19 +00:00
# ifndef G_OS_WIN32
2008-11-13 14:37:47 +00:00
/* if we are *not* using an alternate config directory, we check whether the old one
* in ~ / . geany still exists and try to move it */
if ( alternate_config = = NULL )
{
gchar * old_dir = g_build_filename ( g_get_home_dir ( ) , " .geany " , NULL ) ;
/* move the old config dir if it exists */
if ( g_file_test ( old_dir , G_FILE_TEST_EXISTS ) )
{
2008-11-14 13:38:59 +00:00
if ( ! dialogs_show_question_full ( main_widgets . window ,
GTK_STOCK_YES , GTK_STOCK_QUIT , _ ( " Move it now? " ) ,
" %s " ,
_ ( " Geany needs to move your old configuration directory before starting. " ) ) )
exit ( 0 ) ;
2009-05-10 17:44:43 +00:00
if ( ! g_file_test ( app - > configdir , G_FILE_TEST_IS_DIR ) )
utils_mkdir ( app - > configdir , TRUE ) ;
2008-11-13 14:37:47 +00:00
if ( g_rename ( old_dir , app - > configdir ) = = 0 )
{
dialogs_show_msgbox ( GTK_MESSAGE_INFO ,
_ ( " Your configuration directory has been successfully moved from \" %s \" to \" %s \" . " ) ,
old_dir , app - > configdir ) ;
g_free ( old_dir ) ;
return 0 ;
}
else
{
dialogs_show_msgbox ( GTK_MESSAGE_WARNING ,
/* for translators: the third %s in brackets is the error message which
* describes why moving the dir didn ' t work */
_ ( " Your old configuration directory \" %s \" could not be moved to \" %s \" (%s). "
" Please move manually the directory to the new location. " ) ,
old_dir , app - > configdir , g_strerror ( errno ) ) ;
}
}
g_free ( old_dir ) ;
}
2009-02-06 14:15:19 +00:00
# endif
2008-11-13 14:37:47 +00:00
geany_debug ( " creating config directory %s " , app - > configdir ) ;
2009-05-10 17:44:43 +00:00
saved_errno = utils_mkdir ( app - > configdir , TRUE ) ;
2008-11-13 14:37:47 +00:00
}
if ( saved_errno = = 0 & & ! g_file_test ( conf_file , G_FILE_TEST_EXISTS ) )
{ /* check whether geany.conf can be written */
2011-02-06 16:47:18 +00:00
saved_errno = utils_is_file_writable ( app - > configdir ) ;
2008-11-13 14:37:47 +00:00
}
/* make subdir for filetype definitions */
if ( saved_errno = = 0 )
{
gchar * filedefs_readme = g_build_filename ( app - > configdir ,
GEANY_FILEDEFS_SUBDIR , " filetypes.README " , NULL ) ;
if ( ! g_file_test ( filedefs_dir , G_FILE_TEST_EXISTS ) )
{
saved_errno = utils_mkdir ( filedefs_dir , FALSE ) ;
}
if ( saved_errno = = 0 & & ! g_file_test ( filedefs_readme , G_FILE_TEST_EXISTS ) )
{
gchar * text = g_strconcat (
" Copy files from " , app - > datadir , " to this directory to overwrite "
" them. To use the defaults, just delete the file in this directory. \n For more information read "
2010-11-01 15:17:22 +00:00
" the documentation (in " , app - > docdir , G_DIR_SEPARATOR_S " index.html or visit " GEANY_HOMEPAGE " ). " , NULL ) ;
2008-11-13 14:37:47 +00:00
utils_write_file ( filedefs_readme , text ) ;
g_free ( text ) ;
}
g_free ( filedefs_readme ) ;
}
/* make subdir for template files */
if ( saved_errno = = 0 )
{
gchar * templates_readme = g_build_filename ( app - > configdir , GEANY_TEMPLATES_SUBDIR ,
" templates.README " , NULL ) ;
if ( ! g_file_test ( templates_dir , G_FILE_TEST_EXISTS ) )
{
saved_errno = utils_mkdir ( templates_dir , FALSE ) ;
}
if ( saved_errno = = 0 & & ! g_file_test ( templates_readme , G_FILE_TEST_EXISTS ) )
{
gchar * text = g_strconcat (
" There are several template files in this directory. For these templates you can use wildcards. \n \
2010-11-01 15:17:22 +00:00
For more information read the documentation ( in " , app->docdir, G_DIR_SEPARATOR_S " index . html or visit " GEANY_HOMEPAGE " ) . " ,
2008-11-13 14:37:47 +00:00
NULL ) ;
utils_write_file ( templates_readme , text ) ;
g_free ( text ) ;
}
g_free ( templates_readme ) ;
}
g_free ( filedefs_dir ) ;
g_free ( templates_dir ) ;
g_free ( conf_file ) ;
return saved_errno ;
}
2008-02-27 13:17:29 +00:00
/* Returns 0 if config dir is OK. */
2008-02-20 11:24:23 +00:00
static gint setup_config_dir ( void )
2006-08-17 14:40:43 +00:00
{
gint mkdir_result = 0 ;
2007-02-12 16:32:56 +00:00
2008-02-27 13:17:29 +00:00
/* convert configdir to locale encoding to avoid troubles */
2008-11-14 13:38:59 +00:00
setptr ( app - > configdir , utils_get_locale_from_utf8 ( app - > configdir ) ) ;
2006-02-26 18:19:28 +00:00
2008-11-13 14:37:47 +00:00
mkdir_result = create_config_dir ( ) ;
2009-04-15 22:47:33 +00:00
if ( mkdir_result ! = 0 )
2006-02-26 18:19:28 +00:00
{
2006-07-25 12:46:08 +00:00
if ( ! dialogs_show_question (
_ ( " Configuration directory could not be created (%s). \n There could be some problems "
2006-07-26 17:02:16 +00:00
" using Geany without a configuration directory. \n Start Geany anyway? " ) ,
g_strerror ( mkdir_result ) ) )
2006-07-25 12:46:08 +00:00
{
2006-08-17 14:40:43 +00:00
exit ( 0 ) ;
2006-07-25 12:46:08 +00:00
}
2006-02-26 18:19:28 +00:00
}
2008-12-28 13:40:26 +00:00
/* make configdir a real path */
if ( g_file_test ( app - > configdir , G_FILE_TEST_EXISTS ) )
setptr ( app - > configdir , tm_get_real_path ( app - > configdir ) ) ;
2006-08-17 14:40:43 +00:00
return mkdir_result ;
}
2006-02-10 21:06:41 +00:00
2006-08-17 14:40:43 +00:00
static void signal_cb ( gint sig )
{
if ( sig = = SIGTERM )
{
on_exit_clicked ( NULL , NULL ) ;
}
}
2008-07-21 14:12:15 +00:00
/* Used for command-line arguments at startup or from socket.
* this will strip any : line : col filename suffix from locale_filename */
2009-01-09 18:21:12 +00:00
gboolean main_handle_filename ( const gchar * locale_filename )
2008-04-16 11:41:36 +00:00
{
2008-06-15 13:35:48 +00:00
GeanyDocument * doc ;
2008-07-21 14:12:15 +00:00
gint line = - 1 , column = - 1 ;
2009-01-09 18:21:12 +00:00
gchar * filename ;
2008-04-16 11:41:36 +00:00
2009-04-15 22:47:33 +00:00
g_return_val_if_fail ( locale_filename , FALSE ) ;
2008-04-16 11:41:36 +00:00
2009-01-09 18:21:12 +00:00
/* check whether the passed filename is an URI */
filename = utils_get_path_from_uri ( locale_filename ) ;
2009-04-15 22:47:33 +00:00
if ( filename = = NULL )
2009-01-09 18:21:12 +00:00
return FALSE ;
get_line_and_column_from_filename ( filename , & line , & column ) ;
2008-07-21 14:12:15 +00:00
if ( line > = 0 )
cl_options . goto_line = line ;
if ( column > = 0 )
cl_options . goto_column = column ;
2008-04-16 11:41:36 +00:00
2010-07-05 12:03:27 +00:00
if ( g_file_test ( filename , G_FILE_TEST_IS_REGULAR ) )
2008-04-16 11:41:36 +00:00
{
2009-01-09 18:21:12 +00:00
doc = document_open_file ( filename , FALSE , NULL , NULL ) ;
2008-07-21 14:12:15 +00:00
/* add recent file manually if opening_session_files is set */
2009-04-15 22:47:33 +00:00
if ( doc ! = NULL & & main_status . opening_session_files )
2008-06-15 13:35:48 +00:00
ui_add_recent_file ( doc - > file_name ) ;
2009-01-09 18:21:12 +00:00
g_free ( filename ) ;
2008-07-21 14:12:15 +00:00
return TRUE ;
2008-04-16 11:41:36 +00:00
}
2008-07-21 14:28:46 +00:00
else if ( file_prefs . cmdline_new_files )
2008-07-21 14:12:15 +00:00
{ /* create new file with the given filename */
2009-01-09 18:21:12 +00:00
gchar * utf8_filename = utils_get_utf8_from_locale ( filename ) ;
2008-04-16 11:41:36 +00:00
2008-07-21 14:12:15 +00:00
doc = document_new_file ( utf8_filename , NULL , NULL ) ;
2009-04-15 22:47:33 +00:00
if ( doc ! = NULL )
2008-07-21 14:12:15 +00:00
ui_add_recent_file ( doc - > file_name ) ;
g_free ( utf8_filename ) ;
2009-01-09 18:21:12 +00:00
g_free ( filename ) ;
2008-07-21 14:12:15 +00:00
return TRUE ;
2008-04-16 11:41:36 +00:00
}
2009-01-09 18:21:12 +00:00
g_free ( filename ) ;
2008-07-21 14:12:15 +00:00
return FALSE ;
2008-04-16 11:41:36 +00:00
}
2008-02-27 13:17:29 +00:00
/* open files from command line */
2007-02-15 23:56:15 +00:00
static gboolean open_cl_files ( gint argc , gchar * * argv )
2007-01-13 12:42:12 +00:00
{
gint i ;
if ( argc < = 1 ) return FALSE ;
2008-04-16 11:41:36 +00:00
for ( i = 1 ; i < argc ; i + + )
2007-01-13 12:42:12 +00:00
{
2008-09-24 12:07:22 +00:00
gchar * filename = main_get_argv_filename ( argv [ i ] ) ;
2010-09-14 11:29:42 +00:00
if ( g_file_test ( filename , G_FILE_TEST_IS_DIR ) )
{
g_free ( filename ) ;
continue ;
}
2008-11-21 15:42:26 +00:00
# ifdef G_OS_WIN32
/* It seems argv elements are encoded in CP1252 on a German Windows */
setptr ( filename , g_locale_to_utf8 ( filename , - 1 , NULL , NULL , NULL ) ) ;
# endif
2009-04-15 22:47:33 +00:00
if ( filename & & ! main_handle_filename ( filename ) )
2008-07-21 14:12:15 +00:00
{
const gchar * msg = _ ( " Could not find file '%s'. " ) ;
g_printerr ( msg , filename ) ; /* also print to the terminal */
g_printerr ( " \n " ) ;
ui_set_statusbar ( TRUE , msg , filename ) ;
}
2007-01-13 12:42:12 +00:00
g_free ( filename ) ;
}
return TRUE ;
}
2008-10-20 12:13:27 +00:00
static void load_session_project_file ( void )
2007-04-21 12:25:17 +00:00
{
gchar * locale_filename ;
2009-04-15 22:47:33 +00:00
g_return_if_fail ( project_prefs . session_file ! = NULL ) ;
2007-04-21 12:25:17 +00:00
locale_filename = utils_get_locale_from_utf8 ( project_prefs . session_file ) ;
2009-01-17 18:46:44 +00:00
if ( NZV ( locale_filename ) )
2007-04-21 12:25:17 +00:00
project_load_file ( locale_filename ) ;
g_free ( locale_filename ) ;
2008-02-27 13:17:29 +00:00
g_free ( project_prefs . session_file ) ; /* no longer needed */
2007-04-21 12:25:17 +00:00
}
2008-02-20 11:24:23 +00:00
static void load_settings ( void )
2007-08-16 15:20:38 +00:00
{
configuration_load ( ) ;
2008-02-27 13:17:29 +00:00
/* let cmdline options overwrite configuration settings */
2007-08-16 15:20:38 +00:00
# ifdef HAVE_VTE
vte_info . have_vte = ( no_vte ) ? FALSE : vte_info . load_vte ;
# endif
2009-04-05 21:07:40 +00:00
if ( no_msgwin )
ui_prefs . msgwindow_visible = FALSE ;
2007-08-16 15:20:38 +00:00
2007-11-11 09:09:47 +00:00
# ifdef HAVE_PLUGINS
2007-08-23 11:34:06 +00:00
want_plugins = prefs . load_plugins & & ! no_plugins ;
2007-11-11 09:09:47 +00:00
# endif
2007-08-16 15:20:38 +00:00
}
2009-11-29 19:59:13 +00:00
void main_load_project_from_command_line ( const gchar * locale_filename , gboolean use_session )
{
gchar * pfile = NULL ;
if ( utils_is_uri ( locale_filename ) )
pfile = utils_get_path_from_uri ( locale_filename ) ;
else
pfile = g_strdup ( locale_filename ) ;
if ( pfile ! = NULL )
{
if ( use_session )
project_load_file_with_session ( pfile ) ;
else
project_load_file ( pfile ) ;
}
g_free ( pfile ) ;
}
2008-10-20 12:13:27 +00:00
static void load_startup_files ( gint argc , gchar * * argv )
{
gboolean load_project_from_cl = FALSE ;
/* ATM when opening a project file any other filenames are ignored */
load_project_from_cl = ( argc > 1 ) & & g_str_has_suffix ( argv [ 1 ] , " .geany " ) ;
2008-10-20 14:52:29 +00:00
if ( load_project_from_cl & & argc > 2 )
2008-12-04 15:56:54 +00:00
g_print ( " Ignoring extra filenames after %s " , argv [ 1 ] ) ;
2008-10-20 12:13:27 +00:00
if ( load_project_from_cl | | ! open_cl_files ( argc , argv ) )
{
if ( prefs . load_session )
{
if ( load_project_from_cl )
2009-01-09 18:21:12 +00:00
{
2009-11-29 19:59:13 +00:00
main_load_project_from_command_line ( argv [ 1 ] , FALSE ) ;
2009-01-09 18:21:12 +00:00
}
else if ( cl_options . load_session & & ! cl_options . new_instance )
2008-10-20 12:13:27 +00:00
load_session_project_file ( ) ;
/* when we want a new instance, we still load project session files unless -s
* was passed */
if ( ! cl_options . load_session | | ( ! load_project_from_cl & & cl_options . new_instance ) )
return ;
/* load session files into tabs, as they are found in the session_files variable */
configuration_open_files ( ) ;
if ( gtk_notebook_get_n_pages ( GTK_NOTEBOOK ( main_widgets . notebook ) ) = = 0 )
{
ui_update_popup_copy_items ( NULL ) ;
ui_update_popup_reundo_items ( NULL ) ;
}
}
}
}
2010-01-17 15:17:30 +00:00
static gboolean send_startup_complete ( gpointer data )
{
g_signal_emit_by_name ( geany_object , " geany-startup-complete " ) ;
return FALSE ;
}
2010-05-29 18:35:51 +00:00
static const gchar * get_locale ( void )
{
const gchar * locale = " unknown " ;
# ifdef HAVE_LOCALE_H
locale = setlocale ( LC_CTYPE , NULL ) ;
# endif
return locale ;
}
2006-08-17 14:40:43 +00:00
gint main ( gint argc , gchar * * argv )
{
2008-06-15 13:35:48 +00:00
GeanyDocument * doc ;
2006-08-17 14:40:43 +00:00
gint config_dir_result ;
2010-05-29 18:35:51 +00:00
const gchar * locale ;
2006-08-17 14:40:43 +00:00
2008-08-11 18:16:35 +00:00
log_handlers_init ( ) ;
2008-08-11 18:20:19 +00:00
2007-08-23 11:34:06 +00:00
app = g_new0 ( GeanyApp , 1 ) ;
memset ( & main_status , 0 , sizeof ( GeanyStatus ) ) ;
memset ( & prefs , 0 , sizeof ( GeanyPrefs ) ) ;
2008-05-16 12:08:39 +00:00
memset ( & interface_prefs , 0 , sizeof ( GeanyInterfacePrefs ) ) ;
memset ( & toolbar_prefs , 0 , sizeof ( GeanyToolbarPrefs ) ) ;
memset ( & file_prefs , 0 , sizeof ( GeanyFilePrefs ) ) ;
memset ( & search_prefs , 0 , sizeof ( GeanySearchPrefs ) ) ;
memset ( & tool_prefs , 0 , sizeof ( GeanyToolPrefs ) ) ;
memset ( & template_prefs , 0 , sizeof ( GeanyTemplatePrefs ) ) ;
2007-08-23 11:34:06 +00:00
memset ( & ui_prefs , 0 , sizeof ( UIPrefs ) ) ;
memset ( & ui_widgets , 0 , sizeof ( UIWidgets ) ) ;
2006-08-17 14:40:43 +00:00
setup_paths ( ) ;
2008-10-25 18:56:27 +00:00
# ifdef ENABLE_NLS
main_locale_init ( GEANY_LOCALEDIR , GETTEXT_PACKAGE ) ;
# endif
2006-08-17 14:40:43 +00:00
parse_command_line_options ( & argc , & argv ) ;
signal ( SIGTERM , signal_cb ) ;
2006-11-17 17:49:16 +00:00
# ifdef G_OS_UNIX
2008-02-27 13:17:29 +00:00
/* SIGQUIT is used to kill spawned children and we get also this signal, so ignore */
2006-11-11 18:51:33 +00:00
signal ( SIGQUIT , SIG_IGN ) ;
2008-02-27 13:17:29 +00:00
/* ignore SIGPIPE signal for preventing sudden death of program */
2006-08-17 14:40:43 +00:00
signal ( SIGPIPE , SIG_IGN ) ;
# endif
config_dir_result = setup_config_dir ( ) ;
2006-08-30 18:36:17 +00:00
# ifdef HAVE_SOCKET
2008-02-27 13:17:29 +00:00
/* check and create (unix domain) socket for remote operation */
2006-08-30 18:36:17 +00:00
if ( ! socket_info . ignore_socket )
{
socket_info . lock_socket = - 1 ;
socket_info . lock_socket_tag = 0 ;
socket_info . lock_socket = socket_init ( argc , argv ) ;
2010-04-11 21:56:50 +00:00
/* Socket exists */
2008-02-12 12:04:55 +00:00
if ( socket_info . lock_socket = = - 2 )
2006-08-30 18:36:17 +00:00
{
2010-04-11 21:56:50 +00:00
/* Quit if filenames were sent to first instance or the list of open
* documents has been sent */
if ( argc > 1 | | cl_options . list_documents )
2006-09-03 19:19:56 +00:00
{
2009-04-08 16:06:40 +00:00
gdk_notify_startup_complete ( ) ;
2006-09-03 19:19:56 +00:00
g_free ( app - > configdir ) ;
g_free ( app - > datadir ) ;
g_free ( app - > docdir ) ;
g_free ( app ) ;
return 0 ;
}
2008-02-27 13:17:29 +00:00
/* Start a new instance if no command line strings were passed */
2006-09-03 19:19:56 +00:00
socket_info . ignore_socket = TRUE ;
2008-10-20 12:13:27 +00:00
cl_options . new_instance = TRUE ;
2006-08-30 18:36:17 +00:00
}
}
2006-02-20 22:59:42 +00:00
# endif
2006-02-10 21:06:41 +00:00
2010-05-29 18:35:51 +00:00
locale = get_locale ( ) ;
2010-11-07 17:09:09 +00:00
geany_debug ( " Geany %s, %s " ,
2008-09-24 12:07:22 +00:00
main_get_version_string ( ) ,
2010-05-29 18:35:51 +00:00
locale ) ;
2010-11-07 17:09:09 +00:00
geany_debug ( geany_lib_versions ,
gtk_major_version , gtk_minor_version , gtk_micro_version ,
glib_major_version , glib_minor_version , glib_micro_version ) ;
2010-11-07 16:39:49 +00:00
geany_debug ( " System data dir: %s " , app - > datadir ) ;
geany_debug ( " User config dir: %s " , app - > configdir ) ;
2006-01-14 22:38:06 +00:00
2008-11-21 17:27:16 +00:00
/* create the object so Geany signals can be connected in init() functions */
geany_object = geany_object_new ( ) ;
2008-02-27 13:17:29 +00:00
/* inits */
2006-02-26 18:19:28 +00:00
main_init ( ) ;
2008-08-04 14:07:49 +00:00
2006-07-25 09:12:51 +00:00
encodings_init ( ) ;
2008-08-04 14:07:49 +00:00
editor_init ( ) ;
2006-08-17 16:12:04 +00:00
2010-07-09 17:15:16 +00:00
/* init stash groups before loading keyfile */
2008-12-09 13:16:52 +00:00
configuration_init ( ) ;
2010-07-09 17:15:16 +00:00
ui_init_prefs ( ) ;
2008-12-16 13:01:47 +00:00
search_init ( ) ;
2008-12-28 13:21:35 +00:00
project_init ( ) ;
# ifdef HAVE_PLUGINS
plugins_init ( ) ;
# endif
2009-09-28 11:16:59 +00:00
sidebar_init ( ) ;
2009-07-16 15:04:21 +00:00
load_settings ( ) ; /* load keyfile */
2006-08-17 16:12:04 +00:00
2009-11-04 12:36:56 +00:00
highlighting_init ( ) ;
2006-12-13 16:41:25 +00:00
msgwin_init ( ) ;
2007-08-23 11:34:06 +00:00
build_init ( ) ;
2006-09-05 14:24:47 +00:00
ui_create_insert_menu_items ( ) ;
ui_create_insert_date_menu_items ( ) ;
2006-08-17 16:12:04 +00:00
keybindings_init ( ) ;
2007-02-25 14:26:55 +00:00
tools_create_insert_custom_command_menu_items ( ) ;
2006-08-17 16:12:04 +00:00
notebook_init ( ) ;
2007-04-25 15:01:14 +00:00
filetypes_init ( ) ;
2007-02-19 13:26:06 +00:00
templates_init ( ) ;
2007-08-23 11:34:06 +00:00
navqueue_init ( ) ;
2007-02-19 13:26:06 +00:00
document_init_doclist ( ) ;
2008-11-18 13:29:53 +00:00
symbols_init ( ) ;
2008-11-26 16:09:48 +00:00
filetypes_read_extensions ( ) ;
2008-06-30 16:14:55 +00:00
editor_snippets_init ( ) ;
2006-01-14 22:38:06 +00:00
2008-02-27 13:17:29 +00:00
/* set window icon */
2006-12-13 15:18:49 +00:00
{
2009-07-19 20:19:09 +00:00
GdkPixbuf * pb = ui_new_pixbuf_from_inline ( GEANY_IMAGE_LOGO ) ;
2008-05-22 14:41:28 +00:00
gtk_window_set_icon ( GTK_WINDOW ( main_widgets . window ) , pb ) ;
2008-02-27 13:17:29 +00:00
g_object_unref ( pb ) ; /* free our reference */
2006-12-13 15:18:49 +00:00
}
2005-11-22 12:26:26 +00:00
2008-02-27 13:17:29 +00:00
/* registering some basic events */
2009-06-20 16:51:32 +00:00
g_signal_connect ( main_widgets . window , " delete-event " , G_CALLBACK ( on_exit_clicked ) , NULL ) ;
g_signal_connect ( main_widgets . window , " window-state-event " , G_CALLBACK ( on_window_state_event ) , NULL ) ;
2009-12-20 20:07:04 +00:00
g_signal_connect ( msgwindow . scribble , " motion-notify-event " , G_CALLBACK ( on_motion_event ) , NULL ) ;
2009-06-20 16:51:32 +00:00
2006-01-14 22:38:06 +00:00
# ifdef HAVE_VTE
2005-11-27 20:54:28 +00:00
vte_init ( ) ;
2006-01-14 22:38:06 +00:00
# endif
2009-04-05 14:14:29 +00:00
ui_create_recent_menus ( ) ;
2005-11-22 12:26:26 +00:00
2008-09-24 12:07:22 +00:00
ui_set_statusbar ( TRUE , _ ( " This is Geany %s. " ) , main_get_version_string ( ) ) ;
2006-08-17 14:40:43 +00:00
if ( config_dir_result ! = 0 )
2007-10-24 10:52:48 +00:00
ui_set_statusbar ( TRUE , _ ( " Configuration directory could not be created (%s). " ) ,
2006-08-17 14:40:43 +00:00
g_strerror ( config_dir_result ) ) ;
2005-11-22 12:26:26 +00:00
2008-02-27 13:17:29 +00:00
/* apply all configuration options */
2005-11-22 12:26:26 +00:00
apply_settings ( ) ;
2007-08-10 16:11:17 +00:00
# ifdef HAVE_PLUGINS
2008-02-27 13:17:29 +00:00
/* load any enabled plugins before we open any documents */
2007-08-16 15:20:38 +00:00
if ( want_plugins )
2008-12-28 13:21:35 +00:00
plugins_load_active ( ) ;
2007-08-10 16:11:17 +00:00
# endif
2010-11-22 13:49:38 +00:00
ui_sidebar_show_hide ( ) ;
2009-04-27 19:30:29 +00:00
/* set the active sidebar page after plugins have been loaded */
gtk_notebook_set_current_page ( GTK_NOTEBOOK ( main_widgets . sidebar_notebook ) , ui_prefs . sidebar_page ) ;
2008-03-10 13:54:47 +00:00
/* load keybinding settings after plugins have added their groups */
keybindings_load_keyfile ( ) ;
2008-02-27 13:17:29 +00:00
/* load any command line files or session files */
2007-08-23 11:34:06 +00:00
main_status . opening_session_files = TRUE ;
2008-10-20 12:13:27 +00:00
load_startup_files ( argc , argv ) ;
2007-08-23 11:34:06 +00:00
main_status . opening_session_files = FALSE ;
2005-12-18 22:20:22 +00:00
2008-02-27 13:17:29 +00:00
/* open a new file if no other file was opened */
2008-04-08 14:07:17 +00:00
document_new_file_if_non_open ( ) ;
2005-12-09 01:58:46 +00:00
2007-07-20 12:06:51 +00:00
ui_document_buttons_update ( ) ;
2006-09-05 14:24:47 +00:00
ui_save_buttons_toggle ( FALSE ) ;
2006-01-14 22:38:06 +00:00
2008-06-15 13:35:48 +00:00
doc = document_get_current ( ) ;
2008-07-14 11:13:54 +00:00
gtk_widget_grab_focus ( GTK_WIDGET ( doc - > editor - > sci ) ) ;
2009-09-28 11:16:59 +00:00
sidebar_select_openfiles_item ( doc ) ;
2008-06-15 13:35:48 +00:00
build_menu_update ( doc ) ;
2009-09-28 11:16:59 +00:00
sidebar_update_tag_list ( doc , FALSE ) ;
2006-04-27 18:05:57 +00:00
2009-03-27 16:25:57 +00:00
# ifdef G_OS_WIN32
/* Manually realise the main window to be able to set the position but don't show it.
* We don ' t set the position after showing the window to avoid flickering . */
gtk_widget_realize ( main_widgets . window ) ;
# endif
setup_window_position ( ) ;
/* finally show the window */
2008-05-22 14:41:28 +00:00
gtk_widget_show ( main_widgets . window ) ;
2007-08-23 11:34:06 +00:00
main_status . main_window_realized = TRUE ;
2005-11-22 12:26:26 +00:00
2006-04-27 18:05:57 +00:00
configuration_apply_settings ( ) ;
2006-08-30 18:36:17 +00:00
# ifdef HAVE_SOCKET
2008-02-27 13:17:29 +00:00
/* register the callback of socket input */
2006-08-30 18:36:17 +00:00
if ( ! socket_info . ignore_socket & & socket_info . lock_socket > 0 )
{
socket_info . read_ioc = g_io_channel_unix_new ( socket_info . lock_socket ) ;
socket_info . lock_socket_tag = g_io_add_watch ( socket_info . read_ioc ,
2009-09-16 14:13:38 +00:00
G_IO_IN | G_IO_PRI | G_IO_ERR , socket_lock_input_cb , main_widgets . window ) ;
2006-08-30 18:36:17 +00:00
}
# endif
2009-02-24 18:26:16 +00:00
# ifdef G_OS_WIN32
2009-03-26 20:10:47 +00:00
{
gchar * dir ;
/* On Windows, change the working directory to the Geany installation path to not lock
* the directory of a file passed as command line argument ( see bug # 2626124 ) . */
dir = win32_get_installation_dir ( ) ;
win32_set_working_directory ( dir ) ;
g_free ( dir ) ;
}
2009-02-24 18:26:16 +00:00
# endif
2010-01-17 15:17:30 +00:00
/* when we are really done with setting everything up and the main event loop is running,
* tell other components , mainly plugins , that startup is complete */
g_idle_add_full ( G_PRIORITY_LOW , send_startup_complete , NULL , NULL ) ;
2005-11-22 12:26:26 +00:00
gtk_main ( ) ;
return 0 ;
}
2006-10-21 11:34:18 +00:00
2009-04-05 14:14:29 +00:00
static void queue_free ( GQueue * queue )
{
while ( ! g_queue_is_empty ( queue ) )
{
g_free ( g_queue_pop_tail ( queue ) ) ;
}
g_queue_free ( queue ) ;
}
2006-10-21 11:34:18 +00:00
void main_quit ( )
{
geany_debug ( " Quitting... " ) ;
# ifdef HAVE_SOCKET
socket_finalize ( ) ;
# endif
2007-06-26 16:17:16 +00:00
# ifdef HAVE_PLUGINS
2008-12-28 13:21:35 +00:00
plugins_finalize ( ) ;
2007-06-26 16:17:16 +00:00
# endif
2007-11-12 09:27:43 +00:00
2007-06-02 16:14:07 +00:00
navqueue_free ( ) ;
2006-10-21 11:34:18 +00:00
keybindings_free ( ) ;
filetypes_save_commands ( ) ;
2007-11-02 17:44:05 +00:00
highlighting_free_styles ( ) ;
2006-10-21 11:34:18 +00:00
templates_free_templates ( ) ;
msgwin_finalize ( ) ;
search_finalize ( ) ;
build_finalize ( ) ;
document_finalize ( ) ;
2006-12-15 17:09:05 +00:00
symbols_finalize ( ) ;
2008-12-27 12:55:04 +00:00
project_finalize ( ) ;
2007-06-17 17:56:48 +00:00
editor_finalize ( ) ;
2008-06-30 16:14:55 +00:00
editor_snippets_free ( ) ;
2007-12-07 14:13:05 +00:00
encodings_finalize ( ) ;
2008-12-06 11:10:06 +00:00
toolbar_finalize ( ) ;
2009-09-28 11:16:59 +00:00
sidebar_finalize ( ) ;
2008-12-09 13:16:52 +00:00
configuration_finalize ( ) ;
2009-08-14 11:05:47 +00:00
filetypes_free_types ( ) ;
2010-07-08 16:59:11 +00:00
ui_finalize ( ) ;
2008-08-11 18:16:35 +00:00
log_finalize ( ) ;
2006-10-21 11:34:18 +00:00
tm_workspace_free ( TM_WORK_OBJECT ( app - > tm_workspace ) ) ;
g_free ( app - > configdir ) ;
g_free ( app - > datadir ) ;
g_free ( app - > docdir ) ;
2007-08-23 11:34:06 +00:00
g_free ( prefs . default_open_path ) ;
2009-03-13 10:02:29 +00:00
g_free ( prefs . custom_plugin_path ) ;
2007-08-23 11:34:06 +00:00
g_free ( ui_prefs . custom_date_format ) ;
2008-05-16 12:08:39 +00:00
g_free ( interface_prefs . editor_font ) ;
g_free ( interface_prefs . tagbar_font ) ;
g_free ( interface_prefs . msgwin_font ) ;
2007-08-23 11:34:06 +00:00
g_free ( editor_prefs . long_line_color ) ;
2008-07-27 18:41:07 +00:00
g_free ( editor_prefs . comment_toggle_mark ) ;
2009-11-04 12:36:56 +00:00
g_free ( editor_prefs . color_scheme ) ;
2008-05-16 12:08:39 +00:00
g_free ( tool_prefs . context_action_cmd ) ;
g_free ( template_prefs . developer ) ;
g_free ( template_prefs . company ) ;
g_free ( template_prefs . mail ) ;
g_free ( template_prefs . initials ) ;
g_free ( template_prefs . version ) ;
g_free ( tool_prefs . term_cmd ) ;
g_free ( tool_prefs . browser_cmd ) ;
g_free ( tool_prefs . grep_cmd ) ;
2007-11-17 14:04:27 +00:00
g_free ( printing_prefs . external_print_cmd ) ;
g_free ( printing_prefs . page_header_datefmt ) ;
2007-08-23 11:34:06 +00:00
g_strfreev ( ui_prefs . custom_commands ) ;
2009-04-05 14:14:29 +00:00
queue_free ( ui_prefs . recent_queue ) ;
queue_free ( ui_prefs . recent_projects_queue ) ;
2007-08-23 11:34:06 +00:00
if ( ui_widgets . prefs_dialog & & GTK_IS_WIDGET ( ui_widgets . prefs_dialog ) ) gtk_widget_destroy ( ui_widgets . prefs_dialog ) ;
if ( ui_widgets . save_filesel & & GTK_IS_WIDGET ( ui_widgets . save_filesel ) ) gtk_widget_destroy ( ui_widgets . save_filesel ) ;
if ( ui_widgets . open_filesel & & GTK_IS_WIDGET ( ui_widgets . open_filesel ) ) gtk_widget_destroy ( ui_widgets . open_filesel ) ;
if ( ui_widgets . open_fontsel & & GTK_IS_WIDGET ( ui_widgets . open_fontsel ) ) gtk_widget_destroy ( ui_widgets . open_fontsel ) ;
if ( ui_widgets . open_colorsel & & GTK_IS_WIDGET ( ui_widgets . open_colorsel ) ) gtk_widget_destroy ( ui_widgets . open_colorsel ) ;
2006-10-21 11:34:18 +00:00
# ifdef HAVE_VTE
if ( vte_info . have_vte ) vte_close ( ) ;
g_free ( vte_info . lib_vte ) ;
2006-11-15 18:21:46 +00:00
g_free ( vte_info . dir ) ;
2006-10-21 11:34:18 +00:00
# endif
2008-05-22 14:41:28 +00:00
gtk_widget_destroy ( main_widgets . window ) ;
2006-10-21 11:34:18 +00:00
2008-02-27 13:17:29 +00:00
/* destroy popup menus */
2008-05-22 14:41:28 +00:00
if ( main_widgets . editor_menu & & GTK_IS_WIDGET ( main_widgets . editor_menu ) )
gtk_widget_destroy ( main_widgets . editor_menu ) ;
2007-08-23 11:34:06 +00:00
if ( ui_widgets . toolbar_menu & & GTK_IS_WIDGET ( ui_widgets . toolbar_menu ) )
gtk_widget_destroy ( ui_widgets . toolbar_menu ) ;
2006-10-21 11:34:18 +00:00
if ( msgwindow . popup_status_menu & & GTK_IS_WIDGET ( msgwindow . popup_status_menu ) )
gtk_widget_destroy ( msgwindow . popup_status_menu ) ;
if ( msgwindow . popup_msg_menu & & GTK_IS_WIDGET ( msgwindow . popup_msg_menu ) )
gtk_widget_destroy ( msgwindow . popup_msg_menu ) ;
if ( msgwindow . popup_compiler_menu & & GTK_IS_WIDGET ( msgwindow . popup_compiler_menu ) )
gtk_widget_destroy ( msgwindow . popup_compiler_menu ) ;
2008-11-21 17:27:16 +00:00
g_object_unref ( geany_object ) ;
geany_object = NULL ;
2006-10-21 11:34:18 +00:00
g_free ( app ) ;
gtk_main_quit ( ) ;
}
2007-06-04 13:22:43 +00:00
2008-07-23 11:46:02 +00:00
/**
* 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 ) .
*
2008-10-25 18:56:27 +00:00
* @ since 0.15
2008-07-23 11:46:02 +00:00
* */
void main_reload_configuration ( void )
{
/* reload templates */
templates_free_templates ( ) ;
templates_init ( ) ;
/* reload snippets */
editor_snippets_free ( ) ;
editor_snippets_init ( ) ;
/* reload filetype extensions */
2008-11-26 16:09:48 +00:00
filetypes_read_extensions ( ) ;
2008-07-23 11:46:02 +00:00
2009-09-14 11:53:08 +00:00
filetypes_reload ( ) ;
2009-07-13 11:58:21 +00:00
2008-11-25 12:09:08 +00:00
/* C tag names to ignore */
symbols_reload_config_files ( ) ;
2008-07-23 11:46:02 +00:00
ui_set_statusbar ( TRUE , _ ( " Configuration files reloaded. " ) ) ;
}