[ghex] Simplify scrolling code
- From: Kalev Lember <klember src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [ghex] Simplify scrolling code
- Date: Sat, 6 Aug 2011 17:27:30 +0000 (UTC)
commit 7ec6ab5c99686cc78176b1971ded8d90b6f107e9
Author: RafaÅ MuÅyÅo <galtgendo gmail com>
Date: Sat Aug 6 11:37:43 2011 +0300
Simplify scrolling code
src/gtkhex.c | 50 +++++++++-----------------------------------------
1 files changed, 9 insertions(+), 41 deletions(-)
---
diff --git a/src/gtkhex.c b/src/gtkhex.c
index 4c0012e..84ff569 100644
--- a/src/gtkhex.c
+++ b/src/gtkhex.c
@@ -945,56 +945,24 @@ static void recalc_displays(GtkHex *gh, guint width, guint height) {
/*
* takes care of xdisp and adisp scrolling
* connected to value_changed signal of scrollbar's GtkAdjustment
- * I cant really remember anymore, but I think it was mostly copied
- * from testgtk.c ;)
*/
static void display_scrolled(GtkAdjustment *adj, GtkHex *gh) {
- GtkAllocation xdisp_allocation;
- GdkRectangle rect;
- gint source_min;
- gint source_max;
- gint dest_min;
-
- gtk_widget_get_allocation(gh->xdisp, &xdisp_allocation);
-
- source_min = ((gint)gtk_adjustment_get_value(adj) - gh->top_line) * gh->char_height;
- source_max = source_min + xdisp_allocation.height;
- dest_min = 0;
+ gint dx;
+ gint dy;
if ((!gtk_widget_is_drawable(gh->xdisp)) ||
(!gtk_widget_is_drawable(gh->adisp)))
return;
- gh->top_line = (gint)gtk_adjustment_get_value(adj);
+ dx = 0;
+ dy = (gh->top_line - (gint)gtk_adjustment_get_value (adj)) * gh->char_height;
- if (source_min < 0) {
- rect.y = 0;
- rect.height = -source_min;
- if (rect.height > xdisp_allocation.height)
- rect.height = xdisp_allocation.height;
- source_min = 0;
- dest_min = rect.height;
- }
- else {
- rect.y = 2*xdisp_allocation.height - source_max;
- if (rect.y < 0)
- rect.y = 0;
- rect.height = xdisp_allocation.height - rect.y;
-
- source_max = xdisp_allocation.height;
- }
-
- if (source_min != source_max) {
- gint dx, dy;
-
- dx = 0;
- dy = dest_min - source_min;
+ gh->top_line = (gint)gtk_adjustment_get_value(adj);
- gdk_window_scroll (gtk_widget_get_window (gh->xdisp), dx, dy);
- gdk_window_scroll (gtk_widget_get_window (gh->adisp), dx, dy);
- if (gh->offsets)
- gdk_window_scroll (gtk_widget_get_window (gh->offsets), dx, dy);
- }
+ gdk_window_scroll (gtk_widget_get_window (gh->xdisp), dx, dy);
+ gdk_window_scroll (gtk_widget_get_window (gh->adisp), dx, dy);
+ if (gh->offsets)
+ gdk_window_scroll (gtk_widget_get_window (gh->offsets), dx, dy);
gtk_hex_update_all_auto_highlights(gh, TRUE, TRUE);
gtk_hex_invalidate_all_highlights(gh);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]