1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189 | /* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/*
* Copyright (C) 2008 Jader Henrique da Silva
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more av.
*
* You should have received a copy of the GNU General Public
* License along with this program; if not, write to the
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301 USA.
*
* Author: Jader Henrique da Silva <vovozito@gmail.com>
*/
#include "config.h"
#include <string.h>
#include <glib/gi18n-lib.h>
#include "nst-common.h"
#include "baul-sendto-plugin.h"
enum {
COL_PIXBUF,
COL_LABEL,
NUM_COLS,
};
#define COMBOBOX_OPTION_NEW_DVD 0
#define COMBOBOX_OPTION_EXISTING_DVD 1
static GFile *burn = NULL;
static
gboolean init (NstPlugin *plugin G_GNUC_UNUSED)
{
CtkIconTheme *it;
char *cmd;
g_print ("Init baul burn plugin\n");
bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR);
bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
it = ctk_icon_theme_get_default ();
ctk_icon_theme_append_search_path (it, DATADIR "/brasero/icons");
cmd = g_find_program_in_path ("brasero");
if (cmd == NULL)
return FALSE;
g_free (cmd);
burn = g_file_new_for_uri ("burn:/");
return TRUE;
}
static
CtkWidget* get_contacts_widget (NstPlugin *plugin G_GNUC_UNUSED)
{
CtkWidget *widget;
CtkCellRenderer *renderer;
CtkListStore *store;
CtkTreeModel *model;
GFileEnumerator *fenum;
GFileInfo *file_info = NULL;
int selection = COMBOBOX_OPTION_NEW_DVD;
fenum = g_file_enumerate_children (burn,
G_FILE_ATTRIBUTE_STANDARD_NAME,
G_FILE_QUERY_INFO_NONE,
NULL,
NULL);
if (fenum != NULL) {
file_info = g_file_enumerator_next_file (fenum, NULL, NULL);
g_object_unref (fenum);
}
store = ctk_list_store_new (NUM_COLS, G_TYPE_STRING, G_TYPE_STRING);
ctk_list_store_insert_with_values (store, NULL,
INT_MAX,
COL_PIXBUF, "media-optical-blank",
COL_LABEL, _("New CD/DVD"),
-1);
if (file_info != NULL) {
ctk_list_store_insert_with_values (store, NULL,
INT_MAX,
COL_PIXBUF, "media-optical-data-new",
COL_LABEL, _("Existing CD/DVD"),
-1);
g_object_unref (file_info);
selection = COMBOBOX_OPTION_EXISTING_DVD;
}
model = CTK_TREE_MODEL (store);
widget = ctk_combo_box_new_with_model (model);
renderer = ctk_cell_renderer_pixbuf_new ();
ctk_cell_layout_pack_start (CTK_CELL_LAYOUT (widget),
renderer,
FALSE);
ctk_cell_layout_set_attributes (CTK_CELL_LAYOUT (widget),
renderer,
"icon-name", COL_PIXBUF,
NULL);
renderer = ctk_cell_renderer_text_new ();
ctk_cell_layout_pack_start (CTK_CELL_LAYOUT (widget),
renderer,
TRUE);
ctk_cell_layout_set_attributes (CTK_CELL_LAYOUT (widget),
renderer,
"text", COL_LABEL,
NULL);
ctk_combo_box_set_active (CTK_COMBO_BOX (widget), selection);
return widget;
}
static
gboolean send_files (NstPlugin *plugin G_GNUC_UNUSED,
CtkWidget *burntype_widget,
GList *file_list)
{
GFileEnumerator *fenum;<--- The scope of the variable 'fenum' can be reduced. [+]The scope of the variable 'fenum' can be reduced. Warning: Be careful when fixing this message, especially when there are inner loops. Here is an example where cppcheck will write that the scope for 'i' can be reduced:
void f(int x)
{
int i = 0;
if (x) {
// it's safe to move 'int i = 0;' here
for (int n = 0; n < 10; ++n) {
// it is possible but not safe to move 'int i = 0;' here
do_something(&i);
}
}
}
When you see this message it is always safe to reduce the variable scope 1 level.
GFileInfo *file_info;<--- The scope of the variable 'file_info' can be reduced. [+]The scope of the variable 'file_info' can be reduced. Warning: Be careful when fixing this message, especially when there are inner loops. Here is an example where cppcheck will write that the scope for 'i' can be reduced:
void f(int x)
{
int i = 0;
if (x) {
// it's safe to move 'int i = 0;' here
for (int n = 0; n < 10; ++n) {
// it is possible but not safe to move 'int i = 0;' here
do_something(&i);
}
}
}
When you see this message it is always safe to reduce the variable scope 1 level.
GFile *child;<--- The scope of the variable 'child' can be reduced. [+]The scope of the variable 'child' can be reduced. Warning: Be careful when fixing this message, especially when there are inner loops. Here is an example where cppcheck will write that the scope for 'i' can be reduced:
void f(int x)
{
int i = 0;
if (x) {
// it's safe to move 'int i = 0;' here
for (int n = 0; n < 10; ++n) {
// it is possible but not safe to move 'int i = 0;' here
do_something(&i);
}
}
}
When you see this message it is always safe to reduce the variable scope 1 level.
if (ctk_combo_box_get_active (CTK_COMBO_BOX (burntype_widget)) == COMBOBOX_OPTION_NEW_DVD) {
fenum = g_file_enumerate_children (burn,
G_FILE_ATTRIBUTE_STANDARD_NAME,
G_FILE_QUERY_INFO_NONE,
NULL,
NULL);
if (fenum != NULL) {
while ((file_info = g_file_enumerator_next_file (fenum, NULL, NULL)) != NULL) {
child = g_file_get_child (burn,
g_file_info_get_name(file_info));
g_object_unref (file_info);
g_file_delete (child, NULL, NULL);
g_object_unref (child);
}
g_object_unref (fenum);
}
}
copy_files_to (file_list, burn);
ctk_show_uri_on_window (NULL, "burn:///", CDK_CURRENT_TIME, NULL);
return TRUE;
}
static
gboolean destroy (NstPlugin *plugin G_GNUC_UNUSED) {
g_object_unref (burn);
burn = NULL;
return TRUE;
}
static
NstPluginInfo plugin_info = {
"brasero",
"baul-burn",
N_("CD/DVD Creator"),
NULL,
BAUL_CAPS_SEND_DIRECTORIES,
init,
get_contacts_widget,
NULL,
send_files,
destroy
};
NST_INIT_PLUGIN (plugin_info)
|