1 /* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
2 /*
3  * brasero
4  * Copyright (C) Philippe Rouquier 2005-2008 <bonfire-app@wanadoo.fr>
5  *
6  *  Brasero is free software; you can redistribute it and/or modify
7  *  it under the terms of the GNU General Public License as published by
8  *  the Free Software Foundation; either version 2 of the License, or
9  *  (at your option) any later version.
10  *
11  * brasero 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.
14  * See the GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with brasero.  If not, write to:
18  * 	The Free Software Foundation, Inc.,
19  * 	51 Franklin Street, Fifth Floor
20  * 	Boston, MA  02110-1301, USA.
21  */
22 
23 #ifdef HAVE_CONFIG_H
24 #  include <config.h>
25 #endif
26 
27 #include <glib.h>
28 #include <glib/gi18n-lib.h>
29 #include <gio/gio.h>
30 
31 #include <gtk/gtk.h>
32 
33 #include "brasero-misc.h"
34 
35 #include "brasero-filter-option.h"
36 #include "brasero-data-vfs.h"
37 
38 typedef struct _BraseroFilterOptionPrivate BraseroFilterOptionPrivate;
39 struct _BraseroFilterOptionPrivate
40 {
41 	GSettings *settings;
42 };
43 
44 #define BRASERO_FILTER_OPTION_PRIVATE(o)  (G_TYPE_INSTANCE_GET_PRIVATE ((o), BRASERO_TYPE_FILTER_OPTION, BraseroFilterOptionPrivate))
45 
46 G_DEFINE_TYPE (BraseroFilterOption, brasero_filter_option, GTK_TYPE_BOX);
47 
48 static void
brasero_filter_option_init(BraseroFilterOption * object)49 brasero_filter_option_init (BraseroFilterOption *object)
50 {
51 	gchar *string;
52 	GtkWidget *frame;
53 	GtkWidget *button_sym;
54 	GtkWidget *button_broken;
55 	GtkWidget *button_hidden;
56 	BraseroFilterOptionPrivate *priv;
57 
58 	priv = BRASERO_FILTER_OPTION_PRIVATE (object);
59 
60 	priv->settings = g_settings_new (BRASERO_SCHEMA_FILTER);
61 
62 	gtk_orientable_set_orientation (GTK_ORIENTABLE (object), GTK_ORIENTATION_VERTICAL);
63 
64 	/* filter hidden files */
65 	button_hidden = gtk_check_button_new_with_mnemonic (_("Filter _hidden files"));
66 	g_settings_bind (priv->settings, BRASERO_PROPS_FILTER_HIDDEN,
67 	                 button_hidden, "active",
68 	                 G_SETTINGS_BIND_DEFAULT);
69 	gtk_widget_show (button_hidden);
70 
71 	/* replace symlink */
72 	button_sym = gtk_check_button_new_with_mnemonic (_("Re_place symbolic links"));
73 	g_settings_bind (priv->settings, BRASERO_PROPS_FILTER_REPLACE_SYMLINK,
74 	                 button_sym, "active",
75 	                 G_SETTINGS_BIND_DEFAULT);
76 	gtk_widget_show (button_sym);
77 
78 	/* filter broken symlink button */
79 	button_broken = gtk_check_button_new_with_mnemonic (_("Filter _broken symbolic links"));
80 	g_settings_bind (priv->settings, BRASERO_PROPS_FILTER_BROKEN,
81 	                 button_broken, "active",
82 	                 G_SETTINGS_BIND_DEFAULT);
83 	gtk_widget_show (button_broken);
84 
85 	string = g_strdup_printf ("<b>%s</b>", _("Filtering options"));
86 	frame = brasero_utils_pack_properties (string,
87 					       button_sym,
88 					       button_broken,
89 					       button_hidden,
90 					       NULL);
91 	g_free (string);
92 
93 	gtk_box_pack_start (GTK_BOX (object),
94 			    frame,
95 			    FALSE,
96 			    FALSE,
97 			    0);
98 }
99 
100 static void
brasero_filter_option_finalize(GObject * object)101 brasero_filter_option_finalize (GObject *object)
102 {
103 	BraseroFilterOptionPrivate *priv;
104 
105 	priv = BRASERO_FILTER_OPTION_PRIVATE (object);
106 
107 	if (priv->settings) {
108 		g_object_unref (priv->settings);
109 		priv->settings = NULL;
110 	}
111 
112 	G_OBJECT_CLASS (brasero_filter_option_parent_class)->finalize (object);
113 }
114 
115 static void
brasero_filter_option_class_init(BraseroFilterOptionClass * klass)116 brasero_filter_option_class_init (BraseroFilterOptionClass *klass)
117 {
118 	GObjectClass* object_class = G_OBJECT_CLASS (klass);
119 
120 	g_type_class_add_private (klass, sizeof (BraseroFilterOptionPrivate));
121 
122 	object_class->finalize = brasero_filter_option_finalize;
123 }
124 
125 GtkWidget *
brasero_filter_option_new(void)126 brasero_filter_option_new (void)
127 {
128 	return g_object_new (BRASERO_TYPE_FILTER_OPTION, NULL);
129 }
130