mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
Add a GtkEntry to allow editing of the device name
Ok, so some file chooser widget with a popup dialog would have been more professional, but I'm lazy. Plus I suspect the popup would look horrible when populated with /dev entries, and I don't think there is any sane filter function. So this works, and means that you don't *have* to recompile the whole program just because you have your dive computer on something else than a USB serial line. I suspect I should save the default name as a config variable too. Maybe a setting in the preferences dialog. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
This commit is contained in:
parent
acca9b1804
commit
da47ee401d
1 changed files with 21 additions and 1 deletions
22
gtk-gui.c
22
gtk-gui.c
|
@ -638,13 +638,31 @@ static GtkComboBox *dive_computer_selector(GtkWidget *vbox)
|
||||||
return GTK_COMBO_BOX(combo_box);
|
return GTK_COMBO_BOX(combo_box);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static GtkEntry *dive_computer_device(GtkWidget *vbox)
|
||||||
|
{
|
||||||
|
GtkWidget *hbox, *entry, *frame;
|
||||||
|
|
||||||
|
hbox = gtk_hbox_new(FALSE, 6);
|
||||||
|
gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 3);
|
||||||
|
|
||||||
|
frame = gtk_frame_new("Device name");
|
||||||
|
gtk_box_pack_start(GTK_BOX(hbox), frame, FALSE, TRUE, 3);
|
||||||
|
|
||||||
|
entry = gtk_entry_new();
|
||||||
|
gtk_container_add(GTK_CONTAINER(frame), entry);
|
||||||
|
gtk_entry_set_text(GTK_ENTRY(entry), "/dev/ttyUSB0");
|
||||||
|
|
||||||
|
return GTK_ENTRY(entry);
|
||||||
|
}
|
||||||
|
|
||||||
void import_dialog(GtkWidget *w, gpointer data)
|
void import_dialog(GtkWidget *w, gpointer data)
|
||||||
{
|
{
|
||||||
int result;
|
int result;
|
||||||
GtkWidget *dialog, *hbox, *vbox;
|
GtkWidget *dialog, *hbox, *vbox;
|
||||||
GtkComboBox *computer;
|
GtkComboBox *computer;
|
||||||
|
GtkEntry *device;
|
||||||
device_data_t devicedata = {
|
device_data_t devicedata = {
|
||||||
.devname = "/dev/ttyUSB0",
|
.devname = NULL,
|
||||||
};
|
};
|
||||||
|
|
||||||
dialog = gtk_dialog_new_with_buttons("Import from dive computer",
|
dialog = gtk_dialog_new_with_buttons("Import from dive computer",
|
||||||
|
@ -657,6 +675,7 @@ void import_dialog(GtkWidget *w, gpointer data)
|
||||||
vbox = gtk_dialog_get_content_area(GTK_DIALOG(dialog));
|
vbox = gtk_dialog_get_content_area(GTK_DIALOG(dialog));
|
||||||
|
|
||||||
computer = dive_computer_selector(vbox);
|
computer = dive_computer_selector(vbox);
|
||||||
|
device = dive_computer_device(vbox);
|
||||||
|
|
||||||
hbox = gtk_hbox_new(FALSE, 6);
|
hbox = gtk_hbox_new(FALSE, 6);
|
||||||
gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, TRUE, 3);
|
gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, TRUE, 3);
|
||||||
|
@ -680,6 +699,7 @@ void import_dialog(GtkWidget *w, gpointer data)
|
||||||
-1);
|
-1);
|
||||||
devicedata.type = type;
|
devicedata.type = type;
|
||||||
devicedata.name = comp;
|
devicedata.name = comp;
|
||||||
|
devicedata.devname = gtk_entry_get_text(device);
|
||||||
do_import(&devicedata);
|
do_import(&devicedata);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
|
Loading…
Add table
Reference in a new issue