1 /*
2 * Copyright (C) 2018-2019 Alexandros Theodotou <alex at zrythm dot org>
3 *
4 * This file is part of Zrythm
5 *
6 * Zrythm is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU Affero General Public License as published by
8 * the Free Software Foundation, either version 3 of the License, or
9 * (at your option) any later version.
10 *
11 * Zrythm is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU Affero General Public License for more details.
15 *
16 * You should have received a copy of the GNU Affero General Public License
17 * along with this program. If not, see <https://www.gnu.org/licenses/>.
18 */
19
20 #include "gui/widgets/main_window.h"
21 #include "project.h"
22 #include "utils/dialogs.h"
23 #include "zrythm_app.h"
24
25 #include <gtk/gtk.h>
26 #include <glib/gi18n.h>
27
28 /**
29 * Creates and returns an open project dialog.
30 */
dialogs_get_open_project_dialog(GtkWindow * parent)31 GtkDialog * dialogs_get_open_project_dialog (
32 GtkWindow * parent)
33 {
34 GtkFileChooserAction action =
35 GTK_FILE_CHOOSER_ACTION_OPEN;
36
37 GtkWidget * dialog =
38 gtk_file_chooser_dialog_new (
39 _("Open Project"),
40 GTK_WINDOW (MAIN_WINDOW),
41 action,
42 _("_Cancel"),
43 GTK_RESPONSE_CANCEL,
44 _("_Open"),
45 GTK_RESPONSE_ACCEPT,
46 NULL);
47
48 gtk_file_chooser_set_filename (
49 GTK_FILE_CHOOSER (dialog),
50 PROJECT->dir);
51
52 return GTK_DIALOG (dialog);
53 }
54
55 /**
56 * Creates and returns the overwrite plugin dialog.
57 */
dialogs_get_overwrite_plugin_dialog(GtkWindow * parent)58 GtkDialog * dialogs_get_overwrite_plugin_dialog (
59 GtkWindow * parent)
60 {
61 GtkDialogFlags flags =
62 GTK_DIALOG_MODAL |
63 GTK_DIALOG_DESTROY_WITH_PARENT;
64 GtkDialog * dialog =
65 GTK_DIALOG (
66 gtk_dialog_new_with_buttons (
67 _("Overwrite Plugin"),
68 GTK_WINDOW (MAIN_WINDOW),
69 flags,
70 _("_OK"),
71 GTK_RESPONSE_ACCEPT,
72 _("_Cancel"),
73 GTK_RESPONSE_REJECT,
74 NULL));
75 GtkWidget * box =
76 gtk_dialog_get_content_area (dialog);
77 GtkWidget * label =
78 g_object_new (
79 GTK_TYPE_LABEL,
80 "label",
81 _("A plugin already exists at the selected "
82 "slot. Overwrite it?"),
83 "margin-start", 8,
84 "margin-end", 8,
85 "margin-top", 4,
86 "margin-bottom", 8,
87 NULL);
88 gtk_widget_set_visible (label, 1);
89 gtk_container_add (
90 GTK_CONTAINER (box), label);
91 return dialog;
92 }
93
dialogs_get_error_instantiating_plugin_dialog(GtkWindow * parent)94 GtkDialog * dialogs_get_error_instantiating_plugin_dialog (
95 GtkWindow * parent)
96 {
97 GtkDialogFlags flags =
98 GTK_DIALOG_DESTROY_WITH_PARENT;
99 GtkWidget * dialog =
100 gtk_message_dialog_new (
101 GTK_WINDOW (MAIN_WINDOW),
102 flags,
103 GTK_MESSAGE_ERROR,
104 GTK_BUTTONS_CLOSE,
105 _("Error instantiating plugin. "
106 "Please see log for details."));
107 return GTK_DIALOG (dialog);
108 }
109