actions: Add timestamp to default performance log filename

ISO 8601 basic format was used for standardization. Windows
does not support colons in filenames, so the more human-readable
extended format could not be used.
This commit is contained in:
Alx Sa 2025-01-31 03:46:41 +00:00
parent 70a065eada
commit 553aacbb19

View file

@ -111,6 +111,9 @@ dashboard_log_record_cmd_callback (GimpAction *action,
GtkWidget *label;
GtkWidget *spinbutton;
GtkWidget *toggle;
GDateTime *datetime;
gchar *timestamp;
gchar *default_filename;
dialog = gtk_file_chooser_dialog_new (
"Record Performance Log", NULL, GTK_FILE_CHOOSER_ACTION_SAVE,
@ -168,8 +171,19 @@ dashboard_log_record_cmd_callback (GimpAction *action,
GTK_FILE_CHOOSER (dialog), info->folder, NULL);
}
datetime = g_date_time_new_now_local ();
/* Since Windows doesn't allow colons in filenames,
* we use ISO 8601 basic format for the timestamp */
timestamp = g_date_time_format (datetime, "%Y%m%dT%H%M%SZ");
default_filename = g_strdup_printf ("gimp-performance-%s.log",
timestamp);
g_date_time_unref (datetime);
g_free (timestamp);
gtk_file_chooser_set_current_name (GTK_FILE_CHOOSER (dialog),
"gimp-performance.log");
default_filename);
g_free (default_filename);
hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 8);
gtk_file_chooser_set_extra_widget (GTK_FILE_CHOOSER (dialog), hbox);