Balsa information window
- From: Peter Bloomfield <PeterBloomfield bellsouth net>
- To: Balsa list <balsa-list gnome org>
- Subject: Balsa information window
- Date: Wed, 28 May 2003 21:58:16 -0400
The information window has been mentioned as being broken wrt
wrapping. This patch (to current cvs, but probably to most 2.0.x
source trees) uses a GtkTextView widget instead of the current
GtkTreeView--see how you like it!
The GtkTreeView was used only because it's the logical successor to
GtkCList, which was used before, and...oh, well...
Peter
Index: src/information-dialog.c
===================================================================
RCS file: /cvs/gnome/balsa/src/information-dialog.c,v
retrieving revision 1.16
diff -u -r1.16 information-dialog.c
--- src/information-dialog.c 21 Mar 2003 15:53:24 -0000 1.16
+++ src/information-dialog.c 29 May 2003 01:52:07 -0000
@@ -45,11 +45,11 @@
gpointer data)
{
GtkWidget *list = data;
- GtkTreeModel *model = gtk_tree_view_get_model(GTK_TREE_VIEW(list));
+ GtkTextBuffer *buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(list));
switch (response) {
case GTK_RESPONSE_APPLY:
- gtk_list_store_clear(GTK_LIST_STORE(model));
+ gtk_text_buffer_set_text(buffer, "", 0);
break;
default:
gtk_widget_destroy(GTK_WIDGET(dialog));
@@ -154,21 +154,14 @@
static GtkWidget *
balsa_information_list_new(void)
{
- GtkListStore *list_store;
- GtkTreeView *view;
- GtkCellRenderer *renderer;
- GtkTreeViewColumn *column;
-
- list_store = gtk_list_store_new(1, G_TYPE_STRING);
- view = GTK_TREE_VIEW(gtk_tree_view_new_with_model
- (GTK_TREE_MODEL(list_store)));
- g_object_unref(list_store);
-
- renderer = gtk_cell_renderer_text_new();
- column = gtk_tree_view_column_new_with_attributes(NULL, renderer,
- "text", 0, NULL);
- gtk_tree_view_append_column(view, column);
- gtk_tree_view_set_headers_visible(view, FALSE);
+ GtkTextView *view;
+
+ view = GTK_TEXT_VIEW(gtk_text_view_new());
+ gtk_text_view_set_editable(view, FALSE);
+ gtk_text_view_set_left_margin(view, 14);
+ gtk_text_view_set_indent(view, -12);
+ gtk_text_view_set_right_margin(view, 2);
+ gtk_text_view_set_wrap_mode(view, GTK_WRAP_WORD);
return GTK_WIDGET(view);
}
@@ -183,15 +176,7 @@
balsa_information_list(LibBalsaInformationType type, char *msg)
{
static GtkWidget *information_list = NULL;
- gchar *outstr;
- GtkTreeModel *model;
- GtkTreeIter iter;
- GtkTreePath *path;
-
- outstr = msg;
- /* this may break UNICODE strings */
- for(;*msg; msg++)
- if(*msg == '\n') *msg= ' ';
+ GtkTextBuffer *buffer;
if (information_list == NULL) {
GtkWidget *information_dialog;
@@ -212,8 +197,6 @@
/* Reset the policy gtk_dialog_new makes itself non-resizable */
gtk_window_set_resizable(GTK_WINDOW(information_dialog), TRUE);
gtk_window_set_default_size(GTK_WINDOW(information_dialog), 350, 200);
- gtk_container_set_border_width(GTK_CONTAINER(GTK_WINDOW(
- information_dialog)), 6);
gtk_box_set_spacing(GTK_BOX(GTK_DIALOG(information_dialog)->vbox), 12);
gtk_window_set_wmclass(GTK_WINDOW(information_dialog),
"Information", "Balsa");
@@ -229,8 +212,7 @@
GTK_POLICY_AUTOMATIC);
gtk_box_pack_start(GTK_BOX(GTK_DIALOG(information_dialog)->vbox),
scrolled_window, TRUE, TRUE, 1);
- gtk_container_set_border_width(GTK_CONTAINER(GTK_SCROLLED_WINDOW(
- scrolled_window)), 6);
+ gtk_container_set_border_width(GTK_CONTAINER(scrolled_window), 6);
gtk_widget_show(scrolled_window);
/* The list itself */
@@ -241,23 +223,17 @@
G_CALLBACK(balsa_information_list_response_cb),
information_list);
- gtk_widget_show(information_list);
-
- gtk_widget_show(information_dialog);
+ gtk_widget_show_all(information_dialog);
}
- model = gtk_tree_view_get_model(GTK_TREE_VIEW(information_list));
- gtk_list_store_append(GTK_LIST_STORE(model), &iter);
- gtk_list_store_set(GTK_LIST_STORE(model), &iter, 0, outstr, -1);
- path = gtk_tree_model_get_path(model, &iter);
- gtk_tree_view_scroll_to_cell(GTK_TREE_VIEW(information_list),
- path, NULL, TRUE, 1, 0);
- gtk_tree_path_free(path);
-
- /* FIXME: Colour hilight the list */
-
- gnome_appbar_set_status(balsa_app.appbar, outstr);
+ buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(information_list));
+ gtk_text_buffer_insert_at_cursor(buffer, msg, -1);
+ gtk_text_buffer_insert_at_cursor(buffer, "\n", 1);
+ gtk_text_view_scroll_to_mark(GTK_TEXT_VIEW(information_list),
+ gtk_text_buffer_get_insert(buffer),
+ 0, FALSE, 0, 0);
+ gnome_appbar_set_status(balsa_app.appbar, msg);
}
static void
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]