[gedit] Bug 306982 - Show bracket matching updates in statusbar
- From: Garrett Regier <gregier src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gedit] Bug 306982 - Show bracket matching updates in statusbar
- Date: Sat, 15 May 2010 17:20:24 +0000 (UTC)
commit ea89039d61753647ec2474ec80ff191ab8ea90b4
Author: Garrett Regier <alias301 gmail com>
Date: Sat May 15 10:12:49 2010 -0700
Bug 306982 - Show bracket matching updates in statusbar
gedit/gedit-window-private.h | 5 ++++-
gedit/gedit-window.c | 42 ++++++++++++++++++++++++++++++++++++++++++
2 files changed, 46 insertions(+), 1 deletions(-)
---
diff --git a/gedit/gedit-window-private.h b/gedit/gedit-window-private.h
index bbd164d..898a7fa 100644
--- a/gedit/gedit-window-private.h
+++ b/gedit/gedit-window-private.h
@@ -68,9 +68,12 @@ struct _GeditWindowPrivate
gboolean fullscreen_animation_enter;
/* statusbar and context ids for statusbar messages */
- GtkWidget *statusbar;
+ GtkWidget *statusbar;
guint generic_message_cid;
guint tip_message_cid;
+ guint bracket_match_message_cid;
+
+ /* signal handler ids */
guint tab_width_id;
guint spaces_instead_of_tabs_id;
guint language_changed_id;
diff --git a/gedit/gedit-window.c b/gedit/gedit-window.c
index 69f2255..4482ea0 100644
--- a/gedit/gedit-window.c
+++ b/gedit/gedit-window.c
@@ -2080,6 +2080,8 @@ create_statusbar (GeditWindow *window,
(GTK_STATUSBAR (window->priv->statusbar), "generic_message");
window->priv->tip_message_cid = gtk_statusbar_get_context_id
(GTK_STATUSBAR (window->priv->statusbar), "tip_message");
+ window->priv->bracket_match_message_cid = gtk_statusbar_get_context_id
+ (GTK_STATUSBAR (window->priv->statusbar), "bracket_match_message");
gtk_box_pack_end (GTK_BOX (main_box),
window->priv->statusbar,
@@ -2191,6 +2193,42 @@ clone_window (GeditWindow *origin)
}
static void
+bracket_matched_cb (GtkSourceBuffer *buffer,
+ GtkTextIter *iter,
+ GtkSourceBracketMatchType *result,
+ GeditWindow *window)
+{
+ if (buffer != GTK_SOURCE_BUFFER (gedit_window_get_active_document (window)))
+ return;
+
+ switch (*result)
+ {
+ case GTK_SOURCE_BRACKET_MATCH_NONE:
+ gtk_statusbar_pop (GTK_STATUSBAR (window->priv->statusbar),
+ window->priv->bracket_match_message_cid);
+ break;
+ case GTK_SOURCE_BRACKET_MATCH_OUT_OF_RANGE:
+ gedit_statusbar_flash_message (GEDIT_STATUSBAR (window->priv->statusbar),
+ window->priv->bracket_match_message_cid,
+ _("Bracket match is out of range"));
+ break;
+ case GTK_SOURCE_BRACKET_MATCH_NOT_FOUND:
+ gedit_statusbar_flash_message (GEDIT_STATUSBAR (window->priv->statusbar),
+ window->priv->bracket_match_message_cid,
+ _("Bracket match not found"));
+ break;
+ case GTK_SOURCE_BRACKET_MATCH_FOUND:
+ gedit_statusbar_flash_message (GEDIT_STATUSBAR (window->priv->statusbar),
+ window->priv->bracket_match_message_cid,
+ _("Bracket match found on line: %d"),
+ gtk_text_iter_get_line (iter) + 1);
+ break;
+ default:
+ g_assert_not_reached ();
+ }
+}
+
+static void
update_cursor_position_statusbar (GtkTextBuffer *buffer,
GeditWindow *window)
{
@@ -3340,6 +3378,10 @@ notebook_tab_added (GeditNotebook *notebook,
window);
g_signal_connect (doc,
+ "bracket-matched",
+ G_CALLBACK (bracket_matched_cb),
+ window);
+ g_signal_connect (doc,
"cursor-moved",
G_CALLBACK (update_cursor_position_statusbar),
window);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]