[ekiga] Made the gtk+ frontend show the main window when the status icon gets clicked



commit a5543961af4c168e219507a9dfc87a8e29d57dad
Author: Julien Puydt <jpuydt free fr>
Date:   Thu Jun 20 16:44:20 2013 +0200

    Made the gtk+ frontend show the main window when the status icon gets clicked
    
    That makes the frontend a little bigger and the main window a little smaller

 lib/engine/gui/gtk-frontend/gtk-frontend.cpp |   32 +++++++++++++++++++++++--
 lib/engine/gui/gtk-frontend/main_window.cpp  |   31 -------------------------
 lib/engine/gui/gtk-frontend/statusicon.cpp   |    5 +--
 3 files changed, 31 insertions(+), 37 deletions(-)
---
diff --git a/lib/engine/gui/gtk-frontend/gtk-frontend.cpp b/lib/engine/gui/gtk-frontend/gtk-frontend.cpp
index dd5f4d8..0e69442 100644
--- a/lib/engine/gui/gtk-frontend/gtk-frontend.cpp
+++ b/lib/engine/gui/gtk-frontend/gtk-frontend.cpp
@@ -62,6 +62,30 @@
 
 #include "gmwindow.h"
 
+/* Private helpers */
+
+// when the status icon is clicked, we want to either show or hide the main window
+static void
+on_status_icon_clicked (G_GNUC_UNUSED GtkWidget* widget,
+                        gpointer data)
+{
+  GtkWidget *window = GTK_WIDGET (((GtkFrontend*)data)->get_main_window ());
+
+  if (!gtk_widget_get_visible (window)
+      || (gdk_window_get_state (GDK_WINDOW (gtk_widget_get_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));
+  }
+}
+
+/* Public api */
+
 bool
 gtk_frontend_init (Ekiga::ServiceCore &core,
                   int * /*argc*/,
@@ -133,10 +157,12 @@ GtkFrontend::build ()
   status_icon =
     boost::shared_ptr<StatusIcon> (status_icon_new (core),
                                   g_object_unref);
+  g_signal_connect (status_icon.get (), "clicked",
+                   G_CALLBACK (on_status_icon_clicked), this);
 
-  // BEWARE: the main window uses the chat window and status icon at
-  // startup already, and later on needs the call window, addressbook
-  // window, preferences window and assistant window
+  // BEWARE: the main window uses the chat window at startup already,
+  // and later on needs the call window, addressbook window,
+  // preferences window and assistant window
   main_window =
     boost::shared_ptr<GtkWidget> (gm_main_window_new (core),
                                 gtk_widget_destroy);
diff --git a/lib/engine/gui/gtk-frontend/main_window.cpp b/lib/engine/gui/gtk-frontend/main_window.cpp
index 6f4aa30..5b99fef 100644
--- a/lib/engine/gui/gtk-frontend/main_window.cpp
+++ b/lib/engine/gui/gtk-frontend/main_window.cpp
@@ -196,12 +196,6 @@ 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!)
@@ -757,26 +751,6 @@ 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 (gtk_widget_get_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)
@@ -1632,14 +1606,9 @@ gm_main_window_new (Ekiga::ServiceCore & core)
   if (gtk_frontend) {
 
     GtkWidget *chat_window = GTK_WIDGET (gtk_frontend->get_chat_window ());
-    StatusIcon *status_icon = STATUSICON (gtk_frontend->get_status_icon ());
 
     g_signal_connect (chat_window, "unread-alert",
                      G_CALLBACK (on_chat_unread_alert), mw);
-
-    if (status_icon)
-      g_signal_connect (status_icon, "clicked",
-                       G_CALLBACK (status_icon_clicked_cb), mw);
   }
 
   return GTK_WIDGET(mw);
diff --git a/lib/engine/gui/gtk-frontend/statusicon.cpp b/lib/engine/gui/gtk-frontend/statusicon.cpp
index efd9d01..06ff4a5 100644
--- a/lib/engine/gui/gtk-frontend/statusicon.cpp
+++ b/lib/engine/gui/gtk-frontend/statusicon.cpp
@@ -259,11 +259,10 @@ statusicon_activated_cb (G_GNUC_UNUSED GtkStatusIcon *icon,
 {
   StatusIcon *self = STATUSICON (data);
 
-  // No unread messages => show ekiga
+  // No unread messages => signal the gtk+ frontend
+  // (should hide/present the main window)
   if (!self->priv->unread_messages) {
 
-    // FIXME: When the main_window will be a GtkFrontend component,
-    // this signal will be useless
     g_signal_emit (self, signals, 0, NULL);
   }
   else {


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