add text alignment options - issue #340
Esse commit está contido em:
@@ -172,7 +172,8 @@ class GSetting:
|
||||
LAST_GENRE_FOLDER='last-genre-folder',
|
||||
ENTRY_VIEW_MODE='entry-view-mode',
|
||||
FOLLOWING='following',
|
||||
ACTIVATIONS='activations')
|
||||
ACTIVATIONS='activations',
|
||||
TEXT_ALIGNMENT='text-alignment')
|
||||
|
||||
self.setting = {}
|
||||
|
||||
@@ -526,6 +527,18 @@ class Preferences(GObject.Object, PeasGtk.Configurable):
|
||||
else:
|
||||
self.black_radiobutton.set_active(True)
|
||||
|
||||
self.text_alignment = self.settings[gs.PluginKey.TEXT_ALIGNMENT]
|
||||
self.text_alignment_left_radiobutton = builder.get_object('left_alignment_radiobutton')
|
||||
self.text_alignment_centre_radiobutton = builder.get_object('centre_alignment_radiobutton')
|
||||
self.text_alignment_right_radiobutton = builder.get_object('right_alignment_radiobutton')
|
||||
|
||||
if self.text_alignment == 0:
|
||||
self.text_alignment_left_radiobutton.set_active(True)
|
||||
elif self.text_alignment == 1:
|
||||
self.text_alignment_centre_radiobutton.set_active(True)
|
||||
else:
|
||||
self.text_alignment_right_radiobutton.set_active(True)
|
||||
|
||||
# return the dialog
|
||||
self._first_run = False
|
||||
print ("end create dialog contents")
|
||||
@@ -586,6 +599,19 @@ class Preferences(GObject.Object, PeasGtk.Configurable):
|
||||
self.settings[gs.PluginKey.DISPLAY_TEXT_POS] = False
|
||||
self.settings[gs.PluginKey.ADD_SHADOW] = False
|
||||
|
||||
def on_text_alignment_radiobutton_toggled(self, button):
|
||||
if self._first_run:
|
||||
return
|
||||
|
||||
if button.get_active():
|
||||
gs = GSetting()
|
||||
if button == self.text_alignment_left_radiobutton:
|
||||
self.settings[gs.PluginKey.TEXT_ALIGNMENT] = 0
|
||||
elif button == self.text_alignment_centre_radiobutton:
|
||||
self.settings[gs.PluginKey.TEXT_ALIGNMENT] = 1
|
||||
else:
|
||||
self.settings[gs.PluginKey.TEXT_ALIGNMENT] = 2
|
||||
|
||||
def on_add_shadow_checkbox_toggled(self, button):
|
||||
if button.get_active():
|
||||
#gs = GSetting()
|
||||
|
||||
@@ -88,7 +88,7 @@ class CellRendererThumb(Gtk.CellRendererPixbuf):
|
||||
layout_width = cell_area.width - 2
|
||||
pango_layout = PangoCairo.create_layout(cr)
|
||||
pango_layout.set_markup(self.markup, -1)
|
||||
pango_layout.set_alignment(Pango.Alignment.CENTER)
|
||||
pango_layout.set_alignment(self.cell_area_source.text_alignment)
|
||||
pango_layout.set_font_description(self.font_description)
|
||||
pango_layout.set_width(int(layout_width * Pango.SCALE))
|
||||
pango_layout.set_wrap(Pango.WrapMode.WORD_CHAR)
|
||||
@@ -129,6 +129,7 @@ class AlbumArtCellArea(Gtk.CellAreaBox):
|
||||
display_text = GObject.property(type=bool, default=False)
|
||||
add_shadow = GObject.property(type=bool, default=False)
|
||||
hover_pixbuf = GObject.property(type=object, default=None)
|
||||
text_alignment = GObject.property(type=int, default=1)
|
||||
|
||||
def __init__(self, ):
|
||||
super(AlbumArtCellArea, self).__init__()
|
||||
@@ -163,6 +164,10 @@ class AlbumArtCellArea(Gtk.CellAreaBox):
|
||||
setting.bind(gs.PluginKey.ADD_SHADOW, self, 'add-shadow',
|
||||
Gio.SettingsBindFlags.GET)
|
||||
|
||||
setting.bind(gs.PluginKey.TEXT_ALIGNMENT, self, 'text-alignment',
|
||||
Gio.SettingsBindFlags.GET)
|
||||
|
||||
|
||||
def calc_play_icon_offset(self, initial_x_offset, initial_y_offset):
|
||||
'''
|
||||
calculates the x & y offset for the play hover icon
|
||||
@@ -254,6 +259,7 @@ class CoverIconView(EnhancedIconView, AbstractView):
|
||||
display_text_pos = GObject.property(type=bool, default=False)
|
||||
name = 'coverview'
|
||||
panedposition = PanedCollapsible.Paned.COLLAPSE
|
||||
text_alignment = GObject.property(type=int, default=1)
|
||||
|
||||
__gsignals__ = {
|
||||
'update-toolbar': (GObject.SIGNAL_RUN_LAST, None, ())
|
||||
@@ -360,6 +366,9 @@ class CoverIconView(EnhancedIconView, AbstractView):
|
||||
setting.bind(self.gs.PluginKey.DISPLAY_TEXT_POS, self,
|
||||
'display-text-pos', Gio.SettingsBindFlags.GET)
|
||||
|
||||
setting.bind(self.gs.PluginKey.TEXT_ALIGNMENT, self,
|
||||
'text-alignment', Gio.SettingsBindFlags.GET)
|
||||
|
||||
def _connect_signals(self):
|
||||
self.connect("item-clicked", self.item_clicked_callback)
|
||||
self.connect("selection-changed", self.selectionchanged_callback)
|
||||
@@ -372,6 +381,8 @@ class CoverIconView(EnhancedIconView, AbstractView):
|
||||
self._activate_markup)
|
||||
self.connect('notify::display-text-pos',
|
||||
self._activate_markup)
|
||||
self.connect('notify::text-alignment',
|
||||
self._create_and_configure_renderer)
|
||||
self.connect("motion-notify-event", self.on_pointer_motion)
|
||||
|
||||
def get_view_icon_name(self):
|
||||
@@ -655,13 +666,20 @@ class CoverIconView(EnhancedIconView, AbstractView):
|
||||
self.set_row_spacing(self.icon_spacing)
|
||||
self.set_column_spacing(self.icon_spacing)
|
||||
|
||||
def _create_and_configure_renderer(self):
|
||||
# Add own cellrenderer
|
||||
self._text_renderer = Gtk.CellRendererText()
|
||||
def _create_and_configure_renderer(self, *args):
|
||||
if not self._text_renderer:
|
||||
# Add own cellrenderer
|
||||
self._text_renderer = Gtk.CellRendererText()
|
||||
|
||||
self._text_renderer.props.alignment = Pango.Alignment.CENTER
|
||||
self._text_renderer.props.alignment = self.text_alignment
|
||||
self._text_renderer.props.wrap_mode = Pango.WrapMode.WORD
|
||||
self._text_renderer.props.xalign = 0.5
|
||||
if self.text_alignment == 1:
|
||||
self._text_renderer.props.xalign = 0.5
|
||||
elif self.text_alignment == 0:
|
||||
self._text_renderer.props.xalign = 0
|
||||
else:
|
||||
self._text_renderer.props.xalign = 1
|
||||
|
||||
self._text_renderer.props.yalign = 0
|
||||
self._text_renderer.props.width = \
|
||||
self.album_manager.cover_man.cover_size
|
||||
|
||||
@@ -226,5 +226,10 @@
|
||||
<summary>number of times the plugin has been activated</summary>
|
||||
<description>number of times the plugin has been activated</description>
|
||||
</key>
|
||||
<key type="i" name="text-alignment">
|
||||
<default>1</default>
|
||||
<summary>alignment of coverart info</summary>
|
||||
<description>Pango Alignment value</description>
|
||||
</key>
|
||||
</schema>
|
||||
</schemalist>
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!-- Generated with glade 3.16.1 -->
|
||||
<interface>
|
||||
<requires lib="gtk+" version="3.0"/>
|
||||
<requires lib="gtk+" version="3.10"/>
|
||||
<object class="GtkImage" id="add_image">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
@@ -689,6 +689,78 @@ albums to play</property>
|
||||
<property name="position">4</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkBox" id="box13">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="halign">center</property>
|
||||
<child>
|
||||
<object class="GtkRadioButton" id="left_alignment_radiobutton">
|
||||
<property name="label">gtk-justify-left</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="receives_default">False</property>
|
||||
<property name="use_stock">True</property>
|
||||
<property name="xalign">0</property>
|
||||
<property name="image_position">top</property>
|
||||
<property name="always_show_image">True</property>
|
||||
<property name="draw_indicator">False</property>
|
||||
<signal name="toggled" handler="on_text_alignment_radiobutton_toggled" swapped="no"/>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">0</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkRadioButton" id="centre_alignment_radiobutton">
|
||||
<property name="label">gtk-justify-center</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="receives_default">False</property>
|
||||
<property name="use_stock">True</property>
|
||||
<property name="xalign">0</property>
|
||||
<property name="image_position">top</property>
|
||||
<property name="always_show_image">True</property>
|
||||
<property name="active">True</property>
|
||||
<property name="draw_indicator">False</property>
|
||||
<property name="group">left_alignment_radiobutton</property>
|
||||
<signal name="toggled" handler="on_text_alignment_radiobutton_toggled" swapped="no"/>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">1</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkRadioButton" id="right_alignment_radiobutton">
|
||||
<property name="label">gtk-justify-right</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="receives_default">False</property>
|
||||
<property name="use_stock">True</property>
|
||||
<property name="xalign">0</property>
|
||||
<property name="image_position">top</property>
|
||||
<property name="always_show_image">True</property>
|
||||
<property name="draw_indicator">False</property>
|
||||
<property name="group">left_alignment_radiobutton</property>
|
||||
<signal name="toggled" handler="on_text_alignment_radiobutton_toggled" swapped="no"/>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">2</property>
|
||||
</packing>
|
||||
</child>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">5</property>
|
||||
</packing>
|
||||
</child>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
@@ -985,6 +1057,11 @@ albums to play</property>
|
||||
</packing>
|
||||
</child>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">9</property>
|
||||
</packing>
|
||||
</child>
|
||||
</object>
|
||||
<packing>
|
||||
|
||||
Referência em uma Nova Issue
Bloquear um usuário