Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Luigi Maselli
committed
Feb 1, 2009
1 parent
1dda8a9
commit d33a626
Showing
23 changed files
with
3,412 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,7 @@ | ||
see: http://grigio.org/xmp_manager | ||
|
||
Regenerate the UI | ||
------------------ | ||
Xmp Manager uses Gtk::Builder, but Glade doesn't support it natively so you need to regenerate the Gtk GUI everytime you do a change: | ||
|
||
$ gtk-builder-convert data/xmpmanager/nautilus-xmp-manager.glade data/xmpmanager/nautilus-xmp-manager.ui |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
$:.unshift(File.join(File.dirname(__FILE__), 'lib')) | ||
require 'rubygems' | ||
require 'spec/version' | ||
require 'spec/rake/spectask' | ||
|
||
desc "Run all specs" | ||
Spec::Rake::SpecTask.new do |t| | ||
t.spec_files = FileList['spec/**/*_spec.rb'] | ||
t.spec_opts = ['--options', 'spec/spec.opts'] | ||
end | ||
|
||
task :RegenerateUi do | ||
puts "Regenerate the Gtk GUI" | ||
system 'gtk-builder-convert data/xmpmanager/nautilus-xmp-manager.glade data/xmpmanager/nautilus-xmp-manager.ui' | ||
end |
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
# XMP Manager is a GUI to easly write XMP Metadata and tags on files | ||
# | ||
# Copyright (C) 2007 Luigi Maselli <luigix_@t_gmail_com> | ||
# | ||
# This program is free software; you can redistribute it and/or modify it under | ||
# the terms of the GNU General Public License as published by the Free Software | ||
# Foundation; either version 2, or (at your option) any later version. | ||
# | ||
# This program is distributed in the hope that it will be useful, but WITHOUT | ||
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS | ||
# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more | ||
# details. | ||
# | ||
# You should have received a copy of the GNU General Public License along with | ||
# this program; if not, write to the Free Software Foundation, Inc., 51 Franklin | ||
# St, Fifth Floor, Boston, MA 02110-1301 USA | ||
|
||
module XmpManager | ||
|
||
module Exiftool | ||
EXIFTOOL = "/usr/bin/exiftool" | ||
|
||
def load_fields(path) | ||
fields = {} | ||
command = "|#{EXIFTOOL} #{path} -xmp:all" | ||
puts ">> #{command}" if DEBUG | ||
cmd = open(command) | ||
while (temp = cmd.gets) | ||
key, value = parse_line(temp) | ||
fields[key] = value unless key.nil? | ||
end | ||
cmd.close | ||
fields | ||
end | ||
|
||
def save | ||
field_list = '' | ||
fields.each do |field, value| | ||
unless field == 'subject' | ||
field_list << " -xmp:#{field}=\"#{value}\"" | ||
else | ||
tags = value.split(", ") | ||
tags.each {|tag| field_list << " -xmp:#{field}=\"#{tag}\""} | ||
end | ||
end | ||
command = "#{EXIFTOOL} #{path} #{field_list} -overwrite_original_in_place" | ||
puts ">> #{command}" if DEBUG | ||
cmd = system command | ||
end | ||
# -- | ||
|
||
private | ||
|
||
def parse_line(line) | ||
# "Country : italia".downcase.strip | ||
key, value = line.split(': ') unless line.nil? | ||
return nil, nil if key.nil? || value.nil? | ||
key.downcase!.gsub!(' ','').gsub!("/",'_') # To generate valid methods in Selection | ||
value[-1]='' #remove a capo | ||
return key, value | ||
end | ||
|
||
end | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
# XMP Manager is a GUI to easly write XMP Metadata and tags on files | ||
# | ||
# Copyright (C) 2007 Luigi Maselli <luigix_@t_gmail_com> | ||
# | ||
# This program is free software; you can redistribute it and/or modify it under | ||
# the terms of the GNU General Public License as published by the Free Software | ||
# Foundation; either version 2, or (at your option) any later version. | ||
# | ||
# This program is distributed in the hope that it will be useful, but WITHOUT | ||
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS | ||
# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more | ||
# details. | ||
# | ||
# You should have received a copy of the GNU General Public License along with | ||
# this program; if not, write to the Free Software Foundation, Inc., 51 Franklin | ||
# St, Fifth Floor, Boston, MA 02110-1301 USA | ||
|
||
require 'xmpmanager/backend/exiftool' | ||
|
||
module XmpManager | ||
|
||
class File | ||
# backend specific methods | ||
include XmpManager::Exiftool | ||
|
||
def initialize(path) | ||
@path = path | ||
@field = load_fields(path) | ||
end | ||
|
||
def path | ||
@path | ||
end | ||
|
||
def field | ||
@field | ||
end | ||
alias_method :fields, :field | ||
|
||
# is selection? TODO: write tag? | ||
def tags | ||
@field['subject'].split(', ').sort | ||
end | ||
|
||
def reload! | ||
|
||
end | ||
|
||
# def save | ||
# | ||
# end | ||
|
||
|
||
#private | ||
|
||
|
||
end | ||
|
||
end |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,133 @@ | ||
# XMP Manager is a GUI to easly write XMP Metadata and tags on files | ||
# | ||
# Copyright (C) 2007 Luigi Maselli <luigix_@t_gmail_com> | ||
# | ||
# This program is free software; you can redistribute it and/or modify it under | ||
# the terms of the GNU General Public License as published by the Free Software | ||
# Foundation; either version 2, or (at your option) any later version. | ||
# | ||
# This program is distributed in the hope that it will be useful, but WITHOUT | ||
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS | ||
# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more | ||
# details. | ||
# | ||
# You should have received a copy of the GNU General Public License along with | ||
# this program; if not, write to the Free Software Foundation, Inc., 51 Franklin | ||
# St, Fifth Floor, Boston, MA 02110-1301 USA | ||
|
||
require 'xmpmanager/file' | ||
|
||
module XmpManager | ||
|
||
class Selection | ||
# backend specific methods | ||
include XmpManager::Exiftool | ||
|
||
def initialize(*paths) | ||
# clean *paths ARGV ? | ||
*paths = 'spec/images/write-tests/a.jpg', 'spec/images/write-tests/b.jpg' if DEBUG | ||
@files = load_files(*paths) # return a File Array | ||
@field, @status, @tags = {}, {}, {} | ||
#@field, @status, @tags = | ||
load_selection # from @files | ||
load_dynamic_methods | ||
#load_dynamic_methods | ||
#load_template # common fields | ||
end | ||
|
||
def field(key = nil) | ||
if key.nil? | ||
@field | ||
else | ||
@field[key] | ||
end | ||
end | ||
alias_method :fields, :field | ||
|
||
# Old style method *not dynamic* | ||
def field_set(key, value) | ||
@field[key] = value | ||
end | ||
|
||
# it takes the intersection of common tags | ||
def tags | ||
@tags.keys.sort | ||
end | ||
|
||
def tag_add(tag) | ||
@tags[tag] = true | ||
end | ||
|
||
def tag_del(tag) | ||
@tags[tag] = false | ||
end | ||
|
||
def tag_status(tag) | ||
@tags[tag] | ||
end | ||
|
||
def status(key) | ||
@status[key] | ||
end | ||
|
||
def save | ||
@files.each do |file| | ||
@field.each do |key, value| | ||
file.field[key] = value | ||
end | ||
|
||
tags_to_write = "" | ||
@tags.each{|key, value| tags_to_write << key+", "} #TODO: fix inconsistencies | ||
file.field['subject'] = tags_to_write | ||
|
||
file.save | ||
end | ||
end | ||
|
||
private | ||
|
||
def load_files(*paths) | ||
files = [] | ||
paths.each do |path| | ||
files << XmpManager::File.new(path) | ||
end | ||
files | ||
end | ||
|
||
def load_selection | ||
# load default fields FIXME: move to template | ||
@field.merge! 'description' => '', 'author' => '', 'rights' => '' | ||
# load data | ||
@files.each do |file| | ||
@field.merge! file.fields | ||
end | ||
# load tags #FIXME: nil false true | ||
@files.each do |file| | ||
file.tags.each do |tag| | ||
@tags.merge! tag => true | ||
end | ||
end | ||
end | ||
|
||
def load_dynamic_methods | ||
# TODO: changed? false | ||
# ex. sel.title, sel.title = <value>, sel.title_changed? | ||
@field.each_key do |key| | ||
eval <<-STR | ||
def #{key}=(value) | ||
unless value.empty? | ||
@field['#{key}'] = value | ||
@status['#{key}'] = true | ||
else | ||
@status['#{key}'] = false | ||
end | ||
end | ||
def #{key}; @field['#{key}']; end | ||
def #{key}_changed?; @status['#{key}']; end | ||
STR | ||
end | ||
end | ||
|
||
end | ||
|
||
end |
Oops, something went wrong.