- Main Page
- Related Pages
- Data Structures
- Files

# vte.c

Go to the documentation of this file.

    00001
    00030 #include "gnoclVTE.h"
    00031
    00035 static GnoclOption vteOptions[] =
    00036 {
    00037
    00038         {"-transparent", GNOCL_BOOL, "background-transparent"},
    00039
    00043         { "-data", GNOCL_OBJ, "", gnoclOptData },
    00044         { "-hasFocus", GNOCL_BOOL, "has-focus" },
    00045         { "-heightGroup", GNOCL_OBJ, "h", gnoclOptSizeGroup },
    00046         { "-name", GNOCL_STRING, "name" },
    00047         { "-backgroundColor", GNOCL_OBJ, "normal", gnoclOptGdkColorBg },
    00048
    00049         /* GtkButton specific signals */
    00050         { "-onEnter", GNOCL_OBJ, "E", gnoclOptOnEnterLeave },
    00051         { "-onLeave", GNOCL_OBJ, "L", gnoclOptOnEnterLeave },
    00052         { "-onClicked", GNOCL_OBJ, "clicked", gnoclOptCommand },
    00053         { "-onButtonPress", GNOCL_OBJ, "P", gnoclOptOnButton },
    00054         { "-onButtonRelease", GNOCL_OBJ, "R", gnoclOptOnButton },
    00055
    00056         /* GtkWidget signals */
    00057         { "-onPopupMenu", GNOCL_OBJ, "popup-menu", gnoclOptCommand },
    00058         { "-onRealize", GNOCL_OBJ, "realize", gnoclOptCommand },
    00059         { "-onShowHelp", GNOCL_OBJ, "", gnoclOptOnShowHelp },
    00060
    00061         { "-prelightBackgroundColor", GNOCL_OBJ, "prelight", gnoclOptGdkColorBg },
    00062         { "-relief", GNOCL_OBJ, "relief", gnoclOptRelief },
    00063         { "-sensitive", GNOCL_BOOL, "sensitive" },
    00064         { "-sizeGroup", GNOCL_OBJ, "s", gnoclOptSizeGroup },
    00065         { "-tooltip", GNOCL_OBJ, "", gnoclOptTooltip },
    00066         { "-visible", GNOCL_BOOL, "visible" },
    00067         { "-widthGroup", GNOCL_OBJ, "w", gnoclOptSizeGroup },
    00068
    00069         { "-backgroundImage", GNOCL_OBJ, "", gnoclOptBackgroundImage },
    00070
    00071         /* inherited GtkWidget properties */
    00072         { "-heightRequest", GNOCL_INT, "height-request" },
    00073         { "-widthRequest", GNOCL_INT, "width-request" },
    00074
    00075
    00076         { NULL },
    00077 };
    00078
    00082 static int vteFunc (
    00083         ClientData data,
    00084         Tcl_Interp *interp,
    00085         int objc,
    00086         Tcl_Obj * const objv[] )
    00087 {
    00088         return TCL_OK;
    00089 }
    00090
    00097 static int configure (
    00098         Tcl_Interp *interp,
    00099         GtkWidget *term,
    00100         GnoclOption options[] )
    00101 {
    00102         g_print ( "vte/configure\n" );
    00103         return TCL_OK;
    00104 }
    00105
    00106
    00110 int gnoclVTECmd (
    00111         ClientData data,
    00112         Tcl_Interp *interp,
    00113         int objc,
    00114         Tcl_Obj * const objv[] )
    00115 {
    00116
    00117         g_print ( "gnoclVTECmd\n" );
    00118
    00119         int               ret;
    00120         GtkWidget *term;
    00121
    00122         if ( gnoclParseOptions ( interp, objc, objv, vteOptions ) != TCL_OK )
    00123         {
    00124                 gnoclClearOptions ( vteOptions );
    00125                 return TCL_ERROR;
    00126         }
    00127
    00128
    00129         GtkWidget *terminal = vte_terminal_new ();
    00130
    00131         GtkWidget *scrollbar = gtk_vscrollbar_new ( vte_terminal_get_adjustment
    00132                                                    ( VTE_TERMINAL ( terminal ) ) );
    00133         GtkWidget *hbox = gtk_hbox_new ( FALSE, 0 );
    00134
    00135         vte_terminal_fork_command ( VTE_TERMINAL ( terminal ), "/bin/bash",
    00136                                                                 NULL, NULL, g_get_home_dir (), FALSE, FALSE, FALSE );
    00137         vte_terminal_set_font_from_string ( VTE_TERMINAL ( terminal ), "Monospace 9" );
    00138         vte_terminal_set_scroll_on_output ( VTE_TERMINAL ( terminal ), FALSE );
    00139         vte_terminal_set_scroll_on_keystroke ( VTE_TERMINAL ( terminal ), TRUE );
    00140         vte_terminal_set_mouse_autohide ( VTE_TERMINAL ( terminal ), TRUE );
    00141
    00142         gtk_box_pack_start ( GTK_BOX ( hbox ), terminal, TRUE, TRUE, 0 );
    00143
    00144         gtk_box_pack_start ( GTK_BOX ( hbox ), scrollbar, FALSE, FALSE, 0 );
    00145
    00146         /* set options */
    00147
    00148
    00149         gtk_widget_show ( GTK_WIDGET ( terminal ) );
    00150
    00151         ret = gnoclSetOptions ( interp, vteOptions, G_OBJECT ( terminal ), -1 );
    00152
    00153         if ( ret == TCL_OK )
    00154         {
    00155                 ret = configure ( interp, terminal, vteOptions );
    00156         }
    00157
    00158         gnoclClearOptions ( vteOptions );
    00159
    00160         if ( ret != TCL_OK )
    00161         {
    00162                 gtk_widget_destroy ( GTK_WIDGET ( terminal ) );
    00163                 return TCL_ERROR;
    00164         }
    00165
    00166
    00167         char *command = "mc\n";
    00168
    00169         /* -background */
    00170         GdkColor color;
    00171         gchar text[] = "red";
    00172         gdk_color_parse ( &text, &color );
    00173         vte_terminal_set_color_background ( VTE_TERMINAL ( terminal ), &color );
    00174
    00175         /* -foreground */
    00176         vte_terminal_set_color_foreground ( VTE_TERMINAL ( terminal ), &color );
    00177
    00178         /* -tint */
    00179         vte_terminal_set_background_tint_color ( VTE_TERMINAL ( terminal ), &color );
    00180
    00181         /* -bold */
    00182         vte_terminal_set_color_bold ( VTE_TERMINAL ( terminal ), &color );
    00183
    00184         /* -saturation */
    00185         vte_terminal_set_background_saturation ( VTE_TERMINAL ( terminal ), 0.5 );
    00186
    00187         /* -transparent */
    00188         vte_terminal_set_background_transparent ( VTE_TERMINAL ( terminal ), 1 );
    00189
    00190         /* -backgroundImage */
    00191         vte_terminal_set_background_image_file ( VTE_TERMINAL ( terminal ), "./EU_flag.jpg" );
    00192
    00193         /* -scrollBackground */
    00194         vte_terminal_set_scroll_background ( VTE_TERMINAL ( terminal ), 1 );
    00195
    00196         /* -cursor
    00197          * typedef enum {
    00198             VTE_CURSOR_SHAPE_BLOCK,
    00199             VTE_CURSOR_SHAPE_IBEAM,
    00200             VTE_CURSOR_SHAPE_UNDERLINE
    00201                 } VteTerminalCursorShape;
    00202          * */
    00203         /* not available */
    00204         /*
    00205          vte_terminal_set_cursor_shape (VTE_TERMINAL (terminal),1);
    00206         */
    00207
    00208         /* -cursorBlink default = 0*/
    00209         vte_terminal_set_cursor_blinks ( VTE_TERMINAL ( terminal ), 1 );
    00210
    00211         /* -mouseHide default = 1*/
    00212         vte_terminal_set_mouse_autohide ( VTE_TERMINAL ( terminal ), 0 );
    00213
    00214         /* -font */
    00215         // vte_terminal_set_font_from_string (VTE_TERMINAL (terminal), text);
    00216
    00217         /* -hearBell default = 0 */
    00218         vte_terminal_set_audible_bell ( VTE_TERMINAL ( terminal ), 1 );
    00219
    00220         /* -seeBell default = 0 */
    00221         vte_terminal_set_visible_bell ( VTE_TERMINAL ( terminal ), 1 );
    00222
    00223         /* -allowBold */
    00224         vte_terminal_set_allow_bold ( VTE_TERMINAL ( terminal ), 1 );
    00225
    00226         /* id feed ??string?? */
    00227         vte_terminal_feed_child ( VTE_TERMINAL ( terminal ), command, strlen ( command ) );
    00228
    00229         return gnoclRegisterWidget ( interp, GTK_WIDGET ( hbox ) , vteFunc );
    00230
    00231         //return TCL_OK;
    00232
    00233 }
    00234