Merge lp:~gue5t/midori/devpet-1232865-2 into lp:midori

Proposed by gue5t gue5t
Status: Merged
Approved by: André Stösel
Approved revision: 6439
Merged at revision: 6488
Proposed branch: lp:~gue5t/midori/devpet-1232865-2
Merge into: lp:midori
Diff against target: 82 lines (+28/-8)
1 file modified
extensions/devpet.vala (+28/-8)
To merge this branch: bzr merge lp:~gue5t/midori/devpet-1232865-2
Reviewer Review Type Date Requested Status
André Stösel Approve
Paweł Forysiuk Approve
Review via email: mp+191491@code.launchpad.net

Commit message

instead of creating devpet status icon on extension load, create it only to show new messages

Description of the change

This is based on ivaldi's prior work: https://code.launchpad.net/~ivaldi/midori/devpet-1232865/+merge/190567

Instead of creating the status icon when the extension loads, this creates it only when a message first gets shown. It also clears messages if devpet is deactivated--because in the time between activations devpet has no idea which errors are occurring, so it shouldn't provide false context by keeping messages from a previous activation.

To post a comment you must log in.
Revision history for this message
Paweł Forysiuk (tuxator) :
review: Approve
lp:~gue5t/midori/devpet-1232865-2 updated
6439. By gue5t <email address hidden>

merge

Revision history for this message
André Stösel (ivaldi) wrote :

thx

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'extensions/devpet.vala'
2--- extensions/devpet.vala 2013-10-28 23:25:49 +0000
3+++ extensions/devpet.vala 2013-11-19 23:46:24 +0000
4@@ -143,14 +143,15 @@
5
6 private class Manager : Midori.Extension {
7 public Gtk.ListStore list_store;
8- private Gtk.StatusIcon trayicon;
9+ private Gtk.StatusIcon? trayicon = null;
10 private LogWindow? log_window;
11 private GLib.LogFunc default_log_func;
12 private GLib.LogLevelFlags icon_flag = GLib.LogLevelFlags.LEVEL_DEBUG;
13
14 public void clear_list() {
15 this.icon_flag = GLib.LogLevelFlags.LEVEL_DEBUG;
16- this.trayicon.set_visible (false);
17+ if(this.trayicon != null)
18+ this.trayicon.set_visible (false);
19 this.list_store.clear ();
20 }
21
22@@ -167,10 +168,21 @@
23 return Gtk.Stock.DIALOG_INFO;
24 }
25
26+ private void ensure_trayicon() {
27+ if(this.trayicon != null)
28+ return;
29+
30+ this.trayicon = new Gtk.StatusIcon ();
31+ this.trayicon.set_tooltip_text ("Midori - DevPet");
32+ this.trayicon.activate.connect(this.show_error_log);
33+ }
34+
35 private void log_handler(string? domain, GLib.LogLevelFlags flags, string message) {
36 Gtk.TreeIter iter;
37 unowned string stock = this.get_stock_from_log_level (flags);
38
39+ this.ensure_trayicon();
40+
41 if (flags < this.icon_flag) {
42 this.icon_flag = flags;
43 this.trayicon.set_from_stock (stock);
44@@ -215,13 +227,25 @@
45 }
46
47 private void activated (Midori.App app) {
48- this.trayicon.set_visible (false);
49 this.default_log_func = GLib.Log.default_handler;
50 GLib.Log.set_default_handler (this.log_handler);
51+ if (this.trayicon != null) {
52+ int length = 0;
53+ this.list_store.foreach((model, path, iter) => {
54+ length++;
55+ return false;
56+ });
57+
58+ if (length > 0) {
59+ this.trayicon.set_visible (true);
60+ }
61+ }
62 }
63
64 private void deactivated () {
65- this.trayicon.set_visible (false);
66+ if (this.trayicon != null)
67+ this.trayicon.set_visible (false);
68+
69 GLib.Log.set_default_handler (this.default_log_func);
70 }
71
72@@ -231,10 +255,6 @@
73 version: "0.1",
74 authors: "André Stösel <andre@stoesel.de>");
75
76- this.trayicon = new Gtk.StatusIcon ();
77- this.trayicon.set_tooltip_text ("Midori - DevPet");
78- this.trayicon.activate.connect(this.show_error_log);
79-
80 this.list_store = new Gtk.ListStore (TreeCells.COUNT, typeof(string), typeof(string), typeof (string));
81
82 this.activate.connect (this.activated);

Subscribers

People subscribed via source and target branches

to all changes: