Commit 0bec5c02 authored by Enrico Lumetti's avatar Enrico Lumetti

Address style issues

parent 35cc1780
......@@ -90,7 +90,7 @@ typedef struct {
GdkCursorType cursor;
guint annotations_idle;
GPtrArray *ink_annot_paths; // array of GArray of PopplerPoint
GPtrArray *ink_annot_paths; /* array of GArray of PopplerPoint */
GArray *current_ink_path;
gboolean single_path_per_annot;
} PgdAnnotsDemo;
......@@ -384,23 +384,24 @@ pgd_annots_start_add_annot (GtkWidget *button,
static void pgd_annots_done (PgdAnnotsDemo *demo);
static void
pgd_annots_start_toggle_annot (GtkWidget *button, PgdAnnotsDemo *demo)
pgd_annots_start_toggle_annot (GtkWidget *button,
PgdAnnotsDemo *demo)
{
switch (demo->mode)
{
case MODE_NORMAL: {
gtk_button_set_label(GTK_BUTTON(button), "Done");
gtk_widget_hide(demo->timer_label);
gtk_widget_show(demo->single_ink_path_check);
pgd_annots_start_add_annot(button, demo);
gtk_button_set_label (GTK_BUTTON (button), "Done");
gtk_widget_hide (demo->timer_label);
gtk_widget_show (demo->single_ink_path_check);
pgd_annots_start_add_annot (button, demo);
}
break;
case MODE_ADD: {
gtk_button_set_label(GTK_BUTTON(button), "Add");
gtk_widget_show(demo->timer_label);
gtk_widget_hide(demo->single_ink_path_check);
pgd_annots_done(demo);
gtk_button_set_label (GTK_BUTTON (button), "Add");
gtk_widget_show (demo->timer_label);
gtk_widget_hide (demo->single_ink_path_check);
pgd_annots_done (demo);
}
break;
......@@ -534,11 +535,13 @@ pgd_annot_view_set_annot_text_markup (GtkWidget *table,
}
static void
pgd_annot_view_set_annot_ink (GtkWidget *table, PopplerAnnotInk *annot, gint *row)
pgd_annot_view_set_annot_ink (GtkWidget *table,
PopplerAnnotInk *annot,
gint *row)
{
gchar* text = g_strdup_printf("%d", poppler_annot_ink_get_ink_list_size(annot));
gchar* text = g_strdup_printf ("%d", poppler_annot_ink_get_ink_list_size (annot));
pgd_table_add_property (GTK_GRID (table), "<b>InkList size:</b>", text, row);
g_free(text);
g_free (text);
}
......@@ -557,12 +560,12 @@ pgd_annot_view_set_annot_free_text (GtkWidget *table,
}
static void
pgd_single_ink_annot_changed(GtkToggleButton *button, PgdAnnotsDemo *demo)
pgd_single_ink_annot_changed (GtkToggleButton *button,
PgdAnnotsDemo *demo)
{
if (demo->mode != MODE_NORMAL) {
// don't change path saving mechanism while drawing
if (demo->mode != MODE_NORMAL)
/* don't change path saving mechanism while drawing */
return;
}
demo->single_path_per_annot = gtk_toggle_button_get_active(button);
}
......@@ -864,10 +867,9 @@ pgd_annots_selection_changed (GtkTreeSelection *treeselection,
pgd_annot_view_set_annot (demo, annot);
g_object_unref (annot);
// we don't want the remove button to be enabled while drawing
if (demo->mode == MODE_NORMAL) {
/* we don't want the remove button to be enabled while drawing */
if (demo->mode == MODE_NORMAL)
gtk_widget_set_sensitive (demo->remove_button, TRUE);
}
} else {
pgd_annot_view_set_annot (demo, NULL);
gtk_widget_set_sensitive (demo->remove_button, FALSE);
......@@ -1072,17 +1074,17 @@ pgd_annots_done (PgdAnnotsDemo *demo)
if (!demo->single_path_per_annot && demo->ink_annot_paths != NULL) {
guint n_paths = demo->ink_annot_paths->len;
for (guint i = 0; i < n_paths; i++) {
GArray* path_ptr = g_ptr_array_index(demo->ink_annot_paths, i);
g_array_free(path_ptr, TRUE);
GArray* path_ptr = g_ptr_array_index (demo->ink_annot_paths, i);
g_array_free (path_ptr, TRUE);
}
g_ptr_array_free(demo->ink_annot_paths, FALSE);
g_ptr_array_free (demo->ink_annot_paths, FALSE);
}
demo->current_ink_path = NULL;
demo->ink_annot_paths = NULL;
gtk_widget_set_sensitive(demo->remove_button, TRUE);
gtk_widget_set_sensitive(demo->single_ink_path_check, TRUE);
gtk_widget_set_sensitive (demo->remove_button, TRUE);
gtk_widget_set_sensitive (demo->single_ink_path_check, TRUE);
gtk_widget_hide (demo->single_ink_path_check);
gtk_label_set_text (GTK_LABEL (demo->timer_label), NULL);
......@@ -1096,7 +1098,7 @@ pgd_annots_register_annot (PgdAnnotsDemo *demo)
if (demo->annot_type == POPPLER_ANNOT_INK) {
if (demo->single_path_per_annot) {
g_array_free(demo->current_ink_path, TRUE);
g_array_free (demo->current_ink_path, TRUE);
demo->current_ink_path = NULL;
}
}
......@@ -1186,13 +1188,15 @@ pgd_annots_update_selected_text (PgdAnnotsDemo *demo)
}
static void
pgd_annot_update_ink_path (PgdAnnotsDemo *demo, gdouble x, gdouble y)
pgd_annot_update_ink_path (PgdAnnotsDemo *demo,
gdouble x,
gdouble y)
{
PopplerAnnotInk* annot = (PopplerAnnotInk*) demo->active_annot;
PopplerPoint p = { .x = (gdouble) x, .y = (gdouble) y };
g_array_append_val(demo->current_ink_path, p);
poppler_annot_ink_set_ink_list(annot, demo->ink_annot_paths);
g_array_append_val (demo->current_ink_path, p);
poppler_annot_ink_set_ink_list (POPPLER_ANNOT_INK (demo->active_annot), demo->ink_annot_paths);
}
/* Render area */
......@@ -1300,8 +1304,8 @@ pgd_annots_drawing_area_button_press (GtkWidget *area,
}
if (demo->annot_type == POPPLER_ANNOT_INK) {
demo->current_ink_path = g_array_new(FALSE, TRUE, sizeof(PopplerPoint));
g_ptr_array_add(demo->ink_annot_paths, demo->current_ink_path);
demo->current_ink_path = g_array_new (FALSE, TRUE, sizeof(PopplerPoint));
g_ptr_array_add (demo->ink_annot_paths, demo->current_ink_path);
}
pgd_annots_viewer_queue_redraw (demo);
......
......@@ -2141,28 +2141,30 @@ poppler_annot_square_set_interior_color (PopplerAnnotSquare *poppler_annot,
}
void
poppler_annot_ink_set_ink_list(PopplerAnnotInk* poppler_annot, const GPtrArray* poppler_paths)
poppler_annot_ink_set_ink_list (PopplerAnnotInk* poppler_annot,
const GPtrArray* poppler_paths)
{
g_return_if_fail (POPPLER_IS_ANNOT_INK (poppler_annot));
const guint paths_len = poppler_paths->len;
AnnotPath** paths = new AnnotPath*[paths_len];
for (guint i = 0; i < paths_len; i++) {
const GArray* coord_array = (GArray*) g_ptr_array_index(poppler_paths, i); // an array of PopplerPoint
const GArray* coord_array = (GArray*) g_ptr_array_index (poppler_paths, i); /* an array of PopplerPoint */
std::vector<AnnotCoord> coords;
coords.reserve(coord_array->len);
coords.reserve (coord_array->len);
for (guint j = 0; j < coord_array->len; j++) {
PopplerPoint* p = &g_array_index(coord_array, PopplerPoint, j);
coords.emplace_back(AnnotCoord{p->x, p->y});
PopplerPoint* p = &g_array_index (coord_array, PopplerPoint, j);
coords.emplace_back (AnnotCoord{p->x, p->y});
}
paths[i] = new AnnotPath{std::move(coords)};
paths[i] = new AnnotPath{std::move (coords)};
}
AnnotInk *annot = static_cast<AnnotInk*>(POPPLER_ANNOT (poppler_annot)->annot);
annot->setInkList(paths, paths_len);
annot->setInkList (paths, paths_len);
for (guint i = 0; i < paths_len; i++) {
delete paths[i];
......@@ -2171,10 +2173,11 @@ poppler_annot_ink_set_ink_list(PopplerAnnotInk* poppler_annot, const GPtrArray*
}
gint
poppler_annot_ink_get_ink_list_size(PopplerAnnotInk *poppler_annot)
poppler_annot_ink_get_ink_list_size (PopplerAnnotInk *poppler_annot)
{
g_return_val_if_fail (POPPLER_IS_ANNOT_INK (poppler_annot), -1);
AnnotInk* annot = static_cast<AnnotInk*>(POPPLER_ANNOT (poppler_annot)->annot);
AnnotInk* annot = static_cast<AnnotInk*> (POPPLER_ANNOT (poppler_annot)->annot);
return annot->getInkListLength();
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment