Merge branch 'stable' into 'main'
[ladish.git] / gui / save_project_dialog.c
blob96f49fa2df9b7903631d9a1b4f52559bfaee1092
1 /* -*- Mode: C ; c-basic-offset: 2 -*- */
2 /*
3 * LADI Session Handler (ladish)
5 * Copyright (C) 2010, 2011 Nedko Arnaudov <nedko@arnaudov.name>
7 **************************************************************************
8 * This file contains implementation of the save project dialog
9 **************************************************************************
11 * LADI Session Handler is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
16 * LADI Session Handler is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
21 * You should have received a copy of the GNU General Public License
22 * along with LADI Session Handler. If not, see <http://www.gnu.org/licenses/>
23 * or write to the Free Software Foundation, Inc.,
24 * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
27 #include "save_project_dialog.h"
28 #include "gtk_builder.h"
30 static GtkEntry * path = NULL;
32 static void on_path_button_clicked(void)
34 GtkWidget * dialog;
35 GtkResponseType response;
37 dialog = get_gtk_builder_widget("project_save_as_dir_sel_dialog");
39 gtk_widget_show(dialog);
40 response = gtk_dialog_run(GTK_DIALOG(dialog));
41 gtk_widget_hide(dialog);
43 if (response == GTK_RESPONSE_OK)
45 gtk_entry_set_text(
46 path,
47 gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(dialog)));
51 void ladish_init_save_project_dialog(void)
53 GtkWidget * path_button = NULL;
54 path_button = get_gtk_builder_widget("project_save_as_path_button");
55 g_signal_connect( G_OBJECT(path_button), "clicked", G_CALLBACK(on_path_button_clicked), NULL);
58 void ladish_run_save_project_dialog(ladish_room_proxy_handle room)
60 GtkWidget * dialog = NULL;
61 GtkEntry * name = NULL;
62 GtkResponseType response;
64 const char * project_dir;
65 const char * project_name;
67 dialog = get_gtk_builder_widget("project_save_as_dialog");
68 path = GTK_ENTRY(get_gtk_builder_widget("project_save_as_path_entry"));
69 name = GTK_ENTRY(get_gtk_builder_widget("project_save_as_name_entry"));
71 ladish_room_proxy_get_project_properties(room, &project_dir, &project_name, NULL, NULL);
73 gtk_entry_set_text(path, project_dir);
74 gtk_entry_set_text(name, project_name);
76 gtk_widget_show(dialog);
77 response = gtk_dialog_run(GTK_DIALOG(dialog));
78 gtk_widget_hide(dialog);
79 if (response == GTK_RESPONSE_OK)
81 log_info("Saving project to '%s' (%s)", gtk_entry_get_text(path), gtk_entry_get_text(name));
82 if (!ladish_room_proxy_save_project(room, gtk_entry_get_text(path), gtk_entry_get_text(name)))
84 log_error("ladish_room_proxy_save_project() failed.");