int main (int argc, char const **argv) { GOErrorInfo *plugin_errs; GOCmdContext *cc; GOptionContext *ocontext; GError *error = NULL; const char *testname; /* No code before here, we need to init threads */ argv = gnm_pre_parse_init (argc, argv); ocontext = g_option_context_new (_("[testname]")); g_option_context_add_main_entries (ocontext, sstest_options, GETTEXT_PACKAGE); g_option_context_add_group (ocontext, gnm_get_option_group ()); g_option_context_parse (ocontext, &argc, (gchar ***)&argv, &error); g_option_context_free (ocontext); if (error) { g_printerr (_("%s\nRun '%s --help' to see a full list of available command line options.\n"), error->message, g_get_prgname ()); g_error_free (error); return 1; } if (sstest_show_version) { g_printerr (_("version '%s'\ndatadir := '%s'\nlibdir := '%s'\n"), GNM_VERSION_FULL, gnm_sys_data_dir (), gnm_sys_lib_dir ()); return 0; } gnm_init (); cc = cmd_context_stderr_new (); gnm_plugins_init (GO_CMD_CONTEXT (cc)); go_plugin_db_activate_plugin_list ( go_plugins_get_available_plugins (), &plugin_errs); if (plugin_errs) { /* FIXME: What do we want to do here? */ go_error_info_free (plugin_errs); } testname = argv[1]; if (!testname) testname = "all"; /* ---------------------------------------- */ MAYBE_DO ("test_insdel_rowcol_names") test_insdel_rowcol_names (); MAYBE_DO ("test_func_help") test_func_help (); MAYBE_DO ("test_go_data_cache_build_cache") test_go_data_cache_build_cache(); MAYBE_DO ("test_go_data_slicer_tuple_compare_to") test_go_data_slicer_tuple_compare_to (); /* ---------------------------------------- */ g_object_unref (cc); gnm_shutdown (); gnm_pre_parse_shutdown (); return 0; }
static gboolean gnumeric_init(GTypeModule *type_module, GList **registered_types, GError **error) { GOErrorInfo *plugin_errors = NULL; const gchar *argv[1]; command_context_register_type(type_module, registered_types); argv[0] = g_get_prgname(); gnm_pre_parse_init(1, argv); gnm_init(); command_context = command_context_new(); gnm_plugins_init(GO_CMD_CONTEXT(command_context)); go_plugin_db_activate_plugin_list(go_plugins_get_available_plugins(), &plugin_errors); if (plugin_errors) { g_set_error(error, CHUPA_DECOMPOSER_ERROR, CHUPA_DECOMPOSER_ERROR_INIT, "[decomposer][excel][init][error]" ": failed to initialize GOffice plugins: %s", go_error_info_peek_message(plugin_errors)); go_error_info_free(plugin_errors); return FALSE; } else { return TRUE; } }
void go_error_info_free (GOErrorInfo *error) { GSList *l; if (error == NULL || error->ref_count-- > 1) return; g_free (error->msg); for (l = error->details; l != NULL; l = l->next) go_error_info_free ((GOErrorInfo *) l->data); g_slist_free (error->details); g_free(error); }
static gboolean go_plugin_file_opener_probe (GOFileOpener const *fo, GsfInput *input, GOFileProbeLevel pl) { GOPluginFileOpener *pfo = GO_PLUGIN_FILE_OPENER (fo); GOPluginServiceFileOpener *service_file_opener = GO_PLUGIN_SERVICE_FILE_OPENER (pfo->service); g_return_val_if_fail (GSF_IS_INPUT (input), FALSE); if (pl == GO_FILE_PROBE_FILE_NAME && service_file_opener->suffixes != NULL) { GSList *ptr; gchar const *extension; gchar *lowercase_extension; if (gsf_input_name (input) == NULL) return FALSE; extension = gsf_extension_pointer (gsf_input_name (input)); if (extension == NULL) return FALSE; lowercase_extension = g_utf8_strdown (extension, -1); for (ptr = service_file_opener->suffixes; ptr != NULL ; ptr = ptr->next) if (0 == strcmp (lowercase_extension, ptr->data)) break; g_free (lowercase_extension); return ptr != NULL; } if (service_file_opener->has_probe) { GOErrorInfo *ignored_error = NULL; go_plugin_service_load (pfo->service, &ignored_error); if (ignored_error != NULL) { go_error_info_print (ignored_error); go_error_info_free (ignored_error); return FALSE; } else if (service_file_opener->cbs.plugin_func_file_probe == NULL) { return FALSE; } else { gboolean res = service_file_opener->cbs.plugin_func_file_probe (fo, pfo->service, input, pl); gsf_input_seek (input, 0, G_SEEK_SET); return res; } } else { return FALSE; } }
void go_plugin_service_deactivate (GOPluginService *service, GOErrorInfo **ret_error) { g_return_if_fail (GO_IS_PLUGIN_SERVICE (service)); GO_INIT_RET_ERROR_INFO (ret_error); if (!service->is_active) { return; } GO_PLUGIN_SERVICE_GET_CLASS (service)->deactivate (service, ret_error); if (*ret_error == NULL) { GOErrorInfo *ignored_error = NULL; service->is_active = FALSE; /* FIXME */ go_plugin_service_unload (service, &ignored_error); go_error_info_free (ignored_error); } }
static void cb_pm_button_rescan_directories_clicked (PluginManagerGUI *pm_gui) { GOErrorInfo *error; GSList *new_plugins, *l; GtkTreeModel *model = GTK_TREE_MODEL (pm_gui->model_plugins); GtkTreeIter iter, new_iter; gboolean has_iter; go_plugins_rescan (&error, &new_plugins); if (error != NULL) { go_cmd_context_error_info (pm_gui->cc, error); go_error_info_free (error); } GO_SLIST_SORT (new_plugins, plugin_compare_name); for (has_iter = gtk_tree_model_get_iter_first (model, &iter), l = new_plugins; has_iter && l != NULL; has_iter = gtk_tree_model_iter_next (model, &iter)) { GOPlugin *old_plugin, *new_plugin; gtk_tree_model_get (model, &iter, PLUGIN_POINTER, &old_plugin, -1); while (new_plugin = l->data, plugin_compare_name (old_plugin, new_plugin) > 0) { gtk_list_store_insert_before (pm_gui->model_plugins, &new_iter, &iter); set_plugin_model_row (pm_gui, &new_iter, new_plugin); l = l->next; if (l == NULL) break; } } while (l != NULL) { gtk_list_store_append (pm_gui->model_plugins, &new_iter); set_plugin_model_row (pm_gui, &new_iter, GO_PLUGIN (l->data)); l = l->next; } g_slist_free (new_plugins); }
int main (int argc, char const **argv) { GOErrorInfo *plugin_errs; int res = 0; GOCmdContext *cc; GOptionContext *ocontext; GError *error = NULL; /* No code before here, we need to init threads */ argv = gnm_pre_parse_init (argc, argv); ocontext = g_option_context_new (_("INFILE...")); g_option_context_add_main_entries (ocontext, ssindex_options, GETTEXT_PACKAGE); g_option_context_add_group (ocontext, gnm_get_option_group ()); g_option_context_parse (ocontext, &argc, (gchar ***)&argv, &error); g_option_context_free (ocontext); if (error) { g_printerr (_("%s\nRun '%s --help' to see a full list of available command line options.\n"), error->message, argv[0]); g_error_free (error); return 1; } if (ssindex_show_version) { g_printerr (_("ssindex version '%s'\ndatadir := '%s'\nlibdir := '%s'\n"), GNM_VERSION_FULL, gnm_sys_data_dir (), gnm_sys_lib_dir ()); return 0; } else if (!ssindex_run_indexer && !ssindex_list_mime_types) { g_printerr (_("Usage: %s [OPTION...] %s\n"), g_get_prgname (), _("INFILE...")); return 1; } gnm_init (); cc = gnm_cmd_context_stderr_new (); gnm_plugins_init (GO_CMD_CONTEXT (cc)); go_plugin_db_activate_plugin_list ( go_plugins_get_available_plugins (), &plugin_errs); if (plugin_errs) { /* FIXME: What do we want to do here? */ go_error_info_free (plugin_errs); } go_component_set_default_command_context (cc); if (ssindex_run_indexer) { GOIOContext *ioc = go_io_context_new (cc); int i; go_io_context_set_num_files (ioc, argc - 1); for (i = 1; i < argc; i++) { char const *file = argv[i]; go_io_context_processing_file (ioc, file); res |= ssindex (file, ioc); } g_object_unref (ioc); } else if (ssindex_list_mime_types) { GList *o; for (o = go_get_file_openers (); o != NULL ; o = o->next) { GSList const *mime = go_file_opener_get_mimes (o->data); for (; mime != NULL ; mime = mime->next) g_print ("%s\n", (char const *)mime->data); } } go_component_set_default_command_context (NULL); g_object_unref (cc); gnm_shutdown (); gnm_pre_parse_shutdown (); return res; }
void show_python_console (GnmAction const *action, WorkbookControl *wbc) { GtkWidget *vbox, *sc_win, *hbox, *sel, *cline, *w; GtkTextIter enditer; PangoFontDescription *font_desc; GOErrorInfo *err = NULL; if (app != NULL) { gtk_window_present (GTK_WINDOW (app->win)); return; } sel = gnm_py_interpreter_selector_new (&err); if (err != NULL) { go_cmd_context_error_info (GO_CMD_CONTEXT (wbc), err); go_error_info_free (err); return; } app = g_new (App, 1); app->win = gtk_window_new (GTK_WINDOW_TOPLEVEL); gtk_window_set_title (GTK_WINDOW (app->win), _("Gnumeric Python console")); app->cur_interpreter = gnm_py_interpreter_selector_get_current (GNM_PY_INTERPRETER_SELECTOR (sel)); g_signal_connect_object ( G_OBJECT (sel), "interpreter_changed", G_CALLBACK (app_interpreter_changed), app->win, 0); vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0); hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0); w = gtk_label_new_with_mnemonic (_("E_xecute in:")); gtk_label_set_mnemonic_widget (GTK_LABEL (w), sel); gtk_box_pack_start (GTK_BOX (hbox), w, FALSE, TRUE, 4); gtk_box_pack_start (GTK_BOX (hbox), sel, FALSE, TRUE, 0); gtk_box_pack_start (GTK_BOX (hbox), gtk_label_new (""), TRUE, TRUE, 0); w = gtk_button_new_from_stock (GTK_STOCK_CLEAR); g_signal_connect (G_OBJECT (w), "clicked", G_CALLBACK (cb_clear), NULL); gtk_box_pack_start (GTK_BOX (hbox), w, FALSE, TRUE, 0); gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, TRUE, 2); sc_win = gtk_scrolled_window_new (NULL, NULL); gtk_scrolled_window_set_policy ( GTK_SCROLLED_WINDOW (sc_win), GTK_POLICY_NEVER, GTK_POLICY_ALWAYS); app->text_view = GTK_TEXT_VIEW (gtk_text_view_new ()); app->text_buffer = gtk_text_view_get_buffer (app->text_view); app->text_tags[FORMAT_COMMAND] = gtk_text_buffer_create_tag ( app->text_buffer, NULL, "foreground", "black", NULL); app->text_tags[FORMAT_RESULT] = gtk_text_buffer_create_tag ( app->text_buffer, NULL, "foreground", "black", NULL); app->text_tags[FORMAT_MESSAGE] = gtk_text_buffer_create_tag ( app->text_buffer, NULL, "foreground", "green", NULL); app->text_tags[FORMAT_STDOUT] = gtk_text_buffer_create_tag ( app->text_buffer, NULL, "foreground", "blue", NULL); app->text_tags[FORMAT_STDERR] = gtk_text_buffer_create_tag ( app->text_buffer, NULL, "foreground", "red", NULL); gtk_text_buffer_get_iter_at_offset (app->text_buffer, &enditer, -1); app->text_end = gtk_text_buffer_create_mark (app->text_buffer, "text_end", &enditer, FALSE); font_desc = pango_font_description_from_string ("Fixed"); gtk_widget_override_font (GTK_WIDGET (app->text_view), font_desc); pango_font_description_free (font_desc); gtk_text_view_set_editable (GTK_TEXT_VIEW (app->text_view), FALSE); gtk_text_view_set_wrap_mode (GTK_TEXT_VIEW (app->text_view), GTK_WRAP_WORD); gtk_container_add (GTK_CONTAINER (sc_win), GTK_WIDGET (app->text_view)); gtk_box_pack_start (GTK_BOX (vbox), sc_win, TRUE, TRUE, 0); hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0); cline = gnm_py_command_line_new (); g_signal_connect (G_OBJECT (cline), "entered", G_CALLBACK (app_cline_entered), NULL); w = gtk_label_new_with_mnemonic (_("C_ommand:")); gtk_label_set_mnemonic_widget (GTK_LABEL (w), cline); gtk_box_pack_start (GTK_BOX (hbox), w, FALSE, TRUE, 4); gtk_box_pack_start (GTK_BOX (hbox), cline, TRUE, TRUE, 0); gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, TRUE, 0); gtk_container_add (GTK_CONTAINER (app->win), vbox); gtk_widget_grab_focus (cline); gtk_window_set_default_size (GTK_WINDOW (app->win), 600, 400); g_signal_connect (G_OBJECT (app->win), "delete_event", G_CALLBACK (cb_delete_app), NULL); g_signal_connect (G_OBJECT (app->win), "key_press_event", G_CALLBACK (cb_key_event), NULL); gtk_widget_show_all (app->win); }