⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 calculator.ksh.stdin

📁 gtk_server的源代码
💻 STDIN
📖 第 1 页 / 共 2 页
字号:
#!/bin/ksh## Demonstration on how to use Glade and the GTK-server with BASH.## Tested with GTK-server 2.3.1 on SLAMD12 and Kornshell93# October 28, 2008 (c) Peter van Eerten - GPL license.## Adapted from the BASH version to test the unlimited STDIN interface.##----------------------------------------------------------- Setup embedded GTK# Find GTK-server configfile firstif [[ -f gtk-server.cfg ]]; then    CFG=gtk-server.cfgelif [[ -f /etc/gtk-server.cfg ]]; then    CFG=/etc/gtk-server.cfgelif [[ -f /usr/local/etc/gtk-server.cfg ]]; then    CFG=/usr/local/etc/gtk-server.cfgelse    echo "No GTK-server configfile found! Please install GTK-server..."    exit 1fi# Now create global functionnames from GTK APIif [[ ! -f $HOME/.gtk4korn || $CFG -nt $HOME/.gtk4korn ]]; then    print "# Embedded GTK functions for KornShell" > $HOME/.gtk4korn    while read LINE    do	if [[ $LINE = +(FUNCTION_NAME*) ]]; then	    TMP=${LINE#*= }	    print "function ${TMP%%,*}" >> $HOME/.gtk4korn	    print "{\nprint -p ${TMP%%,*} \$@" >> $HOME/.gtk4korn	    print "read -p GTK\n}" >> $HOME/.gtk4korn	fi    done < $CFGfi# Declare global variablestypeset GTK NULL="NULL"unset CFG PIPE LINE# Assignment functionfunction define { $2 $3 $4 $5 $6 $7 $8 $9; eval $1="\"$GTK\""; }# Include the generated file to use embedded GTK functions. ${HOME}/.gtk4korn# Start GTK-servergtk-server -stdin |&#---------------------------------------------------------- Global inits# Set GUI definitionGUI="<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?><!DOCTYPE glade-interface SYSTEM \"glade-2.0.dtd\"><!--Generated with glade3 3.4.0 on Fri Jan 11 20:13:32 2008 --><glade-interface>  <widget class=\"GtkWindow\" id=\"window\">    <property name=\"width_request\">250</property>    <property name=\"height_request\">225</property>    <property name=\"visible\">True</property>    <property name=\"title\" translatable=\"yes\">KORN Calculator STDIN</property>    <property name=\"resizable\">False</property>    <property name=\"window_position\">GTK_WIN_POS_CENTER</property>    <property name=\"default_width\">264</property>    <property name=\"default_height\">248</property>    <property name=\"icon_name\">calc</property>    <child>      <widget class=\"GtkTable\" id=\"table1\">        <property name=\"visible\">True</property>        <property name=\"n_rows\">5</property>        <property name=\"n_columns\">5</property>        <property name=\"homogeneous\">True</property>        <child>          <widget class=\"GtkButton\" id=\"buttonMemadd\">            <property name=\"visible\">True</property>            <property name=\"label\" translatable=\"yes\">M+</property>            <property name=\"response_id\">0</property>          </widget>          <packing>            <property name=\"left_attach\">3</property>            <property name=\"right_attach\">4</property>            <property name=\"top_attach\">4</property>            <property name=\"bottom_attach\">5</property>            <property name=\"x_padding\">4</property>            <property name=\"y_padding\">8</property>          </packing>        </child>        <child>          <widget class=\"GtkEntry\" id=\"entry\">            <property name=\"visible\">True</property>            <property name=\"sensitive\">False</property>            <property name=\"editable\">False</property>            <property name=\"xalign\">1</property>          </widget>          <packing>            <property name=\"right_attach\">5</property>            <property name=\"x_padding\">4</property>          </packing>        </child>        <child>          <widget class=\"GtkButton\" id=\"button1\">            <property name=\"width_request\">0</property>            <property name=\"visible\">True</property>            <property name=\"label\" translatable=\"yes\">1</property>            <property name=\"response_id\">0</property>          </widget>          <packing>            <property name=\"top_attach\">1</property>            <property name=\"bottom_attach\">2</property>            <property name=\"x_padding\">4</property>            <property name=\"y_padding\">8</property>          </packing>        </child>        <child>          <widget class=\"GtkButton\" id=\"button3\">            <property name=\"visible\">True</property>            <property name=\"label\" translatable=\"yes\">3</property>            <property name=\"response_id\">0</property>          </widget>          <packing>            <property name=\"left_attach\">2</property>            <property name=\"right_attach\">3</property>            <property name=\"top_attach\">1</property>            <property name=\"bottom_attach\">2</property>            <property name=\"x_padding\">4</property>            <property name=\"y_padding\">8</property>          </packing>        </child>        <child>          <widget class=\"GtkButton\" id=\"buttonC\">            <property name=\"visible\">True</property>            <property name=\"label\" translatable=\"yes\">C</property>            <property name=\"response_id\">0</property>          </widget>          <packing>            <property name=\"left_attach\">3</property>            <property name=\"right_attach\">4</property>            <property name=\"top_attach\">1</property>            <property name=\"bottom_attach\">2</property>            <property name=\"x_padding\">4</property>            <property name=\"y_padding\">8</property>          </packing>        </child>        <child>          <widget class=\"GtkButton\" id=\"buttonCE\">            <property name=\"visible\">True</property>            <property name=\"label\" translatable=\"yes\">CE</property>            <property name=\"response_id\">0</property>          </widget>          <packing>            <property name=\"left_attach\">4</property>            <property name=\"right_attach\">5</property>            <property name=\"top_attach\">1</property>            <property name=\"bottom_attach\">2</property>            <property name=\"x_padding\">4</property>            <property name=\"y_padding\">8</property>          </packing>        </child>        <child>          <widget class=\"GtkButton\" id=\"button4\">            <property name=\"visible\">True</property>            <property name=\"label\" translatable=\"yes\">4</property>            <property name=\"response_id\">0</property>          </widget>          <packing>            <property name=\"top_attach\">2</property>            <property name=\"bottom_attach\">3</property>            <property name=\"x_padding\">4</property>            <property name=\"y_padding\">8</property>          </packing>        </child>        <child>          <widget class=\"GtkButton\" id=\"button5\">            <property name=\"visible\">True</property>            <property name=\"label\" translatable=\"yes\">5</property>            <property name=\"response_id\">0</property>          </widget>          <packing>            <property name=\"left_attach\">1</property>            <property name=\"right_attach\">2</property>            <property name=\"top_attach\">2</property>            <property name=\"bottom_attach\">3</property>            <property name=\"x_padding\">4</property>            <property name=\"y_padding\">8</property>          </packing>        </child>        <child>          <widget class=\"GtkButton\" id=\"button6\">            <property name=\"visible\">True</property>            <property name=\"label\" translatable=\"yes\">6</property>            <property name=\"response_id\">0</property>          </widget>          <packing>            <property name=\"left_attach\">2</property>            <property name=\"right_attach\">3</property>            <property name=\"top_attach\">2</property>            <property name=\"bottom_attach\">3</property>            <property name=\"x_padding\">4</property>            <property name=\"y_padding\">8</property>          </packing>        </child>        <child>          <widget class=\"GtkButton\" id=\"buttonAdd\">            <property name=\"visible\">True</property>            <property name=\"label\" translatable=\"yes\">+</property>            <property name=\"response_id\">0</property>          </widget>          <packing>            <property name=\"left_attach\">3</property>            <property name=\"right_attach\">4</property>            <property name=\"top_attach\">2</property>            <property name=\"bottom_attach\">3</property>            <property name=\"x_padding\">4</property>            <property name=\"y_padding\">8</property>          </packing>        </child>        <child>          <widget class=\"GtkButton\" id=\"buttonMinus\">            <property name=\"visible\">True</property>            <property name=\"label\" translatable=\"yes\">-</property>            <property name=\"response_id\">0</property>          </widget>          <packing>            <property name=\"left_attach\">4</property>            <property name=\"right_attach\">5</property>            <property name=\"top_attach\">2</property>            <property name=\"bottom_attach\">3</property>            <property name=\"x_padding\">4</property>            <property name=\"y_padding\">8</property>          </packing>        </child>        <child>          <widget class=\"GtkButton\" id=\"button7\">            <property name=\"visible\">True</property>            <property name=\"label\" translatable=\"yes\">7</property>            <property name=\"response_id\">0</property>          </widget>          <packing>            <property name=\"top_attach\">3</property>            <property name=\"bottom_attach\">4</property>            <property name=\"x_padding\">4</property>            <property name=\"y_padding\">8</property>          </packing>        </child>        <child>          <widget class=\"GtkButton\" id=\"button8\">            <property name=\"visible\">True</property>            <property name=\"label\" translatable=\"yes\">8</property>            <property name=\"response_id\">0</property>          </widget>          <packing>            <property name=\"left_attach\">1</property>            <property name=\"right_attach\">2</property>            <property name=\"top_attach\">3</property>            <property name=\"bottom_attach\">4</property>            <property name=\"x_padding\">5</property>            <property name=\"y_padding\">8</property>          </packing>        </child>        <child>          <widget class=\"GtkButton\" id=\"button9\">            <property name=\"visible\">True</property>            <property name=\"label\" translatable=\"yes\">9</property>            <property name=\"response_id\">0</property>          </widget>          <packing>            <property name=\"left_attach\">2</property>            <property name=\"right_attach\">3</property>            <property name=\"top_attach\">3</property>            <property name=\"bottom_attach\">4</property>            <property name=\"x_padding\">4</property>            <property name=\"y_padding\">8</property>          </packing>        </child>        <child>          <widget class=\"GtkButton\" id=\"buttonMul\">

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -