Commit 42790494 authored by Morten Welinder's avatar Morten Welinder Committed by Morten Welinder

New function allowing the use of mouse in the data area.

2005-02-28  Morten Welinder  <terra@gnome.org>

	* dialog-stf-format-page.c (cb_treeview_button_press): New
	function allowing the use of mouse in the data area.

	* dialog-stf-preview.c (stf_preview_find_column): New function.
	* dialog-stf-fixed-page.c (cb_treeview_button_press): Use
	stf_preview_find_column.
parent 5207eb6a
......@@ -34,6 +34,7 @@ Morten:
* Fix crash when using --quit. Fix leak too.
* Fix rare crash on exit.
* Use unicode minus (U2212) for numbers. [#168467]
* Improve format selection dialog for text import.
--------------------------------------------------------------------------
Gnumeric 1.5.0
......
2005-02-28 Morten Welinder <terra@gnome.org>
* dialog-stf-format-page.c (cb_treeview_button_press): New
function allowing the use of mouse in the data area.
* dialog-stf-preview.c (stf_preview_find_column): New function.
* dialog-stf-fixed-page.c (cb_treeview_button_press): Use
stf_preview_find_column.
* dialog-stf-format-page.c (format_context_menu): Factor out from
cb_col_event. Constify.
......
......@@ -251,28 +251,6 @@ fixed_context_menu (StfDialogData *pagedata, GdkEventButton *event,
sensitivity_filter, event);
}
static void
find_column (StfDialogData *pagedata, int x, int *pcol, int *dx)
{
int colcount = stf_parse_options_fixed_splitpositions_count (pagedata->parseoptions);
int col;
/* Figure out what column we pressed in. */
for (col = 0; col < colcount; col++) {
GtkTreeViewColumn *column =
stf_preview_get_column (pagedata->fixed.renderdata, col);
GtkWidget *w = GTK_BIN (column->button)->child;
if (x < w->allocation.x + w->allocation.width) {
*dx = x - w->allocation.x;
break;
}
}
*pcol = col;
}
static gint
cb_treeview_button_press (GtkWidget *treeview,
GdkEventButton *event,
......@@ -280,14 +258,14 @@ cb_treeview_button_press (GtkWidget *treeview,
{
if (event->type == GDK_2BUTTON_PRESS && event->button == 1) {
int dx, col;
find_column (pagedata, (int)event->x, &col, &dx);
stf_preview_find_column (pagedata->fixed.renderdata, (int)event->x, &col, &dx);
make_new_column (pagedata, col, dx, FALSE);
return TRUE;
}
if (event->type == GDK_BUTTON_PRESS && event->button == 3) {
int dx, col;
find_column (pagedata, (int)event->x, &col, &dx);
stf_preview_find_column (pagedata->fixed.renderdata, (int)event->x, &col, &dx);
fixed_context_menu (pagedata, event, col, dx);
return TRUE;
}
......
......@@ -355,6 +355,27 @@ cb_col_event (GtkWidget *widget, GdkEvent *event, gpointer _col)
return FALSE;
}
static gint
cb_treeview_button_press (GtkWidget *treeview,
GdkEventButton *event,
StfDialogData *pagedata)
{
if (event->type == GDK_BUTTON_PRESS && event->button == 1) {
int dx, col;
stf_preview_find_column (pagedata->format.renderdata, (int)event->x, &col, &dx);
activate_column (pagedata, col);
return TRUE;
} else if (event->type == GDK_BUTTON_PRESS && event->button == 3) {
int dx, col;
stf_preview_find_column (pagedata->format.renderdata, (int)event->x, &col, &dx);
activate_column (pagedata, col);
format_context_menu (pagedata, event, col);
return TRUE;
}
return FALSE;
}
/**
* format_page_update_preview
......@@ -647,5 +668,10 @@ stf_dialog_format_page_init (GladeXML *gui, StfDialogData *pagedata)
G_CALLBACK (format_page_trim_menu_changed), pagedata);
gtk_combo_box_set_active (GTK_COMBO_BOX (pagedata->format.format_trim), 0);
g_signal_connect (G_OBJECT (pagedata->format.renderdata->tree_view),
"button_press_event",
G_CALLBACK (cb_treeview_button_press),
pagedata);
format_page_update_column_selection (pagedata);
}
......@@ -314,3 +314,26 @@ stf_preview_get_cell_renderer (RenderData_t *renderdata, int col)
}
return res;
}
void
stf_preview_find_column (RenderData_t *renderdata, int x, int *pcol, int *dx)
{
int col;
/* Figure out what column we pressed in. */
for (col = 0; 1; col++) {
GtkWidget *w;
GtkTreeViewColumn *column =
stf_preview_get_column (renderdata, col);
if (!column)
break;
w = GTK_BIN (column->button)->child;
if (x < w->allocation.x + w->allocation.width) {
*dx = x - w->allocation.x;
break;
}
}
*pcol = col;
*dx = 0;
}
......@@ -61,4 +61,6 @@ void stf_preview_colformats_add (RenderData_t *renderda
GtkTreeViewColumn *stf_preview_get_column (RenderData_t *renderdata, int col);
GtkCellRenderer *stf_preview_get_cell_renderer (RenderData_t *renderdata, int col);
void stf_preview_find_column (RenderData_t *renderdata, int x, int *pcol, int *dx);
#endif /* GNUMERIC_DIALOG_STF_PREVIEW_H */
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