int main(int argc, char **argv) { #if ENABLE_NLS bindtextdomain(GETTEXT_PACKAGE, LOCALEDIR); bind_textdomain_codeset(GETTEXT_PACKAGE, "UTF-8"); textdomain(GETTEXT_PACKAGE); #endif g_thread_init(NULL); gdk_threads_init(); gdk_threads_enter(); g_atexit(gdk_threads_leave); read_opts_preinit(&argc, &argv); hash_init(); g_atexit(hash_deinit); gui_init(opts.datadir ? opts.datadir : DATADIR); g_atexit(gui_deinit); list_init(); prefs_init(); g_atexit(prefs_deinit); read_opts_postinit(); gui_run(); return EXIT_SUCCESS; }
static gboolean activate_plugin (AnjutaPlugin *plugin) { TerminalPlugin *term_plugin; static gboolean initialized = FALSE; AnjutaUI *ui; DEBUG_PRINT ("%s", "TerminalPlugin: Activating Terminal plugin ..."); term_plugin = ANJUTA_PLUGIN_TERMINAL (plugin); term_plugin->widget_added_to_shell = FALSE; ui = anjuta_shell_get_ui (plugin->shell, NULL); term_plugin->action_group = anjuta_ui_add_action_group_entries (ui, "ActionGroupTerminal", _("terminal operations"), actions_terminal, G_N_ELEMENTS (actions_terminal), GETTEXT_PACKAGE, TRUE, term_plugin); term_plugin->uiid = anjuta_ui_merge (ui, UI_FILE); terminal_create (term_plugin); if (!initialized) { register_stock_icons (plugin); } /* Setup prefs callbacks */ prefs_init (term_plugin); /* Added widget in shell */ anjuta_shell_add_widget (plugin->shell, term_plugin->frame, "AnjutaTerminal", _("Terminal"), "terminal-plugin-icon", ANJUTA_SHELL_PLACEMENT_BOTTOM, NULL); /* terminal_focus_cb (term_plugin->term, NULL, term_plugin); */ term_plugin->widget_added_to_shell = TRUE; initialized = TRUE; /* Set all terminal preferences, at that time the terminal widget is * not realized, a few vte functions are not working. Another * possibility could be to call this when the widget is realized */ preferences_changed (term_plugin->settings, term_plugin); /* set up project directory watch */ term_plugin->root_watch_id = anjuta_plugin_add_watch (plugin, IANJUTA_PROJECT_MANAGER_PROJECT_ROOT_URI, on_project_root_added, 0, NULL); return TRUE; }
void epan_init(void (*register_all_protocols_func)(register_cb cb, gpointer client_data), void (*register_all_handoffs_func)(register_cb cb, gpointer client_data), register_cb cb, gpointer client_data, void (*report_failure)(const char *, va_list), void (*report_open_failure)(const char *, int, gboolean), void (*report_read_failure)(const char *, int), void (*report_write_failure)(const char *, int)) { init_report_err(report_failure, report_open_failure, report_read_failure, report_write_failure); /* initialize memory allocation subsystem */ ep_init_chunk(); se_init_chunk(); /* initialize the GUID to name mapping table */ guids_init(); except_init(); #ifdef HAVE_LIBGNUTLS gnutls_global_init(); #elif defined(HAVE_LIBGCRYPT) gcry_check_version(NULL); #endif tvbuff_init(); tap_init(); prefs_init(); proto_init(register_all_protocols_func, register_all_handoffs_func, cb, client_data); packet_init(); dfilter_init(); final_registration_all_protocols(); host_name_lookup_init(); expert_init(); oids_init(); #ifdef HAVE_LUA_5_1 wslua_init(NULL); #endif #ifdef HAVE_GEOIP geoip_db_init(); #endif }
/// Prints the known set of properties and their current values. /// @param[in] all boolean - if true, show undocumented properties too /// @param[in] verbose boolean - if true, show property descriptions /// @param[in] exe the name of the current program void prop_help(int all, int verbose, CCS exe) { int prop; char name[PROP_NAME_MAX]; CCS val; if (verbose) { printf("\nPROPERTIES [current values]:\n\n"); } for (prop = 0; proptab[prop].pr_name; prop++) { if (!((proptab[prop].pr_flags & PROP_FLAG_PUBLIC) || all)) { continue; } if (!(val = _prop_get_str((prop_e)prop, 0))) { val = PROP_NULL; } if (verbose && proptab[prop].pr_desc) { char pfx; if (all && (proptab[prop].pr_flags & PROP_FLAG_EXPORT)) { pfx = '*'; } else { pfx = '#'; } printf("%c %s:\n", pfx, proptab[prop].pr_desc); } snprintf(name, sizeof(name), "%s:", proptab[prop].pr_name); printf("%-28s %s\n", name, val); if (verbose && proptab[prop + 1].pr_name) { fputc('\n', stdout); } } if (verbose && exe) { printf("LOADED FROM:\n"); prefs_init(exe, PROP_EXT, "\t"); } }
void epan_init(void (*register_all_protocols_func)(register_cb cb, gpointer client_data), void (*register_all_handoffs_func)(register_cb cb, gpointer client_data), register_cb cb, gpointer client_data, void (*report_failure_fcn_p)(const char *, va_list), void (*report_open_failure_fcn_p)(const char *, int, gboolean), void (*report_read_failure_fcn_p)(const char *, int), void (*report_write_failure_fcn_p)(const char *, int)) { init_report_err(report_failure_fcn_p, report_open_failure_fcn_p, report_read_failure_fcn_p, report_write_failure_fcn_p); /* initialize memory allocation subsystems */ emem_init(); wmem_init(); /* initialize the GUID to name mapping table */ guids_init(); except_init(); #ifdef HAVE_LIBGCRYPT /* initialize libgcrypt (beware, it won't be thread-safe) */ gcry_check_version(NULL); gcry_control (GCRYCTL_DISABLE_SECMEM, 0); gcry_control (GCRYCTL_INITIALIZATION_FINISHED, 0); #endif #ifdef HAVE_LIBGNUTLS gnutls_global_init(); #endif tap_init(); prefs_init(); expert_init(); proto_init(register_all_protocols_func, register_all_handoffs_func, cb, client_data); packet_init(); dfilter_init(); final_registration_all_protocols(); /*host_name_lookup_init();*//* We load the hostname file in cf_open, no need to do it here? */ expert_packet_init(); #ifdef HAVE_LUA wslua_init(cb, client_data); #endif }
int main (int argc, char *argv[]) { GOptionContext *context; gboolean retval; GError *error = NULL; setlocale (LC_ALL, ""); bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR); bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8"); textdomain (GETTEXT_PACKAGE); context = g_option_context_new (NULL); g_option_context_add_group (context, gtk_get_option_group (TRUE)); retval = g_option_context_parse (context, &argc, &argv, &error); g_option_context_free (context); if (!retval) { g_print ("%s", error->message); g_error_free (error); exit (1); } settings = g_settings_new ("org.gnome.gnect"); g_set_application_name (_(APPNAME_LONG)); prefs_init (); game_init (); /* init gfx */ if (!gfx_load_pixmaps ()) { exit (1); } if (create_app ()) { game_reset (); gtk_main (); } game_free (); return 0; }
static void prefs_event_cb( enum app_event_enum e, gpointer p, gint i) { switch(e) { case EVENT_MAIN_INIT: prefs_init(); break; case EVENT_MAIN_REGISTER_PREFS: prefs_register(PREFS_PREFS_AUTO_SAVE, PREFS_TYPE_BOOL, _("Save settings on exit"), NULL, NULL); break; case EVENT_MAIN_PRESET_PREFS: prefs_set(PREFS_PREFS_AUTO_SAVE, TRUE); break; case EVENT_MAIN_LOAD_PREFS: prefs_load(); break; case EVENT_MAIN_CLOSE: /* save configuration */ if(prefs_bool(PREFS_PREFS_AUTO_SAVE)) prefs_store(); prefs_free(); break; case EVENT_IFACE_RELOAD_CONFIG: /* force reload of config */ prefs_load(); break; case EVENT_IFACE_STORE_CONFIG: prefs_store(); break; default: break; } }
void epan_init(void (*register_all_protocols_func)(register_cb cb, gpointer client_data), void (*register_all_handoffs_func)(register_cb cb, gpointer client_data), register_cb cb, gpointer client_data) { /* initialize memory allocation subsystem */ wmem_init(); /* initialize the GUID to name mapping table */ guids_init(); /* initialize name resolution (addr_resolv.c) */ addr_resolv_init(); except_init(); #ifdef HAVE_LIBGCRYPT /* initialize libgcrypt (beware, it won't be thread-safe) */ gcry_check_version(NULL); gcry_control (GCRYCTL_DISABLE_SECMEM, 0); gcry_control (GCRYCTL_INITIALIZATION_FINISHED, 0); #endif #ifdef HAVE_LIBGNUTLS gnutls_global_init(); #endif tap_init(); prefs_init(); expert_init(); packet_init(); proto_init(register_all_protocols_func, register_all_handoffs_func, cb, client_data); packet_cache_proto_handles(); dfilter_init(); final_registration_all_protocols(); print_cache_field_handles(); expert_packet_init(); #ifdef HAVE_LUA wslua_init(cb, client_data); #endif }
gboolean epan_init(void (*register_all_protocols_func)(register_cb cb, gpointer client_data), void (*register_all_handoffs_func)(register_cb cb, gpointer client_data), register_cb cb, gpointer client_data) { volatile gboolean status = TRUE; /* initialize memory allocation subsystem */ wmem_init(); /* initialize the GUID to name mapping table */ guids_init(); /* initialize name resolution (addr_resolv.c) */ addr_resolv_init(); except_init(); #ifdef HAVE_LIBGCRYPT /* initialize libgcrypt (beware, it won't be thread-safe) */ gcry_check_version(NULL); gcry_control (GCRYCTL_DISABLE_SECMEM, 0); gcry_control (GCRYCTL_INITIALIZATION_FINISHED, 0); #endif #ifdef HAVE_LIBGNUTLS gnutls_global_init(); #endif TRY { tap_init(); prefs_init(); expert_init(); packet_init(); capture_dissector_init(); proto_init(register_all_protocols_func, register_all_handoffs_func, cb, client_data); packet_cache_proto_handles(); dfilter_init(); final_registration_all_protocols(); print_cache_field_handles(); expert_packet_init(); export_pdu_init(); #ifdef HAVE_LUA wslua_init(cb, client_data); #endif } CATCH(DissectorError) { /* * This is probably a dissector, or something it calls, * calling REPORT_DISSECTOR_ERROR() in a registration * routine or something else outside the normal dissection * code path. */ const char *exception_message = GET_MESSAGE; static const char dissector_error_nomsg[] = "Dissector writer didn't bother saying what the error was"; report_failure("Dissector bug: %s", exception_message == NULL ? dissector_error_nomsg : exception_message); if (getenv("WIRESHARK_ABORT_ON_DISSECTOR_BUG") != NULL) abort(); status = FALSE; } ENDTRY; return status; }
void app_init (int argc, char **argv) { static gboolean nosplash = FALSE; static gboolean nonew = FALSE; static gboolean use_integrated_ui = TRUE; static gboolean credits = FALSE; static gboolean version = FALSE; static gboolean verbose = FALSE; static gboolean log_to_stderr = FALSE; #ifdef HAVE_GNOME GnomeClient *client; #endif static char *export_file_name = NULL; static char *export_file_format = NULL; static char *size = NULL; static char *show_layers = NULL; gboolean made_conversions = FALSE; GSList *files = NULL; static const gchar **filenames = NULL; int i = 0; gchar *export_format_string = /* Translators: The argument is a list of options, not to be translated */ g_strdup_printf(_("Select the filter/format out of: %s"), "cgm, dia, dxf, eps, eps-builtin, " EPS_PANGO "fig, mp, plt, hpgl, png (" # if defined(HAVE_LIBPNG) && defined(HAVE_LIBART) "png-libart, " # endif # ifdef HAVE_CAIRO "cairo-png, cairo-alpha-png, " # endif /* we always have pixbuf but don't know exactly all it's *few* save formats */ "pixbuf-png), jpg, " "shape, svg, tex (pgf-tex, pstricks-tex), " WMF "wpg"); GOptionContext *context = NULL; static GOptionEntry options[] = { {"export", 'e', 0, G_OPTION_ARG_FILENAME, NULL /* &export_file_name */, N_("Export loaded file and exit"), N_("OUTPUT")}, {"filter",'t', 0, G_OPTION_ARG_STRING, NULL /* &export_file_format */, NULL /* &export_format_string */, N_("TYPE") }, {"size", 's', 0, G_OPTION_ARG_STRING, NULL, N_("Export graphics size"), N_("WxH")}, {"show-layers", 'L', 0, G_OPTION_ARG_STRING, NULL, N_("Show only specified layers (e.g. when exporting). Can be either the layer name or a range of layer numbers (X-Y)"), N_("LAYER,LAYER,...")}, {"nosplash", 'n', 0, G_OPTION_ARG_NONE, &nosplash, N_("Don't show the splash screen"), NULL }, {"nonew", 'n', 0, G_OPTION_ARG_NONE, &nonew, N_("Don't create an empty diagram"), NULL }, {"classic", '\0', G_OPTION_FLAG_REVERSE, G_OPTION_ARG_NONE, &use_integrated_ui, N_("Start classic user interface (no diagrams in tabs)"), NULL }, {"log-to-stderr", 'l', 0, G_OPTION_ARG_NONE, &log_to_stderr, N_("Send error messages to stderr instead of showing dialogs."), NULL }, {"input-directory", 'I', 0, G_OPTION_ARG_CALLBACK, _check_option_input_directory, N_("Directory containing input files"), N_("DIRECTORY")}, {"output-directory", 'O', 0, G_OPTION_ARG_CALLBACK, _check_option_output_directory, N_("Directory containing output files"), N_("DIRECTORY")}, {"credits", 'c', 0, G_OPTION_ARG_NONE, &credits, N_("Display credits list and exit"), NULL }, {"verbose", 0, 0, G_OPTION_ARG_NONE, &verbose, N_("Generate verbose output"), NULL }, {"version", 'v', 0, G_OPTION_ARG_NONE, &version, N_("Display version and exit"), NULL }, { G_OPTION_REMAINING, 0, 0, G_OPTION_ARG_FILENAME_ARRAY, NULL /* &filenames */, NULL, NULL }, { NULL } }; /* for users of app_init() the default is interactive */ dia_is_interactive = TRUE; options[0].arg_data = &export_file_name; options[1].arg_data = &export_file_format; options[1].description = export_format_string; options[2].arg_data = &size; options[3].arg_data = &show_layers; g_assert (strcmp (options[13].long_name, G_OPTION_REMAINING) == 0); options[13].arg_data = (void*)&filenames; argv0 = (argc > 0) ? argv[0] : "(none)"; #if GTK_CHECK_VERSION(2,24,0) /* ... use setlocale directly? */ #else gtk_set_locale(); #endif setlocale(LC_NUMERIC, "C"); _setup_textdomains (); context = g_option_context_new(_("[FILE...]")); g_option_context_add_main_entries (context, options, GETTEXT_PACKAGE); #ifndef HAVE_GNOME /* avoid to add it a second time */ g_option_context_add_group (context, gtk_get_option_group (FALSE)); #endif if (argv) { GError *error = NULL; if (!g_option_context_parse (context, &argc, &argv, &error)) { if (error) { /* IMO !error here is a bug upstream, triggered e.g. with --gdk-debug=updates */ g_print ("%s", error->message); g_error_free (error); } else { g_print (_("Invalid option?")); } g_option_context_free(context); exit(1); } /* second level check of command line options, existance of input files etc. */ if (filenames) { while (filenames[i] != NULL) { gchar *filename; gchar *testpath; if (g_str_has_prefix (filenames[i], "file://")) { filename = g_filename_from_uri (filenames[i], NULL, NULL); if (!g_utf8_validate(filename, -1, NULL)) { gchar *tfn = filename; filename = g_filename_to_utf8(filename, -1, NULL, NULL, NULL); g_free(tfn); } } else filename = g_filename_to_utf8 (filenames[i], -1, NULL, NULL, NULL); if (!filename) { g_print (_("Filename conversion failed: %s\n"), filenames[i]); continue; } if (g_path_is_absolute(filename)) testpath = filename; else testpath = g_build_filename(input_directory ? input_directory : ".", filename, NULL); /* we still have a problem here, if GLib's file name encoding would not be utf-8 */ if (g_file_test (testpath, G_FILE_TEST_IS_REGULAR)) files = g_slist_append(files, filename); else { g_print (_("Missing input: %s\n"), filename); g_free (filename); } if (filename != testpath) g_free (testpath); ++i; } } /* given some files to output, we are not starting up the UI */ if (export_file_name || export_file_format || size) dia_is_interactive = FALSE; } if (argv && dia_is_interactive && !version) { #ifdef HAVE_GNOME GnomeProgram *program = gnome_program_init (PACKAGE, VERSION, LIBGNOMEUI_MODULE, argc, argv, /* haven't found a quick way to pass GOption here */ GNOME_PARAM_GOPTION_CONTEXT, context, GNOME_PROGRAM_STANDARD_PROPERTIES, GNOME_PARAM_NONE); client = gnome_master_client(); if(client == NULL) { g_warning(_("Can't connect to session manager!\n")); } else { g_signal_connect(G_OBJECT (client), "save_yourself", G_CALLBACK (save_state), NULL); g_signal_connect(G_OBJECT (client), "die", G_CALLBACK (session_die), NULL); } /* This smaller icon is 48x48, standard Gnome size */ /* gnome_window_icon_set_default_from_file (GNOME_ICONDIR"/dia_gnome_icon.png");*/ #else # ifdef G_THREADS_ENABLED g_thread_init (NULL); # endif gtk_init(&argc, &argv); #endif } else { #ifdef G_THREADS_ENABLED g_thread_init (NULL); #endif g_type_init(); /* * On Windows there is no command line without display so that gtk_init is harmless. * On X11 we need gtk_init_check() to avoid exit() just because there is no display * running outside of X11. */ if (!gtk_init_check(&argc, &argv)) dia_log_message ("Running without display"); } /* done with option parsing, don't leak */ g_free(export_format_string); if (version) { gchar *ver_utf8; gchar *ver_locale; #if (defined __TIME__) && (defined __DATE__) /* TRANSLATOR: 2nd and 3rd %s are time and date respectively. */ ver_utf8 = g_strdup_printf(_("Dia version %s, compiled %s %s\n"), VERSION, __TIME__, __DATE__); #else ver_utf8 = g_strdup_printf(_("Dia version %s\n"), VERSION); #endif ver_locale = g_locale_from_utf8(ver_utf8, -1, NULL, NULL, NULL); printf("%s\n", ver_locale); g_free(ver_locale); g_free(ver_utf8); if (verbose) dump_dependencies(); exit(0); } if (!dia_is_interactive) log_to_stderr = TRUE; libdia_init ( (dia_is_interactive ? DIA_INTERACTIVE : 0) | (log_to_stderr ? DIA_MESSAGE_STDERR : 0) | (verbose ? DIA_VERBOSE : 0) ); print_credits(credits); if (dia_is_interactive) { create_user_dirs(); if (!nosplash) app_splash_init(""); /* Init cursors: */ default_cursor = gdk_cursor_new(GDK_LEFT_PTR); ddisplay_set_all_cursor(default_cursor); } dia_register_plugins(); dia_register_builtin_plugin(internal_plugin_init); load_all_sheets(); /* new mechanism */ dia_log_message ("object defaults"); { DiaContext *ctx = dia_context_new (_("Object Defaults")); dia_object_defaults_load (NULL, TRUE /* prefs.object_defaults_create_lazy */, ctx); dia_context_release (ctx); } debug_break(); if (object_get_type("Standard - Box") == NULL) { message_error(_("Couldn't find standard objects when looking for " "object-libs; exiting...\n")); g_critical( _("Couldn't find standard objects when looking for " "object-libs in '%s'; exiting...\n"), dia_get_lib_directory("dia")); exit(1); } persistence_load(); /** Must load prefs after persistence */ prefs_init(); if (dia_is_interactive) { /* further initialization *before* reading files */ active_tool = create_modify_tool(); dia_log_message ("ui creation"); if (use_integrated_ui) { create_integrated_ui(); } else { create_toolbox(); /* for the integrated ui case it is integrated */ persistence_register_window_create("layer_window", (NullaryFunc*)&layer_dialog_create); } /*fill recent file menu */ recent_file_history_init(); /* Set up autosave to check every 5 minutes */ g_timeout_add_seconds(5*60, autosave_check_autosave, NULL); #if 0 /* do we really open these automatically in the next session? */ persistence_register_window_create("diagram_tree", &diagram_tree_show); #endif persistence_register_window_create("sheets_main_dialog", (NullaryFunc*)&sheets_dialog_create); /* In current setup, we can't find the autosaved files. */ /*autosave_restore_documents();*/ } dia_log_message ("diagrams"); made_conversions = handle_all_diagrams(files, export_file_name, export_file_format, size, show_layers, input_directory, output_directory); if (dia_is_interactive && files == NULL && !nonew) { if (use_integrated_ui) { GList * list; file_new_callback(NULL); list = dia_open_diagrams(); if (list) { Diagram * diagram = list->data; diagram_update_extents(diagram); diagram->is_default = TRUE; } } else { gchar *filename = g_filename_from_utf8(_("Diagram1.dia"), -1, NULL, NULL, NULL); Diagram *diagram = new_diagram (filename); g_free(filename); if (diagram != NULL) { diagram_update_extents(diagram); diagram->is_default = TRUE; /* I think this is done in diagram_init() with a call to * layer_dialog_update_diagram_list() */ layer_dialog_set_diagram(diagram); new_display(diagram); } } } g_slist_free(files); if (made_conversions) exit(0); dynobj_refresh_init(); dia_log_message ("initialized"); }
void plugin_init(G_GNUC_UNUSED GeanyData *gdata) { GeanyKeyGroup *scope_key_group; char *gladefile = g_build_filename(PLUGINDATADIR, "scope.glade", NULL); GError *gerror = NULL; GtkWidget *menubar1 = find_widget(geany->main_widgets->window, "menubar1"); guint item; const MenuKey *menu_key = debug_menu_keys; ToolItem *tool_item = toolbar_items; const ScopeCallback *scb; main_locale_init(LOCALEDIR, GETTEXT_PACKAGE); scope_key_group = plugin_set_key_group(geany_plugin, "scope", COUNT_KB, NULL); builder = gtk_builder_new(); gtk_builder_set_translation_domain(builder, GETTEXT_PACKAGE); scp_tree_store_register_dynamic(); if (!gtk_builder_add_from_file(builder, gladefile, &gerror)) { msgwin_status_add(_("Scope: %s."), gerror->message); g_warning(_("Scope: %s."), gerror->message); g_error_free(gerror); g_object_unref(builder); builder = NULL; } g_free(gladefile); if (!builder) return; /* interface */ #ifndef G_OS_UNIX gtk_widget_hide(get_widget("terminal_show")); #endif debug_item = get_widget("debug_item"); if (menubar1) gtk_menu_shell_insert(GTK_MENU_SHELL(menubar1), debug_item, DEBUG_MENU_ITEM_POS); else gtk_container_add(GTK_CONTAINER(geany->main_widgets->tools_menu), debug_item); menu_connect("debug_menu", &debug_menu_info, NULL); ui_add_document_sensitive(get_widget("scope_reset_markers")); ui_add_document_sensitive(get_widget("scope_cleanup_files")); for (item = 0; item < EVALUATE_KB; item++, menu_key++) { keybindings_set_item(scope_key_group, item, on_scope_key, 0, 0, menu_key->name, _(menu_key->label), debug_menu_items[item].widget); } geany_statusbar = GTK_STATUSBAR(gtk_widget_get_parent(geany->main_widgets->progressbar)); debug_statusbar = get_widget("debug_statusbar"); debug_state_label = GTK_LABEL(get_widget("debug_state_label")); gtk_box_pack_end(GTK_BOX(geany_statusbar), debug_statusbar, FALSE, FALSE, 0); debug_panel = get_widget("debug_panel"); gtk_notebook_append_page(GTK_NOTEBOOK(geany->main_widgets->message_window_notebook), debug_panel, get_widget("debug_label")); /* startup */ gtk216_init(); program_init(); prefs_init(); conterm_init(); inspect_init(); register_init(); parse_init(); debug_init(); views_init(); thread_init(); break_init(); watch_init(); stack_init(); local_init(); memory_init(); menu_init(); menu_set_popup_keybindings(scope_key_group, item); for (item = 0; tool_item->index != -1; item++, tool_item++) { GtkMenuItem *menu_item = GTK_MENU_ITEM(debug_menu_items[tool_item->index].widget); GtkToolItem *button = gtk_tool_button_new(NULL, gtk_menu_item_get_label(menu_item)); gtk_tool_button_set_use_underline(GTK_TOOL_BUTTON(button), gtk_menu_item_get_use_underline(menu_item)); g_signal_connect(button, "clicked", G_CALLBACK(on_toolbar_button_clicked), GINT_TO_POINTER(tool_item->index)); g_signal_connect(button, "toolbar-reconfigured", G_CALLBACK(on_toolbar_reconfigured), tool_item); tool_item->widget = GTK_WIDGET(button); plugin_add_toolbar_item(geany_plugin, button); } toolbar_update_state(DS_INACTIVE); views_update_state(DS_INACTIVE); configure_toolbar(); g_signal_connect(debug_panel, "switch-page", G_CALLBACK(on_view_changed), NULL); for (scb = scope_callbacks; scb->name; scb++) plugin_signal_connect(geany_plugin, NULL, scb->name, FALSE, scb->callback, NULL); }
void gtkpod_init(int argc, char *argv[]) { AnjutaPluginManager *plugin_manager; AnjutaProfileManager *profile_manager; AnjutaApp *app; AnjutaStatus *status; AnjutaProfile *profile; GFile *session_profile; GError *error = NULL; gchar *default_profile_file = NULL; gchar *user_profile_file = NULL; gchar *ui_file = NULL; gchar *remembered_plugins = NULL; gchar *session_dir = NULL; gchar *splash = NULL; /* Initialise important directories */ init_directories(argv); register_stock_icon(GTKPOD_ICON, GTKPOD_ICON_STOCK_ID); /* Initialise the ui file */ ui_file = g_build_filename(get_ui_dir(), "gtkpod.ui", NULL); anjuta_set_ui_file_path(ui_file); /* Register the application icon */ register_stock_icon("gtkpod", GTKPOD_APP_ICON_STOCK_ID); /* Initialize application class instance*/ app = ANJUTA_APP(anjuta_app_new()); gtkpod_app = GTKPOD_APP(app); /* Initialise the preferences as required for the display of the splash screen */ prefs_init(argc, argv); /* Show some progress as the app is initialised */ status = anjuta_shell_get_status(ANJUTA_SHELL(app), NULL); anjuta_status_progress_add_ticks(status, 1); /* Show the splash screen if user requires */ if (! prefs_get_int(DISABLE_SPLASH_SCREEN)) { splash = g_build_filename(get_icon_dir(), "gtkpod-splash.png", NULL); if (g_file_test(splash, G_FILE_TEST_IS_REGULAR)) anjuta_status_set_splash(status, splash, 100); else { anjuta_status_disable_splash(status, TRUE); } g_free(splash); } /* * initialise gtkpod library items. Needs to be safety threaded due * to splash screen. */ gdk_threads_enter(); gp_init(argc, argv); gdk_threads_leave(); /* Add blocking widgets from the framework */ add_blocked_widget(app->toolbar); add_blocked_widget(app->view_menu); /* Set up shutdown signals */ g_signal_connect(G_OBJECT(app), "delete_event", G_CALLBACK( on_gtkpod_delete_event), NULL); g_signal_connect(G_OBJECT(app), "destroy", G_CALLBACK(on_gtkpod_destroy), NULL); plugin_manager = anjuta_shell_get_plugin_manager(ANJUTA_SHELL(app), NULL); profile_manager = anjuta_shell_get_profile_manager(ANJUTA_SHELL(app), NULL); /* Restore remembered plugins */ remembered_plugins = g_settings_get_string(app->settings, GTKPOD_REMEMBERED_PLUGINS); if (remembered_plugins) anjuta_plugin_manager_set_remembered_plugins(plugin_manager, remembered_plugins); g_free(remembered_plugins); /* Load default profile */ default_profile_file = get_default_profile_path(); profile = anjuta_profile_new(USER_PROFILE_NAME, plugin_manager); session_profile = g_file_new_for_path(default_profile_file); anjuta_profile_add_plugins_from_xml(profile, session_profile, TRUE, &error); if (error) { anjuta_util_dialog_error(GTK_WINDOW(app), "%s", error->message); g_error_free(error); error = NULL; } g_object_unref(session_profile); g_free(default_profile_file); /* Load user session profile */ user_profile_file = get_user_profile_path(); session_profile = g_file_new_for_path(user_profile_file); if (g_file_query_exists(session_profile, NULL)) { anjuta_profile_add_plugins_from_xml(profile, session_profile, FALSE, &error); if (error) { anjuta_util_dialog_error(GTK_WINDOW(app), "%s", error->message); g_error_free(error); error = NULL; } } anjuta_profile_set_sync_file(profile, session_profile); g_object_unref(session_profile); g_free(user_profile_file); /* Load profile */ anjuta_profile_manager_freeze(profile_manager); anjuta_profile_manager_push(profile_manager, profile, &error); if (error) { anjuta_util_dialog_error(GTK_WINDOW(app), "%s", error->message); g_error_free(error); error = NULL; } /* Prepare for session save and load on profile change */ g_signal_connect (profile_manager, "profile-scoped", G_CALLBACK (on_profile_scoped), app); anjuta_profile_manager_thaw(profile_manager, &error); if (error) { anjuta_util_dialog_error(GTK_WINDOW(app), "%s", error->message); g_error_free(error); error = NULL; } g_signal_connect (profile_manager, "profile-descoped", G_CALLBACK (on_profile_descoped), app); gdk_threads_enter(); gp_init_itdbs(); gdk_threads_leave(); /* Load layout.*/ session_dir = get_user_session_dir(); if (!g_file_test(session_dir, G_FILE_TEST_IS_DIR)) session_dir = g_strdup(get_data_dir()); /* Restore session */ anjuta_shell_session_load(ANJUTA_SHELL(app), session_dir, NULL); g_free(session_dir); anjuta_status_progress_tick(status, NULL, _("Loaded Session...")); anjuta_status_disable_splash(status, TRUE); gtk_window_set_default_icon_name("gtkpod"); gtk_window_set_auto_startup_notification(TRUE); gtk_window_set_role(GTK_WINDOW(app), "gtkpod-app"); gtk_widget_show(GTK_WIDGET(app)); }
int main(int argc, char *argv[]) { int c; struct state *state = NULL; #if TEST_BUILD struct test_case *test_case; #endif prefs_init(); while(1) { int option_index = 0; static struct option long_options[] = { {"cart", required_argument, 0, OPT_CART }, {"force-extreme-disasm", no_argument, 0, OPT_FORCE_EXTREME_DISASM }, {"crop-screen", no_argument, 0, OPT_CROP_SCREEN }, {"loglevels" , required_argument, 0, OPT_LOGLEVELS }, {"audio-device" , required_argument, 0, OPT_AUDIO_DEVICE }, #if TEST_BUILD {"test-case", required_argument, 0, OPT_TEST_MODE}, #endif {0, 0, 0, 0 } }; c = getopt_long(argc, argv, "a:b:c:t:s:hdpyVAMvq", long_options, &option_index); if(c == -1) break; switch(c) { case 'a': prefs_set("diskimage", optarg); break; case 'b': prefs_set("diskimage2", optarg); break; case 'c': prefs_set("hdimage", optarg); break; case 't': prefs_set("tosimage", optarg); break; case 's': prefs_set("stateimage", optarg); break; case OPT_CART: prefs_set("cartimage", optarg); break; case OPT_FORCE_EXTREME_DISASM: cprint_all = 1; break; case OPT_CROP_SCREEN: crop_screen = 1; break; case OPT_LOGLEVELS: diag_set_module_levels(optarg); break; case OPT_AUDIO_DEVICE: if(!strncmp("list", optarg, 4)) { audio_device = -1; } else { audio_device = atoi(optarg); } break; #if TEST_BUILD case OPT_TEST_MODE: test_case_name = xstrdup(optarg); test_mode = 1; break; #endif case 'd': debugger = 1; break; case 'p': ppmoutput = 1; break; case 'y': psgoutput = 1; break; case 'v': verbosity++; break; case 'q': verbosity = MAX(1, verbosity-1); break; case 'V': vsync_delay = 1; break; case 'A': play_audio = 1; break; case 'M': monitor_sm124 = 1; break; case 'h': default: printf("Usage: %s [-AdMpqvVy] [-a diskimage1] [-b diskimage2] [-c hdimage] [-t tosimage] [-s stateimage]\n", argv[0]); exit(-1); break; } } /* Do not crop screen while debugging */ if(debugger) { crop_screen = 0; } if((prefs.diskimage == NULL) && (argv[optind] != NULL)) prefs_set("diskimage", argv[optind]); SDL_Init(SDL_INIT_VIDEO|SDL_INIT_JOYSTICK|SDL_INIT_AUDIO); #if TEST_BUILD if(test_mode) { test_case = test_init(test_case_name); if(test_case) { if(test_case->cartridge_name) { prefs_set("cartimage", test_case->cartridge_name); } if(test_case->floppy_name) { prefs_set("diskimage", test_case->floppy_name); } } else { printf("DEBUG: Could not load test case %s\n", test_case_name); exit(-3); } } #endif /* Must run before hardware module inits */ mmu_init(); /* This must also be run before hardware modules. It gives a dummy area for some memory regions to not cause bus errors */ mmu_fallback_init(); /* Actual hardware */ ram_init(); rom_init(); cpu_init(); if(prefs.cartimage) { cartridge_init(prefs.cartimage); } else { cartridge_init(NULL); } psg_init(); midi_init(); acia_init(); ikbd_init(); #if INCLUDE_RTC rtc_init(); #endif dma_init(); fdc_init(); hdc_init(prefs.hdimage); mfp_init(); screen_disable(0); glue_init(); shifter_init(); if(debugger) { debug_init(); cpu_halt_for_debug(); } screen_init(); floppy_init(prefs.diskimage, prefs.diskimage2); if(prefs.stateimage) { state = state_load(prefs.stateimage); } if(state != NULL) state_restore(state); memset(&reset, 0, sizeof reset); reset.sa_sigaction = reset_action; sigaction(SIGHUP, &reset, NULL); while(cpu_run(CPU_RUN)); return 0; }