Status: | Merged |
---|---|
Merge reported by: | Thiago Teixeira |
Merged at revision: | not available |
Proposed branch: | lp:~benpicco/cardapio/mate |
Merge into: | lp:cardapio |
Diff against target: |
743 lines (+589/-6) 11 files modified
Makefile (+27/-2) src/Cardapio.py (+1/-1) src/CardapioAppletInterface.py (+1/-0) src/DesktopEnvironment.py (+30/-2) src/cardapio (+25/-0) src/gnomepanel/CardapioGnomeApplet.py (+1/-1) src/matepanel/CardapioMateApplet.py (+419/-0) src/matepanel/CardapioMateAppletFactory.py (+26/-0) src/matepanel/cardapio-mate-panel-applet (+30/-0) src/matepanel/cardapio.server (+27/-0) src/matepanel/cardapio.server.h (+2/-0) |
To merge this branch: | bzr merge lp:~benpicco/cardapio/mate |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Thiago Teixeira | Pending | ||
Review via email: mp+88795@code.launchpad.net |
Commit message
Description of the change
I've forked the gnomepanel component and ran the mate migrate script (just changes gnome strings to mate strings) so that it works with the Gnome 2 fork Mate.
To post a comment you must log in.
lp:~benpicco/cardapio/mate
updated
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'Makefile' |
2 | --- Makefile 2011-11-17 07:33:21 +0000 |
3 | +++ Makefile 2012-01-17 03:21:25 +0000 |
4 | @@ -21,7 +21,7 @@ |
5 | $(MAKE) -f $(CURDIR)/debian/rules clean |
6 | find . -name '*.pyc' -delete |
7 | |
8 | -install: install-alone install-panel install-docky install-awn install-shell |
9 | +install: install-alone install-panel install-docky install-awn install-shell install-mate-panel |
10 | |
11 | install-alone: |
12 | python -m compileall src/ |
13 | @@ -110,6 +110,27 @@ |
14 | rm locale/*.po |
15 | |
16 | |
17 | +install-mate-panel: install-alone |
18 | + python -m compileall src/matepanel/ |
19 | + cp -f src/matepanel/cardapio-mate-panel-applet $(PREFIX)/lib/cardapio/ |
20 | + |
21 | + mkdir -p $(PREFIX)/lib/cardapio/matepanel |
22 | + cp -f src/matepanel/CardapioMateApplet* $(PREFIX)/lib/cardapio/matepanel/ |
23 | + cp -f src/matepanel/CardapioMateAppletFactory* $(PREFIX)/lib/cardapio/matepanel/ |
24 | + cp -f src/matepanel/__init__* $(PREFIX)/lib/cardapio/matepanel/ |
25 | + |
26 | + mkdir -p $(PREFIX)/bin |
27 | + ln -fs $(PREFIX)/lib/cardapio/cardapio-mate-panel-applet $(PREFIX)/bin/cardapio-mate-panel-applet |
28 | + |
29 | + mkdir -p $(DESTDIR)/usr/lib/matecomponent/servers |
30 | + #cp -f src/matepanel/cardapio.server $(DESTDIR)/usr/lib/matecomponent/servers/ |
31 | + for f in locale/*; \ |
32 | + do test -f $$f/LC_MESSAGES/cardapio.mo && msgunfmt -o $$f.po $$f/LC_MESSAGES/cardapio.mo || true; \ |
33 | + done |
34 | + intltool-merge -b locale src/matepanel/cardapio.server $(DESTDIR)/usr/lib/matecomponent/servers/cardapio.server |
35 | + rm locale/*.po |
36 | + |
37 | + |
38 | install-docky: install-alone |
39 | python -m compileall src/docky/ |
40 | cp -f res/cardapioDocky.desktop $(PREFIX)/lib/cardapio/ |
41 | @@ -139,7 +160,7 @@ |
42 | mkdir -p $(PREFIX)/share/gnome-shell/extensions |
43 | cp -rf src/gnomeshell/cardapio@varal.org $(PREFIX)/share/gnome-shell/extensions/ |
44 | |
45 | -uninstall: uninstall-alone uninstall-panel uninstall-docky uninstall-awn uninstall-shell |
46 | +uninstall: uninstall-alone uninstall-panel uninstall-docky uninstall-awn uninstall-shell uninstall-mate-panel |
47 | |
48 | uninstall-alone: uninstall-panel uninstall-docky uninstall-awn uninstall-shell |
49 | rm -rf $(PREFIX)/lib/cardapio |
50 | @@ -159,6 +180,10 @@ |
51 | rm -rf $(PREFIX)/bin/cardapio-gnome-panel-applet |
52 | rm -f $(DESTDIR)/usr/lib/bonobo/servers/cardapio.server |
53 | |
54 | +uninstall-mate-panel: |
55 | + rm -rf $(PREFIX)/bin/cardapio-mate-panel-applet |
56 | + rm -f $(DESTDIR)/usr/lib/matecomponent/servers/cardapio.server |
57 | + |
58 | uninstall-docky: |
59 | if test -d $(PREFIX)/share/dockmanager; then\ |
60 | rm -rf $(PREFIX)/share/dockmanager/metadata/cardapio_helper.py.info; \ |
61 | |
62 | === modified file 'src/Cardapio.py' |
63 | --- src/Cardapio.py 2011-11-17 07:30:54 +0000 |
64 | +++ src/Cardapio.py 2012-01-17 03:21:25 +0000 |
65 | @@ -354,7 +354,7 @@ |
66 | Prepares Cardapio's applet in any of the compatible panels. |
67 | """ |
68 | |
69 | - if self._applet.panel_type == PANEL_TYPE_GNOME2: |
70 | + if self._applet.panel_type == PANEL_TYPE_GNOME2 or self._applet.panel_type == PANEL_TYPE_MATE: |
71 | self._view.remove_about_context_menu_items() |
72 | |
73 | if self.settings['show titlebar']: |
74 | |
75 | === modified file 'src/CardapioAppletInterface.py' |
76 | --- src/CardapioAppletInterface.py 2011-09-22 22:34:02 +0000 |
77 | +++ src/CardapioAppletInterface.py 2012-01-17 03:21:25 +0000 |
78 | @@ -20,6 +20,7 @@ |
79 | PANEL_TYPE_AWN = 2 |
80 | PANEL_TYPE_DOCKY = 3 |
81 | PANEL_TYPE_SIMPLEDBUS = 4 |
82 | +PANEL_TYPE_MATE = 5 |
83 | |
84 | POS_TOP = 0 |
85 | POS_BOTTOM = 1 |
86 | |
87 | === modified file 'src/DesktopEnvironment.py' |
88 | --- src/DesktopEnvironment.py 2011-12-06 18:46:46 +0000 |
89 | +++ src/DesktopEnvironment.py 2012-01-17 03:21:25 +0000 |
90 | @@ -49,6 +49,7 @@ |
91 | elif self.environment == 'xfce' : pass |
92 | elif self.environment == 'lxde' : self.init_lxde() |
93 | elif self.environment == 'lwde' : pass |
94 | + elif self.environment == 'mate' : self.init_mate() |
95 | elif self.environment == 'gnome' : self.init_gnome() |
96 | elif self.environment == 'gnome-shell' : self.init_gnome3() |
97 | |
98 | @@ -69,6 +70,28 @@ |
99 | except Exception, exception: |
100 | logging.warn('Warning: you will not be able to execute scripts in the terminal') |
101 | |
102 | + def init_mate(self): |
103 | + """ |
104 | + Override some of the default variables for use in Mate |
105 | + """ |
106 | + |
107 | + # When libexo is installed (use in some xfce apps) it breaks xdg-open |
108 | + # for some reason. So we here substitute it with gnome-open. |
109 | + self.file_open = "mate-open '%s'" |
110 | + self.menu_editor = 'mozo' |
111 | + self.connect_to_server = which('caja-connect-server') |
112 | + self.lock_screen = 'mate-screensaver-command --lock' |
113 | + self.save_session = 'mate-session-save --logout-dialog' |
114 | + self.shutdown = 'mate-session-save --shutdown-dialog' |
115 | + self.about_de = 'mate-about' |
116 | + |
117 | + try: |
118 | + from mate import execute_terminal_shell |
119 | + self.execute_in_terminal = execute_terminal_shell |
120 | + |
121 | + except Exception, exception: |
122 | + logging.warn('Warning: you will not be able to execute scripts in the terminal') |
123 | + |
124 | def init_gnome3(self): |
125 | """ |
126 | Override some of the default variables for use in Gnome3 |
127 | @@ -102,6 +125,7 @@ |
128 | """ |
129 | |
130 | if self.environment == 'gnome': self.register_gnome_session_close_handler(handler) |
131 | + if self.environment == 'mate': self.register_gnome_session_close_handler(handler) |
132 | |
133 | |
134 | def register_gnome_session_close_handler(self, handler): |
135 | @@ -110,8 +134,12 @@ |
136 | """ |
137 | |
138 | try: |
139 | - from gnome import program_init as gnome_program_init |
140 | - from gnome.ui import master_client as gnome_ui_master_client |
141 | + if self.environment == 'gnome': |
142 | + from gnome import program_init as gnome_program_init |
143 | + from gnome.ui import master_client as gnome_ui_master_client |
144 | + if self.environment == 'mate': |
145 | + from mate import program_init as gnome_program_init |
146 | + from mate.ui import master_client as gnome_ui_master_client |
147 | |
148 | except Exception, exception: |
149 | logging.warn('Warning: Cardapio will not be able to tell when the Gnome session is closed') |
150 | |
151 | === modified file 'src/cardapio' |
152 | --- src/cardapio 2011-08-25 21:27:25 +0000 |
153 | +++ src/cardapio 2012-01-17 03:21:25 +0000 |
154 | @@ -70,6 +70,27 @@ |
155 | gtk.main() |
156 | gtk.gdk.threads_leave() |
157 | |
158 | +def cardapio_run_in_mate_window(): |
159 | + |
160 | + import os |
161 | + import mateapplet |
162 | + import gtk |
163 | + from matepanel.CardapioMateAppletFactory import CardapioMateAppletFactory |
164 | + |
165 | + # make sure Cardapio shows even if using Ubuntu's AppMenu |
166 | + os.environ['UBUNTU_MENUPROXY'] = '' |
167 | + |
168 | + # open new Cardapio instance |
169 | + main_window = gtk.Window(gtk.WINDOW_TOPLEVEL) |
170 | + main_window.set_title('Cardapio') |
171 | + main_window.connect('destroy', gtk.main_quit) |
172 | + app = mateapplet.Applet() |
173 | + CardapioMateAppletFactory(app, None) |
174 | + app.reparent(main_window) |
175 | + main_window.show_all() |
176 | + gtk.gdk.threads_enter() |
177 | + gtk.main() |
178 | + gtk.gdk.threads_leave() |
179 | |
180 | def cardapio_run_standalone_but_hidden(): |
181 | |
182 | @@ -144,6 +165,9 @@ |
183 | if sys.argv[1] == 'run-in-window': |
184 | cardapio_run_in_window() |
185 | |
186 | + if sys.argv[1] == 'run-in-mate-window': |
187 | + cardapio_run_in_mate_window() |
188 | + |
189 | elif sys.argv[1] == 'hidden': |
190 | cardapio_run_standalone_but_hidden() |
191 | |
192 | @@ -167,6 +191,7 @@ |
193 | print(' hidden - Load Cardapio but do not show it yet.') |
194 | print(' options - Show Cardapio\'s preferences window') |
195 | print(' run-in-window - Used for debugging the Gnome Panel applet.') |
196 | + print(' run-in-mate-window - Used for debugging the Mate Panel applet.') |
197 | print('If Cardapio is already loaded, both "show" and "show-near-mouse" simply show the existing instance. That is, they do not load a new Cardapio instance.') |
198 | |
199 | else: |
200 | |
201 | === modified file 'src/gnomepanel/CardapioGnomeApplet.py' |
202 | --- src/gnomepanel/CardapioGnomeApplet.py 2011-09-22 22:34:02 +0000 |
203 | +++ src/gnomepanel/CardapioGnomeApplet.py 2012-01-17 03:21:25 +0000 |
204 | @@ -405,7 +405,7 @@ |
205 | |
206 | |
207 | def launch_edit_app(self, widget, verb): |
208 | - self.cardapio.launch_edit_app() |
209 | + self.cardapio.handle_editor_menu_item_clicked() |
210 | |
211 | |
212 | def get_screen_number(self): |
213 | |
214 | === added directory 'src/matepanel' |
215 | === added file 'src/matepanel/CardapioMateApplet.py' |
216 | --- src/matepanel/CardapioMateApplet.py 1970-01-01 00:00:00 +0000 |
217 | +++ src/matepanel/CardapioMateApplet.py 2012-01-17 03:21:25 +0000 |
218 | @@ -0,0 +1,419 @@ |
219 | +# |
220 | +# Copyright (C) 2010 Cardapio Team (tvst@hotmail.com) |
221 | +# |
222 | +# This program is free software: you can redistribute it and/or modify |
223 | +# it under the terms of the GNU General Public License as published by |
224 | +# the Free Software Foundation, either version 3 of the License, or |
225 | +# (at your option) any later version. |
226 | +# |
227 | +# This program is distributed in the hope that it will be useful, |
228 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of |
229 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
230 | +# GNU General Public License for more details. |
231 | +# |
232 | +# You should have received a copy of the GNU General Public License |
233 | +# along with this program. If not, see <http://www.gnu.org/licenses/>. |
234 | +# |
235 | + |
236 | +from misc import * |
237 | +import sys |
238 | + |
239 | +try: |
240 | + import gtk |
241 | + import glib |
242 | + import mateapplet |
243 | + from CardapioAppletInterface import * |
244 | + |
245 | +except Exception, exception: |
246 | + fatal_error("Fatal error loading Cardapio's applet for the Mate Panel", exception) |
247 | + sys.exit(1) |
248 | + |
249 | + |
250 | +class CardapioMateApplet(CardapioAppletInterface): |
251 | + |
252 | + PANEL_SIZE_CHANGE_IGNORE_INTERVAL = 200 # milliseconds |
253 | + SETUP_PANEL_BUTTON_DELAY = 100 # milliseconds (must be smaller than PANEL_SIZE_CHANGE_IGNORE_INTERVAL) |
254 | + |
255 | + panel_type = PANEL_TYPE_MATE |
256 | + |
257 | + IS_CONFIGURABLE = True |
258 | + IS_CONTROLLABLE = True |
259 | + |
260 | + # Added this to fix a bug where CardapioMateApplet was being |
261 | + # reinstantiated (possibly by Mate Panel) right after it was destroyed! As |
262 | + # a hackish fix I make sure CardapioMateApplet is a singleton using the |
263 | + # variable below. Eek. |
264 | + _singleton_instance = None |
265 | + |
266 | + def __init__(self, applet): |
267 | + |
268 | + if CardapioMateApplet._singleton_instance is not None: |
269 | + return CardapioMateApplet._singleton_instance |
270 | + |
271 | + CardapioMateApplet._singleton_instance = self |
272 | + |
273 | + self.applet = applet |
274 | + self.button = gtk.ImageMenuItem() |
275 | + self.applet_press_handler = None |
276 | + self.applet_enter_handler = None |
277 | + self.applet_leave_handler = None |
278 | + |
279 | + |
280 | + def setup(self, cardapio): |
281 | + |
282 | + self.icon_helper = cardapio.icon_helper |
283 | + self.cardapio = cardapio |
284 | + |
285 | + self.context_menu_xml = ''' |
286 | + <popup name="button3"> |
287 | + <menuitem name="Item 1" verb="Properties" label="%s" pixtype="stock" pixname="gtk-properties"/> |
288 | + <menuitem name="Item 2" verb="Edit" label="%s" pixtype="stock" pixname="gtk-edit"/> |
289 | + <separator /> |
290 | + <menuitem name="Item 3" verb="AboutCardapio" label="%s" pixtype="stock" pixname="gtk-about"/> |
291 | + <menuitem name="Item 4" verb="AboutMate" label="%s" pixtype="none"/> |
292 | + <menuitem name="Item 5" verb="AboutDistro" label="%s" pixtype="none"/> |
293 | + </popup> |
294 | + ''' % ( |
295 | + _('_Properties'), |
296 | + _('_Edit Menus'), |
297 | + _('_About Cardapio'), |
298 | + _('_About Mate'), |
299 | + _('_About %(distro_name)s') % {'distro_name' : cardapio.distro_name} |
300 | + ) |
301 | + |
302 | + self.context_menu_verbs = [ |
303 | + ('Properties', self.open_options_dialog), |
304 | + ('Edit', self.launch_edit_app), |
305 | + ('AboutCardapio', self.open_about_dialog), |
306 | + ('AboutMate', self.open_about_dialog), |
307 | + ('AboutDistro', self.open_about_dialog) |
308 | + ] |
309 | + |
310 | + self.button.set_tooltip_text(_('Access applications, folders, system settings, etc.')) |
311 | + self.button.set_always_show_image(True) |
312 | + self.button.set_name('CardapioApplet') |
313 | + |
314 | + menubar = gtk.MenuBar() |
315 | + menubar.set_name('CardapioAppletMenu') |
316 | + menubar.add(self.button) |
317 | + |
318 | + gtk.rc_parse_string(''' |
319 | + style "cardapio-applet-menu-style" |
320 | + { |
321 | + xthickness = 0 |
322 | + ythickness = 0 |
323 | + GtkMenuBar::shadow-type = GTK_SHADOW_NONE |
324 | + GtkMenuBar::internal-padding = 0 |
325 | + GtkMenuBar::focus-padding = 0 |
326 | + GtkWidget::focus-padding = 0 |
327 | + GtkWidget::focus-line-width = 0 |
328 | + #bg[NORMAL] = "#ff0000" |
329 | + engine "murrine" {} # fix background color bug |
330 | + } |
331 | + |
332 | + style "cardapio-applet-style" |
333 | + { |
334 | + xthickness = 0 |
335 | + ythickness = 0 |
336 | + GtkWidget::focus-line-width = 0 |
337 | + GtkWidget::focus-padding = 0 |
338 | + } |
339 | + |
340 | + widget "*CardapioAppletMenu" style:highest "cardapio-applet-menu-style" |
341 | + widget "*MatePanelApplet" style:highest "cardapio-applet-style" |
342 | + ''') |
343 | + |
344 | + self.applet.add(menubar) |
345 | + |
346 | + self.applet.connect('size-allocate', self._on_panel_size_changed) |
347 | + self.applet.connect('change-orient', self._panel_change_orientation) |
348 | + self.applet.connect('change-background', self._on_panel_change_background) |
349 | + self.applet.connect('destroy', self._on_panel_destroy) |
350 | + |
351 | + self.applet.set_applet_flags(mateapplet.EXPAND_MINOR) |
352 | + self.applet.show_all() |
353 | + |
354 | + return True |
355 | + |
356 | + |
357 | + def update_from_user_settings(self, settings): |
358 | + |
359 | + self.applet_label = settings['applet label'] |
360 | + self.applet_icon = settings['applet icon'] |
361 | + self.open_on_hover = settings['open on hover'] |
362 | + self._load_settings() |
363 | + |
364 | + |
365 | + def get_size(self): |
366 | + |
367 | + # here we get the size of the toplevel window because that's actually |
368 | + # just the small area of the panel where the applet will be drawn -- |
369 | + # *not* the entire panel as you would expect. |
370 | + |
371 | + panel = self.button.get_toplevel().window |
372 | + wh = panel.get_size() |
373 | + return wh |
374 | + |
375 | + |
376 | + def get_position(self): |
377 | + |
378 | + xy = self.applet.get_window().get_origin() |
379 | + return xy |
380 | + |
381 | + |
382 | + def get_orientation(self): |
383 | + |
384 | + orientation = self.applet.get_orient() |
385 | + if orientation == mateapplet.ORIENT_UP : return POS_BOTTOM # bottom and top are flipped for some reason |
386 | + if orientation == mateapplet.ORIENT_DOWN: return POS_TOP # bottom and top are flipped for some reason |
387 | + if orientation == mateapplet.ORIENT_LEFT: return POS_RIGHT # left and right are flipped for some reason |
388 | + return POS_LEFT # left and right are flipped for some reason |
389 | + |
390 | + |
391 | + def draw_toggled_state(self, state): |
392 | + |
393 | + if state: self.button.select() |
394 | + else: self.button.deselect() |
395 | + |
396 | + |
397 | + def _panel_change_orientation(self, *dummy): |
398 | + """ |
399 | + Resize the panel applet when the panel orientation is changed |
400 | + """ |
401 | + |
402 | + orientation = self.applet.get_orient() |
403 | + |
404 | + if orientation == mateapplet.ORIENT_UP or orientation == mateapplet.ORIENT_DOWN: |
405 | + self.button.parent.set_child_pack_direction(gtk.PACK_DIRECTION_LTR) |
406 | + self.button.child.set_angle(0) |
407 | + self.button.child.set_alignment(0, 0.5) |
408 | + |
409 | + elif orientation == mateapplet.ORIENT_RIGHT: |
410 | + self.button.parent.set_child_pack_direction(gtk.PACK_DIRECTION_BTT) |
411 | + self.button.child.set_angle(90) |
412 | + self.button.child.set_alignment(0.5, 0) |
413 | + |
414 | + elif orientation == mateapplet.ORIENT_LEFT: |
415 | + self.button.parent.set_child_pack_direction(gtk.PACK_DIRECTION_TTB) |
416 | + self.button.child.set_angle(270) |
417 | + self.button.child.set_alignment(0.5, 0) |
418 | + |
419 | + |
420 | + def _on_panel_change_background(self, widget, bg_type, color, pixmap): |
421 | + """ |
422 | + Update the Cardapio applet background when the user changes |
423 | + the panel background |
424 | + """ |
425 | + |
426 | + self.button.parent.set_style(None) |
427 | + |
428 | + clean_style = gtk.RcStyle() |
429 | + self.button.parent.modify_style(clean_style) |
430 | + |
431 | + if bg_type == mateapplet.COLOR_BACKGROUND: |
432 | + self.button.parent.modify_bg(gtk.STATE_NORMAL, color) |
433 | + |
434 | + elif bg_type == mateapplet.PIXMAP_BACKGROUND: |
435 | + style = self.button.parent.get_style() |
436 | + style.bg_pixmap[gtk.STATE_NORMAL] = pixmap |
437 | + self.button.parent.set_style(style) |
438 | + |
439 | + #elif bg_type == mateapplet.NO_BACKGROUND: pass |
440 | + |
441 | + |
442 | + def _on_panel_size_change_done(self): |
443 | + """ |
444 | + Restore a signal handler that we had deactivated |
445 | + """ |
446 | + |
447 | + self.applet.handler_unblock_by_func(self._on_panel_size_changed) |
448 | + return False # must return false to cancel the timer |
449 | + |
450 | + |
451 | + def _on_panel_size_changed(self, widget, allocation): |
452 | + """ |
453 | + Resize the panel applet when the panel size is changed |
454 | + """ |
455 | + |
456 | + self.applet.handler_block_by_func(self._on_panel_size_changed) |
457 | + glib.timeout_add(CardapioMateApplet.SETUP_PANEL_BUTTON_DELAY, self._load_settings) |
458 | + glib.timeout_add(CardapioMateApplet.PANEL_SIZE_CHANGE_IGNORE_INTERVAL, self._on_panel_size_change_done) # added this to avoid an infinite loop |
459 | + |
460 | + |
461 | + def _on_panel_button_pressed(self, widget, event): |
462 | + """ |
463 | + Show the context menu when the user right-clicks the panel applet |
464 | + """ |
465 | + |
466 | + if event.type == gtk.gdk.BUTTON_PRESS: |
467 | + |
468 | + if event.button == 3: |
469 | + |
470 | + widget.emit_stop_by_name('button-press-event') |
471 | + self.applet.setup_menu(self.context_menu_xml, self.context_menu_verbs, None) |
472 | + |
473 | + if event.button == 2: |
474 | + |
475 | + # make sure middle click does nothing, so it can be used to move |
476 | + # the applet |
477 | + |
478 | + widget.emit_stop_by_name('button-press-event') |
479 | + self.cardapio.hide() |
480 | + |
481 | + |
482 | + def _on_panel_button_toggled(self, widget, event, ignore_main_button): |
483 | + """ |
484 | + Show/Hide cardapio when the panel applet is clicked |
485 | + """ |
486 | + |
487 | + if event.type == gtk.gdk.BUTTON_PRESS: |
488 | + |
489 | + if event.button == 1: |
490 | + |
491 | + if not ignore_main_button: |
492 | + self.cardapio.show_hide() |
493 | + |
494 | + return True # required! or we get strange focus problems |
495 | + |
496 | + |
497 | + def _on_applet_cursor_enter(self, widget, event): |
498 | + """ |
499 | + Handler for when the cursor enters the panel applet. |
500 | + """ |
501 | + |
502 | + self.cardapio.show_hide() |
503 | + return True |
504 | + |
505 | + |
506 | + def _on_applet_cursor_leave(self, *dummy): |
507 | + """ |
508 | + Handler for whent the cursor leaves the panel applet. |
509 | + """ |
510 | + |
511 | + self.cardapio.handle_mainwindow_cursor_leave() |
512 | + |
513 | + |
514 | + def _on_panel_destroy(self, *dummy): |
515 | + """ |
516 | + Handler for when the applet is removed from the panel |
517 | + """ |
518 | + |
519 | + self.cardapio.save_and_quit() |
520 | + |
521 | + |
522 | + def _load_settings(self): |
523 | + |
524 | + self.button.set_label(self.applet_label) |
525 | + |
526 | + if self.applet_icon: |
527 | + button_icon_pixbuf = self.icon_helper.get_icon_pixbuf(self.applet_icon, self._get_best_icon_size_for_panel(), 'start-here') |
528 | + button_icon = gtk.image_new_from_pixbuf(button_icon_pixbuf) |
529 | + self.button.set_image(button_icon) |
530 | + else: |
531 | + self.button.set_image(None) |
532 | + |
533 | + clean_imagemenuitem = gtk.ImageMenuItem() |
534 | + is_horizontal = (self.applet.get_orient() in (mateapplet.ORIENT_UP, mateapplet.ORIENT_DOWN)) |
535 | + |
536 | + if self.applet_label and self.applet_icon: |
537 | + toggle_spacing = clean_imagemenuitem.style_get_property('toggle-spacing') |
538 | + else: |
539 | + toggle_spacing = 0 |
540 | + |
541 | + if is_horizontal: |
542 | + horizontal_padding = clean_imagemenuitem.style_get_property('horizontal-padding') |
543 | + else: |
544 | + horizontal_padding = 0 |
545 | + |
546 | + gtk.rc_parse_string(''' |
547 | + style "cardapio-applet-style" |
548 | + { |
549 | + GtkImageMenuItem::toggle-spacing = %d |
550 | + GtkImageMenuItem::horizontal-padding = %d |
551 | + } |
552 | + widget "*CardapioApplet" style:application "cardapio-applet-style" |
553 | + ''' % (toggle_spacing, horizontal_padding)) |
554 | + |
555 | + # apparently this happens sometimes (maybe when the parent isn't realized yet?) |
556 | + if self.button.parent is None: return |
557 | + |
558 | + menubar = self.button.parent |
559 | + menubar.remove(self.button) |
560 | + menubar.add(self.button) |
561 | + |
562 | + menubar.connect('button-press-event', self._on_panel_button_pressed) |
563 | + |
564 | + if self.applet_press_handler is not None: |
565 | + try: |
566 | + self.button.disconnect(self.applet_press_handler) |
567 | + self.button.disconnect(self.applet_enter_handler) |
568 | + self.button.disconnect(self.applet_leave_handler) |
569 | + except: pass |
570 | + |
571 | + if self.open_on_hover: |
572 | + self.applet_press_handler = self.button.connect('button-press-event', self._on_panel_button_toggled, True) |
573 | + self.applet_enter_handler = self.button.connect('enter-notify-event', self._on_applet_cursor_enter) |
574 | + self.applet_leave_handler = self.button.connect('leave-notify-event', self._on_applet_cursor_leave) |
575 | + |
576 | + else: |
577 | + self.applet_press_handler = self.button.connect('button-press-event', self._on_panel_button_toggled, False) |
578 | + self.applet_enter_handler = self.button.connect('enter-notify-event', return_true) |
579 | + self.applet_leave_handler = self.button.connect('leave-notify-event', return_true) |
580 | + |
581 | + |
582 | + def _get_best_icon_size_for_panel(self): |
583 | + """ |
584 | + Returns the best icon size for the current panel size |
585 | + """ |
586 | + |
587 | + try: |
588 | + panel_width, panel_height = self.get_size() |
589 | + except: |
590 | + return gtk.icon_size_lookup(gtk.ICON_SIZE_LARGE_TOOLBAR)[0] |
591 | + |
592 | + orientation = self.applet.get_orient() |
593 | + |
594 | + if orientation in (mateapplet.ORIENT_DOWN, mateapplet.ORIENT_UP): |
595 | + panel_size = panel_height |
596 | + |
597 | + else: |
598 | + panel_size = panel_width |
599 | + |
600 | + # "snap" the icon size to the closest stock icon size |
601 | + for icon_size in range(1,7): |
602 | + |
603 | + icon_size_pixels = gtk.icon_size_lookup(icon_size)[0] |
604 | + |
605 | + if abs(icon_size_pixels - panel_size) <= 1: |
606 | + return icon_size_pixels |
607 | + |
608 | + # if no stock icon size if close enough, then use the panel size |
609 | + return panel_size |
610 | + |
611 | + |
612 | + def open_about_dialog(self, widget, verb): |
613 | + """ |
614 | + This method simply forwards its "verb" argument to the appropriate |
615 | + method in Cardapio, acting as a layer to remove the dependence on the |
616 | + "widget" argument. |
617 | + """ |
618 | + self.cardapio.handle_about_menu_item_clicked(verb) |
619 | + |
620 | + |
621 | + def open_options_dialog(self, widget, verb): |
622 | + self.cardapio.open_options_dialog() |
623 | + |
624 | + |
625 | + def launch_edit_app(self, widget, verb): |
626 | + self.cardapio.handle_editor_menu_item_clicked() |
627 | + |
628 | + |
629 | + def get_screen_number(self): |
630 | + """ |
631 | + Returns the number of the screen where the applet is placed |
632 | + """ |
633 | + screen = self.button.get_screen() |
634 | + if screen is None: return 0 |
635 | + return screen.get_number() |
636 | + |
637 | + |
638 | |
639 | === added file 'src/matepanel/CardapioMateAppletFactory.py' |
640 | --- src/matepanel/CardapioMateAppletFactory.py 1970-01-01 00:00:00 +0000 |
641 | +++ src/matepanel/CardapioMateAppletFactory.py 2012-01-17 03:21:25 +0000 |
642 | @@ -0,0 +1,26 @@ |
643 | +# |
644 | +# Copyright (C) 2010 Cardapio Team (tvst@hotmail.com) |
645 | +# |
646 | +# This program is free software: you can redistribute it and/or modify |
647 | +# it under the terms of the GNU General Public License as published by |
648 | +# the Free Software Foundation, either version 3 of the License, or |
649 | +# (at your option) any later version. |
650 | +# |
651 | +# This program is distributed in the hope that it will be useful, |
652 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of |
653 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
654 | +# GNU General Public License for more details. |
655 | +# |
656 | +# You should have received a copy of the GNU General Public License |
657 | +# along with this program. If not, see <http://www.gnu.org/licenses/>. |
658 | +# |
659 | + |
660 | +from Cardapio import Cardapio |
661 | +from CardapioMateApplet import CardapioMateApplet |
662 | +import Constants |
663 | + |
664 | +def CardapioMateAppletFactory(applet, iid): |
665 | + |
666 | + mate_panel_applet = CardapioMateApplet(applet) |
667 | + cardapio = Cardapio(show = Constants.DONT_SHOW, panel_applet = mate_panel_applet) |
668 | + |
669 | |
670 | === added file 'src/matepanel/__init__.py' |
671 | === added file 'src/matepanel/cardapio-mate-panel-applet' |
672 | --- src/matepanel/cardapio-mate-panel-applet 1970-01-01 00:00:00 +0000 |
673 | +++ src/matepanel/cardapio-mate-panel-applet 2012-01-17 03:21:25 +0000 |
674 | @@ -0,0 +1,30 @@ |
675 | +#!/usr/bin/env python |
676 | +# |
677 | +# Cardapio is an alternative menu applet, launcher, and much more! |
678 | +# |
679 | +# This program is free software: you can redistribute it and/or modify |
680 | +# it under the terms of the GNU General Public License as published by |
681 | +# the Free Software Foundation, either version 3 of the License, or |
682 | +# (at your option) any later version. |
683 | +# |
684 | +# This program is distributed in the hope that it will be useful, |
685 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of |
686 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
687 | +# GNU General Public License for more details. |
688 | +# |
689 | +# You should have received a copy of the GNU General Public License |
690 | +# along with this program. If not, see <http://www.gnu.org/licenses/>. |
691 | +# |
692 | + |
693 | +import mateapplet |
694 | +import os |
695 | + |
696 | +from matepanel.CardapioMateAppletFactory import CardapioMateAppletFactory |
697 | + |
698 | +# make sure Cardapio shows even if using Ubuntu's AppMenu |
699 | +os.environ['UBUNTU_MENUPROXY'] = '' |
700 | + |
701 | +mateapplet.matecomponent_factory('OAFIID:MATE_Cardapio_Factory', |
702 | + mateapplet.Applet.__gtype__, 'Cardapio', '0', CardapioMateAppletFactory) |
703 | + |
704 | + |
705 | |
706 | === added file 'src/matepanel/cardapio.server' |
707 | --- src/matepanel/cardapio.server 1970-01-01 00:00:00 +0000 |
708 | +++ src/matepanel/cardapio.server 2012-01-17 03:21:25 +0000 |
709 | @@ -0,0 +1,27 @@ |
710 | +<oaf_info> |
711 | +<oaf_server iid="OAFIID:MATE_Cardapio_Factory" |
712 | + type="exe" location="cardapio-mate-panel-applet"> |
713 | + |
714 | + <oaf_attribute name="repo_ids" type="stringv"> |
715 | + <item value="IDL:MateComponent/GenericFactory:1.0"/> |
716 | + <item value="IDL:MateComponent/Unknown:1.0"/> |
717 | + </oaf_attribute> |
718 | + <oaf_attribute name="name" type="string" _value="Cardapio"/> |
719 | + <oaf_attribute name="description" type="string" _value="A menu with search capabilities."/> |
720 | +</oaf_server> |
721 | + |
722 | +<oaf_server iid="OAFIID:MATE_Cardapio" |
723 | + type="factory" location="OAFIID:MATE_Cardapio_Factory"> |
724 | + |
725 | + <oaf_attribute name="repo_ids" type="stringv"> |
726 | + <item value="IDL:MATE/Vertigo/MatePanelAppletShell:1.0"/> |
727 | + <item value="IDL:MateComponent/Control:1.0"/> |
728 | + <item value="IDL:MateComponent/Unknown:1.0"/> |
729 | + </oaf_attribute> |
730 | + <oaf_attribute name="name" type="string" _value="Cardapio"/> |
731 | + <oaf_attribute name="description" type="string" _value="A menu with search capabilities."/> |
732 | + <oaf_attribute name="panel:category" type="string" value="Miscellaneous"/> |
733 | + <oaf_attribute name="panel:icon" type="string" value="cardapio-dark256"/> |
734 | +</oaf_server> |
735 | +</oaf_info> |
736 | + |
737 | |
738 | === added file 'src/matepanel/cardapio.server.h' |
739 | --- src/matepanel/cardapio.server.h 1970-01-01 00:00:00 +0000 |
740 | +++ src/matepanel/cardapio.server.h 2012-01-17 03:21:25 +0000 |
741 | @@ -0,0 +1,2 @@ |
742 | +char *s = N_("A menu with search capabilities."); |
743 | +char *s = N_("Cardapio"); |