From 1c744c5ac02fb2c0541e05f37ea753bd8ce087be Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pablo=20Correa=20G=C3=B3mez?= Date: Thu, 7 Nov 2024 17:44:48 +0100 Subject: [PATCH 1/2] shell: show annotations' color picker also for text annotations --- shell/pps-document-view.c | 31 ++++++++++--------------------- 1 file changed, 10 insertions(+), 21 deletions(-) diff --git a/shell/pps-document-view.c b/shell/pps-document-view.c index e18c5255f..7c84177e2 100644 --- a/shell/pps-document-view.c +++ b/shell/pps-document-view.c @@ -128,7 +128,6 @@ typedef struct GMenu *annot_menu; GtkWidget *annot_menu_child; - gboolean annot_menu_child_added; GSimpleActionGroup *document_action_group; @@ -279,10 +278,18 @@ pps_document_view_set_default_actions (PpsDocumentView *pps_doc_view) FALSE); } - if (!PPS_IS_DOCUMENT_ANNOTATIONS (document)) { + if (PPS_IS_DOCUMENT_ANNOTATIONS (document) && + pps_document_annotations_can_add_annotation (PPS_DOCUMENT_ANNOTATIONS (document))) { + g_autoptr (GMenuItem) item = g_menu_item_new (NULL, NULL); + g_menu_item_set_attribute (item, "custom", "s", "palette"); + g_menu_insert_item (priv->annot_menu, 0, item); + + gtk_popover_menu_add_child (GTK_POPOVER_MENU (priv->view_popup), + priv->annot_menu_child, "palette"); + } else { pps_document_view_set_action_enabled (pps_doc_view, "add-text-annotation", - pps_document_annotations_can_add_annotation (PPS_DOCUMENT_ANNOTATIONS (document))); + FALSE); } if (PPS_IS_DOCUMENT_SIGNATURES (document)) { @@ -649,24 +656,6 @@ view_selection_changed_cb (PpsView *view, pps_document_view_set_action_enabled (window, "add-highlight-annotation", can_annotate && has_selection); - - if (can_annotate && has_selection && !priv->annot_menu_child_added) { - g_autoptr (GMenuItem) item = g_menu_item_new (NULL, NULL); - - g_menu_item_set_attribute (item, "custom", "s", "palette"); - g_menu_insert_item (priv->annot_menu, 0, item); - - gtk_popover_menu_add_child (GTK_POPOVER_MENU (priv->view_popup), - priv->annot_menu_child, "palette"); - - priv->annot_menu_child_added = TRUE; - } - - if (!(can_annotate && has_selection) && priv->annot_menu_child_added) { - g_menu_remove_all (priv->annot_menu); - - priv->annot_menu_child_added = FALSE; - } } static void -- GitLab From 78372c046fc7629c9008afbb662d3d1f7a9fa354 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pablo=20Correa=20G=C3=B3mez?= Date: Thu, 7 Nov 2024 17:45:59 +0100 Subject: [PATCH 2/2] shell: add some more actions to be disabled by default This is a regression from previous cleanups --- shell/pps-document-view.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/shell/pps-document-view.c b/shell/pps-document-view.c index 7c84177e2..1750c4b39 100644 --- a/shell/pps-document-view.c +++ b/shell/pps-document-view.c @@ -4513,9 +4513,11 @@ pps_document_view_init (PpsDocumentView *pps_doc_view) pps_doc_view); gtk_widget_insert_action_group (GTK_WIDGET (pps_doc_view), "doc", G_ACTION_GROUP (priv->document_action_group)); - // These are only enabled once the search has started + // These are only enabled once the user takes action pps_document_view_set_action_enabled (pps_doc_view, "find-next", FALSE); pps_document_view_set_action_enabled (pps_doc_view, "find-previous", FALSE); + pps_document_view_set_action_enabled (pps_doc_view, "add-highlight-annotation", FALSE); + pps_document_view_set_action_enabled (pps_doc_view, "copy", FALSE); page_cache_mb = g_settings_get_uint (priv->settings, GS_PAGE_CACHE_SIZE); -- GitLab