Kaydet (Commit) 871d1663 authored tarafından Enrico Tröger's avatar Enrico Tröger

Use a table to layout the word count dialog.


git-svn-id: https://geany.svn.sourceforge.net/svnroot/geany/trunk@1079 ea778897-0a13-0410-b9d1-a72fbfd435f5
üst 33425f1a
......@@ -4,6 +4,7 @@
src/prefs.c, src/vte.c, src/vte.h:
Added option to execute programs in the VTE instead of executing
them in a terminal emulation window (closes #1594456).
* src/dialogs.c: Use a table to layout the word count dialog.
2006-12-09 Nick Treleaven <nick.treleaven@btinternet.com>
......
......@@ -429,10 +429,10 @@ void dialogs_show_open_font()
void dialogs_show_word_count()
{
GtkWidget *dialog, *label, *vbox;
GtkWidget *dialog, *label, *vbox, *table;
gint idx;
guint chars, lines, words;
gchar *string, *text, *range;
gchar *text, *range;
idx = document_get_cur_idx();
if (idx == -1 || ! doc_list[idx].is_valid) return;
......@@ -446,23 +446,76 @@ void dialogs_show_word_count()
{
text = g_malloc0(sci_get_selected_text_length(doc_list[idx].sci) + 1);
sci_get_selected_text(doc_list[idx].sci, text);
utils_wordcount(text, &chars, &lines, &words);
g_free(text);
range = _("selection");
}
else
{
text = g_malloc(sci_get_length(doc_list[idx].sci) + 1);
sci_get_text(doc_list[idx].sci, sci_get_length(doc_list[idx].sci) + 1 , text);
utils_wordcount(text, &chars, &lines, &words);
g_free(text);
range = _("whole document");
}
string = g_strdup_printf(_("Range:\t\t%s\n\nLines:\t\t%d\nWords:\t\t%d\nCharacters:\t%d"),
range, lines, words, chars);
label = gtk_label_new(string);
g_free(string);
gtk_container_add(GTK_CONTAINER(vbox), label);
utils_wordcount(text, &chars, &lines, &words);
g_free(text);
table = gtk_table_new(4, 2, FALSE);
gtk_table_set_row_spacings(GTK_TABLE(table), 5);
gtk_table_set_col_spacings(GTK_TABLE(table), 10);
label = gtk_label_new(_("Range:"));
gtk_table_attach(GTK_TABLE(table), label, 0, 1, 0, 1,
(GtkAttachOptions) (GTK_FILL),
(GtkAttachOptions) (0), 0, 0);
gtk_misc_set_alignment(GTK_MISC(label), 1, 0);
label = gtk_label_new(range);
gtk_table_attach(GTK_TABLE(table), label, 1, 2, 0, 1,
(GtkAttachOptions) (GTK_FILL),
(GtkAttachOptions) (0), 0, 0);
gtk_misc_set_alignment(GTK_MISC(label), 0, 0);
label = gtk_label_new(_("Lines:"));
gtk_table_attach(GTK_TABLE(table), label, 0, 1, 1, 2,
(GtkAttachOptions) (GTK_FILL),
(GtkAttachOptions) (0), 0, 0);
gtk_misc_set_alignment(GTK_MISC(label), 1, 0);
text = g_strdup_printf("%d", lines);
label = gtk_label_new(text);
gtk_table_attach(GTK_TABLE(table), label, 1, 2, 1, 2,
(GtkAttachOptions) (GTK_FILL),
(GtkAttachOptions) (0), 0, 0);
gtk_misc_set_alignment(GTK_MISC(label), 0, 0);
g_free(text);
label = gtk_label_new(_("Words:"));
gtk_table_attach(GTK_TABLE(table), label, 0, 1, 2, 3,
(GtkAttachOptions) (GTK_FILL),
(GtkAttachOptions) (0), 0, 0);
gtk_misc_set_alignment(GTK_MISC(label), 1, 0);
text = g_strdup_printf("%d", words);
label = gtk_label_new(text);
gtk_table_attach(GTK_TABLE(table), label, 1, 2, 2, 3,
(GtkAttachOptions) (GTK_FILL),
(GtkAttachOptions) (0), 0, 0);
gtk_misc_set_alignment(GTK_MISC(label), 0, 0);
g_free(text);
label = gtk_label_new(_("Characters:"));
gtk_table_attach(GTK_TABLE(table), label, 0, 1, 3, 4,
(GtkAttachOptions) (GTK_FILL),
(GtkAttachOptions) (0), 0, 0);
gtk_misc_set_alignment(GTK_MISC(label), 1, 0);
text = g_strdup_printf("%d", chars);
label = gtk_label_new(text);
gtk_table_attach(GTK_TABLE(table), label, 1, 2, 3, 4,
(GtkAttachOptions) (GTK_FILL),
(GtkAttachOptions) (0), 0, 0);
gtk_misc_set_alignment(GTK_MISC(label), 0, 0);
g_free(text);
gtk_container_add(GTK_CONTAINER(vbox), table);
g_signal_connect(dialog, "response", G_CALLBACK(gtk_widget_destroy), dialog);
g_signal_connect(dialog, "delete-event", G_CALLBACK(gtk_widget_destroy), dialog);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment