Fix #490: Creating info sidebar panes
[geeqie.git] / src / bar.c
index 0250d4f..4fda126 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"
 
@@ -188,6 +196,7 @@ struct _BarData
        GtkWidget *vbox;
        FileData *fd;
        GtkWidget *label_file_name;
+       GtkWidget *add_button;
 
        LayoutWindow *lw;
        gint width;
@@ -314,6 +323,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 +355,12 @@ static gboolean bar_menu_cb(GtkWidget *widget, GdkEventButton *bevent, gpointer
        return FALSE;
 }
 
+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)
 {
@@ -597,6 +633,8 @@ GtkWidget *bar_new(LayoutWindow *lw)
        BarData *bd;
        GtkWidget *box;
        GtkWidget *scrolled;
+       GtkWidget *tbar;
+       GtkWidget *add_box;
 
        bd = g_new0(BarData, 1);
 
@@ -638,6 +676,14 @@ 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);
+       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