/* Interface for EXIF data */ static int lua_exif_get_datum(lua_State *L) { const gchar *key; gchar *value = NULL; ExifData *exif; struct tm tm; time_t datetime; exif = lua_check_exif(L, 1); key = luaL_checkstring(L, 2); if (key == (gchar*)NULL || key[0] == '\0') { lua_pushnil(L); return 1; } if (!exif) { lua_pushnil(L); return 1; } value = exif_get_data_as_text(exif, key); if (strcmp(key, "Exif.Photo.DateTimeOriginal") == 0) { memset(&tm, 0, sizeof(tm)); if (value && strptime(value, "%Y:%m:%d %H:%M:%S", &tm)) { datetime = mktime(&tm); lua_pushnumber(L, datetime); return 1; } else { lua_pushnil(L); return 1; } } else if (strcmp(key, "Exif.Photo.DateTimeDigitized") == 0) { memset(&tm, 0, sizeof(tm)); if (value && strptime(value, "%Y:%m:%d %H:%M:%S", &tm)) { datetime = mktime(&tm); lua_pushnumber(L, datetime); return 1; } else { lua_pushnil(L); return 1; } } lua_pushstring(L, value); return 1; }
static void bar_exif_update(ExifBar *eb) { ExifData *exif; gint len, i; exif = exif_read(eb->path, FALSE); 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); }