Merge lp:~donadigo/wingpanel-indicator-sound/fix-set-icon-warning into lp:~wingpanel-devs/wingpanel-indicator-sound/trunk

Proposed by Adam Bieńkowski
Status: Merged
Approved by: Djax
Approved revision: 126
Merged at revision: 126
Proposed branch: lp:~donadigo/wingpanel-indicator-sound/fix-set-icon-warning
Merge into: lp:~wingpanel-devs/wingpanel-indicator-sound/trunk
Diff against target: 138 lines (+58/-57)
1 file modified
src/Indicator.vala (+58/-57)
To merge this branch: bzr merge lp:~donadigo/wingpanel-indicator-sound/fix-set-icon-warning
Reviewer Review Type Date Requested Status
Djax Approve
Review via email: mp+310122@code.launchpad.net

Commit message

* Fix fatal warnings "wingpanel_widgets_overlay_icon_set_main_icon_name: assertion 'self != NULL' failed"

Description of the change

Fixes "wingpanel_widgets_overlay_icon_set_main_icon_name: assertion 'self != NULL' failed" warnings.

To post a comment you must log in.
Revision history for this message
Djax (parnold-x) wrote :

works

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/Indicator.vala'
2--- src/Indicator.vala 2016-10-23 14:43:54 +0000
3+++ src/Indicator.vala 2016-11-05 19:14:42 +0000
4@@ -67,6 +67,21 @@
5 }
6
7 construct {
8+ panel_icon = new Wingpanel.Widgets.OverlayIcon ("audio-output-none");
9+
10+ // toggle mute on middle click
11+ panel_icon.button_press_event.connect ((e) => {
12+ if (e.button == Gdk.BUTTON_MIDDLE) {
13+ volume_control.toggle_mute ();
14+ return Gdk.EVENT_STOP;
15+ }
16+
17+ return Gdk.EVENT_PROPAGATE;
18+ });
19+
20+ // change volume on scroll
21+ panel_icon.scroll_event.connect (on_icon_scroll_event);
22+
23 var locale = Intl.setlocale (LocaleCategory.MESSAGES, null);
24 volume_scale = new Widgets.Scale ("audio-volume-high-symbolic", true, 0.0, max_volume, 0.01);
25 mic_scale = new Widgets.Scale ("audio-input-microphone-symbolic", true, 0.0, 1.0, 0.01);
26@@ -148,6 +163,48 @@
27 this.update_panel_icon (volume_control.volume.volume);
28 }
29
30+ private bool on_icon_scroll_event (Gdk.EventScroll e) {
31+ var vol = new Services.VolumeControl.Volume ();
32+ vol.reason = Services.VolumeControl.VolumeReasons.USER_KEYPRESS;
33+
34+ int dir = 0;
35+ if (e.direction == Gdk.ScrollDirection.UP) {
36+ dir = 1;
37+ } else if (e.direction == Gdk.ScrollDirection.DOWN) {
38+ dir = -1;
39+ }
40+
41+ double v = this.volume_control.volume.volume + volume_step_percentage * dir;
42+ vol.volume = v.clamp (0.0, this.max_volume);
43+ this.volume_control.volume = vol;
44+
45+ if (open == false && this.notification != null && v >= -0.05 && v <= (this.max_volume + 0.05)) {
46+ string icon;
47+ if (v <= 0.0) {
48+ icon = "audio-volume-muted-symbolic";
49+ } else if (v <= 0.3) {
50+ icon = "audio-volume-low-symbolic";
51+ } else if (v <= 0.7) {
52+ icon = "audio-volume-medium-symbolic";
53+ } else {
54+ icon = "audio-volume-high-symbolic";
55+ }
56+
57+ this.notification.update ("indicator-sound", "", icon);
58+ this.notification.set_hint ("value", new Variant.int32 (
59+ (int32)Math.round(volume_control.volume.volume / this.max_volume * 100.0)));
60+ try {
61+ this.notification.show ();
62+ } catch (Error e) {
63+ warning ("Unable to show sound notification: %s", e.message);
64+ }
65+ } else if (v <= (this.max_volume + 0.05)) {
66+ play_sound_blubble ();
67+ }
68+
69+ return Gdk.EVENT_STOP;
70+ }
71+
72 private void update_mic_visibility () {
73 if (this.volume_control.is_listening) {
74 mic_scale.no_show_all = false;
75@@ -206,63 +263,7 @@
76 }
77
78 public override Gtk.Widget get_display_widget () {
79- if (panel_icon == null) {
80- panel_icon = new Wingpanel.Widgets.OverlayIcon ("audio-output-none");
81- // toggle mute on middle click
82- panel_icon.button_press_event.connect ((e) => {
83- if (e.button == Gdk.BUTTON_MIDDLE) {
84- volume_control.toggle_mute ();
85- return Gdk.EVENT_STOP;
86- }
87-
88- return Gdk.EVENT_PROPAGATE;
89- });
90-
91- var vol = new Services.VolumeControl.Volume ();
92- vol.reason = Services.VolumeControl.VolumeReasons.USER_KEYPRESS;
93-
94- // change volume on scroll
95- panel_icon.scroll_event.connect ((e) => {
96- int dir = 0;
97- if (e.direction == Gdk.ScrollDirection.UP) {
98- dir = 1;
99- } else if (e.direction == Gdk.ScrollDirection.DOWN) {
100- dir = -1;
101- }
102-
103- double v = this.volume_control.volume.volume + volume_step_percentage * dir;
104- vol.volume = v.clamp (0.0, this.max_volume);
105- this.volume_control.volume = vol;
106-
107- if (open == false && this.notification != null && v >= -0.05 && v <= (this.max_volume + 0.05)) {
108- string icon;
109- if (v <= 0.0) {
110- icon = "audio-volume-muted-symbolic";
111- } else if (v <= 0.3) {
112- icon = "audio-volume-low-symbolic";
113- } else if (v <= 0.7) {
114- icon = "audio-volume-medium-symbolic";
115- } else {
116- icon = "audio-volume-high-symbolic";
117- }
118-
119- this.notification.update ("indicator-sound", "", icon);
120- this.notification.set_hint ("value", new Variant.int32 (
121- (int32)Math.round(volume_control.volume.volume / this.max_volume * 100.0)));
122- try {
123- this.notification.show ();
124- } catch (Error e) {
125- warning ("Unable to show sound notification: %s", e.message);
126- }
127- } else if (v <= (this.max_volume + 0.05)) {
128- play_sound_blubble ();
129- }
130-
131- return Gdk.EVENT_STOP;
132- });
133- update_panel_icon (volume_control.volume.volume);
134- }
135-
136+ update_panel_icon (volume_control.volume.volume);
137 return panel_icon;
138 }
139

Subscribers

People subscribed via source and target branches

to all changes: