summaryrefslogtreecommitdiff
path: root/hardinfo2
diff options
context:
space:
mode:
authorLeandro Pereira <leandro@hardinfo.org>2009-12-27 22:08:05 -0200
committerLeandro Pereira <leandro@hardinfo.org>2009-12-27 22:08:05 -0200
commit000ade2d1866021554cbb04f77174638d3c1706c (patch)
tree9135c12620d386dcb5f5cabc291c7f0648cb4fda /hardinfo2
parent160dfa7d7176d7220e0d4b7a58ba875bd22526d4 (diff)
Don't scroll back when reloading a section
Diffstat (limited to 'hardinfo2')
-rw-r--r--hardinfo2/benchmark.c7
-rw-r--r--hardinfo2/hardinfo.h3
-rw-r--r--hardinfo2/shell.c21
3 files changed, 27 insertions, 4 deletions
diff --git a/hardinfo2/benchmark.c b/hardinfo2/benchmark.c
index b273ea72..11ad9b01 100644
--- a/hardinfo2/benchmark.c
+++ b/hardinfo2/benchmark.c
@@ -363,9 +363,14 @@ static void do_benchmark(void (*benchmark_function)(void), int entry)
GtkWidget *bench_dialog;
GtkWidget *bench_image;
BenchmarkDialog *benchmark_dialog;
+ gchar *bench_status;
+
+ bench_status = g_strdup_printf("Benchmarking: <b>%s</b>.", entries[entry].name);
shell_view_set_enabled(FALSE);
- shell_status_update("Benchmarking.");
+ shell_status_update(bench_status);
+
+ g_free(bench_status);
bench_image = icon_cache_get_image("benchmark.png");
gtk_widget_show(bench_image);
diff --git a/hardinfo2/hardinfo.h b/hardinfo2/hardinfo.h
index 235036be..dc720069 100644
--- a/hardinfo2/hardinfo.h
+++ b/hardinfo2/hardinfo.h
@@ -136,4 +136,7 @@ gchar *h_sysfs_read_string(gchar *endpoint, gchar *entry);
#define SCAN_START() static gboolean scanned = FALSE; if (reload) scanned = FALSE; if (scanned) return;
#define SCAN_END() scanned = TRUE;
+#define _CONCAT(a,b) a ## b
+#define CONCAT(a,b) _CONCAT(a,b)
+
#endif /* __HARDINFO_H__ */
diff --git a/hardinfo2/shell.c b/hardinfo2/shell.c
index 50dc0232..912515da 100644
--- a/hardinfo2/shell.c
+++ b/hardinfo2/shell.c
@@ -811,9 +811,15 @@ static gboolean update_field(gpointer data)
}
#define RANGE_SET_VALUE(tree,scrollbar,value) \
- gtk_range_set_value(GTK_RANGE \
+ do { \
+ GtkRange CONCAT(*range, __LINE__) = GTK_RANGE(GTK_SCROLLED_WINDOW(shell->tree->scroll)->scrollbar); \
+ gtk_range_set_value(CONCAT(range, __LINE__), value); \
+ gtk_adjustment_value_changed(GTK_ADJUSTMENT(gtk_range_get_adjustment(CONCAT(range, __LINE__)))); \
+ } while (0)
+#define RANGE_GET_VALUE(tree,scrollbar) \
+ gtk_range_get_value(GTK_RANGE \
(GTK_SCROLLED_WINDOW(shell->tree->scroll)-> \
- scrollbar), value);
+ scrollbar))
static gboolean reload_section(gpointer data)
{
@@ -823,7 +829,12 @@ static gboolean reload_section(gpointer data)
if (entry->selected) {
GtkTreePath *path = NULL;
GtkTreeIter iter;
-
+ double pos_info_scroll, pos_more_scroll;
+
+ /* save current position */
+ pos_info_scroll = RANGE_GET_VALUE(info, vscrollbar);
+ pos_more_scroll = RANGE_GET_VALUE(moreinfo, vscrollbar);
+
/* avoid drawing the window while we reload */
gdk_window_freeze_updates(shell->window->window);
@@ -848,6 +859,10 @@ static gboolean reload_section(gpointer data)
/* make the window drawable again */
gdk_window_thaw_updates(shell->window->window);
+
+ /* restore position */
+ RANGE_SET_VALUE(info, vscrollbar, pos_info_scroll);
+ RANGE_SET_VALUE(moreinfo, vscrollbar, pos_more_scroll);
}
/* destroy the timeout: it'll be set up again */