static void message_handler(DictionaryIterator *received, void *context) { bool refresh_window = 0; Tuple *tuple_show_date = dict_find(received, MESSAGE_KEY_ShowDate); Tuple *tuple_show_battery = dict_find(received, MESSAGE_KEY_ShowBattery); Tuple *tuple_use_bold_font = dict_find(received, MESSAGE_KEY_UseBoldFont); Tuple *tuple_use_larger_font = dict_find(received, MESSAGE_KEY_UseLargerFont); if (tuple_show_date) { refresh_window = 1; settings.show_date = (bool)tuple_show_date->value->int32; } if (tuple_show_battery) { refresh_window = 1; settings.show_battery = (bool)tuple_show_battery->value->int32; } if (tuple_use_bold_font) { refresh_window = 1; settings.use_bold_font = (bool)tuple_use_bold_font->value->int32; } if (tuple_use_larger_font) { refresh_window = 1; settings.use_larger_font = (bool)tuple_use_larger_font->value->int32; } persist_write_data(SETTINGS_KEY, &settings, sizeof(settings)); if (refresh_window) { main_window_destroy(); main_window_create(); } }
int main(int argc, char **argv) { gchar *backend = NULL; gchar *backend_opt = NULL; gchar *majacd_app = NULL; GOptionEntry entries[] = { {"backend", 'b', 0, G_OPTION_ARG_STRING, &backend_opt, "Path to majacd application", "<path>"}, {NULL} }; GError *err = NULL; GOptionContext *context; GtkWidget *err_dialog; context = g_option_context_new("- system tray icon to " "control the majacd application"); g_option_context_add_group(context, gtk_get_option_group(TRUE)); g_option_context_add_main_entries(context, entries, NULL); g_option_context_parse(context, &argc, &argv, &err); g_option_context_free(context); if (backend_opt) { backend = g_strdup(backend_opt); } else { backend = g_strdup(MAJACD_APP); } gtk_init(&argc, &argv); if (!(majacd_app = g_find_program_in_path(backend))) { err_dialog = gtk_message_dialog_new(NULL, GTK_DIALOG_MODAL, GTK_MESSAGE_ERROR, GTK_BUTTONS_CLOSE, "Could not locate the majacd application"); gtk_window_set_title(GTK_WINDOW(err_dialog), "Error"); gtk_dialog_run(GTK_DIALOG(err_dialog)); gtk_widget_destroy(err_dialog); g_error("Could not locate the majacd application\n"); /* NOT REACHED */ return EXIT_FAILURE; } if (backend_ctl_command(CMD_INIT, (gpointer) majacd_app) < 0) { g_error("Error starting %s", majacd_app); } main_window_create(); main_window_hide(); tray_icon_create(); gtk_main(); g_free(backend); g_free(majacd_app); return EXIT_SUCCESS; }
int main (int argc, char **argv) { #ifdef ENABLE_NLS setlocale (LC_ALL, ""); bindtextdomain(GETTEXT_PACKAGE, PACKAGE_LOCALE_DIR); bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8"); textdomain (GETTEXT_PACKAGE); #endif /* ENABLE_NLS */ gtk_init(&argc, &argv); #if GLIB_CHECK_VERSION (2, 24, 0) g_type_init(); #else if (!g_thread_supported()) g_thread_init(NULL); #endif gphpedit_debug_init (); main_window.prefmg = preferences_manager_new(); /* Start of IPC communication */ if (get_preferences_manager_single_instance_only(main_window.prefmg) && poke_existing_instance (argc - 1, argv + 1)) return 0; main_window_create(); main_window.tempmg = templates_manager_new(); main_window.docmg = document_manager_new_full(argv, argc); gtk_main(); /* it makes sense to install sigterm handler that would call this too */ shutdown_ipc (); return 0; }
int main(int argc, char** argv) { //Error handler signal(SIGSEGV, _on_crash); //Initialize IUP if(IupOpen(NULL,NULL) == IUP_ERROR) { printf("Error initializing IUP! Make sure the graphical environment is running.\n"); return 1; } //Initialize the DAT format driver formatRegisterDAT(); //Create the main window win = main_window_create(argc, argv); //Mainloop IupMainLoop(); //Clean up and exit main_window_cleanup(); IupClose(); return 0; }
static void message_handler(DictionaryIterator *received, void *context) { bool refresh_window = 0; app_log(APP_LOG_LEVEL_INFO, __FILE__, __LINE__, "this is message_handler"); /* options */ Tuple *tuple_black_on_white = dict_find(received, OPTION_BLACK_ON_WHITE); Tuple *tuple_show_date = dict_find(received, OPTION_SHOW_DATE); Tuple *tuple_show_battery = dict_find(received, OPTION_SHOW_BATTERY); Tuple *tuple_larger_clock_font = dict_find(received, OPTION_LARGER_CLOCK_FONT); /* options */ if (tuple_black_on_white) { app_log(APP_LOG_LEVEL_INFO, __FILE__, __LINE__, "found tuple_black_on_white"); refresh_window = 1; black_on_white = (bool)tuple_black_on_white->value->int32; } if (tuple_show_date) { app_log(APP_LOG_LEVEL_INFO, __FILE__, __LINE__, "found tuple_show_data"); refresh_window = 1; show_date = (bool)tuple_show_date->value->int32; } if (tuple_show_battery) { app_log(APP_LOG_LEVEL_INFO, __FILE__, __LINE__, "found tuple_show_battery"); refresh_window = 1; show_battery = (bool)tuple_show_battery->value->int32; } if (tuple_larger_clock_font) { app_log(APP_LOG_LEVEL_INFO, __FILE__, __LINE__, "found tuple_larger_clock_font"); refresh_window = 1; larger_clock_font = (bool)tuple_larger_clock_font->value->int32; } /* options */ persist_write_bool(OPTION_BLACK_ON_WHITE, black_on_white); persist_write_bool(OPTION_SHOW_DATE, show_date); persist_write_bool(OPTION_SHOW_BATTERY, show_battery); persist_write_bool(OPTION_LARGER_CLOCK_FONT, larger_clock_font); if (refresh_window) { main_window_unload(s_main_window); main_window_destroy(); main_window_create(); main_window_load(s_main_window); } }
int WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE /*hPrevInstance*/, LPWSTR /*lpCmdLine*/, int nCmdShow) { { INITCOMMONCONTROLSEX icc = INITCOMMONCONTROLSEX(); icc.dwSize = sizeof icc; icc.dwICC = ICC_WIN95_CLASSES; InitCommonControlsEx(&icc); } std::experimental::optional<prev_instance_mutex> m; try { m = std::move(prev_instance_mutex(application_mutex)); } catch (const windows_error& e) { explain(e); return 0; } if (*(m->prev_instance_exists())) { main_window_activate_prev_instance(); return 0; } std::experimental::optional<com_manager> c; try { c = std::move(com_manager()); } catch (const _com_error& e) { explain(e); return 0; } main_window_register(hInstance); main_window_create(hInstance, nCmdShow); BOOL r; MSG msg; while ((r = GetMessage(&msg, nullptr, 0, 0)) > 0) { TranslateMessage(&msg); DispatchMessage(&msg); } if (r == -1) { explain(L"GetMessage failed"); return 0; } return msg.wParam; }
static void init(void) { main_window_create(); app_message_open(app_message_inbox_size_maximum(), app_message_outbox_size_maximum()); app_message_register_inbox_received(message_handler); }
/******************************************************** * 'Here be Dragons'...art, beauty, fun, & magic. * ********************************************************/ gboolean program_init(int argc, char **argv){ if((ipc_init_check(argc, argv))){ g_fprintf(stdout, "%s is already running. Be sure to check your desktop's notification tray for %s's icon.\n", GETTEXT_PACKAGE, GETTEXT_PACKAGE); ipc_deinit(); return FALSE; } datetime_locale_init(); GOptionContext *option_context=g_option_context_new(GETTEXT_PACKAGE); GOptionEntry option_entries[]={ { G_OPTION_REMAINING, 0, 0, G_OPTION_ARG_FILENAME_ARRAY, &remaining_argv, "Special option that collects any remaining arguments for us" }, { NULL } }; g_option_context_add_main_entries(option_context, option_entries, NULL); program=gnome_program_init( GETTEXT_PACKAGE, PACKAGE_RELEASE_VERSION, LIBGNOME_MODULE, argc, argv, GNOME_PARAM_GOPTION_CONTEXT, option_context, GNOME_PARAM_NONE ); if(remaining_argv) remaining_argc=g_strv_length(remaining_argv)-1; bindtextdomain(GETTEXT_PACKAGE, LOCALEDIR); bind_textdomain_codeset(GETTEXT_PACKAGE, "UTF-8"); textdomain(GETTEXT_PACKAGE); g_set_application_name(GETTEXT_PACKAGE); gtk_window_set_default_icon_name(GETTEXT_PACKAGE); if(!g_thread_supported()) g_thread_init(NULL); gtk_init(&argc, &argv); cache_init(); debug_init(); gconfig_start(); notifing=notify_init(GETTEXT_PACKAGE); proxy_init(); online_services_init(); www_init(); images_init(); groups_init(); main_window_create(); return TRUE; }/*program_init();*/