1 /*
2 * Copyright (C) 2019-2021 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 Zrythm. If not, see <https://www.gnu.org/licenses/>.
18 */
19
20 /**
21 * \file
22 *
23 * Export dialog.
24 */
25
26 #include <stdio.h>
27
28 #include "audio/engine.h"
29 #include "audio/exporter.h"
30 #include "gui/widgets/dialogs/export_progress_dialog.h"
31 #include "gui/widgets/main_window.h"
32 #include "project.h"
33 #include "utils/io.h"
34 #include "utils/math.h"
35 #include "utils/resources.h"
36 #include "utils/ui.h"
37 #include "zrythm_app.h"
38
39 #include <gtk/gtk.h>
40 #include <glib/gi18n.h>
41
G_DEFINE_TYPE(ExportProgressDialogWidget,export_progress_dialog_widget,GENERIC_PROGRESS_DIALOG_WIDGET_TYPE)42 G_DEFINE_TYPE (
43 ExportProgressDialogWidget,
44 export_progress_dialog_widget,
45 GENERIC_PROGRESS_DIALOG_WIDGET_TYPE)
46
47 static void
48 on_open_directory_clicked (
49 GtkButton * btn,
50 ExportProgressDialogWidget * self)
51 {
52 char * dir = io_get_dir (self->info->file_uri);
53 io_open_directory (dir);
54 g_free (dir);
55 }
56
57 /**
58 * Creates an export dialog widget and displays it.
59 */
60 ExportProgressDialogWidget *
export_progress_dialog_widget_new(ExportSettings * info,bool autoclose,bool show_open_dir_btn,bool cancelable)61 export_progress_dialog_widget_new (
62 ExportSettings * info,
63 bool autoclose,
64 bool show_open_dir_btn,
65 bool cancelable)
66 {
67 g_type_ensure (
68 GENERIC_PROGRESS_DIALOG_WIDGET_TYPE);
69
70 ExportProgressDialogWidget * self =
71 g_object_new (
72 EXPORT_PROGRESS_DIALOG_WIDGET_TYPE, NULL);
73
74 GenericProgressDialogWidget * generic_progress_dialog =
75 Z_GENERIC_PROGRESS_DIALOG_WIDGET (self);
76
77 self->info = info;
78 strcpy (
79 info->progress_info.label_str,
80 _("Exporting..."));
81 strcpy (
82 info->progress_info.label_done_str,
83 _("Exported"));
84
85 generic_progress_dialog_widget_setup (
86 generic_progress_dialog, _("Export Progress"),
87 &info->progress_info, autoclose, cancelable);
88
89 self->show_open_dir_btn = show_open_dir_btn;
90
91 if (show_open_dir_btn)
92 {
93 self->open_directory =
94 GTK_BUTTON (
95 gtk_button_new_with_label (
96 _("Open Directory")));
97 gtk_widget_set_tooltip_text (
98 GTK_WIDGET (self->open_directory),
99 _("Opens the containing directory"));
100 g_signal_connect (
101 G_OBJECT (self->open_directory), "clicked",
102 G_CALLBACK (on_open_directory_clicked), self);
103
104 generic_progress_dialog_add_button (
105 generic_progress_dialog,
106 self->open_directory, true, true);
107 }
108
109 return self;
110 }
111
112 static void
export_progress_dialog_widget_class_init(ExportProgressDialogWidgetClass * _klass)113 export_progress_dialog_widget_class_init (
114 ExportProgressDialogWidgetClass * _klass)
115 {
116 }
117
118 static void
export_progress_dialog_widget_init(ExportProgressDialogWidget * self)119 export_progress_dialog_widget_init (
120 ExportProgressDialogWidget * self)
121 {
122 g_type_ensure (
123 GENERIC_PROGRESS_DIALOG_WIDGET_TYPE);
124 }
125