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

I got too agressive with the test so no Strings + Numbers were being

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

	* src/sheet-autofill.c (string_has_number): I got too agressive
	with the test so no Strings + Numbers were being autofilled.

	* src/workbook.c (workbook_setup_edit_area): Remove the CAN_FOCUS
	flags form the accept and cancel buttons.  Bind the buttons.
	(buttons): Neither Zoom-in and Zoom-out can take the focus.
	(change_selection_font): New function to change the fonts of a
	cell range.

	* src/sheet.c (sheet_accept_pending_input): Renamed from
	sheet_accept_pending_output.

	* samples/: Added a new sample file: hypothetical-sales.
parent 2abd0f81
1998-09-23 Miguel de Icaza <miguel@nuclecu.unam.mx>
* src/sheet-autofill.c (string_has_number): I got too agressive
with the test so no Strings + Numbers were being autofilled.
* src/workbook.c (workbook_setup_edit_area): Remove the CAN_FOCUS
flags form the accept and cancel buttons. Bind the buttons.
(buttons): Neither Zoom-in and Zoom-out can take the focus.
(change_selection_font): New function to change the fonts of a
cell range.
* src/sheet.c (sheet_accept_pending_input): Renamed from
sheet_accept_pending_output.
* samples/: Added a new sample file: hypothetical-sales.
* src/parser.y (yylex): Accept underscores in identifiers.
* src/xml-io.c (readXmlCell): Set the content of the cell even if
......
1998-09-23 Miguel de Icaza <miguel@nuclecu.unam.mx>
* src/sheet-autofill.c (string_has_number): I got too agressive
with the test so no Strings + Numbers were being autofilled.
* src/workbook.c (workbook_setup_edit_area): Remove the CAN_FOCUS
flags form the accept and cancel buttons. Bind the buttons.
(buttons): Neither Zoom-in and Zoom-out can take the focus.
(change_selection_font): New function to change the fonts of a
cell range.
* src/sheet.c (sheet_accept_pending_input): Renamed from
sheet_accept_pending_output.
* samples/: Added a new sample file: hypothetical-sales.
* src/parser.y (yylex): Accept underscores in identifiers.
* src/xml-io.c (readXmlCell): Set the content of the cell even if
......
1998-09-23 Miguel de Icaza <miguel@nuclecu.unam.mx>
* src/sheet-autofill.c (string_has_number): I got too agressive
with the test so no Strings + Numbers were being autofilled.
* src/workbook.c (workbook_setup_edit_area): Remove the CAN_FOCUS
flags form the accept and cancel buttons. Bind the buttons.
(buttons): Neither Zoom-in and Zoom-out can take the focus.
(change_selection_font): New function to change the fonts of a
cell range.
* src/sheet.c (sheet_accept_pending_input): Renamed from
sheet_accept_pending_output.
* samples/: Added a new sample file: hypothetical-sales.
* src/parser.y (yylex): Accept underscores in identifiers.
* src/xml-io.c (readXmlCell): Set the content of the cell even if
......
1998-09-23 Miguel de Icaza <miguel@nuclecu.unam.mx>
* src/sheet-autofill.c (string_has_number): I got too agressive
with the test so no Strings + Numbers were being autofilled.
* src/workbook.c (workbook_setup_edit_area): Remove the CAN_FOCUS
flags form the accept and cancel buttons. Bind the buttons.
(buttons): Neither Zoom-in and Zoom-out can take the focus.
(change_selection_font): New function to change the fonts of a
cell range.
* src/sheet.c (sheet_accept_pending_input): Renamed from
sheet_accept_pending_output.
* samples/: Added a new sample file: hypothetical-sales.
* src/parser.y (yylex): Accept underscores in identifiers.
* src/xml-io.c (readXmlCell): Set the content of the cell even if
......
......@@ -638,12 +638,12 @@ gnumeric_sheet_key (GtkWidget *widget, GdkEventKey *event)
if (gsheet->item_editor){
Cell *cell;
sheet_accept_pending_output (sheet);
sheet_accept_pending_input (sheet);
cell = sheet_cell_get (sheet,
sheet->cursor_col,
sheet->cursor_row);
/* I am assuming sheet_accept_pending_output
/* I am assuming sheet_accept_pending_input
* will always create the cell with the given
* input (based on the fact that we had an
* gsheet->item_editor when we entered this
......
......@@ -638,12 +638,12 @@ gnumeric_sheet_key (GtkWidget *widget, GdkEventKey *event)
if (gsheet->item_editor){
Cell *cell;
sheet_accept_pending_output (sheet);
sheet_accept_pending_input (sheet);
cell = sheet_cell_get (sheet,
sheet->cursor_col,
sheet->cursor_row);
/* I am assuming sheet_accept_pending_output
/* I am assuming sheet_accept_pending_input
* will always create the cell with the given
* input (based on the fact that we had an
* gsheet->item_editor when we entered this
......
......@@ -7,6 +7,7 @@
*/
#include <config.h>
#include <gnome.h>
#include <string.h>
#include "gnumeric.h"
#include "gnumeric-util.h"
......@@ -117,3 +118,57 @@ range_contains (Range *range, int col, int row)
return FALSE;
}
char *
font_change_component (char *fontname, int idx, char *newvalue)
{
char *components [15];
char *new = g_strdup (fontname), *res;
char *p = new;
int n = 0, i, len;
/* split the font name */
for (;*p; p++){
if (*p == '-'){
*p = 0;
p++;
components [n++] = p;
}
}
/* Change the value */
components [idx] = newvalue;
/* reassemble */
len = 1;
for (i = 0; i < n; i++){
len += strlen (components [i]) + 1;
}
len++;
res = g_malloc (len);
res [0] = '-';
res [1] = 0;
for (i = 0; i < n; i++){
strcat (res, components [i]);
if (i + 1 != n)
strcat (res, "-");
}
g_free (new);
return res;
}
char *
font_get_bold_name (char *fontname)
{
char *f;
f = font_change_component (fontname, 2, "bold");
return f;
}
......@@ -10,4 +10,7 @@ int run_popup_menu (GdkEvent *event, int button, char **strings);
int gtk_radio_group_get_selected (GSList *radio_group);
void gtk_radio_button_select (GSList *group, int n);
char *font_get_bold_name (char *fontname);
char *font_get_italic_name (char *fontname);
char *font_change_component (char *fontname, int idx, char *value);
#endif
......@@ -7,6 +7,7 @@
*/
#include <config.h>
#include <gnome.h>
#include <string.h>
#include "gnumeric.h"
#include "gnumeric-util.h"
......@@ -117,3 +118,57 @@ range_contains (Range *range, int col, int row)
return FALSE;
}
char *
font_change_component (char *fontname, int idx, char *newvalue)
{
char *components [15];
char *new = g_strdup (fontname), *res;
char *p = new;
int n = 0, i, len;
/* split the font name */
for (;*p; p++){
if (*p == '-'){
*p = 0;
p++;
components [n++] = p;
}
}
/* Change the value */
components [idx] = newvalue;
/* reassemble */
len = 1;
for (i = 0; i < n; i++){
len += strlen (components [i]) + 1;
}
len++;
res = g_malloc (len);
res [0] = '-';
res [1] = 0;
for (i = 0; i < n; i++){
strcat (res, components [i]);
if (i + 1 != n)
strcat (res, "-");
}
g_free (new);
return res;
}
char *
font_get_bold_name (char *fontname)
{
char *f;
f = font_change_component (fontname, 2, "bold");
return f;
}
......@@ -10,4 +10,7 @@ int run_popup_menu (GdkEvent *event, int button, char **strings);
int gtk_radio_group_get_selected (GSList *radio_group);
void gtk_radio_button_select (GSList *group, int n);
char *font_get_bold_name (char *fontname);
char *font_get_italic_name (char *fontname);
char *font_change_component (char *fontname, int idx, char *value);
#endif
......@@ -658,7 +658,7 @@ item_cursor_autofill_event (GnomeCanvasItem *item, GdkEvent *event)
if (!((item_cursor->end_col == item_cursor->base_col + item_cursor->base_cols) &&
(item_cursor->end_row == item_cursor->base_row + item_cursor->base_rows))){
sheet_accept_pending_output (sheet);
sheet_accept_pending_input (sheet);
sheet_autofill (sheet,
item_cursor->base_col, item_cursor->base_row,
item_cursor->base_cols+1, item_cursor->base_rows+1,
......
......@@ -624,7 +624,7 @@ item_grid_event (GnomeCanvasItem *item, GdkEvent *event)
col = item_grid_find_col (item_grid, x, NULL);
row = item_grid_find_row (item_grid, y, NULL);
sheet_accept_pending_output (sheet);
sheet_accept_pending_input (sheet);
sheet_cursor_move (sheet, col, row);
if (!(event->button.state & GDK_CONTROL_MASK))
sheet_selection_reset_only (sheet);
......
......@@ -5,3 +5,4 @@
#include "pixmaps/line.xpm"
#include "pixmaps/arrow.xpm"
#include "pixmaps/oval.xpm"
#include "pixmaps/bold.xpm"
......@@ -144,6 +144,7 @@ string_has_number (String *str, int *num, int *pos)
{
char *s = str->str, *p;
int l = strlen (s);
gboolean found_number = FALSE;
if (isdigit (*s)){
*num = atoi (s);
......@@ -154,13 +155,11 @@ string_has_number (String *str, int *num, int *pos)
return FALSE;
for (p = s + l - 1; p > str->str && isdigit (*p); p--)
;
found_number = TRUE;
if (p == str->str)
if (!found_number)
return FALSE;
if (!isdigit (*p))
return FALSE;
p++;
*num = atoi (p);
*pos = p - str->str;
......
......@@ -636,7 +636,7 @@ sheet_stop_editing (Sheet *sheet)
}
void
sheet_accept_pending_output (Sheet *sheet)
sheet_accept_pending_input (Sheet *sheet)
{
GList *l;
......@@ -756,7 +756,7 @@ sheet_selection_append_range (Sheet *sheet,
sheet->selections = g_list_prepend (sheet->selections, ss);
sheet_accept_pending_output (sheet);
sheet_accept_pending_input (sheet);
sheet_load_cell_val (sheet);
for (l = sheet->sheet_views; l; l = l->next){
......@@ -1068,7 +1068,7 @@ sheet_selection_change (Sheet *sheet, SheetSelection *old, SheetSelection *new)
if (sheet_selection_equal (old, new))
return;
sheet_accept_pending_output (sheet);
sheet_accept_pending_input (sheet);
sheet_redraw_selection (sheet, old);
sheet_redraw_selection (sheet, new);
sheet_selection_changed_hook (sheet);
......@@ -2751,7 +2751,7 @@ sheet_cursor_move (Sheet *sheet, int col, int row)
g_return_if_fail (sheet != NULL);
g_return_if_fail (IS_SHEET (sheet));
sheet_accept_pending_output (sheet);
sheet_accept_pending_input (sheet);
sheet->cursor_col = col;
sheet->cursor_row = row;
......
......@@ -274,7 +274,7 @@ void sheet_style_attach (Sheet *sheet,
*/
void sheet_start_editing_at_cursor (Sheet *sheet);
void sheet_set_current_value (Sheet *sheet);
void sheet_accept_pending_output (Sheet *sheet);
void sheet_accept_pending_input (Sheet *sheet);
void sheet_cancel_pending_input (Sheet *sheet);
void sheet_load_cell_val (Sheet *sheet);
void sheet_selection_col_extend_to (Sheet *sheet, int col);
......
......@@ -64,7 +64,7 @@ style_format_unref (StyleFormat *sf)
}
StyleFont *
style_font_new (char *font_name, int units)
style_font_new_simple (char *font_name, int units)
{
StyleFont *font;
StyleFont key;
......@@ -81,31 +81,38 @@ style_font_new (char *font_name, int units)
gdk_font = gdk_font_load (font_name);
if (gdk_font){
if (!gdk_font)
return NULL;
font = g_new0 (StyleFont, 1);
font->font_name = g_strdup (font_name);
font->units = units;
font->font = gdk_font_load (font_name);
g_hash_table_insert (style_font_hash, font, font);
} else {
/*
* If we cant use the specified font, try:
* - Loading the default font instead
* - Loading fixed font
*/
if (!strcmp (font_name, "fixed"))
g_error ("Can not load fixed font\n");
}
font->ref_count++;
if (!strcmp (font_name, DEFAULT_FONT))
font_name = "fixed";
else
font_name = DEFAULT_FONT;
return font;
}
StyleFont *
style_font_new (char *font_name, int units)
{
StyleFont *font;
StyleFont key;
g_return_val_if_fail (font_name != NULL, NULL);
g_return_val_if_fail (units != 0, NULL);
font = style_font_new_simple (font_name, units);
if (!font)
font = style_font_new_simple (DEFAULT_FONT, DEFAULT_SIZE);
return style_font_new (font_name, DEFAULT_SIZE);
}
}
font->ref_count++;
if (!font)
font = style_font_new_simple ("fixed", DEFAULT_SIZE);
if (!font)
g_error ("Can not load fixed font\n");
return font;
}
......
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