LQ Newbie
Registered: Dec 2013
Location: Not hiding but ashamed that it is worse than New Jersey
Distribution: slackware 14.2
Posts: 2
Rep:
|
No such file or directory, but the file is there.
The following code to make an inbox works now that I recompiled it in slackware14, but the binary compiled from the same source in puppy lupu
gives a "no such file..." message.
Also, I tried to get a package converted from a deb package to run and got the same message.
Why does slackware give a misleading error message?
I use this inbox program in scripts because it allows the enter key to
output the input text. I don't know of another input program that has a gui that doesn't require a mouse click to return the input.
Barry Brooks
/**
* compile with the following command
* gcc -Wall -g $f.c -o $f `pkg-config --libs --cflags gtk+-2.0`
* gcc -Wall -g hello.c -o hello `pkg-config --cflags gtk+-2.0` `pkg-config --libs gtk+-2.0`
*/
#include <gtk/gtk.h>
#include <gdk/gdkkeysyms.h>
#include <string.h>
// for EXIT_SUCCESS must #include <stdlib.h>
int xcode = 0;
gboolean delete1 (GtkWidget *widget, GdkEvent *event, gpointer udat)
{
xcode = 122;
return FALSE;
}
void destroy1 (GtkObject *object, gpointer udat)
{
xcode = 1;
gtk_main_quit();
}
gboolean key_pressed(GtkWidget * window, GdkEventKey* event, gpointer entry2) {
if ((event->keyval== GDK_Return)) {
gchar *strout=NULL;
// strout = g_strconcat(gtk_entry_get_text(GTK_ENTRY(entry2)), NULL);
strout = g_strdup(gtk_entry_get_text(GTK_ENTRY(entry2)));
int len; /* current line length */
len = strlen (strout);
if (len > 0) {
g_print ("%s\n", strout);
// g_print ("\n");
g_free(strout);
xcode = 0;
gtk_main_quit ();}
else {
xcode = 255;
gtk_main_quit ();}
}
return FALSE;
}
gboolean button_pressed(GtkWidget * window, gpointer entry3) {
gchar *strout=NULL;
strout = g_strdup(gtk_entry_get_text(GTK_ENTRY(entry3)));
int len; /* current line length */
len = strlen (strout);
if (len > 0) {
g_print ("%s\n", strout);
// g_print ("\n");
g_free(strout);
xcode = 0;
gtk_main_quit ();}
else {
xcode = 255;
gtk_main_quit ();}
return FALSE;
}
int main( int argc,
char *argv[] )
{
GtkWidget *window; // The main application window
GtkWidget *instruct; // GtkLabel "Enter Your Name:"
GtkWidget *entry; // GtkEntry box1
GtkWidget *box1; // Vertical box1 for packing widgets in the window
// GtkWidget *box2; // Vertical box1 for packing widgets in the window
GtkWidget *button; // What one pushes
char *labeltext = "Enter String";
char *windowtitle = "Input box1";
int iwidth;
int iheight;
gtk_init (&argc, &argv);
if (argc < 3)
{
iwidth = 300;
iheight = 75;
}
else
{
// iwidth = strtol (argv[1], &tail, 0);
// iheight = strtol (argv[2], &tail, 0);
iwidth = 600;
iheight = 150;
}
if (argc > 3)
{
labeltext = argv[3];
}
if (argc > 4)
{
windowtitle = argv[4];
}
// Create the top-level window
window = gtk_window_new (GTK_WINDOW_TOPLEVEL); // Create the window
gtk_container_set_border_width(GTK_CONTAINER(window),10); // Set a border around the edges
gtk_window_set_urgency_hint (GTK_WINDOW(window), TRUE); // Send the urgency signal to the window manager (e.g make the taskbar entry flash)
gtk_window_set_title (GTK_WINDOW(window),windowtitle); // Set the window title
gtk_window_set_default_size(GTK_WINDOW(window), iwidth, iheight);
gtk_window_set_position(GTK_WINDOW(window), GTK_WIN_POS_CENTER);
g_signal_connect(G_OBJECT(window), "destroy", G_CALLBACK(destroy1), NULL);
g_signal_connect(G_OBJECT(window), "delete_event", G_CALLBACK(delete1), NULL);
box1 = gtk_vbox_new (FALSE, 0); // Create the vbox
gtk_container_add(GTK_CONTAINER(window), box1); // Add the vbox to the window
gtk_widget_show(box1); // Display the vbox (although you can't actually see anything)
instruct = gtk_label_new (labeltext);
gtk_box_pack_start (GTK_BOX (box1), instruct, TRUE, TRUE, 5); // Add the widget to the vbox (first item)
gtk_widget_show(instruct);
entry = gtk_entry_new();
gtk_box_pack_start (GTK_BOX (box1), entry, TRUE, TRUE, 5); // Add the widget to the vbox (second item)
gtk_widget_show(entry);
gtk_widget_grab_focus(entry);
g_signal_connect(G_OBJECT(entry), "key-press-event", G_CALLBACK(key_pressed), entry);
// box2 = gtk_hbox_new (FALSE, 0); // Create the vbox
// gtk_container_add(GTK_CONTAINER(window), box2); // Add the vbox to the window
// gtk_widget_show(box2); // Display the vbox (although you can't actually see anything)
button = gtk_button_new_with_label ("Done");
gtk_box_pack_start (GTK_BOX (box1), button, TRUE, TRUE, 5); // Add the widget to the hbox (second item)
gtk_widget_show (button);
g_signal_connect(button, "clicked", G_CALLBACK (button_pressed), entry);
gtk_widget_show (window); // Display the window
gtk_main (); // Start the Gtk Main Loop
return xcode;
}
|