vte r2228 - in trunk: . src



Author: chpe
Date: Sat Nov 29 17:52:07 2008
New Revision: 2228
URL: http://svn.gnome.org/viewvc/vte?rev=2228&view=rev

Log:
	* src/vteapp.c: (main): Add options to use a GtkScrolledWindow as the
	terminal's container, and to set its vertical scrollbar policy, to
	allow testing VteTerminal in a scrolled window.

Modified:
   trunk/ChangeLog
   trunk/src/vteapp.c

Modified: trunk/src/vteapp.c
==============================================================================
--- trunk/src/vteapp.c	(original)
+++ trunk/src/vteapp.c	Sat Nov 29 17:52:07 2008
@@ -17,7 +17,7 @@
  */
 
 
-#include "../config.h"
+#include <config.h>
 
 #include <stdlib.h>
 #include <sys/ioctl.h>
@@ -31,7 +31,7 @@
 #include "debug.h"
 #include "vte.h"
 
-#include <glib/gi18n-lib.h>
+#include <glib/gi18n.h>
 
 #define DINGUS1 "(((news|telnet|nntp|file|http|ftp|https)://)|(www|ftp)[-A-Za-z0-9]*\\.)[-A-Za-z0-9\\.]+(:[0-9]*)?"
 #define DINGUS2 "(((news|telnet|nntp|file|http|ftp|https)://)|(www|ftp)[-A-Za-z0-9]*\\.)[-A-Za-z0-9\\.]+(:[0-9]*)?/[-A-Za-z0-9_\\$\\.\\+\\!\\*\\(\\),;:@&=\\?/~\\#\\%]*[^]'\\.}>\\) ,\\\"]"
@@ -416,7 +416,7 @@
 {
 	GdkScreen *screen;
 	GdkColormap *colormap;
-	GtkWidget *window, *hbox, *scrollbar, *widget;
+	GtkWidget *window, *widget,*hbox, *scrollbar, *scrolled_window;
 	VteTerminal *terminal;
 	char *env_add[] = {
 #ifdef VTE_DEBUG
@@ -429,7 +429,8 @@
 		 console = FALSE, scroll = FALSE, keep = FALSE,
 		 icon_title = FALSE, shell = TRUE, highlight_set = FALSE,
 		 cursor_set = FALSE, reverse = FALSE, use_geometry_hints = TRUE,
-		 antialias = TRUE;
+		 antialias = TRUE, use_scrolled_window = FALSE;
+        int scrollbar_policy = 0;
         char *geometry = NULL;
 	gint lines = 100;
 	const char *message = "Launching interactive shell...\r\n";
@@ -557,6 +558,18 @@
 			"Allow the terminal to be resized to any dimension, not constrained to fit to an integer multiple of characters",
 			NULL
 		},
+		{
+			"scrolled-window", 'W', 0,
+			G_OPTION_ARG_NONE, &use_scrolled_window,
+			"Use a GtkScrolledWindow as terminal container",
+			NULL
+		},
+		{
+			"scrollbar-policy", 'P', 0,
+			G_OPTION_ARG_INT, &scrollbar_policy,
+			"Set the policy for the vertical scroolbar in the scrolled window (0=always, 1=auto, 2=never; default:0)",
+			NULL
+		},
 		{ NULL }
 	};
 	GOptionContext *context;
@@ -611,9 +624,17 @@
 	if (colormap)
 	    gtk_widget_set_colormap(window, colormap);
 
-	/* Create a box to hold everything. */
-	hbox = gtk_hbox_new(0, FALSE);
-	gtk_container_add(GTK_CONTAINER(window), hbox);
+        if (use_scrolled_window) {
+                scrolled_window = gtk_scrolled_window_new (NULL, NULL);
+                gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolled_window),
+                                               GTK_POLICY_NEVER,
+                                               CLAMP (scrollbar_policy, GTK_POLICY_ALWAYS, GTK_POLICY_NEVER));
+                gtk_container_add(GTK_CONTAINER(window), scrolled_window);
+        } else {
+                /* Create a box to hold everything. */
+                hbox = gtk_hbox_new(0, FALSE);
+                gtk_container_add(GTK_CONTAINER(window), hbox);
+        }
 
 	/* Create the terminal widget and add it to the scrolling shell. */
 	widget = vte_terminal_new();
@@ -621,7 +642,11 @@
 	if (!dbuffer) {
 		gtk_widget_set_double_buffered(widget, dbuffer);
 	}
-	gtk_box_pack_start(GTK_BOX(hbox), widget, TRUE, TRUE, 0);
+        if (use_scrolled_window) {
+                gtk_container_add(GTK_CONTAINER(scrolled_window), GTK_WIDGET(terminal));
+        } else {
+                gtk_box_pack_start(GTK_BOX(hbox), widget, TRUE, TRUE, 0);
+        }
 
 	/* Connect to the "char_size_changed" signal to set geometry hints
 	 * whenever the font used by the terminal is changed. */
@@ -682,9 +707,11 @@
 	g_signal_connect(widget, "decrease-font-size",
 			 G_CALLBACK(decrease_font_size), window);
 
-	/* Create the scrollbar for the widget. */
-	scrollbar = gtk_vscrollbar_new(terminal->adjustment);
-	gtk_box_pack_start(GTK_BOX(hbox), scrollbar, FALSE, FALSE, 0);
+        if (!use_scrolled_window) {
+                /* Create the scrollbar for the widget. */
+                scrollbar = gtk_vscrollbar_new(terminal->adjustment);
+                gtk_box_pack_start(GTK_BOX(hbox), scrollbar, FALSE, FALSE, 0);
+        }
 
 	/* Set some defaults. */
 	vte_terminal_set_audible_bell(terminal, audible);



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]