[eog: 1/11] details-dialog: Add details dialog




commit bf242564d590e58cbe0abd96f762b19f5a1abda3
Author: Peter Eisenmann <p3732 getgoogleoff me>
Date:   Mon Aug 2 03:03:27 2021 +0200

    details-dialog: Add details dialog
    
    Adds a details-only dialog. Code is adapted from eog-properties-dialog.
    UI uses GtkWindow instead of GtkDialog.

 data/eog-details-dialog.ui |  91 +++++++++++++++++++++
 data/meson.build           |   1 +
 po/POTFILES.in             |   1 +
 src/eog-details-dialog.c   | 191 +++++++++++++++++++++++++++++++++++++++++++++
 src/eog-details-dialog.h   |  72 +++++++++++++++++
 src/eog.gresource.xml      |   1 +
 src/meson.build            |   2 +
 7 files changed, 359 insertions(+)
---
diff --git a/data/eog-details-dialog.ui b/data/eog-details-dialog.ui
new file mode 100644
index 00000000..f92b882a
--- /dev/null
+++ b/data/eog-details-dialog.ui
@@ -0,0 +1,91 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- Generated with glade 3.38.2 -->
+<interface>
+  <requires lib="gtk+" version="3.10"/>
+  <template class="EogDetailsDialog" parent="GtkWindow">
+    <property name="width-request">300</property>
+    <property name="height-request">80</property>
+    <property name="can-focus">False</property>
+    <property name="title" translatable="yes">Details</property>
+    <property name="default-width">440</property>
+    <property name="default-height">350</property>
+    <child>
+      <object class="GtkStack" id="details_stack">
+        <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-top">6</property>
+        <property name="margin-bottom">6</property>
+        <child>
+          <object class="GtkBox">
+            <property name="visible">True</property>
+            <property name="can-focus">False</property>
+            <property name="orientation">vertical</property>
+            <property name="spacing">6</property>
+            <child>
+              <object class="GtkImage">
+                <property name="visible">True</property>
+                <property name="can-focus">False</property>
+                <property name="valign">end</property>
+                <property name="pixel-size">64</property>
+                <property name="icon-name">action-unavailable-symbolic</property>
+                <property name="icon_size">0</property>
+              </object>
+              <packing>
+                <property name="expand">True</property>
+                <property name="fill">True</property>
+                <property name="position">0</property>
+              </packing>
+            </child>
+            <child>
+              <object class="GtkLabel">
+                <property name="visible">True</property>
+                <property name="can-focus">False</property>
+                <property name="valign">start</property>
+                <property name="label" translatable="yes">Not Available</property>
+                <property name="justify">center</property>
+                <property name="wrap">True</property>
+              </object>
+              <packing>
+                <property name="expand">True</property>
+                <property name="fill">True</property>
+                <property name="position">1</property>
+              </packing>
+            </child>
+          </object>
+          <packing>
+            <property name="name">no_details</property>
+          </packing>
+        </child>
+        <child>
+          <object class="GtkScrolledWindow">
+            <property name="visible">True</property>
+            <property name="can-focus">True</property>
+            <property name="shadow-type">in</property>
+            <child>
+              <object class="GtkViewport">
+                <property name="visible">True</property>
+                <property name="can-focus">False</property>
+                <child>
+                  <object class="GtkBox" id="metadata_details_box">
+                    <property name="visible">True</property>
+                    <property name="can-focus">False</property>
+                    <property name="orientation">vertical</property>
+                    <child>
+                      <placeholder/>
+                    </child>
+                  </object>
+                </child>
+              </object>
+            </child>
+          </object>
+          <packing>
+            <property name="name">show_details</property>
+            <property name="position">1</property>
+          </packing>
+        </child>
+      </object>
+    </child>
+  </template>
+</interface>
diff --git a/data/meson.build b/data/meson.build
index 96208833..db56402b 100644
--- a/data/meson.build
+++ b/data/meson.build
@@ -2,6 +2,7 @@ subdir('icons')
 
 resource_data = files(
   'pixmaps/thumbnail-frame.png',
+  'eog-details-dialog.ui',
   'eog-gear-menu.ui',
   'eog-image-properties-dialog.ui',
   'eog-multiple-save-as-dialog.ui',
diff --git a/po/POTFILES.in b/po/POTFILES.in
index e3190c3f..69f553f5 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -2,6 +2,7 @@
 # Please keep this file sorted alphabetically.
 data/eog.appdata.xml.in
 data/eog-gear-menu.ui
+data/eog-details-dialog.ui
 data/eog-image-properties-dialog.ui
 data/eog-multiple-save-as-dialog.ui
 data/eog-preferences-dialog.ui
diff --git a/src/eog-details-dialog.c b/src/eog-details-dialog.c
new file mode 100644
index 00000000..b44f5ba4
--- /dev/null
+++ b/src/eog-details-dialog.c
@@ -0,0 +1,191 @@
+/* Eye Of Gnome - Details Dialog
+ *
+ * Copyright (C) 2021 The Free Software Foundation
+ *
+ * Author: Lucas Rocha <lucasr gnome org>
+ *         Hubert Figuiere <hub figuiere net> (XMP support)
+ *         Peter Eisenmann <p3732 getgoogleoff me> (from eog-properties-dialog)
+ *
+ * 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 of the License, 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 Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ */
+
+#include "eog-details-dialog.h"
+
+#ifdef HAVE_METADATA
+
+#include "eog-image.h"
+#include "eog-util.h"
+
+#ifdef HAVE_EXIF
+#include "eog-exif-util.h"
+#endif
+
+#include <glib.h>
+#include <glib/gi18n.h>
+#include <glib-object.h>
+#include <gio/gio.h>
+#include <gtk/gtk.h>
+
+#ifdef HAVE_EXEMPI
+#include <exempi/xmp.h>
+#include <exempi/xmpconsts.h>
+#endif
+
+#include "eog-metadata-details.h"
+
+struct _EogDetailsDialogPrivate {
+    GtkStack       *details_stack;
+
+    GtkWidget      *metadata_details;
+    GtkWidget      *metadata_details_box;
+};
+
+G_DEFINE_TYPE_WITH_PRIVATE (EogDetailsDialog, eog_details_dialog, GTK_TYPE_WINDOW);
+
+#ifdef HAVE_EXIF
+static gboolean
+eog_details_dialog_update_exif (EogDetailsDialog *details_dialog,
+                                EogImage         *image)
+{
+    ExifData *exif_data;
+
+    if (eog_image_has_data (image, EOG_IMAGE_DATA_EXIF)) {
+        exif_data = (ExifData *) eog_image_get_exif_info (image);
+
+        eog_metadata_details_update (EOG_METADATA_DETAILS (details_dialog->priv->metadata_details),
+                    exif_data);
+
+        /* exif_data_unref can handle NULL-values */
+        exif_data_unref(exif_data);
+
+        return TRUE;
+    } else {
+        return FALSE;
+    }
+}
+#endif
+
+#ifdef HAVE_EXEMPI
+static gboolean
+eog_details_dialog_update_exempi (EogDetailsDialog *details_dialog,
+                                  EogImage         *image)
+{
+    XmpPtr xmp_data;
+
+    if (eog_image_has_data (image, EOG_IMAGE_DATA_XMP)) {
+        xmp_data = (XmpPtr) eog_image_get_xmp_info (image);
+
+        if (xmp_data != NULL) {
+            eog_metadata_details_xmp_update (EOG_METADATA_DETAILS (details_dialog->priv->metadata_details), 
xmp_data);
+
+            xmp_free (xmp_data);
+        }
+
+        return TRUE;
+    } else {
+        return FALSE;
+    }
+}
+#endif
+
+static void
+eog_details_dialog_class_init (EogDetailsDialogClass *klass)
+{
+    gtk_widget_class_set_template_from_resource ((GtkWidgetClass *) klass, 
"/org/gnome/eog/ui/eog-details-dialog.ui");
+
+    GtkWidgetClass *wklass = (GtkWidgetClass*) klass;
+    gtk_widget_class_bind_template_child_private(wklass,
+                             EogDetailsDialog,
+                             details_stack);
+    gtk_widget_class_bind_template_child_private(wklass,
+                             EogDetailsDialog,
+                             metadata_details_box);
+}
+
+static void
+eog_details_dialog_init (EogDetailsDialog *details_dialog)
+{
+    EogDetailsDialogPrivate *priv;
+
+    priv = eog_details_dialog_get_instance_private (details_dialog);
+
+    details_dialog->priv = priv;
+
+    gtk_widget_init_template (GTK_WIDGET (details_dialog));
+
+    g_signal_connect (details_dialog,
+              "delete-event",
+              G_CALLBACK (gtk_widget_hide_on_delete),
+              details_dialog);
+
+    gtk_stack_set_visible_child_name(priv->details_stack, "no_details");
+
+       priv->metadata_details = eog_metadata_details_new ();
+       gtk_widget_set_vexpand (priv->metadata_details, TRUE);
+
+       gtk_container_add (GTK_CONTAINER (priv->metadata_details_box), priv->metadata_details);
+       gtk_widget_show_all (priv->metadata_details_box);
+}
+
+/**
+ * eog_details_dialog_new:
+ * @parent: the dialog's parent window
+ *
+ * If %parent implements #GActionMap its actions will be automatically
+ * inserted in the "win" namespace.
+ *
+ * Returns: (transfer full) (type EogDetailsDialog): a new #EogDetailsDialog
+ **/
+GtkWidget *
+eog_details_dialog_new (GtkWindow *parent)
+{
+    GObject *details_dialog;
+
+    g_return_val_if_fail (GTK_IS_WINDOW (parent), NULL);
+
+    details_dialog = g_object_new (EOG_TYPE_DETAILS_DIALOG, NULL);
+
+    gtk_window_set_transient_for (GTK_WINDOW (details_dialog), parent);
+
+    if (G_LIKELY (G_IS_ACTION_GROUP (parent))) {
+        gtk_widget_insert_action_group (GTK_WIDGET (details_dialog),
+                                        "win",
+                                        G_ACTION_GROUP (parent));
+    }
+
+    return GTK_WIDGET (details_dialog);
+}
+
+void
+eog_details_dialog_update (EogDetailsDialog *details_dialog,
+                           EogImage         *image)
+{
+    g_return_if_fail (EOG_IS_DETAILS_DIALOG (details_dialog));
+
+    if (FALSE
+#ifdef HAVE_EXIF
+        | eog_details_dialog_update_exif(details_dialog, image)
+#endif
+#ifdef HAVE_EXEMPI
+        | eog_details_dialog_update_exempi(details_dialog, image)
+#endif
+        ) {
+        gtk_stack_set_visible_child_name(details_dialog->priv->details_stack, "show_details");
+    } else {
+        gtk_stack_set_visible_child_name(details_dialog->priv->details_stack, "no_details");
+    }
+}
+
+#endif // HAVE_METADATA
\ No newline at end of file
diff --git a/src/eog-details-dialog.h b/src/eog-details-dialog.h
new file mode 100644
index 00000000..680f3b42
--- /dev/null
+++ b/src/eog-details-dialog.h
@@ -0,0 +1,72 @@
+/* Eye Of Gnome - Details Dialog
+ *
+ * Copyright (C) 2021 The Free Software Foundation
+ *
+ * Author: Lucas Rocha <lucasr gnome org>
+ *         Peter Eisenmann <p3732 getgoogleoff me> (from eog-properties-dialog)
+ *
+ * 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 of the License, 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 Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ */
+
+#ifndef __EOG_DETAILS_DIALOG_H__
+#define __EOG_DETAILS_DIALOG_H__
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#if defined(HAVE_EXIF) || defined(HAVE_EXEMPI)
+#define HAVE_METADATA
+
+#include "eog-image.h"
+
+#include <glib.h>
+#include <glib-object.h>
+#include <gtk/gtk.h>
+
+G_BEGIN_DECLS
+
+typedef struct _EogDetailsDialog EogDetailsDialog;
+typedef struct _EogDetailsDialogClass EogDetailsDialogClass;
+typedef struct _EogDetailsDialogPrivate EogDetailsDialogPrivate;
+
+#define EOG_TYPE_DETAILS_DIALOG            (eog_details_dialog_get_type ())
+#define EOG_DETAILS_DIALOG(obj)            (G_TYPE_CHECK_INSTANCE_CAST((obj), EOG_TYPE_DETAILS_DIALOG, 
EogDetailsDialog))
+#define EOG_DETAILS_DIALOG_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST((klass),  EOG_TYPE_DETAILS_DIALOG, 
EogDetailsDialogClass))
+#define EOG_IS_DETAILS_DIALOG(obj)         (G_TYPE_CHECK_INSTANCE_TYPE((obj), EOG_TYPE_DETAILS_DIALOG))
+#define EOG_IS_DETAILS_DIALOG_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass),  EOG_TYPE_DETAILS_DIALOG))
+#define EOG_DETAILS_DIALOG_GET_CLASS(obj)  (G_TYPE_INSTANCE_GET_CLASS((obj),  EOG_TYPE_DETAILS_DIALOG, 
EogDetailsDialogClass))
+
+struct _EogDetailsDialog {
+    GtkWindow window;
+
+    EogDetailsDialogPrivate *priv;
+};
+
+struct _EogDetailsDialogClass {
+    GtkWindowClass parent_class;
+};
+
+GType      eog_details_dialog_get_type (void) G_GNUC_CONST;
+
+GtkWidget  *eog_details_dialog_new             (GtkWindow            *parent);
+
+void       eog_details_dialog_update   (EogDetailsDialog     *details_dialog,
+                                         EogImage             *image);
+
+G_END_DECLS
+
+#endif /* defined(HAVE_EXIF) || defined(HAVE_EXEMPI) */
+#endif /* __EOG_DETAILS_DIALOG_H__ */
diff --git a/src/eog.gresource.xml b/src/eog.gresource.xml
index 472408a9..3a16da3a 100644
--- a/src/eog.gresource.xml
+++ b/src/eog.gresource.xml
@@ -3,6 +3,7 @@
   <gresource prefix="/org/gnome/eog/ui">
     <file>eog.css</file>
     <file compressed="true" preprocess="xml-stripblanks">eog-gear-menu.ui</file>
+    <file compressed="true" preprocess="xml-stripblanks">eog-details-dialog.ui</file>
     <file compressed="true" preprocess="xml-stripblanks">eog-image-properties-dialog.ui</file>
     <file compressed="true" preprocess="xml-stripblanks">eog-multiple-save-as-dialog.ui</file>
     <file compressed="true" preprocess="xml-stripblanks">eog-preferences-dialog.ui</file>
diff --git a/src/meson.build b/src/meson.build
index 34c07431..cf05a433 100644
--- a/src/meson.build
+++ b/src/meson.build
@@ -23,6 +23,7 @@ headers = enum_headers + files(
   'eog-application-activatable.h',
   'eog-clipboard-handler.h',
   'eog-debug.h',
+  'eog-details-dialog.h',
   'eog-enums.h',
   'eog-file-chooser.h',
   'eog-image.h',
@@ -47,6 +48,7 @@ sources = files(
   'eog-clipboard-handler.c',
   'eog-close-confirmation-dialog.c',
   'eog-debug.c',
+  'eog-details-dialog.c',
   'eog-error-message-area.c',
   'eog-file-chooser.c',
   'eog-image.c',


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]