changeset 175:682705e0c0e0

do not show frame for full-window images
author nadvornik
date Mon, 11 Feb 2008 15:23:43 +0000
parents 126724275319
children 695e1ad3b169
files src/image.c src/layout_image.c
diffstat 2 files changed, 85 insertions(+), 34 deletions(-) [+]
line wrap: on
line diff
--- a/src/image.c	Mon Feb 11 12:51:28 2008 +0000
+++ b/src/image.c	Mon Feb 11 15:23:43 2008 +0000
@@ -1691,13 +1691,13 @@
 		{
 		if (selectable) 
 			{
-			gtk_frame_set_shadow_type(GTK_FRAME(imd->widget), GTK_SHADOW_NONE);
-			gtk_container_set_border_width (GTK_CONTAINER (imd->widget), 4);
+			gtk_frame_set_shadow_type(GTK_FRAME(imd->frame), GTK_SHADOW_NONE);
+			gtk_container_set_border_width (GTK_CONTAINER (imd->frame), 4);
 			}
 		else
 			{
-			gtk_frame_set_shadow_type(GTK_FRAME(imd->widget), GTK_SHADOW_NONE);
-			gtk_container_set_border_width (GTK_CONTAINER (imd->widget), 0);
+			gtk_frame_set_shadow_type(GTK_FRAME(imd->frame), GTK_SHADOW_NONE);
+			gtk_container_set_border_width (GTK_CONTAINER (imd->frame), 0);
 			}
 		}
 }
@@ -1786,6 +1786,55 @@
 }
 
 
+void image_set_frame(ImageWindow *imd, gboolean frame)
+{
+	frame = !!frame;
+	
+	if (frame == imd->has_frame) return;
+	
+	gtk_widget_hide(imd->pr);
+	
+	if (frame)
+		{
+		imd->frame = gtk_frame_new(NULL);
+		gtk_widget_ref(imd->pr);
+		if (imd->has_frame != -1) gtk_container_remove(GTK_CONTAINER(imd->widget), imd->pr);
+		gtk_container_add(GTK_CONTAINER(imd->frame), imd->pr);
+		gtk_widget_unref(imd->pr);
+		g_signal_connect (G_OBJECT (imd->frame), "expose_event",  
+                    G_CALLBACK (selectable_frame_expose_cb), NULL);
+
+		GTK_WIDGET_SET_FLAGS(imd->frame, GTK_CAN_FOCUS);
+		g_signal_connect(G_OBJECT(imd->frame), "focus_in_event",
+				 G_CALLBACK(image_focus_in_cb), imd);
+		g_signal_connect(G_OBJECT(imd->frame), "focus_out_event",
+				 G_CALLBACK(image_focus_out_cb), imd);
+
+		g_signal_connect_after(G_OBJECT(imd->frame), "expose_event",
+				       G_CALLBACK(image_focus_expose), imd);
+
+
+		gtk_box_pack_start_defaults(GTK_BOX(imd->widget), imd->frame);
+		gtk_widget_show(imd->frame);
+		}
+	else
+		{
+		gtk_widget_ref(imd->pr);
+		if (imd->frame) 
+			{
+			gtk_container_remove(GTK_CONTAINER(imd->frame), imd->pr);
+			gtk_widget_destroy(imd->frame);
+			imd->frame = NULL;
+			}
+		gtk_box_pack_start_defaults(GTK_BOX(imd->widget), imd->pr);
+		gtk_widget_unref(imd->pr);
+		}
+
+	gtk_widget_show(imd->pr);
+	
+	imd->has_frame = frame;
+}
+
 ImageWindow *image_new(gint frame)
 {
 	ImageWindow *imd;
@@ -1799,7 +1848,7 @@
 
 	imd->unknown = TRUE;
 
-	imd->has_frame = frame;
+	imd->has_frame = -1; /* not initialized; for image_set_frame */
 	imd->top_window_sync = FALSE;
 
 	imd->delay_alter_type = ALTER_NONE;
@@ -1833,28 +1882,12 @@
 
 	image_options_set(imd);
 
-	if (imd->has_frame)
-		{
-		imd->widget = gtk_frame_new(NULL);
-		image_set_selectable(imd, 0);
-		gtk_container_add(GTK_CONTAINER(imd->widget), imd->pr);
-		gtk_widget_show(imd->pr);
-		g_signal_connect (G_OBJECT (imd->widget), "expose_event",  
-                    G_CALLBACK (selectable_frame_expose_cb), NULL);
+	
+	imd->widget = gtk_vbox_new(0, 0);
 
-		GTK_WIDGET_SET_FLAGS(imd->widget, GTK_CAN_FOCUS);
-		g_signal_connect(G_OBJECT(imd->widget), "focus_in_event",
-				 G_CALLBACK(image_focus_in_cb), imd);
-		g_signal_connect(G_OBJECT(imd->widget), "focus_out_event",
-				 G_CALLBACK(image_focus_out_cb), imd);
+	image_set_frame(imd, frame);
 
-		g_signal_connect_after(G_OBJECT(imd->widget), "expose_event",
-				       G_CALLBACK(image_focus_expose), imd);
-		}
-	else
-		{
-		imd->widget = imd->pr;
-		}
+	image_set_selectable(imd, 0);
 
 	g_signal_connect(G_OBJECT(imd->pr), "clicked",
 			 G_CALLBACK(image_click_cb), imd);
--- a/src/layout_image.c	Mon Feb 11 12:51:28 2008 +0000
+++ b/src/layout_image.c	Mon Feb 11 15:23:43 2008 +0000
@@ -1693,8 +1693,15 @@
 	if (!lw->split_images[0])
 		{
 		layout_image_new(lw, 0);
+		image_set_frame(lw->split_images[0], (!lw->tools_float && !lw->tools_hidden));
+		image_set_selectable(lw->split_images[0], 0);
 		layout_image_activate(lw, 0);
 		}
+	else
+		{
+		image_set_frame(lw->split_images[0], (!lw->tools_float && !lw->tools_hidden));
+		image_set_selectable(lw->split_images[0], 0);
+		}
 		
 	for (i=1; i < MAX_SPLIT_IMAGES; i++)
 		{
@@ -1705,13 +1712,12 @@
 			}
 		}
 
+
 	layout_image_activate(lw, 0);
-	image_set_selectable(lw->split_images[0], 0);
 	
 	lw->split_image_widget = lw->split_images[0]->widget;
 			
 	return lw->split_image_widget;
-
 }
 
 GtkWidget *layout_image_setup_split_hv(LayoutWindow *lw, gboolean horizontal)
@@ -1725,10 +1731,14 @@
 		{
 		layout_image_new(lw, 0);
 		}
+	image_set_frame(lw->split_images[0], 1);
+	image_set_selectable(lw->split_images[0], 1);
 
 	if (!lw->split_images[1])
 		{
 		layout_image_new(lw, 1);
+		image_set_frame(lw->split_images[1], 1);
+		image_set_selectable(lw->split_images[1], 1);
 		if (lw->image)
 			{
 			gdouble sx, sy;
@@ -1740,6 +1750,11 @@
 		layout_image_deactivate(lw, 1);
 		layout_image_activate(lw, 0);
 		}
+	else
+		{
+		image_set_frame(lw->split_images[1], 1);
+		image_set_selectable(lw->split_images[1], 1);
+		}
 
 	
 	for (i=2; i < MAX_SPLIT_IMAGES; i++)
@@ -1751,9 +1766,6 @@
 			}
 		}
 
-	image_set_selectable(lw->split_images[0], 1);
-	image_set_selectable(lw->split_images[1], 1);
-
         if (!lw->image || lw->active_split_image < 0 || lw->active_split_image > 1)
 		{
 		layout_image_activate(lw, 0);
@@ -1792,6 +1804,9 @@
 		layout_image_new(lw, 0);
 		}
 
+	image_set_frame(lw->split_images[0], 1);
+	image_set_selectable(lw->split_images[0], 1);
+
 	if (!lw->split_images[1])
 		{
 		layout_image_activate(lw, 0);
@@ -1801,6 +1816,8 @@
 		if (!lw->split_images[i])
 			{
 			layout_image_new(lw, i);
+			image_set_frame(lw->split_images[i], 1);
+			image_set_selectable(lw->split_images[i], 1);
 			if (lw->image)
 				{
 				gdouble sx, sy;
@@ -1811,6 +1828,11 @@
 				}
 			layout_image_deactivate(lw, i);
 			}
+		else
+			{
+			image_set_frame(lw->split_images[i], 1);
+			image_set_selectable(lw->split_images[i], 1);
+			}
 
 	for (i=4; i < MAX_SPLIT_IMAGES; i++)
 		{
@@ -1821,10 +1843,6 @@
 			}
 		}
 
-	image_set_selectable(lw->split_images[0], 1);
-	image_set_selectable(lw->split_images[1], 1);
-	image_set_selectable(lw->split_images[2], 1);
-	image_set_selectable(lw->split_images[3], 1);
 
         if (!lw->image || lw->active_split_image < 0 || lw->active_split_image > 3)
 		{