1 /* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
3 * Copyright (C) 2008 Collabora Ltd.
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
10 * This library 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 * Lesser General Public License for more details.
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
19 * Authors: Xavier Claessens <xclaesse@gmail.com>
26 #include <glib/gi18n.h>
29 #include <libempathy/empathy-utils.h>
30 #include <libempathy/empathy-log-manager.h>
32 #include "empathy-contact-menu.h"
33 #include "empathy-images.h"
34 #include "empathy-log-window.h"
35 #include "empathy-contact-dialogs.h"
37 #define DEBUG_DOMAIN "ContactMenu"
40 empathy_contact_menu_new (EmpathyContact *contact,
41 EmpathyContactFeatureFlags features)
47 g_return_val_if_fail (EMPATHY_IS_CONTACT (contact), NULL);
49 if (features == EMPATHY_CONTACT_FEATURE_NONE) {
53 menu = gtk_menu_new ();
54 shell = GTK_MENU_SHELL (menu);
57 if (features & EMPATHY_CONTACT_FEATURE_CHAT) {
58 item = empathy_contact_chat_menu_item_new (contact);
59 gtk_menu_shell_append (shell, item);
60 gtk_widget_show (item);
64 if (features & EMPATHY_CONTACT_FEATURE_CALL) {
65 item = empathy_contact_call_menu_item_new (contact);
66 gtk_menu_shell_append (shell, item);
67 gtk_widget_show (item);
71 if (features & EMPATHY_CONTACT_FEATURE_LOG) {
72 item = empathy_contact_log_menu_item_new (contact);
73 gtk_menu_shell_append (shell, item);
74 gtk_widget_show (item);
78 if (features & (EMPATHY_CONTACT_FEATURE_EDIT |
79 EMPATHY_CONTACT_FEATURE_INFO)) {
80 item = gtk_separator_menu_item_new ();
81 gtk_menu_shell_append (shell, item);
82 gtk_widget_show (item);
86 if (features & EMPATHY_CONTACT_FEATURE_EDIT) {
87 item = empathy_contact_edit_menu_item_new (contact);
88 gtk_menu_shell_append (shell, item);
89 gtk_widget_show (item);
93 if (features & EMPATHY_CONTACT_FEATURE_INFO) {
94 item = empathy_contact_info_menu_item_new (contact);
95 gtk_menu_shell_append (shell, item);
96 gtk_widget_show (item);
103 empathy_contact_chat_menu_item_new (EmpathyContact *contact)
108 g_return_val_if_fail (EMPATHY_IS_CONTACT (contact), NULL);
110 item = gtk_image_menu_item_new_with_mnemonic (_("_Chat"));
111 image = gtk_image_new_from_icon_name (EMPATHY_IMAGE_MESSAGE,
113 gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (item), image);
114 gtk_widget_show (image);
116 g_signal_connect_swapped (item, "activate",
117 G_CALLBACK (empathy_chat_with_contact),
124 empathy_contact_call_menu_item_new (EmpathyContact *contact)
129 g_return_val_if_fail (EMPATHY_IS_CONTACT (contact), NULL);
131 item = gtk_image_menu_item_new_with_mnemonic (_("_Call"));
132 image = gtk_image_new_from_icon_name (EMPATHY_IMAGE_VOIP,
134 gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (item), image);
135 gtk_widget_set_sensitive (item, empathy_contact_can_voip (contact));
136 gtk_widget_show (image);
138 g_signal_connect_swapped (item, "activate",
139 G_CALLBACK (empathy_call_with_contact),
146 contact_log_menu_item_activate_cb (EmpathyContact *contact)
148 empathy_log_window_show (empathy_contact_get_account (contact),
149 empathy_contact_get_id (contact),
154 empathy_contact_log_menu_item_new (EmpathyContact *contact)
156 EmpathyLogManager *manager;
161 g_return_val_if_fail (EMPATHY_IS_CONTACT (contact), NULL);
163 manager = empathy_log_manager_new ();
164 have_log = empathy_log_manager_exists (manager,
165 empathy_contact_get_account (contact),
166 empathy_contact_get_id (contact),
168 g_object_unref (manager);
170 item = gtk_image_menu_item_new_with_mnemonic (_("_View Previous Conversations"));
171 image = gtk_image_new_from_icon_name (EMPATHY_IMAGE_LOG,
173 gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (item), image);
174 gtk_widget_set_sensitive (item, have_log);
175 gtk_widget_show (image);
177 g_signal_connect_swapped (item, "activate",
178 G_CALLBACK (contact_log_menu_item_activate_cb),
185 contact_info_menu_item_activate_cb (EmpathyContact *contact)
187 empathy_contact_information_dialog_show (contact, NULL, FALSE, FALSE);
191 empathy_contact_info_menu_item_new (EmpathyContact *contact)
196 g_return_val_if_fail (EMPATHY_IS_CONTACT (contact), NULL);
198 item = gtk_image_menu_item_new_with_mnemonic (_("Infor_mation"));
199 image = gtk_image_new_from_icon_name (EMPATHY_IMAGE_CONTACT_INFORMATION,
201 gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (item), image);
202 gtk_widget_show (image);
204 g_signal_connect_swapped (item, "activate",
205 G_CALLBACK (contact_info_menu_item_activate_cb),
212 contact_edit_menu_item_activate_cb (EmpathyContact *contact)
214 empathy_contact_information_dialog_show (contact, NULL, TRUE, FALSE);
218 empathy_contact_edit_menu_item_new (EmpathyContact *contact)
223 g_return_val_if_fail (EMPATHY_IS_CONTACT (contact), NULL);
225 item = gtk_image_menu_item_new_with_mnemonic (_("_Edit"));
226 image = gtk_image_new_from_icon_name (GTK_STOCK_EDIT,
228 gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (item), image);
229 gtk_widget_show (image);
231 g_signal_connect_swapped (item, "activate",
232 G_CALLBACK (contact_edit_menu_item_activate_cb),