[ekiga/ds-gsettings] Moved most of video devices keys to GSettings.
- From: Damien Sandras <dsandras src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [ekiga/ds-gsettings] Moved most of video devices keys to GSettings.
- Date: Sun, 5 May 2013 15:54:21 +0000 (UTC)
commit e7c45c9de69c4371c8b0743af435e9d593eb8647
Author: Damien Sandras <dsandras beip be>
Date: Sun May 5 17:50:25 2013 +0200
Moved most of video devices keys to GSettings.
Also rewrote a part of the VideoInputCore to make it more robust.
This work is unfinished unfortunately.
lib/ekiga-settings.h | 1 +
lib/engine/engine.cpp | 3 +-
lib/engine/gui/gtk-frontend/call-window.cpp | 5 +-
lib/engine/gui/gtk-frontend/preferences-window.cpp | 196 +++++++++++++++++++-
lib/engine/videoinput/videoinput-core.cpp | 151 +++++++++++++---
lib/engine/videoinput/videoinput-core.h | 18 ++-
lib/engine/videoinput/videoinput-gmconf-bridge.cpp | 62 ------
src/gui/main_window.cpp | 84 +++++----
8 files changed, 383 insertions(+), 137 deletions(-)
---
diff --git a/lib/ekiga-settings.h b/lib/ekiga-settings.h
index 8dc05fc..a0cf2b7 100644
--- a/lib/ekiga-settings.h
+++ b/lib/ekiga-settings.h
@@ -46,6 +46,7 @@
#define SOUND_EVENTS_SCHEMA "org.gnome." PACKAGE_NAME ".general.sound-events"
#define AUDIO_DEVICES_SCHEMA "org.gnome." PACKAGE_NAME ".devices.audio"
+#define VIDEO_DEVICES_SCHEMA "org.gnome." PACKAGE_NAME ".devices.video"
namespace Ekiga {
diff --git a/lib/engine/engine.cpp b/lib/engine/engine.cpp
index d666d0e..c6a3ab6 100644
--- a/lib/engine/engine.cpp
+++ b/lib/engine/engine.cpp
@@ -200,7 +200,8 @@ engine_init (Ekiga::ServiceCorePtr service_core,
*/
videooutput_core->setup_conf_bridge();
- videoinput_core->setup_conf_bridge();
+ videoinput_core->setup_conf_bridge ();
+ videoinput_core->setup ("any");
audioinput_core->setup ();
audiooutput_core->setup ();
diff --git a/lib/engine/gui/gtk-frontend/call-window.cpp b/lib/engine/gui/gtk-frontend/call-window.cpp
index 3fa4680..955b611 100644
--- a/lib/engine/gui/gtk-frontend/call-window.cpp
+++ b/lib/engine/gui/gtk-frontend/call-window.cpp
@@ -1354,6 +1354,7 @@ ekiga_call_window_delete_event_cb (GtkWidget *widget,
G_GNUC_UNUSED GdkEventAny *event)
{
EkigaCallWindow *cw = NULL;
+ GSettings *settings = NULL;
cw = EKIGA_CALL_WINDOW (widget);
g_return_val_if_fail (EKIGA_IS_CALL_WINDOW (cw), false);
@@ -1363,7 +1364,9 @@ ekiga_call_window_delete_event_cb (GtkWidget *widget,
cw->priv->current_call->hang_up ();
}
else {
- gm_conf_set_bool (VIDEO_DEVICES_KEY "enable_preview", false);
+ settings = g_settings_new (VIDEO_DEVICES_SCHEMA);
+ g_settings_set_boolean (settings, "enable-preview", false);
+ g_clear_object (&settings);
}
return true; // Do not relay the event anymore
diff --git a/lib/engine/gui/gtk-frontend/preferences-window.cpp
b/lib/engine/gui/gtk-frontend/preferences-window.cpp
index e7a9ed4..1113694 100644
--- a/lib/engine/gui/gtk-frontend/preferences-window.cpp
+++ b/lib/engine/gui/gtk-frontend/preferences-window.cpp
@@ -75,6 +75,7 @@ typedef struct _GmPreferencesWindow
GtkWidget *fsbutton;
GSettings *sound_events_settings;
GSettings *audio_devices_settings;
+ GSettings *video_devices_settings;
Ekiga::ServiceCore& core;
Ekiga::scoped_connections connections;
} GmPreferencesWindow;
@@ -85,12 +86,14 @@ _GmPreferencesWindow::_GmPreferencesWindow(Ekiga::ServiceCore &_core): core(_cor
{
sound_events_settings = g_settings_new (SOUND_EVENTS_SCHEMA);
audio_devices_settings = g_settings_new (AUDIO_DEVICES_SCHEMA);
+ video_devices_settings = g_settings_new (VIDEO_DEVICES_SCHEMA);
}
_GmPreferencesWindow::~_GmPreferencesWindow()
{
g_clear_object (&sound_events_settings);
g_clear_object (&audio_devices_settings);
+ g_clear_object (&video_devices_settings);
}
enum {
@@ -228,6 +231,8 @@ static void gm_pw_init_video_codecs_page (GtkWidget *prefs_window,
GtkWidget *container);
+// FIXME: I'm sure the int and string option menus could be merged together...
+
/* DESCRIPTION : /
* BEHAVIOR : Creates a GtkOptionMenu associated with a string config
* key and returns the result.
@@ -247,6 +252,24 @@ static GtkWidget *gm_pw_string_option_menu_new (GtkWidget *,
/* DESCRIPTION : /
+ * BEHAVIOR : Creates a GtkOptionMenu associated with an int config
+ * key and returns the result.
+ * The first parameter is the section in which the GtkEntry
+ * should be attached. The other parameters are the text label,
+ * the possible values for the menu, the config key, the
+ * tooltip, the row where to attach it in the section.
+ * PRE : The array ends with NULL.
+ */
+static GtkWidget *gm_pw_int_option_menu_new (GtkWidget *table,
+ const gchar *label_txt,
+ const gchar **options,
+ GSettings *settings,
+ const gchar *conf_key,
+ const gchar *tooltip,
+ int row);
+
+
+/* DESCRIPTION : /
* BEHAVIOR : Updates the content of a GtkOptionMenu associated with
* a string config key. The first parameter is the menu,
* the second is the array of possible values, and the
@@ -340,6 +363,13 @@ static void string_option_setting_changed (GSettings *settings,
gchar *key,
gpointer data);
+static void int_option_menu_changed (GtkWidget *option_menu,
+ gpointer data);
+
+static void int_option_setting_changed (GSettings *settings,
+ gchar *key,
+ gpointer data);
+
static void
gm_prefs_window_get_audiooutput_devices_list (Ekiga::ServiceCore& core,
std::vector<std::string> & device_list);
@@ -933,15 +963,15 @@ gm_pw_init_video_devices_page (GtkWidget *prefs_window,
gm_prefs_window_get_videoinput_devices_list (pw->core, device_list);
array = gm_prefs_window_convert_string_list(device_list);
pw->video_device =
- gnome_prefs_string_option_menu_new (subsection, _("Input device:"), (const gchar **)array,
VIDEO_DEVICES_KEY "input_device", _("Select the video input device to use. If an error occurs when using this
device a test picture will be transmitted."), 0, NULL);
+ gm_pw_string_option_menu_new (subsection, _("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."), 0);
g_free (array);
/* Video Channel */
gnome_prefs_spin_new (subsection, _("Channel:"), VIDEO_DEVICES_KEY "channel", _("The video channel number
to use (to select camera, tv or other sources)"), 0.0, 10.0, 1.0, 3, NULL, false);
- gnome_prefs_int_option_menu_new (subsection, _("Size:"), (const gchar**)video_size, VIDEO_DEVICES_KEY
"size", _("Select the transmitted video size"), 1);
+ gm_pw_int_option_menu_new (subsection, _("Size:"), (const gchar**)video_size, pw->video_devices_settings,
"size", _("Select the transmitted video size"), 1);
- gnome_prefs_int_option_menu_new (subsection, _("Format:"), video_format, VIDEO_DEVICES_KEY "format",
_("Select the format for video cameras (does not apply to most USB cameras)"), 2);
+ gm_pw_int_option_menu_new (subsection, _("Format:"), video_format, pw->video_devices_settings, "format",
_("Select the format for video cameras (does not apply to most USB cameras)"), 2);
/* 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);
@@ -1120,6 +1150,96 @@ gm_pw_string_option_menu_new (GtkWidget *table,
}
+GtkWidget *
+gm_pw_int_option_menu_new (GtkWidget *table,
+ const gchar *label_txt,
+ const gchar **options,
+ GSettings *settings,
+ const gchar *conf_key,
+ const gchar *tooltip,
+ int row)
+{
+ GtkWidget *label = NULL;
+ GtkWidget *option_menu = NULL;
+
+ GtkListStore *list_store = NULL;
+ GtkCellRenderer *renderer = NULL;
+ GtkTreeIter iter;
+
+ gchar *signal_name = NULL;
+ gboolean writable = FALSE;
+
+ int history = -1;
+ int cpt = 0;
+
+ writable = g_settings_is_writable (settings, conf_key);
+
+ label = gtk_label_new_with_mnemonic (label_txt);
+ if (!writable)
+ gtk_widget_set_sensitive (GTK_WIDGET (label), FALSE);
+
+ gtk_table_attach (GTK_TABLE (table), label, 0, 1, row, row+1,
+ (GtkAttachOptions) (GTK_FILL),
+ (GtkAttachOptions) (GTK_FILL),
+ 0, 0);
+
+ gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
+ gtk_label_set_justify (GTK_LABEL (label), GTK_JUSTIFY_LEFT);
+
+ list_store = gtk_list_store_new (4, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_POINTER);
+ option_menu = gtk_combo_box_new_with_model (GTK_TREE_MODEL (list_store));
+ if (!writable)
+ gtk_widget_set_sensitive (GTK_WIDGET (option_menu), FALSE);
+ renderer = gtk_cell_renderer_text_new ();
+ gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (option_menu), renderer, FALSE);
+ gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (option_menu), renderer,
+ "text", COLUMN_STRING_TRANSLATED,
+ NULL);
+ g_object_set (G_OBJECT (renderer),
+ "ellipsize-set", TRUE,
+ "ellipsize", PANGO_ELLIPSIZE_END,
+ "width-chars", 30, NULL);
+ gtk_label_set_mnemonic_widget (GTK_LABEL (label), option_menu);
+
+ history = g_settings_get_int (settings, conf_key);
+ while (options [cpt]) {
+
+ gtk_list_store_append (GTK_LIST_STORE (list_store), &iter);
+ gtk_list_store_set (GTK_LIST_STORE (list_store), &iter,
+ COLUMN_STRING_RAW, options [cpt],
+ COLUMN_STRING_TRANSLATED, gettext (options [cpt]),
+ COLUMN_GSETTINGS, settings,
+ -1);
+ cpt++;
+ }
+
+ gtk_combo_box_set_active (GTK_COMBO_BOX (option_menu), history);
+ gtk_table_attach (GTK_TABLE (table), option_menu, 1, 2, row, row+1,
+ (GtkAttachOptions) (GTK_FILL),
+ (GtkAttachOptions) (GTK_FILL),
+ 0, 0);
+
+ if (tooltip)
+ gtk_widget_set_tooltip_text (option_menu, tooltip);
+
+ /* Update configuration when the user changes the selected option */
+ g_signal_connect (option_menu, "changed",
+ G_CALLBACK (int_option_menu_changed),
+ (gpointer) conf_key);
+
+ /* Update the widget when the user changes the configuration */
+ signal_name = g_strdup_printf ("changed::%s", conf_key);
+ g_signal_connect (settings, signal_name,
+ G_CALLBACK (int_option_setting_changed), option_menu);
+ g_free (signal_name);
+
+ gtk_widget_show_all (table);
+
+ return option_menu;
+}
+
+
+
void
gm_pw_string_option_menu_update (GtkWidget *option_menu,
const gchar **options,
@@ -1193,7 +1313,7 @@ refresh_devices_list_cb (G_GNUC_UNUSED GtkWidget *widget,
g_return_if_fail (data != NULL);
GtkWidget *prefs_window = GTK_WIDGET (data);
- gm_prefs_window_update_devices_list(prefs_window);
+ gm_prefs_window_update_devices_list (prefs_window);
}
@@ -1524,8 +1644,74 @@ string_option_setting_changed (GSettings *settings,
NULL);
}
+
+void
+int_option_menu_changed (GtkWidget *option_menu,
+ gpointer data)
+{
+ gchar *key = NULL;
+ GSettings *settings = NULL;
+
+ GtkTreeModel *model = NULL;
+ GtkTreeIter iter;
+
+ unsigned int i = 0;
+ unsigned int current_value = 0;
+
+ key = (gchar *) data;
+
+ model = gtk_combo_box_get_model (GTK_COMBO_BOX (option_menu));
+ if (gtk_combo_box_get_active_iter (GTK_COMBO_BOX (option_menu), &iter)) {
+
+ gtk_tree_model_get (GTK_TREE_MODEL (model), &iter,
+ COLUMN_GSETTINGS, &settings, -1);
+ i = gtk_combo_box_get_active (GTK_COMBO_BOX (option_menu));
+ current_value = g_settings_get_int (settings, key);
+
+ if (i != current_value)
+ g_settings_set_int (settings, key, i);
+ }
+}
+
+
+void
+int_option_setting_changed (GSettings *settings,
+ gchar *key,
+ gpointer data)
+{
+ GtkWidget *e = NULL;
+
+ GtkTreeModel *model = NULL;
+ GtkTreeIter iter;
+
+ gint current_value = 0;
+
+ e = GTK_WIDGET (data);
+
+ model = gtk_combo_box_get_model (GTK_COMBO_BOX (e));
+ gtk_tree_model_get_iter_first (model, &iter);
+
+ gtk_tree_model_get (model, &iter, COLUMN_GSETTINGS, &settings, -1);
+
+ current_value = g_settings_get_int (settings, key);
+
+ g_signal_handlers_block_matched (G_OBJECT (e),
+ G_SIGNAL_MATCH_FUNC,
+ 0, 0, NULL,
+ (gpointer) int_option_menu_changed,
+ NULL);
+ if (current_value != gtk_combo_box_get_active (GTK_COMBO_BOX (e)))
+ gtk_combo_box_set_active (GTK_COMBO_BOX (e), current_value);
+ g_signal_handlers_unblock_matched (G_OBJECT (e),
+ G_SIGNAL_MATCH_FUNC,
+ 0, 0, NULL,
+ (gpointer) int_option_menu_changed,
+ NULL);
+}
+
+
/* Public functions */
-void
+void
gm_prefs_window_update_devices_list (GtkWidget *prefs_window)
{
GmPreferencesWindow *pw = NULL;
diff --git a/lib/engine/videoinput/videoinput-core.cpp b/lib/engine/videoinput/videoinput-core.cpp
index 56b27fd..717b7bb 100644
--- a/lib/engine/videoinput/videoinput-core.cpp
+++ b/lib/engine/videoinput/videoinput-core.cpp
@@ -46,6 +46,7 @@
using namespace Ekiga;
+
VideoInputCore::VideoPreviewManager::VideoPreviewManager (VideoInputCore& _videoinput_core,
boost::shared_ptr<VideoOutputCore> _videooutput_core)
: PThread (1000, AutoDeleteThread, HighestPriority, "VideoPreviewManager"),
videoinput_core (_videoinput_core),
@@ -59,64 +60,89 @@ VideoInputCore::VideoPreviewManager::VideoPreviewManager (VideoInputCore& _video
// Since windows does not like to restart a thread that
// was never started, we do so here
this->Resume ();
- thread_paused.Wait();
}
void VideoInputCore::VideoPreviewManager::quit ()
{
- if (!pause_thread)
- stop();
+ stop ();
+
+ PWaitAndSignal q(exit_mutex);
end_thread = true;
- run_thread.Signal();
- PWaitAndSignal m(thread_ended);
+
+ PWaitAndSignal m(thread_mutex);
+ if (frame)
+ free (frame);
}
void VideoInputCore::VideoPreviewManager::start (unsigned _width, unsigned _height)
{
PTRACE(4, "PreviewManager\tStarting Preview");
- width = _width;
- height = _height;
- end_thread = false;
- frame = (char*) malloc (unsigned (width * height * 3 / 2));
+
+ {
+ PWaitAndSignal c(capture_mutex);
+ width = _width;
+ height = _height;
+ pause_thread = false;
+ }
videooutput_core->start();
- pause_thread = false;
- run_thread.Signal();
}
void VideoInputCore::VideoPreviewManager::stop ()
{
PTRACE(4, "PreviewManager\tStopping Preview");
- pause_thread = true;
- thread_paused.Wait();
- if (frame) {
- free (frame);
- frame = NULL;
+ {
+ PWaitAndSignal c(capture_mutex);
+ if (pause_thread)
+ return;
+ pause_thread = true;
}
+
videooutput_core->stop();
}
void VideoInputCore::VideoPreviewManager::Main ()
{
- PWaitAndSignal m(thread_ended);
+ PWaitAndSignal m(thread_mutex);
+ bool exit = end_thread;
+ bool capture = !pause_thread;
- while (!end_thread) {
+ while (!exit) {
- thread_paused.Signal ();
- run_thread.Wait ();
+ {
+ PWaitAndSignal c(capture_mutex);
+ capture = !pause_thread;
+ if (capture) {
+ if (frame)
+ free (frame);
+ frame = (char*) malloc (unsigned (width * height * 3 / 2));
+ }
+ }
+ while (capture) {
- while (!pause_thread) {
if (frame) {
+
videoinput_core.get_frame_data(frame);
videooutput_core->set_frame_data(frame, width, height, 0, 1);
}
+ {
+ PWaitAndSignal c(capture_mutex);
+ capture = !pause_thread;
+ }
+
// We have to sleep some time outside the mutex lock
// to give other threads time to get the mutex
// It will be taken into account by PAdaptiveDelay
Current()->Sleep (5);
}
+ {
+ PWaitAndSignal q(exit_mutex);
+ exit = end_thread;
+ }
+
+ Current()->Sleep (5);
}
}
@@ -129,6 +155,7 @@ VideoInputCore::VideoInputCore (Ekiga::ServiceCore & _core,
preview_manager = new VideoPreviewManager (*this, _videooutput_core);
+
preview_config.active = false;
preview_config.width = 176;
preview_config.height = 144;
@@ -152,6 +179,9 @@ VideoInputCore::VideoInputCore (Ekiga::ServiceCore & _core,
current_manager = NULL;
videoinput_core_conf_bridge = NULL;
notification_core = core.get<Ekiga::NotificationCore> ("notification-core");
+
+ device_settings = new Settings (VIDEO_DEVICES_SCHEMA);
+ device_settings->changed.connect (boost::bind (&VideoInputCore::setup, this, _1));
}
VideoInputCore::~VideoInputCore ()
@@ -169,8 +199,11 @@ VideoInputCore::~VideoInputCore ()
delete (*iter);
managers.clear();
+
+ delete device_settings;
}
+
void VideoInputCore::setup_conf_bridge ()
{
PWaitAndSignal m(core_mutex);
@@ -178,6 +211,40 @@ void VideoInputCore::setup_conf_bridge ()
videoinput_core_conf_bridge = new VideoInputCoreConfBridge (*this);
}
+
+void VideoInputCore::setup (std::string setting)
+{
+ std::cout << "dans setup " << setting << std::endl << std::flush;
+ GSettings* settings = device_settings->get_g_settings ();
+ VideoInputDevice device;
+
+ /* 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 channel = g_settings_get_int (settings, "channel");
+ device.SetFromString (device_string);
+
+ std::cout << "dans setup set device " << setting << " " << device_string << std::endl << std::flush;
+ set_device (device, channel, (VideoInputFormat) video_format);
+ g_free (device_string);
+ }
+
+ /* Previenw */
+ if (setting == "any" || setting == "enable-preview") {
+ std::cout << "dans setup " << setting << std::endl << std::flush;
+ if (g_settings_get_boolean (settings, "enable-preview")) {
+ std::cout << "start " << std::endl << std::flush;
+ start_preview ();
+ }
+ else {
+ std::cout << "stop " << std::endl << std::flush;
+ stop_preview ();
+ }
+ }
+}
+
+
void VideoInputCore::add_manager (VideoInputManager &manager)
{
managers.insert (&manager);
@@ -220,10 +287,46 @@ void VideoInputCore::get_devices (std::vector <VideoInputDevice> & devices)
#endif
}
-void VideoInputCore::set_device(const VideoInputDevice & device, int channel, VideoInputFormat format)
+void VideoInputCore::set_device(const VideoInputDevice & _device, int channel, VideoInputFormat format)
{
PWaitAndSignal m(core_mutex);
- internal_set_device(device, channel, format);
+ std::cout << "dans set_device" << std::endl << std::flush;
+ VideoInputDevice device;
+
+ /* Check if device exists */
+ std::vector <VideoInputDevice> devices;
+ bool found = false;
+ get_devices (devices);
+ for (std::vector<VideoInputDevice>::iterator it = devices.begin ();
+ it < devices.end ();
+ it++) {
+ if ((*it).GetString () == _device.GetString ()) {
+ found = true;
+ break;
+ }
+ }
+ PTRACE(4, "VidInputCoreConfBridge\tUpdating device");
+
+ if (found)
+ device = _device;
+ else
+ device.SetFromString (devices.begin ()->GetString ());
+
+ if ( (device.type == "" ) ||
+ (device.source == "") ||
+ (device.name == "" ) ) {
+ PTRACE(1, "VidinputCore\tTried to set malformed device");
+ device.type = VIDEO_INPUT_FALLBACK_DEVICE_TYPE;
+ device.source = VIDEO_INPUT_FALLBACK_DEVICE_SOURCE;
+ device.name = VIDEO_INPUT_FALLBACK_DEVICE_NAME;
+ }
+
+ if (format >= VI_FORMAT_MAX) {
+ PTRACE(1, "VidInputCoreConfBridge\t" << VIDEO_DEVICES_KEY "format" << " out of range, ajusting to 3");
+ format = (VideoInputFormat) 3;
+ }
+
+ internal_set_device (device, channel, format);
desired_device = device;
}
@@ -400,8 +503,6 @@ void VideoInputCore::get_frame_data (char *data)
internal_close();
- internal_set_fallback();
-
if (preview_config.active && !stream_config.active)
internal_open(preview_config.width, preview_config.height, preview_config.fps);
diff --git a/lib/engine/videoinput/videoinput-core.h b/lib/engine/videoinput/videoinput-core.h
index 3f87f89..de21651 100644
--- a/lib/engine/videoinput/videoinput-core.h
+++ b/lib/engine/videoinput/videoinput-core.h
@@ -49,9 +49,11 @@
#include <boost/bind.hpp>
#include <glib.h>
#include <set>
+#include <gio/gio.h>
#include "ptbuildopts.h"
#include "ptlib.h"
+#include "ekiga-settings.h"
#define VIDEO_INPUT_FALLBACK_DEVICE_TYPE "Moving Logo"
#define VIDEO_INPUT_FALLBACK_DEVICE_SOURCE "Moving Logo"
@@ -117,6 +119,10 @@ namespace Ekiga
*/
void setup_conf_bridge();
+ /** Set up settings
+ */
+ void setup (std::string setting);
+
/*** Service Implementation ***/
@@ -354,9 +360,10 @@ private:
bool end_thread;
bool pause_thread;
- PMutex thread_ended;
- PSyncPoint thread_paused;
- PSyncPoint run_thread;
+
+ PMutex exit_mutex;
+ PMutex thread_mutex;
+ PMutex capture_mutex;
VideoInputCore & videoinput_core;
boost::shared_ptr<VideoOutputCore> videooutput_core;
@@ -419,6 +426,7 @@ private:
};
private:
+
std::set<VideoInputManager *> managers;
VideoDeviceConfig preview_config;
@@ -429,7 +437,7 @@ private:
VideoInputDevice current_device;
VideoInputFormat current_format;
int current_channel;
- VideoInputSettings current_settings;
+ VideoInputSettings current_settings;
VideoInputSettings desired_settings;
PMutex core_mutex;
@@ -439,6 +447,8 @@ private:
VideoPreviewManager* preview_manager;
VideoInputCoreConfBridge* videoinput_core_conf_bridge;
boost::shared_ptr<Ekiga::NotificationCore> notification_core;
+
+ Settings* device_settings;
};
/**
* @}
diff --git a/lib/engine/videoinput/videoinput-gmconf-bridge.cpp
b/lib/engine/videoinput/videoinput-gmconf-bridge.cpp
index 12b9997..6309f8e 100644
--- a/lib/engine/videoinput/videoinput-gmconf-bridge.cpp
+++ b/lib/engine/videoinput/videoinput-gmconf-bridge.cpp
@@ -80,68 +80,6 @@ VideoInputCoreConfBridge::on_property_changed (std::string key,
VideoSizes[size].height,
max_frame_rate);
}
- else if ( (key == VIDEO_DEVICES_KEY "input_device") ||
- (key == VIDEO_DEVICES_KEY "channel") ||
- (key == VIDEO_DEVICES_KEY "format") ) {
-
- std::vector <VideoInputDevice> devices;
- bool found = false;
- gchar *value = gm_conf_get_string (VIDEO_DEVICES_KEY "input_device");
- videoinput_core.get_devices (devices);
- if (value != NULL) {
- for (std::vector<VideoInputDevice>::iterator it = devices.begin ();
- it < devices.end ();
- it++) {
- if ((*it).GetString () == value) {
- found = true;
- break;
- }
- }
- }
- PTRACE(4, "VidInputCoreConfBridge\tUpdating device");
-
- VideoInputDevice device;
- if (found)
- device.SetFromString (value);
- else
- device.SetFromString (devices.begin ()->GetString ());
- g_free (value);
-
- if ( (device.type == "" ) ||
- (device.source == "") ||
- (device.name == "" ) ) {
- PTRACE(1, "VidinputCore\tTried to set malformed device");
- device.type = VIDEO_INPUT_FALLBACK_DEVICE_TYPE;
- device.source = VIDEO_INPUT_FALLBACK_DEVICE_SOURCE;
- device.name = VIDEO_INPUT_FALLBACK_DEVICE_NAME;
- }
-
- unsigned video_format = gm_conf_get_int (VIDEO_DEVICES_KEY "format");
- if (video_format >= VI_FORMAT_MAX) {
- PTRACE(1, "VidInputCoreConfBridge\t" << VIDEO_DEVICES_KEY "format" << " out of range, ajusting to 3");
- video_format = 3;
- }
-
- videoinput_core.set_device (device, gm_conf_get_int (VIDEO_DEVICES_KEY "channel") ,(VideoInputFormat)
video_format);
- }
- else if (key == VIDEO_DEVICES_KEY "enable_preview") {
-
- static bool startup = true;
-
- if (!startup) {
-
- PTRACE(4, "VidInputCoreConfBridge\tUpdating preview");
- if (gm_conf_get_bool ( VIDEO_DEVICES_KEY "enable_preview"))
- videoinput_core.start_preview();
- else
- videoinput_core.stop_preview();
- } else {
-
- startup = false;
- if (gm_conf_get_bool ( VIDEO_DEVICES_KEY "enable_preview"))
- Ekiga::Runtime::run_in_main (boost::bind (&VideoInputCore::start_preview, boost::ref
(videoinput_core)), 5);
- }
- }
else if (key == VIDEO_DEVICES_KEY "image") {
PTRACE(4, "VidInputCoreConfBridge\tUpdating image");
}
diff --git a/src/gui/main_window.cpp b/src/gui/main_window.cpp
index e75f516..d75dfaa 100644
--- a/src/gui/main_window.cpp
+++ b/src/gui/main_window.cpp
@@ -151,6 +151,7 @@ struct _EkigaMainWindowPrivate
std::list<gpointer> notifiers;
GSettings *sound_events_settings;
+ GSettings *video_devices_settings;
};
/* channel types */
@@ -255,9 +256,9 @@ static void panel_section_changed_nt (gpointer id,
* BEHAVIOR : Show / hide the call window.
* PRE : /
*/
-static void video_preview_changed_nt (gpointer id,
- GmConfEntry *entry,
- gpointer data);
+static void video_preview_changed (GSettings *settings,
+ gchar *key,
+ gpointer data);
/** Pull a trigger from a Ekiga::Service
*
@@ -784,7 +785,8 @@ on_delayed_hide_call_window_cb (gpointer data)
GtkWidget* call_window = GTK_WIDGET (gtk_frontend->get_call_window ());
- if (!mw->priv->current_call && !gm_conf_get_bool (VIDEO_DEVICES_KEY "enable_preview"))
+ if (!mw->priv->current_call
+ && !g_settings_get_boolean (mw->priv->video_devices_settings, "enable-preview"))
gtk_widget_hide (GTK_WIDGET (call_window));
}
@@ -950,39 +952,35 @@ panel_section_changed_nt (G_GNUC_UNUSED gpointer id,
static void
-video_preview_changed_nt (G_GNUC_UNUSED gpointer id,
- GmConfEntry *entry,
- gpointer data)
+video_preview_changed (GSettings *settings,
+ gchar *key,
+ gpointer data)
{
g_return_if_fail (EKIGA_IS_MAIN_WINDOW (data));
- if (gm_conf_entry_get_type (entry) == GM_CONF_BOOL) {
+ EkigaMainWindow* mw = EKIGA_MAIN_WINDOW (data);
+ GtkWidget *menu_item = NULL;
- EkigaMainWindow* mw = EKIGA_MAIN_WINDOW (data);
- GtkWidget *menu_item = NULL;
-
- if (gm_conf_entry_get_type (entry) == GM_CONF_BOOL) {
- if (mw->priv->calling_state == Standby) {
-
- boost::shared_ptr<GtkFrontend> gtk_frontend = mw->priv->gtk_frontend.lock ();
- if (gtk_frontend) {
-
- GtkWidget *call_window = GTK_WIDGET (gtk_frontend->get_call_window ());
- if (!gm_conf_entry_get_bool (entry))
- gtk_widget_hide (call_window);
- else
- gtk_widget_show (call_window);
- }
- g_signal_handlers_block_by_func (mw->priv->preview_button,
- (gpointer) video_preview_action_toggled_cb, mw);
- menu_item = gtk_menu_get_widget (mw->priv->main_menu, "preview");
- gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (menu_item), gm_conf_entry_get_bool (entry));
- gtk_toggle_tool_button_set_active (GTK_TOGGLE_TOOL_BUTTON (mw->priv->preview_button),
- gm_conf_entry_get_bool (entry));
- g_signal_handlers_unblock_by_func (mw->priv->preview_button,
- (gpointer) video_preview_action_toggled_cb, mw);
- }
+ if (mw->priv->calling_state == Standby) {
+
+ bool toggled = g_settings_get_boolean (settings, key);
+ boost::shared_ptr<GtkFrontend> gtk_frontend = mw->priv->gtk_frontend.lock ();
+ if (gtk_frontend) {
+
+ GtkWidget *call_window = GTK_WIDGET (gtk_frontend->get_call_window ());
+ if (!toggled)
+ gtk_widget_hide (call_window);
+ else
+ gtk_widget_show (call_window);
}
+ g_signal_handlers_block_by_func (mw->priv->preview_button,
+ (gpointer) video_preview_action_toggled_cb, mw);
+ menu_item = gtk_menu_get_widget (mw->priv->main_menu, "preview");
+ gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (menu_item), toggled);
+ gtk_toggle_tool_button_set_active (GTK_TOGGLE_TOOL_BUTTON (mw->priv->preview_button),
+ toggled);
+ g_signal_handlers_unblock_by_func (mw->priv->preview_button,
+ (gpointer) video_preview_action_toggled_cb, mw);
}
}
@@ -1019,9 +1017,14 @@ panel_section_action_clicked_cb (GtkWidget * /*widget*/,
static void
video_preview_action_toggled_cb (GtkToggleToolButton *b,
- G_GNUC_UNUSED gpointer data)
+ gpointer data)
{
- gm_conf_set_bool (VIDEO_DEVICES_KEY "enable_preview", gtk_toggle_tool_button_get_active (b));
+ if (g_settings_get_boolean (EKIGA_MAIN_WINDOW (data)->priv->video_devices_settings,
+ "enable-preview")
+ != gtk_toggle_tool_button_get_active (b))
+ g_settings_set_boolean (EKIGA_MAIN_WINDOW (data)->priv->video_devices_settings,
+ "enable-preview",
+ gtk_toggle_tool_button_get_active (b));
}
@@ -1297,7 +1300,8 @@ ekiga_main_window_init_menu (EkigaMainWindow *mw)
/* Default values */
cps = (PanelSection) gm_conf_get_int (USER_INTERFACE_KEY "main_window/panel_section");
show_offline_contacts = gm_conf_get_bool (CONTACTS_KEY "show_offline_contacts");
- enable_preview = gm_conf_get_bool (VIDEO_DEVICES_KEY "enable_preview");
+ enable_preview = g_settings_get_boolean (mw->priv->video_devices_settings,
+ "enable-preview");
static MenuEntry gnomemeeting_menu [] =
{
@@ -1362,6 +1366,7 @@ ekiga_main_window_init_menu (EkigaMainWindow *mw)
GTK_MENU_NEW(_("_View")),
+ //FIXME GSETTINGS MENU
GTK_MENU_TOGGLE_ENTRY("preview", _("_Video Preview"),
_("Display images from your camera device"),
NULL, 0,
@@ -1579,6 +1584,7 @@ ekiga_main_window_init (EkigaMainWindow *mw)
mw->priv->calling_state = Standby;
mw->priv->sound_events_settings = g_settings_new (SOUND_EVENTS_SCHEMA);
+ mw->priv->video_devices_settings = g_settings_new (VIDEO_DEVICES_SCHEMA);
for (int i = 0 ; i < NUM_SECTIONS ; i++)
mw->priv->toggle_buttons[i] = NULL;
@@ -1589,10 +1595,9 @@ ekiga_main_window_init (EkigaMainWindow *mw)
gm_conf_notifier_add (USER_INTERFACE_KEY "main_window/panel_section",
panel_section_changed_nt, mw);
mw->priv->notifiers.push_front (notifier);
- notifier =
- gm_conf_notifier_add (VIDEO_DEVICES_KEY "enable_preview",
- video_preview_changed_nt, mw);
- mw->priv->notifiers.push_front (notifier);
+
+ g_signal_connect (mw->priv->video_devices_settings, "changed::enable-preview",
+ G_CALLBACK (video_preview_changed), mw);
}
static GObject *
@@ -1628,6 +1633,7 @@ ekiga_main_window_dispose (GObject* gobject)
}
g_clear_object (&mw->priv->sound_events_settings);
+ g_clear_object (&mw->priv->video_devices_settings);
G_OBJECT_CLASS (ekiga_main_window_parent_class)->dispose (gobject);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]