[gnome-music] Set required GTK+ version to 3.10



commit 3f8445300b096dbb7a65e6d9a4c1e936f100229c
Author: Arnel A. Borja <arnelborja src gnome org>
Date:   Tue Apr 15 09:34:54 2014 +0800

    Set required GTK+ version to 3.10

 configure.ac                                     |    6 +--
 data/{PlaylistDialog.ui.in => PlaylistDialog.ui} |    2 +-
 data/{headerbar.ui.in => headerbar.ui}           |   36 +-----------------
 gnomemusic/toolbar.py                            |   45 +---------------------
 gnomemusic/view.py                               |   25 +++++-------
 gnomemusic/widgets.py                            |    6 +--
 gnomemusic/window.py                             |   15 +------
 po/POTFILES.in                                   |    4 +-
 po/POTFILES.skip                                 |    2 -
 9 files changed, 21 insertions(+), 120 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index bc14ca4..d428131 100644
--- a/configure.ac
+++ b/configure.ac
@@ -31,9 +31,7 @@ PKG_PROG_PKG_CONFIG([0.22])
 
 GLIB_GSETTINGS
 GOBJECT_INTROSPECTION_REQUIRE([1.35.9])
-PKG_CHECK_MODULES([GTK], [gtk+-3.0 >= 3.8])
-PKG_CHECK_EXISTS([gtk+-3.0 >= 3.9.0], [GTK_OR_GD=Gtk], [GTK_OR_GD=Gd])
-AC_SUBST(GTK_OR_GD)
+PKG_CHECK_MODULES([GTK], [gtk+-3.0 >= 3.10])
 
 GLIB_COMPILE_RESOURCES=`$PKG_CONFIG --variable glib_compile_resources gio-2.0`
 AC_SUBST(GLIB_COMPILE_RESOURCES)
@@ -45,9 +43,7 @@ AC_CONFIG_FILES([
   Makefile
   data/Makefile
   help/Makefile
-  data/headerbar.ui
   data/AboutDialog.ui
-  data/PlaylistDialog.ui
   gnomemusic/Makefile
   po/Makefile.in
   libgd/Makefile
diff --git a/data/PlaylistDialog.ui.in b/data/PlaylistDialog.ui
similarity index 98%
rename from data/PlaylistDialog.ui.in
rename to data/PlaylistDialog.ui
index 2fde3f1..3770117 100644
--- a/data/PlaylistDialog.ui.in
+++ b/data/PlaylistDialog.ui
@@ -56,7 +56,7 @@
       </object>
     </child>
   </object>
-  <object class="@GTK_OR_GD HeaderBar" id="headerbar1">
+  <object class="GtkHeaderBar" id="headerbar1">
     <property name="title" translatable="yes">Select Playlist</property>
     <property name="visible">True</property>
     <child>
diff --git a/data/headerbar.ui.in b/data/headerbar.ui
similarity index 81%
rename from data/headerbar.ui.in
rename to data/headerbar.ui
index 77e0b12..3b0304a 100644
--- a/data/headerbar.ui.in
+++ b/data/headerbar.ui
@@ -55,7 +55,7 @@
       <class name="selection-menu"/>
     </style>
   </object>
-  <object class="@GTK_OR_GD HeaderBar" id="header-bar">
+  <object class="GtkHeaderBar" id="header-bar">
     <property name="visible">True</property>
     <property name="vexpand">False</property>
     <child>
@@ -140,40 +140,6 @@
         <property name="pack_type">start</property>
       </packing>
     </child>
-    <child>
-      <object class="GtkSeparator" id="close-button-separator">
-        <property name="visible">True</property>
-        <property name="orientation">vertical</property>
-        <property name="valign">fill</property>
-      </object>
-      <packing>
-        <property name="pack_type">end</property>
-      </packing>
-    </child>
-    <child>
-      <object class="GtkButton" id="close-button">
-        <property name="visible">True</property>
-        <property name="can_focus">False</property>
-        <property name="valign">center</property>
-        <property name="relief">none</property>
-        <property name="sensitive">True</property>
-        <style>
-          <class name="image-button"/>
-          <class name="titlebutton"/>
-        </style>
-        <child>
-          <object class="GtkImage" id="close-button-image">
-            <property name="visible">True</property>
-            <property name="can_focus">False</property>
-            <property name="icon_name">window-close-symbolic</property>
-            <property name="icon_size">1</property>
-          </object>
-        </child>
-      </object>
-      <packing>
-        <property name="pack_type">end</property>
-      </packing>
-    </child>
   </object>
   <object class="GtkSizeGroup" id="size1">
       <property name="mode">vertical</property>
diff --git a/gnomemusic/toolbar.py b/gnomemusic/toolbar.py
index ef6f4e4..e39b0c6 100644
--- a/gnomemusic/toolbar.py
+++ b/gnomemusic/toolbar.py
@@ -30,10 +30,6 @@
 
 from gi.repository import Gtk, Gdk, GObject
 
-if Gtk.get_minor_version() > 8:
-    from gi.repository.Gtk import StackSwitcher
-else:
-    from gi.repository.Gd import StackSwitcher
 from gnomemusic.searchbar import Searchbar
 
 from gnomemusic import log
@@ -56,12 +52,11 @@ class Toolbar(GObject.GObject):
         'selection-mode-changed': (GObject.SIGNAL_RUN_FIRST, None, ()),
     }
     _selectionMode = False
-    _maximized = False
 
     @log
     def __init__(self):
         GObject.GObject.__init__(self)
-        self._stack_switcher = StackSwitcher(margin_top=2, margin_bottom=2, can_focus=False)
+        self._stack_switcher = Gtk.StackSwitcher(margin_top=2, margin_bottom=2, can_focus=False)
         self._stack_switcher.show()
         self._ui = Gtk.Builder()
         self._ui.add_from_resource('/org/gnome/Music/headerbar.ui')
@@ -71,8 +66,6 @@ class Toolbar(GObject.GObject):
         self._select_button = self._ui.get_object('select-button')
         self._cancel_button = self._ui.get_object('done-button')
         self._back_button = self._ui.get_object('back-button')
-        self._close_separator = self._ui.get_object('close-button-separator')
-        self._close_button = self._ui.get_object('close-button')
         self._selection_menu = self._ui.get_object('selection-menu')
         self._selection_menu_button = self._ui.get_object('selection-menu-button')
         self._selection_menu_label = self._ui.get_object('selection-menu-button-label')
@@ -81,48 +74,20 @@ class Toolbar(GObject.GObject):
             _back_button_image = self._ui.get_object('back-button-image')
             _back_button_image.set_property('icon-name', 'go-previous-rtl-symbolic')
         if Gtk.get_minor_version() >= 11:
-            self.header_bar.remove(self._close_button)
-            self.header_bar.remove(self._close_separator)
             self.header_bar.remove(self._select_button)
             self.header_bar.remove(self._cancel_button)
             self.header_bar.remove(self._search_button)
 
-            self.header_bar.pack_end(self._close_button)
-            self.header_bar.pack_end(self._close_separator)
             self.header_bar.pack_end(self._select_button)
             self.header_bar.pack_end(self._cancel_button)
             self.header_bar.pack_end(self._search_button)
         self._back_button.connect('clicked', self.on_back_button_clicked)
-        self._close_button.connect('clicked', self._close_button_clicked)
-        if Gtk.get_minor_version() <= 8:
-            self._close_button.connect('hierarchy-changed', self._on_hierarchy_changed)
-
-    @log
-    def _close_button_clicked(self, btn):
-        if Gtk.get_minor_version() > 8:
-            self._close_button.get_toplevel().close()
-        else:
-            self._close_button.get_toplevel().destroy()
 
     @log
     def reset_header_title(self):
         self.header_bar.set_custom_title(self._stack_switcher)
 
     @log
-    def _on_hierarchy_changed(self, widget, previous_toplevel):
-        if previous_toplevel:
-            previous_toplevel.disconnect(self._window_state_handler)
-        self._close_button.get_toplevel().add_events(Gdk.EventMask.STRUCTURE_MASK)
-        self._window_state_handler = \
-            self._close_button.get_toplevel().connect('window-state-event', self._on_window_state_event)
-
-    @log
-    def _on_window_state_event(self, widget, event):
-        if event.changed_mask & Gdk.WindowState.MAXIMIZED:
-            self._maximized = bool(event.new_window_state & Gdk.WindowState.MAXIMIZED)
-            self._update()
-
-    @log
     def set_stack(self, stack):
         self._stack_switcher.set_stack(stack)
 
@@ -176,10 +141,4 @@ class Toolbar(GObject.GObject):
             self.reset_header_title()
 
         self._back_button.set_visible(not self._selectionMode and self._state == ToolbarState.SINGLE)
-
-        if Gtk.get_minor_version() > 8:
-            self._close_separator.set_visible(not self._selectionMode)
-            self._close_button.set_visible(not self._selectionMode)
-        else:
-            self._close_separator.set_visible(not self._selectionMode and self._maximized)
-            self._close_button.set_visible(not self._selectionMode and self._maximized)
+        self.header_bar.set_show_close_button(not self._selectionMode)
diff --git a/gnomemusic/view.py b/gnomemusic/view.py
index 3356054..00bc6f8 100644
--- a/gnomemusic/view.py
+++ b/gnomemusic/view.py
@@ -54,13 +54,8 @@ logger = logging.getLogger(__name__)
 tracker = Tracker.SparqlConnection.get(None)
 playlists = Playlists.get_default()
 
-if Gtk.get_minor_version() > 8:
-    from gi.repository.Gtk import Stack, StackTransitionType
-else:
-    from gi.repository.Gd import Stack, StackTransitionType
 
-
-class ViewContainer(Stack):
+class ViewContainer(Gtk.Stack):
     if Gtk.Widget.get_default_direction() is not Gtk.TextDirection.RTL:
         nowPlayingIconName = 'media-playback-start-symbolic'
     else:
@@ -72,8 +67,8 @@ class ViewContainer(Stack):
 
     @log
     def __init__(self, title, header_bar, selection_toolbar, view_type, use_sidebar=False, sidebar=None):
-        Stack.__init__(self,
-                       transition_type=StackTransitionType.CROSSFADE)
+        Gtk.Stack.__init__(self,
+                           transition_type=Gtk.StackTransitionType.CROSSFADE)
         self._grid = Gtk.Grid(orientation=Gtk.Orientation.HORIZONTAL)
         self._iconWidth = 128
         self._iconHeight = 128
@@ -105,8 +100,8 @@ class ViewContainer(Stack):
         box = Gtk.Box(orientation=Gtk.Orientation.VERTICAL)
         box.pack_start(self.view, True, True, 0)
         if use_sidebar:
-            self.stack = Stack(
-                transition_type=StackTransitionType.SLIDE_RIGHT,
+            self.stack = Gtk.Stack(
+                transition_type=Gtk.StackTransitionType.SLIDE_RIGHT,
             )
             dummy = Gtk.Frame(visible=False)
             self.stack.add_named(dummy, 'dummy')
@@ -338,11 +333,11 @@ class ViewContainer(Stack):
 
 
 # Class for the Empty View
-class Empty(Stack):
+class Empty(Gtk.Stack):
     @log
     def __init__(self, header_bar, player):
-        Stack.__init__(self,
-                       transition_type=StackTransitionType.CROSSFADE)
+        Gtk.Stack.__init__(self,
+                           transition_type=Gtk.StackTransitionType.CROSSFADE)
         builder = Gtk.Builder()
         builder.add_from_resource('/org/gnome/Music/NoMusic.ui')
         music_folder_path = GLib.get_user_special_dir(GLib.USER_DIRECTORY_MUSIC)
@@ -605,8 +600,8 @@ class Artists (ViewContainer):
         self.items_selected = []
         self.items_selected_callback = None
         self.countQuery = Query.ARTISTS_COUNT
-        self.artistAlbumsStack = Stack(
-            transition_type=StackTransitionType.CROSSFADE,
+        self.artistAlbumsStack = Gtk.Stack(
+            transition_type=Gtk.StackTransitionType.CROSSFADE,
         )
         self._artistAlbumsWidget = Gtk.Frame(
             shadow_type=Gtk.ShadowType.NONE,
diff --git a/gnomemusic/widgets.py b/gnomemusic/widgets.py
index a013025..4356686 100644
--- a/gnomemusic/widgets.py
+++ b/gnomemusic/widgets.py
@@ -668,11 +668,7 @@ class PlaylistDialog():
         self.populate(playlist_names)
 
         self.title_bar = self.ui.get_object('headerbar1')
-        if Gtk.get_minor_version() > 8:
-            self.dialog_box.set_titlebar(self.title_bar)
-        else:
-            self.dialog_box.get_content_area().add(self.title_bar)
-            self.dialog_box.get_content_area().reorder_child(self.title_bar, 0)
+        self.dialog_box.set_titlebar(self.title_bar)
 
         self._cancel_button = self.ui.get_object('cancel-button')
         self._select_button = self.ui.get_object('select-button')
diff --git a/gnomemusic/window.py b/gnomemusic/window.py
index aea0b4f..d8f7417 100644
--- a/gnomemusic/window.py
+++ b/gnomemusic/window.py
@@ -47,11 +47,6 @@ logger = logging.getLogger(__name__)
 playlist = Playlists.get_default()
 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):
 
@@ -178,16 +173,12 @@ class Window(Gtk.ApplicationWindow):
         self.selection_toolbar = SelectionToolbar()
         self.toolbar = Toolbar()
         self.views = []
-        self._stack = Stack(
-            transition_type=StackTransitionType.CROSSFADE,
+        self._stack = Gtk.Stack(
+            transition_type=Gtk.StackTransitionType.CROSSFADE,
             transition_duration=100,
             visible=True,
             can_focus=False)
-        if Gtk.get_minor_version() > 8:
-            self.set_titlebar(self.toolbar.header_bar)
-        else:
-            self._box.pack_start(self.toolbar.header_bar, False, False, 0)
-            self.set_hide_titlebar_when_maximized(True)
+        self.set_titlebar(self.toolbar.header_bar)
         self._box.pack_start(self.toolbar.searchbar, False, False, 0)
         self._box.pack_start(self._stack, True, True, 0)
         self._box.pack_start(self.player.eventBox, False, False, 0)
diff --git a/po/POTFILES.in b/po/POTFILES.in
index cc85990..b4edd2a 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -25,7 +25,7 @@ gnomemusic/window.py
 [type: gettext/glade]data/PlayerToolbar.ui
 [type: gettext/glade]data/TrackWidget.ui
 [type: gettext/glade]data/NoMusic.ui
-[type: gettext/glade]data/headerbar.ui.in
+[type: gettext/glade]data/headerbar.ui
 [type: gettext/glade]data/SelectionToolbar.ui
 [type: gettext/glade]data/PlaylistControls.ui
-[type: gettext/glade]data/PlaylistDialog.ui.in
+[type: gettext/glade]data/PlaylistDialog.ui
diff --git a/po/POTFILES.skip b/po/POTFILES.skip
index c4ce26f..bf30003 100644
--- a/po/POTFILES.skip
+++ b/po/POTFILES.skip
@@ -1,4 +1,2 @@
-data/headerbar.ui
 data/AboutDialog.ui
-data/PlaylistDialog.ui
 data/gnome-music.appdata.xml


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]