add text alignment options - issue #340

Esse commit está contido em:
fossfreedom
2014-11-23 00:09:59 +00:00
commit a51329e0dd
4 arquivos alterados com 134 adições e 8 exclusões
+27 -1
Ver Arquivo
@@ -172,7 +172,8 @@ class GSetting:
LAST_GENRE_FOLDER='last-genre-folder', LAST_GENRE_FOLDER='last-genre-folder',
ENTRY_VIEW_MODE='entry-view-mode', ENTRY_VIEW_MODE='entry-view-mode',
FOLLOWING='following', FOLLOWING='following',
ACTIVATIONS='activations') ACTIVATIONS='activations',
TEXT_ALIGNMENT='text-alignment')
self.setting = {} self.setting = {}
@@ -526,6 +527,18 @@ class Preferences(GObject.Object, PeasGtk.Configurable):
else: else:
self.black_radiobutton.set_active(True) 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 # return the dialog
self._first_run = False self._first_run = False
print ("end create dialog contents") 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.DISPLAY_TEXT_POS] = False
self.settings[gs.PluginKey.ADD_SHADOW] = 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): def on_add_shadow_checkbox_toggled(self, button):
if button.get_active(): if button.get_active():
#gs = GSetting() #gs = GSetting()
+24 -6
Ver Arquivo
@@ -88,7 +88,7 @@ class CellRendererThumb(Gtk.CellRendererPixbuf):
layout_width = cell_area.width - 2 layout_width = cell_area.width - 2
pango_layout = PangoCairo.create_layout(cr) pango_layout = PangoCairo.create_layout(cr)
pango_layout.set_markup(self.markup, -1) 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_font_description(self.font_description)
pango_layout.set_width(int(layout_width * Pango.SCALE)) pango_layout.set_width(int(layout_width * Pango.SCALE))
pango_layout.set_wrap(Pango.WrapMode.WORD_CHAR) pango_layout.set_wrap(Pango.WrapMode.WORD_CHAR)
@@ -129,6 +129,7 @@ class AlbumArtCellArea(Gtk.CellAreaBox):
display_text = GObject.property(type=bool, default=False) display_text = GObject.property(type=bool, default=False)
add_shadow = GObject.property(type=bool, default=False) add_shadow = GObject.property(type=bool, default=False)
hover_pixbuf = GObject.property(type=object, default=None) hover_pixbuf = GObject.property(type=object, default=None)
text_alignment = GObject.property(type=int, default=1)
def __init__(self, ): def __init__(self, ):
super(AlbumArtCellArea, self).__init__() super(AlbumArtCellArea, self).__init__()
@@ -163,6 +164,10 @@ class AlbumArtCellArea(Gtk.CellAreaBox):
setting.bind(gs.PluginKey.ADD_SHADOW, self, 'add-shadow', setting.bind(gs.PluginKey.ADD_SHADOW, self, 'add-shadow',
Gio.SettingsBindFlags.GET) 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): def calc_play_icon_offset(self, initial_x_offset, initial_y_offset):
''' '''
calculates the x & y offset for the play hover icon 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) display_text_pos = GObject.property(type=bool, default=False)
name = 'coverview' name = 'coverview'
panedposition = PanedCollapsible.Paned.COLLAPSE panedposition = PanedCollapsible.Paned.COLLAPSE
text_alignment = GObject.property(type=int, default=1)
__gsignals__ = { __gsignals__ = {
'update-toolbar': (GObject.SIGNAL_RUN_LAST, None, ()) 'update-toolbar': (GObject.SIGNAL_RUN_LAST, None, ())
@@ -360,6 +366,9 @@ class CoverIconView(EnhancedIconView, AbstractView):
setting.bind(self.gs.PluginKey.DISPLAY_TEXT_POS, self, setting.bind(self.gs.PluginKey.DISPLAY_TEXT_POS, self,
'display-text-pos', Gio.SettingsBindFlags.GET) 'display-text-pos', Gio.SettingsBindFlags.GET)
setting.bind(self.gs.PluginKey.TEXT_ALIGNMENT, self,
'text-alignment', Gio.SettingsBindFlags.GET)
def _connect_signals(self): def _connect_signals(self):
self.connect("item-clicked", self.item_clicked_callback) self.connect("item-clicked", self.item_clicked_callback)
self.connect("selection-changed", self.selectionchanged_callback) self.connect("selection-changed", self.selectionchanged_callback)
@@ -372,6 +381,8 @@ class CoverIconView(EnhancedIconView, AbstractView):
self._activate_markup) self._activate_markup)
self.connect('notify::display-text-pos', self.connect('notify::display-text-pos',
self._activate_markup) self._activate_markup)
self.connect('notify::text-alignment',
self._create_and_configure_renderer)
self.connect("motion-notify-event", self.on_pointer_motion) self.connect("motion-notify-event", self.on_pointer_motion)
def get_view_icon_name(self): def get_view_icon_name(self):
@@ -655,13 +666,20 @@ class CoverIconView(EnhancedIconView, AbstractView):
self.set_row_spacing(self.icon_spacing) self.set_row_spacing(self.icon_spacing)
self.set_column_spacing(self.icon_spacing) self.set_column_spacing(self.icon_spacing)
def _create_and_configure_renderer(self): def _create_and_configure_renderer(self, *args):
# Add own cellrenderer if not self._text_renderer:
self._text_renderer = Gtk.CellRendererText() # 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.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.yalign = 0
self._text_renderer.props.width = \ self._text_renderer.props.width = \
self.album_manager.cover_man.cover_size self.album_manager.cover_man.cover_size
@@ -226,5 +226,10 @@
<summary>number of times the plugin has been activated</summary> <summary>number of times the plugin has been activated</summary>
<description>number of times the plugin has been activated</description> <description>number of times the plugin has been activated</description>
</key> </key>
<key type="i" name="text-alignment">
<default>1</default>
<summary>alignment of coverart info</summary>
<description>Pango Alignment value</description>
</key>
</schema> </schema>
</schemalist> </schemalist>
+78 -1
Ver Arquivo
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<!-- Generated with glade 3.16.1 --> <!-- Generated with glade 3.16.1 -->
<interface> <interface>
<requires lib="gtk+" version="3.0"/> <requires lib="gtk+" version="3.10"/>
<object class="GtkImage" id="add_image"> <object class="GtkImage" id="add_image">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">False</property> <property name="can_focus">False</property>
@@ -689,6 +689,78 @@ albums to play</property>
<property name="position">4</property> <property name="position">4</property>
</packing> </packing>
</child> </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> </object>
<packing> <packing>
<property name="expand">False</property> <property name="expand">False</property>
@@ -985,6 +1057,11 @@ albums to play</property>
</packing> </packing>
</child> </child>
</object> </object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">9</property>
</packing>
</child> </child>
</object> </object>
<packing> <packing>