[ekiga] Accounts Window: Converted to GObject and moved it to the engine.



commit fbcc49774d0ed4427b1835dec5a57ef9afbdaced
Author: Damien Sandras <dsandras beip be>
Date:   Sun Jun 3 14:49:00 2012 +0200

    Accounts Window: Converted to GObject and moved it to the engine.

 lib/Makefile.am                                    |    2 +
 .../engine/gui/gtk-frontend/accounts-window.cpp    |  287 ++++++++++----------
 lib/engine/gui/gtk-frontend/accounts-window.h      |   95 +++++++
 lib/engine/gui/gtk-frontend/gtk-frontend.cpp       |   12 +-
 lib/engine/gui/gtk-frontend/gtk-frontend.h         |    3 +
 src/Makefile.am                                    |    2 -
 src/dbus-helper/dbus.cpp                           |    1 -
 src/ekiga.cpp                                      |   16 -
 src/ekiga.h                                        |    7 -
 src/gui/accounts.h                                 |   57 ----
 src/gui/main_window.cpp                            |    4 +-
 11 files changed, 253 insertions(+), 233 deletions(-)
---
diff --git a/lib/Makefile.am b/lib/Makefile.am
index 482de4f..6f7ce4d 100644
--- a/lib/Makefile.am
+++ b/lib/Makefile.am
@@ -429,6 +429,8 @@ libekiga_la_SOURCES += \
 libekiga_la_SOURCES += \
 	$(engine_dir)/gui/gtk-frontend/addressbook-window.h \
 	$(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/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/accounts.cpp b/lib/engine/gui/gtk-frontend/accounts-window.cpp
similarity index 71%
rename from src/gui/accounts.cpp
rename to lib/engine/gui/gtk-frontend/accounts-window.cpp
index 4125f25..953d304 100644
--- a/src/gui/accounts.cpp
+++ b/lib/engine/gui/gtk-frontend/accounts-window.cpp
@@ -35,7 +35,7 @@
  *   			    manipulate accounts.
  */
 
-#include "accounts.h"
+#include "accounts-window.h"
 
 #include "account.h"
 #include "bank.h"
@@ -45,7 +45,6 @@
 #include "gmcallbacks.h"
 
 #include "gmconf.h"
-#include "gmwindow.h"
 
 #include "services.h"
 #include "menu-builder-tools.h"
@@ -53,39 +52,22 @@
 #include "form-dialog-gtk.h"
 #include "optional-buttons-gtk.h"
 
-typedef struct GmAccountsWindow_ {
 
-  GmAccountsWindow_ (Ekiga::ServiceCore & _core) : core (_core)
-  {}
+struct _AccountsWindowPrivate
+{
+  _AccountsWindowPrivate (Ekiga::ServiceCore & _core):core (_core) { }
 
   GtkWidget *accounts_list;
   GtkWidget *menu_item_core;
   GtkAccelGroup *accel;
 
   Ekiga::ServiceCore &core;
-  OptionalButtonsGtk toolbar;
-
-} GmAccountsWindow;
-
-#define GM_ACCOUNTS_WINDOW(x) (GmAccountsWindow *) (x)
-
-
-/* GUI Functions */
-
-/* DESCRIPTION  : /
- * BEHAVIOR     : Frees a GmAccountsWindow and its content.
- * PRE          : A non-NULL pointer to a GmAccountsWindow structure.
- */
-static void gm_aw_destroy (gpointer aw);
+  std::vector<boost::signals::connection> connections;
 
+  OptionalButtonsGtk toolbar;
+};
 
-/* DESCRIPTION  : /
- * BEHAVIOR     : Returns a pointer to the private GmAccountsWindow structure
- *                used by the preferences window GMObject.
- * PRE          : The given GtkWidget pointer must be a preferences window
- * 		  GMObject.
- */
-static GmAccountsWindow *gm_aw_get_aw (GtkWidget *account_window);
+G_DEFINE_TYPE (AccountsWindow, accounts_window, GM_TYPE_WINDOW);
 
 
 /* GTK+ Callbacks */
@@ -132,32 +114,10 @@ enum {
 };
 
 
-/* GUI Functions */
-static void
-gm_aw_destroy (gpointer aw)
-{
-  g_return_if_fail (aw != NULL);
-
-  delete ((GmAccountsWindow *) aw);
-}
-
-
-static GmAccountsWindow *
-gm_aw_get_aw (GtkWidget *accounts_window)
-{
-  g_return_val_if_fail (accounts_window != NULL, NULL);
-
-  return GM_ACCOUNTS_WINDOW (g_object_get_data (G_OBJECT (accounts_window), "GMObject"));
-}
-
-
 /* Engine callbacks */
-
 static void
 populate_menu (GtkWidget *window)
 {
-  GmAccountsWindow *aw = NULL;
-
   MenuBuilderGtk builder;
 
   GtkWidget *item = NULL;
@@ -166,13 +126,12 @@ populate_menu (GtkWidget *window)
   GtkTreeIter iter;
 
   Ekiga::Account *account = NULL;
+  AccountsWindow *self = ACCOUNTS_WINDOW (window);
 
-  aw = gm_aw_get_aw (GTK_WIDGET (window));
-
-  selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (aw->accounts_list));
-  model = gtk_tree_view_get_model (GTK_TREE_VIEW (aw->accounts_list));
+  selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (self->priv->accounts_list));
+  model = gtk_tree_view_get_model (GTK_TREE_VIEW (self->priv->accounts_list));
 
-  boost::shared_ptr<Ekiga::AccountCore> account_core = aw->core.get<Ekiga::AccountCore> ("account-core");
+  boost::shared_ptr<Ekiga::AccountCore> account_core = self->priv->core.get<Ekiga::AccountCore> ("account-core");
 
   if (account_core->populate_menu (builder)) {
     item = gtk_separator_menu_item_new ();
@@ -190,13 +149,13 @@ populate_menu (GtkWidget *window)
       gtk_menu_shell_append (GTK_MENU_SHELL (builder.menu), item);
     }
   }
-  item = gtk_image_menu_item_new_from_stock (GTK_STOCK_CLOSE, aw->accel);
+  item = gtk_image_menu_item_new_from_stock (GTK_STOCK_CLOSE, self->priv->accel);
   gtk_menu_shell_append (GTK_MENU_SHELL (builder.menu), item);
   g_signal_connect_swapped (item, "activate",
                             G_CALLBACK (gtk_widget_hide),
                             (gpointer) window);
 
-  gtk_menu_item_set_submenu (GTK_MENU_ITEM (aw->menu_item_core),
+  gtk_menu_item_set_submenu (GTK_MENU_ITEM (self->priv->menu_item_core),
                              builder.menu);
 
   gtk_widget_show_all (builder.menu);
@@ -209,7 +168,7 @@ account_clicked_cb (G_GNUC_UNUSED GtkWidget *w,
 		    GdkEventButton *event,
 		    gpointer data)
 {
-  GmAccountsWindow *aw = NULL;
+  AccountsWindow *self = ACCOUNTS_WINDOW (data);
 
   GtkTreePath *path = NULL;
   GtkTreeView *tree_view = NULL;
@@ -218,9 +177,7 @@ account_clicked_cb (G_GNUC_UNUSED GtkWidget *w,
 
   Ekiga::Account *account = NULL;
 
-  aw = gm_aw_get_aw (GTK_WIDGET (data));
-
-  tree_view = GTK_TREE_VIEW (aw->accounts_list);
+  tree_view = GTK_TREE_VIEW (self->priv->accounts_list);
   model = gtk_tree_view_get_model (tree_view);
 
   if (event->type == GDK_BUTTON_PRESS || event->type == GDK_KEY_PRESS || event->type == GDK_2BUTTON_PRESS) {
@@ -277,7 +234,7 @@ void account_toggled_cb (G_GNUC_UNUSED GtkCellRendererToggle* renderer,
 			 gchar* path_string,
 			 gpointer data)
 {
-  GmAccountsWindow* aw = NULL;
+  AccountsWindow *self = ACCOUNTS_WINDOW (data);
 
   GtkTreeModel* model = NULL;
   GtkTreePath* path = NULL;
@@ -285,9 +242,7 @@ void account_toggled_cb (G_GNUC_UNUSED GtkCellRendererToggle* renderer,
   Ekiga::Account* account = NULL;
   gboolean is_enabled;
 
-  aw = gm_aw_get_aw (GTK_WIDGET (data));
-
-  model = gtk_tree_view_get_model (GTK_TREE_VIEW (aw->accounts_list));
+  model = gtk_tree_view_get_model (GTK_TREE_VIEW (self->priv->accounts_list));
   path = gtk_tree_path_new_from_string (path_string);
 
   if (gtk_tree_model_get_iter (model, &iter, path)) {
@@ -316,15 +271,15 @@ static void
 on_selection_changed (GtkTreeSelection* /*selection*/,
 		      gpointer data)
 {
-  GmAccountsWindow* aw = (GmAccountsWindow*) data;
   GtkTreeSelection* selection = NULL;
   GtkTreeModel *model = NULL;
   GtkTreeIter iter;
   Ekiga::Account* account = NULL;
 
-  g_return_if_fail (aw != NULL);
+  g_return_if_fail (data != NULL);
+  AccountsWindow *self = ACCOUNTS_WINDOW (data);
 
-  selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (aw->accounts_list));
+  selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (self->priv->accounts_list));
 
   if (gtk_tree_selection_get_selected (selection, &model, &iter)) {
 
@@ -333,16 +288,16 @@ on_selection_changed (GtkTreeSelection* /*selection*/,
 			-1);
     if (account) {
 
-      aw->toolbar.reset ();
-      account->populate_menu (aw->toolbar);
+      self->priv->toolbar.reset ();
+      account->populate_menu (self->priv->toolbar);
     } else {
 
-      aw->toolbar.reset ();
+      self->priv->toolbar.reset ();
     }
 
   } else {
 
-    aw->toolbar.reset ();
+    self->priv->toolbar.reset ();
   }
 }
 
@@ -350,16 +305,14 @@ static void
 gm_accounts_window_add_account (GtkWidget *window,
                                 Ekiga::AccountPtr account)
 {
-  GmAccountsWindow *aw = NULL;
   GtkTreeModel *model = NULL;
 
   GtkTreeIter iter;
 
   g_return_if_fail (window != NULL);
+  AccountsWindow *self = ACCOUNTS_WINDOW (window);
 
-  aw = gm_aw_get_aw (window);
-
-  model = gtk_tree_view_get_model (GTK_TREE_VIEW (aw->accounts_list));
+  model = gtk_tree_view_get_model (GTK_TREE_VIEW (self->priv->accounts_list));
 
   gtk_list_store_append (GTK_LIST_STORE (model), &iter);
   gtk_list_store_set (GTK_LIST_STORE (model), &iter,
@@ -375,8 +328,6 @@ void
 gm_accounts_window_update_account (GtkWidget *accounts_window,
                                    Ekiga::AccountPtr account)
 {
-  GmAccountsWindow *aw = NULL;
-
   GtkTreeModel *model = NULL;
   GtkTreeSelection *selection = NULL;
 
@@ -384,11 +335,10 @@ gm_accounts_window_update_account (GtkWidget *accounts_window,
   Ekiga::Account *caccount = NULL;
 
   g_return_if_fail (accounts_window != NULL);
-
-  aw = gm_aw_get_aw (accounts_window);
+  AccountsWindow *self = ACCOUNTS_WINDOW (accounts_window);
 
   /* on the one end we update the view */
-  model = gtk_tree_view_get_model (GTK_TREE_VIEW (aw->accounts_list));
+  model = gtk_tree_view_get_model (GTK_TREE_VIEW (self->priv->accounts_list));
 
   if (gtk_tree_model_get_iter_first (GTK_TREE_MODEL (model), &iter)){
 
@@ -414,7 +364,7 @@ gm_accounts_window_update_account (GtkWidget *accounts_window,
   /* on the other end, if the updated account is the one which is selected,
    * we update the actions on it
    */
-  selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (aw->accounts_list));
+  selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (self->priv->accounts_list));
   if (gtk_tree_selection_get_selected (selection, &model, &iter)) {
 
     gtk_tree_model_get (model, &iter,
@@ -423,8 +373,8 @@ gm_accounts_window_update_account (GtkWidget *accounts_window,
 
     if (caccount == account.get ()) {
 
-      aw->toolbar.reset ();
-      account->populate_menu (aw->toolbar);
+      self->priv->toolbar.reset ();
+      account->populate_menu (self->priv->toolbar);
     }
   }
 }
@@ -440,13 +390,10 @@ gm_accounts_window_remove_account (GtkWidget *accounts_window,
 
   GtkTreeIter iter;
 
-  GmAccountsWindow *aw = NULL;
-
   g_return_if_fail (accounts_window != NULL);
+  AccountsWindow *self = ACCOUNTS_WINDOW (accounts_window);
 
-  aw = gm_aw_get_aw (accounts_window);
-
-  model = gtk_tree_view_get_model (GTK_TREE_VIEW (aw->accounts_list));
+  model = gtk_tree_view_get_model (GTK_TREE_VIEW (self->priv->accounts_list));
 
   if (gtk_tree_model_get_iter_first (GTK_TREE_MODEL (model), &iter)){
 
@@ -530,13 +477,63 @@ on_handle_questions (Ekiga::FormRequestPtr request,
 }
 
 
+/* Implementation of the GObject stuff */
+static void
+accounts_window_dispose (GObject *obj)
+{
+  AccountsWindow *self = ACCOUNTS_WINDOW (obj);
+
+  if (self->priv->menu_item_core) {
+
+    g_object_unref (self->priv->menu_item_core);
+    self->priv->menu_item_core = NULL;
+  }
+
+  G_OBJECT_CLASS (accounts_window_parent_class)->dispose (obj);
+}
+
+
+static void
+accounts_window_finalize (GObject *obj)
+{
+  AccountsWindow *self = ACCOUNTS_WINDOW (obj);
+
+  for (std::vector<boost::signals::connection>::iterator iter
+	 = self->priv->connections.begin ();
+       iter != self->priv->connections.end ();
+       iter++)
+    iter->disconnect ();
+
+  delete self->priv;
+
+  G_OBJECT_CLASS (accounts_window_parent_class)->finalize (obj);
+}
+
+static void
+accounts_window_init (G_GNUC_UNUSED AccountsWindow* self)
+{
+  /* can't do anything here... we're waiting for a core :-/ */
+}
+
+static void
+accounts_window_class_init (AccountsWindowClass *klass)
+{
+  GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
+
+  gobject_class->dispose = accounts_window_dispose;
+  gobject_class->finalize = accounts_window_finalize;
+}
+
+
+/* Public API */
 GtkWidget *
-gm_accounts_window_new (Ekiga::ServiceCore &core)
+accounts_window_new (Ekiga::ServiceCore &core)
 {
-  GmAccountsWindow *aw = NULL;
+  AccountsWindow *self = NULL;
 
-  GtkWidget *window = NULL;
+  boost::signals::connection conn;
 
+  GtkWidget *vbox = NULL;
   GtkWidget *menu_bar = NULL;
   GtkWidget *menu_item = NULL;
   GtkWidget *menu = NULL;
@@ -567,29 +564,20 @@ gm_accounts_window_new (Ekiga::ServiceCore &core)
   };
 
   /* The window */
-  window = gtk_dialog_new ();
-  gtk_dialog_add_button (GTK_DIALOG (window), GTK_STOCK_CLOSE, GTK_RESPONSE_CANCEL);
-
-  g_object_set_data_full (G_OBJECT (window), "window_name",
-			  g_strdup ("accounts_window"), g_free);
-
-  gtk_window_set_title (GTK_WINDOW (window), _("Accounts"));
-  gtk_window_set_position (GTK_WINDOW (window), GTK_WIN_POS_CENTER);
-
-  aw = new GmAccountsWindow (core);
-  g_object_set_data_full (G_OBJECT (window), "GMObject",
-			  aw, gm_aw_destroy);
+  self = (AccountsWindow *) g_object_new (ACCOUNTS_WINDOW_TYPE, NULL);
+  self->priv = new AccountsWindowPrivate (core);
+  vbox = gtk_vbox_new (FALSE, 2);
 
   /* The menu */
   menu_bar = gtk_menu_bar_new ();
 
-  aw->accel = gtk_accel_group_new ();
-  gtk_window_add_accel_group (GTK_WINDOW (window), aw->accel);
-  g_object_unref (aw->accel);
+  self->priv->accel = gtk_accel_group_new ();
+  gtk_window_add_accel_group (GTK_WINDOW (self), self->priv->accel);
+  g_object_unref (self->priv->accel);
 
-  aw->menu_item_core = gtk_menu_item_new_with_mnemonic (_("_Accounts"));
-  gtk_menu_shell_append (GTK_MENU_SHELL (menu_bar), aw->menu_item_core);
-  g_object_ref (aw->menu_item_core);
+  self->priv->menu_item_core = gtk_menu_item_new_with_mnemonic (_("_Accounts"));
+  gtk_menu_shell_append (GTK_MENU_SHELL (menu_bar), self->priv->menu_item_core);
+  g_object_ref (self->priv->menu_item_core);
 
   menu_item = gtk_menu_item_new_with_mnemonic (_("_Help"));
   gtk_menu_shell_append (GTK_MENU_SHELL (menu_bar), menu_item);
@@ -609,12 +597,12 @@ gm_accounts_window_new (Ekiga::ServiceCore &core)
 				   G_TYPE_STRING,  /* Error Message */
 				   G_TYPE_INT);    /* State */
 
-  aw->accounts_list = gtk_tree_view_new_with_model (GTK_TREE_MODEL (list_store));
+  self->priv->accounts_list = gtk_tree_view_new_with_model (GTK_TREE_MODEL (list_store));
   g_object_unref (list_store);
-  gtk_tree_view_set_rules_hint (GTK_TREE_VIEW (aw->accounts_list), TRUE);
-  gtk_tree_view_set_reorderable (GTK_TREE_VIEW (aw->accounts_list), TRUE);
+  gtk_tree_view_set_rules_hint (GTK_TREE_VIEW (self->priv->accounts_list), TRUE);
+  gtk_tree_view_set_reorderable (GTK_TREE_VIEW (self->priv->accounts_list), TRUE);
 
-  aobj = gtk_widget_get_accessible (GTK_WIDGET (aw->accounts_list));
+  aobj = gtk_widget_get_accessible (GTK_WIDGET (self->priv->accounts_list));
   atk_object_set_name (aobj, _("Accounts"));
 
   renderer = gtk_cell_renderer_toggle_new ();
@@ -623,10 +611,10 @@ gm_accounts_window_new (Ekiga::ServiceCore &core)
 						     "active",
 						     COLUMN_ACCOUNT_IS_ENABLED,
 						     NULL);
-  gtk_tree_view_append_column (GTK_TREE_VIEW (aw->accounts_list), column);
+  gtk_tree_view_append_column (GTK_TREE_VIEW (self->priv->accounts_list), column);
   g_signal_connect (renderer, "toggled",
 		    G_CALLBACK (account_toggled_cb),
-		    (gpointer)window);
+		    (gpointer)self);
 
   /* Add all text renderers */
   for (int i = COLUMN_ACCOUNT_ACCOUNT_NAME ; i < COLUMN_ACCOUNT_NUMBER - 1 ; i++) {
@@ -639,20 +627,20 @@ gm_accounts_window_new (Ekiga::ServiceCore &core)
 						       "weight",
 						       COLUMN_ACCOUNT_WEIGHT,
 						       NULL);
-    gtk_tree_view_append_column (GTK_TREE_VIEW (aw->accounts_list), column);
+    gtk_tree_view_append_column (GTK_TREE_VIEW (self->priv->accounts_list), column);
     gtk_tree_view_column_set_resizable (GTK_TREE_VIEW_COLUMN (column), TRUE);
     gtk_tree_view_column_set_sizing (GTK_TREE_VIEW_COLUMN (column),
 				     GTK_TREE_VIEW_COLUMN_AUTOSIZE);
     gtk_tree_view_column_set_sort_column_id (column, i);
   }
 
-  g_signal_connect (aw->accounts_list, "event_after",
-		    G_CALLBACK (account_clicked_cb), window);
+  g_signal_connect (self->priv->accounts_list, "event_after",
+		    G_CALLBACK (account_clicked_cb), self);
 
-  selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (aw->accounts_list));
+  selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (self->priv->accounts_list));
   gtk_tree_selection_set_mode (selection, GTK_SELECTION_SINGLE);
   g_signal_connect (selection, "changed",
-		    G_CALLBACK (on_selection_changed), aw);
+		    G_CALLBACK (on_selection_changed), self);
 
   /* The scrolled window with the accounts list store */
   scroll_window = gtk_scrolled_window_new (FALSE, FALSE);
@@ -670,8 +658,8 @@ gm_accounts_window_new (Ekiga::ServiceCore &core)
   gtk_container_set_border_width (GTK_CONTAINER (frame), 4);
   gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_IN);
   gtk_container_add (GTK_CONTAINER (frame), scroll_window);
-  gtk_container_add (GTK_CONTAINER (scroll_window), aw->accounts_list);
-  gtk_container_set_border_width (GTK_CONTAINER (aw->accounts_list), 0);
+  gtk_container_add (GTK_CONTAINER (scroll_window), self->priv->accounts_list);
+  gtk_container_set_border_width (GTK_CONTAINER (self->priv->accounts_list), 0);
   gtk_box_pack_start (GTK_BOX (hbox), frame, TRUE, TRUE, 0);
 
   /* setting up a horizontal button box
@@ -681,43 +669,48 @@ gm_accounts_window_new (Ekiga::ServiceCore &core)
   gtk_button_box_set_layout (GTK_BUTTON_BOX (button_box), GTK_BUTTONBOX_CENTER);
   button = gtk_button_new_with_mnemonic (_("_Enable"));
   gtk_box_pack_start (GTK_BOX (button_box), button, FALSE, FALSE, 3);
-  aw->toolbar.add_button ("user-available", GTK_BUTTON (button));
+  self->priv->toolbar.add_button ("user-available", GTK_BUTTON (button));
   button = gtk_button_new_with_mnemonic (_("_Disable"));
   gtk_box_pack_start (GTK_BOX (button_box), button, FALSE, FALSE, 3);
-  aw->toolbar.add_button ("user-offline", GTK_BUTTON (button));
+  self->priv->toolbar.add_button ("user-offline", GTK_BUTTON (button));
   button = gtk_button_new_with_mnemonic (_("Edi_t"));
   gtk_box_pack_start (GTK_BOX (button_box), button, FALSE, FALSE, 3);
-  aw->toolbar.add_button ("gtk-edit", GTK_BUTTON (button));
+  self->priv->toolbar.add_button ("gtk-edit", GTK_BUTTON (button));
   button = gtk_button_new_with_mnemonic (_("_Remove"));
   gtk_box_pack_start (GTK_BOX (button_box), button, FALSE, FALSE, 3);
-  aw->toolbar.add_button ("gtk-remove", GTK_BUTTON (button));
+  self->priv->toolbar.add_button ("gtk-remove", GTK_BUTTON (button));
   gtk_box_pack_start (GTK_BOX (hbox), button_box, FALSE, FALSE, 10);
 
-  populate_menu (window); // This will add static and dynamic actions
-  gtk_box_pack_start (GTK_BOX (GTK_DIALOG (window)->vbox), menu_bar, FALSE, FALSE, 0);
-  gtk_box_pack_start (GTK_BOX (GTK_DIALOG (window)->vbox), event_box, TRUE, TRUE, 0);
-
-  /* Generic signals */
-  g_signal_connect_swapped (window, "response",
-			    G_CALLBACK (gm_window_hide),
-			    (gpointer) window);
-
-  gm_window_hide_on_delete (window);
-
-  gtk_widget_show_all (GTK_WIDGET (GTK_DIALOG (window)->vbox));
-
+  populate_menu (GTK_WIDGET (self)); // This will add static and dynamic actions
+  gtk_box_pack_start (GTK_BOX (vbox), menu_bar, FALSE, FALSE, 0);
+  gtk_box_pack_start (GTK_BOX (vbox), event_box, TRUE, TRUE, 0);
+  gtk_container_add (GTK_CONTAINER (self), vbox);
+  gtk_widget_show_all (GTK_WIDGET (vbox));
 
   /* Engine Signals callbacks */
-  // FIXME boost::signals::connection conn;
-
   boost::shared_ptr<Ekiga::AccountCore> account_core = core.get<Ekiga::AccountCore> ("account-core");
-  account_core->bank_added.connect (boost::bind (&on_bank_added, _1, window));
-  account_core->account_added.connect (boost::bind (&on_account_added, _1, _2, window));
-  account_core->account_updated.connect (boost::bind (&on_account_updated, _1, _2, window));
-  account_core->account_removed.connect (boost::bind (&on_account_removed, _1, _2, window));
-  account_core->questions.connect (boost::bind (&on_handle_questions, _1, (gpointer) window));
+  conn = account_core->bank_added.connect (boost::bind (&on_bank_added, _1, self));
+  self->priv->connections.push_back (conn);
+  conn = account_core->account_added.connect (boost::bind (&on_account_added, _1, _2, self));
+  self->priv->connections.push_back (conn);
+  conn = account_core->account_updated.connect (boost::bind (&on_account_updated, _1, _2, self));
+  self->priv->connections.push_back (conn);
+  conn = account_core->account_removed.connect (boost::bind (&on_account_removed, _1, _2, self));
+  self->priv->connections.push_back (conn);
+  conn = account_core->questions.connect (boost::bind (&on_handle_questions, _1, (gpointer) self));
+  self->priv->connections.push_back (conn);
+
+  account_core->visit_banks (boost::bind (&on_visit_banks, _1, self));
+
+  return GTK_WIDGET (self);
+}
 
-  account_core->visit_banks (boost::bind (&on_visit_banks, _1, window));
+GtkWidget *
+accounts_window_new_with_key (Ekiga::ServiceCore &_core,
+                              const std::string _key)
+{
+  AccountsWindow *self = ACCOUNTS_WINDOW (accounts_window_new (_core));
+  gm_window_set_key (GM_WINDOW (self), _key.c_str ());
 
-  return window;
+  return GTK_WIDGET (self);
 }
diff --git a/lib/engine/gui/gtk-frontend/accounts-window.h b/lib/engine/gui/gtk-frontend/accounts-window.h
new file mode 100644
index 0000000..fe18127
--- /dev/null
+++ b/lib/engine/gui/gtk-frontend/accounts-window.h
@@ -0,0 +1,95 @@
+
+/* Ekiga -- A VoIP and Video-Conferencing application
+ * Copyright (C) 2000-2009 Damien Sandras <dsandras seconix com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ *
+ * Ekiga is licensed under the GPL license and as a special exception,
+ * you have permission to link or otherwise combine this program with the
+ * programs OPAL, OpenH323 and PWLIB, and distribute the combination,
+ * without applying the requirements of the GNU GPL to the OPAL, OpenH323
+ * and PWLIB programs, as long as you do follow the requirements of the
+ * GNU GPL for all the rest of the software thus combined.
+ */
+
+
+/*
+ *                         accounts.h  -  description
+ *                         --------------------------
+ *   begin                : Sun Feb 13 2005
+ *   copyright            : (C) 2000-2006 by Damien Sandras
+ *   description          : This file contains all the functions needed to
+ *   			    manipulate accounts.
+ */
+
+
+#ifndef _ACCOUNTS_H_
+#define _ACCOUNTS_H_
+
+#include <glib.h>
+#include <glib/gi18n.h>
+#include <gtk/gtk.h>
+
+#include "services.h"
+
+#include "gmwindow.h"
+
+
+typedef struct _AccountsWindow AccountsWindow;
+typedef struct _AccountsWindowPrivate AccountsWindowPrivate;
+typedef struct _AccountsWindowClass AccountsWindowClass;
+
+/* GObject thingies */
+struct _AccountsWindow
+{
+  GmWindow parent;
+
+  AccountsWindowPrivate *priv;
+};
+
+struct _AccountsWindowClass
+{
+  GmWindowClass parent;
+};
+
+
+#define ACCOUNTS_WINDOW_TYPE (accounts_window_get_type ())
+
+#define ACCOUNTS_WINDOW(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), ACCOUNTS_WINDOW_TYPE, AccountsWindow))
+
+#define IS_ACCOUNTS_WINDOW(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), ACCOUNTS_WINDOW_TYPE))
+
+#define ACCOUNTS_WINDOW_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), ACCOUNTS_WINDOW_TYPE, AccountsWindowClass))
+
+#define IS_ACCOUNTS_WINDOW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), ACCOUNTS_WINDOW_TYPE))
+
+#define ACCOUNTS_WINDOW_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), ACCOUNTS_WINDOW_TYPE, AccountsWindowClass))
+
+GType accounts_window_get_type ();
+
+
+/* The API */
+
+/* DESCRIPTION  : /
+ * BEHAVIOR     : Builds the GMAccounts window GObject.
+ * PRE          : /
+ */
+GtkWidget *accounts_window_new (Ekiga::ServiceCore &core);
+
+GtkWidget *accounts_window_new_with_key (Ekiga::ServiceCore &core,
+                                         const std::string _key);
+
+#endif
diff --git a/lib/engine/gui/gtk-frontend/gtk-frontend.cpp b/lib/engine/gui/gtk-frontend/gtk-frontend.cpp
index e26d1e5..776eacd 100644
--- a/lib/engine/gui/gtk-frontend/gtk-frontend.cpp
+++ b/lib/engine/gui/gtk-frontend/gtk-frontend.cpp
@@ -48,6 +48,7 @@
 #include "contact-core.h"
 #include "presence-core.h"
 #include "addressbook-window.h"
+#include "accounts-window.h"
 #include "call-window.h"
 #include "chat-window.h"
 #include "statusicon.h"
@@ -90,6 +91,7 @@ GtkFrontend::GtkFrontend (Ekiga::ServiceCore & _core) : core(_core)
 GtkFrontend::~GtkFrontend ()
 {
   gtk_widget_destroy (addressbook_window);
+  gtk_widget_destroy (accounts_window);
   gtk_widget_destroy (chat_window);
   if (status_icon)
     g_object_unref (status_icon);
@@ -101,7 +103,9 @@ 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");
 
-  addressbook_window = addressbook_window_new_with_key (*contact_core, "/apps/" PACKAGE_NAME "/general/user_interface/addressbook_window");
+  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");
   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);
@@ -127,6 +131,12 @@ const GtkWidget *GtkFrontend::get_addressbook_window () const
 }
 
 
+const GtkWidget *GtkFrontend::get_accounts_window () const
+{
+  return accounts_window;
+}
+
+
 const GtkWidget *GtkFrontend::get_preferences_window () const
 {
   return preferences_window;
diff --git a/lib/engine/gui/gtk-frontend/gtk-frontend.h b/lib/engine/gui/gtk-frontend/gtk-frontend.h
index 30b45ab..5c91bbb 100644
--- a/lib/engine/gui/gtk-frontend/gtk-frontend.h
+++ b/lib/engine/gui/gtk-frontend/gtk-frontend.h
@@ -67,6 +67,8 @@ public:
 
   const GtkWidget *get_addressbook_window () const;
 
+  const GtkWidget *get_accounts_window () const;
+
   const GtkWidget *get_call_window () const;
 
   const GtkWidget *get_chat_window () const;
@@ -77,6 +79,7 @@ private :
 
   GtkWidget *preferences_window;
   GtkWidget *addressbook_window;
+  GtkWidget *accounts_window;
   GtkWidget *call_window;
   GtkWidget *chat_window;
   StatusIcon *status_icon;
diff --git a/src/Makefile.am b/src/Makefile.am
index 86d4ace..1d2fc1d 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -55,8 +55,6 @@ nodist_ekiga_SOURCES =
 
 # Graphical User Interface
 ekiga_SOURCES +=			\
-	gui/accounts.h    		\
-	gui/accounts.cpp		\
 	gui/assistant.h			\
 	gui/assistant.cpp		\
 	gui/conf.h			\
diff --git a/src/dbus-helper/dbus.cpp b/src/dbus-helper/dbus.cpp
index a537c3a..5261bab 100644
--- a/src/dbus-helper/dbus.cpp
+++ b/src/dbus-helper/dbus.cpp
@@ -47,7 +47,6 @@
 #include "gmmarshallers.h"
 #include "gmconf.h"
 #include "gmcallbacks.h"
-#include "accounts.h"
 
 #include "call-core.h"
 
diff --git a/src/ekiga.cpp b/src/ekiga.cpp
index 59fa9f0..f27f0ee 100644
--- a/src/ekiga.cpp
+++ b/src/ekiga.cpp
@@ -40,7 +40,6 @@
 
 #include "ekiga.h"
 #include "assistant.h"
-#include "accounts.h"
 #include "main_window.h"
 #include "gmstockicons.h"
 
@@ -59,7 +58,6 @@ GnomeMeeting::GnomeMeeting ()
   assistant_window = NULL;
   main_window = NULL;
   assistant_window = NULL;
-  accounts_window = NULL;
 }
 
 
@@ -75,10 +73,6 @@ GnomeMeeting::Exit ()
   if (assistant_window)
     gtk_widget_destroy (assistant_window);
   assistant_window = NULL;
-
-  if (accounts_window)
-    gtk_widget_destroy (accounts_window);
-  accounts_window = NULL;
 }
 
 
@@ -103,13 +97,6 @@ GnomeMeeting::GetAssistantWindow ()
 }
 
 
-GtkWidget *
-GnomeMeeting::GetAccountsWindow ()
-{
-  return accounts_window;
-}
-
-
 void GnomeMeeting::Main ()
 {
 }
@@ -122,11 +109,8 @@ void GnomeMeeting::BuildGUI (Ekiga::ServiceCorePtr services)
 
   /* Build the GUI */
   gtk_window_set_default_icon_name (GM_ICON_LOGO);
-  accounts_window = gm_accounts_window_new (*services);
   assistant_window = ekiga_assistant_new (services.get ());
   main_window = gm_main_window_new (*services);
-  // FIXME should be moved inside the gm_accounts_window_new code
-  gtk_window_set_transient_for (GTK_WINDOW (accounts_window), GTK_WINDOW (main_window));
   // FIXME should be moved in ekiga_assistant_new
   gtk_window_set_transient_for (GTK_WINDOW (assistant_window), GTK_WINDOW (main_window));
 
diff --git a/src/ekiga.h b/src/ekiga.h
index ed1fe7b..d039840 100644
--- a/src/ekiga.h
+++ b/src/ekiga.h
@@ -90,13 +90,6 @@ class GnomeMeeting : public PProcess
   GtkWidget* GetAssistantWindow ();
 
 
-  /* DESCRIPTION  :  /
-   * BEHAVIOR     :  Returns a pointer to the accounts window.
-   * PRE          :  /
-   */
-  GtkWidget *GetAccountsWindow ();
-
-
   /* Needed for PProcess */
   void Main();
   static GnomeMeeting *Process ();
diff --git a/src/gui/main_window.cpp b/src/gui/main_window.cpp
index fc5a408..f127be8 100644
--- a/src/gui/main_window.cpp
+++ b/src/gui/main_window.cpp
@@ -1259,7 +1259,7 @@ ekiga_main_window_init_menu (EkigaMainWindow *mw)
   boost::shared_ptr<Ekiga::Trigger> local_cluster_trigger = mw->priv->core->get<Ekiga::Trigger> ("local-cluster");
   boost::shared_ptr<GtkFrontend> gtk_frontend = mw->priv->core->get<GtkFrontend> ("gtk-frontend");
   addressbook_window = GTK_WIDGET (gtk_frontend->get_addressbook_window ());
-  accounts_window = GnomeMeeting::Process ()->GetAccountsWindow ();
+  accounts_window = GTK_WIDGET (gtk_frontend->get_accounts_window ());
   prefs_window = GTK_WIDGET (gtk_frontend->get_preferences_window ());
   assistant_window = GnomeMeeting::Process ()->GetAssistantWindow ();
 
@@ -1330,7 +1330,7 @@ ekiga_main_window_init_menu (EkigaMainWindow *mw)
       GTK_MENU_ENTRY("accounts", _("_Accounts"),
 		     _("Edit your accounts"),
 		     NULL, 'E',
-		     G_CALLBACK (show_gm_window_cb),
+		     G_CALLBACK (show_widget_cb),
 		     (gpointer) accounts_window, TRUE),
 
       GTK_MENU_ENTRY("preferences", NULL,



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