Include a Other Software section in Help file
[geeqie.git] / src / bar.c
index 0250d4f..6fd0ee6 100644 (file)
--- a/src/bar.c
+++ b/src/bar.c
@@ -1,16 +1,24 @@
 /*
- * Geeqie
- * (C) 2004 John Ellis
- * Copyright (C) 2008 - 2012 The Geeqie Team
+ * Copyright (C) 2004 John Ellis
+ * Copyright (C) 2008 - 2016 The Geeqie Team
  *
  * Author: Vladimir Nadvornik
  *
- * This software is released under the GNU General Public License (GNU GPL).
- * Please read the included file COPYING for more information.
- * This software comes with no warranty of any kind, use at your own risk!
+ * 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 "main.h"
 #include "bar.h"
 
@@ -58,6 +66,15 @@ static const gchar default_config_title[] =
 "    </layout>"
 "</gq>";
 
+static const gchar default_config_headline[] =
+"<gq>"
+"    <layout id = '_current_'>"
+"        <bar>"
+"            <pane_comment id = 'headline' expanded = 'true' key = 'Xmp.photoshop.Headline'  height = '40' />"
+"        </bar>"
+"    </layout>"
+"</gq>";
+
 static const gchar default_config_keywords[] =
 "<gq>"
 "    <layout id = '_current_'>"
@@ -75,6 +92,14 @@ static const gchar default_config_comment[] =
 "        </bar>"
 "    </layout>"
 "</gq>";
+static const gchar default_config_rating[] =
+"<gq>"
+"    <layout id = '_current_'>"
+"        <bar>"
+"            <pane_comment id = 'rating' expanded = 'true' key = '" RATING_KEY "' height = '10' />"
+"        </bar>"
+"    </layout>"
+"</gq>";
 
 static const gchar default_config_exif[] =
 "<gq>"
@@ -83,6 +108,7 @@ static const gchar default_config_exif[] =
 "            <pane_exif id = 'exif' expanded = 'true' >"
 "                <entry key = 'formatted.Camera' if_set = 'true' editable = 'false' />"
 "                <entry key = 'formatted.DateTime' if_set = 'true' editable = 'false' />"
+"                <entry key = 'formatted.localtime' if_set = 'true' editable = 'false' />"
 "                <entry key = 'formatted.ShutterSpeed' if_set = 'true' editable = 'false' />"
 "                <entry key = 'formatted.Aperture' if_set = 'true' editable = 'false' />"
 "                <entry key = 'formatted.ExposureBias' if_set = 'true' editable = 'false' />"
@@ -97,6 +123,7 @@ static const gchar default_config_exif[] =
 "                <entry key = 'formatted.SubjectDistance' if_set = 'true' editable = 'false' />"
 "                <entry key = 'formatted.Resolution' if_set = 'true' editable = 'false' />"
 "                <entry key = '" ORIENTATION_KEY "' if_set = 'true' editable = 'false' />"
+"                <entry key = 'formatted.star_rating' if_set = 'true' editable = 'false' />"
 "            </pane_exif>"
 "        </bar>"
 "    </layout>"
@@ -110,6 +137,10 @@ static const gchar default_config_file_info[] =
 "                <entry key = 'file.mode' if_set = 'false' editable = 'false' />"
 "                <entry key = 'file.date' if_set = 'false' editable = 'false' />"
 "                <entry key = 'file.size' if_set = 'false' editable = 'false' />"
+"                <entry key = 'file.owner' if_set = 'false' editable = 'false' />"
+"                <entry key = 'file.group' if_set = 'false' editable = 'false' />"
+"                <entry key = 'file.class' if_set = 'false' editable = 'false' />"
+"                <entry key = 'file.link' if_set = 'false' editable = 'false' />"
 "            </pane_exif>"
 "        </bar>"
 "    </layout>"
@@ -122,6 +153,7 @@ static const gchar default_config_location[] =
 "            <pane_exif id = 'location' expanded = 'true' >"
 "                <entry key = 'formatted.GPSPosition' if_set = 'true' editable = 'false' />"
 "                <entry key = 'formatted.GPSAltitude' if_set = 'true' editable = 'false' />"
+"                <entry key = 'formatted.timezone' if_set = 'true' editable = 'false' />"
 "                <entry key = 'Xmp.photoshop.Country' if_set = 'false' editable = 'true' />"
 "                <entry key = 'Xmp.iptc.CountryCode' if_set = 'false' editable = 'true' />"
 "                <entry key = 'Xmp.photoshop.State' if_set = 'false' editable = 'true' />"
@@ -168,6 +200,8 @@ static const KnownPanes known_panes[] = {
        {PANE_COMMENT,          "title",        N_("Title"),            default_config_title},
        {PANE_KEYWORDS,         "keywords",     N_("Keywords"),         default_config_keywords},
        {PANE_COMMENT,          "comment",      N_("Comment"),          default_config_comment},
+       {PANE_COMMENT,          "rating",       N_("Rating"),           default_config_rating},
+       {PANE_COMMENT,          "headline",     N_("Headline"),         default_config_headline},
        {PANE_EXIF,             "exif",         N_("Exif"),             default_config_exif},
 /* other pre-configured panes */
        {PANE_EXIF,             "file_info",    N_("File info"),        default_config_file_info},
@@ -188,6 +222,7 @@ struct _BarData
        GtkWidget *vbox;
        FileData *fd;
        GtkWidget *label_file_name;
+       GtkWidget *add_button;
 
        LayoutWindow *lw;
        gint width;
@@ -314,6 +349,27 @@ static void bar_menu_popup(GtkWidget *widget)
        gtk_menu_popup(GTK_MENU(menu), NULL, NULL, NULL, bar, 0, GDK_CURRENT_TIME);
 }
 
+static void bar_menu_add_popup(GtkWidget *widget)
+{
+       GtkWidget *menu;
+       GtkWidget *bar;
+       const KnownPanes *pane = known_panes;
+
+       bar = widget;
+
+       menu = popup_menu_short_lived();
+
+       while (pane->id)
+               {
+               GtkWidget *item;
+               item = menu_item_add_stock(menu, _(pane->title), GTK_STOCK_ADD, G_CALLBACK(bar_expander_add_cb), bar);
+               g_object_set_data(G_OBJECT(item), "pane_add_id", pane->id);
+               pane++;
+               }
+
+       gtk_menu_popup(GTK_MENU(menu), NULL, NULL, NULL, bar, 0, GDK_CURRENT_TIME);
+}
+
 
 static gboolean bar_menu_cb(GtkWidget *widget, GdkEventButton *bevent, gpointer data)
 {
@@ -325,6 +381,30 @@ static gboolean bar_menu_cb(GtkWidget *widget, GdkEventButton *bevent, gpointer
        return FALSE;
 }
 
+static void bar_expander_cb(GObject *object, GParamSpec *param_spec, gpointer data)
+{
+       GtkExpander *expander;
+       GtkWidget *child;
+
+       expander = GTK_EXPANDER(object);
+       child = gtk_bin_get_child(GTK_BIN(expander));
+
+       if (gtk_expander_get_expanded(expander))
+               {
+               gtk_widget_show_all(child);
+               }
+       else
+               {
+               gtk_widget_hide(child);
+               }
+}
+
+static gboolean bar_menu_add_cb(GtkWidget *widget, GdkEventButton *bevent, gpointer data)
+{
+       bar_menu_add_popup(widget);
+       return TRUE;
+}
+
 
 static void bar_pane_set_fd_cb(GtkWidget *expander, gpointer data)
 {
@@ -509,6 +589,7 @@ void bar_add(GtkWidget *bar, GtkWidget *pane)
        pd->bar = bar;
 
        expander = gtk_expander_new(NULL);
+       DEBUG_NAME(expander);
        if (pd && pd->title)
                {
                gtk_expander_set_label_widget(GTK_EXPANDER(expander), pd->title);
@@ -518,6 +599,7 @@ void bar_add(GtkWidget *bar, GtkWidget *pane)
        gtk_box_pack_start(GTK_BOX(bd->vbox), expander, FALSE, TRUE, 0);
 
        g_signal_connect(expander, "button_release_event", G_CALLBACK(bar_menu_cb), bd);
+       g_signal_connect(expander, "notify::expanded", G_CALLBACK(bar_expander_cb), pd);
 
        gtk_container_add(GTK_CONTAINER(expander), pane);
 
@@ -531,7 +613,7 @@ void bar_add(GtkWidget *bar, GtkWidget *pane)
 
 void bar_populate_default(GtkWidget *bar)
 {
-       const gchar *populate_id[] = {"histogram", "title", "keywords", "comment", "exif", NULL};
+       const gchar *populate_id[] = {"histogram", "title", "keywords", "comment", "rating", "exif", NULL};
        const gchar **id = populate_id;
 
        while (*id)
@@ -578,8 +660,8 @@ static void bar_destroy(GtkWidget *widget, gpointer data)
 }
 
 #ifdef HAVE_LIBCHAMPLAIN_GTK
-/*
-   FIXME: this is an ugly hack that works around this bug:
+/**
+   @FIXME this is an ugly hack that works around this bug:
    https://bugzilla.gnome.org/show_bug.cgi?id=590692
    http://bugzilla.openedhand.com/show_bug.cgi?id=1751
    it should be removed as soon as a better solution exists
@@ -597,12 +679,15 @@ GtkWidget *bar_new(LayoutWindow *lw)
        BarData *bd;
        GtkWidget *box;
        GtkWidget *scrolled;
+       GtkWidget *tbar;
+       GtkWidget *add_box;
 
        bd = g_new0(BarData, 1);
 
        bd->lw = lw;
 
        bd->widget = gtk_vbox_new(FALSE, PREF_PAD_GAP);
+       DEBUG_NAME(bd->widget);
        g_object_set_data(G_OBJECT(bd->widget), "bar_data", bd);
        g_signal_connect(G_OBJECT(bd->widget), "destroy",
                         G_CALLBACK(bar_destroy), bd);
@@ -616,11 +701,17 @@ GtkWidget *bar_new(LayoutWindow *lw)
        gtk_widget_set_size_request(bd->widget, bd->width, -1);
 
        box = gtk_hbox_new(FALSE, 0);
+       DEBUG_NAME(box);
 
        bd->label_file_name = gtk_label_new("");
        gtk_label_set_ellipsize(GTK_LABEL(bd->label_file_name), PANGO_ELLIPSIZE_END);
        gtk_label_set_selectable(GTK_LABEL(bd->label_file_name), TRUE);
+#if GTK_CHECK_VERSION(3,16,0)
+       gtk_label_set_xalign(GTK_LABEL(bd->label_file_name), 0.5);
+       gtk_label_set_yalign(GTK_LABEL(bd->label_file_name), 0.5);
+#else
        gtk_misc_set_alignment(GTK_MISC(bd->label_file_name), 0.5, 0.5);
+#endif
        gtk_box_pack_start(GTK_BOX(box), bd->label_file_name, TRUE, TRUE, 0);
        gtk_widget_show(bd->label_file_name);
 
@@ -628,6 +719,7 @@ GtkWidget *bar_new(LayoutWindow *lw)
        gtk_widget_show(box);
 
        scrolled = gtk_scrolled_window_new(NULL, NULL);
+       DEBUG_NAME(scrolled);
        gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolled),
                GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
        gtk_box_pack_start(GTK_BOX(bd->widget), scrolled, TRUE, TRUE, 0);
@@ -638,6 +730,15 @@ GtkWidget *bar_new(LayoutWindow *lw)
        gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(scrolled), bd->vbox);
        gtk_viewport_set_shadow_type(GTK_VIEWPORT(gtk_bin_get_child(GTK_BIN(scrolled))), GTK_SHADOW_NONE);
 
+       add_box = gtk_vbox_new(FALSE, 0);
+       DEBUG_NAME(add_box);
+       gtk_box_pack_end(GTK_BOX(bd->widget), add_box, FALSE, FALSE, 0);
+       tbar = pref_toolbar_new(add_box, GTK_TOOLBAR_ICONS);
+       bd->add_button = pref_toolbar_button(tbar, GTK_STOCK_ADD, NULL, FALSE,
+                                            _("Add Pane"),
+                                            G_CALLBACK(bar_menu_add_cb), bd);
+       gtk_widget_show(add_box);
+
 #ifdef HAVE_LIBCHAMPLAIN_GTK
        g_signal_connect(G_OBJECT(gtk_bin_get_child(GTK_BIN(scrolled))), "unrealize", G_CALLBACK(bar_unrealize_clutter_fix_cb), NULL);
 #endif
@@ -665,7 +766,16 @@ GtkWidget *bar_update_from_config(GtkWidget *bar, const gchar **attribute_names,
                log_printf("unknown attribute %s = %s\n", option, value);
                }
 
+#if !GTK_CHECK_VERSION(3,0,0)
+/** @FIXME In bar_size_allocate() the width obtained is the allocated width. In GTK2 this
+ * is the actual width. In GTK3 it is the *minimum* width.
+ * This results in the info sidebar being able to increase, but not
+ * decrease. There does not seem to be a way in GTK3 to get the actual width of
+ * a widget. For GTK3 the only way is to disable it. The width of the sidebar
+ * is therefore not preserved across restarts.
+ */
        gtk_widget_set_size_request(bar, width, -1);
+#endif
        if (enabled)
                {
                gtk_widget_show(bar);
@@ -688,7 +798,8 @@ GtkWidget *bar_pane_expander_title(const gchar *title)
        GtkWidget *widget = gtk_label_new(title);
 
        pref_label_bold(widget, TRUE, FALSE);
-       //gtk_label_set_ellipsize(GTK_LABEL(widget), PANGO_ELLIPSIZE_END); //FIXME: do not work
+       //gtk_label_set_ellipsize(GTK_LABEL(widget), PANGO_ELLIPSIZE_END);
+       /** @FIXME do not work */
 
        return widget;
 }