In my project, I have created a SAVE AS file submenu.
I have two question:
1) This "save as" does not have any key board shortcut(Ctrl+S as standard) like open or new file submenu, which are also created in the same way, using accel group. Why this is so?
2) Though the file copying is working fine, I would love to receive some comment about if this is a dependable(in sense of failsafe and fast) process of copying file.
The code is as follows:
accel_group = gtk_accel_group_new();
save = gtk_image_menu_item_new_from_stock(GTK_STOCK_SAVE_AS, accel_group);
g_signal_connect(G_OBJECT(save), "activate", G_CALLBACK(rename_file), NULL);
//the called function
static void rename_file(GtkWidget *widget, gpointer data)
gchar *fname=NULL, *str;
dialog=gtk_file_chooser_dialog_new("Save File", GTK_WINDOW(window),
GTK_STOCK_SAVE, GTK_RESPONSE_ACCEPT, NULL);
gtk_file_chooser_set_do_overwrite_confirmation (GTK_FILE_CHOOSER (dialog), TRUE);
if (gtk_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_ACCEPT)
g_file_get_contents(filename, &cts, &length, &Err);
g_file_set_contents(filename, cts, -1, &Err);
caution("Failed to save in %s",filename);