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 /v4l.c | |
| 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.
Diffstat (limited to 'v4l.c')
| -rw-r--r-- | v4l.c | 137 | 
1 files changed, 137 insertions, 0 deletions
| @@ -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); +	} +} | 
