*
* You should have received a copy of the GNU General Public
* License along with this library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
+ * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
+ * Boston, MA 02110-1301 USA
*
* Authors: Based on Novell's e-image-chooser.
* Xavier Claessens <xclaesse@gmail.com>
guint max_width = 0, max_height = 0, max_size = 0;
gchar **mime_types = NULL;
gboolean needs_conversion = FALSE;
- gint width, height;
+ guint width, height;
gchar *new_format_name = NULL;
gchar *new_mime_type = NULL;
gdouble min_factor, max_factor;
/* If there is no format we can use, report error to the user. */
if (new_mime_type == NULL || new_format_name == NULL) {
avatar_chooser_error_show (chooser, _("Couldn't convert image"),
- _("None of the accepted image formats is "
+ _("None of the accepted image formats are "
"supported on your system"));
return NULL;
}
* a difference of 1k.
*/
} while (min_factor != max_factor &&
- ABS (max_size - converted_image_size) > 1024);
+ abs (max_size - converted_image_size) > 1024);
g_free (new_format_name);
/* Takes ownership of new_mime_type and converted_image_data */
- avatar = empathy_avatar_new (converted_image_data,
- converted_image_size, new_mime_type, NULL);
+ avatar = empathy_avatar_new ((guchar *) converted_image_data,
+ converted_image_size, new_mime_type, NULL, NULL);
return avatar;
}
pixbuf = empathy_pixbuf_from_data_and_mime (data, size, &mime_type);
if (pixbuf == NULL) {
g_free (data);
+ data = NULL;
return;
}
/* avatar takes ownership of data and mime_type */
- avatar = empathy_avatar_new (data, size, mime_type, NULL);
+ avatar = empathy_avatar_new ((guchar *) data, size, mime_type, NULL, NULL);
avatar_chooser_set_image (chooser, avatar, pixbuf, set_locally);
}
g_assert (avatar != NULL);
- pixbuf = empathy_pixbuf_from_data_and_mime (avatar->data,
+ pixbuf = empathy_pixbuf_from_data_and_mime ((gchar *) avatar->data,
avatar->len,
&mime_type);
if (pixbuf == NULL) {
GdkDragContext *context,
gint x,
gint y,
- guint time,
+ guint time_,
EmpathyAvatarChooser *chooser)
{
EmpathyAvatarChooserPriv *priv;
if (!strcmp (possible_type, URI_LIST_TYPE)) {
g_free (possible_type);
- gdk_drag_status (context, GDK_ACTION_COPY, time);
+ gdk_drag_status (context, GDK_ACTION_COPY, time_);
return TRUE;
}
static void
avatar_chooser_drag_leave_cb (GtkWidget *widget,
GdkDragContext *context,
- guint time,
+ guint time_,
EmpathyAvatarChooser *chooser)
{
}
GdkDragContext *context,
gint x,
gint y,
- guint time,
+ guint time_,
EmpathyAvatarChooser *chooser)
{
EmpathyAvatarChooserPriv *priv;
g_free (possible_type);
gtk_drag_get_data (widget, context,
GDK_POINTER_TO_ATOM (p->data),
- time);
+ time_);
return TRUE;
}
gint y,
GtkSelectionData *selection_data,
guint info,
- guint time,
+ guint time_,
EmpathyAvatarChooser *chooser)
{
gchar *target_type;
gboolean handled = FALSE;
- target_type = gdk_atom_name (selection_data->target);
+ target_type = gdk_atom_name (gtk_selection_data_get_target (selection_data));
if (!strcmp (target_type, URI_LIST_TYPE)) {
GFile *file;
- GFileInputStream *input_stream;
gchar *nl;
gchar *data = NULL;
+ gsize bytes_read;
- nl = strstr (selection_data->data, "\r\n");
+ nl = strstr ((gchar *) gtk_selection_data_get_data (selection_data),
+ "\r\n");
if (nl) {
gchar *uri;
- uri = g_strndup (selection_data->data,
- nl - (gchar*) selection_data->data);
+ uri = g_strndup ((gchar *) gtk_selection_data_get_data (selection_data),
+ nl - (gchar *) gtk_selection_data_get_data (selection_data));
file = g_file_new_for_uri (uri);
g_free (uri);
} else {
- file = g_file_new_for_uri (selection_data->data);
+ file = g_file_new_for_uri ((gchar *) gtk_selection_data_get_data (
+ selection_data));
}
- input_stream = g_file_read (file, NULL, NULL);
-
- if (input_stream != NULL) {
- GFileInfo *info;
-
- info = g_file_query_info (file,
- G_FILE_ATTRIBUTE_STANDARD_SIZE,
- 0, NULL, NULL);
- if (info != NULL) {
- goffset size;
- gssize bytes_read;
-
- size = g_file_info_get_size (info);
- data = g_malloc (size);
-
- bytes_read = g_input_stream_read (G_INPUT_STREAM (input_stream),
- data, size,
- NULL, NULL);
- if (bytes_read != -1) {
- avatar_chooser_set_image_from_data (
- chooser, data,
- (gsize) bytes_read,
- TRUE);
- handled = TRUE;
- }
-
- g_free (data);
- g_object_unref (info);
- }
+ handled = g_file_load_contents (file, NULL, &data, &bytes_read,
+ NULL, NULL);
- g_object_unref (input_stream);
+ if (handled) {
+ /* this in turn calls empathy_avatar_new (), which assumes
+ * ownership of data.
+ */
+ avatar_chooser_set_image_from_data (chooser, data,
+ bytes_read,
+ TRUE);
}
-
+
g_object_unref (file);
}
- gtk_drag_finish (context, handled, FALSE, time);
+ gtk_drag_finish (context, handled, FALSE, time_);
}
static void
gtk_file_chooser_add_filter (chooser_dialog, filter);
filter = gtk_file_filter_new ();
gtk_file_filter_set_name (filter, _("All Files"));
- gtk_file_filter_add_pattern(filter, "*");
+ gtk_file_filter_add_pattern (filter, "*");
gtk_file_chooser_add_filter (chooser_dialog, filter);
/* Setup response */
if (priv->avatar != NULL) {
if (data != NULL) {
- *data = priv->avatar->data;
+ *data = (gchar *) priv->avatar->data;
}
if (data_size != NULL) {
*data_size = priv->avatar->len;