librano |
04-30-2009 06:22 AM |
gtkdialog + glade + bash/dash/sh
Hi all!
I am trying to build some simple applications in Linux. I am not a seasoned coder. I have some experience in bash scripting and very minimal knowledge of python. This is why I decided on using gtkdialog with an interface built using Glade and the code written in bash.
Let me mention that I am using Linux Mint Felicia which is based on Ubuntu Intrepid.
However, I am facing some problems with running gtkdialog. I keep getting this error:
Code:
sh: source: not found
sh: login_server: not found
It even appears when I use the example scripts that are provided in the gtkdialog docs. The GUI is displayed but any action that is initiated (clicking a button) gives this error in the terminal.
From my searches, I think the problem lies with the function scripts which contain bashisms... but I am not sure.
Here are the example files I am running.
glade-01.00-entries_functions.sh
Code:
#! /bin/bash
gtkdialog --glade-xml=glade-01.00-entries_functions.glade \
--include=glade-01.00-entries_functions.functions \
--program=login_window
glade-01.00-entries_functions.glade
Code:
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE glade-interface SYSTEM "glade-2.0.dtd">
<!-- Generated with glade3
Version: 3.0.1
Date: Thu Oct 26 22:04:10 2006
User: pipas
Host: desktop.otthon
-->
<glade-interface>
<widget class="GtkWindow" id="login_window">
<property name="border_width">5</property>
<property name="title">GtkDialog Example</property>
<child>
<widget class="GtkVBox" id="vbox1">
<property name="visible">True</property>
<child>
<widget class="GtkFrame" id="frame1">
<property name="visible">True</property>
<property name="label_xalign">0,000000</property>
<child>
<widget class="GtkAlignment" id="alignment1">
<property name="visible">True</property>
<property name="border_width">5</property>
<property name="left_padding">12</property>
<child>
<widget class="GtkTable" id="table1">
<property name="visible">True</property>
<property name="n_rows">3</property>
<property name="n_columns">2</property>
<property name="column_spacing">5</property>
<property name="row_spacing">5</property>
<child>
<widget class="GtkEntry" id="database_entry">
<property name="visible">True</property>
<property name="activates_default">True</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>
</packing>
</child>
<child>
<widget class="GtkEntry" id="name_entry">
<property name="visible">True</property>
<property name="activates_default">True</property>
<signal name="realize" handler="whoami"/>
</widget>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="top_attach">1</property>
<property name="bottom_attach">2</property>
</packing>
</child>
<child>
<widget class="GtkEntry" id="server_entry">
<property name="visible">True</property>
<property name="activates_default">True</property>
<property name="text">localhost</property>
</widget>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
</packing>
</child>
<child>
<widget class="GtkLabel" id="label4">
<property name="visible">True</property>
<property name="label" translatable="yes">Database:</property>
</widget>
<packing>
<property name="top_attach">2</property>
<property name="bottom_attach">3</property>
</packing>
</child>
<child>
<widget class="GtkLabel" id="label3">
<property name="visible">True</property>
<property name="label" translatable="yes">Name:</property>
</widget>
<packing>
<property name="top_attach">1</property>
<property name="bottom_attach">2</property>
</packing>
</child>
<child>
<widget class="GtkLabel" id="label2">
<property name="visible">True</property>
<property name="label" translatable="yes">Server:</property>
</widget>
</child>
</widget>
</child>
</widget>
</child>
<child>
<widget class="GtkLabel" id="label1">
<property name="visible">True</property>
<property name="label" translatable="yes"><b>PostgreSQL Login</b></property>
<property name="use_markup">True</property>
</widget>
<packing>
<property name="type">label_item</property>
</packing>
</child>
</widget>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
</packing>
</child>
<child>
<widget class="GtkHButtonBox" id="hbuttonbox1">
<property name="visible">True</property>
<property name="border_width">5</property>
<property name="spacing">5</property>
<property name="layout_style">GTK_BUTTONBOX_END</property>
<child>
<widget class="GtkButton" id="cancel_button">
<property name="visible">True</property>
<property name="label">gtk-cancel</property>
<property name="use_stock">True</property>
<signal name="clicked" handler="echo "hello"" object="objektum neve"/>
<signal name="clicked" handler="exit:Cancel"/>
</widget>
</child>
<child>
<widget class="GtkButton" id="ok_button">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="can_default">True</property>
<property name="has_default">True</property>
<property name="label">gtk-ok</property>
<property name="use_stock">True</property>
<signal name="clicked" handler="login_server "$server_entry" "$name_entry" "$database_entry""/>
</widget>
<packing>
<property name="position">1</property>
</packing>
</child>
</widget>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">1</property>
</packing>
</child>
</widget>
</child>
</widget>
</glade-interface>
glade-01.00-entries_functions.functions
Code:
#! /bin/bash
#
# We don't really need this first line but my text editor recognizes it and i
# like the syntax highlight.
#
function login_server()
{
xterm -hold -e "psql -h $1 -U $2 -d $3" &
}
What is wrong here? I am totally stumped...
|