Philipp Hörist pushed to branch master at gajim / gajim
Commits: 80ceee57 by Philipp Hörist at 2017-12-17T22:30:16+01:00 Remove unused methods
Action Button was removed in the last ChatControl redesign
- - - - - e3effdcb by Philipp Hörist at 2017-12-17T22:30:16+01:00 Refactor SubscriptionWindow
- - - - - f4a6b029 by Philipp Hörist at 2017-12-17T22:30:16+01:00 Remove deprecated Gdk.Screen methods
height() and weidth() is not supported any more
- - - - -
7 changed files:
- gajim/chat_control_base.py - − gajim/data/gui/subscription_request_popup_menu.ui - gajim/data/gui/subscription_request_window.ui - gajim/dialogs.py - gajim/gtkgui_helpers.py - gajim/gui_interface.py - gajim/message_window.py
Changes:
===================================== gajim/chat_control_base.py ===================================== --- a/gajim/chat_control_base.py +++ b/gajim/chat_control_base.py @@ -1044,16 +1044,6 @@ class ChatControlBase(MessageControl, ChatCommandProcessor, CommandTools): def on_clear_formatting_menuitem_activate(self, widget): self.msg_textview.clear_tags()
- def on_actions_button_clicked(self, widget): - """ - Popup action menu - """ - menu = self.prepare_context_menu(hide_buttonbar_items=True) - menu.show_all() - menu.attach_to_widget(widget, None) - gtkgui_helpers.popup_emoticons_under_button(menu, widget, - self.parent_win) - def update_tags(self): self.conv_textview.update_tags()
===================================== gajim/data/gui/subscription_request_popup_menu.ui deleted ===================================== --- a/gajim/data/gui/subscription_request_popup_menu.ui +++ /dev/null @@ -1,27 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!-- Generated with glade 3.18.3 --> -<interface> - <requires lib="gtk+" version="3.12"/> - <object class="GtkAccelGroup" id="accelgroup1"/> - <object class="GtkMenu" id="subscription_request_popup_menu"> - <property name="can_focus">False</property> - <child> - <object class="GtkMenuItem" id="start_chat_menuitem"> - <property name="visible">True</property> - <property name="can_focus">False</property> - <property name="label" translatable="yes">_Start Chat</property> - <property name="use_underline">True</property> - <signal name="activate" handler="on_start_chat_activate" swapped="no"/> - </object> - </child> - <child> - <object class="GtkMenuItem" id="information_menuitem"> - <property name="visible">True</property> - <property name="can_focus">False</property> - <property name="label">_Information</property> - <property name="use_underline">True</property> - <signal name="activate" handler="on_contact_info_activate" swapped="no"/> - </object> - </child> - </object> -</interface>
===================================== gajim/data/gui/subscription_request_window.ui ===================================== --- a/gajim/data/gui/subscription_request_window.ui +++ b/gajim/data/gui/subscription_request_window.ui @@ -1,35 +1,88 @@ <?xml version="1.0" encoding="UTF-8"?> -<!-- Generated with glade 3.18.3 --> +<!-- Generated with glade 3.20.1 --> <interface> <requires lib="gtk+" version="3.12"/> - <object class="GtkImage" id="image1"> + <object class="GtkMenu" id="subscription_request_popup_menu"> <property name="visible">True</property> <property name="can_focus">False</property> - <property name="stock">gtk-add</property> + <child> + <object class="GtkMenuItem" id="start_chat_menuitem"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="label" translatable="yes">_Start Chat</property> + <property name="use_underline">True</property> + <signal name="activate" handler="on_start_chat_activate" swapped="no"/> + </object> + </child> + <child> + <object class="GtkMenuItem" id="information_menuitem"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="label">_Information</property> + <property name="use_underline">True</property> + <signal name="activate" handler="on_contact_info_activate" swapped="no"/> + </object> + </child> </object> - <object class="GtkImage" id="image2"> + <object class="GtkBox" id="subscription_box"> <property name="visible">True</property> <property name="can_focus">False</property> - <property name="stock">gtk-cancel</property> - </object> - <object class="GtkTextBuffer" id="textbuffer1"/> - <object class="GtkWindow" id="subscription_request_window"> - <property name="can_focus">False</property> - <property name="border_width">12</property> - <property name="title" translatable="yes">Subscription Request</property> - <property name="resizable">False</property> - <property name="type_hint">dialog</property> - <signal name="destroy" handler="on_subscription_request_window_destroy" swapped="no"/> + <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="orientation">vertical</property> + <property name="spacing">5</property> <child> - <object class="GtkBox" id="vbox10"> + <object class="GtkLabel" id="from_label"> <property name="visible">True</property> <property name="can_focus">False</property> - <property name="orientation">vertical</property> - <property name="spacing">5</property> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">False</property> + <property name="position">0</property> + </packing> + </child> + <child> + <object class="GtkScrolledWindow" id="scrolledwindow8"> + <property name="height_request">100</property> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="border_width">5</property> + <property name="shadow_type">in</property> + <child> + <object class="GtkTextView" id="message_textview"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="editable">False</property> + <property name="wrap_mode">word</property> + <property name="cursor_visible">False</property> + </object> + </child> + </object> + <packing> + <property name="expand">True</property> + <property name="fill">True</property> + <property name="position">1</property> + </packing> + </child> + <child> + <object class="GtkButtonBox" id="hbuttonbox3"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="border_width">5</property> + <property name="spacing">12</property> + <property name="layout_style">end</property> <child> - <object class="GtkLabel" id="from_label"> + <object class="GtkButton" id="close_button"> + <property name="label">_Close</property> <property name="visible">True</property> - <property name="can_focus">False</property> + <property name="can_focus">True</property> + <property name="can_default">True</property> + <property name="receives_default">False</property> + <property name="use_underline">True</property> + <signal name="clicked" handler="on_close_button_clicked" swapped="no"/> </object> <packing> <property name="expand">False</property> @@ -38,154 +91,66 @@ </packing> </child> <child> - <object class="GtkScrolledWindow" id="scrolledwindow8"> - <property name="height_request">100</property> + <object class="GtkButton" id="deny_button"> + <property name="label" translatable="yes">_Deny</property> <property name="visible">True</property> <property name="can_focus">True</property> - <property name="border_width">5</property> - <property name="shadow_type">in</property> + <property name="can_default">True</property> + <property name="receives_default">False</property> + <property name="tooltip_text" translatable="yes">Deny authorization from contact so he or she cannot know when you're connected</property> + <property name="use_underline">True</property> + <signal name="clicked" handler="on_deny_button_clicked" swapped="no"/> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">False</property> + <property name="position">1</property> + </packing> + </child> + <child> + <object class="GtkMenuButton"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="receives_default">True</property> + <property name="popup">subscription_request_popup_menu</property> + <property name="use_popover">False</property> <child> - <object class="GtkTextView" id="message_textview"> + <object class="GtkImage"> <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="editable">False</property> - <property name="wrap_mode">word</property> - <property name="cursor_visible">False</property> - <property name="buffer">textbuffer1</property> + <property name="can_focus">False</property> + <property name="icon_name">applications-system-symbolic</property> </object> </child> </object> <packing> <property name="expand">True</property> <property name="fill">True</property> - <property name="position">1</property> + <property name="position">2</property> </packing> </child> <child> - <object class="GtkButtonBox" id="hbuttonbox3"> + <object class="GtkButton" id="authorize_button"> + <property name="label" translatable="yes">Au_thorize</property> <property name="visible">True</property> - <property name="can_focus">False</property> - <property name="border_width">5</property> - <property name="spacing">12</property> - <property name="layout_style">end</property> - <child> - <object class="GtkButton" id="close_button"> - <property name="label">gtk-close</property> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="can_default">True</property> - <property name="receives_default">False</property> - <property name="use_stock">True</property> - <signal name="clicked" handler="on_close_button_clicked" swapped="no"/> - </object> - <packing> - <property name="expand">False</property> - <property name="fill">False</property> - <property name="position">0</property> - </packing> - </child> - <child> - <object class="GtkButton" id="deny_button"> - <property name="label" translatable="yes">_Deny</property> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="can_default">True</property> - <property name="receives_default">False</property> - <property name="tooltip_text" translatable="yes">Deny authorization from contact so he or she cannot know when you're connected</property> - <property name="image">image2</property> - <property name="use_underline">True</property> - <signal name="clicked" handler="on_deny_button_clicked" swapped="no"/> - </object> - <packing> - <property name="expand">False</property> - <property name="fill">False</property> - <property name="position">1</property> - </packing> - </child> - <child> - <object class="GtkButton" id="actions_button"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="receives_default">False</property> - <signal name="clicked" handler="on_actions_button_clicked" swapped="no"/> - <child> - <object class="GtkBox" id="hbox3009"> - <property name="visible">True</property> - <property name="can_focus">False</property> - <property name="spacing">2</property> - <child> - <object class="GtkImage" id="image1338"> - <property name="visible">True</property> - <property name="can_focus">False</property> - <property name="stock">gtk-execute</property> - </object> - <packing> - <property name="expand">False</property> - <property name="fill">False</property> - <property name="position">0</property> - </packing> - </child> - <child> - <object class="GtkLabel" id="label372"> - <property name="visible">True</property> - <property name="can_focus">False</property> - <property name="label" translatable="yes" comments="Make sure the character after "_" is not M/m (conflicts with Alt+M that is supposed to show the Emoticon Selector)">_Actions</property> - <property name="use_underline">True</property> - </object> - <packing> - <property name="expand">False</property> - <property name="fill">False</property> - <property name="position">1</property> - </packing> - </child> - <child> - <object class="GtkArrow" id="arrow4"> - <property name="visible">True</property> - <property name="can_focus">False</property> - <property name="arrow_type">down</property> - </object> - <packing> - <property name="expand">False</property> - <property name="fill">False</property> - <property name="position">2</property> - </packing> - </child> - </object> - </child> - </object> - <packing> - <property name="expand">False</property> - <property name="fill">False</property> - <property name="position">2</property> - </packing> - </child> - <child> - <object class="GtkButton" id="authorize_button"> - <property name="label" translatable="yes">Au_thorize</property> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="can_default">True</property> - <property name="has_default">True</property> - <property name="receives_default">False</property> - <property name="tooltip_text" translatable="yes">Authorize contact so he or she can know when you're connected</property> - <property name="image">image1</property> - <property name="use_underline">True</property> - <signal name="clicked" handler="on_authorize_button_clicked" swapped="no"/> - </object> - <packing> - <property name="expand">False</property> - <property name="fill">False</property> - <property name="position">3</property> - </packing> - </child> + <property name="can_focus">True</property> + <property name="can_default">True</property> + <property name="receives_default">False</property> + <property name="tooltip_text" translatable="yes">Authorize contact so he or she can know when you're connected</property> + <property name="use_underline">True</property> + <signal name="clicked" handler="on_authorize_button_clicked" swapped="no"/> </object> <packing> <property name="expand">False</property> <property name="fill">False</property> - <property name="position">2</property> + <property name="position">3</property> </packing> </child> </object> + <packing> + <property name="expand">False</property> + <property name="fill">False</property> + <property name="position">2</property> + </packing> </child> </object> </interface>
===================================== gajim/dialogs.py ===================================== --- a/gajim/dialogs.py +++ b/gajim/dialogs.py @@ -2269,10 +2269,18 @@ class DoubleInputDialog: else: self.cancel_handler()
-class SubscriptionRequestWindow: +class SubscriptionRequestWindow(Gtk.ApplicationWindow): def __init__(self, jid, text, account, user_nick=None): + Gtk.ApplicationWindow.__init__(self) + self.set_name('SubscriptionRequest') + self.set_application(app.app) + self.set_show_menubar(False) + self.set_resizable(False) + self.set_position(Gtk.WindowPosition.CENTER) + self.set_title(_('Subscription Request')) + xml = gtkgui_helpers.get_gtk_builder('subscription_request_window.ui') - self.window = xml.get_object('subscription_request_window') + self.add(xml.get_object('subscription_box')) self.jid = jid self.account = account self.user_nick = user_nick @@ -2282,10 +2290,16 @@ class SubscriptionRequestWindow: % {'account': account, 'jid': self.jid} else: prompt_text = _('Subscription request from %s') % self.jid - xml.get_object('from_label').set_text(prompt_text) - xml.get_object('message_textview').get_buffer().set_text(text) + + from_label = xml.get_object('from_label') + from_label.set_text(prompt_text) + + textview = xml.get_object('message_textview') + textview.get_buffer().set_text(text) + + self.set_default(xml.get_object('authorize_button')) xml.connect_signals(self) - self.window.show_all() + self.show_all()
def on_subscription_request_window_destroy(self, widget): """ @@ -2295,21 +2309,15 @@ class SubscriptionRequestWindow: # remove us from open windows del app.interface.instances[self.account]['sub_request'][self.jid]
- def prepare_popup_menu(self): - xml = gtkgui_helpers.get_gtk_builder('subscription_request_popup_menu.ui') - menu = xml.get_object('subscription_request_popup_menu') - xml.connect_signals(self) - return menu - def on_close_button_clicked(self, widget): - self.window.destroy() + self.destroy()
def on_authorize_button_clicked(self, widget): """ Accept the request """ app.connections[self.account].send_authorization(self.jid) - self.window.destroy() + self.destroy() contact = app.contacts.get_contact(self.account, self.jid) if not contact or _('Not in Roster') in contact.groups: AddNewContactWindow(self.account, self.jid, self.user_nick) @@ -2342,16 +2350,7 @@ class SubscriptionRequestWindow: contact = app.contacts.get_contact(self.account, self.jid) if contact and _('Not in Roster') in contact.get_shown_groups(): app.interface.roster.remove_contact(self.jid, self.account) - self.window.destroy() - - def on_actions_button_clicked(self, widget): - """ - Popup action menu - """ - menu = self.prepare_popup_menu() - menu.show_all() - gtkgui_helpers.popup_emoticons_under_button(menu, widget, - self.window.get_window()) + self.destroy()
class JoinGroupchatWindow(Gtk.ApplicationWindow): def __init__(self, account, room_jid, password=None, automatic=None): @@ -3178,11 +3177,12 @@ class PopupNotificationWindow: window_width, self.window_height = self.window.get_size() app.interface.roster.popups_notification_height += self.window_height pos_x = app.config.get('notification_position_x') + screen_w, screen_h = gtkgui_helpers.get_display_geometry() if pos_x < 0: - pos_x = Gdk.Screen.width() - window_width + pos_x + 1 + pos_x = screen_w - window_width + pos_x + 1 pos_y = app.config.get('notification_position_y') if pos_y < 0: - pos_y = Gdk.Screen.height() - \ + pos_y = screen_h - \ app.interface.roster.popups_notification_height + pos_y + 1 self.window.move(pos_x, pos_y)
@@ -3214,8 +3214,9 @@ class PopupNotificationWindow: current_index += 1 window_width, window_height = window_instance.window.get_size() app.interface.roster.popups_notification_height += window_height - window_instance.window.move(Gdk.Screen.width() - window_width, - Gdk.Screen.height() - \ + screen_w, screen_h = gtkgui_helpers.get_display_geometry() + window_instance.window.move(screen_w - window_width, + screen_h - \ app.interface.roster.popups_notification_height)
def on_popup_notification_window_button_press_event(self, widget, event):
===================================== gajim/gtkgui_helpers.py ===================================== --- a/gajim/gtkgui_helpers.py +++ b/gajim/gtkgui_helpers.py @@ -99,8 +99,11 @@ if os.name == 'nt':
from gajim.common import helpers
-screen_w = Gdk.Screen.width() -screen_h = Gdk.Screen.height() +def get_display_geometry(): + display = Gdk.Display.get_default() + monitor = display.get_monitor(0) + geometry = monitor.get_geometry() + return geometry.width, geometry.height
def add_image_to_button(button, icon_name): img = Gtk.Image() @@ -151,43 +154,6 @@ def get_completion_liststore(entry): entry.set_completion(completion) return liststore
- -def popup_emoticons_under_button(menu, button, parent_win): - """ - Popup the emoticons menu under button, which is in parent_win - """ - window_x1, window_y1 = parent_win.get_origin()[1:] - - def position_menu_under_button(menu, _x=None, _y=None, data=None): - # inline function, which will not keep refs, when used as CB - alloc = button.get_allocation() - button_x, button_y = alloc.x, alloc.y - translated_coordinates = button.translate_coordinates( - app.interface.roster.window, 0, 0) - if translated_coordinates: - button_x, button_y = translated_coordinates - - # now convert them to X11-relative - window_x, window_y = window_x1, window_y1 - x = window_x + button_x - y = window_y + button_y - - menu_height = menu.get_preferred_size()[0].height - - ## should we pop down or up? - if (y + alloc.height + menu_height < Gdk.Screen.height()): - # now move the menu below the button - y += alloc.height - else: - # now move the menu above the button - y -= menu_height - - # push_in is True so all the menuitems are always inside screen - push_in = True - return (x, y, push_in) - - menu.popup(None, None, position_menu_under_button, None, 1, 0) - def get_theme_font_for_option(theme, option): """ Return string description of the font, stored in theme preferences @@ -208,6 +174,7 @@ def move_window(window, x, y): """ Move the window, but also check if out of screen """ + screen_w, screen_h = get_display_geometry() if x < 0: x = 0 if y < 0: @@ -223,6 +190,7 @@ def resize_window(window, w, h): """ Resize window, but also checks if huge window or negative values """ + screen_w, screen_h = get_display_geometry() if not w or not h: return if w > screen_w:
===================================== gajim/gui_interface.py ===================================== --- a/gajim/gui_interface.py +++ b/gajim/gui_interface.py @@ -499,7 +499,7 @@ class Interface: account = obj.conn.name if helpers.allow_popup_window(account) or not self.systray_enabled: if obj.jid in self.instances[account]['sub_request']: - self.instances[account]['sub_request'][obj.jid].window.destroy() + self.instances[account]['sub_request'][obj.jid].destroy() self.instances[account]['sub_request'][obj.jid] = \ dialogs.SubscriptionRequestWindow(obj.jid, obj.status, account, obj.user_nick) @@ -829,7 +829,7 @@ class Interface: self.roster.draw_contact(obj.jid, account) if obj.jid in self.instances[account]['sub_request'] and obj.sub in ( 'from', 'both'): - self.instances[account]['sub_request'][obj.jid].window.destroy() + self.instances[account]['sub_request'][obj.jid].destroy()
def handle_event_bookmarks(self, obj): # ('BOOKMARKS', account, [{name,jid,autojoin,password,nick}, {}])
===================================== gajim/message_window.py ===================================== --- a/gajim/message_window.py +++ b/gajim/message_window.py @@ -451,11 +451,6 @@ class MessageWindow(object): elif keyval == Gdk.KEY_m: # ALT + M show emoticons menu control.emoticons_button.get_popover().show() return True - elif keyval == Gdk.KEY_d: # ALT + D show actions menu - if Gtk.Settings.get_default().get_property( - 'gtk-key-theme-name') != 'Emacs': - control.on_actions_button_clicked(control.actions_button) - return True elif control.type_id == message_control.TYPE_GC and \ keyval == Gdk.KEY_t: # ALT + t control._on_change_subject_menuitem_activate(None)
View it on GitLab: https://dev.gajim.org/gajim/gajim/compare/8f2630b10f18edf0741ad6bf3267bcc376...
--- View it on GitLab: https://dev.gajim.org/gajim/gajim/compare/8f2630b10f18edf0741ad6bf3267bcc376... You're receiving this email because of your account on dev.gajim.org.