aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDanielle Madeley <danielle.madeley@collabora.co.uk>2010-06-24 17:38:15 +0800
committerDanielle Madeley <danielle.madeley@collabora.co.uk>2010-06-24 17:38:15 +0800
commit45ca662701afa1fd92d26c587e56b6e1ade16e83 (patch)
treefe7ca4cbfc938f895a33f736135db44970c3d77d
parent249af05e390dc85d6545917b5449f090c1e19d16 (diff)
parentee36de0c87a759e0ffe7ef6e845110e53a724299 (diff)
downloadgsoc2013-empathy-45ca662701afa1fd92d26c587e56b6e1ade16e83.tar
gsoc2013-empathy-45ca662701afa1fd92d26c587e56b6e1ade16e83.tar.gz
gsoc2013-empathy-45ca662701afa1fd92d26c587e56b6e1ade16e83.tar.bz2
gsoc2013-empathy-45ca662701afa1fd92d26c587e56b6e1ade16e83.tar.lz
gsoc2013-empathy-45ca662701afa1fd92d26c587e56b6e1ade16e83.tar.xz
gsoc2013-empathy-45ca662701afa1fd92d26c587e56b6e1ade16e83.tar.zst
gsoc2013-empathy-45ca662701afa1fd92d26c587e56b6e1ade16e83.zip
Merge branch 'preferences-dialog-622557'
-rw-r--r--src/empathy-event-manager.c29
-rw-r--r--src/empathy-main-window.c477
-rw-r--r--src/empathy-main-window.h26
-rw-r--r--src/empathy-main-window.ui8
-rw-r--r--src/empathy-preferences.c325
-rw-r--r--src/empathy-preferences.h25
-rw-r--r--src/empathy-preferences.ui49
-rw-r--r--src/empathy.c3
8 files changed, 522 insertions, 420 deletions
diff --git a/src/empathy-event-manager.c b/src/empathy-event-manager.c
index 1a91c22fa..a4f1448cb 100644
--- a/src/empathy-event-manager.c
+++ b/src/empathy-event-manager.c
@@ -480,6 +480,7 @@ event_manager_chat_message_received_cb (EmpathyTpChat *tp_chat,
EmpathyMessage *message,
EventManagerApproval *approval)
{
+ GtkWidget *window = empathy_main_window_dup ();
EmpathyContact *sender;
const gchar *header;
const gchar *msg;
@@ -504,8 +505,9 @@ event_manager_chat_message_received_cb (EmpathyTpChat *tp_chat,
EMPATHY_IMAGE_NEW_MESSAGE, header, msg, approval,
event_text_channel_process_func, NULL);
- empathy_sound_play (empathy_main_window_get (),
- EMPATHY_SOUND_CONVERSATION_NEW);
+ empathy_sound_play (window, EMPATHY_SOUND_CONVERSATION_NEW);
+
+ g_object_unref (window);
}
static void
@@ -560,6 +562,7 @@ static void
event_manager_media_channel_got_contact (EventManagerApproval *approval)
{
EmpathyEventManagerPriv *priv = GET_PRIV (approval->manager);
+ GtkWidget *window = empathy_main_window_dup ();
gchar *header;
EmpathyTpCall *call;
gboolean video;
@@ -582,8 +585,10 @@ event_manager_media_channel_got_contact (EventManagerApproval *approval)
priv->ringing++;
if (priv->ringing == 1)
- empathy_sound_start_playing (empathy_main_window_get (),
+ empathy_sound_start_playing (window,
EMPATHY_SOUND_PHONE_INCOMING, MS_BETWEEN_RING);
+
+ g_object_unref (window);
}
static void
@@ -679,6 +684,7 @@ event_manager_muc_invite_got_contact_cb (TpConnection *connection,
GObject *object)
{
EventManagerApproval *approval = (EventManagerApproval *) user_data;
+ GtkWidget *window = empathy_main_window_dup ();
const gchar *invite_msg;
gchar *msg;
TpHandle self_handle;
@@ -704,10 +710,10 @@ event_manager_muc_invite_got_contact_cb (TpConnection *connection,
EMPATHY_EVENT_TYPE_CHAT, EMPATHY_IMAGE_GROUP_MESSAGE, msg, invite_msg,
approval, event_room_channel_process_func, NULL);
- empathy_sound_play (empathy_main_window_get (),
- EMPATHY_SOUND_CONVERSATION_NEW);
+ empathy_sound_play (window, EMPATHY_SOUND_CONVERSATION_NEW);
g_free (msg);
+ g_object_unref (window);
}
static void
@@ -718,6 +724,7 @@ event_manager_ft_got_contact_cb (TpConnection *connection,
GObject *object)
{
EventManagerApproval *approval = (EventManagerApproval *) user_data;
+ GtkWidget *window = empathy_main_window_dup ();
char *header;
approval->contact = g_object_ref (contact);
@@ -730,10 +737,10 @@ event_manager_ft_got_contact_cb (TpConnection *connection,
approval, event_channel_process_func, NULL);
/* FIXME better sound for incoming file transfers ?*/
- empathy_sound_play (empathy_main_window_get (),
- EMPATHY_SOUND_CONVERSATION_NEW);
+ empathy_sound_play (window, EMPATHY_SOUND_CONVERSATION_NEW);
g_free (header);
+ g_object_unref (window);
}
/* If there is a file-transfer or media channel consider it as the
@@ -941,6 +948,7 @@ event_manager_presence_changed_cb (EmpathyContact *contact,
gchar *header = NULL;
EmpathyIdle *idle;
GSettings *gsettings = g_settings_new (EMPATHY_PREFS_NOTIFICATIONS_SCHEMA);
+ GtkWidget *window = empathy_main_window_dup ();
account = empathy_contact_get_account (contact);
idle = empathy_idle_dup_singleton ();
@@ -956,8 +964,7 @@ event_manager_presence_changed_cb (EmpathyContact *contact,
TP_CONNECTION_PRESENCE_TYPE_OFFLINE) <= 0)
{
/* someone is logging off */
- empathy_sound_play (empathy_main_window_get (),
- EMPATHY_SOUND_CONTACT_DISCONNECTED);
+ empathy_sound_play (window, EMPATHY_SOUND_CONTACT_DISCONNECTED);
if (g_settings_get_boolean (gsettings,
EMPATHY_PREFS_NOTIFICATIONS_CONTACT_SIGNOUT))
@@ -977,8 +984,7 @@ event_manager_presence_changed_cb (EmpathyContact *contact,
TP_CONNECTION_PRESENCE_TYPE_OFFLINE) > 0)
{
/* someone is logging in */
- empathy_sound_play (empathy_main_window_get (),
- EMPATHY_SOUND_CONTACT_CONNECTED);
+ empathy_sound_play (window, EMPATHY_SOUND_CONTACT_CONNECTED);
if (g_settings_get_boolean (gsettings,
EMPATHY_PREFS_NOTIFICATIONS_CONTACT_SIGNIN))
@@ -996,6 +1002,7 @@ event_manager_presence_changed_cb (EmpathyContact *contact,
out:
g_object_unref (idle);
g_object_unref (gsettings);
+ g_object_unref (window);
}
static void
diff --git a/src/empathy-main-window.c b/src/empathy-main-window.c
index 9b818bc4c..b8033a207 100644
--- a/src/empathy-main-window.c
+++ b/src/empathy-main-window.c
@@ -19,6 +19,7 @@
* Boston, MA 02110-1301 USA
*
* Authors: Xavier Claessens <xclaesse@gmail.com>
+ * Danielle Madeley <danielle.madeley@collabora.co.uk>
*/
#include <config.h>
@@ -82,7 +83,11 @@
/* Name in the geometry file */
#define GEOMETRY_NAME "main-window"
-typedef struct {
+G_DEFINE_TYPE (EmpathyMainWindow, empathy_main_window, GTK_TYPE_WINDOW);
+
+#define GET_PRIV(self) ((EmpathyMainWindowPriv*)((EmpathyMainWindow*)self)->priv)
+
+struct _EmpathyMainWindowPriv {
EmpathyContactListView *list_view;
EmpathyContactListStore *list_store;
TpAccountManager *account_manager;
@@ -94,7 +99,7 @@ typedef struct {
GSettings *gsettings_ui;
GSettings *gsettings_contacts;
- GtkWidget *window;
+ GtkWidget *preferences;
GtkWidget *main_vbox;
GtkWidget *throbber;
GtkWidget *throbber_tool_item;
@@ -130,21 +135,21 @@ typedef struct {
/* The idle event source to migrate butterfly's logs */
guint butterfly_log_migration_members_changed_id;
-} EmpathyMainWindow;
-
-static EmpathyMainWindow *main_window = NULL;
+};
static void
main_window_flash_stop (EmpathyMainWindow *window)
{
- if (window->flash_timeout_id == 0) {
+ EmpathyMainWindowPriv *priv = GET_PRIV (window);
+
+ if (priv->flash_timeout_id == 0) {
return;
}
DEBUG ("Stop flashing");
- g_source_remove (window->flash_timeout_id);
- window->flash_timeout_id = 0;
- window->flash_on = FALSE;
+ g_source_remove (priv->flash_timeout_id);
+ priv->flash_timeout_id = 0;
+ priv->flash_on = FALSE;
}
typedef struct {
@@ -185,7 +190,7 @@ main_window_flash_foreach (GtkTreeModel *model,
pixbuf = empathy_pixbuf_from_icon_name (icon_name, GTK_ICON_SIZE_MENU);
} else {
pixbuf = contact_list_store_get_contact_status_icon (
- data->window->list_store,
+ GET_PRIV (data->window)->list_store,
contact);
}
@@ -213,16 +218,17 @@ main_window_flash_foreach (GtkTreeModel *model,
static gboolean
main_window_flash_cb (EmpathyMainWindow *window)
{
+ EmpathyMainWindowPriv *priv = GET_PRIV (window);
GtkTreeModel *model;
GSList *events, *l;
gboolean found_event = FALSE;
FlashForeachData data;
- window->flash_on = !window->flash_on;
- data.on = window->flash_on;
- model = GTK_TREE_MODEL (window->list_store);
+ priv->flash_on = !priv->flash_on;
+ data.on = priv->flash_on;
+ model = GTK_TREE_MODEL (priv->list_store);
- events = empathy_event_manager_get_events (window->event_manager);
+ events = empathy_event_manager_get_events (priv->event_manager);
for (l = events; l; l = l->next) {
data.event = l->data;
data.window = window;
@@ -246,14 +252,16 @@ main_window_flash_cb (EmpathyMainWindow *window)
static void
main_window_flash_start (EmpathyMainWindow *window)
{
- if (window->flash_timeout_id != 0) {
+ EmpathyMainWindowPriv *priv = GET_PRIV (window);
+
+ if (priv->flash_timeout_id != 0) {
return;
}
DEBUG ("Start flashing");
- window->flash_timeout_id = g_timeout_add (FLASH_TIMEOUT,
- (GSourceFunc) main_window_flash_cb,
- window);
+ priv->flash_timeout_id = g_timeout_add (FLASH_TIMEOUT,
+ (GSourceFunc) main_window_flash_cb,
+ window);
main_window_flash_cb (window);
}
@@ -272,6 +280,7 @@ main_window_event_removed_cb (EmpathyEventManager *manager,
EmpathyEvent *event,
EmpathyMainWindow *window)
{
+ EmpathyMainWindowPriv *priv = GET_PRIV (window);
FlashForeachData data;
if (!event->contact) {
@@ -281,7 +290,7 @@ main_window_event_removed_cb (EmpathyEventManager *manager,
data.on = FALSE;
data.event = event;
data.window = window;
- gtk_tree_model_foreach (GTK_TREE_MODEL (window->list_store),
+ gtk_tree_model_foreach (GTK_TREE_MODEL (priv->list_store),
main_window_flash_foreach,
&data);
}
@@ -292,12 +301,13 @@ main_window_row_activated_cb (EmpathyContactListView *view,
GtkTreeViewColumn *col,
EmpathyMainWindow *window)
{
+ EmpathyMainWindowPriv *priv = GET_PRIV (window);
EmpathyContact *contact;
GtkTreeModel *model;
GtkTreeIter iter;
GSList *events, *l;
- model = gtk_tree_view_get_model (GTK_TREE_VIEW (window->list_view));
+ model = gtk_tree_view_get_model (GTK_TREE_VIEW (priv->list_view));
gtk_tree_model_get_iter (model, &iter, path);
gtk_tree_model_get (model, &iter,
EMPATHY_CONTACT_LIST_STORE_COL_CONTACT, &contact,
@@ -309,7 +319,7 @@ main_window_row_activated_cb (EmpathyContactListView *view,
/* If the contact has an event activate it, otherwise the
* default handler of row-activated will be called. */
- events = empathy_event_manager_get_events (window->event_manager);
+ events = empathy_event_manager_get_events (priv->event_manager);
for (l = events; l; l = l->next) {
EmpathyEvent *event = l->data;
@@ -331,12 +341,13 @@ static void
main_window_remove_error (EmpathyMainWindow *window,
TpAccount *account)
{
+ EmpathyMainWindowPriv *priv = GET_PRIV (window);
GtkWidget *error_widget;
- error_widget = g_hash_table_lookup (window->errors, account);
+ error_widget = g_hash_table_lookup (priv->errors, account);
if (error_widget != NULL) {
gtk_widget_destroy (error_widget);
- g_hash_table_remove (window->errors, account);
+ g_hash_table_remove (priv->errors, account);
}
}
@@ -390,6 +401,7 @@ main_window_error_display (EmpathyMainWindow *window,
TpAccount *account,
const gchar *message)
{
+ EmpathyMainWindowPriv *priv = GET_PRIV (window);
GtkWidget *info_bar;
GtkWidget *content_area;
GtkWidget *label;
@@ -406,7 +418,7 @@ main_window_error_display (EmpathyMainWindow *window,
tp_account_get_display_name (account),
message);
- info_bar = g_hash_table_lookup (window->errors, account);
+ info_bar = g_hash_table_lookup (priv->errors, account);
if (info_bar) {
label = g_object_get_data (G_OBJECT (info_bar), "label");
@@ -421,7 +433,7 @@ main_window_error_display (EmpathyMainWindow *window,
gtk_info_bar_set_message_type (GTK_INFO_BAR (info_bar), GTK_MESSAGE_ERROR);
gtk_widget_set_no_show_all (info_bar, TRUE);
- gtk_box_pack_start (GTK_BOX (window->errors_vbox), info_bar, FALSE, TRUE, 0);
+ gtk_box_pack_start (GTK_BOX (priv->errors_vbox), info_bar, FALSE, TRUE, 0);
gtk_widget_show (info_bar);
icon_name = tp_account_get_icon_name (account);
@@ -498,14 +510,15 @@ main_window_error_display (EmpathyMainWindow *window,
G_CALLBACK (main_window_error_retry_clicked_cb),
window);
- gtk_widget_show (window->errors_vbox);
+ gtk_widget_show (priv->errors_vbox);
- g_hash_table_insert (window->errors, g_object_ref (account), info_bar);
+ g_hash_table_insert (priv->errors, g_object_ref (account), info_bar);
}
static void
main_window_update_status (EmpathyMainWindow *window)
{
+ EmpathyMainWindowPriv *priv = GET_PRIV (window);
gboolean connected, connecting;
GList *l;
@@ -513,15 +526,15 @@ main_window_update_status (EmpathyMainWindow *window)
/* Update the spinner state */
if (connecting) {
- gtk_spinner_start (GTK_SPINNER (window->throbber));
- gtk_widget_show (window->throbber_tool_item);
+ gtk_spinner_start (GTK_SPINNER (priv->throbber));
+ gtk_widget_show (priv->throbber_tool_item);
} else {
- gtk_spinner_stop (GTK_SPINNER (window->throbber));
- gtk_widget_hide (window->throbber_tool_item);
+ gtk_spinner_stop (GTK_SPINNER (priv->throbber));
+ gtk_widget_hide (priv->throbber_tool_item);
}
/* Update widgets sensibility */
- for (l = window->actions_connected; l; l = l->next) {
+ for (l = priv->actions_connected; l; l = l->next) {
gtk_action_set_sensitive (l->data, connected);
}
}
@@ -547,12 +560,12 @@ main_window_connection_changed_cb (TpAccount *account,
}
if (current == TP_CONNECTION_STATUS_DISCONNECTED) {
- empathy_sound_play (GTK_WIDGET (window->window),
+ empathy_sound_play (GTK_WIDGET (window),
EMPATHY_SOUND_ACCOUNT_DISCONNECTED);
}
if (current == TP_CONNECTION_STATUS_CONNECTED) {
- empathy_sound_play (GTK_WIDGET (window->window),
+ empathy_sound_play (GTK_WIDGET (window),
EMPATHY_SOUND_ACCOUNT_CONNECTED);
/* Account connected without error, remove error message if any */
@@ -592,43 +605,43 @@ main_window_accels_save (void)
}
static void
-main_window_destroy_cb (GtkWidget *widget,
- EmpathyMainWindow *window)
+empathy_main_window_finalize (GObject *window)
{
+ EmpathyMainWindowPriv *priv = GET_PRIV (window);
GHashTableIter iter;
gpointer key, value;
/* Save user-defined accelerators. */
main_window_accels_save ();
- g_list_free (window->actions_connected);
+ g_list_free (priv->actions_connected);
- g_object_unref (window->account_manager);
- g_object_unref (window->list_store);
- g_hash_table_destroy (window->errors);
+ g_object_unref (priv->account_manager);
+ g_object_unref (priv->list_store);
+ g_hash_table_destroy (priv->errors);
/* disconnect all handlers of status-changed signal */
- g_hash_table_iter_init (&iter, window->status_changed_handlers);
+ g_hash_table_iter_init (&iter, priv->status_changed_handlers);
while (g_hash_table_iter_next (&iter, &key, &value))
g_signal_handler_disconnect (TP_ACCOUNT (key),
GPOINTER_TO_UINT (value));
- g_hash_table_destroy (window->status_changed_handlers);
+ g_hash_table_destroy (priv->status_changed_handlers);
- g_signal_handlers_disconnect_by_func (window->event_manager,
+ g_signal_handlers_disconnect_by_func (priv->event_manager,
main_window_event_added_cb,
window);
- g_signal_handlers_disconnect_by_func (window->event_manager,
+ g_signal_handlers_disconnect_by_func (priv->event_manager,
main_window_event_removed_cb,
window);
- g_object_unref (window->event_manager);
- g_object_unref (window->ui_manager);
- g_object_unref (window->chatroom_manager);
+ g_object_unref (priv->event_manager);
+ g_object_unref (priv->ui_manager);
+ g_object_unref (priv->chatroom_manager);
- g_object_unref (window->gsettings_ui);
- g_object_unref (window->gsettings_contacts);
+ g_object_unref (priv->gsettings_ui);
+ g_object_unref (priv->gsettings_contacts);
- g_free (window);
+ G_OBJECT_CLASS (empathy_main_window_parent_class)->finalize (window);
}
static gboolean
@@ -659,28 +672,28 @@ static void
main_window_view_history_cb (GtkAction *action,
EmpathyMainWindow *window)
{
- empathy_log_window_show (NULL, NULL, FALSE, GTK_WINDOW (window->window));
+ empathy_log_window_show (NULL, NULL, FALSE, GTK_WINDOW (window));
}
static void
main_window_chat_new_message_cb (GtkAction *action,
EmpathyMainWindow *window)
{
- empathy_new_message_dialog_show (GTK_WINDOW (window->window));
+ empathy_new_message_dialog_show (GTK_WINDOW (window));
}
static void
main_window_chat_new_call_cb (GtkAction *action,
EmpathyMainWindow *window)
{
- empathy_new_call_dialog_show (GTK_WINDOW (window->window));
+ empathy_new_call_dialog_show (GTK_WINDOW (window));
}
static void
main_window_chat_add_contact_cb (GtkAction *action,
EmpathyMainWindow *window)
{
- empathy_new_contact_dialog_show (GTK_WINDOW (window->window));
+ empathy_new_contact_dialog_show (GTK_WINDOW (window));
}
static void
@@ -694,16 +707,17 @@ static void
main_window_view_show_offline_cb (GtkToggleAction *action,
EmpathyMainWindow *window)
{
+ EmpathyMainWindowPriv *priv = GET_PRIV (window);
gboolean current;
current = gtk_toggle_action_get_active (action);
- g_settings_set_boolean (window->gsettings_ui,
+ g_settings_set_boolean (priv->gsettings_ui,
EMPATHY_PREFS_UI_SHOW_OFFLINE,
current);
/* Turn off sound just while we alter the contact list. */
// FIXME: empathy_sound_set_enabled (FALSE);
- empathy_contact_list_store_set_show_offline (window->list_store, current);
+ empathy_contact_list_store_set_show_offline (priv->list_store, current);
//empathy_sound_set_enabled (TRUE);
}
@@ -712,6 +726,7 @@ main_window_notify_sort_contact_cb (GSettings *gsettings,
const gchar *key,
EmpathyMainWindow *window)
{
+ EmpathyMainWindowPriv *priv = GET_PRIV (window);
gchar *str;
str = g_settings_get_string (gsettings, key);
@@ -728,7 +743,7 @@ main_window_notify_sort_contact_cb (GSettings *gsettings,
/* By changing the value of the GtkRadioAction,
it emits a signal that calls main_window_view_sort_contacts_cb
which updates the contacts list */
- gtk_radio_action_set_current_value (window->sort_by_name,
+ gtk_radio_action_set_current_value (priv->sort_by_name,
enum_value->value);
} else {
g_warning ("Wrong value for sort_criterium configuration : %s", str);
@@ -742,6 +757,7 @@ main_window_view_sort_contacts_cb (GtkRadioAction *action,
GtkRadioAction *current,
EmpathyMainWindow *window)
{
+ EmpathyMainWindowPriv *priv = GET_PRIV (window);
EmpathyContactListStoreSort value;
GSList *group;
GType type;
@@ -760,25 +776,26 @@ main_window_view_sort_contacts_cb (GtkRadioAction *action,
g_warning ("No GEnumValue for EmpathyContactListSort with GtkRadioAction index:%d",
g_slist_index (group, action));
} else {
- g_settings_set_string (window->gsettings_contacts,
+ g_settings_set_string (priv->gsettings_contacts,
EMPATHY_PREFS_CONTACTS_SORT_CRITERIUM,
enum_value->value_nick);
}
- empathy_contact_list_store_set_sort_criterium (window->list_store, value);
+ empathy_contact_list_store_set_sort_criterium (priv->list_store, value);
}
static void
main_window_view_show_protocols_cb (GtkToggleAction *action,
EmpathyMainWindow *window)
{
+ EmpathyMainWindowPriv *priv = GET_PRIV (window);
gboolean value;
value = gtk_toggle_action_get_active (action);
- g_settings_set_boolean (window->gsettings_ui,
+ g_settings_set_boolean (priv->gsettings_ui,
EMPATHY_PREFS_UI_SHOW_PROTOCOLS,
value);
- empathy_contact_list_store_set_show_protocols (window->list_store,
+ empathy_contact_list_store_set_show_protocols (priv->list_store,
value);
}
@@ -792,6 +809,7 @@ main_window_view_contacts_list_size_cb (GtkRadioAction *action,
GtkRadioAction *current,
EmpathyMainWindow *window)
{
+ EmpathyMainWindowPriv *priv = GET_PRIV (window);
GSettings *gsettings_ui;
gint value;
@@ -812,9 +830,9 @@ main_window_view_contacts_list_size_cb (GtkRadioAction *action,
value == CONTACT_LIST_COMPACT_SIZE);
g_settings_apply (gsettings_ui);
- empathy_contact_list_store_set_show_avatars (window->list_store,
+ empathy_contact_list_store_set_show_avatars (priv->list_store,
value == CONTACT_LIST_NORMAL_SIZE_WITH_AVATARS);
- empathy_contact_list_store_set_is_compact (window->list_store,
+ empathy_contact_list_store_set_is_compact (priv->list_store,
value == CONTACT_LIST_COMPACT_SIZE);
g_object_unref (gsettings_ui);
@@ -824,7 +842,9 @@ static void main_window_notify_show_protocols_cb (GSettings *gsettings,
const gchar *key,
EmpathyMainWindow *window)
{
- gtk_toggle_action_set_active (window->show_protocols,
+ EmpathyMainWindowPriv *priv = GET_PRIV (window);
+
+ gtk_toggle_action_set_active (priv->show_protocols,
g_settings_get_boolean (gsettings,
EMPATHY_PREFS_UI_SHOW_PROTOCOLS));
}
@@ -835,6 +855,7 @@ main_window_notify_contact_list_size_cb (GSettings *gsettings,
const gchar *key,
EmpathyMainWindow *window)
{
+ EmpathyMainWindowPriv *priv = GET_PRIV (window);
gint value;
if (g_settings_get_boolean (gsettings,
@@ -852,7 +873,7 @@ main_window_notify_contact_list_size_cb (GSettings *gsettings,
/* By changing the value of the GtkRadioAction,
it emits a signal that calls main_window_view_contacts_list_size_cb
which updates the contacts list */
- gtk_radio_action_set_current_value (window->normal_with_avatars, value);
+ gtk_radio_action_set_current_value (priv->normal_with_avatars, value);
}
static void
@@ -993,6 +1014,7 @@ static void
main_window_favorite_chatroom_menu_add (EmpathyMainWindow *window,
EmpathyChatroom *chatroom)
{
+ EmpathyMainWindowPriv *priv = GET_PRIV (window);
GtkWidget *menu_item;
const gchar *name;
@@ -1008,7 +1030,7 @@ main_window_favorite_chatroom_menu_add (EmpathyMainWindow *window,
G_CALLBACK (main_window_favorite_chatroom_menu_activate_cb),
chatroom);
- gtk_menu_shell_insert (GTK_MENU_SHELL (window->room_menu),
+ gtk_menu_shell_insert (GTK_MENU_SHELL (priv->room_menu),
menu_item, 4);
gtk_widget_show (menu_item);
@@ -1019,9 +1041,11 @@ main_window_favorite_chatroom_menu_added_cb (EmpathyChatroomManager *manager,
EmpathyChatroom *chatroom,
EmpathyMainWindow *window)
{
+ EmpathyMainWindowPriv *priv = GET_PRIV (window);
+
main_window_favorite_chatroom_menu_add (window, chatroom);
- gtk_widget_show (window->room_separator);
- gtk_action_set_sensitive (window->room_join_favorites, TRUE);
+ gtk_widget_show (priv->room_separator);
+ gtk_action_set_sensitive (priv->room_join_favorites, TRUE);
}
static void
@@ -1029,6 +1053,7 @@ main_window_favorite_chatroom_menu_removed_cb (EmpathyChatroomManager *manager,
EmpathyChatroom *chatroom,
EmpathyMainWindow *window)
{
+ EmpathyMainWindowPriv *priv = GET_PRIV (window);
GtkWidget *menu_item;
GList *chatrooms;
@@ -1036,29 +1061,31 @@ main_window_favorite_chatroom_menu_removed_cb (EmpathyChatroomManager *manager,
g_object_set_data (G_OBJECT (chatroom), "menu_item", NULL);
gtk_widget_destroy (menu_item);
- chatrooms = empathy_chatroom_manager_get_chatrooms (window->chatroom_manager, NULL);
+ chatrooms = empathy_chatroom_manager_get_chatrooms (priv->chatroom_manager, NULL);
if (chatrooms) {
- gtk_widget_show (window->room_separator);
+ gtk_widget_show (priv->room_separator);
} else {
- gtk_widget_hide (window->room_separator);
+ gtk_widget_hide (priv->room_separator);
}
- gtk_action_set_sensitive (window->room_join_favorites, chatrooms != NULL);
+ gtk_action_set_sensitive (priv->room_join_favorites, chatrooms != NULL);
g_list_free (chatrooms);
}
static void
main_window_favorite_chatroom_menu_setup (EmpathyMainWindow *window)
{
+ EmpathyMainWindowPriv *priv = GET_PRIV (window);
GList *chatrooms, *l;
GtkWidget *room;
- window->chatroom_manager = empathy_chatroom_manager_dup_singleton (NULL);
- chatrooms = empathy_chatroom_manager_get_chatrooms (window->chatroom_manager, NULL);
- room = gtk_ui_manager_get_widget (window->ui_manager,
+ priv->chatroom_manager = empathy_chatroom_manager_dup_singleton (NULL);
+ chatrooms = empathy_chatroom_manager_get_chatrooms (
+ priv->chatroom_manager, NULL);
+ room = gtk_ui_manager_get_widget (priv->ui_manager,
"/menubar/room");
- window->room_menu = gtk_menu_item_get_submenu (GTK_MENU_ITEM (room));
- window->room_separator = gtk_ui_manager_get_widget (window->ui_manager,
+ priv->room_menu = gtk_menu_item_get_submenu (GTK_MENU_ITEM (room));
+ priv->room_separator = gtk_ui_manager_get_widget (priv->ui_manager,
"/menubar/room/room_separator");
for (l = chatrooms; l; l = l->next) {
@@ -1066,15 +1093,15 @@ main_window_favorite_chatroom_menu_setup (EmpathyMainWindow *window)
}
if (!chatrooms) {
- gtk_widget_hide (window->room_separator);
+ gtk_widget_hide (priv->room_separator);
}
- gtk_action_set_sensitive (window->room_join_favorites, chatrooms != NULL);
+ gtk_action_set_sensitive (priv->room_join_favorites, chatrooms != NULL);
- g_signal_connect (window->chatroom_manager, "chatroom-added",
+ g_signal_connect (priv->chatroom_manager, "chatroom-added",
G_CALLBACK (main_window_favorite_chatroom_menu_added_cb),
window);
- g_signal_connect (window->chatroom_manager, "chatroom-removed",
+ g_signal_connect (priv->chatroom_manager, "chatroom-removed",
G_CALLBACK (main_window_favorite_chatroom_menu_removed_cb),
window);
@@ -1085,16 +1112,17 @@ static void
main_window_room_join_new_cb (GtkAction *action,
EmpathyMainWindow *window)
{
- empathy_new_chatroom_dialog_show (GTK_WINDOW (window->window));
+ empathy_new_chatroom_dialog_show (GTK_WINDOW (window));
}
static void
main_window_room_join_favorites_cb (GtkAction *action,
EmpathyMainWindow *window)
{
+ EmpathyMainWindowPriv *priv = GET_PRIV (window);
GList *chatrooms, *l;
- chatrooms = empathy_chatroom_manager_get_chatrooms (window->chatroom_manager, NULL);
+ chatrooms = empathy_chatroom_manager_get_chatrooms (priv->chatroom_manager, NULL);
for (l = chatrooms; l; l = l->next) {
main_window_favorite_chatroom_join (l->data);
}
@@ -1105,52 +1133,53 @@ static void
main_window_room_manage_favorites_cb (GtkAction *action,
EmpathyMainWindow *window)
{
- empathy_chatrooms_window_show (GTK_WINDOW (window->window));
+ empathy_chatrooms_window_show (GTK_WINDOW (window));
}
static void
main_window_edit_cb (GtkAction *action,
EmpathyMainWindow *window)
{
+ EmpathyMainWindowPriv *priv = GET_PRIV (window);
GtkWidget *submenu;
/* FIXME: It should use the UIManager to merge the contact/group submenu */
- submenu = empathy_contact_list_view_get_contact_menu (window->list_view);
+ submenu = empathy_contact_list_view_get_contact_menu (priv->list_view);
if (submenu) {
GtkMenuItem *item;
GtkWidget *label;
- item = GTK_MENU_ITEM (window->edit_context);
+ item = GTK_MENU_ITEM (priv->edit_context);
label = gtk_bin_get_child (GTK_BIN (item));
gtk_label_set_text (GTK_LABEL (label), _("Contact"));
- gtk_widget_show (window->edit_context);
- gtk_widget_show (window->edit_context_separator);
+ gtk_widget_show (priv->edit_context);
+ gtk_widget_show (priv->edit_context_separator);
gtk_menu_item_set_submenu (item, submenu);
return;
}
- submenu = empathy_contact_list_view_get_group_menu (window->list_view);
+ submenu = empathy_contact_list_view_get_group_menu (priv->list_view);
if (submenu) {
GtkMenuItem *item;
GtkWidget *label;
- item = GTK_MENU_ITEM (window->edit_context);
+ item = GTK_MENU_ITEM (priv->edit_context);
label = gtk_bin_get_child (GTK_BIN (item));
gtk_label_set_text (GTK_LABEL (label), _("Group"));
- gtk_widget_show (window->edit_context);
- gtk_widget_show (window->edit_context_separator);
+ gtk_widget_show (priv->edit_context);
+ gtk_widget_show (priv->edit_context_separator);
gtk_menu_item_set_submenu (item, submenu);
return;
}
- gtk_widget_hide (window->edit_context);
- gtk_widget_hide (window->edit_context_separator);
+ gtk_widget_hide (priv->edit_context);
+ gtk_widget_hide (priv->edit_context_separator);
return;
}
@@ -1167,21 +1196,31 @@ static void
main_window_edit_personal_information_cb (GtkAction *action,
EmpathyMainWindow *window)
{
- empathy_contact_personal_dialog_show (GTK_WINDOW (window->window));
+ empathy_contact_personal_dialog_show (GTK_WINDOW (window));
}
static void
main_window_edit_preferences_cb (GtkAction *action,
EmpathyMainWindow *window)
{
- empathy_preferences_show (GTK_WINDOW (window->window));
+ EmpathyMainWindowPriv *priv = GET_PRIV (window);
+
+ if (priv->preferences == NULL) {
+ priv->preferences = empathy_preferences_new (GTK_WINDOW (window));
+ g_object_add_weak_pointer (G_OBJECT (priv->preferences),
+ (gpointer) &priv->preferences);
+
+ gtk_widget_show (priv->preferences);
+ } else {
+ gtk_window_present (GTK_WINDOW (priv->preferences));
+ }
}
static void
main_window_help_about_cb (GtkAction *action,
EmpathyMainWindow *window)
{
- empathy_about_dialog_new (GTK_WINDOW (window->window));
+ empathy_about_dialog_new (GTK_WINDOW (window));
}
static void
@@ -1223,7 +1262,7 @@ static void
main_window_help_contents_cb (GtkAction *action,
EmpathyMainWindow *window)
{
- empathy_url_show (window->window, "ghelp:empathy");
+ empathy_url_show (GTK_WIDGET (window), "ghelp:empathy");
}
static gboolean
@@ -1248,11 +1287,12 @@ main_window_account_removed_cb (TpAccountManager *manager,
TpAccount *account,
EmpathyMainWindow *window)
{
+ EmpathyMainWindowPriv *priv = GET_PRIV (window);
GList *a;
a = tp_account_manager_get_valid_accounts (manager);
- gtk_action_set_sensitive (window->view_history,
+ gtk_action_set_sensitive (priv->view_history,
g_list_length (a) > 0);
g_list_free (a);
@@ -1267,10 +1307,12 @@ main_window_account_validity_changed_cb (TpAccountManager *manager,
gboolean valid,
EmpathyMainWindow *window)
{
+ EmpathyMainWindowPriv *priv = GET_PRIV (window);
+
if (valid) {
gulong handler_id;
handler_id = GPOINTER_TO_UINT (g_hash_table_lookup (
- window->status_changed_handlers, account));
+ priv->status_changed_handlers, account));
/* connect signal only if it was not connected yet */
if (handler_id == 0) {
@@ -1278,7 +1320,7 @@ main_window_account_validity_changed_cb (TpAccountManager *manager,
"status-changed",
G_CALLBACK (main_window_connection_changed_cb),
window);
- g_hash_table_insert (window->status_changed_handlers,
+ g_hash_table_insert (priv->status_changed_handlers,
account, GUINT_TO_POINTER (handler_id));
}
}
@@ -1299,6 +1341,7 @@ static void
main_window_connection_items_setup (EmpathyMainWindow *window,
GtkBuilder *gui)
{
+ EmpathyMainWindowPriv *priv = GET_PRIV (window);
GList *list;
GObject *action;
guint i;
@@ -1315,13 +1358,7 @@ main_window_connection_items_setup (EmpathyMainWindow *window,
list = g_list_prepend (list, action);
}
- window->actions_connected = list;
-}
-
-GtkWidget *
-empathy_main_window_get (void)
-{
- return main_window != NULL ? main_window->window : NULL;
+ priv->actions_connected = list;
}
static void
@@ -1332,6 +1369,7 @@ account_manager_prepared_cb (GObject *source_object,
GList *accounts, *j;
TpAccountManager *manager = TP_ACCOUNT_MANAGER (source_object);
EmpathyMainWindow *window = user_data;
+ EmpathyMainWindowPriv *priv = GET_PRIV (window);
GError *error = NULL;
if (!tp_account_manager_prepare_finish (manager, result, &error)) {
@@ -1340,7 +1378,7 @@ account_manager_prepared_cb (GObject *source_object,
return;
}
- accounts = tp_account_manager_get_valid_accounts (window->account_manager);
+ accounts = tp_account_manager_get_valid_accounts (priv->account_manager);
for (j = accounts; j != NULL; j = j->next) {
TpAccount *account = TP_ACCOUNT (j->data);
gulong handler_id;
@@ -1348,7 +1386,7 @@ account_manager_prepared_cb (GObject *source_object,
handler_id = g_signal_connect (account, "status-changed",
G_CALLBACK (main_window_connection_changed_cb),
window);
- g_hash_table_insert (window->status_changed_handlers,
+ g_hash_table_insert (priv->status_changed_handlers,
account, GUINT_TO_POINTER (handler_id));
}
@@ -1359,7 +1397,7 @@ account_manager_prepared_cb (GObject *source_object,
main_window_update_status (window);
/* Disable the "Previous Conversations" menu entry if there is no account */
- gtk_action_set_sensitive (window->view_history,
+ gtk_action_set_sensitive (priv->view_history,
g_list_length (accounts) > 0);
g_list_free (accounts);
@@ -1374,20 +1412,51 @@ main_window_members_changed_cb (EmpathyContactList *list,
gboolean is_member,
EmpathyMainWindow *window)
{
+ EmpathyMainWindowPriv *priv = GET_PRIV (window);
+
if (!is_member)
return;
if (!empathy_migrate_butterfly_logs (contact)) {
g_signal_handler_disconnect (list,
- window->butterfly_log_migration_members_changed_id);
- window->butterfly_log_migration_members_changed_id = 0;
+ priv->butterfly_log_migration_members_changed_id);
+ priv->butterfly_log_migration_members_changed_id = 0;
}
}
-GtkWidget *
-empathy_main_window_show (void)
+static GObject *
+empathy_main_window_constructor (GType type,
+ guint n_construct_params,
+ GObjectConstructParam *construct_params)
{
- EmpathyMainWindow *window;
+ static GObject *window = NULL;
+
+ if (window != NULL)
+ return g_object_ref (window);
+
+ window = G_OBJECT_CLASS (empathy_main_window_parent_class)->constructor (
+ type, n_construct_params, construct_params);
+
+ g_object_add_weak_pointer (window, (gpointer) &window);
+
+ return window;
+}
+
+static void
+empathy_main_window_class_init (EmpathyMainWindowClass *klass)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+
+ object_class->finalize = empathy_main_window_finalize;
+ object_class->constructor = empathy_main_window_constructor;
+
+ g_type_class_add_private (object_class, sizeof (EmpathyMainWindowPriv));
+}
+
+static void
+empathy_main_window_init (EmpathyMainWindow *window)
+{
+ EmpathyMainWindowPriv *priv;
EmpathyContactList *list_iface;
GtkBuilder *gui;
GtkWidget *sw;
@@ -1398,41 +1467,41 @@ empathy_main_window_show (void)
gchar *filename;
GSList *l;
- if (main_window) {
- empathy_window_present (GTK_WINDOW (main_window->window));
- return main_window->window;
- }
+ priv = window->priv = G_TYPE_INSTANCE_GET_PRIVATE (window,
+ EMPATHY_TYPE_MAIN_WINDOW, EmpathyMainWindowPriv);
- main_window = g_new0 (EmpathyMainWindow, 1);
- window = main_window;
+ priv->gsettings_ui = g_settings_new (EMPATHY_PREFS_UI_SCHEMA);
+ priv->gsettings_contacts = g_settings_new (EMPATHY_PREFS_CONTACTS_SCHEMA);
- window->gsettings_ui = g_settings_new (EMPATHY_PREFS_UI_SCHEMA);
- window->gsettings_contacts = g_settings_new (EMPATHY_PREFS_CONTACTS_SCHEMA);
+ gtk_window_set_title (GTK_WINDOW (window), _("Contact List"));
+ gtk_window_set_role (GTK_WINDOW (window), "contact_list");
+ gtk_window_set_default_size (GTK_WINDOW (window), 225, 325);
/* Set up interface */
filename = empathy_file_lookup ("empathy-main-window.ui", "src");
gui = empathy_builder_get_file (filename,
- "main_window", &window->window,
- "main_vbox", &window->main_vbox,
- "errors_vbox", &window->errors_vbox,
- "ui_manager", &window->ui_manager,
+ "main_vbox", &priv->main_vbox,
+ "errors_vbox", &priv->errors_vbox,
+ "ui_manager", &priv->ui_manager,
"view_show_offline", &show_offline_widget,
- "view_show_protocols", &window->show_protocols,
- "view_sort_by_name", &window->sort_by_name,
- "view_sort_by_status", &window->sort_by_status,
- "view_normal_size_with_avatars", &window->normal_with_avatars,
- "view_normal_size", &window->normal_size,
- "view_compact_size", &window->compact_size,
- "view_history", &window->view_history,
+ "view_show_protocols", &priv->show_protocols,
+ "view_sort_by_name", &priv->sort_by_name,
+ "view_sort_by_status", &priv->sort_by_status,
+ "view_normal_size_with_avatars", &priv->normal_with_avatars,
+ "view_normal_size", &priv->normal_size,
+ "view_compact_size", &priv->compact_size,
+ "view_history", &priv->view_history,
"view_show_map", &show_map_widget,
- "room_join_favorites", &window->room_join_favorites,
- "presence_toolbar", &window->presence_toolbar,
+ "room_join_favorites", &priv->room_join_favorites,
+ "presence_toolbar", &priv->presence_toolbar,
"roster_scrolledwindow", &sw,
NULL);
g_free (filename);
+ gtk_container_add (GTK_CONTAINER (window), priv->main_vbox);
+ gtk_widget_show (priv->main_vbox);
+
empathy_builder_connect (gui, window,
- "main_window", "destroy", main_window_destroy_cb,
"main_window", "key-press-event", main_window_key_press_event_cb,
"chat_quit", "activate", main_window_chat_quit_cb,
"chat_new_message", "activate", main_window_chat_new_message_cb,
@@ -1460,133 +1529,134 @@ empathy_main_window_show (void)
/* Set up connection related widgets. */
main_window_connection_items_setup (window, gui);
- g_object_ref (window->ui_manager);
+ g_object_ref (priv->ui_manager);
g_object_unref (gui);
#if !HAVE_LIBCHAMPLAIN
gtk_action_set_visible (show_map_widget, FALSE);
#endif
- window->account_manager = tp_account_manager_dup ();
+ priv->account_manager = tp_account_manager_dup ();
- tp_account_manager_prepare_async (window->account_manager, NULL,
+ tp_account_manager_prepare_async (priv->account_manager, NULL,
account_manager_prepared_cb, window);
- window->errors = g_hash_table_new_full (g_direct_hash,
- g_direct_equal,
- g_object_unref,
- NULL);
+ priv->errors = g_hash_table_new_full (g_direct_hash,
+ g_direct_equal,
+ g_object_unref,
+ NULL);
- window->status_changed_handlers = g_hash_table_new_full (g_direct_hash,
- g_direct_equal,
- NULL,
- NULL);
+ priv->status_changed_handlers = g_hash_table_new_full (g_direct_hash,
+ g_direct_equal,
+ NULL,
+ NULL);
/* Set up menu */
main_window_favorite_chatroom_menu_setup (window);
- window->edit_context = gtk_ui_manager_get_widget (window->ui_manager,
+ priv->edit_context = gtk_ui_manager_get_widget (priv->ui_manager,
"/menubar/edit/edit_context");
- window->edit_context_separator = gtk_ui_manager_get_widget (window->ui_manager,
+ priv->edit_context_separator = gtk_ui_manager_get_widget (
+ priv->ui_manager,
"/menubar/edit/edit_context_separator");
- gtk_widget_hide (window->edit_context);
- gtk_widget_hide (window->edit_context_separator);
+ gtk_widget_hide (priv->edit_context);
+ gtk_widget_hide (priv->edit_context_separator);
/* Set up contact list. */
empathy_status_presets_get_all ();
/* Set up presence chooser */
- window->presence_chooser = empathy_presence_chooser_new ();
- gtk_widget_show (window->presence_chooser);
+ priv->presence_chooser = empathy_presence_chooser_new ();
+ gtk_widget_show (priv->presence_chooser);
item = gtk_tool_item_new ();
gtk_widget_show (GTK_WIDGET (item));
- gtk_container_add (GTK_CONTAINER (item), window->presence_chooser);
+ gtk_container_add (GTK_CONTAINER (item), priv->presence_chooser);
gtk_tool_item_set_is_important (item, TRUE);
gtk_tool_item_set_expand (item, TRUE);
- gtk_toolbar_insert (GTK_TOOLBAR (window->presence_toolbar), item, -1);
+ gtk_toolbar_insert (GTK_TOOLBAR (priv->presence_toolbar), item, -1);
/* Set up the throbber */
- window->throbber = gtk_spinner_new ();
- gtk_widget_set_size_request (window->throbber, 16, -1);
- gtk_widget_set_tooltip_text (window->throbber, _("Show and edit accounts"));
- gtk_widget_set_has_window (GTK_WIDGET (window->throbber), TRUE);
- gtk_widget_set_events (window->throbber, GDK_BUTTON_PRESS_MASK);
- g_signal_connect (window->throbber, "button-press-event",
+ priv->throbber = gtk_spinner_new ();
+ gtk_widget_set_size_request (priv->throbber, 16, -1);
+ gtk_widget_set_tooltip_text (priv->throbber, _("Show and edit accounts"));
+ gtk_widget_set_has_window (GTK_WIDGET (priv->throbber), TRUE);
+ gtk_widget_set_events (priv->throbber, GDK_BUTTON_PRESS_MASK);
+ g_signal_connect (priv->throbber, "button-press-event",
G_CALLBACK (main_window_throbber_button_press_event_cb),
window);
- gtk_widget_show (window->throbber);
+ gtk_widget_show (priv->throbber);
item = gtk_tool_item_new ();
gtk_container_set_border_width (GTK_CONTAINER (item), 6);
- gtk_toolbar_insert (GTK_TOOLBAR (window->presence_toolbar), item, -1);
- gtk_container_add (GTK_CONTAINER (item), window->throbber);
- window->throbber_tool_item = GTK_WIDGET (item);
+ gtk_toolbar_insert (GTK_TOOLBAR (priv->presence_toolbar), item, -1);
+ gtk_container_add (GTK_CONTAINER (item), priv->throbber);
+ priv->throbber_tool_item = GTK_WIDGET (item);
list_iface = EMPATHY_CONTACT_LIST (empathy_contact_manager_dup_singleton ());
- window->list_store = empathy_contact_list_store_new (list_iface);
- window->list_view = empathy_contact_list_view_new (window->list_store,
- EMPATHY_CONTACT_LIST_FEATURE_ALL,
- EMPATHY_CONTACT_FEATURE_ALL);
+ priv->list_store = empathy_contact_list_store_new (list_iface);
+ priv->list_view = empathy_contact_list_view_new (priv->list_store,
+ EMPATHY_CONTACT_LIST_FEATURE_ALL,
+ EMPATHY_CONTACT_FEATURE_ALL);
- window->butterfly_log_migration_members_changed_id = g_signal_connect (
+ priv->butterfly_log_migration_members_changed_id = g_signal_connect (
list_iface, "members-changed",
G_CALLBACK (main_window_members_changed_cb), window);
g_object_unref (list_iface);
- gtk_widget_show (GTK_WIDGET (window->list_view));
+ gtk_widget_show (GTK_WIDGET (priv->list_view));
gtk_container_add (GTK_CONTAINER (sw),
- GTK_WIDGET (window->list_view));
- g_signal_connect (window->list_view, "row-activated",
+ GTK_WIDGET (priv->list_view));
+ g_signal_connect (priv->list_view, "row-activated",
G_CALLBACK (main_window_row_activated_cb),
window);
/* Set up search bar */
- window->search_bar = empathy_live_search_new (
- GTK_WIDGET (window->list_view));
- empathy_contact_list_view_set_live_search (window->list_view,
- EMPATHY_LIVE_SEARCH (window->search_bar));
- gtk_box_pack_start (GTK_BOX (window->main_vbox), window->search_bar,
+ priv->search_bar = empathy_live_search_new (
+ GTK_WIDGET (priv->list_view));
+ empathy_contact_list_view_set_live_search (priv->list_view,
+ EMPATHY_LIVE_SEARCH (priv->search_bar));
+ gtk_box_pack_start (GTK_BOX (priv->main_vbox), priv->search_bar,
FALSE, TRUE, 0);
- g_signal_connect_swapped (window->window, "map",
- G_CALLBACK (gtk_widget_grab_focus), window->list_view);
+ g_signal_connect_swapped (window, "map",
+ G_CALLBACK (gtk_widget_grab_focus), priv->list_view);
/* Load user-defined accelerators. */
main_window_accels_load ();
/* Set window size. */
- empathy_geometry_bind (GTK_WINDOW (window->window), GEOMETRY_NAME);
+ empathy_geometry_bind (GTK_WINDOW (window), GEOMETRY_NAME);
/* Enable event handling */
- window->event_manager = empathy_event_manager_dup_singleton ();
- g_signal_connect (window->event_manager, "event-added",
+ priv->event_manager = empathy_event_manager_dup_singleton ();
+ g_signal_connect (priv->event_manager, "event-added",
G_CALLBACK (main_window_event_added_cb),
window);
- g_signal_connect (window->event_manager, "event-removed",
+ g_signal_connect (priv->event_manager, "event-removed",
G_CALLBACK (main_window_event_removed_cb),
window);
- g_signal_connect (window->account_manager, "account-validity-changed",
+ g_signal_connect (priv->account_manager, "account-validity-changed",
G_CALLBACK (main_window_account_validity_changed_cb),
window);
- g_signal_connect (window->account_manager, "account-removed",
+ g_signal_connect (priv->account_manager, "account-removed",
G_CALLBACK (main_window_account_removed_cb),
window);
- g_signal_connect (window->account_manager, "account-disabled",
+ g_signal_connect (priv->account_manager, "account-disabled",
G_CALLBACK (main_window_account_disabled_cb),
window);
- l = empathy_event_manager_get_events (window->event_manager);
+ l = empathy_event_manager_get_events (priv->event_manager);
while (l) {
- main_window_event_added_cb (window->event_manager,
+ main_window_event_added_cb (priv->event_manager,
l->data, window);
l = l->next;
}
/* Show offline ? */
- show_offline = g_settings_get_boolean (window->gsettings_ui,
+ show_offline = g_settings_get_boolean (priv->gsettings_ui,
EMPATHY_PREFS_UI_SHOW_OFFLINE);
- g_signal_connect (window->gsettings_ui,
+ g_signal_connect (priv->gsettings_ui,
"changed::" EMPATHY_PREFS_UI_SHOW_OFFLINE,
G_CALLBACK (main_window_notify_show_offline_cb),
show_offline_widget);
@@ -1594,39 +1664,42 @@ empathy_main_window_show (void)
gtk_toggle_action_set_active (show_offline_widget, show_offline);
/* Show protocol ? */
- g_signal_connect (window->gsettings_ui,
+ g_signal_connect (priv->gsettings_ui,
"changed::" EMPATHY_PREFS_UI_SHOW_PROTOCOLS,
G_CALLBACK (main_window_notify_show_protocols_cb),
window);
- main_window_notify_show_protocols_cb (window->gsettings_ui,
+ main_window_notify_show_protocols_cb (priv->gsettings_ui,
EMPATHY_PREFS_UI_SHOW_PROTOCOLS,
window);
/* Sort by name / by status ? */
- g_signal_connect (window->gsettings_contacts,
+ g_signal_connect (priv->gsettings_contacts,
"changed::" EMPATHY_PREFS_CONTACTS_SORT_CRITERIUM,
G_CALLBACK (main_window_notify_sort_contact_cb),
window);
- main_window_notify_sort_contact_cb (window->gsettings_contacts,
+ main_window_notify_sort_contact_cb (priv->gsettings_contacts,
EMPATHY_PREFS_CONTACTS_SORT_CRITERIUM,
window);
/* Contacts list size */
- g_signal_connect (window->gsettings_ui,
+ g_signal_connect (priv->gsettings_ui,
"changed::" EMPATHY_PREFS_UI_COMPACT_CONTACT_LIST,
G_CALLBACK (main_window_notify_contact_list_size_cb),
window);
- g_signal_connect (window->gsettings_ui,
+ g_signal_connect (priv->gsettings_ui,
"changed::" EMPATHY_PREFS_UI_SHOW_AVATARS,
G_CALLBACK (main_window_notify_contact_list_size_cb),
window);
- main_window_notify_contact_list_size_cb (window->gsettings_ui,
+ main_window_notify_contact_list_size_cb (priv->gsettings_ui,
EMPATHY_PREFS_UI_SHOW_AVATARS,
window);
-
- return window->window;
}
+GtkWidget *
+empathy_main_window_dup (void)
+{
+ return g_object_new (EMPATHY_TYPE_MAIN_WINDOW, NULL);
+}
diff --git a/src/empathy-main-window.h b/src/empathy-main-window.h
index 3d34e6c6b..38879fb29 100644
--- a/src/empathy-main-window.h
+++ b/src/empathy-main-window.h
@@ -19,6 +19,7 @@
* Boston, MA 02110-1301 USA
*
* Authors: Xavier Claessens <xclaesse@gmail.com>
+ * Danielle Madeley <danielle.madeley@collabora.co.uk>
*/
#ifndef __EMPATHY_MAIN_WINDOW_H__
@@ -28,8 +29,29 @@
G_BEGIN_DECLS
-GtkWidget *empathy_main_window_get (void);
-GtkWidget *empathy_main_window_show (void);
+#define EMPATHY_TYPE_MAIN_WINDOW (empathy_main_window_get_type ())
+#define EMPATHY_MAIN_WINDOW(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), EMPATHY_TYPE_MAIN_WINDOW, EmpathyMainWindow))
+#define EMPATHY_MAIN_WINDOW_CLASS(k) (G_TYPE_CHECK_CLASS_CAST ((k), EMPATHY_TYPE_MAIN_WINDOW, EmpathyMainWindowClass))
+#define EMPATHY_IS_MAIN_WINDOW(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), EMPATHY_TYPE_MAIN_WINDOW))
+#define EMPATHY_IS_MAIN_WINDOW_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), EMPATHY_TYPE_MAIN_WINDOW))
+#define EMPATHY_MAIN_WINDOW_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), EMPATHY_TYPE_MAIN_WINDOW, EmpathyMainWindowClass))
+
+typedef struct _EmpathyMainWindow EmpathyMainWindow;
+typedef struct _EmpathyMainWindowClass EmpathyMainWindowClass;
+typedef struct _EmpathyMainWindowPriv EmpathyMainWindowPriv;
+
+struct _EmpathyMainWindow {
+ GtkWindow parent;
+ gpointer priv;
+};
+
+struct _EmpathyMainWindowClass {
+ GtkWindowClass parent_class;
+};
+
+GType empathy_main_window_get_type (void);
+
+GtkWidget *empathy_main_window_dup (void);
G_END_DECLS
diff --git a/src/empathy-main-window.ui b/src/empathy-main-window.ui
index 2fc81b408..cd0ff296c 100644
--- a/src/empathy-main-window.ui
+++ b/src/empathy-main-window.ui
@@ -267,12 +267,6 @@
</menubar>
</ui>
</object>
- <object class="GtkWindow" id="main_window">
- <property name="title" translatable="yes">Contact List</property>
- <property name="role">contact_list</property>
- <property name="default_width">225</property>
- <property name="default_height">325</property>
- <child>
<object class="GtkVBox" id="main_vbox">
<property name="visible">True</property>
<child>
@@ -323,6 +317,4 @@
</packing>
</child>
</object>
- </child>
- </object>
</interface>
diff --git a/src/empathy-preferences.c b/src/empathy-preferences.c
index 4460d6f85..e45e5405d 100644
--- a/src/empathy-preferences.c
+++ b/src/empathy-preferences.c
@@ -20,6 +20,7 @@
* Authors: Mikael Hallendal <micke@imendio.com>
* Richard Hult <richard@imendio.com>
* Martyn Russell <martyn@imendio.com>
+ * Danielle Madeley <danielle.madeley@collabora.co.uk>
*/
#include <config.h>
@@ -46,9 +47,11 @@
#include "empathy-preferences.h"
-typedef struct {
- GtkWidget *dialog;
+G_DEFINE_TYPE (EmpathyPreferences, empathy_preferences, GTK_TYPE_DIALOG);
+
+#define GET_PRIV(self) ((EmpathyPreferencesPriv*)((EmpathyPreferences*)self)->priv)
+struct _EmpathyPreferencesPriv {
GtkWidget *notebook;
GtkWidget *checkbutton_show_smileys;
@@ -81,7 +84,7 @@ typedef struct {
GSettings *gsettings_notify;
GSettings *gsettings_sound;
GSettings *gsettings_ui;
-} EmpathyPreferences;
+};
static void preferences_setup_widgets (EmpathyPreferences *preferences);
static void preferences_languages_setup (EmpathyPreferences *preferences);
@@ -99,11 +102,6 @@ static gboolean preferences_languages_load_foreach (GtkTreeModel
static void preferences_languages_cell_toggled_cb (GtkCellRendererToggle *cell,
gchar *path_string,
EmpathyPreferences *preferences);
-static void preferences_destroy_cb (GtkWidget *widget,
- EmpathyPreferences *preferences);
-static void preferences_response_cb (GtkWidget *widget,
- gint response,
- EmpathyPreferences *preferences);
enum {
COL_LANG_ENABLED,
@@ -146,145 +144,147 @@ static SoundEventEntry sound_entries [] = {
static void
preferences_setup_widgets (EmpathyPreferences *preferences)
{
- g_settings_bind (preferences->gsettings_notify,
+ EmpathyPreferencesPriv *priv = GET_PRIV (preferences);
+
+ g_settings_bind (priv->gsettings_notify,
EMPATHY_PREFS_NOTIFICATIONS_ENABLED,
- preferences->checkbutton_notifications_enabled,
+ priv->checkbutton_notifications_enabled,
"active",
G_SETTINGS_BIND_DEFAULT);
- g_settings_bind (preferences->gsettings_notify,
+ g_settings_bind (priv->gsettings_notify,
EMPATHY_PREFS_NOTIFICATIONS_DISABLED_AWAY,
- preferences->checkbutton_notifications_disabled_away,
+ priv->checkbutton_notifications_disabled_away,
"active",
G_SETTINGS_BIND_DEFAULT);
- g_settings_bind (preferences->gsettings_notify,
+ g_settings_bind (priv->gsettings_notify,
EMPATHY_PREFS_NOTIFICATIONS_FOCUS,
- preferences->checkbutton_notifications_focus,
+ priv->checkbutton_notifications_focus,
"active",
G_SETTINGS_BIND_DEFAULT);
- g_settings_bind (preferences->gsettings_notify,
+ g_settings_bind (priv->gsettings_notify,
EMPATHY_PREFS_NOTIFICATIONS_CONTACT_SIGNIN,
- preferences->checkbutton_notifications_contact_signin,
+ priv->checkbutton_notifications_contact_signin,
"active",
G_SETTINGS_BIND_DEFAULT);
- g_settings_bind (preferences->gsettings_notify,
+ g_settings_bind (priv->gsettings_notify,
EMPATHY_PREFS_NOTIFICATIONS_CONTACT_SIGNOUT,
- preferences->checkbutton_notifications_contact_signout,
+ priv->checkbutton_notifications_contact_signout,
"active",
G_SETTINGS_BIND_DEFAULT);
- g_settings_bind (preferences->gsettings_notify,
+ g_settings_bind (priv->gsettings_notify,
EMPATHY_PREFS_NOTIFICATIONS_ENABLED,
- preferences->checkbutton_notifications_disabled_away,
+ priv->checkbutton_notifications_disabled_away,
"sensitive",
G_SETTINGS_BIND_GET);
- g_settings_bind (preferences->gsettings_notify,
+ g_settings_bind (priv->gsettings_notify,
EMPATHY_PREFS_NOTIFICATIONS_ENABLED,
- preferences->checkbutton_notifications_focus,
+ priv->checkbutton_notifications_focus,
"sensitive",
G_SETTINGS_BIND_GET);
- g_settings_bind (preferences->gsettings_notify,
+ g_settings_bind (priv->gsettings_notify,
EMPATHY_PREFS_NOTIFICATIONS_ENABLED,
- preferences->checkbutton_notifications_contact_signin,
+ priv->checkbutton_notifications_contact_signin,
"sensitive",
G_SETTINGS_BIND_GET);
- g_settings_bind (preferences->gsettings_notify,
+ g_settings_bind (priv->gsettings_notify,
EMPATHY_PREFS_NOTIFICATIONS_ENABLED,
- preferences->checkbutton_notifications_contact_signout,
+ priv->checkbutton_notifications_contact_signout,
"sensitive",
G_SETTINGS_BIND_GET);
- g_settings_bind (preferences->gsettings_sound,
+ g_settings_bind (priv->gsettings_sound,
EMPATHY_PREFS_SOUNDS_ENABLED,
- preferences->checkbutton_sounds_enabled,
+ priv->checkbutton_sounds_enabled,
"active",
G_SETTINGS_BIND_DEFAULT);
- g_settings_bind (preferences->gsettings_sound,
+ g_settings_bind (priv->gsettings_sound,
EMPATHY_PREFS_SOUNDS_DISABLED_AWAY,
- preferences->checkbutton_sounds_disabled_away,
+ priv->checkbutton_sounds_disabled_away,
"active",
G_SETTINGS_BIND_DEFAULT);
- g_settings_bind (preferences->gsettings_sound,
+ g_settings_bind (priv->gsettings_sound,
EMPATHY_PREFS_SOUNDS_ENABLED,
- preferences->checkbutton_sounds_disabled_away,
+ priv->checkbutton_sounds_disabled_away,
"sensitive",
G_SETTINGS_BIND_GET);
- g_settings_bind (preferences->gsettings_sound,
+ g_settings_bind (priv->gsettings_sound,
EMPATHY_PREFS_SOUNDS_ENABLED,
- preferences->treeview_sounds,
+ priv->treeview_sounds,
"sensitive",
G_SETTINGS_BIND_GET);
- g_settings_bind (preferences->gsettings_ui,
+ g_settings_bind (priv->gsettings_ui,
EMPATHY_PREFS_UI_SEPARATE_CHAT_WINDOWS,
- preferences->checkbutton_separate_chat_windows,
+ priv->checkbutton_separate_chat_windows,
"active",
G_SETTINGS_BIND_DEFAULT);
- g_settings_bind (preferences->gsettings_chat,
+ g_settings_bind (priv->gsettings_chat,
EMPATHY_PREFS_CHAT_SHOW_SMILEYS,
- preferences->checkbutton_show_smileys,
+ priv->checkbutton_show_smileys,
"active",
G_SETTINGS_BIND_DEFAULT);
- g_settings_bind (preferences->gsettings_chat,
+ g_settings_bind (priv->gsettings_chat,
EMPATHY_PREFS_CHAT_SHOW_CONTACTS_IN_ROOMS,
- preferences->checkbutton_show_contacts_in_rooms,
+ priv->checkbutton_show_contacts_in_rooms,
"active",
G_SETTINGS_BIND_DEFAULT);
- g_settings_bind (preferences->gsettings,
+ g_settings_bind (priv->gsettings,
EMPATHY_PREFS_AUTOCONNECT,
- preferences->checkbutton_autoconnect,
+ priv->checkbutton_autoconnect,
"active",
G_SETTINGS_BIND_DEFAULT);
- g_settings_bind (preferences->gsettings_loc,
+ g_settings_bind (priv->gsettings_loc,
EMPATHY_PREFS_LOCATION_PUBLISH,
- preferences->checkbutton_location_publish,
+ priv->checkbutton_location_publish,
"active",
G_SETTINGS_BIND_DEFAULT);
- g_settings_bind (preferences->gsettings_loc,
+ g_settings_bind (priv->gsettings_loc,
EMPATHY_PREFS_LOCATION_RESOURCE_NETWORK,
- preferences->checkbutton_location_resource_network,
+ priv->checkbutton_location_resource_network,
"active",
G_SETTINGS_BIND_DEFAULT);
- g_settings_bind (preferences->gsettings_loc,
+ g_settings_bind (priv->gsettings_loc,
EMPATHY_PREFS_LOCATION_PUBLISH,
- preferences->checkbutton_location_resource_network,
+ priv->checkbutton_location_resource_network,
"sensitive",
G_SETTINGS_BIND_GET);
- g_settings_bind (preferences->gsettings_loc,
+ g_settings_bind (priv->gsettings_loc,
EMPATHY_PREFS_LOCATION_RESOURCE_CELL,
- preferences->checkbutton_location_resource_cell,
+ priv->checkbutton_location_resource_cell,
"active",
G_SETTINGS_BIND_DEFAULT);
- g_settings_bind (preferences->gsettings_loc,
+ g_settings_bind (priv->gsettings_loc,
EMPATHY_PREFS_LOCATION_PUBLISH,
- preferences->checkbutton_location_resource_cell,
+ priv->checkbutton_location_resource_cell,
"sensitive",
G_SETTINGS_BIND_GET);
- g_settings_bind (preferences->gsettings_loc,
+ g_settings_bind (priv->gsettings_loc,
EMPATHY_PREFS_LOCATION_RESOURCE_GPS,
- preferences->checkbutton_location_resource_gps,
+ priv->checkbutton_location_resource_gps,
"active",
G_SETTINGS_BIND_DEFAULT);
- g_settings_bind (preferences->gsettings_loc,
+ g_settings_bind (priv->gsettings_loc,
EMPATHY_PREFS_LOCATION_PUBLISH,
- preferences->checkbutton_location_resource_gps,
+ priv->checkbutton_location_resource_gps,
"sensitive",
G_SETTINGS_BIND_GET);
- g_settings_bind (preferences->gsettings_loc,
+ g_settings_bind (priv->gsettings_loc,
EMPATHY_PREFS_LOCATION_REDUCE_ACCURACY,
- preferences->checkbutton_location_reduce_accuracy,
+ priv->checkbutton_location_reduce_accuracy,
"active",
G_SETTINGS_BIND_DEFAULT);
- g_settings_bind (preferences->gsettings_loc,
+ g_settings_bind (priv->gsettings_loc,
EMPATHY_PREFS_LOCATION_PUBLISH,
- preferences->checkbutton_location_reduce_accuracy,
+ priv->checkbutton_location_reduce_accuracy,
"sensitive",
G_SETTINGS_BIND_GET);
}
@@ -294,6 +294,7 @@ preferences_sound_cell_toggled_cb (GtkCellRendererToggle *toggle,
char *path_string,
EmpathyPreferences *preferences)
{
+ EmpathyPreferencesPriv *priv = GET_PRIV (preferences);
GtkTreePath *path;
gboolean toggled, instore;
GtkTreeIter iter;
@@ -301,7 +302,7 @@ preferences_sound_cell_toggled_cb (GtkCellRendererToggle *toggle,
GtkTreeModel *model;
char *key;
- view = GTK_TREE_VIEW (preferences->treeview_sounds);
+ view = GTK_TREE_VIEW (priv->treeview_sounds);
model = gtk_tree_view_get_model (view);
path = gtk_tree_path_new_from_string (path_string);
@@ -316,7 +317,7 @@ preferences_sound_cell_toggled_cb (GtkCellRendererToggle *toggle,
gtk_list_store_set (GTK_LIST_STORE (model), &iter,
COL_SOUND_ENABLED, instore, -1);
- g_settings_set_boolean (preferences->gsettings_sound, key, instore);
+ g_settings_set_boolean (priv->gsettings_sound, key, instore);
g_free (key);
gtk_tree_path_free (path);
@@ -325,17 +326,18 @@ preferences_sound_cell_toggled_cb (GtkCellRendererToggle *toggle,
static void
preferences_sound_load (EmpathyPreferences *preferences)
{
+ EmpathyPreferencesPriv *priv = GET_PRIV (preferences);
guint i;
GtkTreeView *view;
GtkListStore *store;
GtkTreeIter iter;
gboolean set;
- view = GTK_TREE_VIEW (preferences->treeview_sounds);
+ view = GTK_TREE_VIEW (priv->treeview_sounds);
store = GTK_LIST_STORE (gtk_tree_view_get_model (view));
for (i = 0; i < G_N_ELEMENTS (sound_entries); i++) {
- set = g_settings_get_boolean (preferences->gsettings_sound,
+ set = g_settings_get_boolean (priv->gsettings_sound,
sound_entries[i].key);
gtk_list_store_insert_with_values (store, &iter, i,
@@ -348,12 +350,13 @@ preferences_sound_load (EmpathyPreferences *preferences)
static void
preferences_sound_setup (EmpathyPreferences *preferences)
{
+ EmpathyPreferencesPriv *priv = GET_PRIV (preferences);
GtkTreeView *view;
GtkListStore *store;
GtkCellRenderer *renderer;
GtkTreeViewColumn *column;
- view = GTK_TREE_VIEW (preferences->treeview_sounds);
+ view = GTK_TREE_VIEW (priv->treeview_sounds);
store = gtk_list_store_new (COL_SOUND_COUNT,
G_TYPE_BOOLEAN, /* enabled */
@@ -388,6 +391,7 @@ preferences_sound_setup (EmpathyPreferences *preferences)
static void
preferences_languages_setup (EmpathyPreferences *preferences)
{
+ EmpathyPreferencesPriv *priv = GET_PRIV (preferences);
GtkTreeView *view;
GtkListStore *store;
GtkTreeSelection *selection;
@@ -396,7 +400,7 @@ preferences_languages_setup (EmpathyPreferences *preferences)
GtkCellRenderer *renderer;
guint col_offset;
- view = GTK_TREE_VIEW (preferences->treeview_spell_checker);
+ view = GTK_TREE_VIEW (priv->treeview_spell_checker);
store = gtk_list_store_new (COL_LANG_COUNT,
G_TYPE_BOOLEAN, /* enabled */
@@ -442,20 +446,21 @@ preferences_languages_setup (EmpathyPreferences *preferences)
static void
preferences_languages_add (EmpathyPreferences *preferences)
{
+ EmpathyPreferencesPriv *priv = GET_PRIV (preferences);
GtkTreeView *view;
GtkListStore *store;
GList *codes, *l;
- view = GTK_TREE_VIEW (preferences->treeview_spell_checker);
+ view = GTK_TREE_VIEW (priv->treeview_spell_checker);
store = GTK_LIST_STORE (gtk_tree_view_get_model (view));
codes = empathy_spell_get_language_codes ();
- g_settings_set_boolean (preferences->gsettings_chat,
+ g_settings_set_boolean (priv->gsettings_chat,
EMPATHY_PREFS_CHAT_SPELL_CHECKER_ENABLED,
codes != NULL);
if (!codes) {
- gtk_widget_set_sensitive (preferences->treeview_spell_checker, FALSE);
+ gtk_widget_set_sensitive (priv->treeview_spell_checker, FALSE);
}
for (l = codes; l; l = l->next) {
@@ -482,12 +487,13 @@ preferences_languages_add (EmpathyPreferences *preferences)
static void
preferences_languages_save (EmpathyPreferences *preferences)
{
+ EmpathyPreferencesPriv *priv = GET_PRIV (preferences);
GtkTreeView *view;
GtkTreeModel *model;
gchar *languages = NULL;
- view = GTK_TREE_VIEW (preferences->treeview_spell_checker);
+ view = GTK_TREE_VIEW (priv->treeview_spell_checker);
model = gtk_tree_view_get_model (view);
gtk_tree_model_foreach (model,
@@ -495,11 +501,11 @@ preferences_languages_save (EmpathyPreferences *preferences)
&languages);
/* if user selects no languages, we don't want spell check */
- g_settings_set_boolean (preferences->gsettings_chat,
+ g_settings_set_boolean (priv->gsettings_chat,
EMPATHY_PREFS_CHAT_SPELL_CHECKER_ENABLED,
languages != NULL);
- g_settings_set_string (preferences->gsettings_chat,
+ g_settings_set_string (priv->gsettings_chat,
EMPATHY_PREFS_CHAT_SPELL_CHECKER_LANGUAGES,
languages != NULL ? languages : "");
@@ -545,12 +551,13 @@ preferences_languages_save_foreach (GtkTreeModel *model,
static void
preferences_languages_load (EmpathyPreferences *preferences)
{
+ EmpathyPreferencesPriv *priv = GET_PRIV (preferences);
GtkTreeView *view;
GtkTreeModel *model;
gchar *value;
gchar **vlanguages;
- value = g_settings_get_string (preferences->gsettings_chat,
+ value = g_settings_get_string (priv->gsettings_chat,
EMPATHY_PREFS_CHAT_SPELL_CHECKER_LANGUAGES);
if (value == NULL)
@@ -559,7 +566,7 @@ preferences_languages_load (EmpathyPreferences *preferences)
vlanguages = g_strsplit (value, ",", -1);
g_free (value);
- view = GTK_TREE_VIEW (preferences->treeview_spell_checker);
+ view = GTK_TREE_VIEW (priv->treeview_spell_checker);
model = gtk_tree_view_get_model (view);
gtk_tree_model_foreach (model,
@@ -605,6 +612,7 @@ preferences_languages_cell_toggled_cb (GtkCellRendererToggle *cell,
gchar *path_string,
EmpathyPreferences *preferences)
{
+ EmpathyPreferencesPriv *priv = GET_PRIV (preferences);
GtkTreeView *view;
GtkTreeModel *model;
GtkListStore *store;
@@ -612,7 +620,7 @@ preferences_languages_cell_toggled_cb (GtkCellRendererToggle *cell,
GtkTreeIter iter;
gboolean enabled;
- view = GTK_TREE_VIEW (preferences->treeview_spell_checker);
+ view = GTK_TREE_VIEW (priv->treeview_spell_checker);
model = gtk_tree_view_get_model (view);
store = GTK_LIST_STORE (model);
@@ -635,6 +643,7 @@ preferences_theme_notify_cb (GSettings *gsettings,
gpointer user_data)
{
EmpathyPreferences *preferences = user_data;
+ EmpathyPreferencesPriv *priv = GET_PRIV (preferences);
GtkComboBox *combo;
gchar *conf_name;
gchar *conf_path;
@@ -645,7 +654,7 @@ preferences_theme_notify_cb (GSettings *gsettings,
conf_name = g_settings_get_string (gsettings, EMPATHY_PREFS_CHAT_THEME);
conf_path = g_settings_get_string (gsettings, EMPATHY_PREFS_CHAT_ADIUM_PATH);
- combo = GTK_COMBO_BOX (preferences->combobox_chat_theme);
+ combo = GTK_COMBO_BOX (priv->combobox_chat_theme);
model = gtk_combo_box_get_model (combo);
if (gtk_tree_model_get_iter_first (model, &iter)) {
gboolean is_adium;
@@ -690,6 +699,7 @@ static void
preferences_theme_changed_cb (GtkComboBox *combo,
EmpathyPreferences *preferences)
{
+ EmpathyPreferencesPriv *priv = GET_PRIV (preferences);
GtkTreeModel *model;
GtkTreeIter iter;
gboolean is_adium;
@@ -705,11 +715,11 @@ preferences_theme_changed_cb (GtkComboBox *combo,
COL_COMBO_PATH, &path,
-1);
- g_settings_set_string (preferences->gsettings_chat,
+ g_settings_set_string (priv->gsettings_chat,
EMPATHY_PREFS_CHAT_THEME,
name);
if (is_adium == TRUE)
- g_settings_set_string (preferences->gsettings_chat,
+ g_settings_set_string (priv->gsettings_chat,
EMPATHY_PREFS_CHAT_ADIUM_PATH,
path);
g_free (name);
@@ -720,6 +730,7 @@ preferences_theme_changed_cb (GtkComboBox *combo,
static void
preferences_themes_setup (EmpathyPreferences *preferences)
{
+ EmpathyPreferencesPriv *priv = GET_PRIV (preferences);
GtkComboBox *combo;
GtkCellLayout *cell_layout;
GtkCellRenderer *renderer;
@@ -728,7 +739,7 @@ preferences_themes_setup (EmpathyPreferences *preferences)
GList *adium_themes;
gint i;
- combo = GTK_COMBO_BOX (preferences->combobox_chat_theme);
+ combo = GTK_COMBO_BOX (priv->combobox_chat_theme);
cell_layout = GTK_CELL_LAYOUT (combo);
/* Create the model */
@@ -787,98 +798,114 @@ preferences_themes_setup (EmpathyPreferences *preferences)
preferences);
/* Select the theme from the GSetting key and track changes */
- preferences_theme_notify_cb (preferences->gsettings_chat,
+ preferences_theme_notify_cb (priv->gsettings_chat,
EMPATHY_PREFS_CHAT_THEME,
preferences);
- g_signal_connect (preferences->gsettings_chat,
+ g_signal_connect (priv->gsettings_chat,
"changed::" EMPATHY_PREFS_CHAT_THEME,
G_CALLBACK (preferences_theme_notify_cb),
preferences);
- g_signal_connect (preferences->gsettings_chat,
+ g_signal_connect (priv->gsettings_chat,
"changed::" EMPATHY_PREFS_CHAT_ADIUM_PATH,
G_CALLBACK (preferences_theme_notify_cb),
preferences);
}
static void
-preferences_response_cb (GtkWidget *widget,
- gint response,
- EmpathyPreferences *preferences)
+empathy_preferences_response (GtkDialog *widget,
+ gint response)
{
- gtk_widget_destroy (widget);
+ gtk_widget_destroy (GTK_WIDGET (widget));
}
static void
-preferences_destroy_cb (GtkWidget *widget,
- EmpathyPreferences *preferences)
+empathy_preferences_finalize (GObject *self)
{
- g_object_unref (preferences->gsettings);
- g_object_unref (preferences->gsettings_chat);
- g_object_unref (preferences->gsettings_loc);
- g_object_unref (preferences->gsettings_notify);
- g_object_unref (preferences->gsettings_sound);
- g_object_unref (preferences->gsettings_ui);
-
- g_free (preferences);
+ EmpathyPreferencesPriv *priv = GET_PRIV (self);
+
+ g_object_unref (priv->gsettings);
+ g_object_unref (priv->gsettings_chat);
+ g_object_unref (priv->gsettings_loc);
+ g_object_unref (priv->gsettings_notify);
+ g_object_unref (priv->gsettings_sound);
+ g_object_unref (priv->gsettings_ui);
+
+ G_OBJECT_CLASS (empathy_preferences_parent_class)->finalize (self);
}
-GtkWidget *
-empathy_preferences_show (GtkWindow *parent)
+static void
+empathy_preferences_class_init (EmpathyPreferencesClass *klass)
{
- static EmpathyPreferences *preferences;
+ GtkDialogClass *dialog_class = GTK_DIALOG_CLASS (klass);
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+
+ dialog_class->response = empathy_preferences_response;
+
+ object_class->finalize = empathy_preferences_finalize;
+
+ g_type_class_add_private (object_class,
+ sizeof (EmpathyPreferencesPriv));
+}
+
+static void
+empathy_preferences_init (EmpathyPreferences *preferences)
+{
+ EmpathyPreferencesPriv *priv;
GtkBuilder *gui;
gchar *filename;
GtkWidget *page;
- if (preferences) {
- gtk_window_present (GTK_WINDOW (preferences->dialog));
- return preferences->dialog;
- }
+ priv = preferences->priv = G_TYPE_INSTANCE_GET_PRIVATE (preferences,
+ EMPATHY_TYPE_PREFERENCES, EmpathyPreferencesPriv);
- preferences = g_new0 (EmpathyPreferences, 1);
+ gtk_dialog_add_button (GTK_DIALOG (preferences),
+ GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE);
+
+ gtk_container_set_border_width (GTK_CONTAINER (preferences), 5);
+ gtk_window_set_title (GTK_WINDOW (preferences), _("Preferences"));
+ gtk_window_set_role (GTK_WINDOW (preferences), "preferences");
+ gtk_window_set_position (GTK_WINDOW (preferences),
+ GTK_WIN_POS_CENTER_ON_PARENT);
+ gtk_window_set_icon_name (GTK_WINDOW (preferences), "gtk-preferences");
+ gtk_dialog_set_has_separator (GTK_DIALOG (preferences), FALSE);
filename = empathy_file_lookup ("empathy-preferences.ui", "src");
gui = empathy_builder_get_file (filename,
- "preferences_dialog", &preferences->dialog,
- "notebook", &preferences->notebook,
- "checkbutton_show_smileys", &preferences->checkbutton_show_smileys,
- "checkbutton_show_contacts_in_rooms", &preferences->checkbutton_show_contacts_in_rooms,
- "combobox_chat_theme", &preferences->combobox_chat_theme,
- "checkbutton_separate_chat_windows", &preferences->checkbutton_separate_chat_windows,
- "checkbutton_autoconnect", &preferences->checkbutton_autoconnect,
- "checkbutton_notifications_enabled", &preferences->checkbutton_notifications_enabled,
- "checkbutton_notifications_disabled_away", &preferences->checkbutton_notifications_disabled_away,
- "checkbutton_notifications_focus", &preferences->checkbutton_notifications_focus,
- "checkbutton_notifications_contact_signin", &preferences->checkbutton_notifications_contact_signin,
- "checkbutton_notifications_contact_signout", &preferences->checkbutton_notifications_contact_signout,
- "checkbutton_sounds_enabled", &preferences->checkbutton_sounds_enabled,
- "checkbutton_sounds_disabled_away", &preferences->checkbutton_sounds_disabled_away,
- "treeview_sounds", &preferences->treeview_sounds,
- "treeview_spell_checker", &preferences->treeview_spell_checker,
- "checkbutton_location_publish", &preferences->checkbutton_location_publish,
- "checkbutton_location_reduce_accuracy", &preferences->checkbutton_location_reduce_accuracy,
- "checkbutton_location_resource_network", &preferences->checkbutton_location_resource_network,
- "checkbutton_location_resource_cell", &preferences->checkbutton_location_resource_cell,
- "checkbutton_location_resource_gps", &preferences->checkbutton_location_resource_gps,
+ "notebook", &priv->notebook,
+ "checkbutton_show_smileys", &priv->checkbutton_show_smileys,
+ "checkbutton_show_contacts_in_rooms", &priv->checkbutton_show_contacts_in_rooms,
+ "combobox_chat_theme", &priv->combobox_chat_theme,
+ "checkbutton_separate_chat_windows", &priv->checkbutton_separate_chat_windows,
+ "checkbutton_autoconnect", &priv->checkbutton_autoconnect,
+ "checkbutton_notifications_enabled", &priv->checkbutton_notifications_enabled,
+ "checkbutton_notifications_disabled_away", &priv->checkbutton_notifications_disabled_away,
+ "checkbutton_notifications_focus", &priv->checkbutton_notifications_focus,
+ "checkbutton_notifications_contact_signin", &priv->checkbutton_notifications_contact_signin,
+ "checkbutton_notifications_contact_signout", &priv->checkbutton_notifications_contact_signout,
+ "checkbutton_sounds_enabled", &priv->checkbutton_sounds_enabled,
+ "checkbutton_sounds_disabled_away", &priv->checkbutton_sounds_disabled_away,
+ "treeview_sounds", &priv->treeview_sounds,
+ "treeview_spell_checker", &priv->treeview_spell_checker,
+ "checkbutton_location_publish", &priv->checkbutton_location_publish,
+ "checkbutton_location_reduce_accuracy", &priv->checkbutton_location_reduce_accuracy,
+ "checkbutton_location_resource_network", &priv->checkbutton_location_resource_network,
+ "checkbutton_location_resource_cell", &priv->checkbutton_location_resource_cell,
+ "checkbutton_location_resource_gps", &priv->checkbutton_location_resource_gps,
NULL);
g_free (filename);
- empathy_builder_connect (gui, preferences,
- "preferences_dialog", "destroy", preferences_destroy_cb,
- "preferences_dialog", "response", preferences_response_cb,
- NULL);
+ gtk_container_add (GTK_CONTAINER (gtk_dialog_get_content_area (GTK_DIALOG (preferences))), priv->notebook);
+ gtk_widget_show (priv->notebook);
g_object_unref (gui);
- g_object_add_weak_pointer (G_OBJECT (preferences->dialog), (gpointer) &preferences);
-
- preferences->gsettings = g_settings_new (EMPATHY_PREFS_SCHEMA);
- preferences->gsettings_chat = g_settings_new (EMPATHY_PREFS_CHAT_SCHEMA);
- preferences->gsettings_loc = g_settings_new (EMPATHY_PREFS_LOCATION_SCHEMA);
- preferences->gsettings_notify = g_settings_new (EMPATHY_PREFS_NOTIFICATIONS_SCHEMA);
- preferences->gsettings_sound = g_settings_new (EMPATHY_PREFS_SOUNDS_SCHEMA);
- preferences->gsettings_ui = g_settings_new (EMPATHY_PREFS_UI_SCHEMA);
+ priv->gsettings = g_settings_new (EMPATHY_PREFS_SCHEMA);
+ priv->gsettings_chat = g_settings_new (EMPATHY_PREFS_CHAT_SCHEMA);
+ priv->gsettings_loc = g_settings_new (EMPATHY_PREFS_LOCATION_SCHEMA);
+ priv->gsettings_notify = g_settings_new (EMPATHY_PREFS_NOTIFICATIONS_SCHEMA);
+ priv->gsettings_sound = g_settings_new (EMPATHY_PREFS_SOUNDS_SCHEMA);
+ priv->gsettings_ui = g_settings_new (EMPATHY_PREFS_UI_SCHEMA);
preferences_themes_setup (preferences);
@@ -892,25 +919,31 @@ empathy_preferences_show (GtkWindow *parent)
preferences_sound_load (preferences);
if (empathy_spell_supported ()) {
- page = gtk_notebook_get_nth_page (GTK_NOTEBOOK (preferences->notebook), 2);
+ page = gtk_notebook_get_nth_page (GTK_NOTEBOOK (priv->notebook), 2);
gtk_widget_show (page);
}
- page = gtk_notebook_get_nth_page (GTK_NOTEBOOK (preferences->notebook), 3);
+ page = gtk_notebook_get_nth_page (GTK_NOTEBOOK (priv->notebook), 3);
#if HAVE_GEOCLUE
gtk_widget_show (page);
#else
gtk_widget_hide (page);
#endif
+}
+GtkWidget *
+empathy_preferences_new (GtkWindow *parent)
+{
+ GtkWidget *self;
- if (parent) {
- gtk_window_set_transient_for (GTK_WINDOW (preferences->dialog),
- GTK_WINDOW (parent));
- }
+ g_return_val_if_fail (parent == NULL || GTK_IS_WINDOW (parent), NULL);
- gtk_widget_show (preferences->dialog);
+ self = g_object_new (EMPATHY_TYPE_PREFERENCES, NULL);
- return preferences->dialog;
-}
+ if (parent != NULL) {
+ gtk_window_set_transient_for (GTK_WINDOW (self),
+ parent);
+ }
+ return self;
+}
diff --git a/src/empathy-preferences.h b/src/empathy-preferences.h
index aba58828e..0d7204fcc 100644
--- a/src/empathy-preferences.h
+++ b/src/empathy-preferences.h
@@ -20,6 +20,7 @@
* Authors: Mikael Hallendal <micke@imendio.com>
* Richard Hult <richard@imendio.com>
* Martyn Russell <martyn@imendio.com>
+ * Danielle Madeley <danielle.madeley@collabora.co.uk>
*/
#ifndef __EMPATHY_PREFERENCES_H__
@@ -29,7 +30,29 @@
G_BEGIN_DECLS
-GtkWidget * empathy_preferences_show (GtkWindow *parent);
+#define EMPATHY_TYPE_PREFERENCES (empathy_preferences_get_type ())
+#define EMPATHY_PREFERENCES(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), EMPATHY_TYPE_PREFERENCES, EmpathyPreferences))
+#define EMPATHY_PREFERENCES_CLASS(k) (G_TYPE_CHECK_CLASS_CAST ((k), EMPATHY_TYPE_PREFERENCES, EmpathyPreferencesClass))
+#define EMPATHY_IS_PREFERENCES(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), EMPATHY_TYPE_PREFERENCES))
+#define EMPATHY_IS_PREFERENCES_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), EMPATHY_TYPE_PREFERENCES))
+#define EMPATHY_PREFERENCES_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), EMPATHY_TYPE_PREFERENCES, EmpathyPreferencesClass))
+
+typedef struct _EmpathyPreferences EmpathyPreferences;
+typedef struct _EmpathyPreferencesClass EmpathyPreferencesClass;
+typedef struct _EmpathyPreferencesPriv EmpathyPreferencesPriv;
+
+struct _EmpathyPreferences {
+ GtkDialog parent;
+ gpointer priv;
+};
+
+struct _EmpathyPreferencesClass {
+ GtkDialogClass parent_class;
+};
+
+GType empathy_preferences_get_type (void);
+
+GtkWidget *empathy_preferences_new (GtkWindow *parent);
G_END_DECLS
diff --git a/src/empathy-preferences.ui b/src/empathy-preferences.ui
index aa4cc153f..e39d36d8a 100644
--- a/src/empathy-preferences.ui
+++ b/src/empathy-preferences.ui
@@ -2,19 +2,6 @@
<interface>
<requires lib="gtk+" version="2.16"/>
<!-- interface-naming-policy toplevel-contextual -->
- <object class="GtkDialog" id="preferences_dialog">
- <property name="border_width">5</property>
- <property name="title" translatable="yes">Preferences</property>
- <property name="role">preferences</property>
- <property name="window_position">center-on-parent</property>
- <property name="icon_name">gtk-preferences</property>
- <property name="type_hint">dialog</property>
- <property name="has_separator">False</property>
- <child internal-child="vbox">
- <object class="GtkVBox" id="dialog-vbox5">
- <property name="visible">True</property>
- <property name="spacing">2</property>
- <child>
<object class="GtkNotebook" id="notebook">
<property name="visible">True</property>
<property name="can_focus">True</property>
@@ -793,40 +780,4 @@
</packing>
</child>
</object>
- <packing>
- <property name="position">1</property>
- </packing>
- </child>
- <child internal-child="action_area">
- <object class="GtkHButtonBox" id="dialog-action_area5">
- <property name="visible">True</property>
- <property name="layout_style">end</property>
- <child>
- <object class="GtkButton" id="button_close">
- <property name="label">gtk-close</property>
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="can_default">True</property>
- <property name="receives_default">False</property>
- <property name="use_stock">True</property>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">False</property>
- <property name="position">0</property>
- </packing>
- </child>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="pack_type">end</property>
- <property name="position">0</property>
- </packing>
- </child>
- </object>
- </child>
- <action-widgets>
- <action-widget response="-6">button_close</action-widget>
- </action-widgets>
- </object>
</interface>
diff --git a/src/empathy.c b/src/empathy.c
index 85c0ea8b7..e1b6528eb 100644
--- a/src/empathy.c
+++ b/src/empathy.c
@@ -649,7 +649,8 @@ main (int argc, char *argv[])
migrate_config_to_xdg_dir ();
/* Setting up UI */
- window = empathy_main_window_show ();
+ window = empathy_main_window_dup ();
+ gtk_widget_show (window);
icon = empathy_status_icon_new (GTK_WINDOW (window), start_hidden);
/* Chat manager */