Merge lp:~elementaryart/granite/new-appmenu-constructor into lp:~elementary-pantheon/granite/granite

Proposed by Jaap Broekhuizen
Status: Merged
Merged at revision: 59
Proposed branch: lp:~elementaryart/granite/new-appmenu-constructor
Merge into: lp:~elementary-pantheon/granite/granite
Diff against target: 115 lines (+51/-13)
2 files modified
lib/Application.vala (+11/-2)
lib/Widgets/AppMenu.vala (+40/-11)
To merge this branch: bzr merge lp:~elementaryart/granite/new-appmenu-constructor
Reviewer Review Type Date Requested Status
xapantu Pending
Review via email: mp+72963@code.launchpad.net
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 'lib/Application.vala'
2--- lib/Application.vala 2011-08-25 11:19:12 +0000
3+++ lib/Application.vala 2011-08-25 21:47:30 +0000
4@@ -18,6 +18,7 @@
5 using Gtk;
6
7 using Granite.Services;
8+using Granite.Widgets;
9
10 namespace Granite {
11
12@@ -86,7 +87,8 @@
13 if (!Thread.supported ())
14 error ("Problem initializing thread support.");
15 Gdk.threads_init ();
16-
17+
18+ // Deprecated
19 Granite.app = this;
20
21 }
22@@ -123,7 +125,6 @@
23
24 protected static void sig_handler (int sig) {
25 warning ("Caught signal (%d), exiting", sig);
26- Granite.app.quit_mainloop ();
27 }
28
29 protected virtual void set_options () {
30@@ -132,6 +133,14 @@
31 Logger.DisplayLevel = LogLevel.DEBUG;
32 }
33
34+ public AppMenu create_appmenu (Menu menu) {
35+
36+ AppMenu app_menu = new AppMenu.with_urls (menu, this.help_url, this.translate_url, this.bug_url);
37+ app_menu.show_about.connect ((parent) => this.show_about (parent));
38+
39+ return app_menu;
40+ }
41+
42 protected AboutDialog about_dlg;
43
44 public virtual void show_about (Gtk.Widget parent) {
45
46=== modified file 'lib/Widgets/AppMenu.vala'
47--- lib/Widgets/AppMenu.vala 2011-08-25 10:43:20 +0000
48+++ lib/Widgets/AppMenu.vala 2011-08-25 21:47:30 +0000
49@@ -23,12 +23,48 @@
50
51 public class AppMenu : ToolButtonWithMenu {
52
53+ public MenuItem help_item;
54+ public MenuItem translate_item;
55+ public MenuItem report_item;
56+ public MenuItem about_item;
57+
58+ /**
59+ * Deprecated constructor
60+ *
61+ * @deprecated
62+ */
63 public AppMenu (Menu menu) {
64
65- var help_item = new MenuItem.with_label (_("Get Help Online..."));
66- var translate_item = new MenuItem.with_label (_("Translate This Application..."));
67- var report_item = new MenuItem.with_label (_("Report a Problem..."));
68- var about_item = new MenuItem.with_label (_("About"));
69+ base (new Image.from_stock (Stock.PROPERTIES, IconSize.MENU), _("Menu"), menu);
70+
71+ this.add_items (menu);
72+
73+ help_item.activate.connect(() => System.open_uri (Granite.app.help_url));
74+ translate_item.activate.connect(() => System.open_uri (Granite.app.translate_url));
75+ report_item.activate.connect(() => System.open_uri (Granite.app.bug_url));
76+ about_item.activate.connect (() => Granite.app.show_about (get_toplevel ()));
77+ }
78+
79+ public virtual signal void show_about (Gtk.Widget parent) { }
80+
81+ public AppMenu.with_urls (Menu menu, string help_url, string translate_url, string bug_url) {
82+
83+ base (new Image.from_stock (Stock.PROPERTIES, IconSize.MENU), _("Menu"), menu);
84+
85+ this.add_items (menu);
86+
87+ help_item.activate.connect(() => System.open_uri (help_url));
88+ translate_item.activate.connect(() => System.open_uri (translate_url));
89+ report_item.activate.connect(() => System.open_uri (bug_url));
90+ about_item.activate.connect (() => this.show_about (get_toplevel ()));
91+ }
92+
93+ public void add_items (Menu menu) {
94+
95+ help_item = new MenuItem.with_label (_("Get Help Online..."));
96+ translate_item = new MenuItem.with_label (_("Translate This Application..."));
97+ report_item = new MenuItem.with_label (_("Report a Problem..."));
98+ about_item = new MenuItem.with_label (_("About"));
99
100 if (menu.get_children ().length () > 0)
101 menu.append (new SeparatorMenuItem ());
102@@ -37,13 +73,6 @@
103 menu.append (report_item);
104 menu.append (new SeparatorMenuItem ());
105 menu.append (about_item);
106-
107- base (new Image.from_stock (Stock.PROPERTIES, IconSize.MENU), _("Menu"), menu);
108-
109- help_item.activate.connect(() => System.open_uri (Granite.app.help_url));
110- translate_item.activate.connect(() => System.open_uri (Granite.app.translate_url));
111- report_item.activate.connect(() => System.open_uri (Granite.app.bug_url));
112- about_item.activate.connect (() => Granite.app.show_about (get_toplevel ()));
113 }
114
115 }

Subscribers

People subscribed via source and target branches