summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWerner Almesberger <werner@almesberger.net>2016-08-04 09:02:33 -0300
committerWerner Almesberger <werner@almesberger.net>2016-08-04 09:02:33 -0300
commit9cfa7a62ffe4be68645f89552832ff384e732cae (patch)
tree1c43b301997f611dee41ef87b685b02a8e980eb7
parent0e0688126ee1beb8a3001818609c1783644b050b (diff)
downloadeeshow-9cfa7a62ffe4be68645f89552832ff384e732cae.tar.gz
eeshow-9cfa7a62ffe4be68645f89552832ff384e732cae.tar.bz2
eeshow-9cfa7a62ffe4be68645f89552832ff384e732cae.zip
eeshow/gui.c, README: PgUp/PgDn iterate through sheets in sequence
-rw-r--r--README2
-rw-r--r--gui.c60
2 files changed, 47 insertions, 15 deletions
diff --git a/README b/README
index 7d20465..4bda222 100644
--- a/README
+++ b/README
@@ -35,4 +35,6 @@ Key functions in GUI mode
* zoom to extents
Home go to the top sheet
Delete or Backspace go to the previous sheet
+PgUp go to the previous sheet in sequence
+PgDn go to the next sheet in sequence
Q quit the viewer
diff --git a/gui.c b/gui.c
index 5db0a40..c8b4d51 100644
--- a/gui.c
+++ b/gui.c
@@ -217,10 +217,24 @@ static void zoom_to_extents(struct gui_ctx *ctx)
/* ----- Navigate sheets --------------------------------------------------- */
+static bool go_up_sheet(struct gui_ctx *ctx);
+
+
+static void close_subsheet(void *user)
+{
+ struct gui_ctx *ctx = user;
+
+ go_up_sheet(ctx);
+}
+
+
static void go_to_sheet(struct gui_ctx *ctx, struct gui_sheet *sheet)
{
ctx->curr_sheet = sheet;
overlay_remove_all(&ctx->overlays);
+ if (sheet->sch->title)
+ overlay_add(&ctx->overlays, sheet->sch->title,
+ &ctx->aois, NULL, close_subsheet, ctx);
zoom_to_extents(ctx);
}
@@ -241,6 +255,28 @@ static bool go_up_sheet(struct gui_ctx *ctx)
}
+static bool go_prev_sheet(struct gui_ctx *ctx)
+{
+ struct gui_sheet *sheet;
+
+ for (sheet = ctx->sheets; sheet; sheet = sheet->next)
+ if (sheet->next && sheet->next == ctx->curr_sheet) {
+ go_to_sheet(ctx, sheet);
+ return 1;
+ }
+ return 0;
+}
+
+
+static bool go_next_sheet(struct gui_ctx *ctx)
+{
+ if (!ctx->curr_sheet->next)
+ return 0;
+ go_to_sheet(ctx, ctx->curr_sheet->next);
+ return 1;
+}
+
+
/* ----- Event handlers ---------------------------------------------------- */
@@ -338,6 +374,14 @@ static gboolean key_press_event(GtkWidget *widget, GdkEventKey *event,
case GDK_KEY_Delete:
go_up_sheet(ctx);
break;
+ case GDK_KEY_Page_Up:
+ case GDK_KEY_KP_Page_Up:
+ go_prev_sheet(ctx);
+ break;
+ case GDK_KEY_Page_Down:
+ case GDK_KEY_KP_Page_Down:
+ go_next_sheet(ctx);
+ break;
case GDK_KEY_q:
gtk_main_quit();
}
@@ -384,14 +428,6 @@ struct sheet_aoi_ctx {
};
-static void close_subsheet(void *user)
-{
- struct gui_ctx *ctx = user;
-
- go_up_sheet(ctx);
-}
-
-
static void select_subsheet(void *user)
{
const struct sheet_aoi_ctx *aoi_ctx = user;
@@ -401,13 +437,7 @@ static void select_subsheet(void *user)
for (sheet = ctx->sheets; sheet; sheet = sheet->next)
if (sheet->sch == obj->u.sheet.sheet) {
- const char *name;
-
go_to_sheet(ctx, sheet);
- name = sheet->sch->title ? sheet->sch->title :
- obj->u.sheet.name;
- overlay_add(&ctx->overlays, name,
- &ctx->aois, NULL, close_subsheet, ctx);
return;
}
abort();
@@ -524,7 +554,7 @@ int gui(const struct sheet *sheets)
gtk_window_set_title(GTK_WINDOW(window), "eeshow");
gtk_widget_show_all(window);
- zoom_to_extents(&ctx);
+ go_to_sheet(&ctx, ctx.sheets);
gtk_main();