diff options
| author | Leandro Pereira <leandro@linuxmag.com.br> | 2004-06-14 21:33:25 -0300 | 
|---|---|---|
| committer | Simon Quigley <tsimonq2@ubuntu.com> | 2017-06-19 14:38:31 -0500 | 
| commit | 7d65a12d6431f72e601ea1d0c3ef5d09af8bfb96 (patch) | |
| tree | 7ad1761adce3212a13e5342a54865e31b917f18b | |
| parent | 0864b0a8e6f0b0983c3536931cfbad1414137d6b (diff) | |
| parent | 8c1612d32c5682a86216adb8c8d11ce715fe5475 (diff) | |
Import Debian changes 0.3.6-5
hardinfo (0.3.6-5) unstable; urgency=high
  * Add Amd64 support (closes: #253935).
    Thanks to Kurt Roeckx <Q@ping.be>
  * Close duplicate "doesn't work with newer pciutils" bug (closes: #254018).
hardinfo (0.3.6-4) unstable; urgency=high
  * Fixed segfault on startup (closes: #242843).
    Thanks to Remco van de Meent <remco@debian.org>
hardinfo (0.3.6-3) unstable; urgency=high
  * Added Debian menu entry icon.
  * Fixed some misc packaging bugs.
  * Changed package description.
hardinfo (0.3.6-2) unstable; urgency=low
  * Sync with upstream sources.
  * Disabled "Network" tab.
hardinfo (0.3.6-1) unstable; urgency=high
  * Sync with upstream sources.
hardinfo (0.3.5-1) unstable; urgency=high
  * Sync with upstream sources.
hardinfo (0.3.4-1) unstable; urgency=high
  * Sync with upstream sources.
hardinfo (0.3.3-1) unstable; urgency=low
  * Sync with upstream sources.
hardinfo (0.3.2-1) unstable; urgency=low
  * Sync with upstream sources.
hardinfo (0.3.1-1) unstable; urgency=low
  * Sync with upstream sources.
hardinfo (0.3-1) unstable; urgency=low
  * Initial Release.
| -rw-r--r-- | ChangeLog | 136 | ||||
| -rw-r--r-- | Makefile.in | 47 | ||||
| -rw-r--r-- | README | 8 | ||||
| -rw-r--r-- | about.c | 120 | ||||
| -rw-r--r-- | about.h | 16 | ||||
| -rw-r--r-- | computer.c | 515 | ||||
| -rw-r--r-- | computer.h | 45 | ||||
| -rwxr-xr-x | configure | 228 | ||||
| -rw-r--r-- | debian/changelog | 72 | ||||
| -rw-r--r-- | debian/compat | 1 | ||||
| -rw-r--r-- | debian/control | 16 | ||||
| -rw-r--r-- | debian/copyright | 13 | ||||
| -rw-r--r-- | debian/dirs | 2 | ||||
| -rw-r--r-- | debian/hardinfo.1 | 35 | ||||
| -rw-r--r-- | debian/menu | 4 | ||||
| -rw-r--r-- | debian/postinst | 48 | ||||
| -rw-r--r-- | debian/postrm | 38 | ||||
| -rw-r--r-- | debian/preinst | 44 | ||||
| -rw-r--r-- | debian/prerm | 39 | ||||
| -rwxr-xr-x | debian/rules | 95 | ||||
| -rwxr-xr-x | genintl.pl | 80 | ||||
| -rw-r--r-- | hardinfo.c | 623 | ||||
| -rw-r--r-- | hardinfo.desktop | 12 | ||||
| -rw-r--r-- | hardinfo.h | 86 | ||||
| -rw-r--r-- | ide.c | 142 | ||||
| -rw-r--r-- | ide.h | 18 | ||||
| -rw-r--r-- | intl.c | 111 | ||||
| -rw-r--r-- | intl.h | 11 | ||||
| -rw-r--r-- | isapnp.c | 130 | ||||
| -rw-r--r-- | isapnp.h | 20 | ||||
| l--------- | lang/es_CO.lang | 1 | ||||
| l--------- | lang/es_DO.lang | 1 | ||||
| l--------- | lang/es_ES.lang | 1 | ||||
| l--------- | lang/es_GT.lang | 1 | ||||
| -rw-r--r-- | lang/es_MX.ISO-8859-1.lang | 117 | ||||
| l--------- | lang/es_MX.lang | 1 | ||||
| l--------- | lang/es_PR.lang | 1 | ||||
| l--------- | lang/es_US.lang | 1 | ||||
| -rw-r--r-- | lang/pt_BR.lang | 117 | ||||
| -rw-r--r-- | net.c | 220 | ||||
| -rw-r--r-- | net.h | 29 | ||||
| -rw-r--r-- | parport.c | 234 | ||||
| -rw-r--r-- | parport.h | 30 | ||||
| -rw-r--r-- | pci.c | 323 | ||||
| -rw-r--r-- | pci.h | 31 | ||||
| -rwxr-xr-x | pixmaps/cd.png | bin | 0 -> 2811 bytes | |||
| -rwxr-xr-x | pixmaps/cpu.png | bin | 0 -> 2753 bytes | |||
| -rwxr-xr-x | pixmaps/distro/.xvpics/mdk.png | bin | 0 -> 2706 bytes | |||
| -rwxr-xr-x | pixmaps/distro/cnc.png | bin | 0 -> 4379 bytes | |||
| -rwxr-xr-x | pixmaps/distro/deb.png | bin | 0 -> 1718 bytes | |||
| -rwxr-xr-x | pixmaps/distro/gnt.png | bin | 0 -> 3470 bytes | |||
| -rwxr-xr-x | pixmaps/distro/mdk.png | bin | 0 -> 4648 bytes | |||
| -rwxr-xr-x | pixmaps/distro/rh.png | bin | 0 -> 3199 bytes | |||
| -rwxr-xr-x | pixmaps/distro/slk.png | bin | 0 -> 2054 bytes | |||
| -rwxr-xr-x | pixmaps/distro/suse.png | bin | 0 -> 988 bytes | |||
| -rwxr-xr-x | pixmaps/distro/tl.png | bin | 0 -> 731 bytes | |||
| -rwxr-xr-x | pixmaps/distro/unk.png | bin | 0 -> 2945 bytes | |||
| -rwxr-xr-x | pixmaps/distro/yd.png | bin | 0 -> 2173 bytes | |||
| -rwxr-xr-x | pixmaps/distro/yellow-dog.gif | bin | 0 -> 342 bytes | |||
| -rwxr-xr-x | pixmaps/gen_connector.png | bin | 0 -> 1820 bytes | |||
| -rwxr-xr-x | pixmaps/gen_connector.xpm | 46 | ||||
| -rwxr-xr-x | pixmaps/hdd.png | bin | 0 -> 3805 bytes | |||
| -rwxr-xr-x | pixmaps/hdd.xpm | 138 | ||||
| -rwxr-xr-x | pixmaps/logo.png | bin | 0 -> 2699 bytes | |||
| -rwxr-xr-x | pixmaps/lpr.png | bin | 0 -> 5741 bytes | |||
| -rwxr-xr-x | pixmaps/media.png | bin | 0 -> 3113 bytes | |||
| -rwxr-xr-x | pixmaps/mem.png | bin | 0 -> 2792 bytes | |||
| -rwxr-xr-x | pixmaps/pci.png | bin | 0 -> 3797 bytes | |||
| -rwxr-xr-x | pixmaps/pci.xpm | 136 | ||||
| -rwxr-xr-x | pixmaps/scan.png | bin | 0 -> 1517 bytes | |||
| -rwxr-xr-x | pixmaps/scsi.png | bin | 0 -> 647 bytes | |||
| -rwxr-xr-x | pixmaps/scsi.xpm | 79 | ||||
| -rwxr-xr-x | pixmaps/stock-about-16.png | bin | 0 -> 320 bytes | |||
| -rwxr-xr-x | pixmaps/tape.png | bin | 0 -> 1013 bytes | |||
| -rwxr-xr-x | pixmaps/usb.png | bin | 0 -> 2925 bytes | |||
| -rwxr-xr-x | pixmaps/usb.xpm | 49 | ||||
| -rwxr-xr-x | pixmaps/v4l.png | bin | 0 -> 3133 bytes | |||
| -rwxr-xr-x | pixmaps/x11.png | bin | 0 -> 1061 bytes | |||
| -rw-r--r-- | scsi.c | 197 | ||||
| -rw-r--r-- | scsi.h | 23 | ||||
| -rw-r--r-- | serial.c | 123 | ||||
| -rw-r--r-- | serial.h | 19 | ||||
| -rw-r--r-- | status.c | 68 | ||||
| -rw-r--r-- | status.h | 20 | ||||
| -rw-r--r-- | usb.c | 216 | ||||
| -rw-r--r-- | usb.h | 28 | ||||
| -rw-r--r-- | v4l.c | 137 | ||||
| -rw-r--r-- | v4l.h | 16 | ||||
| -rw-r--r-- | x11.c | 243 | ||||
| -rw-r--r-- | x11.h | 20 | 
90 files changed, 5421 insertions, 0 deletions
| diff --git a/ChangeLog b/ChangeLog new file mode 100644 index 00000000..b46ca90c --- /dev/null +++ b/ChangeLog @@ -0,0 +1,136 @@ +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). + +03/07/2003 13:25 BRST	<leandro@linuxmag.com.br>	0.3.6-pre3 + +	* v4l.[ch], hardinfo.[ch], pixmaps/v4l.png +	  - Added Video 4 Linux support + +02/07/2003 20:51 BRST	<leandro@linuxmag.com.br>	0.3.6-pre2 + +	* pixmaps/cnc.png +	  - Added pixmap for Conectiva Linux. + +	* pci.c +	  - Fixed memory detection bug in lspci parser. + +24/06/2003 20:10 BRST	<leandro@linuxmag.com.br>	0.3.6-pre1 + +	* intl.c +	  - Search for locale information in LANG, LC_MESSAGES and LC_ALL. + +	* about.[ch], hardinfo.[ch], pixmaps/logo.png +	  - Included about box. + +	* configure +	  - Added --with-gtk1 and --with-gtk2. + +	* lang/es_*.lang +	  - Added Spanish translation +	    (Thanks to Erica Andrews <phrozensmoke@yahoo.com>) + +	* pixmaps/usb.png +	  - Changed USB icon a little bit. + +23/06/2003 15:50 BRST	<leandro@linuxmag.com.br>	0.3.5 + +	* intl.c +	  - Improved error checking. +	  - Fixed segfault. +	    (Patch from Sameh Attia <sameh.attia@tedata.net>) + +	* configure +	  - Added option to disable i18n (--disable-nls). + +22/06/2003 21:52 BRST	<leandro@linuxmag.com.br>	0.3.4 + +	* 0.3.4 released! + +19/06/2003 21:42 BRST	<leandro@linuxmag.com.br>	0.3.4-pre2 + +	* intl.c, intl.h, genintl.pl, lang/* +	  - Added i18n support. + +	* configure, computer.c +	  - Finished PowerPC processor information support. + +19/06/2003 10:52 BRST	<leandro@linuxmag.com.br>	0.3.4-pre1 + +	* hardinfo.h +	  - Fixed segfault on startup. +	    (Patch from Thomas Zajic <zlatko@gmx.at>) + +	* x11.c, x11.h, hardinfo.c +	  - Added X-Window system information. + +	* pixmaps/x11.png +	  - Added pixmap for X-Window information. + +	* configure, computer.c +	  - Preliminary PowerPC processor information support. + +18/06/2003 22:14 BRST	<leandro@linuxmag.com.br>	0.3.3 + +	* pci.c +	  - Fixed a bug in lspci parser. + +	* computer.c, computer.h, hardinfo.c, hardinfo.h +	  - Added operating system, processor and memory information + +	* hardinfo.c, hardinfo.h +	  - Added "Refresh" and "Close" buttons + +16/06/2003 17:50 BRST	<leandro@linuxmag.com.br>	0.3.2 + +	* configure, Makefile.in, hardinfo.c, pci.c +	  - Some cleanups. + +16/06/2003 17:41 BRST	<leandro@linuxmag.com.br>	0.3.2-pre2 + +	* configure, Makefile.in +	  - Using automatic configuration utility: +	    o If GTK2 isn't available, the GTK1.2 version will be built. +	    o Search for lspci in various paths. If not found, fall back +	      to the old /proc/pci parser. + +	* hardinfo.c +	  - Parallel Port support added. + +	* ide.c, isapnp.c, parport.c, pci.c, scsi.c, serial.c, usb.c +	  - Separate parsers from GUI. + +	* *.xpm +	  - Moved *.xpm to pixmaps/. + +16/06/2003 10:46 BRST	<leandro@linuxmag.com.br>	0.3.2-pre1 + +	* hardinfo.c +	  - SCSI support added. +	    (Patch from Pascal F.Martin <pascalmartin@earthlink.net>) +	  - Fixed lspci path (it's now fixed in "/sbin/lspci", which seems +	    to be the default, as Google says). +	 +	* *.png +	  - Moved all PNG files to pixmaps/. + + +15/06/2003 21:17 BRST	<leandro@linuxmag.com.br>	0.3.1 + +	* hardinfo.c +	  - Application is now exits when the window is closed. +	  - Parse `lspci -v' output instead of `/proc/pci', which +	    is deprecated. This should work with 2.5 kernels too! +	  - Images are not loaded from current directory anymore. + +	* debian/ +	  - HardInfo is now Debianized. :) + +	* Makefile +	  - Added `install' target. +	  - Images are now installed in `/usr/share/hardinfo/pixmaps'. diff --git a/Makefile.in b/Makefile.in new file mode 100644 index 00000000..fa0aab7e --- /dev/null +++ b/Makefile.in @@ -0,0 +1,47 @@ +# ---------------------------------------------------------------------------- + +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 + +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 +	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} + @@ -0,0 +1,8 @@ + + +Some sites that mentions HardInfo: +---------------------------------- + +- http://www.smlug.org/meetings/2003/06.php +- http://www.linuxzone.cz/modules/tisk_clanku-nw.phtml?ids=7&idc=742 +- http://vico.kleinplanet.de/crux.html diff --git a/about.c b/about.c new file mode 100644 index 00000000..0d7fae0e --- /dev/null +++ b/about.c @@ -0,0 +1,120 @@ +#include "hardinfo.h" +#include "about.h" + +static void about_close(GtkWidget *widget, gpointer data) +{ +	GtkAbout *about = (GtkAbout*) data; + +	gtk_widget_destroy(about->window); +} + +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; +	GtkAbout *about; +	gint i; + +	about = g_new0(GtkAbout, 1); + +	window = gtk_window_new(GTK_WINDOW_TOPLEVEL); +	gtk_window_set_title(GTK_WINDOW(window), "About"); +	gtk_container_set_border_width(GTK_CONTAINER(window), 8); + +	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); + +	ADD_LABEL(description, vbox); + +	for (i = 0; authors[i] != NULL; i++) { +		auth = authors[i]; +		 +		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); +		} +	} + +	hr = gtk_hseparator_new(); +	gtk_box_pack_start(GTK_BOX(vbox), hr, FALSE, FALSE, 0); + +	hbox = gtk_hbutton_box_new(); +        gtk_container_set_border_width(GTK_CONTAINER(hbox), 4); +        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); + +#ifdef GTK2 +        btn = gtk_button_new_from_stock(GTK_STOCK_OK); +        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); + +	gtk_widget_show_all(window); + +	return about; + +} diff --git a/about.h b/about.h new file mode 100644 index 00000000..a131b0d9 --- /dev/null +++ b/about.h @@ -0,0 +1,16 @@ +#ifndef __GTK_ABOUT_H__ +#define __GTK_ABOUT_H__ + +typedef struct _GtkAbout GtkAbout; + +struct _GtkAbout { +	GtkWidget *window; +}; + +GtkAbout *gtk_about_new(const gchar * name, +			const gchar * version, +			const gchar * comments, +			const gchar * authors[], +			const gchar * logo_img); + +#endif				/* __GTK_ABOUT_H__ */ diff --git a/computer.c b/computer.c new file mode 100644 index 00000000..c88695c4 --- /dev/null +++ b/computer.c @@ -0,0 +1,515 @@ +/* + * Distribuition detection routines + * Copyright (c) 2003 Leandro Pereira <leandro@linuxmag.com.br> + * + * May be distributed under the terms of GNU General Public License version 2. + */ + +#include "hardinfo.h" +#include "computer.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 "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 } +}; + +#define get_int_val(var)  { \ +		walk_until_inclusive(':'); buf++; \ +		var = atoi(buf); \ +		continue; \ +	} + +#define get_str_val(var)  { \ +		walk_until_inclusive(':'); buf++; \ +		var = g_strdup(buf); \ +		continue; \ +	} + +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) + +	} +	fclose(procmem); + +	mi->used  = mi->total - memfree; + +	mi->total/=1000; +	mi->cached/=1000; +	mi->used/=1000;	 +	memfree/=1000; + +	memused = mi->total - mi->used + mi->cached; + +#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; + +	return mi; +} + +#if defined(ARCH_i386) || defined(ARCH_x86_64) +#define PARSE_PROC_CPU()					\ +		if(!strncmp(buf, "bogomips", 8))		\ +			get_int_val(ci->bogomips)		\ +		else if(!strncmp(buf, "cpu family", 10))	\ +			get_int_val(ci->family)			\ +		else if(!strncmp(buf, "model name", 10))	\ +			get_str_val(ci->processor)		\ +		else if(!strncmp(buf, "stepping", 8))		\ +			get_int_val(ci->stepping)		\ +		else if(!strncmp(buf, "cpu MHz", 7))		\ +			get_int_val(ci->frequency)		\ +		else if(!strncmp(buf, "cache size", 10))	\ +			get_int_val(ci->cachel2)		\ +		else if(!strncmp(buf, "model", 5))		\ +			get_int_val(ci->model)			 +#endif +#ifdef ARCH_PPC +#define PARSE_PROC_CPU()					\ +		if(!strncmp(buf, "bogomips", 8))		\ +			get_int_val(ci->bogomips)		\ +		else if(!strncmp(buf, "cpu", 3))		\ +			get_str_val(ci->processor)		\ +		else if(!strncmp(buf, "clock", 5))		\ +			get_int_val(ci->frequency)		\ +		else if(!strncmp(buf, "L2 cache", 8))		\ +			get_int_val(ci->cachel2)		 +#endif + +#ifndef PARSE_PROC_CPU +#error ARCH_i386 or ARCH_PPC not defined! Add support! Send me patches! +#endif + +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); + +#ifdef ARCH_PPC +	{ +		gchar *proctemp; +		 +		proctemp = g_strdup_printf("PowerPC %s", ci->processor); +		g_free(ci->processor); +		ci->processor = proctemp; +	} +#endif +	 +	 +} + +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; +		} +	} + +	uname(&utsbuf); +	 +	ci->kernel = g_strdup_printf("%s %s (%s)", utsbuf.sysname, +		utsbuf.release, utsbuf.machine); + +	ci->hostname = g_strdup(utsbuf.nodename); + +	computer_processor_info(ci); + +	return ci; +} + +/* + * 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; +	 +#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));  +	} + +	gtk_label_set_text(GTK_LABEL(mainwindow->uptime), buf); +	g_free(buf); +	 +	return TRUE; +} + +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 + +	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 +	 */  +#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); + +#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); + +#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); + +#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); + + +	/* +	 * 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; +} + +gboolean memory_update(gpointer data) +{ +	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 *memory_get_widget(MainWindow *mainwindow) +{ +	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 + +	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); + +#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); +#endif + +	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; +} + diff --git a/computer.h b/computer.h new file mode 100644 index 00000000..60579689 --- /dev/null +++ b/computer.h @@ -0,0 +1,45 @@ +#ifndef __COMPUTER_H__ +#define __COMPUTER_H__ + +#include <glib.h> + +#define DB_PREFIX	"/etc/" + +typedef struct _ComputerInfo ComputerInfo; +typedef struct _MemoryInfo   MemoryInfo; + +struct _MemoryInfo { +	gint total; +	gint used; +	gint cached; + +	gdouble ratio; +}; + +struct _ComputerInfo { +	gchar *distrocode; +	gchar *distroinfo; +	 +	gchar *kernel; +	 +	gchar *hostname; +	 +	gint  procno; +	gchar *processor; +	gint  frequency; +	gint  family, model, stepping; +	gint  cachel2; +	gint  bogomips; +}; + +ComputerInfo *computer_get_info(void); +MemoryInfo *memory_get_info(void); + +GtkWidget *os_get_widget(MainWindow *mainwindow); +GtkWidget *memory_get_widget(MainWindow *mainwindow); +GtkWidget *processor_get_widget(void); + +gboolean uptime_update(gpointer data); +gboolean memory_update(gpointer data); + +#endif diff --git a/configure b/configure new file mode 100755 index 00000000..7ea4e433 --- /dev/null +++ b/configure @@ -0,0 +1,228 @@ +#!/usr/bin/env bash +# +# ToscoConf 0.02 +# Copyright (c) 2003 Leandro Pereira <leandro@linuxmag.com.br> +# All rights reserved. +# +# This script is in the Tosco Public License. It may be copied and/or +# modified, in whole or in part, provided that all copies must retain the +# above copyright notice, this condition and the following disclaimer. +# +# THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, +# INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY +# AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE +# COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT +# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +# +# (yes, I did a copy&paste from the BSD license, eat me) +# +# --------------------------------------------------------------------------- +# Some defaults + +IGNORE_GTK2=0 +DISABLE_NLS=0 + +# --------------------------------------------------------------------------- + +PACKAGE=`basename ${PWD} | cut -d"-" -f1`; +VERSION=`basename ${PWD} | cut -d"-" -f2`; + +echo "ToscoConf (version 0.03) 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-nls) +			echo "NLS disabled." +			DISABLE_NLS=1 ;; +		--help) +			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 " --help			This help screen." + +			exit 1;; +		*) +			echo "Please use the --help switch." +			exit 1;; +	esac +	shift +done + + +# --------------------------------------------------------------------------- + +echo -n "Running: " +OS=`uname` +echo -n $OS +case $OS in		 +	Linux) +		echo -n " (OK) " ;; +	*) +		echo " (not supported, yet!)" +		exit ;; +esac	 + +PROC=`uname -m` +case $PROC in +	i?86) +		ARCH="ARCH_i386" ;; +	ppc) +		ARCH="ARCH_PPC" ;; +	x86_64) +		ARCH="ARCH_x86_64" ;; +	*) +		echo "Architeture \"$ARCH\" not supported."  +		exit ;; +esac + +echo "$PROC ($ARCH)" + +# --------------------------------------------------------------------------- + +echo -n "Checking for lspci... " +LSPCIPATH="`which lspci` /sbin/lspci /usr/sbin/lspci /bin/lspci /usr/bin/lspci" +for i in $LSPCIPATH; do +	if [ -x "$i" ]; then +		USE_LSPCI=1 +		LSPCI=$i +		break; +	fi +done + +if [ -e "$LSPCI" ]; then +	echo $LSPCI +else +	if [ -e "/proc/pci" ]; then +		echo "not found, will parse /proc/pci" +	else +		echo "no lspci, no /proc/pci..." +		echo "Are you sure you're running Linux?" +		exit +	fi +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 + +# 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 + +# -------------------------------------------------------------------------- + +if [ `expr $GTK1 + $GTK2` -eq -2 ]; 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" +	echo "Will do the trick." +	exit +fi + +# -------------------------------------------------------------------------- + +echo -e "\nWriting config.h..." +rm -f config.h +echo -e "#ifndef __CONFIG_H__\n#define __CONFIG_H__\n" > config.h + +echo "#define VERSION \"$VERSION\"" >> config.h + +if [ "$LSPCI" ]; then +	echo "#define USE_LSPCI" >> config.h +	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 + +if [ "$DISABLE_NLS" != "1" ]; then +	echo "#define ENABLE_NLS" >> config.h +fi + +echo "#define $ARCH" >> 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 "GTK_LIBS = ${GTK_LIBS}" >> Makefile +echo "GTK_CFLAGS = ${GTK_FLAGS}" >> Makefile +echo "PACKAGE = `basename ${PWD}`" >> Makefile + +cat Makefile.in >> Makefile + +echo -e "\nDone. Type \"make\" to compile the program.\n" +echo "If you get errors, probably you don't have the right libraries," +echo "includes or utilities. However, if you're sure this is a bug in my" +echo -e "code, please send a patch (use \"diff -u\") to <leandro@linuxmag.com.br>.\n" + diff --git a/debian/changelog b/debian/changelog new file mode 100644 index 00000000..049c41bf --- /dev/null +++ b/debian/changelog @@ -0,0 +1,72 @@ +hardinfo (0.3.6-5) unstable; urgency=high + +  * Add Amd64 support (closes: #253935). +    Thanks to Kurt Roeckx <Q@ping.be> +  * Close duplicate "doesn't work with newer pciutils" bug (closes: #254018). + + -- Leandro Pereira <leandro@linuxmag.com.br>  Sat, 14 Jun 2004 21:33:25 -0300 + +hardinfo (0.3.6-4) unstable; urgency=high + +  * Fixed segfault on startup (closes: #242843). +    Thanks to Remco van de Meent <remco@debian.org> + + -- Leandro Pereira <leandro@linuxmag.com.br>  Sat, 05 Jun 2004 20:35:12 -0300 + +hardinfo (0.3.6-3) unstable; urgency=high + +  * Added Debian menu entry icon. +  * Fixed some misc packaging bugs. +  * Changed package description. + + -- Leandro Pereira <leandro@linuxmag.com.br>  Sun, 17 Dec 2003 10:52:45 -0300 + +hardinfo (0.3.6-2) unstable; urgency=low + +  * Sync with upstream sources. +  * Disabled "Network" tab. + + -- Leandro Pereira <leandro@linuxmag.com.br>  Sun, 17 Dec 2003 10:31:23 -0300 + +hardinfo (0.3.6-1) unstable; urgency=high + +  * Sync with upstream sources. + + -- Leandro Pereira <leandro@linuxmag.com.br>  Sun, 18 Jul 2003 10:07:58 -0300 + +hardinfo (0.3.5-1) unstable; urgency=high + +  * Sync with upstream sources. + + -- Leandro Pereira <leandro@linuxmag.com.br>  Sun, 23 Jun 2003 15:55:22 -0300 + +hardinfo (0.3.4-1) unstable; urgency=high + +  * Sync with upstream sources. + + -- Leandro Pereira <leandro@linuxmag.com.br>  Sun, 22 Jun 2003 21:45:15 -0300 + +hardinfo (0.3.3-1) unstable; urgency=low + +  * Sync with upstream sources. + + -- Leandro Pereira <leandro@linuxmag.com.br>  Sun, 18 Jun 2003 22:15:34 -0300 + +hardinfo (0.3.2-1) unstable; urgency=low + +  * Sync with upstream sources. + + -- Leandro Pereira <leandro@linuxmag.com.br>  Sun, 17 Jun 2003 10:50:34 -0300 + +hardinfo (0.3.1-1) unstable; urgency=low + +  * Sync with upstream sources. + + -- Leandro Pereira <leandro@linuxmag.com.br>  Sun, 15 Jun 2003 21:32:14 -0300 + +hardinfo (0.3-1) unstable; urgency=low + +  * Initial Release. + + -- Leandro Pereira <leandro@linuxmag.com.br>  Sun, 15 Jun 2003 11:13:14 -0300 + diff --git a/debian/compat b/debian/compat new file mode 100644 index 00000000..b8626c4c --- /dev/null +++ b/debian/compat @@ -0,0 +1 @@ +4 diff --git a/debian/control b/debian/control new file mode 100644 index 00000000..7d215ba2 --- /dev/null +++ b/debian/control @@ -0,0 +1,16 @@ +Source: hardinfo +Section: x11 +Priority: optional +Maintainer: Leandro Pereira <leandro@linuxmag.com.br> +Build-Depends: debhelper (>> 4.0.0), libgtk2.0-dev, pciutils (>=1:2.1.11-10) +Standards-Version: 3.5.8 + +Package: hardinfo +Architecture: any +Depends: ${shlibs:Depends}, pciutils (>=1:2.1.11-10) +Description: Displays system information + HardInfo is a small application that displays information about your + hardware and operating system. Currently it knows about PCI, ISA PnP, USB, + IDE, SCSI, Serial and parallel port devices. + . + Homepage: http://alpha.linuxmag.com.br/~leandro/hardinfo diff --git a/debian/copyright b/debian/copyright new file mode 100644 index 00000000..00d5b7df --- /dev/null +++ b/debian/copyright @@ -0,0 +1,13 @@ +This package was debianized by Leandro Pereira <leandro@linuxmag.com.br> on +Sun, 15 Jun 2003 11:13:14 -0300. + +It was downloaded from http://alpha.linuxmag.com.br/~leandro/hardinfo/ + +Upstream Author: Leandro Pereira <leandro@linuxmag.com.br> + +This software is copyright (c) 2003 by Leandro Pereira. + +You are free to distribute and/or modify this software under the terms of +the GNU General Public License. +On Debian systems, the complete text of the GNU General Public License can +be found in /usr/share/common-licenses/GPL file. diff --git a/debian/dirs b/debian/dirs new file mode 100644 index 00000000..70e8bfc7 --- /dev/null +++ b/debian/dirs @@ -0,0 +1,2 @@ +usr/bin +usr/share/hardinfo/pixmaps diff --git a/debian/hardinfo.1 b/debian/hardinfo.1 new file mode 100644 index 00000000..e3f492f8 --- /dev/null +++ b/debian/hardinfo.1 @@ -0,0 +1,35 @@ +.\"                                      Hey, EMACS: -*- nroff -*- +.\" First parameter, NAME, should be all caps +.\" Second parameter, SECTION, should be 1-8, maybe w/ subsection +.\" other parameters are allowed: see man(7), man(1) +.TH HARDINFO 1 "June 15, 2003" +.\" Please adjust this date whenever revising the manpage. +.\" +.\" Some roff macros, for reference: +.\" .nh        disable hyphenation +.\" .hy        enable hyphenation +.\" .ad l      left justify +.\" .ad b      justify to both left and right margins +.\" .nf        disable filling +.\" .fi        enable filling +.\" .br        insert line break +.\" .sp <n>    insert n+1 empty lines +.\" for manpage-specific macros, see man(7) +.SH NAME +hardinfo \- shows hardware information in a GTK+ window +.SH SYNOPSIS +.B hardinfo +.SH DESCRIPTION +.B hardinfo +parses some files in /proc and displays their information in a +user-friendly window. + +This manual page was written for the Debian distribution +because the original program does not have a manual page. +.PP +.\" TeX users may be more comfortable with the \fB<whatever>\fP and +.\" \fI<whatever>\fP escape sequences to invode bold face and italics,  +.\" respectively. +.SH AUTHOR +This manual page was written by Leandro Pereira <leandro@linuxmag.com.br>, +for the Debian project (but may be used by others). diff --git a/debian/menu b/debian/menu new file mode 100644 index 00000000..474c06a4 --- /dev/null +++ b/debian/menu @@ -0,0 +1,4 @@ +?package(hardinfo):needs=X11 section=Apps/System\ +  title="System Information" command="/usr/bin/hardinfo" \ +  icon=/usr/share/hardinfo/pixmaps/logo.png + diff --git a/debian/postinst b/debian/postinst new file mode 100644 index 00000000..10a660b2 --- /dev/null +++ b/debian/postinst @@ -0,0 +1,48 @@ +#! /bin/sh +# postinst script for hardinfo +# +# see: dh_installdeb(1) + +set -e + +# summary of how this script can be called: +#        * <postinst> `configure' <most-recently-configured-version> +#        * <old-postinst> `abort-upgrade' <new version> +#        * <conflictor's-postinst> `abort-remove' `in-favour' <package> +#          <new-version> +#        * <deconfigured's-postinst> `abort-deconfigure' `in-favour' +#          <failed-install-package> <version> `removing' +#          <conflicting-package> <version> +# for details, see http://www.debian.org/doc/debian-policy/ or +# the debian-policy package +# +# quoting from the policy: +#     Any necessary prompting should almost always be confined to the +#     post-installation script, and should be protected with a conditional +#     so that unnecessary prompting doesn't happen if a package's +#     installation fails and the `postinst' is called with `abort-upgrade', +#     `abort-remove' or `abort-deconfigure'. + +case "$1" in +    configure) + +    ;; + +    abort-upgrade|abort-remove|abort-deconfigure) + +    ;; + +    *) +        echo "postinst called with unknown argument \`$1'" >&2 +        exit 1 +    ;; +esac + +# dh_installdeb will replace this with shell code automatically +# generated by other debhelper scripts. + +#DEBHELPER# + +exit 0 + + diff --git a/debian/postrm b/debian/postrm new file mode 100644 index 00000000..9149cd4c --- /dev/null +++ b/debian/postrm @@ -0,0 +1,38 @@ +#! /bin/sh +# postrm script for hardinfo +# +# see: dh_installdeb(1) + +set -e + +# summary of how this script can be called: +#        * <postrm> `remove' +#        * <postrm> `purge' +#        * <old-postrm> `upgrade' <new-version> +#        * <new-postrm> `failed-upgrade' <old-version> +#        * <new-postrm> `abort-install' +#        * <new-postrm> `abort-install' <old-version> +#        * <new-postrm> `abort-upgrade' <old-version> +#        * <disappearer's-postrm> `disappear' <r>overwrit>r> <new-version> +# for details, see http://www.debian.org/doc/debian-policy/ or +# the debian-policy package + + +case "$1" in +       purge|remove|upgrade|failed-upgrade|abort-install|abort-upgrade|disappear) + + +        ;; + +    *) +        echo "postrm called with unknown argument \`$1'" >&2 +        exit 1 + +esac + +# dh_installdeb will replace this with shell code automatically +# generated by other debhelper scripts. + +#DEBHELPER# + +exit 0 diff --git a/debian/preinst b/debian/preinst new file mode 100644 index 00000000..f7df1741 --- /dev/null +++ b/debian/preinst @@ -0,0 +1,44 @@ +#! /bin/sh +# preinst script for hardinfo +# +# see: dh_installdeb(1) + +set -e + +# summary of how this script can be called: +#        * <new-preinst> `install' +#        * <new-preinst> `install' <old-version> +#        * <new-preinst> `upgrade' <old-version> +#        * <old-preinst> `abort-upgrade' <new-version> +# +# for details, see http://www.debian.org/doc/debian-policy/ or +# the debian-policy package + + +case "$1" in +    install|upgrade) +#        if [ "$1" = "upgrade" ] +#        then +#            start-stop-daemon --stop --quiet --oknodo  \ +#                --pidfile /var/run/hardinfo.pid  \ +#                --exec /usr/sbin/hardinfo 2>/dev/null || true +#        fi +    ;; + +    abort-upgrade) +    ;; + +    *) +        echo "preinst called with unknown argument \`$1'" >&2 +        exit 1 +    ;; +esac + +# dh_installdeb will replace this with shell code automatically +# generated by other debhelper scripts. + +#DEBHELPER# + +exit 0 + + diff --git a/debian/prerm b/debian/prerm new file mode 100644 index 00000000..2a27c8cd --- /dev/null +++ b/debian/prerm @@ -0,0 +1,39 @@ +#! /bin/sh +# prerm script for hardinfo +# +# see: dh_installdeb(1) + +set -e + +# summary of how this script can be called: +#        * <prerm> `remove' +#        * <old-prerm> `upgrade' <new-version> +#        * <new-prerm> `failed-upgrade' <old-version> +#        * <conflictor's-prerm> `remove' `in-favour' <package> <new-version> +#        * <deconfigured's-prerm> `deconfigure' `in-favour' +#          <package-being-installed> <version> `removing' +#          <conflicting-package> <version> +# for details, see http://www.debian.org/doc/debian-policy/ or +# the debian-policy package + + +case "$1" in +    remove|upgrade|deconfigure) +#       install-info --quiet --remove /usr/info/hardinfo.info.gz +        ;; +    failed-upgrade) +        ;; +    *) +        echo "prerm called with unknown argument \`$1'" >&2 +        exit 1 +    ;; +esac + +# dh_installdeb will replace this with shell code automatically +# generated by other debhelper scripts. + +#DEBHELPER# + +exit 0 + + diff --git a/debian/rules b/debian/rules new file mode 100755 index 00000000..9d2c0f5b --- /dev/null +++ b/debian/rules @@ -0,0 +1,95 @@ +#!/usr/bin/make -f +# Sample debian/rules that uses debhelper. +# GNU copyright 1997 to 1999 by Joey Hess. + +# Uncomment this to turn on verbose mode. +#export DH_VERBOSE=1 + + + + +CFLAGS = -Wall -g + +ifneq (,$(findstring noopt,$(DEB_BUILD_OPTIONS))) +	CFLAGS += -O0 +else +	CFLAGS += -O2 +endif +ifeq (,$(findstring nostrip,$(DEB_BUILD_OPTIONS))) +	INSTALL_PROGRAM += -s +endif + +configure: configure-stamp +configure-stamp: +	dh_testdir +	./configure + +	touch configure-stamp + + +build: build-stamp + +build-stamp: configure-stamp  +	dh_testdir + +	$(MAKE) + +	touch build-stamp + +clean: +	dh_testdir +	dh_testroot +	rm -f build-stamp configure-stamp + +	# Add here commands to clean up after the build process. +	-$(MAKE) clean + +	dh_clean + +install: build +	dh_testdir +	dh_testroot +	dh_clean -k +	dh_installdirs + +	# Add here commands to install the package into debian/hardinfo. +	$(MAKE) install DESTDIR=$(CURDIR)/debian/hardinfo + + +# Build architecture-independent files here. +binary-indep: build install +# We have nothing to do by default. + +# Build architecture-dependent files here. +binary-arch: build install +	dh_testdir +	dh_testroot +	dh_installchangelogs ChangeLog +	dh_installdocs +#	dh_installexamples +	dh_install +	dh_installmenu +#	dh_installdebconf	 +#	dh_installlogrotate +#	dh_installemacsen +#	dh_installpam +#	dh_installmime +#	dh_installinit +#	dh_installcron +#	dh_installinfo +	dh_installman debian/hardinfo.1 +	dh_link +	dh_strip +	dh_compress +	dh_fixperms +#	dh_perl +#	dh_python +#	dh_makeshlibs +	dh_installdeb +	dh_shlibdeps +	dh_gencontrol +	dh_md5sums +	dh_builddeb + +binary: binary-indep binary-arch +.PHONY: build clean binary-indep binary-arch binary install configure diff --git a/genintl.pl b/genintl.pl new file mode 100755 index 00000000..0e19846c --- /dev/null +++ b/genintl.pl @@ -0,0 +1,80 @@ +#!/usr/bin/perl +# +# Script para gerar arquivo de internacionalização +# Versão 1.0 +# +# Copyright (c) 2002-2003 Leandro Pereira <leandro@linuxmag.com.br> +# Copyright (c) 2003      RadSys Software Ltda. +# Todos os direitos reservados. +# +# É permitida a distribuição e modificação deste, desde que os créditos +# estejam presentes e que exista uma notificação sobre as modificações +# feitas. +# Não há restrição de uso. +# + +print "Generating `default.lang' catalog...\n"; + +@list=`find *.c`; + +$maxsize=0; +foreach $i (0..$#list){ +	$maxsize=length($list[$i]) if(length($list[$i]) > $maxsize); +} + +open(B, ">default.lang"); + +print B "[Translation]\n"; +print B "translated-by=Unknown\n\n"; + +$messages=0; + +foreach $k (0..$#list){ +	$line=0; +	$thismsg=0; + +	$file=$list[$k]; +	chomp($file); +	print B "[$file]\n"; +	print STDERR "Searching in `$file':"; +	print STDERR " " x ($maxsize - length($file) + 2); + +	open(A, $file); +	while(<A>){ +		$line++; +		if(/_\(/){ +			chomp; +			$_=~s/\t//g; +			$_=~s/_ \(/_\(/g; +	 +			for($i=0; $i<=length($_); $i++){ +				if(substr($_, $i, 1) eq "_" && +				    substr($_, $i+1, 1) eq "\("){			 +					for($j=$i+3; substr($_, $j, 1) ne "\""; $j++){ +						print B substr($_, $j, 1); +					} +					print B "="; +					for($j=$i+3; substr($_, $j, 1) ne "\""; $j++){ +						print B substr($_, $j, 1); +					} +					print B "\n"; + +					$messages++; +					$thismsg++; +				} +			} +		} +	} +	close(A); +	print B "\n"; +	if($thismsg){ +		printf "%02d messages", $thismsg; +	}else{ +		print "Nothing"; +	} +	print " found.\n"; +} + +close(B); + +print "$messages messages saved in `default.lang'\n"; diff --git a/hardinfo.c b/hardinfo.c new file mode 100644 index 00000000..e78cf7f5 --- /dev/null +++ b/hardinfo.c @@ -0,0 +1,623 @@ +/* + * 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 "hardinfo.h" +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <sys/stat.h> + +#include "pixmaps/pci.xpm" +#include "pixmaps/usb.xpm" +#include "pixmaps/hdd.xpm" +#include "pixmaps/gen_connector.xpm" +#include "pixmaps/scsi.xpm" + +#include "computer.h" +#include "status.h" + +GenericDevice *generic_devices = NULL; + +void hi_show_device_info(GtkCTree * tree, GList * node, +			 gint column, gpointer user_data); +void hi_hide_device_info(GtkCTree * tree, GList * node, +			 gint column, gpointer user_data); +void hi_scan_all(MainWindow * mainwindow); + +void +main_window_refresh(GtkWidget * widget, gpointer data) +{ +	MainWindow *mainwindow = (MainWindow *) data; + +	if (!mainwindow) +		return; + +	hi_hide_device_info(NULL, NULL, 0, mainwindow); + +	memory_update(mainwindow); +	uptime_update(mainwindow); +	net_update(mainwindow); + +	hi_scan_all(mainwindow); +} + +static void +about_window_create(void) +{ +	GtkAbout *about; +	const gchar *authors[] = { +		">Written by:", +			"Leandro 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.", +		NULL +	}; + +	about = gtk_about_new("HardInfo", VERSION, +			      _("System information tool for Linux.\n"), +			      authors, IMG_PREFIX "logo.png"); + +} + +MainWindow * +main_window_create(void) +{ +	GtkWidget *window, *mbox, *vbox, *frame, *ctree, *scroll; +	GtkWidget *notebook, *label, *hbox, *btn, *hbbox; +	MainWindow *mainwindow; + +	mainwindow = g_new0(MainWindow, 1); + +	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 + +	mbox = gtk_vbox_new(FALSE, 5); +	gtk_widget_show(mbox); +	gtk_container_add(GTK_CONTAINER(window), mbox); + +	notebook = gtk_notebook_new(); +	gtk_box_pack_start(GTK_BOX(mbox), notebook, TRUE, TRUE, 0); + +	/* +	 * Computer tab +	 */ +	vbox = gtk_vbox_new(FALSE, 5); +	gtk_container_set_border_width(GTK_CONTAINER(vbox), 4); +	gtk_widget_show(vbox); +	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); +	gtk_box_pack_start(GTK_BOX(vbox), memory_get_widget(mainwindow), +			   FALSE, FALSE, 0); + +	/* +	 * Devices tab +	 */ +	vbox = gtk_vbox_new(FALSE, 5); +	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"))); + +	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); +#ifdef GTK2 +	g_signal_connect(G_OBJECT(ctree), "tree-select-row", +			 (GCallback) hi_show_device_info, 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); + +	/* +	 * Environment tab +	 */ +	vbox = gtk_vbox_new(FALSE, 5); +	gtk_container_set_border_width(GTK_CONTAINER(vbox), 4); +	gtk_widget_show(vbox); +	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); + +#if 0 +	/* +	 * Network tab +	 */ +	vbox = gtk_vbox_new(FALSE, 5); +	gtk_container_set_border_width(GTK_CONTAINER(vbox), 4); +	gtk_widget_show(vbox); +	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); +	 +	hbbox = gtk_hbutton_box_new(); +	gtk_container_set_border_width(GTK_CONTAINER(hbbox), 4); +	gtk_widget_show(hbbox); +	gtk_box_pack_start(GTK_BOX(hbox), 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_START); + +	btn = gtk_button_new_with_mnemonic(_("Abo_ut...")); +#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); + +	hbbox = gtk_hbutton_box_new(); +	gtk_container_set_border_width(GTK_CONTAINER(hbbox), 4); +	gtk_widget_show(hbbox); +	gtk_box_pack_end(GTK_BOX(hbox), 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); + +#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; +} + +static GdkColor +gdk_color_from_rgb(gint r, gint g, gint b) +{ +	GdkColormap *cmap = NULL; +	GdkColor color; + +	if (!cmap) { +		cmap = gdk_colormap_get_system(); +		gdk_colormap_ref(cmap); +	} + +	color.red = r * 255; +	color.green = g * 255; +	color.blue = b * 255; + +	gdk_color_alloc(cmap, &color); +	gdk_colormap_unref(cmap); + +	return color; +} + +GtkCTreeNode * +tree_group_new(MainWindow * mainwindow, const gchar * name, DeviceType type) +{ +	GtkCTreeNode *node; +	const gchar *text[] = { NULL, name, NULL }; +	GdkPixmap *pixmap = NULL; +	GdkBitmap *mask = NULL; +	GdkColor color; +	GdkColormap *colormap = NULL; + +	if (!name) +		return NULL; +	if (type == NONE) +		return NULL; +	if (!mainwindow) +		return NULL; + +	colormap = gtk_widget_get_colormap(mainwindow->window); + +	switch (type) { +	case PARPORT: +	case SERIAL: +		pixmap = gdk_pixmap_colormap_create_from_xpm_d +		    (NULL, colormap, &mask, NULL, gen_connector_xpm); + +		break; +	case V4L: +	case PCI: +	case ISAPnP: +		pixmap = gdk_pixmap_colormap_create_from_xpm_d +		    (NULL, colormap, &mask, NULL, pci_xpm); +		break; +	case SCSI: +		pixmap = gdk_pixmap_colormap_create_from_xpm_d +		    (NULL, colormap, &mask, NULL, scsi_xpm); +		break; +	case IDE: +		pixmap = gdk_pixmap_colormap_create_from_xpm_d +		    (NULL, colormap, &mask, NULL, hdd_xpm); +		break; +	case USB: +		pixmap = gdk_pixmap_colormap_create_from_xpm_d +		    (NULL, colormap, &mask, NULL, usb_xpm); +		break; +	default: +		mask = pixmap = NULL; +		break; +	} + +	node = gtk_ctree_insert_node(GTK_CTREE(mainwindow->ctree), +				     NULL, NULL, text, 0, pixmap, mask, pixmap, +				     mask, FALSE, TRUE); + +	color = gdk_color_from_rgb(0xcc, 0xcc, 0xcc); +	gtk_ctree_node_set_background(GTK_CTREE(mainwindow->ctree), +				      node, &color); + +	gdk_pixmap_unref(pixmap); +	gdk_bitmap_unref(mask); + +	return node; +} + +void +tree_insert_item(MainWindow * mainwindow, GtkCTreeNode * group, gchar * name, +		 gpointer data) +{ +	GtkCTreeNode *node; +	gchar *text[] = { NULL, name, NULL }; + +	if (!mainwindow) +		return; +	if (!name) +		return; +	if (!group) +		return; + +	node = gtk_ctree_insert_node(GTK_CTREE(mainwindow->ctree), +				     group, NULL, +				     text, 0, +				     NULL, NULL, NULL, NULL, FALSE, TRUE); +	gtk_ctree_node_set_row_data(GTK_CTREE(mainwindow->ctree), node, data); +} + +void +hi_insert_generic(gpointer device, DeviceType type) +{ +	GenericDevice *generic; + +	generic = g_new0(GenericDevice, 1); + +	generic->next = generic_devices; +	generic_devices = generic; + +	generic_devices->device = device; +	generic_devices->type = type; +} + +void +hi_hide_device_info(GtkCTree * tree, GList * node, +		    gint column, gpointer user_data) +{ +	MainWindow *mainwindow = (MainWindow *) user_data; + +	gtk_widget_hide(mainwindow->frame); +} + +void +hi_show_device_info(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); + +	if (!dev) +		return; + +#define dev_info(type,name,func) \ +	{ \ +		type *name; \ +		name = (type *)dev->device; \ +		func(mainwindow, name); \ +	} \ +	break; + +	switch (dev->type) { +	case PCI: +		dev_info(PCIDevice, pci, hi_show_pci_info); +	case ISAPnP: +		dev_info(ISADevice, isa, hi_show_isa_info); +	case USB: +		dev_info(USBDevice, usb, hi_show_usb_info); +	case SERIAL: +		dev_info(SerialDevice, serial, hi_show_serial_info); +	case PARPORT: +		dev_info(ParportDevice, parport, hi_show_parport_info); +	case IDE: +		dev_info(IDEDevice, ide, hi_show_ide_info); +	case SCSI: +		dev_info(SCSIDevice, scsi, hi_show_scsi_info); +	case V4L: +		dev_info(V4LDevice, v4l, hi_show_v4l_info); +	default: +		g_print("Showing info of device type %d not implemented yet.\n", +			dev->type); +		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; + +	status = my_status_new(_("Scanning Devices"), _("Scanning devices...")); + +#define DEVICE_SCAN(name,ptr,func) \ +		ptr = func(); \ +		buf = g_strdup_printf(_("Scanning %s devices..."), name); \ +		my_status_set_text(status, buf); \ +		g_free(buf); \ +		my_status_pulse(status) +	 +	DEVICE_SCAN("PCI",	pci,	hi_scan_pci); +	DEVICE_SCAN("ISA PnP",	isa,	hi_scan_isapnp); +	DEVICE_SCAN("IDE",	ide,	hi_scan_ide); +	DEVICE_SCAN("SCSI",	scsi,	hi_scan_scsi); +	DEVICE_SCAN("V4L",	v4l,	hi_scan_v4l); +	DEVICE_SCAN("Parallel",	pp,	hi_scan_parport); +	DEVICE_SCAN("Serial",	sd,	hi_scan_serial); + +	gtk_clist_freeze(GTK_CLIST(mainwindow->ctree)); + +	/* +	 * Free the generic_devices stuff and remove all device-related +	 * nodes. +	 */ +	if (gd != NULL) { +		for (; gd != NULL; gd = gd->next) { +			g_free(gd->device); +			gtk_ctree_remove_node(GTK_CTREE(mainwindow->ctree), +					      gd->node); +			g_free(gd); +		} +		generic_devices = NULL; +	} +	 +#define CHECK_INSERT(a,b,c,d) \ +	if (a) { \ +		node = tree_group_new(mainwindow, b, c); \ +		for (; a != NULL; a = a->next) { \ +			if (a->d) { \ +				hi_insert_generic(a, c); \ +				tree_insert_item(mainwindow, node, a->d, \ +					generic_devices); \ +			} \ +		} \ +	} + +	CHECK_INSERT(pci, _("PCI Devices"), PCI, name); +	CHECK_INSERT(isa, _("ISA PnP Devices"), ISAPnP, card); + +	/* +	 * USB is different since it's Plug'n'Pray, so we have a +	 * routine just for it :) +	 */ +	usb_update(mainwindow); + +	CHECK_INSERT(ide, _("ATA/IDE Block Devices"), IDE, model); +	CHECK_INSERT(scsi, _("SCSI Devices"), SCSI, model); +	CHECK_INSERT(v4l, _("Video for Linux"), V4L, name); +	CHECK_INSERT(sd, _("Communication Ports"), SERIAL, name); +	CHECK_INSERT(pp, _("Parallel Ports"), PARPORT, name); + +	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); +	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 +	    ("Copyright (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(_ +		("under the terms of GNU GPL version 2. See http://www.fsf.org/\n")); +	g_print(_("for more information.\n\n")); + +	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 + +#if 0 +	for (i = 1; i < argc; i++) { +		if (!strncmp(argv[i], "--help", 6) || +		    !strncmp(argv[i], "-h", 2)) { +			usage(argv[0]); +		} else +		    if (!strncmp(argv[i], "--prefix", 8) || +			!strncmp(argv[i], "-p", 2)) { +			i++; +			if (argv[i][0] == '-') +				usage(argv[0]); + +			g_print("prefix = %s\n", argv[i]); +		} +	} +#endif + +	mainwindow = main_window_create(); +	main_window_refresh(NULL, mainwindow); + +	gtk_main(); + +	return 0; +} diff --git a/hardinfo.desktop b/hardinfo.desktop new file mode 100644 index 00000000..32895d6d --- /dev/null +++ b/hardinfo.desktop @@ -0,0 +1,12 @@ +[Desktop Entry] +Name=System Information (hardinfo) +Name[pt_BR]=Informações do Sistema (hardinfo) +Comment=Information on your hardware devices +Comment[pt_BR]=Informações sobre seus dispositivos de hardware +Exec=hardinfo +Icon=/usr/share/hardinfo/pixmaps/logo.png +Terminal=false +MultipleArgs=false +Type=Application +StartupNotify=true +Categories=Application;System diff --git a/hardinfo.h b/hardinfo.h new file mode 100644 index 00000000..8ba587d0 --- /dev/null +++ b/hardinfo.h @@ -0,0 +1,86 @@ +#ifndef __HARDINFO_H__ +#define __HARDINFO_H__ + +#define walk_until(x)   while((*buf != '\0') && (*buf != x)) buf++ +#define walk_until_inclusive(x) walk_until(x); buf++ + +#define PREFIX		"/usr/share/hardinfo/" +#define IMG_PREFIX	PREFIX "pixmaps/" + +#include <gtk/gtk.h> +#include <stdio.h> +#include <string.h> +#include <sys/stat.h> + +#include "config.h" + +#ifdef ENABLE_NLS +#define	INTL_PREFIX	PREFIX "lang/" +#include "intl.h" +#else +#define _(x)	(x) +#endif + +typedef struct _GenericDevice	GenericDevice; +typedef enum   _DeviceType	DeviceType; + +typedef struct _MainWindow	MainWindow; + +enum _DeviceType { +	NONE, PCI, ISAPnP, USB, +	IDE, SCSI, SERIAL, PARPORT, +	V4L +}; + +struct _GenericDevice { +	gpointer device; +	DeviceType type; + +	GtkCTreeNode *node; +	 +	GenericDevice *next; +}; + +struct _MainWindow { +	GtkWidget *window; +	 +	GtkWidget *ctree; +	 +	GtkWidget *frame; +	GtkWidget *framec; +	 +	GtkWidget *membar; +	GtkWidget *uptime; +	 +	GtkWidget *recv_bytes; +	GtkWidget *recv_errors; +	GtkWidget *recv_packets; +	 +	GtkWidget *trans_bytes; +	GtkWidget *trans_errors; +	GtkWidget *trans_packets; +}; + +extern GenericDevice *generic_devices; + +#include "ide.h" +#include "scsi.h" +#include "isapnp.h" +#include "usb.h" +#include "pci.h" +#include "serial.h" +#include "parport.h" +#include "v4l.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); + +#endif @@ -0,0 +1,142 @@ +/* + * 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 "hardinfo.h" +#include "ide.h" + +#include <stdlib.h> + +IDEDevice *hi_scan_ide(void) +{ +	FILE *proc_ide; +	gchar *device, iface; +	gint n=0, i=0; +	struct stat st; +	IDEDevice *ide_dev, *ide; +	 +	ide = NULL;	 +	 +	for (i=0; i<=16; i++) { +		iface='a'+i; +		device = g_strdup_printf("/proc/ide/hd%c/model", iface); +		if (!stat(device, &st)) {  +			gchar buf[64]; +			 +			ide_dev = g_new0(IDEDevice, 1); +			ide_dev->next = ide; +			ide = ide_dev; +			 +			proc_ide = fopen(device, "r"); +			fgets(buf, 64, proc_ide); +			fclose(proc_ide); +			 +			buf[strlen(buf)-1]=0; +			 +			ide_dev->model = g_strdup(buf); +			 +			g_free(device); +			 +			device = g_strdup_printf("/proc/ide/hd%c/media", iface); +			proc_ide = fopen(device, "r"); +			fgets(buf, 64, proc_ide); +			fclose(proc_ide); +			buf[strlen(buf)-1]=0; +			 +			ide_dev->media = g_strdup(buf); +						 +			g_free(device); +			 +			device = g_strdup_printf("/proc/ide/hd%c/cache", iface); +			if (!stat(device, &st)) { +				proc_ide = fopen(device, "r"); +				fgets(buf, 64, proc_ide); +				fclose(proc_ide); +			 +				ide_dev->cache = atoi(buf); +			}					 +			n++; +		} +		g_free(device); +	} +	 +	return ide; +} + +void hi_show_ide_info(MainWindow *mainwindow, IDEDevice *device) +{ +	GtkWidget *hbox, *vbox, *label; +        static struct { +                char *type; +                char *label; +                char *icon;  +        } type2icon[] = {    +                {"cdrom",       "CD-ROM",         "cd.png"}, +                {"disk",	"Hard Disk",	  "hdd.png"} +        }; +        int i; +	gchar *buf; +#ifdef GTK2 +	GtkWidget *pixmap;	 +#endif + +	if(!device) return; +	 +	for (i = 0; type2icon[i].type != NULL; ++i) { +		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; + +	buf = g_strdup_printf(_("ATA/IDE %s Device"), type2icon[i].label); +	gtk_frame_set_label(GTK_FRAME(mainwindow->frame), 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); +	 +	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); +	}	 +} @@ -0,0 +1,18 @@ +#ifndef __IDE_H__ +#define __IDE_H__ + +typedef struct _IDEDevice	IDEDevice; + +struct _IDEDevice { +	gchar *model; +	 +	gchar *media; +	gint cache; + +	IDEDevice *next; +}; + +void hi_show_ide_info(MainWindow *mainwindow, IDEDevice *device); +IDEDevice *hi_scan_ide(void); + +#endif @@ -0,0 +1,111 @@ +/* + * ToscoIntl version 0.1 + * Copyright (c) 2002-2003 Leandro Pereira <leandro@linuxmag.com.br> + * All rights reserved. + * + * This script is in the Tosco Public License. It may be copied and/or + * modified, in whole or in part, provided that all copies and related + * documentation includes the above copyright notice, this condition + * and the following disclaimer. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, + * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY + * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * + * (yes, the disclaimer is a copy from the BSD license, eat me!) + */ + +#include <stdio.h> +#include <string.h> +#include <stdlib.h> +#include <sys/stat.h> + +#include "hardinfo.h" + +#ifdef ENABLE_NLS + +void intl_init(void) +{ +	const gchar *by; +	 +	g_print("Translation module registered.\n"); + +	by = intl_translate("translated-by", "Translation"); +	if (strcmp(by, "translated-by")) { +		g_print("Translated by: %s\n", by); +	} +} + +/* + * GNU's gettext is cool and all... but hey, this is smaller :) + */ +const gchar * +intl_translate(const gchar * string, const gchar * source) __THROW +{ +	FILE *file; +	gchar buffer[256], *keyname, *lang = NULL, *langenv = NULL; +	const gchar *retval, *langvars[] = +		 {"LANG", "LC_MESSAGES", "LC_ALL", NULL}; +	gboolean found; +	struct stat st; +	gint i = 0; + +	keyname = g_strdup_printf("[%s]", source); + +	for (; langvars[i]; i++) +		if (getenv(langvars[i])) { +			langenv = getenv(langvars[i]); +			goto langenv_ok; +		} + +	goto not_found; + +     langenv_ok: +	lang = g_strconcat(INTL_PREFIX, langenv, ".lang", NULL); +	if (stat(lang, &st)) { +		lang = g_strconcat(INTL_PREFIX, "default.lang", NULL); +		if (stat(lang, &st)) { +		     not_found: +			retval = string; +			goto finished; +		}  +	} + +	retval  = string; + +	file = fopen(lang, "r"); +	if (!file) +		goto finished; +	 +	while (fgets(buffer, 256, file)) { +		const gchar *buf = buffer; +		 +		buf = g_strstrip(buf); +		 +		if (*buf == '[' && !found && +			!strncmp(buf, keyname, strlen(keyname))) +				found = TRUE; +		if (found && !strncmp(buf, string, strlen(string)) && +			*(buf + strlen(string)) == '=') { +				walk_until_inclusive('='); +				retval = g_strdup(buf); + +				fclose(file); +	 +				goto finished; +		} +	} +	fclose(file); +	 +     finished: +     	g_free(keyname); +     	g_free(lang); + +	return retval; +} + +#endif @@ -0,0 +1,11 @@ +#ifndef __INTL_H__ +#define __INTL_H__ + +#include "config.h" + +void intl_init(void); +const gchar *intl_translate(const gchar *string, const gchar *source) __THROW; + +#define _(x) (intl_translate(x, __FILE__)) + +#endif				/* __INTL_H__ */ diff --git a/isapnp.c b/isapnp.c new file mode 100644 index 00000000..39163349 --- /dev/null +++ b/isapnp.c @@ -0,0 +1,130 @@ +/* + * Hardware Information, version 0.3.1b + * Copyright (C) 2003 Leandro Pereira <leandro@linuxmag.com.br> + * + * May be modified and/or distributed under the terms of GNU GPL version 2. + * + */ + +#include "hardinfo.h" +#include "isapnp.h" + +ISADevice *hi_scan_isapnp(void) +{ +	FILE *proc_isapnp; +	gchar buffer[256], *buf; +	gint n=0; +	ISADevice *isa_dev, *isa; +	struct stat st; +	 +	isa = NULL; +	 +	if(stat("/proc/isapnp", &st)) return NULL; + +	proc_isapnp = fopen("/proc/isapnp", "r"); +	while(fgets(buffer, 256, proc_isapnp)){ +		buf = g_strstrip(buffer); +		if(!strncmp(buf, "Card", 4)){ +			gboolean lock = FALSE; +			gfloat pnpversion, prodversion; +			gint card_id; +			gpointer start, end; +			 +			sscanf(buf, "Card %d", &card_id); +			 +			for (; buf != NULL; buf++) { +				if (lock && *buf == '\'') { +					end = buf; +					break; +				} else if (!lock && *buf == ':') { +					start = buf+1; +					lock = TRUE; +				} +			} +			buf+=2; +			 +			sscanf(buf, "PnP version %f Product version %f", &pnpversion, &prodversion); +			 +			buf = end; +			*buf=0; +			buf = start; +			 +			isa_dev = g_new0(ISADevice, 1); +			 +			isa_dev->next = isa; +			isa = isa_dev; +			 +			isa_dev->pnpversion = pnpversion; +			isa_dev->prodversion = prodversion; +			isa_dev->card_id = card_id; +			 +			isa_dev->card = g_strdup(buf); +			 +			n++;			 +		} +	} +	fclose(proc_isapnp); +	 +	return isa; +} + +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")); +	 +#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->card); +	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->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); +	g_free(buf); +} + diff --git a/isapnp.h b/isapnp.h new file mode 100644 index 00000000..e6e283c9 --- /dev/null +++ b/isapnp.h @@ -0,0 +1,20 @@ +#ifndef __ISAPnP_H__ +#define __ISAPnP_H__ + +#include "hardinfo.h" + +typedef struct _ISADevice	ISADevice; + +struct _ISADevice { +	gchar *card; +	gint card_id; +	gfloat pnpversion, prodversion; + +	ISADevice *next; +}; + +ISADevice *hi_scan_isapnp(void); +void hi_show_isa_info(MainWindow *mainwindow, ISADevice *device); + + +#endif diff --git a/lang/es_CO.lang b/lang/es_CO.lang new file mode 120000 index 00000000..990137fc --- /dev/null +++ b/lang/es_CO.lang @@ -0,0 +1 @@ +es_MX.ISO-8859-1.lang
\ No newline at end of file diff --git a/lang/es_DO.lang b/lang/es_DO.lang new file mode 120000 index 00000000..990137fc --- /dev/null +++ b/lang/es_DO.lang @@ -0,0 +1 @@ +es_MX.ISO-8859-1.lang
\ No newline at end of file diff --git a/lang/es_ES.lang b/lang/es_ES.lang new file mode 120000 index 00000000..990137fc --- /dev/null +++ b/lang/es_ES.lang @@ -0,0 +1 @@ +es_MX.ISO-8859-1.lang
\ No newline at end of file diff --git a/lang/es_GT.lang b/lang/es_GT.lang new file mode 120000 index 00000000..990137fc --- /dev/null +++ b/lang/es_GT.lang @@ -0,0 +1 @@ +es_MX.ISO-8859-1.lang
\ No newline at end of file diff --git a/lang/es_MX.ISO-8859-1.lang b/lang/es_MX.ISO-8859-1.lang new file mode 100644 index 00000000..79511225 --- /dev/null +++ b/lang/es_MX.ISO-8859-1.lang @@ -0,0 +1,117 @@ +[Translation] +translated-by=Erica Andrews <PhrozenSmoke@yahoo.com> + +[computer.c] +Unknown distribution=Distribución desconocido +%d hour%s and %ld minute%s=%d hora%s y %ld minuto%s +%d day%s, %d hour%s and %ld minute%s=%d dia%s, %d hora%s y %ld minuto%s +<b>Computer name:</b>=<b>Nombre de computadora:</b> +Computer name:=Nombre de computadora: +<b>Distribution:</b>=<b>Distribución:</b> +Distribution:=Distribución: +<b>Kernel:</b>=<b>Kernel:</b> +Kernel:=Kernel: +<b>Uptime:</b>=<b>Uptime:</b> +Uptime:=Uptime: +Updating...=Atualizando... +<b>%s</b> at %d MHz (%d bogomips)=<b>%s</b> en %d MHz (%d bogomips) +%s at %d MHz (%d bogomips)=%s en %d MHz (%d bogomips) +Family %d, model %d, stepping %d=Familia %d, modelo %d, stepping %d +%d KB L2 cache=%d KB de caché L2 + +[hardinfo.c] +System Information=Información de Sistema +Computer=Computadora +<b><big>Operating System</big></b>=<b><big>Sistema Operativo</big></b> +Operating System=Sistema Operativo +<b><big>Processor</big></b>=<b><big>Procesador</big></b> +Processor=Procesador +<b><big>Memory Usage</big></b>=<b><big>Uso de Memoria</big></b> +Memory Usage=Uso de Memoria +Devices=Dispositivos +Device information=Información de Dispositivo +Refresh=Refrescar +Close=Cerrar +Environment=Ambiente +<b><big>X-Window System</big></b>=<b><big>X-Window System</big></b> +X-Window System=Sistema X-Window +PCI Devices=Dispositivos PCI +ISA PnP Devices=Dispositivos ISA PnP +ATA/IDE Block Devices=Dispositivos ATA/IDE +SCSI Devices=Dispositivos SCSI +Communication Ports=Puertos de Communicación +Parallel Ports=Puertos Paralelos +This is free software; you can modify and/or distribute it\n=Este programa es software libre; puede modficarlo o distribuirlo\n +under the terms of GNU GPL version 2. See http://www.fsf.org/\n=conforme a los termos de la licencia GNU GPL versión 2. Vea http://www.fsf.org/\n +for more information.\n\n=para más información.\n\n +Translation module registered.\n=Módulo de traducción registrado.\n + +[ide.c] +ATA/IDE %s Device=%s ATA/IDE +Cache: %d KB=Caché: %d KB + +[intl.c] + +[isapnp.c] +ISA Plug and Play Device=Dispositivo ISA Plug and Play +Card ID: %d=Identificación de tarjeta: %d +PnP version: %.2f, Product version: %.2f=Versión PnP: %.2f, versión de producto: %.2f + +[parport.c] +N/A=N/D +Printer=Impresora +Multimedia=Multimedia +Legacy Device=Dispositivo Legado +Parallel Port=Puerto paralelo +Description: %s=Descripción: %s +Command set: %s=Mandos: %s +Class: %s=Clase: %s +Base I/O address: 0x%x=Direccion I/O básico: 0x%x +Modes: %s=Modos: %s +Uses DMA=Uso acesso directo a memoria + +[pci.c] +I/O address: 0x%x to 0x%x=Direccion de I/O: desde 0x%x hasta 0x%x +Memory: %ld KB=Memoria: %ld KB +Frequency: %dMHz=Frecuencia: %dMHz +Latency: %d=Tiempo de Latencia: %d +Bus master=Bus master +Bus: %d, Device: %d, Function: %d=Bus: %d, Unidad: %d, Función: %d + +[scsi.c] +Disk=Disco +Tape=Cinta +Printer=Impresora +CD-ROM=CD-ROM +CD-ROM=CD-ROM +Scanner=Escáner +Generic=Genérico +SCSI %s Device=%s SCSI +Revision: %s=Revisión: %s +Type: %s=Tipo: %s +Controller: %d, Bus: %d, ID: %d, LUN: %d=Controlador: %d, Bus: %d, ID: %d, LUN: %d + +[serial.c] +Communication Port=Puerto de Communicación +I/O port: 0x%x, IRQ: %d=Puerto de I/O: 0x%x, IRQ: %d + +[usb.c] +USB Device=Dispositivo USB +Manufacturer: %s=Fabricante: %s +Class: %s (%d)=Clase: %s (%d) +Version: %.2f, Revision: %.2f=Versión: %.2f, Revisión: %.2f +Vendor ID: 0x%X, Product ID: 0x%X=Identificación de fabricante: 0x%X, producto: 0x%X +USB Devices=Dispositivos USB +Unknown device (%s)=Dispositivo desconocido (%s) + +[x11.c] +<b>Display:</b>=<b>Display:</b> +Display:=Display: +<b>Vendor:</b>=<b>Distribuidor:</b> +Vendor:=Distribuidor: +<b>Release:</b>=<b>Versión:</b> +Release:=Versión: +<b>Resolution:</b>=<b>Resolución:</b> +Resolution:=Resolución: +Local display (%s)=Pantalla local (%s) +Remote display (%s)=Pantalla remota (%s) diff --git a/lang/es_MX.lang b/lang/es_MX.lang new file mode 120000 index 00000000..990137fc --- /dev/null +++ b/lang/es_MX.lang @@ -0,0 +1 @@ +es_MX.ISO-8859-1.lang
\ No newline at end of file diff --git a/lang/es_PR.lang b/lang/es_PR.lang new file mode 120000 index 00000000..990137fc --- /dev/null +++ b/lang/es_PR.lang @@ -0,0 +1 @@ +es_MX.ISO-8859-1.lang
\ No newline at end of file diff --git a/lang/es_US.lang b/lang/es_US.lang new file mode 120000 index 00000000..990137fc --- /dev/null +++ b/lang/es_US.lang @@ -0,0 +1 @@ +es_MX.ISO-8859-1.lang
\ No newline at end of file diff --git a/lang/pt_BR.lang b/lang/pt_BR.lang new file mode 100644 index 00000000..cc4c592c --- /dev/null +++ b/lang/pt_BR.lang @@ -0,0 +1,117 @@ +[Translation] +translated-by=Leandro Pereira <leandro@linuxmag.com.br> + +[computer.c] +Unknown distribution=Distribuição desconhecida +%d hour%s and %ld minute%s=%d hora%s e %ld minuto%s +%d day%s, %d hour%s and %ld minute%s=%d dia%s, %d hora%s e %ld minuto%s +<b>Computer name:</b>=<b>Nome do computador:</b> +Computer name:=Nome do computador: +<b>Distribution:</b>=<b>Distribuição:</b> +Distribution:=Distribuição: +<b>Kernel:</b>=<b>Kernel:</b> +Kernel:=Kernel: +<b>Uptime:</b>=<b>Uptime:</b> +Uptime:=Uptime: +Updating...=Atualizando... +<b>%s</b> at %d MHz (%d bogomips)=<b>%s</b> em %d MHz (%d bogomips) +%s at %d MHz (%d bogomips)=%s em %d MHz (%d bogomips) +Family %d, model %d, stepping %d=FamÃlia %d, modelo %d, stepping %d +%d KB L2 cache=%d KB de cache nÃvel 2 + +[hardinfo.c] +System Information=Informações do Sistema +Computer=Computador +<b><big>Operating System</big></b>=<b><big>Sistema Operacional</big></b> +Operating System=Sistema Operacional +<b><big>Processor</big></b>=<b><big>Processador</big></b> +Processor=Processador +<b><big>Memory Usage</big></b>=<b><big>Uso da Memória</big></b> +Memory Usage=Uso da Memória +Devices=Dipositivos +Device information=Informação do Dispositivo +Refresh=Atualizar +Close=Fechar +Environment=Ambiente +<b><big>X-Window System</big></b>=<b><big>X-Window System</big></b> +X-Window System=Sistema X-Window +PCI Devices=Dispositivos PCI +ISA PnP Devices=Dispositivos ISA PnP +ATA/IDE Block Devices=Dispositivos ATA/IDE +SCSI Devices=Dispositivos SCSI +Communication Ports=Portas de Comunicação +Parallel Ports=Portas Paralelas +This is free software; you can modify and/or distribute it\n=Este programa é software livre; você pode modificá-lo e/ou distribuÃ-lo\n +under the terms of GNU GPL version 2. See http://www.fsf.org/\n=sob os termos da GNU GPL versão 2. Veja http://www.fsf.org/\n +for more information.\n\n=para maiores informações.\n\n +Translation module registered.\n=Módulo de tradução registrado.\n + +[ide.c] +ATA/IDE %s Device=%s ATA/IDE +Cache: %d KB=Cache: %d KB + +[intl.c] + +[isapnp.c] +ISA Plug and Play Device=Dispositivo ISA Plug and Play +Card ID: %d=Identificação da placa: %d +PnP version: %.2f, Product version: %.2f=Versão PnP: %.2f, versão do produto: %.2f + +[parport.c] +N/A=N/D +Printer=Impressora +Multimedia=MultimÃdia +Legacy Device=Dispositivo Legado +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 +Modes: %s=Modos: %s +Uses DMA=Usa acesso direto à memória + +[pci.c] +I/O address: 0x%x to 0x%x=Endereço de E/S: 0x%x até 0x%x +Memory: %ld KB=Memória: %ld KB +Frequency: %dMHz=Frequência: %dMHz +Latency: %d=Latência: %d +Bus master=Bus master +Bus: %d, Device: %d, Function: %d=Barramento: %d, Dispositivo: %d, Função: %d + +[scsi.c] +Disk=Disco +Tape=Fita +Printer=Impressora +CD-ROM=CD-ROM +CD-ROM=CD-ROM +Scanner=Scanner +Generic=Genérico +SCSI %s Device=%s SCSI +Revision: %s=Revisão: %s +Type: %s=Tipo: %s +Controller: %d, Bus: %d, ID: %d, LUN: %d=Controlador: %d, Barramento: %d, ID: %d, LUN: %d + +[serial.c] +Communication Port=Porta de Comunicação +I/O port: 0x%x, IRQ: %d=Porta de E/S: 0x%x, IRQ: %d + +[usb.c] +USB Device=Dispositivo USB +Manufacturer: %s=Fabricante: %s +Class: %s (%d)=Classe: %s (%d) +Version: %.2f, Revision: %.2f=Versão: %.2f, Revisão: %.2f +Vendor ID: 0x%X, Product ID: 0x%X=Identificação do fabricante: 0x%X, produto: 0x%X +USB Devices=Dispositivos USB +Unknown device (%s)=Dispositivo desconhecido (%s) + +[x11.c] +<b>Display:</b>=<b>Display:</b> +Display:=Display: +<b>Vendor:</b>=<b>Distribuidor:</b> +Vendor:=Distribuidor: +<b>Release:</b>=<b>Versão:</b> +Release:=Versão: +<b>Resolution:</b>=<b>Resolução:</b> +Resolution:=Resolução: +Local display (%s)=Display local (%s) +Remote display (%s)=Display remoto (%s) @@ -0,0 +1,220 @@ +/* + * 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. + * + * Tested only with 2.4.x kernels on ix86. + * USB support needs netdevfs. + */ + +#include <stdio.h> +#include "hardinfo.h" +#include "net.h" + +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; +} + +gboolean net_update(gpointer data) +{ +    MainWindow *mainwindow = (MainWindow *) data; +    NetDevice *net; + +    if (!mainwindow) +	return FALSE; + +    net = hi_scan_net(); + +    return TRUE; +} + +NetDevice *hi_scan_net(void) +{ +    FILE *proc_net; +    gchar buffer[256]; +    NetDevice *net_dev, *net; +    struct stat st; + +    net = NULL; + +    if (stat("/proc/net/dev", &st)) +	return NULL; + +    proc_net = fopen("/proc/net/dev", "r"); +    while (fgets(buffer, 256, proc_net)) { +	if (strchr(buffer, ':')) { +	    gint trash; +	    gchar ifacename[4]; +	    gchar *buf = buffer; +	    gint i; + +	    net_dev = g_new0(NetDevice, 1); +	    net_dev->next = net; +	    net = net_dev; + +	    buf = g_strstrip(buf); + +	    memset(ifacename, 0, 4); + +	    for (i = 0; buffer[i] != ':' && i < 4; 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", +		   &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); + +	} +    } +    fclose(proc_net); + +    return net; +} @@ -0,0 +1,29 @@ +#ifndef __NET_H__ +#define __NET_H__ + +#include "hardinfo.h" + +typedef struct _NetDevice	NetDevice; + +struct _NetDevice { +	gchar *iface; +	 +	guint recv_bytes; +	guint recv_errors; +	guint recv_packets; +	 +	guint trans_bytes; +	guint trans_errors; +	guint trans_packets; + +	NetDevice *next; +}; + + +NetDevice *hi_scan_net(void); +GtkWidget *net_get_widget(MainWindow *mainwindow); +void hi_show_net_info(MainWindow *mainwindow, NetDevice *device); + +gboolean net_update(gpointer data); + +#endif diff --git a/parport.c b/parport.c new file mode 100644 index 00000000..d27aca2b --- /dev/null +++ b/parport.c @@ -0,0 +1,234 @@ +/* + * Hardware Information, version 0.3.1b + * 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 usbdevfs. + */ + +#include "hardinfo.h" +#include "parport.h" + +#define srch_def(str,len,var) \ +	if (!strncmp(buffer, str, len)) { \ +		walk_until_inclusive(':'); \ +		parport_dev->var = g_strdup(buf); \ +	} + +ParportDevice *hi_scan_parport(void) +{ +	FILE *autoprobe; +	struct stat st; +	gint n=0, i; +	ParportDevice *parport_dev, *parport; + +	parport = NULL; +	 +	for (i = 0; i <= 16; i++) { +		gchar *file; +		gchar buffer[128]; +		gint port, dma; +		 +		file = g_strdup_printf(PARPORT_PROC_BASE "parport%d", i); + +		if (stat(file, &st)) { +			g_free(file); +			continue; +		} +		g_free(file); + +		file = g_strdup_printf +			(PARPORT_PROC_BASE "parport%d/autoprobe", i); + +		parport_dev = g_new0(ParportDevice, 1);		 +		parport_dev->next = parport; +		parport = parport_dev; +		 +		n++; + +		parport_dev->number = i; +		 +		autoprobe = fopen(file, "r"); +		while (autoprobe && fgets(buffer, 128, autoprobe)) { +			char *buf; + +			buf = g_strstrip(buffer); +			*(buf + strlen(buf) - 1) = 0; +			 +			srch_def("CLASS:", 6, pclass); +			srch_def("MODEL:", 6, model); +			srch_def("MANUFA", 6, manufacturer); +			srch_def("DESCRI", 6, description); +			srch_def("COMMAN", 6, cmdset); +		} +		if(autoprobe) fclose(autoprobe); +		 +		g_free(file); +		 +		if (parport_dev->model) { +			parport_dev->name =  +				g_strdup_printf("%s %s (lp%d)", +					parport_dev->manufacturer, +					parport_dev->model, i); +		} else { +			parport_dev->name = +				g_strdup_printf ("Parallel port (lp%d)", i); +		} + +		file = g_strdup_printf +			(PARPORT_PROC_BASE "parport%d/base-addr", i); +		autoprobe = fopen(file, "r"); +		if (autoprobe) { +			fscanf(autoprobe, "%d", &port); +			fclose(autoprobe); +		 +			parport_dev->port = port; +		}		 +		g_free(file); +		 +		file = g_strdup_printf +			(PARPORT_PROC_BASE "parport%d/dma", i); +		autoprobe = fopen(file, "r"); +		if (autoprobe) { +			fscanf(autoprobe, "%d", &dma); +			fclose(autoprobe); + +			parport_dev->dma = (dma == -1) ? FALSE : TRUE; +		} +		g_free(file); +		 +		file = g_strdup_printf +			(PARPORT_PROC_BASE "parport%d/modes", i); +		autoprobe = fopen(file, "r"); +		if (autoprobe) { +			gchar modes[64]; +			 +			fgets(modes, 64, autoprobe); +			fclose(autoprobe); + +			modes[strlen(modes)-1]=0; +			parport_dev->modes = g_strdup(modes); + +		} +		if(!parport_dev->modes) +			parport_dev->modes = g_strdup(_("N/A")); +			 +		g_free(file); +	} +	 +	return parport; + +} + +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"},		 +		{NULL,		"Legacy Device",	"gen_connector.png"}, +	}; +	gint i; +#ifdef GTK2 +	GtkWidget *pixmap;		 +#endif + +	if(!device) return; + +	if (device->pclass) { +		for (i = 0; type2icon[i].type != NULL; ++i) +			if(!strcmp(device->pclass, type2icon[i].type)) +				break; +	} else +		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); +	 +	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; + +	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); +	 +		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); +	} + +} diff --git a/parport.h b/parport.h new file mode 100644 index 00000000..1461a909 --- /dev/null +++ b/parport.h @@ -0,0 +1,30 @@ +#ifndef __PARPORT_H__ +#define __PARPORT_H__ + +#include "hardinfo.h" + +#define PARPORT_PROC_BASE "/proc/sys/dev/parport/" + +typedef struct _ParportDevice	ParportDevice; + +struct _ParportDevice { +	gchar *name; + +	gchar *cmdset; +	gchar *model; +	gchar *manufacturer; +	gchar *description; +	gchar *pclass; + +	gint number, port; +	gboolean dma; +	 +	gchar *modes; + +	ParportDevice *next; +}; + +ParportDevice *hi_scan_parport(void); +void hi_show_parport_info(MainWindow *mainwindow, ParportDevice *device); + +#endif @@ -0,0 +1,323 @@ +/* + * 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 "hardinfo.h" +#include "pci.h" + +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); + +#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->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, +			device->io_addr_end); +	 +		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->memory) { +		buf = g_strdup_printf(_("Memory: %ld %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); +	 +		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);				 +	} + +	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); +	 +		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); +	} + +	buf = g_strdup_printf(_("Bus: %d, Device: %d, Function: %d"), +		device->bus, device->device, device->function); +	 +	label = gtk_label_new(buf); +	gtk_widget_show(label); +	gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0); +	g_free(buf);				 +} + +#ifdef USE_LSPCI +PCIDevice *hi_scan_pci(void) +{ +	FILE *lspci; +	gchar buffer[256], *buf; +	gint n=0; +	PCIDevice *pci_dev, *pci; +	 +	pci = NULL; +	 +	lspci = popen(LSPCI, "r"); +	if(!lspci) return NULL; +	 +	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); +			for (i = 0; i <= 10; i++) { +				if(!list[i]) break; +			 +				if(!strncmp(list[i], "IRQ", 3)) +					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)) +					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 (latency) pci_dev->latency = latency; +		}  +		 +		else if(!strncmp(buf, "Memory at", 9) && +			  strstr(buf, "[size=")) { +			gulong mem; +			gchar unit; +			 +			walk_until('['); +			sscanf(buf, "[size=%ld%c", &mem, &unit); + +			mem *= (unit == ']') ? 1 : +			       (unit == 'K') ? 1024 : +			       (unit == 'M') ? 1024 * 1000 : +			       (unit == 'G') ? 1024 * 1000 * 1000 : 1; + +			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; +			 +			pci_dev = g_new0(PCIDevice, 1); + +			pci_dev->next = pci;			 +			pci = pci_dev; +			 +			sscanf(buf, "%x:%x:%x.%d", &domain, &bus, &device, &function); +			 +			pci_dev->bus		= bus; +			pci_dev->device		= device; +			pci_dev->function 	= function; + +			walk_until(' '); + +			start = buf; +			 +			walk_until(':'); +			end = buf+1; +			*buf=0; + +			buf = start+1;			 +			pci_dev->category = g_strdup(buf); +			 +			buf = end; +			start = buf; +			walk_until('('); +			*buf = 0; +			buf = start+1; +				 +			pci_dev->name = g_strdup(buf); + +			n++; +		} +	} +	pclose(lspci); +	 +	return pci; +} + +#else + +#warning Using /proc/pci is deprecated, please install pciutils! + +PCIDevice *hi_scan_pci(void) +{ +	FILE *proc_pci; +	gchar buffer[256], *buf; +	gboolean next_is_name = FALSE; +	gint n=0; +	PCIDevice *pci_dev, *pci; +	struct stat st; +	 +	g_print("Scanning PCI devices... "); +	 +	pci = NULL; +	 +	if(stat("/proc/pci", &st)) return NULL; +	 +	proc_pci = fopen("/proc/pci", "r"); +	while(fgets(buffer, 256, proc_pci)){ +		buf = g_strstrip(buffer); +		if(next_is_name == TRUE) { +			gpointer start, end; +			 +			start = buf; +			 +			walk_until(':'); +			end = buf+1; +			*buf=0; + +			buf = start;			 +			pci_dev->category = g_strdup(buf); +			 +			buf = end;			 +			buf[strlen(buf)-1]=0; +			pci_dev->name = g_strdup(buf); +			 +			next_is_name = FALSE; +		} else if(!strncmp(buf, "IRQ", 3)){ +			gint irq; +			 +			sscanf(buf, "IRQ %d", &irq); +			 +			pci_dev->irq		= irq; +		} else if(!strncmp(buf, "Prefetchable 32 bit", 19) || +				!strncmp(buf, "Non-prefetchable 32 bit", 23)){ +			gulong mem_st, mem_end; +			 +			if(*buf == 'N') buf+=4; +			buf++; +			 +			sscanf(buf, "refetchable 32 bit memory at %lx [%lx]", +				&mem_st, &mem_end); +			 +			pci_dev->memory+=(mem_end-mem_st)/1024; +		} else if(!strncmp(buf, "I/O", 3)){ +			guint io_addr, io_addr_end; +			 +			sscanf(buf, "I/O at %x [%x]", &io_addr, &io_addr_end); +			 +			pci_dev->io_addr	= io_addr;			 +			pci_dev->io_addr_end	= io_addr_end; +		} else if(!strncmp(buf, "Bus", 3)){ +			gint bus, device, function; +			 +			pci_dev = g_new0(PCIDevice, 1); + +			pci_dev->next = pci;			 +			pci = pci_dev; +			 +			sscanf(buf, "Bus %d, device %d, function %d:", +					&bus, &device, &function); +			 +			pci_dev->bus		= bus; +			pci_dev->device		= device; +			pci_dev->function 	= function; + +			next_is_name = TRUE; +			n++; +		} +	} +	fclose(proc_pci); +	 +	g_print ("%d devices found\n", n);	 +	 +	return pci; +} +#endif + @@ -0,0 +1,31 @@ +#ifndef __PCI_H__ +#define __PCI_H__ + +typedef struct _PCIDevice	PCIDevice; + +struct _PCIDevice { +	gchar *name; +	gchar *category; +	 +	gint  irq; +	guint io_addr; +	guint io_addr_end; +	 +	gulong memory; + +	gint bus; +	gint device; +	gint function; + +	gint latency; +	gint freq; +	 +	gboolean bus_master; +	 +	PCIDevice *next; +}; + +void hi_show_pci_info(MainWindow *mainwindow, PCIDevice *device); +PCIDevice *hi_scan_pci(void); + +#endif diff --git a/pixmaps/cd.png b/pixmaps/cd.pngBinary files differ new file mode 100755 index 00000000..dd5d3341 --- /dev/null +++ b/pixmaps/cd.png diff --git a/pixmaps/cpu.png b/pixmaps/cpu.pngBinary files differ new file mode 100755 index 00000000..da4f71d2 --- /dev/null +++ b/pixmaps/cpu.png diff --git a/pixmaps/distro/.xvpics/mdk.png b/pixmaps/distro/.xvpics/mdk.pngBinary files differ new file mode 100755 index 00000000..84b3f79c --- /dev/null +++ b/pixmaps/distro/.xvpics/mdk.png diff --git a/pixmaps/distro/cnc.png b/pixmaps/distro/cnc.pngBinary files differ new file mode 100755 index 00000000..3967c237 --- /dev/null +++ b/pixmaps/distro/cnc.png diff --git a/pixmaps/distro/deb.png b/pixmaps/distro/deb.pngBinary files differ new file mode 100755 index 00000000..0ced3130 --- /dev/null +++ b/pixmaps/distro/deb.png diff --git a/pixmaps/distro/gnt.png b/pixmaps/distro/gnt.pngBinary files differ new file mode 100755 index 00000000..bf4290a9 --- /dev/null +++ b/pixmaps/distro/gnt.png diff --git a/pixmaps/distro/mdk.png b/pixmaps/distro/mdk.pngBinary files differ new file mode 100755 index 00000000..a997ea10 --- /dev/null +++ b/pixmaps/distro/mdk.png diff --git a/pixmaps/distro/rh.png b/pixmaps/distro/rh.pngBinary files differ new file mode 100755 index 00000000..f612354b --- /dev/null +++ b/pixmaps/distro/rh.png diff --git a/pixmaps/distro/slk.png b/pixmaps/distro/slk.pngBinary files differ new file mode 100755 index 00000000..fd6d3365 --- /dev/null +++ b/pixmaps/distro/slk.png diff --git a/pixmaps/distro/suse.png b/pixmaps/distro/suse.pngBinary files differ new file mode 100755 index 00000000..0c7759a1 --- /dev/null +++ b/pixmaps/distro/suse.png diff --git a/pixmaps/distro/tl.png b/pixmaps/distro/tl.pngBinary files differ new file mode 100755 index 00000000..353bddd2 --- /dev/null +++ b/pixmaps/distro/tl.png diff --git a/pixmaps/distro/unk.png b/pixmaps/distro/unk.pngBinary files differ new file mode 100755 index 00000000..ed850e40 --- /dev/null +++ b/pixmaps/distro/unk.png diff --git a/pixmaps/distro/yd.png b/pixmaps/distro/yd.pngBinary files differ new file mode 100755 index 00000000..ce002956 --- /dev/null +++ b/pixmaps/distro/yd.png diff --git a/pixmaps/distro/yellow-dog.gif b/pixmaps/distro/yellow-dog.gifBinary files differ new file mode 100755 index 00000000..cf143ce1 --- /dev/null +++ b/pixmaps/distro/yellow-dog.gif diff --git a/pixmaps/gen_connector.png b/pixmaps/gen_connector.pngBinary files differ new file mode 100755 index 00000000..477e55ff --- /dev/null +++ b/pixmaps/gen_connector.png diff --git a/pixmaps/gen_connector.xpm b/pixmaps/gen_connector.xpm new file mode 100755 index 00000000..28aa0382 --- /dev/null +++ b/pixmaps/gen_connector.xpm @@ -0,0 +1,46 @@ +/* XPM */ +static char * gen_connector_xpm[] = { +"16 16 27 1", +" 	c None", +".	c #000000", +"+	c #F0F0F0", +"@	c #FFFFFF", +"#	c #EEEEEE", +"$	c #EBEBEB", +"%	c #E4E4E4", +"&	c #C5C5C5", +"*	c #C9C9C9", +"=	c #D2D2D2", +"-	c #BABABA", +";	c #A1A1A1", +">	c #F7F7F7", +",	c #EDEDED", +"'	c #B8B8B8", +")	c #8C8C8C", +"!	c #989898", +"~	c #ADADAD", +"{	c #7B7B7B", +"]	c #BDBDBD", +"^	c #D0D0D0", +"/	c #CECECE", +"(	c #DBDBDB", +"_	c #DFDFDF", +":	c #464646", +"<	c #DDDDDD", +"[	c #7E7E7E", +"                ", +"   ...........  ", +"   .+@#$%%%%&.  ", +" . .*@=*----;. .", +"  ............. ", +"  .>,,,,,,,,,'. ", +"  .,)!!!!!!!~{. ", +"  .,;-------*{. ", +"  .,]^^^^^^/({. ", +"  ._{{{{{{{{{:. ", +"   ...{{{{{...  ", +"      .<-[.     ", +"      ..-..     ", +"       .-.      ", +"       .-.      ", +"       .-.      "}; diff --git a/pixmaps/hdd.png b/pixmaps/hdd.pngBinary files differ new file mode 100755 index 00000000..cc308f88 --- /dev/null +++ b/pixmaps/hdd.png diff --git a/pixmaps/hdd.xpm b/pixmaps/hdd.xpm new file mode 100755 index 00000000..7f1d54f7 --- /dev/null +++ b/pixmaps/hdd.xpm @@ -0,0 +1,138 @@ +/* XPM */ +static char * hdd_xpm[] = { +"16 16 119 2", +"  	c None", +". 	c #5A5A5A", +"+ 	c #626262", +"@ 	c #363636", +"# 	c #434343", +"$ 	c #686868", +"% 	c #6E6356", +"& 	c #A87B4A", +"* 	c #EBCAA5", +"= 	c #E3B88A", +"- 	c #AA9277", +"; 	c #7C746C", +"> 	c #877159", +", 	c #B06F28", +"' 	c #C58C4D", +") 	c #EDCCA9", +"! 	c #EBC7A1", +"~ 	c #F2D8BC", +"{ 	c #EBD0B2", +"] 	c #8A7E71", +"^ 	c #5D5852", +"/ 	c #C79055", +"( 	c #BC7F3E", +"_ 	c #C28544", +": 	c #B28C64", +"< 	c #CCA276", +"[ 	c #EFD3B6", +"} 	c #EFD3B5", +"| 	c #B79672", +"1 	c #666666", +"2 	c #5D5D5D", +"3 	c #745A3F", +"4 	c #E5BD92", +"5 	c #E4BA8E", +"6 	c #70471D", +"7 	c #83684A", +"8 	c #84582B", +"9 	c #C79967", +"0 	c #E8C096", +"a 	c #E8C196", +"b 	c #423426", +"c 	c #565656", +"d 	c #272624", +"e 	c #796045", +"f 	c #F0D4B7", +"g 	c #EBCBA9", +"h 	c #7A4F22", +"i 	c #A67F56", +"j 	c #513416", +"k 	c #986E42", +"l 	c #EAC6A1", +"m 	c #ECCAA6", +"n 	c #352615", +"o 	c #6B6A6A", +"p 	c #6A6A6A", +"q 	c #7A7A7A", +"r 	c #797877", +"s 	c #938A80", +"t 	c #B2A89E", +"u 	c #A39A8F", +"v 	c #7F6E5B", +"w 	c #7A5734", +"x 	c #744F28", +"y 	c #B27532", +"z 	c #CE975A", +"A 	c #B38350", +"B 	c #494745", +"C 	c #606060", +"D 	c #747474", +"E 	c #858585", +"F 	c #656463", +"G 	c #767575", +"H 	c #514F4C", +"I 	c #776C5F", +"J 	c #BFB0A0", +"K 	c #F0D4B6", +"L 	c #EECEAB", +"M 	c #DAAC79", +"N 	c #B37736", +"O 	c #AF6E28", +"P 	c #715E4B", +"Q 	c #282828", +"R 	c #474747", +"S 	c #A5A5A5", +"T 	c #797979", +"U 	c #171310", +"V 	c #15110D", +"W 	c #2A2015", +"X 	c #B89C7D", +"Y 	c #EDCCA8", +"Z 	c #F0D1AF", +"` 	c #E0B78C", +" .	c #B97E3F", +"..	c #78624A", +"+.	c #616161", +"@.	c #4D4D4D", +"#.	c #A4A4A4", +"$.	c #767473", +"%.	c #261A0E", +"&.	c #5C4D3D", +"*.	c #55412B", +"=.	c #4F4C4C", +"-.	c #4B4B4B", +";.	c #A2A2A2", +">.	c #474542", +",.	c #5F5F5F", +"'.	c #262626", +").	c #A7A7A7", +"!.	c #474441", +"~.	c #5C5C5C", +"{.	c #252525", +"].	c #4E4E4E", +"^.	c #AAAAAA", +"/.	c #8D8D8D", +"(.	c #5B5B5B", +"_.	c #4F4F4F", +":.	c #999999", +"<.	c #777777", +"[.	c #242424", +"                . +             ", +"              . @ # $           ", +"            % & * = - ;         ", +"          > , ' ) ! ~ { ]       ", +"        ^ / ( _ : < [ } | 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 C Q   ", +"R S T U V W X Y Z `  ...+.Q     ", +"  @.#.$.V V V %.&.*.=.C Q       ", +"    -.;.$.V V V V >.,.'.        ", +"      @.).$.U V !.~.{.          ", +"        ].^./.1 (.{.            ", +"          _.:.<.[.              ", +"                                "}; diff --git a/pixmaps/logo.png b/pixmaps/logo.pngBinary files differ new file mode 100755 index 00000000..e19c735a --- /dev/null +++ b/pixmaps/logo.png diff --git a/pixmaps/lpr.png b/pixmaps/lpr.pngBinary files differ new file mode 100755 index 00000000..3ad6dc99 --- /dev/null +++ b/pixmaps/lpr.png diff --git a/pixmaps/media.png b/pixmaps/media.pngBinary files differ new file mode 100755 index 00000000..cd061e66 --- /dev/null +++ b/pixmaps/media.png diff --git a/pixmaps/mem.png b/pixmaps/mem.pngBinary files differ new file mode 100755 index 00000000..a852520b --- /dev/null +++ b/pixmaps/mem.png diff --git a/pixmaps/pci.png b/pixmaps/pci.pngBinary files differ new file mode 100755 index 00000000..21905108 --- /dev/null +++ b/pixmaps/pci.png diff --git a/pixmaps/pci.xpm b/pixmaps/pci.xpm new file mode 100755 index 00000000..3e6f936a --- /dev/null +++ b/pixmaps/pci.xpm @@ -0,0 +1,136 @@ +/* XPM */ +static char * pci_xpm[] = { +"16 16 111 2", +"  	c None", +". 	c #030303", +"+ 	c #D6DDD0", +"@ 	c #A5B393", +"# 	c #95B882", +"$ 	c #B8CAB0", +"% 	c #A9BEA2", +"& 	c #809A75", +"* 	c #93AB88", +"= 	c #ACBEA4", +"- 	c #3C5234", +"; 	c #3F5A32", +"> 	c #738B57", +", 	c #4B673F", +"' 	c #546B47", +") 	c #3B542F", +"! 	c #FFFFFF", +"~ 	c #717171", +"{ 	c #DADBDA", +"] 	c #B9B691", +"^ 	c #55643F", +"/ 	c #A0A591", +"( 	c #606950", +"_ 	c #A0A593", +": 	c #2C3A21", +"< 	c #A9AAA9", +"[ 	c #B1B1B1", +"} 	c #A4A4A4", +"| 	c #A9A9A9", +"1 	c #6D6B59", +"2 	c #3E4832", +"3 	c #8F9391", +"4 	c #4F4436", +"5 	c #8F9393", +"6 	c #1E2416", +"7 	c #B0BFA7", +"8 	c #8A866E", +"9 	c #000000", +"0 	c #848069", +"a 	c #B9B086", +"b 	c #474736", +"c 	c #343E25", +"d 	c #6A706E", +"e 	c #443B33", +"f 	c #606769", +"g 	c #1D2416", +"h 	c #FAFAFA", +"i 	c #BEBEBE", +"j 	c #475236", +"k 	c #383E2B", +"l 	c #313726", +"m 	c #313425", +"n 	c #363A28", +"o 	c #1F2317", +"p 	c #3A4225", +"q 	c #3C502C", +"r 	c #334425", +"s 	c #364525", +"t 	c #27341C", +"u 	c #4D6538", +"v 	c #556437", +"w 	c #48552F", +"x 	c #4A552F", +"y 	c #4D5932", +"z 	c #3F4D29", +"A 	c #4D6433", +"B 	c #658042", +"C 	c #658248", +"D 	c #8F976F", +"E 	c #57604B", +"F 	c #848257", +"G 	c #939165", +"H 	c #B1B091", +"I 	c #9E9E77", +"J 	c #6B6942", +"K 	c #45592F", +"L 	c #4D6B36", +"M 	c #658442", +"N 	c #62824B", +"O 	c #80887A", +"P 	c #545454", +"Q 	c #343A21", +"R 	c #2B311C", +"S 	c #474D2B", +"T 	c #2C321D", +"U 	c #2D311C", +"V 	c #556736", +"W 	c #778F4A", +"X 	c #648241", +"Y 	c #648047", +"Z 	c #485441", +"` 	c #262925", +" .	c #547E47", +"..	c #A0A95E", +"+.	c #D1CC84", +"@.	c #8B9752", +"#.	c #BBBB75", +"$.	c #989E55", +"%.	c #CAC77F", +"&.	c #91A054", +"*.	c #CFCB83", +"=.	c #27361C", +"-.	c #10140D", +";.	c #0B0D09", +">.	c #B8B078", +",.	c #DDD58F", +"'.	c #A5A161", +").	c #D4CD84", +"!.	c #ADA772", +"~.	c #D7D088", +"{.	c #DAD38B", +"                            .   ", +"                          .     ", +"                          .     ", +"  . . . . . . . . . . . . .     ", +". + @ @ @ @ @ @ @ @ @ @ @ .     ", +". # $ % & * = - ; > , ' ) .     ", +". # ! ~ ! ~ { ] ^ / ( _ : .     ", +". ! < [ } | ~ 1 2 3 4 5 6 . .   ", +". 7 8 9 0 9 a b c d e f g . h   ", +". # j k l m n o p q r s t . 9   ", +". # u v 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 ` .     ", +".  ...+.@.#.$.%.&.*.=.-.;..     ", +"  . >.,.'.).!.~.'.{..     .     ", +"  . . . . . . . . . .     .     "}; + + +/* + * Ripped from Ximian Setup Tools <http://www.ximian.com> + * Unknown author + */ diff --git a/pixmaps/scan.png b/pixmaps/scan.pngBinary files differ new file mode 100755 index 00000000..8074cea6 --- /dev/null +++ b/pixmaps/scan.png diff --git a/pixmaps/scsi.png b/pixmaps/scsi.pngBinary files differ new file mode 100755 index 00000000..23dd73fd --- /dev/null +++ b/pixmaps/scsi.png diff --git a/pixmaps/scsi.xpm b/pixmaps/scsi.xpm new file mode 100755 index 00000000..402906f0 --- /dev/null +++ b/pixmaps/scsi.xpm @@ -0,0 +1,79 @@ +/* XPM */ +static char * scsi_xpm[] = { +"16 16 60 1", +" 	g None", +".	g #696969", +"+	g #B4B4B4", +"@	g #B1B1B1", +"#	g #6D6D6D", +"$	g #B2B2B2", +"%	g #ADADAD", +"&	g #A5A5A5", +"*	g #5E5E5E", +"=	g #B0B0B0", +"-	g #A3A3A3", +";	g #595959", +">	g #969696", +",	g #9A9A9A", +"'	g #585858", +")	g #818181", +"!	g #616161", +"~	g #8C8C8C", +"{	g #868686", +"]	g #505050", +"^	g #797979", +"/	g #515151", +"(	g #464646", +"_	g #747474", +":	g #9C9C9C", +"<	g #7C7C7C", +"[	g #5B5B5B", +"}	g #A7A7A7", +"|	g #5D5D5D", +"1	g #6A6A6A", +"2	g #666666", +"3	g #636363", +"4	g #5F5F5F", +"5	g #575757", +"6	g #A6A6A6", +"7	g #919191", +"8	g #676767", +"9	g #404040", +"0	g #5C5C5C", +"a	g #555555", +"b	g #4E4E4E", +"c	g #737373", +"d	g #7D7D7D", +"e	g #707070", +"f	g #3E3E3E", +"g	g #2F2F2F", +"h	g #606060", +"i	g #474747", +"j	g #3B3B3B", +"k	g #4B4B4B", +"l	g #3F3F3F", +"m	g #4F4F4F", +"n	g #545454", +"o	g #3C3C3C", +"p	g #373737", +"q	g #414141", +"r	g #454545", +"s	g #363636", +"t	g #353535", +"u	g #313131", +"        .       ", +"       +@#      ", +"      $@%&*     ", +"     =-*;>,'    ", +"     )!   ~{]   ", +"    ^/    (_    ", +"  :<[           ", +" }-|    (1234[5 ", +" 678    9!0aa]b ", +"  cd|           ", +"   8e]    fbg   ", +"    ;hi  jkl    ", +"     mnop(o     ", +"      qrqs      ", +"       tu       ", +"                "}; diff --git a/pixmaps/stock-about-16.png b/pixmaps/stock-about-16.pngBinary files differ new file mode 100755 index 00000000..d66bfd7b --- /dev/null +++ b/pixmaps/stock-about-16.png diff --git a/pixmaps/tape.png b/pixmaps/tape.pngBinary files differ new file mode 100755 index 00000000..90b2e297 --- /dev/null +++ b/pixmaps/tape.png diff --git a/pixmaps/usb.png b/pixmaps/usb.pngBinary files differ new file mode 100755 index 00000000..a662ce55 --- /dev/null +++ b/pixmaps/usb.png diff --git a/pixmaps/usb.xpm b/pixmaps/usb.xpm new file mode 100755 index 00000000..476432fd --- /dev/null +++ b/pixmaps/usb.xpm @@ -0,0 +1,49 @@ +/* XPM */ +static char * usb_xpm[] = { +"16 16 30 1", +" 	c None", +".	c #929292", +"+	c #464646", +"@	c #313131", +"#	c #353535", +"$	c #424242", +"%	c #000000", +"&	c #2E2E2E", +"*	c #878787", +"=	c #272727", +"-	c #242424", +";	c #717171", +">	c #4B4B4B", +",	c #2B2B2B", +"'	c #323232", +")	c #808080", +"!	c #010101", +"~	c #C6C6C6", +"{	c #040404", +"]	c #0D0D0D", +"^	c #0B0B0B", +"/	c #131313", +"(	c #7D7D7D", +"_	c #030303", +":	c #787878", +"<	c #999999", +"[	c #CCCCCC", +"}	c #959595", +"|	c #8E8E8E", +"1	c #C2C2C2", +"                ", +"                ", +"                ", +"                ", +"                ", +"    .+@@@@#     ", +"   $%%%%%%&*=-; ", +"  >%%%%%%% ,,') ", +"%%%%%%%%%% !,%~ ", +"%%{%%%%%%] ^,/  ", +"  (_%%%%%> ::<  ", +"   [}||||1      ", +"                ", +"                ", +"                ", +"                "}; diff --git a/pixmaps/v4l.png b/pixmaps/v4l.pngBinary files differ new file mode 100755 index 00000000..88801a39 --- /dev/null +++ b/pixmaps/v4l.png diff --git a/pixmaps/x11.png b/pixmaps/x11.pngBinary files differ new file mode 100755 index 00000000..49924ba2 --- /dev/null +++ b/pixmaps/x11.png @@ -0,0 +1,197 @@ +/* + * 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. + * + */ + +/* + * SCSI support by Pascal F.Martin <pascalmartin@earthlink.net> + */ + +#include "hardinfo.h" +#include "scsi.h" + +SCSIDevice *hi_scan_scsi(void) +{ +	FILE *proc_scsi; +	gchar buffer[256], *buf; +	gint n=0; +	SCSIDevice *scsi_dev, *scsi; +	struct stat st; +	 +	scsi = NULL; +	 +	if(stat("/proc/scsi/scsi", &st)) return NULL; + +	proc_scsi = fopen("/proc/scsi/scsi", "r"); +	while(fgets(buffer, 256, proc_scsi)) { +		buf = g_strstrip(buffer); +		if(!strncmp(buf, "Host: scsi", 10)) { +			gint scsi_controller; +			gint scsi_channel; +			gint scsi_id; +			gint scsi_lun; + +			sscanf(buf, +				"Host: scsi%d Channel: %d Id: %d Lun: %d", +				&scsi_controller, +				&scsi_channel, +				&scsi_id, +				&scsi_lun); + +			buf = strstr (buffer, "Rev: "); +			if (buf == NULL) { +				buf = "(unknown)"; +			} else { +				buf += 5; +			} +			scsi_dev = g_new0(SCSIDevice, 1); +			 +			scsi_dev->next = scsi; +			scsi = scsi_dev; +			 +			scsi_dev->controller = scsi_controller; +			scsi_dev->channel = scsi_channel; +			scsi_dev->id = scsi_id; +			scsi_dev->lun = scsi_lun; + +			n++;			 + +		} else if (!strncmp(buf, "Vendor: ", 8)) { + +			char *p; +			char *model = strstr (buf, "Model: "); +			char *rev = strstr (buf, "Rev: "); + +			if (model == NULL) { +				model = buf + strlen(buf); +			} +			p = model; +			while (*(--p) == ' ') ; +			*(++p) = 0; +			scsi_dev->vendor = g_strdup(buf+8); + +			if (rev != NULL) { +				scsi_dev->revision = g_strdup(rev+5); +			} else { +				rev = model + strlen(model); +			} +			p = rev; +			while (*(--p) == ' ') ; +			*(++p) = 0; +			scsi_dev->model = +				g_strdup_printf +					("%s %s", scsi_dev->vendor, model+7); + +		} else if (!strncmp(buf, "Type:   ", 8)) { +			char *p = strstr (buf, "ANSI SCSI revi"); + +			if (p != NULL) { +				while (*(--p) == ' ') ; +				*(++p) = 0; +				scsi_dev->type = g_strdup(buf+8); +			} +		} +	} +	fclose(proc_scsi); +	 +	return scsi; +} + +void hi_show_scsi_info(MainWindow *mainwindow, SCSIDevice *device) +{ +        static struct { +                char *type; +                char *label; +                char *icon;  +        } type2icon[] = {    +                {"Direct-Access",       "Disk",         "hdd.png"}, +                {"Sequential-Access",   "Tape",         "tape.png"}, +                {"Printer",             "Printer",      "lpr.png"},  +                {"WORM",                "CD-ROM",       "cd.png"},   +                {"CD-ROM",              "CD-ROM",       "cd.png"},   +                {"Scanner",             "Scanner",      "scan.png"}, +                {NULL,                  "Generic",      "scsi.png"}  +        }; + +        int i; +        GtkWidget *hbox, *vbox, *label; +        gchar *buf; +#ifdef GTK2 +        GtkWidget *pixmap; +#endif + +        if(!device) return; + +        for (i = 0; type2icon[i].type != NULL; ++i) { +                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); +         +        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); +        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); + +        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); + +        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); +} @@ -0,0 +1,23 @@ +#ifndef __SCSI_H__ +#define __SCSI_H__ + +typedef struct _SCSIDevice	SCSIDevice; + +struct _SCSIDevice { +	gchar *model; +	 +	gchar *vendor; +	gchar *type; +	gchar *revision; +	gint controller; +	gint channel; +	gint id; +	gint lun; + +	SCSIDevice *next; +}; + +void hi_show_scsi_info(MainWindow *mainwindow, SCSIDevice *device); +SCSIDevice *hi_scan_scsi(void); + +#endif diff --git a/serial.c b/serial.c new file mode 100644 index 00000000..0de96982 --- /dev/null +++ b/serial.c @@ -0,0 +1,123 @@ +/* + * Hardware Information, version 0.3.1b + * Copyright (C) 2003 Leandro Pereira <leandro@linuxmag.com.br> + * + * May be modified and/or distributed under the terms of GNU GPL version 2. + */ + +#include "hardinfo.h" +#include "serial.h" + +SerialDevice *hi_scan_serial(void) +{ +	FILE *proc_tty; +	struct stat st; +	const gchar *ser_drv="/proc/tty/driver/serial"; +	gint n=0; +	SerialDevice *serial_dev, *serial; +	 +	serial = NULL; +	 +	if (!stat(ser_drv, &st)) { +		gchar buffer[256]; +		 +		proc_tty = fopen(ser_drv, "r"); +		while(fgets(buffer, 256, proc_tty)){ +			gint port, irq; +			gpointer start, end; +			gchar *buf = buffer; +		 +			if(*buf == 's') continue; +			if(strstr(buf, "unknown")) continue; +		 +			serial_dev = g_new0(SerialDevice, 1); +			 +			serial_dev->next = serial; +			serial = serial_dev; + +			serial_dev->name = g_strdup_printf +				("Serial Port (tty%d)", buffer[0]-'0'); + +			walk_until('t'); +			buf+=2; +			start = buf; +			walk_until(' '); +			end = buf; +			*buf = 0; +			buf = start; +			 +			serial_dev->uart = g_strdup(buf); +			 +			buf = end; +			*buf = ' '; +			 +			sscanf(buf, " port:%x irq:%d", &port, &irq); +			serial->port = port; +			serial->irq = irq; +			n++; +		} +		fclose(proc_tty); +	} +	 +	return serial; +} + +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); + +	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); +	 +} diff --git a/serial.h b/serial.h new file mode 100644 index 00000000..e2d3e5e8 --- /dev/null +++ b/serial.h @@ -0,0 +1,19 @@ +#ifndef __SERIAL_H__ +#define __SERIAL_H__ + +#include "hardinfo.h" + +typedef struct _SerialDevice	SerialDevice; + +struct _SerialDevice { +	gchar *name; +	gchar *uart; +	gint port, irq, baud; + +	SerialDevice *next; +}; + +SerialDevice *hi_scan_serial(void); +void hi_show_serial_info(MainWindow *mainwindow, SerialDevice *device); + +#endif diff --git a/status.c b/status.c new file mode 100644 index 00000000..0d3be0f3 --- /dev/null +++ b/status.c @@ -0,0 +1,68 @@ +#include "status.h" + +myStatus *my_status_new(gchar *title, gchar *text) +{ +	GtkWidget *window, *label, *hbox, *img, *vbox, *progress; +	myStatus *status; +	 +	window = gtk_window_new(GTK_WINDOW_TOPLEVEL); +	gtk_window_set_title(GTK_WINDOW(window), title); +	gtk_container_set_border_width(GTK_CONTAINER(window), 15); +	gtk_window_set_position(GTK_WINDOW(window), GTK_WIN_POS_CENTER_ALWAYS); +	 +	hbox = gtk_hbox_new(FALSE, 5); +	gtk_widget_show(hbox); +	gtk_container_add(GTK_CONTAINER(window), hbox); +	 +	img = gtk_image_new_from_file(IMG_PREFIX "logo.png"); +	gtk_widget_show(img); +	gtk_box_pack_start(GTK_BOX(hbox), img, FALSE, FALSE, 0); +	gtk_widget_set_usize(GTK_WIDGET(img), 96, 64); +	 +	vbox = gtk_vbox_new(FALSE, 5); +	gtk_widget_show(vbox); +	gtk_box_pack_start(GTK_BOX(hbox), vbox, TRUE, TRUE, 0); +	 +	label = gtk_label_new(text); +	gtk_label_set_use_markup(GTK_LABEL(label), TRUE); +	gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.5); +	gtk_widget_show(label); +	gtk_box_pack_start(GTK_BOX(vbox), label, TRUE, TRUE, 0); +	 +	progress = gtk_progress_bar_new(); +	gtk_widget_show(progress); +	gtk_box_pack_start(GTK_BOX(vbox), progress, TRUE, FALSE, 0); +	 +	gtk_widget_show(window); +	 +	status = g_new0(myStatus, 1); +	status->window   = window; +	status->label    = label; +	status->progress = progress; +	 +	return status; +} + +void my_status_pulse(myStatus *status) +{ +	gtk_progress_bar_pulse(GTK_PROGRESS_BAR(status->progress)); + +	while (gtk_events_pending()) +		gtk_main_iteration(); +} + +void my_status_destroy(myStatus *status) +{ +	gtk_widget_destroy(status->window); +	g_free(status); +	status = NULL; +} + +void my_status_set_text(myStatus *status, gchar *text) +{ +	gtk_label_set_markup(GTK_LABEL(status->label), text); + +	while (gtk_events_pending()) +		gtk_main_iteration();	 +} + diff --git a/status.h b/status.h new file mode 100644 index 00000000..f3cfa91e --- /dev/null +++ b/status.h @@ -0,0 +1,20 @@ +#ifndef __STATUS_H__ +#define __STATUS_H__ + +#include <gtk/gtk.h> +#include "hardinfo.h" + +typedef struct _myStatus myStatus; + +struct _myStatus { +	GtkWidget *window; +	GtkWidget *label; +	GtkWidget *progress; +}; + +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); + +#endif		/* __STATUS_H__ */ @@ -0,0 +1,216 @@ +/* + * 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 "hardinfo.h" +#include "usb.h" + +gboolean usb_update(gpointer data) +{ +	MainWindow *mainwindow = (MainWindow*)data; +	GtkCTreeNode *node; +	USBDevice *usb;	 +	 +	if(!mainwindow) return FALSE; + +	gtk_clist_freeze(GTK_CLIST(mainwindow->ctree)); + +	usb = hi_scan_usb(); + +        if (usb != NULL) { +                node = tree_group_new(mainwindow, _("USB Devices"), USB); +                for (; usb != NULL; usb = usb->next) { +                        hi_insert_generic(usb, USB); +                        if (!usb->product)  +                                usb->product = g_strdup_printf +                                        (_("Unknown device (%s)"), usb->class); +                         +                        tree_insert_item(mainwindow, node, usb->product, +                                         generic_devices); +                } +        } + +	gtk_clist_thaw(GTK_CLIST(mainwindow->ctree)); +	 +	return TRUE;	 +} + +USBDevice *hi_scan_usb(void) +{ +	FILE *proc_usb; +	gchar buffer[64]; +	gint n=0; +	USBDevice *usb_dev, *usb; +	struct stat st; +	 +	usb = NULL; + +	if (stat("/proc/bus/usb/devices", &st)) return NULL; + +	proc_usb = fopen("/proc/bus/usb/devices", "r"); +	while(fgets(buffer, 64, proc_usb)){ +		if (strstr(buffer, "Manufacturer=")) { +			gchar *buf = buffer; +			gboolean lock = FALSE; +			gpointer start, end; +			 +			for (; buf != NULL; buf++) { +				if (lock && *buf == '\n') { +					end = buf; +					break; +				} else if (!lock && *buf == '=') { +					start = buf+1; +					lock = TRUE; +				} +			} +			 +			buf = end; +			*buf = 0; +			buf = start; +			 +			usb->vendor = g_strdup(buf); +		} else if (strstr(buffer, "Product=")) { +			gchar *buf = buffer; +			gboolean lock = FALSE; +			gpointer start, end; +			 +			for (; buf != NULL; buf++) { +				if (lock && *buf == '\n') { +					end = buf; +					break; +				} else if (!lock && *buf == '=') { +					start = buf+1; +					lock = TRUE; +				} +			} +			 +			buf = end; +			*buf=0; +			buf = start; + +			usb_dev->product = g_strdup(buf); +		} else if (!strncmp(buffer, "D:  Ve", 6)) { +			gchar *buf = buffer; +			gpointer start; +			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('('); +			start = buf+1; +			buf+=6; +			*buf = 0; +			buf = start; +			 +			usb_dev->class = g_strdup(buf); +			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); +			 +			usb_dev->vendor_id = vendor_id; +			usb_dev->prod_id = prod_id; +			usb_dev->revision = rev; +		} +	} +	fclose(proc_usb); +	 +	return usb; +} + +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; + +	gtk_frame_set_label(GTK_FRAME(mainwindow->frame), _("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); + +#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); +	 +	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); +	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); +	g_free(buf); + +	if(!device->prod_id) return; +	 +	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); +	 +} + @@ -0,0 +1,28 @@ +#ifndef __USB_H__ +#define __USB_H__ + +#include "hardinfo.h" + +typedef struct _USBDevice	USBDevice; + +struct _USBDevice { +	gchar *product; +	gchar *vendor; +	gchar *class; +	 +	gfloat version, revision; +	 +	gint bus, port, vendor_id, prod_id, class_id; +	 +	gchar *driver; + +	USBDevice *next; +}; + + +USBDevice *hi_scan_usb(void); +void hi_show_usb_info(MainWindow *mainwindow, USBDevice *device); + +gboolean usb_update(gpointer data); + +#endif @@ -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 "hardinfo.h" +#include "v4l.h" + +#include <stdlib.h> +#include <dirent.h> + +#define get_str_val(var) { \ +	        walk_until_inclusive(':'); buf++; \ +	        var = g_strdup(buf); \ +        	continue; \ + 	} + +V4LDevice *hi_scan_v4l(void) +{ +	FILE *proc_video; +	DIR *proc_dir; +	struct dirent *sd; +	V4LDevice *v4l_dev, *v4l; +	struct stat st; +	 +	v4l = NULL; + +	if (stat("/proc/video/dev", &st)) +		return NULL; +	 +	proc_dir = opendir("/proc/video/dev"); +	if(!proc_dir) +		return NULL; + +	while (sd = readdir(proc_dir)) { +		gchar *dev, buffer[128]; +		 +		dev = g_strdup_printf("/proc/video/dev/%s", sd->d_name); +		proc_video = fopen(dev, "r"); +		g_free(dev); +		 +		if(!proc_video) +			continue; +			 +		v4l_dev = g_new0(V4LDevice, 1); +		v4l_dev->next = v4l; +		v4l = v4l_dev; +		 +		while (fgets(buffer, 128, proc_video)) { +			char *buf = g_strstrip(buffer); +			 +			if(!strncmp(buf, "name", 4)) +				get_str_val(v4l_dev->name) +			else if(!strncmp(buf, "type", 4)) +				get_str_val(v4l_dev->type) +		}		 + +		fclose(proc_video);		 +	} + +	return v4l; +} + +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); +	 +	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")); +	 +	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 + +	if (device->type) { +		gchar *b = g_strdup(device->type); +		gpointer b_start = b; +	 +		do { +			if (*b == '|') *b = '\n'; +			b++; +		} 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); +		g_free(b); +	} +} @@ -0,0 +1,16 @@ +#ifndef __V4L_H__ +#define __V4L_H__ + +typedef struct _V4LDevice V4LDevice; + +struct _V4LDevice { +	gchar *name; +	gchar *type; + +	V4LDevice *next; +}; + +void hi_show_v4l_info(MainWindow *mainwindow, V4LDevice *device); +V4LDevice *hi_scan_v4l(void); + +#endif @@ -0,0 +1,243 @@ +/* + * 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 + * + * Permission to use, copy, modify, distribute, and sell this software and its + * documentation for any purpose is hereby granted without fee, provided that + * the above copyright notice appear in all copies and that both that + * copyright notice and this permission notice appear in supporting + * documentation. + *  + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + *  + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE + * OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + * Except as contained in this notice, the name of The Open Group shall not be + * used in advertising or otherwise to promote the sale, use or other dealings + * in this Software without prior written authorization from The Open Group.  + */ + +#include "hardinfo.h" +#include "x11.h" + +#include <stdlib.h> + +X11Info * +x11_get_info(void) +{ +	X11Info *info; +	Display *dpy; +	gint default_screen = 0, color_depth = 0; +	gchar *buf; + +	dpy = XOpenDisplay(NULL); +	if(!dpy) return NULL; + +	info = g_new0(X11Info, 1); + +	buf = DisplayString(dpy); +	if (*buf == ':') +		info->display = g_strdup_printf(_("Local display (%s)"), buf); +	else +		info->display = g_strdup_printf(_("Remote display (%s)"), buf); +	 +	info->vendor = g_strdup(ServerVendor(dpy)); + +	if (strstr(ServerVendor(dpy), "XFree86")) { +		int vendrel = VendorRelease(dpy); + +		if (vendrel < 336) { +			/* +			 * vendrel was set incorrectly for 3.3.4 and 3.3.5, so handle +			 * those cases here. +			 */ +			buf = g_strdup_printf +				("%d.%d.%d", vendrel / 100, (vendrel / 10) % 10, +				 vendrel % 10); +		} else if (vendrel < 3900) { +			/* 3.3.x versions, other than the exceptions handled above */ +			buf = g_strdup_printf("%d.%d", vendrel / 1000, (vendrel / 100) % 10); +			if (((vendrel / 10) % 10) || (vendrel % 10)) { +				gchar *buf2; +				 +				buf2 = g_strdup_printf(".%d", (vendrel / 10) % 10); +				buf = g_strconcat(buf, buf2, NULL); +				g_free(buf2); +				 +				if (vendrel % 10) { +					buf2 = g_strdup_printf(".%d", vendrel % 10); +					buf = g_strconcat(buf, buf2, NULL); +					g_free(buf2); +				} +			} +		} else if (vendrel < 40000000) { +			gchar *buf2; +			/* 4.0.x versions */ +			buf = g_strdup_printf("%d.%d", vendrel / 1000, (vendrel / 10) % 10); + +			if (vendrel % 10) { +				buf2 = g_strdup_printf(".%d", vendrel % 10); +				buf = g_strconcat(buf, buf2, NULL); +				g_free(buf2); +			} +		} else { +			/* post-4.0.x */ +			buf = g_strdup_printf("%d.%d.%d", vendrel / 10000000, +			       (vendrel / 100000) % 100, +			       (vendrel / 1000) % 100); +			if (vendrel % 1000) { +				gchar *buf2; +				 +				buf2 = g_strdup_printf(".%d", vendrel % 1000); +				buf = g_strconcat(buf, buf2, NULL); +				g_free(buf2); +			} +		} +	} +	if (buf) { +		info->xf86version = g_strdup(buf); +		g_free(buf); +	} + +	default_screen = DefaultScreen(dpy); +	color_depth = XDefaultDepth(dpy, default_screen); +	info->screen_size = g_strdup_printf("%dx%d pixels (%d bpp)", +					    DisplayWidth(dpy, default_screen), +					    DisplayHeight(dpy, default_screen), +					    color_depth); + + +	if (info->xf86version) { +		info->version = g_strdup_printf(_("XFree86 version %s (protocol version %d.%d)"), +					info->xf86version, ProtocolVersion(dpy), +				 	        ProtocolRevision(dpy)); +	} else { +		info->version = g_strdup_printf(_("%d (protocol version %d.%d)"), +					VendorRelease(dpy), ProtocolVersion(dpy), +				 	        ProtocolRevision(dpy)); +	} + +	XCloseDisplay(dpy); + +	return info; +} + +GtkWidget * +x11_get_widget(MainWindow * mainwindow) +{ +	GtkWidget *label, *hbox; +	GtkWidget *table; +#ifdef GTK2 +	GtkWidget *pixmap; +	gchar *buf; +#endif +	X11Info *info; + +	if (!mainwindow) +		return NULL; + +	info = x11_get_info(); +	 +	if (!info) +		return NULL; + +	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); +	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 +	 */ +#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); + +	/* +	 * Table content  +	 */ +	label = gtk_label_new(info->display); +	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->vendor); +	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->version); +	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(info->screen_size); +	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); + +	g_free(info); + +	return hbox; +} @@ -0,0 +1,20 @@ +#ifndef __X11_H__ +#define __X11_H__ + +#include <X11/Xlib.h> +#include <X11/Xutil.h> + +typedef struct _X11Info	X11Info; + +struct _X11Info { +	gchar *display; +	gchar *version; +	gchar *vendor; +	gchar *xf86version; +	gchar *screen_size; +}; + +X11Info	*x11_get_info(void); +GtkWidget *x11_get_widget(MainWindow *mainwindow); + +#endif | 
