32
32
#include "bluetooth-filter-widget.h"
33
33
#include "bluetooth-client.h"
34
34
#include "gnome-bluetooth-enum-types.h"
35
#include "seahorse-bind.h"
37
36
#define BLUETOOTH_FILTER_WIDGET_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE((obj), \
38
37
BLUETOOTH_TYPE_FILTER_WIDGET, BluetoothFilterWidgetPrivate))
52
51
int device_category_filter;
53
52
char *device_service_filter;
55
/* See bluetooth_filter_widget_bind_chooser () */
58
54
guint show_device_type : 1;
59
55
guint show_device_category : 1;
172
168
bluetooth_filter_widget_set_title (BluetoothFilterWidget *self, gchar *title)
174
171
BluetoothFilterWidgetPrivate *priv = BLUETOOTH_FILTER_WIDGET_GET_PRIVATE(self);
176
gtk_label_set_text (GTK_LABEL (priv->title), title);
173
markup = g_strdup_printf ("<b>%s</b>", title);
174
gtk_label_set_text (GTK_LABEL (priv->title), markup);
177
177
gtk_label_set_use_markup (GTK_LABEL (priv->title), TRUE);
181
181
bluetooth_filter_widget_bind_chooser_single (BluetoothFilterWidget *self,
182
182
BluetoothChooser *chooser,
183
const char *property,
183
const char *property)
186
BluetoothFilterWidgetPrivate *priv = BLUETOOTH_FILTER_WIDGET_GET_PRIVATE(self);
188
185
/* NOTE: We are binding the chooser as the source so that all of it's
189
186
* properties are pushed to the filter.
190
* Remember the bindings so we can unbind them later on */
191
priv->bindings[*i] = seahorse_bind_property (property, (gpointer) chooser,
192
property, (gpointer) self);
193
priv->bindings[(*i)++] = seahorse_bind_property (property, (gpointer) self,
194
property, (gpointer) chooser);
187
* The bindings will be automatically removed when one of the
189
g_object_bind_property ((gpointer) chooser, property,
190
(gpointer) self, property,
191
G_BINDING_BIDIRECTIONAL);
210
206
bluetooth_filter_widget_bind_filter (BluetoothFilterWidget *self, BluetoothChooser *chooser)
215
bluetooth_filter_widget_bind_chooser_single (self, chooser, "device-type-filter", &i);
216
bluetooth_filter_widget_bind_chooser_single (self, chooser, "device-category-filter", &i);
217
bluetooth_filter_widget_bind_chooser_single (self, chooser, "show-device-type", &i);
218
bluetooth_filter_widget_bind_chooser_single (self, chooser, "show-device-category", &i);
208
bluetooth_filter_widget_bind_chooser_single (self, chooser, "device-type-filter");
209
bluetooth_filter_widget_bind_chooser_single (self, chooser, "device-category-filter");
210
bluetooth_filter_widget_bind_chooser_single (self, chooser, "show-device-type");
211
bluetooth_filter_widget_bind_chooser_single (self, chooser, "show-device-category");
235
228
gtk_box_set_spacing (GTK_BOX (self), 6);
237
230
priv->title = gtk_label_new ("");
238
bluetooth_filter_widget_set_title (self, _("<b>Show Only Bluetooth Devices With...</b>"));
231
bluetooth_filter_widget_set_title (self, _("Show Only Bluetooth Devices With..."));
239
232
gtk_widget_show (priv->title);
240
233
gtk_box_pack_start (GTK_BOX (self), priv->title, TRUE, TRUE, 0);
241
234
gtk_misc_set_alignment (GTK_MISC (priv->title), 0, 0.5);
260
253
gtk_misc_set_alignment (GTK_MISC (label), 0, 0.5);
261
254
priv->device_category_label = label;
263
priv->device_category = gtk_combo_box_new_text ();
256
priv->device_category = gtk_combo_box_text_new ();
264
257
gtk_widget_set_no_show_all (priv->device_category, TRUE);
265
258
gtk_widget_show (priv->device_category);
266
259
gtk_table_attach (GTK_TABLE (table), priv->device_category, 1, 2, 1, 2,
268
261
(GtkAttachOptions) (GTK_EXPAND | GTK_FILL), 0, 0);
269
262
gtk_widget_set_tooltip_text (priv->device_category, _("Select the device category to filter"));
270
263
for (i = 0; i < BLUETOOTH_CATEGORY_NUM_CATEGORIES; i++) {
271
gtk_combo_box_append_text (GTK_COMBO_BOX (priv->device_category),
272
_(bluetooth_device_category_to_string (i)));
264
gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (priv->device_category),
265
_(bluetooth_device_category_to_string (i)));
274
267
g_signal_connect (G_OBJECT (priv->device_category), "changed",
275
268
G_CALLBACK (filter_category_changed_cb), self);
353
346
bluetooth_filter_widget_dispose (GObject *object)
355
348
BluetoothFilterWidgetPrivate *priv = BLUETOOTH_FILTER_WIDGET_GET_PRIVATE(object);
358
350
if (priv->chooser) {
359
351
g_object_unref (priv->chooser);
360
352
priv->chooser = NULL;
362
for (i = 0; i < 8; i++) {
363
if (priv->bindings[i] != NULL) {
364
seahorse_bind_disconnect (priv->bindings[i]);
365
priv->bindings[i] = NULL;
369
355
G_OBJECT_CLASS(bluetooth_filter_widget_parent_class)->dispose(object);
482
468
* bluetooth_filter_widget_new:
483
* @chooser: The #BluetoothChooser to filter
485
* Return value: A #BluetoothFilterWidget widget
487
470
* Creates a new #BluetoothFilterWidget which can be bound to a #BluetoothChooser to
488
471
* control filtering of that #BluetoothChooser.
489
472
* Usually used in conjunction with a #BluetoothChooser which has the "has-internal-filter"
490
473
* property set to FALSE.
475
* Return value: A #BluetoothFilterWidget widget
492
477
* Note: Must call bluetooth_filter_widget_bind_filter () to bind the #BluetoothFilterWidget
493
478
* to a #BluetoothChooser.