-
Notifications
You must be signed in to change notification settings - Fork 131
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Ubuntu is an ancient African word for not being able to keep up-to-da…
…te Debian
- Loading branch information
Showing
5 changed files
with
71 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
""" | ||
DWSNC - Doing Weird Things in Name of Compatibility | ||
This module, when imported, applies various fixes and monkey-patching to allow | ||
application to run with older versions of GLib and/or GTK. | ||
""" | ||
from __future__ import unicode_literals | ||
from gi.repository import Gtk, GObject | ||
import os | ||
|
||
|
||
def fix_label_missing_set_XYalign_methods(): | ||
""" | ||
Fix Gtk.Label missing set_xalign and set_yalign methods with older | ||
versions of Gtk. | ||
Prevents crashing, but alings are ignored. | ||
""" | ||
Gtk.Label.set_xalign = Gtk.Label.set_yalign = lambda *a : None | ||
|
||
def child_get_property(parent, child, propname): | ||
""" | ||
Wrapper for child_get_property, which pygobject doesn't properly | ||
introspect | ||
""" | ||
value = GObject.Value() | ||
value.init(GObject.TYPE_INT) | ||
parent.child_get_property(child, propname, value) | ||
return value.get_int() | ||
|
||
|
||
def headerbar(bar): | ||
""" | ||
Moves all buttons from left to right (and vice versa) if user's desktop | ||
environment is identified as Unity | ||
""" | ||
pass # Not outside of Unity | ||
|
||
if "XDG_CURRENT_DESKTOP" in os.environ and "Unity" in os.environ["XDG_CURRENT_DESKTOP"].split(":"): | ||
# User runs Unity | ||
def _headerbar(bar): | ||
children = [] + bar.get_children() | ||
pack_start = [] | ||
pack_end = [] | ||
for c in children: | ||
if child_get_property(bar, c, 'pack-type') == Gtk.PackType.END: | ||
bar.remove(c) | ||
pack_start.append(c) | ||
else: | ||
bar.remove(c) | ||
pack_end.append(c) | ||
if len(pack_end) > 1: | ||
c, pack_end = pack_end[0], pack_end[1:] | ||
pack_end.append(c) | ||
if (Gtk.get_major_version(), Gtk.get_minor_version()) > (3, 10): | ||
# Old ubuntu has this in order, new Ubuntu has it reversed | ||
pack_end = reversed(pack_end) | ||
for c in pack_start: bar.pack_start(c) | ||
for c in pack_end: bar.pack_end(c) | ||
headerbar = _headerbar | ||
|
||
if not hasattr(Gtk.Label, "set_xalign"): | ||
# GTK is old enought | ||
fix_label_missing_set_XYalign_methods() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters