mirror of
https://github.com/subsurface/subsurface.git
synced 2024-12-01 06:30:26 +00:00
Make the 'Add Dive' dialog at least slightly less butt-ugly
I still suspect that using spinbuttons for the time handling is the wrong way, and I'm a bit surprised the Calendar widget doesn't have a mode where you can see/set the time too. But this makes things at least minimally prettier, and initializes the time entries to the current time (which is obviously not what anybody really wants, but looks a lot better than defaulting to "midnight" or some other random time that *also* won't be what anybody actually wants). I think this might be something we can live with, although I hope somebody with good taste comes along and say "don't use spinbuttons, do this: xyzzy" and makes things look better yet. Also, I have this suspicion that I should put the time/depth/duration stuff to the right of the calendar. Most displays are wider than they are tall, so tall and skinny dialogs are bad especially if you have limited vertical pixels. I still have flashbacks to my netbook-using days, hating applictions that did that. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
This commit is contained in:
parent
162b36f4a5
commit
03174992a8
1 changed files with 43 additions and 23 deletions
66
info.c
66
info.c
|
@ -12,6 +12,7 @@
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
|
#include <sys/time.h>
|
||||||
|
|
||||||
#include "dive.h"
|
#include "dive.h"
|
||||||
#include "display.h"
|
#include "display.h"
|
||||||
|
@ -420,16 +421,35 @@ int edit_dive_info(struct dive *dive)
|
||||||
return success;
|
return success;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static GtkWidget *frame_box(GtkWidget *vbox, const char *fmt, ...)
|
||||||
|
{
|
||||||
|
va_list ap;
|
||||||
|
char buffer[64];
|
||||||
|
GtkWidget *frame, *hbox;
|
||||||
|
|
||||||
|
va_start(ap, fmt);
|
||||||
|
vsnprintf(buffer, sizeof(buffer), fmt, ap);
|
||||||
|
va_end(ap);
|
||||||
|
|
||||||
|
frame = gtk_frame_new(buffer);
|
||||||
|
gtk_box_pack_start(GTK_BOX(vbox), frame, FALSE, TRUE, 0);
|
||||||
|
hbox = gtk_hbox_new(0, 3);
|
||||||
|
gtk_container_add(GTK_CONTAINER(frame), hbox);
|
||||||
|
return hbox;
|
||||||
|
}
|
||||||
|
|
||||||
/* Fixme - should do at least depths too - a dive without a depth is kind of pointless */
|
/* Fixme - should do at least depths too - a dive without a depth is kind of pointless */
|
||||||
static time_t dive_time_widget(struct dive *dive)
|
static time_t dive_time_widget(struct dive *dive)
|
||||||
{
|
{
|
||||||
GtkWidget *dialog;
|
GtkWidget *dialog;
|
||||||
GtkWidget *cal, *hbox, *vbox;
|
GtkWidget *cal, *hbox, *vbox, *box;
|
||||||
GtkWidget *h, *m;
|
GtkWidget *h, *m;
|
||||||
GtkWidget *duration, *depth;
|
GtkWidget *duration, *depth;
|
||||||
GtkWidget *label;
|
GtkWidget *label;
|
||||||
guint yval, mval, dval;
|
guint yval, mval, dval;
|
||||||
struct tm tm;
|
struct tm tm, *tmp;
|
||||||
|
struct timeval tv;
|
||||||
|
time_t time;
|
||||||
int success;
|
int success;
|
||||||
double depthinterval, val;
|
double depthinterval, val;
|
||||||
|
|
||||||
|
@ -443,47 +463,47 @@ static time_t dive_time_widget(struct dive *dive)
|
||||||
vbox = gtk_dialog_get_content_area(GTK_DIALOG(dialog));
|
vbox = gtk_dialog_get_content_area(GTK_DIALOG(dialog));
|
||||||
|
|
||||||
/* Calendar hbox */
|
/* Calendar hbox */
|
||||||
hbox = gtk_hbox_new(0, 3);
|
hbox = frame_box(vbox, "Date:");
|
||||||
gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, TRUE, 0);
|
|
||||||
|
|
||||||
cal = gtk_calendar_new();
|
cal = gtk_calendar_new();
|
||||||
gtk_box_pack_start(GTK_BOX(hbox), cal, FALSE, TRUE, 0);
|
gtk_box_pack_start(GTK_BOX(hbox), cal, FALSE, TRUE, 0);
|
||||||
|
|
||||||
/* Time/duration hbox */
|
/* Time hbox */
|
||||||
hbox = gtk_hbox_new(0, 3);
|
hbox = frame_box(vbox, "Time");
|
||||||
gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, TRUE, 0);
|
|
||||||
|
|
||||||
h = gtk_spin_button_new_with_range (0.0, 23.0, 1.0);
|
h = gtk_spin_button_new_with_range (0.0, 23.0, 1.0);
|
||||||
m = gtk_spin_button_new_with_range (0.0, 59.0, 1.0);
|
m = gtk_spin_button_new_with_range (0.0, 59.0, 1.0);
|
||||||
|
|
||||||
|
gettimeofday(&tv, NULL);
|
||||||
|
time = tv.tv_sec;
|
||||||
|
tmp = localtime(&time);
|
||||||
|
gtk_spin_button_set_value(GTK_SPIN_BUTTON(h), tmp->tm_hour);
|
||||||
|
gtk_spin_button_set_value(GTK_SPIN_BUTTON(m), (tmp->tm_min / 5)*5);
|
||||||
|
|
||||||
gtk_spin_button_set_wrap(GTK_SPIN_BUTTON(h), TRUE);
|
gtk_spin_button_set_wrap(GTK_SPIN_BUTTON(h), TRUE);
|
||||||
gtk_spin_button_set_wrap(GTK_SPIN_BUTTON(m), TRUE);
|
gtk_spin_button_set_wrap(GTK_SPIN_BUTTON(m), TRUE);
|
||||||
|
|
||||||
duration = gtk_spin_button_new_with_range (0.0, 1000.0, 1.0);
|
gtk_box_pack_end(GTK_BOX(hbox), m, FALSE, FALSE, 0);
|
||||||
|
|
||||||
gtk_box_pack_start(GTK_BOX(hbox), h, FALSE, FALSE, 0);
|
|
||||||
label = gtk_label_new(":");
|
label = gtk_label_new(":");
|
||||||
gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0);
|
gtk_box_pack_end(GTK_BOX(hbox), label, FALSE, FALSE, 0);
|
||||||
gtk_box_pack_start(GTK_BOX(hbox), m, FALSE, FALSE, 0);
|
gtk_box_pack_end(GTK_BOX(hbox), h, FALSE, FALSE, 0);
|
||||||
|
|
||||||
label = gtk_label_new(" Duration:");
|
hbox = gtk_hbox_new(TRUE, 3);
|
||||||
gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0);
|
gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
|
||||||
gtk_box_pack_start(GTK_BOX(hbox), duration, FALSE, FALSE, 0);
|
|
||||||
|
/* Duration hbox */
|
||||||
|
box = frame_box(hbox, "Duration (min)");
|
||||||
|
duration = gtk_spin_button_new_with_range (0.0, 1000.0, 1.0);
|
||||||
|
gtk_box_pack_end(GTK_BOX(box), duration, FALSE, FALSE, 0);
|
||||||
|
|
||||||
/* Depth box */
|
/* Depth box */
|
||||||
hbox = gtk_hbox_new(0, 3);
|
box = frame_box(hbox, "Depth (%s):", output_units.length == FEET ? "ft" : "m");
|
||||||
gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, TRUE, 0);
|
|
||||||
|
|
||||||
if (output_units.length == FEET) {
|
if (output_units.length == FEET) {
|
||||||
depthinterval = 1.0;
|
depthinterval = 1.0;
|
||||||
} else {
|
} else {
|
||||||
depthinterval = 0.1;
|
depthinterval = 0.1;
|
||||||
}
|
}
|
||||||
depth = gtk_spin_button_new_with_range (0.0, 1000.0, depthinterval);
|
depth = gtk_spin_button_new_with_range (0.0, 1000.0, depthinterval);
|
||||||
|
gtk_box_pack_end(GTK_BOX(box), depth, FALSE, FALSE, 0);
|
||||||
label = gtk_label_new("Depth: ");
|
|
||||||
gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0);
|
|
||||||
gtk_box_pack_start(GTK_BOX(hbox), depth, FALSE, FALSE, 0);
|
|
||||||
|
|
||||||
/* All done, show it and wait for editing */
|
/* All done, show it and wait for editing */
|
||||||
gtk_widget_show_all(dialog);
|
gtk_widget_show_all(dialog);
|
||||||
|
|
Loading…
Reference in a new issue