~charlesk/indicator-sound/lp-1244010

« back to all changes in this revision

Viewing changes to src/service.vala

  • Committer: Tarmac
  • Author(s): Lars Uebernickel
  • Date: 2013-09-09 13:57:01 UTC
  • mfrom: (372.1.2 trunk)
  • Revision ID: tarmac-20130909135701-xvm6r0ydbxc1cq81
Fixes bug #1221242 and #1204036 (make scrolling and middle clicking work on the sound indicator)

It soft-depends on lp:~larsu/libindicator/ng-add-scrolling. That means, this branch can be merged without problems, as it only adds an action and a few attributes on the root item. The bugs won't be fixed until both branches land, though.

Please the other merge request for a description of the new attributes. Fixes: https://bugs.launchpad.net/bugs/1204036.

Approved by Charles Kerr, PS Jenkins bot.

Show diffs side-by-side

added added

removed removed

Lines of Context:
64
64
 
65
65
        const ActionEntry[] action_entries = {
66
66
                { "root", null, null, "@a{sv} {}", null },
 
67
                { "scroll", activate_scroll_action, "i", null, null },
67
68
                { "desktop-settings", activate_desktop_settings, null, null, null },
68
69
                { "phone-settings", activate_phone_settings, null, null, null },
69
70
        };
76
77
        MediaPlayerList players;
77
78
        uint player_action_update_id;
78
79
 
 
80
        void activate_scroll_action (SimpleAction action, Variant? param) {
 
81
                const double volume_step_percentage = 0.06;
 
82
                int delta = param.get_int32(); /* positive for up, negative for down */
 
83
 
 
84
                double v = this.volume_control.get_volume () + volume_step_percentage * delta;
 
85
                if (v > 1.0)
 
86
                        v = 1.0;
 
87
                else if (v < 0.0)
 
88
                        v = 0.0;
 
89
 
 
90
                this.volume_control.set_volume (v);
 
91
        }
 
92
 
79
93
        void activate_desktop_settings (SimpleAction action, Variant? param) {
80
94
                var env = Environment.get_variable ("DESKTOP_SESSION");
81
95
                string cmd;