[gthumb] allow to update some file attributes from the image viewer
- From: Paolo Bacchilega <paobac src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gthumb] allow to update some file attributes from the image viewer
- Date: Wed, 28 Jun 2017 09:51:37 +0000 (UTC)
commit f8209791a3d06a485eae49756d601aea69ddc879
Author: Paolo Bacchilega <paobac src gnome org>
Date: Tue Jun 27 16:58:13 2017 +0200
allow to update some file attributes from the image viewer
some attributes are only available after loading the image
extensions/file_viewer/gth-file-viewer-page.c | 2 +-
extensions/gstreamer_tools/gth-media-viewer-page.c | 17 +++++++++---
gthumb/glib-utils.c | 27 ++++++++++++++++++++
gthumb/glib-utils.h | 2 +
gthumb/gth-browser.c | 8 +++--
gthumb/gth-marshal.list | 1 +
gthumb/gth-viewer-page.c | 8 +++--
gthumb/gth-viewer-page.h | 1 +
8 files changed, 54 insertions(+), 12 deletions(-)
---
diff --git a/extensions/file_viewer/gth-file-viewer-page.c b/extensions/file_viewer/gth-file-viewer-page.c
index b043222..c1b20b9 100644
--- a/extensions/file_viewer/gth-file-viewer-page.c
+++ b/extensions/file_viewer/gth-file-viewer-page.c
@@ -210,7 +210,7 @@ thumb_loader_ready_cb (GObject *source_object,
_g_object_unref (pixbuf);
}
- gth_viewer_page_file_loaded (GTH_VIEWER_PAGE (self), self->priv->file_data, TRUE);
+ gth_viewer_page_file_loaded (GTH_VIEWER_PAGE (self), self->priv->file_data, NULL, TRUE);
}
cairo_surface_destroy (image);
diff --git a/extensions/gstreamer_tools/gth-media-viewer-page.c
b/extensions/gstreamer_tools/gth-media-viewer-page.c
index d7d32eb..eb0f529 100644
--- a/extensions/gstreamer_tools/gth-media-viewer-page.c
+++ b/extensions/gstreamer_tools/gth-media-viewer-page.c
@@ -47,6 +47,7 @@ G_DEFINE_TYPE_WITH_CODE (GthMediaViewerPage,
struct _GthMediaViewerPagePrivate {
GthBrowser *browser;
GthFileData *file_data;
+ GFileInfo *updated_info;
GstElement *playbin;
GtkBuilder *builder;
GtkWidget *video_area;
@@ -838,8 +839,8 @@ update_stream_info (GthMediaViewerPage *self)
if (gst_structure_get_int (structure, "width", &video_width)
&& gst_structure_get_int (structure, "height", &video_height))
{
- g_file_info_set_attribute_int32 (self->priv->file_data->info,
"frame::width", video_width);
- g_file_info_set_attribute_int32 (self->priv->file_data->info,
"frame::height", video_height);
+ g_file_info_set_attribute_int32 (self->priv->updated_info,
"frame::width", video_width);
+ g_file_info_set_attribute_int32 (self->priv->updated_info,
"frame::height", video_height);
self->priv->has_video = TRUE;
}
@@ -879,12 +880,12 @@ bus_message_cb (GstBus *bus,
if ((old_state == GST_STATE_NULL) && (new_state == GST_STATE_READY) && (pending_state !=
GST_STATE_PAUSED)) {
update_stream_info (self);
gth_viewer_page_update_sensitivity (GTH_VIEWER_PAGE (self));
- gth_viewer_page_file_loaded (GTH_VIEWER_PAGE (self), self->priv->file_data, TRUE);
+ gth_viewer_page_file_loaded (GTH_VIEWER_PAGE (self), self->priv->file_data,
self->priv->updated_info, TRUE);
}
if ((old_state == GST_STATE_READY) && (new_state == GST_STATE_PAUSED)) {
update_stream_info (self);
gth_viewer_page_update_sensitivity (GTH_VIEWER_PAGE (self));
- gth_viewer_page_file_loaded (GTH_VIEWER_PAGE (self), self->priv->file_data, TRUE);
+ gth_viewer_page_file_loaded (GTH_VIEWER_PAGE (self), self->priv->file_data,
self->priv->updated_info, TRUE);
}
if ((old_state == GST_STATE_READY) || (new_state == GST_STATE_PAUSED))
update_volume_from_playbin (self);
@@ -910,7 +911,7 @@ bus_message_cb (GstBus *bus,
}
case GST_MESSAGE_ERROR:
- gth_viewer_page_file_loaded (GTH_VIEWER_PAGE (self), self->priv->file_data, FALSE);
+ gth_viewer_page_file_loaded (GTH_VIEWER_PAGE (self), self->priv->file_data, NULL, FALSE);
break;
default:
@@ -1092,7 +1093,9 @@ gth_media_viewer_page_real_view (GthViewerPage *base,
/**/
_g_object_unref (self->priv->file_data);
+ _g_object_unref (self->priv->updated_info);
self->priv->file_data = gth_file_data_dup (file_data);
+ self->priv->updated_info = g_file_info_new ();
self->priv->duration = 0;
self->priv->has_audio = FALSE;
@@ -1222,6 +1225,7 @@ gth_media_viewer_page_real_update_info (GthViewerPage *base,
if (! _g_file_equal (self->priv->file_data->file, file_data->file))
return;
+
_g_object_unref (self->priv->file_data);
self->priv->file_data = gth_file_data_dup (file_data);
}
@@ -1252,6 +1256,7 @@ gth_media_viewer_page_finalize (GObject *obj)
}
_g_object_unref (self->priv->icon);
_g_object_unref (self->priv->file_data);
+ _g_object_unref (self->priv->updated_info);
if (self->priv->screensaver != NULL) {
gth_screensaver_uninhibit (self->priv->screensaver);
g_object_unref (self->priv->screensaver);
@@ -1307,6 +1312,8 @@ gth_media_viewer_page_init (GthMediaViewerPage *self)
self->priv->visible = FALSE;
self->priv->screenshot_button = NULL;
self->priv->background_painted = FALSE;
+ self->priv->file_data = NULL;
+ self->priv->updated_info = NULL;
}
diff --git a/gthumb/glib-utils.c b/gthumb/glib-utils.c
index f564c36..4ba90f8 100644
--- a/gthumb/glib-utils.c
+++ b/gthumb/glib-utils.c
@@ -2952,6 +2952,33 @@ _g_file_info_get_secondary_sort_order (GFileInfo *info)
}
+void
+_g_file_info_update (GFileInfo *dest_info,
+ GFileInfo *src_info)
+{
+ char **attributes;
+ int i;
+
+ attributes = g_file_info_list_attributes (src_info, NULL);
+ for (i = 0; attributes[i] != NULL; i++) {
+ GFileAttributeType type;
+ gpointer value_pp;
+ GFileAttributeStatus status;
+
+ if (g_file_info_get_attribute_data (src_info,
+ attributes[i],
+ &type,
+ &value_pp,
+ &status))
+ {
+ g_file_info_set_attribute (dest_info, attributes[i], type, value_pp);
+ }
+ }
+
+ g_strfreev (attributes);
+}
+
+
const char *
_g_content_type_guess_from_name (const char *filename)
{
diff --git a/gthumb/glib-utils.h b/gthumb/glib-utils.h
index de318b3..f161a5d 100644
--- a/gthumb/glib-utils.h
+++ b/gthumb/glib-utils.h
@@ -328,6 +328,8 @@ void _g_file_info_set_secondary_sort_order
gint32 sort_order);
gint32 _g_file_info_get_secondary_sort_order
(GFileInfo *info);
+void _g_file_info_update (GFileInfo *dest_info,
+ GFileInfo *src_info);
const char * _g_content_type_guess_from_name (const char *filename);
gboolean _g_content_type_is_a (const char *type,
const char *supertype);
diff --git a/gthumb/gth-browser.c b/gthumb/gth-browser.c
index c223a2c..163b554 100644
--- a/gthumb/gth-browser.c
+++ b/gthumb/gth-browser.c
@@ -6075,6 +6075,7 @@ load_file_data_unref (LoadFileData *data)
static void
gth_viewer_page_file_loaded_cb (GthViewerPage *viewer_page,
GthFileData *file_data,
+ GFileInfo *updated_metadata,
gboolean success,
gpointer user_data);
@@ -6124,8 +6125,7 @@ file_metadata_ready_cb (GList *files,
/* the mime type can be different for example when a jpeg image has a .png extension */
different_mime_type = ! g_str_equal (gth_file_data_get_mime_type (browser->priv->current_file),
gth_file_data_get_mime_type (file_data));
- g_file_info_copy_into (file_data->info, browser->priv->current_file->info);
- g_file_info_set_attribute_boolean (browser->priv->current_file->info, "gth::file::is-modified",
FALSE);
+ _g_file_info_update (browser->priv->current_file->info, file_data->info);
gth_browser_update_title (browser);
gth_browser_update_statusbar_file_info (browser);
@@ -6205,6 +6205,7 @@ load_metadata_cb (gpointer user_data)
static void
gth_viewer_page_file_loaded_cb (GthViewerPage *viewer_page,
GthFileData *file_data,
+ GFileInfo *updated_metadata,
gboolean success,
gpointer user_data)
{
@@ -6230,6 +6231,7 @@ gth_viewer_page_file_loaded_cb (GthViewerPage *viewer_page,
return;
}
+ _g_file_info_update (browser->priv->current_file->info, updated_metadata);
g_file_info_set_attribute_boolean (browser->priv->current_file->info, "gth::file::is-modified",
FALSE);
if (browser->priv->load_metadata_timeout != 0)
@@ -6327,7 +6329,7 @@ _gth_browser_load_file (GthBrowser *browser,
if (browser->priv->viewer_page != NULL)
gth_viewer_page_view (browser->priv->viewer_page, browser->priv->current_file);
else
- gth_viewer_page_file_loaded_cb (NULL, browser->priv->current_file, FALSE, browser);
+ gth_viewer_page_file_loaded_cb (NULL, browser->priv->current_file, NULL, FALSE, browser);
}
diff --git a/gthumb/gth-marshal.list b/gthumb/gth-marshal.list
index 3d5a98c..8c873a2 100644
--- a/gthumb/gth-marshal.list
+++ b/gthumb/gth-marshal.list
@@ -9,6 +9,7 @@ VOID:OBJECT, BOOLEAN
VOID:OBJECT, BOXED, ENUM
VOID:OBJECT, BOXED, INT, ENUM
VOID:OBJECT, OBJECT
+VOID:OBJECT, OBJECT, BOOLEAN
VOID:OBJECT, POINTER
VOID:OBJECT, STRING
VOID:OBJECT, UINT
diff --git a/gthumb/gth-viewer-page.c b/gthumb/gth-viewer-page.c
index 0dfb828..4ba3f22 100644
--- a/gthumb/gth-viewer-page.c
+++ b/gthumb/gth-viewer-page.c
@@ -49,10 +49,11 @@ gth_viewer_page_default_init (GthViewerPageInterface *iface)
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (GthViewerPageInterface, file_loaded),
NULL, NULL,
- gth_marshal_VOID__OBJECT_BOOLEAN,
+ gth_marshal_VOID__OBJECT_OBJECT_BOOLEAN,
G_TYPE_NONE,
- 2,
+ 3,
G_TYPE_OBJECT,
+ G_TYPE_OBJECT,
G_TYPE_BOOLEAN);
initialized = TRUE;
@@ -193,7 +194,8 @@ gth_viewer_page_show_properties (GthViewerPage *self,
void
gth_viewer_page_file_loaded (GthViewerPage *self,
GthFileData *file_data,
+ GFileInfo *updated_metadata,
gboolean success)
{
- g_signal_emit (self, gth_viewer_page_signals[FILE_LOADED], 0, file_data, success);
+ g_signal_emit (self, gth_viewer_page_signals[FILE_LOADED], 0, file_data, updated_metadata, success);
}
diff --git a/gthumb/gth-viewer-page.h b/gthumb/gth-viewer-page.h
index 02ee2c8..ca56255 100644
--- a/gthumb/gth-viewer-page.h
+++ b/gthumb/gth-viewer-page.h
@@ -114,6 +114,7 @@ void gth_viewer_page_show_properties (GthViewerPage *self,
gboolean show);
void gth_viewer_page_file_loaded (GthViewerPage *self,
GthFileData *file_data,
+ GFileInfo *updated_metadata,
gboolean success);
G_END_DECLS
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]