Beispiel #1
0
void
moz_container_init (MozContainer *container)
{
    gtk_widget_set_can_focus(GTK_WIDGET(container), TRUE);
    gtk_container_set_resize_mode(GTK_CONTAINER(container), GTK_RESIZE_IMMEDIATE);
    gtk_widget_set_redraw_on_allocate(GTK_WIDGET(container), FALSE);
}
Beispiel #2
0
int music_build_container_widgets () {
	
	hbox_bg = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0);
// 	gtk_container_set_resize_mode (GTK_CONTAINER(hbox_bg), GTK_RESIZE_IMMEDIATE);
	frame_music = gtk_frame_new("Music Remote Control");
	vbox_music_contain = gtk_box_new(GTK_ORIENTATION_VERTICAL, 0);
	box_music_bg = button_with_image("/usr/share/raspi_remote_control/ui_images/ui_images_music/bg2.jpg");
	gtk_container_set_border_width (GTK_CONTAINER (vbox_music_contain), 0);
	vbox_music_process = gtk_box_new(GTK_ORIENTATION_VERTICAL, 0);
	
	vbox_info_lyric_contain = gtk_box_new(GTK_ORIENTATION_VERTICAL, 0);
	vbox_lyric_contain = gtk_box_new(GTK_ORIENTATION_VERTICAL, 0);
	gtk_box_set_homogeneous (GTK_BOX(vbox_info_lyric_contain), TRUE);
	gtk_container_set_resize_mode (GTK_CONTAINER(vbox_info_lyric_contain), GTK_RESIZE_PARENT);

	hbox_music2 = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0);
	hbox_music3 = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0);
	hbox_music4 = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0);
	hbox_music5 = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0);
	hbox_music6 = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0);
	hbox_music_list = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0);
	vbox_info_lyric_contain = gtk_box_new(GTK_ORIENTATION_VERTICAL, 0);
// 	gtk_container_set_resize_mode (GTK_CONTAINER(vbox_info_lyric_contain), GTK_RESIZE_IMMEDIATE);
	hbox_info_contain = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0);
	gtk_box_set_homogeneous (GTK_BOX(hbox_info_contain), FALSE);
	vbox_music_info_left = gtk_box_new(GTK_ORIENTATION_VERTICAL, 0);
	vbox_music_info_right = gtk_box_new(GTK_ORIENTATION_VERTICAL, 0);
	return 1;
}
Beispiel #3
0
static void
lyric_show_viewport_init(LyricShowViewport *lsv)
{
    lsv->priv = LYRIC_SHOW_VIEWPORT_GET_PRIVATE(lsv);
    gtk_widget_set_redraw_on_allocate(GTK_WIDGET(lsv),TRUE);
    gtk_container_set_resize_mode (GTK_CONTAINER (lsv), GTK_RESIZE_PARENT);
    gtk_widget_add_events(GTK_WIDGET(lsv),
                            GDK_BUTTON_PRESS_MASK|
                            GDK_BUTTON_RELEASE_MASK|
                            GDK_BUTTON1_MOTION_MASK);
}
Beispiel #4
0
int
clip_GTK_CONTAINERSETRESIZEMODE(ClipMachine * cm)
{
	C_widget *ccon = _fetch_cw_arg(cm);
	int       mode = _clip_parni(cm,2);
	CHECKARG(2,NUMERIC_t);
	CHECKCWID(ccon,GTK_IS_CONTAINER);
	gtk_container_set_resize_mode(GTK_CONTAINER(ccon->widget), mode);
	return 0;
err:
	return 1;
}
Beispiel #5
0
_HYPlatformWindow::_HYPlatformWindow(unsigned char windowFlag,_String windowTitle,bool windowVisibility, Ptr theParent)
{
    lastWW = lastWH = 0;
    last_H_Position = 0.0;
    last_V_Position = -1.0;

    if (windowFlag & HY_WINDOW_SHEET)
        windowFlag |= HY_WINDOW_DLOG;

    theWindow = gtk_window_new (GTK_WINDOW_TOPLEVEL);

    // debug color set here
    /*_HYColor red = {255,0,0};
    GdkColor redGDK = HYColorToGDKColor(red);
    gtk_widget_modify_bg (theWindow, GTK_STATE_NORMAL, &redGDK);*/

    gtk_window_set_title (GTK_WINDOW (theWindow), windowTitle.sData);
    gtk_container_set_border_width (GTK_CONTAINER (theWindow), 0);

    gtk_window_set_default_size (GTK_WINDOW(theWindow),300,250);
    gtk_window_set_resizable	(GTK_WINDOW(theWindow),windowFlag & HY_WINDOW_SIZE);
    gtk_widget_set_events		(theWindow,GDK_ALL_EVENTS_MASK-GDK_POINTER_MOTION_HINT_MASK);
    //gtk_widget_set_events		(theWindow,GDK_POINTER_MOTION_MASK);

    g_signal_connect (G_OBJECT (theWindow), "event",			G_CALLBACK (window_event_callback),		(_HYWindow*)this);
    g_signal_connect (G_OBJECT (theWindow), "activate-default",	G_CALLBACK (activate_window_callback),	(_HYWindow*)this);
    //g_signal_connect (G_OBJECT (theWindow), "expose-event",		G_CALLBACK (window_expose_callback),	(_HYWindow*)this);
    // a(and other menu user UI events)

    if (theParent)
    {
        gtk_window_set_transient_for (GTK_WINDOW(theWindow), GTK_WINDOW((GtkWidget*)((_HYWindow*)theParent)->theWindow));
        gtk_window_set_destroy_with_parent (GTK_WINDOW(theWindow),true);
    }

    windowContent = gtk_fixed_new ();
    g_signal_connect (G_OBJECT (windowContent), "expose-event",	G_CALLBACK (window_expose_callback),	(_HYWindow*)this);
    //g_signal_connect (G_OBJECT (windowContent), "window-state-event",	G_CALLBACK (null_window_state), nil);
    gtk_widget_set_app_paintable(windowContent,TRUE);
    gtk_container_set_resize_mode (GTK_CONTAINER(windowContent),GTK_RESIZE_IMMEDIATE);

    menu_items = nil;

    if (windowFlag & HY_WINDOW_DLOG)
        windowMB = nil;
    else
    {
        windowMB = theWindow;
        ((_HYWindow*)this)->_SetMenuBar  ();
    }

    gtk_widget_show (windowContent);

    if ((windowFlag&HY_WINDOW_SCROLL)&&(windowFlag&HY_WINDOW_SIZE))
    {
        vbox = gtk_vbox_new (FALSE, 0);
        hbox = gtk_hbox_new (FALSE, 0);

        GtkObject
        *v_adj = gtk_adjustment_new(0,0,MAX_CONTROL_VALUE,MAX_CONTROL_VALUE/100.0,MAX_CONTROL_VALUE/10.0,MAX_CONTROL_VALUE/5.0),
         *h_adj = gtk_adjustment_new(0,0,MAX_CONTROL_VALUE,MAX_CONTROL_VALUE/100.0,MAX_CONTROL_VALUE/10.0,MAX_CONTROL_VALUE/5.0);

        vScroll = gtk_vscrollbar_new  ((GtkAdjustment*)v_adj),
        hScroll = gtk_hscrollbar_new  ((GtkAdjustment*)h_adj);

        /*GtkWidget * tScroll = gtk_vscrollbar_new ((GtkAdjustment*)t_adj);
        gtk_widget_set_size_request(tScroll,20,100);

        gtk_fixed_put (GTK_FIXED(windowContent), tScroll, 30,40);
        gtk_widget_show (tScroll);*/

        gtk_widget_show (hScroll);
        gtk_widget_show (vScroll);
        gtk_widget_show (hbox);
        gtk_widget_show (vbox);

        g_signal_connect (G_OBJECT (vScroll), "value-changed",G_CALLBACK (v_scroll_bar_callback_window), (gpointer)((_HYWindow*)this));
        g_signal_connect (G_OBJECT (hScroll), "value-changed",G_CALLBACK (h_scroll_bar_callback_window), (gpointer)((_HYWindow*)this));

        gtk_box_pack_start (GTK_BOX (hbox), windowContent, TRUE, TRUE, 0);
        gtk_box_pack_end   (GTK_BOX (hbox), vScroll, FALSE, FALSE, 0);

        if (windowMB)
        {
            gtk_box_pack_start (GTK_BOX (vbox), windowMB, FALSE, FALSE, 0);
        }
        gtk_box_pack_start (GTK_BOX (vbox), hbox, TRUE, TRUE, 0);
        gtk_box_pack_end (GTK_BOX (vbox), hScroll, FALSE, FALSE, 0);
        gtk_container_add (GTK_CONTAINER (theWindow), vbox);
    }
    else
    {
        if (windowMB)
        {
            hScroll = vScroll = hbox = nil;
            vbox = gtk_vbox_new (FALSE, 0);
            gtk_box_pack_start   (GTK_BOX (vbox), windowMB, FALSE, FALSE, 0);
            gtk_box_pack_end (GTK_BOX (vbox), windowContent, TRUE, TRUE, 0);
            gtk_widget_show (vbox);
            gtk_container_add (GTK_CONTAINER (theWindow), vbox);
        }
        else
        {
            hScroll = vScroll = hbox = vbox = nil;
            windowFlag &= 123;
            gtk_container_add (GTK_CONTAINER (theWindow), windowContent);
        }
    }

    windowPtrs   << (long)theWindow;
    windowObjects<< (long)this;

    gtk_window_set_type_hint (GTK_WINDOW(theWindow),windowFlag & HY_WINDOW_DLOG ? GDK_WINDOW_TYPE_HINT_DIALOG : GDK_WINDOW_TYPE_HINT_NORMAL);
    gtk_window_set_modal		(GTK_WINDOW(theWindow),windowFlag & HY_WINDOW_DLOG);
    if (windowVisibility)
        gtk_widget_show(theWindow);

    flags = windowFlag;

    g_signal_connect (G_OBJECT (theWindow), "size-allocate",	G_CALLBACK (window_resize_callback),    (_HYWindow*)this);
}
Beispiel #6
0
int
main(int argc, char **argv)
{
	GdkScreen *screen;
	GdkColormap *colormap;
	GtkWidget *window, *widget,*hbox = NULL, *scrollbar, *scrolled_window = NULL;
	VteTerminal *terminal;
	char *env_add[] = {
#ifdef VTE_DEBUG
		(char *) "FOO=BAR", (char *) "BOO=BIZ",
#endif
		NULL};
	const char *background = NULL;
	gboolean transparent = FALSE, audible = TRUE, blink = TRUE,
		 debug = FALSE, dingus = FALSE, dbuffer = TRUE,
		 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, use_scrolled_window = FALSE,
                 show_object_notifications = FALSE;
        char *geometry = NULL;
	gint lines = 100;
	const char *message = "Launching interactive shell...\r\n";
	const char *font = NULL;
	const char *termcap = NULL;
	const char *command = NULL;
	const char *working_directory = NULL;
	const char *output_file = NULL;
        char *pty_flags_string = NULL;
        char *cursor_shape_string = NULL;
        char *scrollbar_policy_string = NULL;
	GdkColor fore, back, tint, highlight, cursor;
	const GOptionEntry options[]={
		{
			"antialias", 'A', G_OPTION_FLAG_REVERSE,
			G_OPTION_ARG_NONE, &antialias,
			"Disable the use of anti-aliasing", NULL
		},
		{
			"background", 'B', 0,
			G_OPTION_ARG_FILENAME, &background,
			"Specify a background image", NULL
		},
		{
			"console", 'C', 0,
			G_OPTION_ARG_NONE, &console,
			"Watch /dev/console", NULL
		},
		{
			"dingus", 'D', 0,
			G_OPTION_ARG_NONE, &dingus,
			"Highlight URLs inside the terminal", NULL
		},
		{
			"shell", 'S', G_OPTION_FLAG_REVERSE,
			G_OPTION_ARG_NONE, &shell,
			"Disable spawning a shell inside the terminal", NULL
		},
		{
			"transparent", 'T', 0,
			G_OPTION_ARG_NONE, &transparent,
			"Enable the use of a transparent background", NULL
		},
		{
			"double-buffer", '2', G_OPTION_FLAG_REVERSE,
			G_OPTION_ARG_NONE, &dbuffer,
			"Disable double-buffering", NULL
		},
		{
			"audible", 'a', G_OPTION_FLAG_REVERSE,
			G_OPTION_ARG_NONE, &audible,
			"Use visible, instead of audible, terminal bell",
			NULL
		},
		{
			"blink", 'b', G_OPTION_FLAG_REVERSE,
			G_OPTION_ARG_NONE, &blink,
			"Disable the blinking cursor", NULL
		},
		{
			"command", 'c', 0,
			G_OPTION_ARG_STRING, &command,
			"Execute a command in the terminal", NULL
		},
		{
			"debug", 'd', 0,
			G_OPTION_ARG_NONE, &debug,
			"Enable various debugging checks", NULL
		},
		{
			"font", 'f', 0,
			G_OPTION_ARG_STRING, &font,
			"Specify a font to use", NULL
		},
		{
			"geometry", 'g', 0,
			G_OPTION_ARG_STRING, &geometry,
			"Set the size (in characters) and position", "GEOMETRY"
		},
		{
			"highlight", 'h', 0,
			G_OPTION_ARG_NONE, &highlight_set,
			"Enable the cursor highlighting", NULL
		},
		{
			"icon-title", 'i', 0,
			G_OPTION_ARG_NONE, &icon_title,
			"Enable the setting of the icon title", NULL
		},
		{
			"keep", 'k', 0,
			G_OPTION_ARG_NONE, &keep,
			"Live on after the window closes", NULL
		},
		{
			"scrollback-lines", 'n', 0,
			G_OPTION_ARG_INT, &lines,
			"Specify the number of scrollback-lines", NULL
		},
		{
			"color-cursor", 'r', 0,
			G_OPTION_ARG_NONE, &cursor_set,
			"Enable a colored cursor", NULL
		},
		{
			"cursor-shape", 0, 0,
			G_OPTION_ARG_STRING, &cursor_shape_string,
			"Set cursor shape (block|underline|ibeam)", NULL
		},
		{
			"scroll-background", 's', 0,
			G_OPTION_ARG_NONE, &scroll,
			"Enable a scrolling background", NULL
		},
		{
			"termcap", 't', 0,
			G_OPTION_ARG_STRING, &termcap,
			"Specify the terminal emulation to use", NULL
		},
		{
			"working-directory", 'w', 0,
			G_OPTION_ARG_FILENAME, &working_directory,
			"Specify the initial working directory of the terminal",
			NULL
		},
		{
			"reverse", 0, 0,
			G_OPTION_ARG_NONE, &reverse,
			"Reverse foreground/background colors", NULL
		},
		{
			"no-geometry-hints", 'G', G_OPTION_FLAG_REVERSE,
			G_OPTION_ARG_NONE, &use_geometry_hints,
			"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_STRING, &scrollbar_policy_string,
			"Set the policy for the vertical scroolbar in the scrolled window (always|auto|never; default:always)",
			NULL
		},
		{
			"object-notifications", 'N', 0,
			G_OPTION_ARG_NONE, &show_object_notifications,
			"Print VteTerminal object notifications",
			NULL
		},
		{
			"output-file", 0, 0,
			G_OPTION_ARG_STRING, &output_file,
			"Save terminal contents to file at exit", NULL
		},
		{
			"pty-flags", 0, 0,
			G_OPTION_ARG_STRING, &pty_flags_string,
			"PTY flags set from default|no-utmp|no-wtmp|no-lastlog|no-helper|no-fallback", NULL
		},
		{ NULL }
	};
	GOptionContext *context;
	GError *error = NULL;
        VteTerminalCursorShape cursor_shape = VTE_CURSOR_SHAPE_BLOCK;
        GtkPolicyType scrollbar_policy = GTK_POLICY_ALWAYS;
        VtePtyFlags pty_flags = VTE_PTY_DEFAULT;

	/* Have to do this early. */
	if (getenv("VTE_PROFILE_MEMORY")) {
		if (atol(getenv("VTE_PROFILE_MEMORY")) != 0) {
			g_mem_set_vtable(glib_mem_profiler_table);
		}
	}

	context = g_option_context_new (" - test VTE terminal emulation");
	g_option_context_add_main_entries (context, options, NULL);
	g_option_context_add_group (context, gtk_get_option_group (TRUE));
	g_option_context_parse (context, &argc, &argv, &error);
	g_option_context_free (context);
	if (error != NULL) {
		g_printerr ("Failed to parse command line arguments: %s\n",
				error->message);
		g_error_free (error);
		return 1;
	}

        if (cursor_shape_string) {
                cursor_shape = parse_enum(VTE_TYPE_TERMINAL_CURSOR_SHAPE, cursor_shape_string);
                g_free(cursor_shape_string);
        }
        if (scrollbar_policy_string) {
                scrollbar_policy = parse_enum(GTK_TYPE_POLICY_TYPE, scrollbar_policy_string);
                g_free(scrollbar_policy_string);
        }
        if (pty_flags_string) {
                pty_flags |= parse_flags(VTE_TYPE_PTY_FLAGS, pty_flags_string);
                g_free(pty_flags_string);
        }

	if (!reverse) {
		back.red = back.green = back.blue = 0xffff;
		fore.red = fore.green = fore.blue = 0x0000;
	} else {
		back.red = back.green = back.blue = 0x0000;
		fore.red = fore.green = fore.blue = 0xffff;
	}

	highlight.red = highlight.green = highlight.blue = 0xc000;
	cursor.red = 0xffff;
	cursor.green = cursor.blue = 0x8000;
	tint.red = tint.green = tint.blue = 0;
	tint = back;

	gdk_window_set_debug_updates(debug);

	/* Create a window to hold the scrolling shell, and hook its
	 * delete event to the quit function.. */
	window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
	gtk_container_set_resize_mode(GTK_CONTAINER(window),
				      GTK_RESIZE_IMMEDIATE);

	/* Set ARGB colormap */
	screen = gtk_widget_get_screen (window);
	colormap = gdk_screen_get_rgba_colormap (screen);
	if (colormap)
	    gtk_widget_set_colormap(window, colormap);

        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, scrollbar_policy);
                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();
	terminal = VTE_TERMINAL (widget);
	if (!dbuffer) {
		gtk_widget_set_double_buffered(widget, dbuffer);
	}
        g_signal_connect(terminal, "child-exited", G_CALLBACK(child_exit_cb), NULL);
        if (show_object_notifications)
                g_signal_connect(terminal, "notify", G_CALLBACK(terminal_notify_cb), NULL);
        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. */
	if (use_geometry_hints) {
		char_size_changed(widget, 0, 0, window);
		g_signal_connect(widget, "char-size-changed",
				 G_CALLBACK(char_size_changed), window);
		g_signal_connect(widget, "realize",
				 G_CALLBACK(char_size_realized), window);
	}

	/* Connect to the "window_title_changed" signal to set the main
	 * window's title. */
	g_signal_connect(widget, "window-title-changed",
			 G_CALLBACK(window_title_changed), window);
	if (icon_title) {
		g_signal_connect(widget, "icon-title-changed",
				 G_CALLBACK(icon_title_changed), window);
	}

	/* Connect to the "status-line-changed" signal. */
	g_signal_connect(widget, "status-line-changed",
			 G_CALLBACK(status_line_changed), widget);

	/* Connect to the "button-press" event. */
	g_signal_connect(widget, "button-press-event",
			 G_CALLBACK(button_pressed), widget);

	/* Connect to application request signals. */
	g_signal_connect(widget, "iconify-window",
			 G_CALLBACK(iconify_window), window);
	g_signal_connect(widget, "deiconify-window",
			 G_CALLBACK(deiconify_window), window);
	g_signal_connect(widget, "raise-window",
			 G_CALLBACK(raise_window), window);
	g_signal_connect(widget, "lower-window",
			 G_CALLBACK(lower_window), window);
	g_signal_connect(widget, "maximize-window",
			 G_CALLBACK(maximize_window), window);
	g_signal_connect(widget, "restore-window",
			 G_CALLBACK(restore_window), window);
	g_signal_connect(widget, "refresh-window",
			 G_CALLBACK(refresh_window), window);
	g_signal_connect(widget, "resize-window",
			 G_CALLBACK(resize_window), window);
	g_signal_connect(widget, "move-window",
			 G_CALLBACK(move_window), window);

	/* Connect to font tweakage. */
	g_signal_connect(widget, "increase-font-size",
			 G_CALLBACK(increase_font_size), window);
	g_signal_connect(widget, "decrease-font-size",
			 G_CALLBACK(decrease_font_size), window);

        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);
	vte_terminal_set_visible_bell(terminal, !audible);
	vte_terminal_set_cursor_blink_mode(terminal, blink ? VTE_CURSOR_BLINK_SYSTEM : VTE_CURSOR_BLINK_OFF);
	vte_terminal_set_scroll_background(terminal, scroll);
	vte_terminal_set_scroll_on_output(terminal, FALSE);
	vte_terminal_set_scroll_on_keystroke(terminal, TRUE);
	vte_terminal_set_scrollback_lines(terminal, lines);
	vte_terminal_set_mouse_autohide(terminal, TRUE);
	if (background != NULL) {
		vte_terminal_set_background_image_file(terminal,
						       background);
	}
	if (transparent) {
		vte_terminal_set_background_transparent(terminal,
							TRUE);
	}
	vte_terminal_set_background_tint_color(terminal, &tint);
	vte_terminal_set_colors(terminal, &fore, &back, NULL, 0);
	vte_terminal_set_opacity(terminal, 0xdddd);
	if (highlight_set) {
		vte_terminal_set_color_highlight(terminal,
						 &highlight);
	}
	if (cursor_set) {
		vte_terminal_set_color_cursor(terminal, &cursor);
	}
	if (termcap != NULL) {
		vte_terminal_set_emulation(terminal, termcap);
	}
        vte_terminal_set_cursor_shape(terminal, cursor_shape);

	/* Set the default font. */
	vte_terminal_set_font_from_string_full(terminal, font,
					       antialias ? VTE_ANTI_ALIAS_USE_DEFAULT : VTE_ANTI_ALIAS_FORCE_DISABLE);

	/* Match "abcdefg". */
	if (dingus) {
		int id;
		GRegex *regex;
		regex = g_regex_new (DINGUS1, 0, 0, NULL);
		id = vte_terminal_match_add_gregex(terminal, regex, 0);
		g_regex_unref (regex);
		vte_terminal_match_set_cursor_type(terminal,
						   id, GDK_GUMBY);
		regex = g_regex_new (DINGUS2, 0, 0, NULL);
		id = vte_terminal_match_add_gregex(terminal, regex, 0);
		g_regex_unref (regex);
		vte_terminal_match_set_cursor_type(terminal,
						   id, GDK_HAND1);
	}

	if (console) {
		/* Open a "console" connection. */
		int consolefd = -1, yes = 1, watch;
		GIOChannel *channel;
		consolefd = open("/dev/console", O_RDONLY | O_NOCTTY);
		if (consolefd != -1) {
			/* Assume failure. */
			console = FALSE;
#ifdef TIOCCONS
			if (ioctl(consolefd, TIOCCONS, &yes) != -1) {
				/* Set up a listener. */
				channel = g_io_channel_unix_new(consolefd);
				watch = g_io_add_watch(channel,
						       G_IO_IN,
						       read_and_feed,
						       widget);
				g_signal_connect(widget,
						 "eof",
						 G_CALLBACK(disconnect_watch),
						 GINT_TO_POINTER(watch));
				g_signal_connect(widget,
						 "child-exited",
						 G_CALLBACK(disconnect_watch),
						 GINT_TO_POINTER(watch));
				g_signal_connect(widget,
						 "realize",
						 G_CALLBACK(take_xconsole_ownership),
						 NULL);
#ifdef VTE_DEBUG
				vte_terminal_feed(terminal,
						  "Console log for ...\r\n",
						  -1);
#endif
				/* Record success. */
				console = TRUE;
			}
#endif
		} else {
			/* Bail back to normal mode. */
			g_warning(_("Could not open console.\n"));
			close(consolefd);
			console = FALSE;
		}
	}

	if (!console) {
		if (shell) {
                        GError *err = NULL;
                        char **command_argv = NULL;
                        int command_argc;
                        GPid pid = -1;

			_VTE_DEBUG_IF(VTE_DEBUG_MISC)
				vte_terminal_feed(terminal, message, -1);

                        if (command == NULL)
                                command = "/bin/sh"; // FIXMEchpe

                        if (command != NULL) {
                                if (!g_shell_parse_argv(command, &command_argc, &command_argv, &err) ||
                                    !vte_terminal_fork_command_full(terminal,
                                                                    pty_flags,
                                                                    NULL,
                                                                    command_argv,
                                                                    env_add,
                                                                    G_SPAWN_SEARCH_PATH,
                                                                    NULL, NULL,
                                                                    &pid,
                                                                    &err)) {
                                        g_warning("Failed to fork: %s\n", err->message);
                                        g_error_free(err);
                                } else {
                                        g_print("Fork succeeded, PID %d\n", pid);
                                }
                        }
                        g_strfreev(command_argv);
	#ifdef VTE_DEBUG
			if (command == NULL) {
				vte_terminal_feed_child(terminal,
							"pwd\n", -1);
			}
	#endif
		} else {
			long i;
			i = vte_terminal_forkpty(terminal,
						 env_add, working_directory,
						 TRUE, TRUE, TRUE);
			switch (i) {
			case -1:
				/* abnormal */
				g_warning("Error in vte_terminal_forkpty(): %s",
					  strerror(errno));
				break;
			case 0:
				/* child */
				for (i = 0; ; i++) {
					switch (i % 3) {
					case 0:
					case 1:
						g_print("%ld\n", i);
						break;
					case 2:
						g_printerr("%ld\n", i);
						break;
					}
					sleep(1);
				}
				_exit(0);
				break;
			default:
				g_print("Child PID is %ld (mine is %ld).\n",
					(long) i, (long) getpid());
				/* normal */
				break;
			}
		}
	}

	g_object_set_data (G_OBJECT (widget), "output_file", (gpointer) output_file);

	/* Go for it! */
	g_signal_connect(widget, "child-exited", G_CALLBACK(child_exited), window);
	g_signal_connect(window, "delete-event", G_CALLBACK(delete_event), widget);

	add_weak_pointer(G_OBJECT(widget), &widget);
	add_weak_pointer(G_OBJECT(window), &window);

        gtk_widget_realize(widget);
        if (geometry) {
                if (!gtk_window_parse_geometry (GTK_WINDOW(window), geometry)) {
                        g_warning (_("Could not parse the geometry spec passed to --geometry"));
                }
        }

	gtk_widget_show_all(window);

	gtk_main();

	g_assert(widget == NULL);
	g_assert(window == NULL);

	if (keep) {
		while (TRUE) {
			sleep(60);
		}
	}

	return 0;
}
static void
uim_cand_win_horizontal_gtk_init (UIMCandWinHorizontalGtk *horizontal_cwin)
{
  gint col;
  GtkWidget *viewport;
  UIMCandWinGtk *cwin;

  cwin = UIM_CAND_WIN_GTK(horizontal_cwin);

  horizontal_cwin->buttons = g_ptr_array_new();
  horizontal_cwin->selected = NULL;

#if GTK_CHECK_VERSION(3, 4, 0)
  cwin->view = gtk_grid_new();
  gtk_grid_set_column_spacing(GTK_GRID(cwin->view), 10);
#else
  cwin->view = gtk_table_new(1, DEFAULT_NR_CELLS, FALSE);
  gtk_table_set_col_spacings(GTK_TABLE(cwin->view), 10);
#endif
  viewport = gtk_viewport_new(NULL, NULL);
  gtk_container_add(GTK_CONTAINER(viewport), cwin->view);
  gtk_container_add(GTK_CONTAINER(cwin->scrolled_window), viewport);
  gtk_container_set_resize_mode(GTK_CONTAINER(viewport), GTK_RESIZE_PARENT);
  for (col = 0; col < DEFAULT_NR_CELLS; col++) {
    GtkWidget *button;
    GtkWidget *label;
    struct index_button *idxbutton;

    button = gtk_event_box_new();
    gtk_event_box_set_above_child(GTK_EVENT_BOX(button), TRUE);
    label = gtk_label_new("");
    gtk_container_add(GTK_CONTAINER(button), label);
    scale_label(GTK_EVENT_BOX(button), PANGO_SCALE_LARGE);
    g_signal_connect(button, "button-press-event", G_CALLBACK(button_clicked), horizontal_cwin);
#if GTK_CHECK_VERSION(2, 90, 0)
    g_signal_connect_after(label, "draw", G_CALLBACK(label_draw), horizontal_cwin);
#else
    g_signal_connect_after(label, "expose-event", G_CALLBACK(label_exposed), horizontal_cwin);
#endif
#if GTK_CHECK_VERSION(3, 4, 0)
    gtk_widget_set_hexpand(button, TRUE);
    gtk_widget_set_vexpand(button, TRUE);
    gtk_grid_attach(GTK_GRID(cwin->view), button, col, 0, 1, 1);
#else
    gtk_table_attach_defaults(GTK_TABLE(cwin->view), button, col, col + 1, 0, 1);
#endif
    idxbutton = g_malloc(sizeof(struct index_button));
    if (idxbutton) {
      idxbutton->button = GTK_EVENT_BOX(button);
      clear_button(idxbutton, col);
    }
    g_ptr_array_add(horizontal_cwin->buttons, idxbutton);
  }

  gtk_widget_show_all(cwin->view);
  gtk_widget_show(viewport);

  gtk_widget_set_size_request(cwin->num_label, DEFAULT_MIN_WINDOW_WIDTH, -1);
  gtk_window_set_default_size(GTK_WINDOW(cwin), DEFAULT_MIN_WINDOW_WIDTH, -1);
  gtk_window_set_resizable(GTK_WINDOW(cwin), FALSE);
}