[gthumb] fixed window resize when using "fit window to image"



commit 146a79b8d41575a949e86e2936e233a086b2ca43
Author: Paolo Bacchilega <paobac src gnome org>
Date:   Sat Aug 7 15:37:35 2010 +0200

    fixed window resize when using "fit window to image"
    
    fixed window resize when the property pane and/or the
    thumbnail list is visible

 extensions/image_viewer/gth-image-viewer-page.c |   27 +++++++++++++++++++++-
 gthumb/gth-browser.c                            |    7 ++++++
 gthumb/gth-browser.h                            |    1 +
 gthumb/gth-file-list.c                          |   18 ++++++++++-----
 4 files changed, 45 insertions(+), 8 deletions(-)
---
diff --git a/extensions/image_viewer/gth-image-viewer-page.c b/extensions/image_viewer/gth-image-viewer-page.c
index 569614f..27a3edd 100644
--- a/extensions/image_viewer/gth-image-viewer-page.c
+++ b/extensions/image_viewer/gth-image-viewer-page.c
@@ -1149,6 +1149,23 @@ gth_image_viewer_page_reset (GthImageViewerPage *self)
 
 
 static int
+add_non_content_width (GthImageViewerPage *self,
+		       GtkWidget          *non_content)
+{
+	int width = 0;
+
+	if ((non_content != NULL) && gtk_widget_get_visible (non_content)) {
+		GtkAllocation allocation;
+
+		gtk_widget_get_allocation (non_content, &allocation);
+		width = allocation.width;
+	}
+
+	return width;
+}
+
+
+static int
 add_non_content_height (GthImageViewerPage *self,
 			GtkWidget          *non_content)
 {
@@ -1156,6 +1173,7 @@ add_non_content_height (GthImageViewerPage *self,
 
 	if ((non_content != NULL) && gtk_widget_get_visible (non_content)) {
 		GtkAllocation allocation;
+
 		gtk_widget_get_allocation (non_content, &allocation);
 		height = allocation.height;
 	}
@@ -1212,12 +1230,17 @@ gth_image_viewer_page_shrink_wrap (GthImageViewerPage *self,
 	other_height += add_non_content_height (self, gth_window_get_area (GTH_WINDOW (self->priv->browser), GTH_WINDOW_TOOLBAR));
 	other_height += add_non_content_height (self, gth_window_get_area (GTH_WINDOW (self->priv->browser), GTH_WINDOW_STATUSBAR));
 	other_height += add_non_content_height (self, gth_browser_get_viewer_toolbar (self->priv->browser));
+	if (eel_gconf_get_enum (PREF_UI_VIEWER_THUMBNAILS_ORIENT, GTK_TYPE_ORIENTATION, GTK_ORIENTATION_HORIZONTAL) == GTK_ORIENTATION_HORIZONTAL)
+		other_height += add_non_content_height (self, gth_browser_get_thumbnail_list (self->priv->browser));
+	else
+		other_width += add_non_content_width (self, gth_browser_get_thumbnail_list (self->priv->browser));
+	other_width += add_non_content_width (self, gth_browser_get_viewer_sidebar (self->priv->browser));
 	other_width += 2;
 	other_height += 2;
 
 	screen = gtk_widget_get_screen (GTK_WIDGET (self->priv->browser));
-	max_width = gdk_screen_get_width (screen) * 9 / 10;
-	max_height = gdk_screen_get_height (screen) * 8 / 10;
+	max_width = round ((double) gdk_screen_get_width (screen) * 8.5 / 10.0);
+	max_height = round ((double) gdk_screen_get_height (screen) * 7.5 / 10.0);
 
 	if (width + other_width > max_width) {
 		width = max_width;
diff --git a/gthumb/gth-browser.c b/gthumb/gth-browser.c
index e196fd0..e12dd69 100644
--- a/gthumb/gth-browser.c
+++ b/gthumb/gth-browser.c
@@ -4477,6 +4477,13 @@ gth_browser_get_file_list_view (GthBrowser *browser)
 
 
 GtkWidget *
+gth_browser_get_thumbnail_list (GthBrowser *browser)
+{
+	return browser->priv->thumbnail_list;
+}
+
+
+GtkWidget *
 gth_browser_get_thumbnail_list_view (GthBrowser *browser)
 {
 	return gth_file_list_get_view (GTH_FILE_LIST (browser->priv->thumbnail_list));
diff --git a/gthumb/gth-browser.h b/gthumb/gth-browser.h
index 4159c12..32c684a 100644
--- a/gthumb/gth-browser.h
+++ b/gthumb/gth-browser.h
@@ -106,6 +106,7 @@ GtkWidget *      gth_browser_get_infobar            (GthBrowser       *browser);
 GtkWidget *      gth_browser_get_statusbar          (GthBrowser       *browser);
 GtkWidget *      gth_browser_get_file_list          (GthBrowser       *browser);
 GtkWidget *      gth_browser_get_file_list_view     (GthBrowser       *browser);
+GtkWidget *      gth_browser_get_thumbnail_list     (GthBrowser       *browser);
 GtkWidget *      gth_browser_get_thumbnail_list_view(GthBrowser       *browser);
 GthFileSource *  gth_browser_get_location_source    (GthBrowser       *browser);
 GthFileStore *   gth_browser_get_file_store         (GthBrowser       *browser);
diff --git a/gthumb/gth-file-list.c b/gthumb/gth-file-list.c
index 115f6b8..7a137ab 100644
--- a/gthumb/gth-file-list.c
+++ b/gthumb/gth-file-list.c
@@ -551,14 +551,20 @@ _gth_file_list_set_type (GthFileList     *file_list,
 		      "fixed_size", (file_list->priv->type == GTH_FILE_LIST_TYPE_H_SIDEBAR) || (file_list->priv->type == GTH_FILE_LIST_TYPE_V_SIDEBAR),
 		      NULL);
 
-	if (file_list->priv->type == GTH_FILE_LIST_TYPE_V_SIDEBAR)
+	if (file_list->priv->type == GTH_FILE_LIST_TYPE_V_SIDEBAR) {
+		gtk_orientable_set_orientation (GTK_ORIENTABLE (file_list), GTK_ORIENTATION_VERTICAL);
 		gtk_widget_set_size_request (GTK_WIDGET (file_list->priv->view),
 					     file_list->priv->thumb_size + (THUMBNAIL_BORDER * 2),
-					     -1);
-	else if (file_list->priv->type == GTH_FILE_LIST_TYPE_H_SIDEBAR)
+					     0);
+	}
+	else if (file_list->priv->type == GTH_FILE_LIST_TYPE_H_SIDEBAR) {
+		gtk_orientable_set_orientation (GTK_ORIENTABLE (file_list), GTK_ORIENTATION_HORIZONTAL);
 		gtk_widget_set_size_request (GTK_WIDGET (file_list->priv->view),
-					     -1,
+					     0,
 					     file_list->priv->thumb_size + (THUMBNAIL_BORDER * 2));
+	}
+	else
+		gtk_widget_set_size_request (GTK_WIDGET (file_list->priv->view), 0, 0);
 }
 
 
@@ -1271,10 +1277,10 @@ gth_file_list_set_thumb_size (GthFileList *file_list,
 	if (file_list->priv->type == GTH_FILE_LIST_TYPE_V_SIDEBAR)
 		gtk_widget_set_size_request (GTK_WIDGET (file_list->priv->view),
 					     file_list->priv->thumb_size + (THUMBNAIL_BORDER * 2),
-					     -1);
+					     0);
 	else if (file_list->priv->type == GTH_FILE_LIST_TYPE_H_SIDEBAR)
 		gtk_widget_set_size_request (GTK_WIDGET (file_list->priv->view),
-					     -1,
+					     0,
 					     file_list->priv->thumb_size + (THUMBNAIL_BORDER * 2));
 }
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]