diff options
author | Xavier Claessens <xclaesse@src.gnome.org> | 2008-08-30 00:04:51 +0800 |
---|---|---|
committer | Xavier Claessens <xclaesse@src.gnome.org> | 2008-08-30 00:04:51 +0800 |
commit | f072481137b81850c18db4272bcc729e04dbffc0 (patch) | |
tree | 86b56e737aa86a03b43a24b04dc7172cc5c23028 /src | |
parent | 2823e63a406990540e938b477ac1dcc730c6922b (diff) | |
download | gsoc2013-empathy-f072481137b81850c18db4272bcc729e04dbffc0.tar gsoc2013-empathy-f072481137b81850c18db4272bcc729e04dbffc0.tar.gz gsoc2013-empathy-f072481137b81850c18db4272bcc729e04dbffc0.tar.bz2 gsoc2013-empathy-f072481137b81850c18db4272bcc729e04dbffc0.tar.lz gsoc2013-empathy-f072481137b81850c18db4272bcc729e04dbffc0.tar.xz gsoc2013-empathy-f072481137b81850c18db4272bcc729e04dbffc0.tar.zst gsoc2013-empathy-f072481137b81850c18db4272bcc729e04dbffc0.zip |
Add a menu item in chat window to set the room as favorite
svn path=/trunk/; revision=1401
Diffstat (limited to 'src')
-rw-r--r-- | src/empathy-chat-window.c | 52 | ||||
-rw-r--r-- | src/empathy-chat-window.glade | 7 |
2 files changed, 59 insertions, 0 deletions
diff --git a/src/empathy-chat-window.c b/src/empathy-chat-window.c index 3780629fc..73c41a9f0 100644 --- a/src/empathy-chat-window.c +++ b/src/empathy-chat-window.c @@ -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 @@ typedef struct { gboolean page_added; gboolean dnd_same_window; guint save_geometry_id; + EmpathyChatroomManager *chatroom_manager; GtkWidget *dialog; GtkWidget *notebook; @@ -72,6 +74,7 @@ typedef struct { 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 @@ chat_window_conv_activate_cb (GtkWidget *menuitem, 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 @@ chat_window_conv_activate_cb (GtkWidget *menuitem, } 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 @@ chat_window_clear_activate_cb (GtkWidget *menuitem, 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 @@ chat_window_finalize (GObject *object) 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 @@ empathy_chat_window_init (EmpathyChatWindow *window) "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 @@ empathy_chat_window_init (EmpathyChatWindow *window) "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 @@ empathy_chat_window_init (EmpathyChatWindow *window) 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); diff --git a/src/empathy-chat-window.glade b/src/empathy-chat-window.glade index 2b2e396d4..874fe3f4f 100644 --- a/src/empathy-chat-window.glade +++ b/src/empathy-chat-window.glade @@ -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> |