[ekiga/ds-gsettings3] GSettings: Use enum instead of int when possible.



commit 0356749b6c52f02c4cbd30a471495648994f8f67
Author: Damien Sandras <dsandras beip be>
Date:   Sun Dec 8 18:28:25 2013 +0100

    GSettings: Use enum instead of int when possible.
    
    Various GSettings key have been changed from int values to enum values.
    (h.239 roles, video size, video format, H.323 DTMF mode, SIP DTMF mode,
    ...).
    
    This allows GSettings to control input values and forbit unsupported
    values. Also, configuration editors like dconf-editor are now able to
    present the user with a nice drop-down with valid choices.
    
    A new "Choice" preferences type has been added as part of the change to
    handle the former int_option_menu and string_option_menu in an easy way.
    Moreover, we are now using the new get_devices core implementation
    instead of the various independant get_*_devices methods implemented in
    device-lists.*. Those files can now be safely removed.

 lib/Makefile.am                                    |    2 -
 lib/ekiga-settings.h                               |   12 +-
 lib/engine/components/opal/h323-endpoint.cpp       |   16 +-
 lib/engine/components/opal/sip-endpoint.cpp        |    2 +-
 lib/engine/gui/gtk-frontend/device-lists.cpp       |  112 -------
 lib/engine/gui/gtk-frontend/device-lists.h         |   58 ----
 lib/engine/gui/gtk-frontend/preferences-window.cpp |  307 ++++++++++----------
 lib/engine/videoinput/videoinput-core.cpp          |    4 +-
 lib/engine/videoinput/videoinput-info.h            |    4 +-
 org.gnome.ekiga.gschema.xml.in.in                  |   88 +++++-
 10 files changed, 258 insertions(+), 347 deletions(-)
---
diff --git a/lib/Makefile.am b/lib/Makefile.am
index 3d5d17f..7db1f1f 100644
--- a/lib/Makefile.am
+++ b/lib/Makefile.am
@@ -379,8 +379,6 @@ libekiga_la_SOURCES += \
 ##
 
 libekiga_la_SOURCES += \
-       engine/gui/gtk-frontend/device-lists.h \
-       engine/gui/gtk-frontend/device-lists.cpp \
        engine/gui/gtk-frontend/addressbook-window.h \
        engine/gui/gtk-frontend/addressbook-window.cpp \
        engine/gui/gtk-frontend/accounts-window.h \
diff --git a/lib/ekiga-settings.h b/lib/ekiga-settings.h
index 4cc3472..d582226 100644
--- a/lib/ekiga-settings.h
+++ b/lib/ekiga-settings.h
@@ -126,7 +126,7 @@ public:
     {
       g_settings_set_string (gsettings, key.c_str (), value.c_str ());
     }
-    
+
     int get_int (const std::string & key)
     {
       return g_settings_get_int (gsettings, key.c_str ());
@@ -137,6 +137,16 @@ public:
       g_settings_set_int (gsettings, key.c_str (), i);
     }
 
+    int get_enum (const std::string & key)
+    {
+      return g_settings_get_enum (gsettings, key.c_str ());
+    }
+
+    void set_enum (const std::string & key, int i)
+    {
+      g_settings_set_enum (gsettings, key.c_str (), i);
+    }
+
     bool get_bool (const std::string & key)
     {
       return g_settings_get_boolean (gsettings, key.c_str ());
diff --git a/lib/engine/components/opal/h323-endpoint.cpp b/lib/engine/components/opal/h323-endpoint.cpp
index dcbfd9f..7d95450 100644
--- a/lib/engine/components/opal/h323-endpoint.cpp
+++ b/lib/engine/components/opal/h323-endpoint.cpp
@@ -92,8 +92,8 @@ namespace Opal {
 
 /* The class */
 Opal::H323::EndPoint::EndPoint (Opal::CallManager & _manager):
-  H323EndPoint (_manager),
-  manager (_manager)
+    H323EndPoint (_manager),
+    manager (_manager)
 {
   protocol_name = "h323";
   uri_prefix = "h323:";
@@ -114,15 +114,15 @@ Opal::H323::EndPoint::~EndPoint ()
 
 bool
 Opal::H323::EndPoint::populate_menu (const std::string& /*fullname*/,
-                                    const std::string& uri,
-                                    Ekiga::MenuBuilder& builder)
+                                     const std::string& uri,
+                                     Ekiga::MenuBuilder& builder)
 {
   if (0 == GetConnectionCount ())
     builder.add_action ("phone-pick-up", _("Call"),
-                       boost::bind (&Opal::H323::EndPoint::on_dial, this, uri));
+                        boost::bind (&Opal::H323::EndPoint::on_dial, this, uri));
   else
     builder.add_action ("mail-forward", _("Transfer"),
-                       boost::bind (&Opal::H323::EndPoint::on_transfer, this, uri));
+                        boost::bind (&Opal::H323::EndPoint::on_transfer, this, uri));
   return true;
 }
 
@@ -484,7 +484,7 @@ Opal::H323::EndPoint::setup (const std::string setting)
   }
   if (setting.empty () || setting == "dtmf-mode") {
 
-    set_dtmf_mode (settings->get_int ("dtmf-mode"));
+    set_dtmf_mode (settings->get_enum ("dtmf-mode"));
   }
   if (setting.empty () || setting == "forward-host") {
 
@@ -494,7 +494,7 @@ Opal::H323::EndPoint::setup (const std::string setting)
 
     CallManager::VideoOptions options;
     manager.get_video_options (options);
-    options.extended_video_roles = settings->get_int ("video-role");
+    options.extended_video_roles = settings->get_enum ("video-role");
     manager.set_video_options (options);
   }
   if (setting.empty () || setting == "enable-h239") {
diff --git a/lib/engine/components/opal/sip-endpoint.cpp b/lib/engine/components/opal/sip-endpoint.cpp
index 2e3d010..9b35600 100644
--- a/lib/engine/components/opal/sip-endpoint.cpp
+++ b/lib/engine/components/opal/sip-endpoint.cpp
@@ -165,7 +165,7 @@ Opal::Sip::EndPoint::setup (std::string setting)
     set_outbound_proxy (settings->get_string ("outbound-proxy-host"));
   }
   if (setting.empty () || setting == "dtmf-mode")  {
-    set_dtmf_mode (settings->get_int ("dtmf-mode"));
+    set_dtmf_mode (settings->get_enum ("dtmf-mode"));
   }
   if (setting.empty () || setting == "forward-host")  {
     set_forward_uri (settings->get_string ("forward-host"));
diff --git a/lib/engine/gui/gtk-frontend/preferences-window.cpp 
b/lib/engine/gui/gtk-frontend/preferences-window.cpp
index 4736603..0a838c2 100644
--- a/lib/engine/gui/gtk-frontend/preferences-window.cpp
+++ b/lib/engine/gui/gtk-frontend/preferences-window.cpp
@@ -40,6 +40,7 @@
 #include "config.h"
 
 #include <glib/gi18n.h>
+#include <boost/tuple/tuple.hpp>
 
 #include "ekiga-settings.h"
 
@@ -56,8 +57,6 @@
 #include "audioinput-core.h"
 #include "audiooutput-core.h"
 
-#include "device-lists.h"
-
 #ifdef WIN32
 #include "platform/winpaths.h"
 #endif
@@ -146,6 +145,11 @@ typedef struct _GnomePrefsWindow {
 
 } GnomePrefsWindow;
 
+typedef boost::tuple<std::string, std::string> Choice;
+typedef std::list<Choice> Choices;
+typedef std::list<Choice>::iterator Choices_iterator;
+typedef std::list<Choice>::const_iterator Choices_const_iterator;
+
 /* Declarations */
 
 /* GUI Functions */
@@ -357,7 +361,7 @@ GtkWidget *gm_pw_window_subsection_new (GtkWidget *,
  */
 static GtkWidget *gm_pw_string_option_menu_new (GtkWidget *,
                                                 const gchar *,
-                                                const gchar **,
+                                                const Choices &,
                                                 boost::shared_ptr <Ekiga::Settings>,
                                                 const std::string &,
                                                 const gchar *,
@@ -372,12 +376,12 @@ static GtkWidget *gm_pw_string_option_menu_new (GtkWidget *,
  * PRE          :  The array ends with NULL.
  */
 static void gm_pw_string_option_menu_update (GtkWidget *option_menu,
-                                             const gchar **options,
+                                             const Choices & options,
                                              boost::shared_ptr <Ekiga::Settings>,
                                              const std::string & key);
 
 static void gm_pw_string_option_menu_add (GtkWidget *option_menu,
-                                          const std::string & option,
+                                          const Choice & option,
                                           boost::shared_ptr <Ekiga::Settings>,
                                           const std::string & key);
 
@@ -386,6 +390,8 @@ static void gm_pw_string_option_menu_remove (GtkWidget *option_menu,
                                              boost::shared_ptr <Ekiga::Settings>,
                                              const std::string & key);
 
+static Choices gm_pw_get_device_choices (const std::vector<std::string> & v);
+
 
 /* Callbacks */
 
@@ -791,20 +797,30 @@ gm_pw_init_h323_page (GtkWidget *prefs_window,
 {
   GtkWidget *entry = NULL;
   GmPreferencesWindow *pw = gm_pw_get_pw (prefs_window);
+  Choices capabilities_choices;
+  Choices roles_choices;
+
+  static const char *capabilities[][2] =
+    { { "string",  N_("String") },
+      { "tone",    N_("Tone") },
+      { "rfc2833", N_("RFC2833") },
+      { "q931",    N_("Q.931") },
+      { NULL,      NULL }
+    };
 
-  const gchar *capabilities [] =
-    {_("String"),
-      _("Tone"),
-      _("RFC2833"),
-      _("Q.931"),
-      NULL};
-
-  const gchar *roles [] =
-    { _("Disable H.239 Extended Video"),
-      _("Allow H.239 per Content Role Mask"),
-      _("Force H.239 Presentation Role"),
-      _("Force H.239 Live Role"),
-      NULL };
+  static const char *roles[][2] =
+    { { "none",         N_("Disable H.239 Extended Video") },
+      { "content",      N_("Allow H.239 per Content Role Mask") },
+      { "presentation", N_("Force H.239 Presentation Role") },
+      { "live",         N_("Force H.239 Live Role") },
+      { NULL,           NULL }
+    };
+  for (int i=0 ; capabilities[i][0] ; ++i)
+    capabilities_choices.push_back (boost::make_tuple (capabilities[i][0],
+                                                       gettext (capabilities[i][1])));
+  for (int i=0 ; roles[i][0] ; ++i)
+    roles_choices.push_back (boost::make_tuple (roles[i][0],
+                                                gettext (roles[i][1])));
 
   /* Add Misc Settings */
   entry =
@@ -833,14 +849,16 @@ gm_pw_init_h323_page (GtkWidget *prefs_window,
   gm_pw_toggle_new (container, _("Enable H.239 control"), pw->h323_settings,
                     "enable-h239", _("This enables H.239 capability for additional video roles."));
 
-  gm_pw_string_option_menu_new (container, NULL, roles,
+  gm_pw_string_option_menu_new (container, NULL,
+                                roles_choices,
                                 pw->h323_settings, "video-role",
                                 _("Select the H.239 Video Role"));
 
   /* Packing widget */
   gm_pw_subsection_new (container, _("DTMF Mode"));
 
-  gm_pw_string_option_menu_new (container, _("_Send DTMF as:"), capabilities,
+  gm_pw_string_option_menu_new (container, _("_Send DTMF as:"),
+                                capabilities_choices,
                                 pw->h323_settings, "dtmf-mode",
                                 _("Select the mode for DTMFs sending"));
 }
@@ -853,12 +871,16 @@ gm_pw_init_sip_page (GtkWidget *prefs_window,
   GtkWidget *entry = NULL;
   GmPreferencesWindow *pw = gm_pw_get_pw (prefs_window);
 
-  const gchar *capabilities [] =
+  Choices capabilities_choices;
+
+  static const char *capabilities [][2] =
     {
-      _("RFC2833"),
-      _("INFO"),
-      NULL
+        { "rfc2833", _("RFC2833") },
+        { "info",    _("INFO") },
+        { NULL,      NULL }
     };
+  for (int i=0 ; capabilities[i][0] != NULL ; ++i)
+    capabilities_choices.push_back (boost::make_tuple (capabilities[i][0], capabilities[i][1]));
 
   /* Add Misc Settings */
   gm_pw_entry_new (container, _("_Outbound proxy:"),
@@ -877,7 +899,8 @@ gm_pw_init_sip_page (GtkWidget *prefs_window,
   /* Packing widget */
   gm_pw_subsection_new (container, _("DTMF Mode"));
 
-  gm_pw_string_option_menu_new (container, _("_Send DTMF as:"), capabilities,
+  gm_pw_string_option_menu_new (container, _("_Send DTMF as:"),
+                                capabilities_choices,
                                 pw->sip_settings, "dtmf-mode",
                                 _("Select the mode for DTMFs sending"));
 }
@@ -890,9 +913,10 @@ gm_pw_init_audio_page (GtkWidget *prefs_window,
   GtkWidget *codecs_list = NULL;
   GmPreferencesWindow *pw = NULL;
 
-  gchar **array = NULL;
   int pos = 0;
 
+  std::vector<std::string> devices;
+
   pw = gm_pw_get_pw (prefs_window);
 
   /* Packing widgets */
@@ -924,37 +948,31 @@ gm_pw_init_audio_page (GtkWidget *prefs_window,
   gm_pw_subsection_new (container, _("Devices"));
 
   /* Add all the fields for the audio manager */
-  std::vector <std::string> device_list;
-
-  get_audiooutput_devices (pw->audiooutput_core, device_list);
-  array = vector_of_string_to_array (device_list);
+  pw->audiooutput_core->get_devices (devices);
   pw->sound_events_output =
     gm_pw_string_option_menu_new (container,
                                   _("Ringing device:"),
-                                  (const gchar **) array,
+                                  gm_pw_get_device_choices (devices),
                                   pw->sound_events_settings,
                                   "output-device",
                                   _("Select the ringing audio device to use"));
   pw->audio_player =
     gm_pw_string_option_menu_new (container,
                                   _("Output device:"),
-                                  (const gchar **) array,
+                                  gm_pw_get_device_choices (devices),
                                   pw->audio_devices_settings,
                                   "output-device",
                                   _("Select the audio output device to use"));
-  g_free (array);
 
   /* The recorder */
-  get_audioinput_devices (pw->audioinput_core, device_list);
-  array = vector_of_string_to_array (device_list);
+  pw->audioinput_core->get_devices (devices);
   pw->audio_recorder =
     gm_pw_string_option_menu_new (container,
                                   _("Input device:"),
-                                  (const gchar **) array,
+                                  gm_pw_get_device_choices (devices),
                                   pw->audio_devices_settings,
                                   "input-device",
                                   _("Select the audio input device to use"));
-  g_free (array);
 
   /* That button will refresh the device list */
   gm_pw_add_update_button (container, _("_Detect devices"),
@@ -971,40 +989,47 @@ gm_pw_init_video_page (GtkWidget *prefs_window,
   GtkWidget *codecs_list = NULL;
   PStringArray devs;
 
-  std::vector <std::string> device_list;
+  GmPreferencesWindow *pw = NULL;
 
-  gchar **array = NULL;
-  gchar *video_size[NB_VIDEO_SIZES+1];
-  const gchar *video_sizes_text [] =
-    {
-      _("Small"),
-      _("Medium"),
-      _("Large"),
-      _("Extra Large"),
-      _("480p HD"),
-    };
+  std::vector <std::string> devices;
+
+  Choices video_size_options;
+  Choices video_input_formats;
 
   unsigned int i;
   unsigned int pos = 0;
 
-  for (i=0; i< NB_VIDEO_SIZES; i++)
-    video_size[i] = g_strdup_printf ("%s (%dx%d)",
-                                     video_sizes_text[i < 5 ? i : 4],
-                                     Ekiga::VideoSizes[i].width,
-                                     Ekiga::VideoSizes[i].height);
-  video_size [NB_VIDEO_SIZES] = NULL;
-
-  const gchar *video_format [] =
-    {
-      _("PAL (Europe)"),
-      _("NTSC (America)"),
-      _("SECAM (France)"),
-      _("Auto"),
-      NULL
+  // FIXME: Probably should come from the core itself
+  static const char* VideoSizesDescription[NB_VIDEO_SIZES][2] = {
+      { "qcif", N_("Small")       },
+      { "sif",  N_("Medium")      },
+      { "cif",  N_("Medium")      },
+      { "4sif", N_("480p 4:3 HD") },
+      { "4cif", N_("DVD")         }
+  };
+
+  // FIXME: Probably should come from the core itself
+  static const char* VideoInputFormatDescription[][2] = {
+      { "pal",   N_("PAL (Europe)")   },
+      { "ntsc",  N_("NTSC (America)") },
+      { "secam", N_("SECAM (France)") },
+      { "auto",  N_("Auto")           },
+      { NULL, NULL }
     };
 
+  for (i=0; i< NB_VIDEO_SIZES; i++) {
+    gchar *value = g_strdup_printf ("%s (%dx%d)",
+                                    gettext (VideoSizesDescription[i][1]),
+                                    Ekiga::VideoSizes[i].width,
+                                    Ekiga::VideoSizes[i].height);
+    video_size_options.push_back (boost::make_tuple (VideoSizesDescription[i][0], value));
+    g_free (value);
+  }
 
-  GmPreferencesWindow *pw = NULL;
+  for (i=0; VideoInputFormatDescription[i][0]; i++) {
+    video_input_formats.push_back (boost::make_tuple (VideoInputFormatDescription[i][0],
+                                                      VideoInputFormatDescription[i][1]));
+  }
 
   pw = gm_pw_get_pw (prefs_window);
 
@@ -1034,15 +1059,23 @@ gm_pw_init_video_page (GtkWidget *prefs_window,
   gm_pw_subsection_new (container, _("Devices"));
 
   /* The video device */
-  get_videoinput_devices (pw->videoinput_core, device_list);
-  array = vector_of_string_to_array (device_list);
+  pw->videoinput_core->get_devices (devices);
   pw->video_device =
-    gm_pw_string_option_menu_new (container, _("Input device:"), (const gchar **)array, 
pw->video_devices_settings, "input-device", _("Select the video input device to use. If an error occurs when 
using this device a test picture will be transmitted."));
-  g_free (array);
-
-  gm_pw_string_option_menu_new (container, _("Size:"), (const gchar**)video_size, 
pw->video_devices_settings, "size", _("Select the transmitted video size"));
-
-  gm_pw_string_option_menu_new (container, _("Format:"), video_format, pw->video_devices_settings, "format", 
_("Select the format for video cameras (does not apply to most USB cameras)"));
+    gm_pw_string_option_menu_new (container, _("Input device:"),
+                                  gm_pw_get_device_choices (devices),
+                                  pw->video_devices_settings, "input-device", _("Select the video input 
device to use. If an error occurs when using this device a test picture will be transmitted."));
+
+  gm_pw_string_option_menu_new (container, _("Size:"),
+                                video_size_options,
+                                pw->video_devices_settings,
+                                "size",
+                                _("Select the transmitted video size"));
+
+  gm_pw_string_option_menu_new (container, _("Format:"),
+                                video_input_formats,
+                                pw->video_devices_settings,
+                                "format",
+                                _("Select the format for video cameras (does not apply to most USB 
cameras)"));
 
   gm_pw_spin_new (container, _("Channel:"), NULL,
                   pw->video_devices_settings, "channel",
@@ -1050,9 +1083,6 @@ gm_pw_init_video_page (GtkWidget *prefs_window,
 
   /* That button will refresh the device list */
   gm_pw_add_update_button (container, _("_Detect devices"), G_CALLBACK (refresh_devices_list_cb), _("Click 
here to refresh the device list"), 1, prefs_window);
-
-  for (i=0; i< NB_VIDEO_SIZES; i++)
-    g_free (video_size[i]);
 }
 
 
@@ -1096,7 +1126,7 @@ gm_pw_entry_new (GtkWidget *subsection,
 GtkWidget *
 gm_pw_string_option_menu_new (GtkWidget *subsection,
                               const gchar *label_txt,
-                              const gchar **options,
+                              const Choices & options,
                               boost::shared_ptr <Ekiga::Settings> settings,
                               const std::string & key,
                               const gchar *tooltip,
@@ -1106,17 +1136,10 @@ gm_pw_string_option_menu_new (GtkWidget *subsection,
   GtkWidget *option_menu = NULL;
   GList *cells = NULL;
 
-  int cpt = 0;
   int pos = 0;
-  bool int_setting = false;
 
   GTK_GRID_LAST_ROW (subsection, pos);
 
-  int_setting =
-    !(g_variant_type_equal (g_variant_get_type (g_settings_get_value (settings->get_g_settings (),
-                                                                      key.c_str ())),
-                            G_VARIANT_TYPE_STRING));
-
   label = gtk_label_new_with_mnemonic (label_txt);
   gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
   gtk_label_set_justify (GTK_LABEL (label), GTK_JUSTIFY_LEFT);
@@ -1130,17 +1153,18 @@ gm_pw_string_option_menu_new (GtkWidget *subsection,
   g_list_free (cells);
 
   gtk_label_set_mnemonic_widget (GTK_LABEL (label), option_menu);
-  while (options [cpt]) {
-    if (int_setting)
-      gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (option_menu), options [cpt]);
-    else
-      gtk_combo_box_text_append (GTK_COMBO_BOX_TEXT (option_menu), options [cpt], options [cpt]);
-    cpt++;
-  }
+  for (Choices_const_iterator iter = options.begin ();
+       iter != options.end ();
+       ++iter)
+    gtk_combo_box_text_append (GTK_COMBO_BOX_TEXT (option_menu),
+                               boost::get<0>(*iter).c_str (),
+                               boost::get<1>(*iter).c_str ());
+
   gtk_grid_attach_next_to (GTK_GRID (subsection), option_menu, label, GTK_POS_RIGHT, 1, 1);
 
-  g_settings_bind (settings->get_g_settings (), key.c_str (),
-                   option_menu, int_setting ? "active" : "active-id",
+  g_settings_bind (settings->get_g_settings (),
+                   key.c_str (),
+                   option_menu, "active-id",
                    G_SETTINGS_BIND_DEFAULT);
 
   if (tooltip)
@@ -1154,35 +1178,26 @@ gm_pw_string_option_menu_new (GtkWidget *subsection,
 
 void
 gm_pw_string_option_menu_update (GtkWidget *option_menu,
-                                 const gchar **options,
+                                 const Choices & options,
                                  boost::shared_ptr<Ekiga::Settings> settings,
                                  const std::string & key)
 {
-  int cpt = 0;
-  bool int_setting = false;
-
-  if (!options || key.empty ())
+  if (options.empty () || key.empty ())
     return;
 
-  int_setting =
-    !(g_variant_type_equal (g_variant_get_type (g_settings_get_value (settings->get_g_settings (),
-                                                                      key.c_str ())),
-                            G_VARIANT_TYPE_STRING));
-
   gtk_combo_box_text_remove_all (GTK_COMBO_BOX_TEXT (option_menu));
 
-  while (options [cpt]) {
-
-    if (int_setting)
-      gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (option_menu), options [cpt]);
-    else
-      gtk_combo_box_text_append (GTK_COMBO_BOX_TEXT (option_menu), options [cpt], options [cpt]);
-    cpt++;
-  }
+  for (Choices_const_iterator iter = options.begin ();
+       iter != options.end ();
+       ++iter)
+    gtk_combo_box_text_append (GTK_COMBO_BOX_TEXT (option_menu),
+                               boost::get<0>(*iter).c_str (),
+                               boost::get<1>(*iter).c_str ());
 
   // We need to bind again after a remove_all operation
-  g_settings_bind (settings->get_g_settings (), key.c_str (),
-                   option_menu, int_setting ? "active" : "active-id",
+  g_settings_bind (settings->get_g_settings (),
+                   key.c_str (),
+                   option_menu, "active-id",
                    G_SETTINGS_BIND_DEFAULT);
 
   // Force the corresponding AudioInputCore/AudioOutputCore/VideoInputCore
@@ -1195,24 +1210,16 @@ gm_pw_string_option_menu_update (GtkWidget *option_menu,
 
 void
 gm_pw_string_option_menu_add (GtkWidget *option_menu,
-                              const std::string & option,
-                              boost::shared_ptr <Ekiga::Settings> settings,
-                              const std::string & key)
+                              const Choice & option,
+                              G_GNUC_UNUSED boost::shared_ptr <Ekiga::Settings> settings,
+                              G_GNUC_UNUSED const std::string & key)
 {
-  bool int_setting = false;
-
-  if (option.empty ())
+  if (boost::get<0>(option).empty () || boost::get<1>(option).empty ())
     return;
 
-  int_setting =
-    !(g_variant_type_equal (g_variant_get_type (g_settings_get_value (settings->get_g_settings (),
-                                                                      key.c_str ())),
-                            G_VARIANT_TYPE_STRING));
-
-  if (int_setting)
-    gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (option_menu), option.c_str ());
-  else
-    gtk_combo_box_text_append (GTK_COMBO_BOX_TEXT (option_menu), option.c_str (), option.c_str ());
+  gtk_combo_box_text_append (GTK_COMBO_BOX_TEXT (option_menu),
+                             boost::get<0>(option).c_str (),
+                             boost::get<1>(option).c_str ());
 }
 
 
@@ -1482,6 +1489,18 @@ gm_pw_subsection_new (GtkWidget *container,
   g_free (label_txt);
 }
 
+static Choices
+gm_pw_get_device_choices (const std::vector<std::string> & v)
+{
+  Choices c;
+
+  for (std::vector<std::string>::const_iterator iter = v.begin ();
+       iter != v.end ();
+       ++iter)
+    c.push_back (boost::make_tuple (*iter, *iter));
+
+  return c;
+}
 
 /* Callbacks */
 static void
@@ -1705,7 +1724,8 @@ void on_videoinput_device_added_cb (const Ekiga::VideoInputDevice & device, GtkW
   GmPreferencesWindow *pw = NULL;
   g_return_if_fail (prefs_window != NULL);
   pw = gm_pw_get_pw (prefs_window);
-  gm_pw_string_option_menu_add (pw->video_device, device.GetString(),
+  gm_pw_string_option_menu_add (pw->video_device,
+                                boost::make_tuple (device.GetString (), device.GetString ()),
                                 pw->video_devices_settings, "input-device");
 }
 
@@ -1723,7 +1743,8 @@ void on_audioinput_device_added_cb (const Ekiga::AudioInputDevice & device, GtkW
   GmPreferencesWindow *pw = NULL;
   g_return_if_fail (prefs_window != NULL);
   pw = gm_pw_get_pw (prefs_window);
-  gm_pw_string_option_menu_add (pw->audio_recorder, device.GetString(),
+  gm_pw_string_option_menu_add (pw->audio_recorder,
+                                boost::make_tuple (device.GetString (), device.GetString ()),
                                 pw->audio_devices_settings, "input-device");
 }
 
@@ -1741,9 +1762,11 @@ void on_audiooutput_device_added_cb (const Ekiga::AudioOutputDevice & device, Gt
   GmPreferencesWindow *pw = NULL;
   g_return_if_fail (prefs_window != NULL);
   pw = gm_pw_get_pw (prefs_window);
-  gm_pw_string_option_menu_add (pw->audio_player, device.GetString(),
+  gm_pw_string_option_menu_add (pw->audio_player,
+                                boost::make_tuple (device.GetString (), device.GetString ()),
                                 pw->audio_devices_settings, "output-device");
-  gm_pw_string_option_menu_add (pw->sound_events_output, device.GetString(),
+  gm_pw_string_option_menu_add (pw->sound_events_output,
+                                boost::make_tuple (device.GetString (), device.GetString ()),
                                 pw->sound_events_settings, "output-device");
 }
 
@@ -1764,44 +1787,36 @@ void
 gm_prefs_window_update_devices_list (GtkWidget *prefs_window)
 {
   GmPreferencesWindow *pw = NULL;
-  gchar **array = NULL;
 
   g_return_if_fail (prefs_window != NULL);
   pw = gm_pw_get_pw (prefs_window);
 
-  std::vector <std::string> device_list;
+  std::vector<std::string> devices;
 
   /* The player */
-  get_audiooutput_devices (pw->audiooutput_core, device_list);
-  array = vector_of_string_to_array (device_list);
+  pw->audiooutput_core->get_devices (devices);
   gm_pw_string_option_menu_update (pw->audio_player,
-                                   (const gchar **) array,
+                                   gm_pw_get_device_choices (devices),
                                    pw->audio_devices_settings,
                                    "output-device");
   gm_pw_string_option_menu_update (pw->sound_events_output,
-                                   (const gchar **) array,
+                                   gm_pw_get_device_choices (devices),
                                    pw->sound_events_settings,
                                    "output-device");
-  g_free (array);
 
   /* The recorder */
-  get_audioinput_devices (pw->audioinput_core, device_list);
-  array = vector_of_string_to_array (device_list);
+  pw->audioinput_core->get_devices (devices);
   gm_pw_string_option_menu_update (pw->audio_recorder,
-                                   (const gchar **) array,
+                                   gm_pw_get_device_choices (devices),
                                    pw->audio_devices_settings,
                                    "input-device");
-  g_free (array);
-
 
   /* The Video player */
-  get_videoinput_devices (pw->videoinput_core, device_list);
-  array = vector_of_string_to_array (device_list);
+  pw->videoinput_core->get_devices (devices);
   gm_pw_string_option_menu_update (pw->video_device,
-                                   (const gchar **) array,
+                                   gm_pw_get_device_choices (devices),
                                    pw->video_devices_settings,
                                    "input-device");
-  g_free (array);
 }
 
 
diff --git a/lib/engine/videoinput/videoinput-core.cpp b/lib/engine/videoinput/videoinput-core.cpp
index 0aa5773..5428004 100644
--- a/lib/engine/videoinput/videoinput-core.cpp
+++ b/lib/engine/videoinput/videoinput-core.cpp
@@ -206,7 +206,7 @@ void VideoInputCore::setup (std::string setting)
   /* Get device settings */
   if (setting == "any" || setting == "input-device" || setting == "format" || setting == "channel") {
     gchar *device_string = g_settings_get_string (settings, "input-device");
-    unsigned video_format = g_settings_get_int (settings, "format");
+    unsigned video_format = g_settings_get_enum (settings, "format");
     unsigned channel = g_settings_get_int (settings, "channel");
     device.SetFromString (device_string);
 
@@ -216,7 +216,7 @@ void VideoInputCore::setup (std::string setting)
 
   /* Size and framerate */
   if (setting == "any" || setting == "size" || setting == "max-frame-rate") {
-    unsigned size = g_settings_get_int (settings, "size");
+    unsigned size = g_settings_get_enum (settings, "size");
     unsigned max_frame_rate = g_settings_get_int (codecs_settings, "max-frame-rate");
     if (size >= NB_VIDEO_SIZES) {
       PTRACE(1, "VidInputCore\t" << "size out of range, ajusting to 0");
diff --git a/lib/engine/videoinput/videoinput-info.h b/lib/engine/videoinput/videoinput-info.h
index 265c5f4..ee6b3c9 100644
--- a/lib/engine/videoinput/videoinput-info.h
+++ b/lib/engine/videoinput/videoinput-info.h
@@ -61,10 +61,10 @@ namespace Ekiga
     int height;
   } VideoSizes[NB_VIDEO_SIZES] = {
     {  GM_QCIF_WIDTH,  GM_QCIF_HEIGHT },
-    {  GM_CIF_WIDTH,   GM_CIF_HEIGHT  },
-    {  GM_4CIF_WIDTH,  GM_4CIF_HEIGHT },
     {  GM_SIF_WIDTH,   GM_SIF_HEIGHT  },
+    {  GM_CIF_WIDTH,   GM_CIF_HEIGHT  },
     {  GM_4SIF_WIDTH,  GM_4SIF_HEIGHT },
+    {  GM_4CIF_WIDTH,  GM_4CIF_HEIGHT },
   };
 
   class VideoInputDevice : public Device {};
diff --git a/org.gnome.ekiga.gschema.xml.in.in b/org.gnome.ekiga.gschema.xml.in.in
index 208644a..2a7d685 100644
--- a/org.gnome.ekiga.gschema.xml.in.in
+++ b/org.gnome.ekiga.gschema.xml.in.in
@@ -1,4 +1,33 @@
 <schemalist>
+  <enum id="org gnome  PACKAGE_NAME@.video-sizes">
+    <value nick="qcif" value="0"/>
+    <value nick="sif" value="1"/>
+    <value nick="cif" value="2"/>
+    <value nick="4sif" value="3"/>
+    <value nick="4cif" value="4"/>
+  </enum>
+  <enum id="org gnome  PACKAGE_NAME@.video-formats">
+    <value nick="pal" value="0"/>
+    <value nick="ntsc" value="1"/>
+    <value nick="secam" value="2"/>
+    <value nick="auto" value="3"/>
+  </enum>
+  <enum id="org gnome  PACKAGE_NAME@.h323-dtmf-modes">
+    <value nick="string" value="0"/>
+    <value nick="tone" value="1"/>
+    <value nick="rfc2833" value="2"/>
+    <value nick="q931" value="3"/>
+  </enum>
+  <enum id="org gnome  PACKAGE_NAME@.h239-video-roles">
+    <value nick="none" value="0"/>
+    <value nick="content" value="1"/>
+    <value nick="presentation" value="2"/>
+    <value nick="live" value="3"/>
+  </enum>
+  <enum id="org gnome  PACKAGE_NAME@.sip-dtmf-modes">
+    <value nick="info" value="0"/>
+    <value nick="rfc2833" value="1"/>
+  </enum>
   <schema gettext-domain="@GETTEXT_PACKAGE@" id="org gnome  PACKAGE_NAME@" path="/org/gnome/@PACKAGE_NAME@/">
     <child name="devices" schema="org gnome  PACKAGE_NAME@.devices"/>
     <child name="general" schema="org gnome  PACKAGE_NAME@.general"/>
@@ -28,18 +57,31 @@
       <_summary>Video input device</_summary>
       <_description>Select the video input device to use. If an error occurs when using this device a test 
picture will be transmitted.</_description>
     </key>
-    <key name="size" type="i">
-      <default>0</default>
+    <key name="size" enum="org gnome  PACKAGE_NAME@.video-sizes">
+      <aliases>
+        <alias value='QCIF' target='qcif'/>
+        <alias value='SIF' target='sif'/>
+        <alias value='CIF' target='cif'/>
+        <alias value='4SIF' target='4sif'/>
+        <alias value='4CIF' target='4cif'/>
+      </aliases>
+      <default>'4sif'</default>
       <_summary>Video size</_summary>
-      <_description>Select the transmitted video size: Small (QCIF 176x144) or Large (CIF 
352x288)</_description>
+      <_description>Select the transmitted video size</_description>
     </key>
     <key name="channel" type="i">
       <default>0</default>
       <_summary>Video channel</_summary>
       <_description>The video channel number to use (to select camera, tv or other sources)</_description>
     </key>
-    <key name="format" type="i">
-      <default>0</default>
+    <key name="format" enum="org gnome  PACKAGE_NAME@.video-formats">
+      <aliases>
+        <alias value='PAL' target='pal'/>
+        <alias value='NTSC' target='ntsc'/>
+        <alias value='SECAM' target='secam'/>
+        <alias value='AUTO' target='auto'/>
+      </aliases>
+      <default>'auto'</default>
       <_summary>Video format</_summary>
       <_description>Select the format for video cameras (does not apply to most USB cameras)</_description>
     </key>
@@ -413,10 +455,14 @@
       <_summary>Forward calls to host</_summary>
       <_description>The host where calls should be forwarded if call forwarding is enabled</_description>
     </key>
-    <key name="dtmf-mode" type="i">
-      <default>1</default>
+    <key name="dtmf-mode" enum="org gnome  PACKAGE_NAME@.sip-dtmf-modes">
+      <aliases>
+        <alias value='Info' target='info'/>
+        <alias value='RFC2833' target='rfc2833'/>
+      </aliases>
+      <default>'info'</default>
       <_summary>DTMF sending</_summary>
-      <_description>Select the mode for sending DTMFs. The values can be 0 (for "RFC2833") and 1 (for 
"INFO")</_description>
+      <_description>Select the mode for sending DTMFs. The values can be 'RFC2833' (for "RFC2833") and 
'Info' (for "SIP INFO")</_description>
     </key>
     <key name="binding-timeout" type="i">
       <default>10</default>
@@ -450,15 +496,27 @@
       <_summary>Enable H.239</_summary>
       <_description>This enables H.239 capability for additional video roles</_description>
     </key>
-    <key name="video-role" type="i">
-      <default>0</default>
+    <key name="video-role" enum="org gnome  PACKAGE_NAME@.h239-video-roles">
+      <aliases>
+        <alias value='None' target='none'/>
+        <alias value='Content' target='content'/>
+        <alias value='Presentation' target='presentation'/>
+        <alias value='Live' target='live'/>
+      </aliases>
+      <default>'none'</default>
       <_summary>Extended Video Roles</_summary>
-      <_description>Select the H.239 Video Role. The values can be 0 (for "disable extended video"), 1 (for 
"allow per content role mask"), 2 (for "force presentation"), or 3 (for "force live role")</_description>
-    </key>
-    <key name="dtmf-mode" type="i">
-      <default>2</default>
+      <_description>Select the H.239 Video Role. The values can be "None" (for "disable extended video"), 
"Content" (for "allow per content role mask"), "Presentation" (for "force presentation"), or "Live" (for 
"force live role")</_description>
+    </key>
+    <key name="dtmf-mode" enum="org gnome  PACKAGE_NAME@.h323-dtmf-modes">
+      <aliases>
+        <alias value='String' target='string'/>
+        <alias value='Tone' target='tone'/>
+        <alias value='RFC2833' target='rfc2833'/>
+        <alias value='Q.931' target='q931'/>
+      </aliases>
+      <default>'rfc2833'</default>
       <_summary>DTMF sending</_summary>
-      <_description>Select the mode for sending DTMFs. The values can be 0 (for "String"), 1 (for "Tone"), 2 
(for "RFC2833"), or 3 (for "Q.931") (default is "RFC2833").</_description>
+      <_description>Select the mode for sending DTMFs</_description>
     </key>
     <key name="forward-host" type="s">
       <default>'h323:'</default>


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]