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_chat_menu_item_new (EmpathyContact *contact)
45 g_return_val_if_fail (EMPATHY_IS_CONTACT (contact), NULL);
47 item = gtk_image_menu_item_new_with_mnemonic (_("_Chat"));
48 image = gtk_image_new_from_icon_name (EMPATHY_IMAGE_MESSAGE,
50 gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (item), image);
51 gtk_widget_show (image);
53 g_signal_connect_swapped (item, "activate",
54 G_CALLBACK (empathy_chat_with_contact),
61 empathy_contact_call_menu_item_new (EmpathyContact *contact)
66 g_return_val_if_fail (EMPATHY_IS_CONTACT (contact), NULL);
68 item = gtk_image_menu_item_new_with_mnemonic (_("_Call"));
69 image = gtk_image_new_from_icon_name (EMPATHY_IMAGE_VOIP,
71 gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (item), image);
72 gtk_widget_set_sensitive (item, empathy_contact_can_voip (contact));
73 gtk_widget_show (image);
75 g_signal_connect_swapped (item, "activate",
76 G_CALLBACK (empathy_call_with_contact),
83 contact_log_menu_item_activate_cb (EmpathyContact *contact)
85 empathy_log_window_show (empathy_contact_get_account (contact),
86 empathy_contact_get_id (contact),
91 empathy_contact_log_menu_item_new (EmpathyContact *contact)
93 EmpathyLogManager *manager;
98 g_return_val_if_fail (EMPATHY_IS_CONTACT (contact), NULL);
100 manager = empathy_log_manager_new ();
101 have_log = empathy_log_manager_exists (manager,
102 empathy_contact_get_account (contact),
103 empathy_contact_get_id (contact),
105 g_object_unref (manager);
107 item = gtk_image_menu_item_new_with_mnemonic (_("_View Previous Conversations"));
108 image = gtk_image_new_from_icon_name (EMPATHY_IMAGE_LOG,
110 gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (item), image);
111 gtk_widget_set_sensitive (item, have_log);
112 gtk_widget_show (image);
114 g_signal_connect_swapped (item, "activate",
115 G_CALLBACK (contact_log_menu_item_activate_cb),
122 contact_info_menu_item_activate_cb (EmpathyContact *contact)
124 empathy_contact_information_dialog_show (contact, NULL, FALSE, FALSE);
128 empathy_contact_info_menu_item_new (EmpathyContact *contact)
133 g_return_val_if_fail (EMPATHY_IS_CONTACT (contact), NULL);
135 item = gtk_image_menu_item_new_with_mnemonic (_("Infor_mation"));
136 image = gtk_image_new_from_icon_name (EMPATHY_IMAGE_CONTACT_INFORMATION,
138 gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (item), image);
139 gtk_widget_show (image);
141 g_signal_connect_swapped (item, "activate",
142 G_CALLBACK (contact_info_menu_item_activate_cb),
149 contact_edit_menu_item_activate_cb (EmpathyContact *contact)
151 empathy_contact_information_dialog_show (contact, NULL, TRUE, FALSE);
155 empathy_contact_edit_menu_item_new (EmpathyContact *contact)
160 g_return_val_if_fail (EMPATHY_IS_CONTACT (contact), NULL);
162 item = gtk_image_menu_item_new_with_mnemonic (_("_Edit"));
163 image = gtk_image_new_from_icon_name (GTK_STOCK_EDIT,
165 gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (item), image);
166 gtk_widget_show (image);
168 g_signal_connect_swapped (item, "activate",
169 G_CALLBACK (contact_edit_menu_item_activate_cb),