~dockbar-main/dockbar/dockbarx

« back to all changes in this revision

Viewing changes to dockx_applets/appindicator.py

  • Committer: Matias Särs
  • Date: 2012-10-20 05:22:50 UTC
  • Revision ID: m7s@bastu.net-20121020052250-n8mv4pgl8ilxig7p
- Appindicator menus no longer pop up at mouse pointer location but next to the dock, more like they do in unity.
- Fixed a little visual glitch caused by the last bug fix.
- Removed some left over print statements from the code.

Show diffs side-by-side

added added

removed removed

Lines of Context:
82
82
                                         #~ self.__on_menu_resized)
83
83
        gtkmenu = self.menu.get_menu()
84
84
        self.sd_sid = gtkmenu.connect("selection-done", self.menu_closed)
85
 
        gtkmenu.popup(None, None, None, event.button, event.time)
 
85
        gtkmenu.popup(None, None, self.position_menu,
 
86
                      event.button, event.time)
86
87
 
87
88
    def menu_closed(self, *args):
88
89
        if self.menu is not None:
124
125
        self.title = title
125
126
 
126
127
    def position_menu(self, menu):
127
 
        # Used only with the gtk menu
128
 
        x, y = self.window.get_origin()
 
128
        x, y = self.get_window().get_origin()
129
129
        a = self.get_allocation()
130
 
        x += a.x
131
 
        y += a.y
132
130
        w, h = menu.size_request()
133
 
        if self.dockbar_r().orient == "v":
134
 
            if x < (self.screen.get_width() / 2):
135
 
                x += a.width
136
 
            else:
137
 
                x -= w
138
 
            if y + h > self.screen.get_height():
 
131
        size = self.applet_r().get_size()
 
132
        if self.applet_r().get_position() == "left":
 
133
            x += size
 
134
            y += a.y
 
135
        if self.applet_r().get_position() == "right":
 
136
            x -= w
 
137
            y += a.y
 
138
        if self.applet_r().get_position() == "top":
 
139
            x += a.x
 
140
            y += size
 
141
        if self.applet_r().get_position() == "bottom":
 
142
            x += a.x
 
143
            y -= h
 
144
        screen = self.get_window().get_screen()
 
145
        if y + h > screen.get_height():
139
146
                y -= h - a.height
140
 
        if self.dockbar_r().orient == "h":
141
 
            if y < (self.screen.get_height() / 2):
142
 
                y += a.height
143
 
            else:
144
 
                y -= h
145
 
            if x + w >= self.screen.get_width():
 
147
        if x + w >= screen.get_width():
146
148
                x -= w - a.width
147
149
        return (x, y, False)
148
150