SAL_IMPLEMENT_MAIN_WITH_ARGS( argc, argv ) { sal_Bool bSentArgs = sal_False; const char* pUsePlugin; rtl_uString *pPipePath = NULL; Args *args; int status = 0; struct splash* splash = NULL; struct sigaction sigpipe_action; struct sigaction sigterm_action; /* turn SIGPIPE into an error */ memset(&sigpipe_action, 0, sizeof(struct sigaction)); sigpipe_action.sa_handler = SIG_IGN; sigemptyset(&sigpipe_action.sa_mask); sigaction(SIGPIPE, &sigpipe_action, NULL); memset(&sigterm_action, 0, sizeof(struct sigaction)); sigterm_action.sa_handler = &sigterm_handler; sigemptyset(&sigterm_action.sa_mask); sigaction(SIGTERM, &sigterm_action, NULL); args = args_parse (); args->pAppPath = get_app_path( argv[0] ); if ( !args->pAppPath ) { fprintf( stderr, "ERROR: Can't read app link\n" ); exit( 1 ); } #ifndef ENABLE_QUICKSTART_LIBPNG /* we can't load and render it anyway */ args->bInhibitSplash = sal_True; #endif pUsePlugin = getenv( "SAL_USE_VCLPLUGIN" ); if ( pUsePlugin && !strcmp(pUsePlugin, "svp") ) args->bInhibitSplash = sal_True; if ( !args->bInhibitPipe && getenv("LIBO_XDGAPP") == NULL ) { int fd = 0; pPipePath = get_pipe_path( args->pAppPath ); if ( ( fd = connect_pipe( pPipePath ) ) >= 0 ) { // Wait for answer char resp[ strlen( "InternalIPC::SendArguments" ) + 1]; ssize_t n = read( fd, resp, SAL_N_ELEMENTS( resp ) ); if (n == (ssize_t) SAL_N_ELEMENTS( resp ) && (memcmp( resp, "InternalIPC::SendArguments", SAL_N_ELEMENTS( resp ) - 1) == 0)) { rtl_uString *pCwdPath = NULL; osl_getProcessWorkingDir( &pCwdPath ); // Then send args bSentArgs = send_args( fd, pCwdPath ); } close( fd ); } } if ( !bSentArgs ) { /* we have to prepare for, and exec the binary */ int nPercent = 0; ChildInfo *info; sal_Bool bAllArgs = sal_True; sal_Bool bShortWait, bRestart; /* sanity check pieces */ system_checks(); /* load splash image and create window */ if ( !args->bInhibitSplash ) { splash = splash_create(args->pAppPath, argc, argv); } /* pagein */ if (!args->bInhibitPagein) exec_pagein (args); /* javaldx */ #if HAVE_FEATURE_JAVA if (!args->bInhibitJavaLdx) exec_javaldx (args); #endif do { bRestart = sal_False; /* fast updates if we have somewhere to update it to */ bShortWait = splash ? sal_True : sal_False; /* Periodically update the splash & the percent according to what status_fd says, poll quickly only while starting */ info = child_spawn (args, bAllArgs, bShortWait); g_pProcess = info->child; while (!child_exited_wait (info, bShortWait)) { ProgressStatus eResult; splash_draw_progress( splash, nPercent ); eResult = read_percent( info, &nPercent ); if (eResult != ProgressContinue) { splash_destroy(splash); splash = NULL; bShortWait = sal_False; } } status = child_get_exit_code(info); g_pProcess = NULL; // reset switch (status) { case EXITHELPER_CRASH_WITH_RESTART: // re-start with just -env: parameters bRestart = sal_True; bAllArgs = sal_False; break; case EXITHELPER_NORMAL_RESTART: // re-start with all arguments bRestart = sal_True; bAllArgs = sal_True; break; default: break; } child_info_destroy (info); } while (bRestart); } /* cleanup */ if ( pPipePath ) rtl_uString_release( pPipePath ); args_free (args); return status; }
static void gui_restore_after_callback (Gimp *gimp, GimpInitStatusFunc status_callback) { GimpGuiConfig *gui_config = GIMP_GUI_CONFIG (gimp->config); GimpDisplay *display; if (gimp->be_verbose) g_print ("INIT: %s\n", G_STRFUNC); gimp->message_handler = GIMP_MESSAGE_BOX; if (gui_config->restore_accels) menus_restore (gimp); ui_configurer = g_object_new (GIMP_TYPE_UI_CONFIGURER, "gimp", gimp, NULL); image_ui_manager = gimp_menu_factory_manager_new (global_menu_factory, "<Image>", gimp, gui_config->tearoff_menus); gimp_ui_manager_update (image_ui_manager, gimp); #ifdef GDK_WINDOWING_QUARTZ { GtkosxApplication *osx_app; GtkWidget *menu; GtkWidget *item; osx_app = gtkosx_application_get (); menu = gtk_ui_manager_get_widget (GTK_UI_MANAGER (image_ui_manager), "/image-menubar"); if (GTK_IS_MENU_ITEM (menu)) menu = gtk_menu_item_get_submenu (GTK_MENU_ITEM (menu)); gtkosx_application_set_menu_bar (osx_app, GTK_MENU_SHELL (menu)); gtkosx_application_set_use_quartz_accelerators (osx_app, FALSE); gui_add_to_app_menu (image_ui_manager, osx_app, "/image-menubar/Help/dialogs-about", 0); #define PREFERENCES "/image-menubar/Edit/Preferences/" gui_add_to_app_menu (image_ui_manager, osx_app, PREFERENCES "dialogs-preferences", 2); gui_add_to_app_menu (image_ui_manager, osx_app, PREFERENCES "dialogs-input-devices", 3); gui_add_to_app_menu (image_ui_manager, osx_app, PREFERENCES "dialogs-keyboard-shortcuts", 4); gui_add_to_app_menu (image_ui_manager, osx_app, PREFERENCES "dialogs-module-dialog", 5); gui_add_to_app_menu (image_ui_manager, osx_app, PREFERENCES "plug-in-unit-editor", 6); #undef PREFERENCES item = gtk_separator_menu_item_new (); gtkosx_application_insert_app_menu_item (osx_app, item, 7); item = gtk_ui_manager_get_widget (GTK_UI_MANAGER (image_ui_manager), "/image-menubar/File/file-quit"); gtk_widget_hide (item); g_signal_connect (osx_app, "NSApplicationBlockTermination", G_CALLBACK (gui_quartz_quit_callback), image_ui_manager); gtkosx_application_ready (osx_app); } #endif /* GDK_WINDOWING_QUARTZ */ g_signal_connect_object (gui_config, "notify::single-window-mode", G_CALLBACK (gui_single_window_mode_notify), ui_configurer, 0); g_signal_connect_object (gui_config, "notify::tearoff-menus", G_CALLBACK (gui_tearoff_menus_notify), image_ui_manager, 0); g_signal_connect (image_ui_manager, "show-tooltip", G_CALLBACK (gui_menu_show_tooltip), gimp); g_signal_connect (image_ui_manager, "hide-tooltip", G_CALLBACK (gui_menu_hide_tooltip), gimp); gimp_devices_restore (gimp); gimp_controllers_restore (gimp, image_ui_manager); if (status_callback == splash_update) splash_destroy (); color_history_restore (gimp); if (gimp_get_show_gui (gimp)) { GimpDisplayShell *shell; /* create the empty display */ display = GIMP_DISPLAY (gimp_create_display (gimp, NULL, GIMP_UNIT_PIXEL, 1.0)); shell = gimp_display_get_shell (display); if (gui_config->restore_session) session_restore (gimp); /* move keyboard focus to the display */ gtk_window_present (GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (shell)))); } /* indicate that the application has finished loading */ gdk_notify_startup_complete (); }
static void gui_restore_after_callback (Gimp *gimp, GimpInitStatusFunc status_callback) { GimpGuiConfig *gui_config = GIMP_GUI_CONFIG (gimp->config); GimpDisplay *display; if (gimp->be_verbose) g_print ("INIT: %s\n", G_STRFUNC); gimp->message_handler = GIMP_MESSAGE_BOX; /* load the recent documents after gimp_real_restore() because we * need the mime-types implemented by plug-ins */ status_callback (NULL, _("Documents"), 0.9); gimp_recent_list_load (gimp); /* enable this to always have icons everywhere */ if (g_getenv ("GIMP_ICONS_LIKE_A_BOSS")) { GdkScreen *screen = gdk_screen_get_default (); g_object_set (G_OBJECT (gtk_settings_get_for_screen (screen)), "gtk-button-images", TRUE, "gtk-menu-images", TRUE, NULL); } if (gui_config->restore_accels) menus_restore (gimp); ui_configurer = g_object_new (GIMP_TYPE_UI_CONFIGURER, "gimp", gimp, NULL); image_ui_manager = gimp_menu_factory_manager_new (global_menu_factory, "<Image>", gimp, gui_config->tearoff_menus); gimp_ui_manager_update (image_ui_manager, gimp); gimp_action_history_init (gimp); #ifdef GDK_WINDOWING_QUARTZ { GtkosxApplication *osx_app; GtkWidget *menu; GtkWidget *item; osx_app = gtkosx_application_get (); menu = gtk_ui_manager_get_widget (GTK_UI_MANAGER (image_ui_manager), "/image-menubar"); if (GTK_IS_MENU_ITEM (menu)) menu = gtk_menu_item_get_submenu (GTK_MENU_ITEM (menu)); gtkosx_application_set_menu_bar (osx_app, GTK_MENU_SHELL (menu)); gtkosx_application_set_use_quartz_accelerators (osx_app, FALSE); gui_add_to_app_menu (image_ui_manager, osx_app, "/image-menubar/Help/dialogs-about", 0); gui_add_to_app_menu (image_ui_manager, osx_app, "/image-menubar/Help/dialogs-search-action", 1); #define PREFERENCES "/image-menubar/Edit/Preferences/" gui_add_to_app_menu (image_ui_manager, osx_app, PREFERENCES "dialogs-preferences", 3); gui_add_to_app_menu (image_ui_manager, osx_app, PREFERENCES "dialogs-input-devices", 4); gui_add_to_app_menu (image_ui_manager, osx_app, PREFERENCES "dialogs-keyboard-shortcuts", 5); gui_add_to_app_menu (image_ui_manager, osx_app, PREFERENCES "dialogs-module-dialog", 6); gui_add_to_app_menu (image_ui_manager, osx_app, PREFERENCES "plug-in-unit-editor", 7); #undef PREFERENCES item = gtk_separator_menu_item_new (); gtkosx_application_insert_app_menu_item (osx_app, item, 8); item = gtk_ui_manager_get_widget (GTK_UI_MANAGER (image_ui_manager), "/image-menubar/File/file-quit"); gtk_widget_hide (item); g_signal_connect (osx_app, "NSApplicationBlockTermination", G_CALLBACK (gui_quartz_quit_callback), image_ui_manager); gtkosx_application_ready (osx_app); } #endif /* GDK_WINDOWING_QUARTZ */ g_signal_connect_object (gui_config, "notify::single-window-mode", G_CALLBACK (gui_single_window_mode_notify), ui_configurer, 0); g_signal_connect_object (gui_config, "notify::tearoff-menus", G_CALLBACK (gui_tearoff_menus_notify), image_ui_manager, 0); g_signal_connect (image_ui_manager, "show-tooltip", G_CALLBACK (gui_menu_show_tooltip), gimp); g_signal_connect (image_ui_manager, "hide-tooltip", G_CALLBACK (gui_menu_hide_tooltip), gimp); gimp_devices_restore (gimp); gimp_controllers_restore (gimp, image_ui_manager); if (status_callback == splash_update) splash_destroy (); color_history_restore (gimp); if (gimp_get_show_gui (gimp)) { GimpDisplayShell *shell; GtkWidget *toplevel; /* create the empty display */ display = GIMP_DISPLAY (gimp_create_display (gimp, NULL, GIMP_UNIT_PIXEL, 1.0, G_OBJECT (initial_screen), initial_monitor)); shell = gimp_display_get_shell (display); if (gui_config->restore_session) session_restore (gimp, initial_screen, initial_monitor); /* move keyboard focus to the display */ toplevel = gtk_widget_get_toplevel (GTK_WIDGET (shell)); gtk_window_present (GTK_WINDOW (toplevel)); } /* indicate that the application has finished loading */ gdk_notify_startup_complete (); /* clear startup monitor variables */ initial_screen = NULL; initial_monitor = -1; }
static void app_deinit(void) { splash_destroy(); }