[ekiga/ds-gtk-application] Ekiga: Moved preview control to EkigaApplication.



commit cba0ad9277c3b8b20f761c7079c74f4e0ad278d4
Author: Damien Sandras <dsandras beip be>
Date:   Sat Feb 15 18:36:09 2014 +0100

    Ekiga: Moved preview control to EkigaApplication.
    
    This looks pretty logical to control preview display from the main
    application and not from the VideoInputCore directly as it requires the
    call window to be displayed before starting preview.

 lib/engine/gui/gtk-frontend/ekiga-app.cpp   |   30 ++++++++++++++++++++++++++-
 lib/engine/gui/gtk-frontend/main_window.cpp |   30 ---------------------------
 2 files changed, 29 insertions(+), 31 deletions(-)
---
diff --git a/lib/engine/gui/gtk-frontend/ekiga-app.cpp b/lib/engine/gui/gtk-frontend/ekiga-app.cpp
index 84541eb..2cf331b 100644
--- a/lib/engine/gui/gtk-frontend/ekiga-app.cpp
+++ b/lib/engine/gui/gtk-frontend/ekiga-app.cpp
@@ -105,6 +105,8 @@ struct _GmApplicationPrivate
   GtkWidget *main_window;
   GtkWidget *chat_window;
 
+  boost::shared_ptr<Ekiga::Settings> video_devices_settings;
+
   EkigaDBusComponent *dbus_component;
 };
 
@@ -197,6 +199,27 @@ window_activated (GSimpleAction *action,
     gm_application_show_assistant_window (self);
 }
 
+
+static void
+video_preview_changed (GSettings *settings,
+                       const gchar *key,
+                       gpointer data)
+{
+  g_return_if_fail (GM_IS_APPLICATION (data));
+
+  GmApplication *self = GM_APPLICATION (data);
+  boost::shared_ptr<Ekiga::VideoInputCore> video_input_core =
+    self->priv->core->get<Ekiga::VideoInputCore> ("videoinput-core");
+
+  if (g_settings_get_boolean (settings, key)) {
+    gm_application_show_call_window (self);
+    video_input_core->start_preview ();
+  }
+  else
+    video_input_core->stop_preview ();
+}
+
+
 static GActionEntry app_entries[] =
 {
     { "preferences", window_activated, NULL, NULL, NULL, 0 },
@@ -272,7 +295,6 @@ gm_application_startup (GApplication *app)
   GtkBuilder *builder = NULL;
 
   GMenuModel *app_menu = NULL;
-  GMenuModel *menubar = NULL;
 
   G_APPLICATION_CLASS (gm_application_parent_class)->startup (app);
 
@@ -378,6 +400,12 @@ gm_application_startup (GApplication *app)
   app_menu = G_MENU_MODEL (gtk_builder_get_object (builder, "appmenu"));
   gtk_application_set_app_menu (GTK_APPLICATION (self), app_menu);
   g_object_unref (builder);
+
+  self->priv->video_devices_settings =
+    boost::shared_ptr<Ekiga::Settings> (new Ekiga::Settings (VIDEO_DEVICES_SCHEMA));
+  g_signal_connect (self->priv->video_devices_settings->get_g_settings (),
+                    "changed::enable-preview",
+                    G_CALLBACK (video_preview_changed), self);
 }
 
 
diff --git a/lib/engine/gui/gtk-frontend/main_window.cpp b/lib/engine/gui/gtk-frontend/main_window.cpp
index 8402d67..13110ec 100644
--- a/lib/engine/gui/gtk-frontend/main_window.cpp
+++ b/lib/engine/gui/gtk-frontend/main_window.cpp
@@ -191,14 +191,6 @@ static void panel_section_changed (GtkNotebook *notebook,
                                    gpointer user_data);
 
 
-/* DESCRIPTION  :  This callback is called when the preview button is toggled.
- * BEHAVIOR     :  Show / hide the call window.
- * PRE          :  /
- */
-static void video_preview_changed (GtkToggleToolButton *button,
-                                   gpointer data);
-
-
 /* DESCRIPTION  :  This callback is called when the user
  *                 presses a key.
  * BEHAVIOR     :  Sends a DTMF if we are in a call.
@@ -639,28 +631,6 @@ panel_section_changed (G_GNUC_UNUSED GtkNotebook *notebook,
 
 
 static void
-video_preview_changed (GtkToggleToolButton *button,
-                       gpointer data)
-{
-  g_return_if_fail (EKIGA_IS_MAIN_WINDOW (data));
-
-  EkigaMainWindow* mw = EKIGA_MAIN_WINDOW (data);
-
-  if (mw->priv->calling_state == Standby) {
-
-    bool toggled = gtk_toggle_tool_button_get_active (button);
-    if (!toggled) {
-      if (mw->priv->call_window)
-        gtk_widget_destroy (mw->priv->call_window);
-      mw->priv->call_window = NULL;
-    }
-    else
-      mw->priv->call_window = gm_application_show_call_window (mw->priv->app);
-  }
-}
-
-
-static void
 dialpad_button_clicked_cb (EkigaDialpad  * /* dialpad */,
                           const gchar *button_text,
                           EkigaMainWindow *mw)


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