1 /*
2 * Brasero is free software; you can redistribute it and/or modify
3 * it under the terms of the GNU General Public License as published by
4 * the Free Software Foundation; either version 2 of the License, or
5 * (at your option) any later version.
6 *
7 * Brasero is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 * GNU Library General Public License for more details.
11 *
12 * You should have received a copy of the GNU General Public License
13 * along with this program; if not, write to:
14 * The Free Software Foundation, Inc.,
15 * 51 Franklin Street, Fifth Floor
16 * Boston, MA 02110-1301, USA.
17 */
18 /***************************************************************************
19 * utils.c
20 *
21 * Wed May 18 16:58:16 2005
22 * Copyright 2005 Philippe Rouquier
23 * <brasero-app@wanadoo.fr>
24 ****************************************************************************/
25
26
27 #ifdef HAVE_CONFIG_H
28 # include <config.h>
29 #endif
30
31 #include <stdarg.h>
32 #include <string.h>
33 #include <sys/types.h>
34 #include <unistd.h>
35
36 #include <glib.h>
37 #include <glib/gi18n-lib.h>
38
39 #include <gtk/gtk.h>
40
41 #include "brasero-utils.h"
42 #include "brasero-app.h"
43
44 #define BRASERO_ERROR brasero_error_quark()
45
46 GQuark
brasero_error_quark(void)47 brasero_error_quark (void)
48 {
49 static GQuark quark = 0;
50
51 if (!quark)
52 quark = g_quark_from_static_string ("BraSero_error");
53
54 return quark;
55 }
56
57 void
brasero_utils_launch_app(GtkWidget * widget,GSList * list)58 brasero_utils_launch_app (GtkWidget *widget,
59 GSList *list)
60 {
61 GSList *item;
62
63 for (item = list; item; item = item->next) {
64 GError *error;
65 gchar *uri;
66
67 error = NULL;
68 uri = item->data;
69
70 if (!g_app_info_launch_default_for_uri (uri, NULL, &error)) {
71 gchar *string;
72
73 string = g_strdup_printf ("\"%s\" could not be opened", uri);
74 brasero_app_alert (brasero_app_get_default (),
75 string,
76 error->message,
77 GTK_MESSAGE_ERROR);
78 g_free (string);
79 g_error_free (error);
80 continue;
81 }
82 }
83 }
84
85 gboolean
brasero_clipboard_selection_may_have_uri(GdkAtom * atoms,gint n_atoms)86 brasero_clipboard_selection_may_have_uri (GdkAtom *atoms,
87 gint n_atoms)
88 {
89 GdkAtom *iter;
90
91 /* Check for a text target */
92 if (gtk_targets_include_text (atoms, n_atoms))
93 return TRUE;
94
95 /* Check for special targets like nautilus' and its file copied */
96 iter = atoms;
97 while (n_atoms > 0) {
98 gchar *target;
99
100 target = gdk_atom_name (*iter);
101 if (!strcmp (target, "x-special/gnome-copied-files")) {
102 g_free (target);
103 return TRUE;
104 }
105 g_free (target);
106
107 iter++;
108 n_atoms--;
109 }
110
111 return FALSE;
112 }
113