Now About Social Code
aboutsummaryrefslogtreecommitdiff
path: root/src/main.py
diff options
context:
space:
mode:
Diffstat (limited to 'src/main.py')
-rw-r--r--src/main.py28
1 files changed, 24 insertions, 4 deletions
diff --git a/src/main.py b/src/main.py
index 5334516..ffe1e43 100644
--- a/src/main.py
+++ b/src/main.py
@@ -20,6 +20,7 @@
import sys
import os
import gi
+import traceback
gi.require_version('Gtk', '4.0')
gi.require_version('Adw', '1')
@@ -80,6 +81,22 @@ class WeegtkApplication(Adw.Application):
self.buffers.pop(index)
self.pages.pop(index)
+ def find_buffer_index_for_insert(self, next_buffer):
+ """Find position to insert a buffer in list."""
+ index = -1
+ if next_buffer == '0x0':
+ index = len(self.buffers)
+ else:
+ bufs = [i for i, b in enumerate(self.buffers)
+ if b.pointer() == next_buffer]
+ if bufs:
+ index = bufs[0]
+ if index < 0:
+ print('Warning: unable to find position for buffer, using end of '
+ 'list by default')
+ index = len(self.buffers)
+ return index
+
def disconnect(self, *args):
self.network.disconnect_weechat()
@@ -109,9 +126,8 @@ class WeegtkApplication(Adw.Application):
#print(f"parsed message is f{message}")
self.parse_message(message)
except:
- print('Error while decoding message from WeeChat:\n%s'
- % traceback.format_exc())
- self.net.disconnect_weechat()
+ print(f"Error while decoding message from WeeChat:\n{traceback.format_exc()}")
+ self.disconnect()
def do_activate(self):
"""Called when the application is activated.
@@ -298,8 +314,11 @@ class WeegtkApplication(Adw.Application):
self.buffers[index].data['full_name'] = item['full_name']
self.buffers[index].data['short_name'] = item['short_name']
elif message.msgid == '_buffer_title_changed':
+ # TODO figure out what to do when we get a title change
+ # as grep plugin seems to override title with results
+ # which can break UI
self.buffers[index].data['title'] = item['title']
- self.buffers[index].update_title()
+ ##self.pages[index].set_title(item['title'])
elif message.msgid == '_buffer_cleared':
self.buffers[index].widget.chat.clear()
elif message.msgid.startswith('_buffer_localvar_'):
@@ -347,6 +366,7 @@ class WeegtkApplication(Adw.Application):
# Only make chats visible on main screen
if True or buf.is_chat():
+ print(f"TITLE IS {buf_name}")
page = self.props.active_window.stack.add_titled(buf, name=buf_name, title=buf_name)
if buf.data["full_name"] == "core.weechat":
self.props.active_window.set_page(page)