Skip to content

Commit

Permalink
Open files session files after entering main loop
Browse files Browse the repository at this point in the history
This change makes the main window show immediately after launching Geany
so it's immediately visible Geany started. With big files/projects this
gives users better feedback about it's starting than not showing anything
until all the files are ready.
  • Loading branch information
techee committed Dec 12, 2015
1 parent 66821fb commit 95f1b12
Showing 1 changed file with 35 additions and 17 deletions.
52 changes: 35 additions & 17 deletions src/libmain.c
Expand Up @@ -144,6 +144,12 @@ static GOptionEntry entries[] =
{ NULL, 0, 0, 0, NULL, NULL, NULL }
};

static struct
{
gint argc;
gchar **argv;
} args;


static void setup_window_position(void)
{
Expand Down Expand Up @@ -1003,10 +1009,35 @@ static void setup_gtk2_styles(void)
#endif


static gboolean open_documents(gpointer user_data)
{
GeanyDocument *doc;

/* load any command line files or session files */
main_status.opening_session_files = TRUE;
load_startup_files(args.argc, args.argv);
main_status.opening_session_files = FALSE;

/* open a new file if no other file was opened */
document_new_file_if_non_open();

ui_document_buttons_update();
ui_save_buttons_toggle(FALSE);

doc = document_get_current();
sidebar_select_openfiles_item(doc);
build_menu_update(doc);
sidebar_update_tag_list(doc, FALSE);

document_grab_focus(doc);

return FALSE;
}


GEANY_EXPORT_SYMBOL
gint main_lib(gint argc, gchar **argv)
{
GeanyDocument *doc;
gint config_dir_result;
const gchar *locale;

Expand Down Expand Up @@ -1163,21 +1194,9 @@ gint main_lib(gint argc, gchar **argv)
* accelerator shown for the menu items */
tools_create_insert_custom_command_menu_items();

/* load any command line files or session files */
main_status.opening_session_files = TRUE;
load_startup_files(argc, argv);
main_status.opening_session_files = FALSE;

/* open a new file if no other file was opened */
document_new_file_if_non_open();

ui_document_buttons_update();
ui_save_buttons_toggle(FALSE);

doc = document_get_current();
sidebar_select_openfiles_item(doc);
build_menu_update(doc);
sidebar_update_tag_list(doc, FALSE);
args.argc = argc;
args.argv = argv;
g_idle_add(open_documents, NULL);

#ifdef G_OS_WIN32
/* Manually realise the main window to be able to set the position but don't show it.
Expand All @@ -1187,7 +1206,6 @@ gint main_lib(gint argc, gchar **argv)
setup_window_position();

/* finally show the window */
document_grab_focus(doc);
configuration_apply_settings();
gtk_widget_show(main_widgets.window);
main_status.main_window_realized = TRUE;
Expand Down

0 comments on commit 95f1b12

Please sign in to comment.