Branch: refs/heads/master Author: Enrico Tröger enrico.troeger@uvena.de Committer: Frank Lanitz frank@frank.uvena.de Date: Fri, 18 Oct 2013 09:11:20 UTC Commit: cd1214af29fabc6aeec473dd773704e219496c4b https://github.com/geany/geany-plugins/commit/cd1214af29fabc6aeec473dd773704...
Log Message: ----------- Add a little statusbar below the commit message text widget
Display line and column number below the commit message widget in the commit dialog. This helps to see how long the entered message is, e.g. when you want to ensure GIT commit messages' first line is only about 72 characters long.
Modified Paths: -------------- geanyvc/src/geanyvc.c
Modified: geanyvc/src/geanyvc.c 42 files changed, 40 insertions(+), 2 deletions(-) =================================================================== @@ -1301,6 +1301,26 @@ static void commit_tree_selection_changed_cb(GtkTreeSelection *sel, GtkTextView g_free(path); }
+static gboolean commit_text_line_number_update_cb(GtkWidget *widget, GdkEvent *event, + gpointer user_data) +{ + GtkWidget *text_view = widget; + GtkLabel *line_column_label = GTK_LABEL(user_data); + GtkTextBuffer *buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(text_view)); + GtkTextMark *mark = gtk_text_buffer_get_insert(buffer); + GtkTextIter iter; + gint line, column; + gchar text[64]; + + gtk_text_buffer_get_iter_at_mark(buffer, &iter, mark); + line = gtk_text_iter_get_line(&iter) + 1; + column = gtk_text_iter_get_line_offset(&iter); + + g_snprintf(text, sizeof(text), _("Line :%d Column: %d"), line, column); + gtk_label_set_text(line_column_label, text); + + return FALSE; +}
static GtkWidget * create_commitDialog(void) @@ -1323,6 +1343,8 @@ static void commit_tree_selection_changed_cb(GtkTreeSelection *sel, GtkTextView GtkWidget *btnCancel; GtkWidget *btnCommit; GtkWidget *select_cbox; + GtkWidget *commit_text_vbox; + GtkWidget *lineColumnLabel; GtkTreeSelection *sel;
gchar *rcstyle = g_strdup_printf("style "geanyvc-diff-font"\n" @@ -1408,14 +1430,17 @@ static void commit_tree_selection_changed_cb(GtkTreeSelection *sel, GtkTextView gtk_container_add(GTK_CONTAINER(frame1), alignment1); gtk_alignment_set_padding(GTK_ALIGNMENT(alignment1), 0, 0, 12, 0);
+ commit_text_vbox = gtk_vbox_new(FALSE, 0); + gtk_widget_show(commit_text_vbox); + gtk_container_add(GTK_CONTAINER(alignment1), commit_text_vbox); + scrolledwindow3 = gtk_scrolled_window_new(NULL, NULL); gtk_widget_show(scrolledwindow3); - gtk_container_add(GTK_CONTAINER(alignment1), scrolledwindow3); + gtk_box_pack_start(GTK_BOX(commit_text_vbox), scrolledwindow3, TRUE, TRUE, 0); gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolledwindow3), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(scrolledwindow3), GTK_SHADOW_IN);
- textCommitMessage = gtk_text_view_new(); gtk_widget_show(textCommitMessage); gtk_container_add(GTK_CONTAINER(scrolledwindow3), textCommitMessage); @@ -1428,6 +1453,12 @@ static void commit_tree_selection_changed_cb(GtkTreeSelection *sel, GtkTextView gtk_frame_set_label_widget(GTK_FRAME(frame1), label1); gtk_label_set_use_markup(GTK_LABEL(label1), TRUE);
+ /* line/column status label */ + lineColumnLabel = gtk_label_new(""); + gtk_misc_set_alignment(GTK_MISC(lineColumnLabel), 0, 0.5); + gtk_box_pack_end(GTK_BOX(commit_text_vbox), lineColumnLabel, TRUE, TRUE, 0); + gtk_widget_show(lineColumnLabel); + dialog_action_area1 = GTK_DIALOG(commitDialog)->action_area; gtk_widget_show(dialog_action_area1); gtk_button_box_set_layout(GTK_BUTTON_BOX(dialog_action_area1), GTK_BUTTONBOX_END); @@ -1444,6 +1475,13 @@ static void commit_tree_selection_changed_cb(GtkTreeSelection *sel, GtkTextView gtk_tree_selection_set_mode(sel, GTK_SELECTION_SINGLE); g_signal_connect(sel, "changed", G_CALLBACK(commit_tree_selection_changed_cb), textDiff);
+ g_signal_connect(textCommitMessage, "key-release-event", + G_CALLBACK(commit_text_line_number_update_cb), lineColumnLabel); + g_signal_connect(textCommitMessage, "button-release-event", + G_CALLBACK(commit_text_line_number_update_cb), lineColumnLabel); + /* initial setup */ + commit_text_line_number_update_cb(textCommitMessage, NULL, lineColumnLabel); + /* Store pointers to all widgets, for use by lookup_widget(). */ GLADE_HOOKUP_OBJECT_NO_REF(commitDialog, commitDialog, "commitDialog"); GLADE_HOOKUP_OBJECT_NO_REF(commitDialog, dialog_vbox1, "dialog_vbox1");
-------------- This E-Mail was brought to you by github_commit_mail.py (Source: https://github.com/geany/infrastructure).
plugins-commits@lists.geany.org