[installer] Update GUI

This commit is contained in:
Daniel Brötzmann
2018-10-08 19:59:29 +02:00
committed by Philipp Hörist
parent 6e12a1e493
commit 3e2abc58c0
2 changed files with 249 additions and 247 deletions

View File

@@ -1,9 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<!-- Generated with glade 3.20.0 --> <!-- Generated with glade 3.22.1 -->
<interface> <interface>
<requires lib="gtk+" version="3.14"/> <requires lib="gtk+" version="3.20"/>
<object class="GtkWindow" id="ConfigWindow"> <object class="GtkWindow" id="ConfigWindow">
<property name="can_focus">False</property> <property name="can_focus">False</property>
<child>
<placeholder/>
</child>
<child> <child>
<object class="GtkGrid" id="config_grid"> <object class="GtkGrid" id="config_grid">
<property name="visible">True</property> <property name="visible">True</property>
@@ -55,47 +58,47 @@
<object class="GtkWindow" id="AvailablePlugins"> <object class="GtkWindow" id="AvailablePlugins">
<property name="can_focus">False</property> <property name="can_focus">False</property>
<child> <child>
<object class="GtkPaned" id="paned"> <placeholder/>
</child>
<child>
<object class="GtkBox" id="available_plugins_box">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">True</property> <property name="can_focus">False</property>
<property name="margin_left">18</property>
<property name="margin_right">18</property>
<property name="margin_top">18</property>
<property name="margin_bottom">18</property>
<property name="spacing">18</property>
<child> <child>
<object class="GtkGrid" id="plugin_grid"> <object class="GtkBox">
<property name="width_request">200</property>
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">False</property> <property name="can_focus">False</property>
<property name="hexpand">True</property>
<property name="orientation">vertical</property>
<child> <child>
<object class="GtkProgressBar" id="progressbar"> <object class="GtkScrolledWindow" id="scrolledwindow">
<property name="can_focus">False</property>
<property name="no_show_all">True</property>
<property name="ellipsize">end</property>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">1</property>
</packing>
</child>
<child>
<object class="GtkScrolledWindow" id="scrolledwindow2">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">True</property> <property name="can_focus">True</property>
<property name="hexpand">True</property>
<property name="vexpand">True</property>
<property name="border_width">6</property>
<property name="hscrollbar_policy">never</property> <property name="hscrollbar_policy">never</property>
<property name="shadow_type">out</property>
<child> <child>
<object class="GtkTreeView" id="available_treeview"> <object class="GtkTreeView" id="available_plugins_treeview">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">True</property> <property name="can_focus">True</property>
<property name="vexpand">True</property>
<property name="model">plugin_store</property> <property name="model">plugin_store</property>
<property name="headers_clickable">False</property>
<property name="search_column">1</property>
<child internal-child="selection"> <child internal-child="selection">
<object class="GtkTreeSelection"> <object class="GtkTreeSelection" id="treeview-selection">
<signal name="changed" handler="available_plugins_treeview_selection_changed" swapped="no"/> <signal name="changed" handler="available_plugins_treeview_selection_changed" swapped="no"/>
</object> </object>
</child> </child>
<child> <child>
<object class="GtkTreeViewColumn"> <object class="GtkTreeViewColumn">
<property name="resizable">True</property>
<property name="sizing">fixed</property>
<property name="fixed_width">200</property>
<property name="min_width">150</property>
<property name="max_width">300</property>
<property name="title" translatable="yes">Plugin</property> <property name="title" translatable="yes">Plugin</property>
<property name="expand">True</property> <property name="expand">True</property>
<child> <child>
@@ -137,7 +140,7 @@
<child> <child>
<object class="GtkTreeViewColumn"> <object class="GtkTreeViewColumn">
<property name="title" translatable="yes">Install / <property name="title" translatable="yes">Install /
Upgrade</property> Update</property>
<property name="alignment">0.5</property> <property name="alignment">0.5</property>
<child> <child>
<object class="GtkCellRendererToggle" id="togglerenderer"> <object class="GtkCellRendererToggle" id="togglerenderer">
@@ -149,200 +152,224 @@ Upgrade</property>
</child> </child>
</object> </object>
</child> </child>
<style>
<class name="space"/>
</style>
</object> </object>
</child> </child>
</object> </object>
<packing> <packing>
<property name="left_attach">0</property> <property name="expand">True</property>
<property name="top_attach">0</property> <property name="fill">True</property>
<property name="position">0</property>
</packing> </packing>
</child> </child>
<child> <child>
<object class="GtkButtonBox"> <object class="GtkToolbar">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">False</property> <property name="can_focus">False</property>
<property name="halign">start</property> <property name="show_arrow">False</property>
<property name="margin_top">2</property> <property name="icon_size">1</property>
<property name="margin_bottom">2</property>
<property name="border_width">6</property>
<property name="orientation">vertical</property>
<property name="layout_style">start</property>
<child> <child>
<object class="GtkButton" id="install_button"> <object class="GtkToolButton" id="install_plugin_button">
<property name="label" translatable="yes">Install/Upgrade</property>
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">True</property> <property name="sensitive">False</property>
<property name="receives_default">True</property> <property name="can_focus">False</property>
<property name="valign">start</property> <property name="tooltip_text" translatable="yes">Install/Update Plugin</property>
<property name="vexpand">False</property> <property name="icon_name">system-software-update</property>
<property name="image">refresh</property>
<property name="always_show_image">True</property>
<signal name="clicked" handler="on_install_upgrade_clicked" swapped="no"/> <signal name="clicked" handler="on_install_upgrade_clicked" swapped="no"/>
</object> </object>
<packing> <packing>
<property name="expand">True</property> <property name="expand">False</property>
<property name="fill">True</property> <property name="homogeneous">False</property>
<property name="position">0</property> </packing>
</child>
<style>
<class name="inline-toolbar"/>
</style>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
<child>
<object class="GtkProgressBar" id="progressbar">
<property name="can_focus">False</property>
<property name="no_show_all">True</property>
<property name="ellipsize">end</property>
</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">0</property>
</packing>
</child>
<child>
<object class="GtkBox">
<property name="width_request">400</property>
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="hexpand">True</property>
<property name="orientation">vertical</property>
<property name="spacing">18</property>
<child>
<object class="GtkLabel" id="plugin_name_label">
<property name="can_focus">False</property>
<property name="no_show_all">True</property>
<property name="halign">start</property>
<property name="label" translatable="yes">&lt;Plugin Name&gt;</property>
<property name="selectable">True</property>
<style>
<class name="large-header"/>
</style>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="plugin_description">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="halign">start</property>
<property name="label" translatable="yes">&lt;Description&gt;</property>
<property name="wrap">True</property>
<property name="wrap_mode">word-char</property>
<property name="selectable">True</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
<child>
<object class="GtkGrid">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="row_spacing">6</property>
<property name="column_spacing">12</property>
<child>
<object class="GtkLabel">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="halign">end</property>
<property name="valign">start</property>
<property name="label" translatable="yes">Version</property>
<style>
<class name="dim-label"/>
</style>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">0</property>
</packing>
</child>
<child>
<object class="GtkLabel">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="halign">end</property>
<property name="valign">start</property>
<property name="label" translatable="yes">Authors</property>
<style>
<class name="dim-label"/>
</style>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">1</property>
</packing>
</child>
<child>
<object class="GtkLabel">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="halign">end</property>
<property name="valign">start</property>
<property name="label" translatable="yes">Homepage</property>
<style>
<class name="dim-label"/>
</style>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">2</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="plugin_version_label">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="halign">start</property>
<property name="label" translatable="yes">&lt;empty&gt;</property>
<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="left_attach">1</property>
<property name="top_attach">0</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="plugin_authors_label">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="halign">start</property>
<property name="label" translatable="yes">&lt;empty&gt;</property>
<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="left_attach">1</property>
<property name="top_attach">1</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="plugin_homepage_linkbutton">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="halign">start</property>
<property name="label" translatable="yes">&lt;empty&gt;</property>
<property name="wrap">True</property>
<property name="wrap_mode">word-char</property>
<property name="xalign">0</property>
</object>
<packing>
<property name="left_attach">1</property>
<property name="top_attach">2</property>
</packing> </packing>
</child> </child>
</object> </object>
<packing> <packing>
<property name="left_attach">0</property> <property name="expand">False</property>
<property name="top_attach">2</property> <property name="fill">True</property>
<property name="position">2</property>
</packing> </packing>
</child> </child>
</object> </object>
<packing> <packing>
<property name="resize">True</property> <property name="expand">False</property>
<property name="shrink">False</property> <property name="fill">True</property>
</packing> <property name="position">1</property>
</child>
<child>
<object class="GtkGrid" id="description_grid">
<property name="width_request">350</property>
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="border_width">6</property>
<property name="row_spacing">3</property>
<property name="column_spacing">5</property>
<child>
<object class="GtkLabel" id="name_label">
<property name="can_focus">False</property>
<property name="no_show_all">True</property>
<property name="halign">start</property>
<property name="selectable">True</property>
<attributes>
<attribute name="weight" value="bold"/>
</attributes>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">0</property>
<property name="width">2</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="versionlabel">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="halign">start</property>
<property name="label" translatable="yes">Version:</property>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">1</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="authorslabel">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="halign">start</property>
<property name="valign">start</property>
<property name="label" translatable="yes">Authors:</property>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">2</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="homepage_label">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="halign">start</property>
<property name="label" translatable="yes">Homepage:</property>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">3</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="description_label">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="halign">start</property>
<property name="label" translatable="yes">Description:</property>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">4</property>
<property name="width">2</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="version_label">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="halign">start</property>
<property name="hexpand">False</property>
<property name="selectable">True</property>
</object>
<packing>
<property name="left_attach">1</property>
<property name="top_attach">1</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="authors_label">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="halign">start</property>
<property name="valign">start</property>
<property name="wrap_mode">word-char</property>
<property name="selectable">True</property>
<property name="ellipsize">end</property>
</object>
<packing>
<property name="left_attach">1</property>
<property name="top_attach">2</property>
</packing>
</child>
<child>
<object class="GtkLinkButton" id="homepage_linkbutton">
<property name="can_focus">True</property>
<property name="focus_on_click">False</property>
<property name="receives_default">True</property>
<property name="no_show_all">True</property>
<property name="halign">start</property>
<property name="hexpand">True</property>
<property name="relief">none</property>
</object>
<packing>
<property name="left_attach">1</property>
<property name="top_attach">3</property>
</packing>
</child>
<child>
<object class="GtkScrolledWindow" id="scrolled_description_window">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="hexpand">True</property>
<property name="vexpand">True</property>
<property name="shadow_type">in</property>
<child>
<placeholder/>
</child>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">5</property>
<property name="width">2</property>
</packing>
</child>
</object>
<packing>
<property name="resize">True</property>
<property name="shrink">False</property>
</packing> </packing>
</child> </child>
</object> </object>
</child> </child>
</object> </object>
<object class="GtkImage" id="refresh">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="stock">gtk-refresh</property>
</object>
</interface> </interface>

View File

@@ -43,7 +43,6 @@ try:
from common import gajim as app from common import gajim as app
from plugins import GajimPlugin from plugins import GajimPlugin
from plugins.gui import GajimPluginConfigDialog from plugins.gui import GajimPluginConfigDialog
from htmltextview import HtmlTextView
from dialogs import WarningDialog, HigDialog, YesNoDialog from dialogs import WarningDialog, HigDialog, YesNoDialog
from gtkgui_helpers import get_action from gtkgui_helpers import get_action
except ImportError: except ImportError:
@@ -51,7 +50,6 @@ except ImportError:
from gajim.common import configpaths from gajim.common import configpaths
from gajim.plugins import GajimPlugin from gajim.plugins import GajimPlugin
from gajim.plugins.gui import GajimPluginConfigDialog from gajim.plugins.gui import GajimPluginConfigDialog
from gajim.htmltextview import HtmlTextView
from gajim.dialogs import WarningDialog, HigDialog, YesNoDialog from gajim.dialogs import WarningDialog, HigDialog, YesNoDialog
from gajim.gtkgui_helpers import get_action from gajim.gtkgui_helpers import get_action
@@ -131,7 +129,7 @@ class PluginInstaller(GajimPlugin):
def warn_update(self, plugins): def warn_update(self, plugins):
def open_update(dummy): def open_update(dummy):
get_action('plugins').activate() get_action('plugins').activate()
page = self.notebook.page_num(self.paned) page = self.notebook.page_num(self.available_plugins_box)
self.notebook.set_current_page(page) self.notebook.set_current_page(page)
if plugins: if plugins:
plugins_str = '\n' + '\n'.join(plugins) plugins_str = '\n' + '\n'.join(plugins)
@@ -154,7 +152,7 @@ class PluginInstaller(GajimPlugin):
def deactivate(self): def deactivate(self):
if hasattr(self, 'available_page'): if hasattr(self, 'available_page'):
self.notebook.remove_page(self.notebook.page_num(self.paned)) self.notebook.remove_page(self.notebook.page_num(self.available_plugins_box))
self.notebook.set_current_page(0) self.notebook.set_current_page(0)
for id_, widget in list(self.connected_ids.items()): for id_, widget in list(self.connected_ids.items()):
widget.disconnect(id_) widget.disconnect(id_)
@@ -182,35 +180,24 @@ class PluginInstaller(GajimPlugin):
self.xml = Gtk.Builder() self.xml = Gtk.Builder()
self.xml.set_translation_domain('gajim_plugins') self.xml.set_translation_domain('gajim_plugins')
self.xml.add_objects_from_file(self.Gtk_BUILDER_FILE_PATH, self.xml.add_objects_from_file(self.Gtk_BUILDER_FILE_PATH,
['refresh', 'paned', 'plugin_store']) ['refresh', 'available_plugins_box', 'plugin_store'])
widgets_to_extract = ( widgets_to_extract = (
'name_label', 'available_treeview', 'progressbar', 'paned', 'available_plugins_box', 'install_plugin_button', 'plugin_name_label',
'install_button', 'authors_label', 'homepage_linkbutton', 'plugin_version_label', 'plugin_authors_label', 'plugin_description',
'version_label', 'scrolled_description_window') 'plugin_homepage_linkbutton', 'progressbar', 'available_plugins_treeview',
'available_text', 'available_text_label')
for widget_name in widgets_to_extract: for widget_name in widgets_to_extract:
setattr(self, widget_name, self.xml.get_object(widget_name)) setattr(self, widget_name, self.xml.get_object(widget_name))
# Make Link in LinkButton not centered
style_provider = Gtk.CssProvider()
css = '.link { padding-left: 0px; padding-right: 0px; }'
style_provider.load_from_data(css.encode())
context = self.homepage_linkbutton.get_style_context()
context.add_provider(style_provider,
Gtk.STYLE_PROVIDER_PRIORITY_USER)
self.available_page = self.notebook.append_page( self.available_page = self.notebook.append_page(
self.paned, Gtk.Label.new(_('Available'))) self.available_plugins_box, Gtk.Label.new(_('Available')))
self.available_plugins_model = self.xml.get_object('plugin_store') self.available_plugins_model = self.xml.get_object('plugin_store')
self.available_plugins_model.set_sort_column_id( self.available_plugins_model.set_sort_column_id(
2, Gtk.SortType.ASCENDING) 2, Gtk.SortType.ASCENDING)
self.description_textview = HtmlTextView()
self.description_textview.set_wrap_mode(Gtk.WrapMode.WORD)
self.scrolled_description_window.add(self.description_textview)
self.xml.connect_signals(self) self.xml.connect_signals(self)
self.window.show_all() self.window.show_all()
@@ -227,7 +214,7 @@ class PluginInstaller(GajimPlugin):
for i in range(len(self.available_plugins_model)): for i in range(len(self.available_plugins_model)):
if self.available_plugins_model[i][Column.UPGRADE]: if self.available_plugins_model[i][Column.UPGRADE]:
dir_list.append(self.available_plugins_model[i][Column.DIR]) dir_list.append(self.available_plugins_model[i][Column.DIR])
self.install_button.set_property('sensitive', bool(dir_list)) self.install_plugin_button.set_property('sensitive', bool(dir_list))
def on_notebook_switch_page(self, widget, page, page_num): def on_notebook_switch_page(self, widget, page, page_num):
tab_label_text = self.notebook.get_tab_label_text(page) tab_label_text = self.notebook.get_tab_label_text(page)
@@ -238,7 +225,7 @@ class PluginInstaller(GajimPlugin):
self.start_download(upgrading=True) self.start_download(upgrading=True)
def on_install_upgrade_clicked(self, widget): def on_install_upgrade_clicked(self, widget):
self.install_button.set_property('sensitive', False) self.install_plugin_button.set_property('sensitive', False)
dir_list = [] dir_list = []
for i in range(len(self.available_plugins_model)): for i in range(len(self.available_plugins_model)):
if self.available_plugins_model[i][Column.UPGRADE]: if self.available_plugins_model[i][Column.UPGRADE]:
@@ -316,43 +303,31 @@ class PluginInstaller(GajimPlugin):
def available_plugins_treeview_selection_changed(self, treeview_selection): def available_plugins_treeview_selection_changed(self, treeview_selection):
model, iter_ = treeview_selection.get_selected() model, iter_ = treeview_selection.get_selected()
self.description_textview.get_buffer().set_text('')
if not iter_: if not iter_:
self.name_label.set_text('') self.plugin_name_label.set_text('')
self.version_label.set_text('') self.plugin_version_label.set_text('')
self.authors_label.set_text('') self.plugin_authors_label.set_text('')
self.homepage_linkbutton.set_uri('') self.plugin_homepage_linkbutton.set_text('')
self.homepage_linkbutton.set_label('') self.install_plugin_button.set_sensitive(False)
self.install_button.set_sensitive(False)
return return
self.install_button.set_sensitive(True) self.plugin_name_label.set_text(model.get_value(iter_, Column.NAME))
self.name_label.set_text(model.get_value(iter_, Column.NAME)) self.plugin_version_label.set_text(model.get_value(iter_, Column.VERSION))
self.version_label.set_text(model.get_value(iter_, Column.VERSION)) self.plugin_authors_label.set_text(model.get_value(iter_, Column.AUTHORS))
self.authors_label.set_text(model.get_value(iter_, Column.AUTHORS)) homepage = model.get_value(iter_, Column.HOMEPAGE)
self.homepage_linkbutton.set_uri( markup = '<a href="%s">%s</a>' % (homepage, homepage)
model.get_value(iter_, Column.HOMEPAGE)) self.plugin_homepage_linkbutton.set_markup(markup)
self.homepage_linkbutton.set_label( self.plugin_description.set_text(model.get_value(iter_, Column.DESCRIPTION))
model.get_value(iter_, Column.HOMEPAGE))
link_label = self.homepage_linkbutton.get_children()[0]
link_label.set_ellipsize(Pango.EllipsizeMode.END)
desc = _(model.get_value(iter_, Column.DESCRIPTION))
if not desc.startswith('<body '):
desc = ('<body xmlns=\'http://www.w3.org/1999/xhtml\'>'
'%s</body>') % desc
desc = desc.replace('\n', '<br/>')
self.description_textview.display_html(
desc, self.description_textview, None)
def select_root_iter(self): def select_root_iter(self):
selection = self.available_treeview.get_selection() selection = self.available_plugins_treeview.get_selection()
model, iter_ = selection.get_selected() model, iter_ = selection.get_selected()
if not iter_: if not iter_:
iter_ = self.available_plugins_model.get_iter_first() iter_ = self.available_plugins_model.get_iter_first()
selection.select_iter(iter_) selection.select_iter(iter_)
self.name_label.show() self.plugin_name_label.show()
self.homepage_linkbutton.show() self.plugin_homepage_linkbutton.show()
path = self.available_plugins_model.get_path(iter_) path = self.available_plugins_model.get_path(iter_)
self.available_treeview.scroll_to_cell(path) self.available_plugins_treeview.scroll_to_cell(path)
class DownloadAsync(threading.Thread): class DownloadAsync(threading.Thread):
@@ -504,7 +479,7 @@ class DownloadAsync(threading.Thread):
if V(plugin['version']) > V(plugin['local_version']): if V(plugin['version']) > V(plugin['local_version']):
plugin['upgrade'] = True plugin['upgrade'] = True
GLib.idle_add( GLib.idle_add(
self.plugin.install_button.set_property, self.plugin.install_plugin_button.set_property,
'sensitive', True) 'sensitive', True)
GLib.idle_add(self.model_append, plugin) GLib.idle_add(self.model_append, plugin)
GLib.idle_add(self.plugin.select_root_iter) GLib.idle_add(self.plugin.select_root_iter)