Commit bc6694c2 authored by Jody Goldberg's avatar Jody Goldberg

Set a few more glade flags on the zoom dialog.

Avoid setting accelerators on the radio buttons.
parent 098168c3
...@@ -15,19 +15,13 @@ ...@@ -15,19 +15,13 @@
#define NUM_RADIO_BUTTONS 5 #define NUM_RADIO_BUTTONS 5
#define GLADE_FILE "dialog-zoom.glade"
typedef struct { typedef struct {
GtkRadioButton *me;
int factor; int factor;
GtkSpinButton *zoom; GtkSpinButton *zoom;
GtkRadioButton *custom;
} radio_cb_data; } radio_cb_data;
typedef struct {
Sheet *sheet;
radio_cb_data *cb_data;
} sheet_closure_t;
static void static void
radio_toggled (GtkToggleButton *togglebutton, radio_toggled (GtkToggleButton *togglebutton,
radio_cb_data *dat) radio_cb_data *dat)
...@@ -46,36 +40,6 @@ custom_selected (GtkWidget *widget, GdkEventFocus *event, ...@@ -46,36 +40,6 @@ custom_selected (GtkWidget *widget, GdkEventFocus *event,
return FALSE; 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 static void
dialog_zoom_impl (Workbook *wb, Sheet *cur_sheet, GladeXML *gui) dialog_zoom_impl (Workbook *wb, Sheet *cur_sheet, GladeXML *gui)
{ {
...@@ -90,7 +54,6 @@ dialog_zoom_impl (Workbook *wb, Sheet *cur_sheet, GladeXML *gui) ...@@ -90,7 +54,6 @@ dialog_zoom_impl (Workbook *wb, Sheet *cur_sheet, GladeXML *gui)
{ "radio_25", .25 }, { "radio_25", .25 },
}; };
radio_cb_data cb_data[NUM_RADIO_BUTTONS]; radio_cb_data cb_data[NUM_RADIO_BUTTONS];
GList *sheet_data;
GtkCList *list; GtkCList *list;
GtkWidget *dialog; GtkWidget *dialog;
...@@ -98,6 +61,7 @@ dialog_zoom_impl (Workbook *wb, Sheet *cur_sheet, GladeXML *gui) ...@@ -98,6 +61,7 @@ dialog_zoom_impl (Workbook *wb, Sheet *cur_sheet, GladeXML *gui)
GtkSpinButton *zoom; GtkSpinButton *zoom;
GList *l, *sheets; GList *l, *sheets;
int i, res, cur_row; int i, res, cur_row;
gboolean is_custom = TRUE;
list = GTK_CLIST (glade_xml_get_widget (gui, "sheet_list")); list = GTK_CLIST (glade_xml_get_widget (gui, "sheet_list"));
g_return_if_fail (list); g_return_if_fail (list);
...@@ -114,48 +78,46 @@ dialog_zoom_impl (Workbook *wb, Sheet *cur_sheet, GladeXML *gui) ...@@ -114,48 +78,46 @@ dialog_zoom_impl (Workbook *wb, Sheet *cur_sheet, GladeXML *gui)
g_return_if_fail (radio != NULL); g_return_if_fail (radio != NULL);
cb_data[i].factor = (int)(buttons[i].factor * 100.); cb_data[i].factor = (int)(buttons[i].factor * 100.);
cb_data[i].me = radio;
cb_data[i].zoom = zoom; cb_data[i].zoom = zoom;
cb_data[i].custom = custom;
gtk_signal_connect (GTK_OBJECT (radio), "toggled", gtk_signal_connect (GTK_OBJECT (radio), "toggled",
GTK_SIGNAL_FUNC (radio_toggled), GTK_SIGNAL_FUNC (radio_toggled),
&(cb_data[i])); &(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;
}
} }
update_zoom_buttons (cur_sheet, &cb_data[0]); if (is_custom) {
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (custom), TRUE);
gtk_spin_button_set_value (zoom,
(int)(cur_sheet->last_zoom_factor_used * 100. + .5));
}
/* Get the list of sheets */
gtk_clist_freeze (list); gtk_clist_freeze (list);
sheets = workbook_sheets (wb); sheets = workbook_sheets (wb);
cur_row = -1; cur_row = 0;
sheet_data = NULL;
for (l = sheets; l; l = l->next) { for (l = sheets; l; l = l->next) {
Sheet *sheet = l->data; Sheet *sheet = l->data;
int const row = gtk_clist_append (list, &sheet->name); 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) if (sheet == cur_sheet)
cur_row = row; cur_row = row;
gtk_clist_set_row_data (list, row, sheet);
gtk_signal_connect (GTK_OBJECT (list), "select-row",
GTK_SIGNAL_FUNC (select_sheet_cb),
sdata);
} }
g_list_free (sheets); g_list_free (sheets);
gtk_clist_thaw (list);
gtk_clist_select_row (list, cur_row, 0); gtk_clist_select_row (list, cur_row, 0);
gtk_clist_moveto (list, cur_row, 0, .5, 0.0); gtk_clist_moveto (list, cur_row, 0, .5, 0.0);
gtk_clist_thaw (list);
dialog = glade_xml_get_widget (gui, "Zoom"); dialog = glade_xml_get_widget (gui, "Zoom");
if (dialog == NULL) { if (dialog == NULL) {
printf ("Corrupt file dialog-zoom.glade\n"); printf ("Corrupt file " GLADE_FILE "\n");
return; return;
} }
...@@ -175,12 +137,6 @@ dialog_zoom_impl (Workbook *wb, Sheet *cur_sheet, GladeXML *gui) ...@@ -175,12 +137,6 @@ dialog_zoom_impl (Workbook *wb, Sheet *cur_sheet, GladeXML *gui)
/* If the user closed the dialog with prejudice, its already destroyed */ /* If the user closed the dialog with prejudice, its already destroyed */
if (res >= 0) if (res >= 0)
gnome_dialog_close (GNOME_DIALOG (dialog)); 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 */ /* Wrapper to ensure the libglade object gets removed on error */
...@@ -192,9 +148,9 @@ dialog_zoom (Workbook *wb, Sheet *sheet) ...@@ -192,9 +148,9 @@ dialog_zoom (Workbook *wb, Sheet *sheet)
g_return_if_fail (wb != NULL); g_return_if_fail (wb != NULL);
g_return_if_fail (sheet != NULL); g_return_if_fail (sheet != NULL);
gui = glade_xml_new (GNUMERIC_GLADEDIR "/dialog-zoom.glade", NULL); gui = glade_xml_new (GNUMERIC_GLADEDIR "/" GLADE_FILE , NULL);
if (!gui) { if (!gui) {
printf ("Could not find dialog-zoom.glade\n"); printf ("Could not find " GLADE_FILE "\n");
return; return;
} }
......
...@@ -94,11 +94,6 @@ ...@@ -94,11 +94,6 @@
<class>GtkRadioButton</class> <class>GtkRadioButton</class>
<name>radio_200</name> <name>radio_200</name>
<can_focus>True</can_focus> <can_focus>True</can_focus>
<accelerator>
<modifiers>0</modifiers>
<key>GDK_0</key>
<signal>pressed</signal>
</accelerator>
<label>20_0 %</label> <label>20_0 %</label>
<active>False</active> <active>False</active>
<draw_indicator>True</draw_indicator> <draw_indicator>True</draw_indicator>
...@@ -114,11 +109,6 @@ ...@@ -114,11 +109,6 @@
<class>GtkRadioButton</class> <class>GtkRadioButton</class>
<name>radio_100</name> <name>radio_100</name>
<can_focus>True</can_focus> <can_focus>True</can_focus>
<accelerator>
<modifiers>0</modifiers>
<key>GDK_1</key>
<signal>pressed</signal>
</accelerator>
<label>_100 %</label> <label>_100 %</label>
<active>False</active> <active>False</active>
<draw_indicator>True</draw_indicator> <draw_indicator>True</draw_indicator>
...@@ -134,11 +124,6 @@ ...@@ -134,11 +124,6 @@
<class>GtkRadioButton</class> <class>GtkRadioButton</class>
<name>radio_75</name> <name>radio_75</name>
<can_focus>True</can_focus> <can_focus>True</can_focus>
<accelerator>
<modifiers>0</modifiers>
<key>GDK_7</key>
<signal>pressed</signal>
</accelerator>
<label>_75 %</label> <label>_75 %</label>
<active>False</active> <active>False</active>
<draw_indicator>True</draw_indicator> <draw_indicator>True</draw_indicator>
...@@ -154,11 +139,6 @@ ...@@ -154,11 +139,6 @@
<class>GtkRadioButton</class> <class>GtkRadioButton</class>
<name>radio_50</name> <name>radio_50</name>
<can_focus>True</can_focus> <can_focus>True</can_focus>
<accelerator>
<modifiers>0</modifiers>
<key>GDK_5</key>
<signal>pressed</signal>
</accelerator>
<label>_50 %</label> <label>_50 %</label>
<active>False</active> <active>False</active>
<draw_indicator>True</draw_indicator> <draw_indicator>True</draw_indicator>
...@@ -174,11 +154,6 @@ ...@@ -174,11 +154,6 @@
<class>GtkRadioButton</class> <class>GtkRadioButton</class>
<name>radio_25</name> <name>radio_25</name>
<can_focus>True</can_focus> <can_focus>True</can_focus>
<accelerator>
<modifiers>0</modifiers>
<key>GDK_2</key>
<signal>pressed</signal>
</accelerator>
<label>_25%</label> <label>_25%</label>
<active>False</active> <active>False</active>
<draw_indicator>True</draw_indicator> <draw_indicator>True</draw_indicator>
...@@ -338,15 +313,14 @@ ...@@ -338,15 +313,14 @@
<can_default>True</can_default> <can_default>True</can_default>
<has_default>True</has_default> <has_default>True</has_default>
<can_focus>True</can_focus> <can_focus>True</can_focus>
<has_focus>True</has_focus>
<stock_button>GNOME_STOCK_BUTTON_OK</stock_button> <stock_button>GNOME_STOCK_BUTTON_OK</stock_button>
</widget> </widget>
<widget> <widget>
<class>GtkButton</class> <class>GtkButton</class>
<name>cancel_button</name> <name>cancel_button</name>
<can_default>True</can_default>
<can_focus>True</can_focus> <can_focus>True</can_focus>
<has_focus>True</has_focus>
<stock_button>GNOME_STOCK_BUTTON_CANCEL</stock_button> <stock_button>GNOME_STOCK_BUTTON_CANCEL</stock_button>
</widget> </widget>
</widget> </widget>
......
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