Welcome to mirror list, hosted at ThFree Co, Russian Federation.

dev.gajim.org/gajim/gajim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorwurstsalat <mailtrash@posteo.de>2022-10-03 18:19:42 +0300
committerwurstsalat <mailtrash@posteo.de>2022-10-03 18:19:45 +0300
commit757ddea13b188b1511c2196ce84710410ddec038 (patch)
treec1a9efaefda33bea1957537e1882aaa99cccf3fd
parentc265de03c21cca4a781a85d15e89c61c8432f0c9 (diff)
imprv: Drag and drop: Highlight target areas
Adds highlighting for workspace and chat list drag and drop Fixes #11173
-rw-r--r--gajim/data/style/gajim.css8
-rw-r--r--gajim/gtk/chat_list.py3
-rw-r--r--gajim/gtk/chat_list_row.py10
-rw-r--r--gajim/gtk/main.py27
-rw-r--r--gajim/gtk/workspace_side_bar.py13
5 files changed, 60 insertions, 1 deletions
diff --git a/gajim/data/style/gajim.css b/gajim/data/style/gajim.css
index 6f752a474..27a3fe270 100644
--- a/gajim/data/style/gajim.css
+++ b/gajim/data/style/gajim.css
@@ -813,6 +813,14 @@ button.flat.link { padding: 0; border: 0; }
font-weight: bold;
}
+.dnd-target {
+ animation-name: pulse-opacity;
+ animation-duration: 2.0s;
+ animation-timing-function: ease-in-out;
+ animation-iteration-count: infinite;
+ border: 2px dashed @theme_selected_bg_color;
+}
+
@keyframes pulse-opacity {
0% { opacity: 1.0; }
20% { opacity: 0.5; }
diff --git a/gajim/gtk/chat_list.py b/gajim/gtk/chat_list.py
index 14412b854..1d4c07be7 100644
--- a/gajim/gtk/chat_list.py
+++ b/gajim/gtk/chat_list.py
@@ -279,6 +279,9 @@ class ChatList(Gtk.ListBox, EventHelper):
assert isinstance(row, ChatListRow)
self.select_chat(row.account, row.jid)
+ def get_chat_list_rows(self) -> list[ChatListRow]:
+ return cast(list[ChatListRow], self.get_children())
+
def remove_chat(self,
account: str,
jid: JID,
diff --git a/gajim/gtk/chat_list_row.py b/gajim/gtk/chat_list_row.py
index 5c8aebbfd..6783c3557 100644
--- a/gajim/gtk/chat_list_row.py
+++ b/gajim/gtk/chat_list_row.py
@@ -114,6 +114,7 @@ class ChatListRow(Gtk.ListBoxRow):
entries,
Gdk.DragAction.MOVE)
self.connect('drag-begin', self._on_drag_begin)
+ self.connect('drag-end', self._on_drag_end)
self.connect('drag-data-get', self._on_drag_data_get)
if self.type == 'groupchat':
@@ -428,6 +429,15 @@ class ChatListRow(Gtk.ListBoxRow):
self.draw(context)
Gtk.drag_set_icon_surface(drag_context, surface)
+ app.window.highlight_dnd_targets(row, True)
+
+ def _on_drag_end(self,
+ row: ChatListRow,
+ _drag_context: Gdk.DragContext
+ ) -> None:
+
+ app.window.highlight_dnd_targets(row, False)
+
def _on_drag_data_get(self,
_widget: Gtk.Widget,
_drag_context: Gdk.DragContext,
diff --git a/gajim/gtk/main.py b/gajim/gtk/main.py
index a326423a6..d02fee958 100644
--- a/gajim/gtk/main.py
+++ b/gajim/gtk/main.py
@@ -46,6 +46,7 @@ from .workspace_side_bar import WorkspaceSideBar
from .main_stack import MainStack
from .call_window import CallWindow
from .chat_list import ChatList
+from .chat_list_row import ChatListRow
from .chat_stack import ChatStack
from .const import MAIN_WIN_ACTIONS
from .dialogs import DialogButton
@@ -566,6 +567,32 @@ class MainWindow(Gtk.ApplicationWindow, EventHelper):
return False
return self._chat_page.is_chat_active(account, jid)
+ def highlight_dnd_targets(self, drag_row: Any, highlight: bool) -> None:
+ css_class = 'dnd-target'
+
+ if isinstance(drag_row, ChatListRow):
+ chat_list_stack = self._chat_page.get_chat_list_stack()
+ workspace = self.get_active_workspace()
+ if workspace is None:
+ return
+
+ if drag_row.is_pinned:
+ chat_list = chat_list_stack.get_chatlist(workspace)
+ for row in chat_list.get_chat_list_rows():
+ if not row.is_pinned:
+ continue
+
+ if highlight:
+ row.get_style_context().add_class(css_class)
+ else:
+ row.get_style_context().remove_class(css_class)
+
+ if highlight:
+ self._workspace_side_bar.get_style_context().add_class(css_class)
+ else:
+ self._workspace_side_bar.get_style_context().remove_class(
+ css_class)
+
def _add_workspace(self,
_action: Gio.SimpleAction,
param: GLib.Variant) -> None:
diff --git a/gajim/gtk/workspace_side_bar.py b/gajim/gtk/workspace_side_bar.py
index 2d9cd6e0a..e2c6ea6be 100644
--- a/gajim/gtk/workspace_side_bar.py
+++ b/gajim/gtk/workspace_side_bar.py
@@ -322,6 +322,7 @@ class Workspace(CommonWorkspace):
entries,
Gdk.DragAction.MOVE)
eventbox.connect('drag-begin', self._on_drag_begin)
+ eventbox.connect('drag-end', self._on_drag_end)
eventbox.connect('drag-data-get', self._on_drag_data_get)
eventbox.connect('button-press-event', self._popup_menu)
eventbox.add(overlay)
@@ -348,9 +349,10 @@ class Workspace(CommonWorkspace):
self._unread_label.set_visible(bool(count))
def _on_drag_begin(self,
- _widget: Gtk.Widget,
+ row: Workspace,
drag_context: Gdk.DragContext
) -> None:
+
scale = self.get_scale_factor()
surface = app.app.avatar_storage.get_workspace_surface(
self.workspace_id, AvatarSize.WORKSPACE, scale)
@@ -360,6 +362,15 @@ class Workspace(CommonWorkspace):
listbox = cast(WorkspaceSideBar, self.get_parent())
listbox.set_drag_row(self)
+ app.window.highlight_dnd_targets(row, True)
+
+ def _on_drag_end(self,
+ row: Workspace,
+ drag_context: Gdk.DragContext
+ ) -> None:
+
+ app.window.highlight_dnd_targets(row, False)
+
def _on_drag_data_get(self,
_widget: Gtk.Widget,
_drag_context: Gdk.DragContext,