[gedit] Add menu item to show a source map for the view
- From: Ignacio Casal Quinteiro <icq src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gedit] Add menu item to show a source map for the view
- Date: Sun, 10 May 2015 07:58:13 +0000 (UTC)
commit 7200c8ec4a1b9ef20603387e769f8941922f52c8
Author: Ignacio Casal Quinteiro <icq gnome org>
Date: Sat May 9 15:32:57 2015 +0200
Add menu item to show a source map for the view
data/org.gnome.gedit.gschema.xml.in | 5 +++++
gedit/gedit-settings.h | 1 +
gedit/gedit-view-frame.c | 12 ++++++++++++
gedit/gedit-view-frame.h | 4 +---
gedit/gedit-window.c | 4 ++++
gedit/resources/css/gedit-style.css | 8 ++++++++
gedit/resources/gtk/menus-default.ui | 4 ++++
gedit/resources/gtk/menus-osx.ui | 4 ++++
gedit/resources/gtk/menus-traditional.ui | 4 ++++
gedit/resources/ui/gedit-view-frame.ui | 27 ++++++++++++++++++++++++---
10 files changed, 67 insertions(+), 6 deletions(-)
---
diff --git a/data/org.gnome.gedit.gschema.xml.in b/data/org.gnome.gedit.gschema.xml.in
index 9f33c29..9ee2ea9 100644
--- a/data/org.gnome.gedit.gschema.xml.in
+++ b/data/org.gnome.gedit.gschema.xml.in
@@ -185,6 +185,11 @@
<key name="bottom-panel-visible" type="b">
<default>false</default>
</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">
<default>5</default>
<summary>Maximum Recent Files</summary>
diff --git a/gedit/gedit-settings.h b/gedit/gedit-settings.h
index c3f001c..bfc852b 100644
--- a/gedit/gedit-settings.h
+++ b/gedit/gedit-settings.h
@@ -78,6 +78,7 @@ void gedit_settings_set_list (GSettings
*settings,
#define GEDIT_SETTINGS_STATUSBAR_VISIBLE "statusbar-visible"
#define GEDIT_SETTINGS_SIDE_PANEL_VISIBLE "side-panel-visible"
#define GEDIT_SETTINGS_BOTTOM_PANEL_VISIBLE "bottom-panel-visible"
+#define GEDIT_SETTINGS_MINIMAP_VISIBLE "minimap-visible"
#define GEDIT_SETTINGS_MAX_RECENTS "max-recents"
#define GEDIT_SETTINGS_PRINT_SYNTAX_HIGHLIGHTING "print-syntax-highlighting"
#define GEDIT_SETTINGS_PRINT_HEADER "print-header"
diff --git a/gedit/gedit-view-frame.c b/gedit/gedit-view-frame.c
index 77a8ed4..8d73e2b 100644
--- a/gedit/gedit-view-frame.c
+++ b/gedit/gedit-view-frame.c
@@ -36,6 +36,7 @@
#include "gedit-view-holder.h"
#include "gedit-debug.h"
#include "gedit-utils.h"
+#include "gedit-settings.h"
#include "libgd/gd.h"
#define FLUSH_TIMEOUT_DURATION 30 /* in seconds */
@@ -58,9 +59,12 @@ struct _GeditViewFrame
{
GtkOverlay parent_instance;
+ GSettings *ui_settings;
+
GeditView *view;
GeditViewHolder *view_holder;
GtkWidget *window;
+ GtkFrame *map_frame;
SearchMode search_mode;
@@ -1470,6 +1474,7 @@ gedit_view_frame_class_init (GeditViewFrameClass *klass)
"/org/gnome/gedit/ui/gedit-view-frame.ui");
gtk_widget_class_bind_template_child (widget_class, GeditViewFrame, view);
gtk_widget_class_bind_template_child (widget_class, GeditViewFrame, view_holder);
+ gtk_widget_class_bind_template_child (widget_class, GeditViewFrame, map_frame);
gtk_widget_class_bind_template_child (widget_class, GeditViewFrame, revealer);
gtk_widget_class_bind_template_child (widget_class, GeditViewFrame, search_entry);
gtk_widget_class_bind_template_child (widget_class, GeditViewFrame, go_up_button);
@@ -1538,6 +1543,13 @@ gedit_view_frame_init (GeditViewFrame *frame)
gtk_widget_init_template (GTK_WIDGET (frame));
+ frame->ui_settings = g_settings_new ("org.gnome.gedit.preferences.ui");
+ g_settings_bind (frame->ui_settings,
+ GEDIT_SETTINGS_MINIMAP_VISIBLE,
+ frame->map_frame,
+ "visible",
+ G_SETTINGS_BIND_GET);
+
gtk_widget_override_background_color (GTK_WIDGET (frame), 0, &transparent);
doc = gedit_view_frame_get_document (frame);
diff --git a/gedit/gedit-view-frame.h b/gedit/gedit-view-frame.h
index 81ca932..8ce7d06 100644
--- a/gedit/gedit-view-frame.h
+++ b/gedit/gedit-view-frame.h
@@ -15,9 +15,7 @@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with gedit; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor,
- * Boston, MA 02110-1301 USA
+ * along with gedit. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef __GEDIT_VIEW_FRAME_H__
diff --git a/gedit/gedit-window.c b/gedit/gedit-window.c
index 6d00dda..17a4aba 100644
--- a/gedit/gedit-window.c
+++ b/gedit/gedit-window.c
@@ -2728,6 +2728,7 @@ gedit_window_init (GeditWindow *window)
{
GtkTargetList *tl;
GMenuModel *gear_menu;
+ GAction *action;
gedit_debug (DEBUG_WINDOW);
@@ -2756,6 +2757,9 @@ gedit_window_init (GeditWindow *window)
win_entries,
G_N_ELEMENTS (win_entries),
window);
+ action = g_settings_create_action (window->priv->ui_settings,
+ GEDIT_SETTINGS_MINIMAP_VISIBLE);
+ g_action_map_add_action (G_ACTION_MAP (window), action);
window->priv->window_group = gtk_window_group_new ();
gtk_window_group_add_window (window->priv->window_group, GTK_WINDOW (window));
diff --git a/gedit/resources/css/gedit-style.css b/gedit/resources/css/gedit-style.css
index 6dafc6f..87b5e13 100644
--- a/gedit/resources/css/gedit-style.css
+++ b/gedit/resources/css/gedit-style.css
@@ -35,3 +35,11 @@
.gedit-menu-stack-switcher {
padding: 12px;
}
+
+.gedit-map-frame:dir(ltr) {
+ border-width: 0 0 0 1px;
+}
+
+.gedit-map-frame:dir(rtl) {
+ border-width: 0 1px 0 0;
+}
diff --git a/gedit/resources/gtk/menus-default.ui b/gedit/resources/gtk/menus-default.ui
index 0acd51d..3d10ab9 100644
--- a/gedit/resources/gtk/menus-default.ui
+++ b/gedit/resources/gtk/menus-default.ui
@@ -112,6 +112,10 @@
<section>
<attribute name="id">view-section-2</attribute>
<item>
+ <attribute name="label" translatable="yes">_Minimap</attribute>
+ <attribute name="action">win.minimap-visible</attribute>
+ </item>
+ <item>
<attribute name="label" translatable="yes">_Highlight Mode…</attribute>
<attribute name="action">win.highlight-mode</attribute>
</item>
diff --git a/gedit/resources/gtk/menus-osx.ui b/gedit/resources/gtk/menus-osx.ui
index e4004d8..a3ab029 100644
--- a/gedit/resources/gtk/menus-osx.ui
+++ b/gedit/resources/gtk/menus-osx.ui
@@ -147,6 +147,10 @@
<section>
<attribute name="id">view-section-2</attribute>
<item>
+ <attribute name="label" translatable="yes">_Minimap</attribute>
+ <attribute name="action">win.minimap-visible</attribute>
+ </item>
+ <item>
<attribute name="label" translatable="yes">_Highlight Mode…</attribute>
<attribute name="action">win.highlight-mode</attribute>
</item>
diff --git a/gedit/resources/gtk/menus-traditional.ui b/gedit/resources/gtk/menus-traditional.ui
index 154329f..5cf2479 100644
--- a/gedit/resources/gtk/menus-traditional.ui
+++ b/gedit/resources/gtk/menus-traditional.ui
@@ -81,6 +81,10 @@
<section>
<attribute name="id">view-section-2</attribute>
<item>
+ <attribute name="label" translatable="yes">_Minimap</attribute>
+ <attribute name="action">win.minimap-visible</attribute>
+ </item>
+ <item>
<attribute name="label" translatable="yes">_Highlight Mode…</attribute>
<attribute name="action">win.highlight-mode</attribute>
</item>
diff --git a/gedit/resources/ui/gedit-view-frame.ui b/gedit/resources/ui/gedit-view-frame.ui
index 2dd1395..ec9f38b 100644
--- a/gedit/resources/ui/gedit-view-frame.ui
+++ b/gedit/resources/ui/gedit-view-frame.ui
@@ -7,12 +7,33 @@
<property name="has_focus">False</property>
<property name="is_focus">False</property>
<child>
- <object class="GeditViewHolder" id="view_holder">
+ <object class="GtkGrid" id="grid">
<property name="visible">True</property>
<child>
- <object class="GeditView" id="view">
+ <object class="GeditViewHolder" id="view_holder">
<property name="visible">True</property>
- <property name="can_focus">True</property>
+ <property name="hexpand">True</property>
+ <property name="vexpand">True</property>
+ <child>
+ <object class="GeditView" id="view">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ </object>
+ </child>
+ </object>
+ </child>
+ <child>
+ <object class="GtkFrame" id="map_frame">
+ <property name="visible">True</property>
+ <style>
+ <class name="gedit-map-frame"/>
+ </style>
+ <child>
+ <object class="GtkSourceMap" id="map">
+ <property name="visible">True</property>
+ <property name="view">view</property>
+ </object>
+ </child>
</object>
</child>
</object>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]