[evince/wip/gpoo/204-annot-square-and-circle: 22/22] shell: Add square and circle annotations



commit 83fbbb7c92299128a17a2911b5d3d58b115cadde
Author: Anuj Khare <khareanuj18 gmail com>
Date:   Fri Jul 25 16:12:40 2014 +0200

    shell: Add square and circle annotations
    
    Adds the interior color property of the circle and square annotations
    to the properties dialog.
    
    Extends fix for #204

 shell/ev-annotation-properties-dialog.c | 82 ++++++++++++++++++++++++++++++++-
 shell/ev-annotation-properties-dialog.h |  3 ++
 shell/ev-window.c                       | 32 +++++++++++++
 3 files changed, 116 insertions(+), 1 deletion(-)
---
diff --git a/shell/ev-annotation-properties-dialog.c b/shell/ev-annotation-properties-dialog.c
index 99d19553..0f54cab7 100644
--- a/shell/ev-annotation-properties-dialog.c
+++ b/shell/ev-annotation-properties-dialog.c
@@ -47,6 +47,10 @@ struct _EvAnnotationPropertiesDialog {
 
         /* Text Markup Annotations */
         GtkWidget       *text_markup_type;
+
+        /* Square/Circle Annotations */
+        GtkWidget       *has_interior_color;
+        GtkWidget       *interior_color;
 };
 
 struct _EvAnnotationPropertiesDialogClass {
@@ -85,6 +89,13 @@ ev_annotation_properties_dialog_set_property (GObject      *object,
        }
 }
 
+static void
+ev_annotation_properties_has_interior_color_button_toggled (GtkToggleButton *button,
+                                                            GtkWidget       *interior_color_button)
+{
+        gtk_widget_set_sensitive (interior_color_button, gtk_toggle_button_get_active (button));
+}
+
 static void
 ev_annotation_properties_dialog_constructed (GObject *object)
 {
@@ -135,6 +146,34 @@ ev_annotation_properties_dialog_constructed (GObject *object)
                 gtk_widget_set_hexpand (dialog->text_markup_type, TRUE);
                 gtk_widget_show (dialog->text_markup_type);
                 break;
+        case EV_ANNOTATION_TYPE_CIRCLE:
+        case EV_ANNOTATION_TYPE_SQUARE:
+                /* Has Interior color toggle */
+                label = gtk_label_new (_("Has Interior Color:"));
+                gtk_misc_set_alignment (GTK_MISC (label), 0., 0.5);
+                gtk_grid_attach (GTK_GRID (grid), label, 0, 5, 1, 1);
+                gtk_widget_show (label);
+
+                dialog->has_interior_color = gtk_check_button_new ();
+                gtk_grid_attach (GTK_GRID (grid), dialog->has_interior_color, 1, 5, 1, 1);
+                gtk_widget_set_hexpand (dialog->has_interior_color, TRUE);
+                gtk_widget_show (dialog->has_interior_color);
+
+                /* Interior color chooser */
+                label = gtk_label_new (_("Interior Color:"));
+                gtk_misc_set_alignment (GTK_MISC (label), 0., 0.5);
+                gtk_grid_attach (GTK_GRID (grid), label, 0, 6, 1, 1);
+                gtk_widget_show (label);
+
+                dialog->interior_color = gtk_color_button_new ();
+                gtk_grid_attach (GTK_GRID (grid), dialog->interior_color, 1, 6, 1, 1);
+                gtk_widget_set_hexpand (dialog->interior_color, TRUE);
+                gtk_widget_show (dialog->interior_color);
+
+                g_signal_connect (GTK_TOGGLE_BUTTON (dialog->has_interior_color), "toggled",
+                                  G_CALLBACK (ev_annotation_properties_has_interior_color_button_toggled),
+                                  dialog->interior_color);
+                break;
        default:
                break;
        }
@@ -274,13 +313,41 @@ ev_annotation_properties_dialog_new_with_annotation (EvAnnotation *annot)
 
                gtk_combo_box_set_active (GTK_COMBO_BOX (dialog->icon),
                                          ev_annotation_text_get_icon (annot_text));
-       } else if (EV_IS_ANNOTATION_TEXT_MARKUP (annot)) {
+       }
+
+       if (EV_IS_ANNOTATION_TEXT_MARKUP (annot)) {
                 EvAnnotationTextMarkup *annot_markup = EV_ANNOTATION_TEXT_MARKUP (annot);
 
                 gtk_combo_box_set_active (GTK_COMBO_BOX (dialog->text_markup_type),
                                           ev_annotation_text_markup_get_markup_type (annot_markup));
         }
 
+        if (EV_IS_ANNOTATION_CIRCLE (annot)) {
+                EvAnnotationCircle *annot_circle;
+                GdkRGBA             interior_rgba;
+
+                annot_circle = EV_ANNOTATION_CIRCLE (annot);
+                ev_annotation_circle_get_interior_rgba (annot_circle, &interior_rgba);
+                gtk_color_chooser_set_rgba (GTK_COLOR_CHOOSER (dialog->interior_color), &interior_rgba);
+                gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (dialog->has_interior_color),
+                                              ev_annotation_circle_get_has_interior_color (annot_circle));
+                gtk_widget_set_sensitive (dialog->interior_color,
+                                          gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON 
(dialog->has_interior_color)));
+        }
+
+        if (EV_IS_ANNOTATION_SQUARE (annot)) {
+                EvAnnotationSquare *annot_square;
+                GdkRGBA             interior_rgba;
+
+                annot_square = EV_ANNOTATION_SQUARE (annot);
+                ev_annotation_square_get_interior_rgba (annot_square, &interior_rgba);
+                gtk_color_chooser_set_rgba (GTK_COLOR_CHOOSER (dialog->interior_color), &interior_rgba);
+                gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (dialog->has_interior_color),
+                                              ev_annotation_square_get_has_interior_color (annot_square));
+                gtk_widget_set_sensitive (dialog->interior_color,
+                                          gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON 
(dialog->has_interior_color)));
+        }
+
        return GTK_WIDGET (dialog);
 }
 
@@ -320,3 +387,16 @@ ev_annotation_properties_dialog_get_text_markup_type (EvAnnotationPropertiesDial
 {
         return gtk_combo_box_get_active (GTK_COMBO_BOX (dialog->text_markup_type));
 }
+
+void
+ev_annotation_properties_dialog_get_interior_rgba (EvAnnotationPropertiesDialog *dialog,
+                                                  GdkRGBA                      *rgba)
+{
+       gtk_color_chooser_get_rgba (GTK_COLOR_CHOOSER (dialog->interior_color), rgba);
+}
+
+gboolean
+ev_annotation_properties_dialog_get_has_interior_color (EvAnnotationPropertiesDialog *dialog)
+{
+        return gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (dialog->has_interior_color));
+}
diff --git a/shell/ev-annotation-properties-dialog.h b/shell/ev-annotation-properties-dialog.h
index acd55bd8..4169b682 100644
--- a/shell/ev-annotation-properties-dialog.h
+++ b/shell/ev-annotation-properties-dialog.h
@@ -49,6 +49,9 @@ gdouble                    ev_annotation_properties_dialog_get_opacity
 gboolean                   ev_annotation_properties_dialog_get_popup_is_open    
(EvAnnotationPropertiesDialog *dialog);
 EvAnnotationTextIcon       ev_annotation_properties_dialog_get_text_icon        
(EvAnnotationPropertiesDialog *dialog);
 EvAnnotationTextMarkupType ev_annotation_properties_dialog_get_text_markup_type 
(EvAnnotationPropertiesDialog *dialog);
+void                       ev_annotation_properties_dialog_get_interior_rgba    
(EvAnnotationPropertiesDialog *dialog,
+                                                                                 GdkRGBA                     
 *rgba);
+gboolean                   ev_annotation_properties_dialog_get_has_interior_color 
(EvAnnotationPropertiesDialog *dialog);
 
 G_END_DECLS
 
diff --git a/shell/ev-window.c b/shell/ev-window.c
index 3a7d05b8..1168d7af 100644
--- a/shell/ev-window.c
+++ b/shell/ev-window.c
@@ -7061,6 +7061,38 @@ ev_window_popup_cmd_annot_properties (GSimpleAction *action,
                        mask |= EV_ANNOTATIONS_SAVE_TEXT_MARKUP_TYPE;
        }
 
+        if (EV_IS_ANNOTATION_SQUARE (annot)) {
+                EvAnnotationSquare *annot_square;
+                GdkRGBA             interior_rgba;
+                gboolean            has_interior_color;
+
+                ev_annotation_properties_dialog_get_interior_rgba (dialog, &interior_rgba);
+                has_interior_color = ev_annotation_properties_dialog_get_has_interior_color (dialog);
+
+                annot_square = EV_ANNOTATION_SQUARE (annot);
+                if (ev_annotation_square_set_has_interior_color (annot_square, has_interior_color)) {
+                        mask |= EV_ANNOTATIONS_SAVE_INTERIOR_COLOR;
+        }
+                if (ev_annotation_square_set_interior_rgba (annot_square, &interior_rgba))
+                        mask |= EV_ANNOTATIONS_SAVE_INTERIOR_COLOR;
+        }
+
+        if (EV_IS_ANNOTATION_CIRCLE (annot)) {
+                EvAnnotationCircle *annot_circle;
+                GdkRGBA             interior_rgba;
+                gboolean            has_interior_color;
+
+                ev_annotation_properties_dialog_get_interior_rgba (dialog, &interior_rgba);
+                has_interior_color = ev_annotation_properties_dialog_get_has_interior_color (dialog);
+
+                annot_circle = EV_ANNOTATION_CIRCLE (annot);
+                if (ev_annotation_circle_set_has_interior_color (annot_circle, has_interior_color)) {
+                        mask |= EV_ANNOTATIONS_SAVE_INTERIOR_COLOR;
+        }
+                if (ev_annotation_circle_set_interior_rgba (annot_circle, &interior_rgba))
+                        mask |= EV_ANNOTATIONS_SAVE_INTERIOR_COLOR;
+        }
+
        if (mask != EV_ANNOTATIONS_SAVE_NONE) {
                ev_document_doc_mutex_lock ();
                ev_document_annotations_save_annotation (EV_DOCUMENT_ANNOTATIONS (priv->document),


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]