Commit 33e12497 authored by Miguel de Icaza's avatar Miguel de Icaza Committed by Arturo Espinosa
Browse files

new routine that renders a cell selection into a an ascii string. IT HAS

1998-09-25  Miguel de Icaza  <miguel@nuclecu.unam.mx>

	* src/render-ascii.c (cell_region_render_ascii): new routine that
	renders a cell selection into a an ascii string.  IT HAS PILES OF
	LEAKS.  I have to go to the movies, will fix later tonight.

	* src/clipboard.c (x_clipboard_bind_workbook): New function used
	to connect the selection signals for a workbook.
	(x_selection_handler): New function: X selection handler.
	(clipboard_export_cell_region): New function: Export our clipboard
	to the X selection.
	(clipboard_copy_cell_range): call clipboard_export_cell_region

	* src/plugin-manager.c (plugin_manager_new), plugin.c: Add
	internationalization support.
parent c70dd58c
1998-09-25 Miguel de Icaza <miguel@nuclecu.unam.mx>
* src/render-ascii.c (cell_region_render_ascii): new routine that
renders a cell selection into a an ascii string. IT HAS PILES OF
LEAKS. I have to go to the movies, will fix later tonight.
* src/clipboard.c (x_clipboard_bind_workbook): New function used
to connect the selection signals for a workbook.
(x_selection_handler): New function: X selection handler.
(clipboard_export_cell_region): New function: Export our clipboard
to the X selection.
(clipboard_copy_cell_range): call clipboard_export_cell_region
* src/plugin-manager.c (plugin_manager_new), plugin.c: Add
internationalization support.
* src/sheet.c (sheet_selection_row_extend_to,
sheet_selection_col_extend_to): New version that makes sure the
column information has been allocated.
......
1998-09-25 Miguel de Icaza <miguel@nuclecu.unam.mx>
* src/render-ascii.c (cell_region_render_ascii): new routine that
renders a cell selection into a an ascii string. IT HAS PILES OF
LEAKS. I have to go to the movies, will fix later tonight.
* src/clipboard.c (x_clipboard_bind_workbook): New function used
to connect the selection signals for a workbook.
(x_selection_handler): New function: X selection handler.
(clipboard_export_cell_region): New function: Export our clipboard
to the X selection.
(clipboard_copy_cell_range): call clipboard_export_cell_region
* src/plugin-manager.c (plugin_manager_new), plugin.c: Add
internationalization support.
* src/sheet.c (sheet_selection_row_extend_to,
sheet_selection_col_extend_to): New version that makes sure the
column information has been allocated.
......
1998-09-25 Miguel de Icaza <miguel@nuclecu.unam.mx>
* src/render-ascii.c (cell_region_render_ascii): new routine that
renders a cell selection into a an ascii string. IT HAS PILES OF
LEAKS. I have to go to the movies, will fix later tonight.
* src/clipboard.c (x_clipboard_bind_workbook): New function used
to connect the selection signals for a workbook.
(x_selection_handler): New function: X selection handler.
(clipboard_export_cell_region): New function: Export our clipboard
to the X selection.
(clipboard_copy_cell_range): call clipboard_export_cell_region
* src/plugin-manager.c (plugin_manager_new), plugin.c: Add
internationalization support.
* src/sheet.c (sheet_selection_row_extend_to,
sheet_selection_col_extend_to): New version that makes sure the
column information has been allocated.
......
1998-09-25 Miguel de Icaza <miguel@nuclecu.unam.mx>
* src/render-ascii.c (cell_region_render_ascii): new routine that
renders a cell selection into a an ascii string. IT HAS PILES OF
LEAKS. I have to go to the movies, will fix later tonight.
* src/clipboard.c (x_clipboard_bind_workbook): New function used
to connect the selection signals for a workbook.
(x_selection_handler): New function: X selection handler.
(clipboard_export_cell_region): New function: Export our clipboard
to the X selection.
(clipboard_copy_cell_range): call clipboard_export_cell_region
* src/plugin-manager.c (plugin_manager_new), plugin.c: Add
internationalization support.
* src/sheet.c (sheet_selection_row_extend_to,
sheet_selection_col_extend_to): New version that makes sure the
column information has been allocated.
......
......@@ -66,6 +66,8 @@ GNUMERIC_BASE_SOURCES = \
plugin.c \
plugin.h \
plugin-manager.c \
render-ascii.c \
render-ascii.h \
sheet.c \
sheet.h \
sheet-autofill.c \
......
......@@ -11,6 +11,59 @@
#include "gnumeric-util.h"
#include "clipboard.h"
#include "eval.h"
#include "render-ascii.h"
static gint
x_selection_clear (GtkWidget *widget, GdkEventSelection *event, Workbook *wb)
{
wb->have_x_selection = FALSE;
return TRUE;
}
static void
x_selection_handler (GtkWidget *widget, GtkSelectionData *selection_data, gpointer data)
{
Workbook *wb = data;
char *rendered_selection;
g_assert (wb->clipboard_contents);
rendered_selection = cell_region_render_ascii (wb->clipboard_contents);
gtk_selection_data_set (
selection_data, GDK_SELECTION_TYPE_STRING, 8,
rendered_selection, strlen (rendered_selection));
}
void
x_clipboard_bind_workbook (Workbook *wb)
{
wb->have_x_selection = FALSE;
gtk_signal_connect (
GTK_OBJECT (wb->toplevel), "selection_clear_event",
GTK_SIGNAL_FUNC(x_selection_clear), wb);
gtk_selection_add_handler (
wb->toplevel,
GDK_SELECTION_PRIMARY, GDK_SELECTION_TYPE_STRING,
x_selection_handler, wb);
}
/*
* clipboard_export_cell_region:
*
* This routine exports a CellRegion to the X selection
*/
static void
clipboard_export_cell_region (Workbook *wb, CellRegion *region)
{
wb->have_x_selection = gtk_selection_owner_set (
current_workbook->toplevel,
GDK_SELECTION_PRIMARY,
GDK_CURRENT_TIME);
}
typedef struct {
int base_col, base_row;
......@@ -39,6 +92,11 @@ clipboard_append_cell (Sheet *sheet, int col, int row, Cell *cell, void *user_da
return TRUE;
}
/*
* clipboard_copy_cell_range:
*
* Entry point to the clipboard copy code
*/
CellRegion *
clipboard_copy_cell_range (Sheet *sheet, int start_col, int start_row, int end_col, int end_row)
{
......@@ -60,6 +118,8 @@ clipboard_copy_cell_range (Sheet *sheet, int start_col, int start_row, int end_c
sheet, 1, start_col, start_row, end_col, end_row,
clipboard_append_cell, &c);
clipboard_export_cell_region (sheet->workbook, c.r);
return c.r;
}
......
......@@ -31,4 +31,6 @@ void clipboard_paste_region (CellRegion *region,
void clipboard_release (CellRegion *region);
void x_clipboard_bind_workbook (Workbook *wb);
#endif
......@@ -89,7 +89,8 @@ GtkWidget *
plugin_manager_new (void)
{
PluginManager *pm;
gchar *titles[2] = { "Name", "File" };
gchar *n_titles[2] = { N_("Name"), N_("File") };
gchar *titles[2] = { N_("Name"), N_("File") };
pm = g_new0 (PluginManager, 1);
if (!pm)
......@@ -99,6 +100,9 @@ plugin_manager_new (void)
pm->hbox = gtk_hbox_new (0, 0);
gtk_container_add (GTK_CONTAINER (pm->dialog), pm->hbox);
titles [0] = _(n_titles [0]);
titles [1] = _(n_titles [1]);
pm->clist = gtk_clist_new_with_titles (2, titles);
gtk_widget_set_usize (pm->clist, 300, 120);
......@@ -108,13 +112,13 @@ plugin_manager_new (void)
gtk_button_box_set_layout (GTK_BUTTON_BOX (pm->vbbox), GTK_BUTTONBOX_START);
gtk_box_pack_start (GTK_BOX (pm->hbox), pm->vbbox, 0, 0, 5);
pm->button_close = gtk_button_new_with_label ("Close");
pm->button_close = gtk_button_new_with_label (_("Close"));
gtk_container_add (GTK_CONTAINER(pm->vbbox), pm->button_close);
pm->button_add = gtk_button_new_with_label ("Add...");
pm->button_add = gtk_button_new_with_label (_("Add..."));
gtk_container_add (GTK_CONTAINER (pm->vbbox), pm->button_add);
pm->button_remove = gtk_button_new_with_label ("Remove");
pm->button_remove = gtk_button_new_with_label (_("Remove"));
gtk_container_add (GTK_CONTAINER (pm->vbbox), pm->button_remove);
gtk_widget_realize (pm->clist);
......
......@@ -33,7 +33,7 @@ plugin_load (gchar *modfile)
data->handle = g_module_open (modfile, 0);
if (!data->handle) {
char *str;
str = g_copy_strings("unable to open module file: ", g_module_error(), NULL);
str = g_copy_strings(_("unable to open module file: "), g_module_error(), NULL);
gnumeric_notice(str);
g_free(str);
g_free(data);
......@@ -41,12 +41,12 @@ plugin_load (gchar *modfile)
}
if (!g_module_symbol (data->handle, "init_plugin", (gpointer *) &data->init_plugin)){
gnumeric_notice ("Plugin must contain init_plugin function.");
gnumeric_notice (_("Plugin must contain init_plugin function."));
goto error;
}
if (data->init_plugin (data) < 0){
gnumeric_notice ("init_plugin returned error");
gnumeric_notice (_("init_plugin returned error"));
goto error;
}
......@@ -65,7 +65,7 @@ plugin_unload (PluginData *pd)
g_return_if_fail (pd != NULL);
if (pd->can_unload && !pd->can_unload(pd)) {
gnumeric_notice("Plugin is still in use.\n");
gnumeric_notice(_("Plugin is still in use.\n"));
return;
}
......
/*
* render-ascii.c: Renders a cell region into ascii text
*
* Author:
* MIguel de Icaza (miguel@gnu.org)
*
*/
#include <config.h>
#include <gnome.h>
#include "gnumeric.h"
#include "gnumeric-util.h"
#include "render-ascii.h"
char *
cell_region_render_ascii (CellRegion *cr)
{
int col, row;
char ***data;
GList *l;
GString *all;
g_assert (cr != NULL);
data = g_new0 (char **, cr->rows);
for (row = 0; row < cr->rows; row++)
data [row] = g_new0 (char *, cr->cols);
for (l = cr->list; l; l = l->next){
CellCopy *c_copy = l->data;
data [c_copy->row_offset][c_copy->col_offset] = CELL_TEXT_GET (c_copy->cell);
}
all = g_string_new (NULL);
for (row = 0; row < cr->rows; row++){
GString *str;
str = g_string_new (NULL);
for (col = 0; col < cr->cols; col++){
if (data [row][col])
g_string_append (str, data [row][col]);
g_string_append_c (str, '\t');
}
g_string_append (all, str->str);
g_string_append_c (all, '\n');
}
return all->str;
}
#ifndef RENDER_ASCII_H
#define RENDER_ASCII_H
char *cell_region_render_ascii (CellRegion *cr);
#endif
......@@ -50,9 +50,11 @@ typedef struct {
int max_iterations;
int generation;
/* The clipboard for this workbook */
CellRegion *clipboard_contents;
gboolean have_x_selection;
} Workbook;
typedef struct {
......
......@@ -919,7 +919,10 @@ workbook_new (void)
gtk_signal_connect (
GTK_OBJECT (wb->toplevel), "destroy",
GTK_SIGNAL_FUNC (workbook_close), wb);
/* clipboard setup */
x_clipboard_bind_workbook (wb);
/* Set the default operation to be performed over selections */
workbook_set_auto_expr (wb, "SUM", "SUM(SELECTION())");
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment