Merge lp:~victored/pantheon-files/lp-1309714 into lp:~elementary-apps/pantheon-files/trunk

Proposed by Victor Martinez
Status: Merged
Approved by: David Gomes
Approved revision: 1469
Merged at revision: 1481
Proposed branch: lp:~victored/pantheon-files/lp-1309714
Merge into: lp:~elementary-apps/pantheon-files/trunk
Diff against target: 211 lines (+11/-126)
2 files modified
src/View/OverlayBar.vala (+10/-125)
src/View/ViewContainer.vala (+1/-1)
To merge this branch: bzr merge lp:~victored/pantheon-files/lp-1309714
Reviewer Review Type Date Requested Status
David Gomes (community) Approve
Review via email: mp+216485@code.launchpad.net

Commit message

Use GraniteOverlayBar for floating statusbar.

This deprecates the "files-overlay-bar" style class and removes duplicate code. Fixes lp:1309714

Description of the change

Use GraniteOverlayBar for floating statusbar.

This deprecates the "files-overlay-bar" style class and removes duplicate code. Fixes lp:1309714

To post a comment you must log in.
Revision history for this message
David Gomes (davidgomes) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'src/View/OverlayBar.vala'
--- src/View/OverlayBar.vala 2013-12-21 01:56:36 +0000
+++ src/View/OverlayBar.vala 2014-04-18 19:53:11 +0000
@@ -18,20 +18,7 @@
1818
19namespace Marlin.View {19namespace Marlin.View {
2020
21 public class OverlayBar : Gtk.EventBox {21 public class OverlayBar : Granite.Widgets.OverlayBar {
22
23 private const string FALLBACK_THEME = """
24 .files-overlay-bar {
25 background-color: @bg_color;
26 border-radius: 3px 3px 0 0;
27 padding: 3px 6px 3px 6px;
28 margin: 1px;
29 border-style: solid;
30 border-width: 1px;
31 border-color: darker (@bg_color);
32 }""";
33
34 public Gtk.Label status;
35 private Marlin.View.Window window;22 private Marlin.View.Window window;
3623
37 const int IMAGE_LOADER_BUFFER_SIZE = 8192;24 const int IMAGE_LOADER_BUFFER_SIZE = 8192;
@@ -50,28 +37,12 @@
50 }37 }
51 }38 }
5239
53 public OverlayBar (Marlin.View.Window win)40 public OverlayBar (Marlin.View.Window win, Gtk.Overlay overlay)
54 {41 {
42 base (overlay);
43
55 window = win;44 window = win;
5645
57 visible_window = false;
58
59 status = new Gtk.Label (null);
60 status.set_ellipsize (Pango.EllipsizeMode.END);
61 add (status);
62 status.show ();
63
64 set_halign (Gtk.Align.END);
65 set_valign (Gtk.Align.END);
66
67 set_default_style ();
68
69 var ctx = get_style_context ();
70 ctx.changed.connect (update_spacing);
71 ctx.changed.connect_after (queue_resize);
72
73 update_spacing ();
74
75 window.selection_changed.connect (update);46 window.selection_changed.connect (update);
76 window.item_hovered.connect (update_hovered);47 window.item_hovered.connect (update_hovered);
7748
@@ -82,92 +53,6 @@
82 });53 });
83 }54 }
8455
85 public override void parent_set (Gtk.Widget? old_parent)
86 {
87 Gtk.Widget parent = get_parent ();
88
89 if (old_parent != null)
90 old_parent.enter_notify_event.disconnect (enter_notify_callback);
91 if (parent != null)
92 parent.enter_notify_event.connect (enter_notify_callback);
93 }
94
95 public override bool draw (Cairo.Context cr)
96 {
97 var ctx = get_style_context ();
98 ctx.render_background (cr, 0, 0, get_allocated_width (), get_allocated_height ());
99 ctx.render_frame (cr, 0, 0, get_allocated_width (), get_allocated_height ());
100 return base.draw (cr);
101 }
102
103 public override Gtk.SizeRequestMode get_request_mode ()
104 {
105 return Gtk.SizeRequestMode.HEIGHT_FOR_WIDTH;
106 }
107
108 public override void get_preferred_width (out int minimum_width, out int natural_width)
109 {
110 Gtk.Requisition label_min_size, label_natural_size;
111 status.get_preferred_size (out label_min_size, out label_natural_size);
112
113 var ctx = get_style_context ();
114 var state = ctx.get_state ();
115 var border = ctx.get_border (state);
116
117 int extra_allocation = border.left + border.right;
118 minimum_width = extra_allocation + label_min_size.width;
119 natural_width = extra_allocation + label_natural_size.width;
120 }
121
122 public override void get_preferred_height_for_width (int width, out int minimum_height,
123 out int natural_height)
124 {
125 Gtk.Requisition label_min_size, label_natural_size;
126 status.get_preferred_size (out label_min_size, out label_natural_size);
127
128 var ctx = get_style_context ();
129 var state = ctx.get_state ();
130 var border = ctx.get_border (state);
131
132 int extra_allocation = border.top + border.bottom;
133 minimum_height = extra_allocation + label_min_size.height;
134 natural_height = extra_allocation + label_natural_size.height;
135 }
136
137 private void update_spacing ()
138 {
139 var ctx = get_style_context ();
140 var state = ctx.get_state ();
141
142 var padding = ctx.get_padding (state);
143 status.margin_top = padding.top;
144 status.margin_bottom = padding.bottom;
145 status.margin_left = padding.left;
146 status.margin_right = padding.right;
147
148 var margin = ctx.get_margin (state);
149 margin_top = margin.top;
150 margin_bottom = margin.bottom;
151 margin_left = margin.left;
152 margin_right = margin.right;
153 }
154
155 private void set_default_style ()
156 {
157 int priority = Gtk.STYLE_PROVIDER_PRIORITY_FALLBACK;
158 Granite.Widgets.Utils.set_theming (this, FALLBACK_THEME, "files-overlay-bar", priority);
159 }
160
161 private bool enter_notify_callback (Gdk.EventCrossing event)
162 {
163 message ("enter_notify_event");
164 if (get_halign () == Gtk.Align.START)
165 set_halign (Gtk.Align.END);
166 else
167 set_halign (Gtk.Align.START);
168 return false;
169 }
170
171 private uint count = 0;56 private uint count = 0;
172 private uint folders_count = 0;57 private uint folders_count = 0;
173 private uint files_count = 0;58 private uint files_count = 0;
@@ -217,7 +102,7 @@
217102
218 } else {103 } else {
219 visible = false;104 visible = false;
220 status.set_label ("");105 status = "";
221 }106 }
222 }107 }
223108
@@ -231,7 +116,7 @@
231116
232 if (count == 1) {117 if (count == 1) {
233 if (goffile.is_network_uri_scheme ()) {118 if (goffile.is_network_uri_scheme ()) {
234 status.set_label (goffile.get_display_target_uri ());119 status = goffile.get_display_target_uri ();
235 } else if (!goffile.is_folder ()) {120 } else if (!goffile.is_folder ()) {
236121
237 /* if we have an image, see if we can get its resolution */122 /* if we have an image, see if we can get its resolution */
@@ -240,9 +125,9 @@
240 load_resolution.begin (goffile);125 load_resolution.begin (goffile);
241 }126 }
242127
243 status.set_label ("%s (%s)".printf (goffile.formated_type, goffile.format_size));128 status = "%s (%s)".printf (goffile.formated_type, goffile.format_size);
244 } else {129 } else {
245 status.set_label ("%s - %s".printf (goffile.info.get_name (), goffile.formated_type));130 status = "%s - %s".printf (goffile.info.get_name (), goffile.formated_type);
246131
247 }132 }
248 } else {133 } else {
@@ -275,7 +160,7 @@
275 str = _("%u items selected (%s)").printf (count, format_size ((int64) files_size));160 str = _("%u items selected (%s)").printf (count, format_size ((int64) files_size));
276 }161 }
277162
278 status.set_label (str);163 status = str;
279164
280 }165 }
281 }166 }
@@ -309,7 +194,7 @@
309194
310 loader.size_prepared.connect ((width, height) => {195 loader.size_prepared.connect ((width, height) => {
311 image_size_loaded = true;196 image_size_loaded = true;
312 status.set_label ("%s (%s — %i × %i)".printf (goffile.formated_type, goffile.format_size, width, height));197 status = "%s (%s — %i × %i)".printf (goffile.formated_type, goffile.format_size, width, height);
313 });198 });
314199
315 /* Gdk wants us to always close the loader, so we are nice to it */200 /* Gdk wants us to always close the loader, so we are nice to it */
316201
=== modified file 'src/View/ViewContainer.vala'
--- src/View/ViewContainer.vala 2014-01-07 22:25:32 +0000
+++ src/View/ViewContainer.vala 2014-04-18 19:53:11 +0000
@@ -45,7 +45,7 @@
4545
46 public ViewContainer (Marlin.View.Window win, GLib.File location, int _view_mode = 0) {46 public ViewContainer (Marlin.View.Window win, GLib.File location, int _view_mode = 0) {
47 window = win;47 window = win;
48 overlay_statusbar = new OverlayBar (win);48 overlay_statusbar = new OverlayBar (win, this);
49 view_mode = _view_mode;49 view_mode = _view_mode;
5050
51 /* set active tab */51 /* set active tab */

Subscribers

People subscribed via source and target branches

to all changes: