⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 bar_exif.c

📁 Gqview,Linux下基于GTK+库写成的轻量级而能丰富的图像浏览程序。
💻 C
📖 第 1 页 / 共 2 页
字号:
/* * GQview * (C) 2004 John Ellis * * Author: John Ellis * * This software is released under the GNU General Public License (GNU GPL). * Please read the included file COPYING for more information. * This software comes with no warranty of any kind, use at your own risk! */#include "gqview.h"#include "bar_exif.h"#include "exif.h"#include "ui_bookmark.h"#include "ui_misc.h"#include <math.h>#define EXIF_BAR_SIZE_INCREMENT 48#define EXIF_BAR_ARROW_SIZE 7#define EXIF_BAR_CUSTOM_COUNT 20#define BAR_EXIF_DATA_COLUMN_WIDTH 250static const gchar *bar_exif_key_list[] = {	"fCamera",	"fDateTime",	"fShutterSpeed",	"fAperture",	"ExposureProgram",	"fExposureBias",	"fISOSpeedRating",	"fFocalLength",	"fSubjectDistance",	"MeteringMode",	"fFlash",	"LightSource",	"fResolution",	"Orientation",	"ImageDescription",	"Copyright"};#define bar_exif_key_count (sizeof(bar_exif_key_list) / sizeof(gchar *))/* *------------------------------------------------------------------- * table util *------------------------------------------------------------------- */static void table_add_line_custom(GtkWidget *table, gint x, gint y,                                  const gchar *text1, const gchar *text2,                                  GtkWidget **label1, GtkWidget **label2){	GtkWidget *label;	gchar *buf;	buf = g_strconcat((text1) ? text1 : "fixme", ":", NULL);	if (!text2) text2 = "";	label = gtk_label_new(buf);	gtk_misc_set_alignment(GTK_MISC(label), 1.0, 0.0);	pref_label_bold(label, TRUE, FALSE);	gtk_table_attach(GTK_TABLE(table), label,			 x, x + 1, y, y + 1,			 GTK_FILL, GTK_FILL,			 2, 2);	*label1 = label;	label = gtk_label_new(text2);	gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.0);	gtk_table_attach(GTK_TABLE(table), label,			 x + 1, x + 2, y, y + 1,			 GTK_FILL, GTK_FILL,			 2, 2);	*label2 = label;	g_free(buf);}static GtkWidget *table_add_line(GtkWidget *table, gint x, gint y,				 const gchar *description, const gchar *text){	GtkWidget *key;	GtkWidget *label;	table_add_line_custom(table, x, y, description, text, &key, &label);	gtk_widget_show(key);	gtk_widget_show(label);	return label;}/* *------------------------------------------------------------------- * EXIF bar *------------------------------------------------------------------- */typedef struct _ExifBar ExifBar;struct _ExifBar{	GtkWidget *vbox;	GtkWidget *scrolled;	GtkWidget *table;	GtkWidget *advanced_scrolled;	GtkWidget *listview;	GtkWidget **labels;	GtkWidget *custom_sep;	GtkWidget *custom_name[EXIF_BAR_CUSTOM_COUNT];	GtkWidget *custom_value[EXIF_BAR_CUSTOM_COUNT];	gchar *path;	gint allow_search;};enum {	EXIF_ADVCOL_ENABLED = 0,	EXIF_ADVCOL_TAG,	EXIF_ADVCOL_NAME,	EXIF_ADVCOL_VALUE,	EXIF_ADVCOL_FORMAT,	EXIF_ADVCOL_ELEMENTS,	EXIF_ADVCOL_DESCRIPTION,	EXIF_ADVCOL_COUNT};static gchar *bar_exif_validate_text(gchar *text){	if (text && !g_utf8_validate(text, strlen(text), NULL))		{		gchar *tmp = text;		text = g_convert(tmp, strlen(tmp), "UTF-8", "ISO-8859-1", NULL, NULL, NULL);		g_free(tmp);		}	return text;}static void bar_exif_sensitive(ExifBar *eb, gint enable){	gtk_widget_set_sensitive(eb->table, enable);	if (eb->advanced_scrolled) gtk_widget_set_sensitive(eb->advanced_scrolled, enable);}static gint bar_exif_row_enabled(const gchar *name){	GList *list;	list = history_list_get_by_key("exif_extras");	while (list)		{		if (name && strcmp(name, (gchar *)(list->data)) == 0) return TRUE;		list = list->next;	}	return FALSE;}static void bar_exif_update(ExifBar *eb){	ExifData *exif;	gint len, i;	exif = exif_read(eb->path);	if (!exif)		{		bar_exif_sensitive(eb, FALSE);		return;		}	bar_exif_sensitive(eb, TRUE);	if (GTK_WIDGET_VISIBLE(eb->scrolled))		{		GList *list;		len = bar_exif_key_count;		for (i = 0; i < len; i++)			{			gchar *text;			text = exif_get_data_as_text(exif, bar_exif_key_list[i]);			text = bar_exif_validate_text(text);			gtk_label_set_text(GTK_LABEL(eb->labels[i]), text);			g_free(text);			}		list = g_list_last(history_list_get_by_key("exif_extras"));		if (list)			{			gtk_widget_show(eb->custom_sep);			}		else			{			gtk_widget_hide(eb->custom_sep);			}		i = 0;		while (list && i < EXIF_BAR_CUSTOM_COUNT)			{			gchar *text;			gchar *name;			gchar *buf;			name = list->data;			list = list->prev;			text = exif_get_data_as_text(exif, name);			text = bar_exif_validate_text(text);			buf = g_strconcat(name, ":", NULL);			gtk_label_set_text(GTK_LABEL(eb->custom_name[i]), buf);			g_free(buf);			gtk_label_set_text(GTK_LABEL(eb->custom_value[i]), text);			g_free(text);			gtk_widget_show(eb->custom_name[i]);			gtk_widget_show(eb->custom_value[i]);			i++;			}		while (i < EXIF_BAR_CUSTOM_COUNT)			{			gtk_widget_hide(eb->custom_name[i]);			gtk_widget_hide(eb->custom_value[i]);			i++;			}		}	if (eb->advanced_scrolled && GTK_WIDGET_VISIBLE(eb->advanced_scrolled))		{		GtkListStore *store;		GtkTreeIter iter;		GList *work;				store = GTK_LIST_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW(eb->listview)));		gtk_list_store_clear(store);		work = exif->items;		while (work)			{			ExifItem *item;			gchar *tag;			const gchar *tag_name;			gchar *text;			const gchar *format;			gchar *elements;			const gchar *description;			item = work->data;			work = work->next;			tag = g_strdup_printf("0x%04x", item->tag);			tag_name = exif_item_get_tag_name(item);			format = exif_item_get_format_name(item, TRUE);			text = exif_item_get_data_as_text(item);			text = bar_exif_validate_text(text);			elements = g_strdup_printf("%d", item->elements);			description = exif_item_get_description(item);			if (!description) description = "";			gtk_list_store_append(store, &iter);			gtk_list_store_set(store, &iter,					EXIF_ADVCOL_ENABLED, bar_exif_row_enabled(tag_name),					EXIF_ADVCOL_TAG, tag,					EXIF_ADVCOL_NAME, tag_name,					EXIF_ADVCOL_VALUE, text,					EXIF_ADVCOL_FORMAT, format,					EXIF_ADVCOL_ELEMENTS, elements,					EXIF_ADVCOL_DESCRIPTION, description, -1);			g_free(tag);			g_free(text);			g_free(elements);			}		}	exif_free(exif);}static void bar_exif_clear(ExifBar *eb){	gint len;	gint i;	if (!GTK_WIDGET_SENSITIVE(eb->labels[0])) return;	len = bar_exif_key_count;	for (i = 0; i < len; i++)		{		gtk_label_set_text(GTK_LABEL(eb->labels[i]), "");		}	for (i = 0; i < EXIF_BAR_CUSTOM_COUNT; i++)		{		gtk_label_set_text(GTK_LABEL(eb->custom_value[i]), "");		}	if (eb->listview)		{		GtkListStore *store;		store = GTK_LIST_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW(eb->listview)));		gtk_list_store_clear(store);		}}void bar_exif_set(GtkWidget *bar, const gchar *path){	ExifBar *eb;	eb = g_object_get_data(G_OBJECT(bar), "bar_exif_data");	if (!eb) return;	/* store this, advanced view toggle needs to reload data */	g_free(eb->path);	eb->path = g_strdup(path);	bar_exif_clear(eb);	bar_exif_update(eb);}static void bar_exif_row_toggled_cb(GtkCellRendererToggle *toggle, const gchar *path, gpointer data){	GtkWidget *listview = data;	GtkTreeModel *store;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -