diff options
author | Xavier Claessens <xclaesse@gmail.com> | 2007-05-31 14:34:41 +0800 |
---|---|---|
committer | Xavier Claessens <xclaesse@src.gnome.org> | 2007-05-31 14:34:41 +0800 |
commit | 6fe758a0d83f6872585a177a2e821d4105642308 (patch) | |
tree | 50d79a5ae475063c38e4e62cdaaa3c3817220077 /libempathy-gtk | |
parent | a0c9dc2f22f510378063be5a8c872bfe8c92bd10 (diff) | |
download | gsoc2013-empathy-6fe758a0d83f6872585a177a2e821d4105642308.tar gsoc2013-empathy-6fe758a0d83f6872585a177a2e821d4105642308.tar.gz gsoc2013-empathy-6fe758a0d83f6872585a177a2e821d4105642308.tar.bz2 gsoc2013-empathy-6fe758a0d83f6872585a177a2e821d4105642308.tar.lz gsoc2013-empathy-6fe758a0d83f6872585a177a2e821d4105642308.tar.xz gsoc2013-empathy-6fe758a0d83f6872585a177a2e821d4105642308.tar.zst gsoc2013-empathy-6fe758a0d83f6872585a177a2e821d4105642308.zip |
Fix warning when selecting all accounts.
2007-05-31 Xavier Claessens <xclaesse@gmail.com>
* libempathy-gtk/gossip-account-chooser.c: Fix warning when selecting
all accounts.
* src/empathy-accounts-main.c:
* libempathy-gtk/empathy-status-icon.c:
* libempathy-gtk/gossip-accounts-dialog.h:
* libempathy-gtk/gossip-accounts-dialog.c:
* libempathy-gtk/gossip-preferences.h:
* libempathy-gtk/gossip-preferences.c: Set parent window.
* libempathy-gtk/empathy-main-window.c: Implement favorite chatroom
menu and fix a leak.
* libempathy-gtk/Makefile.am:
* libempathy/Makefile.am:
* libempathy/gossip-chatroom.c:
* libempathy/gossip-chatroom.h:
* libempathy/gossip-chatroom-manager.c:
* libempathy/gossip-chatroom-manager.h:
* libempathy/gossip-chatroom-manager.dtd:
* libempathy-gtk/gossip-chatrooms-window.glade:
* libempathy-gtk/gossip-chatrooms-window.c:
* libempathy-gtk/gossip-chatrooms-window.h: New files to implement
favorite chatrooms and a window to show them.
* libempathy-gtk/gossip-chat.c: Fix tooltip leaked.
* libempathy-gtk/gossip-chat-window.h:
* libempathy-gtk/gossip-chat-window.c: Do not use deprecated
gtk_object_sink(). Implement favorite chatroom features. Find a chat
by comparing the account AND the chat ID.
* src/empathy-chat-main.c:
* libempathy/empathy-tp-chat.h:
* libempathy/empathy-tp-chat.c:
* libempathy/gossip-utils.h:
* libempathy/gossip-utils.c: empathy_tp_chat_get_id() returns the Text
channel's name. The chat ID is unique only for a specified account.
* libempathy/empathy-tp-contact-list.c: Fix some leaks and add a FIXME
comment for a leak not yet fixed.
* TODO: Would be cool to have a glade catalog for libempathy-gtk.
svn path=/trunk/; revision=100
Diffstat (limited to 'libempathy-gtk')
-rw-r--r-- | libempathy-gtk/Makefile.am | 2 | ||||
-rw-r--r-- | libempathy-gtk/empathy-main-window.c | 270 | ||||
-rw-r--r-- | libempathy-gtk/empathy-status-icon.c | 2 | ||||
-rw-r--r-- | libempathy-gtk/gossip-account-chooser.c | 3 | ||||
-rw-r--r-- | libempathy-gtk/gossip-accounts-dialog.c | 7 | ||||
-rw-r--r-- | libempathy-gtk/gossip-accounts-dialog.h | 2 | ||||
-rw-r--r-- | libempathy-gtk/gossip-chat-window.c | 52 | ||||
-rw-r--r-- | libempathy-gtk/gossip-chat-window.h | 5 | ||||
-rw-r--r-- | libempathy-gtk/gossip-chat.c | 3 | ||||
-rw-r--r-- | libempathy-gtk/gossip-chatrooms-window.c | 530 | ||||
-rw-r--r-- | libempathy-gtk/gossip-chatrooms-window.glade | 477 | ||||
-rw-r--r-- | libempathy-gtk/gossip-chatrooms-window.h | 35 | ||||
-rw-r--r-- | libempathy-gtk/gossip-preferences.c | 7 | ||||
-rw-r--r-- | libempathy-gtk/gossip-preferences.h | 4 |
14 files changed, 1291 insertions, 108 deletions
diff --git a/libempathy-gtk/Makefile.am b/libempathy-gtk/Makefile.am index f28e7411c..183f7d8e2 100644 --- a/libempathy-gtk/Makefile.am +++ b/libempathy-gtk/Makefile.am @@ -34,6 +34,7 @@ libempathy_gtk_la_SOURCES = \ gossip-about-dialog.c gossip-about-dialog.h \ gossip-account-chooser.c gossip-account-chooser.h \ gossip-new-chatroom-dialog.c gossip-new-chatroom-dialog.h \ + gossip-chatrooms-window.c gossip-chatrooms-window.h \ gossip-ui-utils.c gossip-ui-utils.h libempathy_gtk_la_LIBADD = \ @@ -52,6 +53,7 @@ glade_DATA = \ gossip-account-widget-jabber.glade \ gossip-new-chatroom-dialog.glade \ gossip-group-chat.glade \ + gossip-chatrooms-window.glade \ gossip-chat.glade dtddir = $(datadir)/empathy diff --git a/libempathy-gtk/empathy-main-window.c b/libempathy-gtk/empathy-main-window.c index b10f6c8d6..befe2f531 100644 --- a/libempathy-gtk/empathy-main-window.c +++ b/libempathy-gtk/empathy-main-window.c @@ -31,6 +31,8 @@ #include <libempathy/gossip-contact.h> #include <libempathy/gossip-debug.h> #include <libempathy/gossip-utils.h> +#include <libempathy/gossip-chatroom-manager.h> +#include <libempathy/gossip-chatroom.h> #include <libempathy/empathy-contact-list.h> #include <libempathy/empathy-contact-manager.h> @@ -46,6 +48,7 @@ #include "gossip-accounts-dialog.h" #include "gossip-about-dialog.h" #include "gossip-new-chatroom-dialog.h" +#include "gossip-chatrooms-window.h" #define DEBUG_DOMAIN "MainWindow" @@ -62,6 +65,7 @@ typedef struct { GossipContactListView *list_view; GossipContactListStore *list_store; MissionControl *mc; + GossipChatroomManager *chatroom_manager; /* Main widgets */ GtkWidget *window; @@ -93,68 +97,79 @@ typedef struct { guint size_timeout_id; } EmpathyMainWindow; -static void main_window_destroy_cb (GtkWidget *widget, - EmpathyMainWindow *window); -static void main_window_favorite_chatroom_menu_setup (void); -static void main_window_chat_quit_cb (GtkWidget *widget, - EmpathyMainWindow *window); -static void main_window_chat_new_message_cb (GtkWidget *widget, - EmpathyMainWindow *window); -static void main_window_chat_history_cb (GtkWidget *widget, - EmpathyMainWindow *window); -static void main_window_room_join_new_cb (GtkWidget *widget, - EmpathyMainWindow *window); -static void main_window_room_join_favorites_cb (GtkWidget *widget, - EmpathyMainWindow *window); -static void main_window_room_manage_favorites_cb (GtkWidget *widget, - EmpathyMainWindow *window); -static void main_window_chat_add_contact_cb (GtkWidget *widget, - EmpathyMainWindow *window); -static void main_window_chat_show_offline_cb (GtkCheckMenuItem *item, - EmpathyMainWindow *window); -static gboolean main_window_edit_button_press_event_cb (GtkWidget *widget, - GdkEventButton *event, - EmpathyMainWindow *window); -static void main_window_edit_accounts_cb (GtkWidget *widget, - EmpathyMainWindow *window); -static void main_window_edit_personal_information_cb (GtkWidget *widget, - EmpathyMainWindow *window); -static void main_window_edit_preferences_cb (GtkWidget *widget, - EmpathyMainWindow *window); -static void main_window_help_about_cb (GtkWidget *widget, - EmpathyMainWindow *window); -static void main_window_help_contents_cb (GtkWidget *widget, - EmpathyMainWindow *window); -static gboolean main_window_throbber_button_press_event_cb (GtkWidget *throbber_ebox, - GdkEventButton *event, - gpointer user_data); -static void main_window_status_changed_cb (MissionControl *mc, - TelepathyConnectionStatus status, - McPresence presence, - TelepathyConnectionStatusReason reason, - const gchar *unique_name, - EmpathyMainWindow *window); -static void main_window_update_status (EmpathyMainWindow *window); -static void main_window_accels_load (void); -static void main_window_accels_save (void); -static void main_window_connection_items_setup (EmpathyMainWindow *window, - GladeXML *glade); -static gboolean main_window_configure_event_timeout_cb (EmpathyMainWindow *window); -static gboolean main_window_configure_event_cb (GtkWidget *widget, - GdkEventConfigure *event, - EmpathyMainWindow *window); -static void main_window_notify_show_offline_cb (GossipConf *conf, - const gchar *key, - gpointer check_menu_item); -static void main_window_notify_show_avatars_cb (GossipConf *conf, - const gchar *key, - EmpathyMainWindow *window); -static void main_window_notify_compact_contact_list_cb (GossipConf *conf, - const gchar *key, - EmpathyMainWindow *window); -static void main_window_notify_sort_criterium_cb (GossipConf *conf, - const gchar *key, - EmpathyMainWindow *window); +static void main_window_destroy_cb (GtkWidget *widget, + EmpathyMainWindow *window); +static void main_window_favorite_chatroom_menu_setup (EmpathyMainWindow *window); +static void main_window_favorite_chatroom_menu_added_cb (GossipChatroomManager *manager, + GossipChatroom *chatroom, + EmpathyMainWindow *window); +static void main_window_favorite_chatroom_menu_removed_cb (GossipChatroomManager *manager, + GossipChatroom *chatroom, + EmpathyMainWindow *window); +static void main_window_favorite_chatroom_menu_activate_cb (GtkMenuItem *menu_item, + GossipChatroom *chatroom); +static void main_window_favorite_chatroom_menu_update (EmpathyMainWindow *window); +static void main_window_favorite_chatroom_menu_add (EmpathyMainWindow *window, + GossipChatroom *chatroom); +static void main_window_chat_quit_cb (GtkWidget *widget, + EmpathyMainWindow *window); +static void main_window_chat_new_message_cb (GtkWidget *widget, + EmpathyMainWindow *window); +static void main_window_chat_history_cb (GtkWidget *widget, + EmpathyMainWindow *window); +static void main_window_room_join_new_cb (GtkWidget *widget, + EmpathyMainWindow *window); +static void main_window_room_join_favorites_cb (GtkWidget *widget, + EmpathyMainWindow *window); +static void main_window_room_manage_favorites_cb (GtkWidget *widget, + EmpathyMainWindow *window); +static void main_window_chat_add_contact_cb (GtkWidget *widget, + EmpathyMainWindow *window); +static void main_window_chat_show_offline_cb (GtkCheckMenuItem *item, + EmpathyMainWindow *window); +static gboolean main_window_edit_button_press_event_cb (GtkWidget *widget, + GdkEventButton *event, + EmpathyMainWindow *window); +static void main_window_edit_accounts_cb (GtkWidget *widget, + EmpathyMainWindow *window); +static void main_window_edit_personal_information_cb (GtkWidget *widget, + EmpathyMainWindow *window); +static void main_window_edit_preferences_cb (GtkWidget *widget, + EmpathyMainWindow *window); +static void main_window_help_about_cb (GtkWidget *widget, + EmpathyMainWindow *window); +static void main_window_help_contents_cb (GtkWidget *widget, + EmpathyMainWindow *window); +static gboolean main_window_throbber_button_press_event_cb (GtkWidget *throbber_ebox, + GdkEventButton *event, + EmpathyMainWindow *window); +static void main_window_status_changed_cb (MissionControl *mc, + TelepathyConnectionStatus status, + McPresence presence, + TelepathyConnectionStatusReason reason, + const gchar *unique_name, + EmpathyMainWindow *window); +static void main_window_update_status (EmpathyMainWindow *window); +static void main_window_accels_load (void); +static void main_window_accels_save (void); +static void main_window_connection_items_setup (EmpathyMainWindow *window, + GladeXML *glade); +static gboolean main_window_configure_event_timeout_cb (EmpathyMainWindow *window); +static gboolean main_window_configure_event_cb (GtkWidget *widget, + GdkEventConfigure *event, + EmpathyMainWindow *window); +static void main_window_notify_show_offline_cb (GossipConf *conf, + const gchar *key, + gpointer check_menu_item); +static void main_window_notify_show_avatars_cb (GossipConf *conf, + const gchar *key, + EmpathyMainWindow *window); +static void main_window_notify_compact_contact_list_cb (GossipConf *conf, + const gchar *key, + EmpathyMainWindow *window); +static void main_window_notify_sort_criterium_cb (GossipConf *conf, + const gchar *key, + EmpathyMainWindow *window); GtkWidget * empathy_main_window_show (void) @@ -227,7 +242,7 @@ empathy_main_window_show (void) window, NULL); /* Set up menu */ - main_window_favorite_chatroom_menu_setup (); + main_window_favorite_chatroom_menu_setup (window); gtk_widget_hide (window->edit_context); gtk_widget_hide (window->edit_context_separator); @@ -263,7 +278,7 @@ empathy_main_window_show (void) g_signal_connect (ebox, "button-press-event", G_CALLBACK (main_window_throbber_button_press_event_cb), - NULL); + window); /* Set up contact list. */ gossip_status_presets_get_all (); @@ -374,8 +389,116 @@ main_window_destroy_cb (GtkWidget *widget, } static void -main_window_favorite_chatroom_menu_setup (void) +main_window_favorite_chatroom_menu_setup (EmpathyMainWindow *window) { + GList *chatrooms, *l; + + window->chatroom_manager = gossip_chatroom_manager_new (); + chatrooms = gossip_chatroom_manager_get_chatrooms (window->chatroom_manager, NULL); + window->room_menu = gtk_menu_item_get_submenu (GTK_MENU_ITEM (window->room)); + + for (l = chatrooms; l; l = l->next) { + main_window_favorite_chatroom_menu_add (window, l->data); + } + + if (!chatrooms) { + gtk_widget_hide (window->room_sep); + } + + gtk_widget_set_sensitive (window->room_join_favorites, chatrooms != NULL); + + g_signal_connect (window->chatroom_manager, "chatroom-added", + G_CALLBACK (main_window_favorite_chatroom_menu_added_cb), + window); + g_signal_connect (window->chatroom_manager, "chatroom-removed", + G_CALLBACK (main_window_favorite_chatroom_menu_removed_cb), + window); + + g_list_free (chatrooms); +} + +static void +main_window_favorite_chatroom_menu_added_cb (GossipChatroomManager *manager, + GossipChatroom *chatroom, + EmpathyMainWindow *window) +{ + main_window_favorite_chatroom_menu_add (window, chatroom); + gtk_widget_show (window->room_sep); + gtk_widget_set_sensitive (window->room_join_favorites, TRUE); +} + +static void +main_window_favorite_chatroom_menu_removed_cb (GossipChatroomManager *manager, + GossipChatroom *chatroom, + EmpathyMainWindow *window) +{ + GtkWidget *menu_item; + + menu_item = g_object_get_data (G_OBJECT (chatroom), "menu_item"); + + g_object_set_data (G_OBJECT (chatroom), "menu_item", NULL); + gtk_widget_destroy (menu_item); + + main_window_favorite_chatroom_menu_update (window); +} + +static void +main_window_favorite_chatroom_menu_activate_cb (GtkMenuItem *menu_item, + GossipChatroom *chatroom) +{ +/*FIXME: + GossipSession *session; + GossipAccount *account; + GossipChatroomProvider *provider; + + session = gossip_app_get_session (); + account = gossip_chatroom_get_account (chatroom); + provider = gossip_session_get_chatroom_provider (session, account); + + gossip_group_chat_new (provider, chatroom); +*/ +} + +static void +main_window_favorite_chatroom_menu_update (EmpathyMainWindow *window) +{ + GList *chatrooms; + + chatrooms = gossip_chatroom_manager_get_chatrooms (window->chatroom_manager, NULL); + + if (chatrooms) { + gtk_widget_show (window->room_sep); + } else { + gtk_widget_hide (window->room_sep); + } + + gtk_widget_set_sensitive (window->room_join_favorites, chatrooms != NULL); + g_list_free (chatrooms); +} + +static void +main_window_favorite_chatroom_menu_add (EmpathyMainWindow *window, + GossipChatroom *chatroom) +{ + GtkWidget *menu_item; + const gchar *name; + + if (g_object_get_data (G_OBJECT (chatroom), "menu_item")) { + return; + } + + name = gossip_chatroom_get_name (chatroom); + menu_item = gtk_menu_item_new_with_label (name); + + g_object_set_data (G_OBJECT (chatroom), "menu_item", menu_item); + g_signal_connect (menu_item, "activate", + G_CALLBACK (main_window_favorite_chatroom_menu_activate_cb), + chatroom); + + gtk_menu_shell_insert (GTK_MENU_SHELL (window->room_menu), + menu_item, 3); + + gtk_widget_show (menu_item); } static void @@ -417,7 +540,7 @@ static void main_window_room_manage_favorites_cb (GtkWidget *widget, EmpathyMainWindow *window) { - //gossip_chatrooms_window_show (NULL, FALSE); + gossip_chatrooms_window_show (GTK_WINDOW (window->window)); } static void @@ -510,7 +633,7 @@ static void main_window_edit_accounts_cb (GtkWidget *widget, EmpathyMainWindow *window) { - gossip_accounts_dialog_show (); + gossip_accounts_dialog_show (GTK_WINDOW (window->window)); } static void @@ -524,7 +647,7 @@ static void main_window_edit_preferences_cb (GtkWidget *widget, EmpathyMainWindow *window) { - gossip_preferences_show (); + gossip_preferences_show (GTK_WINDOW (window->window)); } static void @@ -542,16 +665,16 @@ main_window_help_contents_cb (GtkWidget *widget, } static gboolean -main_window_throbber_button_press_event_cb (GtkWidget *throbber_ebox, - GdkEventButton *event, - gpointer user_data) +main_window_throbber_button_press_event_cb (GtkWidget *throbber_ebox, + GdkEventButton *event, + EmpathyMainWindow *window) { if (event->type != GDK_BUTTON_PRESS || event->button != 1) { return FALSE; } - gossip_accounts_dialog_show (); + gossip_accounts_dialog_show (GTK_WINDOW (window->window)); return FALSE; } @@ -614,8 +737,6 @@ main_window_update_status (EmpathyMainWindow *window) for (l = window->widgets_disconnected; l; l = l->next) { gtk_widget_set_sensitive (l->data, (disconnected > 0)); } - - //app_favorite_chatroom_menu_update (); } /* @@ -768,6 +889,7 @@ main_window_notify_sort_criterium_cb (GossipConf *conf, type = gossip_contact_list_store_sort_get_type (); enum_class = G_ENUM_CLASS (g_type_class_peek (type)); enum_value = g_enum_get_value_by_nick (enum_class, str); + g_free (str); if (enum_value) { gossip_contact_list_store_set_sort_criterium (window->list_store, diff --git a/libempathy-gtk/empathy-status-icon.c b/libempathy-gtk/empathy-status-icon.c index 21082276a..01a542493 100644 --- a/libempathy-gtk/empathy-status-icon.c +++ b/libempathy-gtk/empathy-status-icon.c @@ -231,7 +231,7 @@ status_icon_toggle_visibility (EmpathyStatusIcon *icon) } else { gossip_debug (DEBUG_DOMAIN, "No enabled account, Showing account dialog"); - gossip_accounts_dialog_show (); + gossip_accounts_dialog_show (GTK_WINDOW (priv->window)); } } } diff --git a/libempathy-gtk/gossip-account-chooser.c b/libempathy-gtk/gossip-account-chooser.c index 9cb8e5d41..dfed1bb54 100644 --- a/libempathy-gtk/gossip-account-chooser.c +++ b/libempathy-gtk/gossip-account-chooser.c @@ -593,6 +593,9 @@ account_chooser_set_account_foreach (GtkTreeModel *model, /* Special case so we can make it possible to select the All option */ if (!data->account && !account) { equal = TRUE; + } + else if ((data->account && !account) || (!data->account && account)) { + equal = FALSE; } else { equal = gossip_account_equal (data->account, account); g_object_unref (account); diff --git a/libempathy-gtk/gossip-accounts-dialog.c b/libempathy-gtk/gossip-accounts-dialog.c index 6d7934544..2a3a92764 100644 --- a/libempathy-gtk/gossip-accounts-dialog.c +++ b/libempathy-gtk/gossip-accounts-dialog.c @@ -944,7 +944,7 @@ accounts_dialog_destroy_cb (GtkWidget *widget, } GtkWidget * -gossip_accounts_dialog_show (void) +gossip_accounts_dialog_show (GtkWindow *parent) { static GossipAccountsDialog *dialog = NULL; GladeXML *glade; @@ -1026,6 +1026,11 @@ gossip_accounts_dialog_show (void) accounts_dialog_setup (dialog); accounts_dialog_model_select_first (dialog); + if (parent) { + gtk_window_set_transient_for (GTK_WINDOW (dialog->window), + GTK_WINDOW (parent)); + } + gtk_widget_show (dialog->window); return dialog->window; diff --git a/libempathy-gtk/gossip-accounts-dialog.h b/libempathy-gtk/gossip-accounts-dialog.h index e78b33506..5b058e6a4 100644 --- a/libempathy-gtk/gossip-accounts-dialog.h +++ b/libempathy-gtk/gossip-accounts-dialog.h @@ -28,7 +28,7 @@ G_BEGIN_DECLS -GtkWidget *gossip_accounts_dialog_show (void); +GtkWidget *gossip_accounts_dialog_show (GtkWindow *parent); G_END_DECLS diff --git a/libempathy-gtk/gossip-chat-window.c b/libempathy-gtk/gossip-chat-window.c index 35f3f9ae7..6979e450e 100644 --- a/libempathy-gtk/gossip-chat-window.c +++ b/libempathy-gtk/gossip-chat-window.c @@ -36,10 +36,12 @@ #include <libempathy/empathy-contact-manager.h> #include <libempathy/empathy-contact-list.h> +#include <libempathy/gossip-chatroom-manager.h> #include <libempathy/gossip-contact.h> #include <libempathy/gossip-debug.h> #include <libempathy/gossip-message.h> #include <libempathy/gossip-conf.h> +#include <libempathy/gossip-utils.h> #include "gossip-chat-window.h" #include "empathy-images.h" @@ -274,8 +276,7 @@ gossip_chat_window_init (GossipChatWindow *window) priv = GET_PRIV (window); - priv->tooltips = g_object_ref (gtk_tooltips_new ()); - gtk_object_sink (GTK_OBJECT (priv->tooltips)); + priv->tooltips = g_object_ref_sink (gtk_tooltips_new ()); glade = gossip_glade_get_file ("gossip-chat.glade", "chat_window", @@ -762,9 +763,10 @@ chat_window_update_menu (GossipChatWindow *window) is_connected = gossip_chat_is_connected (priv->current_chat); if (gossip_chat_is_group_chat (priv->current_chat)) { - GossipGroupChat *group_chat; - gboolean saved = TRUE; - gboolean show_contacts; + GossipGroupChat *group_chat; + GossipChatroom *chatroom; + GossipChatroomManager *manager; + gboolean show_contacts; group_chat = GOSSIP_GROUP_CHAT (priv->current_chat); @@ -778,13 +780,13 @@ chat_window_update_menu (GossipChatWindow *window) /* Can we add this room to our favourites and are we * connected to the room? */ - /* FIXME: - manager = gossip_app_get_chatroom_manager (); - id = gossip_chatroom_get_id (chatroom); - saved = gossip_chatroom_manager_find (manager, id) != NULL; - */ + manager = gossip_chatroom_manager_new (); + chatroom = gossip_chatroom_manager_find (manager, + priv->current_chat->account, + gossip_chat_get_id (priv->current_chat)); + g_object_unref (manager); - gtk_widget_set_sensitive (priv->menu_room_add, !saved); + gtk_widget_set_sensitive (priv->menu_room_add, chatroom == NULL); gtk_widget_set_sensitive (priv->menu_conv_insert_smiley, is_connected); gtk_widget_set_sensitive (priv->menu_room_join_new, is_connected); gtk_widget_set_sensitive (priv->menu_room_invite, is_connected); @@ -1079,9 +1081,7 @@ static void chat_window_room_add_activate_cb (GtkWidget *menuitem, GossipChatWindow *window) { -/* FIXME: GossipChatWindowPriv *priv; - GossipGroupChat *group_chat; GossipChatroomManager *manager; GossipChatroom *chatroom; @@ -1093,16 +1093,17 @@ chat_window_room_add_activate_cb (GtkWidget *menuitem, return; } - group_chat = GOSSIP_GROUP_CHAT (priv->current_chat); - chatroom = gossip_group_chat_get_chatroom (group_chat); - gossip_chatroom_set_favourite (chatroom, TRUE); + chatroom = gossip_chatroom_new_full (priv->current_chat->account, + gossip_chat_get_id (priv->current_chat), + gossip_chat_get_name (priv->current_chat), + FALSE); - manager = gossip_app_get_chatroom_manager (); + manager = gossip_chatroom_manager_new (); gossip_chatroom_manager_add (manager, chatroom); - gossip_chatroom_manager_store (manager); - chat_window_update_menu (window); -*/ + + g_object_unref (chatroom); + g_object_unref (manager); } static void @@ -1597,7 +1598,6 @@ chat_window_drag_data_received (GtkWidget *widget, GossipChatWindow *old_window; McAccount *account; const gchar *id = NULL; - gchar *chat_id; if (selection) { id = (const gchar*) selection->data; @@ -1615,10 +1615,8 @@ chat_window_drag_data_received (GtkWidget *widget, } account = gossip_contact_get_account (contact); - chat_id = empathy_tp_chat_build_id (account, id); - chat = gossip_chat_window_find_chat_by_id (chat_id); + chat = gossip_chat_window_find_chat (account, id); old_window = gossip_chat_get_window (chat); - g_free (chat_id); if (old_window) { if (old_window == window) { @@ -1882,7 +1880,8 @@ gossip_chat_window_has_focus (GossipChatWindow *window) } GossipChat * -gossip_chat_window_find_chat_by_id (const gchar *id) +gossip_chat_window_find_chat (McAccount *account, + const gchar *id) { GList *l; @@ -1899,7 +1898,8 @@ gossip_chat_window_find_chat_by_id (const gchar *id) chat = ll->data; - if (strcmp (id, gossip_chat_get_id (chat)) == 0) { + if (gossip_account_equal (account, chat->account) && + strcmp (id, gossip_chat_get_id (chat)) == 0) { return chat; } } diff --git a/libempathy-gtk/gossip-chat-window.h b/libempathy-gtk/gossip-chat-window.h index 18b06ad90..b58e5dac3 100644 --- a/libempathy-gtk/gossip-chat-window.h +++ b/libempathy-gtk/gossip-chat-window.h @@ -30,6 +30,8 @@ #include <glib-object.h> +#include <libmissioncontrol/mc-account.h> + G_BEGIN_DECLS #define GOSSIP_TYPE_CHAT_WINDOW (gossip_chat_window_get_type ()) @@ -70,7 +72,8 @@ void gossip_chat_window_move_chat (GossipChatWindow *old_wind void gossip_chat_window_switch_to_chat (GossipChatWindow *window, GossipChat *chat); gboolean gossip_chat_window_has_focus (GossipChatWindow *window); -GossipChat * gossip_chat_window_find_chat_by_id (const gchar *id); +GossipChat * gossip_chat_window_find_chat (McAccount *account, + const gchar *id); G_END_DECLS diff --git a/libempathy-gtk/gossip-chat.c b/libempathy-gtk/gossip-chat.c index 4072b6eae..a29c31818 100644 --- a/libempathy-gtk/gossip-chat.c +++ b/libempathy-gtk/gossip-chat.c @@ -228,7 +228,7 @@ gossip_chat_init (GossipChat *chat) priv = GET_PRIV (chat); priv->manager = empathy_contact_manager_new (); - priv->tooltips = gtk_tooltips_new (); + priv->tooltips = g_object_ref_sink (gtk_tooltips_new ()); priv->default_window_height = -1; priv->vscroll_visible = FALSE; priv->sensitive = TRUE; @@ -337,6 +337,7 @@ chat_finalize (GObject *object) chat_composing_remove_timeout (chat); g_object_unref (chat->account); g_object_unref (priv->manager); + g_object_unref (priv->tooltips); if (priv->tp_chat) { g_object_unref (priv->tp_chat); diff --git a/libempathy-gtk/gossip-chatrooms-window.c b/libempathy-gtk/gossip-chatrooms-window.c new file mode 100644 index 000000000..5ff5d8812 --- /dev/null +++ b/libempathy-gtk/gossip-chatrooms-window.c @@ -0,0 +1,530 @@ +/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ +/* + * Copyright (C) 2004-2007 Imendio AB + * Copyright (C) 2007 Collabora Ltd. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + * + * Authors: Xavier Claessens <xclaesse@gmail.com> + * Martyn Russell <martyn@imendio.com> + * Mikael Hallendal <micke@imendio.com> + */ + +#include "config.h" + +#include <string.h> +#include <stdio.h> + +#include <gtk/gtk.h> +#include <glade/glade.h> +#include <glib.h> +#include <glib/gi18n.h> + +#include <libempathy/gossip-chatroom-manager.h> +#include <libempathy/gossip-utils.h> + +#include "gossip-account-chooser.h" +#include "gossip-chatrooms-window.h" +//#include "gossip-edit-chatroom-dialog.h" +#include "gossip-new-chatroom-dialog.h" +#include "gossip-ui-utils.h" + +typedef struct { + GossipChatroomManager *manager; + + GtkWidget *window; + GtkWidget *hbox_account; + GtkWidget *label_account; + GtkWidget *account_chooser; + GtkWidget *treeview; + GtkWidget *button_remove; + GtkWidget *button_edit; + GtkWidget *button_close; + + gint room_column; +} GossipChatroomsWindow; + +static void chatrooms_window_destroy_cb (GtkWidget *widget, + GossipChatroomsWindow *window); +static void chatrooms_window_model_setup (GossipChatroomsWindow *window); +static void chatrooms_window_model_add_columns (GossipChatroomsWindow *window); +static void chatrooms_window_model_refresh_data (GossipChatroomsWindow *window, + gboolean first_time); +static void chatrooms_window_model_add (GossipChatroomsWindow *window, + GossipChatroom *chatroom, + gboolean set_active); +static void chatrooms_window_model_cell_auto_connect_toggled (GtkCellRendererToggle *cell, + gchar *path_string, + GossipChatroomsWindow *window); +static GossipChatroom * chatrooms_window_model_get_selected (GossipChatroomsWindow *window); +static void chatrooms_window_model_action_selected (GossipChatroomsWindow *window); +static void chatrooms_window_row_activated_cb (GtkTreeView *tree_view, + GtkTreePath *path, + GtkTreeViewColumn *column, + GossipChatroomsWindow *window); +static void chatrooms_window_button_remove_clicked_cb (GtkWidget *widget, + GossipChatroomsWindow *window); +static void chatrooms_window_button_edit_clicked_cb (GtkWidget *widget, + GossipChatroomsWindow *window); +static void chatrooms_window_button_close_clicked_cb (GtkWidget *widget, + GossipChatroomsWindow *window); +static void chatrooms_window_chatroom_added_cb (GossipChatroomManager *manager, + GossipChatroom *chatroom, + GossipChatroomsWindow *window); +static void chatrooms_window_account_changed_cb (GtkWidget *combo_box, + GossipChatroomsWindow *window); + +enum { + COL_IMAGE, + COL_NAME, + COL_ROOM, + COL_AUTO_CONNECT, + COL_POINTER, + COL_COUNT +}; + +void +gossip_chatrooms_window_show (GtkWindow *parent) +{ + static GossipChatroomsWindow *window = NULL; + GladeXML *glade; + + if (window) { + gtk_window_present (GTK_WINDOW (window->window)); + return; + } + + window = g_new0 (GossipChatroomsWindow, 1); + + glade = gossip_glade_get_file ("gossip-chatrooms-window.glade", + "chatrooms_window", + NULL, + "chatrooms_window", &window->window, + "hbox_account", &window->hbox_account, + "label_account", &window->label_account, + "treeview", &window->treeview, + "button_edit", &window->button_edit, + "button_remove", &window->button_remove, + "button_close", &window->button_close, + NULL); + + gossip_glade_connect (glade, + window, + "chatrooms_window", "destroy", chatrooms_window_destroy_cb, + "button_remove", "clicked", chatrooms_window_button_remove_clicked_cb, + "button_edit", "clicked", chatrooms_window_button_edit_clicked_cb, + "button_close", "clicked", chatrooms_window_button_close_clicked_cb, + NULL); + + g_object_unref (glade); + + g_object_add_weak_pointer (G_OBJECT (window->window), (gpointer) &window); + + /* Get the session and chat room manager */ + window->manager = gossip_chatroom_manager_new (); + + g_signal_connect (window->manager, "chatroom-added", + G_CALLBACK (chatrooms_window_chatroom_added_cb), + window); + + /* Account chooser for chat rooms */ + window->account_chooser = gossip_account_chooser_new (); + gossip_account_chooser_set_account (GOSSIP_ACCOUNT_CHOOSER (window->account_chooser), NULL); + g_object_set (window->account_chooser, + "can-select-all", TRUE, + "has-all-option", TRUE, + NULL); + + gtk_box_pack_start (GTK_BOX (window->hbox_account), + window->account_chooser, + TRUE, TRUE, 0); + + g_signal_connect (window->account_chooser, "changed", + G_CALLBACK (chatrooms_window_account_changed_cb), + window); + + gtk_widget_show (window->account_chooser); + + /* Set up chatrooms */ + chatrooms_window_model_setup (window); + + /* Set focus */ + gtk_widget_grab_focus (window->treeview); + + /* Last touches */ + if (parent) { + gtk_window_set_transient_for (GTK_WINDOW (window->window), + GTK_WINDOW (parent)); + } + + gtk_widget_show (window->window); +} + +static void +chatrooms_window_destroy_cb (GtkWidget *widget, + GossipChatroomsWindow *window) +{ + g_object_unref (window->manager); + g_free (window); +} + +static void +chatrooms_window_model_setup (GossipChatroomsWindow *window) +{ + GtkTreeView *view; + GtkListStore *store; + GtkTreeSelection *selection; + + /* View */ + view = GTK_TREE_VIEW (window->treeview); + + g_signal_connect (view, "row-activated", + G_CALLBACK (chatrooms_window_row_activated_cb), + window); + + /* Store */ + store = gtk_list_store_new (COL_COUNT, + G_TYPE_STRING, /* Image */ + G_TYPE_STRING, /* Name */ + G_TYPE_STRING, /* Room */ + G_TYPE_BOOLEAN, /* Auto start */ + GOSSIP_TYPE_CHATROOM); /* Chatroom */ + + gtk_tree_view_set_model (view, GTK_TREE_MODEL (store)); + + /* Selection */ + selection = gtk_tree_view_get_selection (view); + gtk_tree_selection_set_mode (selection, GTK_SELECTION_SINGLE); + + /* Columns */ + chatrooms_window_model_add_columns (window); + + /* Add data */ + chatrooms_window_model_refresh_data (window, TRUE); + + /* Clean up */ + g_object_unref (store); +} + +static void +chatrooms_window_model_add_columns (GossipChatroomsWindow *window) +{ + GtkTreeView *view; + GtkTreeModel *model; + GtkTreeViewColumn *column; + GtkCellRenderer *cell; + gint count; + + view = GTK_TREE_VIEW (window->treeview); + model = gtk_tree_view_get_model (view); + + gtk_tree_view_set_headers_visible (view, TRUE); + gtk_tree_view_set_headers_clickable (view, TRUE); + + /* Name & Status */ + column = gtk_tree_view_column_new (); + count = gtk_tree_view_append_column (view, column); + + gtk_tree_view_column_set_title (column, _("Name")); + gtk_tree_view_column_set_expand (column, TRUE); + gtk_tree_view_column_set_sort_column_id (column, count - 1); + + cell = gtk_cell_renderer_pixbuf_new (); + gtk_tree_view_column_pack_start (column, cell, FALSE); + gtk_tree_view_column_add_attribute (column, cell, "icon-name", COL_IMAGE); + + cell = gtk_cell_renderer_text_new (); + g_object_set (cell, + "xpad", 4, + "ypad", 1, + NULL); + gtk_tree_view_column_pack_start (column, cell, TRUE); + gtk_tree_view_column_add_attribute (column, cell, "text", COL_NAME); + + /* Room */ + cell = gtk_cell_renderer_text_new (); + column = gtk_tree_view_column_new_with_attributes (_("Room"), cell, + "text", COL_ROOM, + NULL); + count = gtk_tree_view_append_column (view, column); + gtk_tree_view_column_set_sort_column_id (column, count - 1); + window->room_column = count - 1; + + /* Chatroom auto connect */ + cell = gtk_cell_renderer_toggle_new (); + column = gtk_tree_view_column_new_with_attributes (_("Auto Connect"), cell, + "active", COL_AUTO_CONNECT, + NULL); + count = gtk_tree_view_append_column (view, column); + gtk_tree_view_column_set_sort_column_id (column, count - 1); + + g_signal_connect (cell, "toggled", + G_CALLBACK (chatrooms_window_model_cell_auto_connect_toggled), + window); + + /* Sort model */ + gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (model), 0, + GTK_SORT_ASCENDING); +} + +static void +chatrooms_window_model_refresh_data (GossipChatroomsWindow *window, + gboolean first_time) +{ + GtkTreeView *view; + GtkTreeSelection *selection; + GtkTreeModel *model; + GtkListStore *store; + GtkTreeIter iter; + GtkTreeViewColumn *column; + GossipAccountChooser *account_chooser; + McAccount *account; + GList *chatrooms, *l; + + view = GTK_TREE_VIEW (window->treeview); + selection = gtk_tree_view_get_selection (view); + model = gtk_tree_view_get_model (view); + store = GTK_LIST_STORE (model); + + /* Look up chatrooms */ + account_chooser = GOSSIP_ACCOUNT_CHOOSER (window->account_chooser); + account = gossip_account_chooser_get_account (account_chooser); + + chatrooms = gossip_chatroom_manager_get_chatrooms (window->manager, account); + + /* Sort out columns, we only show the server column for + * selected protocol types, such as Jabber. + */ + if (account) { + column = gtk_tree_view_get_column (view, window->room_column); + gtk_tree_view_column_set_visible (column, TRUE); + } else { + column = gtk_tree_view_get_column (view, window->room_column); + gtk_tree_view_column_set_visible (column, FALSE); + } + + /* Clean out the store */ + gtk_list_store_clear (store); + + /* Populate with chatroom list. */ + for (l = chatrooms; l; l = l->next) { + chatrooms_window_model_add (window, l->data, FALSE); + } + + if (gtk_tree_model_get_iter_first (model, &iter)) { + gtk_tree_selection_select_iter (selection, &iter); + } + + if (account) { + g_object_unref (account); + } + + g_list_free (chatrooms); +} + +static void +chatrooms_window_model_add (GossipChatroomsWindow *window, + GossipChatroom *chatroom, + gboolean set_active) +{ + GtkTreeView *view; + GtkTreeModel *model; + GtkTreeSelection *selection; + GtkListStore *store; + GtkTreeIter iter; + + view = GTK_TREE_VIEW (window->treeview); + selection = gtk_tree_view_get_selection (view); + model = gtk_tree_view_get_model (view); + store = GTK_LIST_STORE (model); + + gtk_list_store_append (store, &iter); + gtk_list_store_set (store, &iter, + COL_NAME, gossip_chatroom_get_name (chatroom), + COL_ROOM, gossip_chatroom_get_room (chatroom), + COL_AUTO_CONNECT, gossip_chatroom_get_auto_connect (chatroom), + COL_POINTER, chatroom, + -1); + + if (set_active) { + gtk_tree_selection_select_iter (selection, &iter); + } +} + +static void +chatrooms_window_model_cell_auto_connect_toggled (GtkCellRendererToggle *cell, + gchar *path_string, + GossipChatroomsWindow *window) +{ + GossipChatroom *chatroom; + gboolean enabled; + GtkTreeView *view; + GtkTreeModel *model; + GtkListStore *store; + GtkTreePath *path; + GtkTreeIter iter; + + view = GTK_TREE_VIEW (window->treeview); + model = gtk_tree_view_get_model (view); + store = GTK_LIST_STORE (model); + + path = gtk_tree_path_new_from_string (path_string); + + gtk_tree_model_get_iter (model, &iter, path); + gtk_tree_model_get (model, &iter, + COL_AUTO_CONNECT, &enabled, + COL_POINTER, &chatroom, + -1); + + enabled = !enabled; + + gossip_chatroom_set_auto_connect (chatroom, enabled); + gossip_chatroom_manager_store (window->manager); + + gtk_list_store_set (store, &iter, COL_AUTO_CONNECT, enabled, -1); + gtk_tree_path_free (path); + g_object_unref (chatroom); +} + +static GossipChatroom * +chatrooms_window_model_get_selected (GossipChatroomsWindow *window) +{ + GtkTreeView *view; + GtkTreeModel *model; + GtkTreeSelection *selection; + GtkTreeIter iter; + GossipChatroom *chatroom = NULL; + + view = GTK_TREE_VIEW (window->treeview); + selection = gtk_tree_view_get_selection (view); + + if (gtk_tree_selection_get_selected (selection, &model, &iter)) { + gtk_tree_model_get (model, &iter, COL_POINTER, &chatroom, -1); + } + + return chatroom; +} + +static void +chatrooms_window_model_action_selected (GossipChatroomsWindow *window) +{ + GossipChatroom *chatroom; + GtkTreeView *view; + GtkTreeModel *model; + + view = GTK_TREE_VIEW (window->treeview); + model = gtk_tree_view_get_model (view); + + chatroom = chatrooms_window_model_get_selected (window); + if (!chatroom) { + return; + } + + //gossip_edit_chatroom_dialog_show (GTK_WINDOW (window->window), chatroom); + + g_object_unref (chatroom); +} + +static void +chatrooms_window_row_activated_cb (GtkTreeView *tree_view, + GtkTreePath *path, + GtkTreeViewColumn *column, + GossipChatroomsWindow *window) +{ + if (GTK_WIDGET_IS_SENSITIVE (window->button_edit)) { + chatrooms_window_model_action_selected (window); + } +} + +static void +chatrooms_window_button_remove_clicked_cb (GtkWidget *widget, + GossipChatroomsWindow *window) +{ + GossipChatroom *chatroom; + GtkTreeView *view; + GtkTreeModel *model; + GtkTreeSelection *selection; + GtkTreeIter iter; + + /* Remove from treeview */ + view = GTK_TREE_VIEW (window->treeview); + selection = gtk_tree_view_get_selection (view); + + if (!gtk_tree_selection_get_selected (selection, &model, &iter)) { + return; + } + + gtk_tree_model_get (model, &iter, COL_POINTER, &chatroom, -1); + gtk_list_store_remove (GTK_LIST_STORE (model), &iter); + + /* Remove from config */ + gossip_chatroom_manager_remove (window->manager, chatroom); + + g_object_unref (chatroom); +} + +static void +chatrooms_window_button_edit_clicked_cb (GtkWidget *widget, + GossipChatroomsWindow *window) +{ + GossipChatroom *chatroom; + + chatroom = chatrooms_window_model_get_selected (window); + if (!chatroom) { + return; + } + + //gossip_edit_chatroom_dialog_show (GTK_WINDOW (window->window), chatroom); + + g_object_unref (chatroom); +} + +static void +chatrooms_window_button_close_clicked_cb (GtkWidget *widget, + GossipChatroomsWindow *window) +{ + gtk_widget_destroy (window->window); +} + +static void +chatrooms_window_chatroom_added_cb (GossipChatroomManager *manager, + GossipChatroom *chatroom, + GossipChatroomsWindow *window) +{ + GossipAccountChooser *account_chooser; + McAccount *account; + + account_chooser = GOSSIP_ACCOUNT_CHOOSER (window->account_chooser); + account = gossip_account_chooser_get_account (account_chooser); + + if (!account) { + chatrooms_window_model_add (window, chatroom, FALSE); + } else { + if (gossip_account_equal (account, gossip_chatroom_get_account (chatroom))) { + chatrooms_window_model_add (window, chatroom, FALSE); + } + + g_object_unref (account); + } +} + +static void +chatrooms_window_account_changed_cb (GtkWidget *combo_box, + GossipChatroomsWindow *window) +{ + chatrooms_window_model_refresh_data (window, FALSE); +} + diff --git a/libempathy-gtk/gossip-chatrooms-window.glade b/libempathy-gtk/gossip-chatrooms-window.glade new file mode 100644 index 000000000..ad2971e00 --- /dev/null +++ b/libempathy-gtk/gossip-chatrooms-window.glade @@ -0,0 +1,477 @@ +<?xml version="1.0" standalone="no"?> <!--*- mode: xml -*--> +<!DOCTYPE glade-interface SYSTEM "http://glade.gnome.org/glade-2.0.dtd"> + +<glade-interface> + +<widget class="GtkDialog" id="edit_chatroom_dialog"> + <property name="border_width">5</property> + <property name="visible">True</property> + <property name="title" translatable="yes">Edit Favorite Room</property> + <property name="type">GTK_WINDOW_TOPLEVEL</property> + <property name="window_position">GTK_WIN_POS_NONE</property> + <property name="modal">False</property> + <property name="resizable">False</property> + <property name="destroy_with_parent">False</property> + <property name="icon_name">gtk-edit</property> + <property name="decorated">True</property> + <property name="skip_taskbar_hint">False</property> + <property name="skip_pager_hint">False</property> + <property name="type_hint">GDK_WINDOW_TYPE_HINT_DIALOG</property> + <property name="gravity">GDK_GRAVITY_NORTH_WEST</property> + <property name="focus_on_map">True</property> + <property name="urgency_hint">False</property> + <property name="has_separator">False</property> + + <child internal-child="vbox"> + <widget class="GtkVBox" id="dialog-vbox3"> + <property name="visible">True</property> + <property name="homogeneous">False</property> + <property name="spacing">2</property> + + <child internal-child="action_area"> + <widget class="GtkHButtonBox" id="dialog-action_area3"> + <property name="visible">True</property> + <property name="layout_style">GTK_BUTTONBOX_END</property> + + <child> + <widget class="GtkButton" id="button_cancel"> + <property name="visible">True</property> + <property name="can_default">True</property> + <property name="can_focus">True</property> + <property name="label">gtk-cancel</property> + <property name="use_stock">True</property> + <property name="relief">GTK_RELIEF_NORMAL</property> + <property name="focus_on_click">True</property> + <property name="response_id">-6</property> + </widget> + </child> + + <child> + <widget class="GtkButton" id="button_save"> + <property name="visible">True</property> + <property name="can_default">True</property> + <property name="can_focus">True</property> + <property name="label">gtk-save</property> + <property name="use_stock">True</property> + <property name="relief">GTK_RELIEF_NORMAL</property> + <property name="focus_on_click">True</property> + <property name="response_id">-5</property> + </widget> + </child> + </widget> + <packing> + <property name="padding">0</property> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="pack_type">GTK_PACK_END</property> + </packing> + </child> + + <child> + <widget class="GtkTable" id="table4"> + <property name="border_width">5</property> + <property name="visible">True</property> + <property name="n_rows">5</property> + <property name="n_columns">2</property> + <property name="homogeneous">False</property> + <property name="row_spacing">6</property> + <property name="column_spacing">12</property> + + <child> + <widget class="GtkEntry" id="entry_room"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="editable">True</property> + <property name="visibility">True</property> + <property name="max_length">0</property> + <property name="text" translatable="yes"></property> + <property name="has_frame">True</property> + <property name="invisible_char">*</property> + <property name="activates_default">False</property> + </widget> + <packing> + <property name="left_attach">1</property> + <property name="right_attach">2</property> + <property name="top_attach">3</property> + <property name="bottom_attach">4</property> + <property name="y_options"></property> + </packing> + </child> + + <child> + <widget class="GtkEntry" id="entry_server"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="editable">True</property> + <property name="visibility">True</property> + <property name="max_length">0</property> + <property name="text" translatable="yes"></property> + <property name="has_frame">True</property> + <property name="invisible_char">*</property> + <property name="activates_default">False</property> + </widget> + <packing> + <property name="left_attach">1</property> + <property name="right_attach">2</property> + <property name="top_attach">2</property> + <property name="bottom_attach">3</property> + <property name="y_options"></property> + </packing> + </child> + + <child> + <widget class="GtkEntry" id="entry_nickname"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="editable">True</property> + <property name="visibility">True</property> + <property name="max_length">0</property> + <property name="text" translatable="yes"></property> + <property name="has_frame">True</property> + <property name="invisible_char">*</property> + <property name="activates_default">False</property> + </widget> + <packing> + <property name="left_attach">1</property> + <property name="right_attach">2</property> + <property name="top_attach">1</property> + <property name="bottom_attach">2</property> + <property name="y_options"></property> + </packing> + </child> + + <child> + <widget class="GtkLabel" id="label_room"> + <property name="visible">True</property> + <property name="label" translatable="yes">_Room:</property> + <property name="use_underline">True</property> + <property name="use_markup">False</property> + <property name="justify">GTK_JUSTIFY_LEFT</property> + <property name="wrap">False</property> + <property name="selectable">False</property> + <property name="xalign">0</property> + <property name="yalign">0.5</property> + <property name="xpad">0</property> + <property name="ypad">0</property> + <property name="mnemonic_widget">entry_room</property> + <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property> + <property name="width_chars">-1</property> + <property name="single_line_mode">False</property> + <property name="angle">0</property> + </widget> + <packing> + <property name="left_attach">0</property> + <property name="right_attach">1</property> + <property name="top_attach">3</property> + <property name="bottom_attach">4</property> + <property name="x_options">fill</property> + <property name="y_options"></property> + </packing> + </child> + + <child> + <widget class="GtkLabel" id="label_server"> + <property name="visible">True</property> + <property name="label" translatable="yes">S_erver:</property> + <property name="use_underline">True</property> + <property name="use_markup">False</property> + <property name="justify">GTK_JUSTIFY_LEFT</property> + <property name="wrap">False</property> + <property name="selectable">False</property> + <property name="xalign">0</property> + <property name="yalign">0.5</property> + <property name="xpad">0</property> + <property name="ypad">0</property> + <property name="mnemonic_widget">entry_server</property> + <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property> + <property name="width_chars">-1</property> + <property name="single_line_mode">False</property> + <property name="angle">0</property> + </widget> + <packing> + <property name="left_attach">0</property> + <property name="right_attach">1</property> + <property name="top_attach">2</property> + <property name="bottom_attach">3</property> + <property name="x_options">fill</property> + <property name="y_options"></property> + </packing> + </child> + + <child> + <widget class="GtkLabel" id="label_nickname"> + <property name="visible">True</property> + <property name="label" translatable="yes">_Nickname:</property> + <property name="use_underline">True</property> + <property name="use_markup">False</property> + <property name="justify">GTK_JUSTIFY_LEFT</property> + <property name="wrap">False</property> + <property name="selectable">False</property> + <property name="xalign">0</property> + <property name="yalign">0.5</property> + <property name="xpad">0</property> + <property name="ypad">0</property> + <property name="mnemonic_widget">entry_nickname</property> + <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property> + <property name="width_chars">-1</property> + <property name="single_line_mode">False</property> + <property name="angle">0</property> + </widget> + <packing> + <property name="left_attach">0</property> + <property name="right_attach">1</property> + <property name="top_attach">1</property> + <property name="bottom_attach">2</property> + <property name="x_options">fill</property> + <property name="y_options"></property> + </packing> + </child> + + <child> + <widget class="GtkLabel" id="label_name"> + <property name="visible">True</property> + <property name="label" translatable="yes">N_ame:</property> + <property name="use_underline">True</property> + <property name="use_markup">False</property> + <property name="justify">GTK_JUSTIFY_LEFT</property> + <property name="wrap">False</property> + <property name="selectable">False</property> + <property name="xalign">0</property> + <property name="yalign">0.5</property> + <property name="xpad">0</property> + <property name="ypad">0</property> + <property name="mnemonic_widget">entry_name</property> + <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property> + <property name="width_chars">-1</property> + <property name="single_line_mode">False</property> + <property name="angle">0</property> + </widget> + <packing> + <property name="left_attach">0</property> + <property name="right_attach">1</property> + <property name="top_attach">0</property> + <property name="bottom_attach">1</property> + <property name="x_options">fill</property> + <property name="y_options"></property> + </packing> + </child> + + <child> + <widget class="GtkEntry" id="entry_name"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="editable">True</property> + <property name="visibility">True</property> + <property name="max_length">0</property> + <property name="text" translatable="yes"></property> + <property name="has_frame">True</property> + <property name="invisible_char">*</property> + <property name="activates_default">False</property> + <property name="width_chars">25</property> + </widget> + <packing> + <property name="left_attach">1</property> + <property name="right_attach">2</property> + <property name="top_attach">0</property> + <property name="bottom_attach">1</property> + <property name="y_options"></property> + </packing> + </child> + + <child> + <widget class="GtkCheckButton" id="checkbutton_auto_connect"> + <property name="visible">True</property> + <property name="tooltip" translatable="yes">Join this chat room when Gossip starts and you are connected</property> + <property name="can_focus">True</property> + <property name="label" translatable="yes">Join room on start_up</property> + <property name="use_underline">True</property> + <property name="relief">GTK_RELIEF_NORMAL</property> + <property name="focus_on_click">True</property> + <property name="active">False</property> + <property name="inconsistent">False</property> + <property name="draw_indicator">True</property> + </widget> + <packing> + <property name="left_attach">1</property> + <property name="right_attach">2</property> + <property name="top_attach">4</property> + <property name="bottom_attach">5</property> + <property name="x_options">fill</property> + <property name="y_options"></property> + </packing> + </child> + </widget> + <packing> + <property name="padding">0</property> + <property name="expand">True</property> + <property name="fill">True</property> + </packing> + </child> + </widget> + </child> +</widget> + +<widget class="GtkWindow" id="chatrooms_window"> + <property name="border_width">12</property> + <property name="visible">True</property> + <property name="title" translatable="yes">Manage Favorite Rooms</property> + <property name="type">GTK_WINDOW_TOPLEVEL</property> + <property name="window_position">GTK_WIN_POS_CENTER_ON_PARENT</property> + <property name="modal">False</property> + <property name="resizable">True</property> + <property name="destroy_with_parent">False</property> + <property name="decorated">True</property> + <property name="skip_taskbar_hint">False</property> + <property name="skip_pager_hint">False</property> + <property name="type_hint">GDK_WINDOW_TYPE_HINT_NORMAL</property> + <property name="gravity">GDK_GRAVITY_NORTH_WEST</property> + <property name="focus_on_map">True</property> + <property name="urgency_hint">False</property> + + <child> + <widget class="GtkVBox" id="vbox12"> + <property name="visible">True</property> + <property name="homogeneous">False</property> + <property name="spacing">12</property> + + <child> + <widget class="GtkVBox" id="vbox18"> + <property name="visible">True</property> + <property name="homogeneous">False</property> + <property name="spacing">18</property> + + <child> + <widget class="GtkHBox" id="hbox_account"> + <property name="visible">True</property> + <property name="homogeneous">False</property> + <property name="spacing">12</property> + + <child> + <widget class="GtkLabel" id="label_account"> + <property name="visible">True</property> + <property name="label" translatable="yes">Account:</property> + <property name="use_underline">False</property> + <property name="use_markup">False</property> + <property name="justify">GTK_JUSTIFY_LEFT</property> + <property name="wrap">False</property> + <property name="selectable">False</property> + <property name="xalign">0</property> + <property name="yalign">0.5</property> + <property name="xpad">0</property> + <property name="ypad">0</property> + <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property> + <property name="width_chars">-1</property> + <property name="single_line_mode">False</property> + <property name="angle">0</property> + </widget> + <packing> + <property name="padding">0</property> + <property name="expand">False</property> + <property name="fill">True</property> + </packing> + </child> + + <child> + <placeholder/> + </child> + </widget> + <packing> + <property name="padding">0</property> + <property name="expand">False</property> + <property name="fill">True</property> + </packing> + </child> + + <child> + <widget class="GtkScrolledWindow" id="scrolledwindow1"> + <property name="height_request">150</property> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="hscrollbar_policy">GTK_POLICY_NEVER</property> + <property name="vscrollbar_policy">GTK_POLICY_AUTOMATIC</property> + <property name="shadow_type">GTK_SHADOW_IN</property> + <property name="window_placement">GTK_CORNER_TOP_LEFT</property> + + <child> + <widget class="GtkTreeView" id="treeview"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="has_focus">True</property> + <property name="headers_visible">True</property> + <property name="rules_hint">False</property> + <property name="reorderable">False</property> + <property name="enable_search">True</property> + <property name="fixed_height_mode">False</property> + <property name="hover_selection">False</property> + <property name="hover_expand">False</property> + </widget> + </child> + </widget> + <packing> + <property name="padding">0</property> + <property name="expand">True</property> + <property name="fill">True</property> + </packing> + </child> + </widget> + <packing> + <property name="padding">0</property> + <property name="expand">True</property> + <property name="fill">True</property> + </packing> + </child> + + <child> + <widget class="GtkHButtonBox" id="hbuttonbox3"> + <property name="visible">True</property> + <property name="layout_style">GTK_BUTTONBOX_END</property> + <property name="spacing">6</property> + + <child> + <widget class="GtkButton" id="button_close"> + <property name="visible">True</property> + <property name="can_default">True</property> + <property name="can_focus">True</property> + <property name="label">gtk-close</property> + <property name="use_stock">True</property> + <property name="relief">GTK_RELIEF_NORMAL</property> + <property name="focus_on_click">True</property> + </widget> + </child> + + <child> + <widget class="GtkButton" id="button_remove"> + <property name="visible">True</property> + <property name="can_default">True</property> + <property name="can_focus">True</property> + <property name="label">gtk-remove</property> + <property name="use_stock">True</property> + <property name="relief">GTK_RELIEF_NORMAL</property> + <property name="focus_on_click">True</property> + </widget> + </child> + + <child> + <widget class="GtkButton" id="button_edit"> + <property name="visible">True</property> + <property name="sensitive">False</property> + <property name="can_default">True</property> + <property name="can_focus">True</property> + <property name="label">gtk-edit</property> + <property name="use_stock">True</property> + <property name="relief">GTK_RELIEF_NORMAL</property> + <property name="focus_on_click">True</property> + </widget> + </child> + </widget> + <packing> + <property name="padding">0</property> + <property name="expand">False</property> + <property name="fill">False</property> + </packing> + </child> + </widget> + </child> +</widget> + +</glade-interface> diff --git a/libempathy-gtk/gossip-chatrooms-window.h b/libempathy-gtk/gossip-chatrooms-window.h new file mode 100644 index 000000000..d1314ec29 --- /dev/null +++ b/libempathy-gtk/gossip-chatrooms-window.h @@ -0,0 +1,35 @@ +/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ +/* + * Copyright (C) 2004-2007 Imendio AB + * Copyright (C) 2007 Collabora Ltd. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + * + * Authors: Xavier Claessens <xclaesse@gmail.com> + * Martyn Russell <martyn@imendio.com> + * Mikael Hallendal <micke@imendio.com> + */ + +#ifndef __GOSSIP_CHATROOMS_WINDOW_H__ +#define __GOSSIP_CHATROOMS_WINDOW_H__ + +G_BEGIN_DECLS + +void gossip_chatrooms_window_show (GtkWindow *parent); + +G_END_DECLS + +#endif /* __GOSSIP_CHATROOMS_WINDOW_H__ */ diff --git a/libempathy-gtk/gossip-preferences.c b/libempathy-gtk/gossip-preferences.c index 52c4a804c..fd93353df 100644 --- a/libempathy-gtk/gossip-preferences.c +++ b/libempathy-gtk/gossip-preferences.c @@ -914,7 +914,7 @@ preferences_destroy_cb (GtkWidget *widget, } GtkWidget * -gossip_preferences_show (void) +gossip_preferences_show (GtkWindow *parent) { static GossipPreferences *preferences; GladeXML *glade; @@ -973,6 +973,11 @@ gossip_preferences_show (void) gtk_widget_show (page); } + if (parent) { + gtk_window_set_transient_for (GTK_WINDOW (preferences->dialog), + GTK_WINDOW (parent)); + } + gtk_widget_show (preferences->dialog); return preferences->dialog; diff --git a/libempathy-gtk/gossip-preferences.h b/libempathy-gtk/gossip-preferences.h index 74ecc9041..35b26621f 100644 --- a/libempathy-gtk/gossip-preferences.h +++ b/libempathy-gtk/gossip-preferences.h @@ -25,7 +25,7 @@ #ifndef __GOSSIP_PREFERENCES_H__ #define __GOSSIP_PREFERENCES_H__ -#include <gtk/gtkwidget.h> +#include <gtk/gtkwindow.h> G_BEGIN_DECLS @@ -49,7 +49,7 @@ G_BEGIN_DECLS #define GOSSIP_PREFS_CONTACTS_SORT_CRITERIUM GOSSIP_PREFS_PATH "/contacts/sort_criterium" #define GOSSIP_PREFS_HINTS_CLOSE_MAIN_WINDOW GOSSIP_PREFS_PATH "/hints/close_main_window" -GtkWidget * gossip_preferences_show (void); +GtkWidget * gossip_preferences_show (GtkWindow *parent); G_END_DECLS |