Volume Bar

Volume Bar — How to migrate Volume Bars

Migrating Volume Bars

VolumeBar widgets are deprecated since Hildon 2.2 and the way to exactly reproduce their functionality is to use a GtkScale together with a toggle button. Instead of the toggle button, a Hildon picker button could be used or two radio buttons or any other widgets that allow the user to choose from two options. The toggle button is used in this example since it is the very similar with the deprecated volume bar's button.

The deprecated volume bar is shown on the example bellow.

Example 32. A Typical Volume Bar


HildonVVolumebar *bar = HILDON_VVOLUMEBAR (hildon_vvolumebar_new ());
gtk_widget_set_size_request (GTK_WIDGET (bar), -1, 300);

        

A very similar widget can be done like the following example shows.

Example 33. A Replacement for the Volume Bar


void
toggle_volume_state_cb (GtkToggleButton *toggle, gpointer data)
{
    GtkVScale *bar = GTK_VSCALE (data);
    gboolean mute = gtk_toggle_button_get_active (toggle);
    gtk_widget_set_sensitive (GTK_WIDGET (bar), !mute);
}

GtkVScale *bar = GTK_VSCALE (hildon_gtk_vscale_new ());
gtk_widget_set_size_request (GTK_WIDGET (bar), -1, 300);
gtk_range_set_restrict_to_fill_level (GTK_RANGE (bar), TRUE);
GtkToggleButton *toggle_volume = GTK_TOGGLE_BUTTON (hildon_gtk_toggle_button_new (
                                        HILDON_SIZE_FINGER_HEIGHT));
gtk_button_set_label (GTK_BUTTON (toggle_volume), "Mute");
g_signal_connect (toggle_volume, "toggled",
                    G_CALLBACK (toggle_volume_state_cb), bar);
GtkVBox *volume = GTK_VBOX (gtk_vbox_new (0, FALSE));
gtk_container_add (GTK_CONTAINER (volume), GTK_WIDGET (bar));
gtk_box_pack_end (GTK_BOX (volume), GTK_WIDGET (toggle_volume), FALSE, FALSE, 0);