static void setup_paths(void) { gchar *data_dir; gchar *doc_dir; /* set paths */ #ifdef G_OS_WIN32 /* use the installation directory(the one where geany.exe is located) as the base for the * documentation and data files */ gchar *install_dir = win32_get_installation_dir(); data_dir = g_build_filename(install_dir, "data", NULL); /* e.g. C:\Program Files\geany\data */ doc_dir = g_build_filename(install_dir, "doc", NULL); change_working_directory_on_windows(install_dir); g_free(install_dir); #else data_dir = g_build_filename(GEANY_DATADIR, "geany", NULL); /* e.g. /usr/share/geany */ doc_dir = g_build_filename(GEANY_DOCDIR, "html", NULL); #endif /* convert path names to locale encoding */ 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); }
static void change_working_directory_on_windows(void) { gchar *install_dir = win32_get_installation_dir(); /* remember original working directory for use with opening files from the command line */ original_cwd = g_get_current_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). * This also helps if plugins or other code uses relative paths to load * any additional resources (e.g. share/geany-plugins/...). */ win32_set_working_directory(install_dir); g_free(install_dir); }
/** * 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(). * If the macro HAVE_LOCALE_H is defined, @c 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 @ref PLUGIN_SET_TRANSLATABLE_INFO() you * don't need to call main_locale_init() again as it has already been done. * * @param locale_dir The location where the translation files should be searched. This is * usually the @c LOCALEDIR macro, defined by the build system. * E.g. @c $prefix/share/locale. * Only used on non-Windows systems. On Windows, the directory is determined * by @c g_win32_get_package_installation_directory(). * @param package The package name, usually this is the @c GETTEXT_PACKAGE macro, * defined by the build system. * * @since 0.16 **/ void main_locale_init(const gchar *locale_dir, const gchar *package) { gchar *l_locale_dir = NULL; #ifdef HAVE_LOCALE_H setlocale(LC_ALL, ""); #endif #ifdef G_OS_WIN32 { gchar *install_dir = win32_get_installation_dir(); /* e.g. C:\Program Files\geany\lib\locale */ l_locale_dir = g_build_filename(install_dir, "share", "locale", NULL); g_free(install_dir); } #else l_locale_dir = g_strdup(locale_dir); #endif bindtextdomain(package, l_locale_dir); bind_textdomain_codeset(package, "UTF-8"); g_free(l_locale_dir); }
static void main_init(void) { /* add our icon path in case we aren't installed in the system prefix */ gchar *path; #ifdef G_OS_WIN32 gchar *install_dir = win32_get_installation_dir(); path = g_build_filename(install_dir, "share", "icons", NULL); g_free(install_dir); #else path = g_build_filename(GEANY_DATADIR, "icons", NULL); #endif gtk_icon_theme_append_search_path(gtk_icon_theme_get_default(), path); g_free(path); /* inits */ ui_init_stock_items(); ui_init_builder(); main_widgets.window = NULL; app->project = NULL; ui_widgets.open_fontsel = NULL; ui_widgets.open_colorsel = NULL; ui_widgets.prefs_dialog = NULL; main_status.main_window_realized = FALSE; file_prefs.tab_order_ltr = FALSE; file_prefs.tab_order_beside = FALSE; main_status.quitting = FALSE; ignore_callback = FALSE; app->tm_workspace = tm_get_workspace(); ui_prefs.recent_queue = g_queue_new(); ui_prefs.recent_projects_queue = g_queue_new(); main_status.opening_session_files = FALSE; main_widgets.window = create_window1(); /* 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); /* store important pointers for later reference */ main_widgets.toolbar = toolbar_init(); main_widgets.sidebar_notebook = ui_lookup_widget(main_widgets.window, "notebook3"); main_widgets.notebook = ui_lookup_widget(main_widgets.window, "notebook1"); main_widgets.editor_menu = create_edit_menu1(); main_widgets.tools_menu = ui_lookup_widget(main_widgets.window, "tools1_menu"); main_widgets.message_window_notebook = ui_lookup_widget(main_widgets.window, "notebook_info"); main_widgets.project_menu = ui_lookup_widget(main_widgets.window, "menu_project1_menu"); ui_widgets.toolbar_menu = create_toolbar_popup_menu1(); ui_init(); /* set widget names for matching with .gtkrc-2.0 */ gtk_widget_set_name(main_widgets.window, "GeanyMainWindow"); gtk_widget_set_name(ui_widgets.toolbar_menu, "GeanyToolbarMenu"); gtk_widget_set_name(main_widgets.editor_menu, "GeanyEditMenu"); gtk_widget_set_name(ui_lookup_widget(main_widgets.window, "menubar1"), "GeanyMenubar"); gtk_widget_set_name(main_widgets.toolbar, "GeanyToolbar"); gtk_window_set_default_size(GTK_WINDOW(main_widgets.window), GEANY_WINDOW_DEFAULT_WIDTH, GEANY_WINDOW_DEFAULT_HEIGHT); }