mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
Add Ok/Cancel buttons to unit dialog
.. instead of just having a live running dialog all the time. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
This commit is contained in:
parent
c4d5ebb069
commit
19dd61b126
1 changed files with 17 additions and 4 deletions
21
main.c
21
main.c
|
@ -243,11 +243,11 @@ static void create_radio(GtkWidget *dialog, const char *name, ...)
|
||||||
static void name(GtkWidget *w, gpointer data) \
|
static void name(GtkWidget *w, gpointer data) \
|
||||||
{ \
|
{ \
|
||||||
if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(w))) \
|
if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(w))) \
|
||||||
output_units.type = value; \
|
menu_units.type = value; \
|
||||||
repaint_dive(); \
|
|
||||||
dive_list_update_dives(dive_list); \
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static struct units menu_units;
|
||||||
|
|
||||||
UNITCALLBACK(set_meter, length, METERS)
|
UNITCALLBACK(set_meter, length, METERS)
|
||||||
UNITCALLBACK(set_feet, length, FEET)
|
UNITCALLBACK(set_feet, length, FEET)
|
||||||
UNITCALLBACK(set_bar, pressure, BAR)
|
UNITCALLBACK(set_bar, pressure, BAR)
|
||||||
|
@ -259,11 +259,17 @@ UNITCALLBACK(set_fahrenheit, temperature, FAHRENHEIT)
|
||||||
|
|
||||||
static void unit_dialog(GtkWidget *w, gpointer data)
|
static void unit_dialog(GtkWidget *w, gpointer data)
|
||||||
{
|
{
|
||||||
|
int result;
|
||||||
GtkWidget *dialog;
|
GtkWidget *dialog;
|
||||||
|
|
||||||
|
menu_units = output_units;
|
||||||
|
|
||||||
dialog = gtk_dialog_new_with_buttons("Units",
|
dialog = gtk_dialog_new_with_buttons("Units",
|
||||||
GTK_WINDOW(main_window),
|
GTK_WINDOW(main_window),
|
||||||
GTK_DIALOG_DESTROY_WITH_PARENT, NULL);
|
GTK_DIALOG_DESTROY_WITH_PARENT,
|
||||||
|
GTK_STOCK_OK, GTK_RESPONSE_ACCEPT,
|
||||||
|
GTK_STOCK_CANCEL, GTK_RESPONSE_REJECT,
|
||||||
|
NULL);
|
||||||
|
|
||||||
create_radio(dialog, "Depth:",
|
create_radio(dialog, "Depth:",
|
||||||
"Meter", set_meter, (output_units.length == METERS),
|
"Meter", set_meter, (output_units.length == METERS),
|
||||||
|
@ -286,6 +292,13 @@ static void unit_dialog(GtkWidget *w, gpointer data)
|
||||||
NULL);
|
NULL);
|
||||||
|
|
||||||
gtk_widget_show(dialog);
|
gtk_widget_show(dialog);
|
||||||
|
result = gtk_dialog_run(GTK_DIALOG(dialog));
|
||||||
|
if (result == GTK_RESPONSE_ACCEPT) {
|
||||||
|
output_units = menu_units;
|
||||||
|
repaint_dive();
|
||||||
|
dive_list_update_dives(dive_list);
|
||||||
|
}
|
||||||
|
gtk_widget_destroy(dialog);
|
||||||
}
|
}
|
||||||
|
|
||||||
static GtkActionEntry menu_items[] = {
|
static GtkActionEntry menu_items[] = {
|
||||||
|
|
Loading…
Add table
Reference in a new issue