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
1=== modified file 'extensions/globalmenu/components/src/Makefile.in'
2--- extensions/globalmenu/components/src/Makefile.in 2011-01-19 23:33:32 +0000
3+++ extensions/globalmenu/components/src/Makefile.in 2011-02-03 18:23:11 +0000
4@@ -58,6 +58,7 @@
5 uGlobalMenuBar.cpp \
6 uGlobalMenuSeparator.cpp \
7 uGlobalMenuItem.cpp \
8+ uGlobalMenuDummy.cpp \
9 uGlobalMenu.cpp \
10 uGlobalMenuDocListener.cpp \
11 uGlobalMenuObject.cpp \
12
13=== modified file 'extensions/globalmenu/components/src/uGlobalMenu.cpp'
14--- extensions/globalmenu/components/src/uGlobalMenu.cpp 2011-01-21 01:45:13 +0000
15+++ extensions/globalmenu/components/src/uGlobalMenu.cpp 2011-02-03 18:23:11 +0000
16@@ -54,6 +54,7 @@
17 #include <glib-object.h>
18
19 #include "uGlobalMenu.h"
20+#include "uGlobalMenuDummy.h"
21 #include "uGlobalMenuItem.h"
22 #include "uGlobalMenuSeparator.h"
23 #include "uWidgetAtoms.h"
24@@ -430,6 +431,18 @@
25 mListener,
26 child);
27 newItem = static_cast<uGlobalMenuObject *>(sep);
28+ } else {
29+ // We didn't recognize the tag. We'll insert an invisible
30+ // dummy node so that the indices between the hidden XUL menu
31+ // and the GlobalMenu stay in sync.
32+ uGlobalMenuDummy *dummy = new uGlobalMenuDummy();
33+ if(!dummy)
34+ return NS_ERROR_OUT_OF_MEMORY;
35+
36+ rv = dummy->Init(static_cast<uGlobalMenuObject *>(this),
37+ mListener,
38+ child);
39+ newItem = static_cast<uGlobalMenuObject *>(dummy);
40 }
41
42 AppendMenuObject(newItem);
43
44=== added file 'extensions/globalmenu/components/src/uGlobalMenuDummy.cpp'
45--- extensions/globalmenu/components/src/uGlobalMenuDummy.cpp 1970-01-01 00:00:00 +0000
46+++ extensions/globalmenu/components/src/uGlobalMenuDummy.cpp 2011-02-03 18:23:11 +0000
47@@ -0,0 +1,118 @@
48+/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
49+/* ***** BEGIN LICENSE BLOCK *****
50+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
51+ *
52+ * The contents of this file are subject to the Mozilla Public License Version
53+ * 1.1 (the "License"); you may not use this file except in compliance with
54+ * the License. You may obtain a copy of the License at
55+ * http://www.mozilla.org/MPL/
56+ *
57+ * Software distributed under the License is distributed on an "AS IS" basis,
58+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
59+ * for the specific language governing rights and limitations under the
60+ * License.
61+ *
62+ * The Original Code is globalmenu-extension.
63+ *
64+ * The Initial Developer of the Original Code is
65+ * Canonical Ltd.
66+ * Portions created by the Initial Developer are Copyright (C) 2010
67+ * the Initial Developer. All Rights Reserved.
68+ *
69+ * Contributor(s):
70+ * Chris Coulson <chris.coulson@canonical.com>
71+ * Mike Conley <mconley@mozillamessaging.com>
72+ *
73+ * Alternatively, the contents of this file may be used under the terms of
74+ * either the GNU General Public License Version 2 or later (the "GPL"), or
75+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
76+ * in which case the provisions of the GPL or the LGPL are applicable instead
77+ * of those above. If you wish to allow use of your version of this file only
78+ * under the terms of either the GPL or the LGPL, and not to allow others to
79+ * use your version of this file under the terms of the MPL, indicate your
80+ * decision by deleting the provisions above and replace them with the notice
81+ * and other provisions required by the GPL or the LGPL. If you do not delete
82+ * the provisions above, a recipient may use your version of this file under
83+ * the terms of any one of the MPL, the GPL or the LGPL.
84+ *
85+ * ***** END LICENSE BLOCK ***** */
86+
87+#include <nsIAtom.h>
88+#include <nsDebug.h>
89+#include <nsIContent.h>
90+
91+#include <glib-object.h>
92+#include <libdbusmenu-glib/server.h>
93+
94+#include "uGlobalMenuDummy.h"
95+#include "uWidgetAtoms.h"
96+
97+
98+nsresult
99+uGlobalMenuDummy::ConstructDbusMenuItem()
100+{
101+ mDbusMenuItem = dbusmenu_menuitem_new();
102+ if(!mDbusMenuItem)
103+ return NS_ERROR_OUT_OF_MEMORY;
104+
105+ dbusmenu_menuitem_property_set(mDbusMenuItem,
106+ DBUSMENU_MENUITEM_PROP_VISIBLE,
107+ FALSE);
108+
109+ return NS_OK;
110+}
111+
112+uGlobalMenuDummy::~uGlobalMenuDummy()
113+{
114+
115+ if(mDbusMenuItem)
116+ g_object_unref(mDbusMenuItem);
117+}
118+
119+nsresult
120+uGlobalMenuDummy::Init(uGlobalMenuObject *aParent,
121+ uGlobalMenuDocListener *aListener,
122+ nsIContent *aContent)
123+{
124+ NS_ENSURE_ARG(aParent);
125+ NS_ENSURE_ARG(aListener);
126+ NS_ENSURE_ARG(aContent);
127+
128+ mParent = aParent;
129+ mListener = aListener;
130+ mContent = aContent;
131+
132+ nsresult rv = ConstructDbusMenuItem();
133+ NS_ENSURE_SUCCESS(rv, rv);
134+
135+ return NS_OK;
136+}
137+
138+// GlobalMenuDummy is inert, and does not observe/react to content
139+// changes. The following methods are included simply to fill out
140+// the interface.
141+void
142+uGlobalMenuDummy::ObserveAttributeChanged(nsIDocument *aDocument,
143+ nsIContent *aContent,
144+ nsIAtom *aAttribute)
145+{
146+
147+}
148+
149+void
150+uGlobalMenuDummy::ObserveContentRemoved(nsIDocument *aDocument,
151+ nsIContent *aContainer,
152+ nsIContent *aChild,
153+ PRInt32 aIndexInContainer)
154+{
155+
156+}
157+
158+void
159+uGlobalMenuDummy::ObserveContentInserted(nsIDocument *aDocument,
160+ nsIContent *aContainer,
161+ nsIContent *aChild,
162+ PRInt32 aIndexInContainer)
163+{
164+
165+}
166
167=== added file 'extensions/globalmenu/components/src/uGlobalMenuDummy.h'
168--- extensions/globalmenu/components/src/uGlobalMenuDummy.h 1970-01-01 00:00:00 +0000
169+++ extensions/globalmenu/components/src/uGlobalMenuDummy.h 2011-02-03 18:23:11 +0000
170@@ -0,0 +1,66 @@
171+/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
172+/* ***** BEGIN LICENSE BLOCK *****
173+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
174+ *
175+ * The contents of this file are subject to the Mozilla Public License Version
176+ * 1.1 (the "License"); you may not use this file except in compliance with
177+ * the License. You may obtain a copy of the License at
178+ * http://www.mozilla.org/MPL/
179+ *
180+ * Software distributed under the License is distributed on an "AS IS" basis,
181+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
182+ * for the specific language governing rights and limitations under the
183+ * License.
184+ *
185+ * The Original Code is globalmenu-extension.
186+ *
187+ * The Initial Developer of the Original Code is
188+ * Canonical Ltd.
189+ * Portions created by the Initial Developer are Copyright (C) 2010
190+ * the Initial Developer. All Rights Reserved.
191+ *
192+ * Contributor(s):
193+ * Chris Coulson <chris.coulson@canonical.com>
194+ * Mike Conley <mconley@mozillamessaging.com>
195+ *
196+ * Alternatively, the contents of this file may be used under the terms of
197+ * either the GNU General Public License Version 2 or later (the "GPL"), or
198+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
199+ * in which case the provisions of the GPL or the LGPL are applicable instead
200+ * of those above. If you wish to allow use of your version of this file only
201+ * under the terms of either the GPL or the LGPL, and not to allow others to
202+ * use your version of this file under the terms of the MPL, indicate your
203+ * decision by deleting the provisions above and replace them with the notice
204+ * and other provisions required by the GPL or the LGPL. If you do not delete
205+ * the provisions above, a recipient may use your version of this file under
206+ * the terms of any one of the MPL, the GPL or the LGPL.
207+ *
208+ * ***** END LICENSE BLOCK ***** */
209+
210+#ifndef _U_GLOBALMENUDUMMY_H
211+#define _U_GLOBALMENUDUMMY_H
212+
213+#include "uGlobalMenuObject.h"
214+#include "uMenuChangeObserver.h"
215+
216+class nsIContent;
217+class uGlobalMenuDocListener;
218+
219+class uGlobalMenuDummy: public uGlobalMenuObject,
220+ public uMenuChangeObserver
221+{
222+public:
223+ NS_DECL_UMENUCHANGEOBSERVER
224+ uGlobalMenuDummy (): uGlobalMenuObject(MenuDummy) { };
225+
226+ nsresult Init (uGlobalMenuObject *aParent,
227+ uGlobalMenuDocListener *aListener,
228+ nsIContent *aContent);
229+private:
230+ ~uGlobalMenuDummy ();
231+
232+ nsresult ConstructDbusMenuItem ();
233+};
234+
235+
236+#endif
237
238=== modified file 'extensions/globalmenu/components/src/uGlobalMenuObject.h'
239--- extensions/globalmenu/components/src/uGlobalMenuObject.h 2011-01-21 01:31:20 +0000
240+++ extensions/globalmenu/components/src/uGlobalMenuObject.h 2011-02-03 18:23:11 +0000
241@@ -55,7 +55,8 @@
242 MenuBar,
243 Menu,
244 MenuItem,
245- MenuSeparator
246+ MenuSeparator,
247+ MenuDummy
248 };
249
250 class uGlobalMenuObject;

Subscribers

People subscribed via source and target branches

to all changes: