Minimap (#175)
* Add a minimap Add support for GtkSourceViews SourceMap object. Add both a default setting for new files to the preferences dialog and a menu item to allow temporarily disabling it in any view. * Require gtk and gtksourceview 3.18 * load custom css We can use this to make small tweaks to the interface so every theme doesn't need to add specific support. Make use of this new css to clean up the styling of the new overview map frame a bit.
This commit is contained in:
parent
97e1b0a9ec
commit
ce59112fd1
|
@ -149,8 +149,8 @@ PKG_CHECK_MODULES(XED, [
|
||||||
$GMODULE_ADD
|
$GMODULE_ADD
|
||||||
gthread-2.0 >= 2.13.0
|
gthread-2.0 >= 2.13.0
|
||||||
gio-2.0 >= 2.40.0
|
gio-2.0 >= 2.40.0
|
||||||
gtk+-3.0 >= 3.14.0
|
gtk+-3.0 >= 3.18.0
|
||||||
gtksourceview-3.0 >= 3.14.0
|
gtksourceview-3.0 >= 3.18.0
|
||||||
libpeas-1.0 >= 1.12.0
|
libpeas-1.0 >= 1.12.0
|
||||||
libpeas-gtk-1.0 >= 1.12.0
|
libpeas-gtk-1.0 >= 1.12.0
|
||||||
])
|
])
|
||||||
|
|
|
@ -201,6 +201,12 @@
|
||||||
<description>Whether you can change active tabs by scrolling.</description>
|
<description>Whether you can change active tabs by scrolling.</description>
|
||||||
</key>
|
</key>
|
||||||
|
|
||||||
|
<key name="minimap-visible" type="b">
|
||||||
|
<default>false</default>
|
||||||
|
<summary>Minimap is visible</summary>
|
||||||
|
<description>Whether the minimap for the document should be visible.</description>
|
||||||
|
</key>
|
||||||
|
|
||||||
<key name="max-recents" type="u">
|
<key name="max-recents" type="u">
|
||||||
<default>5</default>
|
<default>5</default>
|
||||||
<summary>Maximum Recent Files</summary>
|
<summary>Maximum Recent Files</summary>
|
||||||
|
|
|
@ -0,0 +1,7 @@
|
||||||
|
.xed-map-frame:dir(ltr) {
|
||||||
|
border-width: 0 0 0 1px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.xed-map-frame:dir(rtl) {
|
||||||
|
border-width: 0 1px 0 0;
|
||||||
|
}
|
|
@ -545,6 +545,51 @@
|
||||||
<property name="position">4</property>
|
<property name="position">4</property>
|
||||||
</packing>
|
</packing>
|
||||||
</child>
|
</child>
|
||||||
|
<child>
|
||||||
|
<object class="GtkBox" id="box3">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="can_focus">False</property>
|
||||||
|
<property name="orientation">vertical</property>
|
||||||
|
<property name="spacing">6</property>
|
||||||
|
<child>
|
||||||
|
<object class="GtkLabel" id="label3">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="can_focus">False</property>
|
||||||
|
<property name="label" translatable="yes">Overview Map</property>
|
||||||
|
<property name="xalign">0</property>
|
||||||
|
<attributes>
|
||||||
|
<attribute name="weight" value="bold"/>
|
||||||
|
</attributes>
|
||||||
|
</object>
|
||||||
|
<packing>
|
||||||
|
<property name="expand">False</property>
|
||||||
|
<property name="fill">True</property>
|
||||||
|
<property name="position">0</property>
|
||||||
|
</packing>
|
||||||
|
</child>
|
||||||
|
<child>
|
||||||
|
<object class="GtkCheckButton" id="mini_map_checkbutton">
|
||||||
|
<property name="label" translatable="yes">Display overview map</property>
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="can_focus">True</property>
|
||||||
|
<property name="receives_default">False</property>
|
||||||
|
<property name="margin_left">12</property>
|
||||||
|
<property name="xalign">0</property>
|
||||||
|
<property name="draw_indicator">True</property>
|
||||||
|
</object>
|
||||||
|
<packing>
|
||||||
|
<property name="expand">False</property>
|
||||||
|
<property name="fill">True</property>
|
||||||
|
<property name="position">1</property>
|
||||||
|
</packing>
|
||||||
|
</child>
|
||||||
|
</object>
|
||||||
|
<packing>
|
||||||
|
<property name="expand">True</property>
|
||||||
|
<property name="fill">True</property>
|
||||||
|
<property name="position">5</property>
|
||||||
|
</packing>
|
||||||
|
</child>
|
||||||
</object>
|
</object>
|
||||||
</child>
|
</child>
|
||||||
<child type="tab">
|
<child type="tab">
|
||||||
|
|
|
@ -52,6 +52,7 @@
|
||||||
<menuitem name="ViewStatusbarMenu" action="ViewStatusbar"/>
|
<menuitem name="ViewStatusbarMenu" action="ViewStatusbar"/>
|
||||||
<menuitem name="ViewSidePaneMenu" action="ViewSidePane"/>
|
<menuitem name="ViewSidePaneMenu" action="ViewSidePane"/>
|
||||||
<menuitem name="ViewBottomPaneMenu" action="ViewBottomPane"/>
|
<menuitem name="ViewBottomPaneMenu" action="ViewBottomPane"/>
|
||||||
|
<menuitem name="ViewOverviewMapMenu" action="ViewOverviewMap"/>
|
||||||
<separator/>
|
<separator/>
|
||||||
<menuitem name="ViewFullscreenMenu" action="ViewFullscreen"/>
|
<menuitem name="ViewFullscreenMenu" action="ViewFullscreen"/>
|
||||||
<separator/>
|
<separator/>
|
||||||
|
|
|
@ -6,6 +6,9 @@
|
||||||
<property name="can_focus">False</property>
|
<property name="can_focus">False</property>
|
||||||
<property name="has_focus">False</property>
|
<property name="has_focus">False</property>
|
||||||
<property name="is_focus">False</property>
|
<property name="is_focus">False</property>
|
||||||
|
<child>
|
||||||
|
<object class="GtkGrid" id="grid">
|
||||||
|
<property name="visible">True</property>
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkScrolledWindow" id="scrolledwindow">
|
<object class="GtkScrolledWindow" id="scrolledwindow">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
|
@ -13,6 +16,8 @@
|
||||||
<property name="has_focus">False</property>
|
<property name="has_focus">False</property>
|
||||||
<property name="is_focus">False</property>
|
<property name="is_focus">False</property>
|
||||||
<property name="shadow_type">none</property>
|
<property name="shadow_type">none</property>
|
||||||
|
<property name="hexpand">True</property>
|
||||||
|
<property name="vexpand">True</property>
|
||||||
<child>
|
<child>
|
||||||
<object class="XedView" id="view">
|
<object class="XedView" id="view">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
|
@ -21,6 +26,22 @@
|
||||||
</child>
|
</child>
|
||||||
</object>
|
</object>
|
||||||
</child>
|
</child>
|
||||||
|
<child>
|
||||||
|
<object class="GtkFrame" id="map_frame">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<style>
|
||||||
|
<class name="xed-map-frame"/>
|
||||||
|
</style>
|
||||||
|
<child>
|
||||||
|
<object class="GtkSourceMap" id="map">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="view">view</property>
|
||||||
|
</object>
|
||||||
|
</child>
|
||||||
|
</object>
|
||||||
|
</child>
|
||||||
|
</object>
|
||||||
|
</child>
|
||||||
<child type="overlay">
|
<child type="overlay">
|
||||||
<object class="GtkRevealer" id="revealer">
|
<object class="GtkRevealer" id="revealer">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
|
|
|
@ -7,5 +7,6 @@
|
||||||
<file preprocess="xml-stripblanks">ui/xed-print-preferences.ui</file>
|
<file preprocess="xml-stripblanks">ui/xed-print-preferences.ui</file>
|
||||||
<file preprocess="xml-stripblanks">ui/xed-searchbar.ui</file>
|
<file preprocess="xml-stripblanks">ui/xed-searchbar.ui</file>
|
||||||
<file preprocess="xml-stripblanks">ui/xed-view-frame.ui</file>
|
<file preprocess="xml-stripblanks">ui/xed-view-frame.ui</file>
|
||||||
|
<file>css/xed-style.css</file>
|
||||||
</gresource>
|
</gresource>
|
||||||
</gresources>
|
</gresources>
|
|
@ -234,6 +234,9 @@ xed_app_startup (GApplication *application)
|
||||||
const gchar *cache_dir;
|
const gchar *cache_dir;
|
||||||
gchar *metadata_filename;
|
gchar *metadata_filename;
|
||||||
#endif
|
#endif
|
||||||
|
GError *error = NULL;
|
||||||
|
GFile *css_file;
|
||||||
|
GtkCssProvider *provider;
|
||||||
|
|
||||||
G_APPLICATION_CLASS (xed_app_parent_class)->startup (application);
|
G_APPLICATION_CLASS (xed_app_parent_class)->startup (application);
|
||||||
|
|
||||||
|
@ -266,6 +269,21 @@ xed_app_startup (GApplication *application)
|
||||||
|
|
||||||
set_initial_theme_style (app);
|
set_initial_theme_style (app);
|
||||||
|
|
||||||
|
/* Load custom css */
|
||||||
|
css_file = g_file_new_for_uri ("resource:///org/x/editor/css/xed-style.css");
|
||||||
|
provider = gtk_css_provider_new ();
|
||||||
|
if (gtk_css_provider_load_from_file (provider, css_file, &error))
|
||||||
|
{
|
||||||
|
gtk_style_context_add_provider_for_screen (gdk_screen_get_default (),
|
||||||
|
GTK_STYLE_PROVIDER (provider),
|
||||||
|
GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
g_warning ("Could not load css provider: %s", error->message);
|
||||||
|
g_error_free (error);
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* We use the default gtksourceview style scheme manager so that plugins
|
* We use the default gtksourceview style scheme manager so that plugins
|
||||||
* can obtain it easily without a xed specific api, but we need to
|
* can obtain it easily without a xed specific api, but we need to
|
||||||
|
|
|
@ -41,7 +41,7 @@
|
||||||
#include "xed-window.h"
|
#include "xed-window.h"
|
||||||
#include "xed-window-private.h"
|
#include "xed-window-private.h"
|
||||||
#include "xed-paned.h"
|
#include "xed-paned.h"
|
||||||
|
#include "xed-view-frame.h"
|
||||||
|
|
||||||
void
|
void
|
||||||
_xed_cmd_view_show_toolbar (GtkAction *action,
|
_xed_cmd_view_show_toolbar (GtkAction *action,
|
||||||
|
@ -144,6 +144,25 @@ _xed_cmd_view_show_bottom_pane (GtkAction *action,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
_xed_cmd_view_toggle_overview_map (GtkAction *action,
|
||||||
|
XedWindow *window)
|
||||||
|
{
|
||||||
|
XedTab *tab;
|
||||||
|
XedViewFrame *frame;
|
||||||
|
GtkFrame *map_frame;
|
||||||
|
gboolean visible;
|
||||||
|
|
||||||
|
xed_debug (DEBUG_COMMANDS);
|
||||||
|
|
||||||
|
tab = xed_window_get_active_tab (window);
|
||||||
|
frame = XED_VIEW_FRAME (_xed_tab_get_view_frame (tab));
|
||||||
|
map_frame = xed_view_frame_get_map_frame (frame);
|
||||||
|
visible = gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action));
|
||||||
|
|
||||||
|
gtk_widget_set_visible (GTK_WIDGET (map_frame), visible);
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
_xed_cmd_view_toggle_fullscreen_mode (GtkAction *action,
|
_xed_cmd_view_toggle_fullscreen_mode (GtkAction *action,
|
||||||
XedWindow *window)
|
XedWindow *window)
|
||||||
|
|
|
@ -45,6 +45,7 @@ void _xed_cmd_view_show_toolbar (GtkAction *action, XedWindow *window);
|
||||||
void _xed_cmd_view_show_statusbar (GtkAction *action, XedWindow *window);
|
void _xed_cmd_view_show_statusbar (GtkAction *action, XedWindow *window);
|
||||||
void _xed_cmd_view_show_side_pane (GtkAction *action, XedWindow *window);
|
void _xed_cmd_view_show_side_pane (GtkAction *action, XedWindow *window);
|
||||||
void _xed_cmd_view_show_bottom_pane (GtkAction *action, XedWindow *window);
|
void _xed_cmd_view_show_bottom_pane (GtkAction *action, XedWindow *window);
|
||||||
|
void _xed_cmd_view_toggle_overview_map (GtkAction *action, XedWindow *window);
|
||||||
void _xed_cmd_view_toggle_fullscreen_mode (GtkAction *action, XedWindow *window);
|
void _xed_cmd_view_toggle_fullscreen_mode (GtkAction *action, XedWindow *window);
|
||||||
void _xed_cmd_view_toggle_word_wrap (GtkAction *action, XedWindow *window);
|
void _xed_cmd_view_toggle_word_wrap (GtkAction *action, XedWindow *window);
|
||||||
void _xed_cmd_view_leave_fullscreen_mode (GtkAction *action, XedWindow *window);
|
void _xed_cmd_view_leave_fullscreen_mode (GtkAction *action, XedWindow *window);
|
||||||
|
|
|
@ -123,6 +123,9 @@ struct _XedPreferencesDialogPrivate
|
||||||
/* Highlight matching bracket */
|
/* Highlight matching bracket */
|
||||||
GtkWidget *bracket_matching_checkbutton;
|
GtkWidget *bracket_matching_checkbutton;
|
||||||
|
|
||||||
|
/* Minimap */
|
||||||
|
GtkWidget *mini_map_checkbutton;
|
||||||
|
|
||||||
/* Right margin */
|
/* Right margin */
|
||||||
GtkWidget *right_margin_checkbutton;
|
GtkWidget *right_margin_checkbutton;
|
||||||
GtkWidget *right_margin_position_spinbutton;
|
GtkWidget *right_margin_position_spinbutton;
|
||||||
|
@ -355,6 +358,11 @@ setup_view_page (XedPreferencesDialog *dlg)
|
||||||
dlg->priv->right_margin_position_spinbutton,
|
dlg->priv->right_margin_position_spinbutton,
|
||||||
"value",
|
"value",
|
||||||
G_SETTINGS_BIND_GET | G_SETTINGS_BIND_SET);
|
G_SETTINGS_BIND_GET | G_SETTINGS_BIND_SET);
|
||||||
|
g_settings_bind (dlg->priv->ui,
|
||||||
|
XED_SETTINGS_MINIMAP_VISIBLE,
|
||||||
|
dlg->priv->mini_map_checkbutton,
|
||||||
|
"active",
|
||||||
|
G_SETTINGS_BIND_GET | G_SETTINGS_BIND_SET);
|
||||||
g_signal_connect (dlg->priv->wrap_text_checkbutton, "toggled",
|
g_signal_connect (dlg->priv->wrap_text_checkbutton, "toggled",
|
||||||
G_CALLBACK (wrap_mode_checkbutton_toggled), dlg);
|
G_CALLBACK (wrap_mode_checkbutton_toggled), dlg);
|
||||||
g_signal_connect (dlg->priv->split_checkbutton, "toggled",
|
g_signal_connect (dlg->priv->split_checkbutton, "toggled",
|
||||||
|
@ -1121,6 +1129,7 @@ xed_preferences_dialog_init (XedPreferencesDialog *dlg)
|
||||||
dlg->priv->display_line_numbers_checkbutton = GTK_WIDGET (gtk_builder_get_object (builder, "display_line_numbers_checkbutton"));
|
dlg->priv->display_line_numbers_checkbutton = GTK_WIDGET (gtk_builder_get_object (builder, "display_line_numbers_checkbutton"));
|
||||||
dlg->priv->highlight_current_line_checkbutton = GTK_WIDGET (gtk_builder_get_object (builder, "highlight_current_line_checkbutton"));
|
dlg->priv->highlight_current_line_checkbutton = GTK_WIDGET (gtk_builder_get_object (builder, "highlight_current_line_checkbutton"));
|
||||||
dlg->priv->bracket_matching_checkbutton = GTK_WIDGET (gtk_builder_get_object (builder, "bracket_matching_checkbutton"));
|
dlg->priv->bracket_matching_checkbutton = GTK_WIDGET (gtk_builder_get_object (builder, "bracket_matching_checkbutton"));
|
||||||
|
dlg->priv->mini_map_checkbutton = GTK_WIDGET (gtk_builder_get_object (builder, "mini_map_checkbutton"));
|
||||||
dlg->priv->wrap_text_checkbutton = GTK_WIDGET (gtk_builder_get_object (builder, "wrap_text_checkbutton"));
|
dlg->priv->wrap_text_checkbutton = GTK_WIDGET (gtk_builder_get_object (builder, "wrap_text_checkbutton"));
|
||||||
dlg->priv->split_checkbutton = GTK_WIDGET (gtk_builder_get_object (builder, "split_checkbutton"));
|
dlg->priv->split_checkbutton = GTK_WIDGET (gtk_builder_get_object (builder, "split_checkbutton"));
|
||||||
dlg->priv->right_margin_checkbutton = GTK_WIDGET (gtk_builder_get_object (builder, "right_margin_checkbutton"));
|
dlg->priv->right_margin_checkbutton = GTK_WIDGET (gtk_builder_get_object (builder, "right_margin_checkbutton"));
|
||||||
|
|
|
@ -98,6 +98,7 @@ void xed_settings_set_list (GSettings *settings,
|
||||||
#define XED_SETTINGS_STATUSBAR_VISIBLE "statusbar-visible"
|
#define XED_SETTINGS_STATUSBAR_VISIBLE "statusbar-visible"
|
||||||
#define XED_SETTINGS_SIDE_PANEL_VISIBLE "side-panel-visible"
|
#define XED_SETTINGS_SIDE_PANEL_VISIBLE "side-panel-visible"
|
||||||
#define XED_SETTINGS_BOTTOM_PANEL_VISIBLE "bottom-panel-visible"
|
#define XED_SETTINGS_BOTTOM_PANEL_VISIBLE "bottom-panel-visible"
|
||||||
|
#define XED_SETTINGS_MINIMAP_VISIBLE "minimap-visible"
|
||||||
#define XED_SETTINGS_MAX_RECENTS "max-recents"
|
#define XED_SETTINGS_MAX_RECENTS "max-recents"
|
||||||
#define XED_SETTINGS_PRINT_SYNTAX_HIGHLIGHTING "print-syntax-highlighting"
|
#define XED_SETTINGS_PRINT_SYNTAX_HIGHLIGHTING "print-syntax-highlighting"
|
||||||
#define XED_SETTINGS_PRINT_HEADER "print-header"
|
#define XED_SETTINGS_PRINT_HEADER "print-header"
|
||||||
|
|
|
@ -159,7 +159,10 @@ static const GtkToggleActionEntry xed_always_sensitive_toggle_menu_entries[] =
|
||||||
G_CALLBACK (_xed_cmd_view_toggle_fullscreen_mode), FALSE },
|
G_CALLBACK (_xed_cmd_view_toggle_fullscreen_mode), FALSE },
|
||||||
{ "ViewWordWrap", NULL, N_("_Word wrap"), NULL,
|
{ "ViewWordWrap", NULL, N_("_Word wrap"), NULL,
|
||||||
N_("Set word wrap for the current document"),
|
N_("Set word wrap for the current document"),
|
||||||
G_CALLBACK (_xed_cmd_view_toggle_word_wrap), FALSE }
|
G_CALLBACK (_xed_cmd_view_toggle_word_wrap), FALSE },
|
||||||
|
{ "ViewOverviewMap", NULL, N_("_Overview Map"), NULL,
|
||||||
|
N_("Show or hide the overview map for the current view"),
|
||||||
|
G_CALLBACK (_xed_cmd_view_toggle_overview_map), FALSE }
|
||||||
};
|
};
|
||||||
|
|
||||||
/* separate group, should be always sensitive except when there are no panes */
|
/* separate group, should be always sensitive except when there are no panes */
|
||||||
|
|
|
@ -28,6 +28,7 @@
|
||||||
#include "xed-marshal.h"
|
#include "xed-marshal.h"
|
||||||
#include "xed-debug.h"
|
#include "xed-debug.h"
|
||||||
#include "xed-utils.h"
|
#include "xed-utils.h"
|
||||||
|
#include "xed-settings.h"
|
||||||
|
|
||||||
#include <gdk/gdkkeysyms.h>
|
#include <gdk/gdkkeysyms.h>
|
||||||
#include <glib/gi18n.h>
|
#include <glib/gi18n.h>
|
||||||
|
@ -40,6 +41,10 @@
|
||||||
struct _XedViewFramePrivate
|
struct _XedViewFramePrivate
|
||||||
{
|
{
|
||||||
GtkWidget *view;
|
GtkWidget *view;
|
||||||
|
GtkFrame *map_frame;
|
||||||
|
GtkSourceMap *map;
|
||||||
|
|
||||||
|
GSettings *ui_settings;
|
||||||
|
|
||||||
GtkTextMark *start_mark;
|
GtkTextMark *start_mark;
|
||||||
|
|
||||||
|
@ -96,6 +101,8 @@ xed_view_frame_dispose (GObject *object)
|
||||||
gtk_source_file_set_mount_operation_factory (file, NULL, NULL, NULL);
|
gtk_source_file_set_mount_operation_factory (file, NULL, NULL, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
g_clear_object (&frame->priv->ui_settings);
|
||||||
|
|
||||||
G_OBJECT_CLASS (xed_view_frame_parent_class)->dispose (object);
|
G_OBJECT_CLASS (xed_view_frame_parent_class)->dispose (object);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -499,6 +506,8 @@ xed_view_frame_class_init (XedViewFrameClass *klass)
|
||||||
|
|
||||||
gtk_widget_class_set_template_from_resource (widget_class, "/org/x/editor/ui/xed-view-frame.ui");
|
gtk_widget_class_set_template_from_resource (widget_class, "/org/x/editor/ui/xed-view-frame.ui");
|
||||||
gtk_widget_class_bind_template_child_private (widget_class, XedViewFrame, view);
|
gtk_widget_class_bind_template_child_private (widget_class, XedViewFrame, view);
|
||||||
|
gtk_widget_class_bind_template_child_private (widget_class, XedViewFrame, map_frame);
|
||||||
|
gtk_widget_class_bind_template_child_private (widget_class, XedViewFrame, map);
|
||||||
gtk_widget_class_bind_template_child_private (widget_class, XedViewFrame, revealer);
|
gtk_widget_class_bind_template_child_private (widget_class, XedViewFrame, revealer);
|
||||||
gtk_widget_class_bind_template_child_private (widget_class, XedViewFrame, search_entry);
|
gtk_widget_class_bind_template_child_private (widget_class, XedViewFrame, search_entry);
|
||||||
}
|
}
|
||||||
|
@ -519,11 +528,23 @@ xed_view_frame_init (XedViewFrame *frame)
|
||||||
XedDocument *doc;
|
XedDocument *doc;
|
||||||
GtkSourceFile *file;
|
GtkSourceFile *file;
|
||||||
GdkRGBA transparent = {0, 0, 0, 0};
|
GdkRGBA transparent = {0, 0, 0, 0};
|
||||||
|
PangoFontDescription *font_desc;
|
||||||
|
|
||||||
frame->priv = xed_view_frame_get_instance_private (frame);
|
frame->priv = xed_view_frame_get_instance_private (frame);
|
||||||
|
|
||||||
gtk_widget_init_template (GTK_WIDGET (frame));
|
gtk_widget_init_template (GTK_WIDGET (frame));
|
||||||
|
|
||||||
|
frame->priv->ui_settings = g_settings_new ("org.x.editor.preferences.ui");
|
||||||
|
g_settings_bind (frame->priv->ui_settings,
|
||||||
|
XED_SETTINGS_MINIMAP_VISIBLE,
|
||||||
|
frame->priv->map_frame,
|
||||||
|
"visible",
|
||||||
|
G_SETTINGS_BIND_GET | G_SETTINGS_BIND_NO_SENSITIVITY);
|
||||||
|
|
||||||
|
font_desc = pango_font_description_from_string ("Monospace 2");
|
||||||
|
g_object_set (frame->priv->map, "font-desc", font_desc, NULL);
|
||||||
|
pango_font_description_free (font_desc);
|
||||||
|
|
||||||
gtk_widget_override_background_color (GTK_WIDGET (frame), 0, &transparent);
|
gtk_widget_override_background_color (GTK_WIDGET (frame), 0, &transparent);
|
||||||
|
|
||||||
doc = xed_view_frame_get_document (frame);
|
doc = xed_view_frame_get_document (frame);
|
||||||
|
@ -559,6 +580,14 @@ xed_view_frame_get_view (XedViewFrame *frame)
|
||||||
return XED_VIEW (frame->priv->view);
|
return XED_VIEW (frame->priv->view);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
GtkFrame *
|
||||||
|
xed_view_frame_get_map_frame (XedViewFrame *frame)
|
||||||
|
{
|
||||||
|
g_return_val_if_fail (XED_IS_VIEW_FRAME (frame), NULL);
|
||||||
|
|
||||||
|
return frame->priv->map_frame;
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
xed_view_frame_popup_goto_line (XedViewFrame *frame)
|
xed_view_frame_popup_goto_line (XedViewFrame *frame)
|
||||||
{
|
{
|
||||||
|
|
|
@ -61,6 +61,8 @@ XedDocument *xed_view_frame_get_document (XedViewFrame *frame);
|
||||||
|
|
||||||
XedView *xed_view_frame_get_view (XedViewFrame *frame);
|
XedView *xed_view_frame_get_view (XedViewFrame *frame);
|
||||||
|
|
||||||
|
GtkFrame *xed_view_frame_get_map_frame (XedViewFrame *frame);
|
||||||
|
|
||||||
void xed_view_frame_popup_goto_line (XedViewFrame *frame);
|
void xed_view_frame_popup_goto_line (XedViewFrame *frame);
|
||||||
|
|
||||||
gboolean xed_view_frame_get_search_popup_visible (XedViewFrame *frame);
|
gboolean xed_view_frame_get_search_popup_visible (XedViewFrame *frame);
|
||||||
|
|
|
@ -79,6 +79,7 @@ struct _XedWindowPrivate
|
||||||
guint spaces_instead_of_tabs_id;
|
guint spaces_instead_of_tabs_id;
|
||||||
guint language_changed_id;
|
guint language_changed_id;
|
||||||
guint use_word_wrap_id;
|
guint use_word_wrap_id;
|
||||||
|
guint show_overview_map_id;
|
||||||
|
|
||||||
/* Menus & Toolbars */
|
/* Menus & Toolbars */
|
||||||
GtkUIManager *manager;
|
GtkUIManager *manager;
|
||||||
|
|
|
@ -2170,6 +2170,28 @@ word_wrap_changed (GObject *object,
|
||||||
g_signal_handlers_unblock_by_func (action, G_CALLBACK (_xed_cmd_view_toggle_word_wrap), window);
|
g_signal_handlers_unblock_by_func (action, G_CALLBACK (_xed_cmd_view_toggle_word_wrap), window);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
show_overview_map_changed (GObject *object,
|
||||||
|
GParamSpec *pspec,
|
||||||
|
XedWindow *window)
|
||||||
|
{
|
||||||
|
GtkFrame *map_frame;
|
||||||
|
GtkAction *action;
|
||||||
|
gboolean overveiw_map_visible = FALSE;
|
||||||
|
|
||||||
|
map_frame = GTK_FRAME (object);
|
||||||
|
action = gtk_action_group_get_action (window->priv->always_sensitive_action_group, "ViewOverviewMap");
|
||||||
|
|
||||||
|
if (gtk_widget_get_visible (map_frame))
|
||||||
|
{
|
||||||
|
overveiw_map_visible = TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
g_signal_handlers_block_by_func (action, G_CALLBACK (_xed_cmd_view_toggle_overview_map), window);
|
||||||
|
gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action), overveiw_map_visible);
|
||||||
|
g_signal_handlers_unblock_by_func (action, G_CALLBACK (_xed_cmd_view_toggle_overview_map), window);
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
notebook_switch_page (GtkNotebook *book,
|
notebook_switch_page (GtkNotebook *book,
|
||||||
GtkWidget *pg,
|
GtkWidget *pg,
|
||||||
|
@ -2177,6 +2199,7 @@ notebook_switch_page (GtkNotebook *book,
|
||||||
XedWindow *window)
|
XedWindow *window)
|
||||||
{
|
{
|
||||||
XedView *view;
|
XedView *view;
|
||||||
|
GtkFrame *map_frame;
|
||||||
XedTab *tab;
|
XedTab *tab;
|
||||||
GtkAction *action;
|
GtkAction *action;
|
||||||
gchar *action_name;
|
gchar *action_name;
|
||||||
|
@ -2209,6 +2232,12 @@ notebook_switch_page (GtkNotebook *book,
|
||||||
g_signal_handler_disconnect (xed_tab_get_view (window->priv->active_tab), window->priv->use_word_wrap_id);
|
g_signal_handler_disconnect (xed_tab_get_view (window->priv->active_tab), window->priv->use_word_wrap_id);
|
||||||
window->priv->use_word_wrap_id = 0;
|
window->priv->use_word_wrap_id = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (window->priv->show_overview_map_id)
|
||||||
|
{
|
||||||
|
g_signal_handler_disconnect (xed_view_frame_get_map_frame (_xed_tab_get_view_frame (window->priv->active_tab)), window->priv->show_overview_map_id);
|
||||||
|
window->priv->show_overview_map_id = 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* set the active tab */
|
/* set the active tab */
|
||||||
|
@ -2236,6 +2265,7 @@ notebook_switch_page (GtkNotebook *book,
|
||||||
update_languages_menu (window);
|
update_languages_menu (window);
|
||||||
|
|
||||||
view = xed_tab_get_view (tab);
|
view = xed_tab_get_view (tab);
|
||||||
|
map_frame = xed_view_frame_get_map_frame (_xed_tab_get_view_frame (tab));
|
||||||
|
|
||||||
/* sync the statusbar */
|
/* sync the statusbar */
|
||||||
update_cursor_position_statusbar (GTK_TEXT_BUFFER (xed_tab_get_document (tab)), window);
|
update_cursor_position_statusbar (GTK_TEXT_BUFFER (xed_tab_get_document (tab)), window);
|
||||||
|
@ -2256,11 +2286,15 @@ notebook_switch_page (GtkNotebook *book,
|
||||||
window->priv->use_word_wrap_id = g_signal_connect (view, "notify::wrap-mode",
|
window->priv->use_word_wrap_id = g_signal_connect (view, "notify::wrap-mode",
|
||||||
G_CALLBACK (word_wrap_changed), window);
|
G_CALLBACK (word_wrap_changed), window);
|
||||||
|
|
||||||
|
window->priv->show_overview_map_id = g_signal_connect (map_frame, "notify::visible",
|
||||||
|
G_CALLBACK (show_overview_map_changed), window);
|
||||||
|
|
||||||
/* call it for the first time */
|
/* call it for the first time */
|
||||||
tab_width_changed (G_OBJECT (view), NULL, window);
|
tab_width_changed (G_OBJECT (view), NULL, window);
|
||||||
spaces_instead_of_tabs_changed (G_OBJECT (view), NULL, window);
|
spaces_instead_of_tabs_changed (G_OBJECT (view), NULL, window);
|
||||||
language_changed (G_OBJECT (xed_tab_get_document (tab)), NULL, window);
|
language_changed (G_OBJECT (xed_tab_get_document (tab)), NULL, window);
|
||||||
word_wrap_changed (G_OBJECT (view), NULL, window);
|
word_wrap_changed (G_OBJECT (view), NULL, window);
|
||||||
|
show_overview_map_changed (G_OBJECT (map_frame), NULL, window);
|
||||||
|
|
||||||
g_signal_emit (G_OBJECT (window), signals[ACTIVE_TAB_CHANGED], 0, window->priv->active_tab);
|
g_signal_emit (G_OBJECT (window), signals[ACTIVE_TAB_CHANGED], 0, window->priv->active_tab);
|
||||||
}
|
}
|
||||||
|
@ -3025,6 +3059,7 @@ notebook_tab_removed (XedNotebook *notebook,
|
||||||
XedWindow *window)
|
XedWindow *window)
|
||||||
{
|
{
|
||||||
XedView *view;
|
XedView *view;
|
||||||
|
XedViewFrame *frame;
|
||||||
XedDocument *doc;
|
XedDocument *doc;
|
||||||
|
|
||||||
xed_debug (DEBUG_WINDOW);
|
xed_debug (DEBUG_WINDOW);
|
||||||
|
@ -3034,6 +3069,7 @@ notebook_tab_removed (XedNotebook *notebook,
|
||||||
--window->priv->num_tabs;
|
--window->priv->num_tabs;
|
||||||
|
|
||||||
view = xed_tab_get_view (tab);
|
view = xed_tab_get_view (tab);
|
||||||
|
frame = _xed_tab_get_view_frame (tab);
|
||||||
doc = xed_tab_get_document (tab);
|
doc = xed_tab_get_document (tab);
|
||||||
|
|
||||||
g_signal_handlers_disconnect_by_func (tab, G_CALLBACK (sync_name), window);
|
g_signal_handlers_disconnect_by_func (tab, G_CALLBACK (sync_name), window);
|
||||||
|
@ -3074,6 +3110,12 @@ notebook_tab_removed (XedNotebook *notebook,
|
||||||
window->priv->use_word_wrap_id = 0;
|
window->priv->use_word_wrap_id = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (window->priv->show_overview_map_id && tab == xed_window_get_active_tab (window))
|
||||||
|
{
|
||||||
|
g_signal_handler_disconnect (xed_view_frame_get_map_frame (frame), window->priv->show_overview_map_id);
|
||||||
|
window->priv->show_overview_map_id = 0;
|
||||||
|
}
|
||||||
|
|
||||||
g_return_if_fail(window->priv->num_tabs >= 0);
|
g_return_if_fail(window->priv->num_tabs >= 0);
|
||||||
if (window->priv->num_tabs == 0)
|
if (window->priv->num_tabs == 0)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue