[gtranslator] Make the context information smarter.
- From: Ignacio Casal Quinteiro <icq src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtranslator] Make the context information smarter.
- Date: Wed, 14 Apr 2010 14:20:39 +0000 (UTC)
commit b175293dcaa6a49c0a99eae52f5d5d34fd5d0974
Author: Ignacio Casal Quinteiro <icq gnome org>
Date: Wed Apr 14 16:19:17 2010 +0200
Make the context information smarter.
Show only the header when there is info for that header and add
a bold tag for the headers. Also sort the information in a more
useful way.
.../source-code-view/gtr-source-code-view-plugin.c | 13 ++++-
src/gtr-context.c | 58 ++++++++++++--------
2 files changed, 45 insertions(+), 26 deletions(-)
---
diff --git a/plugins/source-code-view/gtr-source-code-view-plugin.c b/plugins/source-code-view/gtr-source-code-view-plugin.c
index 4518cae..062bf54 100644
--- a/plugins/source-code-view/gtr-source-code-view-plugin.c
+++ b/plugins/source-code-view/gtr-source-code-view-plugin.c
@@ -429,17 +429,26 @@ showed_message_cb (GtrTab * tab,
GtkTextView *view;
GtrContextPanel *panel;
GtkTextMark *path_start, *path_end;
+ GtkTextTag *bold;
panel = gtr_tab_get_context_panel (tab);
view = gtr_context_panel_get_context_text_view (panel);
buffer = gtk_text_view_get_buffer (view);
- gtk_text_buffer_get_iter_at_offset (buffer, &iter, 0);
+ gtk_text_buffer_get_end_iter (buffer, &iter);
+
+ /* Create the bold tag for header */
+ bold = gtk_text_buffer_create_tag (buffer, NULL, "weight", PANGO_WEIGHT_BOLD,
+ "weight-set", TRUE, NULL);
path_start = gtk_text_buffer_create_mark (buffer,
"path_start", &iter, TRUE);
- gtk_text_buffer_insert (buffer, &iter, _("Paths:\n"), -1);
+
+ if (gtk_text_buffer_get_char_count (buffer) != 0)
+ gtk_text_buffer_insert (buffer, &iter, "\n", 1);
+ gtk_text_buffer_insert_with_tags (buffer, &iter, _("Paths:"), -1, bold, NULL);
+ gtk_text_buffer_insert (buffer, &iter, "\n", 1);
filename = gtr_msg_get_filename (msg, i);
while (filename)
diff --git a/src/gtr-context.c b/src/gtr-context.c
index a73b845..fbd6a5b 100644
--- a/src/gtr-context.c
+++ b/src/gtr-context.c
@@ -33,42 +33,52 @@
GtrContextPanelPrivate))
G_DEFINE_TYPE (GtrContextPanel, gtr_context_panel, GTK_TYPE_VBOX)
- struct _GtrContextPanelPrivate
- {
- GtkWidget *context;
- GtrTab *tab;
- };
+struct _GtrContextPanelPrivate
+{
+ GtkWidget *context;
+
+ GtrTab *tab;
+};
+
+static void
+add_text (GtkTextBuffer *buffer, GtkTextTag *tag, GtkTextIter *pos,
+ const gchar *header, const gchar *text)
+{
+ if (text && *text != '\0')
+ {
+ gtk_text_buffer_insert_with_tags (buffer, pos, header, -1, tag, NULL);
+ gtk_text_buffer_insert (buffer, pos, "\n", 1);
+ gtk_text_buffer_insert (buffer, pos, text, -1);
+ }
+}
- static void
- showed_message_cb (GtrTab * tab, GtrMsg * msg, GtrContextPanel * panel)
+static void
+showed_message_cb (GtrTab * tab, GtrMsg * msg, GtrContextPanel * panel)
{
GtkTextBuffer *buffer;
GtkTextIter iter;
- gchar *extracted;
- gchar *context;
- gchar *format;
- gchar *toset;
+ GtkTextTag *bold;
buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (panel->priv->context));
gtk_text_buffer_set_text (buffer, "", 0);
- gtk_text_buffer_get_iter_at_offset (buffer, &iter, 0);
-
- format = g_strconcat (_("Format:"), gtr_msg_get_format (msg), NULL);
- context = g_strconcat (_("Context:"), gtr_msg_get_msgctxt (msg), NULL);
- extracted =
- g_strconcat (_("Extracted comments:"),
- gtr_msg_get_extracted_comments (msg), NULL);
+ gtk_text_buffer_get_start_iter (buffer, &iter);
- toset = g_strdup_printf ("%s\n%s\n%s", format, context, extracted);
+ /* Create the bold tag for headers */
+ bold = gtk_text_buffer_create_tag (buffer, NULL, "weight", PANGO_WEIGHT_BOLD,
+ "weight-set", TRUE, NULL);
- g_free (format);
- g_free (context);
- g_free (extracted);
+ /* Extracted comments */
+ add_text (buffer, bold, &iter, _("Extracted comments:"),
+ gtr_msg_get_extracted_comments (msg));
- gtk_text_buffer_insert (buffer, &iter, toset, -1);
+ /* Context */
+ add_text (buffer, bold, &iter, _("Context:"),
+ gtr_msg_get_msgctxt (msg));
- g_free (toset);
+ /* Format */
+ add_text (buffer, bold, &iter, _("Format:"),
+ gtr_msg_get_format (msg));
}
static void
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]