Commit fb750b50 authored by Jody Goldberg's avatar Jody Goldberg

More UI solidification.

parent 2afdfa9b
1999-10-05 Jody Goldberg <jgoldberg@home.com>
* src/sheet.c (sheet_destroy_contents) : Mark freed segments with
NULL.
* src/selection.c (selection_contains_colrow) : New function.
* src/item-bar.c (item_bar_event) : Use it.
From : Jon K Hellan <Jon.K.Hellan@item.ntnu.no>
* src/dialogs/{insert,delete}-cells.glade : New files.
* src/dialogs/dialog-{insert,delete}-cells.c : Switch from using
Cauldron to using libglade.
* src/plugin-manager.c (plugin_manager_new):
Go away on <Esc>, set initial focus.
......
......@@ -9,7 +9,10 @@ Michael:
Jody:
* Some Optimization.
* Enhance row/col insert/delete, cell shift, and cell 'cut/paste.
* Enhance row/col insert/delete, cell shift, and cell cut/paste.
Jon K Hellan:
* Dialog improvements.
--------------------------------------------------------------------------
......
1999-10-05 Jody Goldberg <jgoldberg@home.com>
* src/sheet.c (sheet_destroy_contents) : Mark freed segments with
NULL.
* src/selection.c (selection_contains_colrow) : New function.
* src/item-bar.c (item_bar_event) : Use it.
From : Jon K Hellan <Jon.K.Hellan@item.ntnu.no>
* src/dialogs/{insert,delete}-cells.glade : New files.
* src/dialogs/dialog-{insert,delete}-cells.c : Switch from using
Cauldron to using libglade.
* src/plugin-manager.c (plugin_manager_new):
Go away on <Esc>, set initial focus.
......
......@@ -49,7 +49,9 @@ glade_DATA = \
row-height.glade \
sheet-rename.glade \
summary.glade \
dialog-zoom.glade
dialog-zoom.glade \
insert-cells.glade \
delete-cells.glade
glade_msgs = \
col-width.glade.h \
......
<?xml version="1.0"?>
<GTK-Interface>
<project>
<name>Delete-cells</name>
<program_name>delete-cells</program_name>
<directory></directory>
<source_directory>src</source_directory>
<pixmaps_directory>pixmaps</pixmaps_directory>
<language>C</language>
<gnome_support>True</gnome_support>
<gettext_support>True</gettext_support>
<use_widget_names>False</use_widget_names>
<output_main_file>True</output_main_file>
<output_support_files>True</output_support_files>
<output_build_files>True</output_build_files>
<backup_source_files>True</backup_source_files>
<main_source_file>interface.c</main_source_file>
<main_header_file>interface.h</main_header_file>
<handler_source_file>callbacks.c</handler_source_file>
<handler_header_file>callbacks.h</handler_header_file>
<support_source_file>support.c</support_source_file>
<support_header_file>support.h</support_header_file>
<translatable_strings_file></translatable_strings_file>
</project>
<widget>
<class>GnomeDialog</class>
<name>Delete_cells</name>
<title>Delete cells</title>
<visible>False</visible>
<type>GTK_WINDOW_DIALOG</type>
<position>GTK_WIN_POS_NONE</position>
<modal>True</modal>
<allow_shrink>False</allow_shrink>
<allow_grow>False</allow_grow>
<auto_shrink>False</auto_shrink>
<auto_close>False</auto_close>
<hide_on_close>False</hide_on_close>
<widget>
<class>GtkVBox</class>
<child_name>GnomeDialog:vbox</child_name>
<name>dialog-vbox1</name>
<homogeneous>False</homogeneous>
<spacing>8</spacing>
<child>
<padding>4</padding>
<expand>True</expand>
<fill>True</fill>
</child>
<widget>
<class>GtkFrame</class>
<name>frame1</name>
<label>Delete</label>
<label_xalign>0</label_xalign>
<shadow_type>GTK_SHADOW_ETCHED_IN</shadow_type>
<child>
<padding>0</padding>
<expand>True</expand>
<fill>True</fill>
</child>
<widget>
<class>GtkVBox</class>
<name>vbox1</name>
<border_width>4</border_width>
<homogeneous>False</homogeneous>
<spacing>0</spacing>
<widget>
<class>GtkRadioButton</class>
<name>radio_0</name>
<can_focus>True</can_focus>
<has_focus>True</has_focus>
<label>Shift cells _left</label>
<active>False</active>
<draw_indicator>True</draw_indicator>
<group>radios</group>
<child>
<padding>0</padding>
<expand>False</expand>
<fill>False</fill>
</child>
</widget>
<widget>
<class>GtkRadioButton</class>
<name>radio_1</name>
<can_focus>True</can_focus>
<label>Shift cells _up</label>
<active>False</active>
<draw_indicator>True</draw_indicator>
<group>radios</group>
<child>
<padding>0</padding>
<expand>False</expand>
<fill>False</fill>
</child>
</widget>
<widget>
<class>GtkRadioButton</class>
<name>radio_2</name>
<can_focus>True</can_focus>
<label>Delete _row(s)</label>
<active>False</active>
<draw_indicator>True</draw_indicator>
<group>radios</group>
<child>
<padding>0</padding>
<expand>False</expand>
<fill>False</fill>
</child>
</widget>
<widget>
<class>GtkRadioButton</class>
<name>radio_3</name>
<can_focus>True</can_focus>
<label>Delete _column(s)</label>
<active>False</active>
<draw_indicator>True</draw_indicator>
<group>radios</group>
<child>
<padding>0</padding>
<expand>False</expand>
<fill>False</fill>
</child>
</widget>
</widget>
</widget>
<widget>
<class>GtkHButtonBox</class>
<child_name>GnomeDialog:action_area</child_name>
<name>dialog-action_area1</name>
<layout_style>GTK_BUTTONBOX_END</layout_style>
<spacing>8</spacing>
<child_min_width>85</child_min_width>
<child_min_height>27</child_min_height>
<child_ipad_x>7</child_ipad_x>
<child_ipad_y>0</child_ipad_y>
<child>
<padding>0</padding>
<expand>False</expand>
<fill>True</fill>
<pack>GTK_PACK_END</pack>
</child>
<widget>
<class>GtkButton</class>
<name>button1</name>
<can_default>True</can_default>
<has_default>True</has_default>
<can_focus>True</can_focus>
<stock_button>GNOME_STOCK_BUTTON_OK</stock_button>
</widget>
<widget>
<class>GtkButton</class>
<name>button3</name>
<can_default>True</can_default>
<can_focus>True</can_focus>
<stock_button>GNOME_STOCK_BUTTON_CANCEL</stock_button>
</widget>
</widget>
</widget>
</widget>
</GTK-Interface>
/*
* dialog-delete-cells.c: Delete a number of cells.
* dialog-delete-cells.c: Delete a number of cells.
*
* Author:
* Miguel de Icaza (miguel@gnu.org)
......@@ -7,22 +7,75 @@
*/
#include <config.h>
#include <gnome.h>
#include <glade/glade.h>
#include "gnumeric.h"
#include "gnumeric-util.h"
#include "selection.h"
#include "dialogs.h"
#define GLADE_FILE "delete-cells.glade"
static void
dialog_delete_cells_impl (Workbook *wb, Sheet *sheet, GladeXML *gui)
{
GtkWidget *dialog, *radio_0;
SheetSelection *ss;
int cols, rows;
int i, res;
dialog = glade_xml_get_widget (gui, "Delete_cells");
if (dialog == NULL) {
g_print ("Corrupt file " GLADE_FILE "\n");
return;
}
radio_0 = glade_xml_get_widget (gui, "radio_0");
g_return_if_fail (radio_0 != NULL);
/* Make dialog a child of the application so that it will iconify */
gnome_dialog_set_parent (GNOME_DIALOG (dialog),
GTK_WINDOW (wb->toplevel));
/* Bring up the dialog */
res = gnome_dialog_run (GNOME_DIALOG (dialog));
if (res == GNOME_OK) {
i = gtk_radio_group_get_selected
(GTK_RADIO_BUTTON(radio_0)->group);
ss = sheet->selections->data;
cols = ss->user.end.col - ss->user.start.col + 1;
rows = ss->user.end.row - ss->user.start.row + 1;
if (i == 0)
sheet_shift_rows (sheet, ss->user.start.col,
ss->user.start.row,
ss->user.end.row, -cols);
else if (i == 1)
sheet_shift_cols (sheet, ss->user.start.col,
ss->user.end.col,
ss->user.start.row, -rows);
else if (i == 2)
sheet_delete_row (sheet, ss->user.start.row, rows);
else if (i == 3)
sheet_delete_col (sheet, ss->user.start.col, cols);
}
/* If user closed the dialog with prejudice, it's already destroyed */
if (res >= 0)
gnome_dialog_close (GNOME_DIALOG (dialog));
}
void
dialog_delete_cells (Workbook *wb, Sheet *sheet)
{
int state [4] = { 1, 0, 0, 0 };
GladeXML *gui;
SheetSelection *ss;
char *ret;
int cols, rows;
g_return_if_fail (wb != NULL);
g_return_if_fail (sheet != NULL);
g_return_if_fail (IS_SHEET (sheet));
if (!selection_is_simple (sheet, _("delete cells")))
return;
......@@ -42,40 +95,15 @@ dialog_delete_cells (Workbook *wb, Sheet *sheet)
return;
}
ret = gtk_dialog_cauldron (
_("Delete cells"),
GTK_CAULDRON_DIALOG | GTK_CAULDRON_PARENT,
GTK_WINDOW (wb->toplevel),
"( %[ ( %Rd // %Rd / %Rd // %Rd ) ] / ( %Bqrg || %Bqrg ) )",
_("Delete"),
_("Shift cells left"), &state[0],
_("Shift cells up"), &state[1],
_("Delete row(s)"), &state[2],
_("Delete column(s)"), &state[3],
GNOME_STOCK_BUTTON_OK,
GNOME_STOCK_BUTTON_CANCEL);
if (ret == NULL)
return;
if (strcmp (ret, GNOME_STOCK_BUTTON_CANCEL) == 0)
return;
if (state [0]){
sheet_shift_rows (sheet, ss->user.start.col, ss->user.start.row, ss->user.end.row, -cols);
gui = glade_xml_new (GNUMERIC_GLADEDIR "/" GLADE_FILE , NULL);
if (!gui) {
printf ("Could not find " GLADE_FILE "\n");
return;
}
if (state [1]){
sheet_shift_cols (sheet, ss->user.start.col, ss->user.end.col, ss->user.start.row, -rows);
return;
}
if (state [2]){
sheet_delete_row (sheet, ss->user.start.row, rows);
return;
}
/* default */
sheet_delete_col (sheet, ss->user.start.col, cols);
/* Wrapper to ensure the libglade object gets removed on error */
dialog_delete_cells_impl (wb, sheet, gui);
gtk_object_unref (GTK_OBJECT (gui));
}
......@@ -7,17 +7,69 @@
*/
#include <config.h>
#include <gnome.h>
#include <glade/glade.h>
#include "gnumeric.h"
#include "gnumeric-util.h"
#include "selection.h"
#include "dialogs.h"
#define GLADE_FILE "insert-cells.glade"
static void
dialog_insert_cells_impl (Workbook *wb, Sheet *sheet, GladeXML *gui)
{
GtkWidget *dialog, *radio_0;
SheetSelection *ss;
int cols, rows;
int i, res;
dialog = glade_xml_get_widget (gui, "Insert_cells");
if (dialog == NULL) {
g_print ("Corrupt file " GLADE_FILE "\n");
return;
}
radio_0 = glade_xml_get_widget (gui, "radio_0");
g_return_if_fail (radio_0 != NULL);
/* Make dialog a child of the application so that it will iconify */
gnome_dialog_set_parent (GNOME_DIALOG (dialog),
GTK_WINDOW (wb->toplevel));
/* Bring up the dialog */
res = gnome_dialog_run (GNOME_DIALOG (dialog));
if (res == GNOME_OK) {
i = gtk_radio_group_get_selected
(GTK_RADIO_BUTTON(radio_0)->group);
ss = sheet->selections->data;
cols = ss->user.end.col - ss->user.start.col + 1;
rows = ss->user.end.row - ss->user.start.row + 1;
if (i == 0)
sheet_shift_rows (sheet, ss->user.start.col,
ss->user.start.row,
ss->user.end.row, cols);
else if (i == 1)
sheet_shift_cols (sheet, ss->user.start.col,
ss->user.end.col,
ss->user.start.row, rows);
else if (i == 2)
sheet_insert_row (sheet, ss->user.start.row, rows);
else if (i == 3)
sheet_insert_col (sheet, ss->user.start.col, cols);
}
/* If user closed the dialog with prejudice, it's already destroyed */
if (res >= 0)
gnome_dialog_close (GNOME_DIALOG (dialog));
}
void
dialog_insert_cells (Workbook *wb, Sheet *sheet)
{
int state [4] = { 1, 0, 0, 0 };
GladeXML *gui;
SheetSelection *ss;
char *ret;
int cols, rows;
g_return_if_fail (wb != NULL);
......@@ -43,40 +95,14 @@ dialog_insert_cells (Workbook *wb, Sheet *sheet)
return;
}
ret = gtk_dialog_cauldron (
_("Insert cells"),
GTK_CAULDRON_DIALOG | GTK_CAULDRON_PARENT,
GTK_WINDOW (wb->toplevel),
"( %[ ( %Rd // %Rd / %Rd // %Rd ) ] / ( %Bqrg || %Bqrg ) )",
_("Insert"),
_("Shift cells right"), &state[0],
_("Shift cells down"), &state[1],
_("Insert row(s)"), &state[2],
_("Insert column(s)"), &state[3],
GNOME_STOCK_BUTTON_OK,
GNOME_STOCK_BUTTON_CANCEL);
if (ret == NULL)
return;
if (strcmp (ret, GNOME_STOCK_BUTTON_CANCEL) == 0)
return;
if (state [0]){
sheet_shift_rows (sheet, ss->user.start.col, ss->user.start.row, ss->user.end.row, cols);
return;
}
if (state [1]){
sheet_shift_cols (sheet, ss->user.start.col, ss->user.end.col, ss->user.start.row, rows);
return;
}
if (state [2]){
sheet_insert_row (sheet, ss->user.start.row, rows);
gui = glade_xml_new (GNUMERIC_GLADEDIR "/" GLADE_FILE , NULL);
if (!gui) {
printf ("Could not find " GLADE_FILE "\n");
return;
}
/* default */
sheet_insert_col (sheet, ss->user.start.col, cols);
/* Wrapper to ensure the libglade object gets removed on error */
dialog_insert_cells_impl (wb, sheet, gui);
gtk_object_unref (GTK_OBJECT (gui));
}
<?xml version="1.0"?>
<GTK-Interface>
<project>
<name>Delete-cells</name>
<program_name>delete-cells</program_name>
<directory></directory>
<source_directory>src</source_directory>
<pixmaps_directory>pixmaps</pixmaps_directory>
<language>C</language>
<gnome_support>True</gnome_support>
<gettext_support>True</gettext_support>
<use_widget_names>False</use_widget_names>
<output_main_file>True</output_main_file>
<output_support_files>True</output_support_files>
<output_build_files>True</output_build_files>
<backup_source_files>True</backup_source_files>
<main_source_file>interface.c</main_source_file>
<main_header_file>interface.h</main_header_file>
<handler_source_file>callbacks.c</handler_source_file>
<handler_header_file>callbacks.h</handler_header_file>
<support_source_file>support.c</support_source_file>
<support_header_file>support.h</support_header_file>
<translatable_strings_file></translatable_strings_file>
</project>
<widget>
<class>GnomeDialog</class>
<name>Insert_cells</name>
<title>Insert cells</title>
<visible>False</visible>
<type>GTK_WINDOW_DIALOG</type>
<position>GTK_WIN_POS_NONE</position>
<modal>True</modal>
<allow_shrink>False</allow_shrink>
<allow_grow>False</allow_grow>
<auto_shrink>False</auto_shrink>
<auto_close>False</auto_close>
<hide_on_close>False</hide_on_close>
<widget>
<class>GtkVBox</class>
<child_name>GnomeDialog:vbox</child_name>
<name>dialog-vbox1</name>
<homogeneous>False</homogeneous>
<spacing>8</spacing>
<child>
<padding>4</padding>
<expand>True</expand>
<fill>True</fill>
</child>
<widget>
<class>GtkFrame</class>
<name>frame1</name>
<label>Insert</label>
<label_xalign>0</label_xalign>
<shadow_type>GTK_SHADOW_ETCHED_IN</shadow_type>
<child>
<padding>0</padding>
<expand>True</expand>
<fill>True</fill>
</child>
<widget>
<class>GtkVBox</class>
<name>vbox1</name>
<border_width>4</border_width>
<homogeneous>False</homogeneous>
<spacing>0</spacing>
<widget>
<class>GtkRadioButton</class>
<name>radio_0</name>
<can_focus>True</can_focus>
<has_focus>True</has_focus>
<label>_Shift cells right</label>
<active>False</active>
<draw_indicator>True</draw_indicator>
<group>radios</group>
<child>
<padding>0</padding>
<expand>False</expand>
<fill>False</fill>
</child>
</widget>
<widget>
<class>GtkRadioButton</class>
<name>radio_1</name>
<can_focus>True</can_focus>
<label>Shift cells _down</label>
<active>False</active>
<draw_indicator>True</draw_indicator>
<group>radios</group>
<child>
<padding>0</padding>
<expand>False</expand>
<fill>False</fill>
</child>
</widget>
<widget>
<class>GtkRadioButton</class>
<name>radio_2</name>
<can_focus>True</can_focus>
<label>Insert _row(s)</label>
<active>False</active>
<draw_indicator>True</draw_indicator>
<group>radios</group>
<child>
<padding>0</padding>
<expand>False</expand>
<fill>False</fill>
</child>
</widget>
<widget>
<class>GtkRadioButton</class>
<name>radio_3</name>
<can_focus>True</can_focus>
<label>Insert _column(s)</label>
<active>False</active>
<draw_indicator>True</draw_indicator>
<group>radios</group>
<child>
<padding>0</padding>
<expand>False</expand>
<fill>False</fill>
</child>
</widget>
</widget>
</widget>
<widget>
<class>GtkHButtonBox</class>
<child_name>GnomeDialog:action_area</child_name>
<name>dialog-action_area1</name>
<layout_style>GTK_BUTTONBOX_END</layout_style>
<spacing>8</spacing>
<child_min_width>85</child_min_width>
<child_min_height>27</child_min_height>
<child_ipad_x>7</child_ipad_x>
<child_ipad_y>0</child_ipad_y>
<child>
<padding>0</padding>
<expand>False</expand>
<fill>True</fill>
<pack>GTK_PACK_END</pack>
</child>
<widget>
<class>GtkButton</class>
<name>button1</name>
<can_default>True</can_default>
<has_default>True</has_default>
<can_focus>True</can_focus>
<stock_button>GNOME_STOCK_BUTTON_OK</stock_button>
</widget>
<widget>
<class>GtkButton</class>
<name>button3</name>
<can_default>True</can_default>
<can_focus>True</can_focus>
<stock_button>GNOME_STOCK_BUTTON_CANCEL</stock_button>
</widget>
</widget>
</widget>
</widget>
</GTK-Interface>
......@@ -13,6 +13,7 @@
#include "item-bar.h"
#include "item-debug.h"
#include "utils.h"
#include "selection.h"
/* Marshal forward declarations */
static void item_bar_marshal (GtkObject *,
......@@ -500,10 +501,17 @@ item_bar_event (GnomeCanvasItem *item, GdkEvent *e)
item_bar->resize_width = cri->pixels;
} else if (e->button.button == 3){
Sheet *sheet = item_bar->sheet_view->sheet;
gtk_signal_emit (GTK_OBJECT (item),
item_bar_signals [SELECTION_CHANGED],
element, e->button.state | GDK_BUTTON1_MASK);
if (item_bar->orientation == GTK_ORIENTATION_VERTICAL)
gboolean const is_col = (item_bar->orientation != GTK_ORIENTATION_VERTICAL);
/* If the selection does not contain the current row/col
* then clear the selection and add it.
*/
if (!selection_contains_colrow (sheet, element, is_col))
gtk_signal_emit (GTK_OBJECT (item),
item_bar_signals [SELECTION_CHANGED],
element, e->button.state | GDK_BUTTON1_MASK);
if (is_col)
item_grid_popup_menu (sheet, e, element, 0);
else
item_grid_popup_menu (sheet, e, 0, element);
......
......@@ -1022,3 +1022,41 @@ selection_to_list (Sheet *sheet, gboolean allow_intersection)
allow_intersection, &list);
return list;
}