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
1=== modified file 'src/View/OverlayBar.vala'
2--- src/View/OverlayBar.vala 2013-12-21 01:56:36 +0000
3+++ src/View/OverlayBar.vala 2014-04-18 19:53:11 +0000
4@@ -18,20 +18,7 @@
5
6 namespace Marlin.View {
7
8- public class OverlayBar : Gtk.EventBox {
9-
10- private const string FALLBACK_THEME = """
11- .files-overlay-bar {
12- background-color: @bg_color;
13- border-radius: 3px 3px 0 0;
14- padding: 3px 6px 3px 6px;
15- margin: 1px;
16- border-style: solid;
17- border-width: 1px;
18- border-color: darker (@bg_color);
19- }""";
20-
21- public Gtk.Label status;
22+ public class OverlayBar : Granite.Widgets.OverlayBar {
23 private Marlin.View.Window window;
24
25 const int IMAGE_LOADER_BUFFER_SIZE = 8192;
26@@ -50,28 +37,12 @@
27 }
28 }
29
30- public OverlayBar (Marlin.View.Window win)
31+ public OverlayBar (Marlin.View.Window win, Gtk.Overlay overlay)
32 {
33+ base (overlay);
34+
35 window = win;
36
37- visible_window = false;
38-
39- status = new Gtk.Label (null);
40- status.set_ellipsize (Pango.EllipsizeMode.END);
41- add (status);
42- status.show ();
43-
44- set_halign (Gtk.Align.END);
45- set_valign (Gtk.Align.END);
46-
47- set_default_style ();
48-
49- var ctx = get_style_context ();
50- ctx.changed.connect (update_spacing);
51- ctx.changed.connect_after (queue_resize);
52-
53- update_spacing ();
54-
55 window.selection_changed.connect (update);
56 window.item_hovered.connect (update_hovered);
57
58@@ -82,92 +53,6 @@
59 });
60 }
61
62- public override void parent_set (Gtk.Widget? old_parent)
63- {
64- Gtk.Widget parent = get_parent ();
65-
66- if (old_parent != null)
67- old_parent.enter_notify_event.disconnect (enter_notify_callback);
68- if (parent != null)
69- parent.enter_notify_event.connect (enter_notify_callback);
70- }
71-
72- public override bool draw (Cairo.Context cr)
73- {
74- var ctx = get_style_context ();
75- ctx.render_background (cr, 0, 0, get_allocated_width (), get_allocated_height ());
76- ctx.render_frame (cr, 0, 0, get_allocated_width (), get_allocated_height ());
77- return base.draw (cr);
78- }
79-
80- public override Gtk.SizeRequestMode get_request_mode ()
81- {
82- return Gtk.SizeRequestMode.HEIGHT_FOR_WIDTH;
83- }
84-
85- public override void get_preferred_width (out int minimum_width, out int natural_width)
86- {
87- Gtk.Requisition label_min_size, label_natural_size;
88- status.get_preferred_size (out label_min_size, out label_natural_size);
89-
90- var ctx = get_style_context ();
91- var state = ctx.get_state ();
92- var border = ctx.get_border (state);
93-
94- int extra_allocation = border.left + border.right;
95- minimum_width = extra_allocation + label_min_size.width;
96- natural_width = extra_allocation + label_natural_size.width;
97- }
98-
99- public override void get_preferred_height_for_width (int width, out int minimum_height,
100- out int natural_height)
101- {
102- Gtk.Requisition label_min_size, label_natural_size;
103- status.get_preferred_size (out label_min_size, out label_natural_size);
104-
105- var ctx = get_style_context ();
106- var state = ctx.get_state ();
107- var border = ctx.get_border (state);
108-
109- int extra_allocation = border.top + border.bottom;
110- minimum_height = extra_allocation + label_min_size.height;
111- natural_height = extra_allocation + label_natural_size.height;
112- }
113-
114- private void update_spacing ()
115- {
116- var ctx = get_style_context ();
117- var state = ctx.get_state ();
118-
119- var padding = ctx.get_padding (state);
120- status.margin_top = padding.top;
121- status.margin_bottom = padding.bottom;
122- status.margin_left = padding.left;
123- status.margin_right = padding.right;
124-
125- var margin = ctx.get_margin (state);
126- margin_top = margin.top;
127- margin_bottom = margin.bottom;
128- margin_left = margin.left;
129- margin_right = margin.right;
130- }
131-
132- private void set_default_style ()
133- {
134- int priority = Gtk.STYLE_PROVIDER_PRIORITY_FALLBACK;
135- Granite.Widgets.Utils.set_theming (this, FALLBACK_THEME, "files-overlay-bar", priority);
136- }
137-
138- private bool enter_notify_callback (Gdk.EventCrossing event)
139- {
140- message ("enter_notify_event");
141- if (get_halign () == Gtk.Align.START)
142- set_halign (Gtk.Align.END);
143- else
144- set_halign (Gtk.Align.START);
145- return false;
146- }
147-
148 private uint count = 0;
149 private uint folders_count = 0;
150 private uint files_count = 0;
151@@ -217,7 +102,7 @@
152
153 } else {
154 visible = false;
155- status.set_label ("");
156+ status = "";
157 }
158 }
159
160@@ -231,7 +116,7 @@
161
162 if (count == 1) {
163 if (goffile.is_network_uri_scheme ()) {
164- status.set_label (goffile.get_display_target_uri ());
165+ status = goffile.get_display_target_uri ();
166 } else if (!goffile.is_folder ()) {
167
168 /* if we have an image, see if we can get its resolution */
169@@ -240,9 +125,9 @@
170 load_resolution.begin (goffile);
171 }
172
173- status.set_label ("%s (%s)".printf (goffile.formated_type, goffile.format_size));
174+ status = "%s (%s)".printf (goffile.formated_type, goffile.format_size);
175 } else {
176- status.set_label ("%s - %s".printf (goffile.info.get_name (), goffile.formated_type));
177+ status = "%s - %s".printf (goffile.info.get_name (), goffile.formated_type);
178
179 }
180 } else {
181@@ -275,7 +160,7 @@
182 str = _("%u items selected (%s)").printf (count, format_size ((int64) files_size));
183 }
184
185- status.set_label (str);
186+ status = str;
187
188 }
189 }
190@@ -309,7 +194,7 @@
191
192 loader.size_prepared.connect ((width, height) => {
193 image_size_loaded = true;
194- status.set_label ("%s (%s — %i × %i)".printf (goffile.formated_type, goffile.format_size, width, height));
195+ status = "%s (%s — %i × %i)".printf (goffile.formated_type, goffile.format_size, width, height);
196 });
197
198 /* Gdk wants us to always close the loader, so we are nice to it */
199
200=== modified file 'src/View/ViewContainer.vala'
201--- src/View/ViewContainer.vala 2014-01-07 22:25:32 +0000
202+++ src/View/ViewContainer.vala 2014-04-18 19:53:11 +0000
203@@ -45,7 +45,7 @@
204
205 public ViewContainer (Marlin.View.Window win, GLib.File location, int _view_mode = 0) {
206 window = win;
207- overlay_statusbar = new OverlayBar (win);
208+ overlay_statusbar = new OverlayBar (win, this);
209 view_mode = _view_mode;
210
211 /* set active tab */

Subscribers

People subscribed via source and target branches

to all changes: