#include <string.h>
-#include <glib/gi18n.h>
+#include <glib/gi18n-lib.h>
#include <gtk/gtk.h>
#include <gio/gio.h>
EmpathyContactFactory *contact_factory;
McAccount *account;
EmpathyTpContactFactory *tp_contact_factory;
+ GtkFileChooser *chooser_dialog;
gulong ready_handler_id;
G_CALLBACK (avatar_chooser_clicked_cb),
chooser);
- priv->contact_factory = empathy_contact_factory_new ();
+ priv->contact_factory = empathy_contact_factory_dup_singleton ();
empathy_avatar_chooser_set (chooser, NULL);
}
{
EmpathyAvatarChooserPriv *priv = GET_PRIV (chooser);
EmpathyTpContactFactory *tp_cf = priv->tp_contact_factory;
- gint max_width = 0, max_height = 0, max_size = 0;
+ guint max_width = 0, max_height = 0, max_size = 0;
gchar **mime_types = NULL;
gboolean needs_conversion = FALSE;
gint width, height;
* try with a lower factor. */
if (max_size > 0 && avatar->len > max_size && !needs_conversion) {
DEBUG ("Image data (%"G_GSIZE_FORMAT" bytes) is too big "
- "(max is %"G_GSIZE_FORMAT" bytes), conversion needed.",
+ "(max is %u bytes), conversion needed.",
avatar->len, max_size);
factor = 0.5;
max_factor = factor;
if (converted_image_size < max_size)
min_factor = factor;
- factor = min_factor + (max_factor - min_factor)/2;
+ factor = (min_factor + max_factor)/2;
/* We are done if either:
* - min_factor == max_factor. That happens if we resized to
{
EmpathyAvatarChooserPriv *priv = GET_PRIV (chooser);
+ priv->chooser_dialog = NULL;
+
if (response == GTK_RESPONSE_CANCEL) {
goto out;
}
const gchar *default_dir = DEFAULT_DIR;
const gchar *pics_dir;
GtkFileFilter *filter;
+ EmpathyAvatarChooserPriv *priv = GET_PRIV (chooser);
+
+ if (priv->chooser_dialog) {
+ gtk_window_present (GTK_WINDOW (priv->chooser_dialog));
+ return;
+ }
- chooser_dialog = GTK_FILE_CHOOSER (
+ priv->chooser_dialog = GTK_FILE_CHOOSER (
gtk_file_chooser_dialog_new (_("Select Your Avatar Image"),
empathy_get_toplevel_window (GTK_WIDGET (chooser)),
GTK_FILE_CHOOSER_ACTION_OPEN,
GTK_STOCK_OPEN,
GTK_RESPONSE_OK,
NULL));
+ chooser_dialog = priv->chooser_dialog;
+ gtk_window_set_destroy_with_parent (GTK_WINDOW (chooser_dialog), TRUE);
/* Get special dirs */
empathy_conf_get_string (empathy_conf_get (),