From 3c2bf1aef96a7a94c58d9e99ac12a0d8cd788259 Mon Sep 17 00:00:00 2001 From: mbkma Date: Sun, 12 Apr 2020 14:48:20 +0200 Subject: add overview map --- pluma/dialogs/pluma-preferences-dialog.c | 9 ++++ pluma/dialogs/pluma-preferences-dialog.ui | 88 +++++++++++++++++++++++++++++-- pluma/dialogs/ui-a11y.suppr | 2 + pluma/pluma-settings.h | 1 + pluma/pluma-tab.c | 44 +++++++++++++++- 5 files changed, 139 insertions(+), 5 deletions(-) (limited to 'pluma') diff --git a/pluma/dialogs/pluma-preferences-dialog.c b/pluma/dialogs/pluma-preferences-dialog.c index 246388e7..4ba26378 100644 --- a/pluma/dialogs/pluma-preferences-dialog.c +++ b/pluma/dialogs/pluma-preferences-dialog.c @@ -130,6 +130,9 @@ struct _PlumaPreferencesDialogPrivate /* Highlight matching bracket */ GtkWidget *bracket_matching_checkbutton; + /* Display overview map */ + GtkWidget *display_overview_map_checkbutton; + /* Right margin */ GtkWidget *right_margin_checkbutton; GtkWidget *right_margin_position_spinbutton; @@ -528,6 +531,11 @@ setup_view_page (PlumaPreferencesDialog *dlg) dlg->priv->auto_save_spinbutton, "value", G_SETTINGS_BIND_GET | G_SETTINGS_BIND_SET); + g_settings_bind (dlg->priv->editor_settings, + PLUMA_SETTINGS_DISPLAY_OVERVIEW_MAP, + dlg->priv->display_overview_map_checkbutton, + "active", + G_SETTINGS_BIND_GET | G_SETTINGS_BIND_SET); g_signal_connect (dlg->priv->wrap_text_checkbutton, "toggled", @@ -1222,6 +1230,7 @@ pluma_preferences_dialog_init (PlumaPreferencesDialog *dlg) "display_line_numbers_checkbutton", &dlg->priv->display_line_numbers_checkbutton, "highlight_current_line_checkbutton", &dlg->priv->highlight_current_line_checkbutton, "bracket_matching_checkbutton", &dlg->priv->bracket_matching_checkbutton, + "display_overview_map_checkbutton", &dlg->priv->display_overview_map_checkbutton, "wrap_text_checkbutton", &dlg->priv->wrap_text_checkbutton, "split_checkbutton", &dlg->priv->split_checkbutton, diff --git a/pluma/dialogs/pluma-preferences-dialog.ui b/pluma/dialogs/pluma-preferences-dialog.ui index f571d24d..7825e305 100644 --- a/pluma/dialogs/pluma-preferences-dialog.ui +++ b/pluma/dialogs/pluma-preferences-dialog.ui @@ -1,5 +1,5 @@ - + @@ -43,6 +43,9 @@ False True dialog + + + True @@ -562,6 +565,86 @@ 4 + + + True + False + vertical + 6 + + + True + False + start + Overview Map + + + + + + False + False + 0 + + + + + True + False + + + True + False + + + + False + False + 0 + + + + + True + False + vertical + 6 + + + Display _overview map + True + True + False + True + True + + + False + False + 0 + + + + + False + True + 1 + + + + + False + True + 1 + + + + + False + True + 5 + + @@ -1496,8 +1579,5 @@ helpbutton1 closebutton1 - - - diff --git a/pluma/dialogs/ui-a11y.suppr b/pluma/dialogs/ui-a11y.suppr index f3ef7eda..30900bc7 100644 --- a/pluma/dialogs/ui-a11y.suppr +++ b/pluma/dialogs/ui-a11y.suppr @@ -26,6 +26,8 @@ pluma-preferences-dialog.ui://GtkLabel[@id='label819'] orphan-label pluma-preferences-dialog.ui://GtkLabel[@id='label800'] orphan-label pluma-preferences-dialog.ui://GtkLabel[@id='label798'] orphan-label pluma-preferences-dialog.ui://GtkLabel[@id='label797'] orphan-label +pluma-preferences-dialog.ui://GtkLabel[@id='label5'] orphan-label +pluma-preferences-dialog.ui://GtkLabel[@id='label6'] orphan-label pluma-preferences-dialog.ui://GtkTreeView[@id='schemes_treeview'] no-labelled-by pluma-search-dialog.ui://GtkLabel[@id='search_label'] orphan-label pluma-search-dialog.ui://GtkLabel[@id='replace_with_label'] orphan-label diff --git a/pluma/pluma-settings.h b/pluma/pluma-settings.h index 1a15f4b3..1796f978 100644 --- a/pluma/pluma-settings.h +++ b/pluma/pluma-settings.h @@ -140,6 +140,7 @@ GSList * pluma_settings_get_writable_vfs_schemes (GSettings *sett #define PLUMA_SETTINGS_DRAWER_TAB "enable-space-drawer-tab" #define PLUMA_SETTINGS_DRAWER_NEWLINE "enable-space-drawer-newline" #define PLUMA_SETTINGS_DRAWER_NBSP "enable-space-drawer-nbsp" +#define PLUMA_SETTINGS_DISPLAY_OVERVIEW_MAP "display-overview-map" /* White list of writable mate-vfs methods */ #define PLUMA_SETTINGS_WRITABLE_VFS_SCHEMES "writable-vfs-schemes" diff --git a/pluma/pluma-tab.c b/pluma/pluma-tab.c index 9b1f6080..2b096568 100644 --- a/pluma/pluma-tab.c +++ b/pluma/pluma-tab.c @@ -52,8 +52,10 @@ struct _PlumaTabPrivate GSettings *editor_settings; PlumaTabState state; + GtkWidget *overlay; GtkWidget *view; GtkWidget *view_scrolled_window; + GtkWidget *view_map_frame; GtkWidget *message_area; GtkWidget *print_preview; @@ -406,11 +408,15 @@ pluma_tab_set_state (PlumaTab *tab, (state == PLUMA_TAB_STATE_SHOWING_PRINT_PREVIEW)) { gtk_widget_hide (tab->priv->view_scrolled_window); + gtk_widget_hide (tab->priv->overlay); } else { if (tab->priv->print_preview == NULL) + { gtk_widget_show (tab->priv->view_scrolled_window); + gtk_widget_show (tab->priv->overlay); + } } set_cursor_according_to_state (GTK_TEXT_VIEW (tab->priv->view), @@ -1489,6 +1495,8 @@ tab_mount_operation_factory (PlumaDocument *doc, static void pluma_tab_init (PlumaTab *tab) { + GtkWidget *hbox; + GtkWidget *map; GtkWidget *sw; PlumaDocument *doc; PlumaLockdownMask lockdown; @@ -1546,12 +1554,46 @@ pluma_tab_init (PlumaTab *tab) gtk_widget_show (tab->priv->view); g_object_set_data (G_OBJECT (tab->priv->view), PLUMA_TAB_KEY, tab); - gtk_box_pack_end (GTK_BOX (tab), sw, TRUE, TRUE, 0); gtk_container_add (GTK_CONTAINER (sw), tab->priv->view); gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (sw), GTK_SHADOW_IN); gtk_widget_show (sw); + /* Create the minimap overlay */ + tab->priv->overlay = gtk_overlay_new (); + tab->priv->view_map_frame = gtk_frame_new (NULL); + map = gtk_source_map_new(); + + GtkCssProvider *provider = gtk_css_provider_new (); + gtk_css_provider_load_from_data (provider, + "textview { font-family: Monospace; font-size: 1pt; }", + -1, + NULL); + gtk_style_context_add_provider (gtk_widget_get_style_context (map), + GTK_STYLE_PROVIDER (provider), + GTK_STYLE_PROVIDER_PRIORITY_APPLICATION); + g_object_unref (provider); + + gtk_source_map_set_view (GTK_SOURCE_MAP(map), GTK_SOURCE_VIEW(tab->priv->view)); + gtk_container_add (GTK_CONTAINER(tab->priv->view_map_frame), map); + gtk_widget_show (tab->priv->view_map_frame); + + /* Start packing */ + hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0); + gtk_box_pack_start (GTK_BOX (hbox), sw, TRUE, TRUE, 0); + gtk_box_pack_start (GTK_BOX (hbox), tab->priv->view_map_frame, FALSE, FALSE, 0); + gtk_container_add (GTK_CONTAINER(tab->priv->overlay), hbox); + gtk_box_pack_end (GTK_BOX (tab), tab->priv->overlay, TRUE, TRUE, 0); + + gtk_widget_show (hbox); + gtk_widget_show (tab->priv->overlay); + + g_settings_bind (tab->priv->editor_settings, + PLUMA_SETTINGS_DISPLAY_OVERVIEW_MAP, + tab->priv->view_map_frame, + "visible", + G_SETTINGS_BIND_GET | G_SETTINGS_BIND_NO_SENSITIVITY); + g_signal_connect (doc, "notify::uri", G_CALLBACK (document_uri_notify_handler), -- cgit v1.2.1