[Xfce4-commits] [apps/mousepad] 41/45: Implement match-braces setting

noreply at xfce.org noreply at xfce.org
Fri Jul 11 13:03:46 CEST 2014


This is an automated email from the git hooks/post-receive script.

mbrush pushed a commit to branch master
in repository apps/mousepad.

commit 87f2d0636b4028cf38cf469e9add41d5299e3f1d
Author: Matthew Brush <mbrush at codebrainz.ca>
Date:   Fri Jul 11 00:34:59 2014 -0700

    Implement match-braces setting
---
 mousepad/mousepad-prefs-dialog.c       |    3 +-
 mousepad/mousepad-prefs-dialog.glade   |    3 +-
 mousepad/mousepad-settings.h           |    1 +
 mousepad/mousepad-view.c               |   47 ++++++++++++++++++++++++++++++++
 mousepad/mousepad-view.h               |    5 ++++
 mousepad/org.xfce.mousepad.gschema.xml |    8 ++++++
 6 files changed, 64 insertions(+), 3 deletions(-)

diff --git a/mousepad/mousepad-prefs-dialog.c b/mousepad/mousepad-prefs-dialog.c
index 353df21..47b6fd2 100644
--- a/mousepad/mousepad-prefs-dialog.c
+++ b/mousepad/mousepad-prefs-dialog.c
@@ -14,7 +14,7 @@
 #define WID_SHOW_RIGHT_MARGIN_CHECK         "/prefs/view/display/long-line-check"
 #define WID_RIGHT_MARGIN_SPIN               "/prefs/view/display/long-line-spin"
 #define WID_HIGHLIGHT_CURRENT_LINE_CHECK    "/prefs/view/display/highlight-current-line-check"
-#define WID_HIGHLIGHT_MATCHING_BRACES_CHECK "/prefs/view/display/highlight-braces-check"
+#define WID_MATCH_BRACES_CHECK              "/prefs/view/display/match-braces-check"
 #define WID_WORD_WRAP_CHECK                 "/prefs/view/display/word-wrap-check"
 
 #define WID_USE_DEFAULT_FONT_CHECK          "/prefs/view/font/default-check"
@@ -354,6 +354,7 @@ mousepad_prefs_dialog_init (MousepadPrefsDialog *self)
   BIND_CHECKBOX (HIGHLIGHT_CURRENT_LINE);
   BIND_CHECKBOX (WORD_WRAP);
   BIND_CHECKBOX (USE_DEFAULT_FONT);
+  BIND_CHECKBOX (MATCH_BRACES);
 
   /* Editor */
   BIND_CHECKBOX (AUTO_INDENT);
diff --git a/mousepad/mousepad-prefs-dialog.glade b/mousepad/mousepad-prefs-dialog.glade
index ce99499..ff6dd8c 100644
--- a/mousepad/mousepad-prefs-dialog.glade
+++ b/mousepad/mousepad-prefs-dialog.glade
@@ -200,12 +200,11 @@
                       </packing>
                     </child>
                     <child>
-                      <object class="GtkCheckButton" id="/prefs/view/display/highlight-braces-check">
+                      <object class="GtkCheckButton" id="/prefs/view/display/match-braces-check">
                         <property name="label" translatable="yes">Highlight matching brackets</property>
                         <property name="visible">True</property>
                         <property name="can_focus">True</property>
                         <property name="receives_default">False</property>
-                        <property name="active">True</property>
                         <property name="draw_indicator">True</property>
                       </object>
                       <packing>
diff --git a/mousepad/mousepad-settings.h b/mousepad/mousepad-settings.h
index b5bf091..3acf2c7 100644
--- a/mousepad/mousepad-settings.h
+++ b/mousepad/mousepad-settings.h
@@ -23,6 +23,7 @@ G_BEGIN_DECLS
 #define MOUSEPAD_SETTING_SMART_HOME_END             "/preferences/view/smart-home-end"
 #define MOUSEPAD_SETTING_TAB_WIDTH                  "/preferences/view/tab-width"
 #define MOUSEPAD_SETTING_WORD_WRAP                  "/preferences/view/word-wrap"
+#define MOUSEPAD_SETTING_MATCH_BRACES               "/preferences/view/match-braces"
 #define MOUSEPAD_SETTING_COLOR_SCHEME               "/preferences/view/color-scheme"
 #define MOUSEPAD_SETTING_TOOLBAR_VISIBLE            "/preferences/window/toolbar-visible"
 #define MOUSEPAD_SETTING_STATUSBAR_VISIBLE          "/preferences/window/statusbar-visible"
diff --git a/mousepad/mousepad-view.c b/mousepad/mousepad-view.c
index 7f0bd91..1bc35f7 100644
--- a/mousepad/mousepad-view.c
+++ b/mousepad/mousepad-view.c
@@ -133,6 +133,8 @@ struct _MousepadView
   gboolean              show_line_endings;
 
   gchar                *color_scheme;
+
+  gboolean              match_braces;
 };
 
 
@@ -145,6 +147,7 @@ enum
   PROP_SHOW_LINE_ENDINGS,
   PROP_COLOR_SCHEME,
   PROP_WORD_WRAP,
+  PROP_MATCH_BRACES,
   NUM_PROPERTIES
 };
 
@@ -216,6 +219,15 @@ mousepad_view_class_init (MousepadViewClass *klass)
                           "Whether to virtually wrap long lines in the view",
                           FALSE,
                           G_PARAM_READWRITE));
+
+  g_object_class_install_property (
+    gobject_class,
+    PROP_MATCH_BRACES,
+    g_param_spec_boolean ("match-braces",
+                          "MatchBraces",
+                          "Whether to highlight matching braces, parens, brackets, etc.",
+                          FALSE,
+                          G_PARAM_READWRITE));
 }
 
 
@@ -236,6 +248,8 @@ mousepad_view_buffer_changed (MousepadView *view,
       manager = gtk_source_style_scheme_manager_get_default ();
       scheme = gtk_source_style_scheme_manager_get_scheme (manager, view->color_scheme);
       gtk_source_buffer_set_style_scheme (buffer, scheme);
+
+      gtk_source_buffer_set_highlight_matching_brackets (buffer, view->match_braces);
     }
 }
 
@@ -264,6 +278,7 @@ mousepad_view_init (MousepadView *view)
   view->font_name = NULL;
   view->font_desc = NULL;
   view->font_handler = 0;
+  view->match_braces = FALSE;
 
   /* make sure any buffers set on the view get the color scheme applied to them */
   g_signal_connect (view,
@@ -298,6 +313,7 @@ mousepad_view_init (MousepadView *view)
   BIND_ (TAB_WIDTH,              "tab-width");
   BIND_ (COLOR_SCHEME,           "color-scheme");
   BIND_ (WORD_WRAP,              "word-wrap");
+  BIND_ (MATCH_BRACES,           "match-braces");
 
   /* override with default font when the setting is enabled */
   view->font_handler =
@@ -361,6 +377,9 @@ mousepad_view_set_property (GObject      *object,
     case PROP_WORD_WRAP:
       mousepad_view_set_word_wrap (view, g_value_get_boolean (value));
       break;
+    case PROP_MATCH_BRACES:
+      mousepad_view_set_match_braces (view, g_value_get_boolean (value));
+      break;
     default:
       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
       break;
@@ -394,6 +413,9 @@ mousepad_view_get_property (GObject    *object,
     case PROP_WORD_WRAP:
       g_value_set_boolean (value, mousepad_view_get_word_wrap (view));
       break;
+    case PROP_MATCH_BRACES:
+      g_value_set_boolean (value, mousepad_view_get_match_braces (view));
+      break;
     default:
       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
       break;
@@ -2742,3 +2764,28 @@ mousepad_view_get_word_wrap (MousepadView *view)
 
   return (mode == GTK_WRAP_WORD);
 }
+
+
+
+void
+mousepad_view_set_match_braces (MousepadView *view,
+                                gboolean      enabled)
+{
+  g_return_if_fail (MOUSEPAD_IS_VIEW (view));
+
+  view->match_braces = enabled;
+
+  mousepad_view_buffer_changed (view, NULL, NULL);
+
+  g_object_notify (G_OBJECT (view), "match-braces");
+}
+
+
+
+gboolean
+mousepad_view_get_match_braces (MousepadView *view)
+{
+  g_return_val_if_fail (MOUSEPAD_IS_VIEW (view), FALSE);
+
+  return view->match_braces;
+}
diff --git a/mousepad/mousepad-view.h b/mousepad/mousepad-view.h
index aaf3808..491c32c 100644
--- a/mousepad/mousepad-view.h
+++ b/mousepad/mousepad-view.h
@@ -120,6 +120,11 @@ void            mousepad_view_set_word_wrap             (MousepadView      *view
 
 gboolean        mousepad_view_get_word_wrap             (MousepadView      *view);
 
+void            mousepad_view_set_match_braces          (MousepadView      *view,
+                                                         gboolean           enabled);
+
+gboolean        mousepad_view_get_match_braces          (MousepadView      *view);
+
 G_END_DECLS
 
 #endif /* !__MOUSEPAD_VIEW_H__ */
diff --git a/mousepad/org.xfce.mousepad.gschema.xml b/mousepad/org.xfce.mousepad.gschema.xml
index acab4b4..cf8685b 100644
--- a/mousepad/org.xfce.mousepad.gschema.xml
+++ b/mousepad/org.xfce.mousepad.gschema.xml
@@ -149,6 +149,14 @@
         the text view, when false long lines will extend out of view.
       </description>
     </key>
+    <key name="match-braces" type="b">
+      <default>false</default>
+      <summary>Match braces</summary>
+      <description>
+        When true highlight matching braces, brackets, parents, etc, when
+        false don't highlight them.
+      </description>
+    </key>
     <key name="color-scheme" type="s">
       <default>'none'</default>
       <summary>Color scheme</summary>

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the Xfce4-commits mailing list