]> git.0d.be Git - empathy.git/commitdiff
tpaw-utils: move empathy_window_present* to tp-aw and rename it
authorMarco Barisione <marco.barisione@collabora.co.uk>
Fri, 10 May 2013 14:09:02 +0000 (15:09 +0100)
committerMarco Barisione <marco.barisione@collabora.co.uk>
Tue, 20 Aug 2013 10:03:06 +0000 (11:03 +0100)
This commit also changes the licence of the moved code from GPL to LGPL.
See GOSSIP-RELICENSING.txt for details.

https://bugzilla.gnome.org/show_bug.cgi?id=699492

libempathy-gtk/empathy-ui-utils.c
libempathy-gtk/empathy-ui-utils.h
src/empathy-call-window.c
src/empathy-call.c
src/empathy-chat-window.c
src/empathy-status-icon.c
src/empathy.c
tp-account-widgets/tpaw-irc-network-chooser.c
tp-account-widgets/tpaw-utils.c
tp-account-widgets/tpaw-utils.h

index c230324bb9a90e874d7ac99b3632905e9f06ec3e..272c425130559ac60bc66ae84f88620ec9665eaf 100644 (file)
@@ -810,47 +810,6 @@ empathy_filename_from_icon_name (const gchar *icon_name,
   return ret;
 }
 
-/* Takes care of moving the window to the current workspace. */
-void
-empathy_window_present_with_time (GtkWindow *window,
-    guint32 timestamp)
-{
-  GdkWindow *gdk_window;
-
-  g_return_if_fail (GTK_IS_WINDOW (window));
-
-  /* Move the window to the current workspace before trying to show it.
-   * This is the behaviour people expect when clicking on the statusbar icon. */
-  gdk_window = gtk_widget_get_window (GTK_WIDGET (window));
-
-  if (gdk_window)
-    {
-      gint x, y;
-      gint w, h;
-
-      /* Has no effect if the WM has viewports, like compiz */
-      gdk_x11_window_move_to_current_desktop (gdk_window);
-
-      /* If window is still off-screen, hide it to force it to
-       * reposition on the current workspace. */
-      gtk_window_get_position (window, &x, &y);
-      gtk_window_get_size (window, &w, &h);
-      if (!EMPATHY_RECT_IS_ON_SCREEN (x, y, w, h))
-        gtk_widget_hide (GTK_WIDGET (window));
-    }
-
-  if (timestamp == GDK_CURRENT_TIME)
-    gtk_window_present (window);
-  else
-    gtk_window_present_with_time (window, timestamp);
-}
-
-void
-empathy_window_present (GtkWindow *window)
-{
-  empathy_window_present_with_time (window, gtk_get_current_event_time ());
-}
-
 /** empathy_make_absolute_url_len:
  * @url: an url
  * @len: a length
index f9627f7fe901a3fd89b7d0de5cc03c5aa47dce47..79e3e1160dab7ec095c7a40923adcbd8a965d56e 100644 (file)
@@ -94,11 +94,6 @@ GdkPixbuf * empathy_pixbuf_from_icon_name_sized (const gchar *icon_name,
 gchar * empathy_filename_from_icon_name (const gchar *icon_name,
     GtkIconSize icon_size);
 
-/* Windows */
-void empathy_window_present (GtkWindow *window);
-void empathy_window_present_with_time (GtkWindow *window,
-    guint32 timestamp);
-
 void empathy_move_to_window_desktop (GtkWindow *window,
     guint32 timestamp);
 
index 5f10d919e45cafa5758121075e5726b9eda06813..6c215b53b843fcc235803d31a0d437e0f459879b 100644 (file)
@@ -28,6 +28,7 @@
 #include <tp-account-widgets/tpaw-builder.h>
 #include <tp-account-widgets/tpaw-camera-monitor.h>
 #include <tp-account-widgets/tpaw-images.h>
+#include <tp-account-widgets/tpaw-utils.h>
 
 #include "empathy-about-dialog.h"
 #include "empathy-audio-sink.h"
@@ -2464,7 +2465,7 @@ empathy_call_window_new_handler (EmpathyCallWindow *self,
   g_return_if_fail (EMPATHY_IS_CALL_HANDLER (handler));
 
   if (present)
-    empathy_window_present_with_time (GTK_WINDOW (self), x11_time);
+    tpaw_window_present_with_time (GTK_WINDOW (self), x11_time);
 
   if (self->priv->call_state == DISCONNECTED)
     {
index 2b944552bda02f16059839b8e82982f02d163158..3d3ae80cf7645dacf7f5bc37b9ad0d58338961ed 100644 (file)
@@ -25,6 +25,7 @@
 #include <glib/gi18n.h>
 #include <clutter-gtk/clutter-gtk.h>
 #include <clutter-gst/clutter-gst.h>
+#include <tp-account-widgets/tpaw-utils.h>
 
 #ifdef CLUTTER_WINDOWING_X11
 #include <X11/Xlib.h>
@@ -162,7 +163,7 @@ new_call_handler_cb (EmpathyCallFactory *factory,
       gtk_widget_show (GTK_WIDGET (window));
 
       if (present)
-        empathy_window_present_with_time (GTK_WINDOW (window), x11_time);
+        tpaw_window_present_with_time (GTK_WINDOW (window), x11_time);
     }
 }
 
index 5f23b6a4774088e176bb22feaba3e9caf75d59d8..aa9811ef8a63c1766dba7e5ddadb1a17d3964229 100644 (file)
@@ -2854,7 +2854,7 @@ empathy_chat_window_present_chat (EmpathyChat *chat,
 
   empathy_chat_window_switch_to_chat (self, chat);
 
-  /* Don't use empathy_window_present_with_time () which would move the window
+  /* Don't use tpaw_window_present_with_time () which would move the window
    * to our current desktop but move to the window's desktop instead. This is
    * more coherent with Shell's 'app is ready' notication which moves the view
    * to the app desktop rather than moving the app itself. */
index e000f32e1ae3c191615c4a94f451437d0323059c..6d273cc03c83c1d5786a9dc760250f5c7e88cdf8 100644 (file)
@@ -23,6 +23,7 @@
 #include "empathy-status-icon.h"
 
 #include <tp-account-widgets/tpaw-builder.h>
+#include <tp-account-widgets/tpaw-utils.h>
 
 #include "empathy-event-manager.h"
 #include "empathy-gsettings.h"
@@ -210,7 +211,7 @@ status_icon_set_visibility (EmpathyStatusIcon *icon,
        if (!visible) {
                gtk_widget_hide (priv->window);
        } else {
-               empathy_window_present (GTK_WINDOW (priv->window));
+               tpaw_window_present (GTK_WINDOW (priv->window));
        }
 }
 
index 5cfe9f38bb02704e4d12cc26d3e6ad70974e1e75..4a36da61ce11e312ab2e0caccd72cbd9b3fbe1db 100644 (file)
@@ -24,6 +24,7 @@
 #include <glib/gstdio.h>
 #include <glib/gi18n.h>
 #include <libnotify/notify.h>
+#include <tp-account-widgets/tpaw-utils.h>
 
 #ifdef HAVE_LIBCHAMPLAIN
 #include <clutter-gtk/clutter-gtk.h>
@@ -342,7 +343,7 @@ empathy_app_activate (GApplication *app)
   else
     {
       if (!self->start_hidden)
-        empathy_window_present (GTK_WINDOW (self->window));
+        tpaw_window_present (GTK_WINDOW (self->window));
     }
 
   /* Display the accounts dialog if needed */
index 6e6aeb73b1d6c9e71bfcc32296b4d0f409d401df..5339e1ba58bff47d7faba3335a1c33644cb73044 100644 (file)
@@ -333,7 +333,7 @@ clicked_cb (GtkButton *button,
       G_CALLBACK (dialog_response_cb), button, 0);
 
 out:
-  empathy_window_present (GTK_WINDOW (priv->dialog));
+  tpaw_window_present (GTK_WINDOW (priv->dialog));
 }
 
 static void
index 7c0a03082d77b39bb2e82b0a1d2e776be97d537a..933b8570ede5b25a58f3ea4a56bdab4bb624d92e 100644 (file)
@@ -1,11 +1,17 @@
 /*
  * Copyright (C) 2007-2013 Collabora Ltd.
+ * Copyright (C) 2005-2006 Imendio AB
  * Copyright (C) 2006 Xavier Claessens <xavier.claessens@gmail.com>
+ * Copyright (C) 2009 Steve Frécinaux <code@istique.net>
  *
  * Authors: Marco Barisione <marco.barisione@collabora.co.uk>
  *          Guillaume Desmottes <guillaume.desmottes@collabora.co.uk>
  *          Sjoerd Simons <sjoerd.simons@collabora.co.uk>
  *          Xavier Claessens <xavier.claessens@collabora.co.uk>
+ *          Mikael Hallendal <micke@imendio.com>
+ *          Richard Hult <richard@imendio.com>
+ *          Martyn Russell <martyn@imendio.com>
+ *          Steve Frécinaux <code@istique.net>
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
 #include "tpaw-utils.h"
 
 #include <glib/gi18n-lib.h>
+#include <gdk/gdkx.h>
 
 #define DEBUG_FLAG EMPATHY_DEBUG_OTHER
 #include "empathy-debug.h"
 
+#define TPAW_RECT_IS_ON_SCREEN(x,y,w,h) ((x) + (w) > 0 && \
+              (y) + (h) > 0 && \
+              (x) < gdk_screen_width () && \
+              (y) < gdk_screen_height ())
+
 /* Change the RequestedPresence of a newly created account to ensure that it
  * is actually connected. */
 void
@@ -169,6 +181,47 @@ tpaw_make_color_whiter (GdkRGBA *color)
   color->blue = (color->blue + white.blue) / 2;
 }
 
+/* Takes care of moving the window to the current workspace. */
+void
+tpaw_window_present_with_time (GtkWindow *window,
+    guint32 timestamp)
+{
+  GdkWindow *gdk_window;
+
+  g_return_if_fail (GTK_IS_WINDOW (window));
+
+  /* Move the window to the current workspace before trying to show it.
+   * This is the behaviour people expect when clicking on the statusbar icon. */
+  gdk_window = gtk_widget_get_window (GTK_WIDGET (window));
+
+  if (gdk_window)
+    {
+      gint x, y;
+      gint w, h;
+
+      /* Has no effect if the WM has viewports, like compiz */
+      gdk_x11_window_move_to_current_desktop (gdk_window);
+
+      /* If window is still off-screen, hide it to force it to
+       * reposition on the current workspace. */
+      gtk_window_get_position (window, &x, &y);
+      gtk_window_get_size (window, &w, &h);
+      if (!TPAW_RECT_IS_ON_SCREEN (x, y, w, h))
+        gtk_widget_hide (GTK_WIDGET (window));
+    }
+
+  if (timestamp == GDK_CURRENT_TIME)
+    gtk_window_present (window);
+  else
+    gtk_window_present_with_time (window, timestamp);
+}
+
+void
+tpaw_window_present (GtkWindow *window)
+{
+  tpaw_window_present_with_time (window, gtk_get_current_event_time ());
+}
+
 GtkWindow *
 tpaw_get_toplevel_window (GtkWidget *widget)
 {
index 106c3b4e4facbb5d3718faf104e03e69c98c46f9..f82b5a6f72b86354b09110d208636232fee8e5ac 100644 (file)
@@ -1,11 +1,17 @@
 /*
  * Copyright (C) 2007-2013 Collabora Ltd.
+ * Copyright (C) 2005-2006 Imendio AB
  * Copyright (C) 2006 Xavier Claessens <xavier.claessens@gmail.com>
+ * Copyright (C) 2009 Steve Frécinaux <code@istique.net>
  *
  * Authors: Marco Barisione <marco.barisione@collabora.co.uk>
  *          Guillaume Desmottes <guillaume.desmottes@collabora.co.uk>
  *          Sjoerd Simons <sjoerd.simons@collabora.co.uk>
  *          Xavier Claessens <xavier.claessens@collabora.co.uk>
+ *          Mikael Hallendal <micke@imendio.com>
+ *          Richard Hult <richard@imendio.com>
+ *          Martyn Russell <martyn@imendio.com>
+ *          Steve Frécinaux <code@istique.net>
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -41,6 +47,9 @@ const gchar *tpaw_service_name_to_display_name (const gchar *proto_name);
 void  tpaw_make_color_whiter (GdkRGBA *color);
 
 /* Windows */
+void tpaw_window_present (GtkWindow *window);
+void tpaw_window_present_with_time (GtkWindow *window,
+    guint32 timestamp);
 GtkWindow * tpaw_get_toplevel_window (GtkWidget *widget);
 
 /* Copied from wocky/wocky-utils.h */