brasero r732 - in trunk: . src



Author: philippr
Date: Fri Apr 18 19:14:47 2008
New Revision: 732
URL: http://svn.gnome.org/viewvc/brasero?rev=732&view=rev

Log:
	Fix project size widget that fixes
	#528103 â selecting the disc type not displayed well on RTL Desktop
	#514103 â GUI Layout Broken

	* src/brasero-data-disc.c (brasero_data_disc_init):
	* src/brasero-layout.c (brasero_layout_type_changed_cb),
	(brasero_layout_init):
	* src/brasero-project-size.c (brasero_project_size_size_request),
	(brasero_project_size_size_allocate),
	(brasero_project_size_expose),
	(brasero_project_size_menu_position_cb):

Modified:
   trunk/ChangeLog
   trunk/src/brasero-data-disc.c
   trunk/src/brasero-layout.c
   trunk/src/brasero-project-size.c

Modified: trunk/src/brasero-data-disc.c
==============================================================================
--- trunk/src/brasero-data-disc.c	(original)
+++ trunk/src/brasero-data-disc.c	Fri Apr 18 19:14:47 2008
@@ -2112,33 +2112,46 @@
 
 	/* Size column */
 	renderer = gtk_cell_renderer_text_new ();
-	column = gtk_tree_view_column_new_with_attributes (_("Size"),
-							   renderer,
-							   "text", BRASERO_DATA_TREE_MODEL_SIZE,
-							   NULL);
+	column = gtk_tree_view_column_new ();
+	gtk_tree_view_column_pack_start (column, renderer, FALSE);
+
+	gtk_tree_view_column_add_attribute (column, renderer,
+					    "text", BRASERO_DATA_TREE_MODEL_SIZE);
+	gtk_tree_view_column_set_title (column, _("Size"));
+
 	gtk_tree_view_append_column (GTK_TREE_VIEW (priv->tree), column);
 	gtk_tree_view_column_set_resizable (column, TRUE);
+	gtk_tree_view_column_set_expand (column, FALSE);
 	gtk_tree_view_column_set_sort_column_id (column, BRASERO_DATA_TREE_MODEL_SIZE);
 
 	/* Description */
 	renderer = gtk_cell_renderer_text_new ();
-	column = gtk_tree_view_column_new_with_attributes (_("Description"),
-							   renderer,
-							   "text", BRASERO_DATA_TREE_MODEL_MIME_DESC,
-							   NULL);
+	column = gtk_tree_view_column_new ();
+	gtk_tree_view_column_pack_start (column, renderer, FALSE);
+
+	gtk_tree_view_column_add_attribute (column, renderer,
+					    "text", BRASERO_DATA_TREE_MODEL_MIME_DESC);
+	gtk_tree_view_column_set_title (column, _("Description"));
+
 	gtk_tree_view_append_column (GTK_TREE_VIEW (priv->tree), column);
+	gtk_tree_view_column_set_resizable (column, TRUE);
+	gtk_tree_view_column_set_expand (column, FALSE);
 	gtk_tree_view_column_set_sort_column_id (column, BRASERO_DATA_TREE_MODEL_MIME_DESC);
 
 	/* Space column */
 	renderer = baobab_cell_renderer_progress_new ();
-	column = gtk_tree_view_column_new_with_attributes (_("Space"),
-							   renderer,
-							   "visible", BRASERO_DATA_TREE_MODEL_SHOW_PERCENT,
-							   "perc", BRASERO_DATA_TREE_MODEL_PERCENT,
-							   NULL);
+	column = gtk_tree_view_column_new ();
+	gtk_tree_view_column_pack_start (column, renderer, FALSE);
+
+	gtk_tree_view_column_add_attribute (column, renderer,
+					    "visible", BRASERO_DATA_TREE_MODEL_SHOW_PERCENT);
+	gtk_tree_view_column_add_attribute (column, renderer,
+					    "perc", BRASERO_DATA_TREE_MODEL_PERCENT);
+	gtk_tree_view_column_set_title (column, _("Space"));
+
 	gtk_tree_view_append_column (GTK_TREE_VIEW (priv->tree), column);
 	gtk_tree_view_column_set_resizable (column, TRUE);
-
+	gtk_tree_view_column_set_expand (column, FALSE);
 
 	scroll = gtk_scrolled_window_new (NULL, NULL);
 	gtk_widget_show (scroll);

Modified: trunk/src/brasero-layout.c
==============================================================================
--- trunk/src/brasero-layout.c	(original)
+++ trunk/src/brasero-layout.c	Fri Apr 18 19:14:47 2008
@@ -959,14 +959,14 @@
 	switch (layout_type) {
 		case BRASERO_LAYOUT_TOP:
 		case BRASERO_LAYOUT_LEFT:
-			gtk_paned_pack2 (GTK_PANED (layout->priv->pane), source_pane, FALSE, FALSE);
+			gtk_paned_pack2 (GTK_PANED (layout->priv->pane), source_pane, TRUE, FALSE);
 			gtk_paned_pack1 (GTK_PANED (layout->priv->pane), project_pane, TRUE, FALSE);
 			break;
 
 		case BRASERO_LAYOUT_BOTTOM:
 		case BRASERO_LAYOUT_RIGHT:
 			gtk_paned_pack2 (GTK_PANED (layout->priv->pane), project_pane, TRUE, FALSE);
-			gtk_paned_pack1 (GTK_PANED (layout->priv->pane), source_pane, FALSE, FALSE);
+			gtk_paned_pack1 (GTK_PANED (layout->priv->pane), source_pane, TRUE, FALSE);
 			break;
 
 		default:
@@ -1204,9 +1204,9 @@
 
 	if (obj->priv->layout_type == BRASERO_LAYOUT_TOP
 	||  obj->priv->layout_type == BRASERO_LAYOUT_LEFT)
-		gtk_paned_pack2 (GTK_PANED (obj->priv->pane), alignment, FALSE, FALSE);
+		gtk_paned_pack2 (GTK_PANED (obj->priv->pane), alignment, TRUE, FALSE);
 	else
-		gtk_paned_pack1 (GTK_PANED (obj->priv->pane), alignment, FALSE, FALSE);
+		gtk_paned_pack1 (GTK_PANED (obj->priv->pane), alignment, TRUE, FALSE);
 
 	obj->priv->main_box = gtk_vbox_new (FALSE, 0);
 	gtk_container_add (GTK_CONTAINER (alignment), obj->priv->main_box);

Modified: trunk/src/brasero-project-size.c
==============================================================================
--- trunk/src/brasero-project-size.c	(original)
+++ trunk/src/brasero-project-size.c	Fri Apr 18 19:14:47 2008
@@ -604,35 +604,25 @@
 brasero_project_size_size_request (GtkWidget *widget,
 				   GtkRequisition *requisition)
 {
-	gint width, height, text_width, ruler_width, ruler_height;
+	gint width, height, ruler_width, ruler_height;
 	PangoRectangle extents = { 0 };
 	BraseroProjectSize *self;
 	GtkRequisition req;
+	gchar *text;
 
 	self = BRASERO_PROJECT_SIZE (widget);
 
-	if (self->priv->text_layout) {
-		gchar *text;
 
-		/* Set markup every time a size change this function is called */
-		text = brasero_project_size_get_media_string (self);
-		pango_layout_set_markup (self->priv->text_layout, text, -1);
-		g_free (text);
-
-		pango_layout_get_pixel_extents (self->priv->text_layout,
-						NULL,
-						&extents);
-		text_width = extents.width + BRASERO_PROJECT_SIZE_SPACE * 2;
-	}
-	else
-		text_width = 0;
+	/* Set markup every time a size change this function is called */
+	text = brasero_project_size_get_media_string (self);
+	pango_layout_set_markup (self->priv->text_layout, text, -1);
+	g_free (text);
 
 	brasero_project_size_get_ruler_min_width (self, &ruler_width, &ruler_height);
 	gtk_widget_size_request (self->priv->button, &req);
 
-	width = MAX (ruler_width, text_width) +
-		self->priv->frame->style->xthickness * 2 +
-		req.width;
+	width = self->priv->frame->style->xthickness * 2 +
+		req.width * 2;
 
 	height = extents.height + self->priv->frame->style->ythickness * 2;
 	height = MAX (height, req.height);
@@ -654,9 +644,6 @@
 
 	gboolean is_rtl = gtk_widget_get_direction (widget) == GTK_TEXT_DIR_RTL;
 
-	if (!GTK_WIDGET_REALIZED (widget))
-		return;
-
 	widget->allocation = *allocation;
 	if (GTK_WIDGET_REALIZED (widget) && !GTK_WIDGET_NO_WINDOW (widget)) {
 		gdk_window_move_resize (widget->window,
@@ -673,7 +660,7 @@
 	/* NOTE: since we've got our own window, we don't need to take into
 	 * account alloc.x and alloc.y */
 	if (is_rtl)
-		alloc.x = allocation->width - req.width;
+		alloc.x = allocation->width - req.width - 1;
 	else
 		alloc.x = - 1;
 
@@ -684,7 +671,7 @@
 
 	/* allocate the size for the arrow we want to draw on the button */
 	if (is_rtl)
-		alloc.x = alloc.width / 4;
+		alloc.x += alloc.width / 2;
 	else
 		alloc.x = alloc.width / 2;
 
@@ -704,6 +691,7 @@
 	gint x, y, width, total;
 	gint button_width;
 	gdouble num, i;
+	guint next_possible = 0;
 
 	BraseroProjectSize *self;
 	gdouble fraction = 0.0;
@@ -732,16 +720,15 @@
 					self->priv->arrow,
 					event);
 
-	if (!is_rtl)
-		button_width = self->priv->button->allocation.width;
-	else
-		button_width = 0;
+	button_width = self->priv->button->allocation.width;
 
 	drive = self->priv->current;
 	if (!drive)
 		return FALSE;
 
-	/* the number of interval needs to be reasonable, not over 8 not under 5 */
+	/* The number of interval needs to be reasonable, not over 8 not under 5
+	 * They should also depend on the available space for the bar. */
+	
 	if (self->priv->is_audio_context)
 		interval_size = AUDIO_INTERVAL_CD;
 	else if (self->priv->current->media & BRASERO_MEDIUM_DVD)
@@ -759,13 +746,21 @@
 	} while (num > MAX_INTERVAL || num < MIN_INTERVAL);
 
 	/* calculate the size of the interval in pixels */
-	bar_width = widget->allocation.width - self->priv->button->allocation.width - self->priv->frame->style->xthickness * 2;
+	bar_width = widget->allocation.width - button_width - self->priv->frame->style->xthickness * 2;
 	interval_width = bar_width / num;
 
 	/* draw the ruler */
 	layout = gtk_widget_create_pango_layout (widget, NULL);
-	for (i = 1.0; i < num; i ++) {
+
+	if (is_rtl)
+		next_possible = widget->allocation.width - button_width - self->priv->frame->style->xthickness;
+	else
+		next_possible = button_width + self->priv->frame->style->xthickness;
+
+	for (i = 1.; i < num; i ++) {
 		gchar *string;
+		guint arrow_x;
+		guint text_x;
 
 		string = brasero_utils_get_sectors_string (i * interval_size,
 							   self->priv->is_audio_context,
@@ -783,12 +778,28 @@
 		y = widget->allocation.height - extents.height;
 
 		if (is_rtl)
-			x = widget->allocation.width - self->priv->frame->style->xthickness - i * interval_width + widget->style->xthickness + ARROW_WIDTH / 2;
+			x = widget->allocation.width - button_width - self->priv->frame->style->xthickness -
+			    i * interval_width;
 		else
-			x = i * interval_width + self->priv->frame->style->xthickness - widget->style->xthickness - extents.width - ARROW_WIDTH / 2;
+			x = button_width + self->priv->frame->style->xthickness + i * interval_width;
+
+		if (!is_rtl && x <= next_possible)
+			continue;
+
+		if (is_rtl && x >= next_possible)
+			continue;
+
+		if (is_rtl)
+			text_x = x + widget->style->xthickness + ARROW_WIDTH / 2 + 2;
+		else
+			text_x = x - widget->style->xthickness - ARROW_WIDTH / 2 - extents.width - 2;
+
+		if (!is_rtl && text_x <= next_possible)
+			continue;
+
+		if (is_rtl && text_x + extents.width >= next_possible)
+			continue;
 
-		/* add the button width */
-		x += button_width;
 		gtk_paint_layout (widget->style,
 				  widget->window,
 				  GTK_STATE_NORMAL,
@@ -796,20 +807,11 @@
 				  &event->area,
 				  widget,
 				  NULL,
-				  x,
+				  text_x,
 				  y,
 				  layout);
-	}
-	g_object_unref (layout);
-
-	for (i = 1.0; i < num; i ++) {
-		if (is_rtl)
-			x = widget->allocation.width - self->priv->frame->style->xthickness - i * interval_width - ARROW_WIDTH / 2;
-		else
-			x = i * interval_width + self->priv->frame->style->xthickness - ARROW_WIDTH / 2;
 
-		x += button_width;
-  		gtk_paint_arrow (widget->style,
+		gtk_paint_arrow (widget->style,
 				 widget->window,
 				 GTK_STATE_NORMAL,
 				 GTK_SHADOW_ETCHED_IN,
@@ -818,11 +820,18 @@
 				 NULL,
 				 GTK_ARROW_UP,
 				 FALSE,
-				 x,
+				 x - widget->style->xthickness - ARROW_WIDTH/ 2,
 				 widget->allocation.height - text_height,
 				 ARROW_WIDTH,
 				 ARROW_HEIGHT);
+
+		/* calculate the next possible location (2 pixels spacing) */
+		if (is_rtl)
+			next_possible = x - ARROW_WIDTH / 2;
+		else
+			next_possible = x + 2 + ARROW_WIDTH / 2;
 	}
+	g_object_unref (layout);
 
 	bar_height = widget->allocation.height - text_height;
 
@@ -833,6 +842,7 @@
 	else
 		disc_size = drive->free_space;
 
+	/* green part */
 	fraction = ((gdouble) self->priv->sectors / (gdouble) disc_size);
 	if (fraction > 1.0)
 		width = bar_width / fraction * 1.0;
@@ -840,11 +850,10 @@
 		width = fraction * bar_width;
 
 	if (is_rtl)
-		x = widget->allocation.width - width - self->priv->frame->style->xthickness;
+		x = self->priv->frame->style->xthickness + bar_width - width;
 	else
-		x = self->priv->frame->style->xthickness;
+		x = self->priv->frame->style->xthickness + button_width;
 
-	x += button_width;
 	gtk_paint_flat_box (widget->style,
 			    widget->window,
 			    GTK_STATE_INSENSITIVE,
@@ -866,11 +875,10 @@
 			width2 = bar_width / fraction * (fraction - 1.0);
 
 		if (is_rtl)
-			x = widget->allocation.width - width - width2 - self->priv->frame->style->xthickness;
+			x = widget->allocation.width - width - width2 - self->priv->frame->style->xthickness - button_width;
 		else
-			x = width + self->priv->frame->style->xthickness;
+			x = width + self->priv->frame->style->xthickness + button_width;
 
-		x += button_width;
 		gtk_paint_flat_box (widget->style,
 				    widget->window,
 				    GTK_STATE_ACTIVE,
@@ -885,12 +893,11 @@
 
 		if (fraction > 1.03) {
 			if (is_rtl)
-				x = widget->allocation.width - bar_width - self->priv->frame->style->xthickness;
+				x = widget->allocation.width - bar_width - self->priv->frame->style->xthickness - button_width;
 			else
-				x = width + width2 + self->priv->frame->style->xthickness;
+				x = width + width2 + self->priv->frame->style->xthickness + button_width;
 
-		x += button_width;
-		gtk_paint_flat_box (widget->style,
+			gtk_paint_flat_box (widget->style,
 					    widget->window,
 					    GTK_STATE_PRELIGHT,
 					    GTK_SHADOW_NONE,
@@ -904,12 +911,12 @@
 		}
 	}
 	else {
+		/* This is the white part */
 		if (is_rtl)
-			x = width ? widget->allocation.width - bar_width + width - self->priv->frame->style->xthickness:widget->allocation.width - bar_width - self->priv->frame->style->xthickness;
+			x = self->priv->frame->style->xthickness;
 		else
-			x = width ? width:self->priv->frame->style->xthickness;
+			x = width ? width + button_width:self->priv->frame->style->xthickness + button_width;
 
-		x += button_width;
 		gtk_paint_flat_box (widget->style,
 				    widget->window,
 				    GTK_STATE_SELECTED,
@@ -923,7 +930,12 @@
 				    bar_height - self->priv->frame->style->ythickness);
 	}
 
-	alloc.x = button_width;
+	/* Frame around bar */
+	if (is_rtl)
+		alloc.x = 0;
+	else
+		alloc.x = button_width;
+
 	alloc.y = 0;
 	alloc.width = bar_width + self->priv->frame->style->xthickness * 2;
 	alloc.height = bar_height;
@@ -933,8 +945,17 @@
 					event);
 
 	/* set the text */
+	pango_layout_set_width (self->priv->text_layout, -1);
 	pango_layout_get_pixel_extents (self->priv->text_layout, NULL, &extents);
-	x = (widget->allocation.width - button_width - extents.width) / 2;
+	if (extents.width > bar_width) {
+		pango_layout_set_ellipsize (self->priv->text_layout, PANGO_ELLIPSIZE_END);
+		pango_layout_set_width (self->priv->text_layout, (bar_width - BRASERO_PROJECT_SIZE_SPACE * 2) * PANGO_SCALE);
+	}
+	else
+		pango_layout_set_ellipsize (self->priv->text_layout, PANGO_ELLIPSIZE_NONE);
+
+	pango_layout_get_pixel_extents (self->priv->text_layout, NULL, &extents);
+	x = (bar_width - extents.width) / 2;
 	y = (widget->allocation.height - extents.height - text_height) / 2;
 
 	if (!is_rtl)
@@ -996,10 +1017,7 @@
 	gdk_drawable_get_size (GDK_DRAWABLE (self->window), &width, &height);
 	gtk_widget_set_size_request (GTK_WIDGET (menu), width, -1);
 
-	if (gtk_widget_get_direction (self) == GTK_TEXT_DIR_LTR)
-		*x = sx;
-	else
-		*x = sx - req.width;
+	*x = sx;
 	*y = sy;
 
 	screen = gtk_widget_get_screen (self);



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