[gnome-subtitles] Set spin button's width as N chars instead of using pango to detect pixel width
- From: Pedro Daniel da Rocha Melo e Castro <pcastro src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-subtitles] Set spin button's width as N chars instead of using pango to detect pixel width
- Date: Sun, 3 Jul 2011 19:03:38 +0000 (UTC)
commit 410e96213e38d198774883243e02639bb4b10afd
Author: Pedro Castro <pedro gnomesubtitles org>
Date: Sun Jul 3 19:00:18 2011 +0100
Set spin button's width as N chars instead of using pango to detect pixel width
src/GnomeSubtitles/Core/Util.cs | 8 ++------
src/GnomeSubtitles/Dialog/TimingsAdjustDialog.cs | 7 +++----
src/GnomeSubtitles/Dialog/TimingsShiftDialog.cs | 2 +-
src/GnomeSubtitles/Dialog/VideoSeekToDialog.cs | 4 ++--
.../Ui/Edit/SubtitleEditSpinButtons.cs | 4 +++-
5 files changed, 11 insertions(+), 14 deletions(-)
---
diff --git a/src/GnomeSubtitles/Core/Util.cs b/src/GnomeSubtitles/Core/Util.cs
index 649d998..0d087fa 100644
--- a/src/GnomeSubtitles/Core/Util.cs
+++ b/src/GnomeSubtitles/Core/Util.cs
@@ -27,6 +27,7 @@ using SubLib.Core.Domain;
namespace GnomeSubtitles.Core {
public class Util {
+ public static int SpinButtonTimeWidthChars = 11; //00:00:00.000 actually has 12 chars, but some have lower width
//TODO move to other util?
public static int ColumnWidth (Widget widget, string text) {
@@ -52,6 +53,7 @@ public class Util {
return column;
}
+ //TODO stop using this? Doesn't seem to be working for spin buttons anymore (which were updated OTM)
public static int TextWidth (Widget widget, string text, int margins) {
Pango.Layout layout = widget.CreatePangoLayout(text);
int width, height;
@@ -82,10 +84,6 @@ public class Util {
return (int)TimeSpan.Parse(text).TotalMilliseconds;
}
- public static int SpinButtonTimeWidth (SpinButton spinButton) {
- return TextWidth(spinButton, "00:00:00,000", 25);
- }
-
public static void OnTimeInput (object o, InputArgs args) {
SpinButton spinButton = o as SpinButton;
try {
@@ -149,8 +147,6 @@ public class Util {
}
}
-
-
public static bool OpenSendEmail (string email) {
return OpenUrl("mailto:" + email);
}
diff --git a/src/GnomeSubtitles/Dialog/TimingsAdjustDialog.cs b/src/GnomeSubtitles/Dialog/TimingsAdjustDialog.cs
index 5f307dc..144b5a7 100644
--- a/src/GnomeSubtitles/Dialog/TimingsAdjustDialog.cs
+++ b/src/GnomeSubtitles/Dialog/TimingsAdjustDialog.cs
@@ -1,6 +1,6 @@
/*
* This file is part of Gnome Subtitles.
- * Copyright (C) 2006-2009 Pedro Castro
+ * Copyright (C) 2006-2009,2011 Pedro Castro
*
* Gnome Subtitles is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -58,9 +58,8 @@ public class TimingsAdjustDialog : GladeDialog {
}
private void SetSpinButtons () {
- int width = Core.Util.SpinButtonTimeWidth(firstSubtitleNewStartSpinButton);
- firstSubtitleNewStartSpinButton.WidthRequest = width;
- lastSubtitleNewStartSpinButton.WidthRequest = width;
+ firstSubtitleNewStartSpinButton.WidthChars = Core.Util.SpinButtonTimeWidthChars;
+ lastSubtitleNewStartSpinButton.WidthChars = Core.Util.SpinButtonTimeWidthChars;
}
private void UpdateForTimingMode () {
diff --git a/src/GnomeSubtitles/Dialog/TimingsShiftDialog.cs b/src/GnomeSubtitles/Dialog/TimingsShiftDialog.cs
index 143c898..3c0993f 100644
--- a/src/GnomeSubtitles/Dialog/TimingsShiftDialog.cs
+++ b/src/GnomeSubtitles/Dialog/TimingsShiftDialog.cs
@@ -66,7 +66,7 @@ public class TimingsShiftDialog : GladeDialog {
}
private void InitSpinButton () {
- spinButton.WidthRequest = Core.Util.SpinButtonTimeWidth(spinButton);
+ spinButton.WidthChars = Core.Util.SpinButtonTimeWidthChars;
spinButton.Alignment = 0.5f;
}
diff --git a/src/GnomeSubtitles/Dialog/VideoSeekToDialog.cs b/src/GnomeSubtitles/Dialog/VideoSeekToDialog.cs
index d99d774..9e46ca1 100644
--- a/src/GnomeSubtitles/Dialog/VideoSeekToDialog.cs
+++ b/src/GnomeSubtitles/Dialog/VideoSeekToDialog.cs
@@ -1,6 +1,6 @@
/*
* This file is part of Gnome Subtitles.
- * Copyright (C) 2008-2010 Pedro Castro
+ * Copyright (C) 2008-2011 Pedro Castro
*
* Gnome Subtitles is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -56,7 +56,7 @@ public class VideoSeekToDialog : GladeDialog {
/* Private methods */
private void InitSpinButton () {
- spinButton.WidthRequest = Core.Util.SpinButtonTimeWidth(spinButton);
+ spinButton.WidthChars = Core.Util.SpinButtonTimeWidthChars;
spinButton.Alignment = 0.5f;
}
diff --git a/src/GnomeSubtitles/Ui/Edit/SubtitleEditSpinButtons.cs b/src/GnomeSubtitles/Ui/Edit/SubtitleEditSpinButtons.cs
index 05715ae..df666f5 100644
--- a/src/GnomeSubtitles/Ui/Edit/SubtitleEditSpinButtons.cs
+++ b/src/GnomeSubtitles/Ui/Edit/SubtitleEditSpinButtons.cs
@@ -45,7 +45,9 @@ public class SubtitleEditSpinButtons {
durationSpinButton = Base.GetWidget(WidgetNames.DurationSpinButton) as SpinButton;
/* Initialize */
- startSpinButton.WidthRequest = Util.SpinButtonTimeWidth(startSpinButton); //Only need to set one of the spin buttons' width
+ startSpinButton.WidthChars = Util.SpinButtonTimeWidthChars;
+ endSpinButton.WidthChars = Util.SpinButtonTimeWidthChars;
+ durationSpinButton.WidthChars = Util.SpinButtonTimeWidthChars;
/* Set timing mode to Times */
SetTimingMode(TimingMode.Times); //Initial timing mode is Times
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]