[Xfce4-commits] [apps/mousepad] 16/45: Use the rest of the GtkSourceView properties with GSettings

noreply at xfce.org noreply at xfce.org
Fri Jul 11 13:03:21 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 fd87858d8159032fa94ab168acb8f5390ad71083
Author: Matthew Brush <mbrush at codebrainz.ca>
Date:   Sun Jul 6 21:02:05 2014 -0700

    Use the rest of the GtkSourceView properties with GSettings
    
    Rename existing settings to make them match GtkSourceView property
    names for consistency.
---
 mousepad/mousepad-document.c           |    9 +---
 mousepad/mousepad-view.c               |   54 ++++----------------
 mousepad/mousepad-view.h               |   12 -----
 mousepad/mousepad-window.c             |   39 +++++++++-----
 mousepad/org.xfce.Mousepad.gschema.xml |   87 ++++++++++++++++++++++++++++----
 5 files changed, 116 insertions(+), 85 deletions(-)

diff --git a/mousepad/mousepad-document.c b/mousepad/mousepad-document.c
index 40f331e..e520b7b 100644
--- a/mousepad/mousepad-document.c
+++ b/mousepad/mousepad-document.c
@@ -176,9 +176,8 @@ static void
 mousepad_document_init (MousepadDocument *document)
 {
   GtkTargetList        *target_list;
-  gboolean              word_wrap, insert_spaces;
+  gboolean              word_wrap;
   gchar                *color_scheme;
-  gint                  tab_size;
   GtkSourceStyleScheme *scheme = NULL;
 
   /* private structure */
@@ -218,14 +217,10 @@ mousepad_document_init (MousepadDocument *document)
 
   /* read all the default settings */
   word_wrap = mousepad_settings_get_boolean ("view-word-wrap");
-  tab_size = mousepad_settings_get_int ("view-tab-size");
-  insert_spaces = mousepad_settings_get_boolean ("view-insert-spaces");
   color_scheme = mousepad_settings_get_string ("view-color-scheme");
 
   /* set all the settings */
   mousepad_document_set_word_wrap (document, word_wrap);
-  mousepad_view_set_tab_size (document->textview, tab_size);
-  mousepad_view_set_insert_spaces (document->textview, insert_spaces);
 
   if (g_strcmp0 (color_scheme, "none") != 0)
     scheme =  gtk_source_style_scheme_manager_get_scheme (gtk_source_style_scheme_manager_get_default (), color_scheme);
@@ -286,7 +281,7 @@ mousepad_document_notify_cursor_position (GtkTextBuffer    *buffer,
   line = gtk_text_iter_get_line (&iter) + 1;
 
   /* get the tab size */
-  tab_size = mousepad_view_get_tab_size (document->textview);
+  tab_size = mousepad_settings_get_int ("view-tab-width");
 
   /* get the column */
   column = mousepad_util_get_real_line_offset (&iter, tab_size);
diff --git a/mousepad/mousepad-view.c b/mousepad/mousepad-view.c
index f31a6a7..cddb68c 100644
--- a/mousepad/mousepad-view.c
+++ b/mousepad/mousepad-view.c
@@ -213,11 +213,20 @@ mousepad_view_init (MousepadView *view)
                     G_CALLBACK (mousepad_view_commit_handler), view);
 
   /* bind Gsettings */
-  mousepad_settings_bind ("view-line-numbers", view, "show-line-numbers", G_SETTINGS_BIND_DEFAULT);
   mousepad_settings_bind ("view-auto-indent", view, "auto-indent", G_SETTINGS_BIND_DEFAULT);
   mousepad_settings_bind ("view-font-name", view, "font-name", G_SETTINGS_BIND_DEFAULT);
   mousepad_settings_bind ("view-show-whitespace", view, "show-whitespace", G_SETTINGS_BIND_DEFAULT);
   mousepad_settings_bind ("view-show-line-endings", view, "show-line-endings", G_SETTINGS_BIND_DEFAULT);
+  mousepad_settings_bind ("view-highlight-current-line", view, "highlight-current-line", G_SETTINGS_BIND_DEFAULT);
+  mousepad_settings_bind ("view-indent-on-tab", view, "indent-on-tab", G_SETTINGS_BIND_DEFAULT);
+  mousepad_settings_bind ("view-indent-width", view, "indent-width", G_SETTINGS_BIND_DEFAULT);
+  mousepad_settings_bind ("view-insert-spaces", view, "insert-spaces-instead-of-tabs", G_SETTINGS_BIND_DEFAULT);
+  mousepad_settings_bind ("view-right-margin-position", view, "right-margin-position", G_SETTINGS_BIND_DEFAULT);
+  mousepad_settings_bind ("view-show-line-marks", view, "show-line-marks", G_SETTINGS_BIND_DEFAULT);
+  mousepad_settings_bind ("view-show-line-numbers", view, "show-line-numbers", G_SETTINGS_BIND_DEFAULT);
+  mousepad_settings_bind ("view-show-right-margin", view, "show-right-margin", G_SETTINGS_BIND_DEFAULT);
+  mousepad_settings_bind ("view-smart-home-end", view, "smart-home-end", G_SETTINGS_BIND_DEFAULT);
+  mousepad_settings_bind ("view-tab-width", view, "tab-width", G_SETTINGS_BIND_DEFAULT);
 }
 
 
@@ -2394,29 +2403,6 @@ mousepad_view_indent (MousepadView *view,
 
 
 
-void
-mousepad_view_set_tab_size (MousepadView *view,
-                             gint          tab_size)
-{
-  mousepad_return_if_fail (MOUSEPAD_IS_VIEW (view));
-  mousepad_return_if_fail (GTK_IS_TEXT_VIEW (view));
-
-  gtk_source_view_set_tab_width (GTK_SOURCE_VIEW (view), tab_size);
-}
-
-
-
-void
-mousepad_view_set_insert_spaces (MousepadView *view,
-                                 gboolean      insert_spaces)
-{
-  mousepad_return_if_fail (MOUSEPAD_IS_VIEW (view));
-
-  gtk_source_view_set_insert_spaces_instead_of_tabs (GTK_SOURCE_VIEW (view), insert_spaces);
-}
-
-
-
 gboolean
 mousepad_view_get_selection_length (MousepadView *view,
                                     gboolean     *is_column_selection)
@@ -2456,26 +2442,6 @@ mousepad_view_get_selection_length (MousepadView *view,
 
 
 
-gint
-mousepad_view_get_tab_size (MousepadView *view)
-{
-  mousepad_return_val_if_fail (MOUSEPAD_IS_VIEW (view), -1);
-
-  return gtk_source_view_get_tab_width (GTK_SOURCE_VIEW (view));
-}
-
-
-
-gboolean
-mousepad_view_get_insert_spaces (MousepadView *view)
-{
-  mousepad_return_val_if_fail (MOUSEPAD_IS_VIEW (view), FALSE);
-
-  return gtk_source_view_get_insert_spaces_instead_of_tabs (GTK_SOURCE_VIEW (view));
-}
-
-
-
 void
 mousepad_view_set_font_name (MousepadView *view,
                              const gchar  *font_name)
diff --git a/mousepad/mousepad-view.h b/mousepad/mousepad-view.h
index b3d1609..df123a7 100644
--- a/mousepad/mousepad-view.h
+++ b/mousepad/mousepad-view.h
@@ -92,21 +92,9 @@ void            mousepad_view_duplicate                 (MousepadView      *view
 void            mousepad_view_indent                    (MousepadView      *view,
                                                          gint               type);
 
-void            mousepad_view_set_tab_size              (MousepadView      *view,
-                                                         gint               tab_size);
-
-void            mousepad_view_set_insert_spaces         (MousepadView      *view,
-                                                         gboolean           insert_spaces);
-
 gint            mousepad_view_get_selection_length      (MousepadView      *view,
                                                          gboolean          *is_column_selection);
 
-gboolean        mousepad_view_get_line_numbers          (MousepadView      *view);
-
-gint            mousepad_view_get_tab_size              (MousepadView      *view);
-
-gboolean        mousepad_view_get_insert_spaces         (MousepadView      *view);
-
 void            mousepad_view_set_font_name             (MousepadView      *view,
                                                          const gchar       *font_name);
 
diff --git a/mousepad/mousepad-window.c b/mousepad/mousepad-window.c
index 990a5d5..87b946f 100644
--- a/mousepad/mousepad-window.c
+++ b/mousepad/mousepad-window.c
@@ -539,6 +539,18 @@ mousepad_window_class_init (MousepadWindowClass *klass)
 
 
 
+/* Called in response to any settings changed which affect the statusbar labels. */
+static void
+mousepad_window_update_statusbar_settings (MousepadWindow   *window,
+                                           gchar            *key,
+                                           MousepadSettings *settings)
+{
+  if (G_LIKELY (MOUSEPAD_IS_DOCUMENT (window->active)))
+    mousepad_document_send_signals (window->active);
+}
+
+
+
 static void
 mousepad_window_init (MousepadWindow *window)
 {
@@ -698,6 +710,15 @@ mousepad_window_init (MousepadWindow *window)
   gtk_drag_dest_set (GTK_WIDGET (window), GTK_DEST_DEFAULT_MOTION | GTK_DEST_DEFAULT_DROP, drop_targets, G_N_ELEMENTS (drop_targets), GDK_ACTION_COPY | GDK_ACTION_MOVE);
   g_signal_connect (G_OBJECT (window), "drag-data-received", G_CALLBACK (mousepad_window_drag_data_received), window);
 
+  /* update the statusbar with certain settings */
+  g_signal_connect_swapped (MOUSEPAD_GSETTINGS,
+                            "changed::view-tab-width",
+                            G_CALLBACK (mousepad_window_update_statusbar_settings),
+                            window);
+  g_signal_connect_swapped (MOUSEPAD_GSETTINGS,
+                            "changed::view-insert-spaces",
+                            G_CALLBACK (mousepad_window_update_statusbar_settings),
+                            window);
 }
 
 
@@ -2099,7 +2120,7 @@ mousepad_window_menu_tab_sizes_update (MousepadWindow *window)
   lock_menu_updates++;
 
   /* get tab size of active document */
-  tab_size = mousepad_view_get_tab_size (window->active->textview);
+  tab_size = mousepad_settings_get_int ("view-tab-width");
 
   /* check if there is a default item with this number */
   name = g_strdup_printf ("tab-size_%d", tab_size);
@@ -2251,7 +2272,7 @@ mousepad_window_update_actions (MousepadWindow *window)
       action = gtk_action_group_get_action (window->action_group, "word-wrap");
       gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action), active);
 
-      active = mousepad_settings_get_boolean ("view-line-numbers");
+      active = mousepad_settings_get_boolean ("view-show-line-numbers");
       action = gtk_action_group_get_action (window->action_group, "line-numbers");
       gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action), active);
 
@@ -2262,7 +2283,7 @@ mousepad_window_update_actions (MousepadWindow *window)
       /* update the tabs size menu */
       mousepad_window_menu_tab_sizes_update (window);
 
-      active = mousepad_view_get_insert_spaces (document->textview);
+      active = mousepad_settings_get_boolean ("view-insert-spaces");
       action = gtk_action_group_get_action (window->action_group, "insert-spaces");
       gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action), active);
 
@@ -4509,7 +4530,7 @@ mousepad_window_action_line_numbers (GtkToggleAction *action,
   active = gtk_toggle_action_get_active (action);
 
   /* save as the last used line number setting */
-  mousepad_settings_set_boolean ("view-line-numbers", active);
+  mousepad_settings_set_boolean ("view-show-line-numbers", active);
 }
 
 
@@ -4818,17 +4839,14 @@ mousepad_window_action_tab_size (GtkToggleAction *action,
       if (tab_size == 0)
         {
           /* get tab size from document */
-          tab_size = mousepad_view_get_tab_size (window->active->textview);
+          tab_size = mousepad_settings_get_int ("view-tab-width");
 
           /* select other size in dialog */
           tab_size = mousepad_dialogs_other_tab_size (GTK_WINDOW (window), tab_size);
         }
 
       /* store as last used value */
-      mousepad_settings_set_int ("view-tab-size", tab_size);
-
-      /* set the value */
-      mousepad_view_set_tab_size (window->active->textview, tab_size);
+      mousepad_settings_set_int ("view-tab-width", tab_size);
 
       /* update menu */
       mousepad_window_menu_tab_sizes_update (window);
@@ -4940,9 +4958,6 @@ mousepad_window_action_insert_spaces (GtkToggleAction *action,
 
       /* save as the last auto indent mode */
       mousepad_settings_set_boolean ("view-insert-spaces", insert_spaces);
-
-      /* update the active document */
-      mousepad_view_set_insert_spaces (window->active->textview, insert_spaces);
     }
 }
 
diff --git a/mousepad/org.xfce.Mousepad.gschema.xml b/mousepad/org.xfce.Mousepad.gschema.xml
index d7ff57f..d6c3b85 100644
--- a/mousepad/org.xfce.Mousepad.gschema.xml
+++ b/mousepad/org.xfce.Mousepad.gschema.xml
@@ -1,5 +1,14 @@
 <schemalist>
 
+  <!-- Enums and flags -->
+  
+  <enum id="org.xfce.Mousepad.SmartHomeEnd">
+    <value nick="disabled" value="0"/>
+    <value nick="before" value="1"/>
+    <value nick="after" value="2"/>
+    <value nick="always" value="3"/>
+  </enum>
+
   <schema id="org.xfce.Mousepad" path="/org/xfce/Mousepad/" gettext-domain="mousepad">
 
     <!-- Search preferences -->
@@ -90,21 +99,30 @@
       </description>
     </key>
 
-    <key name="view-line-numbers" type="b">
-      <default>false</default>
-      <summary>Show line numbers</summary>
+    <key name="view-highlight-current-line" type="b">
+      <default>true</default>
+      <summary>Highlight current line</summary>
       <description>
-        When true the line numbers gutter/margin will be visible, when false
-        it will not be visible.
+        When true visually indicate the line with the caret on it, when false
+        provide no such indication.
       </description>
     </key>
 
-    <key name="view-tab-size" type="i">
-      <range min="1" max="32"/>
-      <default>8</default>
-      <summary>Tab width</summary>
+    <key name="view-indent-on-tab" type="b">
+      <default>true</default>
+      <summary>Indent on tab</summary>
       <description>
-        The number of characters wide that a tab character appears as.
+        When true indent selected text when tab key is pressed, when false,
+        don't indent on tab.
+      </description>
+    </key>
+
+    <key name="view-indent-width" type="i">
+      <range min="-1" max="32"/>
+      <default>-1</default>
+      <summary>Indentation width</summary>
+      <description>
+        Width of an indentation step expressed in number of spaces.
       </description>
     </key>
 
@@ -116,6 +134,55 @@
         of tab characters, when false tab characters will be inserted.
       </description>
     </key>
+    
+    <key name="view-right-margin-position" type="i">
+      <range min="1" max="1000"/>
+      <default>80</default>
+      <summary>Right margin position</summary>
+      <description>
+        Position of the right margin (line drawn vertically down right side
+        of the view).
+      </description>
+    </key>
+    
+    <key name="view-show-line-marks" type="b">
+      <default>false</default>
+      <summary>Show line marks</summary>
+      <description>Whether to display line mark pixbufs.</description>
+    </key>
+
+    <key name="view-show-line-numbers" type="b">
+      <default>false</default>
+      <summary>Show line numbers</summary>
+      <description>
+        When true the line numbers gutter/margin will be visible, when false
+        it will not be visible.
+      </description>
+    </key>
+
+    <key name="view-show-right-margin" type="b">
+      <default>false</default>
+      <summary>Show right margin</summary>
+      <description>
+        When true the right margin is displayed at the column specified in
+        'view-right-margin-position', when false it is not drawn.
+      </description>
+    </key>
+    
+    <key name="view-smart-home-end" enum="org.xfce.Mousepad.SmartHomeEnd">
+      <default>'disabled'</default>
+      <summary>Smart home end type</summary>
+      <description>Sets the behaviour of the HOME and END keys.</description>
+    </key>
+
+    <key name="view-tab-width" type="i">
+      <range min="1" max="32"/>
+      <default>8</default>
+      <summary>Tab width</summary>
+      <description>
+        The number of characters wide that a tab character appears as.
+      </description>
+    </key>
 
     <key name="view-word-wrap" type="b">
       <default>false</default>

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


More information about the Xfce4-commits mailing list