static void docinfo_real (PlumaDocument *doc, DocInfoDialog *dialog) { GtkTextIter start, end; gint words = 0; gint chars = 0; gint white_chars = 0; gint lines = 0; gint bytes = 0; gchar *tmp_str; gchar *doc_name; pluma_debug (DEBUG_PLUGINS); gtk_text_buffer_get_bounds (GTK_TEXT_BUFFER (doc), &start, &end); lines = gtk_text_buffer_get_line_count (GTK_TEXT_BUFFER (doc)); calculate_info (doc, &start, &end, &chars, &words, &white_chars, &bytes); if (chars == 0) lines = 0; pluma_debug_message (DEBUG_PLUGINS, "Chars: %d", chars); pluma_debug_message (DEBUG_PLUGINS, "Lines: %d", lines); pluma_debug_message (DEBUG_PLUGINS, "Words: %d", words); pluma_debug_message (DEBUG_PLUGINS, "Chars non-space: %d", chars - white_chars); pluma_debug_message (DEBUG_PLUGINS, "Bytes: %d", bytes); doc_name = pluma_document_get_short_name_for_display (doc); tmp_str = g_strdup_printf ("<span weight=\"bold\">%s</span>", doc_name); gtk_label_set_markup (GTK_LABEL (dialog->file_name_label), tmp_str); g_free (doc_name); g_free (tmp_str); tmp_str = g_strdup_printf("%d", lines); gtk_label_set_text (GTK_LABEL (dialog->lines_label), tmp_str); g_free (tmp_str); tmp_str = g_strdup_printf("%d", words); gtk_label_set_text (GTK_LABEL (dialog->words_label), tmp_str); g_free (tmp_str); tmp_str = g_strdup_printf("%d", chars); gtk_label_set_text (GTK_LABEL (dialog->chars_label), tmp_str); g_free (tmp_str); tmp_str = g_strdup_printf("%d", chars - white_chars); gtk_label_set_text (GTK_LABEL (dialog->chars_ns_label), tmp_str); g_free (tmp_str); tmp_str = g_strdup_printf("%d", bytes); gtk_label_set_text (GTK_LABEL (dialog->bytes_label), tmp_str); g_free (tmp_str); }
static gchar * tab_get_name (PlumaTab *tab) { PlumaDocument *doc; gchar *name; gchar *docname; gchar *tab_name; g_return_val_if_fail (PLUMA_IS_TAB (tab), NULL); doc = pluma_tab_get_document (tab); name = pluma_document_get_short_name_for_display (doc); /* Truncate the name so it doesn't get insanely wide. */ docname = pluma_utils_str_middle_truncate (name, MAX_DOC_NAME_LENGTH); if (gtk_text_buffer_get_modified (GTK_TEXT_BUFFER (doc))) { if (pluma_document_get_readonly (doc)) { tab_name = g_markup_printf_escaped ("<i>%s</i> [<i>%s</i>]", docname, _("Read-Only")); } else { tab_name = g_markup_printf_escaped ("<i>%s</i>", docname); } } else { if (pluma_document_get_readonly (doc)) { tab_name = g_markup_printf_escaped ("%s [<i>%s</i>]", docname, _("Read-Only")); } else { tab_name = g_markup_escape_text (docname, -1); } } g_free (docname); g_free (name); return tab_name; }