Merge lp:~victored/granite/thin-paned-gtk-3-13 into lp:~elementary-pantheon/granite/granite

Proposed by Victor Martinez
Status: Rejected
Rejected by: Victor Martinez
Proposed branch: lp:~victored/granite/thin-paned-gtk-3-13
Merge into: lp:~elementary-pantheon/granite/granite
Diff against target: 168 lines (+46/-19)
2 files modified
lib/Widgets/ThinPaned.vala (+44/-18)
lib/style-classes.vala (+2/-1)
To merge this branch: bzr merge lp:~victored/granite/thin-paned-gtk-3-13
Reviewer Review Type Date Requested Status
Victor Martinez (community) Disapprove
Review via email: mp+224047@code.launchpad.net

Commit message

Disable ThinPaned's features with Gtk 3.13, to make it act like a normal GtkPaned.

The style class "thin-paned" will also be present in ThinPaned with Gtk 3.13+

Description of the change

GTK+ 3.13 supports defining overlay pane separator handles from the theme, and ThinPaned will be deprecated in favor of that.

As it seems we're still unsure whether we will be shipping GTK+ 3.12 or 3.14 in Freya, I've added a runtime check to ThinPaned to make the same Granite binary work with both versions.

Basically what this does is disabling ThinPaned's overlay GdkWindow, handle-drawing code, and event handling, so it doesn't override the behavior provided by GtkPaned in GTK+ 3.13.

Notice that ThinPaned adds the style class "thin-paned" with GTK+ 3.13, which can be used as follows:

/* this will match the entire GtkPaned widget */
.thin-paned {
    -GtkPaned-handle-size: 1px;
    border-width: 0;

    /*
     the handle's margins are applied to the entire paned and not the
     pane-separator class, as that one is only used for drawing purposes
    */

    /* additional invisible pixels to add above pane separator for vertically-stacked panes */
    margin-top: 3px;

    /* additional invisible pixels to add below pane separator for vertically-stacked panes */
    margin-bottom: 2px;

    /* additional invisible pixels to add on left side of the pane separator for horizontally-stacked panes */
    margin-left: 2px; /* avoid conflicting with scrollbar */

    /* additional invisible pixels to add on right side of the pane separator for horizontally-stacked panes */
    margin-right: 4px;

    /* optionally, we could simply use 'margin' */
    margin: 3px;
}

/* theme pane separator */
.thin-paned.pane-separator {
   background-color: black;
   border-width: 0;
}

To post a comment you must log in.
Revision history for this message
Victor Martinez (victored) wrote :

This branch is no longer relevant, as it seems we'll simply wait for the release of GTK+ 3.14.

Let's do a clean deprecation when the time comes.

review: Disapprove

Unmerged revisions

742. By Victor Martinez

Add runtime check for GTK+ 3.13 or newer, and make ThinPaned behave as a normal GtkPaned with a style class called "thin-paned".

ThinPaned behaves as usual with Gtk 3.12 or older.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'lib/Widgets/ThinPaned.vala'
--- lib/Widgets/ThinPaned.vala 2014-04-04 03:47:51 +0000
+++ lib/Widgets/ThinPaned.vala 2014-06-22 17:48:43 +0000
@@ -52,6 +52,7 @@
5252
53 private Gdk.Window overlay_handle;53 private Gdk.Window overlay_handle;
54 private bool in_resize = false;54 private bool in_resize = false;
55 private bool use_legacy_gdk_window;
5556
56 static construct {57 static construct {
57 install_style_property (new ParamSpecInt (STYLE_PROP_OVERLAY_HANDLE_SIZE,58 install_style_property (new ParamSpecInt (STYLE_PROP_OVERLAY_HANDLE_SIZE,
@@ -63,17 +64,30 @@
6364
64 public ThinPaned (Gtk.Orientation orientation = Gtk.Orientation.HORIZONTAL) {65 public ThinPaned (Gtk.Orientation orientation = Gtk.Orientation.HORIZONTAL) {
65 this.orientation = orientation;66 this.orientation = orientation;
66 Utils.set_theming (this, DEFAULT_STYLESHEET, null, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION);67
67 Utils.set_theming (this, FALLBACK_STYLESHEET, null, Gtk.STYLE_PROVIDER_PRIORITY_THEME);68 // GtkPaned is already capable of showing an overlay handle since version 3.13,
69 // so we disable ThinPaned's features at runtime when this version is detected,
70 // at least until our widget is properly deprecated.
71 use_legacy_gdk_window = (Gtk.get_minor_version () < 13);
72
73 if (use_legacy_gdk_window) {
74 Utils.set_theming (this, DEFAULT_STYLESHEET, null, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION);
75 Utils.set_theming (this, FALLBACK_STYLESHEET, null, Gtk.STYLE_PROVIDER_PRIORITY_THEME);
76 } else {
77 get_style_context ().add_class (StyleClass.THIN_PANED);
78 }
68 }79 }
6980
70 public unowned Gdk.Window get_overlay_handle_window () {81 public unowned Gdk.Window get_overlay_handle_window () {
71 return overlay_handle;82 return use_legacy_gdk_window ? overlay_handle : get_handle_window ();
72 }83 }
7384
74 public override void realize () {85 public override void realize () {
75 base.realize ();86 base.realize ();
7687
88 if (!use_legacy_gdk_window)
89 return;
90
77 // Create invisible overlay handle91 // Create invisible overlay handle
78 var attributes = Gdk.WindowAttr ();92 var attributes = Gdk.WindowAttr ();
7993
@@ -105,27 +119,34 @@
105119
106 public override void unrealize () {120 public override void unrealize () {
107 base.unrealize ();121 base.unrealize ();
108 overlay_handle.set_user_data (null);122
109 overlay_handle.destroy ();123 if (use_legacy_gdk_window) {
110 overlay_handle = null;124 overlay_handle.set_user_data (null);
125 overlay_handle.destroy ();
126 overlay_handle = null;
127 }
111 }128 }
112129
113 public override void map () {130 public override void map () {
114 base.map ();131 base.map ();
115 overlay_handle.show ();132
133 if (use_legacy_gdk_window)
134 overlay_handle.show ();
116 }135 }
117136
118 public override void unmap () {137 public override void unmap () {
119 base.unmap ();138 base.unmap ();
120 overlay_handle.hide ();139
140 if (use_legacy_gdk_window)
141 overlay_handle.hide ();
121 }142 }
122143
123 public override bool draw (Cairo.Context ctx) {144 public override bool draw (Cairo.Context ctx) {
124 base.draw (ctx);145 bool rv = base.draw (ctx);
125146
126 // if the overlay handle is not visible, don't draw a pane separator.147 // if the overlay handle is not visible, don't draw a pane separator.
127 if (!overlay_handle.is_visible ())148 if (!use_legacy_gdk_window || !overlay_handle.is_visible ())
128 return false;149 return rv;
129150
130 Gtk.Allocation allocation;151 Gtk.Allocation allocation;
131 get_allocation (out allocation);152 get_allocation (out allocation);
@@ -171,7 +192,9 @@
171192
172 public override void size_allocate (Gtk.Allocation allocation) {193 public override void size_allocate (Gtk.Allocation allocation) {
173 base.size_allocate (allocation);194 base.size_allocate (allocation);
174 update_overlay_handle ();195
196 if (use_legacy_gdk_window)
197 update_overlay_handle ();
175 }198 }
176199
177 private void update_overlay_handle () {200 private void update_overlay_handle () {
@@ -212,7 +235,7 @@
212 public override void state_flags_changed (Gtk.StateFlags previous_state) {235 public override void state_flags_changed (Gtk.StateFlags previous_state) {
213 base.state_flags_changed (previous_state);236 base.state_flags_changed (previous_state);
214237
215 if (get_realized ()) {238 if (use_legacy_gdk_window && get_realized ()) {
216 var default_handle_cursor = get_handle_window ().get_cursor ();239 var default_handle_cursor = get_handle_window ().get_cursor ();
217 if (overlay_handle.get_cursor () != default_handle_cursor)240 if (overlay_handle.get_cursor () != default_handle_cursor)
218 overlay_handle.set_cursor (default_handle_cursor);241 overlay_handle.set_cursor (default_handle_cursor);
@@ -220,7 +243,7 @@
220 }243 }
221244
222 public override bool motion_notify_event (Gdk.EventMotion event) {245 public override bool motion_notify_event (Gdk.EventMotion event) {
223 if (!in_resize)246 if (!use_legacy_gdk_window || !in_resize)
224 return base.motion_notify_event (event);247 return base.motion_notify_event (event);
225248
226 var device = event.device ?? Gtk.get_current_event_device ();249 var device = event.device ?? Gtk.get_current_event_device ();
@@ -257,7 +280,8 @@
257 }280 }
258281
259 public override bool button_press_event (Gdk.EventButton event) {282 public override bool button_press_event (Gdk.EventButton event) {
260 if (!in_resize && event.button == Gdk.BUTTON_PRIMARY && event.window == overlay_handle) {283 if (use_legacy_gdk_window && !in_resize && event.button == Gdk.BUTTON_PRIMARY
284 && event.window == overlay_handle) {
261 in_resize = true;285 in_resize = true;
262 Gtk.grab_add (this);286 Gtk.grab_add (this);
263 return true;287 return true;
@@ -267,7 +291,7 @@
267 }291 }
268292
269 public override bool button_release_event (Gdk.EventButton event) {293 public override bool button_release_event (Gdk.EventButton event) {
270 if (event.window == overlay_handle) {294 if (use_legacy_gdk_window && event.window == overlay_handle) {
271 in_resize = false;295 in_resize = false;
272 Gtk.grab_remove (this);296 Gtk.grab_remove (this);
273 return true;297 return true;
@@ -277,7 +301,9 @@
277 }301 }
278302
279 public override bool grab_broken_event (Gdk.EventGrabBroken event) {303 public override bool grab_broken_event (Gdk.EventGrabBroken event) {
280 in_resize = false;304 if (use_legacy_gdk_window)
305 in_resize = false;
306
281 return base.grab_broken_event (event);307 return base.grab_broken_event (event);
282 }308 }
283}309}
284\ No newline at end of file310\ No newline at end of file
285311
=== modified file 'lib/style-classes.vala'
--- lib/style-classes.vala 2014-04-18 19:35:30 +0000
+++ lib/style-classes.vala 2014-06-22 17:48:43 +0000
@@ -28,6 +28,7 @@
28 public const string POPOVER = "popover";28 public const string POPOVER = "popover";
29 public const string POPOVER_BG = "popover_bg";29 public const string POPOVER_BG = "popover_bg";
30 public const string HELP_BUTTON = "help_button";30 public const string HELP_BUTTON = "help_button";
31 public const string THIN_PANED = "thin-paned";
31 public const string THIN_PANE_SEPARATOR = "sidebar-pane-separator";32 public const string THIN_PANE_SEPARATOR = "sidebar-pane-separator";
32 public const string OVERLAY_BAR = "overlay-bar";33 public const string OVERLAY_BAR = "overlay-bar";
3334
@@ -35,4 +36,4 @@
35 public const string H1_TEXT = "h1";36 public const string H1_TEXT = "h1";
36 public const string H2_TEXT = "h2";37 public const string H2_TEXT = "h2";
37 public const string H3_TEXT = "h3";38 public const string H3_TEXT = "h3";
38}39}
39\ No newline at end of file40\ No newline at end of file

Subscribers

People subscribed via source and target branches