Changeset 8d9ed780301cc5a9bd5e13ac8a1486dd0b14ebb6
- Timestamp:
- 04/13/09 14:38:14
(1 year ago)
- Author:
- Federico Mena Quintero <federico@novell.com>
- git-committer:
- Federico Mena Quintero <federico@novell.com> 1239647894 -0500
- git-parent:
[1e3608ffeefd10d0b71db3e82e4ad582a41c5caf]
- git-author:
- Federico Mena Quintero <federico@novell.com> 1239647894 -0500
- Message:
Use widget fields instead of widget names in TransactionEditor?'s utility functions
Signed-off-by: Federico Mena Quintero <federico@novell.com>
-
Files:
-
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
| r1e3608f |
r8d9ed78 |
|
| 117 | 117 | } |
|---|
| 118 | 118 | |
|---|
| 119 | | private void SetEntryBgColor (string widget_name, byte r, byte g, byte b) |
|---|
| | 119 | private void SetEntryBgColor (Gtk.Entry entry, byte r, byte g, byte b) |
|---|
| 120 | 120 | { |
|---|
| 121 | 121 | foreach (Gtk.StateType state in Enum.GetValues (typeof (Gtk.StateType))) |
|---|
| … | … | |
| 124 | 124 | continue; |
|---|
| 125 | 125 | |
|---|
| 126 | | (ui.GetWidget (widget_name) as Gtk.Widget).ModifyBase (state, new Gdk.Color (r, g, b)); |
|---|
| 127 | | } |
|---|
| 128 | | } |
|---|
| 129 | | |
|---|
| 130 | | private void ResetEntryBgColor (string widget_name) |
|---|
| | 126 | entry.ModifyBase (state, new Gdk.Color (r, g, b)); |
|---|
| | 127 | } |
|---|
| | 128 | } |
|---|
| | 129 | |
|---|
| | 130 | private void ResetEntryBgColor (Gtk.Entry entry) |
|---|
| 131 | 131 | { |
|---|
| 132 | 132 | foreach (Gtk.StateType state in Enum.GetValues (typeof (Gtk.StateType))) |
|---|
| … | … | |
| 135 | 135 | continue; |
|---|
| 136 | 136 | |
|---|
| 137 | | (ui.GetWidget (widget_name) as Gtk.Widget).ModifyBase (state); |
|---|
| 138 | | } |
|---|
| 139 | | } |
|---|
| 140 | | |
|---|
| 141 | | private void SetEntryInputGood (string widget_name, bool is_good) |
|---|
| | 137 | entry.ModifyBase (state); |
|---|
| | 138 | } |
|---|
| | 139 | } |
|---|
| | 140 | |
|---|
| | 141 | private void SetEntryInputGood (Gtk.Entry entry, bool is_good) |
|---|
| 142 | 142 | { |
|---|
| 143 | 143 | if (is_good) |
|---|
| 144 | | ResetEntryBgColor (widget_name); |
|---|
| | 144 | ResetEntryBgColor (entry); |
|---|
| 145 | 145 | else |
|---|
| 146 | | SetEntryBgColor (widget_name, 0xff, 0xe0, 0xe0); |
|---|
| 147 | | } |
|---|
| 148 | | |
|---|
| 149 | | private bool SetEntryInputGoodIfNonEmpty (string widget_name) |
|---|
| 150 | | { |
|---|
| 151 | | string s = (ui.GetWidget (widget_name) as Gtk.Entry).Text; |
|---|
| | 146 | SetEntryBgColor (entry, 0xff, 0xe0, 0xe0); |
|---|
| | 147 | } |
|---|
| | 148 | |
|---|
| | 149 | private bool SetEntryInputGoodIfNonEmpty (Gtk.Entry entry) |
|---|
| | 150 | { |
|---|
| | 151 | string s = entry.Text; |
|---|
| 152 | 152 | bool is_good = s.Length > 0 ? true : false; |
|---|
| 153 | 153 | |
|---|
| 154 | | SetEntryInputGood (widget_name, is_good); |
|---|
| | 154 | SetEntryInputGood (entry, is_good); |
|---|
| 155 | 155 | return is_good; |
|---|
| 156 | 156 | } |
|---|
| 157 | 157 | |
|---|
| 158 | | private bool SetEntryInputGoodIfNonZero (string widget_name) |
|---|
| 159 | | { |
|---|
| 160 | | string s = (ui.GetWidget (widget_name) as Gtk.Entry).Text; |
|---|
| | 158 | private bool SetEntryInputGoodIfNonZero (Gtk.Entry entry) |
|---|
| | 159 | { |
|---|
| | 160 | string s = entry.Text; |
|---|
| 161 | 161 | double t = 0.0; |
|---|
| 162 | 162 | |
|---|
| … | … | |
| 169 | 169 | bool is_good = (t != 0.0 ? true : false); |
|---|
| 170 | 170 | |
|---|
| 171 | | SetEntryInputGood (widget_name, is_good); |
|---|
| | 171 | SetEntryInputGood (entry, is_good); |
|---|
| 172 | 172 | return is_good; |
|---|
| 173 | 173 | } |
|---|
| … | … | |
| 180 | 180 | bool bad_input_has_focus = false; |
|---|
| 181 | 181 | |
|---|
| 182 | | is_description_good = SetEntryInputGoodIfNonEmpty ("transaction_editor_description"); |
|---|
| 183 | | is_tags_good = SetEntryInputGoodIfNonEmpty ("transaction_editor_tags"); |
|---|
| 184 | | is_amount_good = SetEntryInputGoodIfNonZero ("transaction_editor_amount"); |
|---|
| | 182 | is_description_good = SetEntryInputGoodIfNonEmpty (transaction_editor_description); |
|---|
| | 183 | is_tags_good = SetEntryInputGoodIfNonEmpty (transaction_editor_tags); |
|---|
| | 184 | is_amount_good = SetEntryInputGoodIfNonZero (transaction_editor_amount); |
|---|
| 185 | 185 | |
|---|
| 186 | 186 | if ((this.Focus == transaction_editor_description && !is_description_good) || |
|---|