Ticket #721: gc_tooltips.diff

File gc_tooltips.diff, 8.5 KB (added by Sef, 5 years ago)

patch enbaling tooltips in GC window

  • src/tooltips.py

     
    241241                self.text_lable.set_markup(text) 
    242242                self.hbox.add(self.table) 
    243243                self.win.add(self.hbox) 
     244class GCTooltip(BaseTooltip, StatusTable): 
     245        ''' Tooltip that is shown in the GC treeview ''' 
     246        def __init__(self, plugin): 
     247                self.account = None 
     248                self.plugin = plugin 
    244249                 
     250                self.image = gtk.Image() 
     251                self.image.set_alignment(0.5, 0.025) 
     252                BaseTooltip.__init__(self) 
     253                StatusTable.__init__(self) 
     254                 
     255        def populate(self, contact): 
     256                if not contact : 
     257                        return 
     258                self.create_window() 
     259                self.hbox = gtk.HBox() 
     260                self.hbox.set_homogeneous(False) 
     261                self.create_table() 
     262                # primary contact 
     263         
     264                info = '<span size="large" weight="bold">' + contact.name + '</span>' 
     265                info += '\n<span weight="bold">' + _('Role: ') + '</span>' + \ 
     266                        gtkgui_helpers.escape_for_pango_markup(contact.role) 
     267 
     268                info += '\n<span weight="bold">' + _('Affiliation: ') + '</span>' + \ 
     269                        gtkgui_helpers.escape_for_pango_markup(contact.affiliation) 
     270 
     271                info += '\n<span weight="bold">' + _('Status: ') + \ 
     272                                        '</span>' + helpers.get_uf_show(contact.show) 
     273                single_line, resource_str, multiple_resource= '', '', False 
     274                num_resources = 0 
     275         
     276                self.text_lable.set_markup(info) 
     277                self.hbox.pack_start(self.image, False, False) 
     278                self.hbox.pack_start(self.table, True, True) 
     279                self.win.add(self.hbox)  
     280 
     281 
    245282class RosterTooltip(BaseTooltip, StatusTable): 
    246283        ''' Tooltip that is shown in the roster treeview ''' 
    247284        def __init__(self, plugin): 
     
    411448                text += status 
    412449                self.text_lable.set_markup(text) 
    413450                self.hbox.add(self.text_lable) 
    414                 self.win.add(self.hbox) 
     451                 
  • src/gtkgui.glade

     
    88658865                      <signal name="row_expanded" handler="on_list_treeview_row_expanded" last_modification_time="Sat, 05 Mar 2005 00:31:57 GMT"/> 
    88668866                      <signal name="button_press_event" handler="on_list_treeview_button_press_event" last_modification_time="Sat, 05 Mar 2005 00:32:05 GMT"/> 
    88678867                      <signal name="key_press_event" handler="on_list_treeview_key_press_event" last_modification_time="Sat, 26 Mar 2005 20:42:24 GMT"/> 
     8868                      <signal name="motion_notify_event" handler="on_list_treeview_motion_notify_event" last_modification_time="Thu, 18 Aug 2005 23:11:24 GMT"/> 
     8869                      <signal name="leave_notify_event" handler="on_list_treeview_leave_notify_event" last_modification_time="Thu, 18 Aug 2005 23:11:51 GMT"/> 
    88688870                    </widget> 
    88698871                  </child> 
    88708872                </widget> 
     
    1757417576              <accessibility> 
    1757517577                <atkproperty name="AtkObject::accessible_name" translatable="yes">Remove file transfer from the list.</atkproperty> 
    1757617578                <atkproperty name="AtkObject::accessible_description" translatable="yes">This action removes single file transfer from the list. If the transfer is active, it is first stopped and then removed</atkproperty> 
    17577                 <atkaction action_name="click" description="Removing selected file transfer"/> 
    1757817579              </accessibility> 
    1757917580              <signal name="clicked" handler="on_remove_button_clicked" last_modification_time="Wed, 03 Aug 2005 00:23:18 GMT"/> 
    1758017581            </widget> 
     
    1760817609              <accessibility> 
    1760917610                <atkproperty name="AtkObject::accessible_name" translatable="yes" comments="Ι'm a atk sting that should say Cancel instead of stop. say that to nkoukr">Stop file transfer</atkproperty> 
    1761017611                <atkproperty name="AtkObject::accessible_description" translatable="yes" comments="Ι'm a atk sting that should say Cancel instead of stop and should not have space at the end nor dot. say that to nkour">Stops the selected file transfer. If there is an incomplete file, kept in the file system it will be removed. This operation is not reversable. </atkproperty> 
    17611                 <atkaction action_name="click" description="Stoping selected file transfer"/> 
    1761217612              </accessibility> 
    1761317613              <signal name="clicked" handler="on_cancel_button_clicked" last_modification_time="Tue, 09 Aug 2005 17:07:31 GMT"/> 
    1761417614            </widget> 
     
    1765017650          <property name="draw_indicator">True</property> 
    1765117651          <accessibility> 
    1765217652            <atkproperty name="AtkObject::accessible_description" translatable="yes" comments="I'm atk string. please remove my last space for 0.9. Remind that to nkour (he's a poor man)">When a file transfer is complete show a popup notification </atkproperty> 
    17653             <atkaction action_name="press" description="Activate/Disable notification for when a file transfer is complete"/> 
    1765417653          </accessibility> 
    1765517654          <signal name="toggled" handler="on_notify_ft_complete_checkbox_toggled" last_modification_time="Wed, 31 Aug 2005 22:52:01 GMT"/> 
    1765617655        </widget> 
  • src/groupchat_window.py

     
    2727import cell_renderer_image 
    2828import gtkgui_helpers 
    2929import history_window 
     30import tooltips 
    3031 
    3132from gajim import Contact 
    3233from common import gajim 
     
    6566                self.gc_refer_to_nick_char = gajim.config.get('gc_refer_to_nick_char') 
    6667                self.new_room(room_jid, nick) 
    6768                self.show_title() 
     69                self.tooltip = tooltips.GCTooltip(plugin) 
    6870                 
    6971                 
    7072                # NOTE: if it not a window event, connect in new_room function 
     
    7476'on_groupchat_window_focus_in_event': self.on_groupchat_window_focus_in_event, 
    7577'on_groupchat_window_focus_out_event': self.on_groupchat_window_focus_out_event, 
    7678'on_chat_notebook_key_press_event': self.on_chat_notebook_key_press_event, 
     79#'on_list_treeview_motion_notify_event': self.on_list_treeview_motion_notify_event, 
     80#'on_list_treeview_leave_notify_event': self.on_list_treeview_leave_notify_event, 
    7781         } 
    7882 
    7983                self.xml.signal_autoconnect(signal_dict) 
     
    10771081                self.got_disconnected(room_jid) #init some variables 
    10781082                conversation_textview.grab_focus() 
    10791083                self.childs[room_jid].show_all() 
    1080  
     1084         
     1085        def on_list_treeview_motion_notify_event(self, widget, event): 
     1086                model = widget.get_model() 
     1087                props = widget.get_path_at_pos(int(event.x), int(event.y)) 
     1088                if self.tooltip.timeout > 0: 
     1089                        if not props or self.tooltip.id != props[0]: 
     1090                                self.tooltip.hide_tooltip() 
     1091                if props: 
     1092                        [row, col, x, y] = props 
     1093                        iter = None 
     1094                        try: 
     1095                                iter = model.get_iter(row) 
     1096                        except: 
     1097                                self.tooltip.hide_tooltip() 
     1098                                return 
     1099                        #print model[iter][2] 
     1100                        room_jid = self.get_active_jid() 
     1101                        nick = model[iter][1] 
     1102                        fjid = gajim.construct_fjid(room_jid, nick) 
     1103                        #print nick,fjid 
     1104                        #print self.plugin.windows[self.account]['gc'] 
     1105                        #print gajim.gc_contacts[self.account] 
     1106                        if nick != 'moderator' and nick !='participant' : 
     1107                                #print model[iter][1], model[iter][2],  model[iter][0] 
     1108                                account = self.account 
     1109                                jid = fjid 
     1110                                img = model[iter][0] 
     1111                                if self.tooltip.timeout == 0 or self.tooltip.id != props[0]: 
     1112                                        self.tooltip.id = row 
     1113                                        self.tooltip.timeout = gobject.timeout_add(500, 
     1114                                                self.show_tooltip, gajim.gc_contacts[account][room_jid][nick]) 
     1115                pass 
     1116                 
     1117        def on_list_treeview_leave_notify_event(self, widget, event): 
     1118                model = widget.get_model() 
     1119                props = widget.get_path_at_pos(int(event.x), int(event.y)) 
     1120                if self.tooltip.timeout > 0: 
     1121                        if not props or self.tooltip.id == props[0]: 
     1122                                self.tooltip.hide_tooltip() 
     1123                pass 
     1124                 
     1125        def show_tooltip(self, contact): 
     1126                room_jid = self.get_active_jid() 
     1127                pointer = self.list_treeview[room_jid].get_pointer() 
     1128                props = self.list_treeview[room_jid].get_path_at_pos(pointer[0], pointer[1]) 
     1129                if props and self.tooltip.id == props[0]: 
     1130                        # check if the current pointer is at the same path 
     1131                        # as it was before setting the timeout 
     1132                        rect =  self.list_treeview[room_jid].get_cell_area(props[0],props[1]) 
     1133                        position = self.list_treeview[room_jid].window.get_root_origin() 
     1134                        pointer = self.window.get_pointer() 
     1135                        self.tooltip.show_tooltip(contact, (pointer[0], rect.height ), 
     1136                                 (position[0], position[1] + rect.width)) 
     1137                else: 
     1138                        self.tooltip.hide_tooltip() 
     1139         
    10811140        def on_treeview_size_allocate(self, widget, allocation): 
    10821141                """The MUC treeview has resized. Move the hpaneds in all tabs to match""" 
    10831142                thisroom_jid = self.get_active_jid() 
  • src/gajim.py

     
    11381138                        #else: 
    11391139                        #       self.systray_capabilities = True 
    11401140                        #       self.systray = systraywin32.SystrayWin32(self) 
     1141                        pass 
    11411142                else: 
    11421143                        try: 
    11431144                                import egg.trayicon # use gnomepythonextras trayicon