Bug 58015 - [PATCH] Add wrapper for Annot::setFlags
Summary: [PATCH] Add wrapper for Annot::setFlags
Status: RESOLVED FIXED
Alias: None
Product: poppler
Classification: Unclassified
Component: glib frontend (show other bugs)
Version: unspecified
Hardware: Other All
: medium normal
Assignee: poppler-bugs
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-12-08 13:35 UTC by Jose Aliste
Modified: 2012-12-08 19:31 UTC (History)
1 user (show)

See Also:
i915 platform:
i915 features:


Attachments
patch: add poppler_annot_set_flags (2.00 KB, patch)
2012-12-08 13:36 UTC, Jose Aliste
Details | Splinter Review
patch: update the demo (3.85 KB, patch)
2012-12-08 13:37 UTC, Jose Aliste
Details | Splinter Review
updated patch: add_poppler_annot_set_flags (2.09 KB, patch)
2012-12-08 16:25 UTC, Jose Aliste
Details | Splinter Review
updated patch: demo (4.00 KB, patch)
2012-12-08 18:10 UTC, Jose Aliste
Details | Splinter Review

Description Jose Aliste 2012-12-08 13:35:59 UTC

    
Comment 1 Jose Aliste 2012-12-08 13:36:57 UTC
Created attachment 71197 [details] [review]
patch: add poppler_annot_set_flags
Comment 2 Jose Aliste 2012-12-08 13:37:34 UTC
Created attachment 71198 [details] [review]
patch: update the demo
Comment 3 Albert Astals Cid 2012-12-08 14:17:33 UTC
This seems like a feature so unless you can convince me it's really a bugfix maybe we should wait for 0.24 since 0.22 is already in feature freeze
Comment 4 Jose Aliste 2012-12-08 14:33:54 UTC
This is new feature, yes, so it should wait until 0.24.
Comment 5 Carlos Garcia Campos 2012-12-08 16:12:05 UTC
Comment on attachment 71197 [details] [review]
patch: add poppler_annot_set_flags

Review of attachment 71197 [details] [review]:
-----------------------------------------------------------------

Patch looks good to me. Albert, the patch is simple and not risky, I think it can go in 0.22.

::: glib/poppler-annot.cc
@@ +513,5 @@
> + * @flags: a #PopplerAnnotFlag
> + *
> + * Sets the flag field specifying various characteristics of the
> + * @poppler_annot.
> + *

Please add a Since: tag here 0.22 or 0.24

@@ +520,5 @@
> +poppler_annot_set_flags (PopplerAnnot *poppler_annot, PopplerAnnotFlag flags)
> +{
> +  g_return_if_fail (POPPLER_IS_ANNOT (poppler_annot));
> +
> +  return poppler_annot->annot->setFlags ((guint) flags);

Remove the return, since the method is void. Also, add an early return if flags don't change, since Annot::setFlags doesn't check it and the xref will be updated and the document marked as modified.
Comment 6 Jose Aliste 2012-12-08 16:25:17 UTC
Created attachment 71205 [details] [review]
updated patch: add_poppler_annot_set_flags

Comments addressed. I added Since:0.22 tag in case Albert decides to get it into 0.22.
Comment 7 Albert Astals Cid 2012-12-08 16:36:36 UTC
Ok, if you want it in 0.22, put it in
Comment 8 Carlos Garcia Campos 2012-12-08 17:27:57 UTC
Comment on attachment 71198 [details] [review]
patch: update the demo

Review of attachment 71198 [details] [review]:
-----------------------------------------------------------------

Looks great, I have a just some minor comments

::: glib/demo/annots.c
@@ +694,5 @@
> +      case ANNOTS_FLAG_HIDDEN_COLUMN:
> +        flag_bit = POPPLER_ANNOT_FLAG_HIDDEN;
> +        break;
> +      default:
> +        flag_bit = POPPLER_ANNOT_FLAG_PRINT;

Instead of default, add the case ANNOTS_FLAG_PRINT_COLUMN: better, and add default: doing nothing or with g_assert_not_reached().

@@ +699,5 @@
> +        break;
> +    }
> +
> +    if (fixed)
> +        flags = flags | flag_bit;

This could be flags |= flag_bit no?

@@ +701,5 @@
> +
> +    if (fixed)
> +        flags = flags | flag_bit;
> +    else
> +        flags = flags & (~flag_bit);

And this flags &= ~flag_bit

@@ +941,4 @@
>                                                   NULL);
>  
>      renderer = gtk_cell_renderer_toggle_new ();
> +    g_signal_connect (G_OBJECT (renderer), "toggled",

g_signal_connect expects a gpointer so no need to cast to GObject.

@@ +965,5 @@
>      renderer = gtk_cell_renderer_toggle_new ();
> +    g_signal_connect (G_OBJECT (renderer), "toggled",
> +                      G_CALLBACK (pgd_annots_flags_toggled),
> +                      (gpointer) demo);
> +    g_object_set_data (G_OBJECT (renderer), "column", GINT_TO_POINTER (ANNOTS_FLAG_PRINT_COLUMN));

I think it would be simpler to add three different callbacks and call a custom method passing the column
Comment 9 Jose Aliste 2012-12-08 18:10:26 UTC
Created attachment 71213 [details] [review]
updated patch: demo

Comments addressed.
Comment 10 Carlos Garcia Campos 2012-12-08 19:31:59 UTC
Pushed both patches to git master, thanks!


Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.