2016-08-03 13:38:57 +03:00
|
|
|
/*
|
2016-08-18 02:54:25 +03:00
|
|
|
* gui/gui.c - GUI for eeshow
|
2016-08-03 13:38:57 +03:00
|
|
|
*
|
|
|
|
* Written 2016 by Werner Almesberger
|
|
|
|
* Copyright 2016 by Werner Almesberger
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Resources:
|
|
|
|
*
|
|
|
|
* http://zetcode.com/gfx/cairo/cairobackends/
|
|
|
|
* https://developer.gnome.org/gtk3/stable/gtk-migrating-2-to-3.html
|
|
|
|
*/
|
|
|
|
|
2016-08-20 03:30:58 +03:00
|
|
|
#define _GNU_SOURCE /* for asprintf */
|
2016-08-04 01:18:50 +03:00
|
|
|
#include <stddef.h>
|
2016-08-03 18:26:22 +03:00
|
|
|
#include <stdbool.h>
|
2016-08-04 01:18:50 +03:00
|
|
|
#include <stdlib.h>
|
2016-08-20 03:30:58 +03:00
|
|
|
#include <stdio.h>
|
2016-08-11 07:27:59 +03:00
|
|
|
#include <string.h>
|
2016-08-03 15:33:16 +03:00
|
|
|
|
2016-08-03 13:38:57 +03:00
|
|
|
#include <gtk/gtk.h>
|
|
|
|
|
2016-08-20 03:30:58 +03:00
|
|
|
#include "version.h"
|
2016-08-18 03:37:15 +03:00
|
|
|
#include "misc/util.h"
|
|
|
|
#include "misc/diag.h"
|
2016-08-18 03:07:13 +03:00
|
|
|
#include "file/git-hist.h"
|
2016-08-18 03:15:44 +03:00
|
|
|
#include "kicad/lib.h"
|
|
|
|
#include "kicad/sch.h"
|
2016-08-18 03:33:10 +03:00
|
|
|
#include "kicad/delta.h"
|
2016-08-18 02:54:25 +03:00
|
|
|
#include "gui/aoi.h"
|
2016-08-18 07:45:24 +03:00
|
|
|
#include "gui/input.h"
|
2016-08-18 08:48:57 +03:00
|
|
|
#include "gui/common.h"
|
2016-08-21 08:41:19 +03:00
|
|
|
#include "gui/icons.h"
|
2016-08-18 02:54:25 +03:00
|
|
|
#include "gui/gui.h"
|
2016-08-03 13:38:57 +03:00
|
|
|
|
|
|
|
|
2016-08-04 00:49:16 +03:00
|
|
|
/* ----- Helper functions -------------------------------------------------- */
|
|
|
|
|
|
|
|
|
2016-08-18 09:50:43 +03:00
|
|
|
struct gui_sheet *find_corresponding_sheet(struct gui_sheet *pick_from,
|
2016-08-07 20:06:50 +03:00
|
|
|
struct gui_sheet *ref_in, const struct gui_sheet *ref)
|
|
|
|
{
|
|
|
|
struct gui_sheet *sheet, *plan_b;
|
|
|
|
const char *title = ref->sch->title;
|
|
|
|
|
|
|
|
/* plan A: try to find sheet with same name */
|
|
|
|
|
|
|
|
if (title)
|
|
|
|
for (sheet = pick_from; sheet; sheet = sheet->next)
|
|
|
|
if (sheet->sch->title &&
|
|
|
|
!strcmp(title, sheet->sch->title))
|
|
|
|
return sheet;
|
|
|
|
|
|
|
|
/* plan B: use sheet in same position in sheet sequence */
|
|
|
|
|
|
|
|
plan_b = ref_in;
|
|
|
|
for (sheet = pick_from; sheet; sheet = sheet->next) {
|
|
|
|
if (plan_b == ref)
|
|
|
|
return sheet;
|
|
|
|
plan_b = plan_b->next;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* plan C: just go to the top */
|
|
|
|
return pick_from;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-08-18 18:16:13 +03:00
|
|
|
/* ----- AoIs -------------------------------------------------------------- */
|
2016-08-03 18:26:22 +03:00
|
|
|
|
|
|
|
|
2016-08-04 13:19:18 +03:00
|
|
|
struct sheet_aoi_ctx {
|
|
|
|
struct gui_ctx *gui_ctx;
|
|
|
|
const struct sch_obj *obj;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
static void select_subsheet(void *user)
|
2016-08-03 18:26:22 +03:00
|
|
|
{
|
2016-08-04 13:19:18 +03:00
|
|
|
const struct sheet_aoi_ctx *aoi_ctx = user;
|
|
|
|
struct gui_ctx *ctx = aoi_ctx->gui_ctx;
|
|
|
|
const struct sch_obj *obj = aoi_ctx->obj;
|
2016-08-05 01:25:31 +03:00
|
|
|
struct gui_sheet *sheet;
|
2016-08-03 18:26:22 +03:00
|
|
|
|
2016-08-11 07:49:49 +03:00
|
|
|
if (!obj->u.sheet.sheet)
|
|
|
|
return;
|
2016-08-19 18:24:05 +03:00
|
|
|
|
|
|
|
if (!ctx->old_hist || ctx->diff_mode != diff_old) {
|
|
|
|
for (sheet = ctx->new_hist->sheets; sheet; sheet = sheet->next)
|
|
|
|
if (sheet->sch == obj->u.sheet.sheet) {
|
|
|
|
go_to_sheet(ctx, sheet);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
abort();
|
|
|
|
}
|
|
|
|
|
|
|
|
for (sheet = ctx->old_hist->sheets; sheet; sheet = sheet->next)
|
|
|
|
if (sheet->sch == obj->u.sheet.sheet)
|
|
|
|
goto found;
|
2016-08-03 18:26:22 +03:00
|
|
|
abort();
|
2016-08-19 18:24:05 +03:00
|
|
|
|
|
|
|
found:
|
|
|
|
sheet = find_corresponding_sheet(ctx->new_hist->sheets,
|
|
|
|
ctx->old_hist->sheets, sheet);
|
|
|
|
go_to_sheet(ctx, sheet);
|
2016-08-03 18:26:22 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-08-04 13:19:18 +03:00
|
|
|
static void add_sheet_aoi(struct gui_ctx *ctx, 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->obj = obj;
|
|
|
|
|
|
|
|
struct aoi aoi = {
|
|
|
|
.x = obj->x,
|
|
|
|
.y = obj->y,
|
|
|
|
.w = obj->u.sheet.w,
|
|
|
|
.h = obj->u.sheet.h,
|
|
|
|
.click = select_subsheet,
|
|
|
|
.user = aoi_ctx,
|
|
|
|
};
|
|
|
|
|
|
|
|
aoi_add(&parent->aois, &aoi);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-08-18 18:16:13 +03:00
|
|
|
/* ----- Load revisions ---------------------------------------------------- */
|
|
|
|
|
|
|
|
|
2016-08-18 09:50:43 +03:00
|
|
|
void mark_aois(struct gui_ctx *ctx, struct gui_sheet *sheet)
|
2016-08-03 18:26:22 +03:00
|
|
|
{
|
|
|
|
const struct sch_obj *obj;
|
|
|
|
|
|
|
|
sheet->aois = NULL;
|
|
|
|
for (obj = sheet->sch->objs; obj; obj = obj->next)
|
|
|
|
switch (obj->type) {
|
2016-08-04 13:19:18 +03:00
|
|
|
case sch_obj_sheet:
|
|
|
|
add_sheet_aoi(ctx, sheet, obj);
|
2016-08-03 18:26:22 +03:00
|
|
|
break;
|
2016-08-11 03:50:07 +03:00
|
|
|
case sch_obj_glabel:
|
|
|
|
add_glabel_aoi(sheet, obj);
|
2016-08-03 18:26:22 +03:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-08-06 15:25:37 +03:00
|
|
|
static struct gui_sheet *get_sheets(struct gui_ctx *ctx,
|
|
|
|
const struct sheet *sheets)
|
2016-08-03 16:52:55 +03:00
|
|
|
{
|
|
|
|
const struct sheet *sheet;
|
2016-08-06 15:25:37 +03:00
|
|
|
struct gui_sheet *gui_sheets = NULL;
|
|
|
|
struct gui_sheet **next = &gui_sheets;
|
|
|
|
struct gui_sheet *new;
|
2016-08-03 16:52:55 +03:00
|
|
|
|
|
|
|
for (sheet = sheets; sheet; sheet = sheet->next) {
|
2016-08-06 15:25:37 +03:00
|
|
|
new = alloc_type(struct gui_sheet);
|
|
|
|
new->sch = sheet;
|
2016-08-11 02:20:51 +03:00
|
|
|
new->ctx = ctx;
|
2016-08-06 16:19:16 +03:00
|
|
|
new->rendered = 0;
|
2016-08-03 18:26:22 +03:00
|
|
|
|
2016-08-06 15:25:37 +03:00
|
|
|
*next = new;
|
|
|
|
next = &new->next;
|
2016-08-03 16:52:55 +03:00
|
|
|
}
|
|
|
|
*next = NULL;
|
2016-08-06 15:25:37 +03:00
|
|
|
return gui_sheets;
|
2016-08-03 16:52:55 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-08-10 22:03:52 +03:00
|
|
|
/*
|
|
|
|
* Library caching:
|
|
|
|
*
|
|
|
|
* We reuse previous components if all libraries are identical
|
|
|
|
*
|
|
|
|
* Future optimizations:
|
|
|
|
* - don't parse into single list of components, so that we can share
|
|
|
|
* libraries that are the same, even if there are others that have changed.
|
|
|
|
* - maybe put components into tree, so that they can be replaced individually
|
|
|
|
* (this would also help to identify sheets that don't need parsing)
|
2016-08-11 02:15:07 +03:00
|
|
|
*
|
|
|
|
* Sheet caching:
|
|
|
|
*
|
|
|
|
* We reuse previous sheets if
|
|
|
|
* - all libraries are identical (whether a given sheet uses them or not),
|
|
|
|
* - they have no sub-sheets, and
|
|
|
|
* - the objects IDs (hashes) are identical.
|
|
|
|
*
|
|
|
|
* Note that we only compare with the immediately preceding (newer) revision,
|
|
|
|
* so branches and merges can disrupt caching.
|
|
|
|
*
|
|
|
|
* Possible optimizations:
|
|
|
|
* - if we record which child sheets a sheet has, we could also clone it,
|
|
|
|
* without having to parse it. However, this is somewhat complex and may
|
|
|
|
* not save all that much time.
|
|
|
|
* - we could record what libraries a sheet uses, and parse only if one of
|
|
|
|
* these has changed (benefits scenarios with many library files),
|
|
|
|
* - we could record what components a sheet uses, and parse only if one of
|
|
|
|
* these has changed (benefits scenarios with few big libraries),
|
|
|
|
* - we could postpone library lookups to render time.
|
|
|
|
* - we could record IDs globally, which would help to avoid tripping over
|
|
|
|
* branches and merges.
|
2016-08-10 22:03:52 +03:00
|
|
|
*/
|
|
|
|
|
|
|
|
static const struct sheet *parse_files(struct gui_hist *hist,
|
2016-08-14 16:13:41 +03:00
|
|
|
int n_args, char **args, bool recurse, struct gui_hist *prev)
|
2016-08-05 02:35:41 +03:00
|
|
|
{
|
2016-08-06 15:25:37 +03:00
|
|
|
char *rev = NULL;
|
2016-08-05 16:24:39 +03:00
|
|
|
struct file sch_file;
|
2016-08-10 22:03:52 +03:00
|
|
|
struct file lib_files[n_args - 1];
|
|
|
|
int libs_open, i;
|
|
|
|
bool libs_cached = 0;
|
2016-08-06 15:25:37 +03:00
|
|
|
bool ok;
|
|
|
|
|
2016-08-11 09:24:34 +03:00
|
|
|
if (hist->vcs_hist && hist->vcs_hist->commit)
|
2016-08-10 22:03:52 +03:00
|
|
|
rev = vcs_git_get_rev(hist->vcs_hist);
|
2016-08-05 16:24:39 +03:00
|
|
|
|
2016-08-11 00:57:04 +03:00
|
|
|
sch_init(&hist->sch_ctx, recurse);
|
2016-08-06 15:25:37 +03:00
|
|
|
ok = file_open_revision(&sch_file, rev, args[n_args - 1], NULL);
|
|
|
|
|
|
|
|
if (rev)
|
|
|
|
free(rev);
|
|
|
|
if (!ok) {
|
2016-08-11 00:57:04 +03:00
|
|
|
sch_free(&hist->sch_ctx);
|
2016-08-06 03:02:57 +03:00
|
|
|
return NULL;
|
|
|
|
}
|
2016-08-05 16:24:39 +03:00
|
|
|
|
2016-08-10 22:03:52 +03:00
|
|
|
lib_init(&hist->lib);
|
|
|
|
for (libs_open = 0; libs_open != n_args - 1; libs_open++)
|
|
|
|
if (!file_open(lib_files + libs_open, args[libs_open],
|
|
|
|
&sch_file))
|
2016-08-06 03:02:57 +03:00
|
|
|
goto fail;
|
2016-08-10 22:03:52 +03:00
|
|
|
|
|
|
|
if (hist->vcs_hist) {
|
2016-08-11 02:28:31 +03:00
|
|
|
hist->oids = alloc_type_n(void *, libs_open);
|
2016-08-12 20:50:13 +03:00
|
|
|
hist->libs_open = libs_open;
|
2016-08-10 22:03:52 +03:00
|
|
|
for (i = 0; i != libs_open; i++)
|
|
|
|
hist->oids[i] = file_oid(lib_files + i);
|
2016-08-12 20:50:13 +03:00
|
|
|
if (prev && prev->vcs_hist && prev->libs_open == libs_open) {
|
2016-08-10 22:03:52 +03:00
|
|
|
for (i = 0; i != libs_open; i++)
|
|
|
|
if (!file_oid_eq(hist->oids[i], prev->oids[i]))
|
|
|
|
break;
|
|
|
|
if (i == libs_open) {
|
|
|
|
hist->lib.comps = prev->lib.comps;
|
|
|
|
libs_cached = 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!libs_cached)
|
|
|
|
for (i = 0; i != libs_open; i++)
|
|
|
|
if (!lib_parse_file(&hist->lib, lib_files +i))
|
|
|
|
goto fail;
|
|
|
|
|
2016-08-11 00:57:04 +03:00
|
|
|
if (!sch_parse(&hist->sch_ctx, &sch_file, &hist->lib,
|
|
|
|
libs_cached ? &prev->sch_ctx : NULL))
|
2016-08-06 03:02:57 +03:00
|
|
|
goto fail;
|
2016-08-10 22:03:52 +03:00
|
|
|
|
|
|
|
for (i = 0; i != libs_open; i++)
|
|
|
|
file_close(lib_files + i);
|
2016-08-05 16:24:39 +03:00
|
|
|
file_close(&sch_file);
|
|
|
|
|
2016-08-14 16:13:41 +03:00
|
|
|
if (prev && sheet_eq(prev->sch_ctx.sheets, hist->sch_ctx.sheets))
|
|
|
|
prev->identical = 1;
|
|
|
|
|
2016-08-06 15:25:37 +03:00
|
|
|
/*
|
|
|
|
* @@@ we have a major memory leak for the component library.
|
|
|
|
* We should record parsed schematics and libraries separately, so
|
|
|
|
* that we can clean them up, without having to rely on the history,
|
2016-08-10 22:03:52 +03:00
|
|
|
* with - when sharing unchanged item - possibly many duplicate
|
|
|
|
* pointers.
|
2016-08-06 15:25:37 +03:00
|
|
|
*/
|
2016-08-11 00:57:04 +03:00
|
|
|
return hist->sch_ctx.sheets;
|
2016-08-06 03:02:57 +03:00
|
|
|
|
|
|
|
fail:
|
2016-08-10 22:03:52 +03:00
|
|
|
while (libs_open--)
|
|
|
|
file_close(lib_files + libs_open);
|
2016-08-11 00:57:04 +03:00
|
|
|
sch_free(&hist->sch_ctx);
|
2016-08-10 22:03:52 +03:00
|
|
|
lib_free(&hist->lib);
|
2016-08-06 03:02:57 +03:00
|
|
|
file_close(&sch_file);
|
|
|
|
return NULL;
|
2016-08-05 16:24:39 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-08-06 15:25:37 +03:00
|
|
|
struct add_hist_ctx {
|
|
|
|
struct gui_ctx *ctx;
|
|
|
|
int n_args;
|
|
|
|
char **args;
|
|
|
|
bool recurse;
|
2016-08-10 15:08:22 +03:00
|
|
|
unsigned limit;
|
2016-08-06 15:25:37 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
static void add_hist(void *user, struct hist *h)
|
|
|
|
{
|
|
|
|
struct add_hist_ctx *ahc = user;
|
|
|
|
struct gui_ctx *ctx = ahc->ctx;
|
2016-08-10 22:03:52 +03:00
|
|
|
struct gui_hist **anchor, *hist, *prev;
|
2016-08-06 15:25:37 +03:00
|
|
|
const struct sheet *sch;
|
2016-08-09 20:16:05 +03:00
|
|
|
unsigned age = 0;
|
2016-08-06 15:25:37 +03:00
|
|
|
|
2016-08-10 15:08:22 +03:00
|
|
|
if (!ahc->limit)
|
|
|
|
return;
|
2016-08-12 16:42:03 +03:00
|
|
|
if (ahc->limit > 0)
|
|
|
|
ahc->limit--;
|
2016-08-10 15:08:22 +03:00
|
|
|
|
2016-08-10 22:03:52 +03:00
|
|
|
prev = NULL;
|
|
|
|
for (anchor = &ctx->hist; *anchor; anchor = &(*anchor)->next) {
|
|
|
|
prev = *anchor;
|
2016-08-09 20:16:05 +03:00
|
|
|
age++;
|
2016-08-10 22:03:52 +03:00
|
|
|
}
|
2016-08-10 20:07:03 +03:00
|
|
|
|
|
|
|
hist = alloc_type(struct gui_hist);
|
|
|
|
hist->ctx = ctx;
|
|
|
|
hist->vcs_hist = h;
|
2016-08-20 02:46:48 +03:00
|
|
|
hist->libs_open = 0;
|
2016-08-14 16:13:41 +03:00
|
|
|
hist->identical = 0;
|
2016-08-10 22:03:52 +03:00
|
|
|
sch = parse_files(hist, ahc->n_args, ahc->args, ahc->recurse, prev);
|
2016-08-10 20:07:03 +03:00
|
|
|
hist->sheets = sch ? get_sheets(ctx, sch) : NULL;
|
|
|
|
hist->age = age;
|
|
|
|
|
|
|
|
hist->next = NULL;
|
|
|
|
*anchor = hist;
|
2016-08-12 19:46:15 +03:00
|
|
|
|
|
|
|
if (ctx->hist_size)
|
|
|
|
progress_update(ctx);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-08-18 18:16:13 +03:00
|
|
|
static void get_revisions(struct gui_ctx *ctx,
|
|
|
|
int n_args, char **args, bool recurse, int limit)
|
|
|
|
{
|
|
|
|
struct add_hist_ctx add_hist_ctx = {
|
|
|
|
.ctx = ctx,
|
|
|
|
.n_args = n_args,
|
|
|
|
.args = args,
|
|
|
|
.recurse = recurse,
|
|
|
|
.limit = limit ? limit < 0 ? -limit : limit : -1,
|
|
|
|
};
|
|
|
|
|
|
|
|
if (ctx->vcs_hist)
|
|
|
|
hist_iterate(ctx->vcs_hist, add_hist, &add_hist_ctx);
|
|
|
|
else
|
|
|
|
add_hist(&add_hist_ctx, NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* ----- Retrieve and count history ---------------------------------------- */
|
|
|
|
|
|
|
|
|
2016-08-12 19:46:15 +03:00
|
|
|
static void count_history(void *user, struct hist *h)
|
|
|
|
{
|
|
|
|
struct gui_ctx *ctx = user;
|
|
|
|
|
|
|
|
ctx->hist_size++;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void get_history(struct gui_ctx *ctx, const char *sch_name, int limit)
|
|
|
|
{
|
|
|
|
if (!vcs_git_try(sch_name)) {
|
|
|
|
ctx->vcs_hist = NULL;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
ctx->vcs_hist = vcs_git_hist(sch_name);
|
|
|
|
if (limit)
|
|
|
|
ctx->hist_size = limit > 0 ? limit : -limit;
|
|
|
|
else
|
|
|
|
hist_iterate(ctx->vcs_hist, count_history, ctx);
|
2016-08-06 15:25:37 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-08-18 18:16:13 +03:00
|
|
|
/* ----- Initialization ---------------------------------------------------- */
|
2016-08-06 15:25:37 +03:00
|
|
|
|
|
|
|
|
2016-08-10 15:08:22 +03:00
|
|
|
int gui(unsigned n_args, char **args, bool recurse, int limit)
|
2016-08-03 13:38:57 +03:00
|
|
|
{
|
|
|
|
GtkWidget *window;
|
2016-08-20 03:30:58 +03:00
|
|
|
char *title;
|
2016-08-03 13:38:57 +03:00
|
|
|
struct gui_ctx ctx = {
|
2016-08-03 15:33:16 +03:00
|
|
|
.zoom = 4, /* scale by 1 / 16 */
|
2016-08-05 02:35:41 +03:00
|
|
|
.hist = NULL,
|
|
|
|
.vcs_hist = NULL,
|
2016-08-09 19:28:27 +03:00
|
|
|
.showing_history= 0,
|
2016-08-05 02:35:41 +03:00
|
|
|
.sheet_overlays = NULL,
|
2016-08-07 12:23:04 +03:00
|
|
|
.hist_overlays = NULL,
|
2016-08-11 05:47:08 +03:00
|
|
|
.pop_overlays = NULL,
|
2016-08-18 23:08:29 +03:00
|
|
|
.pop_underlays = NULL,
|
2016-08-19 12:48:44 +03:00
|
|
|
.pop_origin = NULL,
|
|
|
|
.glabel = NULL,
|
2016-08-04 13:53:25 +03:00
|
|
|
.aois = NULL,
|
2016-08-19 13:05:50 +03:00
|
|
|
.diff_mode = diff_delta,
|
2016-08-10 01:01:05 +03:00
|
|
|
.old_hist = NULL,
|
2016-08-14 19:01:35 +03:00
|
|
|
.hist_y_offset = 0,
|
2016-08-12 19:46:15 +03:00
|
|
|
.hist_size = 0,
|
2016-08-03 13:38:57 +03:00
|
|
|
};
|
|
|
|
|
2016-08-14 19:51:30 +03:00
|
|
|
window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
|
|
|
|
ctx.da = gtk_drawing_area_new();
|
|
|
|
gtk_container_add(GTK_CONTAINER(window), ctx.da);
|
|
|
|
|
|
|
|
gtk_window_set_default_size(GTK_WINDOW(window), 640, 480);
|
2016-08-20 03:30:58 +03:00
|
|
|
if (asprintf(&title, "eeshow (rev %s)", version)) {};
|
|
|
|
gtk_window_set_title(GTK_WINDOW(window), title);
|
2016-08-14 19:51:30 +03:00
|
|
|
|
|
|
|
gtk_widget_set_events(ctx.da,
|
2016-08-18 07:45:24 +03:00
|
|
|
GDK_EXPOSE | GDK_ENTER_NOTIFY_MASK | GDK_LEAVE_NOTIFY_MASK);
|
|
|
|
|
|
|
|
input_setup(ctx.da);
|
2016-08-14 19:51:30 +03:00
|
|
|
|
|
|
|
gtk_widget_show_all(window);
|
|
|
|
|
2016-08-12 19:46:15 +03:00
|
|
|
get_history(&ctx, args[n_args - 1], limit);
|
2016-08-14 19:51:30 +03:00
|
|
|
if (ctx.hist_size)
|
2016-08-12 19:46:15 +03:00
|
|
|
setup_progress_bar(&ctx, window);
|
|
|
|
|
2016-08-10 15:08:22 +03:00
|
|
|
get_revisions(&ctx, n_args, args, recurse, limit);
|
2016-08-10 01:01:05 +03:00
|
|
|
for (ctx.new_hist = ctx.hist; ctx.new_hist && !ctx.new_hist->sheets;
|
|
|
|
ctx.new_hist = ctx.new_hist->next);
|
2016-08-11 23:19:32 +03:00
|
|
|
if (!ctx.new_hist)
|
|
|
|
fatal("no valid sheets\n");
|
2016-08-03 13:38:57 +03:00
|
|
|
|
|
|
|
g_signal_connect(window, "destroy",
|
|
|
|
G_CALLBACK(gtk_main_quit), NULL);
|
|
|
|
|
2016-08-21 07:25:49 +03:00
|
|
|
icons_init();
|
2016-08-18 09:50:43 +03:00
|
|
|
sheet_setup(&ctx);
|
2016-08-18 18:41:12 +03:00
|
|
|
render_setup(&ctx);
|
2016-08-18 09:50:43 +03:00
|
|
|
|
2016-08-03 15:33:16 +03:00
|
|
|
// gtk_window_set_position(GTK_WINDOW(window), GTK_WIN_POS_CENTER);
|
2016-08-03 13:38:57 +03:00
|
|
|
|
2016-08-10 01:01:05 +03:00
|
|
|
go_to_sheet(&ctx, ctx.new_hist->sheets);
|
2016-08-03 13:38:57 +03:00
|
|
|
gtk_widget_show_all(window);
|
|
|
|
|
2016-08-10 15:08:22 +03:00
|
|
|
/* for performance testing, use -N-depth */
|
|
|
|
if (limit >= 0)
|
|
|
|
gtk_main();
|
2016-08-03 13:38:57 +03:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|