Commit 59313e91 authored by Morten Welinder's avatar Morten Welinder Committed by Morten Welinder

Overhaul all navigation.

2003-07-25  Morten Welinder  <terra@gnome.org>

	* dialog-stf-fixed-page.c: Overhaul all navigation.

2003-07-25  Morten Welinder  <terra@gnome.org>

	* src/stf-parse.c (stf_parse_options_fixed_splitpositions_clear):
	Add terminator here.
	(stf_parse_options_fixed_splitpositions_add): Insert sorted.
	(stf_parse_options_fixed_splitpositions_remove,
	stf_parse_options_fixed_splitpositions_count,
	stf_parse_options_fixed_splitpositions_nth): New functions.
parent 3940a682
2003-07-25 Morten Welinder <terra@gnome.org>
* src/stf-parse.c (stf_parse_options_fixed_splitpositions_clear):
Add terminator here.
(stf_parse_options_fixed_splitpositions_add): Insert sorted.
(stf_parse_options_fixed_splitpositions_remove,
stf_parse_options_fixed_splitpositions_count,
stf_parse_options_fixed_splitpositions_nth): New functions.
2003-07-23 Andreas J. Guelzow <aguelzow@taliesin.ca>
* src/commands.c (cmd_goal_seek*): new
......
......@@ -128,6 +128,7 @@ Morten:
* Fix parsing of fractional constants.
* Improve progress display a bit.
* Show default image for types we don't recognize.
* Improve fixed-width stf.
--------------------------------------------------------------------------
......
2003-07-25 Morten Welinder <terra@gnome.org>
* src/stf-parse.c (stf_parse_options_fixed_splitpositions_clear):
Add terminator here.
(stf_parse_options_fixed_splitpositions_add): Insert sorted.
(stf_parse_options_fixed_splitpositions_remove,
stf_parse_options_fixed_splitpositions_count,
stf_parse_options_fixed_splitpositions_nth): New functions.
2003-07-23 Andreas J. Guelzow <aguelzow@taliesin.ca>
* src/commands.c (cmd_goal_seek*): new
......
2003-07-25 Morten Welinder <terra@gnome.org>
* src/stf-parse.c (stf_parse_options_fixed_splitpositions_clear):
Add terminator here.
(stf_parse_options_fixed_splitpositions_add): Insert sorted.
(stf_parse_options_fixed_splitpositions_remove,
stf_parse_options_fixed_splitpositions_count,
stf_parse_options_fixed_splitpositions_nth): New functions.
2003-07-23 Andreas J. Guelzow <aguelzow@taliesin.ca>
* src/commands.c (cmd_goal_seek*): new
......
2003-07-25 Morten Welinder <terra@gnome.org>
* dialog-stf-fixed-page.c: Overhaul all navigation.
2003-07-24 Morten Welinder <terra@gnome.org>
* dialog-stf-fixed-page.c (make_new_column): New function, largely
......
This diff is collapsed.
......@@ -71,10 +71,18 @@ static void
main_page_update_preview (StfDialogData *pagedata)
{
RenderData_t *renderdata = pagedata->main.renderdata;
GPtrArray *lines = stf_parse_lines (pagedata->parseoptions,
pagedata->utf8_data, TRUE);
unsigned int ui;
pagedata->longest_line = 0;
for (ui = 0; ui < lines->len; ui++) {
GPtrArray *line = g_ptr_array_index (lines, ui);
size_t thislen = g_utf8_strlen (g_ptr_array_index (line, 1), -1);
pagedata->longest_line = MAX (pagedata->longest_line, thislen);
}
stf_preview_set_lines (renderdata,
stf_parse_lines (pagedata->parseoptions,
pagedata->utf8_data, TRUE));
stf_preview_set_lines (renderdata, lines);
}
......
......@@ -51,17 +51,14 @@ stf_dialog_set_initial_keyboard_focus (StfDialogData *pagedata)
switch (gtk_notebook_get_current_page (pagedata->notebook)) {
case DPG_MAIN:
focus_widget =
GTK_WIDGET (pagedata->main.main_separated);
focus_widget = GTK_WIDGET (pagedata->main.main_separated);
break;
case DPG_CSV:
focus_widget =
GTK_WIDGET (pagedata->csv.csv_space);
focus_widget = GTK_WIDGET (pagedata->csv.csv_space);
break;
case DPG_FIXED:
focus_widget = GTK_WIDGET
(&pagedata->fixed.fixed_colend->entry);
break; /* ?? */
focus_widget = GTK_WIDGET (pagedata->fixed.fixed_auto);
break;
case DPG_FORMAT:
number_format_selector_set_focus (pagedata->format.format_selector);
break;
......
......@@ -2,7 +2,6 @@
<!DOCTYPE glade-interface SYSTEM "http://glade.gnome.org/glade-2.0.dtd">
<glade-interface>
<requires lib="gnome"/>
<widget class="GtkDialog" id="stf_dialog">
<property name="title" translatable="yes">Text Import Configuration</property>
......@@ -1309,242 +1308,45 @@
<property name="spacing">4</property>
<child>
<widget class="GtkVBox" id="vbox11">
<widget class="GtkHButtonBox" id="hbuttonbox3">
<property name="visible">True</property>
<property name="homogeneous">False</property>
<property name="layout_style">GTK_BUTTONBOX_SPREAD</property>
<property name="spacing">0</property>
<child>
<widget class="GtkScrolledWindow" id="scrolledwindow7">
<property name="visible">True</property>
<property name="hscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
<property name="vscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
<property name="shadow_type">GTK_SHADOW_NONE</property>
<property name="window_placement">GTK_CORNER_TOP_LEFT</property>
<child>
<widget class="GtkCList" id="fixed_collist">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="n_columns">2</property>
<property name="column_widths">80,80</property>
<property name="selection_mode">GTK_SELECTION_SINGLE</property>
<property name="show_titles">True</property>
<property name="shadow_type">GTK_SHADOW_IN</property>
<child>
<widget class="GtkLabel" id="label14">
<property name="label" translatable="yes">Column</property>
<property name="use_underline">False</property>
<property name="use_markup">False</property>
<property name="justify">GTK_JUSTIFY_LEFT</property>
<property name="wrap">False</property>
<property name="selectable">False</property>
<property name="xalign">0</property>
<property name="yalign">0.5</property>
<property name="xpad">0</property>
<property name="ypad">0</property>
</widget>
</child>
<child>
<widget class="GtkLabel" id="label15">
<property name="label" translatable="yes">End</property>
<property name="use_underline">False</property>
<property name="use_markup">False</property>
<property name="justify">GTK_JUSTIFY_LEFT</property>
<property name="wrap">False</property>
<property name="selectable">False</property>
<property name="xalign">0</property>
<property name="yalign">0.5</property>
<property name="xpad">0</property>
<property name="ypad">0</property>
</widget>
</child>
</widget>
</child>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">True</property>
<property name="fill">True</property>
</packing>
</child>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">True</property>
<property name="fill">True</property>
</packing>
</child>
<child>
<widget class="GtkVBox" id="vbox12">
<property name="visible">True</property>
<property name="homogeneous">False</property>
<property name="spacing">4</property>
<child>
<widget class="GtkHBox" id="hbox10">
<property name="visible">True</property>
<property name="homogeneous">False</property>
<property name="spacing">4</property>
<child>
<widget class="GtkHBox" id="hbox11">
<property name="visible">True</property>
<property name="homogeneous">False</property>
<property name="spacing">0</property>
<child>
<widget class="GtkLabel" id="label17">
<property name="visible">True</property>
<property name="label" translatable="yes">Co_lumn end: </property>
<property name="use_underline">True</property>
<property name="use_markup">False</property>
<property name="justify">GTK_JUSTIFY_CENTER</property>
<property name="wrap">False</property>
<property name="selectable">False</property>
<property name="xalign">0.5</property>
<property name="yalign">0.5</property>
<property name="xpad">0</property>
<property name="ypad">0</property>
<property name="mnemonic_widget">fixed_colend</property>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">False</property>
<property name="fill">False</property>
</packing>
</child>
<child>
<widget class="GtkSpinButton" id="fixed_colend">
<property name="visible">True</property>
<property name="tooltip" translatable="yes">Set the end of this column</property>
<property name="can_focus">True</property>
<property name="climb_rate">1</property>
<property name="digits">0</property>
<property name="numeric">True</property>
<property name="update_policy">GTK_UPDATE_ALWAYS</property>
<property name="snap_to_ticks">False</property>
<property name="wrap">False</property>
<property name="adjustment">0 0 100 1 10 10</property>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">True</property>
<property name="fill">True</property>
</packing>
</child>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">False</property>
<property name="fill">False</property>
</packing>
</child>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">False</property>
<property name="fill">True</property>
</packing>
</child>
<child>
<widget class="GtkHBox" id="hbox12">
<widget class="GtkButton" id="fixed_auto">
<property name="visible">True</property>
<property name="homogeneous">False</property>
<property name="spacing">0</property>
<child>
<widget class="GtkHButtonBox" id="hbuttonbox1">
<property name="visible">True</property>
<property name="layout_style">GTK_BUTTONBOX_START</property>
<property name="spacing">0</property>
<child>
<widget class="GtkButton" id="fixed_add">
<property name="visible">True</property>
<property name="tooltip" translatable="yes">Add a new column</property>
<property name="can_default">True</property>
<property name="can_focus">True</property>
<property name="label" translatable="yes">_Add</property>
<property name="use_underline">True</property>
<property name="relief">GTK_RELIEF_NORMAL</property>
</widget>
</child>
<child>
<widget class="GtkButton" id="fixed_remove">
<property name="visible">True</property>
<property name="tooltip" translatable="yes">Remove selected column</property>
<property name="can_default">True</property>
<property name="can_focus">True</property>
<property name="label" translatable="yes">_Remove</property>
<property name="use_underline">True</property>
<property name="relief">GTK_RELIEF_NORMAL</property>
</widget>
</child>
<child>
<widget class="GtkButton" id="fixed_clear">
<property name="visible">True</property>
<property name="tooltip" translatable="yes">Clear list of columns</property>
<property name="can_default">True</property>
<property name="can_focus">True</property>
<property name="label" translatable="yes">_Clear</property>
<property name="use_underline">True</property>
<property name="relief">GTK_RELIEF_NORMAL</property>
</widget>
</child>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">False</property>
<property name="fill">True</property>
</packing>
</child>
<property name="tooltip" translatable="yes">Attempt to recognize columns in the text automatically.</property>
<property name="can_default">True</property>
<property name="can_focus">True</property>
<property name="label" translatable="yes">_Auto Column Discovery</property>
<property name="use_underline">True</property>
<property name="relief">GTK_RELIEF_NORMAL</property>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">False</property>
<property name="fill">False</property>
</packing>
</child>
<child>
<widget class="GtkHButtonBox" id="hbuttonbox2">
<widget class="GtkButton" id="fixed_clear">
<property name="visible">True</property>
<property name="layout_style">GTK_BUTTONBOX_START</property>
<property name="spacing">30</property>
<child>
<widget class="GtkButton" id="fixed_auto">
<property name="visible">True</property>
<property name="tooltip" translatable="yes">Attempt to recognize columns in the text automatically.</property>
<property name="can_default">True</property>
<property name="can_focus">True</property>
<property name="label" translatable="yes">Auto Column _Discovery</property>
<property name="use_underline">True</property>
<property name="relief">GTK_RELIEF_NORMAL</property>
</widget>
</child>
<property name="tooltip" translatable="yes">Clear list of columns</property>
<property name="can_default">True</property>
<property name="can_focus">True</property>
<property name="label" translatable="yes">_Clear</property>
<property name="use_underline">True</property>
<property name="relief">GTK_RELIEF_NORMAL</property>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">False</property>
<property name="fill">True</property>
</packing>
</child>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">False</property>
<property name="expand">True</property>
<property name="fill">True</property>
</packing>
</child>
<child>
<placeholder/>
</child>
</widget>
</child>
......
......@@ -45,14 +45,12 @@ typedef struct {
/* for the fixed_page */
typedef struct {
/*GtkCList*/void *fixed_collist;
GtkSpinButton *fixed_colend;
GtkButton *fixed_add, *fixed_remove, *fixed_clear, *fixed_auto;
GtkButton *fixed_clear, *fixed_auto;
GtkWidget *fixed_data_container;
/* Page members that are created at run-time */
RenderData_t *renderdata;
int index;
RenderData_t *renderdata;
int context_col, context_dx;
} FixedInfo_t;
/* for the format_page */
......@@ -109,6 +107,8 @@ typedef struct {
const char *source; /* Where we are reading from (UTF-8) */
size_t longest_line; /* #characters in longest line. */
MainInfo_t main;
CsvInfo_t csv;
FixedInfo_t fixed;
......
......@@ -9,7 +9,7 @@
* EMail: almer1@dds.nl or almer-t@bigfoot.com
*
* Copyright (C) 2003 Andreas J. Guelzow <aguelzow@taliesin.ca>
*
* Copyright (C) 2003 Morten Welinder <terra@gnome.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
......@@ -153,7 +153,8 @@ stf_parse_options_new (void)
parseoptions->trim_spaces = (TRIM_TYPE_RIGHT | TRIM_TYPE_LEFT);
parseoptions->locale = NULL;
parseoptions->splitpositions = g_array_new (FALSE, FALSE, sizeof (int));
parseoptions->splitpositions = NULL;
stf_parse_options_fixed_splitpositions_clear (parseoptions);
parseoptions->stringindicator = '"';
parseoptions->indicator_2x_is_single = TRUE;
......@@ -380,25 +381,67 @@ stf_parse_options_csv_set_duplicates (StfParseOptions_t *parseoptions, gboolean
void
stf_parse_options_fixed_splitpositions_clear (StfParseOptions_t *parseoptions)
{
int minus_one = -1;
g_return_if_fail (parseoptions != NULL);
g_array_free (parseoptions->splitpositions, TRUE);
if (parseoptions->splitpositions)
g_array_free (parseoptions->splitpositions, TRUE);
parseoptions->splitpositions = g_array_new (FALSE, FALSE, sizeof (int));
g_array_append_val (parseoptions->splitpositions, minus_one);
}
/**
* stf_parse_options_fixed_splitpositions_add:
*
* @position will be added to the splitpositions, @position must be equal to
* or greater than zero or -1 which means as much as "parse to end of line"
* @position will be added to the splitpositions.
**/
void
stf_parse_options_fixed_splitpositions_add (StfParseOptions_t *parseoptions, int const position)
stf_parse_options_fixed_splitpositions_add (StfParseOptions_t *parseoptions, int position)
{
unsigned int ui;
g_return_if_fail (parseoptions != NULL);
g_return_if_fail (position >= 0 || position == -1);
g_return_if_fail (position >= 0);
for (ui = 0; ui < parseoptions->splitpositions->len - 1; ui++) {
int here = g_array_index (parseoptions->splitpositions, int, ui);
if (position == here)
return;
if (position < here)
break;
}
g_array_insert_val (parseoptions->splitpositions, ui, position);
}
void
stf_parse_options_fixed_splitpositions_remove (StfParseOptions_t *parseoptions, int position)
{
unsigned int ui;
g_return_if_fail (parseoptions != NULL);
g_return_if_fail (position >= 0);
for (ui = 0; ui < parseoptions->splitpositions->len - 1; ui++) {
int here = g_array_index (parseoptions->splitpositions, int, ui);
if (position == here)
g_array_remove_index (parseoptions->splitpositions, ui);
if (position <= here)
return;
}
}
int
stf_parse_options_fixed_splitpositions_count (StfParseOptions_t *parseoptions)
{
return parseoptions->splitpositions->len;
}
g_array_append_val (parseoptions->splitpositions, position);
int
stf_parse_options_fixed_splitpositions_nth (StfParseOptions_t *parseoptions, int n)
{
return g_array_index (parseoptions->splitpositions, int, n);
}
......@@ -813,40 +856,6 @@ stf_parse_find_line (StfParseOptions_t *parseoptions,
}
/**
* stf_parse_get_longest_row_width:
*
* Returns the largest number of characters found in a line/row
**/
int
stf_parse_get_longest_row_width (StfParseOptions_t *parseoptions,
char const *data, char const *data_end)
{
char const *s;
int len = 0;
int longest = 0;
g_return_val_if_fail (parseoptions != NULL, 0);
g_return_val_if_fail (data != NULL, 0);
g_return_val_if_fail (data_end != NULL, 0);
for (s = data; *s && s < data_end; ) {
int termlen = compare_terminator (s, parseoptions);
if (termlen > 0) {
longest = MAX (len, longest);
len = 0;
s += termlen;
} else {
len++;
s = g_utf8_next_char (s);
}
}
longest = MAX (len, longest);
return longest;
}
/**
* stf_parse_options_fixed_autodiscover:
* @parseoptions: a Parse options struct.
......
......@@ -56,7 +56,7 @@ typedef struct {
int colcount; /* Number of columns parsed */
gboolean *col_import_array; /* 0/1 array indicating */
/* which cols to import */
GPtrArray *formats; /* Contains StyleFormat *s */
GPtrArray *formats ; /* Contains StyleFormat *s */
} StfParseOptions_t;
/* CREATION/DESTRUCTION of stf options struct */
......@@ -87,7 +87,11 @@ void stf_parse_options_csv_set_duplicates (StfParseOptions_t *parse
gboolean const duplicates);
void stf_parse_options_fixed_splitpositions_clear (StfParseOptions_t *parseoptions);
void stf_parse_options_fixed_splitpositions_add (StfParseOptions_t *parseoptions,
int const position);
int position);
void stf_parse_options_fixed_splitpositions_remove (StfParseOptions_t *parseoptions,
int position);
int stf_parse_options_fixed_splitpositions_count (StfParseOptions_t *parseoptions);
int stf_parse_options_fixed_splitpositions_nth (StfParseOptions_t *parseoptions, int n);
/* USING the stf structs to actually do some parsing, these are the lower-level functions and utility functions */
......@@ -99,10 +103,6 @@ GPtrArray *stf_parse_lines (StfParseO
const char *data,
gboolean with_lineno);
int stf_parse_get_longest_row_width (StfParseOptions_t *parseoptions,
const char *data,
char const *data_end);
void stf_parse_options_fixed_autodiscover (StfParseOptions_t *parseoptions,
char const *data,
char const *data_end);
......
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