...
 
Commits (9)
# Compiling the resources
VCS_TAG = ''
if get_option('profile') != 'default'
git = find_program('git', required : false)
if git.found()
VCS_TAG = run_command('git', 'rev-parse', '--short', 'HEAD').stdout().strip()
endif
if VCS_TAG == ''
VCS_TAG = '-devel'
else
VCS_TAG = '-@0@'.format(VCS_TAG)
endif
endif
about_dialog_conf = configuration_data()
about_dialog_conf.set('PACKAGE_VERSION', '@0@@1@'.format(meson.project_version(), VCS_TAG))
about_dialog_conf.set('PACKAGE_URL', PACKAGE_URL)
about_dialog_conf.set('PROGRAM_NAME', 'Music' + NAME_SUFFIX)
about_dialog_conf.set('APPID', APPLICATION_ID)
# about_dialog is defined in data/ui/meson.build to generate the output file in that directory
gnome.compile_resources(
PROJECT_RDNN_NAME,
PROJECT_RDNN_NAME + '.gresource.xml',
gresource_bundle: true,
source_dir: '.',
source_dir: meson.current_build_dir(),
install_dir: PKGDATA_DIR,
install: true,
dependencies: configure_file(
input: 'AboutDialog.ui.in',
output: 'AboutDialog.ui',
configuration: about_dialog_conf
)
dependencies: about_dialog
)
# Installing the schema file
......
<?xml version="1.0" encoding="UTF-8"?>
<gresources>
<gresource prefix="/org/gnome/Music">
<file preprocess="xml-stripblanks">AboutDialog.ui</file>
<file alias="gtk/menus.ui" preprocess="xml-stripblanks">app-menu.ui</file>
<file alias="gtk/help-overlay.ui" preprocess="xml-stripblanks">help-overlay.ui</file>
<file>application.css</file>
<file>initial-state.png</file>
<file preprocess="xml-stripblanks">AlbumCover.ui</file>
<file preprocess="xml-stripblanks">AlbumWidget.ui</file>
<file preprocess="xml-stripblanks">ArtistAlbumWidget.ui</file>
<file preprocess="xml-stripblanks">ArtistAlbumsWidget.ui</file>
<file preprocess="xml-stripblanks">DiscBox.ui</file>
<file preprocess="xml-stripblanks">DropDown.ui</file>
<file preprocess="xml-stripblanks">EmptyView.ui</file>
<file preprocess="xml-stripblanks">FilterView.ui</file>
<file preprocess="xml-stripblanks">PlayerToolbar.ui</file>
<file preprocess="xml-stripblanks">Searchbar.ui</file>
<file preprocess="xml-stripblanks">SelectionBarMenuButton.ui</file>
<file preprocess="xml-stripblanks">SelectionToolbar.ui</file>
<file preprocess="xml-stripblanks">SidebarRow.ui</file>
<file preprocess="xml-stripblanks">SongWidget.ui</file>
<file preprocess="xml-stripblanks">HeaderBar.ui</file>
<file preprocess="xml-stripblanks">PlaylistContextMenu.ui</file>
<file preprocess="xml-stripblanks">PlaylistControls.ui</file>
<file preprocess="xml-stripblanks">PlaylistDialog.ui</file>
<file preprocess="xml-stripblanks">TwoLineTip.ui</file>
<file preprocess="xml-stripblanks">ui/AboutDialog.ui</file>
<file alias="gtk/menus.ui" preprocess="xml-stripblanks">ui/app-menu.ui</file>
<file alias="gtk/help-overlay.ui" preprocess="xml-stripblanks">ui/help-overlay.ui</file>
<file>org.gnome.Music.css</file>
<file>icons/initial-state.png</file>
<file preprocess="xml-stripblanks">ui/AlbumCover.ui</file>
<file preprocess="xml-stripblanks">ui/AlbumWidget.ui</file>
<file preprocess="xml-stripblanks">ui/ArtistAlbumWidget.ui</file>
<file preprocess="xml-stripblanks">ui/ArtistAlbumsWidget.ui</file>
<file preprocess="xml-stripblanks">ui/DiscBox.ui</file>
<file preprocess="xml-stripblanks">ui/DropDown.ui</file>
<file preprocess="xml-stripblanks">ui/EmptyView.ui</file>
<file preprocess="xml-stripblanks">ui/FilterView.ui</file>
<file preprocess="xml-stripblanks">ui/PlayerToolbar.ui</file>
<file preprocess="xml-stripblanks">ui/Searchbar.ui</file>
<file preprocess="xml-stripblanks">ui/SelectionBarMenuButton.ui</file>
<file preprocess="xml-stripblanks">ui/SelectionToolbar.ui</file>
<file preprocess="xml-stripblanks">ui/SidebarRow.ui</file>
<file preprocess="xml-stripblanks">ui/SongWidget.ui</file>
<file preprocess="xml-stripblanks">ui/HeaderBar.ui</file>
<file preprocess="xml-stripblanks">ui/PlaylistContextMenu.ui</file>
<file preprocess="xml-stripblanks">ui/PlaylistControls.ui</file>
<file preprocess="xml-stripblanks">ui/PlaylistDialog.ui</file>
<file preprocess="xml-stripblanks">ui/TwoLineTip.ui</file>
</gresource>
</gresources>
# AboutDialog.ui configuration
VCS_TAG = ''
if get_option('profile') != 'default'
git = find_program('git', required : false)
if git.found()
VCS_TAG = run_command('git', 'rev-parse', '--short', 'HEAD').stdout().strip()
endif
if VCS_TAG == ''
VCS_TAG = '-devel'
else
VCS_TAG = '-@0@'.format(VCS_TAG)
endif
endif
about_dialog_conf = configuration_data()
about_dialog_conf.set('PACKAGE_VERSION', '@0@@1@'.format(meson.project_version(), VCS_TAG))
about_dialog_conf.set('PACKAGE_URL', PACKAGE_URL)
about_dialog_conf.set('PROGRAM_NAME', 'Music' + NAME_SUFFIX)
about_dialog_conf.set('APPID', APPLICATION_ID)
about_dialog = configure_file(
input: 'AboutDialog.ui.in',
output: 'AboutDialog.ui',
configuration: about_dialog_conf
)
\ No newline at end of file
......@@ -61,7 +61,7 @@ class Application(Gtk.Application):
def _init_style(self):
css_provider_file = Gio.File.new_for_uri(
'resource:///org/gnome/Music/application.css')
'resource:///org/gnome/Music/org.gnome.Music.css')
css_provider = Gtk.CssProvider()
css_provider.load_from_file(css_provider_file)
screen = Gdk.Screen.get_default()
......
......@@ -124,8 +124,7 @@ class ArtistsView(BaseView):
self._view.add(new_artist_albums_widget)
artist_albums = ArtistAlbumsWidget(
artist, albums, self.player, self._headerbar,
self._selection_toolbar, self._window)
artist, albums, self.player, self._window)
self._artists[artist.casefold()]['widget'] = artist_albums
new_artist_albums_widget.add(artist_albums)
new_artist_albums_widget.show()
......
......@@ -32,7 +32,7 @@ from gnomemusic.albumartcache import Art
from gnomemusic.query import Query
@Gtk.Template(resource_path="/org/gnome/Music/EmptyView.ui")
@Gtk.Template(resource_path="/org/gnome/Music/ui/EmptyView.ui")
class EmptyView(Gtk.Stack):
"""Empty view when there is no music to display
......@@ -102,7 +102,7 @@ class EmptyView(Gtk.Stack):
self._main_label.props.label = _("Hey DJ")
self._main_label.props.margin_bottom = 18
self._icon.props.resource = "/org/gnome/Music/initial-state.png"
self._icon.props.resource = "/org/gnome/Music/icons/initial-state.png"
self._icon.props.margin_bottom = 32
self._icon.props.height_request = Art.Size.LARGE.height
self._icon.props.width_request = Art.Size.LARGE.width
......
......@@ -23,6 +23,8 @@
# delete this exception statement from your version.
from gettext import gettext as _
import gi
gi.require_version('Gd', '1.0')
from gi.repository import Gd, Gdk, GdkPixbuf, GObject, Grl, Gtk, Pango
from gnomemusic.albumartcache import Art
......@@ -54,6 +56,9 @@ class SearchView(BaseView):
def __init__(self, window, player):
super().__init__('search', None, window)
# FIXME: Searchbar handling does not belong here.
self._searchbar = window._searchbar
self._add_list_renderers()
self.player = player
self._head_iters = [None, None, None, None]
......@@ -102,7 +107,7 @@ class SearchView(BaseView):
@log
def _back_button_clicked(self, widget, data=None):
self._headerbar.searchbar.reveal(True, False)
self._searchbar.reveal(True, False)
if self.get_visible_child() == self._artist_albums_widget:
self._artist_albums_widget.destroy()
......@@ -140,21 +145,26 @@ class SearchView(BaseView):
self._headerbar.props.title = title
self._headerbar.props.subtitle = artist
self.set_visible_child(self._album_widget)
self._headerbar.searchbar.reveal(False)
self._searchbar.reveal(False)
elif self.model[_iter][12] == 'artist':
artist = self.model[_iter][2]
albums = self._artists[artist.casefold()]['albums']
self._artist_albums_widget = ArtistAlbumsWidget(
artist, albums, self.player, self._headerbar,
self._selection_toolbar, self._window, True)
artist, albums, self.player, self._window, True)
self.add(self._artist_albums_widget)
self._artist_albums_widget.show()
self._artist_albums_widget.bind_property(
'selected-items-count', self, 'selected-items-count')
self.bind_property(
'selection-mode', self._artist_albums_widget, 'selection-mode',
GObject.BindingFlags.BIDIRECTIONAL)
self._headerbar.props.state = HeaderBar.State.SEARCH
self._headerbar.props.title = artist
self.set_visible_child(self._artist_albums_widget)
self._headerbar.searchbar.reveal(False)
self._searchbar.reveal(False)
elif self.model[_iter][12] == 'song':
if self.model[_iter][11] != ValidationStatus.FAILED:
c_iter = self._songs_model.convert_child_iter_to_iter(_iter)[1]
......
......@@ -27,7 +27,7 @@ from gi.repository import Gtk
from gnomemusic import log
@Gtk.Template(resource_path='/org/gnome/Music/AboutDialog.ui')
@Gtk.Template(resource_path='/org/gnome/Music/ui/AboutDialog.ui')
class AboutDialog(Gtk.AboutDialog):
"""About dialog"""
......
......@@ -32,7 +32,7 @@ from gnomemusic.albumartcache import Art
from gnomemusic.widgets.twolinetip import TwoLineTip
@Gtk.Template(resource_path='/org/gnome/Music/AlbumCover.ui')
@Gtk.Template(resource_path='/org/gnome/Music/ui/AlbumCover.ui')
class AlbumCover(Gtk.FlowBoxChild):
"""Cover tile as used in AlbumsView
......
......@@ -35,7 +35,7 @@ from gnomemusic.widgets.songwidget import SongWidget
import gnomemusic.utils as utils
@Gtk.Template(resource_path='/org/gnome/Music/AlbumWidget.ui')
@Gtk.Template(resource_path='/org/gnome/Music/ui/AlbumWidget.ui')
class AlbumWidget(Gtk.EventBox):
"""Album widget.
......
......@@ -34,7 +34,7 @@ from gnomemusic.widgets.songwidget import SongWidget
logger = logging.getLogger(__name__)
@Gtk.Template(resource_path='/org/gnome/Music/ArtistAlbumsWidget.ui')
@Gtk.Template(resource_path='/org/gnome/Music/ui/ArtistAlbumsWidget.ui')
class ArtistAlbumsWidget(Gtk.Box):
"""Widget containing all albums by an artist
......@@ -47,6 +47,7 @@ class ArtistAlbumsWidget(Gtk.Box):
_artist_label = Gtk.Template.Child()
selected_items_count = GObject.Property(type=int, default=0, minimum=0)
selection_mode = GObject.Property(type=bool, default=False)
def __repr__(self):
......@@ -54,15 +55,13 @@ class ArtistAlbumsWidget(Gtk.Box):
@log
def __init__(
self, artist, albums, player, headerbar, selection_toolbar,
window, selection_mode_allowed=False):
self, artist, albums, player, window,
selection_mode_allowed=False):
super().__init__(orientation=Gtk.Orientation.VERTICAL)
self._player = player
self._artist = artist
self._window = window
self._selection_mode_allowed = selection_mode_allowed
self._selection_toolbar = selection_toolbar
self._headerbar = headerbar
self._artist_label.props.label = self._artist
......@@ -88,11 +87,6 @@ class ArtistAlbumsWidget(Gtk.Box):
self._songs_grid_size_group = Gtk.SizeGroup.new(
Gtk.SizeGroupMode.HORIZONTAL)
self.bind_property(
'selection-mode', self._headerbar, 'selection-mode',
GObject.BindingFlags.BIDIRECTIONAL |
GObject.BindingFlags.SYNC_CREATE)
self._window.notifications_popup.push_loading()
self._albums_to_load = len(albums)
......@@ -129,9 +123,8 @@ class ArtistAlbumsWidget(Gtk.Box):
@log
def _add_album(self, album):
widget = ArtistAlbumWidget(
album, self._player, self._model, self._headerbar,
self._selection_mode_allowed, self._songs_grid_size_group,
self._cover_size_group)
album, self._player, self._model, self._selection_mode_allowed,
self._songs_grid_size_group, self._cover_size_group)
self.bind_property(
'selection-mode', widget, 'selection-mode',
......@@ -199,8 +192,7 @@ class ArtistAlbumsWidget(Gtk.Box):
if row[6]:
selected_items += 1
self._selection_toolbar.props.selected_items_count = selected_items
self._headerbar.props.selected_items_count = selected_items
self.props.selected_items_count = selected_items
@log
def select_all(self):
......
......@@ -32,7 +32,7 @@ from gnomemusic.widgets.disclistboxwidget import DiscBox
import gnomemusic.utils as utils
@Gtk.Template(resource_path='/org/gnome/Music/ArtistAlbumWidget.ui')
@Gtk.Template(resource_path='/org/gnome/Music/ui/ArtistAlbumWidget.ui')
class ArtistAlbumWidget(Gtk.Box):
__gtype_name__ = 'ArtistAlbumWidget'
......@@ -54,7 +54,7 @@ class ArtistAlbumWidget(Gtk.Box):
@log
def __init__(
self, media, player, model, header_bar, selection_mode_allowed,
self, media, player, model, selection_mode_allowed,
size_group=None, cover_size_group=None):
super().__init__(orientation=Gtk.Orientation.HORIZONTAL)
......@@ -66,7 +66,6 @@ class ArtistAlbumWidget(Gtk.Box):
self._artist = utils.get_artist_name(self._media)
self._album_title = utils.get_album_title(self._media)
self._model = model
self._header_bar = header_bar
self._selection_mode = False
self._selection_mode_allowed = selection_mode_allowed
......
......@@ -82,7 +82,7 @@ class DiscSongsFlowBox(Gtk.FlowBox):
self.props.min_children_per_line = max_per_line
@Gtk.Template(resource_path='/org/gnome/Music/DiscBox.ui')
@Gtk.Template(resource_path='/org/gnome/Music/ui/DiscBox.ui')
class DiscBox(Gtk.Box):
"""A widget which compromises one disc
......
......@@ -28,11 +28,9 @@ from gettext import gettext as _, ngettext
from gi.repository import GObject, Gtk
from gnomemusic import log
from gnomemusic.widgets.searchbar import Searchbar
from gnomemusic.utils import View
@Gtk.Template(resource_path="/org/gnome/Music/SelectionBarMenuButton.ui")
@Gtk.Template(resource_path="/org/gnome/Music/ui/SelectionBarMenuButton.ui")
class SelectionBarMenuButton(Gtk.MenuButton):
"""Button for popup to select all or no items
......@@ -76,7 +74,7 @@ class SelectionBarMenuButton(Gtk.MenuButton):
self._menu_label.props.label = _("Click on items to select them")
@Gtk.Template(resource_path="/org/gnome/Music/HeaderBar.ui")
@Gtk.Template(resource_path="/org/gnome/Music/ui/HeaderBar.ui")
class HeaderBar(Gtk.HeaderBar):
"""Headerbar of the application"""
......@@ -89,11 +87,16 @@ class HeaderBar(Gtk.HeaderBar):
__gtype_name__ = "HeaderBar"
__gsignals__ = {
'back-button-clicked': (GObject.SignalFlags.RUN_FIRST, None, ()),
}
_search_button = Gtk.Template.Child()
_select_button = Gtk.Template.Child()
_cancel_button = Gtk.Template.Child()
_back_button = Gtk.Template.Child()
search_mode_enabled = GObject.Property(type=bool, default=False)
selected_items_count = GObject.Property(type=int, default=0, minimum=0)
selection_mode_allowed = GObject.Property(type=bool, default=True)
stack = GObject.Property(type=Gtk.Stack)
......@@ -111,14 +114,8 @@ class HeaderBar(Gtk.HeaderBar):
can_focus=False, halign="center")
self._stack_switcher.show()
self.searchbar = Searchbar(self._stack_switcher)
self._selection_menu = SelectionBarMenuButton()
self._search_button.bind_property(
"active", self.searchbar, "search-mode-enabled",
GObject.BindingFlags.BIDIRECTIONAL |
GObject.BindingFlags.SYNC_CREATE)
self.bind_property(
"selection-mode", self, "show-close-button",
GObject.BindingFlags.INVERT_BOOLEAN |
......@@ -138,6 +135,10 @@ class HeaderBar(Gtk.HeaderBar):
self.bind_property(
"selected-items-count", self._selection_menu,
"selected-items-count")
self.bind_property(
"search-mode-enabled", self._search_button, "active",
GObject.BindingFlags.BIDIRECTIONAL |
GObject.BindingFlags.SYNC_CREATE)
self.connect(
"notify::selection-mode-allowed",
......@@ -203,26 +204,7 @@ class HeaderBar(Gtk.HeaderBar):
@Gtk.Template.Callback()
@log
def _on_back_button_clicked(self, widget=None):
if self.props.selection_mode:
return
window = self.get_toplevel()
visible_child = window.curr_view.props.visible_child
# FIXME: Stack switch logic should not be here.
view = self._stack_switcher.props.stack.props.visible_child
view._back_button_clicked(view)
current_view = window.curr_view
if not ((current_view == window.views[View.SEARCH]
or current_view == window.views[View.EMPTY])
and visible_child != current_view._grid):
self.props.state = HeaderBar.State.MAIN
else:
self._search_button.props.visible = True
self.searchbar.reveal(False)
self.emit('back-button-clicked')
@Gtk.Template.Callback()
@log
......
......@@ -35,7 +35,7 @@ from gnomemusic.widgets.twolinetip import TwoLineTip
import gnomemusic.utils as utils
@Gtk.Template(resource_path='/org/gnome/Music/PlayerToolbar.ui')
@Gtk.Template(resource_path='/org/gnome/Music/ui/PlayerToolbar.ui')
class PlayerToolbar(Gtk.ActionBar):
"""Main Player widget object
......
......@@ -27,7 +27,7 @@ from gi.repository import Gtk
from gnomemusic import log
@Gtk.Template(resource_path='/org/gnome/Music/PlaylistContextMenu.ui')
@Gtk.Template(resource_path='/org/gnome/Music/ui/PlaylistContextMenu.ui')
class PlaylistContextMenu(Gtk.Popover):
__gtype_name__ = 'PlaylistContextMenu'
......
......@@ -30,7 +30,7 @@ from gnomemusic import log
import gnomemusic.utils as utils
@Gtk.Template(resource_path='/org/gnome/Music/PlaylistControls.ui')
@Gtk.Template(resource_path='/org/gnome/Music/ui/PlaylistControls.ui')
class PlaylistControls(Gtk.Grid):
"""Widget holding the playlist controls"""
......
......@@ -30,7 +30,7 @@ from gnomemusic.playlists import Playlists
import gnomemusic.utils as utils
@Gtk.Template(resource_path="/org/gnome/Music/PlaylistDialog.ui")
@Gtk.Template(resource_path="/org/gnome/Music/ui/PlaylistDialog.ui")
class PlaylistDialog(Gtk.Dialog):
"""Dialog for adding items to a playlist"""
......
......@@ -160,7 +160,7 @@ class SourceManager(BaseManager):
grilo.search_source = src
@Gtk.Template(resource_path="/org/gnome/Music/FilterView.ui")
@Gtk.Template(resource_path="/org/gnome/Music/ui/FilterView.ui")
class FilterView(Gtk.TreeView):
"""TreeView for search entry items
......@@ -254,7 +254,7 @@ class FilterView(Gtk.TreeView):
self.props.manager.entry.emit('changed')
@Gtk.Template(resource_path="/org/gnome/Music/DropDown.ui")
@Gtk.Template(resource_path="/org/gnome/Music/ui/DropDown.ui")
class DropDown(Gtk.Revealer):
"""Dropdown source/option selection widget for search
......@@ -314,7 +314,7 @@ class DropDown(Gtk.Revealer):
return grilo_id == "grl-tracker-source"
@Gtk.Template(resource_path="/org/gnome/Music/Searchbar.ui")
@Gtk.Template(resource_path="/org/gnome/Music/ui/Searchbar.ui")
class Searchbar(Gtk.SearchBar):
"""Widget containing the search entry
"""
......@@ -324,20 +324,17 @@ class Searchbar(Gtk.SearchBar):
_search_entry = Gtk.Template.Child()
_drop_down_button = Gtk.Template.Child()
stack = GObject.Property(type=Gtk.Stack)
def __repr__(self):
return '<Searchbar>'
@log
def __init__(self, stack_switcher):
"""Initialize the Searchbar
:param Gtk.Stack stack_switcher: The stack switcher containing
the search view.
"""
def __init__(self):
"""Initialize the Searchbar"""
super().__init__()
self._timeout = None
self._stack_switcher = stack_switcher
self._dropdown = DropDown()
self._dropdown.initialize_filters(self)
......@@ -371,10 +368,9 @@ class Searchbar(Gtk.SearchBar):
else:
fields_filter = 'search_all'
stack = self._stack_switcher.props.stack
if search_term != "":
stack.set_visible_child_name('search')
view = stack.get_visible_child()
self.props.stack.set_visible_child_name('search')
view = self.props.stack.get_visible_child()
view.set_search_text(search_term, fields_filter)
self._drop_down_button.set_active(False)
......
......@@ -27,7 +27,7 @@ from gi.repository import GObject, Gtk
from gnomemusic import log
@Gtk.Template(resource_path='/org/gnome/Music/SelectionToolbar.ui')
@Gtk.Template(resource_path='/org/gnome/Music/ui/SelectionToolbar.ui')
class SelectionToolbar(Gtk.ActionBar):
__gtype_name__ = 'SelectionToolbar'
......
......@@ -27,7 +27,7 @@ from gi.repository import GObject, Gtk
from gnomemusic import log
@Gtk.Template(resource_path='/org/gnome/Music/SidebarRow.ui')
@Gtk.Template(resource_path='/org/gnome/Music/ui/SidebarRow.ui')
class SidebarRow(Gtk.ListBoxRow):
"""Row for sidebars
......
......@@ -36,7 +36,7 @@ from gnomemusic.playlists import Playlists, StaticPlaylists
from gnomemusic.widgets.starimage import StarImage # noqa: F401
@Gtk.Template(resource_path='/org/gnome/Music/SongWidget.ui')
@Gtk.Template(resource_path='/org/gnome/Music/ui/SongWidget.ui')
class SongWidget(Gtk.EventBox):
"""The single song widget used in DiscListBox
......
......@@ -27,7 +27,7 @@ from gi.repository import GObject, Gtk
from gnomemusic import log
@Gtk.Template(resource_path='/org/gnome/Music/TwoLineTip.ui')
@Gtk.Template(resource_path='/org/gnome/Music/ui/TwoLineTip.ui')
class TwoLineTip(Gtk.Box):
"""Tooltip with two lines of text
......
......@@ -47,6 +47,7 @@ from gnomemusic.widgets.headerbar import HeaderBar
from gnomemusic.widgets.notificationspopup import NotificationsPopup
from gnomemusic.widgets.playertoolbar import PlayerToolbar
from gnomemusic.widgets.playlistdialog import PlaylistDialog
from gnomemusic.widgets.searchbar import Searchbar
from gnomemusic.widgets.selectiontoolbar import SelectionToolbar
from gnomemusic.playlists import Playlists
from gnomemusic.grilo import grilo
......@@ -153,6 +154,7 @@ class Window(Gtk.ApplicationWindow):
def _setup_view(self):
self._box = Gtk.Box(orientation=Gtk.Orientation.VERTICAL)
self._headerbar = HeaderBar()
self._searchbar = Searchbar()
self.player = Player(self)
self.player_toolbar = PlayerToolbar(self.player, self)
self.selection_toolbar = SelectionToolbar()
......@@ -164,6 +166,14 @@ class Window(Gtk.ApplicationWindow):
visible=True,
can_focus=False)
self._headerbar.bind_property(
"search-mode-enabled", self._searchbar, "search-mode-enabled",
GObject.BindingFlags.BIDIRECTIONAL |
GObject.BindingFlags.SYNC_CREATE)
self._searchbar.props.stack = self._stack
self._headerbar.connect(
'back-button-clicked', self._switch_back_from_childview)
self.connect('notify::selection-mode', self._on_selection_mode_changed)
self.bind_property(
'selected-items-count', self._headerbar, 'selected-items-count')
......@@ -191,9 +201,9 @@ class Window(Gtk.ApplicationWindow):
self._overlay = Gtk.Overlay()
self._overlay.add(self._stack)
# FIXME: Need to find a proper way to do this.
self._overlay.add_overlay(self._headerbar.searchbar._dropdown)
self._overlay.add_overlay(self._searchbar._dropdown)
self.set_titlebar(self._headerbar)
self._box.pack_start(self._headerbar.searchbar, False, False, 0)
self._box.pack_start(self._searchbar, False, False, 0)
self._box.pack_start(self._overlay, True, True, 0)
self._box.pack_start(self.player_toolbar, False, False, 0)
self._box.pack_start(self.selection_toolbar, False, False, 0)
......@@ -261,7 +271,7 @@ class Window(Gtk.ApplicationWindow):
self.views[View.EMPTY].props.state = EmptyView.State.SEARCH
self._headerbar.props.state = HeaderBar.State.MAIN
self._headerbar.props.stack = self._stack
self._headerbar.searchbar.show()
self._searchbar.show()
self.views[View.ALBUM] = AlbumsView(self, self.player)
self.views[View.ARTIST] = ArtistsView(self, self.player)
......@@ -326,7 +336,7 @@ class Window(Gtk.ApplicationWindow):
if (keyval == Gdk.KEY_f
and not self.views[View.PLAYLIST].rename_active
and self._headerbar.props.state != HeaderBar.State.SEARCH):
self._headerbar.searchbar.toggle()
self._searchbar.toggle()
# Play / Pause on Ctrl + SPACE
if keyval == Gdk.KEY_space:
self.player.play_pause()
......@@ -354,9 +364,9 @@ class Window(Gtk.ApplicationWindow):
self._select_none()
# Alt+<KEY>
elif modifiers == mod1_mask:
# Go back from Album view on Alt + Left
# Go back from child view on Alt + Left
if keyval == Gdk.KEY_Left:
self._headerbar._on_back_button_clicked()
self._switch_back_from_childview()
# Headerbar switching
if keyval in [Gdk.KEY_1, Gdk.KEY_KP_1]:
self._toggle_view(View.ALBUM)
......@@ -390,18 +400,18 @@ class Window(Gtk.ApplicationWindow):
if self.props.selection_mode:
self.props.selection_mode = False
else:
self._headerbar.searchbar.reveal(False)
self._searchbar.reveal(False)
# Open the search bar when typing printable chars.
key_unic = Gdk.keyval_to_unicode(keyval)
if ((not self._headerbar.searchbar.get_search_mode()
if ((not self._searchbar.get_search_mode()
and not keyval == Gdk.KEY_space)
and GLib.unichar_isprint(chr(key_unic))
and (modifiers == shift_mask
or modifiers == 0)
and not self.views[View.PLAYLIST].rename_active
and self._headerbar.props.state != HeaderBar.State.SEARCH):
self._headerbar.searchbar.reveal(True)
self._searchbar.reveal(True)
@log
def do_button_release_event(self, event):
......@@ -412,7 +422,7 @@ class Window(Gtk.ApplicationWindow):
__, code = event.get_button()
# Mouse button 8 is the navigation button
if code == 8:
self._headerbar._on_back_button_clicked()
self._switch_back_from_childview()
@log
def _notify_mode_disconnect(self, data=None):
......@@ -433,7 +443,7 @@ class Window(Gtk.ApplicationWindow):
if (self.curr_view != self.views[View.SEARCH]
and self.curr_view != self.views[View.EMPTY]):
self._headerbar.searchbar.reveal(False)
self._searchbar.reveal(False)
# Disable the selection button for the EmptySearch and Playlist
# view
......@@ -463,7 +473,7 @@ class Window(Gtk.ApplicationWindow):
@log
def _on_search_toggled(self, button, data=None):
self._headerbar.searchbar.reveal(
self._searchbar.reveal(
button.get_active(), self.curr_view != self.views[View.SEARCH])
if (not button.get_active()
and (self.curr_view == self.views[View.SEARCH]
......@@ -481,6 +491,21 @@ class Window(Gtk.ApplicationWindow):
if self.props.selection_mode:
self.props.selection_mode = False
@log
def _switch_back_from_childview(self, klass=None):
if self.props.selection_mode:
return
views_with_child = [
self.views[View.ALBUM],
self.views[View.SEARCH]
]
if self.curr_view in views_with_child:
self.curr_view._back_button_clicked(self.curr_view)
if self.curr_view != self.views[View.SEARCH]:
self._searchbar.reveal(False)
@log
def _on_selection_mode_changed(self, widget, data=None):
if self.props.selection_mode:
......
......@@ -54,6 +54,7 @@ subproject('libgd',
'pkglibdir=' + PKGLIB_DIR
])
subdir('data/ui')
subdir('data')
subdir('help')
subdir('po')
......
......@@ -30,14 +30,14 @@ gnomemusic/widgets/playlistdialog.py
gnomemusic/widgets/searchbar.py
gnomemusic/widgets/starhandlerwidget.py
gnomemusic/window.py
data/AboutDialog.ui.in
data/AlbumWidget.ui
data/app-menu.ui
data/HeaderBar.ui
data/help-overlay.ui
data/PlayerToolbar.ui
data/PlaylistContextMenu.ui
data/PlaylistControls.ui
data/PlaylistDialog.ui
data/SelectionBarMenuButton.ui
data/SelectionToolbar.ui
data/ui/AboutDialog.ui.in
data/ui/AlbumWidget.ui
data/ui/app-menu.ui
data/ui/HeaderBar.ui
data/ui/help-overlay.ui
data/ui/PlayerToolbar.ui
data/ui/PlaylistContextMenu.ui
data/ui/PlaylistControls.ui
data/ui/PlaylistDialog.ui
data/ui/SelectionBarMenuButton.ui
data/ui/SelectionToolbar.ui