From a988d2e25088fd77f48b292dd12f0f7b143a1660 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Daniel=20Br=C3=B6tzmann?= <mailtrash@posteo.de>
Date: Sun, 24 Mar 2019 15:33:03 +0100
Subject: [PATCH] Flatpak: Disable install from ZIP

---
 gajim/data/gui/plugins_window.ui |  9 +++++----
 gajim/plugins/gui.py             | 18 +++++++++++++++---
 2 files changed, 20 insertions(+), 7 deletions(-)

diff --git a/gajim/data/gui/plugins_window.ui b/gajim/data/gui/plugins_window.ui
index 5b5ab75aca..16aa023fc2 100644
--- a/gajim/data/gui/plugins_window.ui
+++ b/gajim/data/gui/plugins_window.ui
@@ -1,5 +1,5 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<!-- Generated with glade 3.22.0 -->
+<!-- Generated with glade 3.22.1 -->
 <interface>
   <requires lib="gtk+" version="3.20"/>
   <object class="GtkWindow" id="plugins_window">
@@ -13,6 +13,9 @@
     <property name="type_hint">dialog</property>
     <signal name="destroy" handler="on_plugins_window_destroy" swapped="no"/>
     <signal name="key-press-event" handler="on_key_press_event" swapped="no"/>
+    <child type="titlebar">
+      <placeholder/>
+    </child>
     <child>
       <object class="GtkNotebook" id="plugins_notebook">
         <property name="visible">True</property>
@@ -232,6 +235,7 @@
                     <property name="wrap">True</property>
                     <property name="wrap_mode">word-char</property>
                     <property name="selectable">True</property>
+                    <property name="xalign">0</property>
                   </object>
                   <packing>
                     <property name="expand">False</property>
@@ -375,9 +379,6 @@
         </child>
       </object>
     </child>
-    <child type="titlebar">
-      <placeholder/>
-    </child>
   </object>
   <object class="GtkTextBuffer" id="textbuffer1">
     <property name="text" translatable="yes">Plug-in decription should be displayed here. This text will be erased during PluginsWindow initialization.</property>
diff --git a/gajim/plugins/gui.py b/gajim/plugins/gui.py
index a937ec808d..2b7efe5be2 100644
--- a/gajim/plugins/gui.py
+++ b/gajim/plugins/gui.py
@@ -32,6 +32,7 @@ from gi.repository import Gdk
 from gajim.common import app
 from gajim.common import configpaths
 from gajim.common.exceptions import PluginsystemError
+from gajim.common.helpers import launch_browser_mailer
 
 from gajim.plugins.helpers import log_calls
 from gajim.plugins.helpers import GajimPluginActivateException
@@ -65,14 +66,21 @@ class PluginsWindow:
 
         widgets_to_extract = ('plugins_notebook', 'plugin_name_label',
             'plugin_version_label', 'plugin_authors_label',
-            'plugin_homepage_linkbutton', 'uninstall_plugin_button',
-            'configure_plugin_button', 'installed_plugins_treeview',
-            'available_text', 'available_text_label')
+            'plugin_homepage_linkbutton', 'install_plugin_button',
+            'uninstall_plugin_button', 'configure_plugin_button',
+            'installed_plugins_treeview', 'available_text',
+            'available_text_label')
 
         for widget_name in widgets_to_extract:
             setattr(self, widget_name, builder.get_object(widget_name))
 
         self.plugin_description_textview = builder.get_object('description')
+
+        # Disable 'Install from ZIP' for Flatpak installs
+        if app.is_flatpak():
+            self.install_plugin_button.set_tooltip_text(
+                _('Click to view Gajim\'s wiki page on how to install plugins in Flatpak.'))
+
         self.installed_plugins_model = Gtk.ListStore(object, str, bool, bool,
             GdkPixbuf.Pixbuf)
         self.installed_plugins_treeview.set_model(self.installed_plugins_model)
@@ -241,6 +249,10 @@ class PluginsWindow:
 
     @log_calls('PluginsWindow')
     def on_install_plugin_button_clicked(self, widget):
+        if app.is_flatpak():
+            launch_browser_mailer('url', 'https://dev.gajim.org/gajim/gajim/wikis/help/flathub')
+            return
+
         def show_warn_dialog():
             text = _('Archive is malformed')
             dialog = WarningDialog(text, '', transient_for=self.window)
-- 
GitLab