summaryrefslogtreecommitdiff
path: root/gui
diff options
context:
space:
mode:
authorWerner Almesberger <werner@almesberger.net>2016-10-30 15:37:24 (GMT)
committerWerner Almesberger <werner@almesberger.net>2016-10-30 17:12:33 (GMT)
commit96ef3e03ac812f3c0fbc863b89e860cd336a9293 (patch)
tree6a90267ae2d0d1ddd663efee66351b56fd1c77be /gui
parenta84bff7c2e35e2ed86a44218076b6d1bc9007e32 (diff)
downloadeeshow-96ef3e03ac812f3c0fbc863b89e860cd336a9293.zip
eeshow-96ef3e03ac812f3c0fbc863b89e860cd336a9293.tar.gz
eeshow-96ef3e03ac812f3c0fbc863b89e860cd336a9293.tar.bz2
gui/: "v" opens a viewer window for commit messages (WIP)
Diffstat (limited to 'gui')
-rw-r--r--gui/common.h5
-rw-r--r--gui/gui.c1
-rw-r--r--gui/history.c54
-rw-r--r--gui/sheet.c6
4 files changed, 64 insertions, 2 deletions
diff --git a/gui/common.h b/gui/common.h
index 6a51d76..efcd1c6 100644
--- a/gui/common.h
+++ b/gui/common.h
@@ -130,6 +130,9 @@ struct gui {
int hist_y_offset; /* history list y offset */
+ const struct vcs_hist *commit_hover;
+ /* commit being hovered on; NULL if none */
+
/* progress bar */
int hist_size; /* total number of revisions */
unsigned progress; /* progress counter */
@@ -176,6 +179,8 @@ void sheet_setup(struct gui *gui);
/* history.c */
+void view_full_commit(struct gui *gui);
+void commit_hover(struct gui *gui, const struct vcs_hist *vcs_hist);
void history_draw_event(const struct gui *gui, cairo_t *cr);
void show_history(struct gui *gui, enum selecting sel);
diff --git a/gui/gui.c b/gui/gui.c
index defd125..c5d51a2 100644
--- a/gui/gui.c
+++ b/gui/gui.c
@@ -470,6 +470,7 @@ int run_gui(const struct file_names *fn, bool recurse, int limit,
.diff_mode = diff_delta,
.old_hist = NULL,
.hist_y_offset = 0,
+ .commit_hover = NULL,
.hist_size = 0,
};
diff --git a/gui/history.c b/gui/history.c
index 13a7686..e4f6a81 100644
--- a/gui/history.c
+++ b/gui/history.c
@@ -22,6 +22,7 @@
#include "misc/diag.h"
#include "file/git-hist.h"
#include "gui/fmt-pango.h"
+#include "gui/view.h"
#include "gui/style.h"
#include "gui/aoi.h"
#include "gui/over.h"
@@ -29,6 +30,49 @@
#include "gui/common.h"
+/* ----- Commit view ------------------------------------------------------- */
+
+
+static struct view *view = NULL;
+
+
+static void key_press(void *user, struct view *v, guint keyval)
+{
+ switch (keyval) {
+ case GDK_KEY_v:
+ case GDK_KEY_q:
+ case GDK_KEY_Escape:
+ view_visible(v, 0);
+ break;
+ }
+}
+
+
+void commit_hover(struct gui *gui, const struct vcs_hist *vcs_hist)
+{
+ char *s;
+
+ gui->commit_hover = vcs_hist;
+ /* should only update if visible */
+ if (view && vcs_hist) {
+ s = vcs_git_long_for_pango(vcs_hist, fmt_pango);
+ view_update(view, s, 1);
+ free(s);
+ }
+}
+
+
+void view_full_commit(struct gui *gui)
+{
+ if (!view || !view_visible_toggle(view)) {
+ if (view)
+ view_close(view);
+ view = view_open(key_press, NULL);
+ }
+ commit_hover(gui, gui->commit_hover);
+}
+
+
/* ----- Render threads ---------------------------------------------------- */
@@ -169,6 +213,7 @@ static void hide_history(struct gui *gui)
gui->mode = showing_sheet;
do_revision_overlays(gui);
+ commit_hover(gui, NULL);
redraw(gui);
}
@@ -251,10 +296,13 @@ static bool hover_history(void *user, bool on, int dx, int dy)
if (dy)
overlay_size(h->over, gtk_widget_get_pango_context(gui->da),
NULL, &before);
- if (on)
+ if (on) {
s = vcs_git_long_for_pango(h->vcs_hist, fmt_pango);
- else
+ commit_hover(gui, h->vcs_hist);
+ } else {
s = vcs_git_summary_for_pango(h->vcs_hist, fmt_pango);
+ commit_hover(gui, NULL);
+ }
overlay_text_raw(h->over, s);
free(s);
set_history_style(h, on);
@@ -438,6 +486,8 @@ static void history_key(void *user, int x, int y, int keyval)
break;
case GDK_KEY_q:
gtk_main_quit();
+ case GDK_KEY_v:
+ view_full_commit(gui);
}
}
diff --git a/gui/sheet.c b/gui/sheet.c
index ec83a7a..98e22be 100644
--- a/gui/sheet.c
+++ b/gui/sheet.c
@@ -155,9 +155,11 @@ static bool show_history_details(void *user, bool on, int dx, int dy)
if (on) {
s = vcs_git_long_for_pango(h->vcs_hist, fmt_pango);
overlay_text_raw(h->over, s);
+ commit_hover(gui, h->vcs_hist);
free(s);
} else {
overlay_text(h->over, "%.40s", vcs_git_summary(h->vcs_hist));
+ commit_hover(gui, NULL);
}
redraw(gui);
return 1;
@@ -662,6 +664,10 @@ static void sheet_key(void *user, int x, int y, int keyval)
redraw(gui);
break;
+ case GDK_KEY_v:
+ view_full_commit(gui);
+ break;
+
case GDK_KEY_q:
gtk_main_quit();
}