17
17
#include "pixmaps/hdd.xpm"
18
18
#include "pixmaps/gen_connector.xpm"
19
19
#include "pixmaps/scsi.xpm"
20
#include "pixmaps/processor.xpm"
21
22
#include "computer.h"
22
23
#include "status.h"
24
26
GenericDevice *generic_devices = NULL;
26
void hi_show_device_info(GtkCTree * tree, GList * node,
28
void hi_enable_details_button(GtkCTree * tree, GList * node,
27
29
gint column, gpointer user_data);
28
void hi_hide_device_info(GtkCTree * tree, GList * node,
30
void hi_enable_details_button_real(MainWindow *mainwindow, GenericDevice *dev);
31
void hi_disable_details_button(GtkCTree * tree, GList * node,
29
32
gint column, gpointer user_data);
30
33
void hi_scan_all(MainWindow * mainwindow);
40
hi_hide_device_info(NULL, NULL, 0, mainwindow);
43
hi_disable_details_button(NULL, NULL, 0, mainwindow);
42
45
memory_update(mainwindow);
43
46
uptime_update(mainwindow);
50
53
about_window_create(void)
56
const gchar *sysinfo = HOSTNAME " (" PLATFORM KERNEL ")";
53
57
const gchar *authors[] = {
55
"Leandro Pereira (leandro@linuxmag.com.br)",
59
"Leandro A. F. Pereira (leandro@linuxmag.com.br)",
57
"This is free software; you can modify and/or distribute it",
58
"under the terms of GNU GPL version 2. See http://www.fsf.org/",
59
"for more information.",
61
"This is free software; you can modify and/or distribute it",
62
"under the terms of GNU GPL version 2. See http://www.fsf.org/",
63
"for more information.",
63
69
about = gtk_about_new("HardInfo", VERSION,
64
_("System information tool for Linux.\n"),
70
_("System information tool for GNU/Linux.\n"),
65
71
authors, IMG_PREFIX "logo.png");
70
76
main_window_create(void)
72
GtkWidget *window, *mbox, *vbox, *frame, *ctree, *scroll;
78
GtkWidget *window, *mbox, *vbox, *ctree, *scroll;
73
79
GtkWidget *notebook, *label, *hbox, *btn, *hbbox;
74
80
MainWindow *mainwindow;
76
82
mainwindow = g_new0(MainWindow, 1);
84
mainwindow->det_window = detail_window_new();
78
86
window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
79
87
gtk_container_set_border_width(GTK_CONTAINER(window), 4);
80
88
gtk_window_set_title(GTK_WINDOW(window), _("System Information"));
83
90
g_signal_connect(G_OBJECT(window), "delete-event", gtk_main_quit, NULL);
85
gtk_signal_connect(GTK_OBJECT(window), "delete-event",
86
(GtkSignalFunc) gtk_main_quit, NULL);
91
gtk_window_set_icon_from_file(GTK_WINDOW(window), IMG_PREFIX "logo.png", NULL);
89
93
mbox = gtk_vbox_new(FALSE, 5);
90
94
gtk_widget_show(mbox);
102
106
gtk_notebook_append_page(GTK_NOTEBOOK(notebook), vbox,
103
107
gtk_label_new(_("Computer")));
106
109
label = gtk_label_new(_("<b><big>Operating System</big></b>"));
107
110
gtk_label_set_use_markup(GTK_LABEL(label), TRUE);
109
label = gtk_label_new(_("Operating System"));
111
111
gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.5);
112
112
gtk_widget_show(label);
113
113
gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0);
114
114
gtk_box_pack_start(GTK_BOX(vbox), os_get_widget(mainwindow),
115
115
FALSE, FALSE, 0);
118
117
label = gtk_label_new(_("<b><big>Processor</big></b>"));
119
118
gtk_label_set_use_markup(GTK_LABEL(label), TRUE);
121
label = gtk_label_new(_("Processor"));
123
119
gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.5);
124
120
gtk_widget_show(label);
125
121
gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0);
126
122
gtk_box_pack_start(GTK_BOX(vbox), processor_get_widget(), FALSE,
130
125
label = gtk_label_new(_("<b><big>Memory Usage</big></b>"));
131
126
gtk_label_set_use_markup(GTK_LABEL(label), TRUE);
133
label = gtk_label_new(_("Memory Usage"));
135
127
gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.5);
136
128
gtk_widget_show(label);
137
129
gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0);
145
137
gtk_container_set_border_width(GTK_CONTAINER(vbox), 4);
146
138
gtk_widget_show(vbox);
147
139
gtk_notebook_append_page(GTK_NOTEBOOK(notebook), vbox,
148
gtk_label_new(_("Devices")));
140
gtk_label_new(_("Details")));
142
hbbox = gtk_hbutton_box_new();
143
gtk_container_set_border_width(GTK_CONTAINER(hbbox), 4);
144
gtk_widget_show(hbbox);
145
gtk_box_pack_end(GTK_BOX(vbox), hbbox, FALSE, FALSE, 0);
146
gtk_button_box_set_spacing(GTK_BUTTON_BOX(hbbox), 6);
147
gtk_button_box_set_layout(GTK_BUTTON_BOX(hbbox), GTK_BUTTONBOX_END);
149
btn = gtk_button_new_from_stock(HI_DETAILS);
150
g_signal_connect(G_OBJECT(btn), "clicked",
151
(GCallback) detail_window_show, mainwindow);
152
gtk_widget_show(btn);
153
gtk_box_pack_end(GTK_BOX(hbbox), btn, FALSE, FALSE, 0);
154
mainwindow->details_button = btn;
150
156
scroll = gtk_scrolled_window_new(NULL, NULL);
151
157
gtk_box_pack_start(GTK_BOX(vbox), scroll, TRUE, TRUE, 0);
162
168
gtk_clist_set_column_width(GTK_CLIST(ctree), 0, 32);
163
169
gtk_clist_set_column_width(GTK_CLIST(ctree), 1, 32);
164
170
gtk_clist_set_row_height(GTK_CLIST(ctree), 18);
166
171
g_signal_connect(G_OBJECT(ctree), "tree-select-row",
167
(GCallback) hi_show_device_info, mainwindow);
172
(GCallback) hi_enable_details_button, mainwindow);
168
173
g_signal_connect(G_OBJECT(ctree), "tree-unselect-row",
169
(GCallback) hi_hide_device_info, mainwindow);
171
gtk_signal_connect(GTK_OBJECT(ctree), "tree-select-row",
172
(GtkCTreeFunc) hi_show_device_info, mainwindow);
173
gtk_signal_connect(GTK_OBJECT(ctree), "tree-unselect-row",
174
(GtkCTreeFunc) hi_hide_device_info, mainwindow);
177
frame = gtk_frame_new(_("Device information"));
178
gtk_box_pack_start(GTK_BOX(vbox), frame, FALSE, FALSE, 0);
174
(GCallback) hi_disable_details_button, mainwindow);
181
177
* Environment tab
186
182
gtk_notebook_append_page(GTK_NOTEBOOK(notebook), vbox,
187
183
gtk_label_new(_("Environment")));
190
185
label = gtk_label_new(_("<b><big>X-Window System</big></b>"));
191
186
gtk_label_set_use_markup(GTK_LABEL(label), TRUE);
193
label = gtk_label_new(_("X-Window System"));
195
187
gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.5);
196
188
gtk_widget_show(label);
197
189
gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0);
198
gtk_box_pack_start(GTK_BOX(vbox), x11_get_widget(mainwindow),
190
// gtk_box_pack_start(GTK_BOX(vbox), x11_get_widget(mainwindow),
208
199
gtk_notebook_append_page(GTK_NOTEBOOK(notebook), vbox,
209
200
gtk_label_new(_("Network")));
212
202
label = gtk_label_new(_("<b><big>Interfaces</big></b>"));
213
203
gtk_label_set_use_markup(GTK_LABEL(label), TRUE);
215
label = gtk_label_new(_("Interfaces"));
217
204
gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.5);
218
205
gtk_widget_show(label);
219
206
gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0);
220
207
gtk_box_pack_start(GTK_BOX(vbox), net_get_widget(mainwindow),
228
213
hbox = gtk_hbox_new(FALSE, 5);
229
214
gtk_widget_show(hbox);
230
215
gtk_box_pack_start(GTK_BOX(mbox), hbox, FALSE, FALSE, 0);
236
221
gtk_button_box_set_spacing(GTK_BUTTON_BOX(hbbox), 6);
237
222
gtk_button_box_set_layout(GTK_BUTTON_BOX(hbbox), GTK_BUTTONBOX_START);
239
btn = gtk_button_new_with_mnemonic(_("Abo_ut..."));
224
btn = gtk_button_new_from_stock(HI_ABOUT);
241
225
g_signal_connect(G_OBJECT(btn), "clicked",
242
226
(GCallback) about_window_create, NULL);
244
gtk_signal_connect(GTK_OBJECT(btn), "clicked",
245
(GtkSignalFunc) about_window_create, NULL);
247
227
gtk_widget_show(btn);
248
228
gtk_box_pack_start(GTK_BOX(hbbox), btn, FALSE, FALSE, 0);
254
234
gtk_button_box_set_spacing(GTK_BUTTON_BOX(hbbox), 6);
255
235
gtk_button_box_set_layout(GTK_BUTTON_BOX(hbbox), GTK_BUTTONBOX_END);
258
btn = gtk_button_new_with_label(_("About"));
260
g_signal_connect(G_OBJECT(btn), "clicked",
261
(GCallback) about_window_create, NULL);
263
gtk_signal_connect(GTK_OBJECT(btn), "clicked",
264
(GtkSignalFunc) about_window_create, NULL);
266
gtk_widget_show(btn);
267
gtk_box_pack_start(GTK_BOX(hbbox), btn, FALSE, FALSE, 0);
271
237
btn = gtk_button_new_from_stock(GTK_STOCK_REFRESH);
272
238
g_signal_connect(G_OBJECT(btn), "clicked",
273
239
(GCallback) main_window_refresh, mainwindow);
275
btn = gtk_button_new_with_label(_("Refresh"));
276
gtk_signal_connect(GTK_OBJECT(btn), "clicked",
277
(GtkSignalFunc) main_window_refresh, mainwindow);
279
240
gtk_widget_show(btn);
280
241
gtk_box_pack_start(GTK_BOX(hbbox), btn, FALSE, FALSE, 0);
283
243
btn = gtk_button_new_from_stock(GTK_STOCK_CLOSE);
284
244
g_signal_connect(G_OBJECT(btn), "clicked", gtk_main_quit, NULL);
286
btn = gtk_button_new_with_label(_("Close"));
287
gtk_signal_connect(GTK_OBJECT(btn), "clicked",
288
(GtkSignalFunc) gtk_main_quit, NULL);
290
245
gtk_widget_show(btn);
291
246
gtk_box_pack_start(GTK_BOX(hbbox), btn, FALSE, FALSE, 0);
295
248
gtk_widget_show_all(window);
296
gtk_widget_hide(frame);
298
250
mainwindow->window = window;
299
251
mainwindow->ctree = ctree;
300
mainwindow->frame = frame;
302
253
return mainwindow;
367
317
pixmap = gdk_pixmap_colormap_create_from_xpm_d
368
318
(NULL, colormap, &mask, NULL, usb_xpm);
322
pixmap = gdk_pixmap_colormap_create_from_xpm_d
323
(NULL, colormap, &mask, NULL, processor_xpm);
371
326
mask = pixmap = NULL;
425
hi_hide_device_info(GtkCTree * tree, GList * node,
426
gint column, gpointer user_data)
428
MainWindow *mainwindow = (MainWindow *) user_data;
430
gtk_widget_hide(mainwindow->frame);
434
hi_show_device_info(GtkCTree * tree, GList * node,
435
gint column, gpointer user_data)
438
MainWindow *mainwindow = (MainWindow *) user_data;
440
dev = (GenericDevice *) gtk_ctree_node_get_row_data
441
(GTK_CTREE(tree), GTK_CLIST(tree)->selection->data);
380
hi_disable_details_button(GtkCTree * tree, GList * node,
381
gint column, gpointer user_data)
383
MainWindow *mainwindow = (MainWindow *) user_data;
385
gtk_widget_set_sensitive(GTK_WIDGET(mainwindow->details_button), FALSE);
388
void hi_enable_details_button(GtkCTree * tree, GList * node,
389
gint column, gpointer user_data)
391
MainWindow *mainwindow = (MainWindow *) user_data;
393
gtk_widget_set_sensitive(GTK_WIDGET(mainwindow->details_button), TRUE);
396
void hi_show_device_info_real(MainWindow *mainwindow, GenericDevice *dev)
454
409
switch (dev->type) {
411
dev_info(ModInfo, mod, hi_show_module_info);
413
dev_info(CPUDevice, cpu, hi_show_cpu_info);
456
415
dev_info(PCIDevice, pci, hi_show_pci_info);
478
gtk_widget_show(mainwindow->frame);
483
439
hi_scan_all(MainWindow * mainwindow)
494
GenericDevice *gd = generic_devices;
452
GenericDevice *gd = generic_devices;
497
455
status = my_status_new(_("Scanning Devices"), _("Scanning devices..."));
504
462
my_status_pulse(status)
464
DEVICE_SCAN("CPU", cpu, computer_get_info);
506
465
DEVICE_SCAN("PCI", pci, hi_scan_pci);
507
466
DEVICE_SCAN("ISA PnP", isa, hi_scan_isapnp);
508
467
DEVICE_SCAN("IDE", ide, hi_scan_ide);
510
469
DEVICE_SCAN("V4L", v4l, hi_scan_v4l);
511
470
DEVICE_SCAN("Parallel", pp, hi_scan_parport);
512
471
DEVICE_SCAN("Serial", sd, hi_scan_serial);
472
DEVICE_SCAN("modules", mod, hi_scan_modules);
514
474
gtk_clist_freeze(GTK_CLIST(mainwindow->ctree));
506
node = tree_group_new(mainwindow, _("Processor"), PROCESSOR);
507
hi_insert_generic(cpu, PROCESSOR);
508
tree_insert_item(mainwindow, node, cpu->processor, generic_devices);
542
510
CHECK_INSERT(pci, _("PCI Devices"), PCI, name);
543
511
CHECK_INSERT(isa, _("ISA PnP Devices"), ISAPnP, card);
553
521
CHECK_INSERT(v4l, _("Video for Linux"), V4L, name);
554
522
CHECK_INSERT(sd, _("Communication Ports"), SERIAL, name);
555
523
CHECK_INSERT(pp, _("Parallel Ports"), PARPORT, name);
525
CHECK_INSERT(mod, _("Kernel Modules"), MODULE, description);
557
527
gtk_clist_thaw(GTK_CLIST(mainwindow->ctree));
559
529
my_status_destroy(status);
564
533
usage(char *argv0)
566
g_print("%s [--prefix <prefix>]\n", argv0);
535
g_print("%s [--help] [--prefix <prefix>]\n", argv0);
572
540
main(int argc, char **argv)
574
542
MainWindow *mainwindow;
579
545
#ifdef ENABLE_NLS
583
g_print("HardInfo " VERSION "\n");
549
g_print("HardInfo " VERSION);
550
if (strstr(VERSION, "pre")) {
551
g_print(" *** PRE-RELEASE ***");
585
("Copyright (c) 2003 Leandro Pereira <leandro@linuxmag.com.br>\n\n");
554
("\nCopyright (c) 2003 Leandro Pereira <leandro@linuxmag.com.br>\n\n");
587
556
("This is free software; you can modify and/or distribute it\n"));
592
561
gtk_init(&argc, &argv);
596
gtk_widget_set_default_colormap(gdk_rgb_get_cmap());
597
gtk_widget_set_default_visual(gdk_rgb_get_visual());
601
565
for (i = 1; i < argc; i++) {
602
566
if (!strncmp(argv[i], "--help", 6) ||
603
567
!strncmp(argv[i], "-h", 2)) {