Re: [gtk-list] file selection bombs
- From: Nils Philippsen <nils rhlx01 rz fht-esslingen de>
- To: gtk-list redhat com
- Subject: Re: [gtk-list] file selection bombs
- Date: Fri, 19 Dec 1997 08:04:55 +0100 (MET)
Recently I got the following mail regarding to my query on gtk-list. I
apologize for only posting source code which wouldhn't compile standalone. Now
I attached to files (updownload.c, updownload.h), which will compile out of
the box (gcc -o updownload updownload.c -L<where your gtk+libs are> -I<where
your gtk+includes are> -lgtk -lgdk -lglib -lX11 -lm) _and_ show the strange
behaviour I noticed only in gtk+-0.99.0 (not in previuos versions of gtk+):
Selecting file by double-clicking on it will bomb with SIGABRT, Selecting file
by single-clicking, then OK will succeed.
Thanks for any help regarding this,
Nils
PS: I really do think this is a bug in gtk+, since it bombs with a
double-click and succeeds with a single-click, then OK.
On Thu, 18 Dec 1997, Tim Janik wrote:
> On Thu, 18 Dec 1997, Nils Philippsen wrote:
>
> > Hi,
> >
> > I'm suffering from a problem within the file selection box. Nearly every time
> > I select a file, then OK, the app bombs with SIGABRT:
> >
> > --snip--
>
> hm, could you please post an example that compiles out of the box
> and give a short description how to trigger the bug?
>
> id rather spend my time debugging your problem, than converting your code
> to get it to work ;)
>
> >
> > Regards Nils
> >
>
> ---
> ciaoTJ
>
--
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Nils Philippsen @college: nils@rhlx01.rz.fht-esslingen.de
Vogelsangstrasse 115 @home: nils@wombat.dialup.fht-esslingen.de
D 70197 Stuttgart Do not meddle in the affairs of wizards,
+49-711-6599405 for you are crunchy and good with ketchup.
#ifndef __UPDOWNLOAD_H
#define __UPDOWNLOAD_H
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
void file_upload_cmd_callback (GtkWidget * widget, gpointer data);
void file_download_cmd_callback (GtkWidget * widget, gpointer data);
gint file_upload_del_callback(GtkWidget * widget, GdkEvent *event, GtkWidget *dlg);
void file_upload_ok_sel(GtkWidget *widget, GtkWidget *dlg);
void file_upload_cancel_sel(GtkWidget *widget, GtkWidget *dlg);
void file_upload_fileerror(void);
gint file_upload_fileerror_del(GtkWidget * widget, GdkEvent *event, GtkWidget *dlg);
void file_upload_fileerror_ok(GtkWidget *widget, GtkWidget *dlg);
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* __UPDOWNLOAD_H */
#include <gtk/gtk.h>
#include <string.h>
#include "updownload.h"
char *filename;
void
main (int argc, char **argv)
{
GtkWidget *filew;
filename=strdup("");
gtk_init(&argc, &argv);
filew = gtk_file_selection_new ("Upload File");
gtk_signal_connect (GTK_OBJECT (filew), "delete_event",
(GtkSignalFunc) file_upload_del_callback, GTK_WIDGET(filew));
gtk_signal_connect (GTK_OBJECT (GTK_FILE_SELECTION (filew)->ok_button),
"clicked", (GtkSignalFunc) file_upload_ok_sel, GTK_WIDGET(filew));
gtk_signal_connect (GTK_OBJECT (GTK_FILE_SELECTION (filew)->cancel_button),
"clicked", (GtkSignalFunc) file_upload_cancel_sel, GTK_WIDGET(filew));
gtk_file_selection_set_filename (GTK_FILE_SELECTION(filew), filename);
gtk_widget_show(filew);
gtk_main();
}
gint
file_upload_del_callback (GtkWidget *widget, GdkEvent *event, GtkWidget *dlg)
{
file_upload_cancel_sel(widget, dlg);
return FALSE;
}
void
file_upload_cancel_sel (GtkWidget *widget, GtkWidget *dlg)
{
gtk_widget_hide(dlg);
gtk_widget_destroy(dlg);
}
void
file_upload_ok_sel (GtkWidget *widget, GtkWidget *dlg)
{
char newfilename[1025];
FILE *fd;
strncpy(newfilename,gtk_file_selection_get_filename (GTK_FILE_SELECTION (dlg)),1024);
gtk_widget_hide(GTK_WIDGET(dlg));
gtk_widget_destroy(GTK_WIDGET(dlg));
if((fd=fopen(newfilename, "r"))==(FILE *) NULL) {
fclose(fd);
file_upload_fileerror();
} else {
fclose(fd);
if (filename!=(char *)0)
free(filename);
filename=strdup(newfilename);
}
g_print("Selected filename: %s\n", filename);
gtk_main_quit();
}
void
file_upload_fileerror(void)
{
GtkWidget *window;
GtkWidget *label;
GtkWidget *button;
window=gtk_dialog_new();
gtk_grab_add(window);
gtk_container_border_width(GTK_CONTAINER(window),10);
gtk_grab_add(window);
gtk_window_set_title (GTK_WINDOW (window), "Error");
label=gtk_label_new("File could not be accessed");
gtk_container_add(GTK_CONTAINER(GTK_DIALOG(window)->vbox), label);
gtk_widget_show(label);
button=gtk_button_new_with_label(" OK ");
GTK_WIDGET_SET_FLAGS (button, GTK_CAN_DEFAULT);
gtk_container_add(GTK_CONTAINER(GTK_DIALOG(window)->action_area), button);
gtk_widget_grab_default (button);
gtk_signal_connect (GTK_OBJECT(button), "delete_event", (GtkSignalFunc) file_upload_fileerror_del, window);
gtk_signal_connect (GTK_OBJECT(button), "clicked", (GtkSignalFunc) file_upload_fileerror_ok, window);
gtk_widget_show(button);
gtk_widget_show(window);
}
gint
file_upload_fileerror_del(GtkWidget *widget, GdkEvent *event, GtkWidget *dlg)
{
file_upload_fileerror_ok(widget, dlg);
return FALSE;
}
void
file_upload_fileerror_ok(GtkWidget *widget, GtkWidget *dlg)
{
gtk_grab_remove(dlg);
gtk_widget_hide(dlg);
gtk_widget_destroy(dlg);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]