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-log-manager.h>
30 #include <libempathy/empathy-dispatcher.h>
31 #include <libempathy/empathy-utils.h>
33 #include "empathy-contact-menu.h"
34 #include "empathy-images.h"
35 #include "empathy-log-window.h"
36 #include "empathy-contact-dialogs.h"
39 empathy_contact_menu_new (EmpathyContact *contact,
40 EmpathyContactFeatureFlags features)
46 g_return_val_if_fail (EMPATHY_IS_CONTACT (contact), NULL);
48 if (features == EMPATHY_CONTACT_FEATURE_NONE) {
52 menu = gtk_menu_new ();
53 shell = GTK_MENU_SHELL (menu);
56 if (features & EMPATHY_CONTACT_FEATURE_CHAT) {
57 item = empathy_contact_chat_menu_item_new (contact);
58 gtk_menu_shell_append (shell, item);
59 gtk_widget_show (item);
63 if (features & EMPATHY_CONTACT_FEATURE_CALL) {
64 item = empathy_contact_call_menu_item_new (contact);
65 gtk_menu_shell_append (shell, item);
66 gtk_widget_show (item);
70 if (features & EMPATHY_CONTACT_FEATURE_LOG) {
71 item = empathy_contact_log_menu_item_new (contact);
72 gtk_menu_shell_append (shell, item);
73 gtk_widget_show (item);
77 if (features & (EMPATHY_CONTACT_FEATURE_EDIT |
78 EMPATHY_CONTACT_FEATURE_INFO)) {
79 item = gtk_separator_menu_item_new ();
80 gtk_menu_shell_append (shell, item);
81 gtk_widget_show (item);
85 if (features & EMPATHY_CONTACT_FEATURE_EDIT) {
86 item = empathy_contact_edit_menu_item_new (contact);
87 gtk_menu_shell_append (shell, item);
88 gtk_widget_show (item);
92 if (features & EMPATHY_CONTACT_FEATURE_INFO) {
93 item = empathy_contact_info_menu_item_new (contact);
94 gtk_menu_shell_append (shell, item);
95 gtk_widget_show (item);
102 empathy_contact_chat_menu_item_new (EmpathyContact *contact)
107 g_return_val_if_fail (EMPATHY_IS_CONTACT (contact), NULL);
109 item = gtk_image_menu_item_new_with_mnemonic (_("_Chat"));
110 image = gtk_image_new_from_icon_name (EMPATHY_IMAGE_MESSAGE,
112 gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (item), image);
113 gtk_widget_show (image);
115 g_signal_connect_swapped (item, "activate",
116 G_CALLBACK (empathy_dispatcher_chat_with_contact),
123 empathy_contact_call_menu_item_new (EmpathyContact *contact)
128 g_return_val_if_fail (EMPATHY_IS_CONTACT (contact), NULL);
130 item = gtk_image_menu_item_new_with_mnemonic (_("_Call"));
131 image = gtk_image_new_from_icon_name (EMPATHY_IMAGE_VOIP,
133 gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (item), image);
134 gtk_widget_set_sensitive (item, empathy_contact_can_voip (contact));
135 gtk_widget_show (image);
137 g_signal_connect_swapped (item, "activate",
138 G_CALLBACK (empathy_dispatcher_call_with_contact),
145 contact_log_menu_item_activate_cb (EmpathyContact *contact)
147 empathy_log_window_show (empathy_contact_get_account (contact),
148 empathy_contact_get_id (contact),
153 empathy_contact_log_menu_item_new (EmpathyContact *contact)
155 EmpathyLogManager *manager;
160 g_return_val_if_fail (EMPATHY_IS_CONTACT (contact), NULL);
162 manager = empathy_log_manager_new ();
163 have_log = empathy_log_manager_exists (manager,
164 empathy_contact_get_account (contact),
165 empathy_contact_get_id (contact),
167 g_object_unref (manager);
169 item = gtk_image_menu_item_new_with_mnemonic (_("_View Previous Conversations"));
170 image = gtk_image_new_from_icon_name (EMPATHY_IMAGE_LOG,
172 gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (item), image);
173 gtk_widget_set_sensitive (item, have_log);
174 gtk_widget_show (image);
176 g_signal_connect_swapped (item, "activate",
177 G_CALLBACK (contact_log_menu_item_activate_cb),
184 contact_info_menu_item_activate_cb (EmpathyContact *contact)
186 empathy_contact_information_dialog_show (contact, NULL, FALSE, FALSE);
190 empathy_contact_info_menu_item_new (EmpathyContact *contact)
195 g_return_val_if_fail (EMPATHY_IS_CONTACT (contact), NULL);
197 item = gtk_image_menu_item_new_with_mnemonic (_("Infor_mation"));
198 image = gtk_image_new_from_icon_name (EMPATHY_IMAGE_CONTACT_INFORMATION,
200 gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (item), image);
201 gtk_widget_show (image);
203 g_signal_connect_swapped (item, "activate",
204 G_CALLBACK (contact_info_menu_item_activate_cb),
211 contact_edit_menu_item_activate_cb (EmpathyContact *contact)
213 empathy_contact_information_dialog_show (contact, NULL, TRUE, FALSE);
217 empathy_contact_edit_menu_item_new (EmpathyContact *contact)
222 g_return_val_if_fail (EMPATHY_IS_CONTACT (contact), NULL);
224 item = gtk_image_menu_item_new_with_mnemonic (_("_Edit"));
225 image = gtk_image_new_from_icon_name (GTK_STOCK_EDIT,
227 gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (item), image);
228 gtk_widget_show (image);
230 g_signal_connect_swapped (item, "activate",
231 G_CALLBACK (contact_edit_menu_item_activate_cb),