diff options
| -rw-r--r-- | ChangeLog | 17 | ||||
| -rw-r--r-- | Makefile | 53 | ||||
| -rw-r--r-- | Makefile.in | 4 | ||||
| -rw-r--r-- | about.c | 34 | ||||
| -rw-r--r-- | build-stamp | 0 | ||||
| -rw-r--r-- | computer.c | 907 | ||||
| -rw-r--r-- | computer.h | 5 | ||||
| -rw-r--r-- | config.h | 14 | ||||
| -rwxr-xr-x | configure | 131 | ||||
| -rw-r--r-- | configure-stamp | 0 | ||||
| -rw-r--r-- | debian/changelog | 6 | ||||
| -rw-r--r-- | debian/control | 4 | ||||
| -rw-r--r-- | debian/menu | 8 | ||||
| -rw-r--r-- | default.lang | 148 | ||||
| -rw-r--r-- | details.c | 282 | ||||
| -rw-r--r-- | details.h | 40 | ||||
| -rw-r--r-- | hardinfo.c | 213 | ||||
| -rw-r--r-- | hardinfo.h | 29 | ||||
| -rw-r--r-- | ide.c | 94 | ||||
| -rw-r--r-- | ide.h | 2 | ||||
| -rw-r--r-- | intl.c | 6 | ||||
| -rw-r--r-- | isapnp.c | 62 | ||||
| -rw-r--r-- | lang/pt_BR.lang | 2 | ||||
| -rw-r--r-- | modules.c | 137 | ||||
| -rw-r--r-- | modules.h | 21 | ||||
| -rw-r--r-- | net.c | 183 | ||||
| -rw-r--r-- | net.h | 12 | ||||
| -rw-r--r-- | parport.c | 102 | ||||
| -rw-r--r-- | pci.c | 137 | ||||
| -rw-r--r-- | pci.h | 1 | ||||
| -rw-r--r--[-rwxr-xr-x] | pixmaps/cd.png | bin | 2811 -> 2904 bytes | |||
| -rwxr-xr-x | pixmaps/distro/.xvpics/mdk.png | bin | 2706 -> 0 bytes | |||
| -rwxr-xr-x | pixmaps/distro/yd.png | bin | 2173 -> 3189 bytes | |||
| -rw-r--r--[-rwxr-xr-x] | pixmaps/hdd.png | bin | 3805 -> 992 bytes | |||
| -rwxr-xr-x | pixmaps/logo.png | bin | 2699 -> 3182 bytes | |||
| -rw-r--r-- | pixmaps/logo.xpm | 349 | ||||
| -rw-r--r--[-rwxr-xr-x] | pixmaps/lpr.png | bin | 5741 -> 2143 bytes | |||
| -rw-r--r-- | pixmaps/module.png | bin | 0 -> 2995 bytes | |||
| -rw-r--r-- | pixmaps/processor.xpm | 116 | ||||
| -rwxr-xr-x | pixmaps/scan.png | bin | 1517 -> 0 bytes | |||
| -rw-r--r-- | pixmaps/scanner.png | bin | 0 -> 2426 bytes | |||
| -rw-r--r-- | pixmaps/stock-details.png | bin | 0 -> 966 bytes | |||
| -rw-r--r-- | scsi.c | 80 | ||||
| -rw-r--r-- | serial.c | 71 | ||||
| -rw-r--r-- | status.c | 1 | ||||
| -rw-r--r-- | status.h | 6 | ||||
| -rw-r--r-- | stock.c | 64 | ||||
| -rw-r--r-- | stock.h | 20 | ||||
| -rw-r--r-- | usb.c | 165 | ||||
| -rw-r--r-- | v4l.c | 53 | ||||
| -rw-r--r-- | x11.c | 22 | 
51 files changed, 2271 insertions, 1330 deletions
| @@ -1,11 +1,24 @@ +06/01/2003 12:05 BRST	<leandro@linuxmag.com.br>	0.3.7-pre1 + +	* details.[ch] +	  Use a window to show details instead of showing them inside the +	  main window +	* computer.c, hardinfo.[ch] +	  Show more processor information (currently x86 only) +	* modules.[ch], hardinfo.[ch] +	  Loaded kernel modules information + +05/01/2003 12:05 BRST	<leandro@linuxmag.com.br>	0.3.6 + +	* 0.3.6 released +  17/12/2003 10:50 BRST	<leandro@linuxmag.com.br>	0.3.6-pre4  	* hardinfo.desktop, Makefile.in  	  - Added GNOME/KDE menu entry  	    (Thanks to Gustavo Noronha <kov@debian.org>)  	* net.[ch] -	  - Preliminary network information support (disabled in -	    GUI). +	  - Preliminary network information support (disabled in GUI).  03/07/2003 13:25 BRST	<leandro@linuxmag.com.br>	0.3.6-pre3 diff --git a/Makefile b/Makefile new file mode 100644 index 00000000..2168ea59 --- /dev/null +++ b/Makefile @@ -0,0 +1,53 @@ +TARGET = GTK2 +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   +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   +PACKAGE = hardinfo-0.3.7pre +# ---------------------------------------------------------------------------- + +CC = gcc +CFLAGS = -Wall -g $(GTK_CFLAGS) -O6  + +# ---------------------------------------------------------------------------- + +OBJECTS = hardinfo.o scsi.o ide.o pci.o usb.o isapnp.o serial.o parport.o \ +	computer.o x11.o intl.o about.o v4l.o status.o net.o stock.o \ +	details.o modules.o + +all:	$(OBJECTS) +	$(CC) $(CFLAGS) -o hardinfo $(OBJECTS) $(GTK_LIBS) $(GTK_FLAGS) + +clean: +	rm -rf *~ .xvpics pixmaps/.xvpics *.o hardinfo + +install:	all +	mkdir -p ${DESTDIR}/usr/bin/ +	cp hardinfo ${DESTDIR}/usr/bin/hardinfo +	mkdir -p ${DESTDIR}/usr/share/hardinfo/pixmaps +	cp -rv pixmaps/*.png ${DESTDIR}/usr/share/hardinfo/pixmaps +	cp -rv pixmaps/logo.xpm ${DESTDIR}/usr/share/hardinfo/pixmaps +	mkdir -p ${DESTDIR}/usr/share/hardinfo/pixmaps/distro +	cp -rv pixmaps/distro/*.png ${DESTDIR}/usr/share/hardinfo/pixmaps/distro +	mkdir -p ${DESTDIR}/usr/share/hardinfo/lang +	cp -rv lang/* ${DESTDIR}/usr/share/hardinfo/lang +	chmod -R 755 ${DESTDIR}/usr/share/hardinfo +	chmod -R -x ${DESTDIR}/usr/share/hardinfo +	chmod  755 ${DESTDIR}/usr/share/hardinfo +	chmod  755 ${DESTDIR}/usr/share/hardinfo/pixmaps +	chmod  755 ${DESTDIR}/usr/share/hardinfo/lang +	chmod  755 ${DESTDIR}/usr/share/hardinfo/pixmaps/distro +	mkdir -p ${DESTDIR}/usr/share/applications +	cp hardinfo.desktop ${DESTDIR}/usr/share/applications + +dist-clean:	clean +	rm -rf Makefile debian/hardinfo/ config.h + +package:	dist-clean +	@echo "Creating tar.gz..." +	cd .. && tar czf $(PACKAGE).tar.gz $(PACKAGE)/* && cd $(PACKAGE) +	@echo "Creating tar.bz2..." +	cd .. && tar cjf $(PACKAGE).tar.bz2 $(PACKAGE)/* && cd $(PACKAGE) + +deb:	dist-clean +	@echo "Creating deb..." +	dpkg-buildpackage -rfakeroot -k${USER} + diff --git a/Makefile.in b/Makefile.in index fa0aab7e..29014b89 100644 --- a/Makefile.in +++ b/Makefile.in @@ -6,7 +6,8 @@ CFLAGS = -Wall -g $(GTK_CFLAGS) -O6  # ----------------------------------------------------------------------------  OBJECTS = hardinfo.o scsi.o ide.o pci.o usb.o isapnp.o serial.o parport.o \ -	computer.o x11.o intl.o about.o v4l.o status.o net.o +	computer.o x11.o intl.o about.o v4l.o status.o net.o stock.o \ +	details.o modules.o  all:	$(OBJECTS)  	$(CC) $(CFLAGS) -o hardinfo $(OBJECTS) $(GTK_LIBS) $(GTK_FLAGS) @@ -19,6 +20,7 @@ install:	all  	cp hardinfo ${DESTDIR}/usr/bin/hardinfo  	mkdir -p ${DESTDIR}/usr/share/hardinfo/pixmaps  	cp -rv pixmaps/*.png ${DESTDIR}/usr/share/hardinfo/pixmaps +	cp -rv pixmaps/logo.xpm ${DESTDIR}/usr/share/hardinfo/pixmaps  	mkdir -p ${DESTDIR}/usr/share/hardinfo/pixmaps/distro  	cp -rv pixmaps/distro/*.png ${DESTDIR}/usr/share/hardinfo/pixmaps/distro  	mkdir -p ${DESTDIR}/usr/share/hardinfo/lang @@ -12,9 +12,7 @@ GtkAbout *  gtk_about_new(const gchar * name, const gchar * version,  	      const gchar * description, const gchar * authors[], const gchar * logo_img)  { -#ifdef GTK2  	GtkWidget *img; -#endif  	gchar *buf;  	const gchar *auth;  	GtkWidget *window, *vbox, *label, *btn, *hr, *hbox; @@ -29,42 +27,26 @@ gtk_about_new(const gchar * name, const gchar * version,  	about->window = window; -#ifdef GTK2  	gtk_window_set_resizable(GTK_WINDOW(window), FALSE); -#else -	gtk_window_set_policy(GTK_WINDOW(window), FALSE, FALSE, FALSE); -#endif  	vbox = gtk_vbox_new(FALSE, 5);  	gtk_box_set_spacing(GTK_BOX(vbox), 3);  	gtk_container_add(GTK_CONTAINER(window), vbox); -#ifdef GTK2  	img = gtk_image_new_from_file(logo_img);  	gtk_widget_show(img);  	gtk_box_pack_start(GTK_BOX(vbox), img, FALSE, FALSE, 0);  	gtk_widget_set_usize(GTK_WIDGET(img), 64, 64); -#endif -#ifdef GTK2  #define	ADD_LABEL(x,y)	label = gtk_label_new(x); \  			gtk_label_set_use_markup(GTK_LABEL(label), TRUE); \  			gtk_widget_show(label);	\  			gtk_box_pack_start(GTK_BOX(y), label, TRUE, TRUE, 0); -#else -#define	ADD_LABEL(x,y)	label = gtk_label_new(x); \ -			gtk_widget_show(label);	\ -			gtk_box_pack_start(GTK_BOX(y), label, TRUE, TRUE, 0); -#endif -#ifdef GTK2  	buf =  	    g_strdup_printf  	    ("<span size=\"xx-large\" weight=\"bold\">%s %s</span>", name,  	     version); -#else -	buf = g_strdup_printf("%s %s", name, version); -#endif  	ADD_LABEL(buf, vbox);  	g_free(buf); @@ -76,19 +58,11 @@ gtk_about_new(const gchar * name, const gchar * version,  		if (*auth == '>') {  			auth++; -#ifdef GTK2  			buf = g_strdup_printf("<b>%s</b>", auth); -#else -			buf = g_strdup_printf("%s", auth); -#endif  			ADD_LABEL(buf, vbox);  			g_free(buf);  		} else { -#ifdef GTK2  			buf = g_strdup_printf("<span size=\"small\">%s</span>", auth); -#else -			buf = g_strdup_printf("    %s", auth); -#endif  			ADD_LABEL(buf, vbox);  			g_free(buf);  		} @@ -102,14 +76,10 @@ gtk_about_new(const gchar * name, const gchar * version,          gtk_widget_show(hbox);          gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0);          gtk_button_box_set_spacing(GTK_BUTTON_BOX(hbox), 6); +        gtk_button_box_set_layout(GTK_BUTTON_BOX(hbox), GTK_BUTTONBOX_END); -#ifdef GTK2 -        btn = gtk_button_new_from_stock(GTK_STOCK_OK); +        btn = gtk_button_new_from_stock(GTK_STOCK_CLOSE);          g_signal_connect(G_OBJECT(btn), "clicked", (GCallback)about_close, about); -#else -        btn = gtk_button_new_with_label(_("OK")); -        gtk_signal_connect(GTK_OBJECT(btn), "clicked", about_close, about); -#endif          gtk_widget_show(btn);          gtk_box_pack_start(GTK_BOX(hbox), btn, FALSE, FALSE, 0); diff --git a/build-stamp b/build-stamp new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/build-stamp @@ -8,32 +8,31 @@  #include "hardinfo.h"  #include "computer.h" +#include <gtk/gtk.h>  #include <sys/utsname.h>  #include <unistd.h>  #include <fcntl.h>  #include <stdlib.h>  static struct { -	gchar *file, *codename; -} distro_db [] = { -        { DB_PREFIX "debian_version",           "deb"  }, -        { DB_PREFIX "slackware-version",        "slk"  }, -        { DB_PREFIX "mandrake-release",         "mdk"  }, -        { DB_PREFIX "gentoo-release",           "gnt"  }, -        { DB_PREFIX "conectiva-release",        "cnc"  }, -        { DB_PREFIX "verso-conectiva",         "cnc"  }, -        { DB_PREFIX "turbolinux-release",       "tl"   }, -        { DB_PREFIX "yellowdog-release",        "yd"   }, -        { DB_PREFIX "SuSE-release",             "suse" }, - +    gchar *file, *codename; +} distro_db[] = { +    {    DB_PREFIX "debian_version",		"deb"	}, +    {    DB_PREFIX "slackware-version",		"slk"	}, +    {    DB_PREFIX "mandrake-release",		"mdk"	},  +    {    DB_PREFIX "gentoo-release",		"gnt"	},  +    {    DB_PREFIX "conectiva-release",		"cnc"	},  +    {    DB_PREFIX "versão-conectiva",		"cnc"	},  +    {    DB_PREFIX "turbolinux-release",	"tl"	},  +    {    DB_PREFIX "yellowdog-release", 	"yd"	},  +    {    DB_PREFIX "SuSE-release",		"suse"	},  	/*  	 * RedHat must be the *last* one to be checked, since  	 * some distros (like Mandrake) includes a redhat-relase  	 * file too. -	 */  -	  -        { DB_PREFIX "redhat-release",           "rh"   }, -        { NULL, NULL } +	 */ +    {    DB_PREFIX "redhat-release",		"rh"	}, +    {    NULL, NULL				        }  };  #define get_int_val(var)  { \ @@ -48,55 +47,183 @@ static struct {  		continue; \  	} +#ifdef ARCH_i386 +static struct { +    char *small, *large; +} small2large[] = { +	{    "fpu",	"Floating Point Unit"				}, +	{    "vme",	"Virtual Mode Extension"			}, +	{    "de",	"Debugging Extensions"				}, +	{    "pse",	"Page Size Extensions"				}, +	{    "tsc",	"Time Stamp Counter"				}, +	{    "msr",	"Model Specific Registers"			}, +	{    "pae",	"Physical Address Extensions"			}, +	{    "mce",	"Machine Check Architeture"			}, +	{    "cx8",	"CMPXCHG8 instruction"				}, +	{    "apic",	"Advanced Programmable Interrupt Controller"	}, +	{    "sep",	"Fast System Call"				}, +	{    "mtrr",	"Memory Type Range Registers"			}, +	{    "pge",	"Page Global Enable"				}, +	{    "cmov",	"Conditional Move instruction"			}, +	{    "pat",	"Page Attribute Table"				}, +	{    "pse36",	"36bit Page Size Extensions"			}, +	{    "psn",	"96 bit Processor Serial Number"		}, +	{    "mmx",	"MMX technology"				}, +	{    "fxsr",	"fxsr"						}, +	{    "kni",	"Streaming SIMD instructions"			}, +	{    "xmm",	"Streaming SIMD instructions"			}, +	{    "ht",      "HyperThreading"                                }, +	{    NULL,	NULL						} +}; + +static GtkWidget *get_features_widget(CPUDevice * device) +{ +    GtkWidget *widget, *scroll; +    GtkTextBuffer *buffer; +    GtkTextIter iter; +    gchar **flags; +    gint i, j; + +    if (!device->flags) +	return NULL; + +    buffer = gtk_text_buffer_new(FALSE); +    gtk_text_buffer_set_text(buffer, "", -1); +    gtk_text_buffer_get_iter_at_offset(buffer, &iter, 0); + +    flags = g_strsplit(device->flags, " ", G_N_ELEMENTS(small2large)); +    for (i = 0; *(flags + i); i++) { +	for (j = 0; j < G_N_ELEMENTS(small2large); j++) { +	    if (small2large[j].small && +		!strncmp(small2large[j].small, *(flags + i), +			 strlen(small2large[j].small))) { +//		gtk_text_buffer_insert(buffer, &iter, small2large[j].small, +//				       -1); +		gtk_text_buffer_insert(buffer, &iter, "● ", -1); +		gtk_text_buffer_insert(buffer, &iter, small2large[j].large, +				       -1); +		gtk_text_buffer_insert(buffer, &iter, "\n", -1); +		break; +	    } +	} +    } +    g_strfreev(flags); + +    scroll = gtk_scrolled_window_new(NULL, NULL); +    gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scroll), +				   GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC); +    gtk_container_set_border_width(GTK_CONTAINER(scroll), 4); +    gtk_widget_show(scroll); + +    widget = gtk_text_view_new(); +    gtk_text_view_set_buffer(GTK_TEXT_VIEW(widget), buffer); +    gtk_text_view_set_editable(GTK_TEXT_VIEW(widget), FALSE); +    gtk_text_view_set_cursor_visible(GTK_TEXT_VIEW(widget), FALSE); +    gtk_text_view_set_indent(GTK_TEXT_VIEW(widget), 5); +    gtk_widget_show(widget); + +    gtk_container_add(GTK_CONTAINER(scroll), widget); + +    return scroll; +} +#endif + +void hi_show_cpu_info(MainWindow * mainwindow, CPUDevice * device) +{ +    gchar *buf; + +    if (!device) +	return; + +    gtk_window_set_title(GTK_WINDOW(mainwindow->det_window->window), +			 device->processor); +    detail_window_set_icon(mainwindow->det_window, IMG_PREFIX "cpu.png"); +    detail_window_set_dev_name(mainwindow->det_window, device->processor); +    detail_window_set_dev_type(mainwindow->det_window, device->machine); + +    detail_window_append_info_int(mainwindow->det_window, _("Number"), +				  device->procno, FALSE); +    buf = g_strdup_printf("%dMHz", device->frequency); +    detail_window_append_info(mainwindow->det_window, _("Frequency"), buf); +    g_free(buf); + +    detail_window_append_separator(mainwindow->det_window); +#ifdef ARCH_i386 +    detail_window_append_info_int(mainwindow->det_window, _("Family"), +				  device->family, FALSE); +    detail_window_append_info_int(mainwindow->det_window, _("Model"), +				  device->model, FALSE); +    detail_window_append_info_int(mainwindow->det_window, _("Stepping"), +				  device->stepping, FALSE); +    detail_window_append_separator(mainwindow->det_window); +#endif + +    if (device->cachel2) { +	buf = g_strdup_printf("%dkB", device->cachel2); +	detail_window_append_info(mainwindow->det_window, _("Cache L2"), +				  buf); +	g_free(buf); +    } + +    buf = g_strdup_printf("%d bogomips", device->bogomips); +    detail_window_append_info(mainwindow->det_window, _("Bogomips"), buf); +    g_free(buf); + +#ifdef ARCH_i386 +    { +	GtkWidget *features, *label; + +	label = gtk_label_new(_("Features")); +	gtk_widget_show(label); + +	features = get_features_widget(device); +	gtk_notebook_append_page(GTK_NOTEBOOK +				 (mainwindow->det_window->notebook), +				 features, label); +    } +#endif + +} +  MemoryInfo *memory_get_info(void)  { -	MemoryInfo *mi; -	FILE *procmem; -	gchar buffer[128]; -	gint memfree, memused; - -	mi = g_new0(MemoryInfo, 1); - -	procmem = fopen("/proc/meminfo", "r"); -	while (fgets(buffer, 128, procmem)) { -		gchar *buf = buffer; -		 -		buf = g_strstrip(buf); -		 -		if(!strncmp(buf, "MemTotal", 8)) -			get_int_val(mi->total) -		else if(!strncmp(buf, "MemFree", 7)) -			get_int_val(memfree) -		else if(!strncmp(buf, "Cached", 6)) -			get_int_val(mi->cached) +    MemoryInfo *mi; +    FILE *procmem; +    gchar buffer[128]; +    gint memfree = 0, memused; -	} -	fclose(procmem); +    mi = g_new0(MemoryInfo, 1); + +    procmem = fopen("/proc/meminfo", "r"); +    while (fgets(buffer, 128, procmem)) { +	gchar *buf = buffer; + +	buf = g_strstrip(buf); -	mi->used  = mi->total - memfree; +	if (!strncmp(buf, "MemTotal", 8)) +	    get_int_val(mi->total) +	else if (!strncmp(buf, "MemFree", 7)) +	    get_int_val(memfree) +	else if (!strncmp(buf, "Cached", 6)) +	    get_int_val(mi->cached) +    } +    fclose(procmem); -	mi->total/=1000; -	mi->cached/=1000; -	mi->used/=1000;	 -	memfree/=1000; +    mi->used = mi->total - memfree; -	memused = mi->total - mi->used + mi->cached; +    mi->total  /= 1000; +    mi->cached /= 1000; +    mi->used   /= 1000; +    memfree    /= 1000; -#if 0 -	printf("total    = %d\n" -	       "cached   = %d\n" -	       "used     = %d\n" -	       "free     = %d\n" -	       "realused = %d\n" -	       "ratio    = %f\n\n", mi->total, mi->cached, mi->used, memfree, -	       		memused, (gdouble)memused/mi->total); -#endif	 -	mi->ratio=1 - (gdouble)memused/mi->total; +    memused = mi->total - mi->used + mi->cached; -	return mi; +    mi->ratio = 1 - (gdouble) memused / mi->total; + +    return mi;  } -#if defined(ARCH_i386) || defined(ARCH_x86_64) +#if defined(ARCH_i386) || defined(ARCH_x86_64) || defined(ARCH_PARISC)  #define PARSE_PROC_CPU()					\  		if(!strncmp(buf, "bogomips", 8))		\  			get_int_val(ci->bogomips)		\ @@ -104,6 +231,10 @@ MemoryInfo *memory_get_info(void)  			get_int_val(ci->family)			\  		else if(!strncmp(buf, "model name", 10))	\  			get_str_val(ci->processor)		\ +		else if(!strncmp(buf, "flags", 5))		\ +			get_str_val(ci->flags)			\ +		else if(!strncmp(buf, "vendor_id", 8))		\ +			get_str_val(ci->machine)		\  		else if(!strncmp(buf, "stepping", 8))		\  			get_int_val(ci->stepping)		\  		else if(!strncmp(buf, "cpu MHz", 7))		\ @@ -111,7 +242,7 @@ MemoryInfo *memory_get_info(void)  		else if(!strncmp(buf, "cache size", 10))	\  			get_int_val(ci->cachel2)		\  		else if(!strncmp(buf, "model", 5))		\ -			get_int_val(ci->model)			 +			get_int_val(ci->model)  #endif  #ifdef ARCH_PPC  #define PARSE_PROC_CPU()					\ @@ -119,397 +250,393 @@ MemoryInfo *memory_get_info(void)  			get_int_val(ci->bogomips)		\  		else if(!strncmp(buf, "cpu", 3))		\  			get_str_val(ci->processor)		\ +		else if(!strncmp(buf, "machine", 7))		\ +			get_str_val(ci->machine)		\  		else if(!strncmp(buf, "clock", 5))		\  			get_int_val(ci->frequency)		\  		else if(!strncmp(buf, "L2 cache", 8))		\ -			get_int_val(ci->cachel2)		 +			get_int_val(ci->cachel2) +#endif +#ifdef ARCH_m68k +#define	PARSE_PROC_CPU()					\ +		if (!strncmp(buf, "CPU", 3))			\ +			get_str_val(ci->processor)		\ +		else if (!strncmp(buf, "BogoMips", 8))		\ +			get_int_val(ci->bogomips)		\ +		else if (!strncmp(buf, "Clocking", 8))		\ +			get_int_val(ci->frequency) +#endif +#ifdef ARCH_MIPS +#define	PARSE_PROC_CPU()					\ +                if (!strncmp(buf, "cpu model", 9))		\ +                        get_str_val(ci->processor)		\ +                else if (!strncmp(buf, "BogoMIPS", 8))		\ +                        get_int_val(ci->bogomips)		\ +                else if (!strncmp(buf, "system type", 11))	\ +                        get_str_val(ci->machine)		  #endif  #ifndef PARSE_PROC_CPU -#error ARCH_i386 or ARCH_PPC not defined! Add support! Send me patches! +#error PARSE_PROC_CPU not defined! Maybe your arch is not supported yet; +#error please send me your /proc/cpuinfo and/or 'uname -a' output to +#error leandro@linuxmag.com.br; thanks.  #endif -static void computer_processor_info(ComputerInfo *ci) +static void computer_processor_info(ComputerInfo * ci)  { -	FILE *proccpu; -	gchar buffer[128]; - -	proccpu = fopen("/proc/cpuinfo", "r"); -	while (fgets(buffer, 128, proccpu)) { -		gchar *buf = buffer; -		 -		buf = g_strstrip(buf); -	 -		PARSE_PROC_CPU(); -	} -	fclose(proccpu); +    FILE *proccpu; +    gchar buffer[128]; -#ifdef ARCH_PPC -	{ -		gchar *proctemp; -		 -		proctemp = g_strdup_printf("PowerPC %s", ci->processor); -		g_free(ci->processor); -		ci->processor = proctemp; -	} -#endif -	 -	 -} +    proccpu = fopen("/proc/cpuinfo", "r"); +    while (fgets(buffer, 128, proccpu)) { +	gchar *buf = buffer; -ComputerInfo *computer_get_info(void) -{ -	gint i; -	struct stat st; -	ComputerInfo *ci; -	struct utsname utsbuf; - -	ci = g_new0(ComputerInfo, 1); - -	for (i = 0; ; i++) { -		if (distro_db[i].file == NULL) { -			ci->distrocode = g_strdup("unk"); -			ci->distroinfo = g_strdup(_("Unknown distribution")); -			break; -		} -		 -		if (!stat(distro_db[i].file, &st)) { -			FILE *distro_ver; -			char buf[128]; -			 -			distro_ver = fopen(distro_db[i].file, "r"); -			fgets(buf, 128, distro_ver); -			fclose(distro_ver); -	 -			buf[strlen(buf)-1]=0; - -			/* -			 * Some Debian systems doesn't include -			 * the distribuition name in /etc/debian_release, -			 * so add them here. This is a hack, though... -			 */ -			if (!strncmp(distro_db[i].codename, "deb", 3) && -				buf[0] >= '0' && buf[0] <= '9') { -				ci->distroinfo = g_strdup_printf -					("Debian GNU/Linux %s", buf); -			} else { -				ci->distroinfo = g_strdup(buf); -			} -			 - -			ci->distrocode = g_strdup(distro_db[i].codename); -						 -			break; -		} -	} +	buf = g_strstrip(buf); -	uname(&utsbuf); -	 -	ci->kernel = g_strdup_printf("%s %s (%s)", utsbuf.sysname, -		utsbuf.release, utsbuf.machine); +	PARSE_PROC_CPU(); +    } +    fclose(proccpu); -	ci->hostname = g_strdup(utsbuf.nodename); +#ifdef ARCH_PPC +    { +	gchar *proctemp; -	computer_processor_info(ci); +	proctemp = g_strdup_printf("PowerPC %s", ci->processor); +	g_free(ci->processor); +	ci->processor = proctemp; +    } +#endif +#ifdef ARCH_m68k +    { +	gchar *proctemp; + +	proctemp = g_strdup_printf("Motorola %s", ci->processor); +	g_free(ci->processor); +	ci->processor = proctemp; +    } +#endif -	return ci;  } -/* - * Code stolen from GKrellM <http://www.gkrellm.net> - * Copyright (c) 1999-2002 Bill Wilson <bill@gkrellm.net> - */ -gboolean uptime_update(gpointer data) +ComputerInfo *computer_get_info(void)  { -	MainWindow *mainwindow = (MainWindow *) data; -	gchar *buf; -	gint days, hours; -	FILE *procuptime; -	gulong minutes = 0; -	 -	if(!mainwindow) return FALSE; -	 -#define plural(a) (a == 1) ? "" : "s" - -	if ((procuptime = fopen("/proc/uptime", "r")) != NULL) { -		fscanf(procuptime, "%lu", &minutes); -		minutes /= 60; -		fclose(procuptime); -	} else -		return FALSE; -	 -	hours	 = minutes / 60; -	minutes	%= 60; -	days	 = hours / 24; -	hours	%= 24; -	 -	if (days < 1) { -		buf = g_strdup_printf(_("%d hour%s and %ld minute%s"), hours, -				plural(hours), minutes, plural(minutes));  -	} else { -		buf = g_strdup_printf(_("%d day%s, %d hour%s and %ld minute%s"), -				days, plural(days), hours, plural(hours), -				minutes, plural(minutes));  +    gint i; +    struct stat st; +    ComputerInfo *ci; +    struct utsname utsbuf; + +    ci = g_new0(ComputerInfo, 1); + +    for (i = 0;; i++) { +	if (distro_db[i].file == NULL) { +	    ci->distrocode = g_strdup("unk"); +	    ci->distroinfo = g_strdup(_("Unknown distribution")); +	    break;  	} -	gtk_label_set_text(GTK_LABEL(mainwindow->uptime), buf); -	g_free(buf); -	 -	return TRUE; -} +	if (!stat(distro_db[i].file, &st)) { +	    FILE *distro_ver; +	    char buf[128]; -GtkWidget *os_get_widget(MainWindow *mainwindow) -{ -	GtkWidget *label, *hbox; -	GtkWidget *table; -#ifdef GTK2 -	GtkWidget *pixmap; -	gchar *buf; -#endif -	ComputerInfo *info; -		 -	if(!mainwindow) return NULL; -		 -	info = computer_get_info(); -	 -	hbox = gtk_hbox_new(FALSE, 0); -	gtk_widget_show(hbox); - -#ifdef GTK2	 -	buf = g_strdup_printf("%s/distro/%s.png", IMG_PREFIX, info->distrocode); -	pixmap = gtk_image_new_from_file(buf); -	gtk_widget_set_usize(GTK_WIDGET(pixmap), 64, 0); -	gtk_widget_show(pixmap); -	gtk_box_pack_start(GTK_BOX(hbox), pixmap, FALSE, FALSE, 0); -	g_free(buf); -#endif +	    distro_ver = fopen(distro_db[i].file, "r"); +	    fgets(buf, 128, distro_ver); +	    fclose(distro_ver); -	table = gtk_table_new(4, 2, FALSE); -	gtk_widget_show(table); -	gtk_box_pack_start(GTK_BOX(hbox), table, TRUE, TRUE, 0); -	gtk_container_set_border_width(GTK_CONTAINER(table), 10); -	gtk_table_set_row_spacings(GTK_TABLE(table), 4); -	gtk_table_set_col_spacings(GTK_TABLE(table), 4); +	    buf[strlen(buf) - 1] = 0; -	/* -	 * Table headers -	 */  -#ifdef GTK2 -	label = gtk_label_new(_("<b>Computer name:</b>")); -	gtk_label_set_use_markup(GTK_LABEL(label), TRUE); -#else -	label = gtk_label_new(_("Computer name:")); -#endif -	gtk_table_attach_defaults(GTK_TABLE(table), label, 0, 1, 0, 1); -	gtk_widget_show(label); -	gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.5); +	    /* +	     * HACK: Some Debian systems doesn't include +	     * the distribuition name in /etc/debian_release, +	     * so add them here.  +	     */ +	    if (!strncmp(distro_db[i].codename, "deb", 3) && +		((buf[0] >= '0' && buf[0] <= '9') || buf[0] != 'D')) { +			ci->distroinfo = g_strdup_printf +			    ("Debian GNU/Linux %s", buf); +	    } else { +		ci->distroinfo = g_strdup(buf); +	    } -#ifdef GTK2 -	label = gtk_label_new(_("<b>Distribution:</b>")); -	gtk_label_set_use_markup(GTK_LABEL(label), TRUE); -#else -	label = gtk_label_new(_("Distribution:")); -#endif -	gtk_table_attach_defaults(GTK_TABLE(table), label, 0, 1, 1, 2); -	gtk_widget_show(label); -	gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.5); +	    ci->distrocode = g_strdup(distro_db[i].codename); -#ifdef GTK2 -	label = gtk_label_new(_("<b>Kernel:</b>")); -	gtk_label_set_use_markup(GTK_LABEL(label), TRUE); -#else -	label = gtk_label_new(_("Kernel:")); -#endif -	gtk_table_attach_defaults(GTK_TABLE(table), label, 0, 1, 2, 3); -	gtk_widget_show(label); -	gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.5); +	    break; +	} +    } -#ifdef GTK2 -	label = gtk_label_new(_("<b>Uptime:</b>")); -	gtk_label_set_use_markup(GTK_LABEL(label), TRUE); -#else -	label = gtk_label_new(_("Uptime:")); -#endif -	gtk_table_attach_defaults(GTK_TABLE(table), label, 0, 1, 3, 4); -	gtk_widget_show(label); -	gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.5); +    uname(&utsbuf); +    ci->kernel = g_strdup_printf("%s %s (%s)", utsbuf.sysname, +				 utsbuf.release, utsbuf.machine); +    ci->hostname = g_strdup(utsbuf.nodename); -	/* -	 * Table content  -	 */  -	label = gtk_label_new(info->hostname); -	gtk_table_attach_defaults(GTK_TABLE(table), label, 1, 2, 0, 1); -	gtk_widget_show(label); -	gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.5); +    computer_processor_info(ci); -	label = gtk_label_new(info->distroinfo); -	gtk_table_attach_defaults(GTK_TABLE(table), label, 1, 2, 1, 2); -	gtk_widget_show(label); -	gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.5); -	 -	label = gtk_label_new(info->kernel); -	gtk_table_attach_defaults(GTK_TABLE(table), label, 1, 2, 2, 3); -	gtk_widget_show(label); -	gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.5); +    return ci; +} -	label = gtk_label_new(_("Updating...")); -	gtk_table_attach_defaults(GTK_TABLE(table), label, 1, 2, 3, 4); -	gtk_widget_show(label); -	gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.5); -	mainwindow->uptime = label; +/* + * Code stolen from GKrellM <http://www.gkrellm.net> + * Copyright (c) 1999-2002 Bill Wilson <bill@gkrellm.net> + */ +gboolean uptime_update(gpointer data) +{ +    MainWindow *mainwindow = (MainWindow *) data; +    gchar *buf; +    gint days, hours; +    FILE *procuptime; +    gulong minutes = 0; + +    if (!mainwindow) +	return FALSE; -	uptime_update(mainwindow); -	gtk_timeout_add(30000, uptime_update, mainwindow); +#define plural(a) (a == 1) ? "" : "s" -	g_free(info); -	 -	return hbox; +    if ((procuptime = fopen("/proc/uptime", "r")) != NULL) { +	fscanf(procuptime, "%lu", &minutes); +	minutes /= 60; +	fclose(procuptime); +    } else +	return FALSE; + +    hours = minutes / 60; +    minutes %= 60; +    days = hours / 24; +    hours %= 24; + +    if (days < 1) { +	buf = g_strdup_printf(_("%d hour%s and %ld minute%s"), hours, +			      plural(hours), minutes, plural(minutes)); +    } else { +	buf = +	    g_strdup_printf(_("%d day%s, %d hour%s and %ld minute%s"), +			    days, plural(days), hours, plural(hours), +			    minutes, plural(minutes)); +    } + +    gtk_label_set_text(GTK_LABEL(mainwindow->uptime), buf); +    g_free(buf); + +    return TRUE;  } -gboolean memory_update(gpointer data) +GtkWidget *os_get_widget(MainWindow * mainwindow)  { -	MainWindow *mainwindow = (MainWindow*) data; -	MemoryInfo *mi; -	 -	if(!mainwindow) return FALSE; - -	mi = memory_get_info(); -	 -#ifdef GTK2 -	gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR(mainwindow->membar), -		mi->ratio); -#else -	gtk_progress_set_percentage(GTK_PROGRESS(mainwindow->membar), -		mi->ratio); -#endif -	 -	g_free(mi); -	 -	return TRUE; +    GtkWidget *label, *hbox; +    GtkWidget *table; +    GtkWidget *pixmap; +    gchar *buf; +    ComputerInfo *info; + +    if (!mainwindow) +	return NULL; + +    info = computer_get_info(); + +    hbox = gtk_hbox_new(FALSE, 0); +    gtk_widget_show(hbox); + +    buf = +	g_strdup_printf("%s/distro/%s.png", IMG_PREFIX, info->distrocode); +    pixmap = gtk_image_new_from_file(buf); +    gtk_widget_set_usize(GTK_WIDGET(pixmap), 64, 0); +    gtk_widget_show(pixmap); +    gtk_box_pack_start(GTK_BOX(hbox), pixmap, FALSE, FALSE, 0); +    g_free(buf); + +    table = gtk_table_new(4, 2, FALSE); +    gtk_widget_show(table); +    gtk_box_pack_start(GTK_BOX(hbox), table, TRUE, TRUE, 0); +    gtk_container_set_border_width(GTK_CONTAINER(table), 10); +    gtk_table_set_row_spacings(GTK_TABLE(table), 4); +    gtk_table_set_col_spacings(GTK_TABLE(table), 4); + +    /* +     * Table headers +     */ +    label = gtk_label_new(_("<b>Computer name:</b>")); +    gtk_label_set_use_markup(GTK_LABEL(label), TRUE); +    gtk_table_attach_defaults(GTK_TABLE(table), label, 0, 1, 0, 1); +    gtk_widget_show(label); +    gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.5); + +    label = gtk_label_new(_("<b>Distribution:</b>")); +    gtk_label_set_use_markup(GTK_LABEL(label), TRUE); +    gtk_table_attach_defaults(GTK_TABLE(table), label, 0, 1, 1, 2); +    gtk_widget_show(label); +    gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.5); + +    label = gtk_label_new(_("<b>Kernel:</b>")); +    gtk_label_set_use_markup(GTK_LABEL(label), TRUE); +    gtk_table_attach_defaults(GTK_TABLE(table), label, 0, 1, 2, 3); +    gtk_widget_show(label); +    gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.5); + +    label = gtk_label_new(_("<b>Uptime:</b>")); +    gtk_label_set_use_markup(GTK_LABEL(label), TRUE); +    gtk_table_attach_defaults(GTK_TABLE(table), label, 0, 1, 3, 4); +    gtk_widget_show(label); +    gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.5); + + +    /* +     * Table content  +     */ +    label = gtk_label_new(info->hostname); +    gtk_table_attach_defaults(GTK_TABLE(table), label, 1, 2, 0, 1); +    gtk_widget_show(label); +    gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.5); + +    label = gtk_label_new(info->distroinfo); +    gtk_table_attach_defaults(GTK_TABLE(table), label, 1, 2, 1, 2); +    gtk_widget_show(label); +    gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.5); + +    label = gtk_label_new(info->kernel); +    gtk_table_attach_defaults(GTK_TABLE(table), label, 1, 2, 2, 3); +    gtk_widget_show(label); +    gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.5); + +    label = gtk_label_new(_("Updating...")); +    gtk_table_attach_defaults(GTK_TABLE(table), label, 1, 2, 3, 4); +    gtk_widget_show(label); +    gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.5); +    mainwindow->uptime = label; + +    uptime_update(mainwindow); +    gtk_timeout_add(30000, uptime_update, mainwindow); + +    g_free(info); + +    return hbox;  } -GtkWidget *memory_get_widget(MainWindow *mainwindow) +gboolean memory_update(gpointer data)  { -	GtkWidget *label, *vbox, *hbox, *hbox2, *progress; -#ifdef GTK2 -	GtkWidget *pixmap; -#endif -	MemoryInfo *mi; -	gchar *buf; -		 -	mi = memory_get_info(); -		 -	hbox = gtk_hbox_new(FALSE, 0); -	gtk_widget_show(hbox); - -#ifdef GTK2	 -	buf = g_strdup_printf("%s/mem.png", IMG_PREFIX); -	pixmap = gtk_image_new_from_file(buf); -	gtk_widget_set_usize(GTK_WIDGET(pixmap), 64, 0); -	gtk_widget_show(pixmap); -	gtk_box_pack_start(GTK_BOX(hbox), pixmap, FALSE, FALSE, 0); -	g_free(buf); -#endif +    MainWindow *mainwindow = (MainWindow *) data; +    MemoryInfo *mi; -	vbox = gtk_vbox_new(FALSE, 0); -	gtk_widget_show(vbox); -	gtk_box_pack_start(GTK_BOX(hbox), vbox, TRUE, TRUE, 0); -	gtk_container_set_border_width(GTK_CONTAINER(vbox), 10); -	gtk_box_set_spacing(GTK_BOX(vbox), 4); +    if (!mainwindow) +	return FALSE; -	hbox2 = gtk_hbox_new(FALSE, 5); -	gtk_widget_show(hbox2); -	gtk_box_pack_start(GTK_BOX(vbox), hbox2, TRUE, TRUE, 0); +    mi = memory_get_info(); -	label = gtk_label_new("0MB"); -	gtk_widget_show(label); -	gtk_box_pack_start(GTK_BOX(hbox2), label, FALSE, FALSE, 0); -	gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.5); +    gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR(mainwindow->membar), +				  mi->ratio); -	buf = g_strdup_printf("%dMB", mi->total); -	label = gtk_label_new(buf); -	gtk_widget_show(label); -	gtk_box_pack_end(GTK_BOX(hbox2), label, FALSE, FALSE, 0); -	gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.5); -	g_free(buf); - -	progress = gtk_progress_bar_new(); -	mainwindow->membar = progress; -	gtk_widget_show(progress); -	gtk_box_pack_start(GTK_BOX(vbox), progress, TRUE, TRUE, 0); - -	memory_update(mainwindow); +    g_free(mi); -	gtk_timeout_add(2000, memory_update, mainwindow); +    return TRUE; +} -	g_free(mi);	 -	return hbox; +GtkWidget *memory_get_widget(MainWindow * mainwindow) +{ +    GtkWidget *label, *vbox, *hbox, *hbox2, *progress; +    GtkWidget *pixmap; +    MemoryInfo *mi; +    gchar *buf; + +    mi = memory_get_info(); + +    hbox = gtk_hbox_new(FALSE, 0); +    gtk_widget_show(hbox); + +    buf = g_strdup_printf("%s/mem.png", IMG_PREFIX); +    pixmap = gtk_image_new_from_file(buf); +    gtk_widget_set_usize(GTK_WIDGET(pixmap), 64, 0); +    gtk_widget_show(pixmap); +    gtk_box_pack_start(GTK_BOX(hbox), pixmap, FALSE, FALSE, 0); +    g_free(buf); + +    vbox = gtk_vbox_new(FALSE, 0); +    gtk_widget_show(vbox); +    gtk_box_pack_start(GTK_BOX(hbox), vbox, TRUE, TRUE, 0); +    gtk_container_set_border_width(GTK_CONTAINER(vbox), 10); +    gtk_box_set_spacing(GTK_BOX(vbox), 4); + +    hbox2 = gtk_hbox_new(FALSE, 5); +    gtk_widget_show(hbox2); +    gtk_box_pack_start(GTK_BOX(vbox), hbox2, TRUE, TRUE, 0); + +    label = gtk_label_new("0MB"); +    gtk_widget_show(label); +    gtk_box_pack_start(GTK_BOX(hbox2), label, FALSE, FALSE, 0); +    gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.5); + +    buf = g_strdup_printf("%dMB", mi->total); +    label = gtk_label_new(buf); +    gtk_widget_show(label); +    gtk_box_pack_end(GTK_BOX(hbox2), label, FALSE, FALSE, 0); +    gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.5); +    g_free(buf); + +    progress = gtk_progress_bar_new(); +    mainwindow->membar = progress; +    gtk_widget_show(progress); +    gtk_box_pack_start(GTK_BOX(vbox), progress, TRUE, TRUE, 0); + +    memory_update(mainwindow); + +    gtk_timeout_add(2000, memory_update, mainwindow); + +    g_free(mi); +    return hbox;  }  GtkWidget *processor_get_widget(void)  { -	GtkWidget *label, *vbox, *hbox; -#ifdef GTK2 -	GtkWidget *pixmap; -#endif -	ComputerInfo *info; -	gchar *buf; -		 -	info = computer_get_info(); -	 -	hbox = gtk_hbox_new(FALSE, 0); -	gtk_widget_show(hbox); - -#ifdef GTK2	 -	buf = g_strdup_printf("%s/cpu.png", IMG_PREFIX); -	pixmap = gtk_image_new_from_file(buf); -	gtk_widget_set_usize(GTK_WIDGET(pixmap), 64, 0); -	gtk_widget_show(pixmap); -	gtk_box_pack_start(GTK_BOX(hbox), pixmap, FALSE, FALSE, 0); -	g_free(buf); -#endif - -	vbox = gtk_vbox_new(FALSE, 0); -	gtk_widget_show(vbox); -	gtk_box_pack_start(GTK_BOX(hbox), vbox, FALSE, FALSE, 0); -	gtk_container_set_border_width(GTK_CONTAINER(vbox), 10); -	gtk_box_set_spacing(GTK_BOX(vbox), 4); - -#ifdef GTK2 -	buf = g_strdup_printf(_("<b>%s</b> at %d MHz (%d bogomips)"), info->processor, -		info->frequency, info->bogomips); -#else -	buf = g_strdup_printf(_("%s at %d MHz (%d bogomips)"), info->processor, -		info->frequency, info->bogomips); -#endif -	label = gtk_label_new(buf); -	gtk_widget_show(label); -#ifdef GTK2 -	gtk_label_set_use_markup(GTK_LABEL(label), TRUE); -#endif -	gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0); -	gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.5); -	g_free(buf); +    GtkWidget *label, *vbox, *hbox; +    GtkWidget *pixmap; +    ComputerInfo *info; +    gchar *buf; + +    info = computer_get_info(); + +    hbox = gtk_hbox_new(FALSE, 0); +    gtk_widget_show(hbox); + +    buf = g_strdup_printf("%s/cpu.png", IMG_PREFIX); +    pixmap = gtk_image_new_from_file(buf); +    gtk_widget_set_usize(GTK_WIDGET(pixmap), 64, 0); +    gtk_widget_show(pixmap); +    gtk_box_pack_start(GTK_BOX(hbox), pixmap, FALSE, FALSE, 0); +    g_free(buf); + +    vbox = gtk_vbox_new(FALSE, 0); +    gtk_widget_show(vbox); +    gtk_box_pack_start(GTK_BOX(hbox), vbox, FALSE, FALSE, 0); +    gtk_container_set_border_width(GTK_CONTAINER(vbox), 10); +    gtk_box_set_spacing(GTK_BOX(vbox), 4); + +    buf = g_strdup_printf(_("<b>%s</b> at %d MHz"), +			  info->processor, info->frequency); + +    label = gtk_label_new(buf); +    gtk_widget_show(label); +    gtk_label_set_use_markup(GTK_LABEL(label), TRUE); +    gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0); +    gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.5); +    g_free(buf);  #ifdef ARCH_i386 -	buf = g_strdup_printf(_("Family %d, model %d, stepping %d"), -		info->family, info->model, info->stepping); -	label = gtk_label_new(buf); -	gtk_widget_show(label); -	gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0); -	gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.5); -	g_free(buf); +    buf = g_strdup_printf(_("Family %d, model %d, stepping %d"), +			  info->family, info->model, info->stepping); +    label = gtk_label_new(buf); +    gtk_widget_show(label); +    gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0); +    gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.5); +    g_free(buf);  #endif +    if (info->cachel2) {  	buf = g_strdup_printf(_("%d KB L2 cache"), info->cachel2);  	label = gtk_label_new(buf);  	gtk_widget_show(label); +  	gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0);  	gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.5);  	g_free(buf); +    } -	g_free(info); -	return hbox; +    g_free(info); +    return hbox;  } - @@ -7,6 +7,7 @@  typedef struct _ComputerInfo ComputerInfo;  typedef struct _MemoryInfo   MemoryInfo; +typedef struct _ComputerInfo CPUDevice;  struct _MemoryInfo {  	gint total; @@ -26,6 +27,8 @@ struct _ComputerInfo {  	gint  procno;  	gchar *processor; +	gchar *flags; +	gchar *machine;  	gint  frequency;  	gint  family, model, stepping;  	gint  cachel2; @@ -42,4 +45,6 @@ GtkWidget *processor_get_widget(void);  gboolean uptime_update(gpointer data);  gboolean memory_update(gpointer data); +void hi_show_cpu_info(MainWindow *mainwindow, ComputerInfo *ci); +  #endif diff --git a/config.h b/config.h new file mode 100644 index 00000000..1fd2d479 --- /dev/null +++ b/config.h @@ -0,0 +1,14 @@ +#ifndef __CONFIG_H__ +#define __CONFIG_H__ + +#define VERSION "0.3.7pre" +#define USE_LSPCI +#define LSPCI "/usr/bin/lspci -v" +#define GTK2 +#define ENABLE_NLS +#define ARCH_i386 +#define PLATFORM "Linux" +#define KERNEL   "2.6.8-2-686" +#define HOSTNAME "alface" + +#endif	/* __CONFIG_H__ */ @@ -1,7 +1,7 @@  #!/usr/bin/env bash  # -# ToscoConf 0.02 -# Copyright (c) 2003 Leandro Pereira <leandro@linuxmag.com.br> +# ToscoConf 0.04 +# Copyright (c) 2003-2004 Leandro Pereira <leandro@linuxmag.com.br>  # All rights reserved.  #  # This script is in the Tosco Public License. It may be copied and/or @@ -21,35 +21,32 @@  # ---------------------------------------------------------------------------  # Some defaults -IGNORE_GTK2=0  DISABLE_NLS=0 +IGNORE_LSPCI=0  # ---------------------------------------------------------------------------  PACKAGE=`basename ${PWD} | cut -d"-" -f1`;  VERSION=`basename ${PWD} | cut -d"-" -f2`; -echo "ToscoConf (version 0.03) for $PACKAGE version $VERSION" +echo "ToscoConf (version 0.04) for $PACKAGE version $VERSION"  # ---------------------------------------------------------------------------  # Damn-cool command line argument parsing. Yay.  while [ "$1" != "" ]; do  	case $1 in -		--with-gtk1) -			echo "Building with GTK+ 1.2" -			IGNORE_GTK2=1;; -		--with-gtk2) -			echo "Building with GTK+ 2.0" -			IGNORE_GTK2=0;; +		--disable-lspci) +			echo "Disabling lspci" +			IGNORE_LSPCI=1;;  		--disable-nls)  			echo "NLS disabled."  			DISABLE_NLS=1 ;;  		--help) +			echo ""  			echo " --disable-nls		Don't use i18n." -			echo "Interface (default is auto-test):" -			echo " --with-gtk1		Build with GTK1.2 interface." -			echo " --with-gtk2		Build with GTK2.0 interface." +			echo " --disable-lspci		Disable lspci." +			echo ""  			echo " --help			This help screen."  			exit 1;; @@ -82,9 +79,23 @@ case $PROC in  		ARCH="ARCH_PPC" ;;  	x86_64)  		ARCH="ARCH_x86_64" ;; +	mips) +		ARCH="ARCH_MIPS" ;; +	parisc*) +		ARCH="ARCH_PARISC" ;; +	ia64) +		ARCH="ARCH_IA64" ;;  	*) -		echo "Architeture \"$ARCH\" not supported."  -		exit ;; +		# uname -m on m68k doesn't return anything useful :/ +		cat /proc/cpuinfo | grep "680?0" >/dev/null +		if [ "$?" == "0" ]; then +			ARCH="ARCH_m68k" +		else +			echo "Architeture \"$ARCH\" not supported."  +			exit +		fi + +		;;  esac  echo "$PROC ($ARCH)" @@ -113,66 +124,38 @@ else  	fi  fi +if [ "$IGNORE_LSPCI" -eq 1 ]; then +	echo "Ignoring lspci (as requested)..." +	LSPCI="" +	USE_LSPCI=0 +fi +  # ---------------------------------------------------------------------------  GTK2=-1 -if [ "$IGNORE_GTK2" == "0" ]; then -	MIN_VERSION="2.0.0" -	echo -n "Checking for GTK ${MIN_VERSION}... " -	for i in `which pkg-config`; do -		pkg-config --errors-to-stdout gtk+-2.0 \ -			--atleast-version=$MIN_VERSION > /dev/null -		case $? in -			0) -				GTK_FLAGS=`pkg-config gtk+-2.0 --cflags` -				GTK_LIBS=`pkg-config gtk+-2.0 --libs` -				echo "seems ok, will not test though." -				GTK2=1 ;; -			*) -				echo "not found." ;; -		esac -	done -fi +MIN_VERSION="2.2.0" +echo -n "Checking for GTK ${MIN_VERSION}... " +for i in `which pkg-config`; do +	pkg-config --errors-to-stdout gtk+-2.0 \ +		--atleast-version=$MIN_VERSION > /dev/null +	case $? in +		0) +			GTK_FLAGS=`pkg-config gtk+-2.0 --cflags` +			GTK_LIBS=`pkg-config gtk+-2.0 --libs` +			echo "OK (pkgconfig)" +			GTK2=1 ;; +		*) +			echo "not found." ;; +	esac +done  # If the user doesn't have GTK2, try to compile with GTK1.2 :) - -GTK1=-1 -if [ "$GTK2" -ne 1 ]; then -	min_major=1 -	min_minor=2 -	min_rev=6 -	echo -n "Checking for GTK $min_major.$min_minor.$min_rev... " -	for i in `which gtk-config`; do -		VER=`gtk-config --version` - -		# RegExp stolen from AutoConf. -		major=`echo $VER | sed 's/\([0-9]*\).\([0-9]*\).\([0-9]*\)/\1/'` -		minor=`echo $VER | sed 's/\([0-9]*\).\([0-9]*\).\([0-9]*\)/\2/'` -		rev=`echo $VER | sed 's/\([0-9]*\).\([0-9]*\).\([0-9]*\)/\3/'` -		 -		if [ $major -lt $min_major ]; then -			break;			 -		fi - -		if [ $minor -lt $min_minor ]; then -			break;			 -		fi - -		if [ $rev -lt $min_rev ]; then -			break;			 -		fi - -		GTK_FLAGS=`gtk-config --cflags` -		GTK_LIBS=`gtk-config --libs` -		echo "seems ok, will not test though." -		GTK1=1  -	done -fi +# GTK 1.2 is no longer supported  # -------------------------------------------------------------------------- -if [ `expr $GTK1 + $GTK2` -eq -2 ]; then +if [ $GTK2 -eq -1 ]; then  	echo -e "\nYou need the GTK libraries, including the development stuff."  	echo "If you're using Debian, running the command as root:"  	echo -e "\n\tapt-get install libgtk2.0-dev\n" @@ -193,11 +176,7 @@ if [ "$LSPCI" ]; then  	echo "#define LSPCI \"$LSPCI -v\"" >> config.h  fi -if [ "$GTK2" -ne -1 ]; then -	echo "#define GTK2" >> config.h -else -	echo "#define GTK1" >> config.h -fi +echo "#define GTK2" >> config.h  if [ "$DISABLE_NLS" != "1" ]; then  	echo "#define ENABLE_NLS" >> config.h @@ -205,15 +184,15 @@ fi  echo "#define $ARCH" >> config.h +echo "#define PLATFORM \"`uname`\"" >> config.h +echo "#define KERNEL   \"`uname -r`\"" >> config.h +echo "#define HOSTNAME \"`hostname`\"" >> config.h +  echo -e "\n#endif	/* __CONFIG_H__ */" >> config.h  echo "Writing Makefile..."  rm -f Makefile -if [ "$GTK2" -ne -1 ]; then -	echo "TARGET = GTK2" > Makefile -else -	echo "TARGET = GTK1" > Makefile -fi +echo "TARGET = GTK2" > Makefile  echo "GTK_LIBS = ${GTK_LIBS}" >> Makefile  echo "GTK_CFLAGS = ${GTK_FLAGS}" >> Makefile diff --git a/configure-stamp b/configure-stamp new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/configure-stamp diff --git a/debian/changelog b/debian/changelog index 049c41bf..e56d12bd 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,9 @@ +hardinfo (0.3.7pre-1) unstable; urgency=low + +  * New upstream release. (Closes: #280694, #300114, #233033) + + -- Agney Lopes Roth Ferraz <agney@users.sourceforge.net>  Mon, 13 Jun 2005 18:34:20 -0300 +  hardinfo (0.3.6-5) unstable; urgency=high    * Add Amd64 support (closes: #253935). diff --git a/debian/control b/debian/control index 7d215ba2..ada44e65 100644 --- a/debian/control +++ b/debian/control @@ -1,9 +1,9 @@  Source: hardinfo  Section: x11  Priority: optional -Maintainer: Leandro Pereira <leandro@linuxmag.com.br> +Maintainer: Agney Lopes Roth Ferraz <agney@users.sourceforge.net>  Build-Depends: debhelper (>> 4.0.0), libgtk2.0-dev, pciutils (>=1:2.1.11-10) -Standards-Version: 3.5.8 +Standards-Version: 3.6.1.0  Package: hardinfo  Architecture: any diff --git a/debian/menu b/debian/menu index 474c06a4..4a3ff6d4 100644 --- a/debian/menu +++ b/debian/menu @@ -1,4 +1,6 @@ -?package(hardinfo):needs=X11 section=Apps/System\ -  title="System Information" command="/usr/bin/hardinfo" \ -  icon=/usr/share/hardinfo/pixmaps/logo.png +?package(hardinfo): \ +needs="X11" \ +section="Apps/System" \ +title="System Information" command="/usr/bin/hardinfo" \ +icon="/usr/share/hardinfo/pixmaps/logo.xpm" diff --git a/default.lang b/default.lang new file mode 100644 index 00000000..8c525152 --- /dev/null +++ b/default.lang @@ -0,0 +1,148 @@ +[Translation] +translated-by=Unknown + +[about.c] + +[computer.c] +Number=Number +Frequency=Frequency +Family=Family +Model=Model +Stepping=Stepping +Cache L2=Cache L2 +Bogomips=Bogomips +Features=Features +Unknown distribution=Unknown distribution +%d hour%s and %ld minute%s=%d hour%s and %ld minute%s +%d day%s, %d hour%s and %ld minute%s=%d day%s, %d hour%s and %ld minute%s +<b>Computer name:</b>=<b>Computer name:</b> +<b>Distribution:</b>=<b>Distribution:</b> +<b>Kernel:</b>=<b>Kernel:</b> +<b>Uptime:</b>=<b>Uptime:</b> +Updating...=Updating... +<b>%s</b> at %d MHz=<b>%s</b> at %d MHz +Family %d, model %d, stepping %d=Family %d, model %d, stepping %d +%d KB L2 cache=%d KB L2 cache + +[details.c] +Information=Information +No device selected.=No device selected. + +[hardinfo.c] +System information tool for GNU/Linux.\n=System information tool for GNU/Linux.\n +System Information=System Information +Computer=Computer +<b><big>Operating System</big></b>=<b><big>Operating System</big></b> +<b><big>Processor</big></b>=<b><big>Processor</big></b> +<b><big>Memory Usage</big></b>=<b><big>Memory Usage</big></b> +Details=Details +Environment=Environment +<b><big>X-Window System</big></b>=<b><big>X-Window System</big></b> +Network=Network +<b><big>Interfaces</big></b>=<b><big>Interfaces</big></b> +Scanning Devices=Scanning Devices +Scanning devices...=Scanning devices... +Scanning %s devices...=Scanning %s devices... +Processor=Processor +PCI Devices=PCI Devices +ISA PnP Devices=ISA PnP Devices +ATA/IDE Block Devices=ATA/IDE Block Devices +SCSI Devices=SCSI Devices +Video for Linux=Video for Linux +Communication Ports=Communication Ports +Parallel Ports=Parallel Ports +Kernel Modules=Kernel Modules +for more information.\n\n=for more information.\n\n + +[ide.c] +ATA/IDE %s Device=ATA/IDE %s Device +Cache (kb)=Cache (kb) +Physical geometry=Physical geometry +Logical geometry=Logical geometry + +[intl.c] + +[isapnp.c] +ISA Plug and Play Device=ISA Plug and Play Device +Card ID=Card ID +PnP version=PnP version +Product version=Product version + +[modules.c] +Author=Author +License=License +Depends on=Depends on + +[net.c] + +[parport.c] +N/A=N/A +Parallel Port=Parallel Port +Description=Description +Command set=Command set +Base I/O address=Base I/O address +Modes=Modes +Uses DMA=Uses DMA +Yes=Yes +No=No + +[pci.c] +0x%x to 0x%x=0x%x to 0x%x +I/O Address=I/O Address +%d%s=%d%s +Memory=Memory +%dMHz=%dMHz +Frequency=Frequency +Latency=Latency +Bus master=Bus master +Yes=Yes +No=No +Domain=Domain +Bus=Bus +Device=Device +Function=Function + +[scsi.c] +SCSI %s Device=SCSI %s Device +Revision=Revision +Type=Type +Controller=Controller +Channel=Channel +ID=ID +LUN=LUN + +[serial.c] +Serial Port (tty%d)=Serial Port (tty%d) +Communication Port=Communication Port +Communication Port=Communication Port +I/O port=I/O port +IRQ=IRQ + +[status.c] + +[stock.c] + +[usb.c] +USB Devices=USB Devices +Unknown device (%s)=Unknown device (%s) +USB Device=USB Device +Class=Class +Version=Version +Revision=Revision +Vendor ID=Vendor ID +Product ID=Product ID + +[v4l.c] +Device Information=Device Information +Type=Type + +[x11.c] +Local display (%s)=Local display (%s) +Remote display (%s)=Remote display (%s) +XFree86 version %s (protocol version %d.%d)=XFree86 version %s (protocol version %d.%d) +%d (protocol version %d.%d)=%d (protocol version %d.%d) +<b>Display:</b>=<b>Display:</b> +<b>Vendor:</b>=<b>Vendor:</b> +<b>Release:</b>=<b>Release:</b> +<b>Resolution:</b>=<b>Resolution:</b> + diff --git a/details.c b/details.c new file mode 100644 index 00000000..7c624366 --- /dev/null +++ b/details.c @@ -0,0 +1,282 @@ +/* + * Hardware Information, version 0.3.2 + * Copyright (C) 2003 Leandro Pereira <leandro@linuxmag.com.br> + * + * May be modified and/or distributed under the terms of GNU GPL version 2. + * + */ + +#include "details.h" +#include "hardinfo.h" + +gboolean +detail_window_close(GtkWidget *widget, gpointer data) +{ +	DetailWindow *dw = (DetailWindow *) data; +	 +	gtk_widget_destroy(dw->window); +	 +	return FALSE; +} + +void +detail_window_set_title(DetailWindow *dw, const gchar *title) +{ +	if (!dw) return; +	 +	gtk_window_set_title(GTK_WINDOW(dw->window), title); +} + +void +detail_window_update_names(DetailWindow *dw) +{ +	gchar *buf; +	 +	if (dw->device_name && strstr(dw->device_name, "&")) { +		gchar *temp, *temp2; +		 +		temp = (gchar *) malloc (strlen (dw->device_name) * 2); +		 +		temp2 = temp; +		 +		while (*(dw->device_name)) { +			if (*(dw->device_name) == '&') { +				*(temp++) = '&'; +				*(temp++) = 'a'; +				*(temp++) = 'm'; +				*(temp++) = 'p'; +				*(temp++) = ';'; +			} else { +				*(temp++) = *(dw->device_name); +			} +			dw->device_name++; +		} +		 +		*(temp++) = 0; +		 +		temp = temp2; +		 +		g_free(dw->device_name); +		dw->device_name = g_strdup(temp); +		 +		g_free(temp); +	} +	 +	if (!dw->device_type) +		dw->device_type = ""; +	 +	buf = g_strdup_printf("<big><b>%s</b></big>\n%s", +			      dw->device_name, dw->device_type); + +	gtk_label_set_markup(GTK_LABEL(dw->name_label), buf); +	 +	g_free(buf); +} + +void  +detail_window_append_separator(DetailWindow *dw) +{ +	GtkWidget *sep; +	 +	sep = gtk_hseparator_new(); +	gtk_widget_show(sep); + +	gtk_table_attach_defaults(GTK_TABLE(dw->info_table), sep, 0, 2, dw->last_info, +		                  dw->last_info + 1); +	 +	dw->last_info++;	 +} + +void +detail_window_set_dev_type(DetailWindow *dw, const gchar *type) +{ +	dw->device_type = g_strdup(type); +	 +	detail_window_update_names(dw); +} + +void +detail_window_set_dev_name(DetailWindow *dw, const gchar *name) +{ +	dw->device_name = g_strdup(name); +	 +	detail_window_update_names(dw); +} + +void +detail_window_append_info_int(DetailWindow *dw, const gchar *name, gint val, +			      gboolean hex) +{ +	gchar *buf; +	 +	buf = g_strdup_printf(hex ? "0x%X" : "%d", val); +	detail_window_append_info(dw, name, buf); +	g_free(buf); +} + +void +detail_window_append_info(DetailWindow *dw, const gchar *name, gchar *val) +{ +	GtkWidget *label; +	gchar *buf; +	 +	if (dw->last_info == 0)  +		dw->last_info = 1; + +	buf = g_strdup_printf("<b>%s:</b>", name); +	label = gtk_label_new(buf); +	gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.5); +	gtk_label_set_use_markup(GTK_LABEL(label), TRUE); +	gtk_widget_show(label); +	gtk_table_attach_defaults(GTK_TABLE(dw->info_table), label, 0, 1, dw->last_info, +		                  dw->last_info + 1); +	g_free(buf); + +	label = gtk_label_new(val); +	gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.5); +	gtk_widget_show(label); +	gtk_label_set_line_wrap(GTK_LABEL(label), TRUE); +	gtk_label_set_selectable(GTK_LABEL(label), TRUE); +	gtk_table_attach(GTK_TABLE(dw->info_table), label, 1, 2, dw->last_info, +			 dw->last_info + 1, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0); +				   +	dw->last_info++;				   +		 +} + +static gboolean +notebook_hide_tabs(GtkWidget *widget, gpointer data) +{ +	if (gtk_notebook_get_n_pages(GTK_NOTEBOOK(widget)) == 1) { +		gtk_notebook_set_show_tabs(GTK_NOTEBOOK(widget), FALSE); +		gtk_notebook_set_show_border(GTK_NOTEBOOK(widget), FALSE); +	} else { +		gtk_notebook_set_show_tabs(GTK_NOTEBOOK(widget), TRUE); +		gtk_notebook_set_show_border(GTK_NOTEBOOK(widget), TRUE); +	} +	 +	return FALSE; +} + +void  +detail_window_set_icon(DetailWindow *dw, const gchar *path) +{ +	if (!dw || !dw->icon) return; + +	gtk_image_set_from_file(GTK_IMAGE(dw->icon), path); +} + +DetailWindow * +detail_window_new(void) +{ +	DetailWindow *dw; +	GtkWidget *window, *vbox, *btn, *hbbox, *notebook, *table, +		  *label, *info_table; +	GtkWidget *icon, *vb, *hb; +	 +	dw = g_new0(DetailWindow, 1); +	 +	window = gtk_window_new(GTK_WINDOW_TOPLEVEL); +	gtk_container_set_border_width(GTK_CONTAINER(window), 5); +	gtk_window_set_title(GTK_WINDOW(window), "Hardware Details"); +	gtk_window_set_type_hint(GTK_WINDOW(window), GDK_WINDOW_TYPE_HINT_UTILITY); +	gtk_window_set_resizable(GTK_WINDOW(window), FALSE); +	gtk_widget_realize(window); +	 +	dw->window = window; +		 +	vbox = gtk_vbox_new(FALSE, 0); +	gtk_widget_show(vbox); +	gtk_container_add(GTK_CONTAINER(window), vbox); +	 +	dw->vbox = vbox; + +	notebook = gtk_notebook_new(); +	gtk_widget_show(notebook); +	gtk_box_pack_start(GTK_BOX(vbox), notebook, TRUE, TRUE, 0); +	gtk_notebook_set_show_tabs(GTK_NOTEBOOK(notebook), FALSE); +	gtk_notebook_set_show_border(GTK_NOTEBOOK(notebook), FALSE); +	dw->notebook = notebook; + +	g_signal_connect(G_OBJECT(notebook), "expose-event", +			 G_CALLBACK(notebook_hide_tabs), notebook); + +	table = gtk_table_new(1, 2, FALSE); +	gtk_container_set_border_width(GTK_CONTAINER(table), 8); +	gtk_table_set_row_spacings(GTK_TABLE(table), 4); +	gtk_table_set_col_spacings(GTK_TABLE(table), 16); +	gtk_widget_show(table); +		 +	label = gtk_label_new(_("Information")); +	gtk_widget_show(label); +	gtk_notebook_append_page(GTK_NOTEBOOK(notebook), table,  +				 label); + +	hb = gtk_hbox_new(FALSE, 5); +	gtk_widget_show(hb); +	gtk_table_attach_defaults(GTK_TABLE(table), hb, 0, 1, 0, 1); + +	icon = gtk_image_new(); +	gtk_misc_set_alignment(GTK_MISC(icon), 0.5, 0.0); +	gtk_widget_show(icon); +	dw->icon = icon; + +	gtk_table_attach_defaults(GTK_TABLE(table), icon, 0, 1, 0, 1); + +	vb = gtk_vbox_new(FALSE, 5); +	gtk_widget_show(vb); +	gtk_box_pack_start(GTK_BOX(hb), vb, TRUE, TRUE, 0); + +	label = gtk_label_new(_("No device selected.")); +	gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.5); +	gtk_label_set_use_markup(GTK_LABEL(label), TRUE); +	gtk_widget_show(label); +	gtk_table_attach(GTK_TABLE(table), label, 1, 2, 0, 1, +			 GTK_FILL | GTK_EXPAND, 0, 0, 0); +	dw->name_label = label;	 +	 +	info_table = gtk_table_new(0, 0, FALSE); +	gtk_widget_show(info_table); +	gtk_table_attach(GTK_TABLE(table), info_table, 1, 2, 2, 3, +			 GTK_EXPAND | GTK_FILL, 0, 0, 0); +	gtk_table_set_col_spacings(GTK_TABLE(info_table), 4); +	gtk_table_set_row_spacings(GTK_TABLE(info_table), 2); +	dw->info_table = info_table; +	 +	hbbox = gtk_hbutton_box_new(); +	gtk_container_set_border_width(GTK_CONTAINER(hbbox), 4); +	gtk_widget_show(hbbox); +	gtk_box_pack_start(GTK_BOX(vbox), hbbox, FALSE, FALSE, 0); +	gtk_button_box_set_spacing(GTK_BUTTON_BOX(hbbox), 6); +	gtk_button_box_set_layout(GTK_BUTTON_BOX(hbbox), GTK_BUTTONBOX_END); + +	btn = gtk_button_new_from_stock(GTK_STOCK_CLOSE); +	g_signal_connect(G_OBJECT(btn), "clicked", G_CALLBACK(detail_window_close), dw); +	gtk_widget_show(btn); +	gtk_box_pack_end(GTK_BOX(hbbox), btn, FALSE, FALSE, 0); + +	detail_window_set_icon(dw, IMG_PREFIX "logo.png"); + +	return dw; +} + +void +detail_window_show(GtkWidget *widget, gpointer data) +{ +	MainWindow *mainwindow = (MainWindow *) data; +	GenericDevice *dev; +	 +	mainwindow->det_window = detail_window_new(); + +	dev = (GenericDevice *) gtk_ctree_node_get_row_data +	    (GTK_CTREE(mainwindow->ctree), GTK_CLIST(mainwindow->ctree)-> +	     selection->data); + +	hi_show_device_info_real(mainwindow, dev); + +	gtk_window_set_modal(GTK_WINDOW(mainwindow->det_window->window), TRUE);	 +	gtk_window_set_position(GTK_WINDOW(mainwindow->det_window->window), GTK_WIN_POS_CENTER_ON_PARENT); +	gtk_window_set_transient_for(GTK_WINDOW(mainwindow->det_window->window), +				     GTK_WINDOW(mainwindow->window)); +	gtk_widget_show(mainwindow->det_window->window); +} diff --git a/details.h b/details.h new file mode 100644 index 00000000..e7512173 --- /dev/null +++ b/details.h @@ -0,0 +1,40 @@ +#ifndef __DETAILS_H__ +#define __DETAILS_H__ + +#include <gtk/gtk.h> +#include "config.h" + +typedef struct _DetailWindow	DetailWindow; + +struct _DetailWindow { +	GtkWidget *window; +	GtkWidget *vbox; +	GtkWidget *notebook; +	GtkWidget *icon; +	GtkWidget *name_label; + +	gchar *device_name; +	gchar *device_type; +	gchar *manufacturer; +	 +	GtkWidget *info_table; +	gint   last_info; +}; + +gboolean      detail_window_close(GtkWidget *widget, gpointer data); +DetailWindow *detail_window_new(void); +void	      detail_window_set_icon(DetailWindow *dw, const gchar *path); +void          detail_window_show(GtkWidget *widget, gpointer data); + +void          detail_window_set_dev_name(DetailWindow *dw, const gchar *name); +void          detail_window_set_dev_type(DetailWindow *dw, const gchar *type); +void          detail_window_update_names(DetailWindow *dw); + +void          detail_window_append_info(DetailWindow *dw, const gchar *name, +					gchar *val); +void          detail_window_append_info_int(DetailWindow *dw, const gchar *name, +					    gint val, gboolean hex); +void          detail_window_append_separator(DetailWindow *dw); +                               + +#endif @@ -17,15 +17,18 @@  #include "pixmaps/hdd.xpm"  #include "pixmaps/gen_connector.xpm"  #include "pixmaps/scsi.xpm" +#include "pixmaps/processor.xpm"  #include "computer.h"  #include "status.h" +#include "stock.h"  GenericDevice *generic_devices = NULL; -void hi_show_device_info(GtkCTree * tree, GList * node, +void hi_enable_details_button(GtkCTree * tree, GList * node,  			 gint column, gpointer user_data); -void hi_hide_device_info(GtkCTree * tree, GList * node, +void hi_enable_details_button_real(MainWindow *mainwindow, GenericDevice *dev); +void hi_disable_details_button(GtkCTree * tree, GList * node,  			 gint column, gpointer user_data);  void hi_scan_all(MainWindow * mainwindow); @@ -37,7 +40,7 @@ main_window_refresh(GtkWidget * widget, gpointer data)  	if (!mainwindow)  		return; -	hi_hide_device_info(NULL, NULL, 0, mainwindow); +	hi_disable_details_button(NULL, NULL, 0, mainwindow);  	memory_update(mainwindow);  	uptime_update(mainwindow); @@ -50,18 +53,21 @@ static void  about_window_create(void)  {  	GtkAbout *about; +	const gchar *sysinfo = HOSTNAME " (" PLATFORM KERNEL ")";  	const gchar *authors[] = {  		">Written by:", -			"Leandro Pereira (leandro@linuxmag.com.br)", +		"Leandro A. F. Pereira (leandro@linuxmag.com.br)",  		">Disclaimer:", -			"This is free software; you can modify and/or distribute it", -			"under the terms of GNU GPL version 2. See http://www.fsf.org/", -			"for more information.", +		"This is free software; you can modify and/or distribute it", +		"under the terms of GNU GPL version 2. See http://www.fsf.org/", +		"for more information.", +		">Compiled on:", +		sysinfo,  		NULL  	};  	about = gtk_about_new("HardInfo", VERSION, -			      _("System information tool for Linux.\n"), +			      _("System information tool for GNU/Linux.\n"),  			      authors, IMG_PREFIX "logo.png");  } @@ -69,22 +75,20 @@ about_window_create(void)  MainWindow *  main_window_create(void)  { -	GtkWidget *window, *mbox, *vbox, *frame, *ctree, *scroll; +	GtkWidget *window, *mbox, *vbox, *ctree, *scroll;  	GtkWidget *notebook, *label, *hbox, *btn, *hbbox;  	MainWindow *mainwindow;  	mainwindow = g_new0(MainWindow, 1); +	mainwindow->det_window = detail_window_new(); +  	window = gtk_window_new(GTK_WINDOW_TOPLEVEL);  	gtk_container_set_border_width(GTK_CONTAINER(window), 4);  	gtk_window_set_title(GTK_WINDOW(window), _("System Information")); -#ifdef GTK2  	g_signal_connect(G_OBJECT(window), "delete-event", gtk_main_quit, NULL); -#else -	gtk_signal_connect(GTK_OBJECT(window), "delete-event", -			   (GtkSignalFunc) gtk_main_quit, NULL); -#endif +	gtk_window_set_icon_from_file(GTK_WINDOW(window), IMG_PREFIX "logo.png", NULL);  	mbox = gtk_vbox_new(FALSE, 5);  	gtk_widget_show(mbox); @@ -102,36 +106,24 @@ main_window_create(void)  	gtk_notebook_append_page(GTK_NOTEBOOK(notebook), vbox,  				 gtk_label_new(_("Computer"))); -#ifdef GTK2  	label = gtk_label_new(_("<b><big>Operating System</big></b>"));  	gtk_label_set_use_markup(GTK_LABEL(label), TRUE); -#else -	label = gtk_label_new(_("Operating System")); -#endif  	gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.5);  	gtk_widget_show(label);  	gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0);  	gtk_box_pack_start(GTK_BOX(vbox), os_get_widget(mainwindow),  			   FALSE, FALSE, 0); -#ifdef GTK2  	label = gtk_label_new(_("<b><big>Processor</big></b>"));  	gtk_label_set_use_markup(GTK_LABEL(label), TRUE); -#else -	label = gtk_label_new(_("Processor")); -#endif  	gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.5);  	gtk_widget_show(label);  	gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0);  	gtk_box_pack_start(GTK_BOX(vbox), processor_get_widget(), FALSE,  			   FALSE, 0); -#ifdef GTK2  	label = gtk_label_new(_("<b><big>Memory Usage</big></b>"));  	gtk_label_set_use_markup(GTK_LABEL(label), TRUE); -#else -	label = gtk_label_new(_("Memory Usage")); -#endif  	gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.5);  	gtk_widget_show(label);  	gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0); @@ -145,7 +137,21 @@ main_window_create(void)  	gtk_container_set_border_width(GTK_CONTAINER(vbox), 4);  	gtk_widget_show(vbox);  	gtk_notebook_append_page(GTK_NOTEBOOK(notebook), vbox, -				 gtk_label_new(_("Devices"))); +				 gtk_label_new(_("Details"))); + +	hbbox = gtk_hbutton_box_new(); +	gtk_container_set_border_width(GTK_CONTAINER(hbbox), 4); +	gtk_widget_show(hbbox); +	gtk_box_pack_end(GTK_BOX(vbox), hbbox, FALSE, FALSE, 0); +	gtk_button_box_set_spacing(GTK_BUTTON_BOX(hbbox), 6); +	gtk_button_box_set_layout(GTK_BUTTON_BOX(hbbox), GTK_BUTTONBOX_END); + +	btn = gtk_button_new_from_stock(HI_DETAILS); +	g_signal_connect(G_OBJECT(btn), "clicked", +			 (GCallback) detail_window_show, mainwindow); +	gtk_widget_show(btn); +	gtk_box_pack_end(GTK_BOX(hbbox), btn, FALSE, FALSE, 0); +	mainwindow->details_button = btn;  	scroll = gtk_scrolled_window_new(NULL, NULL);  	gtk_box_pack_start(GTK_BOX(vbox), scroll, TRUE, TRUE, 0); @@ -162,21 +168,11 @@ main_window_create(void)  	gtk_clist_set_column_width(GTK_CLIST(ctree), 0, 32);  	gtk_clist_set_column_width(GTK_CLIST(ctree), 1, 32);  	gtk_clist_set_row_height(GTK_CLIST(ctree), 18); -#ifdef GTK2  	g_signal_connect(G_OBJECT(ctree), "tree-select-row", -			 (GCallback) hi_show_device_info, mainwindow); +			 (GCallback) hi_enable_details_button, mainwindow);  	g_signal_connect(G_OBJECT(ctree), "tree-unselect-row", -			 (GCallback) hi_hide_device_info, mainwindow); -#else -	gtk_signal_connect(GTK_OBJECT(ctree), "tree-select-row", -			   (GtkCTreeFunc) hi_show_device_info, mainwindow); -	gtk_signal_connect(GTK_OBJECT(ctree), "tree-unselect-row", -			   (GtkCTreeFunc) hi_hide_device_info, mainwindow); -#endif - -	frame = gtk_frame_new(_("Device information")); -	gtk_box_pack_start(GTK_BOX(vbox), frame, FALSE, FALSE, 0); - +			 (GCallback) hi_disable_details_button, mainwindow); +			   	/*  	 * Environment tab  	 */ @@ -186,19 +182,14 @@ main_window_create(void)  	gtk_notebook_append_page(GTK_NOTEBOOK(notebook), vbox,  				 gtk_label_new(_("Environment"))); -#ifdef GTK2  	label = gtk_label_new(_("<b><big>X-Window System</big></b>"));  	gtk_label_set_use_markup(GTK_LABEL(label), TRUE); -#else -	label = gtk_label_new(_("X-Window System")); -#endif  	gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.5);  	gtk_widget_show(label);  	gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0); -	gtk_box_pack_start(GTK_BOX(vbox), x11_get_widget(mainwindow), -			   FALSE, FALSE, 0); +//	gtk_box_pack_start(GTK_BOX(vbox), x11_get_widget(mainwindow), +//			   FALSE, FALSE, 0); -#if 0  	/*  	 * Network tab  	 */ @@ -208,23 +199,17 @@ main_window_create(void)  	gtk_notebook_append_page(GTK_NOTEBOOK(notebook), vbox,  				 gtk_label_new(_("Network"))); -#ifdef GTK2  	label = gtk_label_new(_("<b><big>Interfaces</big></b>"));  	gtk_label_set_use_markup(GTK_LABEL(label), TRUE); -#else -	label = gtk_label_new(_("Interfaces")); -#endif  	gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.5);  	gtk_widget_show(label);  	gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0);  	gtk_box_pack_start(GTK_BOX(vbox), net_get_widget(mainwindow),  			   TRUE, TRUE, 0); -#endif  	/*  	 * Buttons  	 */ -  	hbox = gtk_hbox_new(FALSE, 5);  	gtk_widget_show(hbox);  	gtk_box_pack_start(GTK_BOX(mbox), hbox, FALSE, FALSE, 0); @@ -236,14 +221,9 @@ main_window_create(void)  	gtk_button_box_set_spacing(GTK_BUTTON_BOX(hbbox), 6);  	gtk_button_box_set_layout(GTK_BUTTON_BOX(hbbox), GTK_BUTTONBOX_START); -	btn = gtk_button_new_with_mnemonic(_("Abo_ut...")); -#ifdef GTK2 +	btn = gtk_button_new_from_stock(HI_ABOUT);  	g_signal_connect(G_OBJECT(btn), "clicked",  			 (GCallback) about_window_create, NULL); -#else -	gtk_signal_connect(GTK_OBJECT(btn), "clicked", -			   (GtkSignalFunc) about_window_create, NULL); -#endif  	gtk_widget_show(btn);  	gtk_box_pack_start(GTK_BOX(hbbox), btn, FALSE, FALSE, 0); @@ -254,50 +234,21 @@ main_window_create(void)  	gtk_button_box_set_spacing(GTK_BUTTON_BOX(hbbox), 6);  	gtk_button_box_set_layout(GTK_BUTTON_BOX(hbbox), GTK_BUTTONBOX_END); -#if 0 -	btn = gtk_button_new_with_label(_("About")); -#ifdef GTK2 -	g_signal_connect(G_OBJECT(btn), "clicked", -			 (GCallback) about_window_create, NULL); -#else -	gtk_signal_connect(GTK_OBJECT(btn), "clicked", -			   (GtkSignalFunc) about_window_create, NULL); -#endif -	gtk_widget_show(btn); -	gtk_box_pack_start(GTK_BOX(hbbox), btn, FALSE, FALSE, 0); -#endif - -#ifdef GTK2  	btn = gtk_button_new_from_stock(GTK_STOCK_REFRESH);  	g_signal_connect(G_OBJECT(btn), "clicked",  			 (GCallback) main_window_refresh, mainwindow); -#else -	btn = gtk_button_new_with_label(_("Refresh")); -	gtk_signal_connect(GTK_OBJECT(btn), "clicked", -			   (GtkSignalFunc) main_window_refresh, mainwindow); -#endif  	gtk_widget_show(btn);  	gtk_box_pack_start(GTK_BOX(hbbox), btn, FALSE, FALSE, 0); -#ifdef GTK2  	btn = gtk_button_new_from_stock(GTK_STOCK_CLOSE);  	g_signal_connect(G_OBJECT(btn), "clicked", gtk_main_quit, NULL); -#else -	btn = gtk_button_new_with_label(_("Close")); -	gtk_signal_connect(GTK_OBJECT(btn), "clicked", -			   (GtkSignalFunc) gtk_main_quit, NULL); -#endif  	gtk_widget_show(btn);  	gtk_box_pack_start(GTK_BOX(hbbox), btn, FALSE, FALSE, 0); - -  	gtk_widget_show_all(window); -	gtk_widget_hide(frame);  	mainwindow->window = window;  	mainwindow->ctree = ctree; -	mainwindow->frame = frame;  	return mainwindow;  } @@ -347,7 +298,6 @@ tree_group_new(MainWindow * mainwindow, const gchar * name, DeviceType type)  	case SERIAL:  		pixmap = gdk_pixmap_colormap_create_from_xpm_d  		    (NULL, colormap, &mask, NULL, gen_connector_xpm); -  		break;  	case V4L:  	case PCI: @@ -367,6 +317,11 @@ tree_group_new(MainWindow * mainwindow, const gchar * name, DeviceType type)  		pixmap = gdk_pixmap_colormap_create_from_xpm_d  		    (NULL, colormap, &mask, NULL, usb_xpm);  		break; +	case MODULE: +	case PROCESSOR: +		pixmap = gdk_pixmap_colormap_create_from_xpm_d +		    (NULL, colormap, &mask, NULL, processor_xpm); +		break;  	default:  		mask = pixmap = NULL;  		break; @@ -422,24 +377,24 @@ hi_insert_generic(gpointer device, DeviceType type)  }  void -hi_hide_device_info(GtkCTree * tree, GList * node, +hi_disable_details_button(GtkCTree * tree, GList * node,  		    gint column, gpointer user_data)  {  	MainWindow *mainwindow = (MainWindow *) user_data; -	gtk_widget_hide(mainwindow->frame); +	gtk_widget_set_sensitive(GTK_WIDGET(mainwindow->details_button), FALSE);  } -void -hi_show_device_info(GtkCTree * tree, GList * node, +void hi_enable_details_button(GtkCTree * tree, GList * node,  		    gint column, gpointer user_data)  { -	GenericDevice *dev;  	MainWindow *mainwindow = (MainWindow *) user_data; -	dev = (GenericDevice *) gtk_ctree_node_get_row_data -	    (GTK_CTREE(tree), GTK_CLIST(tree)->selection->data); +	gtk_widget_set_sensitive(GTK_WIDGET(mainwindow->details_button), TRUE); +} +void hi_show_device_info_real(MainWindow *mainwindow, GenericDevice *dev) +{  	if (!dev)  		return; @@ -452,6 +407,10 @@ hi_show_device_info(GtkCTree * tree, GList * node,  	break;  	switch (dev->type) { +	case MODULE: +		dev_info(ModInfo,   mod, hi_show_module_info); +	case PROCESSOR: +		dev_info(CPUDevice, cpu, hi_show_cpu_info);  	case PCI:  		dev_info(PCIDevice, pci, hi_show_pci_info);  	case ISAPnP: @@ -474,25 +433,24 @@ hi_show_device_info(GtkCTree * tree, GList * node,  		return;  		break;  	} - -	gtk_widget_show(mainwindow->frame); -  }  void  hi_scan_all(MainWindow * mainwindow)  { -	myStatus *status; -	PCIDevice *pci;  -	ISADevice *isa;  -	IDEDevice *ide; -	SCSIDevice *scsi; -	V4LDevice *v4l; -	ParportDevice *pp; -	SerialDevice *sd; -	GtkCTreeNode *node; -	GenericDevice *gd = generic_devices; -	gchar *buf; +	myStatus	*status; +	PCIDevice	*pci;  +	ISADevice	*isa;  +	IDEDevice	*ide; +	CPUDevice	*cpu; +	SCSIDevice	*scsi; +	V4LDevice	*v4l; +	ParportDevice	*pp; +	SerialDevice	*sd; +	GtkCTreeNode	*node; +	ModInfo		*mod; +	GenericDevice	*gd = generic_devices; +	gchar		*buf;  	status = my_status_new(_("Scanning Devices"), _("Scanning devices...")); @@ -503,6 +461,7 @@ hi_scan_all(MainWindow * mainwindow)  		g_free(buf); \  		my_status_pulse(status) +	DEVICE_SCAN("CPU",	cpu,	computer_get_info);  	DEVICE_SCAN("PCI",	pci,	hi_scan_pci);  	DEVICE_SCAN("ISA PnP",	isa,	hi_scan_isapnp);  	DEVICE_SCAN("IDE",	ide,	hi_scan_ide); @@ -510,6 +469,7 @@ hi_scan_all(MainWindow * mainwindow)  	DEVICE_SCAN("V4L",	v4l,	hi_scan_v4l);  	DEVICE_SCAN("Parallel",	pp,	hi_scan_parport);  	DEVICE_SCAN("Serial",	sd,	hi_scan_serial); +	DEVICE_SCAN("modules",	mod,	hi_scan_modules);  	gtk_clist_freeze(GTK_CLIST(mainwindow->ctree)); @@ -539,6 +499,14 @@ hi_scan_all(MainWindow * mainwindow)  		} \  	} + +	/* +	 * Processor info +	 */ +	node = tree_group_new(mainwindow, _("Processor"), PROCESSOR); +	hi_insert_generic(cpu, PROCESSOR); +	tree_insert_item(mainwindow, node, cpu->processor, generic_devices); +  	CHECK_INSERT(pci, _("PCI Devices"), PCI, name);  	CHECK_INSERT(isa, _("ISA PnP Devices"), ISAPnP, card); @@ -553,36 +521,37 @@ hi_scan_all(MainWindow * mainwindow)  	CHECK_INSERT(v4l, _("Video for Linux"), V4L, name);  	CHECK_INSERT(sd, _("Communication Ports"), SERIAL, name);  	CHECK_INSERT(pp, _("Parallel Ports"), PARPORT, name); - +  + 	CHECK_INSERT(mod, _("Kernel Modules"), MODULE, description); + 	  	gtk_clist_thaw(GTK_CLIST(mainwindow->ctree));  	my_status_destroy(status);  } -#if 0  static void  usage(char *argv0)  { -	g_print("%s [--prefix <prefix>]\n", argv0); +	g_print("%s [--help] [--prefix <prefix>]\n", argv0);  	exit(1);  } -#endif  int  main(int argc, char **argv)  {  	MainWindow *mainwindow; -#if 0  	gint i; -#endif  #ifdef ENABLE_NLS  	intl_init();  #endif -	g_print("HardInfo " VERSION "\n"); +	g_print("HardInfo " VERSION); +	if (strstr(VERSION, "pre")) { +		g_print(" *** PRE-RELEASE ***"); +	}  	g_print -	    ("Copyright (c) 2003 Leandro Pereira <leandro@linuxmag.com.br>\n\n"); +	    ("\nCopyright (c) 2003 Leandro Pereira <leandro@linuxmag.com.br>\n\n");  	g_print(_  		("This is free software; you can modify and/or distribute it\n"));  	g_print(_ @@ -591,13 +560,8 @@ main(int argc, char **argv)  	gtk_init(&argc, &argv); -#ifndef GTK2 -	gdk_rgb_init(); -	gtk_widget_set_default_colormap(gdk_rgb_get_cmap()); -	gtk_widget_set_default_visual(gdk_rgb_get_visual()); -#endif +	hi_stock_init(); -#if 0  	for (i = 1; i < argc; i++) {  		if (!strncmp(argv[i], "--help", 6) ||  		    !strncmp(argv[i], "-h", 2)) { @@ -612,7 +576,6 @@ main(int argc, char **argv)  			g_print("prefix = %s\n", argv[i]);  		}  	} -#endif  	mainwindow = main_window_create();  	main_window_refresh(NULL, mainwindow); @@ -13,6 +13,7 @@  #include <sys/stat.h>  #include "config.h" +#include "stock.h"  #ifdef ENABLE_NLS  #define	INTL_PREFIX	PREFIX "lang/" @@ -23,13 +24,12 @@  typedef struct _GenericDevice	GenericDevice;  typedef enum   _DeviceType	DeviceType; -  typedef struct _MainWindow	MainWindow;  enum _DeviceType {  	NONE, PCI, ISAPnP, USB,  	IDE, SCSI, SERIAL, PARPORT, -	V4L +	V4L, PROCESSOR, MODULE  };  struct _GenericDevice { @@ -41,14 +41,13 @@ struct _GenericDevice {  	GenericDevice *next;  }; +#include "details.h" +  struct _MainWindow {  	GtkWidget *window;  	GtkWidget *ctree; -	GtkWidget *frame; -	GtkWidget *framec; -	  	GtkWidget *membar;  	GtkWidget *uptime; @@ -59,6 +58,9 @@ struct _MainWindow {  	GtkWidget *trans_bytes;  	GtkWidget *trans_errors;  	GtkWidget *trans_packets; +	 +	GtkWidget *details_button; +	DetailWindow *det_window;  };  extern GenericDevice *generic_devices; @@ -71,16 +73,19 @@ extern GenericDevice *generic_devices;  #include "serial.h"  #include "parport.h"  #include "v4l.h" - +#include "modules.h"  #include "x11.h"  #include "net.h"  #include "about.h" - -GtkCTreeNode *tree_group_new(MainWindow *mainwindow, const gchar *name, -        DeviceType type); -void tree_insert_item(MainWindow *mainwindow, GtkCTreeNode *group, gchar *name, -                gpointer data); -void hi_insert_generic(gpointer device, DeviceType type); +#include "details.h" + +GtkCTreeNode 	*tree_group_new(MainWindow *mainwindow, const gchar *name, +                                DeviceType type); +void 		tree_insert_item(MainWindow *mainwindow, GtkCTreeNode *group, gchar *name, +                                 gpointer data); +void	        hi_insert_generic(gpointer device, DeviceType type); +void		hi_show_device_info_real(MainWindow *mainwindow, +                                         GenericDevice *dev);  #endif @@ -1,3 +1,4 @@ +  /*   * Hardware Information, version 0.3   * Copyright (C) 2003 Leandro Pereira <leandro@linuxmag.com.br> @@ -15,7 +16,7 @@ IDEDevice *hi_scan_ide(void)  {  	FILE *proc_ide;  	gchar *device, iface; -	gint n=0, i=0; +	gint n = 0, i = 0;  	struct stat st;  	IDEDevice *ide_dev, *ide; @@ -59,9 +60,34 @@ IDEDevice *hi_scan_ide(void)  				ide_dev->cache = atoi(buf);  			}					 +			g_free(device); +			 +			device = g_strdup_printf("/proc/ide/hd%c/geometry", iface); +			if (!stat(device, &st)) { +				gchar *tmp; +				 +				proc_ide = fopen(device, "r"); +		 +				fgets(buf, 64, proc_ide);		 +				for (tmp = buf; *tmp; tmp++) { +					if (*tmp >= '0' && *tmp <= '9') break; +				} +				 +				ide_dev->phy_geometry = g_strdup(g_strstrip(tmp)); +				 +				fgets(buf, 64, proc_ide); +				for (tmp = buf; *tmp; tmp++) { +					if (*tmp >= '0' && *tmp <= '9') break; +				} +				ide_dev->log_geometry = g_strdup(g_strstrip(tmp)); + +				fclose(proc_ide); +			}					 +			g_free(device); +  			n++; -		} -		g_free(device); +		} else  +			g_free(device);  	}  	return ide; @@ -69,7 +95,6 @@ IDEDevice *hi_scan_ide(void)  void hi_show_ide_info(MainWindow *mainwindow, IDEDevice *device)  { -	GtkWidget *hbox, *vbox, *label;          static struct {                  char *type;                  char *label; @@ -80,9 +105,6 @@ void hi_show_ide_info(MainWindow *mainwindow, IDEDevice *device)          };          int i;  	gchar *buf; -#ifdef GTK2 -	GtkWidget *pixmap;	 -#endif  	if(!device) return; @@ -90,53 +112,29 @@ void hi_show_ide_info(MainWindow *mainwindow, IDEDevice *device)  		if (!strcmp(device->media, type2icon[i].type)) break;  	} -#ifdef GTK2  	buf = g_strdup_printf("%s%s", IMG_PREFIX, type2icon[i].icon); -	pixmap = gtk_image_new_from_file(buf); -	gtk_widget_show(pixmap); -	 -	g_free(buf); -#endif -	hbox = gtk_hbox_new(FALSE, 2); -	gtk_container_set_border_width(GTK_CONTAINER(hbox), 4); -	gtk_widget_show(hbox); -	 -	if(mainwindow->framec) -		gtk_widget_destroy(mainwindow->framec); - -	gtk_container_add(GTK_CONTAINER(mainwindow->frame), hbox); -	mainwindow->framec = hbox; +	detail_window_set_icon(mainwindow->det_window, buf); +	g_free(buf);	  	buf = g_strdup_printf(_("ATA/IDE %s Device"), type2icon[i].label); -	gtk_frame_set_label(GTK_FRAME(mainwindow->frame), buf); +	gtk_window_set_title(GTK_WINDOW(mainwindow->det_window->window), buf); +	detail_window_set_dev_type(mainwindow->det_window, buf);  	g_free(buf); -	 -#ifdef GTK2 -	gtk_box_pack_start(GTK_BOX(hbox), pixmap, FALSE, FALSE, 0); -#endif - -	vbox = gtk_vbox_new(FALSE, 2); -	gtk_widget_show(vbox); -	gtk_box_pack_start(GTK_BOX(hbox), vbox, TRUE, TRUE, 0); -#ifdef GTK2 -	buf = g_strdup_printf("<b>%s</b>", device->model); -	label = gtk_label_new(buf); -	gtk_label_set_use_markup(GTK_LABEL(label), TRUE); -	gtk_label_set_selectable(GTK_LABEL(label), TRUE); +	detail_window_set_dev_name(mainwindow->det_window, device->model); -	g_free(buf); -#else -	label = gtk_label_new(device->model); -#endif -	gtk_widget_show(label); -	gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0); -  	if (device->cache) { -		buf = g_strdup_printf(_("Cache: %d KB"), device->cache); -		label = gtk_label_new(buf); -		gtk_widget_show(label); -		gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0); -		g_free(buf); +		detail_window_append_info_int(mainwindow->det_window, _("Cache (kb)"), +					      device->cache, FALSE); +	}	 +	 +	if (device->phy_geometry) { +		detail_window_append_info(mainwindow->det_window, _("Physical geometry"), +					      device->phy_geometry); +	}	 +	if (device->log_geometry) { +		detail_window_append_info(mainwindow->det_window, _("Logical geometry"), +					      device->log_geometry);  	}	 +  } @@ -7,6 +7,8 @@ struct _IDEDevice {  	gchar *model;  	gchar *media; +	gchar *phy_geometry; +	gchar *log_geometry;  	gint cache;  	IDEDevice *next; @@ -41,7 +41,8 @@ void intl_init(void)  }  /* - * GNU's gettext is cool and all... but hey, this is smaller :) + * GNU's gettext is cool and all... but hey, this is smaller, + * but slower :P   */  const gchar *  intl_translate(const gchar * string, const gchar * source) __THROW @@ -50,7 +51,7 @@ intl_translate(const gchar * string, const gchar * source) __THROW  	gchar buffer[256], *keyname, *lang = NULL, *langenv = NULL;  	const gchar *retval, *langvars[] =  		 {"LANG", "LC_MESSAGES", "LC_ALL", NULL}; -	gboolean found; +	gboolean found = FALSE;  	struct stat st;  	gint i = 0; @@ -67,6 +68,7 @@ intl_translate(const gchar * string, const gchar * source) __THROW       langenv_ok:  	lang = g_strconcat(INTL_PREFIX, langenv, ".lang", NULL);  	if (stat(lang, &st)) { +		g_free(lang);  		lang = g_strconcat(INTL_PREFIX, "default.lang", NULL);  		if (stat(lang, &st)) {  		     not_found: @@ -28,7 +28,7 @@ ISADevice *hi_scan_isapnp(void)  			gboolean lock = FALSE;  			gfloat pnpversion, prodversion;  			gint card_id; -			gpointer start, end; +			gpointer start = NULL, end = NULL;  			sscanf(buf, "Card %d", &card_id); @@ -41,7 +41,7 @@ ISADevice *hi_scan_isapnp(void)  					lock = TRUE;  				}  			} -			buf+=2; +			buf += 2;  			sscanf(buf, "PnP version %f Product version %f", &pnpversion, &prodversion); @@ -70,61 +70,25 @@ ISADevice *hi_scan_isapnp(void)  void hi_show_isa_info(MainWindow *mainwindow, ISADevice *device)  { -	GtkWidget *hbox, *vbox, *label;  	gchar *buf; -#ifdef GTK2 -	GtkWidget *pixmap; -	 -	pixmap = gtk_image_new_from_file(IMG_PREFIX "pci.png"); -	gtk_widget_show(pixmap); -#endif  	if(!device) return; -	hbox = gtk_hbox_new(FALSE, 2); -	gtk_container_set_border_width(GTK_CONTAINER(hbox), 4); -	gtk_widget_show(hbox); -	 -	if(mainwindow->framec) -		gtk_widget_destroy(mainwindow->framec); - -	gtk_container_add(GTK_CONTAINER(mainwindow->frame), hbox); -	mainwindow->framec = hbox; - -	gtk_frame_set_label(GTK_FRAME(mainwindow->frame), _("ISA Plug and Play Device")); +	gtk_window_set_title(GTK_WINDOW(mainwindow->det_window->window), _("ISA Plug and Play Device")); -#ifdef GTK2 -	gtk_box_pack_start(GTK_BOX(hbox), pixmap, FALSE, FALSE, 0); -#endif +	detail_window_set_dev_name(mainwindow->det_window, device->card); +	detail_window_set_icon(mainwindow->det_window, IMG_PREFIX "pci.png"); -	vbox = gtk_vbox_new(FALSE, 2); -	gtk_widget_show(vbox); -	gtk_box_pack_start(GTK_BOX(hbox), vbox, TRUE, TRUE, 0); - -#ifdef GTK2 -	buf = g_strdup_printf("<b>%s</b>", device->card); -	label = gtk_label_new(buf); -	gtk_label_set_use_markup(GTK_LABEL(label), TRUE); -	gtk_label_set_selectable(GTK_LABEL(label), TRUE); -	 +	detail_window_append_info_int(mainwindow->det_window, _("Card ID"), +				      device->card_id, FALSE);	 +	buf = g_strdup_printf("%.2f", device->pnpversion); +	detail_window_append_info(mainwindow->det_window, _("PnP version"), +				  buf);  	g_free(buf); -#else -	label = gtk_label_new(device->card); -#endif -	gtk_widget_show(label); -	gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0); -	buf = g_strdup_printf(_("Card ID: %d"), device->card_id); -	label = gtk_label_new(buf); -	gtk_widget_show(label); -	gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0); -	g_free(buf); - -	buf = g_strdup_printf(_("PnP version: %.2f, Product version: %.2f"), -			device->pnpversion, device->prodversion); -	label = gtk_label_new(buf); -	gtk_widget_show(label); -	gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0); +	buf = g_strdup_printf("%.2f", device->prodversion); +	detail_window_append_info(mainwindow->det_window, _("Product version"), +				  buf);  	g_free(buf);  } diff --git a/lang/pt_BR.lang b/lang/pt_BR.lang index cc4c592c..8d45505e 100644 --- a/lang/pt_BR.lang +++ b/lang/pt_BR.lang @@ -66,7 +66,7 @@ Parallel Port=Porta paralela  Description: %s=Descrição: %s  Command set: %s=Comandos: %s  Class: %s=Classe: %s -Base I/O address: 0x%x=Endereço E/S básico: 0x%x +Base I/O address: 0x%x=Endereço E/S base: 0x%x  Modes: %s=Modos: %s  Uses DMA=Usa acesso direto à memória diff --git a/modules.c b/modules.c new file mode 100644 index 00000000..ddee1def --- /dev/null +++ b/modules.c @@ -0,0 +1,137 @@ +/* + * Hardware Information, version 0.3 + * Copyright (C) 2003 Leandro Pereira <leandro@linuxmag.com.br> + * + * May be modified and/or distributed under the terms of GNU GPL version 2. + * + */ + +#include <gtk/gtk.h> + +#include "hardinfo.h" +#include "modules.h" + +void hi_show_module_info(MainWindow *mainwindow, ModInfo *device) +{ +	if(!device) return; + +	gtk_window_set_title(GTK_WINDOW(mainwindow->det_window->window), device->description); +	detail_window_set_icon(mainwindow->det_window, IMG_PREFIX "module.png"); + 	detail_window_set_dev_name(mainwindow->det_window, device->name); + 	detail_window_set_dev_type(mainwindow->det_window, device->description); + 	 +	if (device->author && strlen(device->author)) { +	 	detail_window_append_info(mainwindow->det_window, _("Author"), + 					  device->author); +		detail_window_append_separator(mainwindow->det_window); +	} + +	if (device->license && strlen(device->license)) +		detail_window_append_info(mainwindow->det_window, _("License"), +					  device->license); +					   +	if (device->depends &&strlen(device->depends)) +		detail_window_append_info(mainwindow->det_window, _("Depends on"), +					  device->depends);					  + 				   +} + +GtkWidget *module_get_widget(void) +{ +#if 0 +	GtkWidget *vbox, *hbbox, *scroll, *clist, *btn; + +        vbox = gtk_vbox_new(FALSE, 5); +        gtk_container_set_border_width(GTK_CONTAINER(vbox), 4); +        gtk_widget_show(vbox); + +        hbbox = gtk_hbutton_box_new(); +        gtk_container_set_border_width(GTK_CONTAINER(hbbox), 4); +        gtk_widget_show(hbbox); +        gtk_box_pack_end(GTK_BOX(vbox), hbbox, FALSE, FALSE, 0); +        gtk_button_box_set_spacing(GTK_BUTTON_BOX(hbbox), 6); +        gtk_button_box_set_layout(GTK_BUTTON_BOX(hbbox), GTK_BUTTONBOX_END); + +        btn = gtk_button_new_from_stock(HI_DETAILS); +        g_signal_connect(G_OBJECT(btn), "clicked",   +                         (GCallback) detail_window_show, mainwindow); +        gtk_widget_show(btn); +        gtk_box_pack_end(GTK_BOX(hbbox), btn, FALSE, FALSE, 0); +        mainwindow->details_button = btn; + +        scroll = gtk_scrolled_window_new(NULL, NULL); +        gtk_box_pack_start(GTK_BOX(vbox), scroll, TRUE, TRUE, 0); +        gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scroll), +                                       GTK_POLICY_AUTOMATIC, +                                       GTK_POLICY_AUTOMATIC); + +        ctree = gtk_ctree_new(2, 0); +        gtk_container_add(GTK_CONTAINER(scroll), ctree); +        gtk_widget_set_usize(GTK_WIDGET(ctree), 400, 300); +        gtk_ctree_set_expander_style(GTK_CTREE(ctree), +                                     GTK_CTREE_EXPANDER_TRIANGLE); +        gtk_ctree_set_line_style(GTK_CTREE(ctree), GTK_CTREE_LINES_NONE); +        gtk_clist_set_column_width(GTK_CLIST(ctree), 0, 32); +        gtk_clist_set_column_width(GTK_CLIST(ctree), 1, 32); +        gtk_clist_set_row_height(GTK_CLIST(ctree), 18); +        g_signal_connect(G_OBJECT(ctree), "tree-select-row", +                         (GCallback) hi_enable_details_button, mainwindow); +        g_signal_connect(G_OBJECT(ctree), "tree-unselect-row", +                         (GCallback) hi_disable_details_button, mainwindow); + + +	return vbox; +#endif + +	return NULL; +} + +#define SET_VAR(vname,var) \ +	if (!strncmp(buffer, vname, strlen(vname))) { \ +		gchar *_b = buffer; \ +		while (*_b && *_b != ':') _b++; _b++; \ +		while (*_b && (*_b == ' ' || *_b == '\t')) _b++; \ +		modinfo->var = g_strdup(g_strstrip(_b)); \ +	} + +ModInfo *hi_scan_modules(void) +{ +	FILE *lsmod; +	gchar buffer[256]; +	ModInfo *modinfo = NULL, *mod = NULL; +	 +	lsmod = popen("/sbin/lsmod", "r"); +	if(!lsmod) return NULL; +	 +	fgets(buffer, 256, lsmod);	/* Discards the first line */ +	 +	while(fgets(buffer, 256, lsmod)){ +		gchar *start, *buf; +		FILE *modi; +		 +		start = buf = buffer; +		 +		walk_until_inclusive(' '); +		*buf = 0;				 +		 +		modinfo = g_new0(ModInfo, 1); +		 +		modinfo->name = g_strdup(start); +		 +		buf = g_strdup_printf("/sbin/modinfo %s", start); +		modi = popen(buf, "r"); +		while (fgets(buffer, 256, modi)) { +			SET_VAR("author", author); +			SET_VAR("description", description); +			SET_VAR("license", license); +			SET_VAR("depends", depends); +		} +		pclose(modi); +		 +		modinfo->next = mod; +		mod = modinfo; +	} +	pclose(lsmod); +	 +	return mod; +} diff --git a/modules.h b/modules.h new file mode 100644 index 00000000..046d4b94 --- /dev/null +++ b/modules.h @@ -0,0 +1,21 @@ +#ifndef __MODULES_H__ +#define __MODULES_H__ + +#include <gtk/gtk.h> + +typedef struct _ModInfo	ModInfo; + +struct _ModInfo { +	gchar *name; +	gchar *author; +	gchar *description; +	gchar *license; +	gchar *depends; +	 +	ModInfo *next; +}; + +void hi_show_module_info(MainWindow *mainwindow, ModInfo *modinfo); +ModInfo *hi_scan_modules(void); + +#endif @@ -3,166 +3,53 @@   * Copyright (C) 2003 Leandro Pereira <leandro@linuxmag.com.br>   *   * May be modified and/or distributed under the terms of GNU GPL version 2. - * - * Tested only with 2.4.x kernels on ix86. - * USB support needs netdevfs.   */  #include <stdio.h> +#include "config.h"  #include "hardinfo.h"  #include "net.h" +gboolean net_update(gpointer data); +  GtkWidget *net_get_widget(MainWindow * mainwindow)  { -    GtkWidget *vbox1; -    GtkWidget *scrolledwindow1; -    GtkWidget *clist1; -    GtkWidget *label2; -    GtkWidget *table1; -    GtkWidget *label4; -    GtkWidget *label5; -    GtkWidget *label7; -    GtkWidget *label8; -    GtkWidget *label3; -    GtkWidget *label10; -    GtkWidget *label11; -    GtkWidget *label12; -    GtkWidget *label14; -    GtkWidget *label15; -    GtkWidget *vseparator1; - -    vbox1 = gtk_vbox_new(FALSE, 5); -    gtk_widget_show(vbox1); -    gtk_container_set_border_width(GTK_CONTAINER(vbox1), 4); - -    scrolledwindow1 = gtk_scrolled_window_new(NULL, NULL); -    gtk_widget_show(scrolledwindow1); -    gtk_box_pack_start(GTK_BOX(vbox1), scrolledwindow1, TRUE, TRUE, 0); -    gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolledwindow1), -				   GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC); - -    clist1 = gtk_clist_new(2); -    gtk_widget_show(clist1); -    gtk_container_add(GTK_CONTAINER(scrolledwindow1), clist1); -    gtk_clist_set_column_width(GTK_CLIST(clist1), 0, 30); -    gtk_clist_set_column_width(GTK_CLIST(clist1), 1, 80); -    gtk_clist_column_titles_show(GTK_CLIST(clist1)); - -    label2 = gtk_label_new(_("Interface name")); -    gtk_widget_show(label2); -    gtk_clist_set_column_widget(GTK_CLIST(clist1), 1, label2); -    gtk_label_set_justify(GTK_LABEL(label2), GTK_JUSTIFY_LEFT); -    gtk_misc_set_alignment(GTK_MISC(label2), 0, 0.5); - -    table1 = gtk_table_new(3, 5, FALSE); -    gtk_widget_show(table1); -    gtk_box_pack_start(GTK_BOX(vbox1), table1, FALSE, FALSE, 0); -    gtk_container_set_border_width(GTK_CONTAINER(table1), 4); -    gtk_table_set_row_spacings(GTK_TABLE(table1), 4); -    gtk_table_set_col_spacings(GTK_TABLE(table1), 4); - -    label4 = gtk_label_new(_("Bytes:")); -    gtk_widget_show(label4); -    gtk_table_attach(GTK_TABLE(table1), label4, 0, 1, 1, 2, -		     (GtkAttachOptions) (GTK_FILL), -		     (GtkAttachOptions) (0), 0, 0); -    gtk_label_set_justify(GTK_LABEL(label4), GTK_JUSTIFY_LEFT); -    gtk_misc_set_alignment(GTK_MISC(label4), 0, 0.5); - -    label5 = gtk_label_new(_("Speed:")); -    gtk_widget_show(label5); -    gtk_table_attach(GTK_TABLE(table1), label5, 0, 1, 2, 3, -		     (GtkAttachOptions) (GTK_FILL), -		     (GtkAttachOptions) (0), 0, 0); -    gtk_label_set_justify(GTK_LABEL(label5), GTK_JUSTIFY_LEFT); -    gtk_misc_set_alignment(GTK_MISC(label5), 0, 0.5); - -    label7 = gtk_label_new(_("Bytes:")); -    gtk_widget_show(label7); -    gtk_table_attach(GTK_TABLE(table1), label7, 3, 4, 1, 2, -		     (GtkAttachOptions) (GTK_FILL), -		     (GtkAttachOptions) (0), 0, 0); -    gtk_label_set_justify(GTK_LABEL(label7), GTK_JUSTIFY_LEFT); -    gtk_misc_set_alignment(GTK_MISC(label7), 0, 0.5); - -    label8 = gtk_label_new(_("Speed")); -    gtk_widget_show(label8); -    gtk_table_attach(GTK_TABLE(table1), label8, 3, 4, 2, 3, -		     (GtkAttachOptions) (GTK_FILL), -		     (GtkAttachOptions) (0), 0, 0); -    gtk_label_set_justify(GTK_LABEL(label8), GTK_JUSTIFY_LEFT); -    gtk_misc_set_alignment(GTK_MISC(label8), 0, 0.5); - -    label3 = gtk_label_new(_("<big><b>Receive</b></big>")); -    gtk_widget_show(label3); -    gtk_table_attach(GTK_TABLE(table1), label3, 0, 2, 0, 1, -		     (GtkAttachOptions) (GTK_FILL), -		     (GtkAttachOptions) (0), 0, 0); -    gtk_label_set_use_markup(GTK_LABEL(label3), TRUE); -    gtk_label_set_justify(GTK_LABEL(label3), GTK_JUSTIFY_LEFT); -    gtk_misc_set_alignment(GTK_MISC(label3), 0, 0.5); - -    label10 = gtk_label_new(_("<big><b>Transmit</b></big>")); -    gtk_widget_show(label10); -    gtk_table_attach(GTK_TABLE(table1), label10, 3, 5, 0, 1, -		     (GtkAttachOptions) (GTK_FILL), -		     (GtkAttachOptions) (0), 0, 0); -    gtk_label_set_use_markup(GTK_LABEL(label10), TRUE); -    gtk_label_set_justify(GTK_LABEL(label10), GTK_JUSTIFY_LEFT); -    gtk_misc_set_alignment(GTK_MISC(label10), 0, 0.5); - -    label11 = gtk_label_new(_("0B")); -    gtk_widget_show(label11); -    gtk_table_attach(GTK_TABLE(table1), label11, 1, 2, 1, 2, -		     (GtkAttachOptions) (GTK_EXPAND | GTK_FILL), -		     (GtkAttachOptions) (0), 0, 0); -    gtk_label_set_justify(GTK_LABEL(label11), GTK_JUSTIFY_LEFT); -    gtk_misc_set_alignment(GTK_MISC(label11), 0, 0.5); - -    label12 = gtk_label_new(_("0B/s")); -    gtk_widget_show(label12); -    gtk_table_attach(GTK_TABLE(table1), label12, 1, 2, 2, 3, -		     (GtkAttachOptions) (GTK_EXPAND | GTK_FILL), -		     (GtkAttachOptions) (0), 0, 0); -    gtk_label_set_justify(GTK_LABEL(label12), GTK_JUSTIFY_LEFT); -    gtk_misc_set_alignment(GTK_MISC(label12), 0, 0.5); - -    label14 = gtk_label_new(_("0B")); -    gtk_widget_show(label14); -    gtk_table_attach(GTK_TABLE(table1), label14, 4, 5, 1, 2, -		     (GtkAttachOptions) (GTK_EXPAND | GTK_FILL), -		     (GtkAttachOptions) (0), 0, 0); -    gtk_label_set_justify(GTK_LABEL(label14), GTK_JUSTIFY_LEFT); -    gtk_misc_set_alignment(GTK_MISC(label14), 0, 0.5); - -    label15 = gtk_label_new(_("0B/s")); -    gtk_widget_show(label15); -    gtk_table_attach(GTK_TABLE(table1), label15, 4, 5, 2, 3, -		     (GtkAttachOptions) (GTK_EXPAND | GTK_FILL), -		     (GtkAttachOptions) (0), 0, 0); -    gtk_label_set_justify(GTK_LABEL(label15), GTK_JUSTIFY_LEFT); -    gtk_misc_set_alignment(GTK_MISC(label15), 0, 0.5); - -    vseparator1 = gtk_vseparator_new(); -    gtk_widget_show(vseparator1); -    gtk_table_attach(GTK_TABLE(table1), vseparator1, 2, 3, 0, 3, -		     (GtkAttachOptions) (GTK_EXPAND | GTK_FILL), -		     (GtkAttachOptions) (GTK_EXPAND | GTK_FILL), 0, 0); - - -    return vbox1; +    return gtk_label_new("Not implemented yet.");  }  gboolean net_update(gpointer data)  {      MainWindow *mainwindow = (MainWindow *) data;      NetDevice *net; - +    static NetDevice *netold = NULL; +          if (!mainwindow)  	return FALSE;      net = hi_scan_net(); +     +    if (!net) +    	return FALSE; +     +    if (!netold) { +    	netold = net; +    } else { +	NetDevice *nd1, *nd2; +	 +	for (nd1 = netold, nd2 = net; nd1 && nd2; +	     nd1 = nd1->next, nd2 = nd2->next) { +	      +	  	   g_print ("iface %s: %ld bytes/s up, %ld bytes/s down\n", +	  	   	   nd1->iface, +	  	   	   nd2->trans_bytes - nd1->trans_bytes, +	  	   	   nd2->recv_bytes - nd1->recv_bytes); +	} 		    	 +	 +	netold = net; +    } +    g_print("\n\n"); +       return TRUE;  } @@ -182,7 +69,7 @@ NetDevice *hi_scan_net(void)      while (fgets(buffer, 256, proc_net)) {  	if (strchr(buffer, ':')) {  	    gint trash; -	    gchar ifacename[4]; +	    gchar ifacename[16];  	    gchar *buf = buffer;  	    gint i; @@ -192,26 +79,24 @@ NetDevice *hi_scan_net(void)  	    buf = g_strstrip(buf); -	    memset(ifacename, 0, 4); +	    memset(ifacename, 0, 16); -	    for (i = 0; buffer[i] != ':' && i < 4; i++) { +	    for (i = 0; buffer[i] != ':' && i < 16; i++) {  		ifacename[i] = buffer[i];  	    }  	    walk_until_inclusive(':');  	    /* iface: bytes packets errs drop fifo frame compressed multicast */ -	    sscanf(buf, "%d %d %d %d %d %d %d %d %d %d %d", +	    sscanf(buf, "%ld %ld %ld %d %d %d %d %d %ld %ld %ld",  		   &net_dev->recv_bytes, &net_dev->recv_packets,  		   &net_dev->recv_errors, &trash, &trash, &trash, &trash,  		   &trash, &net_dev->trans_bytes, &net_dev->trans_packets,  		   &net_dev->trans_errors); -	    g_print("%s -> %d %d %d | %d %d %d\n", -		    ifacename, net_dev->recv_bytes, net_dev->recv_errors, -		    net_dev->recv_packets, net_dev->trans_bytes, -		    net_dev->trans_errors, net_dev->trans_packets); +	    g_print("%ld\n", net_dev->recv_bytes); +	    net_dev->iface = g_strdup(ifacename);  	}      }      fclose(proc_net); @@ -8,13 +8,13 @@ typedef struct _NetDevice	NetDevice;  struct _NetDevice {  	gchar *iface; -	guint recv_bytes; -	guint recv_errors; -	guint recv_packets; +	gulong recv_bytes; +	gulong recv_errors; +	gulong recv_packets; -	guint trans_bytes; -	guint trans_errors; -	guint trans_packets; +	gulong trans_bytes; +	gulong trans_errors; +	gulong trans_packets;  	NetDevice *next;  }; @@ -124,19 +124,15 @@ ParportDevice *hi_scan_parport(void)  void hi_show_parport_info(MainWindow *mainwindow, ParportDevice *device)  { -	GtkWidget *hbox, *vbox, *label;  	gchar *buf;  	static struct {  		gchar *type, *label, *icon;  	} type2icon[] = { -		{"PRINTER",	"Printer",		"lpr.png"}, -		{"MEDIA",	"Multimedia",	"media.png"},		 +		{"PRINTER",	"Printer",		"lpr.png"	}, +		{"MEDIA",	"Multimedia",		"media.png"	},		  		{NULL,		"Legacy Device",	"gen_connector.png"},  	};  	gint i; -#ifdef GTK2 -	GtkWidget *pixmap;		 -#endif  	if(!device) return; @@ -148,87 +144,27 @@ void hi_show_parport_info(MainWindow *mainwindow, ParportDevice *device)  		i = sizeof(type2icon) / sizeof(type2icon[0]) - 1; -#ifdef GTK2  	buf = g_strdup_printf("%s%s", IMG_PREFIX, type2icon[i].icon); -	pixmap = gtk_image_new_from_file(buf); -	gtk_widget_show(pixmap); -	 +	detail_window_set_icon(mainwindow->det_window, buf);	  	g_free(buf); -#endif -	hbox = gtk_hbox_new(FALSE, 2); -	gtk_container_set_border_width(GTK_CONTAINER(hbox), 4); -	gtk_widget_show(hbox); +	gtk_window_set_title(GTK_WINDOW(mainwindow->det_window->window), _("Parallel Port")); -	if(mainwindow->framec) -		gtk_widget_destroy(mainwindow->framec); - -	gtk_container_add(GTK_CONTAINER(mainwindow->frame), hbox); -	mainwindow->framec = hbox; +	detail_window_set_dev_name(mainwindow->det_window, device->name); +	detail_window_set_dev_type(mainwindow->det_window, type2icon[i].label); -	gtk_frame_set_label(GTK_FRAME(mainwindow->frame), _("Parallel Port")); -	 -#ifdef GTK2 -	gtk_box_pack_start(GTK_BOX(hbox), pixmap, FALSE, FALSE, 0); -#endif - -	vbox = gtk_vbox_new(FALSE, 2); -	gtk_widget_show(vbox); -	gtk_box_pack_start(GTK_BOX(hbox), vbox, TRUE, TRUE, 0); - -#ifdef GTK2 -	buf = g_strdup_printf("<b>%s</b>", device->name); -	label = gtk_label_new(buf); -	gtk_label_set_use_markup(GTK_LABEL(label), TRUE); -	gtk_label_set_selectable(GTK_LABEL(label), TRUE); -	 -	g_free(buf); -#else -	label = gtk_label_new(device->name); -#endif -	gtk_widget_show(label); -	gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0); - -	if (device->description) { -		buf = g_strdup_printf(_("Description: %s"), device->description); -		label = gtk_label_new(buf); -		gtk_widget_show(label); -		gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0); -	 -		g_free(buf); -	} -	 -	if (device->cmdset) { -		buf = g_strdup_printf(_("Command set: %s"), device->cmdset); -		label = gtk_label_new(buf); -		gtk_widget_show(label); -		gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0); +	if (device->description) +		detail_window_append_info(mainwindow->det_window, _("Description"), +					  device->description); -		g_free(buf); -	} - -	buf = g_strdup_printf(_("Class: %s"), type2icon[i].label); -	label = gtk_label_new(buf); -	gtk_widget_show(label); -	gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0);	 -	g_free(buf);	 - -	buf = g_strdup_printf(_("Base I/O address: 0x%x"), device->port); -	label = gtk_label_new(buf); -	gtk_widget_show(label); -	gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0);	 -	g_free(buf);	 - -	buf = g_strdup_printf(_("Modes: %s"), device->modes); -	label = gtk_label_new(buf); -	gtk_widget_show(label); -	gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0);	 -	g_free(buf);	 - -	if (device->dma) { -		label = gtk_label_new(_("Uses DMA")); -		gtk_widget_show(label); -		gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0); -	} - +	if (device->cmdset)  +		detail_window_append_info(mainwindow->det_window, _("Command set"), +					  device->cmdset); + +	detail_window_append_info_int(mainwindow->det_window, _("Base I/O address"), +			              device->port, TRUE); +	detail_window_append_info(mainwindow->det_window, _("Modes"), +			          device->modes); +	detail_window_append_info(mainwindow->det_window, _("Uses DMA"), +			          device->dma ? _("Yes") : _("No"));  } @@ -11,117 +11,67 @@  void hi_show_pci_info(MainWindow *mainwindow, PCIDevice *device)  { -	GtkWidget *hbox, *vbox, *label;  	gchar *buf; -#ifdef GTK2 -	GtkWidget *pixmap; -	 -	pixmap = gtk_image_new_from_file(IMG_PREFIX "pci.png"); -	gtk_widget_show(pixmap); -#endif  	if(!device) return; -	hbox = gtk_hbox_new(FALSE, 2); -	gtk_container_set_border_width(GTK_CONTAINER(hbox), 4); -	gtk_widget_show(hbox); -	 -	if(mainwindow->framec) -		gtk_widget_destroy(mainwindow->framec); - -	gtk_container_add(GTK_CONTAINER(mainwindow->frame), hbox); -	mainwindow->framec = hbox; - -	gtk_frame_set_label(GTK_FRAME(mainwindow->frame), device->category); -	 -#ifdef GTK2 -	gtk_box_pack_start(GTK_BOX(hbox), pixmap, FALSE, FALSE, 0); -#endif - -	vbox = gtk_vbox_new(FALSE, 2); -	gtk_widget_show(vbox); -	gtk_box_pack_start(GTK_BOX(hbox), vbox, TRUE, TRUE, 0); +	gtk_window_set_title(GTK_WINDOW(mainwindow->det_window->window), device->category); +	detail_window_set_icon(mainwindow->det_window, IMG_PREFIX "pci.png"); + 	detail_window_set_dev_name(mainwindow->det_window, device->name); + 	detail_window_set_dev_type(mainwindow->det_window, device->category); -#ifdef GTK2 -	buf = g_strdup_printf("<b>%s</b>", device->name); -	label = gtk_label_new(buf); -	gtk_label_set_use_markup(GTK_LABEL(label), TRUE); -	gtk_label_set_selectable(GTK_LABEL(label), TRUE); +	if (device->irq) +		detail_window_append_info_int(mainwindow->det_window, "IRQ", +					      device->irq, FALSE); -	g_free(buf); -#else -	label = gtk_label_new(device->name); -#endif -	gtk_widget_show(label); -	gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0); - -	if(device->irq) { -		buf = g_strdup_printf("IRQ: %d", device->irq); -	 -		label = gtk_label_new(buf); -		gtk_widget_show(label); -		gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0); -	 -		g_free(buf);				 -	} -  	if(device->io_addr) { -		buf = g_strdup_printf(_("I/O address: 0x%x to 0x%x"), device->io_addr, +		buf = g_strdup_printf(_("0x%x to 0x%x"), device->io_addr,  			device->io_addr_end); -		label = gtk_label_new(buf); -		gtk_widget_show(label); -		gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0); -	 +		detail_window_append_info(mainwindow->det_window, +					  _("I/O Address"), buf);	  		g_free(buf);				  	}  	if(device->memory) { -		buf = g_strdup_printf(_("Memory: %ld %s"), +		buf = g_strdup_printf(_("%d%s"),  			(device->memory <= 1024) ? device->memory :  				device->memory / 1000,  			(device->memory <= 1024) ? "bytes" : "KB"); -		label = gtk_label_new(buf); -		gtk_widget_show(label); -		gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0); +		detail_window_append_info(mainwindow->det_window, +					  _("Memory"), buf);  		g_free(buf);				  	}  	if(device->freq) { -		buf = g_strdup_printf(_("Frequency: %dMHz"), device->freq); -	 -		label = gtk_label_new(buf); -		gtk_widget_show(label); -		gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0); -	 -		g_free(buf);				 -	} +		buf = g_strdup_printf(_("%dMHz"), device->freq); -	if(device->latency) { -		buf = g_strdup_printf(_("Latency: %d"), device->latency); -	 -		label = gtk_label_new(buf); -		gtk_widget_show(label); -		gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0); +		detail_window_append_info(mainwindow->det_window, +					  _("Frequency"), buf);  		g_free(buf);				  	} -	if(device->bus_master) { -		label = gtk_label_new(_("Bus master")); -		gtk_widget_show(label); -		gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0); -	} +	if (device->latency) +		detail_window_append_info_int(mainwindow->det_window, +					      _("Latency"), device->latency, +					      FALSE); + +	detail_window_append_info(mainwindow->det_window, _("Bus master"),  +				  (gchar*)((device->bus_master) ? _("Yes") : _("No"))); -	buf = g_strdup_printf(_("Bus: %d, Device: %d, Function: %d"), -		device->bus, device->device, device->function); +	detail_window_append_separator(mainwindow->det_window); -	label = gtk_label_new(buf); -	gtk_widget_show(label); -	gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0); -	g_free(buf);				 +	detail_window_append_info_int(mainwindow->det_window, _("Domain"), +				      device->domain, FALSE); +	detail_window_append_info_int(mainwindow->det_window, _("Bus"), +				      device->bus, FALSE); +	detail_window_append_info_int(mainwindow->det_window, _("Device"), +				      device->device, FALSE); +	detail_window_append_info_int(mainwindow->det_window, _("Function"), +				      device->function, FALSE);  }  #ifdef USE_LSPCI @@ -130,7 +80,7 @@ PCIDevice *hi_scan_pci(void)  	FILE *lspci;  	gchar buffer[256], *buf;  	gint n=0; -	PCIDevice *pci_dev, *pci; +	PCIDevice *pci_dev = NULL, *pci;  	pci = NULL; @@ -139,12 +89,13 @@ PCIDevice *hi_scan_pci(void)  	while(fgets(buffer, 256, lspci)){  		buf = g_strstrip(buffer); +		  		if(!strncmp(buf, "Flags", 5)){  			gint irq=0, freq=0, latency=0, i;  			gchar **list;  			buf+=7; -						 +			  			pci_dev->bus_master = FALSE;  			list = g_strsplit(buf, ", ", 10); @@ -155,20 +106,17 @@ PCIDevice *hi_scan_pci(void)  					sscanf(list[i], "IRQ %d", &irq);  				else if(strstr(list[i], "Mhz"))  					sscanf(list[i], "%dMhz", &freq); -				else -				if(!strncmp(list[i], "bus master", 10)) +				else if(!strncmp(list[i], "bus master", 10))  					pci_dev->bus_master = TRUE;   				else if(!strncmp(list[i], "latency", 7))  					sscanf(list[i], "latency %d", &latency);  			}  			g_strfreev(list); -			if (irq)  pci_dev->irq = irq; -			if (freq) pci_dev->freq = freq; +			if (irq)     pci_dev->irq = irq; +			if (freq)    pci_dev->freq = freq;  			if (latency) pci_dev->latency = latency; -		}  -		 -		else if(!strncmp(buf, "Memory at", 9) && +		} else if(!strncmp(buf, "Memory at", 9) &&  			  strstr(buf, "[size=")) {  			gulong mem;  			gchar unit; @@ -181,14 +129,16 @@ PCIDevice *hi_scan_pci(void)  			       (unit == 'M') ? 1024 * 1000 :  			       (unit == 'G') ? 1024 * 1000 * 1000 : 1; -			pci_dev->memory += mem; -		}  else if(!strncmp(buf, "I/O", 3)){ +			pci_dev->memory += mem;  +			 +		} else if(!strncmp(buf, "I/O", 3)){  			guint io_addr, io_size;  			sscanf(buf, "I/O ports at %x [size=%d]", &io_addr, &io_size);  			pci_dev->io_addr	= io_addr;			  			pci_dev->io_addr_end	= io_addr+io_size; +		  		} else if((buf[0] >= '0' && buf[0] <= '9') && buf[4] == ':'){  			gint bus, device, function, domain;  			gpointer start, end; @@ -200,6 +150,7 @@ PCIDevice *hi_scan_pci(void)  			sscanf(buf, "%x:%x:%x.%d", &domain, &bus, &device, &function); +			pci_dev->domain		= domain;  			pci_dev->bus		= bus;  			pci_dev->device		= device;  			pci_dev->function 	= function; @@ -13,6 +13,7 @@ struct _PCIDevice {  	gulong memory; +	gint domain;  	gint bus;  	gint device;  	gint function; diff --git a/pixmaps/cd.png b/pixmaps/cd.pngBinary files differ index dd5d3341..c4c7806d 100755..100644 --- a/pixmaps/cd.png +++ b/pixmaps/cd.png diff --git a/pixmaps/distro/.xvpics/mdk.png b/pixmaps/distro/.xvpics/mdk.pngBinary files differ deleted file mode 100755 index 84b3f79c..00000000 --- a/pixmaps/distro/.xvpics/mdk.png +++ /dev/null diff --git a/pixmaps/distro/yd.png b/pixmaps/distro/yd.pngBinary files differ index ce002956..bde8c6ba 100755 --- a/pixmaps/distro/yd.png +++ b/pixmaps/distro/yd.png diff --git a/pixmaps/hdd.png b/pixmaps/hdd.pngBinary files differ index cc308f88..e02487eb 100755..100644 --- a/pixmaps/hdd.png +++ b/pixmaps/hdd.png diff --git a/pixmaps/logo.png b/pixmaps/logo.pngBinary files differ index e19c735a..d2dee31e 100755 --- a/pixmaps/logo.png +++ b/pixmaps/logo.png diff --git a/pixmaps/logo.xpm b/pixmaps/logo.xpm new file mode 100644 index 00000000..18701670 --- /dev/null +++ b/pixmaps/logo.xpm @@ -0,0 +1,349 @@ +/* XPM */ +static char * logo_xpm[] = { +"32 32 314 2", +"  	c None", +". 	c #F3F3F3", +"+ 	c #F2F2F2", +"@ 	c #F1F1F1", +"# 	c #F0F0F0", +"$ 	c #EFEFEF", +"% 	c #EEEEEE", +"& 	c #ECECEC", +"* 	c #EAEAEA", +"= 	c #E8E8E8", +"- 	c #E7E7E7", +"; 	c #E3E3E3", +"> 	c #AEAEAE", +", 	c #F4F4F4", +"' 	c #DCDCDC", +") 	c #D8D8D8", +"! 	c #D6D6D6", +"~ 	c #D5D5D5", +"{ 	c #D3D3D3", +"] 	c #D1D1D1", +"^ 	c #D0D0D0", +"/ 	c #CFCFCF", +"( 	c #CECECE", +"_ 	c #CCCCCC", +": 	c #CBCBCB", +"< 	c #CDCDCD", +"[ 	c #626262", +"} 	c #898989", +"| 	c #383838", +"1 	c #373737", +"2 	c #363636", +"3 	c #353535", +"4 	c #343434", +"5 	c #424242", +"6 	c #E2E2E2", +"7 	c #D9D9D9", +"8 	c #3F3F3F", +"9 	c #6E6E6E", +"0 	c #888682", +"a 	c #E2E2DF", +"b 	c #EDEAE6", +"c 	c #DFDED9", +"d 	c #C9CAC7", +"e 	c #BFC0BD", +"f 	c #C4C1BA", +"g 	c #C1BCB2", +"h 	c #B8B4AA", +"i 	c #ABA69C", +"j 	c #919089", +"k 	c #7D7C76", +"l 	c #282724", +"m 	c #E5E5E5", +"n 	c #D7D7D7", +"o 	c #9A9793", +"p 	c #EEF0F1", +"q 	c #FFFFFF", +"r 	c #EDEDEC", +"s 	c #D8DADA", +"t 	c #D0D2D2", +"u 	c #CAC7C1", +"v 	c #C1BDB3", +"w 	c #AAA49B", +"x 	c #797E7F", +"y 	c #89846E", +"z 	c #2C2B27", +"A 	c #E4E4E4", +"B 	c #6D6D6D", +"C 	c #96948F", +"D 	c #F7F6F5", +"E 	c #FAF9F8", +"F 	c #EEECEA", +"G 	c #EBE9E6", +"H 	c #E7E5E1", +"I 	c #D0CDC5", +"J 	c #C0BCB2", +"K 	c #B8B3A9", +"L 	c #A8A399", +"M 	c #9D9685", +"N 	c #8C7D76", +"O 	c #2B2926", +"P 	c #EBEBEB", +"Q 	c #6C6C6C", +"R 	c #908E89", +"S 	c #F3F2F0", +"T 	c #F4F2F1", +"U 	c #ECEAE7", +"V 	c #E9E7E4", +"W 	c #E6E3DF", +"X 	c #CECBC4", +"Y 	c #BEBAB0", +"Z 	c #B7B2A8", +"` 	c #A6A197", +" .	c #937162", +"..	c #8B6863", +"+.	c #2A2826", +"@.	c #D2D2D2", +"#.	c #464C52", +"$.	c #49525D", +"%.	c #3F4954", +"&.	c #3E4852", +"*.	c #4D545B", +"=.	c #8E8F90", +"-.	c #C8C8C6", +";.	c #E5E3DF", +">.	c #E5E2DF", +",.	c #E2DFDB", +"'.	c #CAC7BE", +").	c #BAB5AC", +"!.	c #B3ADA4", +"~.	c #A39E94", +"{.	c #928E84", +"].	c #928E86", +"^.	c #2A2825", +"/.	c #E1E1E1", +"(.	c #6F7A86", +"_.	c #8397AB", +":.	c #7D96B2", +"<.	c #7B95B1", +"[.	c #758CA7", +"}.	c #637282", +"|.	c #5B5F63", +"1.	c #BAB9B6", +"2.	c #D8D6D3", +"3.	c #DAD8D3", +"4.	c #C3BFB7", +"5.	c #B3AEA4", +"6.	c #ACA79D", +"7.	c #9D988E", +"8.	c #8F8A80", +"9.	c #908B84", +"0.	c #292724", +"a.	c #E0E0E0", +"b.	c #41464D", +"c.	c #7D8A98", +"d.	c #8199B4", +"e.	c #7590AE", +"f.	c #849CB7", +"g.	c #A3B5C9", +"h.	c #94A9C0", +"i.	c #7892AF", +"j.	c #778BA1", +"k.	c #585D60", +"l.	c #A6A4A1", +"m.	c #C7C4C0", +"n.	c #B3AFA7", +"o.	c #A5A097", +"p.	c #9E998F", +"q.	c #928D83", +"r.	c #858077", +"s.	c #8A867F", +"t.	c #272623", +"u.	c #DFDFDF", +"v.	c #606A75", +"w.	c #8097B1", +"x.	c #D1DAE4", +"y.	c #627182", +"z.	c #676868", +"A.	c #B4B2AF", +"B.	c #AFABA5", +"C.	c #A6A29A", +"D.	c #A09C94", +"E.	c #97938B", +"F.	c #908C85", +"G.	c #8D8A83", +"H.	c #272522", +"I.	c #DEDEDE", +"J.	c #C9C9C9", +"K.	c #222528", +"L.	c #7C8EA2", +"M.	c #7892B0", +"N.	c #B2C1D2", +"O.	c #6B84A0", +"P.	c #394048", +"Q.	c #54514C", +"R.	c #5D5A55", +"S.	c #5C5A54", +"T.	c #5A5852", +"U.	c #54514B", +"V.	c #4F4C47", +"W.	c #474540", +"X.	c #151413", +"Y.	c #C6C6C6", +"Z.	c #33373C", +"`.	c #889FB8", +" +	c #708AA7", +".+	c #3D4752", +"++	c #838383", +"@+	c #989898", +"#+	c #9C9C9C", +"$+	c #9B9B9B", +"%+	c #C4C4C4", +"&+	c #393F44", +"*+	c #89A0BA", +"=+	c #E0E6ED", +"-+	c #718BA8", +";+	c #35404B", +">+	c #B0B0B0", +",+	c #D4D4D4", +"'+	c #D7D4C3", +")+	c #E2DAA9", +"!+	c #B5B5B5", +"~+	c #BCBCBC", +"{+	c #3E3E3E", +"]+	c #5F5F5F", +"^+	c #3B3F45", +"/+	c #6F89A6", +"(+	c #999999", +"_+	c #CACACA", +":+	c #C0BDAC", +"<+	c #A09766", +"[+	c #A5A5A5", +"}+	c #7D7D7D", +"|+	c #323232", +"1+	c #9E9E9E", +"2+	c #8394A6", +"3+	c #7A94B1", +"4+	c #5B7188", +"5+	c #262B31", +"6+	c #3A3A3A", +"7+	c #404040", +"8+	c #454545", +"9+	c #434343", +"0+	c #2E2E2E", +"a+	c #1E1E1E", +"b+	c #797979", +"c+	c #565F69", +"d+	c #8198B1", +"e+	c #738DAB", +"f+	c #3D4B5A", +"g+	c #16181A", +"h+	c #1D1D1D", +"i+	c #222222", +"j+	c #212121", +"k+	c #262626", +"l+	c #242424", +"m+	c #252525", +"n+	c #202020", +"o+	c #090909", +"p+	c #6B7580", +"q+	c #748FAD", +"r+	c #6A829E", +"s+	c #465668", +"t+	c #0B0D10", +"u+	c #000000", +"v+	c #535353", +"w+	c #515A65", +"x+	c #76889C", +"y+	c #7D95B0", +"z+	c #748EAA", +"A+	c #6E87A4", +"B+	c #5F758D", +"C+	c #3E4A58", +"D+	c #575A5F", +"E+	c #808080", +"F+	c #969696", +"G+	c #A2A2A2", +"H+	c #A3A3A3", +"I+	c #F5F5F5", +"J+	c #5B5B5B", +"K+	c #7F7F80", +"L+	c #7E8083", +"M+	c #494D52", +"N+	c #464B51", +"O+	c #484B4F", +"P+	c #7A7A7A", +"Q+	c #A1A1A1", +"R+	c #BBBBBB", +"S+	c #C5C5C5", +"T+	c #A9A9A9", +"U+	c #C0C0C0", +"V+	c #B6B6B6", +"W+	c #606060", +"X+	c #727272", +"Y+	c #7E7E7E", +"Z+	c #ABABAB", +"`+	c #AFAFAF", +" @	c #B4B4B4", +".@	c #C3C3C3", +"+@	c #B8B8B8", +"@@	c #A0A0A0", +"#@	c #929292", +"$@	c #525252", +"%@	c #515151", +"&@	c #DADADA", +"*@	c #BDBDBD", +"=@	c #555555", +"-@	c #111111", +";@	c #B7B7B7", +">@	c #BFBFBF", +",@	c #DDDDDD", +"'@	c #9D9D9D", +")@	c #2B2B2B", +"!@	c #9A9A9A", +"~@	c #979797", +"{@	c #939393", +"]@	c #919191", +"^@	c #959595", +"/@	c #848484", +"(@	c #7C7C7C", +"_@	c #757575", +":@	c #8E8E8E", +"<@	c #646464", +"[@	c #6A6A6A", +"}@	c #696969", +"|@	c #686868", +"1@	c #676767", +"2@	c #666666", +"3@	c #656565", +"4@	c #636363", +"5@	c #5E5E5E", +"6@	c #5D5D5D", +"7@	c #5A5A5A", +"8@	c #585858", +"9@	c #575757", +"                                                                ", +"                                                                ", +"                                                                ", +"            . . . + @ @ # $ % % & & * * = - ; >                 ", +"            , @ ' ) ! ~ { { ] ^ / ( _ : < ! ' : [               ", +"            , @ } | 1 1 2 2 3 3 3 3 3 4 1 5 6 7 8               ", +"            . $ 9 0 a b c d e f g h i j k l m n |               ", +"            . $ 9 o p q r s t u v h w x y z A ! |               ", +"            . % B C D E F G H I J K L M N O ; { |               ", +"            @ P Q R S T U V W X Y Z `  ...+.6 @.|               ", +"          #.$.%.&.*.=.-.;.>.,.'.).!.~.{.].^././ |               ", +"        (._.:.:.<.[.}.|.1.2.3.4.5.6.7.8.9.0.a.< |               ", +"    b.c.d.e.f.g.h.e.i.j.k.l.m.n.o.p.q.r.s.t.u.: |               ", +"    v.w.e.e.g.q x.e.e.i.y.z.A.B.C.D.E.F.G.H.I.J.|               ", +"  K.L.M.e.e.h.x.N.e.e.e.O.P.Q.R.S.T.U.V.W.X.' Y.|               ", +"  Z.`.e.e.e.x.x.N.e.e.e. +.+++@+#+#+$+$+$+@+' %+|               ", +"  &+*+e.e.e.=+q x.e.e.e.-+;+>+: ,+@.( _ '+)+!+~+{+]+            ", +"  ^+`.e.e.e.g.q x.e.e.e./+$.(+~+@.^ < _+:+<+[+}+|+3   1+        ", +"    2+3+e.e.g.q x.e.e.e.4+5+6+7+8+8+5 8+9+9+0+a+      1+b+      ", +"    c+d+e.e.g.q x.e.e.e+f+g+h+i+j+k+j+l+m+n+o+        1+b+      ", +"      p+d+3+e.e.e.q+r+s+t+u+u+u+u+u+u+u+u+u+u+        1+v+      ", +"        w+x+y+z+A+B+C+D+E+F+G+H+H+H+H+H+H+H+H+@.I+#+  1+J+      ", +"        K+L+M+N+N+O+P+Q+R+! @.~ S+%+! { Y._ T+U+V+W+X+Y+        ", +"        : 7 Z+`+ @Z+.@R+) _ S+%+Y.] ~++@T+`+F+Z+@@#@$@%@        ", +"        @ /.) ~ ) { &@^ { *@n J._ ( ^ S+_+/ !+R+ @#+=@-@        ", +"      I+# _ ^ &@a.= ' - ,+a.! > ~+;@>@S+,@; _+'@T+U+[ )@        ", +"      % R+.@= @.[+H+'@!@~@{@]@`+@. @G+~+^@/@(@_@T+:@Z+<@        ", +"      (@[@[@[@}@}@|@1@1@2@3@<@<@4@[ W+]+5@6@J+7@8@9@=@1 u+      ", +"            u+u+u+u+u+u+u+u+u+u+u+u+u+u+u+u+u+u+u+u+u+u+        ", +"                                                                ", +"                                                                ", +"                                                                "}; diff --git a/pixmaps/lpr.png b/pixmaps/lpr.pngBinary files differ index 3ad6dc99..7bfdefd1 100755..100644 --- a/pixmaps/lpr.png +++ b/pixmaps/lpr.png diff --git a/pixmaps/module.png b/pixmaps/module.pngBinary files differ new file mode 100644 index 00000000..80dc788d --- /dev/null +++ b/pixmaps/module.png diff --git a/pixmaps/processor.xpm b/pixmaps/processor.xpm new file mode 100644 index 00000000..7a7970d5 --- /dev/null +++ b/pixmaps/processor.xpm @@ -0,0 +1,116 @@ +/* XPM */ +static char * processor_xpm[] = { +"16 16 97 2", +"  	c None", +". 	c #000000", +"+ 	c #090600", +"@ 	c #030000", +"# 	c #E8E6E1", +"$ 	c #A3A09C", +"% 	c #010000", +"& 	c #080000", +"* 	c #D6D2CD", +"= 	c #8F8A84", +"- 	c #FFFAF7", +"; 	c #98938D", +"> 	c #F1EDE9", +", 	c #88827E", +"' 	c #181510", +") 	c #F8EEE4", +"! 	c #F8ECE0", +"~ 	c #F8ECDE", +"{ 	c #0D0600", +"] 	c #F8EBDE", +"^ 	c #F6E7D7", +"/ 	c #C4B5A7", +"( 	c #070000", +"_ 	c #F6E5D3", +": 	c #F7E9D9", +"< 	c #D5C5B6", +"[ 	c #050200", +"} 	c #080300", +"| 	c #312722", +"1 	c #EFE7E0", +"2 	c #F6F2EF", +"3 	c #F6F1EE", +"4 	c #EDE4DB", +"5 	c #F1E4D6", +"6 	c #9D9790", +"7 	c #12110D", +"8 	c #B1A79F", +"9 	c #DDCFC2", +"0 	c #F6E8D9", +"a 	c #F6F1EC", +"b 	c #F5F1EE", +"c 	c #E5D7CB", +"d 	c #F7E8D8", +"e 	c #EEDFD3", +"f 	c #CAC0B6", +"g 	c #645951", +"h 	c #E7D9CA", +"i 	c #F6E6D5", +"j 	c #F7EBDE", +"k 	c #E9DCD2", +"l 	c #756F6D", +"m 	c #F7EFE7", +"n 	c #EDDECF", +"o 	c #D6C8BA", +"p 	c #CBB9AC", +"q 	c #D2C8BC", +"r 	c #F8EEE3", +"s 	c #F5EEE8", +"t 	c #EFE3D7", +"u 	c #B8A99D", +"v 	c #060000", +"w 	c #DBD3CB", +"x 	c #F8F1E8", +"y 	c #F3E3D4", +"z 	c #F1DFCF", +"A 	c #E6D7C7", +"B 	c #F8F2ED", +"C 	c #EDE1D4", +"D 	c #9D8E84", +"E 	c #090200", +"F 	c #DBD3CD", +"G 	c #F8F0EA", +"H 	c #F1E0D1", +"I 	c #F6EEE8", +"J 	c #56504A", +"K 	c #130D0D", +"L 	c #ADA3A2", +"M 	c #C8BDBC", +"N 	c #BEB3AB", +"O 	c #9E9A96", +"P 	c #A8A09E", +"Q 	c #0E0403", +"R 	c #0A0000", +"S 	c #0A0200", +"T 	c #040000", +"U 	c #FCF4F2", +"V 	c #F9F1EF", +"W 	c #F8F0EE", +"X 	c #F2EDEA", +"Y 	c #DDD9D6", +"Z 	c #E5E4E0", +"` 	c #030400", +" .	c #0B0505", +"..	c #050000", +"+.	c #14100F", +"@.	c #090806", +"#.	c #000100", +"              . .               ", +"          + @ # $ % %           ", +"        & * = - ; > , '         ", +"        & ) ; ! ; ~ ; {         ", +"        & ] ; ^ ; ] ; / (       ", +"        & _ ; _ ; : ; < (       ", +"    [ } | 1 2 3 4 5 6 < (       ", +"  7 _ 8 & 9 _ 0 a b c < (       ", +"  % d e f g h i _ j k < (       ", +"    l m n o p q r s t u (       ", +"    v w x y z A B C _ D (       ", +"      E F G _ H I _ < J         ", +"        K L M _ _ N O &         ", +"        P v Q R S T }           ", +"        T U V W X Y Z `         ", +"        T  ...+.@ @.. #.        "}; diff --git a/pixmaps/scan.png b/pixmaps/scan.pngBinary files differ deleted file mode 100755 index 8074cea6..00000000 --- a/pixmaps/scan.png +++ /dev/null diff --git a/pixmaps/scanner.png b/pixmaps/scanner.pngBinary files differ new file mode 100644 index 00000000..cfede3e5 --- /dev/null +++ b/pixmaps/scanner.png diff --git a/pixmaps/stock-details.png b/pixmaps/stock-details.pngBinary files differ new file mode 100644 index 00000000..5a2cd965 --- /dev/null +++ b/pixmaps/stock-details.png @@ -1,13 +1,9 @@  /*   * Hardware Information, version 0.3   * Copyright (C) 2003 Leandro Pereira <leandro@linuxmag.com.br> + * SCSI support by Pascal F.Martin <pascalmartin@earthlink.net>   *   * May be modified and/or distributed under the terms of GNU GPL version 2. - * - */ - -/* - * SCSI support by Pascal F.Martin <pascalmartin@earthlink.net>   */  #include "hardinfo.h" @@ -18,7 +14,7 @@ SCSIDevice *hi_scan_scsi(void)  	FILE *proc_scsi;  	gchar buffer[256], *buf;  	gint n=0; -	SCSIDevice *scsi_dev, *scsi; +	SCSIDevice *scsi_dev = NULL, *scsi;  	struct stat st;  	scsi = NULL; @@ -117,11 +113,7 @@ void hi_show_scsi_info(MainWindow *mainwindow, SCSIDevice *device)          };          int i; -        GtkWidget *hbox, *vbox, *label;          gchar *buf; -#ifdef GTK2 -        GtkWidget *pixmap; -#endif          if(!device) return; @@ -129,69 +121,25 @@ void hi_show_scsi_info(MainWindow *mainwindow, SCSIDevice *device)                  if (!strcmp(device->type, type2icon[i].type)) break;          } -#ifdef GTK2          buf = g_strdup_printf("%s%s", IMG_PREFIX, type2icon[i].icon); -        pixmap = gtk_image_new_from_file(buf); -        gtk_widget_show(pixmap); -         +	detail_window_set_icon(mainwindow->det_window, buf);                  g_free(buf); -#endif -        hbox = gtk_hbox_new(FALSE, 2); -        gtk_container_set_border_width(GTK_CONTAINER(hbox), 4); -        gtk_widget_show(hbox); -         -        if(mainwindow->framec) -                gtk_widget_destroy(mainwindow->framec); - -        gtk_container_add(GTK_CONTAINER(mainwindow->frame), hbox); -        mainwindow->framec = hbox; +          buf = g_strdup_printf(_("SCSI %s Device"), type2icon[i].label); -        gtk_frame_set_label(GTK_FRAME(mainwindow->frame), buf); +        gtk_window_set_title(GTK_WINDOW(mainwindow->det_window->window), buf);         +	detail_window_set_dev_type(mainwindow->det_window, buf);          g_free(buf); -         -#ifdef GTK2 -        gtk_box_pack_start(GTK_BOX(hbox), pixmap, FALSE, FALSE, 0); -#endif -        vbox = gtk_vbox_new(FALSE, 2); -        gtk_widget_show(vbox); -        gtk_box_pack_start(GTK_BOX(hbox), vbox, TRUE, TRUE, 0); +	detail_window_set_dev_name(mainwindow->det_window, device->model); -#ifdef GTK2 -        buf = g_strdup_printf("<b>%s</b>", device->model); -        label = gtk_label_new(buf); -        gtk_label_set_use_markup(GTK_LABEL(label), TRUE); -        gtk_label_set_selectable(GTK_LABEL(label), TRUE); +	detail_window_append_info(mainwindow->det_window, _("Revision"), device->revision); +	detail_window_append_info(mainwindow->det_window, _("Type"), device->type); -        g_free(buf); -#else -        label = gtk_label_new(device->model); -#endif - -        gtk_widget_show(label); -        gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0); - -        buf = g_strdup_printf(_("Revision: %s"), device->revision); -        label = gtk_label_new(buf); -        gtk_widget_show(label); -        gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0); -        g_free(buf); +	detail_window_append_separator(mainwindow->det_window); -        buf = g_strdup_printf(_("Type: %s"), device->type); -        label = gtk_label_new(buf); -        gtk_widget_show(label); -        gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0); -        g_free(buf); - -        buf = g_strdup_printf -                        (_("Controller: %d, Bus: %d, ID: %d, LUN: %d"), -                              device->controller, -                              device->channel,    -                              device->id, -                              device->lun); -        label = gtk_label_new(buf); -        gtk_widget_show(label); -        gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0); -        g_free(buf); +	detail_window_append_info_int(mainwindow->det_window, _("Controller"), device->controller, FALSE); +	detail_window_append_info_int(mainwindow->det_window, _("Channel"), device->channel, FALSE); +	detail_window_append_info_int(mainwindow->det_window, _("ID"), device->id, FALSE); +	detail_window_append_info_int(mainwindow->det_window, _("LUN"), device->lun, FALSE);  } @@ -12,8 +12,8 @@ SerialDevice *hi_scan_serial(void)  {  	FILE *proc_tty;  	struct stat st; -	const gchar *ser_drv="/proc/tty/driver/serial"; -	gint n=0; +	const gchar *ser_drv = "/proc/tty/driver/serial"; +	gint n = 0;  	SerialDevice *serial_dev, *serial;  	serial = NULL; @@ -28,7 +28,7 @@ SerialDevice *hi_scan_serial(void)  			gchar *buf = buffer;  			if(*buf == 's') continue; -			if(strstr(buf, "unknown")) continue; +			if(strstr(buffer, "unknown")) continue;  			serial_dev = g_new0(SerialDevice, 1); @@ -36,10 +36,10 @@ SerialDevice *hi_scan_serial(void)  			serial = serial_dev;  			serial_dev->name = g_strdup_printf -				("Serial Port (tty%d)", buffer[0]-'0'); +				(_("Serial Port (tty%d)"), buffer[0]-'0');  			walk_until('t'); -			buf+=2; +			buf += 2;  			start = buf;  			walk_until(' ');  			end = buf; @@ -64,60 +64,17 @@ SerialDevice *hi_scan_serial(void)  void hi_show_serial_info(MainWindow *mainwindow, SerialDevice *device)  { -	GtkWidget *hbox, *vbox, *label; -	gchar *buf; -#ifdef GTK2 -	GtkWidget *pixmap; -	 -	pixmap = gtk_image_new_from_file(IMG_PREFIX "gen_connector.png"); -	gtk_widget_show(pixmap); -#endif -  	if(!device) return; -	hbox = gtk_hbox_new(FALSE, 2); -	gtk_container_set_border_width(GTK_CONTAINER(hbox), 4); -	gtk_widget_show(hbox); -	 -	if(mainwindow->framec) -		gtk_widget_destroy(mainwindow->framec); - -	gtk_container_add(GTK_CONTAINER(mainwindow->frame), hbox); -	mainwindow->framec = hbox; - -	gtk_frame_set_label(GTK_FRAME(mainwindow->frame), _("Communication Port")); -	 -#ifdef GTK2 -	gtk_box_pack_start(GTK_BOX(hbox), pixmap, FALSE, FALSE, 0); -#endif - -	vbox = gtk_vbox_new(FALSE, 2); -	gtk_widget_show(vbox); -	gtk_box_pack_start(GTK_BOX(hbox), vbox, TRUE, TRUE, 0); - -#ifdef GTK2 -	buf = g_strdup_printf("<b>%s</b>", device->name); -	label = gtk_label_new(buf); -	gtk_label_set_use_markup(GTK_LABEL(label), TRUE); -	gtk_label_set_selectable(GTK_LABEL(label), TRUE); -	 -	g_free(buf); -#else -	label = gtk_label_new(device->name); -#endif -	gtk_widget_show(label); -	gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0); -	 -	buf = g_strdup_printf(_("I/O port: 0x%x, IRQ: %d"), device->port, device->irq); -	label = gtk_label_new(buf); -	gtk_widget_show(label); -	gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0); -	g_free(buf); +	detail_window_set_icon(mainwindow->det_window, IMG_PREFIX "gen_connector.png"); +	gtk_window_set_title(GTK_WINDOW(mainwindow->det_window->window), _("Communication Port")); -	buf = g_strdup_printf("UART: %s", device->uart); -	label = gtk_label_new(buf); -	gtk_widget_show(label); -	gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0); -	g_free(buf); +	detail_window_set_dev_name(mainwindow->det_window, device->name); +	detail_window_set_dev_type(mainwindow->det_window, _("Communication Port")); +	detail_window_append_info_int(mainwindow->det_window, _("I/O port"), +				      device->port, TRUE); +	detail_window_append_info_int(mainwindow->det_window, _("IRQ"), +				      device->irq, TRUE); +	detail_window_append_info(mainwindow->det_window, "UART", device->uart);				        } @@ -1,3 +1,4 @@ +#include "config.h"  #include "status.h"  myStatus *my_status_new(gchar *title, gchar *text) @@ -13,8 +13,8 @@ struct _myStatus {  };  myStatus	*my_status_new(gchar *title, gchar *text); -void	 my_status_pulse(myStatus *status); -void	 my_status_destroy(myStatus *status); -void	 my_status_set_text(myStatus *status, gchar *text); +void	 	 my_status_pulse(myStatus *status); +void	 	 my_status_destroy(myStatus *status); +void	 	 my_status_set_text(myStatus *status, gchar *text);  #endif		/* __STATUS_H__ */ diff --git a/stock.c b/stock.c new file mode 100644 index 00000000..11b05073 --- /dev/null +++ b/stock.c @@ -0,0 +1,64 @@ +/* + * Based on GAIM's stock.c + * Copyright (C) 2002-2003, Christian Hammond <chipx86@gnupdate.org> + * + * Also distributed under GNU GPL version 2. + */  +  +#include <gtk/gtk.h> +#include "stock.h" +#include "hardinfo.h" +#include "config.h" + +static struct StockIcon { +	const char *name; +	const char *filename; +} const stock_icons[] = { +	{ HI_ABOUT,   "stock-about-16.png" }, +	{ HI_DETAILS, "stock-details.png"  } +}; + +const GtkStockItem stock_items[] = { +	{ HI_ABOUT,   "About...",	0, 0, NULL }, +	{ HI_DETAILS, "_Details...",	0, 0, NULL } +}; + +static gint stock_icon_count = sizeof stock_icons / sizeof(*stock_icons); +static gint stock_item_count = sizeof stock_items / sizeof(*stock_items); +static gboolean stock_inited = FALSE; + +void hi_stock_init(void) +{ +	GtkIconFactory *ift; +	int i; +	GtkWidget *win; +	 +	if (stock_inited) return; +	 +	ift = gtk_icon_factory_new(); +	gtk_icon_factory_add_default(ift); +	 +	win = gtk_window_new(GTK_WINDOW_TOPLEVEL); +	gtk_widget_realize(win); +	 +	for (i = 0; i < stock_icon_count; i++) { +		GdkPixbuf *pixbuf; +		GtkIconSet *iconset; +		gchar *filename; +		 +		filename = g_strdup_printf("%s/%s", IMG_PREFIX, stock_icons[i].filename);		 +		pixbuf = gdk_pixbuf_new_from_file(filename, NULL); +		g_free(filename); +		 +		iconset = gtk_icon_set_new_from_pixbuf(pixbuf);		  +		gtk_icon_factory_add(ift, stock_icons[i].name, iconset); +		gtk_icon_set_unref(iconset); +	} +	 +	gtk_widget_destroy(win);	 +	g_object_unref(G_OBJECT(ift)); +	gtk_stock_add_static(stock_items, stock_item_count); +	 +	stock_inited = TRUE; +} + diff --git a/stock.h b/stock.h new file mode 100644 index 00000000..cf9014fd --- /dev/null +++ b/stock.h @@ -0,0 +1,20 @@ +#ifndef __STOCK_H__ +#define __STOCK_H__ + +#include "config.h" + +#ifdef GTK2 + +#define	HI_ABOUT	"hi-about" +#define HI_DETAILS	"hi-details" + +#define	HI_PCI		"hi-pci" +#define HI_HDD		"hi-hdd" +#define HI_SCSI		"hi-scsi" +#define HI_CONNECTOR	"hi-connector" +#define HI_USB		"hi-usb" + +void hi_stock_init(void); +#endif + +#endif	/* __STOCK_H__ */ @@ -1,6 +1,7 @@  /*   * Hardware Information, version 0.3 - * Copyright (C) 2003 Leandro Pereira <leandro@linuxmag.com.br> + * Copyright (C) 2003-2004 Leandro Pereira <leandro@linuxmag.com.br> + * USB support rewritten by Christophe Grosjean <christopheg@wanadoo.fr>   *   * May be modified and/or distributed under the terms of GNU GPL version 2.   */ @@ -38,12 +39,92 @@ gboolean usb_update(gpointer data)  	return TRUE;	  } + + + USBDevice *hi_scan_usb(void) + { + 	FILE *proc_usb; + 	gint n=0; + 	USBDevice *usb_dev = NULL, *usb = NULL; + 	struct stat st; + 	gchar buffer[128]; + 	 + 	if (stat("/proc/bus/usb/devices", &st)) return NULL; + + 	proc_usb = fopen("/proc/bus/usb/devices", "r"); + 	while(fgets(buffer, 128, proc_usb)){ + 	  int lg = strlen(buffer); + 	  if (lg>0 && buffer[lg-1] == '\n'){ + 	    buffer[lg-1]=0; + 	  } + 	  if (strstr(buffer, "Manufacturer=")) { + 	    gchar *buf = buffer; + + 	    for (;*buf; buf++) { + 	      if (*buf == '=') { + 		if (usb){ + 		  usb->vendor = g_strdup(buf+1); + 		} + 		break; + 	      } + 	    } + 	  } else if (strstr(buffer, "Product=")) { + 	    gchar *buf = buffer; + 	    for (; *buf; buf++) { + 	      if (*buf == '=') { + 		if (usb_dev){ + 		  usb_dev->product = g_strdup(buf+1); + 		} + 	      } + 	    } + 	  } else if (!strncmp(buffer, "D:  Ve", 6)) { + 	    gchar *buf = buffer; + 	    gfloat version; + 	    gint class_id; + + 	    usb_dev = g_new0(USBDevice, 1); + 	    usb_dev->next = usb; + 	    usb = usb_dev; + 	     + 	    buf+=4; + 	     + 	    sscanf(buf, "Ver= %f Cls= %d", &version, &class_id); + 	     + 	    usb_dev->version = version; + 	    usb_dev->class_id= class_id; + 	     + 	    walk_until('('); + 	    buf[6]=0; + 	    usb_dev->class = g_strdup(buf+1); + 	     + 	    n++;		 + 	  } else if (!strncmp(buffer, "P:  Ve", 6)) { + 	    gchar *buf = buffer; + 	    gint vendor_id, prod_id; + 	    gfloat rev; + 	     + 	    buf+=4; + 	     + 	    sscanf(buf, "Vendor= %x ProdID= %x Rev= %f", + 		   &vendor_id, &prod_id, &rev); + 	    if (usb_dev){ + 	      usb_dev->vendor_id = vendor_id; + 	      usb_dev->prod_id = prod_id; + 	      usb_dev->revision = rev; + 	    } + 	  } + 	} + 	fclose(proc_usb); + 	return usb; + } + +#if 0  USBDevice *hi_scan_usb(void)  {  	FILE *proc_usb;  	gchar buffer[64];  	gint n=0; -	USBDevice *usb_dev, *usb; +	USBDevice *usb_dev = NULL, *usb = NULL;  	struct stat st;  	usb = NULL; @@ -55,7 +136,7 @@ USBDevice *hi_scan_usb(void)  		if (strstr(buffer, "Manufacturer=")) {  			gchar *buf = buffer;  			gboolean lock = FALSE; -			gpointer start, end; +			gpointer start = NULL, end = NULL;  			for (; buf != NULL; buf++) {  				if (lock && *buf == '\n') { @@ -75,7 +156,7 @@ USBDevice *hi_scan_usb(void)  		} else if (strstr(buffer, "Product=")) {  			gchar *buf = buffer;  			gboolean lock = FALSE; -			gpointer start, end; +			gpointer start = NULL, end = NULL;  			for (; buf != NULL; buf++) {  				if (lock && *buf == '\n') { @@ -136,81 +217,43 @@ USBDevice *hi_scan_usb(void)  	return usb;  } +#endif  void hi_show_usb_info(MainWindow *mainwindow, USBDevice *device)  { -	GtkWidget *hbox, *vbox, *label;  	gchar *buf; -#ifdef GTK2 -	GtkWidget *pixmap; -	 -	pixmap = gtk_image_new_from_file(IMG_PREFIX "usb.png"); -	gtk_widget_show(pixmap); -#endif  	if(!device) return; -	hbox = gtk_hbox_new(FALSE, 2); -	gtk_container_set_border_width(GTK_CONTAINER(hbox), 4); -	gtk_widget_show(hbox); -	 -	if(mainwindow->framec) -		gtk_widget_destroy(mainwindow->framec); - -	gtk_container_add(GTK_CONTAINER(mainwindow->frame), hbox); -	mainwindow->framec = hbox; +	detail_window_set_icon(mainwindow->det_window, IMG_PREFIX "usb.png"); -	gtk_frame_set_label(GTK_FRAME(mainwindow->frame), _("USB Device")); +	gtk_window_set_title(GTK_WINDOW(mainwindow->det_window->window), _("USB Device")); -#ifdef GTK2 -	gtk_box_pack_start(GTK_BOX(hbox), pixmap, FALSE, FALSE, 0); -#endif -	vbox = gtk_vbox_new(FALSE, 2); -	gtk_widget_show(vbox); -	gtk_box_pack_start(GTK_BOX(hbox), vbox, TRUE, TRUE, 0); +	detail_window_set_dev_name(mainwindow->det_window, device->product); +	detail_window_set_dev_type(mainwindow->det_window, device->vendor ? +				   device->vendor : ""); -#ifdef GTK2 -	buf = g_strdup_printf("<b>%s</b>", device->product); -	label = gtk_label_new(buf); -	gtk_label_set_use_markup(GTK_LABEL(label), TRUE); -	gtk_label_set_selectable(GTK_LABEL(label), TRUE); -	 +	buf = g_strdup_printf("%s (%d)", device->class, device->class_id); +	detail_window_append_info(mainwindow->det_window, _("Class"), buf);  	g_free(buf); -#else -	label = gtk_label_new(device->product); -#endif -	gtk_widget_show(label); -	gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0); - -	if (device->vendor) { -		buf = g_strdup_printf(_("Manufacturer: %s"), device->vendor); -		label = gtk_label_new(buf); -		gtk_widget_show(label); -		gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0); -		g_free(buf); -	} - -	buf = g_strdup_printf(_("Class: %s (%d)"), device->class, device->class_id); -	label = gtk_label_new(buf); -	gtk_widget_show(label); -	gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0); +	 +	detail_window_append_separator(mainwindow->det_window); +	 +	buf = g_strdup_printf("%.2f", device->version); +	detail_window_append_info(mainwindow->det_window, _("Version"), buf);  	g_free(buf); -	buf = g_strdup_printf(_("Version: %.2f, Revision: %.2f"), device->version, device->revision); -	label = gtk_label_new(buf); -	gtk_widget_show(label); -	gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0); +	buf = g_strdup_printf("%.2f", device->revision); +	detail_window_append_info(mainwindow->det_window, _("Revision"), buf);  	g_free(buf);  	if(!device->prod_id) return; + +	detail_window_append_separator(mainwindow->det_window); -	buf = g_strdup_printf(_("Vendor ID: 0x%X, Product ID: 0x%X"), -			device->vendor_id, device->prod_id); -	label = gtk_label_new(buf); -	gtk_widget_show(label); -	gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0); -	g_free(buf); +	detail_window_append_info_int(mainwindow->det_window, _("Vendor ID"), device->vendor_id, TRUE); +	detail_window_append_info_int(mainwindow->det_window, _("Product ID"), device->prod_id, TRUE);  } @@ -35,7 +35,7 @@ V4LDevice *hi_scan_v4l(void)  	if(!proc_dir)  		return NULL; -	while (sd = readdir(proc_dir)) { +	while ((sd = readdir(proc_dir))) {  		gchar *dev, buffer[128];  		dev = g_strdup_printf("/proc/video/dev/%s", sd->d_name); @@ -66,54 +66,18 @@ V4LDevice *hi_scan_v4l(void)  void hi_show_v4l_info(MainWindow *mainwindow, V4LDevice *device)  { -	GtkWidget *hbox, *vbox, *label;  	gchar *buf; -#ifdef GTK2 -	GtkWidget *pixmap;	 -#endif  	if(!device) return; -	hbox = gtk_hbox_new(FALSE, 2); -	gtk_container_set_border_width(GTK_CONTAINER(hbox), 4); -	gtk_widget_show(hbox); -	 -#ifdef GTK2  	buf = g_strdup_printf("%sv4l.png", IMG_PREFIX); -	pixmap = gtk_image_new_from_file(buf); -	gtk_widget_show(pixmap); -	 -	gtk_box_pack_start(GTK_BOX(hbox), pixmap, FALSE, FALSE, 0); -	 +	detail_window_set_icon(mainwindow->det_window, buf);	  	g_free(buf); -#endif -	if(mainwindow->framec) -		gtk_widget_destroy(mainwindow->framec); - -	gtk_container_add(GTK_CONTAINER(mainwindow->frame), hbox); -	mainwindow->framec = hbox; -	 -	gtk_frame_set_label(GTK_FRAME(mainwindow->frame), _("Device Information")); +	gtk_window_set_title(GTK_WINDOW(mainwindow->det_window->window), _("Device Information")); -	vbox = gtk_vbox_new(FALSE, 5); -	gtk_widget_show(vbox); -	gtk_box_pack_start(GTK_BOX(hbox), vbox, TRUE, TRUE, 0); -#ifdef GTK2 -	buf = g_strdup_printf("<b>%s</b>", device->name); -	 -	label = gtk_label_new(buf); -	gtk_widget_show(label); -	gtk_label_set_use_markup(GTK_LABEL(label), TRUE); -	gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0); -	 -	g_free(buf); -#else -	label = gtk_label_new(device->name); -	gtk_widget_show(label); -	gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0); -#endif +	detail_window_set_dev_name(mainwindow->det_window, device->name);  	if (device->type) {  		gchar *b = g_strdup(device->type); @@ -125,13 +89,8 @@ void hi_show_v4l_info(MainWindow *mainwindow, V4LDevice *device)  		} while(*b);  		b = b_start; -		buf = g_strdup_printf("Type:\n%s", b); -	 -		label = gtk_label_new(buf); -		gtk_widget_show(label); -		gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0); -	 -		g_free(buf); +		detail_window_append_info(mainwindow->det_window, _("Type"), +					  b);  		g_free(b);  	}  } @@ -2,8 +2,6 @@   * Hardware Information, version 0.3   * Copyright (C) 2003 Leandro Pereira <leandro@linuxmag.com.br>   * - * May be modified and/or distributed under the terms of GNU GPL version 2. - *   * This module contains code from xdpyinfo.c, by Jim Fulton, MIT X Consortium   * Copyright 1988, 1998 The Open Group   * @@ -138,10 +136,8 @@ x11_get_widget(MainWindow * mainwindow)  {  	GtkWidget *label, *hbox;  	GtkWidget *table; -#ifdef GTK2  	GtkWidget *pixmap;  	gchar *buf; -#endif  	X11Info *info;  	if (!mainwindow) @@ -155,14 +151,12 @@ x11_get_widget(MainWindow * mainwindow)  	hbox = gtk_hbox_new(FALSE, 0);  	gtk_widget_show(hbox); -#ifdef GTK2  	buf = g_strdup_printf("%s/x11.png", IMG_PREFIX);  	pixmap = gtk_image_new_from_file(buf);  	gtk_widget_set_usize(GTK_WIDGET(pixmap), 64, 0);  	gtk_widget_show(pixmap);  	gtk_box_pack_start(GTK_BOX(hbox), pixmap, FALSE, FALSE, 0);  	g_free(buf); -#endif  	table = gtk_table_new(4, 2, FALSE);  	gtk_widget_show(table); @@ -174,42 +168,26 @@ x11_get_widget(MainWindow * mainwindow)  	/*  	 * Table headers  	 */ -#ifdef GTK2  	label = gtk_label_new(_("<b>Display:</b>"));  	gtk_label_set_use_markup(GTK_LABEL(label), TRUE); -#else -	label = gtk_label_new(_("Display:")); -#endif  	gtk_table_attach_defaults(GTK_TABLE(table), label, 0, 1, 0, 1);  	gtk_widget_show(label);  	gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.5); -#ifdef GTK2  	label = gtk_label_new(_("<b>Vendor:</b>"));  	gtk_label_set_use_markup(GTK_LABEL(label), TRUE); -#else -	label = gtk_label_new(_("Vendor:")); -#endif  	gtk_table_attach_defaults(GTK_TABLE(table), label, 0, 1, 1, 2);  	gtk_widget_show(label);  	gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.5); -#ifdef GTK2  	label = gtk_label_new(_("<b>Release:</b>"));  	gtk_label_set_use_markup(GTK_LABEL(label), TRUE); -#else -	label = gtk_label_new(_("Release:")); -#endif  	gtk_table_attach_defaults(GTK_TABLE(table), label, 0, 1, 2, 3);  	gtk_widget_show(label);  	gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.5); -#ifdef GTK2  	label = gtk_label_new(_("<b>Resolution:</b>"));  	gtk_label_set_use_markup(GTK_LABEL(label), TRUE); -#else -	label = gtk_label_new(_("Resolution:")); -#endif  	gtk_table_attach_defaults(GTK_TABLE(table), label, 0, 1, 3, 4);  	gtk_widget_show(label);  	gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.5); | 
