ekiga r6166 - in trunk: . lib/gui src/gui



Author: mschneid
Date: Thu Apr 10 20:39:42 2008
New Revision: 6166
URL: http://svn.gnome.org/viewvc/ekiga?rev=6166&view=rev

Log:
Update preferences lists when video devices are added or removed.


Modified:
   trunk/ChangeLog
   trunk/lib/gui/gmpreferences.c
   trunk/lib/gui/gmpreferences.h
   trunk/src/gui/preferences.cpp

Modified: trunk/lib/gui/gmpreferences.c
==============================================================================
--- trunk/lib/gui/gmpreferences.c	(original)
+++ trunk/lib/gui/gmpreferences.c	Thu Apr 10 20:39:42 2008
@@ -755,6 +755,57 @@
   g_free (conf_string); 
 }
 
+void
+gnome_prefs_string_option_menu_add (GtkWidget *option_menu,
+				    const gchar *option)
+{
+  GtkTreeModel *model = NULL;
+  GtkTreeIter iter;
+  gchar *option_string = NULL;
+
+  if (!option)
+    return;
+
+  model = gtk_combo_box_get_model (GTK_COMBO_BOX (option_menu));
+  option_string = g_locale_to_utf8 (option, -1, NULL, NULL, NULL);
+  gtk_list_store_append (GTK_LIST_STORE (model), &iter);
+  gtk_list_store_set (GTK_LIST_STORE (model), &iter, 
+                             COLUMN_STRING_RAW, option,
+                            COLUMN_STRING_TRANSLATED, option_string, -1);
+
+  g_free (option_string);
+}
+
+
+
+
+void
+gnome_prefs_string_option_menu_remove (GtkWidget *option_menu,
+				       const gchar *option)
+{
+  GtkTreeModel *model = NULL;
+  GtkTreeIter iter;
+
+  if (!option)
+    return;
+
+  model = gtk_combo_box_get_model (GTK_COMBO_BOX (option_menu));
+
+  if (gtk_tree_model_get_iter_first (GTK_TREE_MODEL (model), &iter)) {
+    do {
+      gchar *value_string = NULL;
+      GValue value = { 0, };
+      gtk_tree_model_get_value (GTK_TREE_MODEL (model), &iter, 0, &value);
+      value_string = (gchar *) g_value_get_string (&value);
+      if (g_ascii_strcasecmp  (value_string, option) == 0) {
+        gtk_list_store_remove (GTK_LIST_STORE (model), &iter);
+        g_value_unset(&value);
+        break;
+      }
+      g_value_unset(&value);
+    } while (gtk_tree_model_iter_next(GTK_TREE_MODEL (model), &iter));
+  }
+}
 
 GtkWidget *
 gnome_prefs_subsection_new (GtkWidget *window,

Modified: trunk/lib/gui/gmpreferences.h
==============================================================================
--- trunk/lib/gui/gmpreferences.h	(original)
+++ trunk/lib/gui/gmpreferences.h	Thu Apr 10 20:39:42 2008
@@ -216,6 +216,14 @@
 					    const gchar *);
 
 
+
+void gnome_prefs_string_option_menu_add (GtkWidget *option_menu,
+	    			         const gchar *option);
+
+void gnome_prefs_string_option_menu_remove (GtkWidget *option_menu,
+	 			            const gchar *option);
+
+
 /* DESCRIPTION  :  /
  * BEHAVIOR     :  Creates a subsection inside a section of a prefs window.
  *                 The parameters are the prefs window, the section of the

Modified: trunk/src/gui/preferences.cpp
==============================================================================
--- trunk/src/gui/preferences.cpp	(original)
+++ trunk/src/gui/preferences.cpp	Thu Apr 10 20:39:42 2008
@@ -74,6 +74,7 @@
   GtkWidget *video_device;
   GtkWidget *iface;
   Ekiga::ServiceCore *core;
+  std::vector<sigc::connection> connections;
 } GmPreferencesWindow;
 
 #define GM_PREFERENCES_WINDOW(x) (GmPreferencesWindow *) (x)
@@ -1334,11 +1335,27 @@
   gchar* file_name = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (data));
   std::string file_name_string = file_name;
   audiooutput_core->play_file(file_name_string);
-//FIXME: play_wav
 
    g_free (file_name);
 }
 
+void on_vidinputdevice_added_cb (const Ekiga::VidInputDevice & vidinput_device, GtkWidget *prefs_window)
+{
+  GmPreferencesWindow *pw = NULL;
+  g_return_if_fail (prefs_window != NULL);
+  pw = gm_pw_get_pw (prefs_window);
+  std::string device = vidinput_device.type + "/" + vidinput_device.source + "/" + vidinput_device.device;
+  gnome_prefs_string_option_menu_add (pw->video_device, device.c_str());
+}
+
+void on_vidinputdevice_removed_cb (const Ekiga::VidInputDevice & vidinput_device, GtkWidget *prefs_window)
+{
+  GmPreferencesWindow *pw = NULL;
+  g_return_if_fail (prefs_window != NULL);
+  pw = gm_pw_get_pw (prefs_window);
+  std::string device = vidinput_device.type + "/" + vidinput_device.source + "/" + vidinput_device.device;
+  gnome_prefs_string_option_menu_remove(pw->video_device, device.c_str());
+}
 
 
 /* Public functions */
@@ -1558,6 +1575,13 @@
 		    "delete-event", 
 		    G_CALLBACK (delete_window_cb), NULL);
 
+  sigc::connection conn;
+  Ekiga::VidInputCore *vidinput_core = dynamic_cast<Ekiga::VidInputCore *> (core->get ("vidinput-core"));
+  conn = vidinput_core->vidinputdevice_added.connect (sigc::bind (sigc::ptr_fun (on_vidinputdevice_added_cb), window));
+  pw->connections.push_back (conn);
+  conn = vidinput_core->vidinputdevice_removed.connect (sigc::bind (sigc::ptr_fun (on_vidinputdevice_removed_cb), window));
+  pw->connections.push_back (conn);
+
   return window;
 }
 



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