static GtkWidget *dive_profile;
+visible_cols_t visible_cols = {TRUE, FALSE};
+
void repaint_dive(void)
{
update_dive(current_dive);
UNITCALLBACK(set_celsius, temperature, CELSIUS)
UNITCALLBACK(set_fahrenheit, temperature, FAHRENHEIT)
+#define OPTIONCALLBACK(name, option) \
+static void name(GtkWidget *w, gpointer data) \
+{ \
+ option = GTK_TOGGLE_BUTTON(w)->active; \
+}
+
+OPTIONCALLBACK(otu_toggle, visible_cols.otu)
+OPTIONCALLBACK(sac_toggle, visible_cols.sac)
+
static void preferences_dialog(GtkWidget *w, gpointer data)
{
int result;
- GtkWidget *dialog, *font, *frame, *box, *vbox;
+ GtkWidget *dialog, *font, *frame, *box, *vbox, *button;
menu_units = output_units;
"Fahrenheit", set_fahrenheit, (output_units.temperature == FAHRENHEIT),
NULL);
+ frame = gtk_frame_new("Columns");
+ gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog)->vbox), frame, FALSE, FALSE, 5);
+
+ box = gtk_hbox_new(FALSE, 6);
+ gtk_container_add(GTK_CONTAINER(frame), box);
+
+ button = gtk_check_button_new_with_label("Show SAC");
+ gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button), visible_cols.sac);
+ gtk_box_pack_start(GTK_BOX(box), button, FALSE, FALSE, 6);
+ g_signal_connect(G_OBJECT(button), "toggled", G_CALLBACK(sac_toggle), NULL);
+
+ button = gtk_check_button_new_with_label("Show OTU");
+ gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button), visible_cols.otu);
+ gtk_box_pack_start(GTK_BOX(box), button, FALSE, FALSE, 6);
+ g_signal_connect(G_OBJECT(button), "toggled", G_CALLBACK(otu_toggle), NULL);
+
font = gtk_font_button_new_with_font(divelist_font);
gtk_box_pack_start(GTK_BOX(vbox), font, FALSE, FALSE, 5);
output_units = menu_units;
update_dive_list_units();
repaint_dive();
+ update_dive_list_col_visibility();
gconf_client_set_bool(gconf, GCONF_NAME(feet), output_units.length == FEET, NULL);
gconf_client_set_bool(gconf, GCONF_NAME(psi), output_units.pressure == PSI, NULL);
gconf_client_set_bool(gconf, GCONF_NAME(cuft), output_units.volume == CUFT, NULL);
gconf_client_set_bool(gconf, GCONF_NAME(fahrenheit), output_units.temperature == FAHRENHEIT, NULL);
+ gconf_client_set_bool(gconf, GCONF_NAME(SAC), ! visible_cols.sac, NULL); /* inverted to get the correct default */
+ gconf_client_set_bool(gconf, GCONF_NAME(OTU), visible_cols.otu, NULL);
gconf_client_set_string(gconf, GCONF_NAME(divelist_font), divelist_font, NULL);
}
gtk_widget_destroy(dialog);
repaint_dive();
}
+static const char notebook_group[] = "123";
+#define GRP_ID ((void *)notebook_group)
+
static GtkNotebook *create_new_notebook_window(GtkNotebook *source,
GtkWidget *page,
gint x, gint y, gpointer data)
divelist_window = win = gtk_window_new(GTK_WINDOW_TOPLEVEL);
gtk_window_set_title(GTK_WINDOW(win), "Dive List");
- gtk_window_set_transient_for(GTK_WINDOW(win), GTK_WINDOW(main_window));
- gtk_window_set_destroy_with_parent(GTK_WINDOW(win), 1);
gtk_window_move(GTK_WINDOW(win), x, y);
/* Destroying the dive list will kill the application */
gtk_container_add(GTK_CONTAINER(win), vbox);
notebook = gtk_notebook_new();
- gtk_notebook_set_group_id(GTK_NOTEBOOK(notebook), gtk_notebook_get_group_id(source));
+ gtk_notebook_set_group(GTK_NOTEBOOK(notebook), GRP_ID);
gtk_box_pack_start(GTK_BOX(vbox), notebook, TRUE, TRUE, 6);
gtk_widget_set_size_request(notebook, 350, 250);
return GTK_NOTEBOOK(notebook);
}
+static void drag_cb(GtkWidget *widget, GdkDragContext *context,
+ gint x, gint y,
+ GtkSelectionData *selection_data,
+ guint info, guint time,
+ gpointer user_data)
+{
+ GtkWidget *source, *target;
+ GtkWidget *tab;
+
+ /*
+ * We don't actually really *use* this yet, but Dirk wants to
+ * do all the tabs as detatched tabs, and we'd need to use
+ * this all to figure out which window we're talking about.
+ */
+ source = gtk_drag_get_source_widget(context);
+ target = (GtkWidget *) user_data;
+ tab = *(GtkWidget **)selection_data->data;
+
+ gtk_drag_finish(context, TRUE, TRUE, time);
+
+ /*
+ * Horrible, horrible hack. We hide the old divelist window, and
+ * set it to NULL. So if we drag the thing back out, we'll create
+ * a new window. Ugh.
+ *
+ * Actually destroying the divelist window triggers the whole
+ * destroy callback, which we don't want.
+ */
+ if (source != target) {
+ gtk_widget_hide(divelist_window);
+ divelist_window = NULL;
+ }
+}
+
void init_ui(int argc, char **argv)
{
GtkWidget *win;
GtkWidget *equipment;
GtkWidget *menubar;
GtkWidget *vbox;
+ static const GtkTargetEntry notebook_target = {
+ "GTK_NOTEBOOK_TAB", GTK_TARGET_SAME_APP, 0
+ };
gtk_init(&argc, &argv);
output_units.volume = CUFT;
if (gconf_client_get_bool(gconf, GCONF_NAME(fahrenheit), NULL))
output_units.temperature = FAHRENHEIT;
-
+ /* an unset key is FALSE - so in order to get the default behavior right we
+ invert the meaning of the SAC key */
+ visible_cols.otu = gconf_client_get_bool(gconf, GCONF_NAME(OTU), NULL);
+ visible_cols.sac = ! gconf_client_get_bool(gconf, GCONF_NAME(SAC), NULL);
+
divelist_font = gconf_client_get_string(gconf, GCONF_NAME(divelist_font), NULL);
if (!divelist_font)
divelist_font = DIVELIST_DEFAULT_FONT;
/* Notebook for dive info vs profile vs .. */
notebook = gtk_notebook_new();
gtk_box_pack_start(GTK_BOX(vbox), notebook, TRUE, TRUE, 6);
+ gtk_notebook_set_group(GTK_NOTEBOOK(notebook), GRP_ID);
gtk_notebook_set_window_creation_hook(create_new_notebook_window, NULL, NULL);
+ gtk_drag_dest_set(notebook, GTK_DEST_DEFAULT_ALL, ¬ebook_target, 1, GDK_ACTION_MOVE);
+ g_signal_connect(notebook, "drag-data-received", G_CALLBACK(drag_cb), notebook);
g_signal_connect(notebook, "switch-page", G_CALLBACK(switch_page), NULL);
/* Create the actual divelist */
dive_list = dive_list_create();
gtk_notebook_append_page(GTK_NOTEBOOK(notebook), dive_list, gtk_label_new("Dive List"));
gtk_notebook_set_tab_detachable(GTK_NOTEBOOK(notebook), dive_list, 1);
+ gtk_notebook_set_tab_reorderable(GTK_NOTEBOOK(notebook), dive_list, 1);
/* Frame for dive profile */
dive_profile = dive_profile_widget();