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

📄 calculator.bash.ipc

📁 gtk_server的源代码
💻 IPC
📖 第 1 页 / 共 2 页
字号:
#!/bin/bash## Demonstration on how to use Glade and the GTK-server with BASH.## Tested with GTK-server 2.2.9 on SLAMD12 and BASH 3.1# Nov 1, 2008 (c) Peter van Eerten - GPL license.## Proving that the IPC interface accepts unlimited input.##----------------------------------------------------------- Setup embedded GTK# Pipe filename must be unique for your applicationIPC="\$$"# 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/.gtk4bash-ipc || $CFG -nt $HOME/.gtk4bash-ipc ]]; then    echo "#!/bin/bash" > $HOME/.gtk4bash-ipc    echo "gtk-server -ipc=$IPC &" >> $HOME/.gtk4bash-ipc    while read LINE    do	if [[ $LINE = FUNCTION_NAME* ]]; then	    LINE=${LINE#*= }	    printf "function ${LINE%%,*}\n" >> $HOME/.gtk4bash-ipc	    printf "{\nARGS=\"\$@\"\n" >> $HOME/.gtk4bash-ipc	    printf "GTK=\`gtk-server -msg=$IPC,\"${LINE%%,*} \$ARGS\"\`\n}\n" >> $HOME/.gtk4bash-ipc	fi    done < $CFGfi# Declare global variablesdeclare GTK NULL="NULL"unset CFG IPC LINE# Include the generated file to use embedded GTK functions. ${HOME}/.gtk4bash-ipc#---------------------------------------------------------- Global inits# Assignment functionfunction define() { $2 $3 $4 $5 $6 $7 $8 $9; eval $1="$GTK"; }#---------------------------------------------------------- GUI realization# 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\">BASH Calculator IPC</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>

⌨️ 快捷键说明

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