aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavyd Madeley <davyd@madeley.id.au>2009-04-21 09:50:45 +0800
committerDavyd Madeley <davyd@madeley.id.au>2009-04-21 09:50:45 +0800
commit225661fe0ac22a4d8daa7f4e9f33b5fd3c5660c9 (patch)
tree0ad0902e304c772750abc4751343bc84773290d6
parent161c7f5800a89344fb65163b1e9c49ea7585cadf (diff)
downloadgsoc2013-empathy-225661fe0ac22a4d8daa7f4e9f33b5fd3c5660c9.tar
gsoc2013-empathy-225661fe0ac22a4d8daa7f4e9f33b5fd3c5660c9.tar.gz
gsoc2013-empathy-225661fe0ac22a4d8daa7f4e9f33b5fd3c5660c9.tar.bz2
gsoc2013-empathy-225661fe0ac22a4d8daa7f4e9f33b5fd3c5660c9.tar.lz
gsoc2013-empathy-225661fe0ac22a4d8daa7f4e9f33b5fd3c5660c9.tar.xz
gsoc2013-empathy-225661fe0ac22a4d8daa7f4e9f33b5fd3c5660c9.tar.zst
gsoc2013-empathy-225661fe0ac22a4d8daa7f4e9f33b5fd3c5660c9.zip
Reliably set favourite-star
-rw-r--r--libempathy-gtk/empathy-presence-chooser.c78
-rw-r--r--src/empathy-main-window.c6
2 files changed, 53 insertions, 31 deletions
diff --git a/libempathy-gtk/empathy-presence-chooser.c b/libempathy-gtk/empathy-presence-chooser.c
index d5dc1880f..39d4e0676 100644
--- a/libempathy-gtk/empathy-presence-chooser.c
+++ b/libempathy-gtk/empathy-presence-chooser.c
@@ -267,41 +267,63 @@ presence_chooser_get_entry_type (EmpathyPresenceChooser *self)
return type;
}
+static gboolean
+presence_chooser_is_preset (EmpathyPresenceChooser *self)
+{
+ EmpathyPresenceChooserPriv *priv = GET_PRIV (self);
+ McPresence state;
+ const char *status;
+ GList *presets, *l;
+ gboolean match = FALSE;
+
+ state = empathy_idle_get_state (priv->idle);
+ status = empathy_idle_get_status (priv->idle);
+
+ presets = empathy_status_presets_get (state, -1);
+ for (l = presets; l; l = l->next) {
+ char *preset = (char *) l->data;
+
+ if (!strcmp (status, preset)) {
+ match = TRUE;
+ break;
+ }
+ }
+
+ g_list_free (presets);
+
+ DEBUG ("is_preset(%i, %s) = %i\n", state, status, match);
+
+ return match;
+}
+
static void
presence_chooser_set_favourite_icon (EmpathyPresenceChooser *self)
{
- EmpathyPresenceChooserPriv *priv = GET_PRIV (self);
GtkWidget *entry;
PresenceChooserEntryType type;
entry = gtk_bin_get_child (GTK_BIN (self));
type = presence_chooser_get_entry_type (self);
- /* debug */
- g_print ("type = %i\n", type);
- const char *status = empathy_idle_get_status (priv->idle);
- g_print ("STATUS = '%s'", status);
- if (type == ENTRY_TYPE_CUSTOM) g_print ("(Custom)");
- g_print ("\n");
- /* - */
-
- if (type == ENTRY_TYPE_CUSTOM) {
- /* custom entries can be favourited */
- gtk_entry_set_icon_from_icon_name (GTK_ENTRY (entry),
- GTK_ENTRY_ICON_SECONDARY,
- "empathy-unstarred");
- gtk_entry_set_icon_tooltip_text (GTK_ENTRY (entry),
- GTK_ENTRY_ICON_SECONDARY,
- _("Click to make this status a favourite"));
- }
- else if (type == ENTRY_TYPE_SAVED) {
- /* saved entries can be removed from the list */
- gtk_entry_set_icon_from_icon_name (GTK_ENTRY (entry),
+ if (type == ENTRY_TYPE_CUSTOM || type == ENTRY_TYPE_SAVED) {
+ if (presence_chooser_is_preset (self)) {
+ /* saved entries can be removed from the list */
+ gtk_entry_set_icon_from_icon_name (GTK_ENTRY (entry),
GTK_ENTRY_ICON_SECONDARY,
"empathy-starred");
- gtk_entry_set_icon_tooltip_text (GTK_ENTRY (entry),
+ gtk_entry_set_icon_tooltip_text (GTK_ENTRY (entry),
GTK_ENTRY_ICON_SECONDARY,
_("Click to remove this status as a favourite"));
+ }
+ else {
+ /* custom entries can be favourited */
+ gtk_entry_set_icon_from_icon_name (GTK_ENTRY (entry),
+ GTK_ENTRY_ICON_SECONDARY,
+ "empathy-unstarred");
+ gtk_entry_set_icon_tooltip_text (GTK_ENTRY (entry),
+ GTK_ENTRY_ICON_SECONDARY,
+ _("Click to make this status a favourite"));
+ }
}
else {
/* built-in entries cannot be favourited */
@@ -440,16 +462,16 @@ presence_chooser_entry_icon_release_cb (EmpathyPresenceChooser *self,
state = empathy_idle_get_state (priv->idle);
status = empathy_idle_get_status (priv->idle);
- if (type == ENTRY_TYPE_CUSTOM) {
- /* save the entry */
- DEBUG ("SAVING PRESET (%i, %s)\n", state, status);
- empathy_status_presets_set_last (state, status);
- }
- else if (type == ENTRY_TYPE_SAVED) {
+ if (presence_chooser_is_preset (self)) {
/* remove the entry */
DEBUG ("REMOVING PRESET (%i, %s)\n", state, status);
empathy_status_presets_remove (state, status);
}
+ else {
+ /* save the entry */
+ DEBUG ("SAVING PRESET (%i, %s)\n", state, status);
+ empathy_status_presets_set_last (state, status);
+ }
/* update the icon */
presence_chooser_set_favourite_icon (self);
diff --git a/src/empathy-main-window.c b/src/empathy-main-window.c
index 0f09a2a36..6c5f1fa2c 100644
--- a/src/empathy-main-window.c
+++ b/src/empathy-main-window.c
@@ -1186,6 +1186,9 @@ empathy_main_window_show (void)
gtk_widget_hide (window->edit_context);
gtk_widget_hide (window->edit_context_separator);
+ /* Set up contact list. */
+ empathy_status_presets_get_all ();
+
/* Set up presence chooser */
window->presence_chooser = empathy_presence_chooser_new ();
gtk_widget_show (window->presence_chooser);
@@ -1216,9 +1219,6 @@ empathy_main_window_show (void)
gtk_toolbar_insert (GTK_TOOLBAR (window->presence_toolbar), item, -1);
gtk_widget_show (GTK_WIDGET (item));
- /* Set up contact list. */
- empathy_status_presets_get_all ();
-
list_iface = EMPATHY_CONTACT_LIST (empathy_contact_manager_dup_singleton ());
monitor = empathy_contact_list_get_monitor (list_iface);
window->list_store = empathy_contact_list_store_new (list_iface);