*/
#include "config.h"
-
-#include <string.h>
-#include <stdlib.h>
+#include "empathy-presence-chooser.h"
#include <glib/gi18n-lib.h>
-#include <gtk/gtk.h>
-#include <gdk/gdkkeysyms.h>
+#include <tp-account-widgets/tpaw-utils.h>
-#include <telepathy-glib/account-manager.h>
-#include <telepathy-glib/util.h>
-
-#include <libempathy/empathy-connectivity.h>
-#include <libempathy/empathy-presence-manager.h>
-#include <libempathy/empathy-utils.h>
-#include <libempathy/empathy-status-presets.h>
+#include "empathy-presence-manager.h"
+#include "empathy-status-presets.h"
+#include "empathy-utils.h"
#define DEBUG_FLAG EMPATHY_DEBUG_OTHER
-#include <libempathy/empathy-debug.h>
+#include "empathy-debug.h"
#include "empathy-ui-utils.h"
-#include "empathy-images.h"
#include "empathy-presence-chooser.h"
#include "empathy-status-preset-dialog.h"
* Widget which extends #GtkComboBoxEntry to change presence.
*/
-/* Flashing delay for icons (milliseconds). */
-#define FLASH_TIMEOUT 500
-
#define GET_PRIV(obj) EMPATHY_GET_PRIV (obj, EmpathyPresenceChooser)
/* For custom message dialog */
typedef struct {
EmpathyPresenceManager *presence_mgr;
- EmpathyConnectivity *connectivity;
+ GNetworkMonitor *connectivity;
gboolean editing_status;
int block_set_editing;
PresenceChooserEntryType previous_type;
TpAccountManager *account_manager;
- GdkPixbuf *not_favorite_pixbuf;
} EmpathyPresenceChooserPriv;
/* States to be listed in the menu.
state = tp_account_manager_get_most_available_presence (
priv->account_manager, NULL, &tmp);
- if (EMP_STR_EMPTY (tmp)) {
+ if (TPAW_STR_EMPTY (tmp)) {
/* no message, use the default message */
g_free (tmp);
tmp = g_strdup (empathy_presence_get_default_message (state));
static void
presence_chooser_set_favorite_icon (EmpathyPresenceChooser *self)
{
- EmpathyPresenceChooserPriv *priv = GET_PRIV (self);
GtkWidget *entry;
PresenceChooserEntryType type;
/* saved entries can be removed from the list */
gtk_entry_set_icon_from_icon_name (GTK_ENTRY (entry),
GTK_ENTRY_ICON_SECONDARY,
- "emblem-favorite");
+ "starred-symbolic");
gtk_entry_set_icon_tooltip_text (GTK_ENTRY (entry),
GTK_ENTRY_ICON_SECONDARY,
_("Click to remove this status as a favorite"));
}
- else if (priv->not_favorite_pixbuf != NULL) {
+ else {
/* custom entries can be favorited */
- gtk_entry_set_icon_from_pixbuf (GTK_ENTRY (entry),
+ gtk_entry_set_icon_from_icon_name (GTK_ENTRY (entry),
GTK_ENTRY_ICON_SECONDARY,
- priv->not_favorite_pixbuf);
+ "non-starred-symbolic");
gtk_entry_set_icon_tooltip_text (GTK_ENTRY (entry),
GTK_ENTRY_ICON_SECONDARY,
_("Click to make this status a favorite"));
entry = gtk_bin_get_child (GTK_BIN (self));
if (editing) {
+ gchar *tooltip_text;
+ gchar *status;
+
priv->editing_status = TRUE;
+ get_state_and_status (self, &status);
+ /* Translators: %s is a status message like 'At the pub' for example */
+ tooltip_text = g_strdup_printf (_("<b>Current message: %s</b>\n"
+ "<small><i>Press Enter to set the new message or Esc to cancel.</i></small>"),
+ status);
+ gtk_widget_set_tooltip_markup (entry, tooltip_text);
gtk_entry_set_icon_from_stock (GTK_ENTRY (entry),
GTK_ENTRY_ICON_SECONDARY,
GTK_STOCK_OK);
gtk_entry_set_icon_sensitive (GTK_ENTRY (entry),
GTK_ENTRY_ICON_PRIMARY,
FALSE);
+ g_free (status);
+ g_free (tooltip_text);
} else {
GtkWidget *window;
EmpathyPresenceChooserPriv *priv = GET_PRIV (self);
GtkWidget *entry;
const char *icon_name;
+ const gchar *status_tooltip;
entry = gtk_bin_get_child (GTK_BIN (self));
gtk_entry_set_icon_from_icon_name (GTK_ENTRY (entry),
GTK_ENTRY_ICON_PRIMARY,
icon_name);
- gtk_entry_set_text (GTK_ENTRY (entry), status == NULL ? "" : status);
+ status_tooltip = status == NULL ? "" : status;
+ gtk_entry_set_text (GTK_ENTRY (entry), status_tooltip);
+ gtk_widget_set_tooltip_text (GTK_WIDGET (entry), status_tooltip);
presence_chooser_set_favorite_icon (self);
priv->block_changed--;
GList *accounts, *l;
GError *error = NULL;
- if (!tp_account_manager_prepare_finish (manager, result, &error)) {
+ if (!tp_proxy_prepare_finish (manager, result, &error)) {
DEBUG ("Failed to prepare account manager: %s", error->message);
g_error_free (error);
return;
}
- accounts = tp_account_manager_get_valid_accounts (manager);
+ accounts = tp_account_manager_dup_valid_accounts (manager);
for (l = accounts ; l != NULL ; l = g_list_next (l)) {
TpAccount *a = TP_ACCOUNT (l->data);
}
}
- g_list_free (accounts);
+ g_list_free_full (accounts, g_object_unref);
- if (!empathy_connectivity_is_online (priv->connectivity))
+ if (!g_network_monitor_get_network_available (priv->connectivity))
sensitive = FALSE;
gtk_widget_set_sensitive (GTK_WIDGET (chooser), sensitive);
{
EmpathyPresenceChooserPriv *priv = GET_PRIV (chooser);
- tp_account_manager_prepare_async (priv->account_manager, NULL,
+ tp_proxy_prepare_async (priv->account_manager, NULL,
update_sensitivity_am_prepared_cb,
chooser);
}
}
static void
-presence_chooser_connectivity_state_change (EmpathyConnectivity *connectivity,
+presence_chooser_network_change (GNetworkMonitor *connectivity,
gboolean new_online,
EmpathyPresenceChooser *chooser)
{
presence_chooser_update_sensitivity (chooser);
}
-/* Create a greyed version of the 'favorite' icon */
-static GdkPixbuf *
-create_not_favorite_pixbuf (void)
-{
- GdkPixbuf *favorite, *result;
-
- favorite = empathy_pixbuf_from_icon_name ("emblem-favorite",
- GTK_ICON_SIZE_MENU);
-
- if (favorite == NULL)
- return NULL;
-
- result = gdk_pixbuf_copy (favorite);
- gdk_pixbuf_saturate_and_pixelate (favorite, result, 1.0, TRUE);
-
- g_object_unref (favorite);
- return result;
-}
-
-static void
-icon_theme_changed_cb (GtkIconTheme *icon_theme,
- EmpathyPresenceChooser *self)
-{
- EmpathyPresenceChooserPriv *priv = GET_PRIV (self);
-
- /* Theme has changed, recreate the not-favorite icon */
- if (priv->not_favorite_pixbuf != NULL)
- g_object_unref (priv->not_favorite_pixbuf);
- priv->not_favorite_pixbuf = create_not_favorite_pixbuf ();
-
- /* Update the icon */
- presence_chooser_set_favorite_icon (self);
-}
-
static void
empathy_presence_chooser_init (EmpathyPresenceChooser *chooser)
{
EMPATHY_TYPE_PRESENCE_CHOOSER, EmpathyPresenceChooserPriv);
chooser->priv = priv;
-
- /* Create the not-favorite icon */
- priv->not_favorite_pixbuf = create_not_favorite_pixbuf ();
}
static void
EmpathyPresenceChooserPriv *priv = chooser->priv;
GtkWidget *entry;
GtkCellRenderer *renderer;
-
- tp_g_signal_connect_object (gtk_icon_theme_get_default (), "changed",
- G_CALLBACK (icon_theme_changed_cb),
- chooser, 0);
+ const gchar *status_tooltip;
presence_chooser_create_model (chooser);
G_CALLBACK (presence_chooser_account_manager_account_changed_cb),
chooser, 0);
- /* FIXME: this string sucks */
- gtk_widget_set_tooltip_text (GTK_WIDGET (chooser),
- _("Set your presence and current status"));
+ status_tooltip = gtk_entry_get_text (GTK_ENTRY (entry));
+ gtk_widget_set_tooltip_text (GTK_WIDGET (chooser), status_tooltip);
+
+ priv->connectivity = g_network_monitor_get_default ();
+ g_object_ref (priv->connectivity);
- priv->connectivity = empathy_connectivity_dup_singleton ();
tp_g_signal_connect_object (priv->connectivity,
- "state-change",
- G_CALLBACK (presence_chooser_connectivity_state_change),
+ "network-changed",
+ G_CALLBACK (presence_chooser_network_change),
chooser, 0);
presence_chooser_update_sensitivity (chooser);
g_object_unref (priv->presence_mgr);
g_object_unref (priv->connectivity);
- if (priv->not_favorite_pixbuf != NULL)
- g_object_unref (priv->not_favorite_pixbuf);
G_OBJECT_CLASS (empathy_presence_chooser_parent_class)->finalize (object);
}
gtk_entry_set_icon_from_icon_name (GTK_ENTRY (entry),
GTK_ENTRY_ICON_PRIMARY,
empathy_icon_name_for_presence (state));
+ gtk_widget_set_tooltip_text (GTK_WIDGET (entry), status);
entry = gtk_bin_get_child (GTK_BIN (chooser));
gtk_editable_set_editable (GTK_EDITABLE (entry),