Add PiP and play icons as gresource

Add missing PiP icons from web devel kit. Also add play/pause
icons at the right size and remove all workarounds/scaling
implemented or these two.

Playback icons are always two bars for pause and triangle for play,
so hopefully this will not be problematic, as this guaranties the
right size for them that Adwaita unfortunately cannot provide.
This commit is contained in:
Rafał Dzięgiel
2021-09-07 19:34:51 +02:00
parent fa39c45773
commit 98d2b80103
16 changed files with 263 additions and 92 deletions

View File

@@ -43,22 +43,6 @@ class ClapperApp extends AppBase
this._openFilesAsync(files).then(() => this.activate()).catch(debug);
}
_onIconThemeChanged(gtkSettings)
{
super._onIconThemeChanged(gtkSettings);
const display = Gdk.Display.get_default();
if(!display) return;
const iconTheme = Gtk.IconTheme.get_for_display(display);
if(!iconTheme) return;
const { headerBar } = this.active_window.child.revealerTop;
if(!headerBar) return;
headerBar._onIconThemeChanged(iconTheme);
}
_onWindowMap(window)
{
window.disconnect(this.mapSignal);

View File

@@ -31,6 +31,10 @@ class ClapperAppBase extends Gtk.Application
title: Misc.appName,
});
/* FIXME: AFAIK there is no way to detect theme rounded corners.
* Having 2/4 corners rounded in floating mode is not good. */
window.add_css_class('adwrounded');
if(!settings.get_boolean('render-shadows'))
window.add_css_class('gpufriendly');
@@ -99,37 +103,6 @@ class ClapperAppBase extends Gtk.Application
'gtk-application-prefer-dark-theme',
Gio.SettingsBindFlags.GET
);
this._onThemeChanged(gtkSettings);
this._onIconThemeChanged(gtkSettings);
gtkSettings.connect('notify::gtk-theme-name', this._onThemeChanged.bind(this));
gtkSettings.connect('notify::gtk-icon-theme-name', this._onIconThemeChanged.bind(this));
this.doneFirstActivate = true;
}
_onThemeChanged(gtkSettings)
{
const theme = gtkSettings.gtk_theme_name;
const window = this.active_window;
debug(`user selected theme: ${theme}`);
/* FIXME: AFAIK there is no way to detect theme rounded corners.
Having 2/4 corners rounded in floating mode is not good. */
if(!window.has_css_class('adwrounded'))
window.add_css_class('adwrounded');
}
_onIconThemeChanged(gtkSettings)
{
const iconThemeName = gtkSettings.gtk_icon_theme_name;
const window = this.active_window;
const hasAdwIcons = window.has_css_class('adwicons');
if(iconThemeName === 'Adwaita' || iconThemeName === 'Default') {
if(!hasAdwIcons)
window.add_css_class('adwicons');
}
else if(hasAdwIcons)
window.remove_css_class('adwicons');
}
});

5
src/controls.js vendored
View File

@@ -37,10 +37,9 @@ class ClapperControls extends Gtk.Box
this.chapterHideId = null;
this.togglePlayButton = new Buttons.IconToggleButton(
'media-playback-start-symbolic',
'media-playback-pause-symbolic'
'play-symbolic',
'pause-symbolic'
);
this.togglePlayButton.child.add_css_class('playbackicon');
this.togglePlayButton.connect(
'clicked', this._onTogglePlayClicked.bind(this)
);

View File

@@ -28,12 +28,4 @@ class ClapperHeaderBar extends HeaderBarBase
{
this.root.fullscreen();
}
_onIconThemeChanged(iconTheme)
{
super._onIconThemeChanged(iconTheme);
const { controlsRevealer } = this.root.child;
this._updateFloatIcon(!controlsRevealer.reveal_child);
}
});

View File

@@ -23,7 +23,6 @@ class ClapperHeaderBarBase extends Gtk.Box
this.isMaximized = false;
this.isMenuOnLeft = true;
this.hasPipIcons = false;
const uiBuilder = Misc.getBuilderForName('clapper.ui');
@@ -53,7 +52,7 @@ class ClapperHeaderBarBase extends Gtk.Box
this.extraButtonsBox.add_css_class('linked');
const floatButton = new Gtk.Button({
icon_name: 'go-bottom-symbolic',
icon_name: 'pip-in-symbolic',
can_focus: false,
});
floatButton.add_css_class('osd');
@@ -221,9 +220,7 @@ class ClapperHeaderBarBase extends Gtk.Box
const floatButton = this.extraButtonsBox.get_first_child();
if(!floatButton) return;
const iconName = (!this.hasPipIcons)
? 'go-bottom-symbolic'
: (isFloating)
const iconName = (isFloating)
? 'pip-out-symbolic'
: 'pip-in-symbolic';
@@ -242,15 +239,6 @@ class ClapperHeaderBarBase extends Gtk.Box
_onFullscreenButtonClicked(button)
{
}
_onIconThemeChanged(iconTheme)
{
/* Those icons are new, so check if theme has them */
this.hasPipIcons = (
iconTheme.has_icon('pip-in-symbolic')
&& iconTheme.has_icon('pip-out-symbolic')
);
}
});
var HeaderBarPopover = GObject.registerClass({

View File

@@ -676,12 +676,6 @@ class ClapperPlayer extends GstClapper.Clapper
this.set_audio_video_offset(value);
debug(`set audio-video offset: ${value}`);
break;
case 'dark-theme':
root = this.widget.get_root();
if(!root) break;
root.application._onThemeChanged(Gtk.Settings.get_default());
break;
case 'play-flags':
const initialFlags = this.pipeline.flags;
const settingsFlags = settings.get_int(key);

View File

@@ -23,11 +23,10 @@ class ClapperWidgetRemote extends Gtk.Grid
/* FIXME: create better way to add buttons for
* remote app without duplicating too much code */
this.togglePlayButton = new Buttons.IconToggleButton(
'media-playback-start-symbolic',
'media-playback-pause-symbolic'
'play-symbolic',
'pause-symbolic'
);
this.togglePlayButton.remove_css_class('flat');
this.togglePlayButton.child.add_css_class('playbackicon');
this.togglePlayButton.connect(
'clicked', () => this.sendWs('toggle_play')
);