aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarco Barisione <marco.barisione@collabora.co.uk>2013-05-10 22:09:02 +0800
committerMarco Barisione <marco.barisione@collabora.co.uk>2013-08-20 18:03:06 +0800
commit4598bce7db6276a9f1f9e21adef8723b646bf44b (patch)
tree36619009e101de4b0db54926352cffd8f1a3625a
parent44c61cce71ad3683aa6a284ce117e286423f555c (diff)
downloadgsoc2013-empathy-4598bce7db6276a9f1f9e21adef8723b646bf44b.tar
gsoc2013-empathy-4598bce7db6276a9f1f9e21adef8723b646bf44b.tar.gz
gsoc2013-empathy-4598bce7db6276a9f1f9e21adef8723b646bf44b.tar.bz2
gsoc2013-empathy-4598bce7db6276a9f1f9e21adef8723b646bf44b.tar.lz
gsoc2013-empathy-4598bce7db6276a9f1f9e21adef8723b646bf44b.tar.xz
gsoc2013-empathy-4598bce7db6276a9f1f9e21adef8723b646bf44b.tar.zst
gsoc2013-empathy-4598bce7db6276a9f1f9e21adef8723b646bf44b.zip
tpaw-utils: move empathy_window_present* to tp-aw and rename it
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
-rw-r--r--libempathy-gtk/empathy-ui-utils.c41
-rw-r--r--libempathy-gtk/empathy-ui-utils.h5
-rw-r--r--src/empathy-call-window.c3
-rw-r--r--src/empathy-call.c3
-rw-r--r--src/empathy-chat-window.c2
-rw-r--r--src/empathy-status-icon.c3
-rw-r--r--src/empathy.c3
-rw-r--r--tp-account-widgets/tpaw-irc-network-chooser.c2
-rw-r--r--tp-account-widgets/tpaw-utils.c53
-rw-r--r--tp-account-widgets/tpaw-utils.h9
10 files changed, 72 insertions, 52 deletions
diff --git a/libempathy-gtk/empathy-ui-utils.c b/libempathy-gtk/empathy-ui-utils.c
index c230324bb..272c42513 100644
--- a/libempathy-gtk/empathy-ui-utils.c
+++ b/libempathy-gtk/empathy-ui-utils.c
@@ -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
diff --git a/libempathy-gtk/empathy-ui-utils.h b/libempathy-gtk/empathy-ui-utils.h
index f9627f7fe..79e3e1160 100644
--- a/libempathy-gtk/empathy-ui-utils.h
+++ b/libempathy-gtk/empathy-ui-utils.h
@@ -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);
diff --git a/src/empathy-call-window.c b/src/empathy-call-window.c
index 5f10d919e..6c215b53b 100644
--- a/src/empathy-call-window.c
+++ b/src/empathy-call-window.c
@@ -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)
{
diff --git a/src/empathy-call.c b/src/empathy-call.c
index 2b944552b..3d3ae80cf 100644
--- a/src/empathy-call.c
+++ b/src/empathy-call.c
@@ -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);
}
}
diff --git a/src/empathy-chat-window.c b/src/empathy-chat-window.c
index 5f23b6a47..aa9811ef8 100644
--- a/src/empathy-chat-window.c
+++ b/src/empathy-chat-window.c
@@ -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. */
diff --git a/src/empathy-status-icon.c b/src/empathy-status-icon.c
index e000f32e1..6d273cc03 100644
--- a/src/empathy-status-icon.c
+++ b/src/empathy-status-icon.c
@@ -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));
}
}
diff --git a/src/empathy.c b/src/empathy.c
index 5cfe9f38b..4a36da61c 100644
--- a/src/empathy.c
+++ b/src/empathy.c
@@ -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 */
diff --git a/tp-account-widgets/tpaw-irc-network-chooser.c b/tp-account-widgets/tpaw-irc-network-chooser.c
index 6e6aeb73b..5339e1ba5 100644
--- a/tp-account-widgets/tpaw-irc-network-chooser.c
+++ b/tp-account-widgets/tpaw-irc-network-chooser.c
@@ -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
diff --git a/tp-account-widgets/tpaw-utils.c b/tp-account-widgets/tpaw-utils.c
index 7c0a03082..933b8570e 100644
--- a/tp-account-widgets/tpaw-utils.c
+++ b/tp-account-widgets/tpaw-utils.c
@@ -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
@@ -26,10 +32,16 @@
#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)
{
diff --git a/tp-account-widgets/tpaw-utils.h b/tp-account-widgets/tpaw-utils.h
index 106c3b4e4..f82b5a6f7 100644
--- a/tp-account-widgets/tpaw-utils.h
+++ b/tp-account-widgets/tpaw-utils.h
@@ -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 */