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.h>
32 #include <glade/glade.h>
34 #include <telepathy-glib/util.h>
35 #include <libmissioncontrol/mc-enum-types.h>
37 #include <libempathy/empathy-idle.h>
38 #include <libempathy/empathy-utils.h>
39 #include <libempathy/empathy-status-presets.h>
41 #include "empathy-ui-utils.h"
42 #include "empathy-images.h"
43 #include "empathy-presence-chooser.h"
45 #define GET_PRIV(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), EMPATHY_TYPE_PRESENCE_CHOOSER, EmpathyPresenceChooserPriv))
47 /* Flashing delay for icons (milliseconds). */
48 #define FLASH_TIMEOUT 500
58 McPresence last_state;
60 McPresence flash_state_1;
61 McPresence flash_state_2;
62 guint flash_timeout_id;
64 /* The handle the kind of unnessecary scroll support. */
65 guint scroll_timeout_id;
66 McPresence scroll_state;
68 } EmpathyPresenceChooserPriv;
72 GtkWidget *checkbutton_save;
73 GtkWidget *comboboxentry_message;
74 GtkWidget *entry_message;
75 GtkWidget *combobox_status;
76 GtkTreeModel *model_status;
77 } CustomMessageDialog;
91 static CustomMessageDialog *message_dialog = NULL;
92 /* States to be listed in the menu.
93 * Each state has a boolean telling if it can have custom message */
94 static guint states[] = {MC_PRESENCE_AVAILABLE, TRUE,
95 MC_PRESENCE_DO_NOT_DISTURB, TRUE,
96 MC_PRESENCE_AWAY, TRUE,
97 MC_PRESENCE_HIDDEN, FALSE,
98 MC_PRESENCE_OFFLINE, FALSE};
100 static void empathy_presence_chooser_class_init (EmpathyPresenceChooserClass *klass);
101 static void empathy_presence_chooser_init (EmpathyPresenceChooser *chooser);
102 static void presence_chooser_finalize (GObject *object);
103 static void presence_chooser_presence_changed_cb (EmpathyPresenceChooser *chooser);
104 static void presence_chooser_reset_scroll_timeout (EmpathyPresenceChooser *chooser);
105 static gboolean presence_chooser_scroll_timeout_cb (EmpathyPresenceChooser *chooser);
106 static gboolean presence_chooser_scroll_event_cb (EmpathyPresenceChooser *chooser,
107 GdkEventScroll *event,
109 static GList * presence_chooser_get_presets (EmpathyPresenceChooser *chooser);
110 static StateAndStatus *presence_chooser_state_and_status_new (McPresence state,
111 const gchar *status);
112 static gboolean presence_chooser_flash_timeout_cb (EmpathyPresenceChooser *chooser);
113 static void presence_chooser_flash_start (EmpathyPresenceChooser *chooser,
116 static void presence_chooser_flash_stop (EmpathyPresenceChooser *chooser,
118 static gboolean presence_chooser_button_press_event_cb (GtkWidget *chooser,
119 GdkEventButton *event,
121 static void presence_chooser_toggled_cb (GtkWidget *chooser,
123 static void presence_chooser_menu_popup (EmpathyPresenceChooser *chooser);
124 static void presence_chooser_menu_popdown (EmpathyPresenceChooser *chooser);
125 static void presence_chooser_menu_selection_done_cb (GtkMenuShell *menushell,
126 EmpathyPresenceChooser *chooser);
127 static void presence_chooser_menu_destroy_cb (GtkWidget *menu,
128 EmpathyPresenceChooser *chooser);
129 static void presence_chooser_menu_detach (GtkWidget *attach_widget,
131 static void presence_chooser_menu_align_func (GtkMenu *menu,
136 static void presence_chooser_menu_add_item (GtkWidget *menu,
139 static void presence_chooser_noncustom_activate_cb (GtkWidget *item,
141 static void presence_chooser_set_state (McPresence state,
142 const gchar *status);
143 static void presence_chooser_custom_activate_cb (GtkWidget *item,
145 static void presence_chooser_dialog_show (void);
147 G_DEFINE_TYPE (EmpathyPresenceChooser, empathy_presence_chooser, GTK_TYPE_TOGGLE_BUTTON);
150 empathy_presence_chooser_class_init (EmpathyPresenceChooserClass *klass)
152 GObjectClass *object_class = G_OBJECT_CLASS (klass);
154 object_class->finalize = presence_chooser_finalize;
156 g_type_class_add_private (object_class, sizeof (EmpathyPresenceChooserPriv));
160 empathy_presence_chooser_init (EmpathyPresenceChooser *chooser)
162 EmpathyPresenceChooserPriv *priv;
164 GtkWidget *alignment;
166 priv = GET_PRIV (chooser);
168 gtk_button_set_relief (GTK_BUTTON (chooser), GTK_RELIEF_NONE);
169 gtk_button_set_focus_on_click (GTK_BUTTON (chooser), FALSE);
171 alignment = gtk_alignment_new (0.5, 0.5, 1, 1);
172 gtk_widget_show (alignment);
173 gtk_container_add (GTK_CONTAINER (chooser), alignment);
174 gtk_alignment_set_padding (GTK_ALIGNMENT (alignment), 0, 0, 1, 0);
176 priv->hbox = gtk_hbox_new (FALSE, 1);
177 gtk_widget_show (priv->hbox);
178 gtk_container_add (GTK_CONTAINER (alignment), priv->hbox);
180 priv->image = gtk_image_new ();
181 gtk_widget_show (priv->image);
182 gtk_box_pack_start (GTK_BOX (priv->hbox), priv->image, FALSE, TRUE, 0);
184 priv->label = gtk_label_new (NULL);
185 gtk_widget_show (priv->label);
186 gtk_box_pack_start (GTK_BOX (priv->hbox), priv->label, TRUE, TRUE, 0);
187 gtk_label_set_ellipsize (GTK_LABEL (priv->label), PANGO_ELLIPSIZE_END);
188 gtk_misc_set_alignment (GTK_MISC (priv->label), 0, 0.5);
189 gtk_misc_set_padding (GTK_MISC (priv->label), 4, 1);
191 alignment = gtk_alignment_new (0.5, 0.5, 1, 1);
192 gtk_widget_show (alignment);
193 gtk_box_pack_start (GTK_BOX (priv->hbox), alignment, FALSE, FALSE, 0);
195 arrow = gtk_arrow_new (GTK_ARROW_DOWN, GTK_SHADOW_OUT);
196 gtk_widget_show (arrow);
197 gtk_container_add (GTK_CONTAINER (alignment), arrow);
199 g_signal_connect (chooser, "toggled",
200 G_CALLBACK (presence_chooser_toggled_cb),
202 g_signal_connect (chooser, "button-press-event",
203 G_CALLBACK (presence_chooser_button_press_event_cb),
205 g_signal_connect (chooser, "scroll-event",
206 G_CALLBACK (presence_chooser_scroll_event_cb),
209 priv->idle = empathy_idle_new ();
210 presence_chooser_presence_changed_cb (chooser);
211 g_signal_connect_swapped (priv->idle, "notify",
212 G_CALLBACK (presence_chooser_presence_changed_cb),
217 presence_chooser_finalize (GObject *object)
219 EmpathyPresenceChooserPriv *priv;
221 priv = GET_PRIV (object);
223 if (priv->flash_timeout_id) {
224 g_source_remove (priv->flash_timeout_id);
227 if (priv->scroll_timeout_id) {
228 g_source_remove (priv->scroll_timeout_id);
231 g_signal_handlers_disconnect_by_func (priv->idle,
232 presence_chooser_presence_changed_cb,
234 g_object_unref (priv->idle);
236 G_OBJECT_CLASS (empathy_presence_chooser_parent_class)->finalize (object);
240 empathy_presence_chooser_new (void)
244 chooser = g_object_new (EMPATHY_TYPE_PRESENCE_CHOOSER, NULL);
250 presence_chooser_presence_changed_cb (EmpathyPresenceChooser *chooser)
252 EmpathyPresenceChooserPriv *priv;
254 McPresence flash_state;
257 priv = GET_PRIV (chooser);
259 state = empathy_idle_get_state (priv->idle);
260 status = empathy_idle_get_status (priv->idle);
261 flash_state = empathy_idle_get_flash_state (priv->idle);
263 presence_chooser_reset_scroll_timeout (chooser);
264 gtk_label_set_text (GTK_LABEL (priv->label), status);
266 if (flash_state != MC_PRESENCE_UNSET) {
267 presence_chooser_flash_start (chooser, state, flash_state);
269 presence_chooser_flash_stop (chooser, state);
274 presence_chooser_reset_scroll_timeout (EmpathyPresenceChooser *chooser)
276 EmpathyPresenceChooserPriv *priv;
278 priv = GET_PRIV (chooser);
280 if (priv->scroll_timeout_id) {
281 g_source_remove (priv->scroll_timeout_id);
282 priv->scroll_timeout_id = 0;
285 g_free (priv->scroll_status);
286 priv->scroll_status = NULL;
290 presence_chooser_scroll_timeout_cb (EmpathyPresenceChooser *chooser)
292 EmpathyPresenceChooserPriv *priv;
294 priv = GET_PRIV (chooser);
296 priv->scroll_timeout_id = 0;
298 empathy_idle_set_presence (priv->idle,
300 priv->scroll_status);
302 g_free (priv->scroll_status);
303 priv->scroll_status = NULL;
309 presence_chooser_scroll_event_cb (EmpathyPresenceChooser *chooser,
310 GdkEventScroll *event,
313 EmpathyPresenceChooserPriv *priv;
315 const gchar *current_status;
319 priv = GET_PRIV (chooser);
321 switch (event->direction) {
324 case GDK_SCROLL_DOWN:
330 current_status = gtk_label_get_text (GTK_LABEL (priv->label));
332 /* Get the list of presets, which in this context means all the items
333 * without a trailing "...".
335 list = presence_chooser_get_presets (chooser);
338 for (l = list; l; l = l->next) {
341 if (sas->state == priv->last_state &&
342 strcmp (sas->status, current_status) == 0) {
345 if (event->direction == GDK_SCROLL_UP) {
350 else if (event->direction == GDK_SCROLL_DOWN) {
362 presence_chooser_reset_scroll_timeout (chooser);
364 priv->scroll_status = g_strdup (sas->status);
365 priv->scroll_state = sas->state;
367 priv->scroll_timeout_id =
368 g_timeout_add_seconds (1,
369 (GSourceFunc) presence_chooser_scroll_timeout_cb,
372 presence_chooser_flash_stop (chooser, sas->state);
373 gtk_label_set_text (GTK_LABEL (priv->label), sas->status);
377 /* If we didn't get any match at all, it means the last state
378 * was a custom one. Just switch to the first one.
380 status = empathy_presence_get_default_message (states[0]);
382 presence_chooser_reset_scroll_timeout (chooser);
383 empathy_idle_set_presence (priv->idle, states[0], status);
386 g_list_foreach (list, (GFunc) g_free, NULL);
393 presence_chooser_get_presets (EmpathyPresenceChooser *chooser)
398 for (i = 0; i < G_N_ELEMENTS (states); i += 2) {
403 status = empathy_presence_get_default_message (states[i]);
404 sas = presence_chooser_state_and_status_new (states[i], status);
405 list = g_list_prepend (list, sas);
407 /* Go to next state if we don't want messages for that state */
412 presets = empathy_status_presets_get (states[i], 5);
413 for (p = presets; p; p = p->next) {
414 sas = presence_chooser_state_and_status_new (states[i], p->data);
415 list = g_list_prepend (list, sas);
417 g_list_free (presets);
419 list = g_list_reverse (list);
424 static StateAndStatus *
425 presence_chooser_state_and_status_new (McPresence state,
430 sas = g_new0 (StateAndStatus, 1);
433 sas->status = status;
439 presence_chooser_flash_timeout_cb (EmpathyPresenceChooser *chooser)
441 EmpathyPresenceChooserPriv *priv;
443 static gboolean on = FALSE;
445 priv = GET_PRIV (chooser);
448 state = priv->flash_state_1;
450 state = priv->flash_state_2;
453 gtk_image_set_from_icon_name (GTK_IMAGE (priv->image),
454 empathy_icon_name_for_presence (state),
463 presence_chooser_flash_start (EmpathyPresenceChooser *chooser,
467 EmpathyPresenceChooserPriv *priv;
469 g_return_if_fail (EMPATHY_IS_PRESENCE_CHOOSER (chooser));
471 priv = GET_PRIV (chooser);
473 priv->flash_state_1 = state_1;
474 priv->flash_state_2 = state_2;
476 if (!priv->flash_timeout_id) {
477 priv->flash_timeout_id = g_timeout_add (FLASH_TIMEOUT,
478 (GSourceFunc) presence_chooser_flash_timeout_cb,
484 presence_chooser_flash_stop (EmpathyPresenceChooser *chooser,
487 EmpathyPresenceChooserPriv *priv;
489 g_return_if_fail (EMPATHY_IS_PRESENCE_CHOOSER (chooser));
491 priv = GET_PRIV (chooser);
493 if (priv->flash_timeout_id) {
494 g_source_remove (priv->flash_timeout_id);
495 priv->flash_timeout_id = 0;
498 gtk_image_set_from_icon_name (GTK_IMAGE (priv->image),
499 empathy_icon_name_for_presence (state),
502 priv->last_state = state;
506 presence_chooser_button_press_event_cb (GtkWidget *chooser,
507 GdkEventButton *event,
510 if (event->button != 1 || event->type != GDK_BUTTON_PRESS) {
514 if (!gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (chooser))) {
515 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (chooser), TRUE);
523 presence_chooser_toggled_cb (GtkWidget *chooser,
526 if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (chooser))) {
527 presence_chooser_menu_popup (EMPATHY_PRESENCE_CHOOSER (chooser));
529 presence_chooser_menu_popdown (EMPATHY_PRESENCE_CHOOSER (chooser));
534 presence_chooser_menu_popup (EmpathyPresenceChooser *chooser)
536 EmpathyPresenceChooserPriv *priv;
539 priv = GET_PRIV (chooser);
545 menu = empathy_presence_chooser_create_menu ();
547 g_signal_connect_after (menu, "selection-done",
548 G_CALLBACK (presence_chooser_menu_selection_done_cb),
551 g_signal_connect (menu, "destroy",
552 G_CALLBACK (presence_chooser_menu_destroy_cb),
555 gtk_menu_attach_to_widget (GTK_MENU (menu),
556 GTK_WIDGET (chooser),
557 presence_chooser_menu_detach);
559 gtk_menu_popup (GTK_MENU (menu),
561 (GtkMenuPositionFunc) presence_chooser_menu_align_func,
564 gtk_get_current_event_time ());
570 presence_chooser_menu_popdown (EmpathyPresenceChooser *chooser)
572 EmpathyPresenceChooserPriv *priv;
574 priv = GET_PRIV (chooser);
577 gtk_widget_destroy (priv->menu);
582 presence_chooser_menu_selection_done_cb (GtkMenuShell *menushell,
583 EmpathyPresenceChooser *chooser)
585 gtk_widget_destroy (GTK_WIDGET (menushell));
587 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (chooser), FALSE);
591 presence_chooser_menu_destroy_cb (GtkWidget *menu,
592 EmpathyPresenceChooser *chooser)
594 EmpathyPresenceChooserPriv *priv;
596 priv = GET_PRIV (chooser);
602 presence_chooser_menu_detach (GtkWidget *attach_widget,
605 /* We don't need to do anything, but attaching the menu means
606 * we don't own the ref count and it is cleaned up properly.
611 presence_chooser_menu_align_func (GtkMenu *menu,
621 gtk_widget_size_request (GTK_WIDGET (menu), &req);
623 gdk_window_get_origin (widget->window, x, y);
625 *x += widget->allocation.x + 1;
626 *y += widget->allocation.y;
628 screen = gtk_widget_get_screen (GTK_WIDGET (menu));
629 screen_height = gdk_screen_get_height (screen);
631 if (req.height > screen_height) {
632 /* Too big for screen height anyway. */
637 if ((*y + req.height + widget->allocation.height) > screen_height) {
638 /* Can't put it below the button. */
642 /* Put menu below button. */
643 *y += widget->allocation.height;
651 empathy_presence_chooser_create_menu (void)
659 menu = gtk_menu_new ();
661 for (i = 0; i < G_N_ELEMENTS (states); i += 2) {
664 status = empathy_presence_get_default_message (states[i]);
665 presence_chooser_menu_add_item (menu,
670 /* Set custom messages if wanted */
671 list = empathy_status_presets_get (states[i], 5);
672 for (l = list; l; l = l->next) {
673 presence_chooser_menu_add_item (menu,
683 item = gtk_menu_item_new ();
684 gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
685 gtk_widget_show (item);
687 /* Custom messages */
688 item = gtk_image_menu_item_new_with_label (_("Custom messages..."));
689 image = gtk_image_new_from_stock (GTK_STOCK_EDIT, GTK_ICON_SIZE_MENU);
690 gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (item), image);
691 gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
692 gtk_widget_show (image);
693 gtk_widget_show (item);
695 g_signal_connect (item,
697 G_CALLBACK (presence_chooser_custom_activate_cb),
704 presence_chooser_menu_add_item (GtkWidget *menu,
710 const gchar *icon_name;
712 item = gtk_image_menu_item_new_with_label (str);
713 icon_name = empathy_icon_name_for_presence (state);
715 g_signal_connect (item, "activate",
716 G_CALLBACK (presence_chooser_noncustom_activate_cb),
719 image = gtk_image_new_from_icon_name (icon_name, GTK_ICON_SIZE_MENU);
720 gtk_widget_show (image);
722 gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (item), image);
723 gtk_widget_show (item);
725 g_object_set_data_full (G_OBJECT (item),
726 "status", g_strdup (str),
727 (GDestroyNotify) g_free);
729 g_object_set_data (G_OBJECT (item), "state", GINT_TO_POINTER (state));
731 gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
735 presence_chooser_noncustom_activate_cb (GtkWidget *item,
741 status = g_object_get_data (G_OBJECT (item), "status");
742 state = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (item), "state"));
744 presence_chooser_set_state (state, status);
748 presence_chooser_set_state (McPresence state,
753 idle = empathy_idle_new ();
754 empathy_idle_set_presence (idle, state, status);
755 g_object_unref (idle);
759 presence_chooser_custom_activate_cb (GtkWidget *item,
762 presence_chooser_dialog_show ();
766 presence_chooser_dialog_get_selected (CustomMessageDialog *dialog)
770 McPresence presence = LAST_MC_PRESENCE;
772 model = gtk_combo_box_get_model (GTK_COMBO_BOX (dialog->combobox_status));
773 if (gtk_combo_box_get_active_iter (GTK_COMBO_BOX (dialog->combobox_status), &iter)) {
774 gtk_tree_model_get (model, &iter,
775 COL_PRESENCE, &presence,
783 presence_chooser_dialog_status_changed_cb (GtkWidget *widget,
784 CustomMessageDialog *dialog)
788 McPresence presence = LAST_MC_PRESENCE;
791 presence = presence_chooser_dialog_get_selected (dialog);
793 store = gtk_list_store_new (1, G_TYPE_STRING);
794 messages = empathy_status_presets_get (presence, -1);
795 for (l = messages; l; l = l->next) {
796 gtk_list_store_append (store, &iter);
797 gtk_list_store_set (store, &iter, 0, l->data, -1);
800 gtk_entry_set_text (GTK_ENTRY (dialog->entry_message),
801 messages ? messages->data : "");
803 g_list_free (messages);
805 gtk_combo_box_set_model (GTK_COMBO_BOX (dialog->comboboxentry_message),
806 GTK_TREE_MODEL (store));
808 g_object_unref (store);
812 presence_chooser_dialog_message_changed_cb (GtkWidget *widget,
813 CustomMessageDialog *dialog)
818 gboolean found = FALSE;
820 presence = presence_chooser_dialog_get_selected (dialog);
821 text = gtk_entry_get_text (GTK_ENTRY (dialog->entry_message));
823 messages = empathy_status_presets_get (presence, -1);
824 for (l = messages; l; l = l->next) {
825 if (!tp_strdiff (text, l->data)) {
830 g_list_free (messages);
832 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (dialog->checkbutton_save),
837 presence_chooser_dialog_save_toggled_cb (GtkWidget *widget,
838 CustomMessageDialog *dialog)
844 active = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (dialog->checkbutton_save));
845 state = presence_chooser_dialog_get_selected (dialog);
846 text = gtk_entry_get_text (GTK_ENTRY (dialog->entry_message));
849 empathy_status_presets_set_last (state, text);
851 empathy_status_presets_remove (state, text);
856 presence_chooser_dialog_setup (CustomMessageDialog *dialog)
859 GtkCellRenderer *renderer;
863 store = gtk_list_store_new (COL_COUNT,
864 G_TYPE_STRING, /* Icon name */
865 G_TYPE_STRING, /* Label */
866 MC_TYPE_PRESENCE); /* Presence */
867 gtk_combo_box_set_model (GTK_COMBO_BOX (dialog->combobox_status),
868 GTK_TREE_MODEL (store));
870 renderer = gtk_cell_renderer_pixbuf_new ();
871 gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (dialog->combobox_status), renderer, FALSE);
872 gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (dialog->combobox_status), renderer,
873 "icon-name", COL_ICON,
875 g_object_set (renderer, "stock-size", GTK_ICON_SIZE_BUTTON, NULL);
877 renderer = gtk_cell_renderer_text_new ();
878 gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (dialog->combobox_status), renderer, TRUE);
879 gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (dialog->combobox_status), renderer,
883 for (i = 0; i < G_N_ELEMENTS (states); i += 2) {
888 gtk_list_store_append (store, &iter);
889 gtk_list_store_set (store, &iter,
890 COL_ICON, empathy_icon_name_for_presence (states[i]),
891 COL_LABEL, empathy_presence_get_default_message (states[i]),
892 COL_PRESENCE, states[i],
896 gtk_combo_box_set_active (GTK_COMBO_BOX (dialog->combobox_status), 0);
900 presence_chooser_dialog_response_cb (GtkWidget *widget,
902 CustomMessageDialog *dialog)
904 if (response == GTK_RESPONSE_APPLY) {
908 state = presence_chooser_dialog_get_selected (dialog);
909 text = gtk_entry_get_text (GTK_ENTRY (dialog->entry_message));
911 presence_chooser_set_state (state, text);
914 gtk_widget_destroy (widget);
918 presence_chooser_dialog_destroy_cb (GtkWidget *widget,
919 CustomMessageDialog *dialog)
923 message_dialog = NULL;
927 presence_chooser_dialog_show (void)
932 if (message_dialog) {
933 gtk_window_present (GTK_WINDOW (message_dialog->dialog));
937 message_dialog = g_new0 (CustomMessageDialog, 1);
939 filename = empathy_file_lookup ("empathy-presence-chooser.glade",
941 glade = empathy_glade_get_file (filename,
942 "custom_message_dialog",
944 "custom_message_dialog", &message_dialog->dialog,
945 "checkbutton_save", &message_dialog->checkbutton_save,
946 "comboboxentry_message", &message_dialog->comboboxentry_message,
947 "combobox_status", &message_dialog->combobox_status,
951 empathy_glade_connect (glade,
953 "custom_message_dialog", "destroy", presence_chooser_dialog_destroy_cb,
954 "custom_message_dialog", "response", presence_chooser_dialog_response_cb,
955 "combobox_status", "changed", presence_chooser_dialog_status_changed_cb,
956 "checkbutton_save", "toggled", presence_chooser_dialog_save_toggled_cb,
959 g_object_unref (glade);
961 /* Setup the message combobox */
962 message_dialog->entry_message = GTK_BIN (message_dialog->comboboxentry_message)->child;
963 gtk_entry_set_activates_default (GTK_ENTRY (message_dialog->entry_message), TRUE);
964 gtk_entry_set_width_chars (GTK_ENTRY (message_dialog->entry_message), 25);
965 g_signal_connect (message_dialog->entry_message, "changed",
966 G_CALLBACK (presence_chooser_dialog_message_changed_cb),
969 presence_chooser_dialog_setup (message_dialog);
971 gtk_combo_box_entry_set_text_column (GTK_COMBO_BOX_ENTRY (message_dialog->comboboxentry_message), 0);
973 /* FIXME: Set transian for a window ? */
975 gtk_widget_show_all (message_dialog->dialog);