diff options
-rw-r--r-- | gui/common.h | 34 | ||||
-rw-r--r-- | gui/glabel.c | 100 | ||||
-rw-r--r-- | gui/gui.c | 108 | ||||
-rw-r--r-- | gui/gui.h | 2 | ||||
-rw-r--r-- | gui/history.c | 138 | ||||
-rw-r--r-- | gui/index.c | 106 | ||||
-rw-r--r-- | gui/progress.c | 36 | ||||
-rw-r--r-- | gui/render.c | 134 | ||||
-rw-r--r-- | gui/sheet.c | 336 | ||||
-rw-r--r-- | main.c | 2 |
10 files changed, 498 insertions, 498 deletions
diff --git a/gui/common.h b/gui/common.h index cf03953..a64ab70 100644 --- a/gui/common.h +++ b/gui/common.h @@ -31,7 +31,7 @@ struct gui_hist; struct gui_sheet { const struct sheet *sch; - struct gui_ctx *ctx; /* back link */ + struct gui_ctx *gui; /* back link */ struct gui_hist *hist; /* back link */ struct gfx *gfx; struct gfx *gfx_extra; @@ -55,7 +55,7 @@ struct gui_sheet { }; struct gui_hist { - struct gui_ctx *ctx; /* back link */ + struct gui_ctx *gui; /* back link */ struct hist *vcs_hist; /* NULL if not from repo */ struct overlay *over; /* current overlay */ struct gui_sheet *sheets; /* NULL if failed */ @@ -137,8 +137,8 @@ struct gui_ctx { /* progress.c */ -void setup_progress_bar(struct gui_ctx *ctx, GtkWidget *window); -void progress_update(struct gui_ctx *ctx); +void setup_progress_bar(struct gui_ctx *gui, GtkWidget *window); +void progress_update(struct gui_ctx *gui); /* render.c */ @@ -146,37 +146,37 @@ extern bool use_delta; extern bool show_extra; -void redraw(const struct gui_ctx *ctx); +void redraw(const struct gui_ctx *gui); void render_sheet(struct gui_sheet *sheet); -void render_delta(struct gui_ctx *ctx); -void render_setup(struct gui_ctx *ctx); +void render_delta(struct gui_ctx *gui); +void render_setup(struct gui_ctx *gui); /* glabel.c */ -void dehover_glabel(struct gui_ctx *ctx); +void dehover_glabel(struct gui_ctx *gui); void add_glabel_aoi(struct gui_sheet *sheet, const struct sch_obj *obj); /* sheet.c */ -void go_to_sheet(struct gui_ctx *ctx, struct gui_sheet *sheet); -void zoom_to_extents(struct gui_ctx *ctx); -void do_revision_overlays(struct gui_ctx *ctx); -void sheet_setup(struct gui_ctx *ctx); +void go_to_sheet(struct gui_ctx *gui, struct gui_sheet *sheet); +void zoom_to_extents(struct gui_ctx *gui); +void do_revision_overlays(struct gui_ctx *gui); +void sheet_setup(struct gui_ctx *gui); /* history.c */ -void show_history(struct gui_ctx *ctx, enum selecting sel); +void show_history(struct gui_ctx *gui, enum selecting sel); /* index.c */ -void index_draw_event(const struct gui_ctx *ctx, cairo_t *cr); -void index_resize(struct gui_ctx *ctx); -void show_index(struct gui_ctx *ctx); +void index_draw_event(const struct gui_ctx *gui, cairo_t *cr); +void index_resize(struct gui_ctx *gui); +void show_index(struct gui_ctx *gui); /* gui.c */ struct gui_sheet *find_corresponding_sheet(struct gui_sheet *pick_from, struct gui_sheet *ref_in, const struct gui_sheet *ref); -void mark_aois(struct gui_ctx *ctx, struct gui_sheet *sheet); +void mark_aois(struct gui_ctx *gui, struct gui_sheet *sheet); #endif /* !GUI_COMMON_H */ diff --git a/gui/glabel.c b/gui/glabel.c index fba5e04..fb0cc82 100644 --- a/gui/glabel.c +++ b/gui/glabel.c @@ -43,14 +43,14 @@ struct glabel_aoi_ctx { /* ----- Tools ------------------------------------------------------------- */ -static void eeschema_coord(const struct gui_ctx *ctx, +static void eeschema_coord(const struct gui_ctx *gui, int x, int y, int *rx, int *ry) { GtkAllocation alloc; - gtk_widget_get_allocation(ctx->da, &alloc); - *rx = ((x - ctx->x) * ctx->scale) + alloc.width / 2; - *ry = ((y - ctx->y) * ctx->scale) + alloc.height / 2; + gtk_widget_get_allocation(gui->da, &alloc); + *rx = ((x - gui->x) * gui->scale) + alloc.width / 2; + *ry = ((y - gui->y) * gui->scale) + alloc.height / 2; } @@ -61,20 +61,20 @@ static void glabel_dest_click(void *user) { struct gui_sheet *sheet = user; - go_to_sheet(sheet->ctx, sheet); + go_to_sheet(sheet->gui, sheet); } -void dehover_glabel(struct gui_ctx *ctx) +void dehover_glabel(struct gui_ctx *gui) { - overlay_remove_all(&ctx->pop_overlays); - overlay_remove_all(&ctx->pop_underlays); - ctx->pop_origin = NULL; - redraw(ctx); + overlay_remove_all(&gui->pop_overlays); + overlay_remove_all(&gui->pop_underlays); + gui->pop_origin = NULL; + redraw(gui); } -static void add_dest_header(struct gui_ctx *ctx, const char *label) +static void add_dest_header(struct gui_ctx *gui, const char *label) { struct overlay_style style = { .font = BOLD_FONT, @@ -90,13 +90,13 @@ static void add_dest_header(struct gui_ctx *ctx, const char *label) }; struct overlay *over; - over = overlay_add(&ctx->pop_overlays, NULL, NULL, NULL, NULL); + over = overlay_add(&gui->pop_overlays, NULL, NULL, NULL, NULL); overlay_text(over, "%s", label); overlay_style(over, &style); } -static void add_dest_overlay(struct gui_ctx *ctx, const char *label, +static void add_dest_overlay(struct gui_ctx *gui, const char *label, struct gui_sheet *sheet, unsigned n) { struct overlay_style style = { @@ -114,7 +114,7 @@ static void add_dest_overlay(struct gui_ctx *ctx, const char *label, const struct sch_obj *obj; struct overlay *over; - if (sheet == ctx->curr_sheet) + if (sheet == gui->curr_sheet) style.fg = RGBA(0.5, 0.5, 0.5, 1.0); for (obj = sheet->sch->objs; obj; obj = obj->next) { @@ -122,8 +122,8 @@ static void add_dest_overlay(struct gui_ctx *ctx, const char *label, continue; if (strcmp(obj->u.text.s, label)) continue; - over = overlay_add(&ctx->pop_overlays, - &ctx->aois, NULL, glabel_dest_click, sheet); + over = overlay_add(&gui->pop_overlays, + &gui->aois, NULL, glabel_dest_click, sheet); overlay_text(over, "%d %s", n, sheet->sch->title ? sheet->sch->title : "(unnamed)"); overlay_style(over, &style); @@ -134,20 +134,20 @@ static void add_dest_overlay(struct gui_ctx *ctx, const char *label, static bool pop_hover(void *user, bool on, int dx, int dy) { - struct gui_ctx *ctx = user; + struct gui_ctx *gui = user; if (!on) - dehover_glabel(ctx); + dehover_glabel(gui); return 1; } -static void add_dest_frame(struct gui_ctx *ctx) +static void add_dest_frame(struct gui_ctx *gui) { int w, h; - overlay_size_all(ctx->pop_overlays, - gtk_widget_get_pango_context(ctx->da), 0, 1, &w, &h); + overlay_size_all(gui->pop_overlays, + gtk_widget_get_pango_context(gui->da), 0, 1, &w, &h); struct overlay_style style = { .font = BOLD_FONT, @@ -163,8 +163,8 @@ static void add_dest_frame(struct gui_ctx *ctx) }; struct overlay *over; - over = overlay_add(&ctx->pop_underlays, &ctx->aois, - pop_hover, NULL, ctx); + over = overlay_add(&gui->pop_underlays, &gui->aois, + pop_hover, NULL, gui); overlay_text_raw(over, ""); overlay_style(over, &style); @@ -180,25 +180,25 @@ static void add_dest_frame(struct gui_ctx *ctx) * We solve this by declaring the frame overlay to be "related" to the * destination overlays. This suppresses dehovering. */ - overlay_set_related_all(ctx->pop_overlays, over); + overlay_set_related_all(gui->pop_overlays, over); } static bool hover_glabel(void *user, bool on, int dx, int dy) { struct glabel_aoi_ctx *aoi_ctx = user; - struct gui_ctx *ctx = aoi_ctx->sheet->ctx; - const struct gui_sheet *curr_sheet = ctx->curr_sheet; + struct gui_ctx *gui = aoi_ctx->sheet->gui; + const struct gui_sheet *curr_sheet = gui->curr_sheet; const struct dwg_bbox *bbox = &aoi_ctx->bbox; if (!on) { - dehover_glabel(ctx); + dehover_glabel(gui); return 1; } - if (ctx->pop_underlays) { - if (ctx->pop_origin == aoi_ctx) + if (gui->pop_underlays) { + if (gui->pop_origin == aoi_ctx) return 0; - dehover_glabel(ctx); + dehover_glabel(gui); } GtkAllocation alloc; @@ -206,40 +206,40 @@ static bool hover_glabel(void *user, bool on, int dx, int dy) unsigned n = 0; struct gui_sheet *sheet; - ctx->glabel = aoi_ctx->obj->u.text.s; - ctx->pop_origin = aoi_ctx; + gui->glabel = aoi_ctx->obj->u.text.s; + gui->pop_origin = aoi_ctx; aoi_dehover(); - overlay_remove_all(&ctx->pop_overlays); - overlay_remove_all(&ctx->pop_underlays); + overlay_remove_all(&gui->pop_overlays); + overlay_remove_all(&gui->pop_underlays); - add_dest_header(ctx, aoi_ctx->obj->u.text.s); - for (sheet = ctx->new_hist->sheets; sheet; sheet = sheet->next) - add_dest_overlay(ctx, aoi_ctx->obj->u.text.s, sheet, ++n); - add_dest_frame(ctx); + add_dest_header(gui, aoi_ctx->obj->u.text.s); + for (sheet = gui->new_hist->sheets; sheet; sheet = sheet->next) + add_dest_overlay(gui, aoi_ctx->obj->u.text.s, sheet, ++n); + add_dest_frame(gui); - eeschema_coord(ctx, + eeschema_coord(gui, bbox->x - curr_sheet->xmin, bbox->y - curr_sheet->ymin, &sx, &sy); - eeschema_coord(ctx, bbox->x + bbox->w - curr_sheet->xmin, + eeschema_coord(gui, bbox->x + bbox->w - curr_sheet->xmin, bbox->y + bbox->h - curr_sheet->ymin, &ex, &ey); - gtk_widget_get_allocation(ctx->da, &alloc); + gtk_widget_get_allocation(gui->da, &alloc); mx = (sx + ex) / 2; my = (sy + ey) / 2; if (mx < alloc.width / 2) { - ctx->pop_x = sx - CHEAT; - ctx->pop_dx = 1; + gui->pop_x = sx - CHEAT; + gui->pop_dx = 1; } else { - ctx->pop_x = ex + CHEAT; - ctx->pop_dx = -1; + gui->pop_x = ex + CHEAT; + gui->pop_dx = -1; } if (my < alloc.height / 2) { - ctx->pop_y = sy - CHEAT; - ctx->pop_dy = 1; + gui->pop_y = sy - CHEAT; + gui->pop_dy = 1; } else { - ctx->pop_y = ey + CHEAT; - ctx->pop_dy = -1; + gui->pop_y = ey + CHEAT; + gui->pop_dy = -1; } /* @@ -276,7 +276,7 @@ static bool hover_glabel(void *user, bool on, int dx, int dy) * - pressing Escape. */ input_update(); - redraw(ctx); + redraw(gui); return 0; } @@ -86,40 +86,40 @@ struct sheet_aoi_ctx { static void select_subsheet(void *user) { const struct sheet_aoi_ctx *aoi_ctx = user; - struct gui_ctx *ctx = aoi_ctx->gui_ctx; + struct gui_ctx *gui = aoi_ctx->gui_ctx; const struct sch_obj *obj = aoi_ctx->obj; struct gui_sheet *sheet; if (!obj->u.sheet.sheet) return; - if (!ctx->old_hist || ctx->diff_mode != diff_old) { - for (sheet = ctx->new_hist->sheets; sheet; sheet = sheet->next) + if (!gui->old_hist || gui->diff_mode != diff_old) { + for (sheet = gui->new_hist->sheets; sheet; sheet = sheet->next) if (sheet->sch == obj->u.sheet.sheet) { - go_to_sheet(ctx, sheet); + go_to_sheet(gui, sheet); return; } BUG("new sheet not found"); } - for (sheet = ctx->old_hist->sheets; sheet; sheet = sheet->next) + for (sheet = gui->old_hist->sheets; sheet; sheet = sheet->next) if (sheet->sch == obj->u.sheet.sheet) goto found; BUG("old sheet not found"); found: - sheet = find_corresponding_sheet(ctx->new_hist->sheets, - ctx->old_hist->sheets, sheet); - go_to_sheet(ctx, sheet); + sheet = find_corresponding_sheet(gui->new_hist->sheets, + gui->old_hist->sheets, sheet); + go_to_sheet(gui, sheet); } -static void add_sheet_aoi(struct gui_ctx *ctx, struct gui_sheet *parent, +static void add_sheet_aoi(struct gui_ctx *gui, struct gui_sheet *parent, const struct sch_obj *obj) { struct sheet_aoi_ctx *aoi_ctx = alloc_type(struct sheet_aoi_ctx); - aoi_ctx->gui_ctx = ctx; + aoi_ctx->gui_ctx = gui; aoi_ctx->obj = obj; struct aoi aoi = { @@ -138,7 +138,7 @@ static void add_sheet_aoi(struct gui_ctx *ctx, struct gui_sheet *parent, /* ----- Load revisions ---------------------------------------------------- */ -void mark_aois(struct gui_ctx *ctx, struct gui_sheet *sheet) +void mark_aois(struct gui_ctx *gui, struct gui_sheet *sheet) { const struct sch_obj *obj; @@ -146,7 +146,7 @@ void mark_aois(struct gui_ctx *ctx, struct gui_sheet *sheet) for (obj = sheet->sch->objs; obj; obj = obj->next) switch (obj->type) { case sch_obj_sheet: - add_sheet_aoi(ctx, sheet, obj); + add_sheet_aoi(gui, sheet, obj); break; case sch_obj_glabel: add_glabel_aoi(sheet, obj); @@ -156,7 +156,7 @@ void mark_aois(struct gui_ctx *ctx, struct gui_sheet *sheet) } -static struct gui_sheet *get_sheets(struct gui_ctx *ctx, struct gui_hist *hist, +static struct gui_sheet *get_sheets(struct gui_ctx *gui, struct gui_hist *hist, const struct sheet *sheets) { const struct sheet *sheet; @@ -167,7 +167,7 @@ static struct gui_sheet *get_sheets(struct gui_ctx *ctx, struct gui_hist *hist, for (sheet = sheets; sheet; sheet = sheet->next) { new = alloc_type(struct gui_sheet); new->sch = sheet; - new->ctx = ctx; + new->gui = gui; new->hist = hist; new->gfx_thumb = NULL; new->thumb_surf = NULL; @@ -337,7 +337,7 @@ fail: struct add_hist_ctx { - struct gui_ctx *ctx; + struct gui_ctx *gui; const struct file_names *fn; bool recurse; unsigned limit; @@ -347,7 +347,7 @@ struct add_hist_ctx { static void add_hist(void *user, struct hist *h) { struct add_hist_ctx *ahc = user; - struct gui_ctx *ctx = ahc->ctx; + struct gui_ctx *gui = ahc->gui; struct gui_hist **anchor, *hist, *prev; const struct sheet *sch; unsigned age = 0; @@ -358,41 +358,41 @@ static void add_hist(void *user, struct hist *h) ahc->limit--; prev = NULL; - for (anchor = &ctx->hist; *anchor; anchor = &(*anchor)->next) { + for (anchor = &gui->hist; *anchor; anchor = &(*anchor)->next) { prev = *anchor; age++; } hist = alloc_type(struct gui_hist); - hist->ctx = ctx; + hist->gui = gui; hist->vcs_hist = h; hist->libs_open = 0; hist->identical = 0; hist->pl = NULL; sch = parse_files(hist, ahc->fn, ahc->recurse, prev); - hist->sheets = sch ? get_sheets(ctx, hist, sch) : NULL; + hist->sheets = sch ? get_sheets(gui, hist, sch) : NULL; hist->age = age; hist->next = NULL; *anchor = hist; - if (ctx->hist_size) - progress_update(ctx); + if (gui->hist_size) + progress_update(gui); } -static void get_revisions(struct gui_ctx *ctx, const struct file_names *fn, +static void get_revisions(struct gui_ctx *gui, const struct file_names *fn, bool recurse, int limit) { struct add_hist_ctx add_hist_ctx = { - .ctx = ctx, + .gui = gui, .fn = fn, .recurse = recurse, .limit = limit ? limit < 0 ? -limit : limit : -1, }; - if (ctx->vcs_hist) - hist_iterate(ctx->vcs_hist, add_hist, &add_hist_ctx); + if (gui->vcs_hist) + hist_iterate(gui->vcs_hist, add_hist, &add_hist_ctx); else add_hist(&add_hist_ctx, NULL); } @@ -403,24 +403,24 @@ static void get_revisions(struct gui_ctx *ctx, const struct file_names *fn, static void count_history(void *user, struct hist *h) { - struct gui_ctx *ctx = user; + struct gui_ctx *gui = user; - ctx->hist_size++; + gui->hist_size++; } -static void get_history(struct gui_ctx *ctx, const char *sch_name, int limit) +static void get_history(struct gui_ctx *gui, const char *sch_name, int limit) { if (!vcs_git_try(sch_name)) { - ctx->vcs_hist = NULL; + gui->vcs_hist = NULL; return; } - ctx->vcs_hist = vcs_git_hist(sch_name); + gui->vcs_hist = vcs_git_hist(sch_name); if (limit) - ctx->hist_size = limit > 0 ? limit : -limit; + gui->hist_size = limit > 0 ? limit : -limit; else - hist_iterate(ctx->vcs_hist, count_history, ctx); + hist_iterate(gui->vcs_hist, count_history, gui); } @@ -430,22 +430,22 @@ static void get_history(struct gui_ctx *ctx, const char *sch_name, int limit) static void size_allocate_event(GtkWidget *widget, GdkRectangle *allocation, gpointer data) { - struct gui_ctx *ctx = data; + struct gui_ctx *gui = data; - zoom_to_extents(ctx); - if (ctx->mode == showing_index) - index_resize(ctx); + zoom_to_extents(gui); + if (gui->mode == showing_index) + index_resize(gui); } /* ----- Initialization ---------------------------------------------------- */ -int gui(const struct file_names *fn, bool recurse, int limit) +int run_gui(const struct file_names *fn, bool recurse, int limit) { GtkWidget *window; char *title; - struct gui_ctx ctx = { + struct gui_ctx gui = { .scale = 1 / 16.0, .hist = NULL, .vcs_hist = NULL, @@ -465,42 +465,42 @@ int gui(const struct file_names *fn, bool recurse, int limit) }; window = gtk_window_new(GTK_WINDOW_TOPLEVEL); - ctx.da = gtk_drawing_area_new(); - gtk_container_add(GTK_CONTAINER(window), ctx.da); + gui.da = gtk_drawing_area_new(); + gtk_container_add(GTK_CONTAINER(window), gui.da); gtk_window_set_default_size(GTK_WINDOW(window), 640, 480); if (asprintf(&title, "eeshow (rev %s)", version)) {}; gtk_window_set_title(GTK_WINDOW(window), title); - gtk_widget_set_events(ctx.da, + gtk_widget_set_events(gui.da, GDK_EXPOSE | GDK_ENTER_NOTIFY_MASK | GDK_LEAVE_NOTIFY_MASK); - input_setup(ctx.da); + input_setup(gui.da); gtk_widget_show_all(window); - get_history(&ctx, fn->pro ? fn->pro : fn->sch, limit); - if (ctx.hist_size) - setup_progress_bar(&ctx, window); + get_history(&gui, fn->pro ? fn->pro : fn->sch, limit); + if (gui.hist_size) + setup_progress_bar(&gui, window); - get_revisions(&ctx, fn, recurse, limit); - for (ctx.new_hist = ctx.hist; ctx.new_hist && !ctx.new_hist->sheets; - ctx.new_hist = ctx.new_hist->next); - if (!ctx.new_hist) + get_revisions(&gui, fn, recurse, limit); + for (gui.new_hist = gui.hist; gui.new_hist && !gui.new_hist->sheets; + gui.new_hist = gui.new_hist->next); + if (!gui.new_hist) fatal("no valid sheets\n"); - g_signal_connect(G_OBJECT(ctx.da), "size_allocate", - G_CALLBACK(size_allocate_event), &ctx); + g_signal_connect(G_OBJECT(gui.da), "size_allocate", + G_CALLBACK(size_allocate_event), &gui); g_signal_connect(window, "destroy", G_CALLBACK(gtk_main_quit), NULL); icons_init(); - sheet_setup(&ctx); - render_setup(&ctx); + sheet_setup(&gui); + render_setup(&gui); // gtk_window_set_position(GTK_WINDOW(window), GTK_WIN_POS_CENTER); - go_to_sheet(&ctx, ctx.new_hist->sheets); + go_to_sheet(&gui, gui.new_hist->sheets); gtk_widget_show_all(window); /* for performance testing, use -N-depth */ @@ -18,6 +18,6 @@ #include "kicad/ext.h" -int gui(const struct file_names *fn, bool recurse, int limit); +int run_gui(const struct file_names *fn, bool recurse, int limit); #endif /* !GUI_GUI_H */ diff --git a/gui/history.c b/gui/history.c index 52b5e61..0399878 100644 --- a/gui/history.c +++ b/gui/history.c @@ -28,28 +28,28 @@ #include "gui/common.h" -static void hide_history(struct gui_ctx *ctx) +static void hide_history(struct gui_ctx *gui) { input_pop(); - ctx->mode = showing_sheet; - do_revision_overlays(ctx); - redraw(ctx); + gui->mode = showing_sheet; + do_revision_overlays(gui); + redraw(gui); } static void set_history_style(struct gui_hist *h, bool current) { - struct gui_ctx *ctx = h->ctx; + struct gui_ctx *gui = h->gui; struct overlay_style style = overlay_style_dense; - const struct gui_hist *new = ctx->new_hist; - const struct gui_hist *old = ctx->old_hist; + const struct gui_hist *new = gui->new_hist; + const struct gui_hist *old = gui->old_hist; /* this is in addition to showing detailed content */ if (current) style.width++; - switch (ctx->selecting) { + switch (gui->selecting) { case sel_only: case sel_split: style.frame = COLOR(FRAME_SEL_ONLY); @@ -61,14 +61,14 @@ static void set_history_style(struct gui_hist *h, bool current) style.frame = COLOR(FRAME_SEL_NEW); break; default: - BUG("invalid mode %d", ctx->selecting); + BUG("invalid mode %d", gui->selecting); } - if (ctx->new_hist == h || ctx->old_hist == h) { + if (gui->new_hist == h || gui->old_hist == h) { style.width++; style.font = BOLD_FONT; } - if (ctx->old_hist) { + if (gui->old_hist) { if (h == new) style.bg = COLOR(BG_NEW); if (h == old) @@ -109,12 +109,12 @@ static void set_history_style(struct gui_hist *h, bool current) static bool hover_history(void *user, bool on, int dx, int dy) { struct gui_hist *h = user; - struct gui_ctx *ctx = h->ctx; + struct gui_ctx *gui = h->gui; char *s; int before, after; if (dy) - overlay_size(h->over, gtk_widget_get_pango_context(ctx->da), + overlay_size(h->over, gtk_widget_get_pango_context(gui->da), NULL, &before); if (on) { s = vcs_git_long_for_pango(h->vcs_hist, fmt_pango); @@ -126,15 +126,15 @@ static bool hover_history(void *user, bool on, int dx, int dy) } set_history_style(h, on); if (dy) - overlay_size(h->over, gtk_widget_get_pango_context(ctx->da), + overlay_size(h->over, gtk_widget_get_pango_context(gui->da), NULL, &after); if (dy < 0 && on) - ctx->hist_y_offset -= after - before; + gui->hist_y_offset -= after - before; if (dy > 0 && !on) - ctx->hist_y_offset -= after - before; + gui->hist_y_offset -= after - before; - redraw(ctx); + redraw(gui); return 1; } @@ -142,64 +142,64 @@ static bool hover_history(void *user, bool on, int dx, int dy) static void click_history(void *user) { struct gui_hist *h = user; - struct gui_ctx *ctx = h->ctx; + struct gui_ctx *gui = h->gui; struct gui_sheet *sheet, *old_sheet; - hide_history(ctx); + hide_history(gui); if (!h->sheets) return; sheet = find_corresponding_sheet(h->sheets, - ctx->new_hist->sheets, ctx->curr_sheet); + gui->new_hist->sheets, gui->curr_sheet); old_sheet = find_corresponding_sheet( - ctx->old_hist ? ctx->old_hist->sheets : ctx->new_hist->sheets, - ctx->new_hist->sheets, ctx->curr_sheet); + gui->old_hist ? gui->old_hist->sheets : gui->new_hist->sheets, + gui->new_hist->sheets, gui->curr_sheet); - switch (ctx->selecting) { + switch (gui->selecting) { case sel_only: - ctx->new_hist = h; + gui->new_hist = h; break; case sel_split: - ctx->old_hist = ctx->new_hist; - ctx->new_hist = h; + gui->old_hist = gui->new_hist; + gui->new_hist = h; break; case sel_new: - ctx->new_hist = h; + gui->new_hist = h; break; case sel_old: - ctx->old_hist = h; + gui->old_hist = h; break; default: - BUG("invalid mode %d", ctx->selecting); + BUG("invalid mode %d", gui->selecting); } - ctx->diff_mode = diff_delta; + gui->diff_mode = diff_delta; - if (ctx->old_hist) { - if (ctx->new_hist->age > ctx->old_hist->age) { - swap(ctx->new_hist, ctx->old_hist); - if (ctx->selecting == sel_old) { - go_to_sheet(ctx, sheet); + if (gui->old_hist) { + if (gui->new_hist->age > gui->old_hist->age) { + swap(gui->new_hist, gui->old_hist); + if (gui->selecting == sel_old) { + go_to_sheet(gui, sheet); } else { - go_to_sheet(ctx, old_sheet); - render_delta(ctx); + go_to_sheet(gui, old_sheet); + render_delta(gui); } } else { - if (ctx->selecting != sel_old) - go_to_sheet(ctx, sheet); + if (gui->selecting != sel_old) + go_to_sheet(gui, sheet); else - render_delta(ctx); + render_delta(gui); } } else { - go_to_sheet(ctx, sheet); + go_to_sheet(gui, sheet); } - if (ctx->old_hist == ctx->new_hist) - ctx->old_hist = NULL; + if (gui->old_hist == gui->new_hist) + gui->old_hist = NULL; - do_revision_overlays(ctx); - redraw(ctx); + do_revision_overlays(gui); + redraw(gui); } @@ -208,13 +208,13 @@ static void ignore_click(void *user) } -static struct gui_hist *skip_history(struct gui_ctx *ctx, struct gui_hist *h) +static struct gui_hist *skip_history(struct gui_ctx *gui, struct gui_hist *h) { struct overlay_style style = overlay_style_dense; unsigned n; /* don't skip the first entry */ - if (h == ctx->hist) + if (h == gui->hist) return h; /* need at least two entries */ @@ -225,7 +225,7 @@ static struct gui_hist *skip_history(struct gui_ctx *ctx, struct gui_hist *h) for (n = 0; h->next && h->identical; h = h->next) n++; - h->over = overlay_add(&ctx->hist_overlays, &ctx->aois, + h->over = overlay_add(&gui->hist_overlays, &gui->aois, NULL, ignore_click, h); overlay_text(h->over, "<small>%u commits without changes</small>", n); @@ -243,39 +243,39 @@ static struct gui_hist *skip_history(struct gui_ctx *ctx, struct gui_hist *h) static bool history_click(void *user, int x, int y) { - struct gui_ctx *ctx = user; + struct gui_ctx *gui = user; - if (aoi_click(&ctx->aois, x, y)) + if (aoi_click(&gui->aois, x, y)) return 1; - hide_history(ctx); + hide_history(gui); return 1; } static bool history_hover_update(void *user, int x, int y) { - struct gui_ctx *ctx = user; + struct gui_ctx *gui = user; - return aoi_hover(&ctx->aois, x, y); + return aoi_hover(&gui->aois, x, y); } static void history_drag_move(void *user, int dx, int dy) { - struct gui_ctx *ctx = user; + struct gui_ctx *gui = user; - ctx->hist_y_offset += dy; - redraw(ctx); + gui->hist_y_offset += dy; + redraw(gui); } static void history_key(void *user, int x, int y, int keyval) { - struct gui_ctx *ctx = user; + struct gui_ctx *gui = user; switch (keyval) { case GDK_KEY_Escape: - hide_history(ctx); + hide_history(gui); break; case GDK_KEY_q: gtk_main_quit(); @@ -297,22 +297,22 @@ static const struct input_ops history_input_ops = { /* ----- Invocation -------------------------------------------------------- */ -void show_history(struct gui_ctx *ctx, enum selecting sel) +void show_history(struct gui_ctx *gui, enum selecting sel) { - struct gui_hist *h = ctx->hist; + struct gui_hist *h = gui->hist; - input_push(&history_input_ops, ctx); + input_push(&history_input_ops, gui); - ctx->mode = showing_history; - ctx->hist_y_offset = 0; - ctx->selecting = sel; - overlay_remove_all(&ctx->hist_overlays); - for (h = ctx->hist; h; h = h->next) { - h = skip_history(ctx, h); - h->over = overlay_add(&ctx->hist_overlays, &ctx->aois, + gui->mode = showing_history; + gui->hist_y_offset = 0; + gui->selecting = sel; + overlay_remove_all(&gui->hist_overlays); + for (h = gui->hist; h; h = h->next) { + h = skip_history(gui, h); + h->over = overlay_add(&gui->hist_overlays, &gui->aois, hover_history, click_history, h); set_history_style(h, 0); hover_history(h, 0, 0, 0); } - redraw(ctx); + redraw(gui); } diff --git a/gui/index.c b/gui/index.c index a3324a5..3673312 100644 --- a/gui/index.c +++ b/gui/index.c @@ -43,7 +43,7 @@ static const struct gui_sheet *curr_sheet = NULL; /* ----- Tools ------------------------------------------------------------- */ -static void thumbnail_pos(const struct gui_ctx *ctx, GtkAllocation *alloc, +static void thumbnail_pos(const struct gui_ctx *gui, GtkAllocation *alloc, unsigned n, int *ix, int *iy) { *ix = alloc->width / 2 + (thumb_w + SHEET_GAP) * @@ -56,16 +56,16 @@ static void thumbnail_pos(const struct gui_ctx *ctx, GtkAllocation *alloc, /* ----- Drawing ----------------------------------------------------------- */ -static struct gui_sheet *sheets(const struct gui_ctx *ctx) +static struct gui_sheet *sheets(const struct gui_ctx *gui) { - if (ctx->old_hist && ctx->diff_mode == diff_old) - return ctx->old_hist->sheets; + if (gui->old_hist && gui->diff_mode == diff_old) + return gui->old_hist->sheets; else - return ctx->new_hist->sheets; + return gui->new_hist->sheets; } -void index_draw_event(const struct gui_ctx *ctx, cairo_t *cr) +void index_draw_event(const struct gui_ctx *gui, cairo_t *cr) { GtkAllocation alloc; const struct gui_sheet *sheet; @@ -74,14 +74,14 @@ void index_draw_event(const struct gui_ctx *ctx, cairo_t *cr) int w, h; int named = -1; - gtk_widget_get_allocation(ctx->da, &alloc); + gtk_widget_get_allocation(gui->da, &alloc); cairo_set_source_rgba(cr, 1, 1, 1, 0.7); cairo_paint(cr); n = 0; - for (sheet = sheets(ctx); sheet; sheet = sheet->next) { - thumbnail_pos(sheet->ctx, &alloc, n, &ix, &iy); + for (sheet = sheets(gui); sheet; sheet = sheet->next) { + thumbnail_pos(sheet->gui, &alloc, n, &ix, &iy); x = ix - thumb_w / 2 - SHEET_PAD; y = iy - thumb_h / 2 - SHEET_PAD; @@ -94,9 +94,9 @@ void index_draw_event(const struct gui_ctx *ctx, cairo_t *cr) if (named == -1) return; - thumbnail_pos(curr_sheet->ctx, &alloc, named, &ix, &iy); + thumbnail_pos(curr_sheet->gui, &alloc, named, &ix, &iy); overlay_size(name_over, - gtk_widget_get_pango_context(curr_sheet->ctx->da), &w, &h); + gtk_widget_get_pango_context(curr_sheet->gui->da), &w, &h); x = ix - w / 2; if (x < INDEX_MARGIN) x = INDEX_MARGIN; @@ -109,23 +109,23 @@ void index_draw_event(const struct gui_ctx *ctx, cairo_t *cr) /* ----- Thumbnail actions ------------------------------------------------- */ -static void close_index(struct gui_ctx *ctx) +static void close_index(struct gui_ctx *gui) { - overlay_remove_all(&ctx->thumb_overlays); + overlay_remove_all(&gui->thumb_overlays); name_over = NULL; - ctx->mode = showing_sheet; + gui->mode = showing_sheet; input_pop(); - redraw(ctx); + redraw(gui); } static void thumb_click(void *user) { struct gui_sheet *sheet = user; - struct gui_ctx *ctx = sheet->ctx; + struct gui_ctx *gui = sheet->gui; - go_to_sheet(ctx, sheet); - close_index(ctx); + go_to_sheet(gui, sheet); + close_index(gui); } @@ -153,13 +153,13 @@ static void thumb_set_style(struct gui_sheet *sheet, bool selected) static bool thumb_hover(void *user, bool on, int dx, int dy) { struct gui_sheet *sheet = user; - struct gui_ctx *ctx = sheet->ctx; + struct gui_ctx *gui = sheet->gui; struct overlay_style style = overlay_style_default; if (on) { thumb_set_style(sheet, 1); - name_over = overlay_add(&ctx->thumb_overlays, &ctx->aois, + name_over = overlay_add(&gui->thumb_overlays, &gui->aois, NULL, NULL, NULL); if (sheet->sch && sheet->sch->title) overlay_text(name_over, "%s", sheet->sch->title); @@ -172,10 +172,10 @@ static bool thumb_hover(void *user, bool on, int dx, int dy) curr_sheet = sheet; } else { thumb_set_style(sheet, 0); - overlay_remove(&ctx->thumb_overlays, name_over); + overlay_remove(&gui->thumb_overlays, name_over); name_over = NULL; } - redraw(ctx); + redraw(gui); return 1; } @@ -183,7 +183,7 @@ static bool thumb_hover(void *user, bool on, int dx, int dy) /* ----- Rendering to cache ------------------------------------------------ */ -static bool best_ratio(const struct gui_ctx *ctx) +static bool best_ratio(const struct gui_ctx *gui) { GtkAllocation alloc; const struct gui_sheet *sheet; @@ -193,9 +193,9 @@ static bool best_ratio(const struct gui_ctx *ctx) int aw, ah; /* available size */ int w, h; - gtk_widget_get_allocation(ctx->da, &alloc); + gtk_widget_get_allocation(gui->da, &alloc); - for (sheet = sheets(ctx); sheet; sheet = sheet->next) + for (sheet = sheets(gui); sheet; sheet = sheet->next) n++; assert(n); @@ -256,7 +256,7 @@ static void paint_yellow(uint32_t *data, int w, int h, int stride) } -static void index_render_sheet(const struct gui_ctx *ctx, +static void index_render_sheet(const struct gui_ctx *gui, struct gui_sheet *sheet) { int xmin, ymin, w, h; @@ -273,11 +273,11 @@ static void index_render_sheet(const struct gui_ctx *ctx, NULL, NULL, NULL, NULL); } - if (ctx->old_hist && ctx->diff_mode == diff_delta) { + if (gui->old_hist && gui->diff_mode == diff_delta) { const struct gui_sheet *old; - old = find_corresponding_sheet(ctx->old_hist->sheets, - ctx->new_hist->sheets, sheet); + old = find_corresponding_sheet(gui->old_hist->sheets, + gui->new_hist->sheets, sheet); if (!sheet_eq(sheet->sch, old->sch)) yellow = 1; } @@ -317,22 +317,22 @@ static void index_render_sheet(const struct gui_ctx *ctx, } -static void index_add_overlay(struct gui_ctx *ctx, struct gui_sheet *sheet) +static void index_add_overlay(struct gui_ctx *gui, struct gui_sheet *sheet) { - sheet->thumb_over = overlay_add(&ctx->thumb_overlays, &ctx->aois, + sheet->thumb_over = overlay_add(&gui->thumb_overlays, &gui->aois, thumb_hover, thumb_click, sheet); overlay_icon(sheet->thumb_over, sheet->thumb_surf); thumb_set_style(sheet, 0); } -static void index_render_sheets(struct gui_ctx *ctx) +static void index_render_sheets(struct gui_ctx *gui) { struct gui_sheet *sheet; - for (sheet = sheets(ctx); sheet; sheet = sheet->next) { - index_render_sheet(ctx, sheet); - index_add_overlay(ctx, sheet); + for (sheet = sheets(gui); sheet; sheet = sheet->next) { + index_render_sheet(gui, sheet); + index_add_overlay(gui, sheet); } } @@ -342,9 +342,9 @@ static void index_render_sheets(struct gui_ctx *ctx) static bool index_hover_update(void *user, int x, int y) { - struct gui_ctx *ctx = user; + struct gui_ctx *gui = user; - if (aoi_hover(&ctx->aois, x, y)) + if (aoi_hover(&gui->aois, x, y)) return 1; return 0; } @@ -352,24 +352,24 @@ static bool index_hover_update(void *user, int x, int y) static bool index_click(void *user, int x, int y) { - struct gui_ctx *ctx = user; + struct gui_ctx *gui = user; - if (aoi_click(&ctx->aois, x, y)) + if (aoi_click(&gui->aois, x, y)) return 1; - close_index(ctx); + close_index(gui); return 1; } static void index_key(void *user, int x, int y, int keyval) { - struct gui_ctx *ctx = user; + struct gui_ctx *gui = user; switch (keyval) { case GDK_KEY_Escape: - ctx->mode = showing_sheet; + gui->mode = showing_sheet; input_pop(); - redraw(ctx); + redraw(gui); break; case GDK_KEY_h: @@ -395,24 +395,24 @@ static const struct input_ops index_input_ops = { /* ----- Resizing ---------------------------------------------------------- */ -void index_resize(struct gui_ctx *ctx) +void index_resize(struct gui_ctx *gui) { - overlay_remove_all(&ctx->thumb_overlays); + overlay_remove_all(&gui->thumb_overlays); name_over = NULL; - if (best_ratio(ctx)) - index_render_sheets(ctx); + if (best_ratio(gui)) + index_render_sheets(gui); else - close_index(ctx); - redraw(ctx); + close_index(gui); + redraw(gui); } /* ----- Initialization ---------------------------------------------------- */ -void show_index(struct gui_ctx *ctx) +void show_index(struct gui_ctx *gui) { - input_push(&index_input_ops, ctx); - ctx->mode = showing_index; - index_resize(ctx); + input_push(&index_input_ops, gui); + gui->mode = showing_index; + index_resize(gui); } diff --git a/gui/progress.c b/gui/progress.c index b7f1d39..07e4bb1 100644 --- a/gui/progress.c +++ b/gui/progress.c @@ -36,18 +36,18 @@ static void progress_draw_event(GtkWidget *widget, cairo_t *cr, gpointer user_data) { GtkAllocation alloc; - struct gui_ctx *ctx = user_data; + struct gui_ctx *gui = user_data; unsigned w, x; - x = ctx->progress >> ctx->progress_scale; + x = gui->progress >> gui->progress_scale; if (!x) { /* @@@ needed ? Gtk seems to always clear the the surface. */ cairo_set_source_rgb(cr, 1, 1, 1); cairo_paint(cr); } - gtk_widget_get_allocation(ctx->da, &alloc); - w = ctx->hist_size >> ctx->progress_scale; + gtk_widget_get_allocation(gui->da, &alloc); + w = gui->hist_size >> gui->progress_scale; cairo_save(cr); cairo_translate(cr, @@ -67,33 +67,33 @@ static void progress_draw_event(GtkWidget *widget, cairo_t *cr, } -void setup_progress_bar(struct gui_ctx *ctx, GtkWidget *window) +void setup_progress_bar(struct gui_ctx *gui, GtkWidget *window) { GtkAllocation alloc; - gtk_widget_get_allocation(ctx->da, &alloc); + gtk_widget_get_allocation(gui->da, &alloc); - ctx->progress_scale = 0; - while ((ctx->hist_size >> ctx->progress_scale) > alloc.width) - ctx->progress_scale++; - ctx->progress = 0; + gui->progress_scale = 0; + while ((gui->hist_size >> gui->progress_scale) > alloc.width) + gui->progress_scale++; + gui->progress = 0; - g_signal_connect(G_OBJECT(ctx->da), "draw", - G_CALLBACK(progress_draw_event), ctx); + g_signal_connect(G_OBJECT(gui->da), "draw", + G_CALLBACK(progress_draw_event), gui); - redraw(ctx); + redraw(gui); gtk_main_iteration_do(0); } -void progress_update(struct gui_ctx *ctx) +void progress_update(struct gui_ctx *gui) { - unsigned mask = (1 << ctx->progress_scale) - 1; + unsigned mask = (1 << gui->progress_scale) - 1; - ctx->progress++; - if ((ctx->progress & mask) != mask) + gui->progress++; + if ((gui->progress & mask) != mask) return; - redraw(ctx); + redraw(gui); gtk_main_iteration_do(0); } diff --git a/gui/render.c b/gui/render.c index 214b7b2..6de8baa 100644 --- a/gui/render.c +++ b/gui/render.c @@ -49,9 +49,9 @@ bool show_extra = 0; /* ----- Helper functions -------------------------------------------------- */ -void redraw(const struct gui_ctx *ctx) +void redraw(const struct gui_ctx *gui) { - gtk_widget_queue_draw(ctx->da); + gtk_widget_queue_draw(gui->da); } @@ -82,12 +82,12 @@ static inline int cy(int y, int yo, float scale) } -static void highlight_glabel(const struct gui_ctx *ctx, +static void highlight_glabel(const struct gui_ctx *gui, const struct gui_sheet *sheet, cairo_t *cr, int xo, int yo, float f) { const struct sch_obj *obj; - if (!ctx->glabel) + if (!gui->glabel) return; cairo_set_source_rgb(cr, 1, 0.8, 1); @@ -96,7 +96,7 @@ static void highlight_glabel(const struct gui_ctx *ctx, if (obj->type != sch_obj_glabel) continue; - if (strcmp(obj->u.text.s, ctx->glabel)) + if (strcmp(obj->u.text.s, gui->glabel)) continue; cairo_rectangle(cr, @@ -119,10 +119,10 @@ static void highlight_glabel(const struct gui_ctx *ctx, * delta. */ -static struct area *changed_sheets(const struct gui_ctx *ctx, +static struct area *changed_sheets(const struct gui_ctx *gui, int xo, int yo, float f) { - const struct gui_sheet *new = ctx->curr_sheet; + const struct gui_sheet *new = gui->curr_sheet; const struct sch_obj *obj; struct area *areas = NULL; @@ -135,13 +135,13 @@ static struct area *changed_sheets(const struct gui_ctx *ctx, if (!obj->u.sheet.sheet) continue; - for (new_sub = ctx->new_hist->sheets; + for (new_sub = gui->new_hist->sheets; new_sub && new_sub->sch != obj->u.sheet.sheet; new_sub = new_sub->next); if (!new_sub) continue; - old_sub = find_corresponding_sheet(ctx->old_hist->sheets, - ctx->new_hist->sheets, new_sub); + old_sub = find_corresponding_sheet(gui->old_hist->sheets, + gui->new_hist->sheets, new_sub); if (!sheet_eq(new_sub->sch, old_sub->sch)) add_area(&areas, cx(obj->x, xo, f), cy(obj->y, yo, f), @@ -152,16 +152,16 @@ static struct area *changed_sheets(const struct gui_ctx *ctx, } -static void hack(const struct gui_ctx *ctx, cairo_t *cr, +static void hack(const struct gui_ctx *gui, cairo_t *cr, int xo, int yo, float f) { - const struct gui_sheet *new = ctx->curr_sheet; + const struct gui_sheet *new = gui->curr_sheet; const struct gui_sheet *old = find_corresponding_sheet( - ctx->old_hist->sheets, ctx->new_hist->sheets, ctx->curr_sheet); + gui->old_hist->sheets, gui->new_hist->sheets, gui->curr_sheet); struct area *areas = NULL; - areas = changed_sheets(ctx, xo, yo, f); - diff_to_canvas(cr, ctx->x, ctx->y, ctx->scale, + areas = changed_sheets(gui, xo, yo, f); + diff_to_canvas(cr, gui->x, gui->y, gui->scale, gfx_user(old->gfx), show_extra ? gfx_user(old->gfx_extra) : NULL, gfx_user(new->gfx), show_extra ? gfx_user(new->gfx_extra) : NULL, areas); @@ -172,33 +172,33 @@ static void hack(const struct gui_ctx *ctx, cairo_t *cr, static gboolean on_draw_event(GtkWidget *widget, cairo_t *cr, gpointer user_data) { - struct gui_ctx *ctx = user_data; - const struct gui_sheet *sheet = ctx->curr_sheet; + struct gui_ctx *gui = user_data; + const struct gui_sheet *sheet = gui->curr_sheet; GtkAllocation alloc; - float f = ctx->scale; + float f = gui->scale; int x, y; - gtk_widget_get_allocation(ctx->da, &alloc); - x = -(sheet->xmin + ctx->x) * f + alloc.width / 2; - y = -(sheet->ymin + ctx->y) * f + alloc.height / 2; + gtk_widget_get_allocation(gui->da, &alloc); + x = -(sheet->xmin + gui->x) * f + alloc.width / 2; + y = -(sheet->ymin + gui->y) * f + alloc.height / 2; cro_canvas_prepare(cr); - if (!ctx->old_hist || ctx->diff_mode == diff_new) { - highlight_glabel(ctx, sheet, cr, x, y, f); + if (!gui->old_hist || gui->diff_mode == diff_new) { + highlight_glabel(gui, sheet, cr, x, y, f); if (show_extra) cro_canvas_draw(gfx_user(sheet->gfx_extra), cr, x, y, f); cro_canvas_draw(gfx_user(sheet->gfx), cr, x, y, f); - } else if (ctx->diff_mode == diff_old) { - sheet = find_corresponding_sheet(ctx->old_hist->sheets, - ctx->new_hist->sheets, ctx->curr_sheet); - highlight_glabel(ctx, sheet, cr, x, y, f); + } else if (gui->diff_mode == diff_old) { + sheet = find_corresponding_sheet(gui->old_hist->sheets, + gui->new_hist->sheets, gui->curr_sheet); + highlight_glabel(gui, sheet, cr, x, y, f); if (show_extra) cro_canvas_draw(gfx_user(sheet->gfx_extra), cr, x, y, f); cro_canvas_draw(gfx_user(sheet->gfx), cr, x, y, f); } else if (use_delta) { - struct area *areas = changed_sheets(ctx, x, y, f); + struct area *areas = changed_sheets(gui, x, y, f); const struct area *area; cairo_set_source_rgb(cr, 1, 1, 0); @@ -211,36 +211,36 @@ static gboolean on_draw_event(GtkWidget *widget, cairo_t *cr, /* @@@ fix geometry later */ if (show_extra) { - cro_canvas_draw(gfx_user(ctx->delta_ab.gfx_extra), + cro_canvas_draw(gfx_user(gui->delta_ab.gfx_extra), cr, x, y, f); - cro_canvas_draw(gfx_user(ctx->delta_a.gfx_extra), + cro_canvas_draw(gfx_user(gui->delta_a.gfx_extra), cr, x, y, f); - cro_canvas_draw(gfx_user(ctx->delta_b.gfx_extra), + cro_canvas_draw(gfx_user(gui->delta_b.gfx_extra), cr, x, y, f); } - cro_canvas_draw(gfx_user(ctx->delta_ab.gfx), cr, x, y, f); - cro_canvas_draw(gfx_user(ctx->delta_a.gfx), cr, x, y, f); - cro_canvas_draw(gfx_user(ctx->delta_b.gfx), cr, x, y, f); + cro_canvas_draw(gfx_user(gui->delta_ab.gfx), cr, x, y, f); + cro_canvas_draw(gfx_user(gui->delta_a.gfx), cr, x, y, f); + cro_canvas_draw(gfx_user(gui->delta_b.gfx), cr, x, y, f); } else { - hack(ctx, cr, x, y, f); + hack(gui, cr, x, y, f); } - overlay_draw_all(ctx->sheet_overlays, cr, + overlay_draw_all(gui->sheet_overlays, cr, SHEET_OVERLAYS_X, SHEET_OVERLAYS_Y); - overlay_draw_all_d(ctx->hist_overlays, cr, + overlay_draw_all_d(gui->hist_overlays, cr, VCS_OVERLAYS_X, VCS_OVERLAYS_Y + - (ctx->mode == showing_history ? ctx->hist_y_offset : 0), + (gui->mode == showing_history ? gui->hist_y_offset : 0), 0, 1); - overlay_draw_all_d(ctx->pop_underlays, cr, ctx->pop_x, ctx->pop_y, - ctx->pop_dx, ctx->pop_dy); - overlay_draw_all_d(ctx->pop_overlays, cr, - ctx->pop_x + ctx->pop_dx * GLABEL_STACK_PADDING, - ctx->pop_y + ctx->pop_dy * GLABEL_STACK_PADDING, - ctx->pop_dx, ctx->pop_dy); + overlay_draw_all_d(gui->pop_underlays, cr, gui->pop_x, gui->pop_y, + gui->pop_dx, gui->pop_dy); + overlay_draw_all_d(gui->pop_overlays, cr, + gui->pop_x + gui->pop_dx * GLABEL_STACK_PADDING, + gui->pop_y + gui->pop_dy * GLABEL_STACK_PADDING, + gui->pop_dx, gui->pop_dy); - if (ctx->mode == showing_index) - index_draw_event(ctx, cr); + if (gui->mode == showing_index) + index_draw_event(gui, cr); timer_show(cr); @@ -270,45 +270,45 @@ void render_sheet(struct gui_sheet *sheet) } -void render_delta(struct gui_ctx *ctx) +void render_delta(struct gui_ctx *gui) { #if 1 /* @@@ needs updating for curr/last vs. new/old */ struct sheet *sch_a, *sch_b, *sch_ab; - struct gui_sheet *a = ctx->curr_sheet; + struct gui_sheet *a = gui->curr_sheet; struct gui_sheet *b = find_corresponding_sheet( - ctx->old_hist->sheets, ctx->new_hist->sheets, ctx->curr_sheet); + gui->old_hist->sheets, gui->new_hist->sheets, gui->curr_sheet); sch_a = alloc_type(struct sheet); sch_b = alloc_type(struct sheet); sch_ab = alloc_type(struct sheet); delta(a->sch, b->sch, sch_a, sch_b, sch_ab); - ctx->delta_a.sch = sch_a, - ctx->delta_b.sch = sch_b, - ctx->delta_ab.sch = sch_ab, + gui->delta_a.sch = sch_a, + gui->delta_b.sch = sch_b, + gui->delta_ab.sch = sch_ab, - ctx->delta_a.ctx = ctx->delta_b.ctx = ctx->delta_ab.ctx = NULL; - ctx->delta_a.hist = ctx->delta_b.hist = ctx->delta_ab.hist = NULL; + gui->delta_a.gui = gui->delta_b.gui = gui->delta_ab.gui = NULL; + gui->delta_a.hist = gui->delta_b.hist = gui->delta_ab.hist = NULL; - render_sheet(&ctx->delta_a); - render_sheet(&ctx->delta_b); - render_sheet(&ctx->delta_ab); + render_sheet(&gui->delta_a); + render_sheet(&gui->delta_b); + render_sheet(&gui->delta_ab); - cro_color_override(gfx_user(ctx->delta_ab.gfx), COLOR_LIGHT_GREY); - cro_color_override(gfx_user(ctx->delta_b.gfx), COLOR_RED); - cro_color_override(gfx_user(ctx->delta_a.gfx), COLOR_GREEN2); + cro_color_override(gfx_user(gui->delta_ab.gfx), COLOR_LIGHT_GREY); + cro_color_override(gfx_user(gui->delta_b.gfx), COLOR_RED); + cro_color_override(gfx_user(gui->delta_a.gfx), COLOR_GREEN2); - cro_color_override(gfx_user(ctx->delta_ab.gfx_extra), COLOR_LIGHT_GREY); - cro_color_override(gfx_user(ctx->delta_b.gfx_extra), COLOR_RED); - cro_color_override(gfx_user(ctx->delta_a.gfx_extra), COLOR_GREEN2); + cro_color_override(gfx_user(gui->delta_ab.gfx_extra), COLOR_LIGHT_GREY); + cro_color_override(gfx_user(gui->delta_b.gfx_extra), COLOR_RED); + cro_color_override(gfx_user(gui->delta_a.gfx_extra), COLOR_GREEN2); // @@@ clean up when leaving sheet #endif if (!b->rendered) { render_sheet(b); - mark_aois(ctx, b); + mark_aois(gui, b); } } @@ -316,8 +316,8 @@ void render_delta(struct gui_ctx *ctx) /* ----- Setup ------------------------------------------------------------- */ -void render_setup(struct gui_ctx *ctx) +void render_setup(struct gui_ctx *gui) { - g_signal_connect(G_OBJECT(ctx->da), "draw", - G_CALLBACK(on_draw_event), ctx); + g_signal_connect(G_OBJECT(gui->da), "draw", + G_CALLBACK(on_draw_event), gui); } diff --git a/gui/sheet.c b/gui/sheet.c index dc9676b..9499908 100644 --- a/gui/sheet.c +++ b/gui/sheet.c @@ -39,69 +39,69 @@ /* ----- Tools ------------------------------------------------------------- */ -static void canvas_coord(const struct gui_ctx *ctx, +static void canvas_coord(const struct gui_ctx *gui, int ex, int ey, int *x, int *y) { GtkAllocation alloc; int sx, sy; - gtk_widget_get_allocation(ctx->da, &alloc); + gtk_widget_get_allocation(gui->da, &alloc); sx = ex - alloc.width / 2; sy = ey - alloc.height / 2; - *x = sx / ctx->scale + ctx->x; - *y = sy / ctx->scale + ctx->y; + *x = sx / gui->scale + gui->x; + *y = sy / gui->scale + gui->y; } /* ----- Zoom -------------------------------------------------------------- */ -static bool zoom_in(struct gui_ctx *ctx, int x, int y) +static bool zoom_in(struct gui_ctx *gui, int x, int y) { - float old = ctx->scale; + float old = gui->scale; - if (ctx->scale == ZOOM_MAX) + if (gui->scale == ZOOM_MAX) return 0; - ctx->scale *= ZOOM_FACTOR; - if (ctx->scale > ZOOM_MAX) - ctx->scale = ZOOM_MAX; - ctx->x = x + (ctx->x - x) * old / ctx->scale; - ctx->y = y + (ctx->y - y) * old / ctx->scale; - redraw(ctx); + gui->scale *= ZOOM_FACTOR; + if (gui->scale > ZOOM_MAX) + gui->scale = ZOOM_MAX; + gui->x = x + (gui->x - x) * old / gui->scale; + gui->y = y + (gui->y - y) * old / gui->scale; + redraw(gui); return 1; } -static bool zoom_out(struct gui_ctx *ctx, int x, int y) +static bool zoom_out(struct gui_ctx *gui, int x, int y) { - float old = ctx->scale; + float old = gui->scale; - if (ctx->curr_sheet->w * ctx->scale <= ZOOM_MIN_SIZE) + if (gui->curr_sheet->w * gui->scale <= ZOOM_MIN_SIZE) return 0; - ctx->scale /= ZOOM_FACTOR; - if (ctx->curr_sheet->w <= ZOOM_MIN_SIZE) - ctx->scale = 1; - else if (ctx->curr_sheet->w * ctx->scale <= ZOOM_MIN_SIZE ) - ctx->scale = (float) ZOOM_MIN_SIZE / ctx->curr_sheet->w; - ctx->x = x + (ctx->x - x) * old / ctx->scale; - ctx->y = y + (ctx->y - y) * old / ctx->scale; - redraw(ctx); + gui->scale /= ZOOM_FACTOR; + if (gui->curr_sheet->w <= ZOOM_MIN_SIZE) + gui->scale = 1; + else if (gui->curr_sheet->w * gui->scale <= ZOOM_MIN_SIZE ) + gui->scale = (float) ZOOM_MIN_SIZE / gui->curr_sheet->w; + gui->x = x + (gui->x - x) * old / gui->scale; + gui->y = y + (gui->y - y) * old / gui->scale; + redraw(gui); return 1; } -static void curr_sheet_size(struct gui_ctx *ctx, int *w, int *h) +static void curr_sheet_size(struct gui_ctx *gui, int *w, int *h) { - const struct gui_sheet *sheet = ctx->curr_sheet; + const struct gui_sheet *sheet = gui->curr_sheet; int ax1, ay1, bx1, by1; - if (!ctx->old_hist) { + if (!gui->old_hist) { *w = sheet->w; *h = sheet->h; } else { const struct gui_sheet *old = - find_corresponding_sheet(ctx->old_hist->sheets, - ctx->new_hist->sheets, sheet); + find_corresponding_sheet(gui->old_hist->sheets, + gui->new_hist->sheets, sheet); /* * We're only interested in differences here, so no need for @@ -119,23 +119,23 @@ static void curr_sheet_size(struct gui_ctx *ctx, int *w, int *h) } -void zoom_to_extents(struct gui_ctx *ctx) +void zoom_to_extents(struct gui_ctx *gui) { GtkAllocation alloc; int w, h; float sw, sh; - curr_sheet_size(ctx, &w, &h); - ctx->x = w / 2; - ctx->y = h / 2; + curr_sheet_size(gui, &w, &h); + gui->x = w / 2; + gui->y = h / 2; - gtk_widget_get_allocation(ctx->da, &alloc); + gtk_widget_get_allocation(gui->da, &alloc); sw = w ? (float) ZOOM_MARGIN * alloc.width / w : 1; sh = h ? (float) ZOOM_MARGIN * alloc.height / h : 1; - ctx->scale = sw < sh ? sw : sh; + gui->scale = sw < sh ? sw : sh; - redraw(ctx); + redraw(gui); } @@ -145,7 +145,7 @@ void zoom_to_extents(struct gui_ctx *ctx) static bool show_history_details(void *user, bool on, int dx, int dy) { struct gui_hist *h = user; - struct gui_ctx *ctx = h->ctx; + struct gui_ctx *gui = h->gui; char *s; if (on) { @@ -155,67 +155,67 @@ static bool show_history_details(void *user, bool on, int dx, int dy) } else { overlay_text(h->over, "%.40s", vcs_git_summary(h->vcs_hist)); } - redraw(ctx); + redraw(gui); return 1; } -static void set_diff_mode(struct gui_ctx *ctx, enum diff_mode mode) +static void set_diff_mode(struct gui_ctx *gui, enum diff_mode mode) { - ctx->diff_mode = mode; - do_revision_overlays(ctx); - redraw(ctx); + gui->diff_mode = mode; + do_revision_overlays(gui); + redraw(gui); } static void show_history_cb(void *user) { struct gui_hist *h = user; - struct gui_ctx *ctx = h->ctx; + struct gui_ctx *gui = h->gui; enum selecting sel = sel_only; - if (ctx->old_hist) { - if (h == ctx->new_hist && ctx->diff_mode != diff_new) { - set_diff_mode(ctx, diff_new); + if (gui->old_hist) { + if (h == gui->new_hist && gui->diff_mode != diff_new) { + set_diff_mode(gui, diff_new); return; } - if (h == ctx->old_hist && ctx->diff_mode != diff_old) { - set_diff_mode(ctx, diff_old); + if (h == gui->old_hist && gui->diff_mode != diff_old) { + set_diff_mode(gui, diff_old); return; } - sel = h == ctx->new_hist ? sel_new : sel_old; + sel = h == gui->new_hist ? sel_new : sel_old; } - show_history(ctx, sel); + show_history(gui, sel); } static void show_diff_cb(void *user) { - struct gui_ctx *ctx = user; + struct gui_ctx *gui = user; - if (ctx->old_hist) - set_diff_mode(ctx, - ctx->diff_mode == diff_delta ? diff_new : diff_delta); + if (gui->old_hist) + set_diff_mode(gui, + gui->diff_mode == diff_delta ? diff_new : diff_delta); else - show_history(ctx, sel_split); + show_history(gui, sel_split); } -static void toggle_old_new(struct gui_ctx *ctx) +static void toggle_old_new(struct gui_ctx *gui) { - set_diff_mode(ctx, ctx->diff_mode == diff_new ? diff_old : diff_new); + set_diff_mode(gui, gui->diff_mode == diff_new ? diff_old : diff_new); } -static void add_delta(struct gui_ctx *ctx) +static void add_delta(struct gui_ctx *gui) { struct overlay *over; struct overlay_style style; - over = overlay_add(&ctx->hist_overlays, &ctx->aois, - NULL, show_diff_cb, ctx); + over = overlay_add(&gui->hist_overlays, &gui->aois, + NULL, show_diff_cb, gui); style = overlay_style_default; - if (ctx->old_hist && ctx->diff_mode == diff_delta) + if (gui->old_hist && gui->diff_mode == diff_delta) style.frame = RGBA(0, 0, 0, 1); style.pad = 4; overlay_style(over, &style); @@ -226,46 +226,46 @@ static void add_delta(struct gui_ctx *ctx) } -static void revision_overlays_diff(struct gui_ctx *ctx) +static void revision_overlays_diff(struct gui_ctx *gui) { - struct gui_hist *new = ctx->new_hist; - struct gui_hist *old = ctx->old_hist; + struct gui_hist *new = gui->new_hist; + struct gui_hist *old = gui->old_hist; struct overlay_style style; - new->over = overlay_add(&ctx->hist_overlays, &ctx->aois, + new->over = overlay_add(&gui->hist_overlays, &gui->aois, show_history_details, show_history_cb, new); style = overlay_style_diff_new; - if (ctx->diff_mode == diff_new) + if (gui->diff_mode == diff_new) style.frame = RGBA(0, 0, 0, 1); overlay_style(new->over, &style); show_history_details(new, 0, 0, 0); - add_delta(ctx); + add_delta(gui); - old->over = overlay_add(&ctx->hist_overlays, &ctx->aois, + old->over = overlay_add(&gui->hist_overlays, &gui->aois, show_history_details, show_history_cb, old); style = overlay_style_diff_old; - if (ctx->diff_mode == diff_old) + if (gui->diff_mode == diff_old) style.frame = RGBA(0, 0, 0, 1); overlay_style(old->over, &style); show_history_details(old, 0, 0, 0); } -void do_revision_overlays(struct gui_ctx *ctx) +void do_revision_overlays(struct gui_ctx *gui) { - overlay_remove_all(&ctx->hist_overlays); + overlay_remove_all(&gui->hist_overlays); - if (ctx->old_hist) { - revision_overlays_diff(ctx); + if (gui->old_hist) { + revision_overlays_diff(gui); } else { - ctx->new_hist->over = overlay_add(&ctx->hist_overlays, - &ctx->aois, show_history_details, show_history_cb, - ctx->new_hist); - overlay_style(ctx->new_hist->over, &overlay_style_default); - show_history_details(ctx->new_hist, 0, 0, 0); + gui->new_hist->over = overlay_add(&gui->hist_overlays, + &gui->aois, show_history_details, show_history_cb, + gui->new_hist); + overlay_style(gui->new_hist->over, &overlay_style_default); + show_history_details(gui->new_hist, 0, 0, 0); - add_delta(ctx); + add_delta(gui); } } @@ -291,21 +291,21 @@ static struct gui_sheet *find_parent_sheet(struct gui_sheet *sheets, static void close_subsheet(void *user) { struct gui_sheet *sheet = user; - struct gui_ctx *ctx = sheet->ctx; + struct gui_ctx *gui = sheet->gui; struct gui_sheet *parent; - parent = find_parent_sheet(ctx->new_hist->sheets, sheet); + parent = find_parent_sheet(gui->new_hist->sheets, sheet); if (parent) - go_to_sheet(ctx, parent); + go_to_sheet(gui, parent); else - show_index(ctx); + show_index(gui); } static bool hover_sheet(void *user, bool on, int dx, int dy) { struct gui_sheet *sheet = user; - struct gui_ctx *ctx = sheet->ctx; + struct gui_ctx *gui = sheet->gui; const char *title = sheet->sch->title; if (!title) @@ -314,7 +314,7 @@ static bool hover_sheet(void *user, bool on, int dx, int dy) const struct gui_sheet *s; int n = 0, this = -1; - for (s = ctx->new_hist->sheets; s; s = s->next) { + for (s = gui->new_hist->sheets; s; s = s->next) { n++; if (s == sheet) this = n; @@ -324,83 +324,83 @@ static bool hover_sheet(void *user, bool on, int dx, int dy) } else { overlay_text(sheet->over, "<b>%s</b>", title); } - redraw(ctx); + redraw(gui); return 1; } -static void sheet_selector_recurse(struct gui_ctx *ctx, struct gui_sheet *sheet) +static void sheet_selector_recurse(struct gui_ctx *gui, struct gui_sheet *sheet) { struct gui_sheet *parent; - parent = find_parent_sheet(ctx->new_hist->sheets, sheet); + parent = find_parent_sheet(gui->new_hist->sheets, sheet); if (parent) - sheet_selector_recurse(ctx, parent); - sheet->over = overlay_add(&ctx->sheet_overlays, &ctx->aois, + sheet_selector_recurse(gui, parent); + sheet->over = overlay_add(&gui->sheet_overlays, &gui->aois, hover_sheet, close_subsheet, sheet); hover_sheet(sheet, 0, 0, 0); } -static void do_sheet_overlays(struct gui_ctx *ctx) +static void do_sheet_overlays(struct gui_ctx *gui) { - overlay_remove_all(&ctx->sheet_overlays); - sheet_selector_recurse(ctx, ctx->curr_sheet); + overlay_remove_all(&gui->sheet_overlays); + sheet_selector_recurse(gui, gui->curr_sheet); } /* ----- Navigate sheets --------------------------------------------------- */ -void go_to_sheet(struct gui_ctx *ctx, struct gui_sheet *sheet) +void go_to_sheet(struct gui_ctx *gui, struct gui_sheet *sheet) { aoi_dehover(); - overlay_remove_all(&ctx->pop_overlays); - overlay_remove_all(&ctx->pop_underlays); + overlay_remove_all(&gui->pop_overlays); + overlay_remove_all(&gui->pop_underlays); if (!sheet->rendered) { render_sheet(sheet); - mark_aois(ctx, sheet); + mark_aois(gui, sheet); } - ctx->curr_sheet = sheet; - if (ctx->old_hist) - render_delta(ctx); - if (ctx->vcs_hist) - do_revision_overlays(ctx); - do_sheet_overlays(ctx); - zoom_to_extents(ctx); + gui->curr_sheet = sheet; + if (gui->old_hist) + render_delta(gui); + if (gui->vcs_hist) + do_revision_overlays(gui); + do_sheet_overlays(gui); + zoom_to_extents(gui); } -static bool go_up_sheet(struct gui_ctx *ctx) +static bool go_up_sheet(struct gui_ctx *gui) { struct gui_sheet *parent; - parent = find_parent_sheet(ctx->new_hist->sheets, ctx->curr_sheet); + parent = find_parent_sheet(gui->new_hist->sheets, gui->curr_sheet); if (!parent) return 0; - go_to_sheet(ctx, parent); + go_to_sheet(gui, parent); return 1; } -static bool go_prev_sheet(struct gui_ctx *ctx) +static bool go_prev_sheet(struct gui_ctx *gui) { struct gui_sheet *sheet; - for (sheet = ctx->new_hist->sheets; sheet; sheet = sheet->next) - if (sheet->next && sheet->next == ctx->curr_sheet) { - go_to_sheet(ctx, sheet); + for (sheet = gui->new_hist->sheets; sheet; sheet = sheet->next) + if (sheet->next && sheet->next == gui->curr_sheet) { + go_to_sheet(gui, sheet); return 1; } return 0; } -static bool go_next_sheet(struct gui_ctx *ctx) +static bool go_next_sheet(struct gui_ctx *gui) { - if (!ctx->curr_sheet->next) + if (!gui->curr_sheet->next) return 0; - go_to_sheet(ctx, ctx->curr_sheet->next); + go_to_sheet(gui, gui->curr_sheet->next); return 1; } @@ -410,42 +410,42 @@ static bool go_next_sheet(struct gui_ctx *ctx) static bool sheet_click(void *user, int x, int y) { - struct gui_ctx *ctx = user; - const struct gui_sheet *curr_sheet = ctx->curr_sheet; + struct gui_ctx *gui = user; + const struct gui_sheet *curr_sheet = gui->curr_sheet; int ex, ey; - canvas_coord(ctx, x, y, &ex, &ey); + canvas_coord(gui, x, y, &ex, &ey); - if (ctx->old_hist && ctx->diff_mode == diff_old) - curr_sheet = find_corresponding_sheet(ctx->old_hist->sheets, - ctx->new_hist->sheets, ctx->curr_sheet); + if (gui->old_hist && gui->diff_mode == diff_old) + curr_sheet = find_corresponding_sheet(gui->old_hist->sheets, + gui->new_hist->sheets, gui->curr_sheet); - if (aoi_click(&ctx->aois, x, y)) + if (aoi_click(&gui->aois, x, y)) return 1; if (aoi_click(&curr_sheet->aois, ex + curr_sheet->xmin, ey + curr_sheet->ymin)) return 1; - overlay_remove_all(&ctx->pop_overlays); - overlay_remove_all(&ctx->pop_underlays); - redraw(ctx); + overlay_remove_all(&gui->pop_overlays); + overlay_remove_all(&gui->pop_underlays); + redraw(gui); return 1; } static bool sheet_hover_update(void *user, int x, int y) { - struct gui_ctx *ctx = user; - const struct gui_sheet *curr_sheet = ctx->curr_sheet; + struct gui_ctx *gui = user; + const struct gui_sheet *curr_sheet = gui->curr_sheet; int ex, ey; - canvas_coord(ctx, x, y, &ex, &ey); + canvas_coord(gui, x, y, &ex, &ey); - if (ctx->old_hist && ctx->diff_mode == diff_old) - curr_sheet = find_corresponding_sheet(ctx->old_hist->sheets, - ctx->new_hist->sheets, ctx->curr_sheet); + if (gui->old_hist && gui->diff_mode == diff_old) + curr_sheet = find_corresponding_sheet(gui->old_hist->sheets, + gui->new_hist->sheets, gui->curr_sheet); - if (aoi_hover(&ctx->aois, x, y)) + if (aoi_hover(&gui->aois, x, y)) return 1; return aoi_hover(&curr_sheet->aois, ex + curr_sheet->xmin, ey + curr_sheet->ymin); @@ -461,11 +461,11 @@ static bool sheet_drag_begin(void *user, int x, int y) static void sheet_drag_move(void *user, int dx, int dy) { - struct gui_ctx *ctx = user; + struct gui_ctx *gui = user; - ctx->x -= dx / ctx->scale; - ctx->y -= dy / ctx->scale; - redraw(ctx); + gui->x -= dx / gui->scale; + gui->y -= dy / gui->scale; + redraw(gui); } @@ -477,105 +477,105 @@ static void sheet_drag_end(void *user) static void sheet_scroll(void *user, int x, int y, int dy) { - struct gui_ctx *ctx = user; + struct gui_ctx *gui = user; int ex, ey; - canvas_coord(ctx, x, y, &ex, &ey); + canvas_coord(gui, x, y, &ex, &ey); if (dy < 0) { - if (!zoom_in(ctx, ex, ey)) + if (!zoom_in(gui, ex, ey)) return; } else { - if (!zoom_out(ctx, ex, ey)) + if (!zoom_out(gui, ex, ey)) return; } - dehover_glabel(ctx); + dehover_glabel(gui); input_update(); } static void sheet_key(void *user, int x, int y, int keyval) { - struct gui_ctx *ctx = user; - struct gui_sheet *sheet = ctx->curr_sheet; + struct gui_ctx *gui = user; + struct gui_sheet *sheet = gui->curr_sheet; int ex, ey; - canvas_coord(ctx, x, y, &ex, &ey); + canvas_coord(gui, x, y, &ex, &ey); switch (keyval) { case '+': case '=': case GDK_KEY_KP_Add: case GDK_KEY_KP_Equal: - zoom_in(ctx, x, y); + zoom_in(gui, x, y); break; case '-': case GDK_KEY_KP_Subtract: - zoom_out(ctx, x, y); + zoom_out(gui, x, y); break; case '*': case GDK_KEY_KP_Multiply: - zoom_to_extents(ctx); + zoom_to_extents(gui); break; case GDK_KEY_Home: case GDK_KEY_KP_Home: - if (sheet != ctx->new_hist->sheets) - go_to_sheet(ctx, ctx->new_hist->sheets); + if (sheet != gui->new_hist->sheets) + go_to_sheet(gui, gui->new_hist->sheets); break; case GDK_KEY_BackSpace: case GDK_KEY_Delete: case GDK_KEY_KP_Delete: - go_up_sheet(ctx); + go_up_sheet(gui); break; case GDK_KEY_Page_Up: case GDK_KEY_KP_Page_Up: - go_prev_sheet(ctx); + go_prev_sheet(gui); break; case GDK_KEY_Page_Down: case GDK_KEY_KP_Page_Down: - go_next_sheet(ctx); + go_next_sheet(gui); break; case GDK_KEY_Up: case GDK_KEY_KP_Up: - show_history(ctx, sel_new); + show_history(gui, sel_new); break; case GDK_KEY_Down: case GDK_KEY_KP_Down: - show_history(ctx, sel_old); + show_history(gui, sel_old); break; case GDK_KEY_Tab: case GDK_KEY_KP_Tab: - toggle_old_new(ctx); + toggle_old_new(gui); break; case GDK_KEY_Escape: dehover_glabel(user); - ctx->glabel = NULL; - redraw(ctx); + gui->glabel = NULL; + redraw(gui); break; case GDK_KEY_a: use_delta = !use_delta; - do_revision_overlays(ctx); - redraw(ctx); + do_revision_overlays(gui); + redraw(gui); break; case GDK_KEY_e: show_extra = !show_extra; - redraw(ctx); + redraw(gui); break; case GDK_KEY_n: - ctx->diff_mode = diff_new; - redraw(ctx); + gui->diff_mode = diff_new; + redraw(gui); break; case GDK_KEY_o: - ctx->diff_mode = diff_old; - redraw(ctx); + gui->diff_mode = diff_old; + redraw(gui); break; case GDK_KEY_d: - ctx->diff_mode = diff_delta; - redraw(ctx); + gui->diff_mode = diff_delta; + redraw(gui); break; case GDK_KEY_h: @@ -585,7 +585,7 @@ static void sheet_key(void *user, int x, int y, int keyval) case GDK_KEY_t: timer_toggle(); - redraw(ctx); + redraw(gui); break; case GDK_KEY_q: @@ -610,7 +610,7 @@ static const struct input_ops sheet_input_ops = { /* ----- Initialization ---------------------------------------------------- */ -void sheet_setup(struct gui_ctx *ctx) +void sheet_setup(struct gui_ctx *gui) { - input_push(&sheet_input_ops, ctx); + input_push(&sheet_input_ops, gui); } @@ -246,7 +246,7 @@ int main(int argc, char **argv) if (!have_dashdash) { optind = 0; /* reset getopt */ - return gui(&file_names, recurse, limit); + return run_gui(&file_names, recurse, limit); } if (file_names.pro) { |