Merge lp:~elementary-apps/pantheon-calculator/ui-cleanups into lp:~elementary-apps/pantheon-calculator/trunk

Proposed by Danielle Foré
Status: Merged
Approved by: Cody Garver
Approved revision: 206
Merged at revision: 206
Proposed branch: lp:~elementary-apps/pantheon-calculator/ui-cleanups
Merge into: lp:~elementary-apps/pantheon-calculator/trunk
Diff against target: 168 lines (+38/-49)
2 files modified
src/Button.vala (+1/-6)
src/MainWindow.vala (+37/-43)
To merge this branch: bzr merge lp:~elementary-apps/pantheon-calculator/ui-cleanups
Reviewer Review Type Date Requested Status
elementary Apps team Pending
Review via email: mp+288222@code.launchpad.net

Commit message

Cleanup UI a little bit
Get rid of superfluous code

To post a comment you must log in.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'src/Button.vala'
--- src/Button.vala 2015-03-16 17:05:32 +0000
+++ src/Button.vala 2016-03-06 17:57:40 +0000
@@ -21,7 +21,7 @@
2121
22public class PantheonCalculator.Button : Gtk.Button {22public class PantheonCalculator.Button : Gtk.Button {
23 private const int WIDTH = 65;23 private const int WIDTH = 65;
24 private const int HEIGHT = 45;24 private const int HEIGHT = 43;
25 public string function = null;25 public string function = null;
2626
27 public Button (string label, string? description = null) {27 public Button (string label, string? description = null) {
@@ -32,11 +32,6 @@
32 tooltip_text = description;32 tooltip_text = description;
33 }33 }
3434
35 public Button.from_icon_name (string icon_name, string? description = null) {
36 image = new Gtk.Image.from_icon_name (icon_name, Gtk.IconSize.BUTTON);
37 tooltip_text = description;
38 }
39
40 public override void get_preferred_width (out int minimum_width, out int natural_width) {35 public override void get_preferred_width (out int minimum_width, out int natural_width) {
41 minimum_width = WIDTH;36 minimum_width = WIDTH;
42 natural_width = WIDTH;37 natural_width = WIDTH;
4338
=== modified file 'src/MainWindow.vala'
--- src/MainWindow.vala 2015-09-25 17:18:02 +0000
+++ src/MainWindow.vala 2016-03-06 17:57:40 +0000
@@ -75,19 +75,17 @@
75 headerbar.set_title (_("Calculator"));75 headerbar.set_title (_("Calculator"));
76 set_titlebar (headerbar); 76 set_titlebar (headerbar);
7777
78 extended_img_1 = new Gtk.Image.from_icon_name ("pane-hide-symbolic", Gtk.IconSize.LARGE_TOOLBAR);78 extended_img_1 = new Gtk.Image.from_icon_name ("pane-hide-symbolic", Gtk.IconSize.MENU);
79 extended_img_2 = new Gtk.Image.from_icon_name ("pane-show-symbolic", Gtk.IconSize.LARGE_TOOLBAR);79 extended_img_2 = new Gtk.Image.from_icon_name ("pane-show-symbolic", Gtk.IconSize.MENU);
8080
81 button_extended = new Gtk.ToggleButton ();81 button_extended = new Gtk.ToggleButton ();
82 button_extended.image = extended_img_1;82 button_extended.image = extended_img_1;
83 button_extended.tooltip_text = _("Show extended functionality");83 button_extended.tooltip_text = _("Show extended functionality");
84 button_extended.relief = Gtk.ReliefStyle.NONE;
85 button_extended.toggled.connect (toggle_grid);84 button_extended.toggled.connect (toggle_grid);
8685
87 button_history = new Gtk.Button ();86 button_history = new Gtk.Button ();
88 button_history.image = new Gtk.Image.from_icon_name ("document-open-recent-symbolic", Gtk.IconSize.LARGE_TOOLBAR);87 button_history.image = new Gtk.Image.from_icon_name ("document-open-recent-symbolic", Gtk.IconSize.MENU);
89 button_history.tooltip_text = _("History");88 button_history.tooltip_text = _("History");
90 button_history.relief = Gtk.ReliefStyle.NONE;
91 button_history.sensitive = false;89 button_history.sensitive = false;
92 button_history.clicked.connect (show_history);90 button_history.clicked.connect (show_history);
9391
@@ -97,11 +95,7 @@
9795
98 private void build_ui () {96 private void build_ui () {
99 main_grid = new Gtk.Grid ();97 main_grid = new Gtk.Grid ();
100 main_grid.orientation = Gtk.Orientation.VERTICAL;
101 main_grid.row_spacing = 3;
102 main_grid.margin = 6;98 main_grid.margin = 6;
103 main_grid.expand = true;
104 main_grid.halign = Gtk.Align.CENTER;
10599
106 build_basic_ui ();100 build_basic_ui ();
107 build_extended_ui ();101 build_extended_ui ();
@@ -125,6 +119,7 @@
125119
126 private void build_basic_ui () {120 private void build_basic_ui () {
127 entry = new Gtk.Entry ();121 entry = new Gtk.Entry ();
122 entry.set_alignment (1);
128 entry.set_text (settings.get_string ("entry-content"));123 entry.set_text (settings.get_string ("entry-content"));
129 entry.get_style_context ().add_class ("h2");124 entry.get_style_context ().add_class ("h2");
130125
@@ -133,7 +128,7 @@
133 button_calc.get_style_context ().add_class (Gtk.STYLE_CLASS_SUGGESTED_ACTION);128 button_calc.get_style_context ().add_class (Gtk.STYLE_CLASS_SUGGESTED_ACTION);
134 button_ans = new Button ("ANS", _("Add last result"));129 button_ans = new Button ("ANS", _("Add last result"));
135 button_ans.sensitive = false;130 button_ans.sensitive = false;
136 button_undo = new Button.from_icon_name ("go-previous-symbolic", _("Backspace"));131 button_undo = new Button ("Del", _("Backspace"));
137 button_del = new Button ("C", _("Clear entry"));132 button_del = new Button ("C", _("Clear entry"));
138 button_del.get_style_context ().add_class (Gtk.STYLE_CLASS_DESTRUCTIVE_ACTION);133 button_del.get_style_context ().add_class (Gtk.STYLE_CLASS_DESTRUCTIVE_ACTION);
139134
@@ -166,37 +161,36 @@
166 var button_9 = new Button ("9");161 var button_9 = new Button ("9");
167162
168 var basic_grid = new Gtk.Grid ();163 var basic_grid = new Gtk.Grid ();
169 basic_grid.column_spacing = 3;164 basic_grid.column_spacing = 6;
170 basic_grid.row_spacing = 3;165 basic_grid.row_spacing = 6;
171 basic_grid.valign = Gtk.Align.END;166 basic_grid.attach (entry, 0, 0, 4, 1);
172 basic_grid.attach (button_del, 0, 0, 1, 1);167 basic_grid.attach (button_del, 0, 1, 1, 1);
173 basic_grid.attach (button_undo, 1, 0, 1, 1);168 basic_grid.attach (button_undo, 1, 1, 1, 1);
174 basic_grid.attach (button_percent, 2, 0, 1, 1);169 basic_grid.attach (button_percent, 2, 1, 1, 1);
175 basic_grid.attach (button_div, 3, 0, 1, 1);170 basic_grid.attach (button_div, 3, 1, 1, 1);
176171
177 basic_grid.attach (button_7, 0, 1, 1, 1);172 basic_grid.attach (button_7, 0, 2, 1, 1);
178 basic_grid.attach (button_8, 1, 1, 1, 1);173 basic_grid.attach (button_8, 1, 2, 1, 1);
179 basic_grid.attach (button_9, 2, 1, 1, 1);174 basic_grid.attach (button_9, 2, 2, 1, 1);
180 basic_grid.attach (button_mult, 3, 1, 1, 1);175 basic_grid.attach (button_mult, 3, 2, 1, 1);
181176
182 basic_grid.attach (button_4, 0, 2, 1, 1);177 basic_grid.attach (button_4, 0, 3, 1, 1);
183 basic_grid.attach (button_5, 1, 2, 1, 1);178 basic_grid.attach (button_5, 1, 3, 1, 1);
184 basic_grid.attach (button_6, 2, 2, 1, 1);179 basic_grid.attach (button_6, 2, 3, 1, 1);
185 basic_grid.attach (button_sub, 3, 2, 1, 1);180 basic_grid.attach (button_sub, 3, 3, 1, 1);
186181
187 basic_grid.attach (button_1, 0, 3, 1, 1);182 basic_grid.attach (button_1, 0, 4, 1, 1);
188 basic_grid.attach (button_2, 1, 3, 1, 1);183 basic_grid.attach (button_2, 1, 4, 1, 1);
189 basic_grid.attach (button_3, 2, 3, 1, 1);184 basic_grid.attach (button_3, 2, 4, 1, 1);
190 basic_grid.attach (button_add, 3, 3, 1, 1);185 basic_grid.attach (button_add, 3, 4, 1, 1);
191186
192 basic_grid.attach (button_0, 0, 4, 1, 1);187 basic_grid.attach (button_0, 0, 5, 1, 1);
193 basic_grid.attach (button_point, 1, 4, 1, 1);188 basic_grid.attach (button_point, 1, 5, 1, 1);
194 basic_grid.attach (button_ans, 2, 4, 1, 1);189 basic_grid.attach (button_ans, 2, 5, 1, 1);
195 basic_grid.attach (button_calc, 3, 4, 1, 1);190 basic_grid.attach (button_calc, 3, 5, 1, 1);
196191
197 //attach all widgets192 //attach all widgets
198 main_grid.attach (entry, 0, 0, 1, 1);193 main_grid.add (basic_grid);
199 main_grid.attach (basic_grid, 0, 1, 1, 1);
200194
201 entry.changed.connect (remove_error);195 entry.changed.connect (remove_error);
202 entry.activate.connect (button_calc_clicked);196 entry.activate.connect (button_calc_clicked);
@@ -239,9 +233,9 @@
239 var button_e = new Button ("e", _("Euler's Number"));233 var button_e = new Button ("e", _("Euler's Number"));
240234
241 var extended_grid = new Gtk.Grid ();235 var extended_grid = new Gtk.Grid ();
242 extended_grid.margin_start = 3;236 extended_grid.margin_start = 6;
243 extended_grid.column_spacing = 3;237 extended_grid.column_spacing = 6;
244 extended_grid.row_spacing = 3;238 extended_grid.row_spacing = 6;
245 extended_grid.valign = Gtk.Align.END;239 extended_grid.valign = Gtk.Align.END;
246 extended_grid.attach (button_par_left, 0, 0, 1, 1);240 extended_grid.attach (button_par_left, 0, 0, 1, 1);
247 extended_grid.attach (button_par_right, 1, 0, 1, 1);241 extended_grid.attach (button_par_right, 1, 0, 1, 1);
@@ -260,7 +254,7 @@
260 extended_revealer.set_transition_type (Gtk.RevealerTransitionType.SLIDE_LEFT);254 extended_revealer.set_transition_type (Gtk.RevealerTransitionType.SLIDE_LEFT);
261 extended_revealer.show_all ();255 extended_revealer.show_all ();
262 extended_revealer.add (extended_grid);256 extended_revealer.add (extended_grid);
263 main_grid.attach (extended_revealer, 1, 0, 1, 2);257 main_grid.add (extended_revealer);
264258
265 button_pi.clicked.connect (() => {regular_button_clicked (button_pi.function);});259 button_pi.clicked.connect (() => {regular_button_clicked (button_pi.function);});
266 button_e.clicked.connect (() => {regular_button_clicked (button_e.function);});260 button_e.clicked.connect (() => {regular_button_clicked (button_e.function);});

Subscribers

People subscribed via source and target branches