mirror of
https://github.com/MCV-Software/TWBlue.git
synced 2024-11-26 04:48:09 -06:00
Focus is handled in Gtk, accelerators and some menu items work
This commit is contained in:
parent
d8581f47d2
commit
48e918adb0
@ -305,9 +305,7 @@ class baseBufferController(bufferController):
|
||||
|
||||
def bind_events(self):
|
||||
log.debug("Binding events...")
|
||||
### disconnect this for wx
|
||||
# self.buffer.list.list.Bind(wx.EVT_LIST_ITEM_FOCUSED, self.onFocus)
|
||||
# self.buffer.list.list.Bind(wx.EVT_CHAR_HOOK, self.get_event)
|
||||
self.buffer.set_focus_function(self.onFocus)
|
||||
widgetUtils.connect_event(self.buffer, widgetUtils.BUTTON_PRESSED, self.post_tweet, self.buffer.tweet)
|
||||
# if self.type == "baseBuffer":
|
||||
widgetUtils.connect_event(self.buffer, widgetUtils.BUTTON_PRESSED, self.retweet, self.buffer.retweet)
|
||||
@ -372,9 +370,9 @@ class baseBufferController(bufferController):
|
||||
elif answer == widgetUtils.NO:
|
||||
call_threaded(self.session.api_call, call_name="retweet", _sound="retweet_send.ogg", id=id)
|
||||
|
||||
def onFocus(self, ev):
|
||||
def onFocus(self, *args, **kwargs):
|
||||
tweet = self.get_tweet()
|
||||
if self.session.settings["general"]["relative_times"] == True:
|
||||
if platform.system() == "Windows" and self.session.settings["general"]["relative_times"] == True:
|
||||
# fix this:
|
||||
original_date = arrow.get(self.session.db[self.name][self.buffer.list.get_selected()]["created_at"], "ddd MMM D H:m:s Z YYYY", locale="en")
|
||||
ts = original_date.humanize(locale=languageHandler.getLanguage())
|
||||
|
@ -14,7 +14,7 @@ if system == "Windows":
|
||||
import user
|
||||
from issueReporter import issueReporter
|
||||
elif system == "Linux":
|
||||
from gtkUI import (view,)
|
||||
from gtkUI import (view, commonMessageDialogs)
|
||||
from twitter import utils
|
||||
from sessionmanager import manager, sessionManager
|
||||
|
||||
@ -116,21 +116,25 @@ class Controller(object):
|
||||
log.debug("Binding other application events...")
|
||||
pub.subscribe(self.logout_account, "logout")
|
||||
pub.subscribe(self.login_account, "login")
|
||||
pub.subscribe(self.invisible_shorcuts_changed, "invisible-shorcuts-changed")
|
||||
pub.subscribe(self.manage_stream_errors, "stream-error")
|
||||
pub.subscribe(self.create_new_buffer, "create-new-buffer")
|
||||
pub.subscribe(self.restart_streams, "restart-streams")
|
||||
|
||||
if system == "Windows":
|
||||
pub.subscribe(self.invisible_shorcuts_changed, "invisible-shorcuts-changed")
|
||||
widgetUtils.connect_event(self.view, widgetUtils.MENU, self.show_hide, menuitem=self.view.show_hide)
|
||||
widgetUtils.connect_event(self.view, widgetUtils.MENU, self.search, menuitem=self.view.menuitem_search)
|
||||
widgetUtils.connect_event(self.view, widgetUtils.MENU, self.get_trending_topics, menuitem=self.view.trends)
|
||||
widgetUtils.connect_event(self.view, widgetUtils.MENU, self.learn_sounds, menuitem=self.view.sounds_tutorial)
|
||||
widgetUtils.connect_event(self.view, widgetUtils.MENU, self.accountConfiguration, menuitem=self.view.account_settings)
|
||||
widgetUtils.connect_event(self.view, widgetUtils.MENU, self.configuration, menuitem=self.view.prefs)
|
||||
|
||||
widgetUtils.connect_event(self.view, widgetUtils.MENU, self.learn_sounds, menuitem=self.view.sounds_tutorial)
|
||||
widgetUtils.connect_event(self.view, widgetUtils.MENU, self.exit, menuitem=self.view.close)
|
||||
widgetUtils.connect_event(self.view, widgetUtils.CLOSE_EVENT, self.exit)
|
||||
if widgetUtils.toolkit == "wx":
|
||||
log.debug("Binding the exit function...")
|
||||
widgetUtils.connectExitFunction(self.exit_)
|
||||
widgetUtils.connect_event(self.view, widgetUtils.MENU, self.edit_keystrokes, menuitem=self.view.keystroke_editor)
|
||||
widgetUtils.connect_event(self.view, widgetUtils.MENU, self.post_tweet, self.view.compose)
|
||||
widgetUtils.connect_event(self.view, widgetUtils.MENU, self.post_reply, self.view.reply)
|
||||
widgetUtils.connect_event(self.view, widgetUtils.MENU, self.post_retweet, self.view.retweet)
|
||||
@ -153,7 +157,6 @@ class Controller(object):
|
||||
widgetUtils.connect_event(self.view, widgetUtils.MENU, self.check_for_updates, self.view.check_for_updates)
|
||||
widgetUtils.connect_event(self.view, widgetUtils.MENU, self.about, menuitem=self.view.about)
|
||||
widgetUtils.connect_event(self.view, widgetUtils.MENU, self.visit_website, menuitem=self.view.visit_website)
|
||||
widgetUtils.connect_event(self.view, widgetUtils.MENU, self.edit_keystrokes, menuitem=self.view.keystroke_editor)
|
||||
widgetUtils.connect_event(self.view, widgetUtils.MENU, self.manage_accounts, self.view.manage_accounts)
|
||||
widgetUtils.connect_event(self.view, widgetUtils.MENU, self.update_profile, menuitem=self.view.updateProfile)
|
||||
widgetUtils.connect_event(self.view, widgetUtils.MENU, self.user_details, menuitem=self.view.details)
|
||||
@ -162,6 +165,7 @@ class Controller(object):
|
||||
widgetUtils.connect_event(self.view, widgetUtils.MENU, self.open_timeline, self.view.timeline)
|
||||
widgetUtils.connect_event(self.view, widgetUtils.MENU, self.open_favs_timeline, self.view.favs)
|
||||
widgetUtils.connect_event(self.view, widgetUtils.MENU, self.open_conversation, menuitem=self.view.view_conversation)
|
||||
if widgetUtils.toolkit == "wx":
|
||||
widgetUtils.connect_event(self.view.nb, widgetUtils.NOTEBOOK_PAGE_CHANGED, self.buffer_changed)
|
||||
widgetUtils.connect_event(self.view, widgetUtils.MENU, self.report_error, self.view.reportError)
|
||||
|
||||
@ -202,8 +206,8 @@ class Controller(object):
|
||||
self.current_account = ""
|
||||
self.view.prepare()
|
||||
self.bind_stream_events()
|
||||
if system == "Windows":
|
||||
self.bind_other_events()
|
||||
if system == "Windows":
|
||||
self.set_systray_icon()
|
||||
|
||||
def check_invisible_at_startup(self):
|
||||
@ -471,7 +475,7 @@ class Controller(object):
|
||||
|
||||
def exit(self, *args, **kwargs):
|
||||
if config.app["app-settings"]["ask_at_exit"] == True:
|
||||
answer = commonMessageDialogs.exit_dialog()
|
||||
answer = commonMessageDialogs.exit_dialog(self.view)
|
||||
if answer == widgetUtils.YES:
|
||||
self.exit_()
|
||||
else:
|
||||
|
@ -124,6 +124,7 @@ class tweet(basicTweet):
|
||||
self.message.set("upload_image", _(u"Upload a picture"))
|
||||
else:
|
||||
self.image = self.message.get_image()
|
||||
if self.image != None:
|
||||
self.message.set("upload_image", _(u"Discard image"))
|
||||
|
||||
def autocomplete_users(self, *args, **kwargs):
|
||||
|
@ -29,3 +29,7 @@ class basePanel(Gtk.VBox):
|
||||
self.list.select_item(self.list.get_count()-1)
|
||||
else:
|
||||
self.list.select_item(0)
|
||||
|
||||
def set_focus_function(self, f):
|
||||
tree_selection = self.list.list.get_selection()
|
||||
tree_selection.connect("changed", f)
|
||||
|
@ -16,7 +16,7 @@ def delete_tweet_dialog(parent):
|
||||
return answer
|
||||
|
||||
def exit_dialog(parent):
|
||||
dialog = Gtk.MessageDialog(None, 0, Gtk.MessageType.QUESTION, Gtk.ButtonsType.YES_NO, _(u"Exit"))
|
||||
dialog = Gtk.MessageDialog(parent, 0, Gtk.MessageType.QUESTION, Gtk.ButtonsType.YES_NO, _(u"Exit"))
|
||||
dialog.format_secondary_text(_(u"Do you really want to close TW Blue?"))
|
||||
answer = dialog.run()
|
||||
dialog.destroy()
|
||||
|
@ -8,6 +8,7 @@ class textLimited(widgetUtils.baseDialog):
|
||||
|
||||
def createTextArea(self, message="", text=""):
|
||||
self.label = Gtk.Label(message)
|
||||
self.set_title(message, titleWindow=True)
|
||||
self.text = Gtk.Entry()
|
||||
self.text.set_text(text)
|
||||
self.text.set_placeholder_text(message)
|
||||
@ -16,6 +17,18 @@ class textLimited(widgetUtils.baseDialog):
|
||||
self.textBox.add(self.label)
|
||||
self.textBox.add(self.text)
|
||||
|
||||
def get(self, control):
|
||||
if control == "upload_image":
|
||||
return self.upload_image.get_label()
|
||||
elif control == "cb":
|
||||
return self.cb.get_active_text()
|
||||
|
||||
def set(self, control, val):
|
||||
if control == "upload_image":
|
||||
self.upload_image.set_label(val)
|
||||
elif control == "cb":
|
||||
self.cb.set_active_text(val)
|
||||
|
||||
def text_focus(self):
|
||||
self.text.grab_focus()
|
||||
|
||||
@ -25,8 +38,11 @@ class textLimited(widgetUtils.baseDialog):
|
||||
def set_text(self, text):
|
||||
self.text.set_text(text)
|
||||
|
||||
def set_title(self, new_title):
|
||||
def set_title(self, new_title, titleWindow=False):
|
||||
if titleWindow == False:
|
||||
self.text.set_placeholder_text(new_title)
|
||||
else:
|
||||
super(textLimited, self).set_title(new_title)
|
||||
# self.set_title(new_title)
|
||||
|
||||
def enable_button(self, buttonName):
|
||||
@ -78,10 +94,27 @@ class tweet(textLimited):
|
||||
self.show_all()
|
||||
|
||||
def get_image(self):
|
||||
openFileDialog = wx.FileDialog(self, _(u"Select the picture to be uploaded"), "", "", _("Image files (*.png, *.jpg, *.gif)|*.png; *.jpg; *.gif"), wx.FD_OPEN | wx.FD_FILE_MUST_EXIST)
|
||||
if openFileDialog.ShowModal() == wx.ID_CANCEL:
|
||||
dialog = Gtk.FileChooserDialog(_(u"Select the picture to be uploaded"), self, Gtk.FileChooserAction.OPEN, (Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL, Gtk.STOCK_OPEN, Gtk.ResponseType.OK))
|
||||
filter_jpg = Gtk.FileFilter()
|
||||
filter_jpg.set_name(_(u"JPG images"))
|
||||
filter_jpg.add_mime_type("image/jpeg")
|
||||
dialog.add_filter(filter_jpg)
|
||||
filter_gif = Gtk.FileFilter()
|
||||
filter_gif.set_name(_(u"GIF images"))
|
||||
filter_gif.add_mime_type("image/gif")
|
||||
dialog.add_filter(filter_gif)
|
||||
filter_png = Gtk.FileFilter()
|
||||
filter_png.set_name(_(u"PNG Images"))
|
||||
filter_png.add_mime_type("image/png")
|
||||
dialog.add_filter(filter_png)
|
||||
answer = dialog.run()
|
||||
if answer == widgetUtils.OK:
|
||||
image = dialog.get_filename()
|
||||
dialog.destroy()
|
||||
return open(image, "rb")
|
||||
else:
|
||||
dialog.destroy()
|
||||
return None
|
||||
return open(openFileDialog.GetPath(), "rb")
|
||||
|
||||
class dm(textLimited):
|
||||
def createControls(self, title, message, users):
|
||||
@ -121,11 +154,6 @@ class dm(textLimited):
|
||||
self.box.add(self.buttonsBox1)
|
||||
self.text.grab_focus()
|
||||
|
||||
|
||||
def get(self, control):
|
||||
if control == "cb":
|
||||
return self.cb.get_active_text()
|
||||
|
||||
def __init__(self, title, message, users):
|
||||
super(dm, self).__init__()
|
||||
self.createControls(message, title, users)
|
||||
@ -150,7 +178,7 @@ class reply(tweet):
|
||||
class viewTweet(widgetUtils.baseDialog):
|
||||
def set_title(self, lenght):
|
||||
pass
|
||||
# self.set_title(_(u"Tweet - %i characters ") % (lenght,))
|
||||
self.set_title(_(u"Tweet - %i characters ") % (lenght,))
|
||||
|
||||
def __init__(self, text, rt_count, favs_count):
|
||||
super(viewTweet, self).__init__(buttons=(Gtk.STOCK_OK, widgetUtils.OK, Gtk.STOCK_CANCEL, widgetUtils.CANCEL))
|
||||
@ -158,8 +186,8 @@ class viewTweet(widgetUtils.baseDialog):
|
||||
self.text = Gtk.TextView()
|
||||
self.textBuffer = self.text.get_buffer()
|
||||
self.textBuffer.set_text(text)
|
||||
self.textBuffer.set_editable(False)
|
||||
self.text.set_placeholder_text(message)
|
||||
self.text.set_editable(False)
|
||||
# self.textBuffer.set_placeholder_text(message)
|
||||
textBox = Gtk.Box(spacing=6)
|
||||
textBox.add(label)
|
||||
textBox.add(self.text)
|
||||
@ -191,7 +219,7 @@ class viewTweet(widgetUtils.baseDialog):
|
||||
buttonsBox.add(self.spellcheck)
|
||||
buttonsBox.add(self.unshortenButton)
|
||||
buttonsBox.add(self.translateButton)
|
||||
self.box.Add(buttonsBox)
|
||||
self.box.add(buttonsBox)
|
||||
self.show_all()
|
||||
|
||||
def set_text(self, text):
|
||||
|
@ -1,7 +1,7 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
import application
|
||||
import widgetUtils
|
||||
from gi.repository import Gtk
|
||||
from gi.repository import Gtk, Gdk
|
||||
|
||||
class mainFrame(Gtk.Window):
|
||||
""" Main class of the Frame. This is the Main Window."""
|
||||
@ -18,30 +18,38 @@ class mainFrame(Gtk.Window):
|
||||
# Application menu
|
||||
app = Gtk.Menu()
|
||||
|
||||
self.manage_accounts = Gtk.MenuItem(label="Manage accounts")
|
||||
self.manage_accounts = Gtk.MenuItem(label=_(u"Manage accounts"))
|
||||
self.updateProfile = Gtk.MenuItem(label="Update profile")
|
||||
self.updateProfile.add_accelerator("activate", self.accel_group, ord("U"), Gdk.ModifierType.CONTROL_MASK, Gtk.AccelFlags.VISIBLE)
|
||||
# As in Gtk is not possible to bind keyboard shorcuts to the system, we don't have support for an invisible interface.
|
||||
self.show_hide = None
|
||||
self.menuitem_search = Gtk.MenuItem(label="Search")
|
||||
self.trends = Gtk.MenuItem(label="View trending topics")
|
||||
self.trends.add_accelerator("activate", self.accel_group, ord("T"), Gdk.ModifierType.CONTROL_MASK, Gtk.AccelFlags.VISIBLE)
|
||||
self.lists = Gtk.MenuItem(label="Lists manager")
|
||||
self.sounds_tutorial = Gtk.MenuItem(label="Sounds tutorial")
|
||||
self.keystrokes_editor = None
|
||||
self.account_settings = Gtk.MenuItem(label="Account settings")
|
||||
self.prefs = Gtk.MenuItem(label="Global settings")
|
||||
self.close = Gtk.MenuItem(label="Close")
|
||||
self.close.add_accelerator("activate", self.accel_group, ord("Q"), Gdk.ModifierType.CONTROL_MASK, Gtk.AccelFlags.VISIBLE)
|
||||
self.append_to_menu(app, self.manage_accounts, self.updateProfile, self.menuitem_search, self.trends, self.lists, self.sounds_tutorial, self.account_settings, self.prefs, self.close)
|
||||
|
||||
app_menu = Gtk.MenuItem(label="Application")
|
||||
app_menu.add_accelerator("activate", self.accel_group, ord("a"), Gdk.ModifierType.CONTROL_MASK, Gtk.AccelFlags.VISIBLE)
|
||||
app_menu.set_submenu(app)
|
||||
menuBar.append(app_menu)
|
||||
|
||||
# Tweet menu
|
||||
tweet = Gtk.Menu()
|
||||
self.compose = Gtk.MenuItem(label="Tweet")
|
||||
self.compose.add_accelerator("activate", self.accel_group, ord("N"), Gdk.ModifierType.CONTROL_MASK, Gtk.AccelFlags.VISIBLE)
|
||||
self.reply = Gtk.MenuItem(label="Reply")
|
||||
self.reply.add_accelerator("activate", self.accel_group, ord("R"), Gdk.ModifierType.CONTROL_MASK, Gtk.AccelFlags.VISIBLE)
|
||||
self.retweet = Gtk.MenuItem(label="Retweet")
|
||||
self.retweet.add_accelerator("activate", self.accel_group, ord("T"), Gdk.ModifierType.CONTROL_MASK, Gtk.AccelFlags.VISIBLE)
|
||||
self.fav = Gtk.MenuItem(label="Add to favourites")
|
||||
self.fav.add_accelerator("activate", self.accel_group, ord("F"), Gdk.ModifierType.CONTROL_MASK, Gtk.AccelFlags.VISIBLE)
|
||||
self.unfav = Gtk.MenuItem(label="Remove from favourites")
|
||||
self.view = Gtk.MenuItem(label="Show tweet")
|
||||
self.view_coordinates = Gtk.MenuItem(label="View address")
|
||||
@ -103,6 +111,8 @@ class mainFrame(Gtk.Window):
|
||||
def __init__(self):
|
||||
""" Main function of this class."""
|
||||
super(mainFrame, self).__init__(title="TW Blue")
|
||||
self.accel_group = Gtk.AccelGroup()
|
||||
self.add_accel_group(self.accel_group)
|
||||
self.box = Gtk.VBox()
|
||||
self.makeMenus()
|
||||
self.nb = widgetUtils.notebook()
|
||||
|
@ -108,6 +108,12 @@ class notebook(object):
|
||||
column.set_cell_data_func(cell, self.get_buffer)
|
||||
self.view.append_column(column)
|
||||
|
||||
def get_current_page(self):
|
||||
tree_selection = self.view.get_selection()
|
||||
(model, pathlist) = tree_selection.get_selected_rows()
|
||||
iter = pathlist[0]
|
||||
return self.store[iter][0].buffer
|
||||
|
||||
def get_buffer(self, column, cell, model, iter, data):
|
||||
cell.set_property('text', self.store.get_value(iter, 0).name)
|
||||
|
||||
|
@ -4,6 +4,9 @@ from multiplatform_widgets import widgets
|
||||
|
||||
class basePanel(wx.Panel):
|
||||
|
||||
def set_focus_function(self, f):
|
||||
self.list.list.Bind(wx.EVT_LIST_ITEM_FOCUSED, f)
|
||||
|
||||
def create_list(self):
|
||||
self.list = widgets.list(self, _(u"User"), _(u"Text"), _(u"Date"), _(u"Client"), style=wx.LC_REPORT|wx.LC_SINGLE_SEL|wx.LC_VRULES)
|
||||
self.list.set_windows_size(0, 60)
|
||||
|
@ -7,8 +7,8 @@ def retweet_question(parent):
|
||||
def delete_tweet_dialog(parent):
|
||||
return wx.MessageDialog(parent, _(u"Do you really want to delete this message? It will be eliminated from Twitter as well."), _(u"Delete"), wx.ICON_QUESTION|wx.YES_NO).ShowModal()
|
||||
|
||||
def exit_dialog():
|
||||
dlg = wx.MessageDialog(None, _(u"Do you really want to close TW Blue?"), _(u"Exit"), wx.YES_NO|wx.ICON_QUESTION)
|
||||
def exit_dialog(parent):
|
||||
dlg = wx.MessageDialog(parent, _(u"Do you really want to close TW Blue?"), _(u"Exit"), wx.YES_NO|wx.ICON_QUESTION)
|
||||
return dlg.ShowModal()
|
||||
|
||||
def needs_restart():
|
||||
|
@ -12,7 +12,7 @@ class mainFrame(wx.Frame):
|
||||
|
||||
# Application menu
|
||||
app = wx.Menu()
|
||||
self.manage_accounts = app.Append(wx.NewId(), _(u"Manage accounts"))
|
||||
self.manage_accounts = app.Append(wx.NewId(), _(u"&Manage accounts"))
|
||||
self.updateProfile = app.Append(wx.NewId(), _(u"&Update profile"))
|
||||
self.show_hide = app.Append(wx.NewId(), _(u"&Hide window"))
|
||||
self.menuitem_search = app.Append(wx.NewId(), _(u"&Search"))
|
||||
|
Loading…
Reference in New Issue
Block a user