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"
38 empathy_contact_menu_new (EmpathyContact *contact,
39 EmpathyContactFeatureFlags features)
45 g_return_val_if_fail (EMPATHY_IS_CONTACT (contact), NULL);
47 if (features == EMPATHY_CONTACT_FEATURE_NONE) {
51 menu = gtk_menu_new ();
52 shell = GTK_MENU_SHELL (menu);
55 if (features & EMPATHY_CONTACT_FEATURE_CHAT) {
56 item = empathy_contact_chat_menu_item_new (contact);
57 gtk_menu_shell_append (shell, item);
58 gtk_widget_show (item);
62 if (features & EMPATHY_CONTACT_FEATURE_CALL) {
63 item = empathy_contact_call_menu_item_new (contact);
64 gtk_menu_shell_append (shell, item);
65 gtk_widget_show (item);
69 if (features & EMPATHY_CONTACT_FEATURE_LOG) {
70 item = empathy_contact_log_menu_item_new (contact);
71 gtk_menu_shell_append (shell, item);
72 gtk_widget_show (item);
76 if (features & (EMPATHY_CONTACT_FEATURE_EDIT |
77 EMPATHY_CONTACT_FEATURE_INFO)) {
78 item = gtk_separator_menu_item_new ();
79 gtk_menu_shell_append (shell, item);
80 gtk_widget_show (item);
84 if (features & EMPATHY_CONTACT_FEATURE_EDIT) {
85 item = empathy_contact_edit_menu_item_new (contact);
86 gtk_menu_shell_append (shell, item);
87 gtk_widget_show (item);
91 if (features & EMPATHY_CONTACT_FEATURE_INFO) {
92 item = empathy_contact_info_menu_item_new (contact);
93 gtk_menu_shell_append (shell, item);
94 gtk_widget_show (item);
101 empathy_contact_chat_menu_item_new (EmpathyContact *contact)
106 g_return_val_if_fail (EMPATHY_IS_CONTACT (contact), NULL);
108 item = gtk_image_menu_item_new_with_mnemonic (_("_Chat"));
109 image = gtk_image_new_from_icon_name (EMPATHY_IMAGE_MESSAGE,
111 gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (item), image);
112 gtk_widget_show (image);
114 g_signal_connect_swapped (item, "activate",
115 G_CALLBACK (empathy_chat_with_contact),
122 empathy_contact_call_menu_item_new (EmpathyContact *contact)
127 g_return_val_if_fail (EMPATHY_IS_CONTACT (contact), NULL);
129 item = gtk_image_menu_item_new_with_mnemonic (_("_Call"));
130 image = gtk_image_new_from_icon_name (EMPATHY_IMAGE_VOIP,
132 gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (item), image);
133 gtk_widget_set_sensitive (item, empathy_contact_can_voip (contact));
134 gtk_widget_show (image);
136 g_signal_connect_swapped (item, "activate",
137 G_CALLBACK (empathy_call_with_contact),
144 contact_log_menu_item_activate_cb (EmpathyContact *contact)
146 empathy_log_window_show (empathy_contact_get_account (contact),
147 empathy_contact_get_id (contact),
152 empathy_contact_log_menu_item_new (EmpathyContact *contact)
154 EmpathyLogManager *manager;
159 g_return_val_if_fail (EMPATHY_IS_CONTACT (contact), NULL);
161 manager = empathy_log_manager_new ();
162 have_log = empathy_log_manager_exists (manager,
163 empathy_contact_get_account (contact),
164 empathy_contact_get_id (contact),
166 g_object_unref (manager);
168 item = gtk_image_menu_item_new_with_mnemonic (_("_View Previous Conversations"));
169 image = gtk_image_new_from_icon_name (EMPATHY_IMAGE_LOG,
171 gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (item), image);
172 gtk_widget_set_sensitive (item, have_log);
173 gtk_widget_show (image);
175 g_signal_connect_swapped (item, "activate",
176 G_CALLBACK (contact_log_menu_item_activate_cb),
183 contact_info_menu_item_activate_cb (EmpathyContact *contact)
185 empathy_contact_information_dialog_show (contact, NULL, FALSE, FALSE);
189 empathy_contact_info_menu_item_new (EmpathyContact *contact)
194 g_return_val_if_fail (EMPATHY_IS_CONTACT (contact), NULL);
196 item = gtk_image_menu_item_new_with_mnemonic (_("Infor_mation"));
197 image = gtk_image_new_from_icon_name (EMPATHY_IMAGE_CONTACT_INFORMATION,
199 gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (item), image);
200 gtk_widget_show (image);
202 g_signal_connect_swapped (item, "activate",
203 G_CALLBACK (contact_info_menu_item_activate_cb),
210 contact_edit_menu_item_activate_cb (EmpathyContact *contact)
212 empathy_contact_information_dialog_show (contact, NULL, TRUE, FALSE);
216 empathy_contact_edit_menu_item_new (EmpathyContact *contact)
221 g_return_val_if_fail (EMPATHY_IS_CONTACT (contact), NULL);
223 item = gtk_image_menu_item_new_with_mnemonic (_("_Edit"));
224 image = gtk_image_new_from_icon_name (GTK_STOCK_EDIT,
226 gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (item), image);
227 gtk_widget_show (image);
229 g_signal_connect_swapped (item, "activate",
230 G_CALLBACK (contact_edit_menu_item_activate_cb),