2014-10-10 00:17:10 +00:00
|
|
|
#include <gtk/gtk.h>
|
|
|
|
|
|
|
|
static void
|
|
|
|
fill_text_view (GtkWidget *tv, const gchar *text)
|
|
|
|
{
|
2020-07-24 13:54:49 +00:00
|
|
|
int i;
|
2014-10-10 00:17:10 +00:00
|
|
|
GString *s;
|
|
|
|
|
|
|
|
s = g_string_new ("");
|
|
|
|
for (i = 0; i < 200; i++)
|
|
|
|
g_string_append_printf (s, "%s %d\n", text, i);
|
|
|
|
|
|
|
|
gtk_text_buffer_set_text (gtk_text_view_get_buffer (GTK_TEXT_VIEW (tv)),
|
|
|
|
g_string_free (s, FALSE), -1);
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
main (int argc, char *argv[])
|
|
|
|
{
|
|
|
|
GtkWidget *win, *box, *tv, *sw, *sb;
|
|
|
|
GtkAdjustment *adj;
|
|
|
|
|
2016-12-28 13:53:22 +00:00
|
|
|
gtk_init ();
|
2014-10-10 00:17:10 +00:00
|
|
|
|
2020-02-14 19:55:36 +00:00
|
|
|
win = gtk_window_new ();
|
2014-10-10 00:17:10 +00:00
|
|
|
gtk_window_set_default_size (GTK_WINDOW (win), 640, 480);
|
|
|
|
|
|
|
|
box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 5);
|
2020-05-02 21:26:54 +00:00
|
|
|
gtk_window_set_child (GTK_WINDOW (win), box);
|
2014-10-10 00:17:10 +00:00
|
|
|
|
2020-06-24 15:25:09 +00:00
|
|
|
sw = gtk_scrolled_window_new ();
|
2014-10-10 00:17:10 +00:00
|
|
|
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw),
|
|
|
|
GTK_POLICY_NEVER,
|
|
|
|
GTK_POLICY_EXTERNAL);
|
2020-05-10 21:26:42 +00:00
|
|
|
gtk_widget_set_hexpand (sw, TRUE);
|
2020-05-09 12:26:52 +00:00
|
|
|
gtk_box_append (GTK_BOX (box), sw);
|
2014-10-10 00:17:10 +00:00
|
|
|
tv = gtk_text_view_new ();
|
|
|
|
fill_text_view (tv, "Left");
|
2020-05-02 04:51:20 +00:00
|
|
|
gtk_scrolled_window_set_child (GTK_SCROLLED_WINDOW (sw), tv);
|
2014-10-10 00:17:10 +00:00
|
|
|
|
|
|
|
adj = gtk_scrolled_window_get_vadjustment (GTK_SCROLLED_WINDOW (sw));
|
|
|
|
|
2020-06-24 15:25:09 +00:00
|
|
|
sw = gtk_scrolled_window_new ();
|
|
|
|
gtk_scrolled_window_set_vadjustment (GTK_SCROLLED_WINDOW (sw), adj);
|
2014-10-10 00:17:10 +00:00
|
|
|
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw),
|
|
|
|
GTK_POLICY_NEVER,
|
|
|
|
GTK_POLICY_EXTERNAL);
|
2020-05-10 21:26:42 +00:00
|
|
|
gtk_widget_set_hexpand (sw, TRUE);
|
2020-05-09 12:26:52 +00:00
|
|
|
gtk_box_append (GTK_BOX (box), sw);
|
2014-10-10 00:17:10 +00:00
|
|
|
tv = gtk_text_view_new ();
|
|
|
|
fill_text_view (tv, "Middle");
|
2020-05-02 04:51:20 +00:00
|
|
|
gtk_scrolled_window_set_child (GTK_SCROLLED_WINDOW (sw), tv);
|
2014-10-10 00:17:10 +00:00
|
|
|
|
2020-06-24 15:25:09 +00:00
|
|
|
sw = gtk_scrolled_window_new ();
|
|
|
|
gtk_scrolled_window_set_vadjustment (GTK_SCROLLED_WINDOW (sw), adj);
|
2014-10-10 00:17:10 +00:00
|
|
|
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw),
|
|
|
|
GTK_POLICY_NEVER,
|
|
|
|
GTK_POLICY_EXTERNAL);
|
2020-05-10 21:26:42 +00:00
|
|
|
gtk_widget_set_hexpand (sw, TRUE);
|
2020-05-09 12:26:52 +00:00
|
|
|
gtk_box_append (GTK_BOX (box), sw);
|
2014-10-10 00:17:10 +00:00
|
|
|
tv = gtk_text_view_new ();
|
|
|
|
fill_text_view (tv, "Right");
|
2020-05-02 04:51:20 +00:00
|
|
|
gtk_scrolled_window_set_child (GTK_SCROLLED_WINDOW (sw), tv);
|
2014-10-10 00:17:10 +00:00
|
|
|
|
|
|
|
sb = gtk_scrollbar_new (GTK_ORIENTATION_VERTICAL, adj);
|
|
|
|
|
2020-05-09 12:26:52 +00:00
|
|
|
gtk_box_append (GTK_BOX (box), sb);
|
2014-10-10 00:17:10 +00:00
|
|
|
|
2017-01-19 09:02:04 +00:00
|
|
|
gtk_widget_show (win);
|
2014-10-10 00:17:10 +00:00
|
|
|
|
2020-02-10 03:24:47 +00:00
|
|
|
while (TRUE)
|
|
|
|
g_main_context_iteration (NULL, TRUE);
|
2014-10-10 00:17:10 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|