LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   gtkdialog + glade + bash/dash/sh (https://www.linuxquestions.org/questions/programming-9/gtkdialog-glade-bash-dash-sh-722678/)

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">&lt;b&gt;PostgreSQL Login&lt;/b&gt;</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 &quot;hello&quot;" 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 &quot;$server_entry&quot; &quot;$name_entry&quot; &quot;$database_entry&quot;"/>
              </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...

travisn000 06-28-2009 08:22 PM

I know its been awhile, but I saw the answer to this while looking for other related gtkdialog info..

..apparently Ubuntu uses dash instead of bash; the post I saw indicates that it will work normally if you change to a true bash shell. (I think the post was on this forum, but I cannot find it:confused:)

disciplepup 11-24-2009 12:02 AM

It's been even longer now :)
How far did you get with this, and did you find any good examples? I'd quite like to find some gtkdialog/glade examples...

Also, if you didn't want to use glade you should check out the gtkdialog/bash programs used in Puppy Linux, some of which are very complex (a lot are found here - N.B. a .pet file is just a .tar.gz with a checksum), and the gtkdialog tips thread

travisn000 11-24-2009 11:34 PM

I put together a few basic examples awhile back, and also links to my resources:

http://www.pclinuxos.com/forum/index...c,59050.0.html



Hopefully you will find them helpful!

disciplepup 11-26-2009 02:46 AM

thanks


All times are GMT -5. The time now is 07:02 PM.