Commit 8489d5a5e51ed120b544ecf7a4e68aa2acaf70d4

Authored by Perry Werneck
1 parent c39d367d
Exists in master and in 1 other branch develop

Fixing save selection as image.

src/dialogs/save/save.c
@@ -440,7 +440,7 @@ static void icon_press(GtkEntry *entry, G_GNUC_UNUSED GtkEntryIconPosition icon_ @@ -440,7 +440,7 @@ static void icon_press(GtkEntry *entry, G_GNUC_UNUSED GtkEntryIconPosition icon_
440 GList * dynamic = NULL; 440 GList * dynamic = NULL;
441 const GList * selection = NULL; 441 const GList * selection = NULL;
442 442
443 - debug("%s",__FUNCTION__); 443 + debug("%s(%d)",__FUNCTION__,dialog->mode);
444 444
445 switch(dialog->mode) 445 switch(dialog->mode)
446 { 446 {
@@ -464,6 +464,8 @@ static void icon_press(GtkEntry *entry, G_GNUC_UNUSED GtkEntryIconPosition icon_ @@ -464,6 +464,8 @@ static void icon_press(GtkEntry *entry, G_GNUC_UNUSED GtkEntryIconPosition icon_
464 return; 464 return;
465 } 465 }
466 466
  467 + debug("Selection=%p",selection);
  468 +
467 if(!selection) 469 if(!selection)
468 { 470 {
469 *error = g_error_new(g_quark_from_static_string(PACKAGE_NAME),ENOTCONN,"%s",strerror(ENODATA)); 471 *error = g_error_new(g_quark_from_static_string(PACKAGE_NAME),ENOTCONN,"%s",strerror(ENODATA));
@@ -524,7 +526,7 @@ static void icon_press(GtkEntry *entry, G_GNUC_UNUSED GtkEntryIconPosition icon_ @@ -524,7 +526,7 @@ static void icon_press(GtkEntry *entry, G_GNUC_UNUSED GtkEntryIconPosition icon_
524 526
525 static void save_as_image(V3270SaveDialog * dialog, const gchar *format, GError **error) 527 static void save_as_image(V3270SaveDialog * dialog, const gchar *format, GError **error)
526 { 528 {
527 - debug("%s",__FUNCTION__); 529 + debug("%s(%d)",__FUNCTION__,dialog->mode);
528 530
529 GdkPixbuf * pixbuf = NULL; 531 GdkPixbuf * pixbuf = NULL;
530 532
@@ -547,6 +549,7 @@ static void icon_press(GtkEntry *entry, G_GNUC_UNUSED GtkEntryIconPosition icon_ @@ -547,6 +549,7 @@ static void icon_press(GtkEntry *entry, G_GNUC_UNUSED GtkEntryIconPosition icon_
547 { 549 {
548 debug("%s","LIB3270_CONTENT_SELECTED"); 550 debug("%s","LIB3270_CONTENT_SELECTED");
549 GList * selection = g_list_append_lib3270_selection(NULL, v3270_get_session(dialog->terminal),FALSE); 551 GList * selection = g_list_append_lib3270_selection(NULL, v3270_get_session(dialog->terminal),FALSE);
  552 + debug("Selection=%p",selection);
550 pixbuf = v3270_get_selection_as_pixbuf(GTK_V3270(dialog->terminal), selection, FALSE); 553 pixbuf = v3270_get_selection_as_pixbuf(GTK_V3270(dialog->terminal), selection, FALSE);
551 g_list_free_full(selection,(GDestroyNotify) lib3270_free); 554 g_list_free_full(selection,(GDestroyNotify) lib3270_free);
552 } 555 }
@@ -557,10 +560,13 @@ static void icon_press(GtkEntry *entry, G_GNUC_UNUSED GtkEntryIconPosition icon_ @@ -557,10 +560,13 @@ static void icon_press(GtkEntry *entry, G_GNUC_UNUSED GtkEntryIconPosition icon_
557 return; 560 return;
558 } 561 }
559 562
  563 + debug("pixbuff=%p",pixbuf);
  564 +
560 if(pixbuf) 565 if(pixbuf)
561 { 566 {
562 const gchar * filename = get_filename(dialog); 567 const gchar * filename = get_filename(dialog);
563 568
  569 + debug("Filename=%p",filename);
564 if(filename) 570 if(filename)
565 { 571 {
566 gdk_pixbuf_save(pixbuf,filename,format,error,NULL); 572 gdk_pixbuf_save(pixbuf,filename,format,error,NULL);
@@ -568,6 +574,10 @@ static void icon_press(GtkEntry *entry, G_GNUC_UNUSED GtkEntryIconPosition icon_ @@ -568,6 +574,10 @@ static void icon_press(GtkEntry *entry, G_GNUC_UNUSED GtkEntryIconPosition icon_
568 574
569 g_object_unref(pixbuf); 575 g_object_unref(pixbuf);
570 } 576 }
  577 + else
  578 + {
  579 + *error = g_error_new(g_quark_from_static_string(PACKAGE_NAME),-1,_( "Error saving image" ));
  580 + }
571 581
572 } 582 }
573 583
src/selection/pixbuf.c
@@ -57,6 +57,7 @@ GdkPixbuf * v3270_get_selection_as_pixbuf(v3270 * terminal, const GList *selecti @@ -57,6 +57,7 @@ GdkPixbuf * v3270_get_selection_as_pixbuf(v3270 * terminal, const GList *selecti
57 if(col > cols) 57 if(col > cols)
58 cols = col; 58 cols = col;
59 } 59 }
  60 + src++;
60 } 61 }
61 62
62 if(hasSelection) 63 if(hasSelection)
@@ -68,6 +69,8 @@ GdkPixbuf * v3270_get_selection_as_pixbuf(v3270 * terminal, const GList *selecti @@ -68,6 +69,8 @@ GdkPixbuf * v3270_get_selection_as_pixbuf(v3270 * terminal, const GList *selecti
68 69
69 } 70 }
70 71
  72 + debug("%s: rows=%d cols=%d",__FUNCTION__,rows,cols);
  73 +
71 if(!rows) 74 if(!rows)
72 return NULL; 75 return NULL;
73 76
@@ -76,6 +79,8 @@ GdkPixbuf * v3270_get_selection_as_pixbuf(v3270 * terminal, const GList *selecti @@ -76,6 +79,8 @@ GdkPixbuf * v3270_get_selection_as_pixbuf(v3270 * terminal, const GList *selecti
76 gint width = (cols+1) * terminal->font.width; 79 gint width = (cols+1) * terminal->font.width;
77 gint height = (rows+1) * terminal->font.spacing.value; 80 gint height = (rows+1) * terminal->font.spacing.value;
78 81
  82 + debug("%s: width=%d height=%d",__FUNCTION__,width,height);
  83 +
79 cairo_surface_t *surface = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, width, height); 84 cairo_surface_t *surface = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, width, height);
80 85
81 cairo_t *cr = cairo_create(surface); 86 cairo_t *cr = cairo_create(surface);
@@ -131,11 +136,11 @@ GdkPixbuf * v3270_get_selection_as_pixbuf(v3270 * terminal, const GList *selecti @@ -131,11 +136,11 @@ GdkPixbuf * v3270_get_selection_as_pixbuf(v3270 * terminal, const GList *selecti
131 } 136 }
132 } 137 }
133 138
134 - cairo_destroy (cr); 139 + cairo_destroy(cr);
135 140
136 GdkPixbuf * pixbuf = gdk_pixbuf_get_from_surface(surface,0,0,width,height); 141 GdkPixbuf * pixbuf = gdk_pixbuf_get_from_surface(surface,0,0,width,height);
137 142
138 - cairo_surface_destroy (surface); 143 + cairo_surface_destroy(surface);
139 144
140 return pixbuf; 145 return pixbuf;
141 146
src/terminal/actions/action.c
@@ -246,7 +246,7 @@ @@ -246,7 +246,7 @@
246 } 246 }
247 247
248 static gboolean bg_notify_enabled(GObject *action) { 248 static gboolean bg_notify_enabled(GObject *action) {
249 - debug("%s(%s,%s,%d)",__FUNCTION__,g_action_get_name(G_ACTION(action)),(g_action_get_enabled(G_ACTION(action)) ? "enabled" : "disabled"),(int) v3270_action_get_group(G_ACTION(action))); 249 +// debug("%s(%s,%s,%d)",__FUNCTION__,g_action_get_name(G_ACTION(action)),(g_action_get_enabled(G_ACTION(action)) ? "enabled" : "disabled"),(int) v3270_action_get_group(G_ACTION(action)));
250 g_object_notify(action, "enabled"); 250 g_object_notify(action, "enabled");
251 return FALSE; 251 return FALSE;
252 } 252 }