1 /* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
3 * Copyright (C) 2005-2007 Imendio AB
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License as
7 * published by the Free Software Foundation; either version 2 of the
8 * License, or (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * General Public License for more details.
15 * You should have received a copy of the GNU General Public
16 * License along with this program; if not, write to the
17 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 * Boston, MA 02111-1307, USA.
20 * Authors: Richard Hult <richard@imendio.com>
21 * Martyn Russell <martyn@imendio.com>
22 * Xavier Claessens <xclaesse@gmail.com>
30 #include <glib/gi18n-lib.h>
32 #include <glade/glade.h>
33 #include <gdk/gdkkeysyms.h>
35 #include <telepathy-glib/util.h>
36 #include <libmissioncontrol/mc-enum-types.h>
38 #include <libempathy/empathy-idle.h>
39 #include <libempathy/empathy-utils.h>
40 #include <libempathy/empathy-status-presets.h>
42 // FIXME - what's the correct debug flag?
43 #define DEBUG_FLAG EMPATHY_DEBUG_DISPATCHER
44 #include <libempathy/empathy-debug.h>
46 #include "empathy-ui-utils.h"
47 #include "empathy-images.h"
48 #include "empathy-presence-chooser.h"
50 /* Flashing delay for icons (milliseconds). */
51 #define FLASH_TIMEOUT 500
53 #define GET_PRIV(obj) EMPATHY_GET_PRIV (obj, EmpathyPresenceChooser)
57 gboolean editing_status;
58 int block_set_editing;
63 McPresence flash_state_1;
64 McPresence flash_state_2;
65 guint flash_timeout_id;
66 } EmpathyPresenceChooserPriv;
70 GtkWidget *checkbutton_save;
71 GtkWidget *comboboxentry_message;
72 GtkWidget *entry_message;
73 GtkWidget *combobox_status;
74 GtkTreeModel *model_status;
75 } CustomMessageDialog;
84 static CustomMessageDialog *message_dialog = NULL;
85 /* States to be listed in the menu.
86 * Each state has a boolean telling if it can have custom message */
87 static guint states[] = {MC_PRESENCE_AVAILABLE, TRUE,
88 MC_PRESENCE_DO_NOT_DISTURB, TRUE,
89 MC_PRESENCE_AWAY, TRUE,
90 MC_PRESENCE_HIDDEN, FALSE,
91 MC_PRESENCE_OFFLINE, FALSE};
93 static void presence_chooser_finalize (GObject *object);
94 static void presence_chooser_presence_changed_cb (EmpathyPresenceChooser *chooser);
95 static gboolean presence_chooser_flash_timeout_cb (EmpathyPresenceChooser *chooser);
96 static void presence_chooser_flash_start (EmpathyPresenceChooser *chooser,
99 static void presence_chooser_flash_stop (EmpathyPresenceChooser *chooser,
101 static void presence_chooser_menu_add_item (GtkWidget *menu,
104 static void presence_chooser_noncustom_activate_cb (GtkWidget *item,
106 static void presence_chooser_set_state (McPresence state,
107 const gchar *status);
108 static void presence_chooser_custom_activate_cb (GtkWidget *item,
110 static void presence_chooser_dialog_show (GtkWindow *parent);
112 G_DEFINE_TYPE (EmpathyPresenceChooser, empathy_presence_chooser, GTK_TYPE_COMBO_BOX_ENTRY);
115 empathy_presence_chooser_class_init (EmpathyPresenceChooserClass *klass)
117 GObjectClass *object_class = G_OBJECT_CLASS (klass);
119 object_class->finalize = presence_chooser_finalize;
121 g_type_class_add_private (object_class, sizeof (EmpathyPresenceChooserPriv));
141 static GtkTreeModel *
144 GtkListStore *store = gtk_list_store_new (N_COLUMNS,
145 G_TYPE_STRING, /* COL_STATE_ICON_NAME */
146 MC_TYPE_PRESENCE, /* COL_STATE */
147 G_TYPE_STRING, /* COL_STATUS_TEXT */
148 G_TYPE_STRING, /* COL_DISPLAY_MARKUP */
149 G_TYPE_INT); /* COL_TYPE */
154 for (i = 0; i < G_N_ELEMENTS (states); i += 2) {
157 const char *status = empathy_presence_get_default_message (states[i]);
158 const char *icon_name = empathy_icon_name_for_presence (states[i]);
160 gtk_list_store_append (store, &iter);
161 gtk_list_store_set (store, &iter,
162 COL_STATE_ICON_NAME, icon_name,
163 COL_STATE, states[i],
164 COL_STATUS_TEXT, status,
165 COL_DISPLAY_MARKUP, status,
166 COL_TYPE, ENTRY_TYPE_BUILTIN,
170 /* Set custom messages if wanted */
171 list = empathy_status_presets_get (states[i], 5);
172 for (l = list; l; l = l->next) {
173 gtk_list_store_append (store, &iter);
174 gtk_list_store_set (store, &iter,
175 COL_STATE_ICON_NAME, icon_name,
176 COL_STATE, states[i],
177 COL_STATUS_TEXT, l->data,
178 COL_DISPLAY_MARKUP, l->data,
179 COL_TYPE, ENTRY_TYPE_SAVED,
184 gtk_list_store_append (store, &iter);
185 gtk_list_store_set (store, &iter,
186 COL_STATE_ICON_NAME, icon_name,
187 COL_STATE, states[i],
189 COL_DISPLAY_MARKUP, "<i>Custom Message...</i>",
190 COL_TYPE, ENTRY_TYPE_CUSTOM,
196 return GTK_TREE_MODEL (store);
200 popup_shown_cb (GObject *self, GParamSpec *pspec, gpointer user_data)
203 g_object_get (self, "popup-shown", &shown, NULL);
207 GtkTreeModel *model = create_model ();
209 gtk_combo_box_set_model (GTK_COMBO_BOX (self), GTK_TREE_MODEL (model));
211 g_object_unref (model);
215 set_status_editing (EmpathyPresenceChooser *self, gboolean editing)
217 EmpathyPresenceChooserPriv *priv = GET_PRIV (self);
218 GtkWidget *entry = gtk_bin_get_child (GTK_BIN (self));
220 if (priv->block_set_editing) return;
224 priv->editing_status = TRUE;
225 gtk_entry_set_icon_from_stock (GTK_ENTRY (entry),
226 GTK_ENTRY_ICON_SECONDARY,
228 gtk_entry_set_icon_tooltip_text (GTK_ENTRY (entry),
229 GTK_ENTRY_ICON_SECONDARY,
231 gtk_entry_set_icon_sensitive (GTK_ENTRY (entry),
232 GTK_ENTRY_ICON_PRIMARY,
237 gtk_entry_set_icon_from_stock (GTK_ENTRY (entry),
238 GTK_ENTRY_ICON_SECONDARY,
240 gtk_entry_set_icon_tooltip_text (GTK_ENTRY (entry),
241 GTK_ENTRY_ICON_SECONDARY,
243 gtk_entry_set_icon_sensitive (GTK_ENTRY (entry),
244 GTK_ENTRY_ICON_PRIMARY,
247 // FIXME - move the focus somewhere
249 priv->editing_status = FALSE;
254 mc_set_custom_state (EmpathyPresenceChooser *self)
256 EmpathyPresenceChooserPriv *priv = GET_PRIV (self);
257 GtkWidget *entry = gtk_bin_get_child (GTK_BIN (self));
259 /* update the status with MC */
260 const char *status = gtk_entry_get_text (GTK_ENTRY (entry));
261 DEBUG ("Sending state to MC-> %s (%s)\n",
262 g_enum_get_value (g_type_class_peek (MC_TYPE_PRESENCE),
263 priv->state)->value_name,
265 empathy_idle_set_presence (priv->idle, priv->state, status);
269 ui_set_custom_state (EmpathyPresenceChooser *self,
273 EmpathyPresenceChooserPriv *priv = GET_PRIV (self);
274 GtkWidget *entry = gtk_bin_get_child (GTK_BIN (self));
275 const char *icon_name;
277 priv->block_set_editing++;
278 priv->block_changed++;
280 icon_name = empathy_icon_name_for_presence (state);
281 gtk_entry_set_icon_from_icon_name (GTK_ENTRY (entry),
282 GTK_ENTRY_ICON_PRIMARY,
284 gtk_entry_set_text (GTK_ENTRY (entry), status);
286 priv->block_changed--;
287 priv->block_set_editing--;
291 entry_icon_release_cb (EmpathyPresenceChooser *self,
292 GtkEntryIconPosition icon_pos,
296 set_status_editing (self, FALSE);
297 mc_set_custom_state (self);
301 entry_activate_cb (EmpathyPresenceChooser *self,
304 set_status_editing (self, FALSE);
305 mc_set_custom_state (self);
309 entry_key_press_event_cb (EmpathyPresenceChooser *self,
313 EmpathyPresenceChooserPriv *priv = GET_PRIV (self);
315 if (priv->editing_status && event->keyval == GDK_Escape)
317 /* the user pressed Escape, undo the editing */
318 set_status_editing (self, FALSE);
319 presence_chooser_presence_changed_cb (self);
324 return FALSE; /* send this event elsewhere */
328 changed_cb (GtkComboBox *self, gpointer user_data)
330 EmpathyPresenceChooserPriv *priv = GET_PRIV (self);
332 if (priv->block_changed) return;
338 GtkTreeModel *model = gtk_combo_box_get_model (self);
339 if (!gtk_combo_box_get_active_iter (self, &iter))
341 /* the combo is being edited to a custom entry */
342 if (!priv->editing_status)
344 set_status_editing (EMPATHY_PRESENCE_CHOOSER (self), TRUE);
349 gtk_tree_model_get (model, &iter,
350 COL_STATE_ICON_NAME, &icon_name,
351 COL_STATE, &priv->state,
355 GtkWidget *entry = gtk_bin_get_child (GTK_BIN (self));
356 gtk_entry_set_icon_from_icon_name (GTK_ENTRY (entry),
357 GTK_ENTRY_ICON_PRIMARY,
360 if (type == ENTRY_TYPE_CUSTOM)
363 gtk_widget_grab_focus (entry);
364 set_status_editing (EMPATHY_PRESENCE_CHOOSER (self), TRUE);
369 /* just in case we were setting a new status when
370 * things were changed */
371 set_status_editing (EMPATHY_PRESENCE_CHOOSER (self), FALSE);
373 gtk_tree_model_get (model, &iter,
374 COL_STATUS_TEXT, &status,
377 empathy_idle_set_presence (priv->idle, priv->state, status);
386 empathy_presence_chooser_init (EmpathyPresenceChooser *chooser)
388 EmpathyPresenceChooserPriv *priv = G_TYPE_INSTANCE_GET_PRIVATE (chooser,
389 EMPATHY_TYPE_PRESENCE_CHOOSER, EmpathyPresenceChooserPriv);
391 chooser->priv = priv;
393 GtkTreeModel *model = create_model ();
395 gtk_combo_box_set_model (GTK_COMBO_BOX (chooser), GTK_TREE_MODEL (model));
396 gtk_combo_box_entry_set_text_column (GTK_COMBO_BOX_ENTRY (chooser), COL_STATUS_TEXT);
398 GtkWidget *entry = gtk_bin_get_child (GTK_BIN (chooser));
399 gtk_entry_set_icon_activatable (GTK_ENTRY (entry),
400 GTK_ENTRY_ICON_PRIMARY, FALSE);
401 g_signal_connect_object (entry, "icon-release",
402 G_CALLBACK (entry_icon_release_cb), chooser,
404 g_signal_connect_object (entry, "activate",
405 G_CALLBACK (entry_activate_cb), chooser,
407 g_signal_connect_object (entry, "key-press-event",
408 G_CALLBACK (entry_key_press_event_cb), chooser,
410 // FIXME - should this also happen when the user presses TAB ?
412 GtkCellRenderer *renderer;
413 gtk_cell_layout_clear (GTK_CELL_LAYOUT (chooser));
415 renderer = gtk_cell_renderer_pixbuf_new ();
416 gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (chooser), renderer, FALSE);
417 gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (chooser), renderer,
418 "icon-name", COL_STATE_ICON_NAME,
420 g_object_set (renderer, "stock-size", GTK_ICON_SIZE_MENU, NULL);
422 renderer = gtk_cell_renderer_text_new ();
423 gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (chooser), renderer, TRUE);
424 gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (chooser), renderer,
425 "markup", COL_DISPLAY_MARKUP,
428 g_object_unref (model);
430 g_signal_connect (chooser, "notify::popup-shown",
431 G_CALLBACK (popup_shown_cb), NULL);
432 g_signal_connect (chooser, "changed",
433 G_CALLBACK (changed_cb), NULL);
435 priv->idle = empathy_idle_dup_singleton ();
436 presence_chooser_presence_changed_cb (chooser);
437 g_signal_connect_swapped (priv->idle, "notify",
438 G_CALLBACK (presence_chooser_presence_changed_cb),
441 g_object_set (chooser,
442 // FIXME: this string sucks
443 "tooltip-text", _("Set your presence and current status"),
448 presence_chooser_finalize (GObject *object)
450 EmpathyPresenceChooserPriv *priv;
452 priv = GET_PRIV (object);
454 if (priv->flash_timeout_id) {
455 g_source_remove (priv->flash_timeout_id);
458 g_signal_handlers_disconnect_by_func (priv->idle,
459 presence_chooser_presence_changed_cb,
461 g_object_unref (priv->idle);
463 G_OBJECT_CLASS (empathy_presence_chooser_parent_class)->finalize (object);
467 empathy_presence_chooser_new (void)
471 chooser = g_object_new (EMPATHY_TYPE_PRESENCE_CHOOSER, NULL);
477 presence_chooser_presence_changed_cb (EmpathyPresenceChooser *chooser)
479 EmpathyPresenceChooserPriv *priv;
481 McPresence flash_state;
484 priv = GET_PRIV (chooser);
486 priv->state = state = empathy_idle_get_state (priv->idle);
487 status = empathy_idle_get_status (priv->idle);
488 flash_state = empathy_idle_get_flash_state (priv->idle);
490 /* look through the model and attempt to find a matching state */
491 GtkTreeModel *model = gtk_combo_box_get_model (GTK_COMBO_BOX (chooser));
493 gboolean valid, match_state = FALSE, match = FALSE;
494 for (valid = gtk_tree_model_get_iter_first (model, &iter);
496 valid = gtk_tree_model_iter_next (model, &iter))
502 gtk_tree_model_get (model, &iter,
507 if (m_type == ENTRY_TYPE_CUSTOM)
511 else if (!match_state && state == m_state)
513 /* we are now in the section that can contain our
517 else if (match_state && state != m_state)
519 /* we have passed the section that can contain our
524 gtk_tree_model_get (model, &iter,
525 COL_STATUS_TEXT, &m_status,
528 match = !strcmp (status, m_status);
538 priv->block_changed++;
539 gtk_combo_box_set_active_iter (GTK_COMBO_BOX (chooser), &iter);
540 priv->block_changed--;
544 // FIXME - do we insert the match into the menu?
545 ui_set_custom_state (chooser, state, status);
548 if (flash_state != MC_PRESENCE_UNSET) {
549 presence_chooser_flash_start (chooser, state, flash_state);
551 presence_chooser_flash_stop (chooser, state);
556 presence_chooser_flash_timeout_cb (EmpathyPresenceChooser *chooser)
558 EmpathyPresenceChooserPriv *priv;
560 static gboolean on = FALSE;
562 priv = GET_PRIV (chooser);
565 state = priv->flash_state_1;
567 state = priv->flash_state_2;
570 GtkWidget *entry = gtk_bin_get_child (GTK_BIN (chooser));
571 gtk_entry_set_icon_from_icon_name (GTK_ENTRY (entry),
572 GTK_ENTRY_ICON_PRIMARY,
573 empathy_icon_name_for_presence (state));
581 presence_chooser_flash_start (EmpathyPresenceChooser *chooser,
585 EmpathyPresenceChooserPriv *priv;
587 g_return_if_fail (EMPATHY_IS_PRESENCE_CHOOSER (chooser));
589 priv = GET_PRIV (chooser);
591 priv->flash_state_1 = state_1;
592 priv->flash_state_2 = state_2;
594 if (!priv->flash_timeout_id) {
595 priv->flash_timeout_id = g_timeout_add (FLASH_TIMEOUT,
596 (GSourceFunc) presence_chooser_flash_timeout_cb,
602 presence_chooser_flash_stop (EmpathyPresenceChooser *chooser,
605 EmpathyPresenceChooserPriv *priv;
607 g_return_if_fail (EMPATHY_IS_PRESENCE_CHOOSER (chooser));
609 priv = GET_PRIV (chooser);
611 if (priv->flash_timeout_id) {
612 g_source_remove (priv->flash_timeout_id);
613 priv->flash_timeout_id = 0;
615 GtkWidget *entry = gtk_bin_get_child (GTK_BIN (chooser));
617 gtk_entry_set_icon_from_icon_name (GTK_ENTRY (entry),
618 GTK_ENTRY_ICON_PRIMARY,
619 empathy_icon_name_for_presence (state));
621 // FIXME - what does this do?
622 // priv->last_state = state;
626 empathy_presence_chooser_create_menu (void)
634 menu = gtk_menu_new ();
636 for (i = 0; i < G_N_ELEMENTS (states); i += 2) {
639 status = empathy_presence_get_default_message (states[i]);
640 presence_chooser_menu_add_item (menu,
645 /* Set custom messages if wanted */
646 list = empathy_status_presets_get (states[i], 5);
647 for (l = list; l; l = l->next) {
648 presence_chooser_menu_add_item (menu,
658 item = gtk_menu_item_new ();
659 gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
660 gtk_widget_show (item);
662 /* Custom messages */
663 item = gtk_image_menu_item_new_with_label (_("Custom messages..."));
664 image = gtk_image_new_from_stock (GTK_STOCK_EDIT, GTK_ICON_SIZE_MENU);
665 gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (item), image);
666 gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
667 gtk_widget_show (image);
668 gtk_widget_show (item);
670 g_signal_connect (item,
672 G_CALLBACK (presence_chooser_custom_activate_cb),
679 presence_chooser_menu_add_item (GtkWidget *menu,
685 const gchar *icon_name;
687 item = gtk_image_menu_item_new_with_label (str);
688 icon_name = empathy_icon_name_for_presence (state);
690 g_signal_connect (item, "activate",
691 G_CALLBACK (presence_chooser_noncustom_activate_cb),
694 image = gtk_image_new_from_icon_name (icon_name, GTK_ICON_SIZE_MENU);
695 gtk_widget_show (image);
697 gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (item), image);
698 gtk_widget_show (item);
700 g_object_set_data_full (G_OBJECT (item),
701 "status", g_strdup (str),
702 (GDestroyNotify) g_free);
704 g_object_set_data (G_OBJECT (item), "state", GINT_TO_POINTER (state));
706 gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
710 presence_chooser_noncustom_activate_cb (GtkWidget *item,
716 status = g_object_get_data (G_OBJECT (item), "status");
717 state = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (item), "state"));
719 presence_chooser_set_state (state, status);
723 presence_chooser_set_state (McPresence state,
728 idle = empathy_idle_dup_singleton ();
729 empathy_idle_set_presence (idle, state, status);
730 g_object_unref (idle);
734 presence_chooser_custom_activate_cb (GtkWidget *item,
737 presence_chooser_dialog_show (NULL);
741 presence_chooser_dialog_get_selected (CustomMessageDialog *dialog)
745 McPresence presence = LAST_MC_PRESENCE;
747 model = gtk_combo_box_get_model (GTK_COMBO_BOX (dialog->combobox_status));
748 if (gtk_combo_box_get_active_iter (GTK_COMBO_BOX (dialog->combobox_status), &iter)) {
749 gtk_tree_model_get (model, &iter,
750 COL_PRESENCE, &presence,
758 presence_chooser_dialog_status_changed_cb (GtkWidget *widget,
759 CustomMessageDialog *dialog)
763 McPresence presence = LAST_MC_PRESENCE;
766 presence = presence_chooser_dialog_get_selected (dialog);
768 store = gtk_list_store_new (1, G_TYPE_STRING);
769 messages = empathy_status_presets_get (presence, -1);
770 for (l = messages; l; l = l->next) {
771 gtk_list_store_append (store, &iter);
772 gtk_list_store_set (store, &iter, 0, l->data, -1);
775 gtk_entry_set_text (GTK_ENTRY (dialog->entry_message),
776 messages ? messages->data : "");
778 g_list_free (messages);
780 gtk_combo_box_set_model (GTK_COMBO_BOX (dialog->comboboxentry_message),
781 GTK_TREE_MODEL (store));
783 g_object_unref (store);
787 presence_chooser_dialog_message_changed_cb (GtkWidget *widget,
788 CustomMessageDialog *dialog)
793 gboolean found = FALSE;
795 presence = presence_chooser_dialog_get_selected (dialog);
796 text = gtk_entry_get_text (GTK_ENTRY (dialog->entry_message));
798 messages = empathy_status_presets_get (presence, -1);
799 for (l = messages; l; l = l->next) {
800 if (!tp_strdiff (text, l->data)) {
805 g_list_free (messages);
807 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (dialog->checkbutton_save),
812 presence_chooser_dialog_save_toggled_cb (GtkWidget *widget,
813 CustomMessageDialog *dialog)
819 active = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (dialog->checkbutton_save));
820 state = presence_chooser_dialog_get_selected (dialog);
821 text = gtk_entry_get_text (GTK_ENTRY (dialog->entry_message));
824 empathy_status_presets_set_last (state, text);
826 empathy_status_presets_remove (state, text);
831 presence_chooser_dialog_setup (CustomMessageDialog *dialog)
834 GtkCellRenderer *renderer;
838 store = gtk_list_store_new (COL_COUNT,
839 G_TYPE_STRING, /* Icon name */
840 G_TYPE_STRING, /* Label */
841 MC_TYPE_PRESENCE); /* Presence */
842 gtk_combo_box_set_model (GTK_COMBO_BOX (dialog->combobox_status),
843 GTK_TREE_MODEL (store));
845 renderer = gtk_cell_renderer_pixbuf_new ();
846 gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (dialog->combobox_status), renderer, FALSE);
847 gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (dialog->combobox_status), renderer,
848 "icon-name", COL_ICON,
850 g_object_set (renderer, "stock-size", GTK_ICON_SIZE_BUTTON, NULL);
852 renderer = gtk_cell_renderer_text_new ();
853 gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (dialog->combobox_status), renderer, TRUE);
854 gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (dialog->combobox_status), renderer,
858 for (i = 0; i < G_N_ELEMENTS (states); i += 2) {
863 gtk_list_store_append (store, &iter);
864 gtk_list_store_set (store, &iter,
865 COL_ICON, empathy_icon_name_for_presence (states[i]),
866 COL_LABEL, empathy_presence_get_default_message (states[i]),
867 COL_PRESENCE, states[i],
871 gtk_combo_box_set_active (GTK_COMBO_BOX (dialog->combobox_status), 0);
875 presence_chooser_dialog_response_cb (GtkWidget *widget,
877 CustomMessageDialog *dialog)
879 if (response == GTK_RESPONSE_APPLY) {
883 state = presence_chooser_dialog_get_selected (dialog);
884 text = gtk_entry_get_text (GTK_ENTRY (dialog->entry_message));
886 presence_chooser_set_state (state, text);
889 gtk_widget_destroy (widget);
893 presence_chooser_dialog_destroy_cb (GtkWidget *widget,
894 CustomMessageDialog *dialog)
898 message_dialog = NULL;
902 presence_chooser_dialog_show (GtkWindow *parent)
907 if (message_dialog) {
908 gtk_window_present (GTK_WINDOW (message_dialog->dialog));
912 message_dialog = g_new0 (CustomMessageDialog, 1);
914 filename = empathy_file_lookup ("empathy-presence-chooser.glade",
916 glade = empathy_glade_get_file (filename,
917 "custom_message_dialog",
919 "custom_message_dialog", &message_dialog->dialog,
920 "checkbutton_save", &message_dialog->checkbutton_save,
921 "comboboxentry_message", &message_dialog->comboboxentry_message,
922 "combobox_status", &message_dialog->combobox_status,
926 empathy_glade_connect (glade,
928 "custom_message_dialog", "destroy", presence_chooser_dialog_destroy_cb,
929 "custom_message_dialog", "response", presence_chooser_dialog_response_cb,
930 "combobox_status", "changed", presence_chooser_dialog_status_changed_cb,
931 "checkbutton_save", "toggled", presence_chooser_dialog_save_toggled_cb,
934 g_object_unref (glade);
936 /* Setup the message combobox */
937 message_dialog->entry_message = GTK_BIN (message_dialog->comboboxentry_message)->child;
938 gtk_entry_set_activates_default (GTK_ENTRY (message_dialog->entry_message), TRUE);
939 gtk_entry_set_width_chars (GTK_ENTRY (message_dialog->entry_message), 25);
940 g_signal_connect (message_dialog->entry_message, "changed",
941 G_CALLBACK (presence_chooser_dialog_message_changed_cb),
944 presence_chooser_dialog_setup (message_dialog);
946 gtk_combo_box_entry_set_text_column (GTK_COMBO_BOX_ENTRY (message_dialog->comboboxentry_message), 0);
950 gtk_window_set_transient_for (
951 GTK_WINDOW (message_dialog->dialog),
955 gtk_widget_show_all (message_dialog->dialog);