diff options
| author | Jose Antonio Ortega Ruiz <jao@gnu.org> | 2006-08-06 01:32:47 +0000 | 
|---|---|---|
| committer | Jose Antonio Ortega Ruiz <jao@gnu.org> | 2006-08-06 01:32:47 +0000 | 
| commit | 38572a19e884716f6f8e15c7c523ab98270356a5 (patch) | |
| tree | cfd77d1e3af053f7b4c86de420076cee0379beff | |
| parent | 63c94b1e74f3272dbf0b2bc1dae8913d564c72f5 (diff) | |
| download | mdk-38572a19e884716f6f8e15c7c523ab98270356a5.tar.gz mdk-38572a19e884716f6f8e15c7c523ab98270356a5.tar.bz2 | |
Load file dialog remembers last directory
git-archimport-id: mdk@sv.gnu.org/mdk--devel--1--patch-18
| -rw-r--r-- | mixgtk/mixgtk_gen_handlers.c | 55 | ||||
| -rw-r--r-- | mixgtk/mixgtk_gen_handlers.h | 6 | ||||
| -rw-r--r-- | mixgtk/mixgtk_widgets.c | 4 | 
3 files changed, 37 insertions, 28 deletions
| diff --git a/mixgtk/mixgtk_gen_handlers.c b/mixgtk/mixgtk_gen_handlers.c index c67eec8..7ebadfb 100644 --- a/mixgtk/mixgtk_gen_handlers.c +++ b/mixgtk/mixgtk_gen_handlers.c @@ -25,12 +25,16 @@  #include "mixgtk_config.h"  /* grab a file with an externally provided callback */ -void -mixgtk_get_file (file_callback_t callback, -		 const gchar *title, -                 const gchar *pattern, -                 const gchar *def_file) +typedef void (*file_callback_t)(const gchar *file); + +static void +get_file_ (file_callback_t callback, +           const gchar *title, +           const gchar *pattern, +           const gchar *def_file)  { +  static gchar *last_folder = NULL; +    if (callback != NULL)      {        GtkWidget *dialog; @@ -51,15 +55,25 @@ mixgtk_get_file (file_callback_t callback,          }        if (def_file != NULL) -        gtk_file_chooser_set_filename (GTK_FILE_CHOOSER (dialog), def_file); +        { +          gtk_file_chooser_set_filename (GTK_FILE_CHOOSER (dialog), def_file); +        } +      else if (last_folder != NULL) +        { +          gtk_file_chooser_set_current_folder (GTK_FILE_CHOOSER (dialog), +                                               last_folder); +        }        if (gtk_dialog_run (GTK_DIALOG (dialog)) == GTK_RESPONSE_ACCEPT)          { -          char *filename; - -          filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (dialog)); +          gchar *filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (dialog));            callback (filename); -          g_free (filename); +          if (filename) +            { +              if (last_folder) g_free (last_folder); +              last_folder = g_path_get_dirname (filename); +              g_free (filename); +            }          }        gtk_widget_destroy (dialog); @@ -85,42 +99,45 @@ exec_cmd_ (mix_vm_command_t cmd, const gchar *arg)  static void  open_cb_ (const gchar *file)  { -  if (file) -      exec_cmd_ (MIX_CMD_LOAD, file); +  if (file) exec_cmd_ (MIX_CMD_LOAD, file);  }  void  on_file_open_activate (GtkWidget *w, gpointer data)  { -  mixgtk_get_file (open_cb_, _("Load MIX program..."), "*.mix", NULL); +  get_file_ (open_cb_, _("Load MIX program..."), "*.mix", NULL);  }  /* edit mixal source */  static void  edit_cb_ (const gchar *file)  { -  exec_cmd_ (MIX_CMD_EDIT, file); +  if (file) exec_cmd_ (MIX_CMD_EDIT, file);  }  void  on_file_edit_activate (GtkWidget *w, gpointer data)  { -  mixgtk_get_file (edit_cb_, _("Edit MIXAL source file..."), "*.mixal", -		   mixgtk_cmd_dispatcher_get_src_path ()); +  get_file_ (edit_cb_, +             _("Edit MIXAL source file..."), +             "*.mixal", +             mixgtk_cmd_dispatcher_get_src_path ());  }  /* compile mixal source */  static void  compile_cb_ (const gchar *file)  { -  exec_cmd_ (MIX_CMD_COMPILE, file); +  if (file) exec_cmd_ (MIX_CMD_COMPILE, file);  }  void  on_file_compile_activate (GtkWidget *w, gpointer data)  { -  mixgtk_get_file (compile_cb_, _("Compile MIXAL source file..."), "*.mixal", -		   mixgtk_cmd_dispatcher_get_src_path ()); +  get_file_ (compile_cb_, +             _("Compile MIXAL source file..."), +             "*.mixal", +             mixgtk_cmd_dispatcher_get_src_path ());  }  void diff --git a/mixgtk/mixgtk_gen_handlers.h b/mixgtk/mixgtk_gen_handlers.h index 20482e1..7e49b34 100644 --- a/mixgtk/mixgtk_gen_handlers.h +++ b/mixgtk/mixgtk_gen_handlers.h @@ -49,12 +49,6 @@ on_save_on_exit_toggle (GtkWidget *w, gpointer data);  extern void  on_save_activate (GtkWidget *w, gpointer data); -typedef void (*file_callback_t)(const gchar *file); - -extern void -mixgtk_get_file (file_callback_t callback, const gchar *title, -		 const gchar *pattern, const gchar *def_file); -  #endif /* MIXGTK_GEN_HANDLERS_H */ diff --git a/mixgtk/mixgtk_widgets.c b/mixgtk/mixgtk_widgets.c index 724b578..ee6dc69 100644 --- a/mixgtk/mixgtk_widgets.c +++ b/mixgtk/mixgtk_widgets.c @@ -1,9 +1,7 @@  /* -*-c-*- -------------- mixgtk_widgets.c :   * Implementation of the functions declared in mixgtk_widgets.h   * ------------------------------------------------------------------ - *  Last change: Time-stamp: "2001-04-29 14:32:17 jao" - * ------------------------------------------------------------------ - * Copyright (C) 2001, 2004 Free Software Foundation, Inc. + * Copyright (C) 2001, 2004, 2006 Free Software Foundation, Inc.   *   * 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 | 
