Codebase list hardinfo / 61dfcea
Import Debian changes 0.3.7pre-1 hardinfo (0.3.7pre-1) unstable; urgency=low * New upstream release. (Closes: #280694, #300114, #233033) Agney Lopes Roth Ferraz authored 18 years ago Simon Quigley committed 6 years ago
51 changed file(s) with 2341 addition(s) and 1400 deletion(s). Raw diff Collapse all Expand all
0 06/01/2003 12:05 BRST <leandro@linuxmag.com.br> 0.3.7-pre1
1
2 * details.[ch]
3 Use a window to show details instead of showing them inside the
4 main window
5 * computer.c, hardinfo.[ch]
6 Show more processor information (currently x86 only)
7 * modules.[ch], hardinfo.[ch]
8 Loaded kernel modules information
9
10 05/01/2003 12:05 BRST <leandro@linuxmag.com.br> 0.3.6
11
12 * 0.3.6 released
13
014 17/12/2003 10:50 BRST <leandro@linuxmag.com.br> 0.3.6-pre4
115
216 * hardinfo.desktop, Makefile.in
317 - Added GNOME/KDE menu entry
418 (Thanks to Gustavo Noronha <kov@debian.org>)
519 * net.[ch]
6 - Preliminary network information support (disabled in
7 GUI).
20 - Preliminary network information support (disabled in GUI).
821
922 03/07/2003 13:25 BRST <leandro@linuxmag.com.br> 0.3.6-pre3
1023
0 TARGET = GTK2
1 GTK_LIBS = -lgtk-x11-2.0 -lgdk-x11-2.0 -latk-1.0 -lgdk_pixbuf-2.0 -lm -lpangoxft-1.0 -lpangox-1.0 -lpango-1.0 -lgobject-2.0 -lgmodule-2.0 -ldl -lglib-2.0
2 GTK_CFLAGS = -DXTHREADS -I/usr/include/gtk-2.0 -I/usr/lib/gtk-2.0/include -I/usr/X11R6/include -I/usr/include/atk-1.0 -I/usr/include/pango-1.0 -I/usr/include/freetype2 -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include
3 PACKAGE = hardinfo-0.3.7pre
4 # ----------------------------------------------------------------------------
5
6 CC = gcc
7 CFLAGS = -Wall -g $(GTK_CFLAGS) -O6
8
9 # ----------------------------------------------------------------------------
10
11 OBJECTS = hardinfo.o scsi.o ide.o pci.o usb.o isapnp.o serial.o parport.o \
12 computer.o x11.o intl.o about.o v4l.o status.o net.o stock.o \
13 details.o modules.o
14
15 all: $(OBJECTS)
16 $(CC) $(CFLAGS) -o hardinfo $(OBJECTS) $(GTK_LIBS) $(GTK_FLAGS)
17
18 clean:
19 rm -rf *~ .xvpics pixmaps/.xvpics *.o hardinfo
20
21 install: all
22 mkdir -p ${DESTDIR}/usr/bin/
23 cp hardinfo ${DESTDIR}/usr/bin/hardinfo
24 mkdir -p ${DESTDIR}/usr/share/hardinfo/pixmaps
25 cp -rv pixmaps/*.png ${DESTDIR}/usr/share/hardinfo/pixmaps
26 cp -rv pixmaps/logo.xpm ${DESTDIR}/usr/share/hardinfo/pixmaps
27 mkdir -p ${DESTDIR}/usr/share/hardinfo/pixmaps/distro
28 cp -rv pixmaps/distro/*.png ${DESTDIR}/usr/share/hardinfo/pixmaps/distro
29 mkdir -p ${DESTDIR}/usr/share/hardinfo/lang
30 cp -rv lang/* ${DESTDIR}/usr/share/hardinfo/lang
31 chmod -R 755 ${DESTDIR}/usr/share/hardinfo
32 chmod -R -x ${DESTDIR}/usr/share/hardinfo
33 chmod 755 ${DESTDIR}/usr/share/hardinfo
34 chmod 755 ${DESTDIR}/usr/share/hardinfo/pixmaps
35 chmod 755 ${DESTDIR}/usr/share/hardinfo/lang
36 chmod 755 ${DESTDIR}/usr/share/hardinfo/pixmaps/distro
37 mkdir -p ${DESTDIR}/usr/share/applications
38 cp hardinfo.desktop ${DESTDIR}/usr/share/applications
39
40 dist-clean: clean
41 rm -rf Makefile debian/hardinfo/ config.h
42
43 package: dist-clean
44 @echo "Creating tar.gz..."
45 cd .. && tar czf $(PACKAGE).tar.gz $(PACKAGE)/* && cd $(PACKAGE)
46 @echo "Creating tar.bz2..."
47 cd .. && tar cjf $(PACKAGE).tar.bz2 $(PACKAGE)/* && cd $(PACKAGE)
48
49 deb: dist-clean
50 @echo "Creating deb..."
51 dpkg-buildpackage -rfakeroot -k${USER}
52
55 # ----------------------------------------------------------------------------
66
77 OBJECTS = hardinfo.o scsi.o ide.o pci.o usb.o isapnp.o serial.o parport.o \
8 computer.o x11.o intl.o about.o v4l.o status.o net.o
8 computer.o x11.o intl.o about.o v4l.o status.o net.o stock.o \
9 details.o modules.o
910
1011 all: $(OBJECTS)
1112 $(CC) $(CFLAGS) -o hardinfo $(OBJECTS) $(GTK_LIBS) $(GTK_FLAGS)
1819 cp hardinfo ${DESTDIR}/usr/bin/hardinfo
1920 mkdir -p ${DESTDIR}/usr/share/hardinfo/pixmaps
2021 cp -rv pixmaps/*.png ${DESTDIR}/usr/share/hardinfo/pixmaps
22 cp -rv pixmaps/logo.xpm ${DESTDIR}/usr/share/hardinfo/pixmaps
2123 mkdir -p ${DESTDIR}/usr/share/hardinfo/pixmaps/distro
2224 cp -rv pixmaps/distro/*.png ${DESTDIR}/usr/share/hardinfo/pixmaps/distro
2325 mkdir -p ${DESTDIR}/usr/share/hardinfo/lang
1111 gtk_about_new(const gchar * name, const gchar * version,
1212 const gchar * description, const gchar * authors[], const gchar * logo_img)
1313 {
14 #ifdef GTK2
1514 GtkWidget *img;
16 #endif
1715 gchar *buf;
1816 const gchar *auth;
1917 GtkWidget *window, *vbox, *label, *btn, *hr, *hbox;
2826
2927 about->window = window;
3028
31 #ifdef GTK2
3229 gtk_window_set_resizable(GTK_WINDOW(window), FALSE);
33 #else
34 gtk_window_set_policy(GTK_WINDOW(window), FALSE, FALSE, FALSE);
35 #endif
3630
3731 vbox = gtk_vbox_new(FALSE, 5);
3832 gtk_box_set_spacing(GTK_BOX(vbox), 3);
3933 gtk_container_add(GTK_CONTAINER(window), vbox);
4034
41 #ifdef GTK2
4235 img = gtk_image_new_from_file(logo_img);
4336 gtk_widget_show(img);
4437 gtk_box_pack_start(GTK_BOX(vbox), img, FALSE, FALSE, 0);
4538 gtk_widget_set_usize(GTK_WIDGET(img), 64, 64);
46 #endif
4739
48 #ifdef GTK2
4940 #define ADD_LABEL(x,y) label = gtk_label_new(x); \
5041 gtk_label_set_use_markup(GTK_LABEL(label), TRUE); \
5142 gtk_widget_show(label); \
5243 gtk_box_pack_start(GTK_BOX(y), label, TRUE, TRUE, 0);
53 #else
54 #define ADD_LABEL(x,y) label = gtk_label_new(x); \
55 gtk_widget_show(label); \
56 gtk_box_pack_start(GTK_BOX(y), label, TRUE, TRUE, 0);
57 #endif
5844
59 #ifdef GTK2
6045 buf =
6146 g_strdup_printf
6247 ("<span size=\"xx-large\" weight=\"bold\">%s %s</span>", name,
6348 version);
64 #else
65 buf = g_strdup_printf("%s %s", name, version);
66 #endif
6749 ADD_LABEL(buf, vbox);
6850 g_free(buf);
6951
7557 if (*auth == '>') {
7658 auth++;
7759
78 #ifdef GTK2
7960 buf = g_strdup_printf("<b>%s</b>", auth);
80 #else
81 buf = g_strdup_printf("%s", auth);
82 #endif
8361 ADD_LABEL(buf, vbox);
8462 g_free(buf);
8563 } else {
86 #ifdef GTK2
8764 buf = g_strdup_printf("<span size=\"small\">%s</span>", auth);
88 #else
89 buf = g_strdup_printf(" %s", auth);
90 #endif
9165 ADD_LABEL(buf, vbox);
9266 g_free(buf);
9367 }
10175 gtk_widget_show(hbox);
10276 gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
10377 gtk_button_box_set_spacing(GTK_BUTTON_BOX(hbox), 6);
78 gtk_button_box_set_layout(GTK_BUTTON_BOX(hbox), GTK_BUTTONBOX_END);
10479
105 #ifdef GTK2
106 btn = gtk_button_new_from_stock(GTK_STOCK_OK);
80 btn = gtk_button_new_from_stock(GTK_STOCK_CLOSE);
10781 g_signal_connect(G_OBJECT(btn), "clicked", (GCallback)about_close, about);
108 #else
109 btn = gtk_button_new_with_label(_("OK"));
110 gtk_signal_connect(GTK_OBJECT(btn), "clicked", about_close, about);
111 #endif
11282 gtk_widget_show(btn);
11383 gtk_box_pack_start(GTK_BOX(hbox), btn, FALSE, FALSE, 0);
11484
(New empty file)
77 #include "hardinfo.h"
88 #include "computer.h"
99
10 #include <gtk/gtk.h>
1011 #include <sys/utsname.h>
1112 #include <unistd.h>
1213 #include <fcntl.h>
1314 #include <stdlib.h>
1415
1516 static struct {
16 gchar *file, *codename;
17 } distro_db [] = {
18 { DB_PREFIX "debian_version", "deb" },
19 { DB_PREFIX "slackware-version", "slk" },
20 { DB_PREFIX "mandrake-release", "mdk" },
21 { DB_PREFIX "gentoo-release", "gnt" },
22 { DB_PREFIX "conectiva-release", "cnc" },
23 { DB_PREFIX "versão-conectiva", "cnc" },
24 { DB_PREFIX "turbolinux-release", "tl" },
25 { DB_PREFIX "yellowdog-release", "yd" },
26 { DB_PREFIX "SuSE-release", "suse" },
27
17 gchar *file, *codename;
18 } distro_db[] = {
19 { DB_PREFIX "debian_version", "deb" },
20 { DB_PREFIX "slackware-version", "slk" },
21 { DB_PREFIX "mandrake-release", "mdk" },
22 { DB_PREFIX "gentoo-release", "gnt" },
23 { DB_PREFIX "conectiva-release", "cnc" },
24 { DB_PREFIX "versão-conectiva", "cnc" },
25 { DB_PREFIX "turbolinux-release", "tl" },
26 { DB_PREFIX "yellowdog-release", "yd" },
27 { DB_PREFIX "SuSE-release", "suse" },
2828 /*
2929 * RedHat must be the *last* one to be checked, since
3030 * some distros (like Mandrake) includes a redhat-relase
3131 * file too.
32 */
33
34 { DB_PREFIX "redhat-release", "rh" },
35 { NULL, NULL }
32 */
33 { DB_PREFIX "redhat-release", "rh" },
34 { NULL, NULL }
3635 };
3736
3837 #define get_int_val(var) { \
4746 continue; \
4847 }
4948
49 #ifdef ARCH_i386
50 static struct {
51 char *small, *large;
52 } small2large[] = {
53 { "fpu", "Floating Point Unit" },
54 { "vme", "Virtual Mode Extension" },
55 { "de", "Debugging Extensions" },
56 { "pse", "Page Size Extensions" },
57 { "tsc", "Time Stamp Counter" },
58 { "msr", "Model Specific Registers" },
59 { "pae", "Physical Address Extensions" },
60 { "mce", "Machine Check Architeture" },
61 { "cx8", "CMPXCHG8 instruction" },
62 { "apic", "Advanced Programmable Interrupt Controller" },
63 { "sep", "Fast System Call" },
64 { "mtrr", "Memory Type Range Registers" },
65 { "pge", "Page Global Enable" },
66 { "cmov", "Conditional Move instruction" },
67 { "pat", "Page Attribute Table" },
68 { "pse36", "36bit Page Size Extensions" },
69 { "psn", "96 bit Processor Serial Number" },
70 { "mmx", "MMX technology" },
71 { "fxsr", "fxsr" },
72 { "kni", "Streaming SIMD instructions" },
73 { "xmm", "Streaming SIMD instructions" },
74 { "ht", "HyperThreading" },
75 { NULL, NULL }
76 };
77
78 static GtkWidget *get_features_widget(CPUDevice * device)
79 {
80 GtkWidget *widget, *scroll;
81 GtkTextBuffer *buffer;
82 GtkTextIter iter;
83 gchar **flags;
84 gint i, j;
85
86 if (!device->flags)
87 return NULL;
88
89 buffer = gtk_text_buffer_new(FALSE);
90 gtk_text_buffer_set_text(buffer, "", -1);
91 gtk_text_buffer_get_iter_at_offset(buffer, &iter, 0);
92
93 flags = g_strsplit(device->flags, " ", G_N_ELEMENTS(small2large));
94 for (i = 0; *(flags + i); i++) {
95 for (j = 0; j < G_N_ELEMENTS(small2large); j++) {
96 if (small2large[j].small &&
97 !strncmp(small2large[j].small, *(flags + i),
98 strlen(small2large[j].small))) {
99 // gtk_text_buffer_insert(buffer, &iter, small2large[j].small,
100 // -1);
101 gtk_text_buffer_insert(buffer, &iter, "● ", -1);
102 gtk_text_buffer_insert(buffer, &iter, small2large[j].large,
103 -1);
104 gtk_text_buffer_insert(buffer, &iter, "\n", -1);
105 break;
106 }
107 }
108 }
109 g_strfreev(flags);
110
111 scroll = gtk_scrolled_window_new(NULL, NULL);
112 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scroll),
113 GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
114 gtk_container_set_border_width(GTK_CONTAINER(scroll), 4);
115 gtk_widget_show(scroll);
116
117 widget = gtk_text_view_new();
118 gtk_text_view_set_buffer(GTK_TEXT_VIEW(widget), buffer);
119 gtk_text_view_set_editable(GTK_TEXT_VIEW(widget), FALSE);
120 gtk_text_view_set_cursor_visible(GTK_TEXT_VIEW(widget), FALSE);
121 gtk_text_view_set_indent(GTK_TEXT_VIEW(widget), 5);
122 gtk_widget_show(widget);
123
124 gtk_container_add(GTK_CONTAINER(scroll), widget);
125
126 return scroll;
127 }
128 #endif
129
130 void hi_show_cpu_info(MainWindow * mainwindow, CPUDevice * device)
131 {
132 gchar *buf;
133
134 if (!device)
135 return;
136
137 gtk_window_set_title(GTK_WINDOW(mainwindow->det_window->window),
138 device->processor);
139 detail_window_set_icon(mainwindow->det_window, IMG_PREFIX "cpu.png");
140 detail_window_set_dev_name(mainwindow->det_window, device->processor);
141 detail_window_set_dev_type(mainwindow->det_window, device->machine);
142
143 detail_window_append_info_int(mainwindow->det_window, _("Number"),
144 device->procno, FALSE);
145 buf = g_strdup_printf("%dMHz", device->frequency);
146 detail_window_append_info(mainwindow->det_window, _("Frequency"), buf);
147 g_free(buf);
148
149 detail_window_append_separator(mainwindow->det_window);
150 #ifdef ARCH_i386
151 detail_window_append_info_int(mainwindow->det_window, _("Family"),
152 device->family, FALSE);
153 detail_window_append_info_int(mainwindow->det_window, _("Model"),
154 device->model, FALSE);
155 detail_window_append_info_int(mainwindow->det_window, _("Stepping"),
156 device->stepping, FALSE);
157 detail_window_append_separator(mainwindow->det_window);
158 #endif
159
160 if (device->cachel2) {
161 buf = g_strdup_printf("%dkB", device->cachel2);
162 detail_window_append_info(mainwindow->det_window, _("Cache L2"),
163 buf);
164 g_free(buf);
165 }
166
167 buf = g_strdup_printf("%d bogomips", device->bogomips);
168 detail_window_append_info(mainwindow->det_window, _("Bogomips"), buf);
169 g_free(buf);
170
171 #ifdef ARCH_i386
172 {
173 GtkWidget *features, *label;
174
175 label = gtk_label_new(_("Features"));
176 gtk_widget_show(label);
177
178 features = get_features_widget(device);
179 gtk_notebook_append_page(GTK_NOTEBOOK
180 (mainwindow->det_window->notebook),
181 features, label);
182 }
183 #endif
184
185 }
186
50187 MemoryInfo *memory_get_info(void)
51188 {
52 MemoryInfo *mi;
53 FILE *procmem;
54 gchar buffer[128];
55 gint memfree, memused;
56
57 mi = g_new0(MemoryInfo, 1);
58
59 procmem = fopen("/proc/meminfo", "r");
60 while (fgets(buffer, 128, procmem)) {
61 gchar *buf = buffer;
62
63 buf = g_strstrip(buf);
64
65 if(!strncmp(buf, "MemTotal", 8))
66 get_int_val(mi->total)
67 else if(!strncmp(buf, "MemFree", 7))
68 get_int_val(memfree)
69 else if(!strncmp(buf, "Cached", 6))
70 get_int_val(mi->cached)
71
72 }
73 fclose(procmem);
74
75 mi->used = mi->total - memfree;
76
77 mi->total/=1000;
78 mi->cached/=1000;
79 mi->used/=1000;
80 memfree/=1000;
81
82 memused = mi->total - mi->used + mi->cached;
83
84 #if 0
85 printf("total = %d\n"
86 "cached = %d\n"
87 "used = %d\n"
88 "free = %d\n"
89 "realused = %d\n"
90 "ratio = %f\n\n", mi->total, mi->cached, mi->used, memfree,
91 memused, (gdouble)memused/mi->total);
92 #endif
93 mi->ratio=1 - (gdouble)memused/mi->total;
94
95 return mi;
96 }
97
98 #if defined(ARCH_i386) || defined(ARCH_x86_64)
189 MemoryInfo *mi;
190 FILE *procmem;
191 gchar buffer[128];
192 gint memfree = 0, memused;
193
194 mi = g_new0(MemoryInfo, 1);
195
196 procmem = fopen("/proc/meminfo", "r");
197 while (fgets(buffer, 128, procmem)) {
198 gchar *buf = buffer;
199
200 buf = g_strstrip(buf);
201
202 if (!strncmp(buf, "MemTotal", 8))
203 get_int_val(mi->total)
204 else if (!strncmp(buf, "MemFree", 7))
205 get_int_val(memfree)
206 else if (!strncmp(buf, "Cached", 6))
207 get_int_val(mi->cached)
208 }
209 fclose(procmem);
210
211 mi->used = mi->total - memfree;
212
213 mi->total /= 1000;
214 mi->cached /= 1000;
215 mi->used /= 1000;
216 memfree /= 1000;
217
218 memused = mi->total - mi->used + mi->cached;
219
220 mi->ratio = 1 - (gdouble) memused / mi->total;
221
222 return mi;
223 }
224
225 #if defined(ARCH_i386) || defined(ARCH_x86_64) || defined(ARCH_PARISC)
99226 #define PARSE_PROC_CPU() \
100227 if(!strncmp(buf, "bogomips", 8)) \
101228 get_int_val(ci->bogomips) \
103230 get_int_val(ci->family) \
104231 else if(!strncmp(buf, "model name", 10)) \
105232 get_str_val(ci->processor) \
233 else if(!strncmp(buf, "flags", 5)) \
234 get_str_val(ci->flags) \
235 else if(!strncmp(buf, "vendor_id", 8)) \
236 get_str_val(ci->machine) \
106237 else if(!strncmp(buf, "stepping", 8)) \
107238 get_int_val(ci->stepping) \
108239 else if(!strncmp(buf, "cpu MHz", 7)) \
110241 else if(!strncmp(buf, "cache size", 10)) \
111242 get_int_val(ci->cachel2) \
112243 else if(!strncmp(buf, "model", 5)) \
113 get_int_val(ci->model)
244 get_int_val(ci->model)
114245 #endif
115246 #ifdef ARCH_PPC
116247 #define PARSE_PROC_CPU() \
118249 get_int_val(ci->bogomips) \
119250 else if(!strncmp(buf, "cpu", 3)) \
120251 get_str_val(ci->processor) \
252 else if(!strncmp(buf, "machine", 7)) \
253 get_str_val(ci->machine) \
121254 else if(!strncmp(buf, "clock", 5)) \
122255 get_int_val(ci->frequency) \
123256 else if(!strncmp(buf, "L2 cache", 8)) \
124 get_int_val(ci->cachel2)
257 get_int_val(ci->cachel2)
258 #endif
259 #ifdef ARCH_m68k
260 #define PARSE_PROC_CPU() \
261 if (!strncmp(buf, "CPU", 3)) \
262 get_str_val(ci->processor) \
263 else if (!strncmp(buf, "BogoMips", 8)) \
264 get_int_val(ci->bogomips) \
265 else if (!strncmp(buf, "Clocking", 8)) \
266 get_int_val(ci->frequency)
267 #endif
268 #ifdef ARCH_MIPS
269 #define PARSE_PROC_CPU() \
270 if (!strncmp(buf, "cpu model", 9)) \
271 get_str_val(ci->processor) \
272 else if (!strncmp(buf, "BogoMIPS", 8)) \
273 get_int_val(ci->bogomips) \
274 else if (!strncmp(buf, "system type", 11)) \
275 get_str_val(ci->machine)
125276 #endif
126277
127278 #ifndef PARSE_PROC_CPU
128 #error ARCH_i386 or ARCH_PPC not defined! Add support! Send me patches!
129 #endif
130
131 static void computer_processor_info(ComputerInfo *ci)
132 {
133 FILE *proccpu;
134 gchar buffer[128];
135
136 proccpu = fopen("/proc/cpuinfo", "r");
137 while (fgets(buffer, 128, proccpu)) {
138 gchar *buf = buffer;
139
140 buf = g_strstrip(buf);
141
142 PARSE_PROC_CPU();
279 #error PARSE_PROC_CPU not defined! Maybe your arch is not supported yet;
280 #error please send me your /proc/cpuinfo and/or 'uname -a' output to
281 #error leandro@linuxmag.com.br; thanks.
282 #endif
283
284 static void computer_processor_info(ComputerInfo * ci)
285 {
286 FILE *proccpu;
287 gchar buffer[128];
288
289 proccpu = fopen("/proc/cpuinfo", "r");
290 while (fgets(buffer, 128, proccpu)) {
291 gchar *buf = buffer;
292
293 buf = g_strstrip(buf);
294
295 PARSE_PROC_CPU();
296 }
297 fclose(proccpu);
298
299 #ifdef ARCH_PPC
300 {
301 gchar *proctemp;
302
303 proctemp = g_strdup_printf("PowerPC %s", ci->processor);
304 g_free(ci->processor);
305 ci->processor = proctemp;
306 }
307 #endif
308 #ifdef ARCH_m68k
309 {
310 gchar *proctemp;
311
312 proctemp = g_strdup_printf("Motorola %s", ci->processor);
313 g_free(ci->processor);
314 ci->processor = proctemp;
315 }
316 #endif
317
318 }
319
320 ComputerInfo *computer_get_info(void)
321 {
322 gint i;
323 struct stat st;
324 ComputerInfo *ci;
325 struct utsname utsbuf;
326
327 ci = g_new0(ComputerInfo, 1);
328
329 for (i = 0;; i++) {
330 if (distro_db[i].file == NULL) {
331 ci->distrocode = g_strdup("unk");
332 ci->distroinfo = g_strdup(_("Unknown distribution"));
333 break;
143334 }
144 fclose(proccpu);
145
146 #ifdef ARCH_PPC
147 {
148 gchar *proctemp;
149
150 proctemp = g_strdup_printf("PowerPC %s", ci->processor);
151 g_free(ci->processor);
152 ci->processor = proctemp;
335
336 if (!stat(distro_db[i].file, &st)) {
337 FILE *distro_ver;
338 char buf[128];
339
340 distro_ver = fopen(distro_db[i].file, "r");
341 fgets(buf, 128, distro_ver);
342 fclose(distro_ver);
343
344 buf[strlen(buf) - 1] = 0;
345
346 /*
347 * HACK: Some Debian systems doesn't include
348 * the distribuition name in /etc/debian_release,
349 * so add them here.
350 */
351 if (!strncmp(distro_db[i].codename, "deb", 3) &&
352 ((buf[0] >= '0' && buf[0] <= '9') || buf[0] != 'D')) {
353 ci->distroinfo = g_strdup_printf
354 ("Debian GNU/Linux %s", buf);
355 } else {
356 ci->distroinfo = g_strdup(buf);
357 }
358
359 ci->distrocode = g_strdup(distro_db[i].codename);
360
361 break;
153362 }
154 #endif
155
156
157 }
158
159 ComputerInfo *computer_get_info(void)
160 {
161 gint i;
162 struct stat st;
163 ComputerInfo *ci;
164 struct utsname utsbuf;
165
166 ci = g_new0(ComputerInfo, 1);
167
168 for (i = 0; ; i++) {
169 if (distro_db[i].file == NULL) {
170 ci->distrocode = g_strdup("unk");
171 ci->distroinfo = g_strdup(_("Unknown distribution"));
172 break;
173 }
174
175 if (!stat(distro_db[i].file, &st)) {
176 FILE *distro_ver;
177 char buf[128];
178
179 distro_ver = fopen(distro_db[i].file, "r");
180 fgets(buf, 128, distro_ver);
181 fclose(distro_ver);
182
183 buf[strlen(buf)-1]=0;
184
185 /*
186 * Some Debian systems doesn't include
187 * the distribuition name in /etc/debian_release,
188 * so add them here. This is a hack, though...
189 */
190 if (!strncmp(distro_db[i].codename, "deb", 3) &&
191 buf[0] >= '0' && buf[0] <= '9') {
192 ci->distroinfo = g_strdup_printf
193 ("Debian GNU/Linux %s", buf);
194 } else {
195 ci->distroinfo = g_strdup(buf);
196 }
197
198
199 ci->distrocode = g_strdup(distro_db[i].codename);
200
201 break;
202 }
203 }
204
205 uname(&utsbuf);
206
207 ci->kernel = g_strdup_printf("%s %s (%s)", utsbuf.sysname,
208 utsbuf.release, utsbuf.machine);
209
210 ci->hostname = g_strdup(utsbuf.nodename);
211
212 computer_processor_info(ci);
213
214 return ci;
363 }
364
365 uname(&utsbuf);
366 ci->kernel = g_strdup_printf("%s %s (%s)", utsbuf.sysname,
367 utsbuf.release, utsbuf.machine);
368
369 ci->hostname = g_strdup(utsbuf.nodename);
370
371 computer_processor_info(ci);
372
373 return ci;
215374 }
216375
217376 /*
220379 */
221380 gboolean uptime_update(gpointer data)
222381 {
223 MainWindow *mainwindow = (MainWindow *) data;
224 gchar *buf;
225 gint days, hours;
226 FILE *procuptime;
227 gulong minutes = 0;
228
229 if(!mainwindow) return FALSE;
230
382 MainWindow *mainwindow = (MainWindow *) data;
383 gchar *buf;
384 gint days, hours;
385 FILE *procuptime;
386 gulong minutes = 0;
387
388 if (!mainwindow)
389 return FALSE;
390
231391 #define plural(a) (a == 1) ? "" : "s"
232392
233 if ((procuptime = fopen("/proc/uptime", "r")) != NULL) {
234 fscanf(procuptime, "%lu", &minutes);
235 minutes /= 60;
236 fclose(procuptime);
237 } else
238 return FALSE;
239
240 hours = minutes / 60;
241 minutes %= 60;
242 days = hours / 24;
243 hours %= 24;
244
245 if (days < 1) {
246 buf = g_strdup_printf(_("%d hour%s and %ld minute%s"), hours,
247 plural(hours), minutes, plural(minutes));
248 } else {
249 buf = g_strdup_printf(_("%d day%s, %d hour%s and %ld minute%s"),
250 days, plural(days), hours, plural(hours),
251 minutes, plural(minutes));
252 }
253
254 gtk_label_set_text(GTK_LABEL(mainwindow->uptime), buf);
255 g_free(buf);
256
257 return TRUE;
258 }
259
260 GtkWidget *os_get_widget(MainWindow *mainwindow)
261 {
262 GtkWidget *label, *hbox;
263 GtkWidget *table;
264 #ifdef GTK2
265 GtkWidget *pixmap;
266 gchar *buf;
267 #endif
268 ComputerInfo *info;
269
270 if(!mainwindow) return NULL;
271
272 info = computer_get_info();
273
274 hbox = gtk_hbox_new(FALSE, 0);
275 gtk_widget_show(hbox);
276
277 #ifdef GTK2
278 buf = g_strdup_printf("%s/distro/%s.png", IMG_PREFIX, info->distrocode);
279 pixmap = gtk_image_new_from_file(buf);
280 gtk_widget_set_usize(GTK_WIDGET(pixmap), 64, 0);
281 gtk_widget_show(pixmap);
282 gtk_box_pack_start(GTK_BOX(hbox), pixmap, FALSE, FALSE, 0);
283 g_free(buf);
284 #endif
285
286 table = gtk_table_new(4, 2, FALSE);
287 gtk_widget_show(table);
288 gtk_box_pack_start(GTK_BOX(hbox), table, TRUE, TRUE, 0);
289 gtk_container_set_border_width(GTK_CONTAINER(table), 10);
290 gtk_table_set_row_spacings(GTK_TABLE(table), 4);
291 gtk_table_set_col_spacings(GTK_TABLE(table), 4);
292
293 /*
294 * Table headers
295 */
296 #ifdef GTK2
297 label = gtk_label_new(_("<b>Computer name:</b>"));
298 gtk_label_set_use_markup(GTK_LABEL(label), TRUE);
299 #else
300 label = gtk_label_new(_("Computer name:"));
301 #endif
302 gtk_table_attach_defaults(GTK_TABLE(table), label, 0, 1, 0, 1);
303 gtk_widget_show(label);
304 gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.5);
305
306 #ifdef GTK2
307 label = gtk_label_new(_("<b>Distribution:</b>"));
308 gtk_label_set_use_markup(GTK_LABEL(label), TRUE);
309 #else
310 label = gtk_label_new(_("Distribution:"));
311 #endif
312 gtk_table_attach_defaults(GTK_TABLE(table), label, 0, 1, 1, 2);
313 gtk_widget_show(label);
314 gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.5);
315
316 #ifdef GTK2
317 label = gtk_label_new(_("<b>Kernel:</b>"));
318 gtk_label_set_use_markup(GTK_LABEL(label), TRUE);
319 #else
320 label = gtk_label_new(_("Kernel:"));
321 #endif
322 gtk_table_attach_defaults(GTK_TABLE(table), label, 0, 1, 2, 3);
323 gtk_widget_show(label);
324 gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.5);
325
326 #ifdef GTK2
327 label = gtk_label_new(_("<b>Uptime:</b>"));
328 gtk_label_set_use_markup(GTK_LABEL(label), TRUE);
329 #else
330 label = gtk_label_new(_("Uptime:"));
331 #endif
332 gtk_table_attach_defaults(GTK_TABLE(table), label, 0, 1, 3, 4);
333 gtk_widget_show(label);
334 gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.5);
335
336
337 /*
338 * Table content
339 */
340 label = gtk_label_new(info->hostname);
341 gtk_table_attach_defaults(GTK_TABLE(table), label, 1, 2, 0, 1);
342 gtk_widget_show(label);
343 gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.5);
344
345 label = gtk_label_new(info->distroinfo);
346 gtk_table_attach_defaults(GTK_TABLE(table), label, 1, 2, 1, 2);
347 gtk_widget_show(label);
348 gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.5);
349
350 label = gtk_label_new(info->kernel);
351 gtk_table_attach_defaults(GTK_TABLE(table), label, 1, 2, 2, 3);
352 gtk_widget_show(label);
353 gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.5);
354
355 label = gtk_label_new(_("Updating..."));
356 gtk_table_attach_defaults(GTK_TABLE(table), label, 1, 2, 3, 4);
357 gtk_widget_show(label);
358 gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.5);
359 mainwindow->uptime = label;
360
361 uptime_update(mainwindow);
362 gtk_timeout_add(30000, uptime_update, mainwindow);
363
364 g_free(info);
365
366 return hbox;
393 if ((procuptime = fopen("/proc/uptime", "r")) != NULL) {
394 fscanf(procuptime, "%lu", &minutes);
395 minutes /= 60;
396 fclose(procuptime);
397 } else
398 return FALSE;
399
400 hours = minutes / 60;
401 minutes %= 60;
402 days = hours / 24;
403 hours %= 24;
404
405 if (days < 1) {
406 buf = g_strdup_printf(_("%d hour%s and %ld minute%s"), hours,
407 plural(hours), minutes, plural(minutes));
408 } else {
409 buf =
410 g_strdup_printf(_("%d day%s, %d hour%s and %ld minute%s"),
411 days, plural(days), hours, plural(hours),
412 minutes, plural(minutes));
413 }
414
415 gtk_label_set_text(GTK_LABEL(mainwindow->uptime), buf);
416 g_free(buf);
417
418 return TRUE;
419 }
420
421 GtkWidget *os_get_widget(MainWindow * mainwindow)
422 {
423 GtkWidget *label, *hbox;
424 GtkWidget *table;
425 GtkWidget *pixmap;
426 gchar *buf;
427 ComputerInfo *info;
428
429 if (!mainwindow)
430 return NULL;
431
432 info = computer_get_info();
433
434 hbox = gtk_hbox_new(FALSE, 0);
435 gtk_widget_show(hbox);
436
437 buf =
438 g_strdup_printf("%s/distro/%s.png", IMG_PREFIX, info->distrocode);
439 pixmap = gtk_image_new_from_file(buf);
440 gtk_widget_set_usize(GTK_WIDGET(pixmap), 64, 0);
441 gtk_widget_show(pixmap);
442 gtk_box_pack_start(GTK_BOX(hbox), pixmap, FALSE, FALSE, 0);
443 g_free(buf);
444
445 table = gtk_table_new(4, 2, FALSE);
446 gtk_widget_show(table);
447 gtk_box_pack_start(GTK_BOX(hbox), table, TRUE, TRUE, 0);
448 gtk_container_set_border_width(GTK_CONTAINER(table), 10);
449 gtk_table_set_row_spacings(GTK_TABLE(table), 4);
450 gtk_table_set_col_spacings(GTK_TABLE(table), 4);
451
452 /*
453 * Table headers
454 */
455 label = gtk_label_new(_("<b>Computer name:</b>"));
456 gtk_label_set_use_markup(GTK_LABEL(label), TRUE);
457 gtk_table_attach_defaults(GTK_TABLE(table), label, 0, 1, 0, 1);
458 gtk_widget_show(label);
459 gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.5);
460
461 label = gtk_label_new(_("<b>Distribution:</b>"));
462 gtk_label_set_use_markup(GTK_LABEL(label), TRUE);
463 gtk_table_attach_defaults(GTK_TABLE(table), label, 0, 1, 1, 2);
464 gtk_widget_show(label);
465 gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.5);
466
467 label = gtk_label_new(_("<b>Kernel:</b>"));
468 gtk_label_set_use_markup(GTK_LABEL(label), TRUE);
469 gtk_table_attach_defaults(GTK_TABLE(table), label, 0, 1, 2, 3);
470 gtk_widget_show(label);
471 gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.5);
472
473 label = gtk_label_new(_("<b>Uptime:</b>"));
474 gtk_label_set_use_markup(GTK_LABEL(label), TRUE);
475 gtk_table_attach_defaults(GTK_TABLE(table), label, 0, 1, 3, 4);
476 gtk_widget_show(label);
477 gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.5);
478
479
480 /*
481 * Table content
482 */
483 label = gtk_label_new(info->hostname);
484 gtk_table_attach_defaults(GTK_TABLE(table), label, 1, 2, 0, 1);
485 gtk_widget_show(label);
486 gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.5);
487
488 label = gtk_label_new(info->distroinfo);
489 gtk_table_attach_defaults(GTK_TABLE(table), label, 1, 2, 1, 2);
490 gtk_widget_show(label);
491 gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.5);
492
493 label = gtk_label_new(info->kernel);
494 gtk_table_attach_defaults(GTK_TABLE(table), label, 1, 2, 2, 3);
495 gtk_widget_show(label);
496 gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.5);
497
498 label = gtk_label_new(_("Updating..."));
499 gtk_table_attach_defaults(GTK_TABLE(table), label, 1, 2, 3, 4);
500 gtk_widget_show(label);
501 gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.5);
502 mainwindow->uptime = label;
503
504 uptime_update(mainwindow);
505 gtk_timeout_add(30000, uptime_update, mainwindow);
506
507 g_free(info);
508
509 return hbox;
367510 }
368511
369512 gboolean memory_update(gpointer data)
370513 {
371 MainWindow *mainwindow = (MainWindow*) data;
372 MemoryInfo *mi;
373
374 if(!mainwindow) return FALSE;
375
376 mi = memory_get_info();
377
378 #ifdef GTK2
379 gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR(mainwindow->membar),
380 mi->ratio);
381 #else
382 gtk_progress_set_percentage(GTK_PROGRESS(mainwindow->membar),
383 mi->ratio);
384 #endif
385
386 g_free(mi);
387
388 return TRUE;
389 }
390
391 GtkWidget *memory_get_widget(MainWindow *mainwindow)
392 {
393 GtkWidget *label, *vbox, *hbox, *hbox2, *progress;
394 #ifdef GTK2
395 GtkWidget *pixmap;
396 #endif
397 MemoryInfo *mi;
398 gchar *buf;
399
400 mi = memory_get_info();
401
402 hbox = gtk_hbox_new(FALSE, 0);
403 gtk_widget_show(hbox);
404
405 #ifdef GTK2
406 buf = g_strdup_printf("%s/mem.png", IMG_PREFIX);
407 pixmap = gtk_image_new_from_file(buf);
408 gtk_widget_set_usize(GTK_WIDGET(pixmap), 64, 0);
409 gtk_widget_show(pixmap);
410 gtk_box_pack_start(GTK_BOX(hbox), pixmap, FALSE, FALSE, 0);
411 g_free(buf);
412 #endif
413
414 vbox = gtk_vbox_new(FALSE, 0);
415 gtk_widget_show(vbox);
416 gtk_box_pack_start(GTK_BOX(hbox), vbox, TRUE, TRUE, 0);
417 gtk_container_set_border_width(GTK_CONTAINER(vbox), 10);
418 gtk_box_set_spacing(GTK_BOX(vbox), 4);
419
420 hbox2 = gtk_hbox_new(FALSE, 5);
421 gtk_widget_show(hbox2);
422 gtk_box_pack_start(GTK_BOX(vbox), hbox2, TRUE, TRUE, 0);
423
424 label = gtk_label_new("0MB");
425 gtk_widget_show(label);
426 gtk_box_pack_start(GTK_BOX(hbox2), label, FALSE, FALSE, 0);
427 gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.5);
428
429 buf = g_strdup_printf("%dMB", mi->total);
514 MainWindow *mainwindow = (MainWindow *) data;
515 MemoryInfo *mi;
516
517 if (!mainwindow)
518 return FALSE;
519
520 mi = memory_get_info();
521
522 gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR(mainwindow->membar),
523 mi->ratio);
524
525 g_free(mi);
526
527 return TRUE;
528 }
529
530 GtkWidget *memory_get_widget(MainWindow * mainwindow)
531 {
532 GtkWidget *label, *vbox, *hbox, *hbox2, *progress;
533 GtkWidget *pixmap;
534 MemoryInfo *mi;
535 gchar *buf;
536
537 mi = memory_get_info();
538
539 hbox = gtk_hbox_new(FALSE, 0);
540 gtk_widget_show(hbox);
541
542 buf = g_strdup_printf("%s/mem.png", IMG_PREFIX);
543 pixmap = gtk_image_new_from_file(buf);
544 gtk_widget_set_usize(GTK_WIDGET(pixmap), 64, 0);
545 gtk_widget_show(pixmap);
546 gtk_box_pack_start(GTK_BOX(hbox), pixmap, FALSE, FALSE, 0);
547 g_free(buf);
548
549 vbox = gtk_vbox_new(FALSE, 0);
550 gtk_widget_show(vbox);
551 gtk_box_pack_start(GTK_BOX(hbox), vbox, TRUE, TRUE, 0);
552 gtk_container_set_border_width(GTK_CONTAINER(vbox), 10);
553 gtk_box_set_spacing(GTK_BOX(vbox), 4);
554
555 hbox2 = gtk_hbox_new(FALSE, 5);
556 gtk_widget_show(hbox2);
557 gtk_box_pack_start(GTK_BOX(vbox), hbox2, TRUE, TRUE, 0);
558
559 label = gtk_label_new("0MB");
560 gtk_widget_show(label);
561 gtk_box_pack_start(GTK_BOX(hbox2), label, FALSE, FALSE, 0);
562 gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.5);
563
564 buf = g_strdup_printf("%dMB", mi->total);
565 label = gtk_label_new(buf);
566 gtk_widget_show(label);
567 gtk_box_pack_end(GTK_BOX(hbox2), label, FALSE, FALSE, 0);
568 gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.5);
569 g_free(buf);
570
571 progress = gtk_progress_bar_new();
572 mainwindow->membar = progress;
573 gtk_widget_show(progress);
574 gtk_box_pack_start(GTK_BOX(vbox), progress, TRUE, TRUE, 0);
575
576 memory_update(mainwindow);
577
578 gtk_timeout_add(2000, memory_update, mainwindow);
579
580 g_free(mi);
581 return hbox;
582 }
583
584 GtkWidget *processor_get_widget(void)
585 {
586 GtkWidget *label, *vbox, *hbox;
587 GtkWidget *pixmap;
588 ComputerInfo *info;
589 gchar *buf;
590
591 info = computer_get_info();
592
593 hbox = gtk_hbox_new(FALSE, 0);
594 gtk_widget_show(hbox);
595
596 buf = g_strdup_printf("%s/cpu.png", IMG_PREFIX);
597 pixmap = gtk_image_new_from_file(buf);
598 gtk_widget_set_usize(GTK_WIDGET(pixmap), 64, 0);
599 gtk_widget_show(pixmap);
600 gtk_box_pack_start(GTK_BOX(hbox), pixmap, FALSE, FALSE, 0);
601 g_free(buf);
602
603 vbox = gtk_vbox_new(FALSE, 0);
604 gtk_widget_show(vbox);
605 gtk_box_pack_start(GTK_BOX(hbox), vbox, FALSE, FALSE, 0);
606 gtk_container_set_border_width(GTK_CONTAINER(vbox), 10);
607 gtk_box_set_spacing(GTK_BOX(vbox), 4);
608
609 buf = g_strdup_printf(_("<b>%s</b> at %d MHz"),
610 info->processor, info->frequency);
611
612 label = gtk_label_new(buf);
613 gtk_widget_show(label);
614 gtk_label_set_use_markup(GTK_LABEL(label), TRUE);
615 gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0);
616 gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.5);
617 g_free(buf);
618
619 #ifdef ARCH_i386
620 buf = g_strdup_printf(_("Family %d, model %d, stepping %d"),
621 info->family, info->model, info->stepping);
622 label = gtk_label_new(buf);
623 gtk_widget_show(label);
624 gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0);
625 gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.5);
626 g_free(buf);
627 #endif
628
629 if (info->cachel2) {
630 buf = g_strdup_printf(_("%d KB L2 cache"), info->cachel2);
430631 label = gtk_label_new(buf);
431632 gtk_widget_show(label);
432 gtk_box_pack_end(GTK_BOX(hbox2), label, FALSE, FALSE, 0);
433 gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.5);
434 g_free(buf);
435
436 progress = gtk_progress_bar_new();
437 mainwindow->membar = progress;
438 gtk_widget_show(progress);
439 gtk_box_pack_start(GTK_BOX(vbox), progress, TRUE, TRUE, 0);
440
441 memory_update(mainwindow);
442
443 gtk_timeout_add(2000, memory_update, mainwindow);
444
445 g_free(mi);
446 return hbox;
447 }
448
449 GtkWidget *processor_get_widget(void)
450 {
451 GtkWidget *label, *vbox, *hbox;
452 #ifdef GTK2
453 GtkWidget *pixmap;
454 #endif
455 ComputerInfo *info;
456 gchar *buf;
457
458 info = computer_get_info();
459
460 hbox = gtk_hbox_new(FALSE, 0);
461 gtk_widget_show(hbox);
462
463 #ifdef GTK2
464 buf = g_strdup_printf("%s/cpu.png", IMG_PREFIX);
465 pixmap = gtk_image_new_from_file(buf);
466 gtk_widget_set_usize(GTK_WIDGET(pixmap), 64, 0);
467 gtk_widget_show(pixmap);
468 gtk_box_pack_start(GTK_BOX(hbox), pixmap, FALSE, FALSE, 0);
469 g_free(buf);
470 #endif
471
472 vbox = gtk_vbox_new(FALSE, 0);
473 gtk_widget_show(vbox);
474 gtk_box_pack_start(GTK_BOX(hbox), vbox, FALSE, FALSE, 0);
475 gtk_container_set_border_width(GTK_CONTAINER(vbox), 10);
476 gtk_box_set_spacing(GTK_BOX(vbox), 4);
477
478 #ifdef GTK2
479 buf = g_strdup_printf(_("<b>%s</b> at %d MHz (%d bogomips)"), info->processor,
480 info->frequency, info->bogomips);
481 #else
482 buf = g_strdup_printf(_("%s at %d MHz (%d bogomips)"), info->processor,
483 info->frequency, info->bogomips);
484 #endif
485 label = gtk_label_new(buf);
486 gtk_widget_show(label);
487 #ifdef GTK2
488 gtk_label_set_use_markup(GTK_LABEL(label), TRUE);
489 #endif
633
490634 gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0);
491635 gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.5);
492636 g_free(buf);
493
494 #ifdef ARCH_i386
495 buf = g_strdup_printf(_("Family %d, model %d, stepping %d"),
496 info->family, info->model, info->stepping);
497 label = gtk_label_new(buf);
498 gtk_widget_show(label);
499 gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0);
500 gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.5);
501 g_free(buf);
502 #endif
503
504 buf = g_strdup_printf(_("%d KB L2 cache"), info->cachel2);
505 label = gtk_label_new(buf);
506 gtk_widget_show(label);
507 gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0);
508 gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.5);
509 g_free(buf);
510
511 g_free(info);
512 return hbox;
513 }
514
637 }
638
639 g_free(info);
640 return hbox;
641 }
66
77 typedef struct _ComputerInfo ComputerInfo;
88 typedef struct _MemoryInfo MemoryInfo;
9 typedef struct _ComputerInfo CPUDevice;
910
1011 struct _MemoryInfo {
1112 gint total;
2526
2627 gint procno;
2728 gchar *processor;
29 gchar *flags;
30 gchar *machine;
2831 gint frequency;
2932 gint family, model, stepping;
3033 gint cachel2;
4144 gboolean uptime_update(gpointer data);
4245 gboolean memory_update(gpointer data);
4346
47 void hi_show_cpu_info(MainWindow *mainwindow, ComputerInfo *ci);
48
4449 #endif
0 #ifndef __CONFIG_H__
1 #define __CONFIG_H__
2
3 #define VERSION "0.3.7pre"
4 #define USE_LSPCI
5 #define LSPCI "/usr/bin/lspci -v"
6 #define GTK2
7 #define ENABLE_NLS
8 #define ARCH_i386
9 #define PLATFORM "Linux"
10 #define KERNEL "2.6.8-2-686"
11 #define HOSTNAME "alface"
12
13 #endif /* __CONFIG_H__ */
00 #!/usr/bin/env bash
11 #
2 # ToscoConf 0.02
3 # Copyright (c) 2003 Leandro Pereira <leandro@linuxmag.com.br>
2 # ToscoConf 0.04
3 # Copyright (c) 2003-2004 Leandro Pereira <leandro@linuxmag.com.br>
44 # All rights reserved.
55 #
66 # This script is in the Tosco Public License. It may be copied and/or
2020 # ---------------------------------------------------------------------------
2121 # Some defaults
2222
23 IGNORE_GTK2=0
2423 DISABLE_NLS=0
24 IGNORE_LSPCI=0
2525
2626 # ---------------------------------------------------------------------------
2727
2828 PACKAGE=`basename ${PWD} | cut -d"-" -f1`;
2929 VERSION=`basename ${PWD} | cut -d"-" -f2`;
3030
31 echo "ToscoConf (version 0.03) for $PACKAGE version $VERSION"
31 echo "ToscoConf (version 0.04) for $PACKAGE version $VERSION"
3232
3333 # ---------------------------------------------------------------------------
3434 # Damn-cool command line argument parsing. Yay.
3535
3636 while [ "$1" != "" ]; do
3737 case $1 in
38 --with-gtk1)
39 echo "Building with GTK+ 1.2"
40 IGNORE_GTK2=1;;
41 --with-gtk2)
42 echo "Building with GTK+ 2.0"
43 IGNORE_GTK2=0;;
38 --disable-lspci)
39 echo "Disabling lspci"
40 IGNORE_LSPCI=1;;
4441 --disable-nls)
4542 echo "NLS disabled."
4643 DISABLE_NLS=1 ;;
4744 --help)
45 echo ""
4846 echo " --disable-nls Don't use i18n."
49 echo "Interface (default is auto-test):"
50 echo " --with-gtk1 Build with GTK1.2 interface."
51 echo " --with-gtk2 Build with GTK2.0 interface."
47 echo " --disable-lspci Disable lspci."
48 echo ""
5249 echo " --help This help screen."
5350
5451 exit 1;;
8178 ARCH="ARCH_PPC" ;;
8279 x86_64)
8380 ARCH="ARCH_x86_64" ;;
81 mips)
82 ARCH="ARCH_MIPS" ;;
83 parisc*)
84 ARCH="ARCH_PARISC" ;;
85 ia64)
86 ARCH="ARCH_IA64" ;;
8487 *)
85 echo "Architeture \"$ARCH\" not supported."
86 exit ;;
88 # uname -m on m68k doesn't return anything useful :/
89 cat /proc/cpuinfo | grep "680?0" >/dev/null
90 if [ "$?" == "0" ]; then
91 ARCH="ARCH_m68k"
92 else
93 echo "Architeture \"$ARCH\" not supported."
94 exit
95 fi
96
97 ;;
8798 esac
8899
89100 echo "$PROC ($ARCH)"
112123 fi
113124 fi
114125
126 if [ "$IGNORE_LSPCI" -eq 1 ]; then
127 echo "Ignoring lspci (as requested)..."
128 LSPCI=""
129 USE_LSPCI=0
130 fi
131
115132 # ---------------------------------------------------------------------------
116133
117134
118135 GTK2=-1
119 if [ "$IGNORE_GTK2" == "0" ]; then
120 MIN_VERSION="2.0.0"
121 echo -n "Checking for GTK ${MIN_VERSION}... "
122 for i in `which pkg-config`; do
123 pkg-config --errors-to-stdout gtk+-2.0 \
124 --atleast-version=$MIN_VERSION > /dev/null
125 case $? in
126 0)
127 GTK_FLAGS=`pkg-config gtk+-2.0 --cflags`
128 GTK_LIBS=`pkg-config gtk+-2.0 --libs`
129 echo "seems ok, will not test though."
130 GTK2=1 ;;
131 *)
132 echo "not found." ;;
133 esac
134 done
135 fi
136 MIN_VERSION="2.2.0"
137 echo -n "Checking for GTK ${MIN_VERSION}... "
138 for i in `which pkg-config`; do
139 pkg-config --errors-to-stdout gtk+-2.0 \
140 --atleast-version=$MIN_VERSION > /dev/null
141 case $? in
142 0)
143 GTK_FLAGS=`pkg-config gtk+-2.0 --cflags`
144 GTK_LIBS=`pkg-config gtk+-2.0 --libs`
145 echo "OK (pkgconfig)"
146 GTK2=1 ;;
147 *)
148 echo "not found." ;;
149 esac
150 done
136151
137152 # If the user doesn't have GTK2, try to compile with GTK1.2 :)
138
139 GTK1=-1
140 if [ "$GTK2" -ne 1 ]; then
141 min_major=1
142 min_minor=2
143 min_rev=6
144 echo -n "Checking for GTK $min_major.$min_minor.$min_rev... "
145 for i in `which gtk-config`; do
146 VER=`gtk-config --version`
147
148 # RegExp stolen from AutoConf.
149 major=`echo $VER | sed 's/\([0-9]*\).\([0-9]*\).\([0-9]*\)/\1/'`
150 minor=`echo $VER | sed 's/\([0-9]*\).\([0-9]*\).\([0-9]*\)/\2/'`
151 rev=`echo $VER | sed 's/\([0-9]*\).\([0-9]*\).\([0-9]*\)/\3/'`
152
153 if [ $major -lt $min_major ]; then
154 break;
155 fi
156
157 if [ $minor -lt $min_minor ]; then
158 break;
159 fi
160
161 if [ $rev -lt $min_rev ]; then
162 break;
163 fi
164
165 GTK_FLAGS=`gtk-config --cflags`
166 GTK_LIBS=`gtk-config --libs`
167 echo "seems ok, will not test though."
168 GTK1=1
169 done
170 fi
153 # GTK 1.2 is no longer supported
171154
172155 # --------------------------------------------------------------------------
173156
174 if [ `expr $GTK1 + $GTK2` -eq -2 ]; then
157 if [ $GTK2 -eq -1 ]; then
175158 echo -e "\nYou need the GTK libraries, including the development stuff."
176159 echo "If you're using Debian, running the command as root:"
177160 echo -e "\n\tapt-get install libgtk2.0-dev\n"
192175 echo "#define LSPCI \"$LSPCI -v\"" >> config.h
193176 fi
194177
195 if [ "$GTK2" -ne -1 ]; then
196 echo "#define GTK2" >> config.h
197 else
198 echo "#define GTK1" >> config.h
199 fi
178 echo "#define GTK2" >> config.h
200179
201180 if [ "$DISABLE_NLS" != "1" ]; then
202181 echo "#define ENABLE_NLS" >> config.h
204183
205184 echo "#define $ARCH" >> config.h
206185
186 echo "#define PLATFORM \"`uname`\"" >> config.h
187 echo "#define KERNEL \"`uname -r`\"" >> config.h
188 echo "#define HOSTNAME \"`hostname`\"" >> config.h
189
207190 echo -e "\n#endif /* __CONFIG_H__ */" >> config.h
208191
209192 echo "Writing Makefile..."
210193 rm -f Makefile
211 if [ "$GTK2" -ne -1 ]; then
212 echo "TARGET = GTK2" > Makefile
213 else
214 echo "TARGET = GTK1" > Makefile
215 fi
194 echo "TARGET = GTK2" > Makefile
216195
217196 echo "GTK_LIBS = ${GTK_LIBS}" >> Makefile
218197 echo "GTK_CFLAGS = ${GTK_FLAGS}" >> Makefile
(New empty file)
0 hardinfo (0.3.7pre-1) unstable; urgency=low
1
2 * New upstream release. (Closes: #280694, #300114, #233033)
3
4 -- Agney Lopes Roth Ferraz <agney@users.sourceforge.net> Mon, 13 Jun 2005 18:34:20 -0300
5
06 hardinfo (0.3.6-5) unstable; urgency=high
17
28 * Add Amd64 support (closes: #253935).
00 Source: hardinfo
11 Section: x11
22 Priority: optional
3 Maintainer: Leandro Pereira <leandro@linuxmag.com.br>
3 Maintainer: Agney Lopes Roth Ferraz <agney@users.sourceforge.net>
44 Build-Depends: debhelper (>> 4.0.0), libgtk2.0-dev, pciutils (>=1:2.1.11-10)
5 Standards-Version: 3.5.8
5 Standards-Version: 3.6.1.0
66
77 Package: hardinfo
88 Architecture: any
0 ?package(hardinfo):needs=X11 section=Apps/System\
1 title="System Information" command="/usr/bin/hardinfo" \
2 icon=/usr/share/hardinfo/pixmaps/logo.png
0 ?package(hardinfo): \
1 needs="X11" \
2 section="Apps/System" \
3 title="System Information" command="/usr/bin/hardinfo" \
4 icon="/usr/share/hardinfo/pixmaps/logo.xpm"
35
0 [Translation]
1 translated-by=Unknown
2
3 [about.c]
4
5 [computer.c]
6 Number=Number
7 Frequency=Frequency
8 Family=Family
9 Model=Model
10 Stepping=Stepping
11 Cache L2=Cache L2
12 Bogomips=Bogomips
13 Features=Features
14 Unknown distribution=Unknown distribution
15 %d hour%s and %ld minute%s=%d hour%s and %ld minute%s
16 %d day%s, %d hour%s and %ld minute%s=%d day%s, %d hour%s and %ld minute%s
17 <b>Computer name:</b>=<b>Computer name:</b>
18 <b>Distribution:</b>=<b>Distribution:</b>
19 <b>Kernel:</b>=<b>Kernel:</b>
20 <b>Uptime:</b>=<b>Uptime:</b>
21 Updating...=Updating...
22 <b>%s</b> at %d MHz=<b>%s</b> at %d MHz
23 Family %d, model %d, stepping %d=Family %d, model %d, stepping %d
24 %d KB L2 cache=%d KB L2 cache
25
26 [details.c]
27 Information=Information
28 No device selected.=No device selected.
29
30 [hardinfo.c]
31 System information tool for GNU/Linux.\n=System information tool for GNU/Linux.\n
32 System Information=System Information
33 Computer=Computer
34 <b><big>Operating System</big></b>=<b><big>Operating System</big></b>
35 <b><big>Processor</big></b>=<b><big>Processor</big></b>
36 <b><big>Memory Usage</big></b>=<b><big>Memory Usage</big></b>
37 Details=Details
38 Environment=Environment
39 <b><big>X-Window System</big></b>=<b><big>X-Window System</big></b>
40 Network=Network
41 <b><big>Interfaces</big></b>=<b><big>Interfaces</big></b>
42 Scanning Devices=Scanning Devices
43 Scanning devices...=Scanning devices...
44 Scanning %s devices...=Scanning %s devices...
45 Processor=Processor
46 PCI Devices=PCI Devices
47 ISA PnP Devices=ISA PnP Devices
48 ATA/IDE Block Devices=ATA/IDE Block Devices
49 SCSI Devices=SCSI Devices
50 Video for Linux=Video for Linux
51 Communication Ports=Communication Ports
52 Parallel Ports=Parallel Ports
53 Kernel Modules=Kernel Modules
54 for more information.\n\n=for more information.\n\n
55
56 [ide.c]
57 ATA/IDE %s Device=ATA/IDE %s Device
58 Cache (kb)=Cache (kb)
59 Physical geometry=Physical geometry
60 Logical geometry=Logical geometry
61
62 [intl.c]
63
64 [isapnp.c]
65 ISA Plug and Play Device=ISA Plug and Play Device
66 Card ID=Card ID
67 PnP version=PnP version
68 Product version=Product version
69
70 [modules.c]
71 Author=Author
72 License=License
73 Depends on=Depends on
74
75 [net.c]
76
77 [parport.c]
78 N/A=N/A
79 Parallel Port=Parallel Port
80 Description=Description
81 Command set=Command set
82 Base I/O address=Base I/O address
83 Modes=Modes
84 Uses DMA=Uses DMA
85 Yes=Yes
86 No=No
87
88 [pci.c]
89 0x%x to 0x%x=0x%x to 0x%x
90 I/O Address=I/O Address
91 %d%s=%d%s
92 Memory=Memory
93 %dMHz=%dMHz
94 Frequency=Frequency
95 Latency=Latency
96 Bus master=Bus master
97 Yes=Yes
98 No=No
99 Domain=Domain
100 Bus=Bus
101 Device=Device
102 Function=Function
103
104 [scsi.c]
105 SCSI %s Device=SCSI %s Device
106 Revision=Revision
107 Type=Type
108 Controller=Controller
109 Channel=Channel
110 ID=ID
111 LUN=LUN
112
113 [serial.c]
114 Serial Port (tty%d)=Serial Port (tty%d)
115 Communication Port=Communication Port
116 Communication Port=Communication Port
117 I/O port=I/O port
118 IRQ=IRQ
119
120 [status.c]
121
122 [stock.c]
123
124 [usb.c]
125 USB Devices=USB Devices
126 Unknown device (%s)=Unknown device (%s)
127 USB Device=USB Device
128 Class=Class
129 Version=Version
130 Revision=Revision
131 Vendor ID=Vendor ID
132 Product ID=Product ID
133
134 [v4l.c]
135 Device Information=Device Information
136 Type=Type
137
138 [x11.c]
139 Local display (%s)=Local display (%s)
140 Remote display (%s)=Remote display (%s)
141 XFree86 version %s (protocol version %d.%d)=XFree86 version %s (protocol version %d.%d)
142 %d (protocol version %d.%d)=%d (protocol version %d.%d)
143 <b>Display:</b>=<b>Display:</b>
144 <b>Vendor:</b>=<b>Vendor:</b>
145 <b>Release:</b>=<b>Release:</b>
146 <b>Resolution:</b>=<b>Resolution:</b>
147
0 /*
1 * Hardware Information, version 0.3.2
2 * Copyright (C) 2003 Leandro Pereira <leandro@linuxmag.com.br>
3 *
4 * May be modified and/or distributed under the terms of GNU GPL version 2.
5 *
6 */
7
8 #include "details.h"
9 #include "hardinfo.h"
10
11 gboolean
12 detail_window_close(GtkWidget *widget, gpointer data)
13 {
14 DetailWindow *dw = (DetailWindow *) data;
15
16 gtk_widget_destroy(dw->window);
17
18 return FALSE;
19 }
20
21 void
22 detail_window_set_title(DetailWindow *dw, const gchar *title)
23 {
24 if (!dw) return;
25
26 gtk_window_set_title(GTK_WINDOW(dw->window), title);
27 }
28
29 void
30 detail_window_update_names(DetailWindow *dw)
31 {
32 gchar *buf;
33
34 if (dw->device_name && strstr(dw->device_name, "&")) {
35 gchar *temp, *temp2;
36
37 temp = (gchar *) malloc (strlen (dw->device_name) * 2);
38
39 temp2 = temp;
40
41 while (*(dw->device_name)) {
42 if (*(dw->device_name) == '&') {
43 *(temp++) = '&';
44 *(temp++) = 'a';
45 *(temp++) = 'm';
46 *(temp++) = 'p';
47 *(temp++) = ';';
48 } else {
49 *(temp++) = *(dw->device_name);
50 }
51 dw->device_name++;
52 }
53
54 *(temp++) = 0;
55
56 temp = temp2;
57
58 g_free(dw->device_name);
59 dw->device_name = g_strdup(temp);
60
61 g_free(temp);
62 }
63
64 if (!dw->device_type)
65 dw->device_type = "";
66
67 buf = g_strdup_printf("<big><b>%s</b></big>\n%s",
68 dw->device_name, dw->device_type);
69
70 gtk_label_set_markup(GTK_LABEL(dw->name_label), buf);
71
72 g_free(buf);
73 }
74
75 void
76 detail_window_append_separator(DetailWindow *dw)
77 {
78 GtkWidget *sep;
79
80 sep = gtk_hseparator_new();
81 gtk_widget_show(sep);
82
83 gtk_table_attach_defaults(GTK_TABLE(dw->info_table), sep, 0, 2, dw->last_info,
84 dw->last_info + 1);
85
86 dw->last_info++;
87 }
88
89 void
90 detail_window_set_dev_type(DetailWindow *dw, const gchar *type)
91 {
92 dw->device_type = g_strdup(type);
93
94 detail_window_update_names(dw);
95 }
96
97 void
98 detail_window_set_dev_name(DetailWindow *dw, const gchar *name)
99 {
100 dw->device_name = g_strdup(name);
101
102 detail_window_update_names(dw);
103 }
104
105 void
106 detail_window_append_info_int(DetailWindow *dw, const gchar *name, gint val,
107 gboolean hex)
108 {
109 gchar *buf;
110
111 buf = g_strdup_printf(hex ? "0x%X" : "%d", val);
112 detail_window_append_info(dw, name, buf);
113 g_free(buf);
114 }
115
116 void
117 detail_window_append_info(DetailWindow *dw, const gchar *name, gchar *val)
118 {
119 GtkWidget *label;
120 gchar *buf;
121
122 if (dw->last_info == 0)
123 dw->last_info = 1;
124
125 buf = g_strdup_printf("<b>%s:</b>", name);
126 label = gtk_label_new(buf);
127 gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.5);
128 gtk_label_set_use_markup(GTK_LABEL(label), TRUE);
129 gtk_widget_show(label);
130 gtk_table_attach_defaults(GTK_TABLE(dw->info_table), label, 0, 1, dw->last_info,
131 dw->last_info + 1);
132 g_free(buf);
133
134 label = gtk_label_new(val);
135 gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.5);
136 gtk_widget_show(label);
137 gtk_label_set_line_wrap(GTK_LABEL(label), TRUE);
138 gtk_label_set_selectable(GTK_LABEL(label), TRUE);
139 gtk_table_attach(GTK_TABLE(dw->info_table), label, 1, 2, dw->last_info,
140 dw->last_info + 1, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0);
141
142 dw->last_info++;
143
144 }
145
146 static gboolean
147 notebook_hide_tabs(GtkWidget *widget, gpointer data)
148 {
149 if (gtk_notebook_get_n_pages(GTK_NOTEBOOK(widget)) == 1) {
150 gtk_notebook_set_show_tabs(GTK_NOTEBOOK(widget), FALSE);
151 gtk_notebook_set_show_border(GTK_NOTEBOOK(widget), FALSE);
152 } else {
153 gtk_notebook_set_show_tabs(GTK_NOTEBOOK(widget), TRUE);
154 gtk_notebook_set_show_border(GTK_NOTEBOOK(widget), TRUE);
155 }
156
157 return FALSE;
158 }
159
160 void
161 detail_window_set_icon(DetailWindow *dw, const gchar *path)
162 {
163 if (!dw || !dw->icon) return;
164
165 gtk_image_set_from_file(GTK_IMAGE(dw->icon), path);
166 }
167
168 DetailWindow *
169 detail_window_new(void)
170 {
171 DetailWindow *dw;
172 GtkWidget *window, *vbox, *btn, *hbbox, *notebook, *table,
173 *label, *info_table;
174 GtkWidget *icon, *vb, *hb;
175
176 dw = g_new0(DetailWindow, 1);
177
178 window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
179 gtk_container_set_border_width(GTK_CONTAINER(window), 5);
180 gtk_window_set_title(GTK_WINDOW(window), "Hardware Details");
181 gtk_window_set_type_hint(GTK_WINDOW(window), GDK_WINDOW_TYPE_HINT_UTILITY);
182 gtk_window_set_resizable(GTK_WINDOW(window), FALSE);
183 gtk_widget_realize(window);
184
185 dw->window = window;
186
187 vbox = gtk_vbox_new(FALSE, 0);
188 gtk_widget_show(vbox);
189 gtk_container_add(GTK_CONTAINER(window), vbox);
190
191 dw->vbox = vbox;
192
193 notebook = gtk_notebook_new();
194 gtk_widget_show(notebook);
195 gtk_box_pack_start(GTK_BOX(vbox), notebook, TRUE, TRUE, 0);
196 gtk_notebook_set_show_tabs(GTK_NOTEBOOK(notebook), FALSE);
197 gtk_notebook_set_show_border(GTK_NOTEBOOK(notebook), FALSE);
198 dw->notebook = notebook;
199
200 g_signal_connect(G_OBJECT(notebook), "expose-event",
201 G_CALLBACK(notebook_hide_tabs), notebook);
202
203 table = gtk_table_new(1, 2, FALSE);
204 gtk_container_set_border_width(GTK_CONTAINER(table), 8);
205 gtk_table_set_row_spacings(GTK_TABLE(table), 4);
206 gtk_table_set_col_spacings(GTK_TABLE(table), 16);
207 gtk_widget_show(table);
208
209 label = gtk_label_new(_("Information"));
210 gtk_widget_show(label);
211 gtk_notebook_append_page(GTK_NOTEBOOK(notebook), table,
212 label);
213
214 hb = gtk_hbox_new(FALSE, 5);
215 gtk_widget_show(hb);
216 gtk_table_attach_defaults(GTK_TABLE(table), hb, 0, 1, 0, 1);
217
218 icon = gtk_image_new();
219 gtk_misc_set_alignment(GTK_MISC(icon), 0.5, 0.0);
220 gtk_widget_show(icon);
221 dw->icon = icon;
222
223 gtk_table_attach_defaults(GTK_TABLE(table), icon, 0, 1, 0, 1);
224
225 vb = gtk_vbox_new(FALSE, 5);
226 gtk_widget_show(vb);
227 gtk_box_pack_start(GTK_BOX(hb), vb, TRUE, TRUE, 0);
228
229 label = gtk_label_new(_("No device selected."));
230 gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.5);
231 gtk_label_set_use_markup(GTK_LABEL(label), TRUE);
232 gtk_widget_show(label);
233 gtk_table_attach(GTK_TABLE(table), label, 1, 2, 0, 1,
234 GTK_FILL | GTK_EXPAND, 0, 0, 0);
235 dw->name_label = label;
236
237 info_table = gtk_table_new(0, 0, FALSE);
238 gtk_widget_show(info_table);
239 gtk_table_attach(GTK_TABLE(table), info_table, 1, 2, 2, 3,
240 GTK_EXPAND | GTK_FILL, 0, 0, 0);
241 gtk_table_set_col_spacings(GTK_TABLE(info_table), 4);
242 gtk_table_set_row_spacings(GTK_TABLE(info_table), 2);
243 dw->info_table = info_table;
244
245 hbbox = gtk_hbutton_box_new();
246 gtk_container_set_border_width(GTK_CONTAINER(hbbox), 4);
247 gtk_widget_show(hbbox);
248 gtk_box_pack_start(GTK_BOX(vbox), hbbox, FALSE, FALSE, 0);
249 gtk_button_box_set_spacing(GTK_BUTTON_BOX(hbbox), 6);
250 gtk_button_box_set_layout(GTK_BUTTON_BOX(hbbox), GTK_BUTTONBOX_END);
251
252 btn = gtk_button_new_from_stock(GTK_STOCK_CLOSE);
253 g_signal_connect(G_OBJECT(btn), "clicked", G_CALLBACK(detail_window_close), dw);
254 gtk_widget_show(btn);
255 gtk_box_pack_end(GTK_BOX(hbbox), btn, FALSE, FALSE, 0);
256
257 detail_window_set_icon(dw, IMG_PREFIX "logo.png");
258
259 return dw;
260 }
261
262 void
263 detail_window_show(GtkWidget *widget, gpointer data)
264 {
265 MainWindow *mainwindow = (MainWindow *) data;
266 GenericDevice *dev;
267
268 mainwindow->det_window = detail_window_new();
269
270 dev = (GenericDevice *) gtk_ctree_node_get_row_data
271 (GTK_CTREE(mainwindow->ctree), GTK_CLIST(mainwindow->ctree)->
272 selection->data);
273
274 hi_show_device_info_real(mainwindow, dev);
275
276 gtk_window_set_modal(GTK_WINDOW(mainwindow->det_window->window), TRUE);
277 gtk_window_set_position(GTK_WINDOW(mainwindow->det_window->window), GTK_WIN_POS_CENTER_ON_PARENT);
278 gtk_window_set_transient_for(GTK_WINDOW(mainwindow->det_window->window),
279 GTK_WINDOW(mainwindow->window));
280 gtk_widget_show(mainwindow->det_window->window);
281 }
0 #ifndef __DETAILS_H__
1 #define __DETAILS_H__
2
3 #include <gtk/gtk.h>
4 #include "config.h"
5
6 typedef struct _DetailWindow DetailWindow;
7
8 struct _DetailWindow {
9 GtkWidget *window;
10 GtkWidget *vbox;
11 GtkWidget *notebook;
12 GtkWidget *icon;
13 GtkWidget *name_label;
14
15 gchar *device_name;
16 gchar *device_type;
17 gchar *manufacturer;
18
19 GtkWidget *info_table;
20 gint last_info;
21 };
22
23 gboolean detail_window_close(GtkWidget *widget, gpointer data);
24 DetailWindow *detail_window_new(void);
25 void detail_window_set_icon(DetailWindow *dw, const gchar *path);
26 void detail_window_show(GtkWidget *widget, gpointer data);
27
28 void detail_window_set_dev_name(DetailWindow *dw, const gchar *name);
29 void detail_window_set_dev_type(DetailWindow *dw, const gchar *type);
30 void detail_window_update_names(DetailWindow *dw);
31
32 void detail_window_append_info(DetailWindow *dw, const gchar *name,
33 gchar *val);
34 void detail_window_append_info_int(DetailWindow *dw, const gchar *name,
35 gint val, gboolean hex);
36 void detail_window_append_separator(DetailWindow *dw);
37
38
39 #endif
1616 #include "pixmaps/hdd.xpm"
1717 #include "pixmaps/gen_connector.xpm"
1818 #include "pixmaps/scsi.xpm"
19 #include "pixmaps/processor.xpm"
1920
2021 #include "computer.h"
2122 #include "status.h"
23 #include "stock.h"
2224
2325 GenericDevice *generic_devices = NULL;
2426
25 void hi_show_device_info(GtkCTree * tree, GList * node,
27 void hi_enable_details_button(GtkCTree * tree, GList * node,
2628 gint column, gpointer user_data);
27 void hi_hide_device_info(GtkCTree * tree, GList * node,
29 void hi_enable_details_button_real(MainWindow *mainwindow, GenericDevice *dev);
30 void hi_disable_details_button(GtkCTree * tree, GList * node,
2831 gint column, gpointer user_data);
2932 void hi_scan_all(MainWindow * mainwindow);
3033
3639 if (!mainwindow)
3740 return;
3841
39 hi_hide_device_info(NULL, NULL, 0, mainwindow);
42 hi_disable_details_button(NULL, NULL, 0, mainwindow);
4043
4144 memory_update(mainwindow);
4245 uptime_update(mainwindow);
4952 about_window_create(void)
5053 {
5154 GtkAbout *about;
55 const gchar *sysinfo = HOSTNAME " (" PLATFORM KERNEL ")";
5256 const gchar *authors[] = {
5357 ">Written by:",
54 "Leandro Pereira (leandro@linuxmag.com.br)",
58 "Leandro A. F. Pereira (leandro@linuxmag.com.br)",
5559 ">Disclaimer:",
56 "This is free software; you can modify and/or distribute it",
57 "under the terms of GNU GPL version 2. See http://www.fsf.org/",
58 "for more information.",
60 "This is free software; you can modify and/or distribute it",
61 "under the terms of GNU GPL version 2. See http://www.fsf.org/",
62 "for more information.",
63 ">Compiled on:",
64 sysinfo,
5965 NULL
6066 };
6167
6268 about = gtk_about_new("HardInfo", VERSION,
63 _("System information tool for Linux.\n"),
69 _("System information tool for GNU/Linux.\n"),
6470 authors, IMG_PREFIX "logo.png");
6571
6672 }
6874 MainWindow *
6975 main_window_create(void)
7076 {
71 GtkWidget *window, *mbox, *vbox, *frame, *ctree, *scroll;
77 GtkWidget *window, *mbox, *vbox, *ctree, *scroll;
7278 GtkWidget *notebook, *label, *hbox, *btn, *hbbox;
7379 MainWindow *mainwindow;
7480
7581 mainwindow = g_new0(MainWindow, 1);
82
83 mainwindow->det_window = detail_window_new();
7684
7785 window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
7886 gtk_container_set_border_width(GTK_CONTAINER(window), 4);
7987 gtk_window_set_title(GTK_WINDOW(window), _("System Information"));
8088
81 #ifdef GTK2
8289 g_signal_connect(G_OBJECT(window), "delete-event", gtk_main_quit, NULL);
83 #else
84 gtk_signal_connect(GTK_OBJECT(window), "delete-event",
85 (GtkSignalFunc) gtk_main_quit, NULL);
86 #endif
90 gtk_window_set_icon_from_file(GTK_WINDOW(window), IMG_PREFIX "logo.png", NULL);
8791
8892 mbox = gtk_vbox_new(FALSE, 5);
8993 gtk_widget_show(mbox);
101105 gtk_notebook_append_page(GTK_NOTEBOOK(notebook), vbox,
102106 gtk_label_new(_("Computer")));
103107
104 #ifdef GTK2
105108 label = gtk_label_new(_("<b><big>Operating System</big></b>"));
106109 gtk_label_set_use_markup(GTK_LABEL(label), TRUE);
107 #else
108 label = gtk_label_new(_("Operating System"));
109 #endif
110110 gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.5);
111111 gtk_widget_show(label);
112112 gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0);
113113 gtk_box_pack_start(GTK_BOX(vbox), os_get_widget(mainwindow),
114114 FALSE, FALSE, 0);
115115
116 #ifdef GTK2
117116 label = gtk_label_new(_("<b><big>Processor</big></b>"));
118117 gtk_label_set_use_markup(GTK_LABEL(label), TRUE);
119 #else
120 label = gtk_label_new(_("Processor"));
121 #endif
122118 gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.5);
123119 gtk_widget_show(label);
124120 gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0);
125121 gtk_box_pack_start(GTK_BOX(vbox), processor_get_widget(), FALSE,
126122 FALSE, 0);
127123
128 #ifdef GTK2
129124 label = gtk_label_new(_("<b><big>Memory Usage</big></b>"));
130125 gtk_label_set_use_markup(GTK_LABEL(label), TRUE);
131 #else
132 label = gtk_label_new(_("Memory Usage"));
133 #endif
134126 gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.5);
135127 gtk_widget_show(label);
136128 gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0);
144136 gtk_container_set_border_width(GTK_CONTAINER(vbox), 4);
145137 gtk_widget_show(vbox);
146138 gtk_notebook_append_page(GTK_NOTEBOOK(notebook), vbox,
147 gtk_label_new(_("Devices")));
139 gtk_label_new(_("Details")));
140
141 hbbox = gtk_hbutton_box_new();
142 gtk_container_set_border_width(GTK_CONTAINER(hbbox), 4);
143 gtk_widget_show(hbbox);
144 gtk_box_pack_end(GTK_BOX(vbox), hbbox, FALSE, FALSE, 0);
145 gtk_button_box_set_spacing(GTK_BUTTON_BOX(hbbox), 6);
146 gtk_button_box_set_layout(GTK_BUTTON_BOX(hbbox), GTK_BUTTONBOX_END);
147
148 btn = gtk_button_new_from_stock(HI_DETAILS);
149 g_signal_connect(G_OBJECT(btn), "clicked",
150 (GCallback) detail_window_show, mainwindow);
151 gtk_widget_show(btn);
152 gtk_box_pack_end(GTK_BOX(hbbox), btn, FALSE, FALSE, 0);
153 mainwindow->details_button = btn;
148154
149155 scroll = gtk_scrolled_window_new(NULL, NULL);
150156 gtk_box_pack_start(GTK_BOX(vbox), scroll, TRUE, TRUE, 0);
161167 gtk_clist_set_column_width(GTK_CLIST(ctree), 0, 32);
162168 gtk_clist_set_column_width(GTK_CLIST(ctree), 1, 32);
163169 gtk_clist_set_row_height(GTK_CLIST(ctree), 18);
164 #ifdef GTK2
165170 g_signal_connect(G_OBJECT(ctree), "tree-select-row",
166 (GCallback) hi_show_device_info, mainwindow);
171 (GCallback) hi_enable_details_button, mainwindow);
167172 g_signal_connect(G_OBJECT(ctree), "tree-unselect-row",
168 (GCallback) hi_hide_device_info, mainwindow);
169 #else
170 gtk_signal_connect(GTK_OBJECT(ctree), "tree-select-row",
171 (GtkCTreeFunc) hi_show_device_info, mainwindow);
172 gtk_signal_connect(GTK_OBJECT(ctree), "tree-unselect-row",
173 (GtkCTreeFunc) hi_hide_device_info, mainwindow);
174 #endif
175
176 frame = gtk_frame_new(_("Device information"));
177 gtk_box_pack_start(GTK_BOX(vbox), frame, FALSE, FALSE, 0);
178
173 (GCallback) hi_disable_details_button, mainwindow);
174
179175 /*
180176 * Environment tab
181177 */
185181 gtk_notebook_append_page(GTK_NOTEBOOK(notebook), vbox,
186182 gtk_label_new(_("Environment")));
187183
188 #ifdef GTK2
189184 label = gtk_label_new(_("<b><big>X-Window System</big></b>"));
190185 gtk_label_set_use_markup(GTK_LABEL(label), TRUE);
191 #else
192 label = gtk_label_new(_("X-Window System"));
193 #endif
194186 gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.5);
195187 gtk_widget_show(label);
196188 gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0);
197 gtk_box_pack_start(GTK_BOX(vbox), x11_get_widget(mainwindow),
198 FALSE, FALSE, 0);
199
200 #if 0
189 // gtk_box_pack_start(GTK_BOX(vbox), x11_get_widget(mainwindow),
190 // FALSE, FALSE, 0);
191
201192 /*
202193 * Network tab
203194 */
207198 gtk_notebook_append_page(GTK_NOTEBOOK(notebook), vbox,
208199 gtk_label_new(_("Network")));
209200
210 #ifdef GTK2
211201 label = gtk_label_new(_("<b><big>Interfaces</big></b>"));
212202 gtk_label_set_use_markup(GTK_LABEL(label), TRUE);
213 #else
214 label = gtk_label_new(_("Interfaces"));
215 #endif
216203 gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.5);
217204 gtk_widget_show(label);
218205 gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0);
219206 gtk_box_pack_start(GTK_BOX(vbox), net_get_widget(mainwindow),
220207 TRUE, TRUE, 0);
221208
222 #endif
223209 /*
224210 * Buttons
225211 */
226
227212 hbox = gtk_hbox_new(FALSE, 5);
228213 gtk_widget_show(hbox);
229214 gtk_box_pack_start(GTK_BOX(mbox), hbox, FALSE, FALSE, 0);
235220 gtk_button_box_set_spacing(GTK_BUTTON_BOX(hbbox), 6);
236221 gtk_button_box_set_layout(GTK_BUTTON_BOX(hbbox), GTK_BUTTONBOX_START);
237222
238 btn = gtk_button_new_with_mnemonic(_("Abo_ut..."));
239 #ifdef GTK2
223 btn = gtk_button_new_from_stock(HI_ABOUT);
240224 g_signal_connect(G_OBJECT(btn), "clicked",
241225 (GCallback) about_window_create, NULL);
242 #else
243 gtk_signal_connect(GTK_OBJECT(btn), "clicked",
244 (GtkSignalFunc) about_window_create, NULL);
245 #endif
246226 gtk_widget_show(btn);
247227 gtk_box_pack_start(GTK_BOX(hbbox), btn, FALSE, FALSE, 0);
248228
253233 gtk_button_box_set_spacing(GTK_BUTTON_BOX(hbbox), 6);
254234 gtk_button_box_set_layout(GTK_BUTTON_BOX(hbbox), GTK_BUTTONBOX_END);
255235
256 #if 0
257 btn = gtk_button_new_with_label(_("About"));
258 #ifdef GTK2
259 g_signal_connect(G_OBJECT(btn), "clicked",
260 (GCallback) about_window_create, NULL);
261 #else
262 gtk_signal_connect(GTK_OBJECT(btn), "clicked",
263 (GtkSignalFunc) about_window_create, NULL);
264 #endif
265 gtk_widget_show(btn);
266 gtk_box_pack_start(GTK_BOX(hbbox), btn, FALSE, FALSE, 0);
267 #endif
268
269 #ifdef GTK2
270236 btn = gtk_button_new_from_stock(GTK_STOCK_REFRESH);
271237 g_signal_connect(G_OBJECT(btn), "clicked",
272238 (GCallback) main_window_refresh, mainwindow);
273 #else
274 btn = gtk_button_new_with_label(_("Refresh"));
275 gtk_signal_connect(GTK_OBJECT(btn), "clicked",
276 (GtkSignalFunc) main_window_refresh, mainwindow);
277 #endif
278239 gtk_widget_show(btn);
279240 gtk_box_pack_start(GTK_BOX(hbbox), btn, FALSE, FALSE, 0);
280241
281 #ifdef GTK2
282242 btn = gtk_button_new_from_stock(GTK_STOCK_CLOSE);
283243 g_signal_connect(G_OBJECT(btn), "clicked", gtk_main_quit, NULL);
284 #else
285 btn = gtk_button_new_with_label(_("Close"));
286 gtk_signal_connect(GTK_OBJECT(btn), "clicked",
287 (GtkSignalFunc) gtk_main_quit, NULL);
288 #endif
289244 gtk_widget_show(btn);
290245 gtk_box_pack_start(GTK_BOX(hbbox), btn, FALSE, FALSE, 0);
291246
292
293
294247 gtk_widget_show_all(window);
295 gtk_widget_hide(frame);
296248
297249 mainwindow->window = window;
298250 mainwindow->ctree = ctree;
299 mainwindow->frame = frame;
300251
301252 return mainwindow;
302253 }
346297 case SERIAL:
347298 pixmap = gdk_pixmap_colormap_create_from_xpm_d
348299 (NULL, colormap, &mask, NULL, gen_connector_xpm);
349
350300 break;
351301 case V4L:
352302 case PCI:
365315 case USB:
366316 pixmap = gdk_pixmap_colormap_create_from_xpm_d
367317 (NULL, colormap, &mask, NULL, usb_xpm);
318 break;
319 case MODULE:
320 case PROCESSOR:
321 pixmap = gdk_pixmap_colormap_create_from_xpm_d
322 (NULL, colormap, &mask, NULL, processor_xpm);
368323 break;
369324 default:
370325 mask = pixmap = NULL;
421376 }
422377
423378 void
424 hi_hide_device_info(GtkCTree * tree, GList * node,
379 hi_disable_details_button(GtkCTree * tree, GList * node,
425380 gint column, gpointer user_data)
426381 {
427382 MainWindow *mainwindow = (MainWindow *) user_data;
428383
429 gtk_widget_hide(mainwindow->frame);
430 }
431
432 void
433 hi_show_device_info(GtkCTree * tree, GList * node,
384 gtk_widget_set_sensitive(GTK_WIDGET(mainwindow->details_button), FALSE);
385 }
386
387 void hi_enable_details_button(GtkCTree * tree, GList * node,
434388 gint column, gpointer user_data)
435389 {
436 GenericDevice *dev;
437390 MainWindow *mainwindow = (MainWindow *) user_data;
438391
439 dev = (GenericDevice *) gtk_ctree_node_get_row_data
440 (GTK_CTREE(tree), GTK_CLIST(tree)->selection->data);
441
392 gtk_widget_set_sensitive(GTK_WIDGET(mainwindow->details_button), TRUE);
393 }
394
395 void hi_show_device_info_real(MainWindow *mainwindow, GenericDevice *dev)
396 {
442397 if (!dev)
443398 return;
444399
451406 break;
452407
453408 switch (dev->type) {
409 case MODULE:
410 dev_info(ModInfo, mod, hi_show_module_info);
411 case PROCESSOR:
412 dev_info(CPUDevice, cpu, hi_show_cpu_info);
454413 case PCI:
455414 dev_info(PCIDevice, pci, hi_show_pci_info);
456415 case ISAPnP:
473432 return;
474433 break;
475434 }
476
477 gtk_widget_show(mainwindow->frame);
478
479435 }
480436
481437 void
482438 hi_scan_all(MainWindow * mainwindow)
483439 {
484 myStatus *status;
485 PCIDevice *pci;
486 ISADevice *isa;
487 IDEDevice *ide;
488 SCSIDevice *scsi;
489 V4LDevice *v4l;
490 ParportDevice *pp;
491 SerialDevice *sd;
492 GtkCTreeNode *node;
493 GenericDevice *gd = generic_devices;
494 gchar *buf;
440 myStatus *status;
441 PCIDevice *pci;
442 ISADevice *isa;
443 IDEDevice *ide;
444 CPUDevice *cpu;
445 SCSIDevice *scsi;
446 V4LDevice *v4l;
447 ParportDevice *pp;
448 SerialDevice *sd;
449 GtkCTreeNode *node;
450 ModInfo *mod;
451 GenericDevice *gd = generic_devices;
452 gchar *buf;
495453
496454 status = my_status_new(_("Scanning Devices"), _("Scanning devices..."));
497455
502460 g_free(buf); \
503461 my_status_pulse(status)
504462
463 DEVICE_SCAN("CPU", cpu, computer_get_info);
505464 DEVICE_SCAN("PCI", pci, hi_scan_pci);
506465 DEVICE_SCAN("ISA PnP", isa, hi_scan_isapnp);
507466 DEVICE_SCAN("IDE", ide, hi_scan_ide);
509468 DEVICE_SCAN("V4L", v4l, hi_scan_v4l);
510469 DEVICE_SCAN("Parallel", pp, hi_scan_parport);
511470 DEVICE_SCAN("Serial", sd, hi_scan_serial);
471 DEVICE_SCAN("modules", mod, hi_scan_modules);
512472
513473 gtk_clist_freeze(GTK_CLIST(mainwindow->ctree));
514474
538498 } \
539499 }
540500
501
502 /*
503 * Processor info
504 */
505 node = tree_group_new(mainwindow, _("Processor"), PROCESSOR);
506 hi_insert_generic(cpu, PROCESSOR);
507 tree_insert_item(mainwindow, node, cpu->processor, generic_devices);
508
541509 CHECK_INSERT(pci, _("PCI Devices"), PCI, name);
542510 CHECK_INSERT(isa, _("ISA PnP Devices"), ISAPnP, card);
543511
552520 CHECK_INSERT(v4l, _("Video for Linux"), V4L, name);
553521 CHECK_INSERT(sd, _("Communication Ports"), SERIAL, name);
554522 CHECK_INSERT(pp, _("Parallel Ports"), PARPORT, name);
555
523
524 CHECK_INSERT(mod, _("Kernel Modules"), MODULE, description);
525
556526 gtk_clist_thaw(GTK_CLIST(mainwindow->ctree));
557527
558528 my_status_destroy(status);
559529 }
560530
561 #if 0
562531 static void
563532 usage(char *argv0)
564533 {
565 g_print("%s [--prefix <prefix>]\n", argv0);
534 g_print("%s [--help] [--prefix <prefix>]\n", argv0);
566535 exit(1);
567536 }
568 #endif
569537
570538 int
571539 main(int argc, char **argv)
572540 {
573541 MainWindow *mainwindow;
574 #if 0
575542 gint i;
576 #endif
577543
578544 #ifdef ENABLE_NLS
579545 intl_init();
580546 #endif
581547
582 g_print("HardInfo " VERSION "\n");
548 g_print("HardInfo " VERSION);
549 if (strstr(VERSION, "pre")) {
550 g_print(" *** PRE-RELEASE ***");
551 }
583552 g_print
584 ("Copyright (c) 2003 Leandro Pereira <leandro@linuxmag.com.br>\n\n");
553 ("\nCopyright (c) 2003 Leandro Pereira <leandro@linuxmag.com.br>\n\n");
585554 g_print(_
586555 ("This is free software; you can modify and/or distribute it\n"));
587556 g_print(_
590559
591560 gtk_init(&argc, &argv);
592561
593 #ifndef GTK2
594 gdk_rgb_init();
595 gtk_widget_set_default_colormap(gdk_rgb_get_cmap());
596 gtk_widget_set_default_visual(gdk_rgb_get_visual());
597 #endif
598
599 #if 0
562 hi_stock_init();
563
600564 for (i = 1; i < argc; i++) {
601565 if (!strncmp(argv[i], "--help", 6) ||
602566 !strncmp(argv[i], "-h", 2)) {
611575 g_print("prefix = %s\n", argv[i]);
612576 }
613577 }
614 #endif
615578
616579 mainwindow = main_window_create();
617580 main_window_refresh(NULL, mainwindow);
1212 #include <sys/stat.h>
1313
1414 #include "config.h"
15 #include "stock.h"
1516
1617 #ifdef ENABLE_NLS
1718 #define INTL_PREFIX PREFIX "lang/"
2223
2324 typedef struct _GenericDevice GenericDevice;
2425 typedef enum _DeviceType DeviceType;
25
2626 typedef struct _MainWindow MainWindow;
2727
2828 enum _DeviceType {
2929 NONE, PCI, ISAPnP, USB,
3030 IDE, SCSI, SERIAL, PARPORT,
31 V4L
31 V4L, PROCESSOR, MODULE
3232 };
3333
3434 struct _GenericDevice {
4040 GenericDevice *next;
4141 };
4242
43 #include "details.h"
44
4345 struct _MainWindow {
4446 GtkWidget *window;
4547
4648 GtkWidget *ctree;
47
48 GtkWidget *frame;
49 GtkWidget *framec;
5049
5150 GtkWidget *membar;
5251 GtkWidget *uptime;
5857 GtkWidget *trans_bytes;
5958 GtkWidget *trans_errors;
6059 GtkWidget *trans_packets;
60
61 GtkWidget *details_button;
62 DetailWindow *det_window;
6163 };
6264
6365 extern GenericDevice *generic_devices;
7072 #include "serial.h"
7173 #include "parport.h"
7274 #include "v4l.h"
73
75 #include "modules.h"
7476 #include "x11.h"
7577 #include "net.h"
7678
7779 #include "about.h"
80 #include "details.h"
7881
79 GtkCTreeNode *tree_group_new(MainWindow *mainwindow, const gchar *name,
80 DeviceType type);
81 void tree_insert_item(MainWindow *mainwindow, GtkCTreeNode *group, gchar *name,
82 gpointer data);
83 void hi_insert_generic(gpointer device, DeviceType type);
82 GtkCTreeNode *tree_group_new(MainWindow *mainwindow, const gchar *name,
83 DeviceType type);
84 void tree_insert_item(MainWindow *mainwindow, GtkCTreeNode *group, gchar *name,
85 gpointer data);
86 void hi_insert_generic(gpointer device, DeviceType type);
87 void hi_show_device_info_real(MainWindow *mainwindow,
88 GenericDevice *dev);
8489
8590 #endif
+48
-50
ide.c less more
0
01 /*
12 * Hardware Information, version 0.3
23 * Copyright (C) 2003 Leandro Pereira <leandro@linuxmag.com.br>
1415 {
1516 FILE *proc_ide;
1617 gchar *device, iface;
17 gint n=0, i=0;
18 gint n = 0, i = 0;
1819 struct stat st;
1920 IDEDevice *ide_dev, *ide;
2021
5859
5960 ide_dev->cache = atoi(buf);
6061 }
62 g_free(device);
63
64 device = g_strdup_printf("/proc/ide/hd%c/geometry", iface);
65 if (!stat(device, &st)) {
66 gchar *tmp;
67
68 proc_ide = fopen(device, "r");
69
70 fgets(buf, 64, proc_ide);
71 for (tmp = buf; *tmp; tmp++) {
72 if (*tmp >= '0' && *tmp <= '9') break;
73 }
74
75 ide_dev->phy_geometry = g_strdup(g_strstrip(tmp));
76
77 fgets(buf, 64, proc_ide);
78 for (tmp = buf; *tmp; tmp++) {
79 if (*tmp >= '0' && *tmp <= '9') break;
80 }
81 ide_dev->log_geometry = g_strdup(g_strstrip(tmp));
82
83 fclose(proc_ide);
84 }
85 g_free(device);
86
6187 n++;
62 }
63 g_free(device);
88 } else
89 g_free(device);
6490 }
6591
6692 return ide;
6894
6995 void hi_show_ide_info(MainWindow *mainwindow, IDEDevice *device)
7096 {
71 GtkWidget *hbox, *vbox, *label;
7297 static struct {
7398 char *type;
7499 char *label;
79104 };
80105 int i;
81106 gchar *buf;
82 #ifdef GTK2
83 GtkWidget *pixmap;
84 #endif
85107
86108 if(!device) return;
87109
89111 if (!strcmp(device->media, type2icon[i].type)) break;
90112 }
91113
92 #ifdef GTK2
93114 buf = g_strdup_printf("%s%s", IMG_PREFIX, type2icon[i].icon);
94 pixmap = gtk_image_new_from_file(buf);
95 gtk_widget_show(pixmap);
96
97 g_free(buf);
98 #endif
99 hbox = gtk_hbox_new(FALSE, 2);
100 gtk_container_set_border_width(GTK_CONTAINER(hbox), 4);
101 gtk_widget_show(hbox);
102
103 if(mainwindow->framec)
104 gtk_widget_destroy(mainwindow->framec);
105
106 gtk_container_add(GTK_CONTAINER(mainwindow->frame), hbox);
107 mainwindow->framec = hbox;
115 detail_window_set_icon(mainwindow->det_window, buf);
116 g_free(buf);
108117
109118 buf = g_strdup_printf(_("ATA/IDE %s Device"), type2icon[i].label);
110 gtk_frame_set_label(GTK_FRAME(mainwindow->frame), buf);
119 gtk_window_set_title(GTK_WINDOW(mainwindow->det_window->window), buf);
120 detail_window_set_dev_type(mainwindow->det_window, buf);
111121 g_free(buf);
122
123 detail_window_set_dev_name(mainwindow->det_window, device->model);
112124
113 #ifdef GTK2
114 gtk_box_pack_start(GTK_BOX(hbox), pixmap, FALSE, FALSE, 0);
115 #endif
125 if (device->cache) {
126 detail_window_append_info_int(mainwindow->det_window, _("Cache (kb)"),
127 device->cache, FALSE);
128 }
129
130 if (device->phy_geometry) {
131 detail_window_append_info(mainwindow->det_window, _("Physical geometry"),
132 device->phy_geometry);
133 }
134 if (device->log_geometry) {
135 detail_window_append_info(mainwindow->det_window, _("Logical geometry"),
136 device->log_geometry);
137 }
116138
117 vbox = gtk_vbox_new(FALSE, 2);
118 gtk_widget_show(vbox);
119 gtk_box_pack_start(GTK_BOX(hbox), vbox, TRUE, TRUE, 0);
120
121 #ifdef GTK2
122 buf = g_strdup_printf("<b>%s</b>", device->model);
123 label = gtk_label_new(buf);
124 gtk_label_set_use_markup(GTK_LABEL(label), TRUE);
125 gtk_label_set_selectable(GTK_LABEL(label), TRUE);
126
127 g_free(buf);
128 #else
129 label = gtk_label_new(device->model);
130 #endif
131 gtk_widget_show(label);
132 gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0);
133
134 if (device->cache) {
135 buf = g_strdup_printf(_("Cache: %d KB"), device->cache);
136 label = gtk_label_new(buf);
137 gtk_widget_show(label);
138 gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0);
139 g_free(buf);
140 }
141139 }
66 gchar *model;
77
88 gchar *media;
9 gchar *phy_geometry;
10 gchar *log_geometry;
911 gint cache;
1012
1113 IDEDevice *next;
4040 }
4141
4242 /*
43 * GNU's gettext is cool and all... but hey, this is smaller :)
43 * GNU's gettext is cool and all... but hey, this is smaller,
44 * but slower :P
4445 */
4546 const gchar *
4647 intl_translate(const gchar * string, const gchar * source) __THROW
4950 gchar buffer[256], *keyname, *lang = NULL, *langenv = NULL;
5051 const gchar *retval, *langvars[] =
5152 {"LANG", "LC_MESSAGES", "LC_ALL", NULL};
52 gboolean found;
53 gboolean found = FALSE;
5354 struct stat st;
5455 gint i = 0;
5556
6667 langenv_ok:
6768 lang = g_strconcat(INTL_PREFIX, langenv, ".lang", NULL);
6869 if (stat(lang, &st)) {
70 g_free(lang);
6971 lang = g_strconcat(INTL_PREFIX, "default.lang", NULL);
7072 if (stat(lang, &st)) {
7173 not_found:
2727 gboolean lock = FALSE;
2828 gfloat pnpversion, prodversion;
2929 gint card_id;
30 gpointer start, end;
30 gpointer start = NULL, end = NULL;
3131
3232 sscanf(buf, "Card %d", &card_id);
3333
4040 lock = TRUE;
4141 }
4242 }
43 buf+=2;
43 buf += 2;
4444
4545 sscanf(buf, "PnP version %f Product version %f", &pnpversion, &prodversion);
4646
6969
7070 void hi_show_isa_info(MainWindow *mainwindow, ISADevice *device)
7171 {
72 GtkWidget *hbox, *vbox, *label;
7372 gchar *buf;
74 #ifdef GTK2
75 GtkWidget *pixmap;
76
77 pixmap = gtk_image_new_from_file(IMG_PREFIX "pci.png");
78 gtk_widget_show(pixmap);
79 #endif
8073
8174 if(!device) return;
8275
83 hbox = gtk_hbox_new(FALSE, 2);
84 gtk_container_set_border_width(GTK_CONTAINER(hbox), 4);
85 gtk_widget_show(hbox);
76 gtk_window_set_title(GTK_WINDOW(mainwindow->det_window->window), _("ISA Plug and Play Device"));
8677
87 if(mainwindow->framec)
88 gtk_widget_destroy(mainwindow->framec);
78 detail_window_set_dev_name(mainwindow->det_window, device->card);
79 detail_window_set_icon(mainwindow->det_window, IMG_PREFIX "pci.png");
8980
90 gtk_container_add(GTK_CONTAINER(mainwindow->frame), hbox);
91 mainwindow->framec = hbox;
92
93 gtk_frame_set_label(GTK_FRAME(mainwindow->frame), _("ISA Plug and Play Device"));
81 detail_window_append_info_int(mainwindow->det_window, _("Card ID"),
82 device->card_id, FALSE);
83 buf = g_strdup_printf("%.2f", device->pnpversion);
84 detail_window_append_info(mainwindow->det_window, _("PnP version"),
85 buf);
86 g_free(buf);
9487
95 #ifdef GTK2
96 gtk_box_pack_start(GTK_BOX(hbox), pixmap, FALSE, FALSE, 0);
97 #endif
98
99 vbox = gtk_vbox_new(FALSE, 2);
100 gtk_widget_show(vbox);
101 gtk_box_pack_start(GTK_BOX(hbox), vbox, TRUE, TRUE, 0);
102
103 #ifdef GTK2
104 buf = g_strdup_printf("<b>%s</b>", device->card);
105 label = gtk_label_new(buf);
106 gtk_label_set_use_markup(GTK_LABEL(label), TRUE);
107 gtk_label_set_selectable(GTK_LABEL(label), TRUE);
108
109 g_free(buf);
110 #else
111 label = gtk_label_new(device->card);
112 #endif
113 gtk_widget_show(label);
114 gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0);
115
116 buf = g_strdup_printf(_("Card ID: %d"), device->card_id);
117 label = gtk_label_new(buf);
118 gtk_widget_show(label);
119 gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0);
120 g_free(buf);
121
122 buf = g_strdup_printf(_("PnP version: %.2f, Product version: %.2f"),
123 device->pnpversion, device->prodversion);
124 label = gtk_label_new(buf);
125 gtk_widget_show(label);
126 gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0);
88 buf = g_strdup_printf("%.2f", device->prodversion);
89 detail_window_append_info(mainwindow->det_window, _("Product version"),
90 buf);
12791 g_free(buf);
12892 }
12993
6565 Description: %s=Descrição: %s
6666 Command set: %s=Comandos: %s
6767 Class: %s=Classe: %s
68 Base I/O address: 0x%x=Endereço E/S básico: 0x%x
68 Base I/O address: 0x%x=Endereço E/S base: 0x%x
6969 Modes: %s=Modos: %s
7070 Uses DMA=Usa acesso direto à memória
7171
0 /*
1 * Hardware Information, version 0.3
2 * Copyright (C) 2003 Leandro Pereira <leandro@linuxmag.com.br>
3 *
4 * May be modified and/or distributed under the terms of GNU GPL version 2.
5 *
6 */
7
8 #include <gtk/gtk.h>
9
10 #include "hardinfo.h"
11 #include "modules.h"
12
13 void hi_show_module_info(MainWindow *mainwindow, ModInfo *device)
14 {
15 if(!device) return;
16
17 gtk_window_set_title(GTK_WINDOW(mainwindow->det_window->window), device->description);
18 detail_window_set_icon(mainwindow->det_window, IMG_PREFIX "module.png");
19 detail_window_set_dev_name(mainwindow->det_window, device->name);
20 detail_window_set_dev_type(mainwindow->det_window, device->description);
21
22 if (device->author && strlen(device->author)) {
23 detail_window_append_info(mainwindow->det_window, _("Author"),
24 device->author);
25 detail_window_append_separator(mainwindow->det_window);
26 }
27
28 if (device->license && strlen(device->license))
29 detail_window_append_info(mainwindow->det_window, _("License"),
30 device->license);
31
32 if (device->depends &&strlen(device->depends))
33 detail_window_append_info(mainwindow->det_window, _("Depends on"),
34 device->depends);
35
36 }
37
38 GtkWidget *module_get_widget(void)
39 {
40 #if 0
41 GtkWidget *vbox, *hbbox, *scroll, *clist, *btn;
42
43 vbox = gtk_vbox_new(FALSE, 5);
44 gtk_container_set_border_width(GTK_CONTAINER(vbox), 4);
45 gtk_widget_show(vbox);
46
47 hbbox = gtk_hbutton_box_new();
48 gtk_container_set_border_width(GTK_CONTAINER(hbbox), 4);
49 gtk_widget_show(hbbox);
50 gtk_box_pack_end(GTK_BOX(vbox), hbbox, FALSE, FALSE, 0);
51 gtk_button_box_set_spacing(GTK_BUTTON_BOX(hbbox), 6);
52 gtk_button_box_set_layout(GTK_BUTTON_BOX(hbbox), GTK_BUTTONBOX_END);
53
54 btn = gtk_button_new_from_stock(HI_DETAILS);
55 g_signal_connect(G_OBJECT(btn), "clicked",
56 (GCallback) detail_window_show, mainwindow);
57 gtk_widget_show(btn);
58 gtk_box_pack_end(GTK_BOX(hbbox), btn, FALSE, FALSE, 0);
59 mainwindow->details_button = btn;
60
61 scroll = gtk_scrolled_window_new(NULL, NULL);
62 gtk_box_pack_start(GTK_BOX(vbox), scroll, TRUE, TRUE, 0);
63 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scroll),
64 GTK_POLICY_AUTOMATIC,
65 GTK_POLICY_AUTOMATIC);
66
67 ctree = gtk_ctree_new(2, 0);
68 gtk_container_add(GTK_CONTAINER(scroll), ctree);
69 gtk_widget_set_usize(GTK_WIDGET(ctree), 400, 300);
70 gtk_ctree_set_expander_style(GTK_CTREE(ctree),
71 GTK_CTREE_EXPANDER_TRIANGLE);
72 gtk_ctree_set_line_style(GTK_CTREE(ctree), GTK_CTREE_LINES_NONE);
73 gtk_clist_set_column_width(GTK_CLIST(ctree), 0, 32);
74 gtk_clist_set_column_width(GTK_CLIST(ctree), 1, 32);
75 gtk_clist_set_row_height(GTK_CLIST(ctree), 18);
76 g_signal_connect(G_OBJECT(ctree), "tree-select-row",
77 (GCallback) hi_enable_details_button, mainwindow);
78 g_signal_connect(G_OBJECT(ctree), "tree-unselect-row",
79 (GCallback) hi_disable_details_button, mainwindow);
80
81
82 return vbox;
83 #endif
84
85 return NULL;
86 }
87
88 #define SET_VAR(vname,var) \
89 if (!strncmp(buffer, vname, strlen(vname))) { \
90 gchar *_b = buffer; \
91 while (*_b && *_b != ':') _b++; _b++; \
92 while (*_b && (*_b == ' ' || *_b == '\t')) _b++; \
93 modinfo->var = g_strdup(g_strstrip(_b)); \
94 }
95
96 ModInfo *hi_scan_modules(void)
97 {
98 FILE *lsmod;
99 gchar buffer[256];
100 ModInfo *modinfo = NULL, *mod = NULL;
101
102 lsmod = popen("/sbin/lsmod", "r");
103 if(!lsmod) return NULL;
104
105 fgets(buffer, 256, lsmod); /* Discards the first line */
106
107 while(fgets(buffer, 256, lsmod)){
108 gchar *start, *buf;
109 FILE *modi;
110
111 start = buf = buffer;
112
113 walk_until_inclusive(' ');
114 *buf = 0;
115
116 modinfo = g_new0(ModInfo, 1);
117
118 modinfo->name = g_strdup(start);
119
120 buf = g_strdup_printf("/sbin/modinfo %s", start);
121 modi = popen(buf, "r");
122 while (fgets(buffer, 256, modi)) {
123 SET_VAR("author", author);
124 SET_VAR("description", description);
125 SET_VAR("license", license);
126 SET_VAR("depends", depends);
127 }
128 pclose(modi);
129
130 modinfo->next = mod;
131 mod = modinfo;
132 }
133 pclose(lsmod);
134
135 return mod;
136 }
0 #ifndef __MODULES_H__
1 #define __MODULES_H__
2
3 #include <gtk/gtk.h>
4
5 typedef struct _ModInfo ModInfo;
6
7 struct _ModInfo {
8 gchar *name;
9 gchar *author;
10 gchar *description;
11 gchar *license;
12 gchar *depends;
13
14 ModInfo *next;
15 };
16
17 void hi_show_module_info(MainWindow *mainwindow, ModInfo *modinfo);
18 ModInfo *hi_scan_modules(void);
19
20 #endif
+34
-149
net.c less more
22 * Copyright (C) 2003 Leandro Pereira <leandro@linuxmag.com.br>
33 *
44 * May be modified and/or distributed under the terms of GNU GPL version 2.
5 *
6 * Tested only with 2.4.x kernels on ix86.
7 * USB support needs netdevfs.
85 */
96
107 #include <stdio.h>
8 #include "config.h"
119 #include "hardinfo.h"
1210 #include "net.h"
1311
12 gboolean net_update(gpointer data);
13
1414 GtkWidget *net_get_widget(MainWindow * mainwindow)
1515 {
16 GtkWidget *vbox1;
17 GtkWidget *scrolledwindow1;
18 GtkWidget *clist1;
19 GtkWidget *label2;
20 GtkWidget *table1;
21 GtkWidget *label4;
22 GtkWidget *label5;
23 GtkWidget *label7;
24 GtkWidget *label8;
25 GtkWidget *label3;
26 GtkWidget *label10;
27 GtkWidget *label11;
28 GtkWidget *label12;
29 GtkWidget *label14;
30 GtkWidget *label15;
31 GtkWidget *vseparator1;
32
33 vbox1 = gtk_vbox_new(FALSE, 5);
34 gtk_widget_show(vbox1);
35 gtk_container_set_border_width(GTK_CONTAINER(vbox1), 4);
36
37 scrolledwindow1 = gtk_scrolled_window_new(NULL, NULL);
38 gtk_widget_show(scrolledwindow1);
39 gtk_box_pack_start(GTK_BOX(vbox1), scrolledwindow1, TRUE, TRUE, 0);
40 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolledwindow1),
41 GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
42
43 clist1 = gtk_clist_new(2);
44 gtk_widget_show(clist1);
45 gtk_container_add(GTK_CONTAINER(scrolledwindow1), clist1);
46 gtk_clist_set_column_width(GTK_CLIST(clist1), 0, 30);
47 gtk_clist_set_column_width(GTK_CLIST(clist1), 1, 80);
48 gtk_clist_column_titles_show(GTK_CLIST(clist1));
49
50 label2 = gtk_label_new(_("Interface name"));
51 gtk_widget_show(label2);
52 gtk_clist_set_column_widget(GTK_CLIST(clist1), 1, label2);
53 gtk_label_set_justify(GTK_LABEL(label2), GTK_JUSTIFY_LEFT);
54 gtk_misc_set_alignment(GTK_MISC(label2), 0, 0.5);
55
56 table1 = gtk_table_new(3, 5, FALSE);
57 gtk_widget_show(table1);
58 gtk_box_pack_start(GTK_BOX(vbox1), table1, FALSE, FALSE, 0);
59 gtk_container_set_border_width(GTK_CONTAINER(table1), 4);
60 gtk_table_set_row_spacings(GTK_TABLE(table1), 4);
61 gtk_table_set_col_spacings(GTK_TABLE(table1), 4);
62
63 label4 = gtk_label_new(_("Bytes:"));
64 gtk_widget_show(label4);
65 gtk_table_attach(GTK_TABLE(table1), label4, 0, 1, 1, 2,
66 (GtkAttachOptions) (GTK_FILL),
67 (GtkAttachOptions) (0), 0, 0);
68 gtk_label_set_justify(GTK_LABEL(label4), GTK_JUSTIFY_LEFT);
69 gtk_misc_set_alignment(GTK_MISC(label4), 0, 0.5);
70
71 label5 = gtk_label_new(_("Speed:"));
72 gtk_widget_show(label5);
73 gtk_table_attach(GTK_TABLE(table1), label5, 0, 1, 2, 3,
74 (GtkAttachOptions) (GTK_FILL),
75 (GtkAttachOptions) (0), 0, 0);
76 gtk_label_set_justify(GTK_LABEL(label5), GTK_JUSTIFY_LEFT);
77 gtk_misc_set_alignment(GTK_MISC(label5), 0, 0.5);
78
79 label7 = gtk_label_new(_("Bytes:"));
80 gtk_widget_show(label7);
81 gtk_table_attach(GTK_TABLE(table1), label7, 3, 4, 1, 2,
82 (GtkAttachOptions) (GTK_FILL),
83 (GtkAttachOptions) (0), 0, 0);
84 gtk_label_set_justify(GTK_LABEL(label7), GTK_JUSTIFY_LEFT);
85 gtk_misc_set_alignment(GTK_MISC(label7), 0, 0.5);
86
87 label8 = gtk_label_new(_("Speed"));
88 gtk_widget_show(label8);
89 gtk_table_attach(GTK_TABLE(table1), label8, 3, 4, 2, 3,
90 (GtkAttachOptions) (GTK_FILL),
91 (GtkAttachOptions) (0), 0, 0);
92 gtk_label_set_justify(GTK_LABEL(label8), GTK_JUSTIFY_LEFT);
93 gtk_misc_set_alignment(GTK_MISC(label8), 0, 0.5);
94
95 label3 = gtk_label_new(_("<big><b>Receive</b></big>"));
96 gtk_widget_show(label3);
97 gtk_table_attach(GTK_TABLE(table1), label3, 0, 2, 0, 1,
98 (GtkAttachOptions) (GTK_FILL),
99 (GtkAttachOptions) (0), 0, 0);
100 gtk_label_set_use_markup(GTK_LABEL(label3), TRUE);
101 gtk_label_set_justify(GTK_LABEL(label3), GTK_JUSTIFY_LEFT);
102 gtk_misc_set_alignment(GTK_MISC(label3), 0, 0.5);
103
104 label10 = gtk_label_new(_("<big><b>Transmit</b></big>"));
105 gtk_widget_show(label10);
106 gtk_table_attach(GTK_TABLE(table1), label10, 3, 5, 0, 1,
107 (GtkAttachOptions) (GTK_FILL),
108 (GtkAttachOptions) (0), 0, 0);
109 gtk_label_set_use_markup(GTK_LABEL(label10), TRUE);
110 gtk_label_set_justify(GTK_LABEL(label10), GTK_JUSTIFY_LEFT);
111 gtk_misc_set_alignment(GTK_MISC(label10), 0, 0.5);
112
113 label11 = gtk_label_new(_("0B"));
114 gtk_widget_show(label11);
115 gtk_table_attach(GTK_TABLE(table1), label11, 1, 2, 1, 2,
116 (GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
117 (GtkAttachOptions) (0), 0, 0);
118 gtk_label_set_justify(GTK_LABEL(label11), GTK_JUSTIFY_LEFT);
119 gtk_misc_set_alignment(GTK_MISC(label11), 0, 0.5);
120
121 label12 = gtk_label_new(_("0B/s"));
122 gtk_widget_show(label12);
123 gtk_table_attach(GTK_TABLE(table1), label12, 1, 2, 2, 3,
124 (GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
125 (GtkAttachOptions) (0), 0, 0);
126 gtk_label_set_justify(GTK_LABEL(label12), GTK_JUSTIFY_LEFT);
127 gtk_misc_set_alignment(GTK_MISC(label12), 0, 0.5);
128
129 label14 = gtk_label_new(_("0B"));
130 gtk_widget_show(label14);
131 gtk_table_attach(GTK_TABLE(table1), label14, 4, 5, 1, 2,
132 (GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
133 (GtkAttachOptions) (0), 0, 0);
134 gtk_label_set_justify(GTK_LABEL(label14), GTK_JUSTIFY_LEFT);
135 gtk_misc_set_alignment(GTK_MISC(label14), 0, 0.5);
136
137 label15 = gtk_label_new(_("0B/s"));
138 gtk_widget_show(label15);
139 gtk_table_attach(GTK_TABLE(table1), label15, 4, 5, 2, 3,
140 (GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
141 (GtkAttachOptions) (0), 0, 0);
142 gtk_label_set_justify(GTK_LABEL(label15), GTK_JUSTIFY_LEFT);
143 gtk_misc_set_alignment(GTK_MISC(label15), 0, 0.5);
144
145 vseparator1 = gtk_vseparator_new();
146 gtk_widget_show(vseparator1);
147 gtk_table_attach(GTK_TABLE(table1), vseparator1, 2, 3, 0, 3,
148 (GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
149 (GtkAttachOptions) (GTK_EXPAND | GTK_FILL), 0, 0);
150
151
152 return vbox1;
16 return gtk_label_new("Not implemented yet.");
15317 }
15418
15519 gboolean net_update(gpointer data)
15620 {
15721 MainWindow *mainwindow = (MainWindow *) data;
15822 NetDevice *net;
159
23 static NetDevice *netold = NULL;
24
16025 if (!mainwindow)
16126 return FALSE;
16227
16328 net = hi_scan_net();
29
30 if (!net)
31 return FALSE;
32
33 if (!netold) {
34 netold = net;
35 } else {
36 NetDevice *nd1, *nd2;
37
38 for (nd1 = netold, nd2 = net; nd1 && nd2;
39 nd1 = nd1->next, nd2 = nd2->next) {
40
41 g_print ("iface %s: %ld bytes/s up, %ld bytes/s down\n",
42 nd1->iface,
43 nd2->trans_bytes - nd1->trans_bytes,
44 nd2->recv_bytes - nd1->recv_bytes);
45 }
46
47 netold = net;
48 }
16449
50 g_print("\n\n");
51
16552 return TRUE;
16653 }
16754
18168 while (fgets(buffer, 256, proc_net)) {
18269 if (strchr(buffer, ':')) {
18370 gint trash;
184 gchar ifacename[4];
71 gchar ifacename[16];
18572 gchar *buf = buffer;
18673 gint i;
18774
19178
19279 buf = g_strstrip(buf);
19380
194 memset(ifacename, 0, 4);
81 memset(ifacename, 0, 16);
19582
196 for (i = 0; buffer[i] != ':' && i < 4; i++) {
83 for (i = 0; buffer[i] != ':' && i < 16; i++) {
19784 ifacename[i] = buffer[i];
19885 }
19986
20087 walk_until_inclusive(':');
20188
20289 /* iface: bytes packets errs drop fifo frame compressed multicast */
203 sscanf(buf, "%d %d %d %d %d %d %d %d %d %d %d",
90 sscanf(buf, "%ld %ld %ld %d %d %d %d %d %ld %ld %ld",
20491 &net_dev->recv_bytes, &net_dev->recv_packets,
20592 &net_dev->recv_errors, &trash, &trash, &trash, &trash,
20693 &trash, &net_dev->trans_bytes, &net_dev->trans_packets,
20794 &net_dev->trans_errors);
20895
209 g_print("%s -> %d %d %d | %d %d %d\n",
210 ifacename, net_dev->recv_bytes, net_dev->recv_errors,
211 net_dev->recv_packets, net_dev->trans_bytes,
212 net_dev->trans_errors, net_dev->trans_packets);
96 g_print("%ld\n", net_dev->recv_bytes);
21397
98 net_dev->iface = g_strdup(ifacename);
21499 }
215100 }
216101 fclose(proc_net);
77 struct _NetDevice {
88 gchar *iface;
99
10 guint recv_bytes;
11 guint recv_errors;
12 guint recv_packets;
10 gulong recv_bytes;
11 gulong recv_errors;
12 gulong recv_packets;
1313
14 guint trans_bytes;
15 guint trans_errors;
16 guint trans_packets;
14 gulong trans_bytes;
15 gulong trans_errors;
16 gulong trans_packets;
1717
1818 NetDevice *next;
1919 };
123123
124124 void hi_show_parport_info(MainWindow *mainwindow, ParportDevice *device)
125125 {
126 GtkWidget *hbox, *vbox, *label;
127126 gchar *buf;
128127 static struct {
129128 gchar *type, *label, *icon;
130129 } type2icon[] = {
131 {"PRINTER", "Printer", "lpr.png"},
132 {"MEDIA", "Multimedia", "media.png"},
130 {"PRINTER", "Printer", "lpr.png" },
131 {"MEDIA", "Multimedia", "media.png" },
133132 {NULL, "Legacy Device", "gen_connector.png"},
134133 };
135134 gint i;
136 #ifdef GTK2
137 GtkWidget *pixmap;
138 #endif
139135
140136 if(!device) return;
141137
147143 i = sizeof(type2icon) / sizeof(type2icon[0]) - 1;
148144
149145
150 #ifdef GTK2
151146 buf = g_strdup_printf("%s%s", IMG_PREFIX, type2icon[i].icon);
152 pixmap = gtk_image_new_from_file(buf);
153 gtk_widget_show(pixmap);
147 detail_window_set_icon(mainwindow->det_window, buf);
148 g_free(buf);
149
150 gtk_window_set_title(GTK_WINDOW(mainwindow->det_window->window), _("Parallel Port"));
154151
155 g_free(buf);
156 #endif
152 detail_window_set_dev_name(mainwindow->det_window, device->name);
153 detail_window_set_dev_type(mainwindow->det_window, type2icon[i].label);
157154
158 hbox = gtk_hbox_new(FALSE, 2);
159 gtk_container_set_border_width(GTK_CONTAINER(hbox), 4);
160 gtk_widget_show(hbox);
155 if (device->description)
156 detail_window_append_info(mainwindow->det_window, _("Description"),
157 device->description);
161158
162 if(mainwindow->framec)
163 gtk_widget_destroy(mainwindow->framec);
159 if (device->cmdset)
160 detail_window_append_info(mainwindow->det_window, _("Command set"),
161 device->cmdset);
164162
165 gtk_container_add(GTK_CONTAINER(mainwindow->frame), hbox);
166 mainwindow->framec = hbox;
167
168 gtk_frame_set_label(GTK_FRAME(mainwindow->frame), _("Parallel Port"));
169
170 #ifdef GTK2
171 gtk_box_pack_start(GTK_BOX(hbox), pixmap, FALSE, FALSE, 0);
172 #endif
173
174 vbox = gtk_vbox_new(FALSE, 2);
175 gtk_widget_show(vbox);
176 gtk_box_pack_start(GTK_BOX(hbox), vbox, TRUE, TRUE, 0);
177
178 #ifdef GTK2
179 buf = g_strdup_printf("<b>%s</b>", device->name);
180 label = gtk_label_new(buf);
181 gtk_label_set_use_markup(GTK_LABEL(label), TRUE);
182 gtk_label_set_selectable(GTK_LABEL(label), TRUE);
183
184 g_free(buf);
185 #else
186 label = gtk_label_new(device->name);
187 #endif
188 gtk_widget_show(label);
189 gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0);
190
191 if (device->description) {
192 buf = g_strdup_printf(_("Description: %s"), device->description);
193 label = gtk_label_new(buf);
194 gtk_widget_show(label);
195 gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0);
196
197 g_free(buf);
198 }
199
200 if (device->cmdset) {
201 buf = g_strdup_printf(_("Command set: %s"), device->cmdset);
202 label = gtk_label_new(buf);
203 gtk_widget_show(label);
204 gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0);
205
206 g_free(buf);
207 }
208
209 buf = g_strdup_printf(_("Class: %s"), type2icon[i].label);
210 label = gtk_label_new(buf);
211 gtk_widget_show(label);
212 gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0);
213 g_free(buf);
214
215 buf = g_strdup_printf(_("Base I/O address: 0x%x"), device->port);
216 label = gtk_label_new(buf);
217 gtk_widget_show(label);
218 gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0);
219 g_free(buf);
220
221 buf = g_strdup_printf(_("Modes: %s"), device->modes);
222 label = gtk_label_new(buf);
223 gtk_widget_show(label);
224 gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0);
225 g_free(buf);
226
227 if (device->dma) {
228 label = gtk_label_new(_("Uses DMA"));
229 gtk_widget_show(label);
230 gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0);
231 }
232
163 detail_window_append_info_int(mainwindow->det_window, _("Base I/O address"),
164 device->port, TRUE);
165 detail_window_append_info(mainwindow->det_window, _("Modes"),
166 device->modes);
167 detail_window_append_info(mainwindow->det_window, _("Uses DMA"),
168 device->dma ? _("Yes") : _("No"));
233169 }
+52
-101
pci.c less more
1010
1111 void hi_show_pci_info(MainWindow *mainwindow, PCIDevice *device)
1212 {
13 GtkWidget *hbox, *vbox, *label;
1413 gchar *buf;
15 #ifdef GTK2
16 GtkWidget *pixmap;
17
18 pixmap = gtk_image_new_from_file(IMG_PREFIX "pci.png");
19 gtk_widget_show(pixmap);
20 #endif
2114
2215 if(!device) return;
2316
24 hbox = gtk_hbox_new(FALSE, 2);
25 gtk_container_set_border_width(GTK_CONTAINER(hbox), 4);
26 gtk_widget_show(hbox);
27
28 if(mainwindow->framec)
29 gtk_widget_destroy(mainwindow->framec);
30
31 gtk_container_add(GTK_CONTAINER(mainwindow->frame), hbox);
32 mainwindow->framec = hbox;
33
34 gtk_frame_set_label(GTK_FRAME(mainwindow->frame), device->category);
35
36 #ifdef GTK2
37 gtk_box_pack_start(GTK_BOX(hbox), pixmap, FALSE, FALSE, 0);
38 #endif
39
40 vbox = gtk_vbox_new(FALSE, 2);
41 gtk_widget_show(vbox);
42 gtk_box_pack_start(GTK_BOX(hbox), vbox, TRUE, TRUE, 0);
43
44 #ifdef GTK2
45 buf = g_strdup_printf("<b>%s</b>", device->name);
46 label = gtk_label_new(buf);
47 gtk_label_set_use_markup(GTK_LABEL(label), TRUE);
48 gtk_label_set_selectable(GTK_LABEL(label), TRUE);
49
50 g_free(buf);
51 #else
52 label = gtk_label_new(device->name);
53 #endif
54 gtk_widget_show(label);
55 gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0);
56
57 if(device->irq) {
58 buf = g_strdup_printf("IRQ: %d", device->irq);
59
60 label = gtk_label_new(buf);
61 gtk_widget_show(label);
62 gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0);
63
17 gtk_window_set_title(GTK_WINDOW(mainwindow->det_window->window), device->category);
18 detail_window_set_icon(mainwindow->det_window, IMG_PREFIX "pci.png");
19 detail_window_set_dev_name(mainwindow->det_window, device->name);
20 detail_window_set_dev_type(mainwindow->det_window, device->category);
21
22 if (device->irq)
23 detail_window_append_info_int(mainwindow->det_window, "IRQ",
24 device->irq, FALSE);
25
26 if(device->io_addr) {
27 buf = g_strdup_printf(_("0x%x to 0x%x"), device->io_addr,
28 device->io_addr_end);
29
30 detail_window_append_info(mainwindow->det_window,
31 _("I/O Address"), buf);
6432 g_free(buf);
6533 }
6634
67 if(device->io_addr) {
68 buf = g_strdup_printf(_("I/O address: 0x%x to 0x%x"), device->io_addr,
69 device->io_addr_end);
70
71 label = gtk_label_new(buf);
72 gtk_widget_show(label);
73 gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0);
74
75 g_free(buf);
76 }
77
7835 if(device->memory) {
79 buf = g_strdup_printf(_("Memory: %ld %s"),
36 buf = g_strdup_printf(_("%d%s"),
8037 (device->memory <= 1024) ? device->memory :
8138 device->memory / 1000,
8239 (device->memory <= 1024) ? "bytes" : "KB");
8340
84 label = gtk_label_new(buf);
85 gtk_widget_show(label);
86 gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0);
41 detail_window_append_info(mainwindow->det_window,
42 _("Memory"), buf);
8743
8844 g_free(buf);
8945 }
9046
9147 if(device->freq) {
92 buf = g_strdup_printf(_("Frequency: %dMHz"), device->freq);
93
94 label = gtk_label_new(buf);
95 gtk_widget_show(label);
96 gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0);
48 buf = g_strdup_printf(_("%dMHz"), device->freq);
49
50 detail_window_append_info(mainwindow->det_window,
51 _("Frequency"), buf);
9752
9853 g_free(buf);
9954 }
10055
101 if(device->latency) {
102 buf = g_strdup_printf(_("Latency: %d"), device->latency);
103
104 label = gtk_label_new(buf);
105 gtk_widget_show(label);
106 gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0);
107
108 g_free(buf);
109 }
110
111 if(device->bus_master) {
112 label = gtk_label_new(_("Bus master"));
113 gtk_widget_show(label);
114 gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0);
115 }
116
117 buf = g_strdup_printf(_("Bus: %d, Device: %d, Function: %d"),
118 device->bus, device->device, device->function);
119
120 label = gtk_label_new(buf);
121 gtk_widget_show(label);
122 gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0);
123 g_free(buf);
56 if (device->latency)
57 detail_window_append_info_int(mainwindow->det_window,
58 _("Latency"), device->latency,
59 FALSE);
60
61 detail_window_append_info(mainwindow->det_window, _("Bus master"),
62 (gchar*)((device->bus_master) ? _("Yes") : _("No")));
63
64 detail_window_append_separator(mainwindow->det_window);
65
66 detail_window_append_info_int(mainwindow->det_window, _("Domain"),
67 device->domain, FALSE);
68 detail_window_append_info_int(mainwindow->det_window, _("Bus"),
69 device->bus, FALSE);
70 detail_window_append_info_int(mainwindow->det_window, _("Device"),
71 device->device, FALSE);
72 detail_window_append_info_int(mainwindow->det_window, _("Function"),
73 device->function, FALSE);
12474 }
12575
12676 #ifdef USE_LSPCI
12979 FILE *lspci;
13080 gchar buffer[256], *buf;
13181 gint n=0;
132 PCIDevice *pci_dev, *pci;
82 PCIDevice *pci_dev = NULL, *pci;
13383
13484 pci = NULL;
13585
13888
13989 while(fgets(buffer, 256, lspci)){
14090 buf = g_strstrip(buffer);
91
14192 if(!strncmp(buf, "Flags", 5)){
14293 gint irq=0, freq=0, latency=0, i;
14394 gchar **list;
14495
14596 buf+=7;
146
97
14798 pci_dev->bus_master = FALSE;
14899
149100 list = g_strsplit(buf, ", ", 10);
154105 sscanf(list[i], "IRQ %d", &irq);
155106 else if(strstr(list[i], "Mhz"))
156107 sscanf(list[i], "%dMhz", &freq);
157 else
158 if(!strncmp(list[i], "bus master", 10))
108 else if(!strncmp(list[i], "bus master", 10))
159109 pci_dev->bus_master = TRUE;
160110 else if(!strncmp(list[i], "latency", 7))
161111 sscanf(list[i], "latency %d", &latency);
162112 }
163113 g_strfreev(list);
164114
165 if (irq) pci_dev->irq = irq;
166 if (freq) pci_dev->freq = freq;
115 if (irq) pci_dev->irq = irq;
116 if (freq) pci_dev->freq = freq;
167117 if (latency) pci_dev->latency = latency;
168 }
169
170 else if(!strncmp(buf, "Memory at", 9) &&
118 } else if(!strncmp(buf, "Memory at", 9) &&
171119 strstr(buf, "[size=")) {
172120 gulong mem;
173121 gchar unit;
180128 (unit == 'M') ? 1024 * 1000 :
181129 (unit == 'G') ? 1024 * 1000 * 1000 : 1;
182130
183 pci_dev->memory += mem;
184 } else if(!strncmp(buf, "I/O", 3)){
131 pci_dev->memory += mem;
132
133 } else if(!strncmp(buf, "I/O", 3)){
185134 guint io_addr, io_size;
186135
187136 sscanf(buf, "I/O ports at %x [size=%d]", &io_addr, &io_size);
188137
189138 pci_dev->io_addr = io_addr;
190139 pci_dev->io_addr_end = io_addr+io_size;
140
191141 } else if((buf[0] >= '0' && buf[0] <= '9') && buf[4] == ':'){
192142 gint bus, device, function, domain;
193143 gpointer start, end;
199149
200150 sscanf(buf, "%x:%x:%x.%d", &domain, &bus, &device, &function);
201151
152 pci_dev->domain = domain;
202153 pci_dev->bus = bus;
203154 pci_dev->device = device;
204155 pci_dev->function = function;
1212
1313 gulong memory;
1414
15 gint domain;
1516 gint bus;
1617 gint device;
1718 gint function;
Binary diff not shown
pixmaps/distro/.xvpics/mdk.png less more
Binary diff not shown
Binary diff not shown
Binary diff not shown
Binary diff not shown
0 /* XPM */
1 static char * logo_xpm[] = {
2 "32 32 314 2",
3 " c None",
4 ". c #F3F3F3",
5 "+ c #F2F2F2",
6 "@ c #F1F1F1",
7 "# c #F0F0F0",
8 "$ c #EFEFEF",
9 "% c #EEEEEE",
10 "& c #ECECEC",
11 "* c #EAEAEA",
12 "= c #E8E8E8",
13 "- c #E7E7E7",
14 "; c #E3E3E3",
15 "> c #AEAEAE",
16 ", c #F4F4F4",
17 "' c #DCDCDC",
18 ") c #D8D8D8",
19 "! c #D6D6D6",
20 "~ c #D5D5D5",
21 "{ c #D3D3D3",
22 "] c #D1D1D1",
23 "^ c #D0D0D0",
24 "/ c #CFCFCF",
25 "( c #CECECE",
26 "_ c #CCCCCC",
27 ": c #CBCBCB",
28 "< c #CDCDCD",
29 "[ c #626262",
30 "} c #898989",
31 "| c #383838",
32 "1 c #373737",
33 "2 c #363636",
34 "3 c #353535",
35 "4 c #343434",
36 "5 c #424242",
37 "6 c #E2E2E2",
38 "7 c #D9D9D9",
39 "8 c #3F3F3F",
40 "9 c #6E6E6E",
41 "0 c #888682",
42 "a c #E2E2DF",
43 "b c #EDEAE6",
44 "c c #DFDED9",
45 "d c #C9CAC7",
46 "e c #BFC0BD",
47 "f c #C4C1BA",
48 "g c #C1BCB2",
49 "h c #B8B4AA",
50 "i c #ABA69C",
51 "j c #919089",
52 "k c #7D7C76",
53 "l c #282724",
54 "m c #E5E5E5",
55 "n c #D7D7D7",
56 "o c #9A9793",
57 "p c #EEF0F1",
58 "q c #FFFFFF",
59 "r c #EDEDEC",
60 "s c #D8DADA",
61 "t c #D0D2D2",
62 "u c #CAC7C1",
63 "v c #C1BDB3",
64 "w c #AAA49B",
65 "x c #797E7F",
66 "y c #89846E",
67 "z c #2C2B27",
68 "A c #E4E4E4",
69 "B c #6D6D6D",
70 "C c #96948F",
71 "D c #F7F6F5",
72 "E c #FAF9F8",
73 "F c #EEECEA",
74 "G c #EBE9E6",
75 "H c #E7E5E1",
76 "I c #D0CDC5",
77 "J c #C0BCB2",
78 "K c #B8B3A9",
79 "L c #A8A399",
80 "M c #9D9685",
81 "N c #8C7D76",
82 "O c #2B2926",
83 "P c #EBEBEB",
84 "Q c #6C6C6C",
85 "R c #908E89",
86 "S c #F3F2F0",
87 "T c #F4F2F1",
88 "U c #ECEAE7",
89 "V c #E9E7E4",
90 "W c #E6E3DF",
91 "X c #CECBC4",
92 "Y c #BEBAB0",
93 "Z c #B7B2A8",
94 "` c #A6A197",
95 " . c #937162",
96 ".. c #8B6863",
97 "+. c #2A2826",
98 "@. c #D2D2D2",
99 "#. c #464C52",
100 "$. c #49525D",
101 "%. c #3F4954",
102 "&. c #3E4852",
103 "*. c #4D545B",
104 "=. c #8E8F90",
105 "-. c #C8C8C6",
106 ";. c #E5E3DF",
107 ">. c #E5E2DF",
108 ",. c #E2DFDB",
109 "'. c #CAC7BE",
110 "). c #BAB5AC",
111 "!. c #B3ADA4",
112 "~. c #A39E94",
113 "{. c #928E84",
114 "]. c #928E86",
115 "^. c #2A2825",
116 "/. c #E1E1E1",
117 "(. c #6F7A86",
118 "_. c #8397AB",
119 ":. c #7D96B2",
120 "<. c #7B95B1",
121 "[. c #758CA7",
122 "}. c #637282",
123 "|. c #5B5F63",
124 "1. c #BAB9B6",
125 "2. c #D8D6D3",
126 "3. c #DAD8D3",
127 "4. c #C3BFB7",
128 "5. c #B3AEA4",
129 "6. c #ACA79D",
130 "7. c #9D988E",
131 "8. c #8F8A80",
132 "9. c #908B84",
133 "0. c #292724",
134 "a. c #E0E0E0",
135 "b. c #41464D",
136 "c. c #7D8A98",
137 "d. c #8199B4",
138 "e. c #7590AE",
139 "f. c #849CB7",
140 "g. c #A3B5C9",
141 "h. c #94A9C0",
142 "i. c #7892AF",
143 "j. c #778BA1",
144 "k. c #585D60",
145 "l. c #A6A4A1",
146 "m. c #C7C4C0",
147 "n. c #B3AFA7",
148 "o. c #A5A097",
149 "p. c #9E998F",
150 "q. c #928D83",
151 "r. c #858077",
152 "s. c #8A867F",
153 "t. c #272623",
154 "u. c #DFDFDF",
155 "v. c #606A75",
156 "w. c #8097B1",
157 "x. c #D1DAE4",
158 "y. c #627182",
159 "z. c #676868",
160 "A. c #B4B2AF",
161 "B. c #AFABA5",
162 "C. c #A6A29A",
163 "D. c #A09C94",
164 "E. c #97938B",
165 "F. c #908C85",
166 "G. c #8D8A83",
167 "H. c #272522",
168 "I. c #DEDEDE",
169 "J. c #C9C9C9",
170 "K. c #222528",
171 "L. c #7C8EA2",
172 "M. c #7892B0",
173 "N. c #B2C1D2",
174 "O. c #6B84A0",
175 "P. c #394048",
176 "Q. c #54514C",
177 "R. c #5D5A55",
178 "S. c #5C5A54",
179 "T. c #5A5852",
180 "U. c #54514B",
181 "V. c #4F4C47",
182 "W. c #474540",
183 "X. c #151413",
184 "Y. c #C6C6C6",
185 "Z. c #33373C",
186 "`. c #889FB8",
187 " + c #708AA7",
188 ".+ c #3D4752",
189 "++ c #838383",
190 "@+ c #989898",
191 "#+ c #9C9C9C",
192 "$+ c #9B9B9B",
193 "%+ c #C4C4C4",
194 "&+ c #393F44",
195 "*+ c #89A0BA",
196 "=+ c #E0E6ED",
197 "-+ c #718BA8",
198 ";+ c #35404B",
199 ">+ c #B0B0B0",
200 ",+ c #D4D4D4",
201 "'+ c #D7D4C3",
202 ")+ c #E2DAA9",
203 "!+ c #B5B5B5",
204 "~+ c #BCBCBC",
205 "{+ c #3E3E3E",
206 "]+ c #5F5F5F",
207 "^+ c #3B3F45",
208 "/+ c #6F89A6",
209 "(+ c #999999",
210 "_+ c #CACACA",
211 ":+ c #C0BDAC",
212 "<+ c #A09766",
213 "[+ c #A5A5A5",
214 "}+ c #7D7D7D",
215 "|+ c #323232",
216 "1+ c #9E9E9E",
217 "2+ c #8394A6",
218 "3+ c #7A94B1",
219 "4+ c #5B7188",
220 "5+ c #262B31",
221 "6+ c #3A3A3A",
222 "7+ c #404040",
223 "8+ c #454545",
224 "9+ c #434343",
225 "0+ c #2E2E2E",
226 "a+ c #1E1E1E",
227 "b+ c #797979",
228 "c+ c #565F69",
229 "d+ c #8198B1",
230 "e+ c #738DAB",
231 "f+ c #3D4B5A",
232 "g+ c #16181A",
233 "h+ c #1D1D1D",
234 "i+ c #222222",
235 "j+ c #212121",
236 "k+ c #262626",
237 "l+ c #242424",
238 "m+ c #252525",
239 "n+ c #202020",
240 "o+ c #090909",
241 "p+ c #6B7580",
242 "q+ c #748FAD",
243 "r+ c #6A829E",
244 "s+ c #465668",
245 "t+ c #0B0D10",
246 "u+ c #000000",
247 "v+ c #535353",
248 "w+ c #515A65",
249 "x+ c #76889C",
250 "y+ c #7D95B0",
251 "z+ c #748EAA",
252 "A+ c #6E87A4",
253 "B+ c #5F758D",
254 "C+ c #3E4A58",
255 "D+ c #575A5F",
256 "E+ c #808080",
257 "F+ c #969696",
258 "G+ c #A2A2A2",
259 "H+ c #A3A3A3",
260 "I+ c #F5F5F5",
261 "J+ c #5B5B5B",
262 "K+ c #7F7F80",
263 "L+ c #7E8083",
264 "M+ c #494D52",
265 "N+ c #464B51",
266 "O+ c #484B4F",
267 "P+ c #7A7A7A",
268 "Q+ c #A1A1A1",
269 "R+ c #BBBBBB",
270 "S+ c #C5C5C5",
271 "T+ c #A9A9A9",
272 "U+ c #C0C0C0",
273 "V+ c #B6B6B6",
274 "W+ c #606060",
275 "X+ c #727272",
276 "Y+ c #7E7E7E",
277 "Z+ c #ABABAB",
278 "`+ c #AFAFAF",
279 " @ c #B4B4B4",
280 ".@ c #C3C3C3",
281 "+@ c #B8B8B8",
282 "@@ c #A0A0A0",
283 "#@ c #929292",
284 "$@ c #525252",
285 "%@ c #515151",
286 "&@ c #DADADA",
287 "*@ c #BDBDBD",
288 "=@ c #555555",
289 "-@ c #111111",
290 ";@ c #B7B7B7",
291 ">@ c #BFBFBF",
292 ",@ c #DDDDDD",
293 "'@ c #9D9D9D",
294 ")@ c #2B2B2B",
295 "!@ c #9A9A9A",
296 "~@ c #979797",
297 "{@ c #939393",
298 "]@ c #919191",
299 "^@ c #959595",
300 "/@ c #848484",
301 "(@ c #7C7C7C",
302 "_@ c #757575",
303 ":@ c #8E8E8E",
304 "<@ c #646464",
305 "[@ c #6A6A6A",
306 "}@ c #696969",
307 "|@ c #686868",
308 "1@ c #676767",
309 "2@ c #666666",
310 "3@ c #656565",
311 "4@ c #636363",
312 "5@ c #5E5E5E",
313 "6@ c #5D5D5D",
314 "7@ c #5A5A5A",
315 "8@ c #585858",
316 "9@ c #575757",
317 " ",
318 " ",
319 " ",
320 " . . . + @ @ # $ % % & & * * = - ; > ",
321 " , @ ' ) ! ~ { { ] ^ / ( _ : < ! ' : [ ",
322 " , @ } | 1 1 2 2 3 3 3 3 3 4 1 5 6 7 8 ",
323 " . $ 9 0 a b c d e f g h i j k l m n | ",
324 " . $ 9 o p q r s t u v h w x y z A ! | ",
325 " . % B C D E F G H I J K L M N O ; { | ",
326 " @ P Q R S T U V W X Y Z ` ...+.6 @.| ",
327 " #.$.%.&.*.=.-.;.>.,.'.).!.~.{.].^././ | ",
328 " (._.:.:.<.[.}.|.1.2.3.4.5.6.7.8.9.0.a.< | ",
329 " b.c.d.e.f.g.h.e.i.j.k.l.m.n.o.p.q.r.s.t.u.: | ",
330 " v.w.e.e.g.q x.e.e.i.y.z.A.B.C.D.E.F.G.H.I.J.| ",
331 " K.L.M.e.e.h.x.N.e.e.e.O.P.Q.R.S.T.U.V.W.X.' Y.| ",
332 " Z.`.e.e.e.x.x.N.e.e.e. +.+++@+#+#+$+$+$+@+' %+| ",
333 " &+*+e.e.e.=+q x.e.e.e.-+;+>+: ,+@.( _ '+)+!+~+{+]+ ",
334 " ^+`.e.e.e.g.q x.e.e.e./+$.(+~+@.^ < _+:+<+[+}+|+3 1+ ",
335 " 2+3+e.e.g.q x.e.e.e.4+5+6+7+8+8+5 8+9+9+0+a+ 1+b+ ",
336 " c+d+e.e.g.q x.e.e.e+f+g+h+i+j+k+j+l+m+n+o+ 1+b+ ",
337 " p+d+3+e.e.e.q+r+s+t+u+u+u+u+u+u+u+u+u+u+ 1+v+ ",
338 " w+x+y+z+A+B+C+D+E+F+G+H+H+H+H+H+H+H+H+@.I+#+ 1+J+ ",
339 " K+L+M+N+N+O+P+Q+R+! @.~ S+%+! { Y._ T+U+V+W+X+Y+ ",
340 " : 7 Z+`+ @Z+.@R+) _ S+%+Y.] ~++@T+`+F+Z+@@#@$@%@ ",
341 " @ /.) ~ ) { &@^ { *@n J._ ( ^ S+_+/ !+R+ @#+=@-@ ",
342 " I+# _ ^ &@a.= ' - ,+a.! > ~+;@>@S+,@; _+'@T+U+[ )@ ",
343 " % R+.@= @.[+H+'@!@~@{@]@`+@. @G+~+^@/@(@_@T+:@Z+<@ ",
344 " (@[@[@[@}@}@|@1@1@2@3@<@<@4@[ W+]+5@6@J+7@8@9@=@1 u+ ",
345 " u+u+u+u+u+u+u+u+u+u+u+u+u+u+u+u+u+u+u+u+u+u+ ",
346 " ",
347 " ",
348 " "};
Binary diff not shown
Binary diff not shown
0 /* XPM */
1 static char * processor_xpm[] = {
2 "16 16 97 2",
3 " c None",
4 ". c #000000",
5 "+ c #090600",
6 "@ c #030000",
7 "# c #E8E6E1",
8 "$ c #A3A09C",
9 "% c #010000",
10 "& c #080000",
11 "* c #D6D2CD",
12 "= c #8F8A84",
13 "- c #FFFAF7",
14 "; c #98938D",
15 "> c #F1EDE9",
16 ", c #88827E",
17 "' c #181510",
18 ") c #F8EEE4",
19 "! c #F8ECE0",
20 "~ c #F8ECDE",
21 "{ c #0D0600",
22 "] c #F8EBDE",
23 "^ c #F6E7D7",
24 "/ c #C4B5A7",
25 "( c #070000",
26 "_ c #F6E5D3",
27 ": c #F7E9D9",
28 "< c #D5C5B6",
29 "[ c #050200",
30 "} c #080300",
31 "| c #312722",
32 "1 c #EFE7E0",
33 "2 c #F6F2EF",
34 "3 c #F6F1EE",
35 "4 c #EDE4DB",
36 "5 c #F1E4D6",
37 "6 c #9D9790",
38 "7 c #12110D",
39 "8 c #B1A79F",
40 "9 c #DDCFC2",
41 "0 c #F6E8D9",
42 "a c #F6F1EC",
43 "b c #F5F1EE",
44 "c c #E5D7CB",
45 "d c #F7E8D8",
46 "e c #EEDFD3",
47 "f c #CAC0B6",
48 "g c #645951",
49 "h c #E7D9CA",
50 "i c #F6E6D5",
51 "j c #F7EBDE",
52 "k c #E9DCD2",
53 "l c #756F6D",
54 "m c #F7EFE7",
55 "n c #EDDECF",
56 "o c #D6C8BA",
57 "p c #CBB9AC",
58 "q c #D2C8BC",
59 "r c #F8EEE3",
60 "s c #F5EEE8",
61 "t c #EFE3D7",
62 "u c #B8A99D",
63 "v c #060000",
64 "w c #DBD3CB",
65 "x c #F8F1E8",
66 "y c #F3E3D4",
67 "z c #F1DFCF",
68 "A c #E6D7C7",
69 "B c #F8F2ED",
70 "C c #EDE1D4",
71 "D c #9D8E84",
72 "E c #090200",
73 "F c #DBD3CD",
74 "G c #F8F0EA",
75 "H c #F1E0D1",
76 "I c #F6EEE8",
77 "J c #56504A",
78 "K c #130D0D",
79 "L c #ADA3A2",
80 "M c #C8BDBC",
81 "N c #BEB3AB",
82 "O c #9E9A96",
83 "P c #A8A09E",
84 "Q c #0E0403",
85 "R c #0A0000",
86 "S c #0A0200",
87 "T c #040000",
88 "U c #FCF4F2",
89 "V c #F9F1EF",
90 "W c #F8F0EE",
91 "X c #F2EDEA",
92 "Y c #DDD9D6",
93 "Z c #E5E4E0",
94 "` c #030400",
95 " . c #0B0505",
96 ".. c #050000",
97 "+. c #14100F",
98 "@. c #090806",
99 "#. c #000100",
100 " . . ",
101 " + @ # $ % % ",
102 " & * = - ; > , ' ",
103 " & ) ; ! ; ~ ; { ",
104 " & ] ; ^ ; ] ; / ( ",
105 " & _ ; _ ; : ; < ( ",
106 " [ } | 1 2 3 4 5 6 < ( ",
107 " 7 _ 8 & 9 _ 0 a b c < ( ",
108 " % d e f g h i _ j k < ( ",
109 " l m n o p q r s t u ( ",
110 " v w x y z A B C _ D ( ",
111 " E F G _ H I _ < J ",
112 " K L M _ _ N O & ",
113 " P v Q R S T } ",
114 " T U V W X Y Z ` ",
115 " T ...+.@ @.. #. "};
pixmaps/scan.png less more
Binary diff not shown
Binary diff not shown
Binary diff not shown
00 /*
11 * Hardware Information, version 0.3
22 * Copyright (C) 2003 Leandro Pereira <leandro@linuxmag.com.br>
3 * SCSI support by Pascal F.Martin <pascalmartin@earthlink.net>
34 *
45 * May be modified and/or distributed under the terms of GNU GPL version 2.
5 *
6 */
7
8 /*
9 * SCSI support by Pascal F.Martin <pascalmartin@earthlink.net>
106 */
117
128 #include "hardinfo.h"
1713 FILE *proc_scsi;
1814 gchar buffer[256], *buf;
1915 gint n=0;
20 SCSIDevice *scsi_dev, *scsi;
16 SCSIDevice *scsi_dev = NULL, *scsi;
2117 struct stat st;
2218
2319 scsi = NULL;
116112 };
117113
118114 int i;
119 GtkWidget *hbox, *vbox, *label;
120115 gchar *buf;
121 #ifdef GTK2
122 GtkWidget *pixmap;
123 #endif
124116
125117 if(!device) return;
126118
128120 if (!strcmp(device->type, type2icon[i].type)) break;
129121 }
130122
131 #ifdef GTK2
132123 buf = g_strdup_printf("%s%s", IMG_PREFIX, type2icon[i].icon);
133 pixmap = gtk_image_new_from_file(buf);
134 gtk_widget_show(pixmap);
135
136 g_free(buf);
137 #endif
138 hbox = gtk_hbox_new(FALSE, 2);
139 gtk_container_set_border_width(GTK_CONTAINER(hbox), 4);
140 gtk_widget_show(hbox);
141
142 if(mainwindow->framec)
143 gtk_widget_destroy(mainwindow->framec);
144
145 gtk_container_add(GTK_CONTAINER(mainwindow->frame), hbox);
146 mainwindow->framec = hbox;
147 buf = g_strdup_printf(_("SCSI %s Device"), type2icon[i].label);
148 gtk_frame_set_label(GTK_FRAME(mainwindow->frame), buf);
149 g_free(buf);
150
151 #ifdef GTK2
152 gtk_box_pack_start(GTK_BOX(hbox), pixmap, FALSE, FALSE, 0);
153 #endif
154
155 vbox = gtk_vbox_new(FALSE, 2);
156 gtk_widget_show(vbox);
157 gtk_box_pack_start(GTK_BOX(hbox), vbox, TRUE, TRUE, 0);
158
159 #ifdef GTK2
160 buf = g_strdup_printf("<b>%s</b>", device->model);
161
162 label = gtk_label_new(buf);
163 gtk_label_set_use_markup(GTK_LABEL(label), TRUE);
164 gtk_label_set_selectable(GTK_LABEL(label), TRUE);
165
166 g_free(buf);
167 #else
168 label = gtk_label_new(device->model);
169 #endif
170
171 gtk_widget_show(label);
172 gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0);
173
174 buf = g_strdup_printf(_("Revision: %s"), device->revision);
175 label = gtk_label_new(buf);
176 gtk_widget_show(label);
177 gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0);
124 detail_window_set_icon(mainwindow->det_window, buf);
178125 g_free(buf);
179126
180 buf = g_strdup_printf(_("Type: %s"), device->type);
181 label = gtk_label_new(buf);
182 gtk_widget_show(label);
183 gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0);
127 buf = g_strdup_printf(_("SCSI %s Device"), type2icon[i].label);
128 gtk_window_set_title(GTK_WINDOW(mainwindow->det_window->window), buf);
129 detail_window_set_dev_type(mainwindow->det_window, buf);
184130 g_free(buf);
185131
186 buf = g_strdup_printf
187 (_("Controller: %d, Bus: %d, ID: %d, LUN: %d"),
188 device->controller,
189 device->channel,
190 device->id,
191 device->lun);
192 label = gtk_label_new(buf);
193 gtk_widget_show(label);
194 gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0);
195 g_free(buf);
132 detail_window_set_dev_name(mainwindow->det_window, device->model);
133
134
135 detail_window_append_info(mainwindow->det_window, _("Revision"), device->revision);
136 detail_window_append_info(mainwindow->det_window, _("Type"), device->type);
137
138 detail_window_append_separator(mainwindow->det_window);
139
140 detail_window_append_info_int(mainwindow->det_window, _("Controller"), device->controller, FALSE);
141 detail_window_append_info_int(mainwindow->det_window, _("Channel"), device->channel, FALSE);
142 detail_window_append_info_int(mainwindow->det_window, _("ID"), device->id, FALSE);
143 detail_window_append_info_int(mainwindow->det_window, _("LUN"), device->lun, FALSE);
196144 }
1111 {
1212 FILE *proc_tty;
1313 struct stat st;
14 const gchar *ser_drv="/proc/tty/driver/serial";
15 gint n=0;
14 const gchar *ser_drv = "/proc/tty/driver/serial";
15 gint n = 0;
1616 SerialDevice *serial_dev, *serial;
1717
1818 serial = NULL;
2727 gchar *buf = buffer;
2828
2929 if(*buf == 's') continue;
30 if(strstr(buf, "unknown")) continue;
30 if(strstr(buffer, "unknown")) continue;
3131
3232 serial_dev = g_new0(SerialDevice, 1);
3333
3535 serial = serial_dev;
3636
3737 serial_dev->name = g_strdup_printf
38 ("Serial Port (tty%d)", buffer[0]-'0');
38 (_("Serial Port (tty%d)"), buffer[0]-'0');
3939
4040 walk_until('t');
41 buf+=2;
41 buf += 2;
4242 start = buf;
4343 walk_until(' ');
4444 end = buf;
6363
6464 void hi_show_serial_info(MainWindow *mainwindow, SerialDevice *device)
6565 {
66 GtkWidget *hbox, *vbox, *label;
67 gchar *buf;
68 #ifdef GTK2
69 GtkWidget *pixmap;
70
71 pixmap = gtk_image_new_from_file(IMG_PREFIX "gen_connector.png");
72 gtk_widget_show(pixmap);
73 #endif
74
7566 if(!device) return;
7667
77 hbox = gtk_hbox_new(FALSE, 2);
78 gtk_container_set_border_width(GTK_CONTAINER(hbox), 4);
79 gtk_widget_show(hbox);
68 detail_window_set_icon(mainwindow->det_window, IMG_PREFIX "gen_connector.png");
69 gtk_window_set_title(GTK_WINDOW(mainwindow->det_window->window), _("Communication Port"));
70
71 detail_window_set_dev_name(mainwindow->det_window, device->name);
72 detail_window_set_dev_type(mainwindow->det_window, _("Communication Port"));
8073
81 if(mainwindow->framec)
82 gtk_widget_destroy(mainwindow->framec);
83
84 gtk_container_add(GTK_CONTAINER(mainwindow->frame), hbox);
85 mainwindow->framec = hbox;
86
87 gtk_frame_set_label(GTK_FRAME(mainwindow->frame), _("Communication Port"));
88
89 #ifdef GTK2
90 gtk_box_pack_start(GTK_BOX(hbox), pixmap, FALSE, FALSE, 0);
91 #endif
92
93 vbox = gtk_vbox_new(FALSE, 2);
94 gtk_widget_show(vbox);
95 gtk_box_pack_start(GTK_BOX(hbox), vbox, TRUE, TRUE, 0);
96
97 #ifdef GTK2
98 buf = g_strdup_printf("<b>%s</b>", device->name);
99 label = gtk_label_new(buf);
100 gtk_label_set_use_markup(GTK_LABEL(label), TRUE);
101 gtk_label_set_selectable(GTK_LABEL(label), TRUE);
102
103 g_free(buf);
104 #else
105 label = gtk_label_new(device->name);
106 #endif
107 gtk_widget_show(label);
108 gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0);
109
110 buf = g_strdup_printf(_("I/O port: 0x%x, IRQ: %d"), device->port, device->irq);
111 label = gtk_label_new(buf);
112 gtk_widget_show(label);
113 gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0);
114 g_free(buf);
115
116 buf = g_strdup_printf("UART: %s", device->uart);
117 label = gtk_label_new(buf);
118 gtk_widget_show(label);
119 gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0);
120 g_free(buf);
121
74 detail_window_append_info_int(mainwindow->det_window, _("I/O port"),
75 device->port, TRUE);
76 detail_window_append_info_int(mainwindow->det_window, _("IRQ"),
77 device->irq, TRUE);
78 detail_window_append_info(mainwindow->det_window, "UART", device->uart);
12279 }
0 #include "config.h"
01 #include "status.h"
12
23 myStatus *my_status_new(gchar *title, gchar *text)
1212 };
1313
1414 myStatus *my_status_new(gchar *title, gchar *text);
15 void my_status_pulse(myStatus *status);
16 void my_status_destroy(myStatus *status);
17 void my_status_set_text(myStatus *status, gchar *text);
15 void my_status_pulse(myStatus *status);
16 void my_status_destroy(myStatus *status);
17 void my_status_set_text(myStatus *status, gchar *text);
1818
1919 #endif /* __STATUS_H__ */
0 /*
1 * Based on GAIM's stock.c
2 * Copyright (C) 2002-2003, Christian Hammond <chipx86@gnupdate.org>
3 *
4 * Also distributed under GNU GPL version 2.
5 */
6
7 #include <gtk/gtk.h>
8 #include "stock.h"
9 #include "hardinfo.h"
10 #include "config.h"
11
12 static struct StockIcon {
13 const char *name;
14 const char *filename;
15 } const stock_icons[] = {
16 { HI_ABOUT, "stock-about-16.png" },
17 { HI_DETAILS, "stock-details.png" }
18 };
19
20 const GtkStockItem stock_items[] = {
21 { HI_ABOUT, "About...", 0, 0, NULL },
22 { HI_DETAILS, "_Details...", 0, 0, NULL }
23 };
24
25 static gint stock_icon_count = sizeof stock_icons / sizeof(*stock_icons);
26 static gint stock_item_count = sizeof stock_items / sizeof(*stock_items);
27 static gboolean stock_inited = FALSE;
28
29 void hi_stock_init(void)
30 {
31 GtkIconFactory *ift;
32 int i;
33 GtkWidget *win;
34
35 if (stock_inited) return;
36
37 ift = gtk_icon_factory_new();
38 gtk_icon_factory_add_default(ift);
39
40 win = gtk_window_new(GTK_WINDOW_TOPLEVEL);
41 gtk_widget_realize(win);
42
43 for (i = 0; i < stock_icon_count; i++) {
44 GdkPixbuf *pixbuf;
45 GtkIconSet *iconset;
46 gchar *filename;
47
48 filename = g_strdup_printf("%s/%s", IMG_PREFIX, stock_icons[i].filename);
49 pixbuf = gdk_pixbuf_new_from_file(filename, NULL);
50 g_free(filename);
51
52 iconset = gtk_icon_set_new_from_pixbuf(pixbuf);
53 gtk_icon_factory_add(ift, stock_icons[i].name, iconset);
54 gtk_icon_set_unref(iconset);
55 }
56
57 gtk_widget_destroy(win);
58 g_object_unref(G_OBJECT(ift));
59 gtk_stock_add_static(stock_items, stock_item_count);
60
61 stock_inited = TRUE;
62 }
63
0 #ifndef __STOCK_H__
1 #define __STOCK_H__
2
3 #include "config.h"
4
5 #ifdef GTK2
6
7 #define HI_ABOUT "hi-about"
8 #define HI_DETAILS "hi-details"
9
10 #define HI_PCI "hi-pci"
11 #define HI_HDD "hi-hdd"
12 #define HI_SCSI "hi-scsi"
13 #define HI_CONNECTOR "hi-connector"
14 #define HI_USB "hi-usb"
15
16 void hi_stock_init(void);
17 #endif
18
19 #endif /* __STOCK_H__ */
+109
-66
usb.c less more
00 /*
11 * Hardware Information, version 0.3
2 * Copyright (C) 2003 Leandro Pereira <leandro@linuxmag.com.br>
2 * Copyright (C) 2003-2004 Leandro Pereira <leandro@linuxmag.com.br>
3 * USB support rewritten by Christophe Grosjean <christopheg@wanadoo.fr>
34 *
45 * May be modified and/or distributed under the terms of GNU GPL version 2.
56 */
3738 return TRUE;
3839 }
3940
41
42
43 USBDevice *hi_scan_usb(void)
44 {
45 FILE *proc_usb;
46 gint n=0;
47 USBDevice *usb_dev = NULL, *usb = NULL;
48 struct stat st;
49 gchar buffer[128];
50
51 if (stat("/proc/bus/usb/devices", &st)) return NULL;
52
53 proc_usb = fopen("/proc/bus/usb/devices", "r");
54 while(fgets(buffer, 128, proc_usb)){
55 int lg = strlen(buffer);
56 if (lg>0 && buffer[lg-1] == '\n'){
57 buffer[lg-1]=0;
58 }
59 if (strstr(buffer, "Manufacturer=")) {
60 gchar *buf = buffer;
61
62 for (;*buf; buf++) {
63 if (*buf == '=') {
64 if (usb){
65 usb->vendor = g_strdup(buf+1);
66 }
67 break;
68 }
69 }
70 } else if (strstr(buffer, "Product=")) {
71 gchar *buf = buffer;
72 for (; *buf; buf++) {
73 if (*buf == '=') {
74 if (usb_dev){
75 usb_dev->product = g_strdup(buf+1);
76 }
77 }
78 }
79 } else if (!strncmp(buffer, "D: Ve", 6)) {
80 gchar *buf = buffer;
81 gfloat version;
82 gint class_id;
83
84 usb_dev = g_new0(USBDevice, 1);
85 usb_dev->next = usb;
86 usb = usb_dev;
87
88 buf+=4;
89
90 sscanf(buf, "Ver= %f Cls= %d", &version, &class_id);
91
92 usb_dev->version = version;
93 usb_dev->class_id= class_id;
94
95 walk_until('(');
96 buf[6]=0;
97 usb_dev->class = g_strdup(buf+1);
98
99 n++;
100 } else if (!strncmp(buffer, "P: Ve", 6)) {
101 gchar *buf = buffer;
102 gint vendor_id, prod_id;
103 gfloat rev;
104
105 buf+=4;
106
107 sscanf(buf, "Vendor= %x ProdID= %x Rev= %f",
108 &vendor_id, &prod_id, &rev);
109 if (usb_dev){
110 usb_dev->vendor_id = vendor_id;
111 usb_dev->prod_id = prod_id;
112 usb_dev->revision = rev;
113 }
114 }
115 }
116 fclose(proc_usb);
117 return usb;
118 }
119
120 #if 0
40121 USBDevice *hi_scan_usb(void)
41122 {
42123 FILE *proc_usb;
43124 gchar buffer[64];
44125 gint n=0;
45 USBDevice *usb_dev, *usb;
126 USBDevice *usb_dev = NULL, *usb = NULL;
46127 struct stat st;
47128
48129 usb = NULL;
54135 if (strstr(buffer, "Manufacturer=")) {
55136 gchar *buf = buffer;
56137 gboolean lock = FALSE;
57 gpointer start, end;
138 gpointer start = NULL, end = NULL;
58139
59140 for (; buf != NULL; buf++) {
60141 if (lock && *buf == '\n') {
74155 } else if (strstr(buffer, "Product=")) {
75156 gchar *buf = buffer;
76157 gboolean lock = FALSE;
77 gpointer start, end;
158 gpointer start = NULL, end = NULL;
78159
79160 for (; buf != NULL; buf++) {
80161 if (lock && *buf == '\n') {
135216
136217 return usb;
137218 }
219 #endif
138220
139221 void hi_show_usb_info(MainWindow *mainwindow, USBDevice *device)
140222 {
141 GtkWidget *hbox, *vbox, *label;
142223 gchar *buf;
143 #ifdef GTK2
144 GtkWidget *pixmap;
145
146 pixmap = gtk_image_new_from_file(IMG_PREFIX "usb.png");
147 gtk_widget_show(pixmap);
148 #endif
149224
150225 if(!device) return;
151226
152 hbox = gtk_hbox_new(FALSE, 2);
153 gtk_container_set_border_width(GTK_CONTAINER(hbox), 4);
154 gtk_widget_show(hbox);
155
156 if(mainwindow->framec)
157 gtk_widget_destroy(mainwindow->framec);
158
159 gtk_container_add(GTK_CONTAINER(mainwindow->frame), hbox);
160 mainwindow->framec = hbox;
161
162 gtk_frame_set_label(GTK_FRAME(mainwindow->frame), _("USB Device"));
163
164 #ifdef GTK2
165 gtk_box_pack_start(GTK_BOX(hbox), pixmap, FALSE, FALSE, 0);
166 #endif
167
168 vbox = gtk_vbox_new(FALSE, 2);
169 gtk_widget_show(vbox);
170 gtk_box_pack_start(GTK_BOX(hbox), vbox, TRUE, TRUE, 0);
171
172 #ifdef GTK2
173 buf = g_strdup_printf("<b>%s</b>", device->product);
174 label = gtk_label_new(buf);
175 gtk_label_set_use_markup(GTK_LABEL(label), TRUE);
176 gtk_label_set_selectable(GTK_LABEL(label), TRUE);
177
227 detail_window_set_icon(mainwindow->det_window, IMG_PREFIX "usb.png");
228
229 gtk_window_set_title(GTK_WINDOW(mainwindow->det_window->window), _("USB Device"));
230
231
232 detail_window_set_dev_name(mainwindow->det_window, device->product);
233 detail_window_set_dev_type(mainwindow->det_window, device->vendor ?
234 device->vendor : "");
235
236 buf = g_strdup_printf("%s (%d)", device->class, device->class_id);
237 detail_window_append_info(mainwindow->det_window, _("Class"), buf);
178238 g_free(buf);
179 #else
180 label = gtk_label_new(device->product);
181 #endif
182 gtk_widget_show(label);
183 gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0);
184
185 if (device->vendor) {
186 buf = g_strdup_printf(_("Manufacturer: %s"), device->vendor);
187 label = gtk_label_new(buf);
188 gtk_widget_show(label);
189 gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0);
190 g_free(buf);
191 }
192
193 buf = g_strdup_printf(_("Class: %s (%d)"), device->class, device->class_id);
194 label = gtk_label_new(buf);
195 gtk_widget_show(label);
196 gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0);
239
240 detail_window_append_separator(mainwindow->det_window);
241
242 buf = g_strdup_printf("%.2f", device->version);
243 detail_window_append_info(mainwindow->det_window, _("Version"), buf);
197244 g_free(buf);
198245
199 buf = g_strdup_printf(_("Version: %.2f, Revision: %.2f"), device->version, device->revision);
200 label = gtk_label_new(buf);
201 gtk_widget_show(label);
202 gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0);
246 buf = g_strdup_printf("%.2f", device->revision);
247 detail_window_append_info(mainwindow->det_window, _("Revision"), buf);
203248 g_free(buf);
204249
205250 if(!device->prod_id) return;
206
207 buf = g_strdup_printf(_("Vendor ID: 0x%X, Product ID: 0x%X"),
208 device->vendor_id, device->prod_id);
209 label = gtk_label_new(buf);
210 gtk_widget_show(label);
211 gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0);
212 g_free(buf);
251
252 detail_window_append_separator(mainwindow->det_window);
253
254 detail_window_append_info_int(mainwindow->det_window, _("Vendor ID"), device->vendor_id, TRUE);
255 detail_window_append_info_int(mainwindow->det_window, _("Product ID"), device->prod_id, TRUE);
213256
214257 }
215258
3434 if(!proc_dir)
3535 return NULL;
3636
37 while (sd = readdir(proc_dir)) {
37 while ((sd = readdir(proc_dir))) {
3838 gchar *dev, buffer[128];
3939
4040 dev = g_strdup_printf("/proc/video/dev/%s", sd->d_name);
6565
6666 void hi_show_v4l_info(MainWindow *mainwindow, V4LDevice *device)
6767 {
68 GtkWidget *hbox, *vbox, *label;
6968 gchar *buf;
70 #ifdef GTK2
71 GtkWidget *pixmap;
72 #endif
7369
7470 if(!device) return;
7571
76 hbox = gtk_hbox_new(FALSE, 2);
77 gtk_container_set_border_width(GTK_CONTAINER(hbox), 4);
78 gtk_widget_show(hbox);
72 buf = g_strdup_printf("%sv4l.png", IMG_PREFIX);
73 detail_window_set_icon(mainwindow->det_window, buf);
74 g_free(buf);
75
76 gtk_window_set_title(GTK_WINDOW(mainwindow->det_window->window), _("Device Information"));
7977
80 #ifdef GTK2
81 buf = g_strdup_printf("%sv4l.png", IMG_PREFIX);
82 pixmap = gtk_image_new_from_file(buf);
83 gtk_widget_show(pixmap);
84
85 gtk_box_pack_start(GTK_BOX(hbox), pixmap, FALSE, FALSE, 0);
86
87 g_free(buf);
88 #endif
8978
90 if(mainwindow->framec)
91 gtk_widget_destroy(mainwindow->framec);
92
93 gtk_container_add(GTK_CONTAINER(mainwindow->frame), hbox);
94 mainwindow->framec = hbox;
95
96 gtk_frame_set_label(GTK_FRAME(mainwindow->frame), _("Device Information"));
97
98 vbox = gtk_vbox_new(FALSE, 5);
99 gtk_widget_show(vbox);
100 gtk_box_pack_start(GTK_BOX(hbox), vbox, TRUE, TRUE, 0);
101
102 #ifdef GTK2
103 buf = g_strdup_printf("<b>%s</b>", device->name);
104
105 label = gtk_label_new(buf);
106 gtk_widget_show(label);
107 gtk_label_set_use_markup(GTK_LABEL(label), TRUE);
108 gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0);
109
110 g_free(buf);
111 #else
112 label = gtk_label_new(device->name);
113 gtk_widget_show(label);
114 gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0);
115 #endif
79 detail_window_set_dev_name(mainwindow->det_window, device->name);
11680
11781 if (device->type) {
11882 gchar *b = g_strdup(device->type);
12488 } while(*b);
12589 b = b_start;
12690
127 buf = g_strdup_printf("Type:\n%s", b);
128
129 label = gtk_label_new(buf);
130 gtk_widget_show(label);
131 gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0);
132
133 g_free(buf);
91 detail_window_append_info(mainwindow->det_window, _("Type"),
92 b);
13493 g_free(b);
13594 }
13695 }
00 /*
11 * Hardware Information, version 0.3
22 * Copyright (C) 2003 Leandro Pereira <leandro@linuxmag.com.br>
3 *
4 * May be modified and/or distributed under the terms of GNU GPL version 2.
53 *
64 * This module contains code from xdpyinfo.c, by Jim Fulton, MIT X Consortium
75 * Copyright 1988, 1998 The Open Group
137135 {
138136 GtkWidget *label, *hbox;
139137 GtkWidget *table;
140 #ifdef GTK2
141138 GtkWidget *pixmap;
142139 gchar *buf;
143 #endif
144140 X11Info *info;
145141
146142 if (!mainwindow)
154150 hbox = gtk_hbox_new(FALSE, 0);
155151 gtk_widget_show(hbox);
156152
157 #ifdef GTK2
158153 buf = g_strdup_printf("%s/x11.png", IMG_PREFIX);
159154 pixmap = gtk_image_new_from_file(buf);
160155 gtk_widget_set_usize(GTK_WIDGET(pixmap), 64, 0);
161156 gtk_widget_show(pixmap);
162157 gtk_box_pack_start(GTK_BOX(hbox), pixmap, FALSE, FALSE, 0);
163158 g_free(buf);
164 #endif
165159
166160 table = gtk_table_new(4, 2, FALSE);
167161 gtk_widget_show(table);
173167 /*
174168 * Table headers
175169 */
176 #ifdef GTK2
177170 label = gtk_label_new(_("<b>Display:</b>"));
178171 gtk_label_set_use_markup(GTK_LABEL(label), TRUE);
179 #else
180 label = gtk_label_new(_("Display:"));
181 #endif
182172 gtk_table_attach_defaults(GTK_TABLE(table), label, 0, 1, 0, 1);
183173 gtk_widget_show(label);
184174 gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.5);
185175
186 #ifdef GTK2
187176 label = gtk_label_new(_("<b>Vendor:</b>"));
188177 gtk_label_set_use_markup(GTK_LABEL(label), TRUE);
189 #else
190 label = gtk_label_new(_("Vendor:"));
191 #endif
192178 gtk_table_attach_defaults(GTK_TABLE(table), label, 0, 1, 1, 2);
193179 gtk_widget_show(label);
194180 gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.5);
195181
196 #ifdef GTK2
197182 label = gtk_label_new(_("<b>Release:</b>"));
198183 gtk_label_set_use_markup(GTK_LABEL(label), TRUE);
199 #else
200 label = gtk_label_new(_("Release:"));
201 #endif
202184 gtk_table_attach_defaults(GTK_TABLE(table), label, 0, 1, 2, 3);
203185 gtk_widget_show(label);
204186 gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.5);
205187
206 #ifdef GTK2
207188 label = gtk_label_new(_("<b>Resolution:</b>"));
208189 gtk_label_set_use_markup(GTK_LABEL(label), TRUE);
209 #else
210 label = gtk_label_new(_("Resolution:"));
211 #endif
212190 gtk_table_attach_defaults(GTK_TABLE(table), label, 0, 1, 3, 4);
213191 gtk_widget_show(label);
214192 gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.5);