}
g_slist_free(filenames);
report_dives();
- dive_list_update_dives();
}
gtk_widget_destroy(dialog);
}
GtkWidget *equipment;
GtkWidget *menubar;
GtkWidget *vbox;
+ GtkSettings *settings;
static const GtkTargetEntry notebook_target = {
"GTK_NOTEBOOK_TAB", GTK_TARGET_SAME_APP, 0
};
gtk_init(&argc, &argv);
+ settings = gtk_settings_get_default();
+ gtk_settings_set_long_property(settings, "gtk_tooltip_timeout", 10, "subsurface setting");
g_type_init();
gconf = gconf_client_get_default();
gtk_main();
}
+typedef struct {
+ cairo_rectangle_int_t rect;
+ const char *text;
+} tooltip_record_t;
+
+static tooltip_record_t *tooltip_rects;
+static int tooltips;
+
+void attach_tooltip(int x, int y, int w, int h, const char *text)
+{
+ cairo_rectangle_int_t *rect;
+ tooltip_rects = realloc(tooltip_rects, (tooltips + 1) * sizeof(tooltip_record_t));
+ rect = &tooltip_rects[tooltips].rect;
+ rect->x = x;
+ rect->y = y;
+ rect->width = w;
+ rect->height = h;
+ tooltip_rects[tooltips].text = text;
+ tooltips++;
+}
+
+#define INSIDE_RECT(_r,_x,_y) ((_r.x <= _x) && (_r.x + _r.width >= _x) && \
+ (_r.y <= _y) && (_r.y + _r.height >= _y))
+
+static gboolean profile_tooltip (GtkWidget *widget, gint x, gint y,
+ gboolean keyboard_mode, GtkTooltip *tooltip, gpointer user_data)
+{
+ int i;
+ cairo_rectangle_int_t *drawing_area = user_data;
+ gint tx = x - drawing_area->x; /* get transformed coordinates */
+ gint ty = y - drawing_area->y;
+
+ /* are we over an event marker ? */
+ for (i = 0; i < tooltips; i++) {
+ if (INSIDE_RECT(tooltip_rects[i].rect, tx, ty)) {
+ gtk_tooltip_set_text(tooltip,tooltip_rects[i].text);
+ return TRUE; /* show tooltip */
+ }
+ }
+ return FALSE; /* don't show tooltip */
+}
+
static gboolean expose_event(GtkWidget *widget, GdkEventExpose *event, gpointer data)
{
struct dive *dive = current_dive;
struct graphics_context gc = { .printer = 0 };
- int w,h;
+ static cairo_rectangle_int_t drawing_area;
- w = widget->allocation.width;
- h = widget->allocation.height;
+ /* the drawing area gives TOTAL width * height - x,y is used as the topx/topy offset
+ * so effective drawing area is width-2x * height-2y */
+ drawing_area.width = widget->allocation.width;
+ drawing_area.height = widget->allocation.height;
+ drawing_area.x = drawing_area.width / 20.0;
+ drawing_area.y = drawing_area.height / 20.0;
gc.cr = gdk_cairo_create(widget->window);
+ g_object_set(widget, "has-tooltip", TRUE, NULL);
+ g_signal_connect(widget, "query-tooltip", G_CALLBACK(profile_tooltip), &drawing_area);
set_source_rgb(&gc, 0, 0, 0);
cairo_paint(gc.cr);
- if (dive)
- plot(&gc, w, h, dive);
-
+ if (dive) {
+ if (tooltip_rects) {
+ free(tooltip_rects);
+ tooltip_rects = NULL;
+ }
+ tooltips = 0;
+ plot(&gc, &drawing_area, dive);
+ }
cairo_destroy(gc.cr);
return FALSE;
gtk_widget_destroy(dialog);
report_dives();
- dive_list_update_dives();
}
void update_progressbar(progressbar_t *progress, double value)