remove image if exists
This commit is contained in:
11
main.c
11
main.c
@@ -3,22 +3,23 @@
|
||||
|
||||
typedef struct{
|
||||
GtkApplication *app;
|
||||
GtkWidget *window;
|
||||
GtkWidget *box;
|
||||
GtkWidget *input;
|
||||
GtkWidget *window , *box ,*input, *image;
|
||||
char dir[256];
|
||||
} Appdata;
|
||||
|
||||
static void load_image(Appdata *data){
|
||||
GError *error = NULL;
|
||||
if (data->image != NULL){
|
||||
gtk_box_remove(data->box,GTK_WIDGET(data->image));
|
||||
}
|
||||
GdkPixbuf *pix = gdk_pixbuf_new_from_file (("%s", data->dir), &error);
|
||||
if (pix == NULL){
|
||||
g_printerr("Error loading file: #%d %s\n", error->code, error->message);
|
||||
g_error_free(error);
|
||||
exit (1);
|
||||
}
|
||||
GtkWidget *widget = gtk_image_new_from_pixbuf (pix);
|
||||
gtk_box_append(GTK_BOX(data->box),widget);
|
||||
data->image = gtk_image_new_from_pixbuf(pix);
|
||||
gtk_box_append(GTK_BOX(data->box),data->image);
|
||||
}
|
||||
|
||||
// activates after enter dir in input
|
||||
|
||||
Reference in New Issue
Block a user