~cjcurran/indicator-sound/timeout-for-metadata

« back to all changes in this revision

Viewing changes to src/slider-menu-item.c

  • Committer: Conor Curran
  • Date: 2011-03-23 10:17:41 UTC
  • mfrom: (227.1.4 indicator-sound)
  • Revision ID: conor.curran@canonical.com-20110323101741-278793pjvkgigiyk
protection against rogue dbusmenu properties

Show diffs side-by-side

added added

removed removed

Lines of Context:
69
69
static void
70
70
slider_menu_item_init (SliderMenuItem *self)
71
71
{
72
 
/*
73
 
  g_debug("Building new Slider Menu Item");
74
 
*/
75
72
  dbusmenu_menuitem_property_set( DBUSMENU_MENUITEM(self),
76
73
                                  DBUSMENU_MENUITEM_PROP_TYPE,
77
74
                                  DBUSMENU_VOLUME_MENUITEM_TYPE );
108
105
 
109
106
  SliderMenuItemPrivate* priv = SLIDER_MENU_ITEM_GET_PRIVATE (SLIDER_MENU_ITEM (mi));
110
107
  gdouble volume_input = g_variant_get_double (value);
 
108
 
111
109
/*
112
110
  g_debug ("slider menu item handle event with value %f on name %s",
113
111
           volume_input,
114
112
           name);
115
113
*/
 
114
 
116
115
  slider_menu_item_update_volume (SLIDER_MENU_ITEM (mi), volume_input);
117
116
  device_ensure_sink_is_unmuted (priv->a_sink);
118
117
}
135
134
  dbusmenu_menuitem_property_set_variant (DBUSMENU_MENUITEM(self),
136
135
                                          DBUSMENU_VOLUME_MENUITEM_LEVEL,
137
136
                                          new_volume);
138
 
  GVariant* new_mute_update = g_variant_new_int32 (update->mute);
 
137
  GVariant* new_mute_update = g_variant_new_boolean (update->mute == 1);
139
138
  dbusmenu_menuitem_property_set_variant (DBUSMENU_MENUITEM(self),
140
139
                                          DBUSMENU_VOLUME_MENUITEM_MUTE,
141
140
                                          new_mute_update);
147
146
static void
148
147
slider_menu_item_update_volume (SliderMenuItem* self, gdouble percent)
149
148
{
 
149
 
150
150
/*
151
151
  g_debug ("slider menu item update volume - about to set the volume to %f", percent);
152
152
*/
177
177
  gdouble volume_percent = ((gdouble) vol * 100) / PA_VOLUME_NORM;
178
178
 
179
179
  GVariant* new_volume = g_variant_new_double (volume_percent);
 
180
 
180
181
/*
181
182
  g_debug ("slider menu item update - volume update to ui to %f", volume_percent);
182
183
*/
 
184
 
183
185
  dbusmenu_menuitem_property_set_variant (DBUSMENU_MENUITEM(self),
184
186
                                          DBUSMENU_VOLUME_MENUITEM_LEVEL,
185
187
                                          new_volume);
 
188
 
186
189
  if (priv->mute != update->mute){
187
190
    priv->mute = update->mute;
188
191
/*
189
192
    g_debug ("volume menu item - update - mute on ui = %i", update->mute);
190
193
*/
191
 
    GVariant* new_mute_update = g_variant_new_int32 (update->mute);
 
194
    GVariant* new_mute_update = g_variant_new_boolean (update->mute == 1);
192
195
    dbusmenu_menuitem_property_set_variant (DBUSMENU_MENUITEM(self),
193
196
                                            DBUSMENU_VOLUME_MENUITEM_MUTE,
194
197
                                            new_mute_update);
241
244
  SliderMenuItemPrivate* priv = SLIDER_MENU_ITEM_GET_PRIVATE (self);
242
245
  priv->a_sink = sink;
243
246
  return self;
244
 
}
 
 
b'\\ No newline at end of file'
 
247
}