Commit 04efbae0 authored by Paolo Bacchilega's avatar Paolo Bacchilega
Browse files

update the property view after loading the image

parent 37bae9f4
......@@ -81,9 +81,9 @@ thumb_loader_ready_cb (GthThumbLoader *il,
GError *error,
GthFileViewerPage *self)
{
if (error != NULL)
return;
gtk_image_set_from_pixbuf (GTK_IMAGE (self->priv->icon), gth_thumb_loader_get_pixbuf (self->priv->thumb_loader));
gth_viewer_page_file_loaded (GTH_VIEWER_PAGE (self));
if (error == NULL)
gtk_image_set_from_pixbuf (GTK_IMAGE (self->priv->icon), gth_thumb_loader_get_pixbuf (self->priv->thumb_loader));
}
......
......@@ -930,6 +930,7 @@ gth_media_viewer_page_real_view (GthViewerPage *base,
/**/
gth_viewer_page_file_loaded (GTH_VIEWER_PAGE (self));
g_signal_handlers_block_by_func(GET_WIDGET ("adjustment_position"), position_value_changed_cb, self);
gtk_adjustment_set_value (GTK_ADJUSTMENT (GET_WIDGET ("adjustment_position")), 0.0);
g_signal_handlers_unblock_by_func(GET_WIDGET ("adjustment_position"), position_value_changed_cb, self);
......
......@@ -206,9 +206,7 @@ image_ready_cb (GtkWidget *widget,
gth_image_history_add_image (self->priv->history,
gth_image_viewer_get_current_pixbuf (GTH_IMAGE_VIEWER (self->priv->viewer)),
FALSE);
g_file_info_set_attribute_boolean (self->priv->file_data->info, "gth::file::is-modified", FALSE);
gth_monitor_metadata_changed (gth_main_get_default_monitor (), self->priv->file_data);
gth_viewer_page_file_loaded (GTH_VIEWER_PAGE (self));
}
......
......@@ -4183,6 +4183,22 @@ gth_browser_show_last_image (GthBrowser *browser,
}
static void
gth_viewer_page_file_loaded_cb (GthViewerPage *viewer_page,
gpointer user_data)
{
GthBrowser *browser = user_data;
g_file_info_set_attribute_boolean (browser->priv->current_file->info, "gth::file::is-modified", FALSE);
gth_browser_update_title (browser);
_gth_browser_update_statusbar_file_info (browser);
gth_sidebar_set_file (GTH_SIDEBAR (browser->priv->file_properties), browser->priv->current_file);
gth_sidebar_set_file (GTH_SIDEBAR (browser->priv->viewer_sidebar), browser->priv->current_file);
gth_browser_update_sensitivity (browser);
}
static void
file_metadata_ready_cb (GList *files,
GError *error,
......@@ -4199,15 +4215,11 @@ file_metadata_ready_cb (GList *files,
return;
g_file_info_copy_into (file_data->info, browser->priv->current_file->info);
gth_sidebar_set_file (GTH_SIDEBAR (browser->priv->file_properties), file_data);
gth_sidebar_set_file (GTH_SIDEBAR (browser->priv->viewer_sidebar), file_data);
_gth_browser_update_statusbar_file_info (browser);
if (browser->priv->viewer_page != NULL)
gth_viewer_page_view (browser->priv->viewer_page, file_data);
gth_browser_update_title (browser);
gth_browser_update_sensitivity (browser);
else
gth_viewer_page_file_loaded_cb (NULL, browser);
if (browser->priv->location == NULL) {
GFile *parent;
......@@ -4339,6 +4351,11 @@ _gth_browser_load_file (GthBrowser *browser,
browser->priv->viewer_page = g_object_new (G_OBJECT_TYPE (registered_viewer_page), NULL);
gth_viewer_page_activate (browser->priv->viewer_page, browser);
gtk_ui_manager_ensure_update (browser->priv->ui);
g_signal_connect (browser->priv->viewer_page,
"file-loaded",
G_CALLBACK (gth_viewer_page_file_loaded_cb),
browser);
}
break;
}
......
......@@ -92,26 +92,27 @@ gth_file_properties_real_set_file (GthPropertyView *self,
GthFileData *file_data)
{
GthFileProperties *file_properties;
GHashTable *category_root;
GHashTable *category_hash;
GPtrArray *metadata_info;
int i;
GtkTextBuffer *text_buffer;
char *comment;
file_properties = GTH_FILE_PROPERTIES (self);
gtk_list_store_clear (file_properties->priv->tree_model);
if (file_data == NULL)
return;
category_root = g_hash_table_new_full (g_str_hash, g_str_equal, (GDestroyNotify) g_free, NULL);
gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (file_properties->priv->tree_model), GTK_TREE_SORTABLE_UNSORTED_SORT_COLUMN_ID, 0);
category_hash = g_hash_table_new_full (g_str_hash, g_str_equal, (GDestroyNotify) g_free, NULL);
metadata_info = gth_main_get_all_metadata_info ();
for (i = 0; i < metadata_info->len; i++) {
GthMetadataInfo *info;
GthMetadataCategory *category;
char *value;
char *tooltip;
GthMetadataCategory *category;
GtkTreeIter iter;
info = g_ptr_array_index (metadata_info, i);
......@@ -121,8 +122,6 @@ gth_file_properties_real_set_file (GthPropertyView *self,
if ((info->display_name == NULL) || (strncmp (info->display_name, "0x", 2) == 0))
continue;
category = gth_main_get_metadata_category (info->category);
value = gth_file_data_get_attribute_as_string (file_data, info->id);
if ((value == NULL) || (*value == '\0'))
continue;
......@@ -139,19 +138,19 @@ gth_file_properties_real_set_file (GthPropertyView *self,
g_free (value);
value = tmp_value;
}
tooltip = g_markup_printf_escaped ("%s: %s", /*info->display_name FIXME: use the display name before releasing*/ info->id, value);
if (g_hash_table_lookup (category_root, category->id) == NULL) {
GtkTreeIter parent;
tooltip = g_markup_printf_escaped ("%s: %s", info->display_name, value);
gtk_list_store_append (file_properties->priv->tree_model, &parent);
gtk_list_store_set (file_properties->priv->tree_model, &parent,
category = g_hash_table_lookup (category_hash, info->category);
if (category == NULL) {
category = gth_main_get_metadata_category (info->category);
gtk_list_store_append (file_properties->priv->tree_model, &iter);
gtk_list_store_set (file_properties->priv->tree_model, &iter,
WEIGHT_COLUMN, PANGO_WEIGHT_BOLD,
ID_COLUMN, category->id,
DISPLAY_NAME_COLUMN, category->display_name,
POS_COLUMN, category->sort_order * CATEGORY_SIZE,
-1);
g_hash_table_insert (category_root, g_strdup (category->id), GINT_TO_POINTER (1));
g_hash_table_insert (category_hash, g_strdup (info->category), category);
}
gtk_list_store_append (file_properties->priv->tree_model, &iter);
......@@ -168,9 +167,11 @@ gth_file_properties_real_set_file (GthPropertyView *self,
g_free (tooltip);
g_free (value);
}
gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (file_properties->priv->tree_model), POS_COLUMN, GTK_SORT_ASCENDING);
gtk_tree_view_expand_all (GTK_TREE_VIEW (file_properties->priv->tree_view));
g_hash_table_destroy (category_root);
g_hash_table_destroy (category_hash);
/* comment */
......
......@@ -23,6 +23,35 @@
#include <config.h>
#include "gth-viewer-page.h"
enum {
FILE_LOADED,
LAST_SIGNAL
};
static guint gth_viewer_page_signals[LAST_SIGNAL] = { 0 };
static void
gth_viewer_page_base_init (gpointer g_iface)
{
static gboolean initialized = FALSE;
if (initialized)
return;
gth_viewer_page_signals[FILE_LOADED] =
g_signal_new ("file-loaded",
GTH_TYPE_VIEWER_PAGE,
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (GthViewerPageIface, file_loaded),
NULL, NULL,
g_cclosure_marshal_VOID__VOID,
G_TYPE_NONE,
0);
initialized = TRUE;
}
GType
gth_viewer_page_get_type (void) {
......@@ -30,7 +59,7 @@ gth_viewer_page_get_type (void) {
if (gth_viewer_page_type_id == 0) {
static const GTypeInfo g_define_type_info = {
sizeof (GthViewerPageIface),
(GBaseInitFunc) NULL,
(GBaseInitFunc) gth_viewer_page_base_init,
(GBaseFinalizeFunc) NULL,
(GClassInitFunc) NULL,
(GClassFinalizeFunc) NULL,
......@@ -158,3 +187,10 @@ gth_viewer_page_revert (GthViewerPage *self)
{
GTH_VIEWER_PAGE_GET_INTERFACE (self)->revert (self);
}
void
gth_viewer_page_file_loaded (GthViewerPage *self)
{
g_signal_emit (self, gth_viewer_page_signals[FILE_LOADED], 0, NULL);
}
......@@ -45,6 +45,8 @@ typedef void (*FileSavedFunc) (GthViewerPage *viewer_page,
struct _GthViewerPageIface {
GTypeInterface parent_iface;
/*< virtual functions >*/
void (*activate) (GthViewerPage *self,
GthBrowser *browser);
void (*deactivate) (GthViewerPage *self);
......@@ -69,6 +71,10 @@ struct _GthViewerPageIface {
FileSavedFunc func,
gpointer data);
void (*revert) (GthViewerPage *self);
/*< signals >*/
void (*file_loaded) (GthViewerPage *self);
};
GType gth_viewer_page_get_type (void);
......@@ -96,6 +102,7 @@ void gth_viewer_page_save_as (GthViewerPage *self,
FileSavedFunc func,
gpointer data);
void gth_viewer_page_revert (GthViewerPage *self);
void gth_viewer_page_file_loaded (GthViewerPage *self);
G_END_DECLS
......
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