1 /* -*- Mode: C ; c-basic-offset: 2 -*- */
3 * LADI Session Handler (ladish)
5 * Copyright (C) 2010 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)
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
)
47 gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(dialog
)));
51 void ladish_run_save_project_dialog(ladish_room_proxy_handle room
)
53 GtkWidget
* dialog
= NULL
;
54 GtkWidget
* path_button
= NULL
;
55 GtkEntry
* name
= NULL
;
56 GtkResponseType response
;
61 dialog
= get_gtk_builder_widget("project_save_as_dialog");
62 path_button
= get_gtk_builder_widget("project_save_as_path_button");
63 path
= GTK_ENTRY(get_gtk_builder_widget("project_save_as_path_entry"));
64 name
= GTK_ENTRY(get_gtk_builder_widget("project_save_as_name_entry"));
66 g_signal_connect( G_OBJECT(path_button
), "clicked", G_CALLBACK(on_path_button_clicked
), NULL
);
68 if (!ladish_room_proxy_get_project_properties(room
, &project_dir
, &project_name
))
70 error_message_box("Get project properties failed, please inspect logs.");
74 gtk_entry_set_text(path
, project_dir
);
75 gtk_entry_set_text(name
, project_name
);
80 gtk_widget_show(dialog
);
81 response
= gtk_dialog_run(GTK_DIALOG(dialog
));
82 gtk_widget_hide(dialog
);
83 if (response
== GTK_RESPONSE_OK
)
85 log_info("Saving project to '%s' (%s)", gtk_entry_get_text(path
), gtk_entry_get_text(name
));
86 if (!ladish_room_proxy_save_project(room
, gtk_entry_get_text(path
), gtk_entry_get_text(name
)))
88 log_error("ladish_room_proxy_save_project() failed.");