[Buoh-dev] Parche para guardar un comic como jpeg
- From: carlosgc at gnome.org (Carlos Garcia Campos)
- Subject: [Buoh-dev] Parche para guardar un comic como jpeg
- Date: Tue Aug 15 09:42:46 2006
El mi?, 17-08-2005 a las 14:55 +0200, Esteban S?nchez escribi?:
>
> static void
> +buoh_window_menu_save_cb (GtkMenuItem *menuitem, gpointer gdata)
> +{
> + GtkWidget *chooser;
> + GtkFileFilter *filter;
> + gchar *suggested;
> + gchar *name;
> + gchar *page;
> + gchar *filename = NULL;
> + static gchar *folder;
debe estar inicializado a NULL (comentado en correo anterior)
> + BuohWindow *window = BUOH_WINDOW (gdata);
> + BuohComic *comic;
> + GdkPixbuf *pixbuf;
> + GtkWidget *dialog;
> + gboolean successful;
> + GError *error;
> +
> + filter = gtk_file_filter_new ();
> + gtk_file_filter_add_pattern (filter, "*.jpg");
> + gtk_file_filter_add_pattern (filter, "*.jpeg");
> + gtk_file_filter_set_name (filter, _("JPEG Images"));
> +
> + chooser = gtk_file_chooser_dialog_new (_("Save comic"),
> + GTK_WINDOW (window),
> +
> GTK_FILE_CHOOSER_ACTION_SAVE,
> + GTK_STOCK_CANCEL,
> GTK_RESPONSE_CANCEL,
> + GTK_STOCK_SAVE,
> GTK_RESPONSE_ACCEPT,
> + NULL);
> + gtk_file_chooser_set_do_overwrite_confirmation
> (GTK_FILE_CHOOSER (chooser), TRUE);
> + gtk_file_chooser_add_filter (GTK_FILE_CHOOSER (chooser),
> filter);
> +
> + if (folder) {
> + gtk_file_chooser_set_current_folder_uri
> (GTK_FILE_CHOOSER (chooser),
> + folder);
> + }
> +
> + comic = buoh_view_get_comic (window->priv->view);
> + name = buoh_comic_get_title (comic);
> + page = buoh_comic_get_page (comic);
> + suggested = g_strconcat (name, " (", page, ").jpeg", NULL);
> +
> + gtk_file_chooser_set_current_name (GTK_FILE_CHOOSER (chooser),
> + suggested);
> + do {
> + if (gtk_dialog_run (GTK_DIALOG (chooser)) ==
> GTK_RESPONSE_ACCEPT) {
> + pixbuf = buoh_comic_get_pixbuf (comic);
s?calo fuera del bucle, no necesitamos volver a pedir el pixbuf en cada
vuelta (comentado en correo anterior)
> + filename = gtk_file_chooser_get_filename
> (GTK_FILE_CHOOSER (chooser));
> +
> + if (folder != NULL)
> + g_free (folder);
> +
> + folder =
> gtk_file_chooser_get_current_folder_uri (GTK_FILE_CHOOSER (chooser));
> +
> + error = NULL;
> +
> + if (!gdk_pixbuf_save (pixbuf, filename,
> "jpeg", &error, NULL)) {
por que no png?
> + successful = FALSE;
> +
> + dialog = gtk_message_dialog_new
> (GTK_WINDOW (chooser),
> +
> GTK_DIALOG_MODAL|GTK_DIALOG_DESTROY_WITH_PARENT,
> +
> GTK_MESSAGE_ERROR,
> +
> GTK_BUTTONS_CLOSE,
> +
> _("Unable to save comic"));
> +
> + gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog),
> +
> error->message);
> + gtk_dialog_run (GTK_DIALOG (dialog));
> +
> + gtk_widget_destroy (dialog);
> + g_error_free (error);
> + } else
aunque sea una sola l?nea pon llaves aqu?. El c?digo es mas legible y
menos confuso
> + successful = TRUE;
> + g_free (filename);
> + } else
idem
> + successful = TRUE;
> + } while (!successful);
> +
> + g_free (name);
> + g_free (page);
> + g_free (suggested);
> + gtk_widget_destroy (chooser);
> +}
> +
> +static void
> buoh_window_menu_properties_cb (GtkMenuItem *menuitem, gpointer
> gdata)
> {
> BuohWindow *window = BUOH_WINDOW (gdata);
> @@ -556,6 +645,7 @@ buoh_window_comic_actions_set_sensitive
> buoh_window_zoom_out_set_sensitive (window, sensitive);
> buoh_window_normal_size_set_sensitive (window, sensitive);
> buoh_window_set_sensitive (window, "menu_properties",
> sensitive);
> + buoh_window_set_sensitive (window, "menu_save", sensitive);
> }
>
> static void
Salu2
--
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Carlos Garcia Campos a.k.a. KaL
elkalmail yahoo es
carlosgc gnome org
http://carlosgc.linups.org
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
PGP key: http://pgp.mit.edu:11371/pks/lookup?op=get&search=0x523E6462
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part
Url : http://forge.novell.com/pipermail/buoh-dev/attachments/20050817/f50edd1a/attachment.pgp
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]