diff options
| author | Clement Lefebvre <clement.lefebvre@linuxmint.com> | 2018-10-02 13:36:41 +0100 | 
|---|---|---|
| committer | Clement Lefebvre <clement.lefebvre@linuxmint.com> | 2018-10-02 13:36:41 +0100 | 
| commit | dca8334646d8fefeb56332eb1535c595a6599c7d (patch) | |
| tree | be87d17313cf1d03f0d8a58d94a6b5a81869c05d /src | |
| parent | Merge pull request #641 from jonls/delete-de-mo (diff) | |
| download | redshift-ng-dca8334646d8fefeb56332eb1535c595a6599c7d.tar.gz redshift-ng-dca8334646d8fefeb56332eb1535c595a6599c7d.tar.bz2 redshift-ng-dca8334646d8fefeb56332eb1535c595a6599c7d.tar.xz | |
Status icon: Prefer symbolic icons when available
Use 'redshift-status-on-symbolic' and 'redshift-statys-off-symbolic'
if available.
If these icons are not present in the icon theme, fallback to
'redshift-status-on' and 'redshift-status-off'.
Symbolic icons are the only way for themes to properly support
both light and dark panels with grey icons. If the icon name ends
with -symbolic, GTK renders the foreground color of the icon based
on the color of the panel behind it.
Diffstat (limited to 'src')
| -rw-r--r-- | src/redshift-gtk/statusicon.py | 31 | 
1 files changed, 21 insertions, 10 deletions
| diff --git a/src/redshift-gtk/statusicon.py b/src/redshift-gtk/statusicon.py index 3325403..a0ffd7a 100644 --- a/src/redshift-gtk/statusicon.py +++ b/src/redshift-gtk/statusicon.py @@ -53,17 +53,22 @@ class RedshiftStatusIcon(object):          self._controller = controller +        self.icon_theme = Gtk.IconTheme.get_default() +        icon_name = 'redshift-status-on-symbolic' +        if not self.icon_theme.has_icon(icon_name): +            icon_name = 'redshift-status-on' +          if appindicator:              # Create indicator              self.indicator = appindicator.Indicator.new(                  'redshift', -                'redshift-status-on', +                icon_name,                  appindicator.IndicatorCategory.APPLICATION_STATUS)              self.indicator.set_status(appindicator.IndicatorStatus.ACTIVE)          else:              # Create status icon              self.status_icon = Gtk.StatusIcon() -            self.status_icon.set_from_icon_name('redshift-status-on') +            self.status_icon.set_from_icon_name(icon_name)              self.status_icon.set_tooltip_text('Redshift')          # Create popup menu @@ -156,6 +161,7 @@ class RedshiftStatusIcon(object):          self._controller.connect('location-changed', self.location_change_cb)          self._controller.connect('error-occured', self.error_occured_cb)          self._controller.connect('stopped', self.controller_stopped_cb) +        self.icon_theme.connect('changed', self.on_icon_theme_changed_cb)          # Set info box text          self.change_inhibited(self._controller.inhibited) @@ -241,22 +247,27 @@ class RedshiftStatusIcon(object):          self.info_dialog.hide()          return True +    def on_icon_theme_changed_cb(self, theme): +        self.update_status_icon() +      def update_status_icon(self):          """Update the status icon according to the internally recorded state.          This should be called whenever the internally recorded state          might have changed.          """ +        if self._controller.inhibited: +            icon_name = 'redshift-status-off-symbolic' +        else: +            icon_name = 'redshift-status-on-symbolic' + +        if not self.icon_theme.has_icon(icon_name): +            icon_name = icon_name.replace('-symbolic', '') +          if appindicator: -            if not self._controller.inhibited: -                self.indicator.set_icon('redshift-status-on') -            else: -                self.indicator.set_icon('redshift-status-off') +            self.indicator.set_icon(icon_name)          else: -            if not self._controller.inhibited: -                self.status_icon.set_from_icon_name('redshift-status-on') -            else: -                self.status_icon.set_from_icon_name('redshift-status-off') +            self.status_icon.set_from_icon_name(icon_name)      # State update functions      def inhibit_change_cb(self, controller, inhibit): | 
