changeset 1383:3c9abbc05792

use standard GtkHPaned for sidebar width
author nadvornik
date Fri, 06 Mar 2009 14:24:11 +0000
parents 31a747f9d268
children 99eae1622e0c
files src/bar.c src/bar.h src/layout.c src/layout_image.c src/layout_util.c src/main.h src/typedefs.h
diffstat 7 files changed, 32 insertions(+), 69 deletions(-) [+]
line wrap: on
line diff
--- a/src/bar.c	Fri Mar 06 11:42:25 2009 +0000
+++ b/src/bar.c	Fri Mar 06 14:24:11 2009 +0000
@@ -30,8 +30,8 @@
 #include "histogram.h"
 #include "rcfile.h"
 
-#define BAR_SIZE_INCREMENT 48
-#define BAR_ARROW_SIZE 7
+//#define BAR_SIZE_INCREMENT 48
+//#define BAR_ARROW_SIZE 7
 
 
 typedef struct _BarData BarData;
@@ -223,10 +223,6 @@
 	return;
 }
 
-
-
-
-
 void bar_add(GtkWidget *bar, GtkWidget *pane)
 {
 	GtkWidget *expander;
@@ -278,35 +274,18 @@
 	bar_add(bar, widget);
 }
 
-static void bar_sized(GtkWidget *widget, GtkAllocation *allocation, gpointer data)
+static void bar_size_allocate(GtkWidget *widget, GtkAllocation *allocation, gpointer data)
 {
 	BarData *bd = data;
+	
 	bd->width = allocation->width;
 }
 
-
-static void bar_width(BarData *bd, gint val)
+gint bar_get_width(GtkWidget *bar)
 {
-	gint size;
-
-	size = bd->widget->allocation.width;
-	size = CLAMP(size + val, BAR_SIZE_INCREMENT * 2, BAR_SIZE_INCREMENT * 16);
-
-	gtk_widget_set_size_request(bd->widget, size, -1);
-}
-
-static void bar_larger(GtkWidget *widget, gpointer data)
-{
-	BarData *bd = data;
-
-	bar_width(bd, BAR_SIZE_INCREMENT);
-}
-
-static void bar_smaller(GtkWidget *widget, gpointer data)
-{
-	BarData *bd = data;
-
-	bar_width(bd, -BAR_SIZE_INCREMENT);
+	BarData *bd = g_object_get_data(G_OBJECT(bar), "bar_data");
+	if (!bd) return 0;
+	return bd->width;
 }
 
 void bar_close(GtkWidget *bar)
@@ -343,19 +322,14 @@
 	g_signal_connect(G_OBJECT(bd->widget), "destroy",
 			 G_CALLBACK(bar_destroy), bd);
 
-	g_signal_connect(G_OBJECT(bd->widget), "size_allocate",
-			 G_CALLBACK(bar_sized), bd);
+	g_signal_connect(G_OBJECT(bd->widget), "size-allocate",
+			 G_CALLBACK(bar_size_allocate), bd);
 
-	bd->width = PANEL_DEFAULT_WIDTH;
+	bd->width = SIDEBAR_DEFAULT_WIDTH;
 	gtk_widget_set_size_request(bd->widget, bd->width, -1);
 
 	box = gtk_hbox_new(FALSE, 0);
 
-	sizer = sizer_new(bd->widget, bounding_widget, SIZER_POS_LEFT);
-	sizer_set_limits(sizer, BAR_SIZE_INCREMENT * 2, -1, -1 , -1);
-	gtk_box_pack_start(GTK_BOX(box), sizer, FALSE, FALSE, 0);
-	gtk_widget_show(sizer);
-
 	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);
@@ -363,28 +337,6 @@
 	gtk_box_pack_start(GTK_BOX(box), bd->label_file_name, TRUE, TRUE, 0);
 	gtk_widget_show(bd->label_file_name);
 
-	button = gtk_button_new();
-	gtk_button_set_relief(GTK_BUTTON(button), GTK_RELIEF_NONE);
-	g_signal_connect(G_OBJECT(button), "clicked",
-			 G_CALLBACK(bar_smaller), bd);
-	gtk_box_pack_end(GTK_BOX(box), button, FALSE, FALSE, 0);
-	arrow = gtk_arrow_new(GTK_ARROW_RIGHT, GTK_SHADOW_NONE);
-	gtk_widget_set_size_request(arrow, BAR_ARROW_SIZE, BAR_ARROW_SIZE);
-	gtk_container_add(GTK_CONTAINER(button), arrow);
-	gtk_widget_show(arrow);
-	gtk_widget_show(button);
-
-	button = gtk_button_new();
-	gtk_button_set_relief(GTK_BUTTON(button), GTK_RELIEF_NONE);
-	g_signal_connect(G_OBJECT(button), "clicked",
-			 G_CALLBACK(bar_larger), bd);
-	gtk_box_pack_end(GTK_BOX(box), button, FALSE, FALSE, 0);
-	arrow = gtk_arrow_new(GTK_ARROW_LEFT, GTK_SHADOW_NONE);
-	gtk_widget_set_size_request(arrow, BAR_ARROW_SIZE, BAR_ARROW_SIZE);
-	gtk_container_add(GTK_CONTAINER(button), arrow);
-	gtk_widget_show(arrow);
-	gtk_widget_show(button);
-
 	gtk_box_pack_start(GTK_BOX(bd->widget), box, FALSE, FALSE, 0);
 	gtk_widget_show(box);
 
@@ -420,7 +372,7 @@
 	GtkWidget *bar = bar_new(bounding_widget);
 	
 	gboolean enabled = TRUE;
-	gint width = PANEL_DEFAULT_WIDTH;
+	gint width = SIDEBAR_DEFAULT_WIDTH;
 
 	while (*attribute_names)
 		{
--- a/src/bar.h	Fri Mar 06 11:42:25 2009 +0000
+++ b/src/bar.h	Fri Mar 06 14:24:11 2009 +0000
@@ -45,6 +45,7 @@
 gint bar_event(GtkWidget *bar, GdkEvent *event);
 
 void bar_set_selection_func(GtkWidget *bar, GList *(*list_func)(gpointer data), gpointer data); 
+gint bar_get_width(GtkWidget *bar);
 
 /* following functions are common for all panes */
 void bar_pane_set_selection_func(GtkWidget *pane, GList *(*list_func)(gpointer data), gpointer data); 
--- a/src/layout.c	Fri Mar 06 11:42:25 2009 +0000
+++ b/src/layout.c	Fri Mar 06 14:24:11 2009 +0000
@@ -1562,16 +1562,17 @@
 		if (lw->split_images[i])
 			{
 			gtk_widget_hide(lw->split_images[i]->widget);
-			if (lw->split_images[i]->widget->parent != lw->utility_box)
+			if (lw->split_images[i]->widget->parent != lw->utility_paned)
 				gtk_container_remove(GTK_CONTAINER(lw->split_images[i]->widget->parent), lw->split_images[i]->widget);
 			}
 		}
-	gtk_container_remove(GTK_CONTAINER(lw->utility_box), lw->split_image_widget);
+	gtk_container_remove(GTK_CONTAINER(lw->utility_paned), lw->split_image_widget);
 
 	image = layout_image_setup_split(lw, mode);
 
-	gtk_box_pack_start(GTK_BOX(lw->utility_box), image, TRUE, TRUE, 0);
-	gtk_box_reorder_child(GTK_BOX(lw->utility_box), image, 0);
+//	gtk_box_pack_start(GTK_BOX(lw->utility_box), image, TRUE, TRUE, 0);
+//	gtk_box_reorder_child(GTK_BOX(lw->utility_box), image, 0);
+	gtk_paned_pack1(GTK_PANED(lw->utility_paned), image, TRUE, FALSE);
 	gtk_widget_show(image);
 }
 
--- a/src/layout_image.c	Fri Mar 06 11:42:25 2009 +0000
+++ b/src/layout_image.c	Fri Mar 06 14:24:11 2009 +0000
@@ -1579,6 +1579,8 @@
 		image_color_profile_set_use(lw->split_images[i], options->color_profile.enabled);
 
 		gtk_size_group_add_widget(lw->split_image_sizegroup, lw->split_images[i]->widget);
+		gtk_widget_set_size_request(lw->split_images[i]->widget, IMAGE_MIN_WIDTH, -1);
+
 		}
 
 	return lw->split_images[i]->widget;
--- a/src/layout_util.c	Fri Mar 06 11:42:25 2009 +0000
+++ b/src/layout_util.c	Fri Mar 06 14:24:11 2009 +0000
@@ -1996,7 +1996,8 @@
 			 G_CALLBACK(layout_bar_destroyed), lw);
 
 
-	gtk_box_pack_start(GTK_BOX(lw->utility_box), lw->bar, FALSE, FALSE, 0);
+//	gtk_box_pack_start(GTK_BOX(lw->utility_box), lw->bar, FALSE, FALSE, 0);
+	gtk_paned_pack2(GTK_PANED(lw->utility_paned), lw->bar, FALSE, TRUE); 
 
 	bar_set_fd(lw->bar, layout_image_get_fd(lw));
 }
@@ -2124,7 +2125,12 @@
 GtkWidget *layout_bars_prepare(LayoutWindow *lw, GtkWidget *image)
 {
 	lw->utility_box = gtk_hbox_new(FALSE, PREF_PAD_GAP);
-	gtk_box_pack_start(GTK_BOX(lw->utility_box), image, TRUE, TRUE, 0);
+	lw->utility_paned = gtk_hpaned_new();
+	gtk_box_pack_start(GTK_BOX(lw->utility_box), lw->utility_paned, TRUE, TRUE, 0);
+
+	gtk_paned_pack1(GTK_PANED(lw->utility_paned), image, TRUE, FALSE); 
+	gtk_widget_show(lw->utility_paned);
+	
 	gtk_widget_show(image);
 
 	return lw->utility_box;
--- a/src/main.h	Fri Mar 06 11:42:25 2009 +0000
+++ b/src/main.h	Fri Mar 06 14:24:11 2009 +0000
@@ -106,9 +106,9 @@
 #define IMAGE_LOADER_IDLE_READ_LOOP_COUNT_MIN 		1
 #define IMAGE_LOADER_IDLE_READ_LOOP_COUNT_MAX		16
 
-#define PANEL_MIN_WIDTH	64
-#define PANEL_DEFAULT_WIDTH 288
-#define PANEL_MAX_WIDTH 1200
+#define IMAGE_MIN_WIDTH 100
+#define SIDEBAR_DEFAULT_WIDTH 250
+
 
 #define DEFAULT_OVERLAY_INFO	"%collection:<i>*</i>\\n%" \
 				"(%number%/%total%) [%zoom%] <b>%name%</b>\n" \
--- a/src/typedefs.h	Fri Mar 06 11:42:25 2009 +0000
+++ b/src/typedefs.h	Fri Mar 06 14:24:11 2009 +0000
@@ -645,6 +645,7 @@
 	/* misc */
 
 	GtkWidget *utility_box;
+	GtkWidget *utility_paned; /* between image and bar */
 	GtkWidget *bar_sort;
 	GtkWidget *bar;