aboutsummaryrefslogtreecommitdiff
path: root/hardinfo2
diff options
context:
space:
mode:
authorLeandro Pereira <leandro@hardinfo.org>2010-01-03 13:20:55 -0200
committerLeandro Pereira <leandro@hardinfo.org>2010-01-03 13:20:55 -0200
commit9197f8f7599be83c22eb6aa0649e7be4f102a187 (patch)
tree3a3a0b0b1d096aaefa79a44dd4654e55d93e6d26 /hardinfo2
parent679cf487bceb54949f7fe51523f54b5962a7466f (diff)
Add ability to include context-sensitive help files.
Diffstat (limited to 'hardinfo2')
-rw-r--r--hardinfo2/benchmark.c13
-rw-r--r--hardinfo2/callbacks.c41
-rw-r--r--hardinfo2/callbacks.h1
-rw-r--r--hardinfo2/computer.c2
-rw-r--r--hardinfo2/hardinfo.h1
-rw-r--r--hardinfo2/help-viewer.c19
-rw-r--r--hardinfo2/menu.c5
-rw-r--r--hardinfo2/shell.c37
-rw-r--r--hardinfo2/uidefs.h1
9 files changed, 104 insertions, 16 deletions
diff --git a/hardinfo2/benchmark.c b/hardinfo2/benchmark.c
index bb98c575..fcb5a362 100644
--- a/hardinfo2/benchmark.c
+++ b/hardinfo2/benchmark.c
@@ -56,17 +56,16 @@ gchar *callback_nqueens();
gchar *callback_gui();
static ModuleEntry entries[] = {
- {"CPU Blowfish", "blowfish.png", callback_bfsh, scan_bfsh, MODULE_FLAG_NO_REMOTE},
- {"CPU CryptoHash", "cryptohash.png", callback_cryptohash, scan_cryptohash, MODULE_FLAG_NO_REMOTE},
- {"CPU Fibonacci", "nautilus.png", callback_fib, scan_fib, MODULE_FLAG_NO_REMOTE},
- {"CPU N-Queens", "nqueens.png", callback_nqueens, scan_nqueens, MODULE_FLAG_NO_REMOTE},
- {"FPU FFT", "fft.png", callback_fft, scan_fft, MODULE_FLAG_NO_REMOTE},
- {"FPU Raytracing", "raytrace.png", callback_raytr, scan_raytr, MODULE_FLAG_NO_REMOTE},
+ {"CPU Blowfish", "blowfish.png", callback_bfsh, scan_bfsh, MODULE_FLAG_NONE},
+ {"CPU CryptoHash", "cryptohash.png", callback_cryptohash, scan_cryptohash, MODULE_FLAG_NONE},
+ {"CPU Fibonacci", "nautilus.png", callback_fib, scan_fib, MODULE_FLAG_NONE},
+ {"CPU N-Queens", "nqueens.png", callback_nqueens, scan_nqueens, MODULE_FLAG_NONE},
+ {"FPU FFT", "fft.png", callback_fft, scan_fft, MODULE_FLAG_NONE},
+ {"FPU Raytracing", "raytrace.png", callback_raytr, scan_raytr, MODULE_FLAG_NONE},
{"GPU Drawing", "module.png", callback_gui, scan_gui, MODULE_FLAG_NO_REMOTE},
{NULL}
};
-
static gboolean sending_benchmark_results = FALSE;
typedef struct _ParallelBenchTask ParallelBenchTask;
diff --git a/hardinfo2/callbacks.c b/hardinfo2/callbacks.c
index c3b3b972..42a9c642 100644
--- a/hardinfo2/callbacks.c
+++ b/hardinfo2/callbacks.c
@@ -125,7 +125,7 @@ void cb_local_computer()
shell_view_set_enabled(TRUE);
shell_status_update("Done.");
- shell_set_remote_label(shell, "Local");
+ shell_set_remote_label(shell, "");
#endif /* HAS_LIBSOUP */
}
@@ -186,6 +186,45 @@ void cb_open_online_docs()
}
}
+void cb_open_online_docs_context()
+{
+ Shell *shell;
+
+ shell = shell_get_main_shell();
+
+ if (shell->selected->flags & MODULE_FLAG_HAS_HELP) {
+ gchar *temp;
+
+ /* FIXME: better naming for context-help files */
+ temp = g_strdup_printf("context-help-%s-%d.hlp",
+ shell->selected_module_name,
+ shell->selected->number);
+
+ if (shell->help_viewer) {
+ help_viewer_open_page(shell->help_viewer, temp);
+ } else {
+ gchar *help_dir;
+
+ help_dir = g_build_filename(params.path_data, "doc", NULL);
+ shell->help_viewer = help_viewer_new(help_dir, temp);
+ g_free(help_dir);
+ }
+
+ g_free(temp);
+ } else {
+ GtkWidget *dialog;
+
+ dialog = gtk_message_dialog_new(GTK_WINDOW(shell->window),
+ GTK_DIALOG_DESTROY_WITH_PARENT,
+ GTK_MESSAGE_ERROR,
+ GTK_BUTTONS_CLOSE,
+ "No context help available.");
+
+ gtk_dialog_run(GTK_DIALOG(dialog));
+ gtk_widget_destroy(dialog);
+ }
+}
+
void cb_report_bug()
{
open_url("http://wiki.hardinfo.org/BugReports");
diff --git a/hardinfo2/callbacks.h b/hardinfo2/callbacks.h
index 8cb29a87..d53e1861 100644
--- a/hardinfo2/callbacks.h
+++ b/hardinfo2/callbacks.h
@@ -32,6 +32,7 @@ void cb_side_pane();
void cb_toolbar();
void cb_open_web_page();
void cb_open_online_docs();
+void cb_open_online_docs_context();
void cb_sync_manager();
void cb_report_bug();
void cb_donate();
diff --git a/hardinfo2/computer.c b/hardinfo2/computer.c
index 98936598..4ebcd986 100644
--- a/hardinfo2/computer.c
+++ b/hardinfo2/computer.c
@@ -62,7 +62,7 @@ void scan_dev(gboolean reload);
#endif /* GLIB_CHECK_VERSION(2,14,0) */
static ModuleEntry entries[] = {
- {"Summary", "summary.png", callback_summary, scan_summary, MODULE_FLAG_NONE},
+ {"Summary", "summary.png", callback_summary, scan_summary, MODULE_FLAG_HAS_HELP},
{"Operating System", "os.png", callback_os, scan_os, MODULE_FLAG_NONE},
{"Kernel Modules", "module.png", callback_modules, scan_modules, MODULE_FLAG_NONE},
{"Boots", "boot.png", callback_boots, scan_boots, MODULE_FLAG_NONE},
diff --git a/hardinfo2/hardinfo.h b/hardinfo2/hardinfo.h
index 71dc9c14..48d0cf88 100644
--- a/hardinfo2/hardinfo.h
+++ b/hardinfo2/hardinfo.h
@@ -25,6 +25,7 @@
typedef enum {
MODULE_FLAG_NONE = 0,
MODULE_FLAG_NO_REMOTE = 1<<0,
+ MODULE_FLAG_HAS_HELP = 1<<1,
} ModuleEntryFlags;
typedef struct _ModuleEntry ModuleEntry;
diff --git a/hardinfo2/help-viewer.c b/hardinfo2/help-viewer.c
index eaaeeb58..da29756d 100644
--- a/hardinfo2/help-viewer.c
+++ b/hardinfo2/help-viewer.c
@@ -317,6 +317,7 @@ static gboolean destroy_me(GtkWidget *widget, gpointer data)
HelpViewer *
help_viewer_new (const gchar *help_dir, const gchar *help_file)
{
+ Shell *shell;
HelpViewer *hv;
GtkWidget *help_viewer;
GtkWidget *vbox;
@@ -338,13 +339,15 @@ help_viewer_new (const gchar *help_dir, const gchar *help_file)
GtkWidget *status_bar;
GtkWidget *separatortoolitem;
GtkWidget *btn_home;
-
GdkPixbuf *icon;
+
+ shell = shell_get_main_shell();
- help_viewer = gtk_window_new (GTK_WINDOW_TOPLEVEL);
+ help_viewer = gtk_window_new(GTK_WINDOW_TOPLEVEL);
gtk_widget_set_size_request(help_viewer, 300, 200);
gtk_window_set_default_size(GTK_WINDOW(help_viewer), 640, 480);
- gtk_window_set_title (GTK_WINDOW (help_viewer), "Help Viewer");
+ gtk_window_set_title(GTK_WINDOW(help_viewer), "Help Viewer");
+ gtk_window_set_transient_for(GTK_WINDOW(help_viewer), GTK_WINDOW(shell->window));
icon = gtk_widget_render_icon(help_viewer, GTK_STOCK_HELP,
GTK_ICON_SIZE_DIALOG,
@@ -460,13 +463,19 @@ help_viewer_new (const gchar *help_dir, const gchar *help_file)
if (!markdown_textview_load_file(MARKDOWN_TEXTVIEW(markdown_textview), help_file ? help_file : "index.hlp")) {
GtkWidget *dialog;
- dialog = gtk_message_dialog_new(NULL,
+ dialog = gtk_message_dialog_new(GTK_WINDOW(shell->window),
GTK_DIALOG_DESTROY_WITH_PARENT,
GTK_MESSAGE_ERROR,
GTK_BUTTONS_CLOSE,
- "Cannot open help index file.");
+ "Cannot open help file (%s).",
+ help_file ? help_file : "index.hlp");
gtk_dialog_run(GTK_DIALOG(dialog));
gtk_widget_destroy(dialog);
+
+ gtk_widget_destroy(hv->window);
+ g_free(hv);
+
+ return NULL;
}
gtk_widget_show_all(hv->window);
diff --git a/hardinfo2/menu.c b/hardinfo2/menu.c
index bc938994..6b96e271 100644
--- a/hardinfo2/menu.c
+++ b/hardinfo2/menu.c
@@ -88,6 +88,11 @@ static GtkActionEntry entries[] = {
NULL,
G_CALLBACK(cb_open_online_docs)},
+ {"ContextHelpAction", NULL,
+ "Context help", "<Ctrl>F1",
+ NULL,
+ G_CALLBACK(cb_open_online_docs_context)},
+
{"HomePageAction", HI_STOCK_INTERNET,
"_Open HardInfo Web Site", NULL,
NULL,
diff --git a/hardinfo2/shell.c b/hardinfo2/shell.c
index 2974c5ca..e0b5da38 100644
--- a/hardinfo2/shell.c
+++ b/hardinfo2/shell.c
@@ -126,6 +126,19 @@ void shell_action_set_property(const gchar * action_name,
}
}
+void shell_action_set_label(const gchar * action_name, gchar * label)
+{
+ if (params.gui_running && shell->action_group) {
+ GtkAction *action;
+
+ action =
+ gtk_action_group_get_action(shell->action_group, action_name);
+ if (action) {
+ gtk_action_set_label(action, label);
+ }
+ }
+}
+
void shell_action_set_enabled(const gchar * action_name, gboolean setting)
{
if (params.gui_running && shell->action_group) {
@@ -432,7 +445,7 @@ static void create_window(void)
#else
gtk_widget_hide(shell->remote_label);
#endif
- shell_set_remote_label(shell, "Local");
+ shell_set_remote_label(shell, "");
gtk_box_pack_end(GTK_BOX(hbox), shell->remote_label, FALSE, FALSE, 0);
shell->status = gtk_label_new("");
@@ -742,6 +755,7 @@ void shell_init(GSList * modules)
shell_status_update("Done.");
shell_status_set_enabled(FALSE);
+ shell_action_set_enabled("ContextHelpAction", FALSE);
shell_action_set_enabled("RefreshAction", FALSE);
shell_action_set_enabled("CopyAction", FALSE);
shell_action_set_enabled("SaveGraphAction", FALSE);
@@ -1487,10 +1501,25 @@ static void module_selected(gpointer data)
RANGE_SET_VALUE(moreinfo, vscrollbar, 0.0);
RANGE_SET_VALUE(moreinfo, hscrollbar, 0.0);
- title = g_strdup_printf("%s: %s", shell->selected_module_name, entry->name);
+ title = g_strdup_printf("%s - %s", shell->selected_module_name, entry->name);
shell_set_title(shell, title);
g_free(title);
+ if (entry->flags & MODULE_FLAG_HAS_HELP) {
+ gchar *temp;
+
+ shell_action_set_enabled("ContextHelpAction", TRUE);
+
+ temp = g_strdup_printf("Help on %s \342\206\222 %s",
+ shell->selected_module_name,
+ entry->name);
+ shell_action_set_label("ContextHelpAction", temp);
+
+ g_free(temp);
+ } else {
+ goto no_help;
+ }
+
shell_action_set_enabled("RefreshAction", TRUE);
shell_action_set_enabled("CopyAction", TRUE);
@@ -1503,6 +1532,10 @@ static void module_selected(gpointer data)
gtk_tree_store_clear(GTK_TREE_STORE(shell->info->model));
set_view_type(SHELL_VIEW_NORMAL, FALSE);
+
+no_help:
+ shell_action_set_enabled("ContextHelpAction", FALSE);
+ shell_action_set_label("ContextHelpAction", "Context help");
}
current = entry;
diff --git a/hardinfo2/uidefs.h b/hardinfo2/uidefs.h
index 707d9c6e..a54823ad 100644
--- a/hardinfo2/uidefs.h
+++ b/hardinfo2/uidefs.h
@@ -51,6 +51,7 @@ SYNC_MANAGER_ITEMS
REMOTE_MENU_ITEMS \
" <menu name=\"HelpMenu\" action=\"HelpMenuAction\">" \
" <menuitem name=\"OnlineDocs\" action=\"OnlineDocsAction\"/>" \
+" <menuitem name=\"ContextHelp\" action=\"ContextHelpAction\"/>" \
" <separator/>" \
" <menuitem name=\"WebPage\" action=\"HomePageAction\"/>" \
" <menuitem name=\"ReportBug\" action=\"ReportBugAction\"/>" \