aboutsummaryrefslogtreecommitdiff
path: root/hardinfo.c
diff options
context:
space:
mode:
authorSimon Quigley <tsimonq2@ubuntu.com>2017-06-19 14:38:31 -0500
committerSimon Quigley <tsimonq2@ubuntu.com>2017-06-19 14:38:31 -0500
commita08438bda21b3e0d7db2db2360d040841970104d (patch)
treef8a13a1e368bfbd14fe2d9492d6d5824eb5712ce /hardinfo.c
parent8c1612d32c5682a86216adb8c8d11ce715fe5475 (diff)
Import Upstream version 0.3.7pre
Diffstat (limited to 'hardinfo.c')
-rw-r--r--hardinfo.c213
1 files changed, 88 insertions, 125 deletions
diff --git a/hardinfo.c b/hardinfo.c
index e78cf7f5..d1c8d3fd 100644
--- a/hardinfo.c
+++ b/hardinfo.c
@@ -17,15 +17,18 @@
#include "pixmaps/hdd.xpm"
#include "pixmaps/gen_connector.xpm"
#include "pixmaps/scsi.xpm"
+#include "pixmaps/processor.xpm"
#include "computer.h"
#include "status.h"
+#include "stock.h"
GenericDevice *generic_devices = NULL;
-void hi_show_device_info(GtkCTree * tree, GList * node,
+void hi_enable_details_button(GtkCTree * tree, GList * node,
gint column, gpointer user_data);
-void hi_hide_device_info(GtkCTree * tree, GList * node,
+void hi_enable_details_button_real(MainWindow *mainwindow, GenericDevice *dev);
+void hi_disable_details_button(GtkCTree * tree, GList * node,
gint column, gpointer user_data);
void hi_scan_all(MainWindow * mainwindow);
@@ -37,7 +40,7 @@ main_window_refresh(GtkWidget * widget, gpointer data)
if (!mainwindow)
return;
- hi_hide_device_info(NULL, NULL, 0, mainwindow);
+ hi_disable_details_button(NULL, NULL, 0, mainwindow);
memory_update(mainwindow);
uptime_update(mainwindow);
@@ -50,18 +53,21 @@ static void
about_window_create(void)
{
GtkAbout *about;
+ const gchar *sysinfo = HOSTNAME " (" PLATFORM KERNEL ")";
const gchar *authors[] = {
">Written by:",
- "Leandro Pereira (leandro@linuxmag.com.br)",
+ "Leandro A. F. Pereira (leandro@linuxmag.com.br)",
">Disclaimer:",
- "This is free software; you can modify and/or distribute it",
- "under the terms of GNU GPL version 2. See http://www.fsf.org/",
- "for more information.",
+ "This is free software; you can modify and/or distribute it",
+ "under the terms of GNU GPL version 2. See http://www.fsf.org/",
+ "for more information.",
+ ">Compiled on:",
+ sysinfo,
NULL
};
about = gtk_about_new("HardInfo", VERSION,
- _("System information tool for Linux.\n"),
+ _("System information tool for GNU/Linux.\n"),
authors, IMG_PREFIX "logo.png");
}
@@ -69,22 +75,20 @@ about_window_create(void)
MainWindow *
main_window_create(void)
{
- GtkWidget *window, *mbox, *vbox, *frame, *ctree, *scroll;
+ GtkWidget *window, *mbox, *vbox, *ctree, *scroll;
GtkWidget *notebook, *label, *hbox, *btn, *hbbox;
MainWindow *mainwindow;
mainwindow = g_new0(MainWindow, 1);
+ mainwindow->det_window = detail_window_new();
+
window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
gtk_container_set_border_width(GTK_CONTAINER(window), 4);
gtk_window_set_title(GTK_WINDOW(window), _("System Information"));
-#ifdef GTK2
g_signal_connect(G_OBJECT(window), "delete-event", gtk_main_quit, NULL);
-#else
- gtk_signal_connect(GTK_OBJECT(window), "delete-event",
- (GtkSignalFunc) gtk_main_quit, NULL);
-#endif
+ gtk_window_set_icon_from_file(GTK_WINDOW(window), IMG_PREFIX "logo.png", NULL);
mbox = gtk_vbox_new(FALSE, 5);
gtk_widget_show(mbox);
@@ -102,36 +106,24 @@ main_window_create(void)
gtk_notebook_append_page(GTK_NOTEBOOK(notebook), vbox,
gtk_label_new(_("Computer")));
-#ifdef GTK2
label = gtk_label_new(_("<b><big>Operating System</big></b>"));
gtk_label_set_use_markup(GTK_LABEL(label), TRUE);
-#else
- label = gtk_label_new(_("Operating System"));
-#endif
gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.5);
gtk_widget_show(label);
gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0);
gtk_box_pack_start(GTK_BOX(vbox), os_get_widget(mainwindow),
FALSE, FALSE, 0);
-#ifdef GTK2
label = gtk_label_new(_("<b><big>Processor</big></b>"));
gtk_label_set_use_markup(GTK_LABEL(label), TRUE);
-#else
- label = gtk_label_new(_("Processor"));
-#endif
gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.5);
gtk_widget_show(label);
gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0);
gtk_box_pack_start(GTK_BOX(vbox), processor_get_widget(), FALSE,
FALSE, 0);
-#ifdef GTK2
label = gtk_label_new(_("<b><big>Memory Usage</big></b>"));
gtk_label_set_use_markup(GTK_LABEL(label), TRUE);
-#else
- label = gtk_label_new(_("Memory Usage"));
-#endif
gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.5);
gtk_widget_show(label);
gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0);
@@ -145,7 +137,21 @@ main_window_create(void)
gtk_container_set_border_width(GTK_CONTAINER(vbox), 4);
gtk_widget_show(vbox);
gtk_notebook_append_page(GTK_NOTEBOOK(notebook), vbox,
- gtk_label_new(_("Devices")));
+ gtk_label_new(_("Details")));
+
+ hbbox = gtk_hbutton_box_new();
+ gtk_container_set_border_width(GTK_CONTAINER(hbbox), 4);
+ gtk_widget_show(hbbox);
+ gtk_box_pack_end(GTK_BOX(vbox), hbbox, FALSE, FALSE, 0);
+ gtk_button_box_set_spacing(GTK_BUTTON_BOX(hbbox), 6);
+ gtk_button_box_set_layout(GTK_BUTTON_BOX(hbbox), GTK_BUTTONBOX_END);
+
+ btn = gtk_button_new_from_stock(HI_DETAILS);
+ g_signal_connect(G_OBJECT(btn), "clicked",
+ (GCallback) detail_window_show, mainwindow);
+ gtk_widget_show(btn);
+ gtk_box_pack_end(GTK_BOX(hbbox), btn, FALSE, FALSE, 0);
+ mainwindow->details_button = btn;
scroll = gtk_scrolled_window_new(NULL, NULL);
gtk_box_pack_start(GTK_BOX(vbox), scroll, TRUE, TRUE, 0);
@@ -162,21 +168,11 @@ main_window_create(void)
gtk_clist_set_column_width(GTK_CLIST(ctree), 0, 32);
gtk_clist_set_column_width(GTK_CLIST(ctree), 1, 32);
gtk_clist_set_row_height(GTK_CLIST(ctree), 18);
-#ifdef GTK2
g_signal_connect(G_OBJECT(ctree), "tree-select-row",
- (GCallback) hi_show_device_info, mainwindow);
+ (GCallback) hi_enable_details_button, mainwindow);
g_signal_connect(G_OBJECT(ctree), "tree-unselect-row",
- (GCallback) hi_hide_device_info, mainwindow);
-#else
- gtk_signal_connect(GTK_OBJECT(ctree), "tree-select-row",
- (GtkCTreeFunc) hi_show_device_info, mainwindow);
- gtk_signal_connect(GTK_OBJECT(ctree), "tree-unselect-row",
- (GtkCTreeFunc) hi_hide_device_info, mainwindow);
-#endif
-
- frame = gtk_frame_new(_("Device information"));
- gtk_box_pack_start(GTK_BOX(vbox), frame, FALSE, FALSE, 0);
-
+ (GCallback) hi_disable_details_button, mainwindow);
+
/*
* Environment tab
*/
@@ -186,19 +182,14 @@ main_window_create(void)
gtk_notebook_append_page(GTK_NOTEBOOK(notebook), vbox,
gtk_label_new(_("Environment")));
-#ifdef GTK2
label = gtk_label_new(_("<b><big>X-Window System</big></b>"));
gtk_label_set_use_markup(GTK_LABEL(label), TRUE);
-#else
- label = gtk_label_new(_("X-Window System"));
-#endif
gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.5);
gtk_widget_show(label);
gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0);
- gtk_box_pack_start(GTK_BOX(vbox), x11_get_widget(mainwindow),
- FALSE, FALSE, 0);
+// gtk_box_pack_start(GTK_BOX(vbox), x11_get_widget(mainwindow),
+// FALSE, FALSE, 0);
-#if 0
/*
* Network tab
*/
@@ -208,23 +199,17 @@ main_window_create(void)
gtk_notebook_append_page(GTK_NOTEBOOK(notebook), vbox,
gtk_label_new(_("Network")));
-#ifdef GTK2
label = gtk_label_new(_("<b><big>Interfaces</big></b>"));
gtk_label_set_use_markup(GTK_LABEL(label), TRUE);
-#else
- label = gtk_label_new(_("Interfaces"));
-#endif
gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.5);
gtk_widget_show(label);
gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0);
gtk_box_pack_start(GTK_BOX(vbox), net_get_widget(mainwindow),
TRUE, TRUE, 0);
-#endif
/*
* Buttons
*/
-
hbox = gtk_hbox_new(FALSE, 5);
gtk_widget_show(hbox);
gtk_box_pack_start(GTK_BOX(mbox), hbox, FALSE, FALSE, 0);
@@ -236,14 +221,9 @@ main_window_create(void)
gtk_button_box_set_spacing(GTK_BUTTON_BOX(hbbox), 6);
gtk_button_box_set_layout(GTK_BUTTON_BOX(hbbox), GTK_BUTTONBOX_START);
- btn = gtk_button_new_with_mnemonic(_("Abo_ut..."));
-#ifdef GTK2
+ btn = gtk_button_new_from_stock(HI_ABOUT);
g_signal_connect(G_OBJECT(btn), "clicked",
(GCallback) about_window_create, NULL);
-#else
- gtk_signal_connect(GTK_OBJECT(btn), "clicked",
- (GtkSignalFunc) about_window_create, NULL);
-#endif
gtk_widget_show(btn);
gtk_box_pack_start(GTK_BOX(hbbox), btn, FALSE, FALSE, 0);
@@ -254,50 +234,21 @@ main_window_create(void)
gtk_button_box_set_spacing(GTK_BUTTON_BOX(hbbox), 6);
gtk_button_box_set_layout(GTK_BUTTON_BOX(hbbox), GTK_BUTTONBOX_END);
-#if 0
- btn = gtk_button_new_with_label(_("About"));
-#ifdef GTK2
- g_signal_connect(G_OBJECT(btn), "clicked",
- (GCallback) about_window_create, NULL);
-#else
- gtk_signal_connect(GTK_OBJECT(btn), "clicked",
- (GtkSignalFunc) about_window_create, NULL);
-#endif
- gtk_widget_show(btn);
- gtk_box_pack_start(GTK_BOX(hbbox), btn, FALSE, FALSE, 0);
-#endif
-
-#ifdef GTK2
btn = gtk_button_new_from_stock(GTK_STOCK_REFRESH);
g_signal_connect(G_OBJECT(btn), "clicked",
(GCallback) main_window_refresh, mainwindow);
-#else
- btn = gtk_button_new_with_label(_("Refresh"));
- gtk_signal_connect(GTK_OBJECT(btn), "clicked",
- (GtkSignalFunc) main_window_refresh, mainwindow);
-#endif
gtk_widget_show(btn);
gtk_box_pack_start(GTK_BOX(hbbox), btn, FALSE, FALSE, 0);
-#ifdef GTK2
btn = gtk_button_new_from_stock(GTK_STOCK_CLOSE);
g_signal_connect(G_OBJECT(btn), "clicked", gtk_main_quit, NULL);
-#else
- btn = gtk_button_new_with_label(_("Close"));
- gtk_signal_connect(GTK_OBJECT(btn), "clicked",
- (GtkSignalFunc) gtk_main_quit, NULL);
-#endif
gtk_widget_show(btn);
gtk_box_pack_start(GTK_BOX(hbbox), btn, FALSE, FALSE, 0);
-
-
gtk_widget_show_all(window);
- gtk_widget_hide(frame);
mainwindow->window = window;
mainwindow->ctree = ctree;
- mainwindow->frame = frame;
return mainwindow;
}
@@ -347,7 +298,6 @@ tree_group_new(MainWindow * mainwindow, const gchar * name, DeviceType type)
case SERIAL:
pixmap = gdk_pixmap_colormap_create_from_xpm_d
(NULL, colormap, &mask, NULL, gen_connector_xpm);
-
break;
case V4L:
case PCI:
@@ -367,6 +317,11 @@ tree_group_new(MainWindow * mainwindow, const gchar * name, DeviceType type)
pixmap = gdk_pixmap_colormap_create_from_xpm_d
(NULL, colormap, &mask, NULL, usb_xpm);
break;
+ case MODULE:
+ case PROCESSOR:
+ pixmap = gdk_pixmap_colormap_create_from_xpm_d
+ (NULL, colormap, &mask, NULL, processor_xpm);
+ break;
default:
mask = pixmap = NULL;
break;
@@ -422,24 +377,24 @@ hi_insert_generic(gpointer device, DeviceType type)
}
void
-hi_hide_device_info(GtkCTree * tree, GList * node,
+hi_disable_details_button(GtkCTree * tree, GList * node,
gint column, gpointer user_data)
{
MainWindow *mainwindow = (MainWindow *) user_data;
- gtk_widget_hide(mainwindow->frame);
+ gtk_widget_set_sensitive(GTK_WIDGET(mainwindow->details_button), FALSE);
}
-void
-hi_show_device_info(GtkCTree * tree, GList * node,
+void hi_enable_details_button(GtkCTree * tree, GList * node,
gint column, gpointer user_data)
{
- GenericDevice *dev;
MainWindow *mainwindow = (MainWindow *) user_data;
- dev = (GenericDevice *) gtk_ctree_node_get_row_data
- (GTK_CTREE(tree), GTK_CLIST(tree)->selection->data);
+ gtk_widget_set_sensitive(GTK_WIDGET(mainwindow->details_button), TRUE);
+}
+void hi_show_device_info_real(MainWindow *mainwindow, GenericDevice *dev)
+{
if (!dev)
return;
@@ -452,6 +407,10 @@ hi_show_device_info(GtkCTree * tree, GList * node,
break;
switch (dev->type) {
+ case MODULE:
+ dev_info(ModInfo, mod, hi_show_module_info);
+ case PROCESSOR:
+ dev_info(CPUDevice, cpu, hi_show_cpu_info);
case PCI:
dev_info(PCIDevice, pci, hi_show_pci_info);
case ISAPnP:
@@ -474,25 +433,24 @@ hi_show_device_info(GtkCTree * tree, GList * node,
return;
break;
}
-
- gtk_widget_show(mainwindow->frame);
-
}
void
hi_scan_all(MainWindow * mainwindow)
{
- myStatus *status;
- PCIDevice *pci;
- ISADevice *isa;
- IDEDevice *ide;
- SCSIDevice *scsi;
- V4LDevice *v4l;
- ParportDevice *pp;
- SerialDevice *sd;
- GtkCTreeNode *node;
- GenericDevice *gd = generic_devices;
- gchar *buf;
+ myStatus *status;
+ PCIDevice *pci;
+ ISADevice *isa;
+ IDEDevice *ide;
+ CPUDevice *cpu;
+ SCSIDevice *scsi;
+ V4LDevice *v4l;
+ ParportDevice *pp;
+ SerialDevice *sd;
+ GtkCTreeNode *node;
+ ModInfo *mod;
+ GenericDevice *gd = generic_devices;
+ gchar *buf;
status = my_status_new(_("Scanning Devices"), _("Scanning devices..."));
@@ -503,6 +461,7 @@ hi_scan_all(MainWindow * mainwindow)
g_free(buf); \
my_status_pulse(status)
+ DEVICE_SCAN("CPU", cpu, computer_get_info);
DEVICE_SCAN("PCI", pci, hi_scan_pci);
DEVICE_SCAN("ISA PnP", isa, hi_scan_isapnp);
DEVICE_SCAN("IDE", ide, hi_scan_ide);
@@ -510,6 +469,7 @@ hi_scan_all(MainWindow * mainwindow)
DEVICE_SCAN("V4L", v4l, hi_scan_v4l);
DEVICE_SCAN("Parallel", pp, hi_scan_parport);
DEVICE_SCAN("Serial", sd, hi_scan_serial);
+ DEVICE_SCAN("modules", mod, hi_scan_modules);
gtk_clist_freeze(GTK_CLIST(mainwindow->ctree));
@@ -539,6 +499,14 @@ hi_scan_all(MainWindow * mainwindow)
} \
}
+
+ /*
+ * Processor info
+ */
+ node = tree_group_new(mainwindow, _("Processor"), PROCESSOR);
+ hi_insert_generic(cpu, PROCESSOR);
+ tree_insert_item(mainwindow, node, cpu->processor, generic_devices);
+
CHECK_INSERT(pci, _("PCI Devices"), PCI, name);
CHECK_INSERT(isa, _("ISA PnP Devices"), ISAPnP, card);
@@ -553,36 +521,37 @@ hi_scan_all(MainWindow * mainwindow)
CHECK_INSERT(v4l, _("Video for Linux"), V4L, name);
CHECK_INSERT(sd, _("Communication Ports"), SERIAL, name);
CHECK_INSERT(pp, _("Parallel Ports"), PARPORT, name);
-
+
+ CHECK_INSERT(mod, _("Kernel Modules"), MODULE, description);
+
gtk_clist_thaw(GTK_CLIST(mainwindow->ctree));
my_status_destroy(status);
}
-#if 0
static void
usage(char *argv0)
{
- g_print("%s [--prefix <prefix>]\n", argv0);
+ g_print("%s [--help] [--prefix <prefix>]\n", argv0);
exit(1);
}
-#endif
int
main(int argc, char **argv)
{
MainWindow *mainwindow;
-#if 0
gint i;
-#endif
#ifdef ENABLE_NLS
intl_init();
#endif
- g_print("HardInfo " VERSION "\n");
+ g_print("HardInfo " VERSION);
+ if (strstr(VERSION, "pre")) {
+ g_print(" *** PRE-RELEASE ***");
+ }
g_print
- ("Copyright (c) 2003 Leandro Pereira <leandro@linuxmag.com.br>\n\n");
+ ("\nCopyright (c) 2003 Leandro Pereira <leandro@linuxmag.com.br>\n\n");
g_print(_
("This is free software; you can modify and/or distribute it\n"));
g_print(_
@@ -591,13 +560,8 @@ main(int argc, char **argv)
gtk_init(&argc, &argv);
-#ifndef GTK2
- gdk_rgb_init();
- gtk_widget_set_default_colormap(gdk_rgb_get_cmap());
- gtk_widget_set_default_visual(gdk_rgb_get_visual());
-#endif
+ hi_stock_init();
-#if 0
for (i = 1; i < argc; i++) {
if (!strncmp(argv[i], "--help", 6) ||
!strncmp(argv[i], "-h", 2)) {
@@ -612,7 +576,6 @@ main(int argc, char **argv)
g_print("prefix = %s\n", argv[i]);
}
}
-#endif
mainwindow = main_window_create();
main_window_refresh(NULL, mainwindow);