[ekiga] Ekiga: Big reorganisation.



commit 2c6dd9269977820d2502d22d173b07e924b15683
Author: Damien Sandras <dsandras beip be>
Date:   Sun Apr 29 17:41:59 2012 +0200

    Ekiga: Big reorganisation.
    
    - Moved the "callbacks" file to lib/gui/
    - Moved the statusicon code to lib/engine/gui/gtk-frontend
    - Made the notify_has_persistence method static again
    
    This required many changes.

 lib/Makefile.am                                    |    8 +-
 lib/engine/gui/gtk-frontend/gtk-frontend.cpp       |   31 ++++--
 lib/engine/gui/gtk-frontend/gtk-frontend.h         |    9 ++
 .../engine/gui/gtk-frontend}/statusicon.cpp        |  115 ++++++++++----------
 .../engine/gui/gtk-frontend}/statusicon.h          |   10 +-
 src/gui/callbacks.cpp => lib/gui/gmcallbacks.c     |   26 +----
 src/gui/callbacks.h => lib/gui/gmcallbacks.h       |    6 +-
 src/Makefile.am                                    |    4 -
 src/dbus-helper/dbus.cpp                           |    2 +-
 src/ekiga.cpp                                      |   13 ---
 src/ekiga.h                                        |   10 --
 src/gui/accounts.cpp                               |    5 +-
 src/gui/call_window.cpp                            |    1 -
 src/gui/main_window.cpp                            |   39 ++++++-
 src/gui/notify.cpp                                 |   24 ----
 src/gui/notify.h                                   |    6 -
 16 files changed, 147 insertions(+), 162 deletions(-)
---
diff --git a/lib/Makefile.am b/lib/Makefile.am
index 7b18527..f478e9e 100644
--- a/lib/Makefile.am
+++ b/lib/Makefile.am
@@ -48,11 +48,11 @@ INCLUDES = \
 	-I$(top_srcdir)/lib/engine/components/ptlib
 
 AM_CFLAGS = \
-	$(GLIB_CFLAGS) $(GTK_CFLAGS) $(GCONF_CFLAGS) $(DBUS_CFLAGS)
+	$(GLIB_CFLAGS) $(GTK_CFLAGS) $(GCONF_CFLAGS) $(DBUS_CFLAGS) $(NOTIFY_CFLAGS)
 
 AM_CPPFLAGS = \
 	$(BOOST_CPPFLAGS) $(GLIB_CFLAGS) $(XML_CFLAGS) $(GTK_CFLAGS) \
-	$(DBUS_CFLAGS) $(PTLIB_CFLAGS) $(OPAL_CFLAGS)
+	$(DBUS_CFLAGS) $(PTLIB_CFLAGS) $(OPAL_CFLAGS) $(NOTIFY_LIBS)
 AM_LIBS = \
 	$(BOOST_LIBS) $(GLIB_LIBS) $(XML_LIBS) $(GTK_LIBS)
 
@@ -142,6 +142,8 @@ libekiga_la_SOURCES += \
 	$(top_srcdir)/lib/gui/gm-smileys.c \
 	$(top_srcdir)/lib/gui/gmwindow.c \
 	$(top_srcdir)/lib/gui/gmwindow.h \
+	$(top_srcdir)/lib/gui/gmcallbacks.c \
+	$(top_srcdir)/lib/gui/gmcallbacks.h \
 	$(top_srcdir)/lib/gui/gmconfwidgets.c \
 	$(top_srcdir)/lib/gui/gmconfwidgets.h \
 	$(top_srcdir)/lib/gui/gmdialog.c \
@@ -443,6 +445,8 @@ libekiga_la_SOURCES += \
 	$(engine_dir)/gui/gtk-frontend/simple-chat-page.cpp \
 	$(engine_dir)/gui/gtk-frontend/multiple-chat-page.h \
 	$(engine_dir)/gui/gtk-frontend/multiple-chat-page.cpp \
+	$(engine_dir)/gui/gtk-frontend/statusicon.cpp \
+	$(engine_dir)/gui/gtk-frontend/statusicon.h \
 	$(engine_dir)/gui/gtk-frontend/chat-window.h \
 	$(engine_dir)/gui/gtk-frontend/chat-window.cpp \
 	$(engine_dir)/gui/gtk-frontend/gtk-frontend.h \
diff --git a/lib/engine/gui/gtk-frontend/gtk-frontend.cpp b/lib/engine/gui/gtk-frontend/gtk-frontend.cpp
index 634bd17..34ca930 100644
--- a/lib/engine/gui/gtk-frontend/gtk-frontend.cpp
+++ b/lib/engine/gui/gtk-frontend/gtk-frontend.cpp
@@ -49,6 +49,7 @@
 #include "presence-core.h"
 #include "addressbook-window.h"
 #include "chat-window.h"
+#include "statusicon.h"
 #include "roster-view-gtk.h"
 #include "history-source.h"
 #include "book-view-gtk.h"
@@ -72,22 +73,15 @@ gtk_frontend_init (Ekiga::ServiceCore &core,
 
     boost::shared_ptr<GtkFrontend> gtk_frontend (new GtkFrontend (core));
     core.add (gtk_frontend);
+    gtk_frontend->build ();
     result = true;
   }
   return result;
 }
 
 
-GtkFrontend::GtkFrontend (Ekiga::ServiceCore &core)
+GtkFrontend::GtkFrontend (Ekiga::ServiceCore & _core) : core(_core)
 {
-  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");
-  chat_window =
-    chat_window_new (*chat_core,
-		     "/apps/" PACKAGE_NAME "/general/user_interface/chat_window");
 }
 
 
@@ -95,6 +89,19 @@ GtkFrontend::~GtkFrontend ()
 {
   gtk_widget_destroy (addressbook_window);
   gtk_widget_destroy (chat_window);
+  if (status_icon)
+    g_object_unref (status_icon);
+}
+
+
+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");
+  chat_window = chat_window_new (*chat_core, "/apps/" PACKAGE_NAME "/general/user_interface/chat_window");
+  status_icon = status_icon_new (core);
 }
 
 
@@ -120,3 +127,9 @@ const GtkWidget *GtkFrontend::get_chat_window () const
 {
   return chat_window;
 }
+
+
+const StatusIcon *GtkFrontend::get_status_icon () const
+{
+  return status_icon;
+}
diff --git a/lib/engine/gui/gtk-frontend/gtk-frontend.h b/lib/engine/gui/gtk-frontend/gtk-frontend.h
index 686b266..61b8121 100644
--- a/lib/engine/gui/gtk-frontend/gtk-frontend.h
+++ b/lib/engine/gui/gtk-frontend/gtk-frontend.h
@@ -42,6 +42,8 @@
 #include <gtk/gtk.h>
 #include <vector>
 
+#include "statusicon.h"
+
 #include "services.h"
 #include "contact-core.h"
 #include "presence-core.h"
@@ -55,6 +57,8 @@ public:
 
   ~GtkFrontend ();
 
+  void build ();
+
   const std::string get_name () const;
 
   const std::string get_description () const;
@@ -63,10 +67,15 @@ public:
 
   const GtkWidget *get_chat_window () const;
 
+  const StatusIcon *get_status_icon () const;
+
 private :
 
   GtkWidget *addressbook_window;
   GtkWidget *chat_window;
+  StatusIcon *status_icon;
+
+  Ekiga::ServiceCore & core;
 };
 
 
diff --git a/src/gui/statusicon.cpp b/lib/engine/gui/gtk-frontend/statusicon.cpp
similarity index 88%
rename from src/gui/statusicon.cpp
rename to lib/engine/gui/gtk-frontend/statusicon.cpp
index 884efa8..92999df 100644
--- a/src/gui/statusicon.cpp
+++ b/lib/engine/gui/gtk-frontend/statusicon.cpp
@@ -42,15 +42,11 @@
 
 #include "gmstockicons.h"
 #include "gmmenuaddon.h"
-
-#include "callbacks.h" // FIXME SHOULD GET RID OF THIS
-#include "ekiga.h"
+#include "gmcallbacks.h"
 
 #include "gtk-frontend.h"
 #include "call-core.h"
 
-#include <boost/signals.hpp>
-#include <boost/bind.hpp>
 #include <vector>
 
 #include "services.h"
@@ -58,6 +54,10 @@
 #include "notification-core.h"
 #include "personal-details.h"
 
+#ifdef HAVE_NOTIFY
+#include <libnotify/notify.h>
+#endif
+
 
 /*
  * The StatusIcon
@@ -82,7 +82,7 @@ struct _StatusIconPrivate
 };
 
 static GObjectClass *parent_class = NULL;
-
+static guint signals = { 0 };
 
 /*
  * Declaration of Callbacks
@@ -105,11 +105,6 @@ unread_count_cb (GtkWidget *widget,
 static gboolean
 statusicon_blink_cb (gpointer data);
 
-static void
-status_icon_embedding_change_cb (G_GNUC_UNUSED GObject obj,
-				 G_GNUC_UNUSED GParamSpec param,
-				 G_GNUC_UNUSED gpointer data);
-
 
 /*
  * Declaration of local functions
@@ -202,6 +197,15 @@ statusicon_class_init (gpointer g_class,
   gobject_class = (GObjectClass *) g_class;
   gobject_class->dispose = statusicon_dispose;
   gobject_class->finalize = statusicon_finalize;
+
+  signals =
+    g_signal_new ("clicked",
+		  G_OBJECT_CLASS_TYPE (gobject_class),
+		  G_SIGNAL_RUN_LAST,
+		  G_STRUCT_OFFSET (StatusIconClass, clicked),
+		  NULL, NULL,
+		  g_cclosure_marshal_VOID__VOID,
+		  G_TYPE_NONE, 0);
 }
 
 
@@ -252,7 +256,7 @@ show_popup_menu_cb (GtkStatusIcon *icon,
   popup = GTK_WIDGET (data);
 
   gtk_menu_popup (GTK_MENU (popup),
-                  NULL, NULL, 
+                  NULL, NULL,
                   (GtkMenuPositionFunc)gtk_status_icon_position_menu, icon,
                   button, activate_time);
 }
@@ -269,20 +273,9 @@ statusicon_activated_cb (G_GNUC_UNUSED GtkStatusIcon *icon,
   // No unread messages => show ekiga
   if (!self->priv->unread_messages) {
 
-    window = GnomeMeeting::Process ()->GetMainWindow (); //FIXME
-
-    // FIXME when the main window becomes a gobject
-    if (!gtk_widget_get_visible (window)
-        || (gdk_window_get_state (GDK_WINDOW (window->window)) & GDK_WINDOW_STATE_ICONIFIED)) {
-      gtk_widget_show (window);
-    }
-    else {
-
-      if (gtk_window_has_toplevel_focus (GTK_WINDOW (window)))
-        gtk_widget_hide (window);
-      else
-        gtk_window_present (GTK_WINDOW (window));
-    }
+    // FIXME: When the main_window will be a GtkFrontend component,
+    // this signal will be useless
+    g_signal_emit (self, signals, 0, NULL);
   }
   else {
 
@@ -340,11 +333,10 @@ statusicon_blink_cb (gpointer data)
   g_return_val_if_fail (data != NULL, false);
 
   boost::shared_ptr<GtkFrontend> frontend = statusicon->priv->core.get<GtkFrontend> ("gtk-frontend");
-  // FIXME use main_window here
   chat_window = GTK_WIDGET (frontend->get_chat_window ());
 
   pixbuf = gtk_widget_render_icon (chat_window, STATUSICON (data)->priv->blink_image,
-                                   GTK_ICON_SIZE_MENU, NULL); 
+                                   GTK_ICON_SIZE_MENU, NULL);
 
   if (statusicon->priv->blinking)
     gtk_status_icon_set_from_pixbuf (GTK_STATUS_ICON (statusicon), pixbuf);
@@ -358,23 +350,6 @@ statusicon_blink_cb (gpointer data)
 
 
 static void
-status_icon_embedding_change_cb (G_GNUC_UNUSED GObject obj,
-                                 G_GNUC_UNUSED GParamSpec param,
-                                 gpointer data)
-{
-  GtkWidget *main_window = NULL;
-  GtkStatusIcon *status_icon = NULL;
-
-  status_icon = GTK_STATUS_ICON (data);
-  main_window = GnomeMeeting::Process ()->GetMainWindow ();
-
-  /* force the main window to show if no status icon for the user */
-  if (!gtk_status_icon_is_embedded (GTK_STATUS_ICON (status_icon)))
-    gtk_widget_show (main_window);
-}
-
-
-static void
 personal_details_updated_cb (StatusIcon* self,
 			     boost::shared_ptr<Ekiga::PersonalDetails> details)
 {
@@ -498,21 +473,20 @@ statusicon_set_inacall (StatusIcon *statusicon,
   g_return_if_fail (statusicon != NULL);
 
   boost::shared_ptr<GtkFrontend> frontend = statusicon->priv->core.get<GtkFrontend> ("gtk-frontend");
-  // FIXME use main_window here
   chat_window = GTK_WIDGET (frontend->get_chat_window ());
 
-  /* Update the status icon */ 
+  /* Update the status icon */
   if (inacall) {
 
-    pixbuf = gtk_widget_render_icon (chat_window, 
-                                     GM_STOCK_STATUS_INACALL, 
-                                     GTK_ICON_SIZE_MENU, 
-                                     NULL); 
+    pixbuf = gtk_widget_render_icon (chat_window,
+                                     GM_STOCK_STATUS_INACALL,
+                                     GTK_ICON_SIZE_MENU,
+                                     NULL);
     gtk_status_icon_set_from_pixbuf (GTK_STATUS_ICON (statusicon), pixbuf);
     g_object_unref (pixbuf);
   }
   else {
-    
+
     statusicon_set_status (statusicon, statusicon->priv->status);
   }
 }
@@ -540,14 +514,43 @@ statusicon_on_notification_added (boost::shared_ptr<Ekiga::Notification> notific
   g_free (tooltip);
 }
 
+
+static bool
+notify_has_persistence (void)
+{
+  gboolean has = false;
+#ifdef HAVE_NOTIFY
+  GList   *caps;
+  GList   *l;
+
+  caps = notify_get_server_caps ();
+  if (caps == NULL) {
+    fprintf (stderr, "Failed to receive server caps.\n");
+    return FALSE;
+  }
+
+  l = g_list_find_custom (caps, "persistence", (GCompareFunc)strcmp);
+  has = l != NULL;
+
+  g_list_foreach (caps, (GFunc) g_free, NULL);
+  g_list_free (caps);
+#endif
+
+  return has;
+}
+
+
 /*
  * Public API
  */
 StatusIcon *
-statusicon_new (Ekiga::ServiceCore & core)
+status_icon_new (Ekiga::ServiceCore & core)
 {
   StatusIcon *self = NULL;
 
+  if (notify_has_persistence ())
+    return NULL;
+
   boost::signals::connection conn;
 
   self = STATUSICON (g_object_new (STATUSICON_TYPE, NULL));
@@ -561,10 +564,10 @@ statusicon_new (Ekiga::ServiceCore & core)
   self->priv->blink_image = NULL;
   self->priv->unread_messages = false;
 
-  boost::shared_ptr<GtkFrontend> frontend = core.get<GtkFrontend> ("gtk-frontend");
   boost::shared_ptr<Ekiga::PersonalDetails> details = core.get<Ekiga::PersonalDetails> ("personal-details");
   boost::shared_ptr<Ekiga::CallCore> call_core = core.get<Ekiga::CallCore> ("call-core");
   boost::shared_ptr<Ekiga::NotificationCore> notification_core = core.get<Ekiga::NotificationCore> ("notification-core");
+  boost::shared_ptr<GtkFrontend> frontend = core.get<GtkFrontend> ("gtk-frontend");
   GtkWidget *chat_window = GTK_WIDGET (frontend->get_chat_window ());
 
   statusicon_set_status (self, details->get_presence ());
@@ -585,10 +588,6 @@ statusicon_new (Ekiga::ServiceCore & core)
   g_signal_connect (self, "activate",
                     G_CALLBACK (statusicon_activated_cb), self);
 
-  g_signal_connect (self, "notify::embedded",
-		    G_CALLBACK (status_icon_embedding_change_cb), self);
-
-
   g_signal_connect (chat_window, "unread-count",
                     G_CALLBACK (unread_count_cb), self);
 
diff --git a/src/gui/statusicon.h b/lib/engine/gui/gtk-frontend/statusicon.h
similarity index 94%
rename from src/gui/statusicon.h
rename to lib/engine/gui/gtk-frontend/statusicon.h
index 20edb26..19f81e1 100644
--- a/src/gui/statusicon.h
+++ b/lib/engine/gui/gtk-frontend/statusicon.h
@@ -42,13 +42,15 @@
 
 #include <gtk/gtk.h>
 
+#include <boost/signals.hpp>
+#include <boost/bind.hpp>
+
 G_BEGIN_DECLS
 
 typedef struct _StatusIcon StatusIcon;
 typedef struct _StatusIconPrivate StatusIconPrivate;
 typedef struct _StatusIconClass StatusIconClass;
 
-
 /* GObject thingies */
 struct _StatusIcon
 {
@@ -59,6 +61,8 @@ struct _StatusIcon
 struct _StatusIconClass
 {
   GtkStatusIconClass parent;
+
+  void (*clicked) (StatusIcon* self);
 };
 
 #define STATUSICON_TYPE (statusicon_get_type ())
@@ -75,14 +79,12 @@ struct _StatusIconClass
 
 GType statusicon_get_type ();
 
-
-
 /* Public API */
 
 /* DESCRIPTION  : /
  * BEHAVIOR     : Returns a new statusicon, with the default icon and menu
  */
-StatusIcon *statusicon_new (Ekiga::ServiceCore & core);
+StatusIcon *status_icon_new (Ekiga::ServiceCore & core);
 
 G_END_DECLS
 
diff --git a/src/gui/callbacks.cpp b/lib/gui/gmcallbacks.c
similarity index 90%
rename from src/gui/callbacks.cpp
rename to lib/gui/gmcallbacks.c
index fbb5513..19c2b5d 100644
--- a/src/gui/callbacks.cpp
+++ b/lib/gui/gmcallbacks.c
@@ -39,9 +39,8 @@
 
 #include "config.h"
 
-#include "callbacks.h"
+#include "gmcallbacks.h"
 
-#include "ekiga.h"
 #include "gmwindow.h"
 #include "gmstockicons.h"
 
@@ -199,8 +198,8 @@ help_callback (G_GNUC_UNUSED GtkWidget *widget,
 
   if (!success) {
     GtkWidget *d;
-    d = gtk_message_dialog_new (GTK_WINDOW (GnomeMeeting::Process ()->GetMainWindow ()),
-                                (GtkDialogFlags) (GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT),
+    d = gtk_message_dialog_new (NULL,
+                                (GtkDialogFlags) (GTK_DIALOG_MODAL),
                                 GTK_MESSAGE_ERROR, GTK_BUTTONS_CLOSE,
                                 "%s", _("Unable to open help file."));
     gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (d),
@@ -217,25 +216,6 @@ void
 quit_callback (G_GNUC_UNUSED GtkWidget *widget,
 	       G_GNUC_UNUSED gpointer data)
 {
-  GtkWidget *main_window = NULL;
-  GtkWidget *assistant_window = NULL;
-  GtkWidget *prefs_window = NULL;
-  GtkWidget *accounts_window = NULL;
-
-  main_window = GnomeMeeting::Process ()->GetMainWindow ();
-  assistant_window = GnomeMeeting::Process ()->GetAssistantWindow ();
-  prefs_window = GnomeMeeting::Process ()->GetPrefsWindow ();
-  accounts_window = GnomeMeeting::Process ()->GetAccountsWindow ();
-
-  if (main_window)
-    gtk_widget_hide (main_window);
-  if (assistant_window)
-    gm_window_hide (assistant_window);
-  if (prefs_window)
-    gm_window_hide (prefs_window);
-  if (accounts_window)
-    gm_window_hide (accounts_window);
-
   while (gtk_events_pending ())
     gtk_main_iteration ();
 
diff --git a/src/gui/callbacks.h b/lib/gui/gmcallbacks.h
similarity index 97%
rename from src/gui/callbacks.h
rename to lib/gui/gmcallbacks.h
index 271f97f..650d7b7 100644
--- a/src/gui/callbacks.h
+++ b/lib/gui/gmcallbacks.h
@@ -40,7 +40,9 @@
 #ifndef _CALLBACKS_H
 #define _CALLBACKS_H
 
-#include "common.h"
+#include <gtk/gtk.h>
+
+G_BEGIN_DECLS
 
 /* DESCRIPTION  :  This callback is called when the user chooses to open
  *                 the about window.
@@ -67,4 +69,6 @@ void help_callback (GtkWidget *widget,
 void quit_callback (GtkWidget *widget,
 		    gpointer data);
 
+G_END_DECLS
+
 #endif
diff --git a/src/Makefile.am b/src/Makefile.am
index bc43a34..c4732a2 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -59,8 +59,6 @@ ekiga_SOURCES +=			\
 	gui/accounts.cpp		\
 	gui/assistant.h			\
 	gui/assistant.cpp		\
-	gui/callbacks.h			\
-	gui/callbacks.cpp		\
 	gui/conf.h			\
 	gui/conf.cpp			\
 	gui/default_devices.cpp	        \
@@ -73,8 +71,6 @@ ekiga_SOURCES +=			\
 	gui/notify.cpp                  \
 	gui/preferences.h		\
 	gui/preferences.cpp		\
-	gui/statusicon.h		\
-	gui/statusicon.cpp		\
 	gui/statusmenu.h		\
 	gui/statusmenu.cpp
 
diff --git a/src/dbus-helper/dbus.cpp b/src/dbus-helper/dbus.cpp
index 868a418..9647e43 100644
--- a/src/dbus-helper/dbus.cpp
+++ b/src/dbus-helper/dbus.cpp
@@ -46,7 +46,7 @@
 #include "ekiga.h"
 #include "gmmarshallers.h"
 #include "gmconf.h"
-#include "callbacks.h"
+#include "gmcallbacks.h"
 #include "accounts.h"
 
 #include "call-core.h"
diff --git a/src/ekiga.cpp b/src/ekiga.cpp
index 0842940..ebea8cf 100644
--- a/src/ekiga.cpp
+++ b/src/ekiga.cpp
@@ -65,7 +65,6 @@ GnomeMeeting::GnomeMeeting ()
   call_window = NULL;
   assistant_window = NULL;
   accounts_window = NULL;
-  statusicon = NULL;
 }
 
 
@@ -93,10 +92,6 @@ GnomeMeeting::Exit ()
   if (accounts_window)
     gtk_widget_destroy (accounts_window);
   accounts_window = NULL;
-
-  if (statusicon)
-    g_object_unref (statusicon);
-  statusicon = NULL;
 }
 
 
@@ -142,12 +137,6 @@ GnomeMeeting::GetAccountsWindow ()
 }
 
 
-StatusIcon *
-GnomeMeeting::GetStatusicon ()
-{
-  return statusicon;
-}
-
 void GnomeMeeting::Main ()
 {
 }
@@ -164,8 +153,6 @@ void GnomeMeeting::BuildGUI (Ekiga::ServiceCorePtr services)
   prefs_window = gm_prefs_window_new (services.get ());
   assistant_window = ekiga_assistant_new (services.get ());
   call_window = gm_call_window_new (*services);
-  if (!notify_has_persistence ())
-    statusicon = statusicon_new (*services);
   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));
diff --git a/src/ekiga.h b/src/ekiga.h
index 9dc19fe..bc9ad58 100644
--- a/src/ekiga.h
+++ b/src/ekiga.h
@@ -46,8 +46,6 @@
 #include "services.h"
 #include "runtime.h"
 
-#include "statusicon.h"
-
 #include <ptlib/ipsock.h>
 
 
@@ -113,13 +111,6 @@ class GnomeMeeting : public PProcess
   GtkWidget *GetAccountsWindow ();
 
 
-  /* DESCRIPTION  :  /
-   * BEHAVIOR     :  Returns a pointer to the tray.
-   * PRE          :  /
-   */
-  StatusIcon *GetStatusicon ();
-
-
   /* Needed for PProcess */
   void Main();
   static GnomeMeeting *Process ();
@@ -147,7 +138,6 @@ class GnomeMeeting : public PProcess
   GtkWidget *assistant_window;
   GtkWidget *prefs_window;
   GtkWidget *accounts_window;
-  StatusIcon *statusicon;
 
   static GnomeMeeting *GM;
 };
diff --git a/src/gui/accounts.cpp b/src/gui/accounts.cpp
index b2ec2c6..70f083f 100644
--- a/src/gui/accounts.cpp
+++ b/src/gui/accounts.cpp
@@ -42,7 +42,7 @@
 #include "opal-bank.h"
 #include "account-core.h"
 
-#include "callbacks.h"
+#include "gmcallbacks.h"
 
 #include "gmconf.h"
 #include "gmwindow.h"
@@ -667,8 +667,7 @@ gm_accounts_window_new (Ekiga::ServiceCore &core)
 
   frame = gtk_frame_new (NULL);
   gtk_widget_set_size_request (GTK_WIDGET (frame), 250, 150);
-  gtk_container_set_border_width (GTK_CONTAINER (frame),
-				  2 * GNOMEMEETING_PAD_SMALL);
+  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);
diff --git a/src/gui/call_window.cpp b/src/gui/call_window.cpp
index 5ecb67b..8b2aee3 100644
--- a/src/gui/call_window.cpp
+++ b/src/gui/call_window.cpp
@@ -43,7 +43,6 @@
 
 #include "ekiga.h"
 #include "conf.h"
-#include "callbacks.h"
 #include "dialpad.h"
 #include "statusmenu.h"
 
diff --git a/src/gui/main_window.cpp b/src/gui/main_window.cpp
index 0287120..03720cd 100644
--- a/src/gui/main_window.cpp
+++ b/src/gui/main_window.cpp
@@ -43,11 +43,11 @@
 
 #include "ekiga.h"
 #include "conf.h"
-#include "callbacks.h"
 #include "dialpad.h"
 #include "statusmenu.h"
 #include "notify.h"
 
+#include "gmcallbacks.h"
 #include "gmdialog.h"
 #include "gmentrydialog.h"
 #include "gmstatusbar.h"
@@ -242,6 +242,12 @@ static const std::string ekiga_main_window_get_call_url (EkigaMainWindow *mw);
 static void on_chat_unread_alert (GtkWidget*,
 				  gpointer);
 
+/* DESCRIPTION  :  This callback is called when the status icon is cliked
+ * PRE          :  /
+ */
+static void status_icon_clicked_cb (GtkWidget*,
+                                    gpointer);
+
 /* DESCRIPTION  :  This callback is called when the control panel
  *                 section key changes (which can be when the radio
  *                 menu is changed!)
@@ -1043,6 +1049,7 @@ on_roster_selection_changed (G_GNUC_UNUSED GtkWidget* view,
   }
 }
 
+
 static void
 on_chat_unread_alert (G_GNUC_UNUSED GtkWidget* widget,
 		      gpointer data)
@@ -1061,6 +1068,26 @@ on_chat_unread_alert (G_GNUC_UNUSED GtkWidget* widget,
 
 
 static void
+status_icon_clicked_cb (G_GNUC_UNUSED GtkWidget* widget,
+                        gpointer data)
+{
+  GtkWidget *window = GTK_WIDGET (data);
+
+  if (!gtk_widget_get_visible (window)
+      || (gdk_window_get_state (GDK_WINDOW (window->window)) & GDK_WINDOW_STATE_ICONIFIED)) {
+    gtk_widget_show (window);
+  }
+  else {
+
+    if (gtk_window_has_toplevel_focus (GTK_WINDOW (window)))
+      gtk_widget_hide (window);
+    else
+      gtk_window_present (GTK_WINDOW (window));
+  }
+}
+
+
+static void
 panel_section_changed_nt (G_GNUC_UNUSED gpointer id,
                           GmConfEntry *entry,
                           gpointer data)
@@ -1221,6 +1248,8 @@ window_closed_cb (G_GNUC_UNUSED GtkWidget *widget,
 		  G_GNUC_UNUSED GdkEvent *event,
 		  gpointer data)
 {
+  std::cout << "FIXME" << std::endl << std::flush;
+  /*
   StatusIcon *statusicon = GnomeMeeting::Process ()->GetStatusicon ();
   // If we have persistent notifications:
   //  - we can hide the window
@@ -1232,7 +1261,7 @@ window_closed_cb (G_GNUC_UNUSED GtkWidget *widget,
   gtk_widget_hide (GTK_WIDGET (data));
   if (!notify_has_persistence () && statusicon && !gtk_status_icon_is_embedded (GTK_STATUS_ICON (statusicon)))
     quit_callback (NULL, widget);
-
+*/
   return (TRUE);
 }
 
@@ -2150,11 +2179,12 @@ gm_main_window_new (Ekiga::ServiceCore & core)
 {
   GtkWidget *window = NULL;
   GtkWidget *chat_window = NULL;
+  StatusIcon *status_icon = NULL;
 
   /* initialize the callback to play IM message sound */
-  /* FIXME: move this to the chat window code */
   boost::shared_ptr<GtkFrontend> gtk_frontend = core.get<GtkFrontend> ("gtk-frontend");
   chat_window = GTK_WIDGET (gtk_frontend->get_chat_window ());
+  status_icon = STATUSICON (gtk_frontend->get_status_icon ());
 
   g_signal_connect (chat_window, "unread-alert",
 		    G_CALLBACK (on_chat_unread_alert), &core);
@@ -2162,6 +2192,9 @@ gm_main_window_new (Ekiga::ServiceCore & core)
   /* The Top-level window */
   window = ekiga_main_window_new (&core);
 
+  if (status_icon)
+    g_signal_connect (status_icon, "clicked",
+                      G_CALLBACK (status_icon_clicked_cb), (gpointer) window);
 
   return window;
 }
diff --git a/src/gui/notify.cpp b/src/gui/notify.cpp
index e138a56..1ecc79b 100644
--- a/src/gui/notify.cpp
+++ b/src/gui/notify.cpp
@@ -244,27 +244,3 @@ notify_has_actions (void)
 #endif
   return (accepts_actions > 0);
 }
-
-bool
-notify_has_persistence (void)
-{
-  gboolean has = false;
-#ifdef HAVE_NOTIFY
-  GList   *caps;
-  GList   *l;
-
-  caps = notify_get_server_caps ();
-  if (caps == NULL) {
-    fprintf (stderr, "Failed to receive server caps.\n");
-    return FALSE;
-  }
-
-  l = g_list_find_custom (caps, "persistence", (GCompareFunc)strcmp);
-  has = l != NULL;
-
-  g_list_foreach (caps, (GFunc) g_free, NULL);
-  g_list_free (caps);
-#endif
-
-  return has;
-}
diff --git a/src/gui/notify.h b/src/gui/notify.h
index e26fdc3..9390a2e 100644
--- a/src/gui/notify.h
+++ b/src/gui/notify.h
@@ -56,12 +56,6 @@ bool notify_start (Ekiga::ServiceCore & core);
  */
 bool notify_has_actions (void);
 
-/* DESCRIPTION  : /
- * BEHAVIOR     : Returns true if notification server supports persistent
- *                notifications.
- */
-bool notify_has_persistence (void);
-
 G_END_DECLS
 
 #endif



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