diff options
author | Leandro A. F. Pereira <leandro@hardinfo.org> | 2007-01-06 12:47:33 +0000 |
---|---|---|
committer | Leandro A. F. Pereira <leandro@hardinfo.org> | 2007-01-06 12:47:33 +0000 |
commit | 5862c823a3dca7a95027134b05b731d46d0db1d7 (patch) | |
tree | d02cb0811f08442cb5fa6eaeeead159f69b1ac06 | |
parent | be3013df51de306e4494419c595727569ad2c284 (diff) |
Let the fun begin! :)
-rw-r--r-- | hardinfo2/arch/linux/common/devmemory.h | 13 | ||||
-rw-r--r-- | hardinfo2/benchmark.c | 2 | ||||
-rw-r--r-- | hardinfo2/computer.c | 6 | ||||
-rw-r--r-- | hardinfo2/hardinfo.h | 1 | ||||
-rw-r--r-- | hardinfo2/pixmaps/boot.png | bin | 0 -> 783 bytes | |||
-rw-r--r-- | hardinfo2/pixmaps/close.png | bin | 0 -> 347 bytes | |||
-rw-r--r-- | hardinfo2/shell.c | 76 | ||||
-rw-r--r-- | hardinfo2/shell.h | 8 | ||||
-rw-r--r-- | hardinfo2/util.c | 47 |
9 files changed, 130 insertions, 23 deletions
diff --git a/hardinfo2/arch/linux/common/devmemory.h b/hardinfo2/arch/linux/common/devmemory.h index 6b3353a7..780ab12f 100644 --- a/hardinfo2/arch/linux/common/devmemory.h +++ b/hardinfo2/arch/linux/common/devmemory.h @@ -21,13 +21,14 @@ static GHashTable *memlabels; static void __scan_memory() { gchar **keys, *tmp; - static gint linux24_offset = -1; + static gint offset = -1; gint i; - if (linux24_offset == -1) { - linux24_offset = idle_free(module_call_method("computer::isLinux2.4")) ? - 3 : 0; - DEBUG("linux24_offset=%d", linux24_offset); + if (offset == -1) { + /* gah. linux 2.4 adds three lines of data we don't need in + /proc/meminfo */ + offset = strstr(idle_free(module_call_method("computer::getOSKernel")), + "Linux 2.4") ? 3 : 0; } g_file_get_contents("/proc/meminfo", &meminfo, NULL, NULL); @@ -40,7 +41,7 @@ static void __scan_memory() meminfo = g_strdup(""); lginterval = g_strdup(""); - for (i = linux24_offset; keys[i]; i++) { + for (i = offset; keys[i]; i++) { gchar **newkeys = g_strsplit(keys[i], ":", 0); if (!newkeys[0]) { diff --git a/hardinfo2/benchmark.c b/hardinfo2/benchmark.c index 601329ce..1a823f13 100644 --- a/hardinfo2/benchmark.c +++ b/hardinfo2/benchmark.c @@ -206,7 +206,7 @@ const gchar *hi_note_func(gint entry) return "Results in seconds. Lower is better."; } - return ""; + return NULL; } gchar *hi_module_get_name(void) diff --git a/hardinfo2/computer.c b/hardinfo2/computer.c index a9bd3a93..b1fd029a 100644 --- a/hardinfo2/computer.c +++ b/hardinfo2/computer.c @@ -357,17 +357,17 @@ gchar *callback_users() "%s\n", human_users, sys_users); } -gchar *get_is_linux_24(void) +gchar *get_os_kernel(void) { scan_os(FALSE); - return strstr(computer->os->kernel, "Linux 2.4") ? "" : NULL; + return computer->os->kernel; } ShellModuleMethod* hi_exported_methods(void) { static ShellModuleMethod m[] = { - { "isLinux2.4", get_is_linux_24 }, + { "getOSKernel", get_os_kernel }, { NULL } }; diff --git a/hardinfo2/hardinfo.h b/hardinfo2/hardinfo.h index 68b93441..3bc45959 100644 --- a/hardinfo2/hardinfo.h +++ b/hardinfo2/hardinfo.h @@ -93,6 +93,7 @@ void module_entry_scan_all(ModuleEntry *entries); void module_entry_reload(ShellModuleEntry *module_entry); void module_entry_scan(ShellModuleEntry *module_entry); gchar *module_entry_function(ShellModuleEntry *module_entry); +const gchar *module_entry_get_note(ShellModuleEntry *module_entry); /* BinReloc stuff */ gboolean binreloc_init(gboolean try_hardcoded); diff --git a/hardinfo2/pixmaps/boot.png b/hardinfo2/pixmaps/boot.png Binary files differnew file mode 100644 index 00000000..0c2a2d10 --- /dev/null +++ b/hardinfo2/pixmaps/boot.png diff --git a/hardinfo2/pixmaps/close.png b/hardinfo2/pixmaps/close.png Binary files differnew file mode 100644 index 00000000..9b43c0a7 --- /dev/null +++ b/hardinfo2/pixmaps/close.png diff --git a/hardinfo2/shell.c b/hardinfo2/shell.c index 1f2e99f1..b81e0121 100644 --- a/hardinfo2/shell.c +++ b/hardinfo2/shell.c @@ -303,6 +303,41 @@ static void destroy_me(void) cb_quit(); } +static void close_note(GtkWidget *widget, gpointer user_data) +{ + gtk_widget_hide(shell->note->frame); +} + +static ShellNote *note_new(void) +{ + ShellNote *note; + GtkWidget *hbox, *icon, *button; + + note = g_new0(ShellNote, 1); + note->label = gtk_label_new(""); + note->frame = gtk_frame_new(NULL); + button = gtk_button_new(); + + icon = icon_cache_get_image("close.png"); + gtk_widget_show(icon); + gtk_container_add(GTK_CONTAINER(button), icon); + gtk_button_set_relief(GTK_BUTTON(button), GTK_RELIEF_NONE); + g_signal_connect(G_OBJECT(button), "clicked", (GCallback) close_note, NULL); + + hbox = gtk_hbox_new(FALSE, 3); + icon = icon_cache_get_image("dialog-information.png"); + + gtk_box_pack_start(GTK_BOX(hbox), icon, FALSE, FALSE, 0); + gtk_box_pack_start(GTK_BOX(hbox), note->label, FALSE, FALSE, 0); + gtk_box_pack_end(GTK_BOX(hbox), button, FALSE, FALSE, 0); + + gtk_container_set_border_width(GTK_CONTAINER(hbox), 5); + gtk_container_add(GTK_CONTAINER(note->frame), hbox); + gtk_widget_show_all(hbox); + + return note; +} + static void create_window(void) { GtkWidget *vbox, *hbox; @@ -342,13 +377,20 @@ static void create_window(void) gtk_box_pack_end(GTK_BOX(vbox), shell->hpaned, TRUE, TRUE, 0); gtk_paned_set_position(GTK_PANED(shell->hpaned), 210); + vbox = gtk_vbox_new(FALSE, 5); + gtk_widget_show(vbox); + gtk_paned_add2(GTK_PANED(shell->hpaned), vbox); + + shell->note = note_new(); + gtk_box_pack_end(GTK_BOX(vbox), shell->note->frame, FALSE, FALSE, 0); + shell->vpaned = gtk_vpaned_new(); + gtk_box_pack_start(GTK_BOX(vbox), shell->vpaned, TRUE, TRUE, 0); gtk_widget_show(shell->vpaned); - gtk_paned_add2(GTK_PANED(shell->hpaned), shell->vpaned); - + shell->notebook = gtk_notebook_new(); gtk_paned_add2(GTK_PANED(shell->vpaned), shell->notebook); - + gtk_widget_show(shell->window); while (gtk_events_pending()) gtk_main_iteration(); @@ -476,6 +518,7 @@ static void add_modules_to_gui(gpointer data, gpointer user_data) } } + void shell_init(GSList * modules) { if (shell) { @@ -487,15 +530,15 @@ void shell_init(GSList * modules) create_window(); + shell_action_set_property("CopyAction", "is-important", TRUE); + shell_action_set_property("RefreshAction", "is-important", TRUE); + shell_action_set_property("ReportAction", "is-important", TRUE); + shell->tree = tree_new(); shell->info = info_tree_new(FALSE); shell->moreinfo = info_tree_new(TRUE); shell->loadgraph = load_graph_new(75); - shell_action_set_property("CopyAction", "is-important", TRUE); - shell_action_set_property("RefreshAction", "is-important", TRUE); - shell_action_set_property("ReportAction", "is-important", TRUE); - gtk_paned_pack1(GTK_PANED(shell->hpaned), shell->tree->scroll, SHELL_PACK_RESIZE, SHELL_PACK_SHRINK); gtk_paned_pack1(GTK_PANED(shell->vpaned), shell->info->scroll, @@ -522,6 +565,7 @@ void shell_init(GSList * modules) load_graph_configure_expose(shell->loadgraph); gtk_widget_hide(shell->notebook); + gtk_widget_hide(shell->note->frame); shell_status_update("Done."); shell_status_set_enabled(FALSE); @@ -915,6 +959,22 @@ static void update_progress() GTK_TREE_MODEL(sortable)); } +void shell_set_note_from_entry(ShellModuleEntry *entry) +{ + if (entry->notefunc) { + const gchar *note = module_entry_get_note(entry); + + if (note) { + gtk_label_set_markup(GTK_LABEL(shell->note->label), note); + gtk_widget_show(shell->note->frame); + } else { + gtk_widget_hide(shell->note->frame); + } + } else { + gtk_widget_hide(shell->note->frame); + } +} + static void module_selected_show_info(ShellModuleEntry * entry, gboolean reload) { @@ -969,6 +1029,8 @@ module_selected_show_info(ShellModuleEntry * entry, gboolean reload) if (shell->view_type == SHELL_VIEW_PROGRESS) { update_progress(); } + + shell_set_note_from_entry(entry); g_strfreev(groups); g_key_file_free(key_file); diff --git a/hardinfo2/shell.h b/hardinfo2/shell.h index ff096e5f..a90ccf8f 100644 --- a/hardinfo2/shell.h +++ b/hardinfo2/shell.h @@ -24,6 +24,7 @@ typedef struct _Shell Shell; typedef struct _ShellTree ShellTree; typedef struct _ShellInfoTree ShellInfoTree; +typedef struct _ShellNote ShellNote; typedef struct _ShellModule ShellModule; typedef struct _ShellModuleMethod ShellModuleMethod; @@ -75,6 +76,7 @@ struct _Shell { ShellTree *tree; ShellInfoTree *info, *moreinfo; ShellModuleEntry *selected; + ShellNote *note; LoadGraph *loadgraph; GtkActionGroup *action_group; @@ -104,6 +106,11 @@ struct _ShellInfoTree { GtkTreeViewColumn *col_progress, *col_value; }; +struct _ShellNote { + GtkWidget *frame; + GtkWidget *label; +}; + struct _ShellModule { gchar *name; GdkPixbuf *icon; @@ -154,6 +161,7 @@ void shell_action_set_property(const gchar *action_name, gboolean setting); void shell_set_side_pane_visible(gboolean setting); +void shell_set_note_from_entry(ShellModuleEntry *entry); void shell_ui_manager_set_visible(const gchar *path, gboolean setting); diff --git a/hardinfo2/util.c b/hardinfo2/util.c index dc4d6553..50a2e095 100644 --- a/hardinfo2/util.c +++ b/hardinfo2/util.c @@ -176,6 +176,7 @@ gboolean binreloc_init(gboolean try_hardcoded) /* If the runtime data directories we previously found, don't even try to find them again. */ if (params.path_data && params.path_lib) { + DEBUG("data and lib path already found."); return TRUE; } @@ -187,9 +188,13 @@ gboolean binreloc_init(gboolean try_hardcoded) if (error) { g_error_free(error); } + + DEBUG("%strying hardcoded paths.", try_hardcoded ? "" : "binreloc init failed. "); } else { /* If we were able to initialize BinReloc, build the default data and library paths. */ + DEBUG("done, trying to use binreloc paths."); + tmp = gbr_find_data_dir(PREFIX); params.path_data = g_build_filename(tmp, "hardinfo", NULL); g_free(tmp); @@ -199,10 +204,16 @@ gboolean binreloc_init(gboolean try_hardcoded) g_free(tmp); } + DEBUG("searching for runtime data on these locations:"); + DEBUG(" lib: %s", params.path_lib); + DEBUG(" data: %s", params.path_data); + /* Try to see if the uidefs.xml file isn't missing. This isn't the definitive test, but it should do okay for most situations. */ tmp = g_build_filename(params.path_data, "uidefs.xml", NULL); if (!g_file_test(tmp, G_FILE_TEST_EXISTS)) { + DEBUG("runtime data not found"); + g_free(params.path_data); g_free(params.path_lib); g_free(tmp); @@ -212,15 +223,18 @@ gboolean binreloc_init(gboolean try_hardcoded) if (try_hardcoded) { /* We tried the hardcoded paths, but still was unable to find the runtime data. Give up. */ + DEBUG("giving up"); return FALSE; } else { /* Even though BinReloc worked OK, the runtime data was not found. Try the hardcoded paths. */ + DEBUG("trying to find elsewhere"); return binreloc_init(TRUE); } } g_free(tmp); + DEBUG("runtime data found!"); /* We found the runtime data; hope everything is fine */ return TRUE; } @@ -472,6 +486,8 @@ static ShellModule *module_load(gchar *filename) module->weight = weight_func ? weight_func() : 0; module->name = name_func(); + + DEBUG("%p", module->name); entries = get_module_entries(); while (entries[i].name) { @@ -501,6 +517,8 @@ static ShellModule *module_load(gchar *filename) module_register_methods(module); } else { failed: + DEBUG("loading module %s failed", filename); + g_free(module->name); g_free(module); module = NULL; @@ -536,10 +554,12 @@ static void module_entry_free(gpointer data, gpointer user_data) { ShellModuleEntry *entry = (ShellModuleEntry *)data; - g_free(entry->name); - g_object_unref(entry->icon); + if (entry) { + /*g_free(entry->name);*/ + g_object_unref(entry->icon); - g_free(entry); + g_free(entry); + } } static void module_free(ShellModule *module) @@ -587,7 +607,7 @@ static GSList *modules_check_deps(GSList *modules) ShellModule *m; gboolean found = FALSE; - DEBUG(" depends on: %s", deps[i]); + DEBUG(" %s depends on %s", module->name, deps[i]); for (l = modules; l; l = l->next) { m = (ShellModule *)l->data; @@ -601,9 +621,14 @@ static GSList *modules_check_deps(GSList *modules) g_free(name); } + DEBUG(" dependency %s", found ? "found" : "not found"); + if (!found) { if (params.autoload_deps) { - modules = g_slist_append(modules, module_load(deps[i])); + ShellModule *mod = module_load(deps[i]); + + if (mod) + modules = g_slist_append(modules, mod); modules = modules_check_deps(modules); /* re-check dependencies */ break; @@ -624,7 +649,10 @@ static GSList *modules_check_deps(GSList *modules) NULL); if (gtk_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_ACCEPT) { - modules = g_slist_append(modules, module_load(deps[i])); + ShellModule *mod = module_load(deps[i]); + + if (mod) + modules = g_slist_append(modules, mod); modules = modules_check_deps(modules); /* re-check dependencies */ } else { modules = g_slist_remove(modules, module); @@ -637,6 +665,8 @@ static GSList *modules_check_deps(GSList *modules) } } } + } else { + DEBUG(" no dependencies needed"); } } @@ -887,3 +917,8 @@ gchar *module_entry_function(ShellModuleEntry *module_entry) return g_strdup("[Error]\n" "Invalid module="); } + +const gchar *module_entry_get_note(ShellModuleEntry *module_entry) +{ + return module_entry->notefunc(module_entry->number); +} |