Commit 2e5b0655 authored by Felix Riemann's avatar Felix Riemann
Browse files

EogMetadataSidebar: Try to unclutter and improve the sidebar's look

Based on a design by Allan Day.
parent 8cdbae1f
......@@ -33,6 +33,7 @@ EXTRA_DIST = \
eog-image-properties-dialog.ui \
eog-multiple-save-as-dialog.ui \
eog-preferences-dialog.ui \
metadata-sidebar.ui \
popup-menus.ui \
$(DESKTOP_IN_FILES) \
$(appdata_in_files) \
......
<?xml version="1.0" encoding="UTF-8"?>
<!-- Generated with glade 3.18.1 -->
<interface>
<requires lib="gtk+" version="3.14"/>
<template class="EogMetadataSidebar" parent="GtkScrolledWindow">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="hscrollbar_policy">never</property>
<child>
<object class="GtkViewport" id="viewport1">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="shadow_type">none</property>
<child>
<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">6</property>
<property name="column_spacing">6</property>
<child>
<object class="GtkLabel" id="label1">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="valign">baseline</property>
<property name="label" translatable="yes">Size</property>
<property name="justify">right</property>
<property name="xalign">1</property>
<style>
<class name="dim-label"/>
</style>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">0</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="label2">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="valign">baseline</property>
<property name="label" translatable="yes">Type</property>
<property name="justify">right</property>
<property name="xalign">1</property>
<property name="yalign">0</property>
<style>
<class name="dim-label"/>
</style>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">1</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="label3">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">File Size</property>
<property name="justify">right</property>
<property name="xalign">1</property>
<property name="yalign">0</property>
<style>
<class name="dim-label"/>
</style>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">2</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="label4">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="valign">baseline</property>
<property name="margin_bottom">12</property>
<property name="label" translatable="yes">Folder</property>
<property name="justify">right</property>
<property name="xalign">1</property>
<property name="yalign">0</property>
<style>
<class name="dim-label"/>
</style>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">3</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="label5">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">Aperture</property>
<property name="justify">right</property>
<property name="xalign">1</property>
<property name="yalign">0</property>
<style>
<class name="dim-label"/>
</style>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">4</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="label6">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">Exposure</property>
<property name="justify">right</property>
<property name="xalign">1</property>
<property name="yalign">0</property>
<style>
<class name="dim-label"/>
</style>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">5</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="label7">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">ISO</property>
<property name="justify">right</property>
<property name="lines">0</property>
<property name="xalign">1</property>
<property name="yalign">0</property>
<style>
<class name="dim-label"/>
</style>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">7</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="label8">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">Metering</property>
<property name="justify">right</property>
<property name="xalign">1</property>
<property name="yalign">0</property>
<style>
<class name="dim-label"/>
</style>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">8</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="label9">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="margin_bottom">12</property>
<property name="label" translatable="yes">Camera</property>
<property name="justify">right</property>
<property name="xalign">1</property>
<property name="yalign">0</property>
<style>
<class name="dim-label"/>
</style>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">9</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="label10">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="valign">baseline</property>
<property name="label" translatable="yes">Date</property>
<property name="justify">right</property>
<property name="xalign">1</property>
<property name="yalign">0</property>
<style>
<class name="dim-label"/>
</style>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">10</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="label11">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">Time</property>
<property name="justify">right</property>
<property name="xalign">1</property>
<property name="yalign">0</property>
<style>
<class name="dim-label"/>
</style>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">11</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="iso_label">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label">label</property>
<property name="selectable">True</property>
<property name="xalign">0</property>
</object>
<packing>
<property name="left_attach">1</property>
<property name="top_attach">7</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="size_label">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label">label</property>
<property name="selectable">True</property>
<property name="xalign">0</property>
</object>
<packing>
<property name="left_attach">1</property>
<property name="top_attach">0</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="type_label">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label">label</property>
<property name="wrap">True</property>
<property name="selectable">True</property>
<property name="xalign">0</property>
</object>
<packing>
<property name="left_attach">1</property>
<property name="top_attach">1</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="filesize_label">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label">label</property>
<property name="wrap">True</property>
<property name="selectable">True</property>
<property name="xalign">0</property>
</object>
<packing>
<property name="left_attach">1</property>
<property name="top_attach">2</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="aperture_label">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label">label</property>
<property name="wrap">True</property>
<property name="selectable">True</property>
<property name="xalign">0</property>
</object>
<packing>
<property name="left_attach">1</property>
<property name="top_attach">4</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="exposure_label">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label">label</property>
<property name="wrap">True</property>
<property name="selectable">True</property>
<property name="xalign">0</property>
</object>
<packing>
<property name="left_attach">1</property>
<property name="top_attach">5</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="metering_label">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label">label</property>
<property name="wrap">True</property>
<property name="selectable">True</property>
<property name="xalign">0</property>
</object>
<packing>
<property name="left_attach">1</property>
<property name="top_attach">8</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="date_label">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="valign">baseline</property>
<property name="label">label</property>
<property name="wrap">True</property>
<property name="selectable">True</property>
<property name="xalign">0</property>
</object>
<packing>
<property name="left_attach">1</property>
<property name="top_attach">10</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="model_label">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="valign">baseline</property>
<property name="margin_bottom">12</property>
<property name="label">label</property>
<property name="wrap">True</property>
<property name="selectable">True</property>
<property name="xalign">0</property>
</object>
<packing>
<property name="left_attach">1</property>
<property name="top_attach">9</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="time_label">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label">label</property>
<property name="wrap">True</property>
<property name="selectable">True</property>
<property name="xalign">0</property>
</object>
<packing>
<property name="left_attach">1</property>
<property name="top_attach">11</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="folder_label">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="valign">baseline</property>
<property name="margin_bottom">12</property>
<property name="label">label</property>
<property name="use_markup">True</property>
<property name="wrap">True</property>
<property name="wrap_mode">word-char</property>
<property name="track_visited_links">False</property>
<property name="xalign">0</property>
</object>
<packing>
<property name="left_attach">1</property>
<property name="top_attach">3</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="label12">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">Focal Length</property>
<property name="justify">right</property>
<property name="xalign">1</property>
<property name="yalign">0</property>
<style>
<class name="dim-label"/>
</style>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">6</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="focallen_label">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label">label</property>
<property name="wrap">True</property>
<property name="selectable">True</property>
<property name="xalign">0</property>
</object>
<packing>
<property name="left_attach">1</property>
<property name="top_attach">6</property>
</packing>
</child>
</object>
</child>
</object>
</child>
</template>
</interface>
......@@ -8,6 +8,7 @@ data/eog.desktop.in.in
[type: gettext/glade]data/eog-multiple-save-as-dialog.ui
[type: gettext/glade]data/eog-preferences-dialog.ui
[type: gettext/glade]data/fullscreen-toolbar.ui
[type: gettext/glade]data/metadata-sidebar.ui
[type: gettext/gsettings]data/org.gnome.eog.gschema.xml.in
[type: gettext/glade]data/popup-menus.ui
plugins/fullscreen/eog-fullscreen-plugin.c
......
......@@ -67,146 +67,25 @@ struct _EogMetadataSidebarPrivate {
gulong image_changed_id;
gulong thumb_changed_id;
GtkWidget *grid;
GtkWidget *name_label;
GtkWidget *height_label;
GtkWidget *width_label;
GtkWidget *type_label;
GtkWidget *size_label;
GtkWidget *folder_button;
GtkWidget *type_label;
GtkWidget *filesize_label;
GtkWidget *folder_label;
#if HAVE_EXIF
GtkWidget *aperture_label;
GtkWidget *exposure_label;
GtkWidget *focallen_label;
GtkWidget *flash_label;
GtkWidget *iso_label;
GtkWidget *metering_label;
GtkWidget *model_label;
GtkWidget *date_label;
#endif
#if HAVE_EXEMPI
GtkWidget *location_label;
GtkWidget *desc_label;
GtkWidget *keyword_label;
GtkWidget *creator_label;
GtkWidget *rights_label;
#endif
#if HAVE_METADATA
GtkWidget *details_button;
GtkWidget *time_label;
#endif
};
G_DEFINE_TYPE_WITH_PRIVATE(EogMetadataSidebar, eog_metadata_sidebar, GTK_TYPE_SCROLLED_WINDOW)
static GtkWidget*
_gtk_grid_append_title_line (GtkGrid *grid, GtkWidget *sibling,
const gchar *text)
{
GtkWidget *label;
gchar *markup;
label = gtk_label_new (NULL);
markup = g_markup_printf_escaped ("<b>%s</b>", text);
gtk_label_set_markup (GTK_LABEL (label), markup);
g_free (markup);
gtk_grid_attach_next_to (grid, label, sibling, GTK_POS_BOTTOM, 2, 1);
return label;
}
static GtkWidget*
_gtk_grid_append_prop_line (GtkGrid *grid, GtkWidget *sibling,
GtkWidget **data_label, const gchar *text)
{
GtkWidget *label;
gchar *markup;
GtkWidget *box;
box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
label = gtk_label_new (NULL);
markup = g_markup_printf_escaped("<b>%s</b>", text);
gtk_label_set_markup (GTK_LABEL(label), markup);
g_free (markup);
gtk_widget_set_halign (label, GTK_ALIGN_START);
gtk_widget_set_valign (label, GTK_ALIGN_END);
gtk_box_pack_start (GTK_BOX (box), label, FALSE, FALSE, 0);
if (G_LIKELY (data_label != NULL)) {
*data_label = gtk_label_new (NULL);
gtk_label_set_selectable (GTK_LABEL (*data_label), TRUE);
gtk_label_set_line_wrap (GTK_LABEL(*data_label), TRUE);
gtk_widget_set_halign (*data_label, GTK_ALIGN_START);
gtk_widget_set_valign (*data_label, GTK_ALIGN_START);
// Add a small margin to make it a sublabel to the first label
gtk_widget_set_margin_start (*data_label, 12);
gtk_box_pack_end (GTK_BOX(box), *data_label, FALSE, FALSE, 0);
}
gtk_grid_attach_next_to (grid, box, sibling, GTK_POS_BOTTOM, 2, 1);
return box;
}
#if HAVE_EXEMPI
static void
eog_xmp_set_label (XmpPtr xmp,
const char *ns,
const char *propname,
GtkWidget *w)
{
uint32_t options;
XmpStringPtr value = xmp_string_new ();
if (xmp && xmp_get_property (xmp, ns, propname, value, &options)) {
if (XMP_IS_PROP_SIMPLE (options)) {
gtk_label_set_text (GTK_LABEL (w), xmp_string_cstr (value));
} else if (XMP_IS_PROP_ARRAY (options)) {
XmpIteratorPtr iter = xmp_iterator_new (xmp,
ns,
propname,
XMP_ITER_JUSTLEAFNODES);
GString *string = g_string_new ("");
if (iter) {
gboolean first = TRUE;
while (xmp_iterator_next (iter, NULL, NULL, value, &options)
&& !XMP_IS_PROP_QUALIFIER (options)) {
if (!first) {
g_string_append_printf(string, ", ");
} else {
first = FALSE;
}
g_string_append_printf (string,
"%s",
xmp_string_cstr (value));
}
xmp_iterator_free (iter);
}
gtk_label_set_text (GTK_LABEL (w), string->str);
g_string_free (string, TRUE);
}
} else {
/* Property was not found */
/* Clear label so it won't show bogus data */
gtk_label_set_text (GTK_LABEL (w), NULL);
}
xmp_string_free (value);
}
#endif
static void
eog_metadata_sidebar_update_general_section (EogMetadataSidebar *sidebar)
{
......@@ -219,24 +98,17 @@ eog_metadata_sidebar_update_general_section (EogMetadataSidebar *sidebar)
gint width, height;
if (G_UNLIKELY (img == NULL)) {
gtk_label_set_text (GTK_LABEL (priv->name_label), NULL);
gtk_label_set_text (GTK_LABEL (priv->height_label), NULL);
gtk_label_set_text (GTK_LABEL (priv->width_label), NULL);
gtk_label_set_text (GTK_LABEL (priv->type_label), NULL);
gtk_label_set_text (GTK_LABEL (priv->size_label), NULL);
gtk_label_set_text (GTK_LABEL (priv->type_label), NULL);
gtk_label_set_text (GTK_LABEL (priv->filesize_label), NULL);
return;
}
gtk_label_set_text (GTK_LABEL (priv->name_label),
eog_image_get_caption (img));
eog_image_get_size (img, &width, &height);
str = g_strdup_printf ("%d %s", height,
ngettext ("pixel", "pixels", height));
gtk_label_set_text (GTK_LABEL (priv->height_label), str);
g_free (str);
str = g_strdup_printf ("%d %s", width,
ngettext ("pixel", "pixels", width));
gtk_label_set_text (GTK_LABEL (priv->width_label), str);
str = g_strdup_printf (ngettext("%i × %i pixel",
"%i × %i pixels", height),
width, height);
gtk_label_set_text (GTK_LABEL (priv->size_label), str);
g_free (str);
file = eog_image_get_file (img);
......@@ -257,7 +129,7 @@ eog_metadata_sidebar_update_general_section (EogMetadataSidebar *sidebar)
bytes = eog_image_get_bytes (img);
str = g_format_size (bytes);
gtk_label_set_text (GTK_LABEL (priv->size_label), str);
gtk_label_set_text (GTK_LABEL (priv->filesize_label), str);
g_free (str);