Merge lp:~mconley/globalmenu-extension/add_globalmenu_dummy into lp:~chrisccoulson/globalmenu-extension/trunk

Proposed by Mike Conley
Status: Merged
Approved by: Chris Coulson
Approved revision: 77
Merged at revision: 76
Proposed branch: lp:~mconley/globalmenu-extension/add_globalmenu_dummy
Merge into: lp:~chrisccoulson/globalmenu-extension/trunk
Diff against target: 250 lines (+200/-1)
5 files modified
extensions/globalmenu/components/src/Makefile.in (+1/-0)
extensions/globalmenu/components/src/uGlobalMenu.cpp (+13/-0)
extensions/globalmenu/components/src/uGlobalMenuDummy.cpp (+118/-0)
extensions/globalmenu/components/src/uGlobalMenuDummy.h (+66/-0)
extensions/globalmenu/components/src/uGlobalMenuObject.h (+2/-1)
To merge this branch: bzr merge lp:~mconley/globalmenu-extension/add_globalmenu_dummy
Reviewer Review Type Date Requested Status
Chris Coulson Pending
Review via email: mp+48527@code.launchpad.net

Description of the change

Instead of simply skipping over XUL tags that we don't recognize within a menubar, we now associate them with uGlobalMenuDummy objects, which are registered as invisible elements within the Unity menubar.

To post a comment you must log in.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'extensions/globalmenu/components/src/Makefile.in'
--- extensions/globalmenu/components/src/Makefile.in 2011-01-19 23:33:32 +0000
+++ extensions/globalmenu/components/src/Makefile.in 2011-02-03 18:23:11 +0000
@@ -58,6 +58,7 @@
58 uGlobalMenuBar.cpp \58 uGlobalMenuBar.cpp \
59 uGlobalMenuSeparator.cpp \59 uGlobalMenuSeparator.cpp \
60 uGlobalMenuItem.cpp \60 uGlobalMenuItem.cpp \
61 uGlobalMenuDummy.cpp \
61 uGlobalMenu.cpp \62 uGlobalMenu.cpp \
62 uGlobalMenuDocListener.cpp \63 uGlobalMenuDocListener.cpp \
63 uGlobalMenuObject.cpp \64 uGlobalMenuObject.cpp \
6465
=== modified file 'extensions/globalmenu/components/src/uGlobalMenu.cpp'
--- extensions/globalmenu/components/src/uGlobalMenu.cpp 2011-01-21 01:45:13 +0000
+++ extensions/globalmenu/components/src/uGlobalMenu.cpp 2011-02-03 18:23:11 +0000
@@ -54,6 +54,7 @@
54#include <glib-object.h>54#include <glib-object.h>
5555
56#include "uGlobalMenu.h"56#include "uGlobalMenu.h"
57#include "uGlobalMenuDummy.h"
57#include "uGlobalMenuItem.h"58#include "uGlobalMenuItem.h"
58#include "uGlobalMenuSeparator.h"59#include "uGlobalMenuSeparator.h"
59#include "uWidgetAtoms.h"60#include "uWidgetAtoms.h"
@@ -430,6 +431,18 @@
430 mListener,431 mListener,
431 child);432 child);
432 newItem = static_cast<uGlobalMenuObject *>(sep);433 newItem = static_cast<uGlobalMenuObject *>(sep);
434 } else {
435 // We didn't recognize the tag. We'll insert an invisible
436 // dummy node so that the indices between the hidden XUL menu
437 // and the GlobalMenu stay in sync.
438 uGlobalMenuDummy *dummy = new uGlobalMenuDummy();
439 if(!dummy)
440 return NS_ERROR_OUT_OF_MEMORY;
441
442 rv = dummy->Init(static_cast<uGlobalMenuObject *>(this),
443 mListener,
444 child);
445 newItem = static_cast<uGlobalMenuObject *>(dummy);
433 }446 }
434447
435 AppendMenuObject(newItem);448 AppendMenuObject(newItem);
436449
=== added file 'extensions/globalmenu/components/src/uGlobalMenuDummy.cpp'
--- extensions/globalmenu/components/src/uGlobalMenuDummy.cpp 1970-01-01 00:00:00 +0000
+++ extensions/globalmenu/components/src/uGlobalMenuDummy.cpp 2011-02-03 18:23:11 +0000
@@ -0,0 +1,118 @@
1/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2/* ***** BEGIN LICENSE BLOCK *****
3 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
4 *
5 * The contents of this file are subject to the Mozilla Public License Version
6 * 1.1 (the "License"); you may not use this file except in compliance with
7 * the License. You may obtain a copy of the License at
8 * http://www.mozilla.org/MPL/
9 *
10 * Software distributed under the License is distributed on an "AS IS" basis,
11 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
12 * for the specific language governing rights and limitations under the
13 * License.
14 *
15 * The Original Code is globalmenu-extension.
16 *
17 * The Initial Developer of the Original Code is
18 * Canonical Ltd.
19 * Portions created by the Initial Developer are Copyright (C) 2010
20 * the Initial Developer. All Rights Reserved.
21 *
22 * Contributor(s):
23 * Chris Coulson <chris.coulson@canonical.com>
24 * Mike Conley <mconley@mozillamessaging.com>
25 *
26 * Alternatively, the contents of this file may be used under the terms of
27 * either the GNU General Public License Version 2 or later (the "GPL"), or
28 * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
29 * in which case the provisions of the GPL or the LGPL are applicable instead
30 * of those above. If you wish to allow use of your version of this file only
31 * under the terms of either the GPL or the LGPL, and not to allow others to
32 * use your version of this file under the terms of the MPL, indicate your
33 * decision by deleting the provisions above and replace them with the notice
34 * and other provisions required by the GPL or the LGPL. If you do not delete
35 * the provisions above, a recipient may use your version of this file under
36 * the terms of any one of the MPL, the GPL or the LGPL.
37 *
38 * ***** END LICENSE BLOCK ***** */
39
40#include <nsIAtom.h>
41#include <nsDebug.h>
42#include <nsIContent.h>
43
44#include <glib-object.h>
45#include <libdbusmenu-glib/server.h>
46
47#include "uGlobalMenuDummy.h"
48#include "uWidgetAtoms.h"
49
50
51nsresult
52uGlobalMenuDummy::ConstructDbusMenuItem()
53{
54 mDbusMenuItem = dbusmenu_menuitem_new();
55 if(!mDbusMenuItem)
56 return NS_ERROR_OUT_OF_MEMORY;
57
58 dbusmenu_menuitem_property_set(mDbusMenuItem,
59 DBUSMENU_MENUITEM_PROP_VISIBLE,
60 FALSE);
61
62 return NS_OK;
63}
64
65uGlobalMenuDummy::~uGlobalMenuDummy()
66{
67
68 if(mDbusMenuItem)
69 g_object_unref(mDbusMenuItem);
70}
71
72nsresult
73uGlobalMenuDummy::Init(uGlobalMenuObject *aParent,
74 uGlobalMenuDocListener *aListener,
75 nsIContent *aContent)
76{
77 NS_ENSURE_ARG(aParent);
78 NS_ENSURE_ARG(aListener);
79 NS_ENSURE_ARG(aContent);
80
81 mParent = aParent;
82 mListener = aListener;
83 mContent = aContent;
84
85 nsresult rv = ConstructDbusMenuItem();
86 NS_ENSURE_SUCCESS(rv, rv);
87
88 return NS_OK;
89}
90
91// GlobalMenuDummy is inert, and does not observe/react to content
92// changes. The following methods are included simply to fill out
93// the interface.
94void
95uGlobalMenuDummy::ObserveAttributeChanged(nsIDocument *aDocument,
96 nsIContent *aContent,
97 nsIAtom *aAttribute)
98{
99
100}
101
102void
103uGlobalMenuDummy::ObserveContentRemoved(nsIDocument *aDocument,
104 nsIContent *aContainer,
105 nsIContent *aChild,
106 PRInt32 aIndexInContainer)
107{
108
109}
110
111void
112uGlobalMenuDummy::ObserveContentInserted(nsIDocument *aDocument,
113 nsIContent *aContainer,
114 nsIContent *aChild,
115 PRInt32 aIndexInContainer)
116{
117
118}
0119
=== added file 'extensions/globalmenu/components/src/uGlobalMenuDummy.h'
--- extensions/globalmenu/components/src/uGlobalMenuDummy.h 1970-01-01 00:00:00 +0000
+++ extensions/globalmenu/components/src/uGlobalMenuDummy.h 2011-02-03 18:23:11 +0000
@@ -0,0 +1,66 @@
1/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2/* ***** BEGIN LICENSE BLOCK *****
3 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
4 *
5 * The contents of this file are subject to the Mozilla Public License Version
6 * 1.1 (the "License"); you may not use this file except in compliance with
7 * the License. You may obtain a copy of the License at
8 * http://www.mozilla.org/MPL/
9 *
10 * Software distributed under the License is distributed on an "AS IS" basis,
11 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
12 * for the specific language governing rights and limitations under the
13 * License.
14 *
15 * The Original Code is globalmenu-extension.
16 *
17 * The Initial Developer of the Original Code is
18 * Canonical Ltd.
19 * Portions created by the Initial Developer are Copyright (C) 2010
20 * the Initial Developer. All Rights Reserved.
21 *
22 * Contributor(s):
23 * Chris Coulson <chris.coulson@canonical.com>
24 * Mike Conley <mconley@mozillamessaging.com>
25 *
26 * Alternatively, the contents of this file may be used under the terms of
27 * either the GNU General Public License Version 2 or later (the "GPL"), or
28 * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
29 * in which case the provisions of the GPL or the LGPL are applicable instead
30 * of those above. If you wish to allow use of your version of this file only
31 * under the terms of either the GPL or the LGPL, and not to allow others to
32 * use your version of this file under the terms of the MPL, indicate your
33 * decision by deleting the provisions above and replace them with the notice
34 * and other provisions required by the GPL or the LGPL. If you do not delete
35 * the provisions above, a recipient may use your version of this file under
36 * the terms of any one of the MPL, the GPL or the LGPL.
37 *
38 * ***** END LICENSE BLOCK ***** */
39
40#ifndef _U_GLOBALMENUDUMMY_H
41#define _U_GLOBALMENUDUMMY_H
42
43#include "uGlobalMenuObject.h"
44#include "uMenuChangeObserver.h"
45
46class nsIContent;
47class uGlobalMenuDocListener;
48
49class uGlobalMenuDummy: public uGlobalMenuObject,
50 public uMenuChangeObserver
51{
52public:
53 NS_DECL_UMENUCHANGEOBSERVER
54 uGlobalMenuDummy (): uGlobalMenuObject(MenuDummy) { };
55
56 nsresult Init (uGlobalMenuObject *aParent,
57 uGlobalMenuDocListener *aListener,
58 nsIContent *aContent);
59private:
60 ~uGlobalMenuDummy ();
61
62 nsresult ConstructDbusMenuItem ();
63};
64
65
66#endif
067
=== modified file 'extensions/globalmenu/components/src/uGlobalMenuObject.h'
--- extensions/globalmenu/components/src/uGlobalMenuObject.h 2011-01-21 01:31:20 +0000
+++ extensions/globalmenu/components/src/uGlobalMenuObject.h 2011-02-03 18:23:11 +0000
@@ -55,7 +55,8 @@
55 MenuBar,55 MenuBar,
56 Menu,56 Menu,
57 MenuItem,57 MenuItem,
58 MenuSeparator58 MenuSeparator,
59 MenuDummy
59};60};
6061
61class uGlobalMenuObject;62class uGlobalMenuObject;

Subscribers

People subscribed via source and target branches

to all changes: