Commit bf253767 authored by Michael Meeks's avatar Michael Meeks
Browse files

fiddled with jody's dialog.

parent e3b90471
1999-09-25 Michael Meeks <michael@nuclecu.unam.mx>
* src/dialogs/dialog-zoom.c (dialog_zoom): Correct glade name.
(dialog_zoom_impl): use moveto after we know the final list size.
(custom_selected): simplify. (radio_toggled): ditto.
(select_sheet_cb): create. (dialog_zoom_impl): use update_zoom_but
& complicate significantly :-) (update_zoom_buttons): create.
1999-09-25 Jody Goldberg <jgoldberg@home.com>
* src/plugin.c (plugin_load) : Enable the error box when
......
1999-09-25 Michael Meeks <michael@nuclecu.unam.mx>
* src/dialogs/dialog-zoom.c (dialog_zoom): Correct glade name.
(dialog_zoom_impl): use moveto after we know the final list size.
(custom_selected): simplify. (radio_toggled): ditto.
(select_sheet_cb): create. (dialog_zoom_impl): use update_zoom_but
& complicate significantly :-) (update_zoom_buttons): create.
1999-09-25 Jody Goldberg <jgoldberg@home.com>
* src/plugin.c (plugin_load) : Enable the error box when
......
......@@ -13,106 +13,146 @@
#include "gnumeric-sheet.h"
#include "dialogs.h"
#define NUM_RADIO_BUTTONS 5
typedef struct {
GtkSpinButton *zoom;
int factor;
GtkRadioButton *me;
int factor;
GtkSpinButton *zoom;
GtkRadioButton *custom;
} radio_cb_data;
typedef struct {
Sheet *sheet;
radio_cb_data *cb_data;
} sheet_closure_t;
static void
radio_toggled (GtkToggleButton *togglebutton,
gpointer user_data)
radio_cb_data *dat)
{
/* We are only interested in the new state */
if (gtk_toggle_button_get_active(togglebutton)) {
radio_cb_data const * dat = user_data;
if (gtk_toggle_button_get_active (togglebutton))
gtk_spin_button_set_value (GTK_SPIN_BUTTON (dat->zoom),
dat->factor);
}
}
static gboolean
custom_selected (GtkWidget *widget, GdkEventFocus *event,
gpointer user_data)
custom_selected (GtkWidget *widget, GdkEventFocus *event,
GtkWidget *custom_button)
{
GtkWidget *custom_button = user_data;
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (custom_button), TRUE);
return FALSE;
}
static void
update_zoom_buttons (const Sheet *sheet, radio_cb_data *cb_data)
{
int i;
gboolean is_custom = TRUE;
for (i = NUM_RADIO_BUTTONS; --i >= 0; ) {
if (sheet->last_zoom_factor_used * 100.0 == cb_data[i].factor) {
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (cb_data[i].me), TRUE);
is_custom = FALSE;
}
}
if (is_custom) {
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (cb_data[0].custom), TRUE);
gtk_spin_button_set_value (cb_data[0].zoom,
(int)(sheet->last_zoom_factor_used * 100. + .5));
}
}
static void
select_sheet_cb (GtkCList *clist, gint row, gint col, GdkEventButton *event,
sheet_closure_t *sheet_data)
{
g_return_if_fail (sheet_data != NULL);
update_zoom_buttons (sheet_data->sheet, sheet_data->cb_data);
}
static void
dialog_zoom_impl (Workbook *wb, Sheet *cur_sheet, GladeXML *gui)
{
#define NUM_RADIO_BUTTONS 5
static struct {
char const * const name;
float const factor;
char const * const name;
float const factor;
} buttons[NUM_RADIO_BUTTONS] = {
{ "radio_200", 2. },
{ "radio_100", 1. },
{ "radio_75", .75 },
{ "radio_50", .50 },
{ "radio_25", .25 },
{ "radio_200", 2. },
{ "radio_100", 1. },
{ "radio_75", .75 },
{ "radio_50", .50 },
{ "radio_25", .25 },
};
radio_cb_data cb_data[NUM_RADIO_BUTTONS];
GList *sheet_data;
GtkCList *list;
GtkWidget *dialog;
GtkRadioButton *radio;
GtkRadioButton *radio, *custom;
GtkSpinButton *zoom;
GList *l, *sheets;
gboolean is_custom = TRUE;
int i, res;
int i, res, cur_row;
list = GTK_CLIST (glade_xml_get_widget (gui, "sheet_list"));
g_return_if_fail (list);
zoom = GTK_SPIN_BUTTON (glade_xml_get_widget (gui, "zoom"));
g_return_if_fail (zoom != NULL);
radio = GTK_RADIO_BUTTON (glade_xml_get_widget (gui, "radio_custom"));
g_return_if_fail (radio != NULL);
custom = GTK_RADIO_BUTTON (glade_xml_get_widget (gui, "radio_custom"));
g_return_if_fail (custom != NULL);
gtk_signal_connect (GTK_OBJECT (zoom), "focus_in_event",
GTK_SIGNAL_FUNC (custom_selected),
radio);
custom);
for (i = NUM_RADIO_BUTTONS; --i >= 0; ) {
radio = GTK_RADIO_BUTTON (glade_xml_get_widget (gui, buttons[i].name));
g_return_if_fail (radio != NULL);
cb_data[i].zoom = zoom;
cb_data[i].factor = (int)(buttons[i].factor * 100.);
cb_data[i].me = radio;
cb_data[i].zoom = zoom;
cb_data[i].custom = custom;
gtk_signal_connect (GTK_OBJECT (radio), "toggled",
GTK_SIGNAL_FUNC (radio_toggled),
&(cb_data[i]));
if (cur_sheet->last_zoom_factor_used == buttons[i].factor) {
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (radio), TRUE);
is_custom = FALSE;
}
}
if (is_custom) {
radio = GTK_RADIO_BUTTON (glade_xml_get_widget (gui, "radio_custom"));
g_return_if_fail (radio != NULL);
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (radio), TRUE);
gtk_spin_button_set_value (zoom, (int)(cur_sheet->last_zoom_factor_used * 100. + .5));
}
update_zoom_buttons (cur_sheet, &cb_data[0]);
gtk_clist_freeze (list);
sheets = workbook_sheets (wb);
for (l = sheets; l; l = l->next){
cur_row = -1;
sheet_data = NULL;
for (l = sheets; l; l = l->next) {
Sheet *sheet = l->data;
int const row = gtk_clist_append (list, &sheet->name);
sheet_closure_t *sdata = g_new (sheet_closure_t, 1);
gtk_clist_set_row_data (list, row, sheet);
sdata->sheet = sheet;
sdata->cb_data = &cb_data[0];
sheet_data = g_list_append (sheet_data, sdata);
if (sheet == cur_sheet) {
gtk_clist_select_row (list, row, 0);
if (sheet == cur_sheet)
cur_row = row;
/* FIXME : Why is this not working */
gtk_clist_moveto (list, row, 0, .5, 0.);
}
gtk_signal_connect (GTK_OBJECT (list), "select-row",
GTK_SIGNAL_FUNC (select_sheet_cb),
sdata);
}
g_list_free (sheets);
gtk_clist_thaw (list);
gtk_clist_select_row (list, cur_row, 0);
gtk_clist_moveto (list, cur_row, 0, .5, 0.0);
dialog = glade_xml_get_widget (gui, "Zoom");
if (dialog == NULL) {
printf ("Corrupt file dialog-zoom.glade\n");
......@@ -135,6 +175,12 @@ dialog_zoom_impl (Workbook *wb, Sheet *cur_sheet, GladeXML *gui)
/* If the user closed the dialog with prejudice, its already destroyed */
if (res >= 0)
gnome_dialog_close (GNOME_DIALOG (dialog));
for (l = sheet_data; l; l = g_list_next (l))
g_free (l->data);
g_list_free (sheet_data);
}
/* Wrapper to ensure the libglade object gets removed on error */
......@@ -148,7 +194,7 @@ dialog_zoom (Workbook *wb, Sheet *sheet)
gui = glade_xml_new (GNUMERIC_GLADEDIR "/dialog-zoom.glade", NULL);
if (!gui) {
printf ("Could not find zoom.glade\n");
printf ("Could not find dialog-zoom.glade\n");
return;
}
......
......@@ -318,7 +318,7 @@ sheet_object_realize (SheetObject *so)
g_return_if_fail (so != NULL);
g_return_if_fail (IS_SHEET_OBJECT (so));
for (l = so->sheet->sheet_views; l; l = l->next){
for (l = so->sheet->sheet_views; l; l = l->next) {
SheetView *sheet_view = l->data;
GnomeCanvasItem *item;
......@@ -341,7 +341,7 @@ sheet_object_unrealize (SheetObject *so)
g_return_if_fail (so != NULL);
g_return_if_fail (IS_SHEET_OBJECT (so));
for (l = so->sheet->sheet_views; l; l = l->next){
for (l = so->sheet->sheet_views; l; l = l->next) {
SheetView *sheet_view = l->data;
sheet_view_object_unrealize (sheet_view, so);
......
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