[ekiga] Moved the main window and the assistant to lib/engine/gui/gtk-frontend
- From: Julien Puydt <jpuydt src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [ekiga] Moved the main window and the assistant to lib/engine/gui/gtk-frontend
- Date: Wed, 19 Jun 2013 17:59:35 +0000 (UTC)
commit f90a305c9ee344bf32fe3a786bc53a9043d2d47d
Author: Julien Puydt <jpuydt free fr>
Date: Wed Jun 19 07:24:40 2013 +0200
Moved the main window and the assistant to lib/engine/gui/gtk-frontend
The files were not renamed, the api wasn't streamlined, there is
no memory management (everything is leaked), but it should still be a
good starting point.
lib/Makefile.am | 4 +
.../engine/gui/gtk-frontend}/assistant.cpp | 17 ++++--
.../engine/gui/gtk-frontend}/assistant.h | 0
lib/engine/gui/gtk-frontend/gtk-frontend.cpp | 42 ++++++++++--
lib/engine/gui/gtk-frontend/gtk-frontend.h | 6 ++
.../engine/gui/gtk-frontend}/main_window.cpp | 3 +-
.../engine/gui/gtk-frontend}/main_window.h | 0
src/Makefile.am | 6 +--
src/dbus-helper/dbus.cpp | 21 ++++--
src/ekiga.cpp | 68 --------------------
src/ekiga.h | 29 --------
src/gui/main.cpp | 35 ++++++++--
12 files changed, 101 insertions(+), 130 deletions(-)
---
diff --git a/lib/Makefile.am b/lib/Makefile.am
index 4954c00..aa14282 100644
--- a/lib/Makefile.am
+++ b/lib/Makefile.am
@@ -421,6 +421,10 @@ libekiga_la_SOURCES += \
$(engine_dir)/gui/gtk-frontend/addressbook-window.cpp \
$(engine_dir)/gui/gtk-frontend/accounts-window.h \
$(engine_dir)/gui/gtk-frontend/accounts-window.cpp \
+ $(engine_dir)/gui/gtk-frontend/assistant.h \
+ $(engine_dir)/gui/gtk-frontend/assistant.cpp \
+ $(engine_dir)/gui/gtk-frontend/main_window.h \
+ $(engine_dir)/gui/gtk-frontend/main_window.cpp \
$(engine_dir)/gui/gtk-frontend/book-view-gtk.h \
$(engine_dir)/gui/gtk-frontend/book-view-gtk.cpp \
$(engine_dir)/gui/gtk-frontend/call-window.h \
diff --git a/src/gui/assistant.cpp b/lib/engine/gui/gtk-frontend/assistant.cpp
similarity index 99%
rename from src/gui/assistant.cpp
rename to lib/engine/gui/gtk-frontend/assistant.cpp
index e346d20..670784e 100644
--- a/src/gui/assistant.cpp
+++ b/lib/engine/gui/gtk-frontend/assistant.cpp
@@ -43,13 +43,11 @@
#include "account-core.h"
#include "account.h"
-
-#include "ekiga.h"
#include "gmconf.h"
#include "platform.h"
#include "assistant.h"
#include "default_devices.h"
-
+#include "gtk-frontend.h"
#include "opal-bank.h"
#include "videoinput-core.h"
#include "audioinput-core.h"
@@ -60,6 +58,7 @@ G_DEFINE_TYPE (EkigaAssistant, ekiga_assistant, GTK_TYPE_ASSISTANT);
struct _EkigaAssistantPrivate
{
+ Ekiga::ServiceCore* service_core; // FIXME: wrong memory management
boost::shared_ptr<Ekiga::VideoInputCore> videoinput_core;
boost::shared_ptr<Ekiga::AudioInputCore> audioinput_core;
boost::shared_ptr<Ekiga::AudioOutputCore> audiooutput_core;
@@ -1610,16 +1609,22 @@ ekiga_assistant_apply (GtkAssistant *gtkassistant)
/* Hide the assistant and show the main Ekiga window */
gtk_widget_hide (GTK_WIDGET (assistant));
gtk_assistant_set_current_page (gtkassistant, 0);
- gtk_widget_show (GnomeMeeting::Process ()->GetMainWindow ());
+ boost::shared_ptr<GtkFrontend> gtk_frontend
+ = assistant->priv->service_core->get<GtkFrontend>("gtk-frontend");
+ gtk_widget_show (GTK_WIDGET (gtk_frontend->get_main_window ()));
}
static void
ekiga_assistant_cancel (GtkAssistant *gtkassistant)
{
+ EkigaAssistant *assistant = EKIGA_ASSISTANT (gtkassistant);
+
gtk_assistant_set_current_page (gtkassistant, 0);
gtk_widget_hide (GTK_WIDGET (gtkassistant));
- gtk_widget_show (GnomeMeeting::Process ()->GetMainWindow ());
+ boost::shared_ptr<GtkFrontend> gtk_frontend
+ = assistant->priv->service_core->get<GtkFrontend>("gtk-frontend");
+ gtk_widget_show (GTK_WIDGET (gtk_frontend->get_main_window ()));
}
@@ -1686,6 +1691,8 @@ ekiga_assistant_new (Ekiga::ServiceCore& service_core)
assistant = EKIGA_ASSISTANT (g_object_new (EKIGA_TYPE_ASSISTANT, NULL));
+ assistant->priv->service_core = &service_core;
+
/* FIXME: move this into the caller */
g_signal_connect (assistant, "key-press-event",
G_CALLBACK (ekiga_assistant_key_press_cb), NULL);
diff --git a/src/gui/assistant.h b/lib/engine/gui/gtk-frontend/assistant.h
similarity index 100%
rename from src/gui/assistant.h
rename to lib/engine/gui/gtk-frontend/assistant.h
diff --git a/lib/engine/gui/gtk-frontend/gtk-frontend.cpp b/lib/engine/gui/gtk-frontend/gtk-frontend.cpp
index f8f86f6..4979c66 100644
--- a/lib/engine/gui/gtk-frontend/gtk-frontend.cpp
+++ b/lib/engine/gui/gtk-frontend/gtk-frontend.cpp
@@ -43,14 +43,16 @@
#include "config.h"
#include "gtk-frontend.h"
-
+#include "gmstockicons.h"
#include "chat-core.h"
#include "contact-core.h"
#include "presence-core.h"
#include "addressbook-window.h"
#include "accounts-window.h"
+#include "assistant.h"
#include "call-window.h"
#include "chat-window.h"
+#include "main_window.h"
#include "statusicon.h"
#include "preferences-window.h"
#include "roster-view-gtk.h"
@@ -87,15 +89,20 @@ GtkFrontend::GtkFrontend (Ekiga::ServiceCore & _core) : core(_core)
{
}
-
GtkFrontend::~GtkFrontend ()
{
- gtk_widget_destroy (addressbook_window);
- gtk_widget_destroy (accounts_window);
- gtk_widget_destroy (chat_window);
- gtk_widget_destroy (call_window);
- if (status_icon)
- g_object_unref (status_icon);
+ // FIXME: we leak everything here, but the
+ // code should be reworked for a correct memory
+ // management
+
+ //gtk_widget_destroy (assistant_window);
+ //gtk_widget_destroy (addressbook_window);
+ //gtk_widget_destroy (accounts_window);
+ //gtk_widget_destroy (chat_window);
+ //gtk_widget_destroy (call_window);
+ //if (status_icon)
+ // g_object_unref (status_icon);
+ //gtk_widget_destroy (main_window);
}
@@ -104,13 +111,20 @@ void GtkFrontend::build ()
boost::shared_ptr<Ekiga::ContactCore> contact_core = core.get<Ekiga::ContactCore> ("contact-core");
boost::shared_ptr<Ekiga::ChatCore> chat_core = core.get<Ekiga::ChatCore> ("chat-core");
+ /* Init the stock icons */
+ gnomemeeting_stock_icons_init ();
+ gtk_window_set_default_icon_name (GM_ICON_LOGO);
+
addressbook_window =
addressbook_window_new_with_key (*contact_core, "/apps/" PACKAGE_NAME
"/general/user_interface/addressbook_window");
accounts_window = accounts_window_new_with_key (core, "/apps/" PACKAGE_NAME
"/general/user_interface/accounts_window");
+ assistant_window = ekiga_assistant_new (core);
call_window = call_window_new (core);
chat_window = chat_window_new (core, "/apps/" PACKAGE_NAME "/general/user_interface/chat_window");
preferences_window = preferences_window_new (core);
status_icon = status_icon_new (core);
+ main_window = gm_main_window_new (core);
+ gtk_window_set_transient_for (GTK_WINDOW (assistant_window), GTK_WINDOW (main_window));
}
@@ -125,6 +139,18 @@ const std::string GtkFrontend::get_description () const
return "\tGtk+ frontend support";
}
+const GtkWidget*
+GtkFrontend::get_assistant_window () const
+{
+ return assistant_window;
+}
+
+const GtkWidget*
+GtkFrontend::get_main_window () const
+{
+ return main_window;
+}
+
const GtkWidget *GtkFrontend::get_addressbook_window () const
{
diff --git a/lib/engine/gui/gtk-frontend/gtk-frontend.h b/lib/engine/gui/gtk-frontend/gtk-frontend.h
index 5c91bbb..81b4006 100644
--- a/lib/engine/gui/gtk-frontend/gtk-frontend.h
+++ b/lib/engine/gui/gtk-frontend/gtk-frontend.h
@@ -63,6 +63,10 @@ public:
const std::string get_description () const;
+ const GtkWidget* get_assistant_window () const;
+
+ const GtkWidget* get_main_window () const;
+
const GtkWidget *get_preferences_window () const;
const GtkWidget *get_addressbook_window () const;
@@ -77,6 +81,8 @@ public:
private :
+ GtkWidget* assistant_window;
+ GtkWidget* main_window;
GtkWidget *preferences_window;
GtkWidget *addressbook_window;
GtkWidget *accounts_window;
diff --git a/src/gui/main_window.cpp b/lib/engine/gui/gtk-frontend/main_window.cpp
similarity index 99%
rename from src/gui/main_window.cpp
rename to lib/engine/gui/gtk-frontend/main_window.cpp
index d729861..b11042f 100644
--- a/src/gui/main_window.cpp
+++ b/lib/engine/gui/gtk-frontend/main_window.cpp
@@ -39,7 +39,6 @@
#include "main_window.h"
-#include "ekiga.h"
#include "dialpad.h"
#include "statusmenu.h"
@@ -1279,7 +1278,7 @@ ekiga_main_window_init_menu (EkigaMainWindow *mw)
addressbook_window = GTK_WIDGET (gtk_frontend->get_addressbook_window ());
accounts_window = GTK_WIDGET (gtk_frontend->get_accounts_window ());
prefs_window = GTK_WIDGET (gtk_frontend->get_preferences_window ());
- assistant_window = GnomeMeeting::Process ()->GetAssistantWindow ();
+ assistant_window = GTK_WIDGET (gtk_frontend->get_assistant_window ());
/* Default values */
cps = (PanelSection) gm_conf_get_int (USER_INTERFACE_KEY "main_window/panel_section");
diff --git a/src/gui/main_window.h b/lib/engine/gui/gtk-frontend/main_window.h
similarity index 100%
rename from src/gui/main_window.h
rename to lib/engine/gui/gtk-frontend/main_window.h
diff --git a/src/Makefile.am b/src/Makefile.am
index 2f61ef1..c086640 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -55,11 +55,7 @@ nodist_ekiga_SOURCES =
# Graphical User Interface
ekiga_SOURCES += \
- gui/assistant.h \
- gui/assistant.cpp \
- gui/main.cpp \
- gui/main_window.h \
- gui/main_window.cpp
+ gui/main.cpp
# Endpoints
ekiga_SOURCES += \
diff --git a/src/dbus-helper/dbus.cpp b/src/dbus-helper/dbus.cpp
index a2cbbc3..d417c59 100644
--- a/src/dbus-helper/dbus.cpp
+++ b/src/dbus-helper/dbus.cpp
@@ -42,11 +42,10 @@
#include <dbus/dbus-glib.h>
#include "dbus.h"
-
#include "ekiga.h"
#include "gmconf.h"
#include "gmcallbacks.h"
-
+#include "gtk-frontend.h"
#include "call-core.h"
/* Those defines the namespace and path we want to use. */
@@ -58,7 +57,8 @@ G_DEFINE_TYPE(EkigaDBusComponent, ekiga_dbus_component, G_TYPE_OBJECT);
struct _EkigaDBusComponentPrivate
{
- Ekiga::ServiceCore* service_core;
+ boost::weak_ptr<Ekiga::CallCore> call_core;
+ boost::weak_ptr<GtkFrontend> gtk_frontend;
};
/**************************
@@ -105,12 +105,15 @@ ekiga_dbus_component_class_init (EkigaDBusComponentClass *klass)
}
static gboolean
-ekiga_dbus_component_show (G_GNUC_UNUSED EkigaDBusComponent *self,
+ekiga_dbus_component_show (EkigaDBusComponent *self,
G_GNUC_UNUSED GError **error)
{
PTRACE (1, "DBus\tShow");
+ boost::shared_ptr<GtkFrontend> gtk_frontend = self->priv->gtk_frontend.lock ();
+
+ g_return_val_if_fail (gtk_frontend, FALSE);
- GtkWidget *window = GnomeMeeting::Process ()->GetMainWindow ();
+ const GtkWidget *window = gtk_frontend->get_main_window ();
if (gtk_widget_get_visible (GTK_WIDGET (window)))
gtk_window_set_urgency_hint (GTK_WINDOW (window), TRUE);
else
@@ -133,7 +136,10 @@ ekiga_dbus_component_call (EkigaDBusComponent *self,
const gchar *uri,
G_GNUC_UNUSED GError **error)
{
- boost::shared_ptr<Ekiga::CallCore> call_core = self->priv->service_core->get<Ekiga::CallCore>
("call-core");
+ boost::shared_ptr<Ekiga::CallCore> call_core = self->priv->call_core.lock ();
+
+ g_return_val_if_fail (call_core, FALSE);
+
call_core->dial (uri);
return TRUE;
@@ -245,7 +251,8 @@ ekiga_dbus_component_new (Ekiga::ServiceCore& service_core)
}
obj = EKIGA_DBUS_COMPONENT (g_object_new (EKIGA_TYPE_DBUS_COMPONENT, NULL));
- obj->priv->service_core = &service_core;
+ obj->priv->gtk_frontend = service_core.get<GtkFrontend> ("gtk-frontend");
+ obj->priv->call_core = service_core.get<Ekiga::CallCore> ("call-core");
dbus_g_connection_register_g_object (bus, EKIGA_DBUS_PATH, G_OBJECT (obj));
return obj;
diff --git a/src/ekiga.cpp b/src/ekiga.cpp
index 00bd8d5..e1f0fff 100644
--- a/src/ekiga.cpp
+++ b/src/ekiga.cpp
@@ -41,7 +41,6 @@
#include "ekiga.h"
#include "assistant.h"
#include "main_window.h"
-#include "gmstockicons.h"
#include <opal/buildopts.h>
@@ -56,28 +55,12 @@ GnomeMeeting::GnomeMeeting ()
{
GM = this;
-
- assistant_window = NULL;
- main_window = NULL;
- assistant_window = NULL;
}
void
GnomeMeeting::Exit ()
{
- if (main_window) {
- gtk_widget_hide (main_window);
- gtk_widget_destroy (main_window);
- }
- main_window = NULL;
-
- if (assistant_window) {
- gtk_widget_hide (assistant_window);
- gtk_widget_destroy (assistant_window);
- }
- assistant_window = NULL;
-
while (gtk_events_pending ())
gtk_main_iteration ();
}
@@ -90,57 +73,6 @@ GnomeMeeting::Process ()
}
-GtkWidget *
-GnomeMeeting::GetMainWindow ()
-{
- return main_window;
-}
-
-
-GtkWidget *
-GnomeMeeting::GetAssistantWindow ()
-{
- return assistant_window;
-}
-
-
void GnomeMeeting::Main ()
{
}
-
-
-void GnomeMeeting::BuildGUI (Ekiga::ServiceCore& services)
-{
- /* Init the stock icons */
- gnomemeeting_stock_icons_init ();
-
- /* Build the GUI */
- gtk_window_set_default_icon_name (GM_ICON_LOGO);
- assistant_window = ekiga_assistant_new (services);
- main_window = gm_main_window_new (services);
- // FIXME should be moved in ekiga_assistant_new
- gtk_window_set_transient_for (GTK_WINDOW (assistant_window), GTK_WINDOW (main_window));
-
- PTRACE (1, "Ekiga version "
- << MAJOR_VERSION << "." << MINOR_VERSION << "." << BUILD_NUMBER);
-#ifdef EKIGA_REVISION
- PTRACE (1, "Ekiga git revision: " << EKIGA_REVISION);
-#endif
- PTRACE (1, "PTLIB version " << PTLIB_VERSION);
- PTRACE (1, "OPAL version " << OPAL_VERSION);
-#if defined HAVE_XV || defined HAVE_DX
- PTRACE (1, "Accelerated rendering support enabled");
-#else
- PTRACE (1, "Accelerated rendering support disabled");
-#endif
-#ifdef HAVE_DBUS
- PTRACE (1, "DBUS support enabled");
-#else
- PTRACE (1, "DBUS support disabled");
-#endif
-#ifdef HAVE_GCONF
- PTRACE (1, "GConf support enabled");
-#else
- PTRACE (1, "GConf support disabled");
-#endif
-}
diff --git a/src/ekiga.h b/src/ekiga.h
index 0531bc9..9954302 100644
--- a/src/ekiga.h
+++ b/src/ekiga.h
@@ -75,41 +75,12 @@ class GnomeMeeting : public PProcess
void Exit ();
- /* DESCRIPTION : /
- * BEHAVIOR : Returns a pointer to the GmWindow structure
- * of widgets.
- * PRE : /
- */
- GtkWidget *GetMainWindow ();
-
-
- /* DESCRIPTION : /
- * BEHAVIOR : Returns a pointer to the assistant window.
- * PRE : /
- */
- GtkWidget* GetAssistantWindow ();
-
-
/* Needed for PProcess */
void Main();
static GnomeMeeting *Process ();
-
- /* DESCRIPTION : /
- * BEHAVIOR : Builds the GUI of GnomeMeeting. The config, GNOME
- * and GTK need to have been initialized before.
- * The GUI is built accordingly to the preferences
- * stored in config.
- * PRE : /
- */
- void BuildGUI (Ekiga::ServiceCore& services);
-
private:
- /* The different components of the GUI */
- GtkWidget *main_window;
- GtkWidget *assistant_window;
-
static GnomeMeeting *GM;
};
diff --git a/src/gui/main.cpp b/src/gui/main.cpp
index fd2eede..516248f 100644
--- a/src/gui/main.cpp
+++ b/src/gui/main.cpp
@@ -63,6 +63,7 @@
#include "call-core.h"
+#include "gtk-frontend.h"
#include "ekiga.h"
#ifdef WIN32
@@ -80,8 +81,6 @@ main (int argc,
Ekiga::ServiceCorePtr service_core(new Ekiga::ServiceCore);
- GtkWidget *main_window = NULL;
-
gchar *path = NULL;
gchar *url = NULL;
@@ -94,7 +93,7 @@ main (int argc,
#endif
/* GTK+ initialization */
-gtk_init (&argc, &argv);
+ gtk_init (&argc, &argv);
#ifndef WIN32
signal (SIGPIPE, SIG_IGN);
#endif
@@ -187,9 +186,33 @@ gtk_init (&argc, &argv);
Ekiga::Runtime::init ();
engine_init (service_core, argc, argv);
- GnomeMeeting::Process ()->BuildGUI (*service_core);
+ PTRACE (1, "Ekiga version "
+ << MAJOR_VERSION << "." << MINOR_VERSION << "." << BUILD_NUMBER);
+#ifdef EKIGA_REVISION
+ PTRACE (1, "Ekiga git revision: " << EKIGA_REVISION);
+#endif
+ PTRACE (1, "PTLIB version " << PTLIB_VERSION);
+ PTRACE (1, "OPAL version " << OPAL_VERSION);
+#if defined HAVE_XV || defined HAVE_DX
+ PTRACE (1, "Accelerated rendering support enabled");
+#else
+ PTRACE (1, "Accelerated rendering support disabled");
+#endif
+#ifdef HAVE_DBUS
+ PTRACE (1, "DBUS support enabled");
+#else
+ PTRACE (1, "DBUS support disabled");
+#endif
+#ifdef HAVE_GCONF
+ PTRACE (1, "GConf support enabled");
+#else
+ PTRACE (1, "GConf support disabled");
+#endif
+
+ boost::shared_ptr<GtkFrontend> gtk_frontend
+ = service_core->get<GtkFrontend>("gtk-frontend");
- main_window = GnomeMeeting::Process ()->GetMainWindow ();
+ GtkWidget *main_window = GTK_WIDGET (gtk_frontend->get_main_window ());
const int schema_version = MAJOR_VERSION * 1000
+ MINOR_VERSION * 10
@@ -201,7 +224,7 @@ gtk_init (&argc, &argv);
// show the assistant if there is no config file
if (crt_version == 0)
- gtk_widget_show_all (GnomeMeeting::Process ()->GetAssistantWindow ());
+ gtk_widget_show_all (GTK_WIDGET (gtk_frontend->get_assistant_window ()));
/* Update the version number */
gm_conf_set_int (GENERAL_KEY "version", schema_version);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]