empathy r1401 - in trunk: libempathy-gtk src
- From: xclaesse svn gnome org
- To: svn-commits-list gnome org
- Subject: empathy r1401 - in trunk: libempathy-gtk src
- Date: Fri, 29 Aug 2008 16:04:51 +0000 (UTC)
Author: xclaesse
Date: Fri Aug 29 16:04:51 2008
New Revision: 1401
URL: http://svn.gnome.org/viewvc/empathy?rev=1401&view=rev
Log:
Add a menu item in chat window to set the room as favorite
Modified:
trunk/libempathy-gtk/empathy-chat.c
trunk/libempathy-gtk/empathy-chat.h
trunk/src/empathy-chat-window.c
trunk/src/empathy-chat-window.glade
Modified: trunk/libempathy-gtk/empathy-chat.c
==============================================================================
--- trunk/libempathy-gtk/empathy-chat.c (original)
+++ trunk/libempathy-gtk/empathy-chat.c Fri Aug 29 16:04:51 2008
@@ -1793,3 +1793,13 @@
-1);
}
+gboolean
+empathy_chat_is_room (EmpathyChat *chat)
+{
+ EmpathyChatPriv *priv = GET_PRIV (chat);
+
+ g_return_val_if_fail (EMPATHY_IS_CHAT (chat), FALSE);
+
+ return (priv->handle_type == TP_HANDLE_TYPE_ROOM);
+}
+
Modified: trunk/libempathy-gtk/empathy-chat.h
==============================================================================
--- trunk/libempathy-gtk/empathy-chat.h (original)
+++ trunk/libempathy-gtk/empathy-chat.h Fri Aug 29 16:04:51 2008
@@ -82,7 +82,7 @@
GtkTextIter *start,
GtkTextIter *end,
const gchar *new_word);
-
+gboolean empathy_chat_is_room (EmpathyChat *chat);
G_END_DECLS
#endif /* __EMPATHY_CHAT_H__ */
Modified: trunk/src/empathy-chat-window.c
==============================================================================
--- trunk/src/empathy-chat-window.c (original)
+++ trunk/src/empathy-chat-window.c Fri Aug 29 16:04:51 2008
@@ -41,6 +41,7 @@
#include <libempathy/empathy-contact.h>
#include <libempathy/empathy-message.h>
#include <libempathy/empathy-dispatcher.h>
+#include <libempathy/empathy-chatroom-manager.h>
#include <libempathy/empathy-utils.h>
#include <libempathy-gtk/empathy-images.h>
@@ -65,6 +66,7 @@
gboolean page_added;
gboolean dnd_same_window;
guint save_geometry_id;
+ EmpathyChatroomManager *chatroom_manager;
GtkWidget *dialog;
GtkWidget *notebook;
@@ -72,6 +74,7 @@
GtkWidget *menu_conv_clear;
GtkWidget *menu_conv_insert_smiley;
GtkWidget *menu_conv_contact;
+ GtkWidget *menu_conv_favorite;
GtkWidget *menu_conv_close;
GtkWidget *menu_edit_cut;
@@ -474,6 +477,7 @@
EmpathyChatWindowPriv *priv = GET_PRIV (window);
GtkWidget *submenu = NULL;
+ /* Contact submenu */
submenu = empathy_chat_get_contact_menu (priv->current_chat);
if (submenu) {
gtk_menu_item_set_submenu (GTK_MENU_ITEM (priv->menu_conv_contact),
@@ -483,6 +487,25 @@
} else {
gtk_widget_hide (priv->menu_conv_contact);
}
+
+ /* Favorite room menu */
+ if (empathy_chat_is_room (priv->current_chat)) {
+ const gchar *room;
+ McAccount *account;
+ gboolean found;
+
+ room = empathy_chat_get_id (priv->current_chat);
+ account = empathy_chat_get_account (priv->current_chat);
+ found = empathy_chatroom_manager_find (priv->chatroom_manager,
+ account, room) != NULL;
+
+ DEBUG ("This room %s favorite", found ? "is" : "is not");
+ gtk_check_menu_item_set_active (
+ GTK_CHECK_MENU_ITEM (priv->menu_conv_favorite), found);
+ gtk_widget_show (priv->menu_conv_favorite);
+ } else {
+ gtk_widget_hide (priv->menu_conv_favorite);
+ }
}
static void
@@ -494,6 +517,30 @@
empathy_chat_clear (priv->current_chat);
}
+static void
+chat_window_favorite_activate_cb (GtkWidget *menuitem,
+ EmpathyChatWindow *window)
+{
+ EmpathyChatWindowPriv *priv = GET_PRIV (window);
+ McAccount *account;
+ const gchar *room;
+ const gchar *name;
+ EmpathyChatroom *chatroom;
+
+ account = empathy_chat_get_account (priv->current_chat);
+ room = empathy_chat_get_id (priv->current_chat);
+ name = empathy_chat_get_name (priv->current_chat);
+ chatroom = empathy_chatroom_new_full (account, room, name, FALSE);
+
+ if (gtk_check_menu_item_get_active (GTK_CHECK_MENU_ITEM (priv->menu_conv_favorite))) {
+ empathy_chatroom_manager_add (priv->chatroom_manager, chatroom);
+ } else {
+ empathy_chatroom_manager_remove (priv->chatroom_manager, chatroom);
+ }
+
+ g_object_unref (chatroom);
+}
+
static const gchar *
chat_get_window_id_for_geometry (EmpathyChat *chat)
{
@@ -1069,6 +1116,7 @@
DEBUG ("Finalized: %p", object);
+ g_object_unref (priv->chatroom_manager);
if (priv->save_geometry_id != 0) {
g_source_remove (priv->save_geometry_id);
}
@@ -1126,6 +1174,7 @@
"menu_conv_clear", &priv->menu_conv_clear,
"menu_conv_insert_smiley", &priv->menu_conv_insert_smiley,
"menu_conv_contact", &priv->menu_conv_contact,
+ "menu_conv_favorite", &priv->menu_conv_favorite,
"menu_conv_close", &priv->menu_conv_close,
"menu_edit_cut", &priv->menu_edit_cut,
"menu_edit_copy", &priv->menu_edit_copy,
@@ -1145,6 +1194,7 @@
"chat_window", "configure-event", chat_window_configure_event_cb,
"menu_conv", "activate", chat_window_conv_activate_cb,
"menu_conv_clear", "activate", chat_window_clear_activate_cb,
+ "menu_conv_favorite", "activate", chat_window_favorite_activate_cb,
"menu_conv_close", "activate", chat_window_close_activate_cb,
"menu_edit", "activate", chat_window_edit_activate_cb,
"menu_edit_cut", "activate", chat_window_cut_activate_cb,
@@ -1159,6 +1209,8 @@
g_object_unref (glade);
+ priv->chatroom_manager = empathy_chatroom_manager_new ();
+
priv->notebook = gtk_notebook_new ();
gtk_notebook_set_group (GTK_NOTEBOOK (priv->notebook), "EmpathyChatWindow");
gtk_box_pack_start (GTK_BOX (chat_vbox), priv->notebook, TRUE, TRUE, 0);
Modified: trunk/src/empathy-chat-window.glade
==============================================================================
--- trunk/src/empathy-chat-window.glade (original)
+++ trunk/src/empathy-chat-window.glade Fri Aug 29 16:04:51 2008
@@ -56,6 +56,13 @@
</widget>
</child>
<child>
+ <widget class="GtkCheckMenuItem" id="menu_conv_favorite">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes">_Favorite Chatroom</property>
+ <property name="use_underline">True</property>
+ </widget>
+ </child>
+ <child>
<widget class="GtkSeparatorMenuItem" id="separator7">
<property name="visible">True</property>
</widget>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]