static void
go_cmd_context_error_info_list_default 	(GOCmdContext *gcc, GSList *errs)
{
	if (errs == NULL)
		go_cmd_context_error_info (gcc, NULL);
	else
		go_cmd_context_error_info (gcc, g_slist_last (errs)->data);

}
示例#2
0
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);
}
示例#3
0
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);
}