Commit f091cd0a authored by Philipp Hörist's avatar Philipp Hörist

Rework Manage Bookmark dialog

- Make it single account
- Use a Treeview
- Move it to advanced sub menu

Manage Bookmarks should serve in the future as dialog for advanced users.
During normal usage of Gajim there should be no need anymore to access this dialog.
parent b291d573
Pipeline #4017 failed with stages
in 45 seconds
......@@ -36,7 +36,7 @@ from gajim.gtk.add_contact import AddNewContactWindow
from gajim.gtk.single_message import SingleMessageWindow
from gajim.gtk.about import AboutDialog
from gajim.gtk.privacy_list import PrivacyListsWindow
from gajim.gtk.bookmarks import ManageBookmarksWindow
from gajim.gtk.bookmarks import Bookmarks
from gajim.gtk.features import FeaturesDialog
from gajim.gtk.account_wizard import AccountCreationWizard
from gajim.gtk.history import HistoryWindow
......@@ -87,8 +87,13 @@ def on_history_manager(action, param):
HistoryManager()
def on_manage_bookmarks(action, param):
ManageBookmarksWindow()
def on_bookmarks(action, param):
account = param.get_string()
window = app.get_app_window(Bookmarks, account=account)
if window is None:
window = Bookmarks(account)
else:
window.present()
def on_quit(action, param):
......
......@@ -428,7 +428,6 @@ class GajimApplication(Gtk.Application):
('quit', app_actions.on_quit),
('add-account', app_actions.on_add_account),
('manage-proxies', app_actions.on_manage_proxies),
('bookmarks', app_actions.on_manage_bookmarks),
('history-manager', app_actions.on_history_manager),
('preferences', app_actions.on_preferences),
('plugins', app_actions.on_plugins),
......@@ -502,6 +501,7 @@ class GajimApplication(Gtk.Application):
]
return [
('-bookmarks', a.on_bookmarks, 'online', 's'),
('-start-single-chat', a.on_single_message, 'online', 's'),
('-start-chat', a.start_chat, 'online', 'as'),
('-add-contact', a.on_add_contact, 'online', 'as'),
......
......@@ -18,8 +18,6 @@ from typing import Any
from typing import List
from typing import Optional
import copy
import nbxmpp
from nbxmpp.protocol import JID
from nbxmpp.util import is_error_result
......@@ -122,27 +120,6 @@ class Bookmarks(BaseModule):
if bookmark.jid == jid:
return bookmark
def get_sorted_bookmarks(self, short_name=False):
# This returns a sorted by name copy of the bookmarks
sorted_bookmarks = []
for bookmark in self._bookmarks:
bookmark_copy = copy.deepcopy(bookmark)
if not bookmark_copy.name:
# No name was given for this bookmark
# Use the first part of JID instead
name = bookmark_copy.jid.getNode()
bookmark_copy = bookmark_copy._replace(name=name)
if short_name:
name = bookmark_copy.name
name = (name[:42] + '..') if len(name) > 42 else name
bookmark_copy = bookmark_copy._replace(name=name)
sorted_bookmarks.append(bookmark_copy)
sorted_bookmarks.sort(key=lambda x: x.name.lower())
return sorted_bookmarks
def _pubsub_support(self) -> bool:
return (self._con.get_module('PEP').supported and
self._con.get_module('PubSub').publish_options)
......
......@@ -79,11 +79,6 @@
<attribute name="accel">&lt;Primary&gt;G</attribute>
<attribute name="target"></attribute>
</item>
<item>
<attribute name="label" translatable="yes">Bookmarks</attribute>
<attribute name="action">app.bookmarks</attribute>
<attribute name="accel">&lt;Primary&gt;B</attribute>
</item>
<item>
<attribute name="label" translatable="yes">History Manager</attribute>
<attribute name="action">app.history-manager</attribute>
......
<?xml version="1.0" encoding="UTF-8"?>
<!-- Generated with glade 3.22.1 -->
<interface>
<requires lib="gtk+" version="3.20"/>
<object class="GtkListStore" id="bookmarks_store">
<columns>
<!-- column-name jid -->
<column type="gchararray"/>
<!-- column-name name -->
<column type="gchararray"/>
<!-- column-name nick -->
<column type="gchararray"/>
<!-- column-name password -->
<column type="gchararray"/>
<!-- column-name autojoin -->
<column type="gboolean"/>
</columns>
</object>
<object class="GtkGrid" id="bookmarks_grid">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="row_spacing">6</property>
<child>
<object class="GtkBox">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="hexpand">True</property>
<property name="spacing">6</property>
<child>
<object class="GtkButton">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="halign">start</property>
<signal name="clicked" handler="_on_add_clicked" swapped="no"/>
<child>
<object class="GtkImage">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="icon_name">list-add-symbolic</property>
</object>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkButton" id="remove_button">
<property name="visible">True</property>
<property name="sensitive">False</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="halign">start</property>
<signal name="clicked" handler="_on_remove_clicked" swapped="no"/>
<child>
<object class="GtkImage">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="icon_name">list-remove-symbolic</property>
</object>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">1</property>
</packing>
</child>
<child>
<object class="GtkScrolledWindow">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="hexpand">True</property>
<property name="vexpand">True</property>
<property name="hscrollbar_policy">never</property>
<property name="shadow_type">in</property>
<child>
<object class="GtkTreeView" id="bookmarks_view">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="model">bookmarks_store</property>
<property name="search_column">0</property>
<property name="enable_grid_lines">horizontal</property>
<child internal-child="selection">
<object class="GtkTreeSelection">
<signal name="changed" handler="_on_selection_changed" swapped="no"/>
</object>
</child>
<child>
<object class="GtkTreeViewColumn">
<property name="resizable">True</property>
<property name="title" translatable="yes">XMPP Address</property>
<property name="expand">True</property>
<property name="sort_indicator">True</property>
<property name="sort_column_id">0</property>
<child>
<object class="GtkCellRendererText" id="jid">
<property name="editable">True</property>
<property name="ellipsize">end</property>
<property name="placeholder_text">chat@conference.example.org</property>
<signal name="edited" handler="_on_address_edited" swapped="no"/>
</object>
<attributes>
<attribute name="text">0</attribute>
</attributes>
</child>
</object>
</child>
<child>
<object class="GtkTreeViewColumn">
<property name="resizable">True</property>
<property name="min_width">100</property>
<property name="title" translatable="yes">Name</property>
<property name="sort_indicator">True</property>
<property name="sort_column_id">1</property>
<child>
<object class="GtkCellRendererText" id="name">
<property name="editable">True</property>
<property name="ellipsize">end</property>
<signal name="edited" handler="_on_name_edited" swapped="no"/>
</object>
<attributes>
<attribute name="text">1</attribute>
</attributes>
</child>
</object>
</child>
<child>
<object class="GtkTreeViewColumn">
<property name="resizable">True</property>
<property name="title" translatable="yes">Nickname</property>
<property name="sort_indicator">True</property>
<property name="sort_column_id">2</property>
<child>
<object class="GtkCellRendererText" id="nick">
<property name="editable">True</property>
<property name="ellipsize">end</property>
<signal name="edited" handler="_on_nick_edited" swapped="no"/>
</object>
<attributes>
<attribute name="text">2</attribute>
</attributes>
</child>
</object>
</child>
<child>
<object class="GtkTreeViewColumn">
<property name="resizable">True</property>
<property name="title" translatable="yes">Password</property>
<property name="sort_indicator">True</property>
<property name="sort_column_id">3</property>
<child>
<object class="GtkCellRendererText" id="password">
<property name="editable">True</property>
<property name="ellipsize">end</property>
<signal name="edited" handler="_on_password_edited" swapped="no"/>
</object>
<attributes>
<attribute name="text">3</attribute>
</attributes>
</child>
</object>
</child>
<child>
<object class="GtkTreeViewColumn">
<property name="sizing">fixed</property>
<property name="title" translatable="yes">Autojoin</property>
<property name="alignment">0.5</property>
<property name="sort_indicator">True</property>
<property name="sort_column_id">4</property>
<child>
<object class="GtkCellRendererToggle" id="autojoin">
<signal name="toggled" handler="_on_autojoin_toggled" swapped="no"/>
</object>
<attributes>
<attribute name="active">4</attribute>
</attributes>
</child>
</object>
</child>
<style>
<class name="gajim-treeview"/>
</style>
</object>
</child>
<style>
<class name="gajim-scrolled"/>
</style>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">0</property>
<property name="width">2</property>
</packing>
</child>
<child>
<object class="GtkBox">
<property name="visible">True</property>
<property name="can_focus">False</property>
<child>
<object class="GtkButton">
<property name="label" translatable="yes">_Apply</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="halign">end</property>
<property name="use_underline">True</property>
<signal name="clicked" handler="_on_apply_clicked" swapped="no"/>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
</object>
<packing>
<property name="left_attach">1</property>
<property name="top_attach">1</property>
</packing>
</child>
<style>
<class name="padding-18"/>
</style>
</object>
</interface>
This diff is collapsed.
......@@ -227,6 +227,7 @@ list.settings > row > box {
.margin-top12 { margin-top: 12px; }
.margin-12 { margin: 12px; }
.margin-18 { margin: 18px; }
.padding-18 { margin: 18px; }
/* Treeview */
treeview.space { padding: 6px; }
......@@ -266,5 +267,9 @@ button.flat.link { padding: 0; border: 0; }
.search-treeview { padding: 5px; }
.search-scrolled { border: 1px solid; border-color:@unfocused_borders; }
.gajim-treeview { padding: 4px; }
.gajim-treeview check { padding: 0px; }
.gajim-scrolled { border: 1px solid; border-color:@unfocused_borders; }
#GroupchatJoin > box {padding: 18px; }
\ No newline at end of file
This diff is collapsed.
......@@ -676,6 +676,7 @@ def get_account_menu(account):
(_('Advanced'), [
('-archive', _('Archiving Preferences')),
('-blocking', _('Blocking List')),
('-bookmarks', _('Bookmarks')),
('-sync-history', _('Synchronise History')),
('-privacylists', _('Privacy Lists')),
('-server-info', _('Server Info')),
......
......@@ -77,7 +77,6 @@ from gajim.gtk.dialogs import InvitationReceivedDialog
from gajim.gtk.single_message import SingleMessageWindow
from gajim.gtk.add_contact import AddNewContactWindow
from gajim.gtk.pep_config import ManagePEPServicesWindow
from gajim.gtk.bookmarks import ManageBookmarksWindow
from gajim.gtk.account_wizard import AccountCreationWizard
from gajim.gtk.service_registration import ServiceRegistration
from gajim.gtk.discovery import ServiceDiscoveryWindow
......@@ -3521,9 +3520,6 @@ class RosterWindow:
action.set_state(param)
self.refilter_shown_roster_items()
def on_manage_bookmarks_menuitem_activate(self, widget):
ManageBookmarksWindow()
def on_execute_command(self, widget, contact, account, resource=None):
"""
Execute command. Full JID needed; if it is other contact, resource is
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment