Commit 5937de1a authored by Paolo Bacchilega's avatar Paolo Bacchilega
Browse files

Added title support in the comment provider

[bug #605500]
parent 36725ff2
......@@ -31,6 +31,7 @@
struct _GthCommentPrivate { /* All strings in utf8 format. */
char *caption;
char *note;
char *place;
GPtrArray *categories;
......@@ -55,6 +56,11 @@ gth_comment_free_data (GthComment *self)
g_free (self->priv->note);
self->priv->note = NULL;
}
if (self->priv->caption != NULL) {
g_free (self->priv->caption);
self->priv->caption = NULL;
}
}
......@@ -87,6 +93,9 @@ static void
gth_comment_instance_init (GthComment *self)
{
self->priv = GTH_COMMENT_GET_PRIVATE (self);
self->priv->caption = NULL;
self->priv->note = NULL;
self->priv->place = NULL;
self->priv->categories = g_ptr_array_new ();
self->priv->date = g_date_new ();
self->priv->time_of_day = gth_time_new ();
......@@ -125,6 +134,7 @@ gth_comment_real_create_element (DomDomizable *base,
"version", COMMENT_VERSION,
NULL);
dom_element_append_child (element, dom_document_create_element_with_text (doc, self->priv->caption, "caption", NULL));
dom_element_append_child (element, dom_document_create_element_with_text (doc, self->priv->note, "note", NULL));
dom_element_append_child (element, dom_document_create_element_with_text (doc, self->priv->place, "place", NULL));
......@@ -182,7 +192,9 @@ gth_comment_real_load_from_element (DomDomizable *base,
}
else if (g_strcmp0 (dom_element_get_attribute (element, "version"), "3.0") == 0) {
for (node = element->first_child; node; node = node->next_sibling) {
if (g_strcmp0 (node->tag_name, "note") == 0)
if (g_strcmp0 (node->tag_name, "caption") == 0)
gth_comment_set_caption (self, dom_element_get_inner_text (node));
else if (g_strcmp0 (node->tag_name, "note") == 0)
gth_comment_set_note (self, dom_element_get_inner_text (node));
else if (g_strcmp0 (node->tag_name, "place") == 0)
gth_comment_set_place (self, dom_element_get_inner_text (node));
......@@ -352,6 +364,7 @@ gth_comment_dup (GthComment *self)
return NULL;
comment = gth_comment_new ();
gth_comment_set_caption (comment, gth_comment_get_caption (self));
gth_comment_set_note (comment, gth_comment_get_note (self));
gth_comment_set_place (comment, gth_comment_get_place (self));
time = gth_comment_get_time_as_exif_format (self);
......@@ -374,6 +387,18 @@ gth_comment_reset (GthComment *self)
}
void
gth_comment_set_caption (GthComment *comment,
const char *value)
{
g_free (comment->priv->caption);
comment->priv->caption = NULL;
if (value != NULL)
comment->priv->caption = g_strdup (value);
}
void
gth_comment_set_note (GthComment *comment,
const char *value)
......@@ -461,6 +486,13 @@ gth_comment_set_time_from_time_t (GthComment *comment,
}
const char *
gth_comment_get_caption (GthComment *comment)
{
return comment->priv->caption;
}
const char *
gth_comment_get_note (GthComment *comment)
{
......
......@@ -57,6 +57,8 @@ char * gth_comment_to_data (GthComment *comment,
gsize *length);
GthComment * gth_comment_dup (GthComment *comment);
void gth_comment_reset (GthComment *comment);
void gth_comment_set_caption (GthComment *comment,
const char *value);
void gth_comment_set_note (GthComment *comment,
const char *value);
void gth_comment_set_place (GthComment *comment,
......@@ -69,6 +71,7 @@ void gth_comment_set_time_from_exif_format (GthComment *comment,
const char *value);
void gth_comment_set_time_from_time_t (GthComment *comment,
time_t value);
const char * gth_comment_get_caption (GthComment *comment);
const char * gth_comment_get_note (GthComment *comment);
const char * gth_comment_get_place (GthComment *comment);
GPtrArray * gth_comment_get_categories (GthComment *comment);
......
......@@ -37,6 +37,7 @@ gth_metadata_provider_comment_can_read (GthMetadataProvider *self,
{
return _g_file_attributes_matches_any_v ("comment::*,"
"general::datetime,"
"general::title,"
"general::description,"
"general::location,"
"general::tags",
......@@ -51,6 +52,7 @@ gth_metadata_provider_comment_can_write (GthMetadataProvider *self,
{
return _g_file_attributes_matches_any_v ("comment::*,"
"general::datetime,"
"general::title,"
"general::description,"
"general::location,"
"general::tags",
......@@ -100,6 +102,12 @@ gth_metadata_provider_comment_read (GthMetadataProvider *self,
set_attribute_from_string (file_data->info, "general::description", value, NULL);
}
value = gth_comment_get_caption (comment);
if (value != NULL) {
g_file_info_set_attribute_string (file_data->info, "comment::caption", value);
set_attribute_from_string (file_data->info, "general::title", value, NULL);
}
value = gth_comment_get_place (comment);
if (value != NULL) {
g_file_info_set_attribute_string (file_data->info, "comment::place", value);
......@@ -153,6 +161,15 @@ gth_metadata_provider_comment_write (GthMetadataProvider *self,
comment = gth_comment_new ();
/* caption */
metadata = (GthMetadata *) g_file_info_get_attribute_object (file_data->info, "general::title");
if (metadata == NULL)
text = g_file_info_get_attribute_string (file_data->info, "comment::caption");
else
text = gth_metadata_get_raw (metadata);
gth_comment_set_caption (comment, text);
/* comment */
metadata = (GthMetadata *) g_file_info_get_attribute_object (file_data->info, "general::description");
......
......@@ -36,11 +36,12 @@ GthMetadataCategory comments_metadata_category[] = {
GthMetadataInfo comments_metadata_info[] = {
{ "comment::note", "", "comment", 1, GTH_METADATA_ALLOW_NOWHERE },
{ "comment::place", "", "comment", 2, GTH_METADATA_ALLOW_NOWHERE },
{ "comment::time", "", "comment", 3, GTH_METADATA_ALLOW_NOWHERE },
{ "comment::categories", "", "comment", 4, GTH_METADATA_ALLOW_NOWHERE },
{ "comment::rating", "", "comment", 5, GTH_METADATA_ALLOW_NOWHERE },
{ "comment::caption", "", "comment", 1, GTH_METADATA_ALLOW_NOWHERE },
{ "comment::note", "", "comment", 2, GTH_METADATA_ALLOW_NOWHERE },
{ "comment::place", "", "comment", 3, GTH_METADATA_ALLOW_NOWHERE },
{ "comment::time", "", "comment", 4, GTH_METADATA_ALLOW_NOWHERE },
{ "comment::categories", "", "comment", 5, GTH_METADATA_ALLOW_NOWHERE },
{ "comment::rating", "", "comment", 6, GTH_METADATA_ALLOW_NOWHERE },
{ NULL, NULL, NULL, 0, 0 }
};
......
......@@ -4,7 +4,7 @@
<!-- interface-naming-policy project-wide -->
<object class="GtkTable" id="content">
<property name="visible">True</property>
<property name="n_rows">4</property>
<property name="n_rows">6</property>
<property name="n_columns">2</property>
<property name="column_spacing">6</property>
<property name="row_spacing">6</property>
......@@ -29,8 +29,8 @@
<property name="use_underline">True</property>
</object>
<packing>
<property name="top_attach">2</property>
<property name="bottom_attach">3</property>
<property name="top_attach">3</property>
<property name="bottom_attach">4</property>
<property name="x_options">GTK_FILL</property>
<property name="y_options"></property>
</packing>
......@@ -45,15 +45,15 @@
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="top_attach">1</property>
<property name="bottom_attach">2</property>
<property name="top_attach">2</property>
<property name="bottom_attach">3</property>
<property name="y_options"></property>
</packing>
</child>
<child>
<object class="GtkScrolledWindow" id="scrolledwindow3">
<property name="width_request">250</property>
<property name="height_request">200</property>
<property name="height_request">160</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="hscrollbar_policy">automatic</property>
......@@ -70,6 +70,7 @@
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="y_options">GTK_FILL</property>
</packing>
</child>
<child>
......@@ -81,8 +82,8 @@
<property name="mnemonic_widget">place_entry</property>
</object>
<packing>
<property name="top_attach">1</property>
<property name="bottom_attach">2</property>
<property name="top_attach">2</property>
<property name="bottom_attach">3</property>
<property name="x_options">GTK_FILL</property>
<property name="y_options">GTK_FILL</property>
</packing>
......@@ -99,8 +100,9 @@
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="top_attach">3</property>
<property name="bottom_attach">4</property>
<property name="top_attach">4</property>
<property name="bottom_attach">5</property>
<property name="y_options">GTK_FILL</property>
</packing>
</child>
<child>
......@@ -118,8 +120,8 @@
</child>
</object>
<packing>
<property name="top_attach">3</property>
<property name="bottom_attach">4</property>
<property name="top_attach">4</property>
<property name="bottom_attach">5</property>
<property name="x_options">GTK_FILL</property>
<property name="y_options">GTK_FILL</property>
</packing>
......@@ -156,10 +158,81 @@
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="top_attach">2</property>
<property name="bottom_attach">3</property>
<property name="top_attach">3</property>
<property name="bottom_attach">4</property>
<property name="y_options">GTK_FILL</property>
</packing>
</child>
<child>
<object class="GtkHBox" id="hbox4">
<property name="visible">True</property>
<child>
<object class="GtkSpinButton" id="rating_spinbutton">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="invisible_char">&#x25CF;</property>
<property name="adjustment">rating_adjustment</property>
</object>
<packing>
<property name="expand">False</property>
<property name="position">0</property>
</packing>
</child>
</object>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="top_attach">5</property>
<property name="bottom_attach">6</property>
<property name="y_options">GTK_FILL</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="label2">
<property name="visible">True</property>
<property name="xalign">0</property>
<property name="yalign">0.60000002384185791</property>
<property name="label" translatable="yes">_Rating:</property>
<property name="use_underline">True</property>
</object>
<packing>
<property name="top_attach">5</property>
<property name="bottom_attach">6</property>
<property name="y_options">GTK_FILL</property>
</packing>
</child>
<child>
<object class="GtkEntry" id="title_entry">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="invisible_char">&#x25CF;</property>
<property name="activates_default">True</property>
</object>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="top_attach">1</property>
<property name="bottom_attach">2</property>
<property name="y_options"></property>
</packing>
</child>
<child>
<object class="GtkLabel" id="label3">
<property name="visible">True</property>
<property name="xalign">0</property>
<property name="yalign">0.60000002384185791</property>
<property name="label" translatable="yes">_Title:</property>
<property name="use_underline">True</property>
</object>
<packing>
<property name="top_attach">1</property>
<property name="bottom_attach">2</property>
<property name="y_options">GTK_FILL</property>
</packing>
</child>
</object>
<object class="GtkAdjustment" id="rating_adjustment">
<property name="upper">5</property>
<property name="step_increment">1</property>
</object>
</interface>
......@@ -83,6 +83,12 @@ gth_edit_comment_page_real_set_file (GthEditMetadataPage *base,
else
gtk_text_buffer_set_text (buffer, "", -1);
metadata = (GthMetadata *) g_file_info_get_attribute_object (file_data->info, "general::title");
if (metadata != NULL)
gtk_entry_set_text (GTK_ENTRY (GET_WIDGET ("title_entry")), gth_metadata_get_formatted (metadata));
else
gtk_entry_set_text (GTK_ENTRY (GET_WIDGET ("title_entry")), "");
metadata = (GthMetadata *) g_file_info_get_attribute_object (file_data->info, "general::location");
if (metadata != NULL)
gtk_entry_set_text (GTK_ENTRY (GET_WIDGET ("place_entry")), gth_metadata_get_formatted (metadata));
......@@ -140,6 +146,12 @@ gth_edit_comment_page_real_set_file (GthEditMetadataPage *base,
no_provider = FALSE;
_g_object_unref (provider);
provider = gth_main_get_metadata_writer ("general::rating", gth_file_data_get_mime_type (file_data));
gtk_widget_set_sensitive (GET_WIDGET ("rating_spinbutton"), provider != NULL);
if (no_provider && (provider != NULL))
no_provider = FALSE;
_g_object_unref (provider);
if (no_provider)
gtk_widget_hide (GTK_WIDGET (self));
else
......@@ -166,6 +178,16 @@ gth_edit_comment_page_real_update_info (GthEditMetadataPage *base,
self = GTH_EDIT_COMMENT_PAGE (base);
/* caption */
metadata = g_object_new (GTH_TYPE_METADATA,
"id", "general::title",
"raw", gtk_entry_get_text (GTK_ENTRY (GET_WIDGET ("title_entry"))),
"formatted", gtk_entry_get_text (GTK_ENTRY (GET_WIDGET ("title_entry"))),
NULL);
g_file_info_set_attribute_object (info, "general::title", G_OBJECT (metadata));
g_object_unref (metadata);
/* comment */
buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (GET_WIDGET ("note_text")));
......
......@@ -139,6 +139,11 @@ const char *_DESCRIPTION_TAG_NAMES[] = {
NULL
};
const char *_TITLE_TAG_NAMES[] = {
"Xmp::dc::title",
NULL
};
const char *_LOCATION_TAG_NAMES[] = {
"Xmp::iptc::Location",
"Iptc::Application2::LocationName",
......@@ -316,6 +321,7 @@ set_attributes_from_tagsets (GFileInfo *info)
{
set_attribute_from_tagset (info, "general::datetime", _DATE_TAG_NAMES);
set_attribute_from_tagset (info, "general::description", _DESCRIPTION_TAG_NAMES);
set_attribute_from_tagset (info, "general::title", _TITLE_TAG_NAMES);
set_attribute_from_tagset (info, "general::location", _LOCATION_TAG_NAMES);
set_string_list_attribute_from_tagset (info, "general::tags", _KEYWORDS_TAG_NAMES);
set_attribute_from_tagset (info, "Embedded::Photo::DateTimeOriginal", _ORIGINAL_DATE_TAG_NAMES);
......
......@@ -46,6 +46,7 @@ gth_metadata_provider_exiv2_can_read (GthMetadataProvider *self,
"Embedded::Image::*,"
"Embedded::Photo::*,"
"general::datetime,"
"general::title,"
"general::description,"
"general::location,"
"general::tags",
......@@ -67,6 +68,7 @@ gth_metadata_provider_exiv2_can_write (GthMetadataProvider *self,
"Embedded::Image::*,"
"Embedded::Photo::*,"
"general::datetime,"
"general::title,"
"general::description,"
"general::location,"
"general::tags",
......
......@@ -290,7 +290,7 @@ tag_iterate (const GstTagList *list,
tag_key = "audio-video::general::encoder";
}
else if (strcmp (tag, "title") == 0) {
tag_key = "audio-video::general::title";
tag_key = "general::title";
}
else if (strcmp (tag, "artist") == 0) {
tag_key = "audio-video::general::artist";
......
......@@ -103,7 +103,7 @@ _gth_media_viewer_page_update_caption (GthMediaViewerPage *self)
GthMetadata *metadata;
text = NULL;
metadata = (GthMetadata *) g_file_info_get_attribute_object (self->priv->file_data->info, "audio-video::general::title");
metadata = (GthMetadata *) g_file_info_get_attribute_object (self->priv->file_data->info, "general::title");
if (metadata != NULL)
text = gth_metadata_get_formatted (metadata);
else
......
......@@ -41,7 +41,8 @@ gth_metadata_provider_gstreamer_can_read (GthMetadataProvider *self,
return FALSE;
}
return _g_file_attributes_matches_any_v ("general::format,"
return _g_file_attributes_matches_any_v ("general::title,"
"general::format,"
"general::dimensions,"
"audio-video::*",
attribute_v);
......
......@@ -37,7 +37,6 @@ GthMetadataCategory gstreamer_metadata_category[] = {
GthMetadataInfo gstreamer_metadata_info[] = {
{ "audio-video::general::title", N_("Title"), "general", 1, GTH_METADATA_ALLOW_EVERYWHERE },
{ "audio-video::general::artist", N_("Artist"), "general", 2, GTH_METADATA_ALLOW_EVERYWHERE },
{ "audio-video::general::album", N_("Album"), "general", 3, GTH_METADATA_ALLOW_EVERYWHERE },
{ "audio-video::general::bitrate", N_("Bitrate"), "general", 20, GTH_METADATA_ALLOW_IN_PROPERTIES_VIEW },
......
......@@ -55,9 +55,9 @@ _g_object_unref (gpointer object)
void
_g_object_clear (gpointer object)
_g_object_clear (gpointer p)
{
gpointer *object_p = (gpointer *) object;
gpointer *object_p = (gpointer *) p;
if ((object_p != NULL) && (*object_p != NULL)) {
g_object_unref (*object_p);
......
......@@ -78,7 +78,7 @@ G_BEGIN_DECLS
gpointer _g_object_ref (gpointer object);
void _g_object_unref (gpointer object);
void _g_object_clear (gpointer object);
void _g_object_clear (gpointer object_p);
GList * _g_object_list_ref (GList *list);
void _g_object_list_unref (GList *list);
GType g_object_list_get_type (void);
......
......@@ -44,14 +44,15 @@ GthMetadataInfo file_metadata_info[] = {
{ "gth::file::is-modified", NULL, "file", 5, GTH_METADATA_ALLOW_NOWHERE },
{ "gth::file::full-name", N_("Full Name"), "file", 6, GTH_METADATA_ALLOW_IN_PRINT | GTH_METADATA_ALLOW_IN_FILE_LIST },
{ "general::title", N_("Title"), "general", 1, GTH_METADATA_ALLOW_EVERYWHERE },
{ "general::dimensions", N_("Dimensions"), "general", 10, GTH_METADATA_ALLOW_EVERYWHERE },
{ "general::duration", N_("Duration"), "general", 11, GTH_METADATA_ALLOW_EVERYWHERE },
{ "general::format", N_("Format"), "general", 12, GTH_METADATA_ALLOW_IN_PROPERTIES_VIEW },
{ "general::location", N_("Place"), "general", 14, GTH_METADATA_ALLOW_EVERYWHERE },
{ "general::datetime", N_("Date"), "general", 15, GTH_METADATA_ALLOW_EVERYWHERE },
{ "general::description", N_("Description"), "general", 16, GTH_METADATA_ALLOW_IN_PRINT },
{ "general::tags", N_("Tags"), "general", 17, GTH_METADATA_ALLOW_EVERYWHERE },
{ "general::rating", N_("Rating"), "general", 18, GTH_METADATA_ALLOW_EVERYWHERE },
{ "general::description", N_("Description"), "general", 17, GTH_METADATA_ALLOW_IN_PRINT },
{ "general::tags", N_("Tags"), "general", 18, GTH_METADATA_ALLOW_EVERYWHERE },
{ "general::rating", N_("Rating"), "general", 19, GTH_METADATA_ALLOW_EVERYWHERE },
{ "Embedded::Image::Orientation", "", "", 0, GTH_METADATA_ALLOW_NOWHERE },
{ "Embedded::Photo::DateTimeOriginal", "", "", 0, GTH_METADATA_ALLOW_NOWHERE },
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment