Commit db411c5c authored by Philip Withnall's avatar Philip Withnall

Convert connection-speed to an enum

parent 3985fe54
......@@ -35,10 +35,10 @@
<default>false</default>
<_summary>Resize the canvas automatically on file load</_summary>
</key>
<key name="connection-speed" type="i">
<default>11</default>
<key name="connection-speed" enum="org.gnome.totem.BvwConnectionSpeed">
<default>'lan'</default>
<_summary>Network connection speed</_summary>
<_description>Approximate network connection speed, used to select quality on media over the network: "0" for 14.4 Kbps Modem, "1" for 19.2 Kbps Modem, "2" for 28.8 Kbps Modem, "3" for 33.6 Kbps Modem, "4" for 34.4 Kbps Modem, "5" for 56 Kbps Modem/ISDN, "6" for 112 Kbps Dual ISDN/DSL, "7" for 256 Kbps DSL/Cable, "8" for 384 Kbps DSL/Cable, "9" for 512 Kbps DSL/Cable, "10" for 1.5 Mbps T1/Intranet/LAN, "11" for Intranet/LAN.</_description>
<_description>Approximate network connection speed, used to select quality on media over the network.</_description>
</key>
<key name="repeat" type="b">
<default>false</default>
......
......@@ -3276,7 +3276,7 @@ bacon_video_widget_set_connection_speed (BaconVideoWidget * bvw, int speed)
if (bvw->priv->connection_speed != speed) {
bvw->priv->connection_speed = speed;
g_settings_set_int (bvw->priv->settings, "connection-speed", speed);
g_settings_set_enum (bvw->priv->settings, "connection-speed", speed);
g_object_notify (G_OBJECT (bvw), "connection-speed");
}
......@@ -7111,7 +7111,7 @@ bacon_video_widget_new (int width, int height,
}
/* tv/conn (not used yet) */
value = g_settings_get_int (bvw->priv->settings, "connection-speed");
value = g_settings_get_enum (bvw->priv->settings, "connection-speed");
if (value > 0) {
bacon_video_widget_set_connection_speed (bvw, value);
} else {
......
......@@ -35,6 +35,7 @@
#include <sys/stat.h>
#include <sys/types.h>
#include "bacon-video-widget-enums.h"
#include "totem.h"
#include "totem-private.h"
#include "totem-preferences.h"
......@@ -310,6 +311,40 @@ encoding_changed_cb (GSettings *settings, const gchar *key, TotemObject *totem)
g_free (encoding);
}
static gboolean
int_enum_get_mapping (GValue *value, GVariant *variant, GEnumClass *enum_class)
{
GEnumValue *enum_value;
const gchar *nick;
g_return_val_if_fail (G_IS_ENUM_CLASS (enum_class), FALSE);
nick = g_variant_get_string (variant, NULL);
enum_value = g_enum_get_value_by_nick (enum_class, nick);
if (enum_value == NULL)
return FALSE;
g_value_set_int (value, enum_value->value);
return TRUE;
}
static GVariant *
int_enum_set_mapping (const GValue *value, const GVariantType *expected_type, GEnumClass *enum_class)
{
GEnumValue *enum_value;
g_return_val_if_fail (G_IS_ENUM_CLASS (enum_class), NULL);
enum_value = g_enum_get_value (enum_class, g_value_get_int (value));
if (enum_value == NULL)
return NULL;
return g_variant_new_string (enum_value->value_nick);
}
void
totem_setup_preferences (Totem *totem)
{
......@@ -388,8 +423,10 @@ totem_setup_preferences (Totem *totem)
/* Connection Speed */
item = gtk_builder_get_object (totem->xml, "tpw_speed_combobox");
g_settings_bind (totem->settings, "connection-speed", item, "active", G_SETTINGS_BIND_DEFAULT);
g_settings_bind (totem->settings, "connection-speed", bvw, "connection-speed", G_SETTINGS_BIND_DEFAULT);
g_settings_bind_with_mapping (totem->settings, "connection-speed", item, "active", G_SETTINGS_BIND_DEFAULT,
(GSettingsBindGetMapping) int_enum_get_mapping, (GSettingsBindSetMapping) int_enum_set_mapping,
g_type_class_ref (BVW_TYPE_CONNECTION_SPEED), (GDestroyNotify) g_type_class_unref);
/* Enable visuals */
item = gtk_builder_get_object (totem->xml, "tpw_visuals_checkbutton");
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment