diff options
Diffstat (limited to 'hardinfo2')
-rw-r--r-- | hardinfo2/benchmark.c | 14 | ||||
-rw-r--r-- | hardinfo2/callbacks.c | 45 | ||||
-rw-r--r-- | hardinfo2/callbacks.h | 4 | ||||
-rw-r--r-- | hardinfo2/computer.c | 14 | ||||
-rw-r--r-- | hardinfo2/devices.c | 14 | ||||
-rw-r--r-- | hardinfo2/hardinfo.h | 8 | ||||
-rw-r--r-- | hardinfo2/menu.c | 8 | ||||
-rw-r--r-- | hardinfo2/pixmaps/about-modules.png | bin | 0 -> 609 bytes | |||
-rw-r--r-- | hardinfo2/shell.c | 23 | ||||
-rw-r--r-- | hardinfo2/stock.c | 6 | ||||
-rw-r--r-- | hardinfo2/stock.h | 2 | ||||
-rw-r--r-- | hardinfo2/uidefs.xml | 5 | ||||
-rw-r--r-- | hardinfo2/util.c | 11 |
13 files changed, 148 insertions, 6 deletions
diff --git a/hardinfo2/benchmark.c b/hardinfo2/benchmark.c index 8aadb329..5462bccc 100644 --- a/hardinfo2/benchmark.c +++ b/hardinfo2/benchmark.c @@ -223,3 +223,17 @@ ModuleEntry *hi_module_get_entries(void) { return entries; } + +ModuleAbout * +hi_module_get_about(void) +{ + static ModuleAbout ma[] = { + { + .author = "Leandro A. F. Pereira (leandro@linuxmag.com.br)", + .version = VERSION, + .license = "GNU GPL version 2" + } + }; + + return ma; +} diff --git a/hardinfo2/callbacks.c b/hardinfo2/callbacks.c index bc50c668..69201d82 100644 --- a/hardinfo2/callbacks.c +++ b/hardinfo2/callbacks.c @@ -68,6 +68,11 @@ void cb_open_web_page() open_url("http://hardinfo.berlios.de"); } +void cb_open_online_docs() +{ + open_url("http://hardinfo.berlios.de/wiki/Documentation"); +} + void cb_report_bug() { open_url("http://hardinfo.berlios.de/web/BugReports"); @@ -116,6 +121,46 @@ void cb_toolbar() shell_ui_manager_set_visible("/MainMenuBarAction", visible); } +void cb_about_module(GtkAction *action) +{ + Shell *shell = shell_get_main_shell(); + GSList *modules = shell->tree->modules; + ModuleAbout *ma; + gchar *name; + + g_object_get(G_OBJECT(action), "tooltip", &name, NULL); + + for (; modules; modules = modules->next) { + ShellModule *sm = (ShellModule *)modules->data; + + if (!g_str_equal(sm->name, name)) + continue; + + if ((ma = module_get_about(sm))) { + GtkWidget *about; + + about = gtk_about_dialog_new(); + gtk_about_dialog_set_name(GTK_ABOUT_DIALOG(about), sm->name); + gtk_about_dialog_set_version(GTK_ABOUT_DIALOG(about), ma->version); + gtk_about_dialog_set_copyright(GTK_ABOUT_DIALOG(about), + idle_free(g_strdup_printf("Written by %s", ma->author))); + + gtk_about_dialog_set_comments(GTK_ABOUT_DIALOG(about), + idle_free(g_strdup_printf("Licensed under %s", ma->license))); + + gtk_about_dialog_set_logo(GTK_ABOUT_DIALOG(about), sm->icon); + gtk_dialog_run(GTK_DIALOG(about)); + gtk_widget_destroy(about); + } else { + g_warning("No about information is associated with this module."); + } + + break; + } + + g_free(name); +} + void cb_about() { GtkWidget *about; diff --git a/hardinfo2/callbacks.h b/hardinfo2/callbacks.h index 9d1c0dea..7b1170e4 100644 --- a/hardinfo2/callbacks.h +++ b/hardinfo2/callbacks.h @@ -19,7 +19,10 @@ #ifndef __CALLBACKS_H__ #define __CALLBACKS_H__ +#include <gtk/gtk.h> + void cb_about(); +void cb_about_module(GtkAction *action); void cb_generate_report(); void cb_save_graphic(); void cb_quit(); @@ -28,6 +31,7 @@ void cb_copy_to_clipboard(); void cb_side_pane(); void cb_toolbar(); void cb_open_web_page(); +void cb_open_online_docs(); void cb_report_bug(); #endif /* __CALLBACKS_H__ */ diff --git a/hardinfo2/computer.c b/hardinfo2/computer.c index b1676b0f..a4a53c9a 100644 --- a/hardinfo2/computer.c +++ b/hardinfo2/computer.c @@ -389,3 +389,17 @@ hi_module_init(void) computer = g_new0(Computer, 1); moreinfo = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, NULL); } + +ModuleAbout * +hi_module_get_about(void) +{ + static ModuleAbout ma[] = { + { + .author = "Leandro A. F. Pereira (leandro@linuxmag.com.br)", + .version = VERSION, + .license = "GNU GPL version 2" + } + }; + + return ma; +} diff --git a/hardinfo2/devices.c b/hardinfo2/devices.c index eb4cc3e7..b5d97f07 100644 --- a/hardinfo2/devices.c +++ b/hardinfo2/devices.c @@ -381,3 +381,17 @@ hi_module_init(void) { moreinfo = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, g_free); } + +ModuleAbout * +hi_module_get_about(void) +{ + static ModuleAbout ma[] = { + { + .author = "Leandro A. F. Pereira (leandro@linuxmag.com.br)", + .version = VERSION, + .license = "GNU GPL version 2" + } + }; + + return ma; +} diff --git a/hardinfo2/hardinfo.h b/hardinfo2/hardinfo.h index 63b1c6ad..68b93441 100644 --- a/hardinfo2/hardinfo.h +++ b/hardinfo2/hardinfo.h @@ -23,6 +23,7 @@ #include <shell.h> typedef struct _ModuleEntry ModuleEntry; +typedef struct _ModuleAbout ModuleAbout; typedef struct _FileTypes FileTypes; typedef struct _ProgramParameters ProgramParameters; @@ -54,6 +55,12 @@ struct _ModuleEntry { gpointer scan_callback; }; +struct _ModuleAbout { + gchar *author; + gchar *version; + gchar *license; +}; + /* String utility functions */ inline void remove_quotes(gchar *str); inline void strend(gchar *str, gchar chr); @@ -79,6 +86,7 @@ void nonblock_sleep(guint msec); void open_url(gchar *url); GSList *modules_load_selected(void); GSList *modules_load_all(void); +ModuleAbout *module_get_about(ShellModule *module); void module_entry_scan_all_except(ModuleEntry *entries, gint except_entry); void module_entry_scan_all(ModuleEntry *entries); diff --git a/hardinfo2/menu.c b/hardinfo2/menu.c index 06c205d0..c3994dd4 100644 --- a/hardinfo2/menu.c +++ b/hardinfo2/menu.c @@ -33,6 +33,7 @@ static GtkActionEntry entries[] = { "InformationMenuAction", NULL, "_Information" }, /* name, stock id, label */ { "ViewMenuAction", NULL, "_View" }, { "HelpMenuAction", NULL, "_Help" }, + { "HelpMenuModulesAction", NULL, "About _Modules" }, { "MainMenuBarAction", NULL, "" }, { "ReportAction", HI_STOCK_REPORT, /* name, stock id */ @@ -55,6 +56,11 @@ static GtkActionEntry entries[] = NULL, G_CALLBACK(cb_refresh) }, + { "OnlineDocsAction", GTK_STOCK_HELP, + "Contents (online)", "F1", + NULL, + G_CALLBACK(cb_open_online_docs) }, + { "HomePageAction", HI_STOCK_INTERNET, "_Open HardInfo Web Site", NULL, NULL, @@ -66,7 +72,7 @@ static GtkActionEntry entries[] = G_CALLBACK(cb_report_bug) }, { "AboutAction", GTK_STOCK_ABOUT, - "_About", NULL, + "_About HardInfo", NULL, "Displays program version information", G_CALLBACK(cb_about) }, diff --git a/hardinfo2/pixmaps/about-modules.png b/hardinfo2/pixmaps/about-modules.png Binary files differnew file mode 100644 index 00000000..0d49f9df --- /dev/null +++ b/hardinfo2/pixmaps/about-modules.png diff --git a/hardinfo2/shell.c b/hardinfo2/shell.c index 3259697a..dd2f46ba 100644 --- a/hardinfo2/shell.c +++ b/hardinfo2/shell.c @@ -28,6 +28,8 @@ #include <menu.h> #include <stock.h> +#include <callbacks.h> + /* * Internal Prototypes ******************************************************** */ @@ -371,8 +373,10 @@ static void view_menu_select_entry(gpointer data, gpointer data2) gtk_tree_path_free(path); } -static void add_module_to_view_menu(gchar * name, GdkPixbuf * pixbuf) +static void add_module_to_menu(gchar * name, GdkPixbuf * pixbuf) { + gchar *about_module = g_strdup_printf("AboutModule%s", name); + stock_icon_register_pixbuf(pixbuf, name); GtkActionEntry entries[] = { @@ -384,14 +388,27 @@ static void add_module_to_view_menu(gchar * name, GdkPixbuf * pixbuf) NULL, /* tooltip */ NULL, /* callback */ }, + { + about_module, + name, + name, + NULL, + name, + (GCallback) cb_about_module, + }, }; - gtk_action_group_add_actions(shell->action_group, entries, 1, NULL); + gtk_action_group_add_actions(shell->action_group, entries, 2, NULL); gtk_ui_manager_add_ui(shell->ui_manager, gtk_ui_manager_new_merge_id(shell->ui_manager), "/menubar/ViewMenu/LastSep", name, name, GTK_UI_MANAGER_MENU, TRUE); + + gtk_ui_manager_add_ui(shell->ui_manager, + gtk_ui_manager_new_merge_id(shell->ui_manager), + "/menubar/HelpMenu/HelpMenuModules/LastSep", + about_module, about_module, GTK_UI_MANAGER_AUTO, TRUE); } static void @@ -435,7 +452,7 @@ static void add_modules_to_gui(gpointer data, gpointer user_data) -1); } - add_module_to_view_menu(module->name, module->icon); + add_module_to_menu(module->name, module->icon); if (module->entries) { ShellModuleEntry *entry; diff --git a/hardinfo2/stock.c b/hardinfo2/stock.c index 7dc22b7d..98052186 100644 --- a/hardinfo2/stock.c +++ b/hardinfo2/stock.c @@ -25,8 +25,10 @@ static struct { gchar *filename; gchar *stock_id; } stock_icons[] = { - { "report.png", HI_STOCK_REPORT }, - { "internet.png", HI_STOCK_INTERNET }, + { "report.png", HI_STOCK_REPORT }, + { "internet.png", HI_STOCK_INTERNET }, + { "module.png", HI_STOCK_MODULE }, + { "about-modules.png", HI_STOCK_ABOUT_MODULES }, }; static GtkIconFactory *icon_factory; diff --git a/hardinfo2/stock.h b/hardinfo2/stock.h index 60ee782a..8f4e634b 100644 --- a/hardinfo2/stock.h +++ b/hardinfo2/stock.h @@ -21,6 +21,8 @@ #define HI_STOCK_REPORT "hi-stock-report" #define HI_STOCK_INTERNET "hi-stock-internet" +#define HI_STOCK_MODULE "hi-stock-module" +#define HI_STOCK_ABOUT_MODULES "hi-stock-about-modules" void stock_icons_init(void); void stock_icon_register(gchar *filename, gchar *stock_id); diff --git a/hardinfo2/uidefs.xml b/hardinfo2/uidefs.xml index 3eff07e4..f4fad0e3 100644 --- a/hardinfo2/uidefs.xml +++ b/hardinfo2/uidefs.xml @@ -17,9 +17,14 @@ <separator name="LastSep"/> </menu> <menu name="HelpMenu" action="HelpMenuAction"> + <menuitem name="OnlineDocs" action="OnlineDocsAction"/> + <separator/> <menuitem name="WebPage" action="HomePageAction"/> <menuitem name="ReportBug" action="ReportBugAction"/> <separator/> + <menu name="HelpMenuModules" action="HelpMenuModulesAction"> + <separator name="LastSep"/> + </menu> <menuitem name="About" action="AboutAction"/> </menu> </menubar> diff --git a/hardinfo2/util.c b/hardinfo2/util.c index ecd2b6fa..b51dab5d 100644 --- a/hardinfo2/util.c +++ b/hardinfo2/util.c @@ -555,6 +555,17 @@ static void module_free(ShellModule *module) g_free(module); } +ModuleAbout *module_get_about(ShellModule *module) +{ + ModuleAbout *(*get_about)(void); + + if (g_module_symbol(module->dll, "hi_module_get_about", (gpointer) &get_about)) { + return get_about(); + } + + return NULL; +} + static GSList *modules_check_deps(GSList *modules) { GSList *mm; |