add picture icons to track-view and play-source to allow switching between views - issue #318
Esse commit está contido em:
@@ -132,7 +132,7 @@ class CoverArtBrowserPlugin(GObject.Object, Peas.Activatable):
|
||||
|
||||
if setting[gs.PluginKey.AUTOSTART]:
|
||||
GLib.idle_add(self.shell.props.display_page_tree.select,
|
||||
self.source)
|
||||
self.playlist_source)
|
||||
|
||||
def _translation_helper(self):
|
||||
'''
|
||||
|
||||
+55
-13
@@ -40,6 +40,7 @@ from coverart_external_plugins import ExternalPlugin
|
||||
from stars import ReactiveStar
|
||||
from coverart_search import CoverSearchPane
|
||||
from coverart_widgets import PixbufButton
|
||||
from coverart_widgets import PressButton
|
||||
from coverart_window import CoverWindow
|
||||
|
||||
MIN_IMAGE_SIZE = 100
|
||||
@@ -92,7 +93,17 @@ class EntryViewPane(object):
|
||||
self.entry_view_grid.attach(self.stars, 1, 1, 1, 1)
|
||||
stack_switcher = Gtk.StackSwitcher()
|
||||
stack_switcher.set_stack(self.stack)
|
||||
self.entry_view_grid.attach(stack_switcher, 0, 1, 1, 1)
|
||||
|
||||
whatsplayingbutton = PressButton()
|
||||
whatsplayingbutton.set_image(create_button_image(self.plugin, "whatsplaying.png"))
|
||||
whatsplayingbutton.connect('clicked', self.whatsplayingbutton_callback)
|
||||
whatsplayingbutton.props.halign = Gtk.Align.START
|
||||
|
||||
leftgrid = Gtk.Grid()
|
||||
leftgrid.attach(whatsplayingbutton, 0, 0, 1, 1)
|
||||
leftgrid.attach(stack_switcher, 1, 0, 1, 1)
|
||||
self.entry_view_grid.attach(leftgrid, 0, 1, 1, 1)
|
||||
|
||||
viewtoggle = PixbufButton()
|
||||
viewtoggle.set_image(create_button_image(self.plugin, "entryview.png"))
|
||||
self.viewtoggle_id = None
|
||||
@@ -112,14 +123,9 @@ class EntryViewPane(object):
|
||||
self.smallwindowext.appendattribute('action_name', 'SmallWindow')
|
||||
self.smallwindowext.appendattribute('action_type', 'app')
|
||||
|
||||
whatsplayingtoggle = PixbufButton()
|
||||
whatsplayingtoggle.set_image(create_button_image(self.plugin, "whatsplaying.png"))
|
||||
whatsplayingtoggle.connect('toggled', self.whatsplayingtoggle_callback)
|
||||
|
||||
rightgrid = Gtk.Grid()
|
||||
rightgrid.props.halign = Gtk.Align.END
|
||||
|
||||
# rightgrid.attach(whatsplayingtoggle, 0, 0, 1, 1)
|
||||
rightgrid.attach(viewtoggle, 1, 0, 1, 1)
|
||||
rightgrid.attach(smallwindowbutton, 2, 0, 1, 1)
|
||||
|
||||
@@ -130,9 +136,8 @@ class EntryViewPane(object):
|
||||
self.entry_view_grid.show_all()
|
||||
smallwindowbutton.set_visible(self.smallwindowext.is_activated())
|
||||
|
||||
def whatsplayingtoggle_callback(self, widget):
|
||||
self.entry_view_results.emit('whats-playing', widget.get_active())
|
||||
|
||||
def whatsplayingbutton_callback(self, widget):
|
||||
self.entry_view_results.emit('whats-playing')
|
||||
|
||||
def smallwindowbutton_callback(self, widget):
|
||||
if widget.get_active():
|
||||
@@ -276,7 +281,7 @@ class ResultsGrid(Gtk.Grid):
|
||||
# signals
|
||||
__gsignals__ = {
|
||||
'update-cover': (GObject.SIGNAL_RUN_LAST, None, (GObject.Object, RB.RhythmDBEntry)),
|
||||
'whats-playing': (GObject.SIGNAL_RUN_LAST, None, (bool,))
|
||||
'whats-playing': (GObject.SIGNAL_RUN_LAST, None, ())
|
||||
}
|
||||
image_width = 0
|
||||
|
||||
@@ -442,10 +447,47 @@ class ResultsGrid(Gtk.Grid):
|
||||
else:
|
||||
self.image2.queue_draw()
|
||||
|
||||
def display_whats_playing(self, show_playing):
|
||||
view = self.get_child_at(0, 0)
|
||||
def display_whats_playing(self, *args):
|
||||
'''
|
||||
switch to the coverart_play_source
|
||||
|
||||
view.display_playing_tracks(show_playing)
|
||||
to do this we need to first expand the source tree to allow the select method to work
|
||||
|
||||
Unfortunately, rhythmbox api does not allow us to do this directly - there is only a toggle
|
||||
method. Also - no direct access to the source tree-view.
|
||||
|
||||
Use a trick from alternative-toolbar to search for objects beneath other objects i.e.
|
||||
tree-view is below the model
|
||||
|
||||
'''
|
||||
|
||||
def find(node, search_id, search_type):
|
||||
if isinstance(node, Gtk.Buildable):
|
||||
if search_type == 'by_id':
|
||||
if Gtk.Buildable.get_name(node) == search_id:
|
||||
return node
|
||||
elif search_type == 'by_name':
|
||||
if node.get_name() == search_id:
|
||||
return node
|
||||
|
||||
if isinstance(node, Gtk.Container):
|
||||
for child in node.get_children():
|
||||
ret = find(child, search_id, search_type)
|
||||
if ret:
|
||||
return ret
|
||||
return None
|
||||
|
||||
tree_view = find(self.source.shell.props.display_page_tree, "GtkTreeView", "by_name")
|
||||
print (tree_view)
|
||||
|
||||
iter = Gtk.TreeIter()
|
||||
self.source.shell.props.display_page_tree.props.model.find_page(self.source, iter)
|
||||
path = self.source.shell.props.display_page_tree.props.model.get_path(iter)
|
||||
|
||||
if not tree_view.row_expanded(path):
|
||||
tree_view.expand_row(path, False)
|
||||
|
||||
GLib.idle_add( self.source.shell.props.display_page_tree.select, self.source.playlist_source)
|
||||
|
||||
def window_resize(self, widget):
|
||||
alloc = self.get_allocation()
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
from gi.repository import Gtk
|
||||
from gi.repository import RB
|
||||
from gi.repository import GObject
|
||||
from gi.repository import GLib
|
||||
|
||||
from coverart_rb3compat import Menu
|
||||
from coverart_external_plugins import CreateExternalPluginMenu
|
||||
@@ -28,6 +29,9 @@ from coverart_entryview import CoverArtEntryView
|
||||
from coverart_rb3compat import ActionGroup
|
||||
from coverart_rb3compat import ApplicationShell
|
||||
from coverart_browser_prefs import CoverLocale
|
||||
from coverart_widgets import PressButton
|
||||
from coverart_utils import create_button_image
|
||||
|
||||
import rb
|
||||
|
||||
|
||||
@@ -141,7 +145,7 @@ class CoverArtPlaySource(RB.Source):
|
||||
self.entryview.props.hexpand = True
|
||||
self.entryview.props.vexpand = True
|
||||
grid = Gtk.Grid()
|
||||
grid.attach(self.entryview, 0, 1, 1, 1)
|
||||
grid.attach(self.entryview, 0, 1, 3, 1)
|
||||
|
||||
self.entryview.set_model(self.source.source_query_model)
|
||||
|
||||
@@ -160,7 +164,14 @@ class CoverArtPlaySource(RB.Source):
|
||||
app = self.shell.props.application
|
||||
app.link_shared_menus(toolbar_menu)
|
||||
bar = RB.ButtonBar.new(toolbar_menu, toolbar_menu)
|
||||
grid.attach(bar, 0, 0, 1, 1)
|
||||
bar.props.hexpand_set = False
|
||||
grid.attach(bar, 1, 0, 1, 1)
|
||||
|
||||
coverartbutton = PressButton()
|
||||
coverartbutton.props.halign = Gtk.Align.START
|
||||
coverartbutton.set_image(create_button_image(self.plugin, "covermgr_std.png"))
|
||||
coverartbutton.connect('clicked', self.coverartbutton_callback)
|
||||
grid.attach(coverartbutton, 0, 0, 1, 1)
|
||||
|
||||
grid.show_all()
|
||||
self.pack_start(grid, True, True, 0)
|
||||
@@ -175,6 +186,10 @@ class CoverArtPlaySource(RB.Source):
|
||||
action_type='app')
|
||||
appshell.insert_action_group(action_group)
|
||||
|
||||
def coverartbutton_callback(self, *args):
|
||||
GLib.idle_add( self.source.shell.props.display_page_tree.select, self.source)
|
||||
|
||||
|
||||
def clear_playsource(self, *args):
|
||||
for row in self.entryview.props.model:
|
||||
self.entryview.props.model.remove_entry(row[0])
|
||||
|
||||
@@ -213,6 +213,61 @@ class OptionsPopupWidget(OptionsWidget):
|
||||
self.clear_popupmenu()
|
||||
del self._popupmenu
|
||||
|
||||
class PressButton(Gtk.Button):
|
||||
button_relief = GObject.property(type=bool, default=False)
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
super(PressButton, self).__init__(*args, **kwargs)
|
||||
|
||||
gs = GSetting()
|
||||
setting = gs.get_setting(gs.Path.PLUGIN)
|
||||
setting.bind(gs.PluginKey.BUTTON_RELIEF, self,
|
||||
'button_relief', Gio.SettingsBindFlags.GET)
|
||||
|
||||
self.connect('notify::button-relief',
|
||||
self.on_notify_button_relief)
|
||||
|
||||
def on_notify_button_relief(self, *arg):
|
||||
if self.button_relief:
|
||||
self.set_relief(Gtk.ReliefStyle.NONE)
|
||||
else:
|
||||
self.set_relief(Gtk.ReliefStyle.HALF)
|
||||
|
||||
def set_image(self, pixbuf):
|
||||
image = self.get_image()
|
||||
|
||||
if not image:
|
||||
image = Gtk.Image()
|
||||
super(PressButton, self).set_image(image)
|
||||
|
||||
if hasattr(self, "controller.enabled") and not self.controller.enabled:
|
||||
pixbuf = self._getBlendedPixbuf(pixbuf)
|
||||
|
||||
self.get_image().set_from_pixbuf(pixbuf)
|
||||
|
||||
self.on_notify_button_relief()
|
||||
|
||||
def _getBlendedPixbuf(self, pixbuf):
|
||||
"""Turn a pixbuf into a blended version of the pixbuf by drawing a
|
||||
transparent alpha blend on it."""
|
||||
pixbuf = pixbuf.copy()
|
||||
|
||||
w, h = pixbuf.get_width(), pixbuf.get_height()
|
||||
surface = cairo.ImageSurface(
|
||||
cairo.FORMAT_ARGB32, pixbuf.get_width(), pixbuf.get_height())
|
||||
context = cairo.Context(surface)
|
||||
|
||||
Gdk.cairo_set_source_pixbuf(context, pixbuf, 0, 0)
|
||||
context.paint()
|
||||
|
||||
context.set_source_rgba(32, 32, 32, 0.4)
|
||||
context.set_line_width(0)
|
||||
context.rectangle(0, 0, w, h)
|
||||
context.fill()
|
||||
|
||||
pixbuf = Gdk.pixbuf_get_from_surface(surface, 0, 0, w, h)
|
||||
|
||||
return pixbuf
|
||||
|
||||
class EnhancedButton(Gtk.ToggleButton):
|
||||
button_relief = GObject.property(type=bool, default=False)
|
||||
|
||||
Referência em uma Nova Issue
Bloquear um usuário