denemo-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Denemo-devel] Fix for default directory


From: Jeremiah Benham
Subject: Re: [Denemo-devel] Fix for default directory
Date: Thu, 20 Sep 2007 14:55:58 -0500
User-agent: Mutt/1.5.6+20040907i

On Sun, Sep 16, 2007 at 12:57:37PM +0100, Richard Shann wrote:
> Here is a patch to fix the behaviour on opening files. Currently it
> forgets where you opened/saved last.
> This is just a quick fix - it looks like the code introduced for
> templates broke this, I haven't looked at that stuff. I guess there
> should be a mechanism (prefs) to remember the directory for the next
> session...
> Richard
> 

I uploaded this patch and several other of your patches. Thanks for you
contribution. 
In funcion static void  set_current_folder(
I commented out the call to set_current_folder because it creates an
endless loop.

Thanks,
Jeremiah



> --- ../../denemocleaned/src/file.c    2007-09-13 14:24:30.000000000 +0100
> +++ file.c    2007-09-16 12:50:49.000000000 +0100
> @@ -97,6 +97,7 @@
>    GtkWidget *comboentry;
>  };
>  
> +/* directory last used for saving */
>  static gchar *file_selection_path = NULL;
>  
>  /* Prototypes for non-exported functions */
> @@ -218,6 +219,16 @@
>  
>  }
>  
> +
> +static void      update_file_selection_path (gchar *file) {
> +  if(file_selection_path)
> +    g_free(file_selection_path);
> +  file_selection_path = g_path_get_dirname(file);
> +}
> +
> +
> +
> +
>  /**
>   * The function that actually determines the file type and calls the
>   *  function that opens the file.  (So many layers of indirection...)  
> @@ -243,6 +254,7 @@
>      result = froginput (filename, gui->si);
>    if (result != -1)
>      {
> +      update_file_selection_path (filename);      
>        set_si_filename (gui, filename);
>        updatescoreinfo (gui->si);
>        set_rightmeasurenum (gui->si);
> @@ -322,7 +334,7 @@
>  
>  /**
>   * File save callback called by fileselsave callback
> - *
> + * param file_name is full path to file with extension
>   */
>  static void
>  filesel_save (DenemoGUI * gui, const gchar * file_name, gint format_id)
> @@ -341,7 +353,7 @@
>  #ifdef DEBUG
>    g_print("Saving to file %s", file);
>  #endif
> -
> +  update_file_selection_path(file);
>    basename = g_path_get_basename (file);
>    /* we don't want to save scores under ".denemo",
>       ".jtf" and so on. do we? */
> @@ -421,6 +433,8 @@
>   * Open template file wrapper function 
>   * Sets the file_selection_path to the templates directory and 
>   * calls file_open to create the file selection dialog
> + * this needs fixing - open template should open in templates directory but 
> not alter
> + * default save directory FIXME
>   */
>  void
>  file_open_template_wrapper (GtkAction * action, DenemoGUI * gui)
> @@ -460,7 +474,22 @@
>      }
>  }
>  
> -
> +static void  set_current_folder(GtkWidget *file_selection, DenemoGUI *gui){
> +  if (file_selection_path != NULL)
> +    {
> +      gtk_file_chooser_set_current_folder (GTK_FILE_CHOOSER (file_selection),
> +                                        file_selection_path);
> +    } else {
> +      /* open preset directory*/
> +        GDir *denemo_path = g_dir_open(gui->prefs->denemopath->str, 0, NULL);
> +      if(denemo_path != NULL)
> +     {
> +       g_dir_close(denemo_path);
> +       gtk_file_chooser_set_current_folder 
> +         (GTK_FILE_CHOOSER (file_selection), gui->prefs->denemopath->str);
> +     }
> +    }
> +}
>  /**
>   * File open dialog - opened where appropriate 
>   *
> @@ -470,7 +499,7 @@
>  {
>    GtkWidget *file_selection;
>    GtkFileFilter *filter;
> -  GDir *denemo_path;
> +
>    int i;
>  
>    file_selection = gtk_file_chooser_dialog_new (_("Open"),
> @@ -481,22 +510,8 @@
>                                               GTK_STOCK_OPEN,
>                                               GTK_RESPONSE_ACCEPT, NULL);
>    /* Open the last visited directory, if any. */
> -  if (file_selection_path != NULL)
> -    {
> -      gtk_file_chooser_set_current_folder (GTK_FILE_CHOOSER (file_selection),
> -                                        file_selection_path);
> -    }
> -  /* open preset directory*/
> -  /*gtk_file_chooser_set_current_folder 
> -    (GTK_FILE_CHOOSER (file_selection), gui->prefs->denemopath->str);*/
> -  
> -  denemo_path = g_dir_open(gui->prefs->denemopath->str, 0, NULL);
> -  if(denemo_path != NULL)
> -    {
> -      g_dir_close(denemo_path);
> -      gtk_file_chooser_set_current_folder 
> -     (GTK_FILE_CHOOSER (file_selection), gui->prefs->denemopath->str);
> -    }
> +  set_current_folder(file_selection, gui);
> +
>  
>    for (i = 0; i < (gint) G_N_ELEMENTS (supported_import_file_formats); i++)
>      {
> @@ -627,7 +642,7 @@
>    GtkListStore *list_store;
>    GtkTreeIter iter;
>    GtkCellRenderer *renderer;
> -  GDir *denemo_path;
> +
>  
>    file_selection = gtk_file_chooser_dialog_new (_("Save As"),
>                                               GTK_WINDOW (gui->window),
> @@ -639,15 +654,8 @@
>  
>  
>    /*set default folder for saving */
> -   /*gtk_file_chooser_set_current_folder (GTK_FILE_CHOOSER (file_selection), 
> gui->prefs->denemopath->str);*/
> -  denemo_path = g_dir_open(gui->prefs->denemopath->str, 0, NULL);
> -  if(denemo_path != NULL)
> -    {
> -      g_dir_close(denemo_path);
> -      gtk_file_chooser_set_current_folder 
> -     (GTK_FILE_CHOOSER (file_selection), gui->prefs->denemopath->str);
> -    }
> - 
> +  set_current_folder(file_selection, gui);
> +
>    /* assign title */ 
>    if (gui->si->headerinfo->title != NULL)
>      { 

> _______________________________________________
> Denemo-devel mailing list
> address@hidden
> http://lists.gnu.org/mailman/listinfo/denemo-devel





reply via email to

[Prev in Thread] Current Thread [Next in Thread]