Commit da500948 authored by Jonny Lamb's avatar Jonny Lamb

Remove the panel applets. (Closes bug #599042)

Signed-off-by: Jonny Lamb's avatarJonny Lamb <jonnylamb@gnome.org>
parent 90469882
SUBDIRS = tools extensions po data libempathy libempathy-gtk src docs help
if HAVE_MEGAPHONE
SUBDIRS += megaphone
endif
if HAVE_NST
SUBDIRS += nautilus-sendto-plugin
endif
if HAVE_NOTHERE
SUBDIRS += nothere
endif
if HAVE_PYTHON
SUBDIRS += python
endif
......
......@@ -355,33 +355,6 @@ AM_CONDITIONAL(HAVE_MOBLIN, test "x$have_moblin" = "xyes")
AC_SUBST(MOBLIN_CFLAGS)
AC_SUBST(MOBLIN_LIBS)
# -----------------------------------------------------------
# Megaphone
# -----------------------------------------------------------
AC_ARG_ENABLE(megaphone,
AS_HELP_STRING([--enable-megaphone=@<:@no/yes/auto@:>@],
[build megaphone applet]), ,
enable_megaphone=auto)
if test "x$enable_megaphone" != "xno"; then
PKG_CHECK_MODULES(MEGAPHONE,
[
libpanelapplet-2.0 >= $LIBPANELAPPLET_REQUIRED
glib-2.0 >= $GLIB_REQUIRED
gtk+-2.0 >= $GTK_REQUIRED
gconf-2.0 >= $GCONF_REQUIRED
telepathy-glib >= $TELEPATHY_GLIB_REQUIRED
], have_megaphone="yes", have_megaphone="no")
else
have_megaphone=no
fi
if test "x$enable_megaphone" = "xyes" -a "x$have_megaphone" != "xyes"; then
AC_MSG_ERROR([Couldn't find megaphone dependencies.])
fi
AM_CONDITIONAL(HAVE_MEGAPHONE, test "x$have_megaphone" = "xyes")
# -----------------------------------------------------------
# nautilus-sendto
# -----------------------------------------------------------
......@@ -405,33 +378,6 @@ fi
AM_CONDITIONAL(HAVE_NST, test "x$have_nst" = "xyes")
# -----------------------------------------------------------
# Nothere
# -----------------------------------------------------------
AC_ARG_ENABLE(nothere,
AS_HELP_STRING([--enable-nothere=@<:@no/yes/auto@:>@],
[build nothere applet]), ,
enable_nothere=auto)
if test "x$enable_nothere" != "xno"; then
PKG_CHECK_MODULES(NOTHERE,
[
libpanelapplet-2.0 >= $LIBPANELAPPLET_REQUIRED
glib-2.0 >= $GLIB_REQUIRED
gtk+-2.0 >= $GTK_REQUIRED
gconf-2.0 >= $GCONF_REQUIRED
telepathy-glib >= $TELEPATHY_GLIB_REQUIRED
], have_nothere="yes", have_nothere="no")
else
have_nothere=no
fi
if test "x$enable_nothere" = "xyes" -a "x$have_nothere" != "xyes"; then
AC_MSG_ERROR([Couldn't find nothere dependencies.])
fi
AM_CONDITIONAL(HAVE_NOTHERE, test "x$have_nothere" = "xyes")
# -----------------------------------------------------------
# Tests
# -----------------------------------------------------------
......@@ -515,13 +461,7 @@ AC_OUTPUT([
libempathy-gtk/Makefile
libempathy-gtk/libempathy-gtk.pc
src/Makefile
megaphone/Makefile
megaphone/src/Makefile
megaphone/data/Makefile
nautilus-sendto-plugin/Makefile
nothere/Makefile
nothere/src/Makefile
nothere/data/Makefile
docs/Makefile
docs/libempathy/Makefile
docs/libempathy/version.xml
......@@ -562,7 +502,5 @@ Configure summary:
Extras:
Documentation...............: ${enable_gtk_doc}
Python bindings.............: ${have_python}
Megaphone applet............: ${have_megaphone}
Nothere applet..............: ${have_nothere}
Nautilus-sendto plugin......: ${have_nst}
"
GNOME_Megaphone_Applet.schemas
GNOME_Megaphone_Applet.server
GNOME_Megaphone_Applet.server.in
megaphone-applet
<gconfschemafile>
<schemalist>
<schema>
<key>/schemas/apps/megaphone-applet/prefs/contact_id</key>
<applyto>/apps/megaphone-applet/prefs/contact_id</applyto>
<owner>megaphone</owner>
<type>string</type>
<default></default>
<locale name="C">
<short>The contact to display in the applet. Empty means no contact is displayed.</short>
</locale>
</schema>
<schema>
<key>/schemas/apps/megaphone-applet/prefs/avatar_token</key>
<applyto>/apps/megaphone-applet/prefs/avatar_token</applyto>
<owner>megaphone</owner>
<type>string</type>
<default></default>
<locale name="C">
<short>The contact's avatar token. Empty means contact has no avatar.</short>
</locale>
</schema>
</schemalist>
</gconfschemafile>
<oaf_info>
<oaf_server iid="OAFIID:GNOME_Megaphone_Applet_Factory" type="exe" location="@LIBEXECDIR@/megaphone-applet">
<oaf_attribute name="repo_ids" type="stringv">
<item value="IDL:Bonobo/GenericFactory:1.0"/>
<item value="IDL:Bonobo/Unknown:1.0"/>
</oaf_attribute>
<oaf_attribute name="name" type="string" _value="Megaphone"/>
<oaf_attribute name="description" type="string" _value="Talk!"/>
</oaf_server>
<oaf_server iid="OAFIID:GNOME_Megaphone_Applet" type="factory" location="OAFIID:GNOME_Megaphone_Applet_Factory">
<oaf_attribute name="repo_ids" type="stringv">
<item value="IDL:GNOME/Vertigo/PanelAppletShell:1.0"/>
<item value="IDL:Bonobo/Control:1.0"/>
<item value="IDL:Bonobo/Unknown:1.0"/>
</oaf_attribute>
<oaf_attribute name="name" type="string" _value="Megaphone"/>
<oaf_attribute name="description" type="string" _value="Talk!"/>
<oaf_attribute name="panel:category" type="string" value="Internet"/>
<oaf_attribute name="panel:icon" type="string" value="empathy.png"/>
</oaf_server>
</oaf_info>
<Root>
<popups>
<popup name="button3">
<menuitem name="Information" verb="information" _label="_Information" pixtype="stock" pixname="gtk-info"/>
<menuitem name="Preferences" verb="preferences" _label="_Preferences" pixtype="stock" pixname="gtk-properties"/>
<menuitem name="About" verb="about" _label="_About" pixtype="stock" pixname="gtk-about"/>
</popup>
</popups>
</Root>
include $(top_srcdir)/tools/shave.mk
# Panel applet bonobo stuff
serverdir = $(libdir)/bonobo/servers
server_in_files = GNOME_Megaphone_Applet.server.in
server_DATA = $(server_in_files:.server.in=.server)
# GConf Schemas
schemadir = $(GCONF_SCHEMA_FILE_DIR)
schema_in_files = GNOME_Megaphone_Applet.schemas.in
schema_DATA = $(schema_in_files:.schemas.in=.schemas)
# Misc data
resourcesdir = $(pkgdatadir)
resources_DATA = \
GNOME_Megaphone_Applet.xml
megaphonebindir = $(libexecdir)
# Build rules
@INTLTOOL_SERVER_RULE@
@INTLTOOL_SCHEMAS_RULE@
$(server_in_files): $(server_in_files:.server.in=.server.in.in)
$(QUIET_GEN)sed -e "s|\@LIBEXECDIR\@|$(megaphonebindir)|" $< > $@
DISTCLEANFILES = \
$(server_DATA) \
$(server_in_files) \
$(schema_DATA)
EXTRA_DIST = \
GNOME_Megaphone_Applet.server.in.in \
$(resources_DATA) \
$(schema_in_files)
AM_CPPFLAGS = \
-I$(top_srcdir) \
-DPKGDATADIR=\""$(pkgdatadir)"\" \
-DGNOMELOCALEDIR=\""$(prefix)/$(DATADIRNAME)/locale"\" \
-DIMAGEDIR=\"$(datadir)/empathy\" \
$(MEGAPHONE_CFLAGS) $(WARN_CFLAGS) $(DISABLE_DEPRECATED)
libexec_PROGRAMS = megaphone-applet
megaphone_applet_SOURCES = \
megaphone-applet.c megaphone-applet.h
megaphone_applet_LDFLAGS = \
$(MEGAPHONE_LIBS)
megaphone_applet_LDADD = \
$(top_builddir)/libempathy/libempathy.la \
$(top_builddir)/libempathy-gtk/libempathy-gtk.la
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/*
* Copyright (C) 2007 Raphaël Slinckx <raphael@slinckx.net>
* Copyright (C) 2007-2009 Collabora Ltd.
*
* 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
* Authors: Raphaël Slinckx <raphael@slinckx.net>
* Xavier Claessens <xclaesse@gmail.com>
*/
#include "config.h"
#include <string.h>
#include <glib/gi18n.h>
#include <gtk/gtk.h>
#include <bonobo/bonobo-ui-component.h>
#include <panel-2.0/panel-applet-gconf.h>
#include <gconf/gconf-client.h>
#include <libempathy/empathy-tp-contact-factory.h>
#include <libempathy/empathy-account-manager.h>
#include <libempathy/empathy-dispatcher.h>
#include <libempathy/empathy-contact.h>
#include <libempathy/empathy-contact-list.h>
#include <libempathy/empathy-contact-manager.h>
#include <libempathy/empathy-utils.h>
#include <libempathy-gtk/empathy-contact-list-view.h>
#include <libempathy-gtk/empathy-contact-list-store.h>
#include <libempathy-gtk/empathy-contact-dialogs.h>
#include <libempathy-gtk/empathy-ui-utils.h>
#include "megaphone-applet.h"
#define DEBUG_FLAG EMPATHY_DEBUG_OTHER
#include <libempathy/empathy-debug.h>
#define GET_PRIV(obj) EMPATHY_GET_PRIV (obj, MegaphoneApplet)
typedef struct {
EmpathyTpContactFactory *factory;
EmpathyAccountManager *account_manager;
EmpathyAccount *account;
gchar *id;
GtkWidget *image;
gint image_size;
EmpathyContact *contact;
GConfClient *gconf;
guint gconf_cnxn;
} MegaphoneAppletPriv;
G_DEFINE_TYPE(MegaphoneApplet, megaphone_applet, PANEL_TYPE_APPLET)
static void
megaphone_applet_update_icon (MegaphoneApplet *applet)
{
MegaphoneAppletPriv *priv = GET_PRIV (applet);
EmpathyAvatar *avatar = NULL;
GdkPixbuf *avatar_pixbuf;
if (priv->contact) {
avatar = empathy_contact_get_avatar (priv->contact);
} else {
gtk_image_set_from_icon_name (GTK_IMAGE (priv->image),
GTK_STOCK_PREFERENCES,
GTK_ICON_SIZE_MENU);
return;
}
if (!avatar) {
gchar *avatar_token;
/* Try to take avatar from cache */
avatar_token = panel_applet_gconf_get_string (PANEL_APPLET (applet),
"avatar_token",
NULL);
if (!EMP_STR_EMPTY (avatar_token)) {
empathy_contact_load_avatar_cache (priv->contact, avatar_token);
avatar = empathy_contact_get_avatar (priv->contact);
}
g_free (avatar_token);
}
if (avatar) {
avatar_pixbuf = empathy_pixbuf_from_avatar_scaled (avatar,
priv->image_size - 2,
priv->image_size - 2);
} else {
GtkIconTheme *icon_theme;
/* Load the default icon when no avatar is found */
icon_theme = gtk_icon_theme_get_default ();
avatar_pixbuf = gtk_icon_theme_load_icon (icon_theme,
"stock_contact",
priv->image_size - 2,
0, NULL);
}
/* Now some desaturation if the contact is offline */
if (!empathy_contact_is_online (priv->contact)) {
GdkPixbuf *offline_avatar;
offline_avatar = gdk_pixbuf_new (GDK_COLORSPACE_RGB, TRUE,
8,
gdk_pixbuf_get_height (avatar_pixbuf),
gdk_pixbuf_get_width (avatar_pixbuf));
gdk_pixbuf_saturate_and_pixelate (avatar_pixbuf,
offline_avatar,
0.0,
TRUE);
g_object_unref (avatar_pixbuf);
avatar_pixbuf = offline_avatar;
}
gtk_image_set_from_pixbuf (GTK_IMAGE (priv->image), avatar_pixbuf);
g_object_unref (avatar_pixbuf);
}
static void
megaphone_applet_update_contact (MegaphoneApplet *applet)
{
MegaphoneAppletPriv *priv = GET_PRIV (applet);
const gchar *name;
const gchar *status;
gchar *tip;
const gchar *avatar_token = NULL;
if (priv->contact) {
EmpathyAvatar *avatar;
avatar = empathy_contact_get_avatar (priv->contact);
if (avatar) {
avatar_token = avatar->token;
}
}
if (avatar_token) {
panel_applet_gconf_set_string (PANEL_APPLET (applet),
"avatar_token", avatar_token,
NULL);
}
megaphone_applet_update_icon (applet);
if (priv->contact ) {
name = empathy_contact_get_name (priv->contact);
status = empathy_contact_get_status (priv->contact);
tip = g_strdup_printf ("<b>%s</b>: %s", name, status);
gtk_widget_set_tooltip_markup (GTK_WIDGET (applet), tip);
g_free (tip);
} else {
gtk_widget_set_tooltip_markup (GTK_WIDGET (applet),
_("Please configure a contact."));
}
}
static void
megaphone_applet_got_contact_cb (EmpathyTpContactFactory *factory,
EmpathyContact *contact,
const GError *error,
gpointer user_data,
GObject *applet)
{
MegaphoneAppletPriv *priv = GET_PRIV (applet);
if (error != NULL) {
DEBUG ("Error: %s", error->message);
return;
}
priv->contact = g_object_ref (contact);
g_signal_connect_swapped (priv->contact, "notify",
G_CALLBACK (megaphone_applet_update_contact),
applet);
megaphone_applet_update_contact (MEGAPHONE_APPLET (applet));
}
static void
megaphone_applet_new_connection_cb (EmpathyAccountManager *manager,
TpConnection *connection,
EmpathyAccount *account,
MegaphoneApplet *applet)
{
MegaphoneAppletPriv *priv = GET_PRIV (applet);
if (priv->contact || account != priv->account) {
return;
}
priv->factory = empathy_tp_contact_factory_dup_singleton (connection);
empathy_tp_contact_factory_get_from_id (priv->factory, priv->id,
megaphone_applet_got_contact_cb,
NULL, NULL, G_OBJECT (applet));
}
static void
megaphone_applet_preferences_response_cb (GtkWidget *dialog,
gint response,
MegaphoneApplet *applet)
{
if (response == GTK_RESPONSE_ACCEPT) {
EmpathyContactListView *contact_list;
EmpathyContact *contact;
/* Retrieve the selected contact, if any and set it up in gconf.
* GConf will notify us from the change and we will adjust ourselves */
contact_list = g_object_get_data (G_OBJECT (dialog), "contact-list");
contact = empathy_contact_list_view_dup_selected (contact_list);
if (contact) {
EmpathyAccount *account;
const gchar *account_id;
const gchar *contact_id;
gchar *str;
account = empathy_contact_get_account (contact);
account_id = empathy_account_get_unique_name (account);
contact_id = empathy_contact_get_id (contact);
str = g_strconcat (account_id, ":", contact_id, NULL);
panel_applet_gconf_set_string (PANEL_APPLET (applet),
"avatar_token", "",
NULL);
panel_applet_gconf_set_string (PANEL_APPLET (applet),
"contact_id", str,
NULL);
g_free (str);
g_object_unref (contact);
}
}
gtk_widget_destroy (dialog);
}
static void
megaphone_applet_show_preferences (MegaphoneApplet *applet)
{
GtkWidget *dialog;
GtkWidget *scroll;
EmpathyContactListView *contact_list;
EmpathyContactListStore *contact_store;
EmpathyContactManager *contact_manager;
dialog = gtk_dialog_new_with_buttons (_("Select contact..."),
NULL, 0,
GTK_STOCK_CANCEL,
GTK_RESPONSE_REJECT,
GTK_STOCK_OK,
GTK_RESPONSE_ACCEPT,
NULL);
/* Show all contacts, even offline and sort alphabetically */
contact_manager = empathy_contact_manager_dup_singleton ();
contact_store = empathy_contact_list_store_new (EMPATHY_CONTACT_LIST (contact_manager));
g_object_set (contact_store,
"is-compact", TRUE,
"show-avatars", TRUE,
"show-offline", TRUE,
"sort-criterium", EMPATHY_CONTACT_LIST_STORE_SORT_NAME,
NULL);
contact_list = empathy_contact_list_view_new (contact_store,
EMPATHY_CONTACT_LIST_FEATURE_NONE,
EMPATHY_CONTACT_FEATURE_NONE);
g_object_unref (contact_manager);
g_object_unref (contact_store);
gtk_widget_show (GTK_WIDGET (contact_list));
gtk_window_set_default_size (GTK_WINDOW (dialog), 300, 500);
scroll = gtk_scrolled_window_new (NULL, NULL);
gtk_container_add (GTK_CONTAINER (scroll), GTK_WIDGET (contact_list));
gtk_container_add (GTK_CONTAINER (gtk_dialog_get_content_area (GTK_DIALOG (dialog))), scroll);
gtk_widget_show (scroll);
g_object_set_data (G_OBJECT (dialog), "contact-list", contact_list);
g_signal_connect (dialog, "response",
G_CALLBACK (megaphone_applet_preferences_response_cb),
applet);
gtk_widget_show (dialog);
}
static gboolean
megaphone_applet_button_press_event_cb (GtkWidget *widget,
GdkEventButton *event,
MegaphoneApplet *applet)
{
MegaphoneAppletPriv *priv = GET_PRIV (applet);
/* Only react on left-clicks */
if (event->button != 1 || event->type != GDK_BUTTON_PRESS) {
return FALSE;
}
/* If the contact is unavailable we display the preferences dialog */
if (priv->contact == NULL) {
megaphone_applet_show_preferences (applet);
return TRUE;
}
DEBUG ("Requesting text channel for contact %s (%d)",
empathy_contact_get_id (priv->contact),
empathy_contact_get_handle (priv->contact));
empathy_dispatcher_chat_with_contact (priv->contact, NULL, NULL);
return TRUE;
}
static void
megaphone_applet_size_allocate_cb (GtkWidget *widget,
GtkAllocation *allocation,
MegaphoneApplet *applet)
{
MegaphoneAppletPriv *priv = GET_PRIV (applet);
gint size;
PanelAppletOrient orient;
orient = panel_applet_get_orient (PANEL_APPLET (widget));
if (orient == PANEL_APPLET_ORIENT_LEFT ||
orient == PANEL_APPLET_ORIENT_RIGHT) {
size = allocation->width;
} else {
size = allocation->height;
}
if (size != priv->image_size) {
priv->image_size = size;
megaphone_applet_update_icon (applet);
}
}
static void
megaphone_applet_finalize (GObject *object)
{
MegaphoneAppletPriv *priv = GET_PRIV (object);
if (priv->contact) {
g_object_unref (priv->contact);
}
if (priv->factory) {
g_object_unref (priv->factory);
}
if (priv->account_manager) {
g_signal_handlers_disconnect_by_func (priv->account_manager,
megaphone_applet_new_connection_cb, object);
g_object_unref (priv->account_manager);
}
if (priv->gconf_cnxn != 0) {
gconf_client_notify_remove (priv->gconf, priv->gconf_cnxn);
}
g_object_unref (priv->gconf);
g_free (priv->id);
G_OBJECT_CLASS (megaphone_applet_parent_class)->finalize (object);
}
static void
megaphone_applet_class_init (MegaphoneAppletClass *class)
{
GObjectClass *object_class;
object_class = G_OBJECT_CLASS (class);
object_class->finalize = megaphone_applet_finalize;
g_type_class_add_private (object_class, sizeof (MegaphoneAppletPriv));
empathy_gtk_init ();
}
static void
megaphone_applet_init (MegaphoneApplet *applet)
{
MegaphoneAppletPriv *priv = G_TYPE_INSTANCE_GET_PRIVATE (applet,
MEGAPHONE_TYPE_APPLET, MegaphoneAppletPriv);
applet->priv = priv;
priv->gconf = gconf_client_get_default ();
priv->account_manager = empathy_account_manager_dup_singleton ();
g_signal_connect (priv->account_manager, "new-connection",
G_CALLBACK (megaphone_applet_new_connection_cb), applet);
/* Image holds the contact avatar */
priv->image = gtk_image_new ();
gtk_widget_show (priv->image);
gtk_container_add (GTK_CONTAINER (applet), priv->image);
/* We want transparency */
panel_applet_set_flags (PANEL_APPLET (applet), PANEL_APPLET_EXPAND_MINOR);
panel_applet_set_background_widget (PANEL_APPLET (applet), GTK_WIDGET (applet));
/* Listen for clicks on the applet to dispatch a channel */
g_signal_connect (applet, "button-press-event",
G_CALLBACK (megaphone_applet_button_press_event_cb),
applet);
/* Allow to resize our avatar when needed */
g_signal_connect (applet, "size-allocate",
G_CALLBACK (megaphone_applet_size_allocate_cb),
applet);
}
static void
megaphone_applet_set_contact (MegaphoneApplet *applet,
const gchar *str)
{
MegaphoneAppletPriv *priv = GET_PRIV (applet);
TpConnection *connection;
gchar **strv = NULL;
DEBUG ("Setting new contact %s", str);
/* Release old contact, if any */
if (priv->contact) {
g_signal_handlers_disconnect_by_func (priv->contact,
megaphone_applet_update_contact,
applet);
g_object_unref (priv->contact),
priv->contact = NULL;
}
if (priv->account) {
g_object_unref (priv->account),
priv->account = NULL;
}
if (priv->factory) {
g_object_unref (priv->factory),
priv->factory = NULL;
}
/* Lookup the new contact */
if (str) {
strv = g_strsplit (str, ":", 2);
if (g_strv_length (strv) == 2) {
priv->account = empathy_account_manager_get_account (
priv->account_manager, strv[0]);
priv->id = strv[1];
g_free (strv[0]);
g_free (strv);
} else {
g_strfreev (strv);
}
}
if (priv->account) {
g_object_ref (priv->account);
connection = empathy_account_get_connection (priv->account);
if (connection) {
megaphone_applet_new_connection_cb (priv->account_manager,
connection, priv->account, applet);
}
}
}
static void
megaphone_applet_information_cb (BonoboUIComponent *uic,
MegaphoneApplet *applet,
const gchar *verb_name)
{
MegaphoneAppletPriv *priv = GET_PRIV (applet);
/* FIXME: We should grey out the menu item if there are no available contact */
if (priv->contact) {
empathy_contact_information_dialog_show (priv->contact, NULL);
}
}
static void
megaphone_applet_preferences_cb (BonoboUIComponent *uic,
MegaphoneApplet *applet,
const gchar *verb_name)
{
megaphone_applet_show_preferences (applet);
}
static void
megaphone_applet_gconf_notify_cb (GConfClient *client,
guint cnxn_id,
GConfEntry *entry,
MegaphoneApplet *applet)
{
const gchar *key;
GConfValue *value;
key = gconf_entry_get_key (entry);
value = gconf_entry_get_value (entry);
DEBUG ("GConf notification for key '%s'", key);
if (value && g_str_has_suffix (key, "/contact_id")) {
megaphone_applet_set_contact (applet,
gconf_value_get_