[sushi] Add fullscreen button from base class



commit 1d460939b6e928201f48c7294708c21dde087eb3
Author: Cosimo Cecchi <cosimoc gnome org>
Date:   Thu Jun 27 10:54:58 2019 -0700

    Add fullscreen button from base class
    
    Instead of having every renderer do this. We add a hasToolbar
    property to the renderer and make populateToolbar() an optional
    method as part of this.

 src/ui/renderer.js         | 19 ++++++++++++++++++-
 src/viewers/audio.js       |  6 +++++-
 src/viewers/evince.js      |  6 ------
 src/viewers/gst.js         |  6 +++++-
 src/viewers/html.js        |  6 ------
 src/viewers/image.js       |  6 ------
 src/viewers/libreoffice.js |  6 ------
 src/viewers/text.js        |  1 -
 8 files changed, 28 insertions(+), 28 deletions(-)
---
diff --git a/src/ui/renderer.js b/src/ui/renderer.js
index 6a66be3..f939dcb 100644
--- a/src/ui/renderer.js
+++ b/src/ui/renderer.js
@@ -1,6 +1,7 @@
 const {GLib, GObject, Gtk} = imports.gi;
 
 const Constants = imports.util.constants;
+const Utils = imports.ui.utils;
 
 var ResizePolicy = {
     MAX_SIZE: 0,
@@ -28,6 +29,10 @@ var Renderer = GObject.registerClass({
         this.notify('ready');
     }
 
+    populateToolbar() {
+        // do nothing, this is optional
+    }
+
     toggleFullscreen() {
         if (!this.canFullscreen)
             return;
@@ -45,6 +50,10 @@ var Renderer = GObject.registerClass({
         return !!this._fullscreen;
     }
 
+    get hasToolbar() {
+        return true;
+    }
+
     get moveOnClick() {
         return true;
     }
@@ -62,13 +71,21 @@ var Renderer = GObject.registerClass({
     }
 
     get toolbar() {
-        if (!this.populateToolbar)
+        if (!this.hasToolbar)
             return null;
 
         if (!this._toolbar) {
             this._toolbar = new RendererToolbar();
             this.connect('destroy', () => { this._toolbar.destroy(); });
+
             this.populateToolbar(this._toolbar.box);
+
+            if (this.canFullscreen) {
+                if (this._toolbar.box.get_children().length > 0)
+                    this._toolbar.box.add(new Gtk.Separator({ orientation: Gtk.Orientation.VERTICAL }));
+
+                this._toolbar.box.add(Utils.createFullscreenButton(this));
+            }
         }
 
         return this._toolbar;
diff --git a/src/viewers/audio.js b/src/viewers/audio.js
index a12cd67..e339711 100644
--- a/src/viewers/audio.js
+++ b/src/viewers/audio.js
@@ -28,7 +28,6 @@ const {Gdk, GdkPixbuf, Gio, GLib, GObject, Gst, GstTag, Gtk, Soup, Sushi} = impo
 const Constants = imports.util.constants;
 const Renderer = imports.ui.renderer;
 const TotemMimeTypes = imports.util.totemMimeTypes;
-const Utils = imports.ui.utils;
 
 function _formatTimeString(timeVal) {
     let hours = Math.floor(timeVal / 3600);
@@ -367,6 +366,11 @@ var Klass = GObject.registerClass({
         }
     }
 
+    get hasToolbar() {
+        // SushiMediaBin uses its own toolbar
+        return false;
+    }
+
     get resizable() {
         return false;
     }
diff --git a/src/viewers/evince.js b/src/viewers/evince.js
index 103213e..5330eea 100644
--- a/src/viewers/evince.js
+++ b/src/viewers/evince.js
@@ -124,12 +124,6 @@ var Klass = GObject.registerClass({
             this._view.next_page();
         });
         toolbar.add(this._toolbarForward);
-
-        let separator = new Gtk.Separator({ orientation: Gtk.Orientation.VERTICAL });
-        toolbar.add(separator);
-
-        let toolbarZoom = Utils.createFullscreenButton(this);
-        toolbar.add(toolbarZoom);
     }
 });
 
diff --git a/src/viewers/gst.js b/src/viewers/gst.js
index 096b6b8..14d4b00 100644
--- a/src/viewers/gst.js
+++ b/src/viewers/gst.js
@@ -27,7 +27,6 @@ const {GLib, GObject, Sushi} = imports.gi;
 
 const Renderer = imports.ui.renderer;
 const TotemMimeTypes = imports.util.totemMimeTypes;
-const Utils = imports.ui.utils;
 
 var Klass = GObject.registerClass({
     Implements: [Renderer.Renderer],
@@ -65,6 +64,11 @@ var Klass = GObject.registerClass({
         return false;
     }
 
+    get hasToolbar() {
+        // SushiMediaBin uses its own toolbar
+        return false;
+    }
+
     get resizePolicy() {
         return Renderer.ResizePolicy.STRETCHED;
     }
diff --git a/src/viewers/html.js b/src/viewers/html.js
index 7c782bf..a20d55d 100644
--- a/src/viewers/html.js
+++ b/src/viewers/html.js
@@ -26,7 +26,6 @@
 const {Gtk, GLib, GObject, Sushi, WebKit2} = imports.gi;
 
 const Renderer = imports.ui.renderer;
-const Utils = imports.ui.utils;
 
 var Klass = GObject.registerClass({
     Implements: [Renderer.Renderer],
@@ -56,11 +55,6 @@ var Klass = GObject.registerClass({
     get moveOnClick() {
         return false;
     }
-
-    populateToolbar(toolbar) {
-        let toolbarZoom = Utils.createFullscreenButton(this);
-        toolbar.add(toolbarZoom);
-    }
 });
 
 var mimeTypes = [
diff --git a/src/viewers/image.js b/src/viewers/image.js
index 1397f89..bae07cd 100644
--- a/src/viewers/image.js
+++ b/src/viewers/image.js
@@ -26,7 +26,6 @@
 const {Gdk, GdkPixbuf, GLib, GObject, Gtk} = imports.gi;
 
 const Renderer = imports.ui.renderer;
-const Utils = imports.ui.utils;
 
 var Klass = GObject.registerClass({
     Implements: [Renderer.Renderer],
@@ -182,11 +181,6 @@ var Klass = GObject.registerClass({
         return Renderer.ResizePolicy.SCALED;
     }
 
-    populateToolbar(toolbar) {
-        let toolbarZoom = Utils.createFullscreenButton(this);
-        toolbar.add(toolbarZoom);
-    }
-
     _onDestroy() {
         if (this._timeoutId) {
             GLib.source_remove(this._timeoutId);
diff --git a/src/viewers/libreoffice.js b/src/viewers/libreoffice.js
index f3deb98..d153223 100644
--- a/src/viewers/libreoffice.js
+++ b/src/viewers/libreoffice.js
@@ -12,7 +12,6 @@ var isAvailable = function() {
 
 const Constants = imports.util.constants;
 const Renderer = imports.ui.renderer;
-const Utils = imports.ui.utils;
 
 var Klass = GObject.registerClass({
     Implements: [Renderer.Renderer],
@@ -87,11 +86,6 @@ var Klass = GObject.registerClass({
     get moveOnClick() {
         return false;
     }
-
-    populateToolbar(toolbar) {
-        let toolbarZoom = Utils.createFullscreenButton(this);
-        toolbar.add(toolbarZoom);
-    }
 });
 
 var officeTypes = [
diff --git a/src/viewers/text.js b/src/viewers/text.js
index 14f567f..e29dbef 100644
--- a/src/viewers/text.js
+++ b/src/viewers/text.js
@@ -26,7 +26,6 @@
 const {Gdk, Gio, GLib, GObject, Gtk, GtkSource} = imports.gi;
 
 const Renderer = imports.ui.renderer;
-const Utils = imports.ui.utils;
 
 function _getGeditScheme() {
     let geditScheme = 'tango';


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]