[gnome-music: 3/11] Use libgd widgets instead of gtk+ if the later is too old
- From: Vadim Rutkovsky <vrutkovsky src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-music: 3/11] Use libgd widgets instead of gtk+ if the later is too old
- Date: Wed, 7 Aug 2013 09:15:40 +0000 (UTC)
commit 1801174f821641f5e4901b726cf26505fdc7fc13
Author: Arnel A. Borja <arnelborja src gnome org>
Date: Sat Aug 3 20:28:28 2013 +0800
Use libgd widgets instead of gtk+ if the later is too old
Import Stack, StackTransitionType and StackSwitcher from libgd if gtk+ is older
than 3.9.
gnomemusic/toolbar.py | 7 ++++++-
gnomemusic/view.py | 21 +++++++++++++--------
gnomemusic/window.py | 9 +++++++--
3 files changed, 26 insertions(+), 11 deletions(-)
---
diff --git a/gnomemusic/toolbar.py b/gnomemusic/toolbar.py
index d301cb6..ee4f802 100644
--- a/gnomemusic/toolbar.py
+++ b/gnomemusic/toolbar.py
@@ -1,5 +1,10 @@
from gi.repository import Gtk, GObject
+if Gtk.get_minor_version() > 8:
+ from gi.repository.Gtk import StackSwitcher
+else:
+ from gi.repository.Gd import StackSwitcher
+
class ToolbarState:
SINGLE = 0
@@ -18,7 +23,7 @@ class Toolbar(GObject.GObject):
def __init__(self):
GObject.GObject.__init__(self)
- self._stack_switcher = Gtk.StackSwitcher(margin_top=2, margin_bottom=2)
+ self._stack_switcher = StackSwitcher(margin_top=2, margin_bottom=2)
self._ui = Gtk.Builder()
self._ui.add_from_resource('/org/gnome/Music/Headerbar.ui')
self.header_bar = self._ui.get_object('header-bar')
diff --git a/gnomemusic/view.py b/gnomemusic/view.py
index dcedccc..3794c35 100644
--- a/gnomemusic/view.py
+++ b/gnomemusic/view.py
@@ -13,16 +13,21 @@ from gnomemusic.query import Query
from gnomemusic.albumArtCache import AlbumArtCache as albumArtCache
tracker = Tracker.SparqlConnection.get(None)
+if Gtk.get_minor_version() > 8:
+ from gi.repository.Gtk import Stack, StackTransitionType
+else:
+ from gi.repository.Gd import Stack, StackTransitionType
-class ViewContainer(Gtk.Stack):
+
+class ViewContainer(Stack):
nowPlayingIconName = 'media-playback-start-symbolic'
errorIconName = 'dialog-error-symbolic'
starIconName = 'starred-symbolic'
countQuery = None
def __init__(self, title, header_bar, selection_toolbar, useStack=False):
- Gtk.Stack.__init__(self,
- transition_type=Gtk.StackTransitionType.CROSSFADE)
+ Stack.__init__(self,
+ transition_type=StackTransitionType.CROSSFADE)
self._grid = Gtk.Grid(orientation=Gtk.Orientation.VERTICAL)
self._iconWidth = -1
self._iconHeight = 128
@@ -52,8 +57,8 @@ class ViewContainer(Gtk.Stack):
box = Gtk.Box(orientation=Gtk.Orientation.VERTICAL)
box.pack_start(self.view, True, True, 0)
if useStack:
- self.stack = Gd.Stack(
- transition_type=Gd.StackTransitionType.SLIDE_RIGHT,
+ self.stack = Stack(
+ transition_type=StackTransitionType.SLIDE_RIGHT,
)
dummy = Gtk.Frame(visible=False)
self.stack.add_named(dummy, "dummy")
@@ -220,10 +225,10 @@ class ViewContainer(Gtk.Stack):
#Class for the Empty View
-class Empty(Gtk.Stack):
+class Empty(Stack):
def __init__(self, header_bar, player):
- Gtk.Stack.__init__(self,
- transition_type=Gtk.StackTransitionType.CROSSFADE)
+ Stack.__init__(self,
+ transition_type=StackTransitionType.CROSSFADE)
builder = Gtk.Builder()
builder.add_from_resource('/org/gnome/Music/NoMusic.ui')
widget = builder.get_object('container')
diff --git a/gnomemusic/window.py b/gnomemusic/window.py
index 038df65..48566f3 100644
--- a/gnomemusic/window.py
+++ b/gnomemusic/window.py
@@ -8,6 +8,11 @@ import gnomemusic.view as Views
tracker = Tracker.SparqlConnection.get(None)
+if Gtk.get_minor_version() > 8:
+ from gi.repository.Gtk import Stack, StackTransitionType
+else:
+ from gi.repository.Gd import Stack, StackTransitionType
+
class Window(Gtk.ApplicationWindow):
def __init__(self, app):
@@ -60,8 +65,8 @@ class Window(Gtk.ApplicationWindow):
self.toolbar = Toolbar()
self.set_titlebar(self.toolbar.header_bar)
self.views = []
- self._stack = Gtk.Stack(
- transition_type=Gtk.StackTransitionType.CROSSFADE,
+ self._stack = Stack(
+ transition_type=StackTransitionType.CROSSFADE,
transition_duration=100,
visible=True)
self._box.pack_start(self._stack, True, True, 0)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]