[eog: 2/11] sidebar: Add button for details dialog
- From: Felix Riemann <friemann src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [eog: 2/11] sidebar: Add button for details dialog
- Date: Sat, 12 Feb 2022 18:09:30 +0000 (UTC)
commit ab93021919c660497c753271f6a037e1e7ef5fd7
Author: Peter Eisenmann <p3732 getgoogleoff me>
Date: Mon Aug 2 04:09:50 2021 +0200
sidebar: Add button for details dialog
Adds a button to the sidebar that opens the details dialog. It is only
visible if either EXIF or EXEMPI data is available.
data/metadata-sidebar.ui | 38 +++++++++++++++++++++++++----
src/eog-metadata-sidebar.c | 59 ++++++++++++++++++++++++++++++++++++++++------
2 files changed, 86 insertions(+), 11 deletions(-)
---
diff --git a/data/metadata-sidebar.ui b/data/metadata-sidebar.ui
index 3a84bdfe..1e2416a3 100644
--- a/data/metadata-sidebar.ui
+++ b/data/metadata-sidebar.ui
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
-<!-- Generated with glade 3.18.1 -->
+<!-- Generated with glade 3.38.2 -->
<interface>
<requires lib="gtk+" version="3.14"/>
<template class="EogMetadataSidebar" parent="GtkScrolledWindow">
@@ -12,15 +12,22 @@
<property name="can_focus">False</property>
<property name="shadow_type">none</property>
<child>
+ <object class="GtkBox">
+ <property name="visible">True</property>
+ <property name="can-focus">False</property>
+ <property name="margin-start">6</property>
+ <property name="margin-end">6</property>
+ <property name="margin-bottom">6</property>
+ <property name="orientation">vertical</property>
+ <property name="spacing">12</property>
+ <child>
+ <!-- n-columns=2 n-rows=12 -->
<object class="GtkGrid" id="metadata_grid">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="orientation">vertical</property>
<property name="row_spacing">3</property>
<property name="column_spacing">6</property>
- <property name="margin-start">6</property>
- <property name="margin-end">6</property>
- <property name="margin-bottom">6</property>
<child>
<object class="GtkLabel" id="label1">
<property name="visible">True</property>
@@ -416,6 +423,29 @@
<property name="top_attach">6</property>
</packing>
</child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkButton" id="show_details_button">
+ <property name="label" translatable="yes">Show Details</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">True</property>
+ <property name="halign">center</property>
+ <property name="valign">center</property>
+ <signal name="clicked" handler="eog_metadata_sidebar_show_details_cb" swapped="no"/>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
</object>
</child>
</object>
diff --git a/src/eog-metadata-sidebar.c b/src/eog-metadata-sidebar.c
index 87853297..2ee1ef66 100644
--- a/src/eog-metadata-sidebar.c
+++ b/src/eog-metadata-sidebar.c
@@ -34,7 +34,7 @@
#include "eog-image.h"
#include "eog-metadata-sidebar.h"
-#include "eog-properties-dialog.h"
+#include "eog-details-dialog.h"
#include "eog-scroll-view.h"
#include "eog-util.h"
#include "eog-window.h"
@@ -51,7 +51,7 @@
#endif
/* There's no exempi support in the sidebar yet */
-#if defined(HAVE_EXIF) /*|| defined(HAVE_EXEMPI) */
+#if defined(HAVE_EXIF) || defined(HAVE_EXEMPI)
#define HAVE_METADATA
#endif
@@ -85,14 +85,19 @@ struct _EogMetadataSidebarPrivate {
#else
GtkWidget *metadata_grid;
#endif
+
+#ifdef HAVE_METADATA
+ GtkWidget *show_details_button;
+ GtkWidget *details_dialog;
+#endif
};
G_DEFINE_TYPE_WITH_PRIVATE(EogMetadataSidebar, eog_metadata_sidebar, GTK_TYPE_SCROLLED_WINDOW)
static void
parent_file_display_name_query_info_cb (GObject *source_object,
- GAsyncResult *res,
- gpointer user_data)
+ GAsyncResult *res,
+ gpointer user_data)
{
EogMetadataSidebar *sidebar = EOG_METADATA_SIDEBAR (user_data);
GFile *parent_file = G_FILE (source_object);
@@ -189,12 +194,15 @@ static void
eog_metadata_sidebar_update_metadata_section (EogMetadataSidebar *sidebar)
{
EogMetadataSidebarPrivate *priv = sidebar->priv;
+ EogImage *image = priv->image;
+ gboolean has_metadata = FALSE;
+
#ifdef HAVE_EXIF
- EogImage *img = priv->image;
ExifData *exif_data = NULL;
- if (img) {
- exif_data = eog_image_get_exif_info (img);
+ if (image) {
+ exif_data = eog_image_get_exif_info (image);
+ has_metadata |= (exif_data != NULL);
}
eog_exif_util_set_label_text (GTK_LABEL (priv->aperture_label),
@@ -225,6 +233,18 @@ eog_metadata_sidebar_update_metadata_section (EogMetadataSidebar *sidebar)
/* exif_data_unref can handle NULL-values */
exif_data_unref(exif_data);
#endif /* HAVE_EXIF */
+
+#ifdef HAVE_EXEMPI
+ if (image) {
+ has_metadata |= eog_image_has_xmp_info (image);
+ }
+#endif
+
+ gtk_widget_set_visible (priv->show_details_button, has_metadata);
+
+ if (priv->details_dialog != NULL) {
+ eog_details_dialog_update (EOG_DETAILS_DIALOG (priv->details_dialog), priv->image);
+ }
}
#endif /* HAVE_METADATA */
@@ -319,6 +339,22 @@ _folder_label_clicked_cb (GtkLabel *label, const gchar *uri, gpointer user_data)
g_object_unref (file);
}
+static void
+eog_metadata_sidebar_show_details_cb (GtkButton *button, EogMetadataSidebar *sidebar)
+{
+ EogMetadataSidebarPrivate *priv = EOG_METADATA_SIDEBAR(sidebar)->priv;
+
+ g_return_if_fail (priv->parent_window != NULL);
+
+ if (priv->details_dialog == NULL) {
+ priv->details_dialog = eog_details_dialog_new (GTK_WINDOW (priv->parent_window));
+
+ eog_details_dialog_update (EOG_DETAILS_DIALOG (priv->details_dialog), priv->image);
+ }
+
+ gtk_widget_show (priv->details_dialog);
+}
+
static void
eog_metadata_sidebar_set_parent_window (EogMetadataSidebar *sidebar,
EogWindow *window)
@@ -498,6 +534,15 @@ eog_metadata_sidebar_class_init (EogMetadataSidebarClass *klass)
EogMetadataSidebar,
metadata_grid);
#endif /* HAVE_EXIF */
+
+#ifdef HAVE_METADATA
+ gtk_widget_class_bind_template_child_private (widget_class,
+ EogMetadataSidebar,
+ show_details_button);
+
+ gtk_widget_class_bind_template_callback(widget_class,
+ eog_metadata_sidebar_show_details_cb);
+#endif /* HAVE_METADATA */
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]