file_selector.c 17.2 KB
Newer Older
1 2 3 4 5 6
/* gcompris - file_selector.c
 *
 * Copyright (C) 2000 Bruno Coudoin
 *
 *   This program is free software; you can redistribute it and/or modify
 *   it under the terms of the GNU General Public License as published by
7
 *   the Free Software Foundation; either version 3 of the License, or
8 9 10 11 12 13 14 15
 *   (at your option) any later version.
 *
 *   This program is distributed in the hope that it will be useful,
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *   GNU General Public License for more details.
 *
 *   You should have received a copy of the GNU General Public License
16
 *   along with this program; if not, see <http://www.gnu.org/licenses/>.
17 18 19
 */

/**
20
 * A file selector for gcompris
21 22 23
 *
 */

24 25
#include <sys/types.h>
#include <sys/stat.h>
26
#include <string.h>
27

28 29 30 31
/* libxml includes */
#include <libxml/tree.h>
#include <libxml/parser.h>

32
#include "gcompris.h"
33
#include "gc_core.h"
34 35 36

#define SOUNDLISTFILE PACKAGE

37 38
#define MODE_LOAD 1
#define MODE_SAVE 2
39
static gint mode;
40

41 42 43 44 45
static gboolean item_event_file_selector (GooCanvasItem  *item,
					  GooCanvasItem  *target,
					  GdkEventButton *event,
					  char *data);
static void		 item_event_scroll(GtkAdjustment *adj,
46 47
					   GooCanvas *canvas);
static gint		 item_event_directory(GooCanvasItem *item,
48
					      GdkEvent *event,
49
					      char *dir);
50
static void		 display_files(GooCanvasItem *rootitem, gchar *rootdir);
51
static int		 display_file_selector(int mode,
52 53 54
					       GcomprisBoard *gcomprisBoard,
					       gchar *rootdir,
					       gchar *file_types,
55
					       FileSelectorCallBack iscb);
56 57
static void		 entry_enter_callback( GtkWidget *widget,
					       GtkWidget *entry );
58 59
static gboolean		 file_selector_displayed = FALSE;

60 61
static GooCanvasItem	*rootitem = NULL;
static GooCanvasItem	*file_root_item = NULL;
62

63 64
static FileSelectorCallBack  fileSelectorCallBack = NULL;
static GtkWidget            *gtk_combo_filetypes = NULL;
65

66
static gchar *current_rootdir = NULL;
67
static GtkWidget *widget_entry = NULL;
68

69
/* Represent the limits of control area */
70 71 72
static guint32 control_area_x1;
static guint32 control_area_y1;
static guint32 directory_label_y;
73 74

/* Represent the limits of the file area */
75
#define	DRAWING_AREA_X1	40.0
76
#define DRAWING_AREA_Y1	220.0
77 78
#define DRAWING_AREA_X2	760.0
#define DRAWING_AREA_Y2	500.0
79

80 81
#define HORIZONTAL_NUMBER_OF_IMAGE	5
#define VERTICAL_NUMBER_OF_IMAGE	3
82
#define IMAGE_GAP			18
83 84 85 86 87

#define IMAGE_WIDTH  (DRAWING_AREA_X2-DRAWING_AREA_X1)/HORIZONTAL_NUMBER_OF_IMAGE-IMAGE_GAP
#define IMAGE_HEIGHT (DRAWING_AREA_Y2-DRAWING_AREA_Y1)/VERTICAL_NUMBER_OF_IMAGE-IMAGE_GAP

/*
88
 * Main entry point
89 90 91 92 93 94
 * ----------------
 *
 */

/*
 * Do all the file_selector display and register the events
95
 * file_types is A Space separated possible file extensions
96 97
 */

98
void gc_selector_file_save (GcomprisBoard *gcomprisBoard, gchar *rootdir,
99
				  gchar *file_exts,
100 101
				  FileSelectorCallBack iscb)
{
102
  display_file_selector(MODE_SAVE, gcomprisBoard, rootdir, file_exts,
103
			iscb);
104 105
}

106
void gc_selector_file_load (GcomprisBoard *gcomprisBoard, gchar *rootdir,
107
				  gchar *file_exts,
108 109
				  FileSelectorCallBack iscb)
{
110
  display_file_selector(MODE_LOAD, gcomprisBoard, rootdir, file_exts,
111 112 113 114 115 116 117
			iscb);
}

/*
 * Remove the displayed file_selector.
 * Do nothing if none is currently being dislayed
 */
118 119
void
gc_selector_file_stop ()
120
{
121
  GcomprisBoard *gcomprisBoard = gc_board_get_current();
122 123

  if(gcomprisBoard!=NULL && file_selector_displayed)
124
    gc_board_pause(FALSE);
125 126 127

  // Destroy the file_selector box
  if(rootitem!=NULL)
128
    goo_canvas_item_remove(rootitem);
129

130
  rootitem = NULL;
131 132 133 134

  /* No need to destroy it since it's in rootitem but just clear it */
  file_root_item = NULL;

135
  gc_bar_hide(FALSE);
136 137 138 139 140 141 142 143 144 145 146
  file_selector_displayed = FALSE;
}



/*-------------------------------------------------------------------------------*/
/*-------------------------------------------------------------------------------*/
/*-------------------------------------------------------------------------------*/
/*-------------------------------------------------------------------------------*/


147 148
static int
display_file_selector(int the_mode,
149 150
		      GcomprisBoard *gcomprisBoard,
		      gchar *rootdir,
151 152 153 154
		      gchar *file_exts,
		      FileSelectorCallBack iscb)
{
  GooCanvasItem    *item;
155
  GooCanvasItem    *item2;
156 157 158 159 160 161
  GdkPixbuf	   *pixmap = NULL;
  gint		    y = 0;
  gint		    y_start = 0;
  gint		    x_start = 0;
  gchar		   *name = NULL;
  gchar            *full_rootdir;
162

163 164
  mode = the_mode;

165
  /* Get the coordinate x y of the control area from the skin */
166 167 168
  control_area_x1   = gc_skin_get_number_default("gcompris/fileselectx", 85);
  control_area_y1   = gc_skin_get_number_default("gcompris/fileselecty", 80);
  directory_label_y = gc_skin_get_number_default("gcompris/fileselectdiry", 180);
169

170
  if(rootitem)
171
    return 0;
172

173
  gc_bar_hide(TRUE);
174

175
  gc_board_pause(TRUE);
176 177 178 179

  name = gcomprisBoard->name;
  fileSelectorCallBack=iscb;

180 181
  rootitem = goo_canvas_group_new (goo_canvas_get_root_item(gc_get_canvas()),
				   NULL);
182

183
  pixmap = gc_skin_pixmap_load("file_selector_bg.png");
184 185
  y_start = (BOARDHEIGHT - gdk_pixbuf_get_height(pixmap))/2;
  x_start = (BOARDWIDTH - gdk_pixbuf_get_width(pixmap))/2;
186

187 188
  item = goo_canvas_image_new (rootitem,
			       pixmap,
189 190 191 192
			       x_start,
			       y_start,
			       NULL);

193 194 195
  y = BOARDHEIGHT - (BOARDHEIGHT - gdk_pixbuf_get_height(pixmap))/2 + 20;
  gdk_pixbuf_unref(pixmap);

196
  /* Entry area */
197 198
  widget_entry = gtk_entry_new ();

199
  if(mode==MODE_SAVE)
200 201
    gtk_entry_set_max_length(GTK_ENTRY(widget_entry), 30);

202 203 204 205 206 207
  item = goo_canvas_widget_new (rootitem,
				GTK_WIDGET(widget_entry),
				control_area_x1,
				control_area_y1,
				230.0,
				30.0,
208
				NULL);
209

210 211 212
  gtk_signal_connect(GTK_OBJECT(widget_entry), "activate",
		     GTK_SIGNAL_FUNC(entry_enter_callback),
		     widget_entry);
213

214
  gtk_widget_show(widget_entry);
215 216

  /*
217
   * Create the combo with the file types
218 219
   * ------------------------------------
   */
220 221 222 223
  if(mode==MODE_SAVE && file_exts && *file_exts != '\0')
  {
    gchar **all_type = g_strsplit(file_exts, " ", 0);
    guint i = 0;
224

225 226
    gtk_combo_filetypes = gtk_combo_box_new_text();

227
    /* Extract first string */
228 229 230
    while (all_type[i])
      gtk_combo_box_append_text(GTK_COMBO_BOX(gtk_combo_filetypes),
				g_strdup(all_type[i++]) );
231

232
    g_strfreev(all_type);
233

234 235 236 237 238 239
    goo_canvas_widget_new (rootitem,
			   gtk_combo_filetypes,
			   control_area_x1 + 400,
			   control_area_y1,
			   250.0,
			   35.0,
240 241
			   NULL);

242
    gtk_widget_show(gtk_combo_filetypes);
243 244
    gtk_combo_box_set_active(GTK_COMBO_BOX(gtk_combo_filetypes), 0);
  }
245

246 247
  y_start += 110;

248 249 250 251 252
  /*
   * Buttons
   * -------
   */

253
  pixmap = gc_skin_pixmap_load("button_large.png");
254

255
  // CANCEL
256 257 258 259
  item = goo_canvas_image_new (rootitem,
			       pixmap,
			       (double) (BOARDWIDTH*0.33) - gdk_pixbuf_get_width(pixmap)/2,
			       (double) y - gdk_pixbuf_get_height(pixmap) - 25,
260 261
				NULL);

262
  g_signal_connect(item, "button_press_event",
263 264
		   (GtkSignalFunc) item_event_file_selector,
		   "/cancel/");
265
  gc_item_focus_init(item, NULL);
266

267
  item2 = goo_canvas_text_new (rootitem,
268 269 270 271 272 273 274 275
			      _("CANCEL"),
			      (gdouble)  BOARDWIDTH*0.33,
			      (gdouble)  y - gdk_pixbuf_get_height(pixmap),
			      -1,
			      GTK_ANCHOR_CENTER,
			      "font", gc_skin_font_title,
			      "fill-color-rgba", gc_skin_color_text_button,
			      NULL);
276
  g_signal_connect(item2, "button_press_event",
277 278
		   (GtkSignalFunc) item_event_file_selector,
		   "/cancel/");
279
  gc_item_focus_init(item2, item);
280

281
  // OK
282 283 284 285
  item = goo_canvas_image_new (rootitem,
			       pixmap,
			       (double) (BOARDWIDTH*0.66) - gdk_pixbuf_get_width(pixmap)/2,
			       (double) y - gdk_pixbuf_get_height(pixmap) - 25,
286 287
				NULL);

288
  g_signal_connect(item, "button_press_event",
289 290
		     (GtkSignalFunc) item_event_file_selector,
		     "/ok/");
291
  gc_item_focus_init(item, NULL);
292

293
  item2 = goo_canvas_text_new (rootitem,
294 295 296 297 298 299 300 301
			      (mode==MODE_LOAD ? _("LOAD") : _("SAVE")),
			      (gdouble)  BOARDWIDTH*0.66,
			      (gdouble)  y - gdk_pixbuf_get_height(pixmap),
			      -1,
			      GTK_ANCHOR_CENTER,
			      "font", gc_skin_font_title,
			      "fill-color-rgba", gc_skin_color_text_button,
			      NULL);
302
  g_signal_connect(item2, "button_press_event",
303 304
		   (GtkSignalFunc) item_event_file_selector,
		   "/ok/");
305
  gc_item_focus_init(item2, item);
306 307
  gdk_pixbuf_unref(pixmap);

308

309 310
  file_selector_displayed = TRUE;

311
  full_rootdir = g_strconcat(gc_prop_get()->user_dir, "/", rootdir, NULL);
312
  gc_util_create_rootdir(full_rootdir);
313 314

  current_rootdir = full_rootdir;
315

316
  display_files(rootitem, full_rootdir);
317

318 319
  return 0;

320 321
}

322
static void
323
display_files(GooCanvasItem *root_item, gchar *rootdir)
324
{
325
  GooCanvasItem *item;
326
  double iw, ih;
327 328
  const gchar *one_dirent;
  GDir  *dir;
329

330
  /* Initial image position */
331 332 333 334
  guint ix  = 0.0;
  guint iy  = 0.0;

  GtkWidget	  *w;
335
  GooCanvasItem *bg_item;
336

337
  GtkWidget *canvas; /* The scrolled part */
338

339
  GList  *dir_list  = NULL;
340
  GList  *file_list = NULL;
341 342
  GList  *listrunner;

343 344
  GtkAdjustment *adj;

345 346 347
  if(!rootitem)
    return;

348
  /* Display the directory content */
349
  dir = g_dir_open(rootdir, 0, NULL);
350 351

  if (!dir) {
352 353
    g_warning("gcompris_file_selector : no root directory found in %s", rootdir);
    g_free(rootdir);
354 355 356
    return;
  }

357
  /* Delete the previous file root if any */
358 359
  if(file_root_item)
    goo_canvas_item_remove(file_root_item);
360

361
  /* Create a root item to put the image list in it */
362
  file_root_item = goo_canvas_group_new (root_item, NULL);
363

364 365 366 367
  /*
   * Create the scrollbar
   * --------------------
   */
368 369 370 371 372 373
  canvas = goo_canvas_new();

  goo_canvas_widget_new (file_root_item,
			 canvas,
			 DRAWING_AREA_X1,
			 DRAWING_AREA_Y1,
374 375
			 DRAWING_AREA_X2 - DRAWING_AREA_X1 - 20.0,
			 DRAWING_AREA_Y2 - DRAWING_AREA_Y1 - 35.0,
376 377
			 NULL);

378
  gtk_widget_show (canvas);
379 380

  /* Set the new canvas to the background color or it's white */
381 382 383
  bg_item = goo_canvas_rect_new (goo_canvas_get_root_item(GOO_CANVAS(canvas)),
				 0,
				 0,
384
				 DRAWING_AREA_X2 - DRAWING_AREA_X1 + 200,
385
				 DRAWING_AREA_Y2 - DRAWING_AREA_Y1,
386
				 "fill-color-rgba", gc_skin_get_color("gcompris/fileselectbg"),
387
				 "line-width", 0.0,
Bruno Coudoin's avatar
Bruno Coudoin committed
388
				 NULL);
389 390


391 392
  adj = \
    GTK_ADJUSTMENT (gtk_adjustment_new (0.00, 0.00,
393
					IMAGE_HEIGHT,
394 395 396 397
					10, IMAGE_HEIGHT,
					(DRAWING_AREA_Y2 - DRAWING_AREA_Y1)/3)
		    );
  w = gtk_vscrollbar_new (adj);
398

399 400 401 402 403
  goo_canvas_widget_new (file_root_item,
			 w,
			 DRAWING_AREA_X2 - 15.0,
			 DRAWING_AREA_Y1,
			 30.0,
404
			 DRAWING_AREA_Y2 - DRAWING_AREA_Y1 - 20.0,
Bruno Coudoin's avatar
Bruno Coudoin committed
405
			 NULL);
406 407
  gtk_widget_show (w);

408
  /* Set the scrollwheel event */
409 410 411
  g_signal_connect (adj, "value_changed",
		    (GtkSignalFunc) item_event_scroll,
		    canvas);
412 413 414 415 416

  /* Display the directory name
   * --------------------------
   */

417 418 419 420 421 422
  item = goo_canvas_text_new (file_root_item,
			      rootdir,
			      (gdouble)control_area_x1,
			      (gdouble)directory_label_y,
			      -1,
			      GTK_ANCHOR_NW,
423 424
			      "fill-color-rgba",
			      gc_skin_get_color("gcompris/fileselectcol"),
425
			      NULL);
426 427


428 429 430
  iw = IMAGE_WIDTH;
  ih = IMAGE_HEIGHT;

431 432
  /* Insert all files in a sorted list */

433 434 435
  while((one_dirent = g_dir_read_name(dir)) != NULL)
    {
      gchar *filename;
436

437 438
      filename = g_strdup_printf("%s/%s",
				 rootdir, (gchar*)(one_dirent));
439

440 441 442 443 444 445 446 447 448 449
      if(g_file_test(filename, G_FILE_TEST_IS_DIR))
	{
	  dir_list = g_list_insert_sorted(dir_list, filename,
					  (GCompareFunc)strcmp);
	}
      else
	{
	  file_list = g_list_insert_sorted(file_list, filename,
					   (GCompareFunc)strcmp);
	}
450 451 452 453 454
    }

  /* Concat the directory list and file list */
  file_list = g_list_concat(dir_list, file_list);

455 456 457
  g_list_free(dir_list);
  dir_list = NULL;

458 459
  /* We have the list sorted, now display it */
  listrunner = g_list_first(file_list);
460 461 462 463 464 465 466 467 468 469 470 471 472 473
  while(listrunner)
    {
      /* add the file to the display */
      GdkPixbuf *pixmap_current;

      gchar *allfilename = listrunner->data;
      gchar *filename    = g_path_get_basename(allfilename);
      gchar *ext = g_strrstr(filename, ".");
      gchar *file_wo_ext = g_strdup(filename);

      if(ext)
	{
	  gchar *ext2 = g_strrstr(file_wo_ext, ".");
	  *ext2 = '\0';
474
	}
475 476 477 478

      if(g_file_test(allfilename, G_FILE_TEST_IS_DIR))
	pixmap_current  = gc_pixmap_load(gc_skin_image_get("directory.png"));
      else
479
	pixmap_current  = gc_pixmap_load(gc_skin_image_get("file.png"));
480

481 482 483 484 485 486
      item = goo_canvas_image_new (goo_canvas_get_root_item(GOO_CANVAS(canvas)),
				   pixmap_current,
				   ix + (IMAGE_WIDTH + IMAGE_GAP
					 - gdk_pixbuf_get_width(pixmap_current))/2,
				   iy,
				   NULL);
487

488
      gdk_pixbuf_unref(pixmap_current);
489

490 491 492 493 494 495 496 497 498 499 500 501
      if(g_file_test(allfilename, G_FILE_TEST_IS_DIR))
	{
	  g_signal_connect(item, "button_press_event",
			   (GtkSignalFunc) item_event_directory,
			   allfilename);
	}
      else
	{
	  g_signal_connect(item, "button_press_event",
			   (GtkSignalFunc) item_event_file_selector,
			   allfilename);
	}
502
      gc_item_focus_init(item, NULL);
503

504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529
      g_object_set_data_full (G_OBJECT (item),
			      "allfilename", allfilename, g_free);
      /* The type */
      if(ext)
	goo_canvas_text_new (goo_canvas_get_root_item(GOO_CANVAS(canvas)),
			     ext,
			     ix + (IMAGE_WIDTH + IMAGE_GAP)/2,
			     iy + 10,
			     -1,
			     GTK_ANCHOR_CENTER,
			     "font", "Sans 7",
			     "fill-color-rgba",
			     gc_skin_get_color("gcompris/fileselectcol"),
			     NULL);

      /* The filename */
      item = goo_canvas_text_new (goo_canvas_get_root_item(GOO_CANVAS(canvas)),
				  file_wo_ext,
				  ix + (IMAGE_WIDTH + IMAGE_GAP)/2,
				  iy + IMAGE_HEIGHT - 5,
				  -1,
				  GTK_ANCHOR_CENTER,
				  "fill-color-rgba", gc_skin_get_color("gcompris/fileselectcol"),
				  NULL);
      g_free(file_wo_ext);
      g_free(filename);
530

531 532 533 534 535 536 537 538 539 540 541 542
      if(g_file_test(allfilename, G_FILE_TEST_IS_DIR))
	{
	  g_signal_connect(item, "button_press_event",
			   (GtkSignalFunc) item_event_directory,
			   allfilename);
	}
      else
	{
	  g_signal_connect(item, "button_press_event",
			   (GtkSignalFunc) item_event_file_selector,
			   allfilename);
	}
543

544
      ix += IMAGE_WIDTH + IMAGE_GAP;
545

546 547 548 549
      if(ix >= DRAWING_AREA_X2 - DRAWING_AREA_X1 -
	 (IMAGE_WIDTH + IMAGE_GAP) )
	{
	  ix=0;
550

551
	  iy+=IMAGE_HEIGHT + IMAGE_GAP;
552

553 554 555 556 557 558 559 560 561 562 563
	  goo_canvas_set_bounds (GOO_CANVAS(canvas),
				 0, 0,
				 DRAWING_AREA_X2- DRAWING_AREA_X1,
				 iy + IMAGE_HEIGHT + IMAGE_GAP);

	  if(iy >= DRAWING_AREA_Y2-DRAWING_AREA_Y1)
	    {
	      g_object_set(bg_item,
			   "height", (double)iy + IMAGE_HEIGHT + IMAGE_GAP,
			   NULL);
	      g_object_set(adj,
564
			   "upper", (double)iy - IMAGE_HEIGHT + IMAGE_GAP - 1,
565 566
			   NULL);
	    }
567
	}
568 569
      listrunner = g_list_next(listrunner);
    }
570

571
  g_dir_close(dir);
572
  g_list_free(file_list);
573

574 575
  /* Warning: we don't scale the internal canvas dynamicaly */
  goo_canvas_set_scale (GOO_CANVAS(canvas), gc_zoom_factor_get());
576 577
}

578 579
/* Callback when a directory is selected */
static gint
580
item_event_directory(GooCanvasItem *item, GdkEvent *event, gchar *dir)
581 582
{

583
  if(!rootitem)
584
    return FALSE;
585

586
  switch (event->type)
587 588 589 590 591 592 593
    {
    case GDK_BUTTON_PRESS:
      if(strcmp(g_path_get_basename(dir), "..")==0) {
	/* Up one level. Remove .. and one directory on the right of the path */
	dir[strlen(dir)-3] = '\0';
	dir=g_path_get_dirname(dir);
      }
594
      display_files(rootitem, g_strdup(dir));
595
      gtk_entry_set_text(GTK_ENTRY(widget_entry), "");
596 597 598 599 600 601 602
      break;
    default:
      break;
    }
  return FALSE;

}
603

604
/* Callback when a scroll event happens */
605 606
static void
item_event_scroll(GtkAdjustment *adj, GooCanvas *canvas)
607 608
{
  if(!rootitem)
609
    return;
610

611
  goo_canvas_scroll_to (canvas, 0, adj->value);
612 613
}

614
/* Callback when a file is selected */
615 616 617 618 619
static gboolean
item_event_file_selector (GooCanvasItem  *item,
			  GooCanvasItem  *target,
			  GdkEventButton *event,
			  gchar *data)
620
{
621
  if(!rootitem)
622
    return FALSE;
623

624
  switch (event->type)
625 626
    {
    case GDK_BUTTON_PRESS:
627
      if(!strcmp(data, "/ok/"))	{
628 629

	/* Nothing selected, please cancel instead */
630
	if(strcmp(gtk_entry_get_text(GTK_ENTRY(widget_entry)), "")==0)
631
	  return FALSE;
632

633 634 635 636 637 638 639 640 641 642 643 644 645 646 647
	if(fileSelectorCallBack!=NULL)
	  {
	    gchar *result = NULL;
	    gchar *file_type = NULL;

	    if(mode==MODE_SAVE)
	      {
		GtkTreeModel *model;
		GtkTreeIter iter;

		model = gtk_combo_box_get_model ((GtkComboBox *)gtk_combo_filetypes);
		if (gtk_combo_box_get_active_iter ((GtkComboBox *)gtk_combo_filetypes,
						   &iter))
		  gtk_tree_model_get (model, &iter, 0,
				      &file_type, -1);
648 649
	      }

650 651 652 653
	    result = g_strdup_printf("%s/%s%s",
				     current_rootdir,
				     gtk_entry_get_text(GTK_ENTRY(widget_entry)),
				     (file_type ? file_type :  "") );
654

655
	  /* Callback with the proper params */
656
	  fileSelectorCallBack(result, file_type);
657

658
	  if(file_type)
659 660
	    g_free(file_type);

661
	  /* DO NOT FREE RESULT OR PYTHON SIDE WILL BE IN TROUBLE */
662
	  /* ADDENDUM: DOES NOT HURT ANYMORE, WHY ? */
663
	  if(result)
664
	    g_free(result);
665
	}
666
	gc_selector_file_stop();
667
      }
668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686
      else if(!strcmp(data, "/cancel/"))
	{
	  gc_selector_file_stop();
	}
      else
	{
	  gchar *ext = g_strrstr(data, ".");
	  gchar *file_wo_ext = g_strdup(data);

	  if(ext)
	    {
	      gchar *ext2 = g_strrstr(file_wo_ext, ".");
	      *ext2 = '\0';
	    }

	  gtk_entry_set_text(GTK_ENTRY(widget_entry),
			     g_path_get_basename(file_wo_ext));
	  g_free(file_wo_ext);
	}
687
      break;
688 689 690 691 692 693 694
    default:
      break;
    }
  return FALSE;

}

695 696 697 698
static void entry_enter_callback( GtkWidget *widget,
				  GtkWidget *entry )
{
  gchar *entry_text;
699 700 701 702

  if(!rootitem)
    return;

703
  entry_text = (char *)gtk_entry_get_text(GTK_ENTRY(entry));
704
}
705