[brasero/gnome-2-30] Fix a bug in the layout on first start (side pane was hidden and remained so until the user moved it



commit ede1fded3dfe53b008b4ad681fd4d2621ef50a10
Author: Philippe Rouquier <bonfire-app wanadoo fr>
Date:   Thu May 13 20:09:21 2010 +0200

    Fix a bug in the layout on first start (side pane was hidden and remained so until the user moved it)

 src/brasero-file-chooser.c |   13 ++++++-------
 src/brasero-layout.c       |   13 ++++++++-----
 src/brasero-setting.c      |   38 ++++++++++++++++++++++++++------------
 3 files changed, 40 insertions(+), 24 deletions(-)
---
diff --git a/src/brasero-file-chooser.c b/src/brasero-file-chooser.c
index 3333ad7..1a1b68f 100644
--- a/src/brasero-file-chooser.c
+++ b/src/brasero-file-chooser.c
@@ -188,16 +188,15 @@ brasero_file_chooser_allocation_changed (GtkWidget *widget,
 				                   BRASERO_SETTING_BRASERO_FILE_CHOOSER_PERCENT,
 				                   &percent);
 
-		if (GPOINTER_TO_INT (percent) < 0) {
-			/* No value so set something sane */
-			percent = GINT_TO_POINTER (30);
+		if (GPOINTER_TO_INT (percent) >= 0) {
+			position = allocation->width * GPOINTER_TO_INT (percent) / 10000;
+			gtk_paned_set_position (GTK_PANED (widget), position);
 		}
-
-		position = allocation->width * GPOINTER_TO_INT (percent) / 10000;
-		gtk_paned_set_position (GTK_PANED (widget), position);
-		g_object_set_data (G_OBJECT (widget), "position_set", GINT_TO_POINTER (TRUE));
+		else
+			gtk_paned_set_position (GTK_PANED (widget), 30 * allocation->width / 100);
 
 		/* Don't connect to position signal until it was first allocated */
+		g_object_set_data (G_OBJECT (widget), "position_set", GINT_TO_POINTER (TRUE));
 		g_signal_connect (widget,
 		                  "notify::position",
 		                  G_CALLBACK (brasero_file_chooser_position_changed),
diff --git a/src/brasero-layout.c b/src/brasero-layout.c
index b29a5fb..fbf8cd3 100644
--- a/src/brasero-layout.c
+++ b/src/brasero-layout.c
@@ -777,17 +777,20 @@ brasero_layout_main_pane_size_allocate (GtkWidget *widget,
 					GtkAllocation *allocation,
 					BraseroLayout *layout)
 {
-	if (!layout->priv->pane_size_allocated) {
-		guint position;
+	if (!layout->priv->pane_size_allocated && gtk_widget_get_visible (widget)) {
+		gint position;
+		gint value_int;
 		gpointer value = NULL;
 
 		brasero_setting_get_value (brasero_setting_get_default (),
 			                   BRASERO_SETTING_DISPLAY_PROPORTION,
 			                   &value);
 
-		position = allocation->width * GPOINTER_TO_INT (value) / 10000;
-		if (position >= 0)
+		value_int = GPOINTER_TO_INT (value);
+		if (value_int >= 0) {
+			position = value_int * allocation->width / 10000;
 			gtk_paned_set_position (GTK_PANED (layout->priv->pane), position);
+		}
 
 		g_signal_connect (layout->priv->pane,
 				  "notify::position",
@@ -1087,8 +1090,8 @@ brasero_layout_init (BraseroLayout *obj)
 			break;
 	}
 
-	gtk_widget_show (obj->priv->pane);
 	gtk_box_pack_end (GTK_BOX (obj), obj->priv->pane, TRUE, TRUE, 0);
+	gtk_widget_show (obj->priv->pane);
 
 	/* This function will set its proportion */
 	g_signal_connect (obj->priv->pane,
diff --git a/src/brasero-setting.c b/src/brasero-setting.c
index de77028..8bedc80 100644
--- a/src/brasero-setting.c
+++ b/src/brasero-setting.c
@@ -280,6 +280,23 @@ brasero_setting_set_value (BraseroSetting *setting,
 	return TRUE;
 }
 
+static gint
+brasero_setting_get_integer (GKeyFile *file,
+                             const gchar *group_name,
+                             const gchar *key)
+{
+	GError *error = NULL;
+	gint int_value;
+
+	int_value = g_key_file_get_integer (file, group_name, key, &error);
+	if (!int_value && error) {
+		g_error_free (error);
+		return -1;
+	}
+
+	return int_value;
+}
+
 gboolean
 brasero_setting_load (BraseroSetting *setting)
 {
@@ -344,14 +361,12 @@ brasero_setting_load (BraseroSetting *setting)
 	                                             "Display",
 	                                             "main-window-maximized",
 	                                             NULL);
-	priv->stock_file_chooser_percent = g_key_file_get_integer (key_file,
-	                                                           "Display",
-	                                                           "stock-file-chooser-percent",
-	                                                           NULL);
-	priv->brasero_file_chooser_percent = g_key_file_get_integer (key_file,
-	                                                             "Display",
-	                                                             "brasero-file-chooser-percent",
-	                                                             NULL);
+	priv->stock_file_chooser_percent = brasero_setting_get_integer (key_file,
+	                                                                "Display",
+	                                                                "stock-file-chooser-percent");
+	priv->brasero_file_chooser_percent = brasero_setting_get_integer (key_file,
+	                                                                  "Display",
+	                                                                  "brasero-file-chooser-percent");
 	priv->player_volume = g_key_file_get_integer (key_file,
 	                                              "Player",
 	                                              "player-volume",
@@ -384,10 +399,9 @@ brasero_setting_load (BraseroSetting *setting)
 	                                                  "Player",
 	                                                  "video-size-height",
 	                                                  NULL);
-	priv->display_proportion = g_key_file_get_integer (key_file,
-	                                                   "Display",
-	                                                   "pane-position",
-	                                                   NULL);
+	priv->display_proportion = brasero_setting_get_integer (key_file,
+	                                                        "Display",
+	                                                        "pane-position");
 	g_key_file_free (key_file);
 
 	return TRUE;



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