Skip to content
Snippets Groups Projects
Commit afbc9591 authored by Sébastien Blin's avatar Sébastien Blin
Browse files

chatview: set default filename when accepting a file


Change-Id: Ie2ef8df3a4f348c646d8cb8465e6852267ec8c08
Reviewed-by: default avatarPhilippe Gorley <philippe.gorley@savoirfairelinux.com>
parent b5da5ab4
No related branches found
No related tags found
No related merge requests found
...@@ -164,7 +164,7 @@ button_add_to_conversations_clicked(ChatView *self) ...@@ -164,7 +164,7 @@ button_add_to_conversations_clicked(ChatView *self)
} }
static gchar* static gchar*
file_to_manipulate(GtkWindow* top_window, bool send) file_to_manipulate(GtkWindow* top_window, bool send, const std::string& displayName = "")
{ {
GtkWidget* dialog; GtkWidget* dialog;
GtkFileChooserAction action = send? GTK_FILE_CHOOSER_ACTION_OPEN : GTK_FILE_CHOOSER_ACTION_SAVE; GtkFileChooserAction action = send? GTK_FILE_CHOOSER_ACTION_OPEN : GTK_FILE_CHOOSER_ACTION_SAVE;
...@@ -179,6 +179,9 @@ file_to_manipulate(GtkWindow* top_window, bool send) ...@@ -179,6 +179,9 @@ file_to_manipulate(GtkWindow* top_window, bool send)
send? _("_Open"): _("_Save"), send? _("_Open"): _("_Save"),
GTK_RESPONSE_ACCEPT, GTK_RESPONSE_ACCEPT,
nullptr); nullptr);
// Set default save name
if (!send)
gtk_file_chooser_set_current_name (GTK_FILE_CHOOSER(dialog), displayName.c_str());
res = gtk_dialog_run (GTK_DIALOG(dialog)); res = gtk_dialog_run (GTK_DIALOG(dialog));
...@@ -216,7 +219,11 @@ webkit_chat_container_script_dialog(G_GNUC_UNUSED GtkWidget* webview, gchar *int ...@@ -216,7 +219,11 @@ webkit_chat_container_script_dialog(G_GNUC_UNUSED GtkWidget* webview, gchar *int
if (auto model = priv->accountContainer_->info.conversationModel.get()) { if (auto model = priv->accountContainer_->info.conversationModel.get()) {
try { try {
auto interactionId = std::stoull(order.substr(std::string("ACCEPT_FILE:").size())); auto interactionId = std::stoull(order.substr(std::string("ACCEPT_FILE:").size()));
if (auto filename = file_to_manipulate(GTK_WINDOW(gtk_widget_get_toplevel(GTK_WIDGET(self))), false))
lrc::api::datatransfer::Info info = {};
priv->accountContainer_->info.conversationModel->getTransferInfo(interactionId, info);
if (auto filename = file_to_manipulate(GTK_WINDOW(gtk_widget_get_toplevel(GTK_WIDGET(self))), false, info.displayName))
model->acceptTransfer(priv->conversation_->uid, interactionId, filename); model->acceptTransfer(priv->conversation_->uid, interactionId, filename);
else else
model->cancelTransfer(priv->conversation_->uid, interactionId); model->cancelTransfer(priv->conversation_->uid, interactionId);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment