diff options
author | Guillaume Desmottes <gdesmott@gnome.org> | 2008-01-25 05:23:09 +0800 |
---|---|---|
committer | Guillaume Desmottes <gdesmott@gnome.org> | 2008-01-25 05:23:09 +0800 |
commit | e1a2ac951fec7ef11aaeaf3da6b62c036b2be7e9 (patch) | |
tree | 7523f8ac52a5fd7b958d55f9f6533c6add0ace11 /libempathy-gtk | |
parent | 915e5f6d71da5ce14b2462f2db850c90be7546bf (diff) | |
parent | ec3abba0aee010621b096c854851938d9501b3fd (diff) | |
download | gsoc2013-empathy-e1a2ac951fec7ef11aaeaf3da6b62c036b2be7e9.tar gsoc2013-empathy-e1a2ac951fec7ef11aaeaf3da6b62c036b2be7e9.tar.gz gsoc2013-empathy-e1a2ac951fec7ef11aaeaf3da6b62c036b2be7e9.tar.bz2 gsoc2013-empathy-e1a2ac951fec7ef11aaeaf3da6b62c036b2be7e9.tar.lz gsoc2013-empathy-e1a2ac951fec7ef11aaeaf3da6b62c036b2be7e9.tar.xz gsoc2013-empathy-e1a2ac951fec7ef11aaeaf3da6b62c036b2be7e9.tar.zst gsoc2013-empathy-e1a2ac951fec7ef11aaeaf3da6b62c036b2be7e9.zip |
Merge branch 'master' into irc
Conflicts:
docs/libempathy/libempathy-docs.sgml
docs/libempathy/libempathy.types
Diffstat (limited to 'libempathy-gtk')
46 files changed, 1681 insertions, 1715 deletions
diff --git a/libempathy-gtk/Makefile.am b/libempathy-gtk/Makefile.am index d726c357d..b857a8c8b 100644 --- a/libempathy-gtk/Makefile.am +++ b/libempathy-gtk/Makefile.am @@ -15,6 +15,7 @@ libempathy_gtk_la_SOURCES = \ ephy-spinner.c ephy-spinner.h \ empathy-main-window.c \ empathy-status-icon.c \ + empathy-conf.c \ empathy-contact-widget.c \ empathy-contact-dialogs.c \ empathy-accounts-dialog.c \ @@ -29,7 +30,6 @@ libempathy_gtk_la_SOURCES = \ empathy-cell-renderer-activatable.c \ empathy-spell.c \ empathy-spell-dialog.c \ - empathy-contact-groups.c \ empathy-contact-list-store.c \ empathy-contact-list-view.c \ empathy-preferences.c \ @@ -44,7 +44,6 @@ libempathy_gtk_la_SOURCES = \ empathy-private-chat.c \ empathy-group-chat.c \ empathy-geometry.c \ - empathy-status-presets.c \ empathy-presence-chooser.c \ empathy-about-dialog.c \ empathy-account-chooser.c \ @@ -72,6 +71,7 @@ libempathy_gtk_headers = \ empathy-images.h \ empathy-main-window.h \ empathy-status-icon.h \ + empathy-conf.h \ empathy-contact-widget.h \ empathy-contact-dialogs.h \ empathy-accounts-dialog.h \ @@ -86,7 +86,6 @@ libempathy_gtk_headers = \ empathy-cell-renderer-activatable.h \ empathy-spell.h \ empathy-spell-dialog.h \ - empathy-contact-groups.h \ empathy-contact-list-store.h \ empathy-contact-list-view.h \ empathy-preferences.h \ @@ -101,7 +100,6 @@ libempathy_gtk_headers = \ empathy-private-chat.h \ empathy-group-chat.h \ empathy-geometry.h \ - empathy-status-presets.h \ empathy-presence-chooser.h \ empathy-about-dialog.h \ empathy-account-chooser.h \ @@ -179,17 +177,11 @@ empathy-gtk-enum-types.c: Makefile $(libempathy_gtk_headers) && cp xgen-gtc $(@F) \ && rm -f xgen-gtc -dtddir = $(datadir)/empathy -dtd_DATA = \ - empathy-status-presets.dtd \ - empathy-contact-groups.dtd - pkgconfigdir = $(libdir)/pkgconfig pkgconfig_DATA = libempathy-gtk.pc EXTRA_DIST = \ - $(glade_DATA) \ - $(dtd_DATA) + $(glade_DATA) CLEANFILES = \ $(BUILT_SOURCES) \ diff --git a/libempathy-gtk/empathy-account-widget-generic.c b/libempathy-gtk/empathy-account-widget-generic.c index 999b64499..8ade3f26f 100644 --- a/libempathy-gtk/empathy-account-widget-generic.c +++ b/libempathy-gtk/empathy-account-widget-generic.c @@ -48,19 +48,6 @@ typedef struct { guint n_rows; } EmpathyAccountWidgetGeneric; -static gboolean account_widget_generic_entry_focus_cb (GtkWidget *widget, - GdkEventFocus *event, - EmpathyAccountWidgetGeneric *settings); -static void account_widget_generic_int_changed_cb (GtkWidget *widget, - EmpathyAccountWidgetGeneric *settings); -static void account_widget_generic_checkbutton_toggled_cb (GtkWidget *widget, - EmpathyAccountWidgetGeneric *settings); -static gchar * account_widget_generic_format_param_name (const gchar *param_name); -static void account_widget_generic_setup_foreach (McProtocolParam *param, - EmpathyAccountWidgetGeneric *settings); -static void account_widget_generic_destroy_cb (GtkWidget *widget, - EmpathyAccountWidgetGeneric *settings); - static gboolean account_widget_generic_entry_focus_cb (GtkWidget *widget, GdkEventFocus *event, diff --git a/libempathy-gtk/empathy-account-widget-jabber.c b/libempathy-gtk/empathy-account-widget-jabber.c index 81e7d3513..b3339f128 100644 --- a/libempathy-gtk/empathy-account-widget-jabber.c +++ b/libempathy-gtk/empathy-account-widget-jabber.c @@ -32,10 +32,13 @@ #include <libmissioncontrol/mc-profile.h> #include <libempathy/empathy-utils.h> +#include <libempathy/empathy-debug.h> #include "empathy-account-widget-jabber.h" #include "empathy-ui-utils.h" +#define DEBUG_DOMAIN "AccountWidgetJabber" + #define PORT_WITHOUT_SSL 5222 #define PORT_WITH_SSL 5223 @@ -51,23 +54,10 @@ typedef struct { GtkWidget *spinbutton_port; GtkWidget *spinbutton_priority; GtkWidget *checkbutton_ssl; + GtkWidget *checkbutton_ignore_ssl_errors; + GtkWidget *checkbutton_encryption; } EmpathyAccountWidgetJabber; -static gboolean account_widget_jabber_entry_focus_cb (GtkWidget *widget, - GdkEventFocus *event, - EmpathyAccountWidgetJabber *settings); -static void account_widget_jabber_entry_changed_cb (GtkWidget *widget, - EmpathyAccountWidgetJabber *settings); -static void account_widget_jabber_checkbutton_toggled_cb (GtkWidget *widget, - EmpathyAccountWidgetJabber *settings); -static void account_widget_jabber_value_changed_cb (GtkWidget *spinbutton, - EmpathyAccountWidgetJabber *settings); -static void account_widget_jabber_button_forget_clicked_cb (GtkWidget *button, - EmpathyAccountWidgetJabber *settings); -static void account_widget_jabber_destroy_cb (GtkWidget *widget, - EmpathyAccountWidgetJabber *settings); -static void account_widget_jabber_setup (EmpathyAccountWidgetJabber *settings); - static gboolean account_widget_jabber_entry_focus_cb (GtkWidget *widget, GdkEventFocus *event, @@ -95,10 +85,13 @@ account_widget_jabber_entry_focus_cb (GtkWidget *widget, if (G_STR_EMPTY (str)) { gchar *value = NULL; + mc_account_unset_param (settings->account, param); mc_account_get_param_string (settings->account, param, &value); + empathy_debug (DEBUG_DOMAIN, "Unset %s and restore to %s", param, value); gtk_entry_set_text (GTK_ENTRY (widget), value ? value : ""); g_free (value); } else { + empathy_debug (DEBUG_DOMAIN, "Setting %s to %s", param, str); mc_account_set_param_string (settings->account, param, str); } @@ -121,26 +114,50 @@ static void account_widget_jabber_checkbutton_toggled_cb (GtkWidget *widget, EmpathyAccountWidgetJabber *settings) { + gboolean value; + gboolean default_value; + const gchar *param; + + value = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget)); + if (widget == settings->checkbutton_ssl) { - gint port = 0; - gboolean old_ssl; + gint port = 0; mc_account_get_param_int (settings->account, "port", &port); - old_ssl = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget)); - if (old_ssl) { - if (port == PORT_WITHOUT_SSL) { + if (value) { + if (port == PORT_WITHOUT_SSL || port == 0) { port = PORT_WITH_SSL; } } else { - if (port == PORT_WITH_SSL) { + if (port == PORT_WITH_SSL || port == 0) { port = PORT_WITHOUT_SSL; } } - - mc_account_set_param_int (settings->account, "port", port); - mc_account_set_param_boolean (settings->account, "old-ssl", old_ssl); + gtk_spin_button_set_value (GTK_SPIN_BUTTON (settings->spinbutton_port), port); + param = "old-ssl"; + } + else if (widget == settings->checkbutton_ignore_ssl_errors) { + param = "ignore-ssl-errors"; + } + else if (widget == settings->checkbutton_encryption) { + param = "require-encryption"; + } else { + return; + } + + /* FIXME: This is ugly! checkbox don't have a "not-set" value so we + * always unset the param and set the value if different from the + * default value. */ + mc_account_unset_param (settings->account, param); + mc_account_get_param_boolean (settings->account, param, &default_value); + + if (default_value != value) { + empathy_debug (DEBUG_DOMAIN, "Setting %s to %d", param, value); + mc_account_set_param_boolean (settings->account, param, value); + } else { + empathy_debug (DEBUG_DOMAIN, "Unset %s", param, value); } } @@ -148,15 +165,30 @@ static void account_widget_jabber_value_changed_cb (GtkWidget *spinbutton, EmpathyAccountWidgetJabber *settings) { - gdouble value; + gdouble value; + const gchar *param; value = gtk_spin_button_get_value (GTK_SPIN_BUTTON (spinbutton)); if (spinbutton == settings->spinbutton_port) { - mc_account_set_param_int (settings->account, "port", (gint) value); + param = "port"; } else if (spinbutton == settings->spinbutton_priority) { - mc_account_set_param_int (settings->account, "priority", (gint) value); + param = "priority"; + } else { + return; + } + + if (value != 0) { + empathy_debug (DEBUG_DOMAIN, "Setting %s to %d", param, (gint) value); + mc_account_set_param_int (settings->account, param, (gint) value); + } else { + gint val; + + mc_account_unset_param (settings->account, param); + mc_account_get_param_int (settings->account, param, &val); + empathy_debug (DEBUG_DOMAIN, "Unset %s and restore to %d", param, val); + gtk_spin_button_set_value (GTK_SPIN_BUTTON (spinbutton), val); } } @@ -164,7 +196,8 @@ static void account_widget_jabber_button_forget_clicked_cb (GtkWidget *button, EmpathyAccountWidgetJabber *settings) { - mc_account_set_param_string (settings->account, "password", ""); + empathy_debug (DEBUG_DOMAIN, "Unset password"); + mc_account_unset_param (settings->account, "password"); gtk_entry_set_text (GTK_ENTRY (settings->entry_password), ""); } @@ -186,6 +219,8 @@ account_widget_jabber_setup (EmpathyAccountWidgetJabber *settings) gchar *server = NULL; gchar *password = NULL; gboolean old_ssl = FALSE; + gboolean ignore_ssl_errors = FALSE; + gboolean encryption = FALSE; mc_account_get_param_int (settings->account, "port", &port); mc_account_get_param_int (settings->account, "priority", &priority); @@ -194,6 +229,8 @@ account_widget_jabber_setup (EmpathyAccountWidgetJabber *settings) mc_account_get_param_string (settings->account, "server", &server); mc_account_get_param_string (settings->account, "password", &password); mc_account_get_param_boolean (settings->account, "old-ssl", &old_ssl); + mc_account_get_param_boolean (settings->account, "ignore-ssl-errors", &ignore_ssl_errors); + mc_account_get_param_boolean (settings->account, "require-encryption", &encryption); if (!id) { McProfile *profile; @@ -207,13 +244,15 @@ account_widget_jabber_setup (EmpathyAccountWidgetJabber *settings) g_object_unref (profile); } - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (settings->checkbutton_ssl), old_ssl); + gtk_spin_button_set_value (GTK_SPIN_BUTTON (settings->spinbutton_port), port); + gtk_spin_button_set_value (GTK_SPIN_BUTTON (settings->spinbutton_priority), priority); gtk_entry_set_text (GTK_ENTRY (settings->entry_id), id ? id : ""); - gtk_entry_set_text (GTK_ENTRY (settings->entry_password), password ? password : ""); gtk_entry_set_text (GTK_ENTRY (settings->entry_resource), resource ? resource : ""); gtk_entry_set_text (GTK_ENTRY (settings->entry_server), server ? server : ""); - gtk_spin_button_set_value (GTK_SPIN_BUTTON (settings->spinbutton_port), port); - gtk_spin_button_set_value (GTK_SPIN_BUTTON (settings->spinbutton_priority), priority); + gtk_entry_set_text (GTK_ENTRY (settings->entry_password), password ? password : ""); + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (settings->checkbutton_ssl), old_ssl); + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (settings->checkbutton_ignore_ssl_errors), ignore_ssl_errors); + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (settings->checkbutton_encryption), encryption); gtk_widget_set_sensitive (settings->button_forget, !G_STR_EMPTY (password)); @@ -228,7 +267,6 @@ empathy_account_widget_jabber_new (McAccount *account) { EmpathyAccountWidgetJabber *settings; GladeXML *glade; - GtkSizeGroup *size_group; GtkWidget *label_id, *label_password; GtkWidget *label_server, *label_resource; GtkWidget *label_port, *label_priority; @@ -254,6 +292,8 @@ empathy_account_widget_jabber_new (McAccount *account) "spinbutton_port", &settings->spinbutton_port, "spinbutton_priority", &settings->spinbutton_priority, "checkbutton_ssl", &settings->checkbutton_ssl, + "checkbutton_ignore_ssl_errors", &settings->checkbutton_ignore_ssl_errors, + "checkbutton_encryption", &settings->checkbutton_encryption, NULL); account_widget_jabber_setup (settings); @@ -270,22 +310,12 @@ empathy_account_widget_jabber_new (McAccount *account) "entry_resource", "focus-out-event", account_widget_jabber_entry_focus_cb, "entry_server", "focus-out-event", account_widget_jabber_entry_focus_cb, "checkbutton_ssl", "toggled", account_widget_jabber_checkbutton_toggled_cb, + "checkbutton_ignore_ssl_errors", "toggled", account_widget_jabber_checkbutton_toggled_cb, + "checkbutton_encryption", "toggled", account_widget_jabber_checkbutton_toggled_cb, NULL); g_object_unref (glade); - /* Set up remaining widgets */ - size_group = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL); - - gtk_size_group_add_widget (size_group, label_id); - gtk_size_group_add_widget (size_group, label_password); - gtk_size_group_add_widget (size_group, label_resource); - gtk_size_group_add_widget (size_group, label_server); - gtk_size_group_add_widget (size_group, label_port); - gtk_size_group_add_widget (size_group, label_priority); - - g_object_unref (size_group); - gtk_widget_show (settings->vbox_settings); return settings->vbox_settings; diff --git a/libempathy-gtk/empathy-account-widget-jabber.glade b/libempathy-gtk/empathy-account-widget-jabber.glade index 3536dc1d3..d691d1418 100644 --- a/libempathy-gtk/empathy-account-widget-jabber.glade +++ b/libempathy-gtk/empathy-account-widget-jabber.glade @@ -35,35 +35,6 @@ <property name="column_spacing">12</property> <child> - <widget class="GtkLabel" id="label_id"> - <property name="visible">True</property> - <property name="label" translatable="yes">Login I_D:</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_id</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="GtkLabel" id="label_password"> <property name="visible">True</property> <property name="label" translatable="yes">Pass_word:</property> @@ -123,11 +94,40 @@ </child> <child> - <widget class="GtkEntry" id="entry_password"> + <widget class="GtkLabel" id="label_id"> + <property name="visible">True</property> + <property name="label" translatable="yes">Login I_D:</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_id</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_id"> <property name="visible">True</property> <property name="can_focus">True</property> <property name="editable">True</property> - <property name="visibility">False</property> + <property name="visibility">True</property> <property name="max_length">0</property> <property name="text" translatable="yes"></property> <property name="has_frame">True</property> @@ -136,19 +136,19 @@ </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="right_attach">3</property> + <property name="top_attach">0</property> + <property name="bottom_attach">1</property> <property name="y_options"></property> </packing> </child> <child> - <widget class="GtkEntry" id="entry_id"> + <widget class="GtkEntry" id="entry_password"> <property name="visible">True</property> <property name="can_focus">True</property> <property name="editable">True</property> - <property name="visibility">True</property> + <property name="visibility">False</property> <property name="max_length">0</property> <property name="text" translatable="yes"></property> <property name="has_frame">True</property> @@ -157,9 +157,9 @@ </widget> <packing> <property name="left_attach">1</property> - <property name="right_attach">3</property> - <property name="top_attach">0</property> - <property name="bottom_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> @@ -179,232 +179,352 @@ <property name="spacing">0</property> <child> - <widget class="GtkTable" id="table_advanced_settings"> + <widget class="GtkVBox" id="vbox1"> <property name="visible">True</property> - <property name="n_rows">5</property> - <property name="n_columns">3</property> <property name="homogeneous">False</property> - <property name="row_spacing">6</property> - <property name="column_spacing">12</property> + <property name="spacing">0</property> <child> - <widget class="GtkLabel" id="label_resource"> + <widget class="GtkTable" id="table_advanced_settings"> <property name="visible">True</property> - <property name="label" translatable="yes">Reso_urce:</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_resource</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> + <property name="n_rows">4</property> + <property name="n_columns">3</property> + <property name="homogeneous">False</property> + <property name="row_spacing">6</property> + <property name="column_spacing">12</property> - <child> - <widget class="GtkEntry" id="entry_resource"> - <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">3</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_encryption"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="label" translatable="yes">_Encryption required (TLS/SSL)</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">0</property> + <property name="right_attach">3</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="GtkCheckButton" id="checkbutton_ssl"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="label" translatable="yes">Use encryption (SS_L)</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">0</property> - <property name="right_attach">3</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> + <child> + <widget class="GtkLabel" id="label_resource"> + <property name="visible">True</property> + <property name="label" translatable="yes">Reso_urce:</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_resource</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_port"> - <property name="visible">True</property> - <property name="label" translatable="yes">_Port:</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">spinbutton_port</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_priority"> + <property name="visible">True</property> + <property name="label" translatable="yes">Pri_ority:</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">spinbutton_priority</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="GtkSpinButton" id="spinbutton_port"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="climb_rate">1</property> - <property name="digits">0</property> - <property name="numeric">True</property> - <property name="update_policy">GTK_UPDATE_ALWAYS</property> - <property name="snap_to_ticks">False</property> - <property name="wrap">False</property> - <property name="adjustment">5222 0 65556 1 10 10</property> - </widget> - <packing> - <property name="left_attach">1</property> - <property name="right_attach">3</property> - <property name="top_attach">3</property> - <property name="bottom_attach">4</property> - <property name="y_options"></property> - </packing> - </child> + <child> + <widget class="GtkCheckButton" id="checkbutton_ignore_ssl_errors"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="label" translatable="yes">_Ignore SSL certificate errors</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">0</property> + <property name="right_attach">3</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_server"> - <property name="visible">True</property> - <property name="label" translatable="yes">_Server:</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="GtkSpinButton" id="spinbutton_priority"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="climb_rate">1</property> + <property name="digits">0</property> + <property name="numeric">False</property> + <property name="update_policy">GTK_UPDATE_ALWAYS</property> + <property name="snap_to_ticks">False</property> + <property name="wrap">False</property> + <property name="adjustment">0 -128 127 1 10 10</property> + </widget> + <packing> + <property name="left_attach">1</property> + <property name="right_attach">3</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> + <child> + <widget class="GtkEntry" id="entry_resource"> + <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">3</property> + <property name="top_attach">2</property> + <property name="bottom_attach">3</property> + <property name="y_options"></property> + </packing> + </child> </widget> <packing> - <property name="left_attach">1</property> - <property name="right_attach">3</property> - <property name="top_attach">2</property> - <property name="bottom_attach">3</property> - <property name="y_options"></property> + <property name="padding">0</property> + <property name="expand">True</property> + <property name="fill">True</property> </packing> </child> <child> - <widget class="GtkLabel" id="label_priority"> + <widget class="GtkFrame" id="frame1"> <property name="visible">True</property> - <property name="label" translatable="yes">Priority:</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="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> + <property name="label_xalign">0</property> + <property name="label_yalign">0.5</property> + <property name="shadow_type">GTK_SHADOW_NONE</property> - <child> - <widget class="GtkSpinButton" id="spinbutton_priority"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="climb_rate">1</property> - <property name="digits">0</property> - <property name="numeric">False</property> - <property name="update_policy">GTK_UPDATE_ALWAYS</property> - <property name="snap_to_ticks">False</property> - <property name="wrap">False</property> - <property name="adjustment">0 -128 127 1 10 10</property> + <child> + <widget class="GtkAlignment" id="alignment1"> + <property name="visible">True</property> + <property name="xalign">0.5</property> + <property name="yalign">0.5</property> + <property name="xscale">1</property> + <property name="yscale">1</property> + <property name="top_padding">0</property> + <property name="bottom_padding">0</property> + <property name="left_padding">12</property> + <property name="right_padding">0</property> + + <child> + <widget class="GtkTable" id="table1"> + <property name="visible">True</property> + <property name="n_rows">3</property> + <property name="n_columns">2</property> + <property name="homogeneous">False</property> + <property name="row_spacing">6</property> + <property name="column_spacing">6</property> + + <child> + <widget class="GtkLabel" id="label_server"> + <property name="visible">True</property> + <property name="label" translatable="yes">_Server:</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">0</property> + <property name="bottom_attach">1</property> + <property name="x_options">fill</property> + <property name="y_options"></property> + </packing> + </child> + + <child> + <widget class="GtkLabel" id="label_port"> + <property name="visible">True</property> + <property name="label" translatable="yes">_Port:</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">spinbutton_port</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="GtkCheckButton" id="checkbutton_ssl"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="label" translatable="yes">Use old SS_L</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">0</property> + <property name="right_attach">2</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="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">0</property> + <property name="bottom_attach">1</property> + <property name="y_options"></property> + </packing> + </child> + + <child> + <widget class="GtkSpinButton" id="spinbutton_port"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="climb_rate">1</property> + <property name="digits">0</property> + <property name="numeric">True</property> + <property name="update_policy">GTK_UPDATE_ALWAYS</property> + <property name="snap_to_ticks">False</property> + <property name="wrap">False</property> + <property name="adjustment">5222 0 65556 1 10 10</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> + </widget> + </child> + </widget> + </child> + + <child> + <widget class="GtkLabel" id="label2"> + <property name="visible">True</property> + <property name="label" translatable="yes"><b>Override server settings</b></property> + <property name="use_underline">False</property> + <property name="use_markup">True</property> + <property name="justify">GTK_JUSTIFY_LEFT</property> + <property name="wrap">False</property> + <property name="selectable">False</property> + <property name="xalign">0.5</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="type">label_item</property> + </packing> + </child> </widget> <packing> - <property name="left_attach">1</property> - <property name="right_attach">3</property> - <property name="top_attach">1</property> - <property name="bottom_attach">2</property> - <property name="y_options"></property> + <property name="padding">0</property> + <property name="expand">True</property> + <property name="fill">True</property> </packing> </child> </widget> diff --git a/libempathy-gtk/empathy-account-widget-msn.c b/libempathy-gtk/empathy-account-widget-msn.c index 891cc5354..edcd185ad 100644 --- a/libempathy-gtk/empathy-account-widget-msn.c +++ b/libempathy-gtk/empathy-account-widget-msn.c @@ -33,10 +33,13 @@ #include <libmissioncontrol/mc-profile.h> #include <libempathy/empathy-utils.h> +#include <libempathy/empathy-debug.h> #include "empathy-account-widget-msn.h" #include "empathy-ui-utils.h" +#define DEBUG_DOMAIN "AccountWidgetMSN" + typedef struct { McAccount *account; @@ -48,19 +51,6 @@ typedef struct { GtkWidget *spinbutton_port; } EmpathyAccountWidgetMSN; -static gboolean account_widget_msn_entry_focus_cb (GtkWidget *widget, - GdkEventFocus *event, - EmpathyAccountWidgetMSN *settings); -static void account_widget_msn_entry_changed_cb (GtkWidget *widget, - EmpathyAccountWidgetMSN *settings); -static void account_widget_msn_value_changed_cb (GtkWidget *spinbutton, - EmpathyAccountWidgetMSN *settings); -static void account_widget_msn_button_forget_clicked_cb (GtkWidget *button, - EmpathyAccountWidgetMSN *settings); -static void account_widget_msn_destroy_cb (GtkWidget *widget, - EmpathyAccountWidgetMSN *settings); -static void account_widget_msn_setup (EmpathyAccountWidgetMSN *settings); - static gboolean account_widget_msn_entry_focus_cb (GtkWidget *widget, GdkEventFocus *event, @@ -82,14 +72,16 @@ account_widget_msn_entry_focus_cb (GtkWidget *widget, } str = gtk_entry_get_text (GTK_ENTRY (widget)); - if (G_STR_EMPTY (str)) { gchar *value = NULL; + mc_account_unset_param (settings->account, param); mc_account_get_param_string (settings->account, param, &value); + empathy_debug (DEBUG_DOMAIN, "Unset %s and restore to %s", param, value); gtk_entry_set_text (GTK_ENTRY (widget), value ? value : ""); g_free (value); } else { + empathy_debug (DEBUG_DOMAIN, "Setting %s to %s", param, str); mc_account_set_param_string (settings->account, param, str); } @@ -112,11 +104,28 @@ static void account_widget_msn_value_changed_cb (GtkWidget *spinbutton, EmpathyAccountWidgetMSN *settings) { + gdouble value; + const gchar *param; + + value = gtk_spin_button_get_value (GTK_SPIN_BUTTON (spinbutton)); + if (spinbutton == settings->spinbutton_port) { - gdouble value; + param = "port"; + } else { + return; + } - value = gtk_spin_button_get_value (GTK_SPIN_BUTTON (spinbutton)); - mc_account_set_param_int (settings->account, "port", (gint) value); + if (value != 0) { + empathy_debug (DEBUG_DOMAIN, "Setting %s to %d", param, (gint) value); + mc_account_set_param_int (settings->account, param, (gint) value); + } else { + gint val; + + mc_account_unset_param (settings->account, param); + mc_account_get_param_int (settings->account, param, &val); + empathy_debug (DEBUG_DOMAIN, "Unset %s and restore to %d", param, val); + + gtk_spin_button_set_value (GTK_SPIN_BUTTON (spinbutton), val); } } @@ -124,7 +133,8 @@ static void account_widget_msn_button_forget_clicked_cb (GtkWidget *button, EmpathyAccountWidgetMSN *settings) { - mc_account_set_param_string (settings->account, "password", ""); + empathy_debug (DEBUG_DOMAIN, "Unset password"); + mc_account_unset_param (settings->account, "password"); gtk_entry_set_text (GTK_ENTRY (settings->entry_password), ""); } @@ -149,10 +159,10 @@ account_widget_msn_setup (EmpathyAccountWidgetMSN *settings) mc_account_get_param_string (settings->account, "server", &server); mc_account_get_param_string (settings->account, "password", &password); + gtk_spin_button_set_value (GTK_SPIN_BUTTON (settings->spinbutton_port), port); gtk_entry_set_text (GTK_ENTRY (settings->entry_id), id ? id : ""); - gtk_entry_set_text (GTK_ENTRY (settings->entry_password), password ? password : ""); gtk_entry_set_text (GTK_ENTRY (settings->entry_server), server ? server : ""); - gtk_spin_button_set_value (GTK_SPIN_BUTTON (settings->spinbutton_port), port); + gtk_entry_set_text (GTK_ENTRY (settings->entry_password), password ? password : ""); gtk_widget_set_sensitive (settings->button_forget, !G_STR_EMPTY (password)); diff --git a/libempathy-gtk/empathy-account-widget-salut.c b/libempathy-gtk/empathy-account-widget-salut.c index 63131e773..78dce2312 100644 --- a/libempathy-gtk/empathy-account-widget-salut.c +++ b/libempathy-gtk/empathy-account-widget-salut.c @@ -31,10 +31,13 @@ #include <libmissioncontrol/mc-profile.h> #include <libempathy/empathy-utils.h> +#include <libempathy/empathy-debug.h> #include "empathy-account-widget-salut.h" #include "empathy-ui-utils.h" +#define DEBUG_DOMAIN "AccountWidgetMSN" + typedef struct { McAccount *account; @@ -47,15 +50,6 @@ typedef struct { GtkWidget *entry_jid; } EmpathyAccountWidgetSalut; -static gboolean account_widget_salut_entry_focus_cb (GtkWidget *widget, - GdkEventFocus *event, - EmpathyAccountWidgetSalut *settings); -static void account_widget_salut_destroy_cb (GtkWidget *widget, - EmpathyAccountWidgetSalut *settings); -static void account_widget_salut_setup (EmpathyAccountWidgetSalut *settings); - - - static gboolean account_widget_salut_entry_focus_cb (GtkWidget *widget, GdkEventFocus *event, @@ -87,14 +81,16 @@ account_widget_salut_entry_focus_cb (GtkWidget *widget, } str = gtk_entry_get_text (GTK_ENTRY (widget)); - if (G_STR_EMPTY (str)) { gchar *value = NULL; + mc_account_unset_param (settings->account, param); mc_account_get_param_string (settings->account, param, &value); + empathy_debug (DEBUG_DOMAIN, "Unset %s and restore to %s", param, value); gtk_entry_set_text (GTK_ENTRY (widget), value ? value : ""); g_free (value); } else { + empathy_debug (DEBUG_DOMAIN, "Setting %s to %s", param, str); mc_account_set_param_string (settings->account, param, str); } diff --git a/libempathy-gtk/empathy-accounts-dialog.c b/libempathy-gtk/empathy-accounts-dialog.c index 13d8d552a..d614b827a 100644 --- a/libempathy-gtk/empathy-accounts-dialog.c +++ b/libempathy-gtk/empathy-accounts-dialog.c @@ -70,7 +70,6 @@ typedef struct { GtkWidget *button_add; GtkWidget *button_remove; - GtkWidget *button_connect; GtkWidget *frame_new_account; GtkWidget *combobox_profile; @@ -92,6 +91,7 @@ typedef struct { } EmpathyAccountsDialog; enum { + COL_ENABLED, COL_NAME, COL_STATUS, COL_ACCOUNT_POINTER, @@ -138,8 +138,6 @@ static void accounts_dialog_button_create_clicked_cb (GtkWidget EmpathyAccountsDialog *dialog); static void accounts_dialog_button_back_clicked_cb (GtkWidget *button, EmpathyAccountsDialog *dialog); -static void accounts_dialog_button_connect_clicked_cb (GtkWidget *button, - EmpathyAccountsDialog *dialog); static void accounts_dialog_button_add_clicked_cb (GtkWidget *button, EmpathyAccountsDialog *dialog); static void accounts_dialog_remove_response_cb (GtkWidget *dialog, @@ -147,10 +145,6 @@ static void accounts_dialog_remove_response_cb (GtkWidget McAccount *account); static void accounts_dialog_button_remove_clicked_cb (GtkWidget *button, EmpathyAccountsDialog *dialog); -static void accounts_dialog_treeview_row_activated_cb (GtkTreeView *tree_view, - GtkTreePath *path, - GtkTreeViewColumn *column, - EmpathyAccountsDialog *dialog); static void accounts_dialog_response_cb (GtkWidget *widget, gint response, EmpathyAccountsDialog *dialog); @@ -174,6 +168,7 @@ accounts_dialog_setup (EmpathyAccountsDialog *dialog) McAccount *account; const gchar *name; TpConnectionStatus status; + gboolean enabled; account = l->data; @@ -183,9 +178,11 @@ accounts_dialog_setup (EmpathyAccountsDialog *dialog) } status = mission_control_get_connection_status (dialog->mc, account, NULL); + enabled = mc_account_is_enabled (account); gtk_list_store_insert_with_values (store, &iter, -1, + COL_ENABLED, enabled, COL_NAME, name, COL_STATUS, status, COL_ACCOUNT_POINTER, account, @@ -205,32 +202,6 @@ accounts_dialog_setup (EmpathyAccountsDialog *dialog) } static void -accounts_dialog_update_connect_button (EmpathyAccountsDialog *dialog) -{ - McAccount *account; - GtkWidget *image; - const gchar *stock_id; - const gchar *label; - - account = accounts_dialog_model_get_selected (dialog); - - gtk_widget_set_sensitive (dialog->button_connect, account != NULL); - - if (account && mc_account_is_enabled (account)) { - label = _("Disable"); - stock_id = GTK_STOCK_DISCONNECT; - } else { - label = _("Enable"); - stock_id = GTK_STOCK_CONNECT; - } - - image = gtk_image_new_from_stock (stock_id, GTK_ICON_SIZE_BUTTON); - - gtk_button_set_label (GTK_BUTTON (dialog->button_connect), label); - gtk_button_set_image (GTK_BUTTON (dialog->button_connect), image); -} - -static void accounts_dialog_update_account (EmpathyAccountsDialog *dialog, McAccount *account) { @@ -248,7 +219,6 @@ accounts_dialog_update_account (EmpathyAccountsDialog *dialog, gtk_widget_show (dialog->frame_no_account); gtk_widget_hide (dialog->vbox_details); - gtk_widget_set_sensitive (dialog->button_connect, FALSE); gtk_widget_set_sensitive (dialog->button_remove, FALSE); view = GTK_TREE_VIEW (dialog->treeview); @@ -342,6 +312,7 @@ accounts_dialog_model_setup (EmpathyAccountsDialog *dialog) GtkTreeSelection *selection; store = gtk_list_store_new (COL_COUNT, + G_TYPE_BOOLEAN, /* enabled */ G_TYPE_STRING, /* name */ G_TYPE_UINT, /* status */ MC_TYPE_ACCOUNT); /* account */ @@ -391,6 +362,35 @@ accounts_dialog_name_edited_cb (GtkCellRendererText *renderer, } static void +accounts_dialog_enable_toggled_cb (GtkCellRendererToggle *cell_renderer, + gchar *path, + EmpathyAccountsDialog *dialog) +{ + McAccount *account; + GtkTreeModel *model; + GtkTreePath *treepath; + GtkTreeIter iter; + gboolean enabled; + + model = gtk_tree_view_get_model (GTK_TREE_VIEW (dialog->treeview)); + treepath = gtk_tree_path_new_from_string (path); + gtk_tree_model_get_iter (model, &iter, treepath); + gtk_tree_model_get (model, &iter, + COL_ACCOUNT_POINTER, &account, + -1); + gtk_tree_path_free (treepath); + + enabled = mc_account_is_enabled (account); + mc_account_set_enabled (account, !enabled); + + empathy_debug (DEBUG_DOMAIN, "%s account %s", + enabled ? "Disabled" : "Enable", + mc_account_get_display_name(account)); + + g_object_unref (account); +} + +static void accounts_dialog_model_add_columns (EmpathyAccountsDialog *dialog) { GtkTreeView *view; @@ -400,10 +400,18 @@ accounts_dialog_model_add_columns (EmpathyAccountsDialog *dialog) view = GTK_TREE_VIEW (dialog->treeview); gtk_tree_view_set_headers_visible (view, TRUE); - /* account name/status */ column = gtk_tree_view_column_new (); gtk_tree_view_column_set_title (column, _("Accounts")); + /* Enabled */ + cell = gtk_cell_renderer_toggle_new (); + gtk_tree_view_column_pack_start (column, cell, FALSE); + gtk_tree_view_column_add_attribute (column, cell, "active", COL_ENABLED); + g_signal_connect (cell, "toggled", + G_CALLBACK (accounts_dialog_enable_toggled_cb), + dialog); + + /* Icon */ cell = gtk_cell_renderer_pixbuf_new (); gtk_tree_view_column_pack_start (column, cell, FALSE); gtk_tree_view_column_set_cell_data_func (column, cell, @@ -412,15 +420,14 @@ accounts_dialog_model_add_columns (EmpathyAccountsDialog *dialog) dialog, NULL); + /* Name */ cell = gtk_cell_renderer_text_new (); g_object_set (cell, "ellipsize", PANGO_ELLIPSIZE_END, "editable", TRUE, NULL); gtk_tree_view_column_pack_start (column, cell, TRUE); - gtk_tree_view_column_add_attribute (column, - cell, - "text", COL_NAME); + gtk_tree_view_column_add_attribute (column, cell, "text", COL_NAME); g_signal_connect (cell, "edited", G_CALLBACK (accounts_dialog_name_edited_cb), dialog); @@ -501,6 +508,42 @@ accounts_dialog_model_pixbuf_data_func (GtkTreeViewColumn *tree_column, } } +static gboolean +accounts_dialog_get_account_iter (EmpathyAccountsDialog *dialog, + McAccount *account, + GtkTreeIter *iter) +{ + GtkTreeView *view; + GtkTreeSelection *selection; + GtkTreeModel *model; + gboolean ok; + + /* Update the status in the model */ + view = GTK_TREE_VIEW (dialog->treeview); + selection = gtk_tree_view_get_selection (view); + model = gtk_tree_view_get_model (view); + + for (ok = gtk_tree_model_get_iter_first (model, iter); + ok; + ok = gtk_tree_model_iter_next (model, iter)) { + McAccount *this_account; + gboolean equal; + + gtk_tree_model_get (model, iter, + COL_ACCOUNT_POINTER, &this_account, + -1); + + equal = empathy_account_equal (this_account, account); + g_object_unref (this_account); + + if (equal) { + return TRUE; + } + } + + return FALSE; +} + static McAccount * accounts_dialog_model_get_selected (EmpathyAccountsDialog *dialog) { @@ -524,35 +567,14 @@ accounts_dialog_model_get_selected (EmpathyAccountsDialog *dialog) static void accounts_dialog_model_set_selected (EmpathyAccountsDialog *dialog, - McAccount *account) + McAccount *account) { - GtkTreeView *view; GtkTreeSelection *selection; - GtkTreeModel *model; GtkTreeIter iter; - gboolean ok; - view = GTK_TREE_VIEW (dialog->treeview); - model = gtk_tree_view_get_model (view); - selection = gtk_tree_view_get_selection (view); - - for (ok = gtk_tree_model_get_iter_first (model, &iter); - ok; - ok = gtk_tree_model_iter_next (model, &iter)) { - McAccount *this_account; - gboolean equal; - - gtk_tree_model_get (model, &iter, - COL_ACCOUNT_POINTER, &this_account, - -1); - - equal = empathy_account_equal (this_account, account); - g_object_unref (this_account); - - if (equal) { - gtk_tree_selection_select_iter (selection, &iter); - break; - } + selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (dialog->treeview)); + if (accounts_dialog_get_account_iter (dialog, account, &iter)) { + gtk_tree_selection_select_iter (selection, &iter); } } @@ -587,9 +609,6 @@ accounts_dialog_model_selection_changed (GtkTreeSelection *selection, gtk_widget_set_sensitive (dialog->button_add, TRUE); gtk_widget_set_sensitive (dialog->button_remove, is_selection); - gtk_widget_set_sensitive (dialog->button_connect, is_selection); - - accounts_dialog_update_connect_button (dialog); account = accounts_dialog_model_get_selected (dialog); accounts_dialog_update_account (dialog, account); @@ -604,47 +623,30 @@ accounts_dialog_model_selection_changed (GtkTreeSelection *selection, static void accounts_dialog_add_account (EmpathyAccountsDialog *dialog, - McAccount *account) + McAccount *account) { - TpConnectionStatus status; - const gchar *name; - GtkTreeView *view; GtkTreeModel *model; - GtkListStore *store; GtkTreeIter iter; - gboolean ok; - - view = GTK_TREE_VIEW (dialog->treeview); - model = gtk_tree_view_get_model (view); - store = GTK_LIST_STORE (model); - - for (ok = gtk_tree_model_get_iter_first (model, &iter); - ok; - ok = gtk_tree_model_iter_next (model, &iter)) { - McAccount *this_account; - gboolean equal; - - gtk_tree_model_get (model, &iter, - COL_ACCOUNT_POINTER, &this_account, - -1); - - equal = empathy_account_equal (this_account, account); - g_object_unref (this_account); + TpConnectionStatus status; + const gchar *name; + gboolean enabled; - if (equal) { - return; - } + if (accounts_dialog_get_account_iter (dialog, account, &iter)) { + return; } status = mission_control_get_connection_status (dialog->mc, account, NULL); name = mc_account_get_display_name (account); + enabled = mc_account_is_enabled (account); g_return_if_fail (name != NULL); empathy_debug (DEBUG_DOMAIN, "Adding new account: %s", name); - gtk_list_store_insert_with_values (store, &iter, + model = gtk_tree_view_get_model (GTK_TREE_VIEW (dialog->treeview)); + gtk_list_store_insert_with_values (GTK_LIST_STORE (model), &iter, -1, + COL_ENABLED, enabled, COL_NAME, name, COL_STATUS, status, COL_ACCOUNT_POINTER, account, @@ -713,51 +715,30 @@ accounts_dialog_status_changed_cb (MissionControl *mc, const gchar *unique_name, EmpathyAccountsDialog *dialog) { - GtkTreeView *view; - GtkTreeSelection *selection; - GtkTreeModel *model; - GtkTreeIter iter; - gboolean ok; - McAccount *account; - GList *accounts, *l; - gboolean found = FALSE; + GtkTreeModel *model; + GtkTreeIter iter; + McAccount *account; + GList *accounts, *l; + gboolean found = FALSE; /* Update the status in the model */ - view = GTK_TREE_VIEW (dialog->treeview); - selection = gtk_tree_view_get_selection (view); - model = gtk_tree_view_get_model (view); + model = gtk_tree_view_get_model (GTK_TREE_VIEW (dialog->treeview)); account = mc_account_lookup (unique_name); empathy_debug (DEBUG_DOMAIN, "Status changed for account %s: " "status=%d presence=%d", unique_name, status, presence); - for (ok = gtk_tree_model_get_iter_first (model, &iter); - ok; - ok = gtk_tree_model_iter_next (model, &iter)) { - McAccount *this_account; - gboolean equal; + if (accounts_dialog_get_account_iter (dialog, account, &iter)) { + GtkTreePath *path; - gtk_tree_model_get (model, &iter, - COL_ACCOUNT_POINTER, &this_account, + gtk_list_store_set (GTK_LIST_STORE (model), &iter, + COL_STATUS, status, -1); - equal = empathy_account_equal (this_account, account); - g_object_unref (this_account); - - if (equal) { - GtkTreePath *path; - - gtk_list_store_set (GTK_LIST_STORE (model), &iter, - COL_STATUS, status, - -1); - - path = gtk_tree_model_get_path (model, &iter); - gtk_tree_model_row_changed (model, path, &iter); - gtk_tree_path_free (path); - - break; - } + path = gtk_tree_model_get_path (model, &iter); + gtk_tree_model_row_changed (model, path, &iter); + gtk_tree_path_free (path); } g_object_unref (account); @@ -791,6 +772,34 @@ accounts_dialog_status_changed_cb (MissionControl *mc, } static void +accounts_dialog_account_enabled_cb (McAccountMonitor *monitor, + gchar *unique_name, + EmpathyAccountsDialog *dialog) +{ + GtkTreeModel *model; + GtkTreeIter iter; + McAccount *account; + gboolean enabled; + + /* Update the status in the model */ + model = gtk_tree_view_get_model (GTK_TREE_VIEW (dialog->treeview)); + account = mc_account_lookup (unique_name); + enabled = mc_account_is_enabled (account); + + empathy_debug (DEBUG_DOMAIN, "Account %s is now %s", + mc_account_get_display_name (account), + enabled ? "enabled" : "disabled"); + + if (accounts_dialog_get_account_iter (dialog, account, &iter)) { + gtk_list_store_set (GTK_LIST_STORE (model), &iter, + COL_ENABLED, enabled, + -1); + } + + g_object_unref (account); +} + +static void accounts_dialog_button_create_clicked_cb (GtkWidget *button, EmpathyAccountsDialog *dialog) { @@ -835,21 +844,6 @@ accounts_dialog_button_back_clicked_cb (GtkWidget *button, } static void -accounts_dialog_button_connect_clicked_cb (GtkWidget *button, - EmpathyAccountsDialog *dialog) -{ - McAccount *account; - gboolean enable; - - account = accounts_dialog_model_get_selected (dialog); - enable = (!mc_account_is_enabled (account)); - mc_account_set_enabled (account, enable); - accounts_dialog_update_connect_button (dialog); - - g_object_unref (account); -} - -static void accounts_dialog_button_add_clicked_cb (GtkWidget *button, EmpathyAccountsDialog *dialog) { @@ -926,17 +920,6 @@ accounts_dialog_button_remove_clicked_cb (GtkWidget *button, } static void -accounts_dialog_treeview_row_activated_cb (GtkTreeView *tree_view, - GtkTreePath *path, - GtkTreeViewColumn *column, - EmpathyAccountsDialog *dialog) -{ - - accounts_dialog_button_connect_clicked_cb (dialog->button_connect, - dialog); -} - -static void accounts_dialog_response_cb (GtkWidget *widget, gint response, EmpathyAccountsDialog *dialog) @@ -958,7 +941,7 @@ accounts_dialog_destroy_cb (GtkWidget *widget, accounts_dialog_account_removed_cb, dialog); g_signal_handlers_disconnect_by_func (dialog->monitor, - accounts_dialog_update_connect_button, + accounts_dialog_account_enabled_cb, dialog); dbus_g_proxy_disconnect_signal (DBUS_G_PROXY (dialog->mc), "AccountStatusChanged", @@ -1025,7 +1008,6 @@ empathy_accounts_dialog_show (GtkWindow *parent) "label_name", &dialog->label_name, "button_add", &dialog->button_add, "button_remove", &dialog->button_remove, - "button_connect", &dialog->button_connect, "button_close", &button_close, NULL); @@ -1035,8 +1017,6 @@ empathy_accounts_dialog_show (GtkWindow *parent) "accounts_dialog", "response", accounts_dialog_response_cb, "button_create", "clicked", accounts_dialog_button_create_clicked_cb, "button_back", "clicked", accounts_dialog_button_back_clicked_cb, - "treeview", "row-activated", accounts_dialog_treeview_row_activated_cb, - "button_connect", "clicked", accounts_dialog_button_connect_clicked_cb, "button_add", "clicked", accounts_dialog_button_add_clicked_cb, "button_remove", "clicked", accounts_dialog_button_remove_clicked_cb, NULL); @@ -1065,12 +1045,12 @@ empathy_accounts_dialog_show (GtkWindow *parent) g_signal_connect (dialog->monitor, "account-deleted", G_CALLBACK (accounts_dialog_account_removed_cb), dialog); - g_signal_connect_swapped (dialog->monitor, "account-enabled", - G_CALLBACK (accounts_dialog_update_connect_button), - dialog); - g_signal_connect_swapped (dialog->monitor, "account-disabled", - G_CALLBACK (accounts_dialog_update_connect_button), - dialog); + g_signal_connect (dialog->monitor, "account-enabled", + G_CALLBACK (accounts_dialog_account_enabled_cb), + dialog); + g_signal_connect (dialog->monitor, "account-disabled", + G_CALLBACK (accounts_dialog_account_enabled_cb), + dialog); dbus_g_proxy_connect_signal (DBUS_G_PROXY (dialog->mc), "AccountStatusChanged", G_CALLBACK (accounts_dialog_status_changed_cb), dialog, NULL); diff --git a/libempathy-gtk/empathy-accounts-dialog.glade b/libempathy-gtk/empathy-accounts-dialog.glade index e2a8493e5..d9c045af1 100644 --- a/libempathy-gtk/empathy-accounts-dialog.glade +++ b/libempathy-gtk/empathy-accounts-dialog.glade @@ -97,126 +97,35 @@ </child> <child> - <widget class="GtkVBox" id="vbox196"> + <widget class="GtkHBox" id="hbox148"> <property name="visible">True</property> - <property name="homogeneous">False</property> + <property name="homogeneous">True</property> <property name="spacing">6</property> <child> - <widget class="GtkButton" id="button_connect"> + <widget class="GtkButton" id="button_add"> <property name="visible">True</property> <property name="can_focus">True</property> + <property name="label">gtk-add</property> + <property name="use_stock">True</property> <property name="relief">GTK_RELIEF_NORMAL</property> <property name="focus_on_click">True</property> - - <child> - <widget class="GtkAlignment" id="alignment30"> - <property name="visible">True</property> - <property name="xalign">0.5</property> - <property name="yalign">0.5</property> - <property name="xscale">0</property> - <property name="yscale">0</property> - <property name="top_padding">0</property> - <property name="bottom_padding">0</property> - <property name="left_padding">0</property> - <property name="right_padding">0</property> - - <child> - <widget class="GtkHBox" id="hbox182"> - <property name="visible">True</property> - <property name="homogeneous">False</property> - <property name="spacing">2</property> - - <child> - <widget class="GtkImage" id="image2"> - <property name="visible">True</property> - <property name="stock">gtk-connect</property> - <property name="icon_size">4</property> - <property name="xalign">0.5</property> - <property name="yalign">0.5</property> - <property name="xpad">0</property> - <property name="ypad">0</property> - </widget> - <packing> - <property name="padding">0</property> - <property name="expand">False</property> - <property name="fill">False</property> - </packing> - </child> - - <child> - <widget class="GtkLabel" id="label644"> - <property name="visible">True</property> - <property name="label">Enable</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.5</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">False</property> - </packing> - </child> - </widget> - </child> - </widget> - </child> </widget> <packing> <property name="padding">0</property> - <property name="expand">False</property> - <property name="fill">False</property> + <property name="expand">True</property> + <property name="fill">True</property> </packing> </child> <child> - <widget class="GtkHBox" id="hbox148"> + <widget class="GtkButton" id="button_remove"> <property name="visible">True</property> - <property name="homogeneous">True</property> - <property name="spacing">6</property> - - <child> - <widget class="GtkButton" id="button_add"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="label">gtk-add</property> - <property name="use_stock">True</property> - <property name="relief">GTK_RELIEF_NORMAL</property> - <property name="focus_on_click">True</property> - </widget> - <packing> - <property name="padding">0</property> - <property name="expand">True</property> - <property name="fill">True</property> - </packing> - </child> - - <child> - <widget class="GtkButton" id="button_remove"> - <property name="visible">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> - <packing> - <property name="padding">0</property> - <property name="expand">True</property> - <property name="fill">True</property> - </packing> - </child> + <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> <packing> <property name="padding">0</property> diff --git a/libempathy-gtk/empathy-avatar-chooser.c b/libempathy-gtk/empathy-avatar-chooser.c index f9da0dd25..ba557787c 100644 --- a/libempathy-gtk/empathy-avatar-chooser.c +++ b/libempathy-gtk/empathy-avatar-chooser.c @@ -30,15 +30,16 @@ #include <libgnomevfs/gnome-vfs-ops.h> #include <libempathy/empathy-debug.h> -#include <libempathy/empathy-conf.h> + #include "empathy-avatar-chooser.h" +#include "empathy-conf.h" #include "empathy-preferences.h" #include "empathy-ui-utils.h" #define DEBUG_DOMAIN "AvatarChooser" -#define GET_PRIV(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), EMPATHY_AVATAR_CHOOSER_TYPE, EmpathyAvatarChooserPriv)) +#define GET_PRIV(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), EMPATHY_TYPE_AVATAR_CHOOSER, EmpathyAvatarChooserPriv)) #define AVATAR_SIZE_SAVE 96 #define AVATAR_SIZE_VIEW 64 @@ -529,7 +530,7 @@ avatar_chooser_clicked_cb (GtkWidget *button, GtkWidget * empathy_avatar_chooser_new (void) { - return g_object_new (EMPATHY_AVATAR_CHOOSER_TYPE, NULL); + return g_object_new (EMPATHY_TYPE_AVATAR_CHOOSER, NULL); } void diff --git a/libempathy-gtk/empathy-avatar-chooser.h b/libempathy-gtk/empathy-avatar-chooser.h index 55b804f07..83dea2afb 100644 --- a/libempathy-gtk/empathy-avatar-chooser.h +++ b/libempathy-gtk/empathy-avatar-chooser.h @@ -30,11 +30,11 @@ G_BEGIN_DECLS -#define EMPATHY_AVATAR_CHOOSER_TYPE (empathy_avatar_chooser_get_type ()) -#define EMPATHY_AVATAR_CHOOSER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), EMPATHY_AVATAR_CHOOSER_TYPE, EmpathyAvatarChooser)) -#define EMPATHY_AVATAR_CHOOSER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), EMPATHY_AVATAR_CHOOSER_TYPE, EmpathyAvatarChooserClass)) -#define EMPATHY_IS_AVATAR_CHOOSER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), EMPATHY_AVATAR_CHOOSER_TYPE)) -#define EMPATHY_IS_AVATAR_CHOOSER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((obj), EMPATHY_AVATAR_CHOOSER_TYPE)) +#define EMPATHY_TYPE_AVATAR_CHOOSER (empathy_avatar_chooser_get_type ()) +#define EMPATHY_AVATAR_CHOOSER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), EMPATHY_TYPE_AVATAR_CHOOSER, EmpathyAvatarChooser)) +#define EMPATHY_AVATAR_CHOOSER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), EMPATHY_TYPE_AVATAR_CHOOSER, EmpathyAvatarChooserClass)) +#define EMPATHY_IS_AVATAR_CHOOSER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), EMPATHY_TYPE_AVATAR_CHOOSER)) +#define EMPATHY_IS_AVATAR_CHOOSER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((obj), EMPATHY_TYPE_AVATAR_CHOOSER)) typedef struct _EmpathyAvatarChooser EmpathyAvatarChooser; typedef struct _EmpathyAvatarChooserClass EmpathyAvatarChooserClass; diff --git a/libempathy-gtk/empathy-chat-view.c b/libempathy-gtk/empathy-chat-view.c index c7428e9df..f4ad7f316 100644 --- a/libempathy-gtk/empathy-chat-view.c +++ b/libempathy-gtk/empathy-chat-view.c @@ -44,10 +44,10 @@ #include <libempathy/empathy-utils.h> #include <libempathy/empathy-debug.h> -#include <libempathy/empathy-conf.h> #include "empathy-chat-view.h" #include "empathy-chat.h" +#include "empathy-conf.h" #include "empathy-preferences.h" #include "empathy-theme-manager.h" #include "empathy-ui-utils.h" @@ -70,7 +70,7 @@ struct _EmpathyChatViewPriv { EmpathyTheme *theme; time_t last_timestamp; - BlockType last_block_type; + EmpathyChatViewBlock last_block_type; gboolean allow_scrolling; guint scroll_timeout; @@ -158,7 +158,7 @@ empathy_chat_view_init (EmpathyChatView *view) priv->buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (view)); - priv->last_block_type = BLOCK_TYPE_NONE; + priv->last_block_type = EMPATHY_CHAT_VIEW_BLOCK_NONE; priv->last_timestamp = 0; priv->allow_scrolling = TRUE; @@ -638,7 +638,7 @@ chat_view_theme_changed_cb (EmpathyThemeManager *manager, priv = GET_PRIV (view); - priv->last_block_type = BLOCK_TYPE_NONE; + priv->last_block_type = EMPATHY_CHAT_VIEW_BLOCK_NONE; empathy_conf_get_bool (empathy_conf_get (), EMPATHY_PREFS_CHAT_THEME_CHAT_ROOM, @@ -821,7 +821,7 @@ empathy_chat_view_append_event (EmpathyChatView *view, empathy_chat_view_scroll_down (view); } - priv->last_block_type = BLOCK_TYPE_EVENT; + priv->last_block_type = EMPATHY_CHAT_VIEW_BLOCK_EVENT; } void @@ -891,7 +891,7 @@ empathy_chat_view_append_button (EmpathyChatView *view, empathy_chat_view_scroll_down (view); } - priv->last_block_type = BLOCK_TYPE_INVITE; + priv->last_block_type = EMPATHY_CHAT_VIEW_BLOCK_INVITE; } void @@ -996,7 +996,7 @@ empathy_chat_view_clear (EmpathyChatView *view) */ priv = GET_PRIV (view); - priv->last_block_type = BLOCK_TYPE_NONE; + priv->last_block_type = EMPATHY_CHAT_VIEW_BLOCK_NONE; priv->last_timestamp = 0; } @@ -1512,7 +1512,7 @@ empathy_chat_view_set_last_timestamp (EmpathyChatView *view, priv->last_timestamp = timestamp; } -BlockType +EmpathyChatViewBlock empathy_chat_view_get_last_block_type (EmpathyChatView *view) { EmpathyChatViewPriv *priv; @@ -1525,8 +1525,8 @@ empathy_chat_view_get_last_block_type (EmpathyChatView *view) } void -empathy_chat_view_set_last_block_type (EmpathyChatView *view, - BlockType block_type) +empathy_chat_view_set_last_block_type (EmpathyChatView *view, + EmpathyChatViewBlock block_type) { EmpathyChatViewPriv *priv; diff --git a/libempathy-gtk/empathy-chat-view.h b/libempathy-gtk/empathy-chat-view.h index 37a7f9977..58219ca04 100644 --- a/libempathy-gtk/empathy-chat-view.h +++ b/libempathy-gtk/empathy-chat-view.h @@ -54,13 +54,13 @@ struct _EmpathyChatViewClass { }; typedef enum { - BLOCK_TYPE_NONE, - BLOCK_TYPE_SELF, - BLOCK_TYPE_OTHER, - BLOCK_TYPE_EVENT, - BLOCK_TYPE_TIME, - BLOCK_TYPE_INVITE -} BlockType; + EMPATHY_CHAT_VIEW_BLOCK_NONE, + EMPATHY_CHAT_VIEW_BLOCK_SELF, + EMPATHY_CHAT_VIEW_BLOCK_OTHER, + EMPATHY_CHAT_VIEW_BLOCK_EVENT, + EMPATHY_CHAT_VIEW_BLOCK_TIME, + EMPATHY_CHAT_VIEW_BLOCK_INVITE +} EmpathyChatViewBlock; GType empathy_chat_view_get_type (void) G_GNUC_CONST; EmpathyChatView *empathy_chat_view_new (void); @@ -106,9 +106,9 @@ void empathy_chat_view_set_is_group_chat (EmpathyChatView *view, time_t empathy_chat_view_get_last_timestamp (EmpathyChatView *view); void empathy_chat_view_set_last_timestamp (EmpathyChatView *view, time_t timestamp); -BlockType empathy_chat_view_get_last_block_type (EmpathyChatView *view); +EmpathyChatViewBlock empathy_chat_view_get_last_block_type (EmpathyChatView *view); void empathy_chat_view_set_last_block_type (EmpathyChatView *view, - BlockType block_type); + EmpathyChatViewBlock block_type); EmpathyContact * empathy_chat_view_get_last_contact (EmpathyChatView *view); void empathy_chat_view_set_last_contact (EmpathyChatView *view, EmpathyContact *contact); diff --git a/libempathy-gtk/empathy-chat-window.c b/libempathy-gtk/empathy-chat-window.c index b6409f6a8..444616039 100644 --- a/libempathy-gtk/empathy-chat-window.c +++ b/libempathy-gtk/empathy-chat-window.c @@ -43,7 +43,6 @@ #include <libempathy/empathy-contact.h> #include <libempathy/empathy-debug.h> #include <libempathy/empathy-message.h> -#include <libempathy/empathy-conf.h> #include <libempathy/empathy-utils.h> #include "empathy-chat-window.h" @@ -52,6 +51,7 @@ #include "empathy-contact-dialogs.h" #include "empathy-log-window.h" #include "empathy-new-chatroom-dialog.h" +#include "empathy-conf.h" #include "empathy-preferences.h" #include "empathy-private-chat.h" #include "empathy-group-chat.h" @@ -781,21 +781,21 @@ chat_window_update_menu (EmpathyChatWindow *window) chat_window_show_contacts_toggled_cb, window); } else { - EmpathyPrivateChat *chat; - EmpathyContact *contact; - EmpathyPresence *presence; + EmpathyPrivateChat *chat; + EmpathyContact *contact; + McPresence presence; chat = EMPATHY_PRIVATE_CHAT (priv->current_chat); /* Show / Hide widgets */ gtk_widget_hide (priv->menu_room); - /* presence==NULL means this contact refuses to send us his + /* Unset presence means this contact refuses to send us his * presence. By adding the contact we ask the contact to accept * to send his presence. */ contact = empathy_private_chat_get_contact (chat); presence = empathy_contact_get_presence (contact); - if (!presence) { + if (presence == MC_PRESENCE_UNSET) { gtk_widget_show (priv->menu_conv_add_contact); } else { gtk_widget_hide (priv->menu_conv_add_contact); diff --git a/libempathy-gtk/empathy-chat.c b/libempathy-gtk/empathy-chat.c index d07b84b07..fbdf6df44 100644 --- a/libempathy-gtk/empathy-chat.c +++ b/libempathy-gtk/empathy-chat.c @@ -40,12 +40,12 @@ #include <libempathy/empathy-log-manager.h> #include <libempathy/empathy-debug.h> #include <libempathy/empathy-utils.h> -#include <libempathy/empathy-conf.h> #include <libempathy/empathy-marshal.h> #include "empathy-chat.h" #include "empathy-chat-window.h" #include "empathy-geometry.h" +#include "empathy-conf.h" #include "empathy-preferences.h" #include "empathy-spell.h" #include "empathy-spell-dialog.h" diff --git a/libempathy-gtk/empathy-conf.c b/libempathy-gtk/empathy-conf.c new file mode 100644 index 000000000..1ec3feeb4 --- /dev/null +++ b/libempathy-gtk/empathy-conf.c @@ -0,0 +1,373 @@ +/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ +/* + * Copyright (C) 2006 Imendio AB + * + * 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: Richard Hult <richard@imendio.com> + */ + +#include "config.h" + +#include <string.h> + +#include <gconf/gconf-client.h> + +#include <libempathy/empathy-debug.h> + +#include "empathy-conf.h" + +#define DEBUG_DOMAIN "Config" + +#define EMPATHY_CONF_ROOT "/apps/empathy" +#define DESKTOP_INTERFACE_ROOT "/desktop/gnome/interface" + +#define GET_PRIV(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), EMPATHY_TYPE_CONF, EmpathyConfPriv)) + +typedef struct { + GConfClient *gconf_client; +} EmpathyConfPriv; + +typedef struct { + EmpathyConf *conf; + EmpathyConfNotifyFunc func; + gpointer user_data; +} EmpathyConfNotifyData; + +static void conf_finalize (GObject *object); + +G_DEFINE_TYPE (EmpathyConf, empathy_conf, G_TYPE_OBJECT); + +static EmpathyConf *global_conf = NULL; + +static void +empathy_conf_class_init (EmpathyConfClass *class) +{ + GObjectClass *object_class; + + object_class = G_OBJECT_CLASS (class); + + object_class->finalize = conf_finalize; + + g_type_class_add_private (object_class, sizeof (EmpathyConfPriv)); +} + +static void +empathy_conf_init (EmpathyConf *conf) +{ + EmpathyConfPriv *priv; + + priv = GET_PRIV (conf); + + priv->gconf_client = gconf_client_get_default (); + + gconf_client_add_dir (priv->gconf_client, + EMPATHY_CONF_ROOT, + GCONF_CLIENT_PRELOAD_ONELEVEL, + NULL); + gconf_client_add_dir (priv->gconf_client, + DESKTOP_INTERFACE_ROOT, + GCONF_CLIENT_PRELOAD_NONE, + NULL); +} + +static void +conf_finalize (GObject *object) +{ + EmpathyConfPriv *priv; + + priv = GET_PRIV (object); + + gconf_client_remove_dir (priv->gconf_client, + EMPATHY_CONF_ROOT, + NULL); + gconf_client_remove_dir (priv->gconf_client, + DESKTOP_INTERFACE_ROOT, + NULL); + + g_object_unref (priv->gconf_client); + + G_OBJECT_CLASS (empathy_conf_parent_class)->finalize (object); +} + +EmpathyConf * +empathy_conf_get (void) +{ + if (!global_conf) { + global_conf = g_object_new (EMPATHY_TYPE_CONF, NULL); + } + + return global_conf; +} + +void +empathy_conf_shutdown (void) +{ + if (global_conf) { + g_object_unref (global_conf); + global_conf = NULL; + } +} + +gboolean +empathy_conf_set_int (EmpathyConf *conf, + const gchar *key, + gint value) +{ + EmpathyConfPriv *priv; + + g_return_val_if_fail (EMPATHY_IS_CONF (conf), FALSE); + + empathy_debug (DEBUG_DOMAIN, "Setting int:'%s' to %d", key, value); + + priv = GET_PRIV (conf); + + return gconf_client_set_int (priv->gconf_client, + key, + value, + NULL); +} + +gboolean +empathy_conf_get_int (EmpathyConf *conf, + const gchar *key, + gint *value) +{ + EmpathyConfPriv *priv; + GError *error = NULL; + + *value = 0; + + g_return_val_if_fail (EMPATHY_IS_CONF (conf), FALSE); + g_return_val_if_fail (value != NULL, FALSE); + + priv = GET_PRIV (conf); + + *value = gconf_client_get_int (priv->gconf_client, + key, + &error); + + if (error) { + g_error_free (error); + return FALSE; + } + + return TRUE; +} + +gboolean +empathy_conf_set_bool (EmpathyConf *conf, + const gchar *key, + gboolean value) +{ + EmpathyConfPriv *priv; + + g_return_val_if_fail (EMPATHY_IS_CONF (conf), FALSE); + + empathy_debug (DEBUG_DOMAIN, "Setting bool:'%s' to %d ---> %s", + key, value, value ? "true" : "false"); + + priv = GET_PRIV (conf); + + return gconf_client_set_bool (priv->gconf_client, + key, + value, + NULL); +} + +gboolean +empathy_conf_get_bool (EmpathyConf *conf, + const gchar *key, + gboolean *value) +{ + EmpathyConfPriv *priv; + GError *error = NULL; + + *value = FALSE; + + g_return_val_if_fail (EMPATHY_IS_CONF (conf), FALSE); + g_return_val_if_fail (value != NULL, FALSE); + + priv = GET_PRIV (conf); + + *value = gconf_client_get_bool (priv->gconf_client, + key, + &error); + + if (error) { + g_error_free (error); + return FALSE; + } + + return TRUE; +} + +gboolean +empathy_conf_set_string (EmpathyConf *conf, + const gchar *key, + const gchar *value) +{ + EmpathyConfPriv *priv; + + g_return_val_if_fail (EMPATHY_IS_CONF (conf), FALSE); + + empathy_debug (DEBUG_DOMAIN, "Setting string:'%s' to '%s'", + key, value); + + priv = GET_PRIV (conf); + + return gconf_client_set_string (priv->gconf_client, + key, + value, + NULL); +} + +gboolean +empathy_conf_get_string (EmpathyConf *conf, + const gchar *key, + gchar **value) +{ + EmpathyConfPriv *priv; + GError *error = NULL; + + *value = NULL; + + g_return_val_if_fail (EMPATHY_IS_CONF (conf), FALSE); + + priv = GET_PRIV (conf); + + *value = gconf_client_get_string (priv->gconf_client, + key, + &error); + + if (error) { + g_error_free (error); + return FALSE; + } + + return TRUE; +} + +gboolean +empathy_conf_set_string_list (EmpathyConf *conf, + const gchar *key, + GSList *value) +{ + EmpathyConfPriv *priv; + + g_return_val_if_fail (EMPATHY_IS_CONF (conf), FALSE); + + priv = GET_PRIV (conf); + + return gconf_client_set_list (priv->gconf_client, + key, + GCONF_VALUE_STRING, + value, + NULL); +} + +gboolean +empathy_conf_get_string_list (EmpathyConf *conf, + const gchar *key, + GSList **value) +{ + EmpathyConfPriv *priv; + GError *error = NULL; + + *value = NULL; + + g_return_val_if_fail (EMPATHY_IS_CONF (conf), FALSE); + + priv = GET_PRIV (conf); + + *value = gconf_client_get_list (priv->gconf_client, + key, + GCONF_VALUE_STRING, + &error); + if (error) { + g_error_free (error); + return FALSE; + } + + return TRUE; +} + +static void +conf_notify_data_free (EmpathyConfNotifyData *data) +{ + g_object_unref (data->conf); + g_slice_free (EmpathyConfNotifyData, data); +} + +static void +conf_notify_func (GConfClient *client, + guint id, + GConfEntry *entry, + gpointer user_data) +{ + EmpathyConfNotifyData *data; + + data = user_data; + + data->func (data->conf, + gconf_entry_get_key (entry), + data->user_data); +} + +guint +empathy_conf_notify_add (EmpathyConf *conf, + const gchar *key, + EmpathyConfNotifyFunc func, + gpointer user_data) +{ + EmpathyConfPriv *priv; + guint id; + EmpathyConfNotifyData *data; + + g_return_val_if_fail (EMPATHY_IS_CONF (conf), 0); + + priv = GET_PRIV (conf); + + data = g_slice_new (EmpathyConfNotifyData); + data->func = func; + data->user_data = user_data; + data->conf = g_object_ref (conf); + + id = gconf_client_notify_add (priv->gconf_client, + key, + conf_notify_func, + data, + (GFreeFunc) conf_notify_data_free, + NULL); + + return id; +} + +gboolean +empathy_conf_notify_remove (EmpathyConf *conf, + guint id) +{ + EmpathyConfPriv *priv; + + g_return_val_if_fail (EMPATHY_IS_CONF (conf), FALSE); + + priv = GET_PRIV (conf); + + gconf_client_notify_remove (priv->gconf_client, id); + + return TRUE; +} + diff --git a/libempathy-gtk/empathy-conf.h b/libempathy-gtk/empathy-conf.h new file mode 100644 index 000000000..7e8e60e25 --- /dev/null +++ b/libempathy-gtk/empathy-conf.h @@ -0,0 +1,87 @@ +/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ +/* + * Copyright (C) 2006 Imendio AB + * + * 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. + */ + +#ifndef __EMPATHY_CONF_H__ +#define __EMPATHY_CONF_H__ + +#include <glib-object.h> + +G_BEGIN_DECLS + +#define EMPATHY_TYPE_CONF (empathy_conf_get_type ()) +#define EMPATHY_CONF(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), EMPATHY_TYPE_CONF, EmpathyConf)) +#define EMPATHY_CONF_CLASS(k) (G_TYPE_CHECK_CLASS_CAST ((k), EMPATHY_TYPE_CONF, EmpathyConfClass)) +#define EMPATHY_IS_CONF(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), EMPATHY_TYPE_CONF)) +#define EMPATHY_IS_CONF_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), EMPATHY_TYPE_CONF)) +#define EMPATHY_CONF_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), EMPATHY_TYPE_CONF, EmpathyConfClass)) + +typedef struct _EmpathyConf EmpathyConf; +typedef struct _EmpathyConfClass EmpathyConfClass; + +struct _EmpathyConf { + GObject parent; +}; + +struct _EmpathyConfClass { + GObjectClass parent_class; +}; + +typedef void (*EmpathyConfNotifyFunc) (EmpathyConf *conf, + const gchar *key, + gpointer user_data); + +GType empathy_conf_get_type (void) G_GNUC_CONST; +EmpathyConf *empathy_conf_get (void); +void empathy_conf_shutdown (void); +guint empathy_conf_notify_add (EmpathyConf *conf, + const gchar *key, + EmpathyConfNotifyFunc func, + gpointer data); +gboolean empathy_conf_notify_remove (EmpathyConf *conf, + guint id); +gboolean empathy_conf_set_int (EmpathyConf *conf, + const gchar *key, + gint value); +gboolean empathy_conf_get_int (EmpathyConf *conf, + const gchar *key, + gint *value); +gboolean empathy_conf_set_bool (EmpathyConf *conf, + const gchar *key, + gboolean value); +gboolean empathy_conf_get_bool (EmpathyConf *conf, + const gchar *key, + gboolean *value); +gboolean empathy_conf_set_string (EmpathyConf *conf, + const gchar *key, + const gchar *value); +gboolean empathy_conf_get_string (EmpathyConf *conf, + const gchar *key, + gchar **value); +gboolean empathy_conf_set_string_list (EmpathyConf *conf, + const gchar *key, + GSList *value); +gboolean empathy_conf_get_string_list (EmpathyConf *conf, + const gchar *key, + GSList **value); + +G_END_DECLS + +#endif /* __EMPATHY_CONF_H__ */ + diff --git a/libempathy-gtk/empathy-contact-groups.c b/libempathy-gtk/empathy-contact-groups.c deleted file mode 100644 index 1e5fabe29..000000000 --- a/libempathy-gtk/empathy-contact-groups.c +++ /dev/null @@ -1,286 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * Copyright (C) 2005-2007 Imendio AB - * - * 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: Martyn Russell <martyn@imendio.com> - */ - -#include "config.h" - -#include <string.h> -#include <sys/types.h> -#include <sys/stat.h> - -#include <glib.h> -#include <glib/gi18n.h> - -#include <libxml/parser.h> -#include <libxml/tree.h> - -#include <libempathy/empathy-debug.h> -#include <libempathy/empathy-utils.h> - -#include "empathy-contact-groups.h" - -#define DEBUG_DOMAIN "ContactGroups" - -#define CONTACT_GROUPS_XML_FILENAME "contact-groups.xml" -#define CONTACT_GROUPS_DTD_FILENAME "empathy-contact-groups.dtd" - -typedef struct { - gchar *name; - gboolean expanded; -} ContactGroup; - -static void contact_groups_file_parse (const gchar *filename); -static gboolean contact_groups_file_save (void); -static ContactGroup *contact_group_new (const gchar *name, - gboolean expanded); -static void contact_group_free (ContactGroup *group); - -static GList *groups = NULL; - -void -empathy_contact_groups_get_all (void) -{ - gchar *dir; - gchar *file_with_path; - - /* If already set up clean up first */ - if (groups) { - g_list_foreach (groups, (GFunc)contact_group_free, NULL); - g_list_free (groups); - groups = NULL; - } - - dir = g_build_filename (g_get_home_dir (), ".gnome2", PACKAGE_NAME, NULL); - file_with_path = g_build_filename (dir, CONTACT_GROUPS_XML_FILENAME, NULL); - g_free (dir); - - if (g_file_test (file_with_path, G_FILE_TEST_EXISTS)) { - contact_groups_file_parse (file_with_path); - } - - g_free (file_with_path); -} - -static void -contact_groups_file_parse (const gchar *filename) -{ - xmlParserCtxtPtr ctxt; - xmlDocPtr doc; - xmlNodePtr contacts; - xmlNodePtr account; - xmlNodePtr node; - - empathy_debug (DEBUG_DOMAIN, "Attempting to parse file:'%s'...", filename); - - ctxt = xmlNewParserCtxt (); - - /* Parse and validate the file. */ - doc = xmlCtxtReadFile (ctxt, filename, NULL, 0); - if (!doc) { - g_warning ("Failed to parse file:'%s'", filename); - xmlFreeParserCtxt (ctxt); - return; - } - - if (!empathy_xml_validate (doc, CONTACT_GROUPS_DTD_FILENAME)) { - g_warning ("Failed to validate file:'%s'", filename); - xmlFreeDoc(doc); - xmlFreeParserCtxt (ctxt); - return; - } - - /* The root node, contacts. */ - contacts = xmlDocGetRootElement (doc); - - account = NULL; - node = contacts->children; - while (node) { - if (strcmp ((gchar *) node->name, "account") == 0) { - account = node; - break; - } - node = node->next; - } - - node = NULL; - if (account) { - node = account->children; - } - - while (node) { - if (strcmp ((gchar *) node->name, "group") == 0) { - gchar *name; - gchar *expanded_str; - gboolean expanded; - ContactGroup *contact_group; - - name = (gchar *) xmlGetProp (node, "name"); - expanded_str = (gchar *) xmlGetProp (node, "expanded"); - - if (expanded_str && strcmp (expanded_str, "yes") == 0) { - expanded = TRUE; - } else { - expanded = FALSE; - } - - contact_group = contact_group_new (name, expanded); - groups = g_list_append (groups, contact_group); - - xmlFree (name); - xmlFree (expanded_str); - } - - node = node->next; - } - - empathy_debug (DEBUG_DOMAIN, "Parsed %d contact groups", g_list_length (groups)); - - xmlFreeDoc(doc); - xmlFreeParserCtxt (ctxt); -} - -static ContactGroup * -contact_group_new (const gchar *name, - gboolean expanded) -{ - ContactGroup *group; - - group = g_new0 (ContactGroup, 1); - - group->name = g_strdup (name); - group->expanded = expanded; - - return group; -} - -static void -contact_group_free (ContactGroup *group) -{ - g_return_if_fail (group != NULL); - - g_free (group->name); - - g_free (group); -} - -static gboolean -contact_groups_file_save (void) -{ - xmlDocPtr doc; - xmlNodePtr root; - xmlNodePtr node; - GList *l; - gchar *dir; - gchar *file; - - dir = g_build_filename (g_get_home_dir (), ".gnome2", PACKAGE_NAME, NULL); - g_mkdir_with_parents (dir, S_IRUSR | S_IWUSR | S_IXUSR); - file = g_build_filename (dir, CONTACT_GROUPS_XML_FILENAME, NULL); - g_free (dir); - - doc = xmlNewDoc ("1.0"); - root = xmlNewNode (NULL, "contacts"); - xmlDocSetRootElement (doc, root); - - node = xmlNewChild (root, NULL, "account", NULL); - xmlNewProp (node, "name", "Default"); - - for (l = groups; l; l = l->next) { - ContactGroup *cg; - xmlNodePtr subnode; - - cg = l->data; - - subnode = xmlNewChild (node, NULL, "group", NULL); - xmlNewProp (subnode, "expanded", cg->expanded ? "yes" : "no"); - xmlNewProp (subnode, "name", cg->name); - } - - /* Make sure the XML is indented properly */ - xmlIndentTreeOutput = 1; - - empathy_debug (DEBUG_DOMAIN, "Saving file:'%s'", file); - xmlSaveFormatFileEnc (file, doc, "utf-8", 1); - xmlFreeDoc (doc); - - xmlCleanupParser (); - xmlMemoryDump (); - - g_free (file); - - return TRUE; -} - -gboolean -empathy_contact_group_get_expanded (const gchar *group) -{ - GList *l; - gboolean default_val = TRUE; - - g_return_val_if_fail (group != NULL, default_val); - - for (l = groups; l; l = l->next) { - ContactGroup *cg = l->data; - - if (!cg || !cg->name) { - continue; - } - - if (strcmp (cg->name, group) == 0) { - return cg->expanded; - } - } - - return default_val; -} - -void -empathy_contact_group_set_expanded (const gchar *group, - gboolean expanded) -{ - GList *l; - ContactGroup *cg; - gboolean changed = FALSE; - - g_return_if_fail (group != NULL); - - for (l = groups; l; l = l->next) { - ContactGroup *cg = l->data; - - if (!cg || !cg->name) { - continue; - } - - if (strcmp (cg->name, group) == 0) { - cg->expanded = expanded; - changed = TRUE; - break; - } - } - - /* if here... we don't have a ContactGroup for the group. */ - if (!changed) { - cg = contact_group_new (group, expanded); - groups = g_list_append (groups, cg); - } - - contact_groups_file_save (); -} diff --git a/libempathy-gtk/empathy-contact-groups.dtd b/libempathy-gtk/empathy-contact-groups.dtd deleted file mode 100644 index b4de2260a..000000000 --- a/libempathy-gtk/empathy-contact-groups.dtd +++ /dev/null @@ -1,17 +0,0 @@ -<!-- - DTD for Empathys contact groups. - by Martyn Russell <mr@gnome.org> ---> - -<!-- Root element. --> -<!ELEMENT contacts (account)> - -<!ELEMENT account (group)+> -<!ATTLIST account - name CDATA #REQUIRED> - -<!-- Groups in the roster. --> -<!ELEMENT group EMPTY> -<!ATTLIST group - name CDATA #REQUIRED - expanded CDATA #REQUIRED> diff --git a/libempathy-gtk/empathy-contact-groups.h b/libempathy-gtk/empathy-contact-groups.h deleted file mode 100644 index e2e9810e3..000000000 --- a/libempathy-gtk/empathy-contact-groups.h +++ /dev/null @@ -1,38 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * Copyright (C) 2005 Imendio AB - * - * 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: Martyn Russell <martyn@imendio.com> - */ - -#ifndef __EMPATHY_CONTACT_GROUPS_H__ -#define __EMPATHY_CONTACT_GROUPS_H__ - -G_BEGIN_DECLS - -#include <glib.h> - -void empathy_contact_groups_get_all (void); - -gboolean empathy_contact_group_get_expanded (const gchar *group); -void empathy_contact_group_set_expanded (const gchar *group, - gboolean expanded); - -G_END_DECLS - -#endif /* __EMPATHY_CONTACT_GROUPS_H__ */ diff --git a/libempathy-gtk/empathy-contact-list-store.c b/libempathy-gtk/empathy-contact-list-store.c index 820db5b10..7cabea78f 100644 --- a/libempathy-gtk/empathy-contact-list-store.c +++ b/libempathy-gtk/empathy-contact-list-store.c @@ -33,7 +33,6 @@ #include <libempathy/empathy-debug.h> #include "empathy-contact-list-store.h" -#include "empathy-contact-groups.h" #include "empathy-ui-utils.h" #include "empathy-gtk-enum-types.h" @@ -55,6 +54,7 @@ typedef struct { EmpathyContactList *list; gboolean show_offline; gboolean show_avatars; + gboolean show_groups; gboolean is_compact; gboolean show_active; EmpathyContactListStoreSort sort_criterium; @@ -156,14 +156,63 @@ static gboolean contact_list_store_update_list_mode_foreach (GtkTreeMod enum { PROP_0, + PROP_CONTACT_LIST, PROP_SHOW_OFFLINE, PROP_SHOW_AVATARS, + PROP_SHOW_GROUPS, PROP_IS_COMPACT, PROP_SORT_CRITERIUM }; G_DEFINE_TYPE (EmpathyContactListStore, empathy_contact_list_store, GTK_TYPE_TREE_STORE); + +static gboolean +contact_list_store_iface_setup (gpointer user_data) +{ + EmpathyContactListStore *store = user_data; + EmpathyContactListStorePriv *priv = GET_PRIV (store); + GList *contacts, *l; + + /* Signal connection. */ + g_signal_connect (priv->list, + "members-changed", + G_CALLBACK (contact_list_store_members_changed_cb), + store); + g_signal_connect (priv->list, + "groups-changed", + G_CALLBACK (contact_list_store_groups_changed_cb), + store); + + /* Add contacts already created. */ + contacts = empathy_contact_list_get_members (priv->list); + for (l = contacts; l; l = l->next) { + contact_list_store_members_changed_cb (priv->list, l->data, + NULL, 0, NULL, + TRUE, + store); + + g_object_unref (l->data); + } + g_list_free (contacts); + + return FALSE; +} + + +static void +contact_list_store_set_contact_list (EmpathyContactListStore *store, + EmpathyContactList *list_iface) +{ + EmpathyContactListStorePriv *priv = GET_PRIV (store); + + priv->list = g_object_ref (list_iface); + + /* Let a chance to have all properties set before populating */ + g_idle_add (contact_list_store_iface_setup, + store); +} + static void empathy_contact_list_store_class_init (EmpathyContactListStoreClass *klass) { @@ -174,6 +223,14 @@ empathy_contact_list_store_class_init (EmpathyContactListStoreClass *klass) object_class->set_property = contact_list_store_set_property; g_object_class_install_property (object_class, + PROP_CONTACT_LIST, + g_param_spec_object ("contact-list", + "The contact list iface", + "The contact list iface", + EMPATHY_TYPE_CONTACT_LIST, + G_PARAM_CONSTRUCT_ONLY | + G_PARAM_READWRITE)); + g_object_class_install_property (object_class, PROP_SHOW_OFFLINE, g_param_spec_boolean ("show-offline", "Show Offline", @@ -189,6 +246,14 @@ empathy_contact_list_store_class_init (EmpathyContactListStoreClass *klass) "avatars for contacts", TRUE, G_PARAM_READWRITE)); + g_object_class_install_property (object_class, + PROP_SHOW_GROUPS, + g_param_spec_boolean ("show-groups", + "Show Groups", + "Whether contact list should display " + "contact groups", + TRUE, + G_PARAM_READWRITE)); g_object_class_install_property (object_class, PROP_IS_COMPACT, g_param_spec_boolean ("is-compact", @@ -217,9 +282,11 @@ empathy_contact_list_store_init (EmpathyContactListStore *store) priv = GET_PRIV (store); priv->show_avatars = TRUE; + priv->show_groups = TRUE; priv->inhibit_active = g_timeout_add_seconds (ACTIVE_USER_WAIT_TO_ENABLE_TIME, (GSourceFunc) contact_list_store_inibit_active_cb, store); + contact_list_store_setup (store); } static void @@ -261,12 +328,18 @@ contact_list_store_get_property (GObject *object, priv = GET_PRIV (object); switch (param_id) { + case PROP_CONTACT_LIST: + g_value_set_object (value, priv->list); + break; case PROP_SHOW_OFFLINE: g_value_set_boolean (value, priv->show_offline); break; case PROP_SHOW_AVATARS: g_value_set_boolean (value, priv->show_avatars); break; + case PROP_SHOW_GROUPS: + g_value_set_boolean (value, priv->show_groups); + break; case PROP_IS_COMPACT: g_value_set_boolean (value, priv->is_compact); break; @@ -290,6 +363,10 @@ contact_list_store_set_property (GObject *object, priv = GET_PRIV (object); switch (param_id) { + case PROP_CONTACT_LIST: + contact_list_store_set_contact_list (EMPATHY_CONTACT_LIST_STORE (object), + g_value_get_object (value)); + break; case PROP_SHOW_OFFLINE: empathy_contact_list_store_set_show_offline (EMPATHY_CONTACT_LIST_STORE (object), g_value_get_boolean (value)); @@ -298,6 +375,10 @@ contact_list_store_set_property (GObject *object, empathy_contact_list_store_set_show_avatars (EMPATHY_CONTACT_LIST_STORE (object), g_value_get_boolean (value)); break; + case PROP_SHOW_GROUPS: + empathy_contact_list_store_set_show_groups (EMPATHY_CONTACT_LIST_STORE (object), + g_value_get_boolean (value)); + break; case PROP_IS_COMPACT: empathy_contact_list_store_set_is_compact (EMPATHY_CONTACT_LIST_STORE (object), g_value_get_boolean (value)); @@ -315,41 +396,11 @@ contact_list_store_set_property (GObject *object, EmpathyContactListStore * empathy_contact_list_store_new (EmpathyContactList *list_iface) { - EmpathyContactListStore *store; - EmpathyContactListStorePriv *priv; - GList *contacts, *l; - g_return_val_if_fail (EMPATHY_IS_CONTACT_LIST (list_iface), NULL); - store = g_object_new (EMPATHY_TYPE_CONTACT_LIST_STORE, NULL); - priv = GET_PRIV (store); - - contact_list_store_setup (store); - priv->list = g_object_ref (list_iface); - - /* Signal connection. */ - g_signal_connect (priv->list, - "members-changed", - G_CALLBACK (contact_list_store_members_changed_cb), - store); - g_signal_connect (priv->list, - "groups-changed", - G_CALLBACK (contact_list_store_groups_changed_cb), - store); - - /* Add contacts already created. */ - contacts = empathy_contact_list_get_members (priv->list); - for (l = contacts; l; l = l->next) { - contact_list_store_members_changed_cb (priv->list, l->data, - NULL, 0, NULL, - TRUE, - store); - - g_object_unref (l->data); - } - g_list_free (contacts); - - return store; + return g_object_new (EMPATHY_TYPE_CONTACT_LIST_STORE, + "contact-list", list_iface, + NULL); } EmpathyContactList * @@ -404,6 +455,8 @@ empathy_contact_list_store_set_show_offline (EmpathyContactListStore *store, /* Restore to original setting. */ priv->show_active = show_active; + + g_object_notify (G_OBJECT (store), "show-offline"); } gboolean @@ -437,6 +490,54 @@ empathy_contact_list_store_set_show_avatars (EmpathyContactListStore *store, (GtkTreeModelForeachFunc) contact_list_store_update_list_mode_foreach, store); + + g_object_notify (G_OBJECT (store), "show-avatars"); +} + +gboolean +empathy_contact_list_store_get_show_groups (EmpathyContactListStore *store) +{ + EmpathyContactListStorePriv *priv; + + g_return_val_if_fail (EMPATHY_IS_CONTACT_LIST_STORE (store), TRUE); + + priv = GET_PRIV (store); + + return priv->show_groups; +} + +void +empathy_contact_list_store_set_show_groups (EmpathyContactListStore *store, + gboolean show_groups) +{ + EmpathyContactListStorePriv *priv; + GList *contacts, *l; + + g_return_if_fail (EMPATHY_IS_CONTACT_LIST_STORE (store)); + + priv = GET_PRIV (store); + + if (priv->show_groups == show_groups) { + return; + } + + priv->show_groups = show_groups; + + /* Remove all contacts and add them back, not optimized but that's the + * easy way :) */ + gtk_tree_store_clear (GTK_TREE_STORE (store)); + contacts = empathy_contact_list_get_members (priv->list); + for (l = contacts; l; l = l->next) { + contact_list_store_members_changed_cb (priv->list, l->data, + NULL, 0, NULL, + TRUE, + store); + + g_object_unref (l->data); + } + g_list_free (contacts); + + g_object_notify (G_OBJECT (store), "show-groups"); } gboolean @@ -470,6 +571,8 @@ empathy_contact_list_store_set_is_compact (EmpathyContactListStore *store, (GtkTreeModelForeachFunc) contact_list_store_update_list_mode_foreach, store); + + g_object_notify (G_OBJECT (store), "is-compact"); } EmpathyContactListStoreSort @@ -509,6 +612,8 @@ empathy_contact_list_store_set_sort_criterium (EmpathyContactListStore *stor GTK_SORT_ASCENDING); break; } + + g_object_notify (G_OBJECT (store), "sort-criterium"); } gboolean @@ -715,6 +820,9 @@ contact_list_store_members_changed_cb (EmpathyContactList *list_iface, g_signal_connect (contact, "notify::presence", G_CALLBACK (contact_list_store_contact_updated_cb), store); + g_signal_connect (contact, "notify::presence-message", + G_CALLBACK (contact_list_store_contact_updated_cb), + store); g_signal_connect (contact, "notify::name", G_CALLBACK (contact_list_store_contact_updated_cb), store); @@ -768,7 +876,7 @@ contact_list_store_add_contact (EmpathyContactListStore *store, { EmpathyContactListStorePriv *priv; GtkTreeIter iter; - GList *groups, *l; + GList *groups = NULL, *l; priv = GET_PRIV (store); @@ -776,7 +884,9 @@ contact_list_store_add_contact (EmpathyContactListStore *store, return; } - groups = empathy_contact_list_get_groups (priv->list, contact); + if (priv->show_groups) { + groups = empathy_contact_list_get_groups (priv->list, contact); + } /* If no groups just add it at the top level. */ if (!groups) { @@ -1213,6 +1323,28 @@ contact_list_store_get_group (EmpathyContactListStore *store, } } +static guint +contact_list_store_ordered_presence (McPresence state) +{ + switch (state) { + case MC_PRESENCE_UNSET: + case MC_PRESENCE_OFFLINE: + return 5; + case MC_PRESENCE_AVAILABLE: + return 0; + case MC_PRESENCE_AWAY: + return 2; + case MC_PRESENCE_EXTENDED_AWAY: + return 3; + case MC_PRESENCE_HIDDEN: + return 4; + case MC_PRESENCE_DO_NOT_DISTURB: + return 1; + default: + g_return_val_if_reached (6); + } +} + static gint contact_list_store_state_sort_func (GtkTreeModel *model, GtkTreeIter *iter_a, @@ -1222,9 +1354,8 @@ contact_list_store_state_sort_func (GtkTreeModel *model, gint ret_val = 0; gchar *name_a, *name_b; gboolean is_separator_a, is_separator_b; - EmpathyContact *contact_a, *contact_b; - EmpathyPresence *presence_a, *presence_b; - McPresence state_a, state_b; + EmpathyContact *contact_a, *contact_b; + guint presence_a, presence_b; gtk_tree_model_get (model, iter_a, EMPATHY_CONTACT_LIST_STORE_COL_NAME, &name_a, @@ -1261,27 +1392,17 @@ contact_list_store_state_sort_func (GtkTreeModel *model, * the presences. */ presence_a = empathy_contact_get_presence (EMPATHY_CONTACT (contact_a)); + presence_a = contact_list_store_ordered_presence (presence_a); presence_b = empathy_contact_get_presence (EMPATHY_CONTACT (contact_b)); + presence_b = contact_list_store_ordered_presence (presence_b); - if (!presence_a && presence_b) { - ret_val = 1; - } else if (presence_a && !presence_b) { + if (presence_a < presence_b) { ret_val = -1; - } else if (!presence_a && !presence_b) { - /* Both offline, sort by name */ - ret_val = g_utf8_collate (name_a, name_b); + } else if (presence_a > presence_b) { + ret_val = 1; } else { - state_a = empathy_presence_get_state (presence_a); - state_b = empathy_presence_get_state (presence_b); - - if (state_a < state_b) { - ret_val = -1; - } else if (state_a > state_b) { - ret_val = 1; - } else { - /* Fallback: compare by name */ - ret_val = g_utf8_collate (name_a, name_b); - } + /* Fallback: compare by name */ + ret_val = g_utf8_collate (name_a, name_b); } free_and_out: diff --git a/libempathy-gtk/empathy-contact-list-store.h b/libempathy-gtk/empathy-contact-list-store.h index 214f5be60..6766a4e97 100644 --- a/libempathy-gtk/empathy-contact-list-store.h +++ b/libempathy-gtk/empathy-contact-list-store.h @@ -81,6 +81,9 @@ void empathy_contact_list_store_set_show_offline (Empath gboolean empathy_contact_list_store_get_show_avatars (EmpathyContactListStore *store); void empathy_contact_list_store_set_show_avatars (EmpathyContactListStore *store, gboolean show_avatars); +gboolean empathy_contact_list_store_get_show_groups (EmpathyContactListStore *store); +void empathy_contact_list_store_set_show_groups (EmpathyContactListStore *store, + gboolean show_groups); gboolean empathy_contact_list_store_get_is_compact (EmpathyContactListStore *store); void empathy_contact_list_store_set_is_compact (EmpathyContactListStore *store, gboolean is_compact); diff --git a/libempathy-gtk/empathy-contact-list-view.c b/libempathy-gtk/empathy-contact-list-view.c index 6e5ab8536..78ac3980c 100644 --- a/libempathy-gtk/empathy-contact-list-view.c +++ b/libempathy-gtk/empathy-contact-list-view.c @@ -40,6 +40,7 @@ #include <libempathy/empathy-contact-list.h> #include <libempathy/empathy-log-manager.h> #include <libempathy/empathy-tp-group.h> +#include <libempathy/empathy-contact-groups.h> #include <libempathy/empathy-debug.h> #include <libempathy/empathy-utils.h> #include <libempathy/empathy-marshal.h> @@ -47,7 +48,6 @@ #include "empathy-contact-list-view.h" #include "empathy-contact-list-store.h" #include "empathy-images.h" -#include "empathy-contact-groups.h" #include "empathy-cell-renderer-expander.h" #include "empathy-cell-renderer-text.h" #include "empathy-cell-renderer-activatable.h" @@ -56,6 +56,7 @@ //#include "empathy-chat-invite.h" //#include "empathy-ft-window.h" #include "empathy-log-window.h" +#include "empathy-gtk-enum-types.h" #define DEBUG_DOMAIN "ContactListView" @@ -68,12 +69,12 @@ #define GET_PRIV(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), EMPATHY_TYPE_CONTACT_LIST_VIEW, EmpathyContactListViewPriv)) -struct _EmpathyContactListViewPriv { - EmpathyContactListStore *store; - GtkUIManager *ui; - GtkTreeRowReference *drag_row; - gboolean interactive; -}; +typedef struct { + EmpathyContactListStore *store; + GtkUIManager *ui; + GtkTreeRowReference *drag_row; + EmpathyContactListFeatures features; +} EmpathyContactListViewPriv; typedef struct { EmpathyContactListView *view; @@ -188,7 +189,7 @@ static void contact_list_view_voip_activated (EmpathyContactLi enum { PROP_0, - PROP_INTERACTIVE + PROP_FEATURES }; static const GtkActionEntry entries[] = { @@ -326,12 +327,13 @@ empathy_contact_list_view_class_init (EmpathyContactListViewClass *klass) 3, EMPATHY_TYPE_CONTACT, G_TYPE_STRING, G_TYPE_STRING); g_object_class_install_property (object_class, - PROP_INTERACTIVE, - g_param_spec_boolean ("interactive", - "View is interactive", - "Is the view interactive", - FALSE, - G_PARAM_READWRITE)); + PROP_FEATURES, + g_param_spec_flags ("features", + "Features of the view", + "Falgs for all enabled features", + EMPATHY_TYPE_CONTACT_LIST_FEATURES, + 0, + G_PARAM_READWRITE)); g_type_class_add_private (object_class, sizeof (EmpathyContactListViewPriv)); } @@ -414,8 +416,8 @@ contact_list_view_get_property (GObject *object, priv = GET_PRIV (object); switch (param_id) { - case PROP_INTERACTIVE: - g_value_set_boolean (value, priv->interactive); + case PROP_FEATURES: + g_value_set_flags (value, priv->features); break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec); @@ -435,8 +437,8 @@ contact_list_view_set_property (GObject *object, priv = GET_PRIV (object); switch (param_id) { - case PROP_INTERACTIVE: - empathy_contact_list_view_set_interactive (view, g_value_get_boolean (value)); + case PROP_FEATURES: + empathy_contact_list_view_set_features (view, g_value_get_flags (value)); break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec); @@ -445,40 +447,69 @@ contact_list_view_set_property (GObject *object, } EmpathyContactListView * -empathy_contact_list_view_new (EmpathyContactListStore *store) +empathy_contact_list_view_new (EmpathyContactListStore *store, + EmpathyContactListFeatures features) { - EmpathyContactListViewPriv *priv; EmpathyContactListView *view; + EmpathyContactListViewPriv *priv; + + g_return_val_if_fail (EMPATHY_IS_CONTACT_LIST_STORE (store), NULL); - view = g_object_new (EMPATHY_TYPE_CONTACT_LIST_VIEW, NULL); - priv = GET_PRIV (view); + view = g_object_new (EMPATHY_TYPE_CONTACT_LIST_VIEW, + "features", features, + NULL); + priv = GET_PRIV (view); priv->store = g_object_ref (store); - contact_list_view_setup (view); + contact_list_view_setup (EMPATHY_CONTACT_LIST_VIEW (view)); return view; } void -empathy_contact_list_view_set_interactive (EmpathyContactListView *view, - gboolean interactive) +empathy_contact_list_view_set_features (EmpathyContactListView *view, + EmpathyContactListFeatures features) { EmpathyContactListViewPriv *priv = GET_PRIV (view); g_return_if_fail (EMPATHY_IS_CONTACT_LIST_VIEW (view)); - priv->interactive = interactive; - g_object_notify (G_OBJECT (view), "interactive"); + priv->features = features; + + /* Update DnD source/dest */ + if (features & EMPATHY_CONTACT_LIST_FEATURE_CONTACT_DRAG) { + gtk_drag_source_set (GTK_WIDGET (view), + GDK_BUTTON1_MASK, + drag_types_source, + G_N_ELEMENTS (drag_types_source), + GDK_ACTION_MOVE | GDK_ACTION_COPY); + } else { + gtk_drag_source_unset (GTK_WIDGET (view)); + + } + + if (features & EMPATHY_CONTACT_LIST_FEATURE_CONTACT_DROP) { + gtk_drag_dest_set (GTK_WIDGET (view), + GTK_DEST_DEFAULT_ALL, + drag_types_dest, + G_N_ELEMENTS (drag_types_dest), + GDK_ACTION_MOVE | GDK_ACTION_COPY); + } else { + /* FIXME: URI could still be droped depending on FT feature */ + gtk_drag_dest_unset (GTK_WIDGET (view)); + } + + g_object_notify (G_OBJECT (view), "features"); } -gboolean -empathy_contact_list_view_get_interactive (EmpathyContactListView *view) +EmpathyContactListFeatures +empathy_contact_list_view_get_features (EmpathyContactListView *view) { EmpathyContactListViewPriv *priv = GET_PRIV (view); g_return_val_if_fail (EMPATHY_IS_CONTACT_LIST_VIEW (view), FALSE); - return priv->interactive; + return priv->features; } EmpathyContact * @@ -538,48 +569,6 @@ empathy_contact_list_view_get_selected_group (EmpathyContactListView *view) return name; } -GtkWidget * -empathy_contact_list_view_get_group_menu (EmpathyContactListView *view) -{ - EmpathyContactListViewPriv *priv; - GtkWidget *widget; - - g_return_val_if_fail (EMPATHY_IS_CONTACT_LIST_VIEW (view), NULL); - - priv = GET_PRIV (view); - - widget = gtk_ui_manager_get_widget (priv->ui, "/Group"); - - return widget; -} - -GtkWidget * -empathy_contact_list_view_get_contact_menu (EmpathyContactListView *view, - EmpathyContact *contact) -{ - EmpathyLogManager *log_manager; - gboolean can_show_log; - gboolean can_send_file; - gboolean can_voip; - - g_return_val_if_fail (EMPATHY_IS_CONTACT_LIST_VIEW (view), NULL); - g_return_val_if_fail (EMPATHY_IS_CONTACT (contact), NULL); - - log_manager = empathy_log_manager_new (); - can_show_log = empathy_log_manager_exists (log_manager, - empathy_contact_get_account (contact), - empathy_contact_get_id (contact), - FALSE); - g_object_unref (log_manager); - can_send_file = FALSE; - can_voip = empathy_contact_can_voip (contact); - - return contact_list_view_get_contact_menu (view, - can_send_file, - can_show_log, - can_voip); -} - static void contact_list_view_setup (EmpathyContactListView *view) { @@ -693,21 +682,6 @@ contact_list_view_setup (EmpathyContactListView *view) drag_atoms_source[i] = gdk_atom_intern (drag_types_source[i].target, FALSE); } - - /* Note: We support the COPY action too, but need to make the - * MOVE action the default. - */ - gtk_drag_source_set (GTK_WIDGET (view), - GDK_BUTTON1_MASK, - drag_types_source, - G_N_ELEMENTS (drag_types_source), - GDK_ACTION_MOVE | GDK_ACTION_COPY); - - gtk_drag_dest_set (GTK_WIDGET (view), - GTK_DEST_DEFAULT_ALL, - drag_types_dest, - G_N_ELEMENTS (drag_types_dest), - GDK_ACTION_MOVE | GDK_ACTION_COPY); } static void @@ -716,6 +690,7 @@ contact_list_view_row_has_child_toggled_cb (GtkTreeModel *model, GtkTreeIter *iter, EmpathyContactListView *view) { + EmpathyContactListViewPriv *priv = GET_PRIV (view); gboolean is_group = FALSE; gchar *name = NULL; @@ -729,7 +704,8 @@ contact_list_view_row_has_child_toggled_cb (GtkTreeModel *model, return; } - if (empathy_contact_group_get_expanded (name)) { + if (!(priv->features & EMPATHY_CONTACT_LIST_FEATURE_GROUPS_SAVE) || + empathy_contact_group_get_expanded (name)) { g_signal_handlers_block_by_func (view, contact_list_view_row_expand_or_collapse_cb, GINT_TO_POINTER (TRUE)); @@ -953,7 +929,6 @@ contact_list_view_drag_data_get (GtkWidget *widget, const gchar *contact_id; const gchar *account_id; gchar *str; - priv = GET_PRIV (widget); @@ -1204,27 +1179,100 @@ contact_list_view_get_contact_menu (EmpathyContactListView *view, gboolean can_show_log, gboolean can_voip) { - EmpathyContactListViewPriv *priv; - GtkAction *action; - GtkWidget *widget; - - priv = GET_PRIV (view); + EmpathyContactListViewPriv *priv = GET_PRIV (view); + GtkAction *action; + + if (!(priv->features & (EMPATHY_CONTACT_LIST_FEATURE_CONTACT_CHAT | + EMPATHY_CONTACT_LIST_FEATURE_CONTACT_CALL | + EMPATHY_CONTACT_LIST_FEATURE_CONTACT_LOG | + EMPATHY_CONTACT_LIST_FEATURE_CONTACT_FT | + EMPATHY_CONTACT_LIST_FEATURE_CONTACT_INVITE | + EMPATHY_CONTACT_LIST_FEATURE_CONTACT_EDIT | + EMPATHY_CONTACT_LIST_FEATURE_CONTACT_INFO | + EMPATHY_CONTACT_LIST_FEATURE_CONTACT_REMOVE))) { + return NULL; + } - /* Sort out sensitive items */ - action = gtk_ui_manager_get_action (priv->ui, "/Contact/Log"); - gtk_action_set_sensitive (action, can_show_log); + /* Sort out sensitive/visible items */ + action = gtk_ui_manager_get_action (priv->ui, "/Contact/Chat"); + gtk_action_set_visible (action, priv->features & EMPATHY_CONTACT_LIST_FEATURE_CONTACT_CHAT); #ifdef HAVE_VOIP action = gtk_ui_manager_get_action (priv->ui, "/Contact/Call"); gtk_action_set_sensitive (action, can_voip); + gtk_action_set_visible (action, priv->features & EMPATHY_CONTACT_LIST_FEATURE_CONTACT_CALL); #endif + action = gtk_ui_manager_get_action (priv->ui, "/Contact/Log"); + gtk_action_set_sensitive (action, can_show_log); + gtk_action_set_visible (action, priv->features & EMPATHY_CONTACT_LIST_FEATURE_CONTACT_LOG); + + action = gtk_ui_manager_get_action (priv->ui, "/Contact/SendFile"); - gtk_action_set_visible (action, can_send_file); + gtk_action_set_visible (action, can_send_file && (priv->features & EMPATHY_CONTACT_LIST_FEATURE_CONTACT_FT)); + + action = gtk_ui_manager_get_action (priv->ui, "/Contact/Invite"); + gtk_action_set_visible (action, priv->features & EMPATHY_CONTACT_LIST_FEATURE_CONTACT_INVITE); + + action = gtk_ui_manager_get_action (priv->ui, "/Contact/Edit"); + gtk_action_set_visible (action, priv->features & EMPATHY_CONTACT_LIST_FEATURE_CONTACT_EDIT); + + action = gtk_ui_manager_get_action (priv->ui, "/Contact/Information"); + gtk_action_set_visible (action, priv->features & EMPATHY_CONTACT_LIST_FEATURE_CONTACT_INFO); + + action = gtk_ui_manager_get_action (priv->ui, "/Contact/Remove"); + gtk_action_set_visible (action, priv->features & EMPATHY_CONTACT_LIST_FEATURE_CONTACT_REMOVE); + + return gtk_ui_manager_get_widget (priv->ui, "/Contact"); +} + +GtkWidget * +empathy_contact_list_view_get_group_menu (EmpathyContactListView *view) +{ + EmpathyContactListViewPriv *priv = GET_PRIV (view); + GtkAction *action; - widget = gtk_ui_manager_get_widget (priv->ui, "/Contact"); + g_return_val_if_fail (EMPATHY_IS_CONTACT_LIST_VIEW (view), NULL); - return widget; + if (!(priv->features & (EMPATHY_CONTACT_LIST_FEATURE_GROUPS_RENAME | + EMPATHY_CONTACT_LIST_FEATURE_GROUPS_REMOVE))) { + return NULL; + } + + action = gtk_ui_manager_get_action (priv->ui, "/Group/Rename"); + gtk_action_set_visible (action, priv->features & EMPATHY_CONTACT_LIST_FEATURE_GROUPS_RENAME); + + action = gtk_ui_manager_get_action (priv->ui, "/Group/Remove"); + gtk_action_set_visible (action, priv->features & EMPATHY_CONTACT_LIST_FEATURE_GROUPS_REMOVE); + + return gtk_ui_manager_get_widget (priv->ui, "/Group"); +} + +GtkWidget * +empathy_contact_list_view_get_contact_menu (EmpathyContactListView *view, + EmpathyContact *contact) +{ + EmpathyLogManager *log_manager; + gboolean can_show_log; + gboolean can_send_file; + gboolean can_voip; + + g_return_val_if_fail (EMPATHY_IS_CONTACT_LIST_VIEW (view), NULL); + g_return_val_if_fail (EMPATHY_IS_CONTACT (contact), NULL); + + log_manager = empathy_log_manager_new (); + can_show_log = empathy_log_manager_exists (log_manager, + empathy_contact_get_account (contact), + empathy_contact_get_id (contact), + FALSE); + g_object_unref (log_manager); + can_send_file = FALSE; + can_voip = empathy_contact_can_voip (contact); + + return contact_list_view_get_contact_menu (view, + can_send_file, + can_show_log, + can_voip); } static gboolean @@ -1243,7 +1291,7 @@ contact_list_view_button_press_event_cb (EmpathyContactListView *view, priv = GET_PRIV (view); - if (!priv->interactive || event->button != 3) { + if (event->button != 3) { return FALSE; } @@ -1301,7 +1349,7 @@ contact_list_view_row_activated_cb (EmpathyContactListView *view, GtkTreeModel *model; GtkTreeIter iter; - if (!priv->interactive) { + if (!(priv->features & EMPATHY_CONTACT_LIST_FEATURE_CONTACT_CHAT)) { return; } @@ -1329,7 +1377,7 @@ contact_list_view_voip_activated_cb (EmpathyCellRendererActivatable *cell, GtkTreeIter iter; EmpathyContact *contact; - if (!priv->interactive) { + if (!(priv->features & EMPATHY_CONTACT_LIST_FEATURE_CONTACT_CALL)) { return; } @@ -1356,9 +1404,14 @@ contact_list_view_row_expand_or_collapse_cb (EmpathyContactListView *view, GtkTreePath *path, gpointer user_data) { - GtkTreeModel *model; - gchar *name; - gboolean expanded; + EmpathyContactListViewPriv *priv = GET_PRIV (view); + GtkTreeModel *model; + gchar *name; + gboolean expanded; + + if (!(priv->features & EMPATHY_CONTACT_LIST_FEATURE_GROUPS_SAVE)) { + return; + } model = gtk_tree_view_get_model (GTK_TREE_VIEW (view)); diff --git a/libempathy-gtk/empathy-contact-list-view.h b/libempathy-gtk/empathy-contact-list-view.h index c37e5c716..13a685d33 100644 --- a/libempathy-gtk/empathy-contact-list-view.h +++ b/libempathy-gtk/empathy-contact-list-view.h @@ -43,7 +43,24 @@ G_BEGIN_DECLS typedef struct _EmpathyContactListView EmpathyContactListView; typedef struct _EmpathyContactListViewClass EmpathyContactListViewClass; -typedef struct _EmpathyContactListViewPriv EmpathyContactListViewPriv; + +typedef enum { + EMPATHY_CONTACT_LIST_FEATURE_NONE = 0, + EMPATHY_CONTACT_LIST_FEATURE_GROUPS_SAVE = 1 << 0, + EMPATHY_CONTACT_LIST_FEATURE_GROUPS_RENAME = 1 << 1, + EMPATHY_CONTACT_LIST_FEATURE_GROUPS_REMOVE = 1 << 2, + EMPATHY_CONTACT_LIST_FEATURE_CONTACT_CHAT = 1 << 3, + EMPATHY_CONTACT_LIST_FEATURE_CONTACT_CALL = 1 << 4, + EMPATHY_CONTACT_LIST_FEATURE_CONTACT_LOG = 1 << 5, + EMPATHY_CONTACT_LIST_FEATURE_CONTACT_FT = 1 << 6, + EMPATHY_CONTACT_LIST_FEATURE_CONTACT_INVITE = 1 << 7, + EMPATHY_CONTACT_LIST_FEATURE_CONTACT_EDIT = 1 << 8, + EMPATHY_CONTACT_LIST_FEATURE_CONTACT_INFO = 1 << 9, + EMPATHY_CONTACT_LIST_FEATURE_CONTACT_REMOVE = 1 << 10, + EMPATHY_CONTACT_LIST_FEATURE_CONTACT_DROP = 1 << 11, + EMPATHY_CONTACT_LIST_FEATURE_CONTACT_DRAG = 1 << 12, + EMPATHY_CONTACT_LIST_FEATURE_ALL = (1 << 13) - 1, +} EmpathyContactListFeatures; struct _EmpathyContactListView { GtkTreeView parent; @@ -53,16 +70,17 @@ struct _EmpathyContactListViewClass { GtkTreeViewClass parent_class; }; -GType empathy_contact_list_view_get_type (void) G_GNUC_CONST; -EmpathyContactListView *empathy_contact_list_view_new (EmpathyContactListStore *store); -void empathy_contact_list_view_set_interactive (EmpathyContactListView *view, - gboolean interactive); -gboolean empathy_contact_list_view_get_interactive (EmpathyContactListView *view); -EmpathyContact * empathy_contact_list_view_get_selected (EmpathyContactListView *view); -gchar * empathy_contact_list_view_get_selected_group (EmpathyContactListView *view); -GtkWidget * empathy_contact_list_view_get_contact_menu (EmpathyContactListView *view, - EmpathyContact *contact); -GtkWidget * empathy_contact_list_view_get_group_menu (EmpathyContactListView *view); +GType empathy_contact_list_view_get_type (void) G_GNUC_CONST; +EmpathyContactListView * empathy_contact_list_view_new (EmpathyContactListStore *store, + EmpathyContactListFeatures features); +void empathy_contact_list_view_set_features (EmpathyContactListView *view, + EmpathyContactListFeatures features); +EmpathyContactListFeatures empathy_contact_list_view_get_features (EmpathyContactListView *view); +EmpathyContact * empathy_contact_list_view_get_selected (EmpathyContactListView *view); +gchar * empathy_contact_list_view_get_selected_group (EmpathyContactListView *view); +GtkWidget * empathy_contact_list_view_get_contact_menu (EmpathyContactListView *view, + EmpathyContact *contact); +GtkWidget * empathy_contact_list_view_get_group_menu (EmpathyContactListView *view); G_END_DECLS diff --git a/libempathy-gtk/empathy-contact-widget.c b/libempathy-gtk/empathy-contact-widget.c index 51d17bfb7..c290ef6a3 100644 --- a/libempathy-gtk/empathy-contact-widget.c +++ b/libempathy-gtk/empathy-contact-widget.c @@ -224,6 +224,23 @@ empathy_contact_widget_get_contact (GtkWidget *widget) } void +empathy_contact_widget_set_contact (GtkWidget *widget, + EmpathyContact *contact) +{ + EmpathyContactWidget *information; + + g_return_if_fail (GTK_IS_WIDGET (widget)); + g_return_if_fail (EMPATHY_IS_CONTACT (contact)); + + information = g_object_get_data (G_OBJECT (widget), "EmpathyContactWidget"); + if (!information) { + return; + } + + contact_widget_set_contact (information, contact); +} + +void empathy_contact_widget_set_account_filter (GtkWidget *widget, EmpathyAccountChooserFilterFunc filter, gpointer user_data) @@ -289,6 +306,12 @@ static void contact_widget_set_contact (EmpathyContactWidget *information, EmpathyContact *contact) { + if (contact == information->contact || + (contact && information->contact && + empathy_contact_equal (contact, information->contact))) { + return; + } + contact_widget_remove_contact (information); if (contact) { information->contact = g_object_ref (contact); @@ -406,6 +429,9 @@ contact_widget_contact_update (EmpathyContactWidget *information) g_signal_connect_swapped (information->contact, "notify::presence", G_CALLBACK (contact_widget_presence_notify_cb), information); + g_signal_connect_swapped (information->contact, "notify::presence-message", + G_CALLBACK (contact_widget_presence_notify_cb), + information); g_signal_connect_swapped (information->contact, "notify::avatar", G_CALLBACK (contact_widget_avatar_notify_cb), information); diff --git a/libempathy-gtk/empathy-contact-widget.h b/libempathy-gtk/empathy-contact-widget.h index 21dd1bf0c..643867ef5 100644 --- a/libempathy-gtk/empathy-contact-widget.h +++ b/libempathy-gtk/empathy-contact-widget.h @@ -41,6 +41,8 @@ typedef enum { GtkWidget * empathy_contact_widget_new (EmpathyContact *contact, EmpathyContactWidgetFlags flags); EmpathyContact *empathy_contact_widget_get_contact (GtkWidget *widget); +void empathy_contact_widget_set_contact (GtkWidget *widget, + EmpathyContact *contact); void empathy_contact_widget_set_account_filter (GtkWidget *widget, EmpathyAccountChooserFilterFunc filter, gpointer user_data); diff --git a/libempathy-gtk/empathy-group-chat.c b/libempathy-gtk/empathy-group-chat.c index 777514652..4f86ef2ba 100644 --- a/libempathy-gtk/empathy-group-chat.c +++ b/libempathy-gtk/empathy-group-chat.c @@ -40,7 +40,6 @@ #include <libempathy/empathy-contact.h> #include <libempathy/empathy-utils.h> #include <libempathy/empathy-debug.h> -#include <libempathy/empathy-conf.h> #include "empathy-group-chat.h" #include "empathy-chat.h" @@ -51,6 +50,7 @@ //#include "empathy-sound.h" #include "empathy-images.h" #include "empathy-ui-utils.h" +#include "empathy-conf.h" #include "empathy-preferences.h" #define DEBUG_DOMAIN "GroupChat" @@ -527,8 +527,14 @@ group_chat_set_tp_chat (EmpathyChat *chat, /* Create contact list */ priv->store = empathy_contact_list_store_new (EMPATHY_CONTACT_LIST (priv->tp_chat)); - priv->view = empathy_contact_list_view_new (priv->store); - empathy_contact_list_view_set_interactive (priv->view, TRUE); + priv->view = empathy_contact_list_view_new (priv->store, + EMPATHY_CONTACT_LIST_FEATURE_CONTACT_CHAT | + EMPATHY_CONTACT_LIST_FEATURE_CONTACT_CALL | + EMPATHY_CONTACT_LIST_FEATURE_CONTACT_LOG | + EMPATHY_CONTACT_LIST_FEATURE_CONTACT_FT | + EMPATHY_CONTACT_LIST_FEATURE_CONTACT_INVITE | + EMPATHY_CONTACT_LIST_FEATURE_CONTACT_INFO); + gtk_container_add (GTK_CONTAINER (priv->scrolled_window_contacts), GTK_WIDGET (priv->view)); gtk_widget_show (GTK_WIDGET (priv->view)); diff --git a/libempathy-gtk/empathy-log-window.c b/libempathy-gtk/empathy-log-window.c index da553075f..c32ed76e0 100644 --- a/libempathy-gtk/empathy-log-window.c +++ b/libempathy-gtk/empathy-log-window.c @@ -136,7 +136,7 @@ enum { COL_CHAT_COUNT }; -void +GtkWidget * empathy_log_window_show (McAccount *account, const gchar *chat_id, gboolean is_chatroom, @@ -157,7 +157,7 @@ empathy_log_window_show (McAccount *account, chat_id, is_chatroom); } - return; + return window->window; } window = g_new0 (EmpathyLogWindow, 1); @@ -261,6 +261,8 @@ empathy_log_window_show (McAccount *account, } gtk_widget_show (window->window); + + return window->window; } static void diff --git a/libempathy-gtk/empathy-log-window.h b/libempathy-gtk/empathy-log-window.h index 09a986399..a45cbbb84 100644 --- a/libempathy-gtk/empathy-log-window.h +++ b/libempathy-gtk/empathy-log-window.h @@ -29,10 +29,10 @@ G_BEGIN_DECLS -void empathy_log_window_show (McAccount *account, - const gchar *chat_id, - gboolean chatroom, - GtkWindow *parent); +GtkWidget * empathy_log_window_show (McAccount *account, + const gchar *chat_id, + gboolean chatroom, + GtkWindow *parent); G_END_DECLS diff --git a/libempathy-gtk/empathy-main-window.c b/libempathy-gtk/empathy-main-window.c index 399d0e5ee..951b80e95 100644 --- a/libempathy-gtk/empathy-main-window.c +++ b/libempathy-gtk/empathy-main-window.c @@ -28,7 +28,6 @@ #include <glade/glade.h> #include <glib/gi18n.h> -#include <libempathy/empathy-conf.h> #include <libempathy/empathy-contact.h> #include <libempathy/empathy-debug.h> #include <libempathy/empathy-utils.h> @@ -37,6 +36,7 @@ #include <libempathy/empathy-contact-list.h> #include <libempathy/empathy-contact-manager.h> #include <libempathy/empathy-contact-factory.h> +#include <libempathy/empathy-status-presets.h> #include "empathy-main-window.h" #include "empathy-contact-dialogs.h" @@ -45,8 +45,8 @@ #include "empathy-contact-list-view.h" #include "empathy-presence-chooser.h" #include "empathy-ui-utils.h" -#include "empathy-status-presets.h" #include "empathy-geometry.h" +#include "empathy-conf.h" #include "empathy-preferences.h" #include "empathy-accounts-dialog.h" #include "empathy-about-dialog.h" @@ -285,8 +285,8 @@ empathy_main_window_show (void) list_iface = EMPATHY_CONTACT_LIST (empathy_contact_manager_new ()); window->list_store = empathy_contact_list_store_new (list_iface); - window->list_view = empathy_contact_list_view_new (window->list_store); - empathy_contact_list_view_set_interactive (window->list_view, TRUE); + window->list_view = empathy_contact_list_view_new (window->list_store, + EMPATHY_CONTACT_LIST_FEATURE_ALL); g_object_unref (list_iface); gtk_widget_show (GTK_WIDGET (window->list_view)); @@ -810,7 +810,7 @@ main_window_error_display (EmpathyMainWindow *window, gtk_widget_show (image); gtk_box_pack_start (GTK_BOX (hbox), image, FALSE, FALSE, 0); - label = gtk_label_new_with_mnemonic (_("Edit Account _Details")); + label = gtk_label_new_with_mnemonic (_("_Edit account")); gtk_widget_show (label); gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0); diff --git a/libempathy-gtk/empathy-preferences.c b/libempathy-gtk/empathy-preferences.c index a8b52954d..50c9d5660 100644 --- a/libempathy-gtk/empathy-preferences.c +++ b/libempathy-gtk/empathy-preferences.c @@ -30,8 +30,7 @@ #include <glade/glade.h> #include <glib/gi18n.h> -#include <libempathy/empathy-conf.h> - +#include "empathy-conf.h" #include "empathy-preferences.h" #include "empathy-ui-utils.h" #include "empathy-theme-manager.h" @@ -50,6 +49,7 @@ typedef struct { GtkWidget *combobox_chat_theme; GtkWidget *checkbutton_theme_chat_room; GtkWidget *checkbutton_separate_chat_windows; + GtkWidget *checkbutton_autoconnect; GtkWidget *radiobutton_contact_list_sort_by_name; GtkWidget *radiobutton_contact_list_sort_by_state; @@ -200,6 +200,10 @@ preferences_setup_widgets (EmpathyPreferences *preferences) preferences_hookup_radio_button (preferences, EMPATHY_PREFS_CONTACTS_SORT_CRITERIUM, preferences->radiobutton_contact_list_sort_by_name); + + preferences_hookup_toggle_button (preferences, + EMPATHY_PREFS_AUTOCONNECT, + preferences->checkbutton_autoconnect); } static void @@ -939,6 +943,7 @@ empathy_preferences_show (GtkWindow *parent) "combobox_chat_theme", &preferences->combobox_chat_theme, "checkbutton_theme_chat_room", &preferences->checkbutton_theme_chat_room, "checkbutton_separate_chat_windows", &preferences->checkbutton_separate_chat_windows, + "checkbutton_autoconnect", &preferences->checkbutton_autoconnect, "radiobutton_contact_list_sort_by_name", &preferences->radiobutton_contact_list_sort_by_name, "radiobutton_contact_list_sort_by_state", &preferences->radiobutton_contact_list_sort_by_state, "checkbutton_sounds_for_messages", &preferences->checkbutton_sounds_for_messages, diff --git a/libempathy-gtk/empathy-preferences.glade b/libempathy-gtk/empathy-preferences.glade index 4db860f13..725844491 100644 --- a/libempathy-gtk/empathy-preferences.glade +++ b/libempathy-gtk/empathy-preferences.glade @@ -2,7 +2,6 @@ <!DOCTYPE glade-interface SYSTEM "http://glade.gnome.org/glade-2.0.dtd"> <glade-interface> -<requires lib="gnome"/> <widget class="GtkDialog" id="preferences_dialog"> <property name="border_width">5</property> @@ -232,6 +231,25 @@ <property name="fill">False</property> </packing> </child> + + <child> + <widget class="GtkCheckButton" id="checkbutton_autoconnect"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="label" translatable="yes">Automatically _connect on startup </property> + <property name="use_underline">True</property> + <property name="relief">GTK_RELIEF_NORMAL</property> + <property name="focus_on_click">True</property> + <property name="active">True</property> + <property name="inconsistent">False</property> + <property name="draw_indicator">True</property> + </widget> + <packing> + <property name="padding">0</property> + <property name="expand">True</property> + <property name="fill">True</property> + </packing> + </child> </widget> </child> </widget> diff --git a/libempathy-gtk/empathy-preferences.h b/libempathy-gtk/empathy-preferences.h index e4cf122bc..750666b09 100644 --- a/libempathy-gtk/empathy-preferences.h +++ b/libempathy-gtk/empathy-preferences.h @@ -51,6 +51,7 @@ G_BEGIN_DECLS #define EMPATHY_PREFS_HINTS_CLOSE_MAIN_WINDOW EMPATHY_PREFS_PATH "/hints/close_main_window" #define EMPATHY_PREFS_SALUT_ACCOUNT_CREATED EMPATHY_PREFS_PATH "/accounts/salut_created" #define EMPATHY_PREFS_USE_NM EMPATHY_PREFS_PATH "/use_nm" +#define EMPATHY_PREFS_AUTOCONNECT EMPATHY_PREFS_PATH "/autoconnect" GtkWidget * empathy_preferences_show (GtkWindow *parent); diff --git a/libempathy-gtk/empathy-presence-chooser.c b/libempathy-gtk/empathy-presence-chooser.c index 6f34a3985..e543a5f1f 100644 --- a/libempathy-gtk/empathy-presence-chooser.c +++ b/libempathy-gtk/empathy-presence-chooser.c @@ -38,11 +38,11 @@ #include <libempathy/empathy-utils.h> #include <libempathy/empathy-debug.h> #include <libempathy/empathy-marshal.h> +#include <libempathy/empathy-status-presets.h> #include "empathy-ui-utils.h" #include "empathy-images.h" #include "empathy-presence-chooser.h" -#include "empathy-status-presets.h" #define GET_PRIV(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), EMPATHY_TYPE_PRESENCE_CHOOSER, EmpathyPresenceChooserPriv)) @@ -381,7 +381,7 @@ presence_chooser_scroll_event_cb (EmpathyPresenceChooser *chooser, /* If we didn't get any match at all, it means the last state * was a custom one. Just switch to the first one. */ - status = empathy_presence_state_get_default_status (states[0]); + status = empathy_presence_get_default_message (states[0]); presence_chooser_reset_scroll_timeout (chooser); empathy_idle_set_presence (priv->idle, states[0], status); @@ -404,7 +404,7 @@ presence_chooser_get_presets (EmpathyPresenceChooser *chooser) StateAndStatus *sas; const gchar *status; - status = empathy_presence_state_get_default_status (states[i]); + status = empathy_presence_get_default_message (states[i]); sas = presence_chooser_state_and_status_new (states[i], status); list = g_list_prepend (list, sas); @@ -455,7 +455,7 @@ presence_chooser_flash_timeout_cb (EmpathyPresenceChooser *chooser) } gtk_image_set_from_icon_name (GTK_IMAGE (priv->image), - empathy_icon_name_for_presence_state (state), + empathy_icon_name_for_presence (state), GTK_ICON_SIZE_MENU); on = !on; @@ -500,7 +500,7 @@ presence_chooser_flash_stop (EmpathyPresenceChooser *chooser, } gtk_image_set_from_icon_name (GTK_IMAGE (priv->image), - empathy_icon_name_for_presence_state (state), + empathy_icon_name_for_presence (state), GTK_ICON_SIZE_MENU); priv->last_state = state; @@ -665,7 +665,7 @@ empathy_presence_chooser_create_menu (void) for (i = 0; i < G_N_ELEMENTS (states); i += 2) { GList *list, *l; - status = empathy_presence_state_get_default_status (states[i]); + status = empathy_presence_get_default_message (states[i]); presence_chooser_menu_add_item (menu, status, states[i]); @@ -714,7 +714,7 @@ presence_chooser_menu_add_item (GtkWidget *menu, const gchar *icon_name; item = gtk_image_menu_item_new_with_label (str); - icon_name = empathy_icon_name_for_presence_state (state); + icon_name = empathy_icon_name_for_presence (state); g_signal_connect (item, "activate", G_CALLBACK (presence_chooser_noncustom_activate_cb), @@ -808,6 +808,8 @@ presence_chooser_dialog_status_changed_cb (GtkWidget *widget, gtk_combo_box_set_model (GTK_COMBO_BOX (dialog->comboboxentry_message), GTK_TREE_MODEL (store)); + + g_object_unref (store); } static void @@ -889,8 +891,8 @@ presence_chooser_dialog_setup (CustomMessageDialog *dialog) gtk_list_store_append (store, &iter); gtk_list_store_set (store, &iter, - COL_ICON, empathy_icon_name_for_presence_state (states[i]), - COL_LABEL, empathy_presence_state_get_default_status (states[i]), + COL_ICON, empathy_icon_name_for_presence (states[i]), + COL_LABEL, empathy_presence_get_default_message (states[i]), COL_PRESENCE, states[i], -1); } @@ -899,16 +901,27 @@ presence_chooser_dialog_setup (CustomMessageDialog *dialog) } static void -presence_chooser_dialog_destroy_cb (GtkWidget *widget, - CustomMessageDialog *dialog) +presence_chooser_dialog_response_cb (GtkWidget *widget, + gint response, + CustomMessageDialog *dialog) { - McPresence state; - const gchar *text; + if (response == GTK_RESPONSE_APPLY) { + McPresence state; + const gchar *text; - state = presence_chooser_dialog_get_selected (dialog); - text = gtk_entry_get_text (GTK_ENTRY (dialog->entry_message)); + state = presence_chooser_dialog_get_selected (dialog); + text = gtk_entry_get_text (GTK_ENTRY (dialog->entry_message)); - presence_chooser_set_state (state, text); + presence_chooser_set_state (state, text); + } + + gtk_widget_destroy (widget); +} + +static void +presence_chooser_dialog_destroy_cb (GtkWidget *widget, + CustomMessageDialog *dialog) +{ g_free (dialog); message_dialog = NULL; @@ -936,7 +949,7 @@ presence_chooser_dialog_show (void) empathy_glade_connect (glade, message_dialog, "custom_message_dialog", "destroy", presence_chooser_dialog_destroy_cb, - "custom_message_dialog", "response", gtk_widget_destroy, + "custom_message_dialog", "response", presence_chooser_dialog_response_cb, "combobox_status", "changed", presence_chooser_dialog_status_changed_cb, "checkbutton_save", "toggled", presence_chooser_dialog_save_toggled_cb, NULL); diff --git a/libempathy-gtk/empathy-presence-chooser.glade b/libempathy-gtk/empathy-presence-chooser.glade index 9433d2651..a3a26a156 100644 --- a/libempathy-gtk/empathy-presence-chooser.glade +++ b/libempathy-gtk/empathy-presence-chooser.glade @@ -5,6 +5,7 @@ <requires lib="gnome"/> <widget class="GtkDialog" id="custom_message_dialog"> + <property name="border_width">5</property> <property name="visible">True</property> <property name="title" translatable="yes">Custom message</property> <property name="type">GTK_WINDOW_TOPLEVEL</property> @@ -20,7 +21,6 @@ <property name="focus_on_map">True</property> <property name="urgency_hint">False</property> <property name="has_separator">False</property> - <property name="border_width">5</property> <child internal-child="vbox"> <widget class="GtkVBox" id="dialog-vbox6"> @@ -38,11 +38,24 @@ <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="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="button1"> + <property name="visible">True</property> + <property name="can_default">True</property> + <property name="can_focus">True</property> + <property name="label">gtk-apply</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">-7</property> + <property name="response_id">-10</property> </widget> </child> </widget> @@ -56,13 +69,13 @@ <child> <widget class="GtkTable" id="table1"> + <property name="border_width">5</property> <property name="visible">True</property> <property name="n_rows">3</property> <property name="n_columns">2</property> <property name="homogeneous">False</property> <property name="row_spacing">6</property> <property name="column_spacing">6</property> - <property name="border_width">5</property> <child> <widget class="GtkLabel" id="label471"> diff --git a/libempathy-gtk/empathy-presence-chooser.h b/libempathy-gtk/empathy-presence-chooser.h index 8a9349620..a04458d83 100644 --- a/libempathy-gtk/empathy-presence-chooser.h +++ b/libempathy-gtk/empathy-presence-chooser.h @@ -27,8 +27,6 @@ #include <gtk/gtk.h> -#include <libempathy/empathy-presence.h> - G_BEGIN_DECLS #define EMPATHY_TYPE_PRESENCE_CHOOSER (empathy_presence_chooser_get_type ()) diff --git a/libempathy-gtk/empathy-smiley-manager.c b/libempathy-gtk/empathy-smiley-manager.c index 8b1e9e18d..502af2d4e 100644 --- a/libempathy-gtk/empathy-smiley-manager.c +++ b/libempathy-gtk/empathy-smiley-manager.c @@ -266,7 +266,7 @@ empathy_smiley_manager_load (EmpathySmileyManager *manager) g_return_if_fail (EMPATHY_IS_SMILEY_MANAGER (manager)); /* From fd.o icon-naming spec */ - empathy_smiley_manager_add (manager, "face-angel", "0:-)", "0:)", NULL); + empathy_smiley_manager_add (manager, "face-angel", "O:-)", "O:)", NULL); empathy_smiley_manager_add (manager, "face-cool", "B-)", "B)", NULL); empathy_smiley_manager_add (manager, "face-crying", ":'(", NULL); empathy_smiley_manager_add (manager, "face-devilish", ">:-)", ">:)", NULL); @@ -279,7 +279,7 @@ empathy_smiley_manager_load (EmpathySmileyManager *manager) empathy_smiley_manager_add (manager, "face-smile", ":-)", ":)", NULL); empathy_smiley_manager_add (manager, "face-smile-big", ":-D", ":D", ":-d", ":d", NULL); empathy_smiley_manager_add (manager, "face-smirk", ":-!", ":!", NULL); - empathy_smiley_manager_add (manager, "face-surprise", ":-0", ":0", NULL); + empathy_smiley_manager_add (manager, "face-surprise", ":-O", ":O", NULL); empathy_smiley_manager_add (manager, "face-wink", ";-)", ";)", NULL); } diff --git a/libempathy-gtk/empathy-spell.c b/libempathy-gtk/empathy-spell.c index 88696cca3..b6620118a 100644 --- a/libempathy-gtk/empathy-spell.c +++ b/libempathy-gtk/empathy-spell.c @@ -33,9 +33,9 @@ #endif #include <libempathy/empathy-debug.h> -#include <libempathy/empathy-conf.h> #include "empathy-spell.h" +#include "empathy-conf.h" #include "empathy-preferences.h" #define DEBUG_DOMAIN "Spell" diff --git a/libempathy-gtk/empathy-status-icon.c b/libempathy-gtk/empathy-status-icon.c index 0fd6c0d67..0cffeb1b4 100644 --- a/libempathy-gtk/empathy-status-icon.c +++ b/libempathy-gtk/empathy-status-icon.c @@ -35,13 +35,13 @@ #include <libempathy/empathy-tp-chat.h> #include <libempathy/empathy-debug.h> #include <libempathy/empathy-utils.h> -#include <libempathy/empathy-conf.h> #include <libempathy/empathy-idle.h> #include <libempathy/empathy-filter.h> #include "empathy-status-icon.h" #include "empathy-contact-dialogs.h" #include "empathy-presence-chooser.h" +#include "empathy-conf.h" #include "empathy-preferences.h" #include "empathy-ui-utils.h" #include "empathy-accounts-dialog.h" @@ -101,7 +101,8 @@ static void status_icon_idle_notify_cb (EmpathyStatusIcon *icon) static void status_icon_update_tooltip (EmpathyStatusIcon *icon); static void status_icon_set_from_state (EmpathyStatusIcon *icon); static void status_icon_set_visibility (EmpathyStatusIcon *icon, - gboolean visible); + gboolean visible, + gboolean store); static void status_icon_toggle_visibility (EmpathyStatusIcon *icon); static void status_icon_activate_cb (GtkStatusIcon *status_icon, EmpathyStatusIcon *icon); @@ -153,6 +154,19 @@ status_icon_notify_use_nm_cb (EmpathyConf *conf, } static void +status_icon_notify_visibility_cb (EmpathyConf *conf, + const gchar *key, + gpointer user_data) +{ + EmpathyStatusIcon *icon = user_data; + gboolean hidden = FALSE; + + if (empathy_conf_get_bool (conf, key, &hidden)) { + status_icon_set_visibility (icon, !hidden, FALSE); + } +} + +static void empathy_status_icon_class_init (EmpathyStatusIconClass *klass) { GObjectClass *object_class = G_OBJECT_CLASS (klass); @@ -192,6 +206,11 @@ empathy_status_icon_init (EmpathyStatusIcon *icon) empathy_idle_set_auto_away (priv->idle, TRUE); empathy_idle_set_use_nm (priv->idle, use_nm); + /* make icon listen and respond to MAIN_WINDOW_HIDDEN changes */ + empathy_conf_notify_add (empathy_conf_get (), + EMPATHY_PREFS_UI_MAIN_WINDOW_HIDDEN, + status_icon_notify_visibility_cb, + icon); status_icon_create_menu (icon); status_icon_idle_notify_cb (icon); @@ -273,7 +292,7 @@ empathy_status_icon_new (GtkWindow *window) &should_hide); if (gtk_window_is_active (priv->window) == should_hide) { - status_icon_set_visibility (icon, !should_hide); + status_icon_set_visibility (icon, !should_hide, FALSE); } return icon; @@ -353,7 +372,7 @@ status_icon_idle_notify_cb (EmpathyStatusIcon *icon) if (flash_state != MC_PRESENCE_UNSET) { const gchar *icon_name; - icon_name = empathy_icon_name_for_presence_state (flash_state); + icon_name = empathy_icon_name_for_presence (flash_state); if (!priv->flash_state_event) { /* We are now flashing */ priv->flash_state_event = status_icon_event_new (icon, icon_name, NULL); @@ -410,20 +429,23 @@ status_icon_set_from_state (EmpathyStatusIcon *icon) priv = GET_PRIV (icon); state = empathy_idle_get_state (priv->idle); - icon_name = empathy_icon_name_for_presence_state (state); + icon_name = empathy_icon_name_for_presence (state); gtk_status_icon_set_from_icon_name (priv->icon, icon_name); } static void status_icon_set_visibility (EmpathyStatusIcon *icon, - gboolean visible) + gboolean visible, + gboolean store) { EmpathyStatusIconPriv *priv; priv = GET_PRIV (icon); - empathy_conf_set_bool (empathy_conf_get (), - EMPATHY_PREFS_UI_MAIN_WINDOW_HIDDEN, !visible); + if (store) { + empathy_conf_set_bool (empathy_conf_get (), + EMPATHY_PREFS_UI_MAIN_WINDOW_HIDDEN, !visible); + } if (!visible) { empathy_window_iconify (priv->window, priv->icon); @@ -451,7 +473,7 @@ status_icon_toggle_visibility (EmpathyStatusIcon *icon) gboolean visible; visible = gtk_window_is_active (priv->window); - status_icon_set_visibility (icon, !visible); + status_icon_set_visibility (icon, !visible, TRUE); } static void @@ -477,7 +499,7 @@ status_icon_delete_event_cb (GtkWidget *widget, GdkEvent *event, EmpathyStatusIcon *icon) { - status_icon_set_visibility (icon, FALSE); + status_icon_set_visibility (icon, FALSE, TRUE); return TRUE; } @@ -569,7 +591,7 @@ status_icon_show_hide_window_cb (GtkWidget *widget, gboolean visible; visible = gtk_check_menu_item_get_active (GTK_CHECK_MENU_ITEM (widget)); - status_icon_set_visibility (icon, visible); + status_icon_set_visibility (icon, visible, TRUE); } static void diff --git a/libempathy-gtk/empathy-status-presets.c b/libempathy-gtk/empathy-status-presets.c deleted file mode 100644 index 13b71bc75..000000000 --- a/libempathy-gtk/empathy-status-presets.c +++ /dev/null @@ -1,408 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * Copyright (C) 2005-2007 Imendio AB - * - * 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. - * - * Author: Martyn Russell <martyn@imendio.com> - */ - -#include "config.h" - -#include <sys/types.h> -#include <sys/stat.h> -#include <string.h> - -#include <glib.h> -#include <glib/gi18n.h> - -#include <libxml/parser.h> -#include <libxml/tree.h> - -#include <telepathy-glib/util.h> - -#include <libempathy/empathy-debug.h> -#include <libempathy/empathy-utils.h> - -#include "empathy-status-presets.h" - -#define DEBUG_DOMAIN "StatusPresets" - -#define STATUS_PRESETS_XML_FILENAME "status-presets.xml" -#define STATUS_PRESETS_DTD_FILENAME "empathy-status-presets.dtd" -#define STATUS_PRESETS_MAX_EACH 15 - -typedef struct { - gchar *status; - McPresence state; -} StatusPreset; - -static StatusPreset *status_preset_new (McPresence state, - const gchar *status); -static void status_preset_free (StatusPreset *status); -static void status_presets_file_parse (const gchar *filename); -const gchar * status_presets_get_state_as_str (McPresence state); -static gboolean status_presets_file_save (void); -static void status_presets_set_default (McPresence state, - const gchar *status); - -static GList *presets = NULL; -static StatusPreset *default_preset = NULL; - -static StatusPreset * -status_preset_new (McPresence state, - const gchar *status) -{ - StatusPreset *preset; - - preset = g_new0 (StatusPreset, 1); - - preset->status = g_strdup (status); - preset->state = state; - - return preset; -} - -static void -status_preset_free (StatusPreset *preset) -{ - g_free (preset->status); - g_free (preset); -} - -static void -status_presets_file_parse (const gchar *filename) -{ - xmlParserCtxtPtr ctxt; - xmlDocPtr doc; - xmlNodePtr presets_node; - xmlNodePtr node; - - empathy_debug (DEBUG_DOMAIN, "Attempting to parse file:'%s'...", filename); - - ctxt = xmlNewParserCtxt (); - - /* Parse and validate the file. */ - doc = xmlCtxtReadFile (ctxt, filename, NULL, 0); - if (!doc) { - g_warning ("Failed to parse file:'%s'", filename); - xmlFreeParserCtxt (ctxt); - return; - } - - if (!empathy_xml_validate (doc, STATUS_PRESETS_DTD_FILENAME)) { - g_warning ("Failed to validate file:'%s'", filename); - xmlFreeDoc(doc); - xmlFreeParserCtxt (ctxt); - return; - } - - /* The root node, presets. */ - presets_node = xmlDocGetRootElement (doc); - - node = presets_node->children; - while (node) { - if (strcmp ((gchar *) node->name, "status") == 0 || - strcmp ((gchar *) node->name, "default") == 0) { - McPresence state; - gchar *status; - gchar *state_str; - StatusPreset *preset; - gboolean is_default = FALSE; - - if (strcmp ((gchar *) node->name, "default") == 0) { - is_default = TRUE; - } - - status = (gchar *) xmlNodeGetContent (node); - state_str = (gchar *) xmlGetProp (node, "presence"); - - if (state_str) { - state = empathy_presence_state_from_str (state_str); - - if (is_default) { - empathy_debug (DEBUG_DOMAIN, - "Default status preset state is:'%s', status:'%s'", - state_str, status); - - status_presets_set_default (state, status); - } else { - preset = status_preset_new (state, status); - presets = g_list_append (presets, preset); - } - } - - xmlFree (status); - xmlFree (state_str); - } - - node = node->next; - } - - /* Use the default if not set */ - if (!default_preset) { - status_presets_set_default (MC_PRESENCE_OFFLINE, NULL); - } - - empathy_debug (DEBUG_DOMAIN, "Parsed %d status presets", g_list_length (presets)); - - xmlFreeDoc (doc); - xmlFreeParserCtxt (ctxt); -} - -void -empathy_status_presets_get_all (void) -{ - gchar *dir; - gchar *file_with_path; - - /* If already set up clean up first. */ - if (presets) { - g_list_foreach (presets, (GFunc) status_preset_free, NULL); - g_list_free (presets); - presets = NULL; - } - - dir = g_build_filename (g_get_home_dir (), ".gnome2", PACKAGE_NAME, NULL); - g_mkdir_with_parents (dir, S_IRUSR | S_IWUSR | S_IXUSR); - file_with_path = g_build_filename (dir, STATUS_PRESETS_XML_FILENAME, NULL); - g_free (dir); - - if (g_file_test (file_with_path, G_FILE_TEST_EXISTS)) { - status_presets_file_parse (file_with_path); - } - - g_free (file_with_path); -} - -static gboolean -status_presets_file_save (void) -{ - xmlDocPtr doc; - xmlNodePtr root; - GList *l; - gchar *dir; - gchar *file; - gint count[LAST_MC_PRESENCE]; - gint i; - - for (i = 0; i < LAST_MC_PRESENCE; i++) { - count[i] = 0; - } - - dir = g_build_filename (g_get_home_dir (), ".gnome2", PACKAGE_NAME, NULL); - g_mkdir_with_parents (dir, S_IRUSR | S_IWUSR | S_IXUSR); - file = g_build_filename (dir, STATUS_PRESETS_XML_FILENAME, NULL); - g_free (dir); - - doc = xmlNewDoc ("1.0"); - root = xmlNewNode (NULL, "presets"); - xmlDocSetRootElement (doc, root); - - if (default_preset) { - xmlNodePtr subnode; - xmlChar *state; - - state = (gchar*) empathy_presence_state_to_str (default_preset->state); - - subnode = xmlNewTextChild (root, NULL, "default", - default_preset->status); - xmlNewProp (subnode, "presence", state); - } - - for (l = presets; l; l = l->next) { - StatusPreset *sp; - xmlNodePtr subnode; - xmlChar *state; - - sp = l->data; - state = (gchar*) empathy_presence_state_to_str (sp->state); - - count[sp->state]++; - if (count[sp->state] > STATUS_PRESETS_MAX_EACH) { - continue; - } - - subnode = xmlNewTextChild (root, NULL, - "status", sp->status); - xmlNewProp (subnode, "presence", state); - } - - /* Make sure the XML is indented properly */ - xmlIndentTreeOutput = 1; - - empathy_debug (DEBUG_DOMAIN, "Saving file:'%s'", file); - xmlSaveFormatFileEnc (file, doc, "utf-8", 1); - xmlFreeDoc (doc); - - g_free (file); - - return TRUE; -} - -GList * -empathy_status_presets_get (McPresence state, - gint max_number) -{ - GList *list = NULL; - GList *l; - gint i; - - i = 0; - for (l = presets; l; l = l->next) { - StatusPreset *sp; - - sp = l->data; - - if (sp->state != state) { - continue; - } - - list = g_list_append (list, sp->status); - i++; - - if (max_number != -1 && i >= max_number) { - break; - } - } - - return list; -} - -void -empathy_status_presets_set_last (McPresence state, - const gchar *status) -{ - GList *l; - StatusPreset *preset; - gint num; - - /* Check if duplicate */ - for (l = presets; l; l = l->next) { - preset = l->data; - - if (state == preset->state && - !tp_strdiff (status, preset->status)) { - return; - } - } - - preset = status_preset_new (state, status); - presets = g_list_prepend (presets, preset); - - num = 0; - for (l = presets; l; l = l->next) { - preset = l->data; - - if (state != preset->state) { - continue; - } - - num++; - - if (num > STATUS_PRESETS_MAX_EACH) { - status_preset_free (preset); - presets = g_list_delete_link (presets, l); - break; - } - } - - status_presets_file_save (); -} - -void -empathy_status_presets_remove (McPresence state, - const gchar *status) -{ - StatusPreset *preset; - GList *l; - - for (l = presets; l; l = l->next) { - preset = l->data; - - if (state == preset->state && - !tp_strdiff (status, preset->status)) { - status_preset_free (preset); - presets = g_list_delete_link (presets, l); - status_presets_file_save (); - break; - } - } -} - -void -empathy_status_presets_reset (void) -{ - g_list_foreach (presets, (GFunc) status_preset_free, NULL); - g_list_free (presets); - - presets = NULL; - - status_presets_set_default (MC_PRESENCE_AVAILABLE, NULL); - - status_presets_file_save (); -} - -McPresence -empathy_status_presets_get_default_state (void) -{ - if (!default_preset) { - return MC_PRESENCE_OFFLINE; - } - - return default_preset->state; -} - -const gchar * -empathy_status_presets_get_default_status (void) -{ - if (!default_preset || - !default_preset->status) { - return NULL; - } - - return default_preset->status; -} - -static void -status_presets_set_default (McPresence state, - const gchar *status) -{ - if (default_preset) { - status_preset_free (default_preset); - } - - default_preset = status_preset_new (state, status); -} - -void -empathy_status_presets_set_default (McPresence state, - const gchar *status) -{ - status_presets_set_default (state, status); - status_presets_file_save (); -} - -void -empathy_status_presets_clear_default (void) -{ - if (default_preset) { - status_preset_free (default_preset); - default_preset = NULL; - } - - status_presets_file_save (); -} diff --git a/libempathy-gtk/empathy-status-presets.dtd b/libempathy-gtk/empathy-status-presets.dtd deleted file mode 100644 index 872be6b4e..000000000 --- a/libempathy-gtk/empathy-status-presets.dtd +++ /dev/null @@ -1,14 +0,0 @@ -<!-- - DTD for Empathys status presets. - by Martyn Russell <martyn@imendio.com> ---> - -<!-- Root element. --> -<!ELEMENT presets ((default?),status*)> - -<!ELEMENT default (#PCDATA)> -<!ATTLIST default presence CDATA #REQUIRED> - -<!ELEMENT status (#PCDATA)> -<!ATTLIST status presence CDATA #REQUIRED> - diff --git a/libempathy-gtk/empathy-status-presets.h b/libempathy-gtk/empathy-status-presets.h deleted file mode 100644 index 8a4564f00..000000000 --- a/libempathy-gtk/empathy-status-presets.h +++ /dev/null @@ -1,46 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * Copyright (C) 2005-2007 Imendio AB - * - * 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. - * - * Author: Martyn Russell <martyn@imendio.com> - */ - -#ifndef __EMPATHY_STATUS_PRESETS_H__ -#define __EMPATHY_STATUS_PRESETS_H__ - -#include <libempathy/empathy-presence.h> - -G_BEGIN_DECLS - -void empathy_status_presets_get_all (void); -GList * empathy_status_presets_get (McPresence state, - gint max_number); -void empathy_status_presets_set_last (McPresence state, - const gchar *status); -void empathy_status_presets_remove (McPresence state, - const gchar *status); -void empathy_status_presets_reset (void); -McPresence empathy_status_presets_get_default_state (void); -const gchar * empathy_status_presets_get_default_status (void); -void empathy_status_presets_set_default (McPresence state, - const gchar *status); -void empathy_status_presets_clear_default (void); - -G_END_DECLS - -#endif /* __EMPATHY_STATUS_PRESETS_H__ */ diff --git a/libempathy-gtk/empathy-theme-boxes.c b/libempathy-gtk/empathy-theme-boxes.c index 87eac87d5..30ae59f30 100644 --- a/libempathy-gtk/empathy-theme-boxes.c +++ b/libempathy-gtk/empathy-theme-boxes.c @@ -559,16 +559,16 @@ theme_boxes_maybe_append_header (EmpathyTheme *theme, /* Only insert a header if the previously inserted block is not the same * as this one. This catches all the different cases: */ - if (empathy_chat_view_get_last_block_type (view) != BLOCK_TYPE_SELF && - empathy_chat_view_get_last_block_type (view) != BLOCK_TYPE_OTHER) { + if (empathy_chat_view_get_last_block_type (view) != EMPATHY_CHAT_VIEW_BLOCK_SELF && + empathy_chat_view_get_last_block_type (view) != EMPATHY_CHAT_VIEW_BLOCK_OTHER) { header = TRUE; } else if (from_self && - empathy_chat_view_get_last_block_type (view) == BLOCK_TYPE_OTHER) { + empathy_chat_view_get_last_block_type (view) == EMPATHY_CHAT_VIEW_BLOCK_OTHER) { header = TRUE; } else if (!from_self && - empathy_chat_view_get_last_block_type (view) == BLOCK_TYPE_SELF) { + empathy_chat_view_get_last_block_type (view) == EMPATHY_CHAT_VIEW_BLOCK_SELF) { header = TRUE; } else if (!from_self && @@ -710,10 +710,10 @@ theme_boxes_append_message (EmpathyTheme *theme, } if (empathy_contact_is_user (sender)) { - empathy_chat_view_set_last_block_type (view, BLOCK_TYPE_SELF); + empathy_chat_view_set_last_block_type (view, EMPATHY_CHAT_VIEW_BLOCK_SELF); empathy_chat_view_set_last_contact (view, NULL); } else { - empathy_chat_view_set_last_block_type (view, BLOCK_TYPE_OTHER); + empathy_chat_view_set_last_block_type (view, EMPATHY_CHAT_VIEW_BLOCK_OTHER); empathy_chat_view_set_last_contact (view, sender); } } @@ -741,7 +741,7 @@ theme_boxes_append_event (EmpathyTheme *theme, NULL); g_free (msg); - empathy_chat_view_set_last_block_type (view, BLOCK_TYPE_EVENT); + empathy_chat_view_set_last_block_type (view, EMPATHY_CHAT_VIEW_BLOCK_EVENT); } static void @@ -804,7 +804,7 @@ theme_boxes_append_timestamp (EmpathyTheme *theme, "fancy-time", NULL); - empathy_chat_view_set_last_block_type (view, BLOCK_TYPE_TIME); + empathy_chat_view_set_last_block_type (view, EMPATHY_CHAT_VIEW_BLOCK_TIME); empathy_chat_view_set_last_timestamp (view, timestamp); } diff --git a/libempathy-gtk/empathy-theme-manager.c b/libempathy-gtk/empathy-theme-manager.c index 6bece7506..94276c964 100644 --- a/libempathy-gtk/empathy-theme-manager.c +++ b/libempathy-gtk/empathy-theme-manager.c @@ -26,9 +26,9 @@ #include <gtk/gtk.h> #include <libempathy/empathy-utils.h> -#include <libempathy/empathy-conf.h> #include "empathy-chat-view.h" +#include "empathy-conf.h" #include "empathy-preferences.h" #include "empathy-theme.h" #include "empathy-theme-boxes.h" diff --git a/libempathy-gtk/empathy-theme.c b/libempathy-gtk/empathy-theme.c index 1895b8ccb..c8a9a0d48 100644 --- a/libempathy-gtk/empathy-theme.c +++ b/libempathy-gtk/empathy-theme.c @@ -24,12 +24,12 @@ #include <glib/gi18n.h> #include <gtk/gtk.h> -#include <libempathy/empathy-conf.h> #include <libempathy/empathy-debug.h> #include <libempathy/empathy-utils.h> #include <libempathy/empathy-marshal.h> #include "empathy-chat.h" +#include "empathy-conf.h" #include "empathy-preferences.h" #include "empathy-theme.h" #include "empathy-smiley-manager.h" diff --git a/libempathy-gtk/empathy-ui-utils.c b/libempathy-gtk/empathy-ui-utils.c index 2989ce2ac..0b29232bc 100644 --- a/libempathy-gtk/empathy-ui-utils.c +++ b/libempathy-gtk/empathy-ui-utils.c @@ -28,6 +28,8 @@ * Jeroen Zwartepoorte */ +#include <config.h> + #include <string.h> #include <X11/Xatom.h> #include <gdk/gdkx.h> @@ -63,7 +65,13 @@ get_glade_file (const gchar *filename, const char *name; GtkWidget **widget_ptr; - path = g_build_filename (DATADIR, "empathy", filename, NULL); + path = g_build_filename (UNINSTALLED_GLADE_DIR, filename, NULL); + if (!g_file_test (path, G_FILE_TEST_EXISTS)) { + g_free (path); + path = g_build_filename (DATADIR, "empathy", filename, NULL); + } + empathy_debug (DEBUG_DOMAIN, "Loading glade file %s", path); + gui = glade_xml_new (path, root, domain); g_free (path); @@ -212,9 +220,9 @@ empathy_icon_name_from_account (McAccount *account) } const gchar * -empathy_icon_name_for_presence_state (McPresence state) +empathy_icon_name_for_presence (McPresence presence) { - switch (state) { + switch (presence) { case MC_PRESENCE_AVAILABLE: return EMPATHY_IMAGE_AVAILABLE; case MC_PRESENCE_DO_NOT_DISTURB: @@ -236,32 +244,15 @@ empathy_icon_name_for_presence_state (McPresence state) } const gchar * -empathy_icon_name_for_presence (EmpathyPresence *presence) -{ - McPresence state; - - g_return_val_if_fail (EMPATHY_IS_PRESENCE (presence), - EMPATHY_IMAGE_OFFLINE); - - state = empathy_presence_get_state (presence); - - return empathy_icon_name_for_presence_state (state); -} - -const gchar * empathy_icon_name_for_contact (EmpathyContact *contact) { - EmpathyPresence *presence; + McPresence presence; g_return_val_if_fail (EMPATHY_IS_CONTACT (contact), EMPATHY_IMAGE_OFFLINE); presence = empathy_contact_get_presence (contact); - if (presence) { - return empathy_icon_name_for_presence (presence); - } - - return EMPATHY_IMAGE_UNKNOWN; + return empathy_icon_name_for_presence (presence); } GdkPixbuf * diff --git a/libempathy-gtk/empathy-ui-utils.h b/libempathy-gtk/empathy-ui-utils.h index fd1f7c633..1fb29a97d 100644 --- a/libempathy-gtk/empathy-ui-utils.h +++ b/libempathy-gtk/empathy-ui-utils.h @@ -37,7 +37,6 @@ #include <libmissioncontrol/mc-account.h> #include <libmissioncontrol/mc-profile.h> -#include <libempathy/empathy-presence.h> #include <libempathy/empathy-contact.h> #include <libempathy/empathy-avatar.h> @@ -68,8 +67,7 @@ void empathy_glade_setup_size_group (GladeXML *gui, ...); /* Pixbufs */ const gchar * empathy_icon_name_from_account (McAccount *account); -const gchar * empathy_icon_name_for_presence_state (McPresence state); -const gchar * empathy_icon_name_for_presence (EmpathyPresence *presence); +const gchar * empathy_icon_name_for_presence (McPresence presence); const gchar * empathy_icon_name_for_contact (EmpathyContact *contact); GdkPixbuf * empathy_pixbuf_from_data (gchar *data, gsize data_size); |