[gitg] Added showing right margin in commit message



commit f88f6b158340a2d6de46f7d7016a4e20db5063e4
Author: Jesse van den Kieboom <jesse icecrew nl>
Date:   Wed Jun 24 01:40:37 2009 +0200

    Added showing right margin in commit message
    
    This adds a preference to show the right margin at a particular column.
    This can be used to easily see where commit messages could be wrapped
    to stay within a certain column width.

 data/gitg.schemas.in           |   27 ++++++++
 gitg/gitg-commit-view.c        |   10 +++
 gitg/gitg-preferences-dialog.c |   33 ++++++++++
 gitg/gitg-preferences.c        |   32 ++++++++++
 gitg/gitg-preferences.xml      |  134 +++++++++++++++++++++++++++++++++++++++-
 gitg/gitg-ui.xml               |    2 +-
 6 files changed, 236 insertions(+), 2 deletions(-)
---
diff --git a/data/gitg.schemas.in b/data/gitg.schemas.in
index 0349bef..1bce33e 100644
--- a/data/gitg.schemas.in
+++ b/data/gitg.schemas.in
@@ -25,5 +25,32 @@
         </long>
       </locale>
     </schema>
+    <schema>
+      <key>/schemas/apps/gitg/preferences/commit/message/show-right-margin</key>
+      <applyto>/apps/gitg/preferences/commit/message/show-right-margin</applyto>
+      <owner>gitg</owner>
+      <type>bool</type>
+      <default>TRUE</default>
+      <locale name="C">
+        <short>Show Right Margin in Commit Message View</short>
+        <long>Show a right margin indicator in the commit message view. This 
+        can be used to easily see where to break the commit message at a
+        particular column.
+        </long>
+      </locale>
+    </schema>
+    <schema>
+      <key>/schemas/apps/gitg/preferences/commit/message/right-margin-at</key>
+      <applyto>/apps/gitg/preferences/commit/message/right-margin-at</applyto>
+      <owner>gitg</owner>
+      <type>int</type>
+      <default>72</default>
+      <locale name="C">
+        <short>Column at Which Right Margin is Shown</short>
+        <long>The column at which the right margin is shown if the right-margin
+        preference is set to TRUE.
+        </long>
+      </locale>
+    </schema>
   </schemalist>
 </gconfschemafile>
diff --git a/gitg/gitg-commit-view.c b/gitg/gitg-commit-view.c
index 64fa73d..86744ee 100644
--- a/gitg/gitg-commit-view.c
+++ b/gitg/gitg-commit-view.c
@@ -30,6 +30,8 @@
 #include "gitg-commit.h"
 #include "gitg-utils.h"
 #include "gitg-diff-view.h"
+#include "gitg-preferences.h"
+#include "gitg-data-binding.h"
 
 #define GITG_COMMIT_VIEW_GET_PRIVATE(object)(G_TYPE_INSTANCE_GET_PRIVATE((object), GITG_TYPE_COMMIT_VIEW, GitgCommitViewPrivate))
 #define CATEGORY_UNSTAGE_HUNK "CategoryUnstageHunk"
@@ -923,6 +925,14 @@ gitg_commit_view_parser_finished(GtkBuildable *buildable, GtkBuilder *builder)
 	self->priv->changes_view = GTK_SOURCE_VIEW(gtk_builder_get_object(builder, "source_view_changes"));
 	self->priv->comment_view = GTK_TEXT_VIEW(gtk_builder_get_object(builder, "text_view_comment"));
 	self->priv->check_button_signed_off_by = GTK_CHECK_BUTTON(gtk_builder_get_object(builder, "check_button_signed_off_by"));
+
+	GitgPreferences *preferences = gitg_preferences_get_default();
+	
+	gitg_data_binding_new(preferences, "message-show-right-margin",
+	                      self->priv->comment_view, "show-right-margin");
+
+	gitg_data_binding_new(preferences, "message-right-margin-at",
+	                      self->priv->comment_view, "right-margin-position");
 	
 	self->priv->hscale_context = GTK_HSCALE(gtk_builder_get_object(builder, "hscale_context"));
 	self->priv->group_context = GTK_ACTION_GROUP(gtk_builder_get_object(builder, "action_group_commit_context"));
diff --git a/gitg/gitg-preferences-dialog.c b/gitg/gitg-preferences-dialog.c
index c689e44..4dd72b2 100644
--- a/gitg/gitg-preferences-dialog.c
+++ b/gitg/gitg-preferences-dialog.c
@@ -48,6 +48,11 @@ struct _GitgPreferencesDialogPrivate
 	GtkCheckButton *history_show_virtual_staged;
 	GtkCheckButton *history_show_virtual_unstaged;
 	GtkCheckButton *check_button_collapse_inactive;
+	
+	GtkCheckButton *check_button_show_right_margin;
+	GtkLabel *label_right_margin;
+	GtkSpinButton *spin_button_right_margin;
+	
 	GtkWidget *table;
 
 	gint prev_value;
@@ -113,6 +118,15 @@ on_collapse_inactive_toggled(GtkToggleButton *button, GitgPreferencesDialog *dia
 }
 
 static void
+on_check_button_show_right_margin_toggled(GtkToggleButton *button, GitgPreferencesDialog *dialog)
+{
+	gboolean active = gtk_toggle_button_get_active (button);
+
+	gtk_widget_set_sensitive(GTK_WIDGET(dialog->priv->label_right_margin), active);
+	gtk_widget_set_sensitive(GTK_WIDGET(dialog->priv->spin_button_right_margin), active);
+}
+
+static void
 initialize_view(GitgPreferencesDialog *dialog)
 {
 	GitgPreferences *preferences = gitg_preferences_get_default();
@@ -122,6 +136,11 @@ initialize_view(GitgPreferencesDialog *dialog)
 	                  G_CALLBACK (on_collapse_inactive_toggled),
 	                  dialog);
 
+	g_signal_connect (dialog->priv->check_button_show_right_margin,
+	                  "toggled",
+	                  G_CALLBACK (on_check_button_show_right_margin_toggled),
+	                  dialog);
+
 	gitg_data_binding_new_mutual(preferences, 
 	                             "history-search-filter", 
 	                             dialog->priv->history_search_filter, 
@@ -154,6 +173,16 @@ initialize_view(GitgPreferencesDialog *dialog)
 	                             "history-show-virtual-unstaged",
 	                             dialog->priv->history_show_virtual_unstaged, 
 	                             "active");
+
+	gitg_data_binding_new_mutual(preferences,
+	                             "message-show-right-margin",
+	                             dialog->priv->check_button_show_right_margin,
+	                             "active");
+
+	gitg_data_binding_new_mutual(preferences,
+	                             "message-right-margin-at",
+	                             dialog->priv->spin_button_right_margin,
+	                             "value");
 }
 
 static void
@@ -176,6 +205,10 @@ create_preferences_dialog()
 	priv->check_button_collapse_inactive = GTK_CHECK_BUTTON(gtk_builder_get_object(b, "check_button_collapse_inactive"));
 	priv->table = GTK_WIDGET(gtk_builder_get_object(b, "table_collapse_inactive_lanes"));
 	
+	priv->check_button_show_right_margin = GTK_CHECK_BUTTON(gtk_builder_get_object(b, "check_button_show_right_margin"));
+	priv->label_right_margin = GTK_LABEL(gtk_builder_get_object(b, "label_right_margin"));
+	priv->spin_button_right_margin = GTK_SPIN_BUTTON(gtk_builder_get_object(b, "spin_button_right_margin"));
+	
 	priv->prev_value = (gint)gtk_adjustment_get_value(priv->collapse_inactive_lanes);
 	g_signal_connect(preferences_dialog, "response", G_CALLBACK(on_response), NULL);
 	
diff --git a/gitg/gitg-preferences.c b/gitg/gitg-preferences.c
index 1446f51..c101dd0 100644
--- a/gitg/gitg-preferences.c
+++ b/gitg/gitg-preferences.c
@@ -42,6 +42,9 @@ enum
 	PROP_HISTORY_SHOW_VIRTUAL_STASH,
 	PROP_HISTORY_SHOW_VIRTUAL_STAGED,
 	PROP_HISTORY_SHOW_VIRTUAL_UNSTAGED,
+	
+	PROP_MESSAGE_SHOW_RIGHT_MARGIN,
+	PROP_MESSAGE_RIGHT_MARGIN_AT,
 
 	PROP_STYLE_TEXT_FOREGROUND,
 	PROP_STYLE_TEXT_BACKGROUND,
@@ -384,6 +387,35 @@ gitg_preferences_class_init(GitgPreferencesClass *klass)
 							      TRUE,
 							      G_PARAM_READWRITE));
 
+
+	install_property_binding(PROP_MESSAGE_SHOW_RIGHT_MARGIN, 
+							 "commit/message",
+							 "show-right-margin", 
+							 wrap_get_boolean,
+							 wrap_set_boolean);
+
+	g_object_class_install_property(object_class, PROP_MESSAGE_SHOW_RIGHT_MARGIN,
+					 g_param_spec_boolean("message-show-right-margin",
+							      "MESSAGE_SHOW_RIGHT_MARGIN",
+							      "Show right margin in commit message view",
+							      TRUE,
+							      G_PARAM_READWRITE));
+
+	install_property_binding(PROP_MESSAGE_RIGHT_MARGIN_AT, 
+							 "commit/message",
+							 "right-margin-at", 
+							 wrap_get_int,
+							 wrap_set_int);
+
+	g_object_class_install_property(object_class, PROP_MESSAGE_RIGHT_MARGIN_AT,
+					 g_param_spec_int("message-right-margin-at",
+							      "MESSAGE_RIGHT_MARGIN_AT",
+							      "The column to show the right margin at",
+							      1,
+							      160,
+							      72,
+							      G_PARAM_READWRITE));
+
 	install_style_properties(object_class, PROP_STYLE_TEXT_FOREGROUND, "text");
 	install_style_properties(object_class, PROP_STYLE_ADDED_LINE_FOREGROUND, "added-line");
 	install_style_properties(object_class, PROP_STYLE_REMOVED_LINE_FOREGROUND, "removed-line");
diff --git a/gitg/gitg-preferences.xml b/gitg/gitg-preferences.xml
index d8e823c..ad89ad9 100644
--- a/gitg/gitg-preferences.xml
+++ b/gitg/gitg-preferences.xml
@@ -7,7 +7,15 @@
     <property name="step_increment">1</property>
     <property name="page_increment">1</property>
     <property name="page_size">1</property>
-    <signal after="false" name="notify::value" handler="on_collapse_inactive_lanes_changed"/>
+    <signal after="False" name="notify::value" handler="on_collapse_inactive_lanes_changed"/>
+  </object>
+  <object class="GtkAdjustment" id="spin_button_right_margin_adjustment">
+    <property name="upper">160</property>
+    <property name="lower">1</property>
+    <property name="page_increment">10</property>
+    <property name="step_increment">1</property>
+    <property name="page_size">0</property>
+    <property name="value">72</property>
   </object>
   <object class="GitgPreferencesDialog" id="dialog_preferences">
     <property name="border_width">5</property>
@@ -212,6 +220,130 @@
                 <property name="tab_fill">False</property>
               </packing>
             </child>
+            <child>
+              <object class="GtkVBox" id="vbox_commit">
+                <property name="visible">True</property>
+                <property name="spacing">18</property>
+                <child>
+                  <object class="GtkVBox" id="vbox_commit_intern">
+                    <property name="visible">True</property>
+                    <property name="border_width">12</property>
+                    <property name="spacing">6</property>
+                    <child>
+                      <object class="GtkLabel" id="label10">
+                        <property name="visible">True</property>
+                        <property name="xalign">0</property>
+                        <property name="label" translatable="yes">&lt;b&gt;Commit Message&lt;/b&gt;</property>
+                        <property name="use_markup">True</property>
+                      </object>
+                      <packing>
+                        <property name="expand">False</property>
+                        <property name="position">0</property>
+                      </packing>
+                    </child>
+                    <child>
+                      <object class="GtkHBox" id="hbox_commit_message">
+                        <property name="visible">True</property>
+                        <child>
+                          <object class="GtkLabel" id="label12">
+                            <property name="visible">True</property>
+                            <property name="label">    </property>
+                          </object>
+                          <packing>
+                            <property name="expand">False</property>
+                            <property name="fill">False</property>
+                            <property name="position">0</property>
+                          </packing>
+                        </child>
+                        <child>
+                          <object class="GtkVBox" id="vbox_commit_message">
+                            <property name="visible">True</property>
+                            <property name="spacing">6</property>
+                            <child>
+                              <object class="GtkCheckButton" id="check_button_show_right_margin">
+                                <property name="label" translatable="yes">Display right _margin</property>
+                                <property name="use_underline">True</property>
+                                <property name="visible">True</property>
+                                <property name="can_focus">True</property>
+                                <property name="receives_default">False</property>
+                                <property name="draw_indicator">True</property>
+                                <property name="active">True</property>
+                              </object>
+                              <packing>
+                                <property name="position">0</property>
+                              </packing>
+                            </child>
+                            <child>
+                              <object class="GtkHBox" id="hbox_right_margin">
+                                <property name="visible">True</property>
+                                <property name="spacing">6</property>
+                                <child>
+                                  <object class="GtkLabel" id="label_right_margin">
+                                    <property name="visible">True</property>
+                                    <property name="label" translatable="yes">_Right margin at column:</property>
+                                    <property name="use_underline">True</property>
+                                    <property name="use_markup">False</property>
+                                    <property name="justify">GTK_JUSTIFY_LEFT</property>
+                                    <property name="wrap">False</property>
+                                    <property name="selectable">False</property>
+                                    <property name="xalign">0</property>
+                                    <property name="yalign">0.5</property>
+                                    <property name="xpad">0</property>
+                                    <property name="ypad">0</property>
+                                  </object>
+                                  <packing>
+                                    <property name="padding">0</property>
+                                    <property name="expand">False</property>
+                                    <property name="fill">False</property>
+                                  </packing>
+                                </child>
+                                <child>
+                                  <object class="GtkSpinButton" id="spin_button_right_margin">
+                                    <property name="visible">True</property>
+                                    <property name="can_focus">True</property>
+                                    <property name="climb_rate">1</property>
+                                    <property name="digits">0</property>
+                                    <property name="numeric">True</property>
+                                    <property name="update_policy">GTK_UPDATE_ALWAYS</property>
+                                    <property name="snap_to_ticks">True</property>
+                                    <property name="wrap">False</property>
+                                    <property name="adjustment">spin_button_right_margin_adjustment</property>
+                                  </object>
+                                  <packing>
+                                    <property name="padding">0</property>
+                                    <property name="expand">False</property>
+                                    <property name="fill">False</property>
+                                  </packing>
+                                </child>
+                              </object>
+                            </child>
+                          </object>
+                          <packing>
+                            <property name="position">1</property>
+                          </packing>
+                        </child>
+                      </object>
+                      <packing>
+                        <property name="expand">False</property>
+                        <property name="position">1</property>
+                      </packing>
+                    </child>
+                  </object>
+                  <packing>
+                    <property name="position">0</property>
+                  </packing>
+                </child>
+              </object>
+            </child>
+            <child type="tab">
+              <object class="GtkLabel" id="label_commit">
+                <property name="visible">True</property>
+                <property name="label" translatable="yes">Commit</property>
+              </object>
+              <packing>
+                <property name="tab_fill">False</property>
+              </packing>
+            </child>
           </object>
           <packing>
             <property name="position">1</property>
diff --git a/gitg/gitg-ui.xml b/gitg/gitg-ui.xml
index 46bc68c..9ea723e 100644
--- a/gitg/gitg-ui.xml
+++ b/gitg/gitg-ui.xml
@@ -874,7 +874,7 @@
                             <property name="vscrollbar_policy">automatic</property>
                             <property name="shadow_type">etched-in</property>
                             <child>
-                              <object class="GtkTextView" id="text_view_comment">
+                              <object class="GtkSourceView" id="text_view_comment">
                                 <property name="visible">True</property>
                                 <property name="can_focus">True</property>
                                 <property name="wrap_mode">word-char</property>



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]