~timchen119/ubuntu/trusty/gnome-bluetooth/lp1035431

« back to all changes in this revision

Viewing changes to lib/bluetooth-filter-widget.c

  • Committer: Bazaar Package Importer
  • Author(s): Emilio Pozuelo Monfort
  • Date: 2011-02-27 15:45:22 UTC
  • mfrom: (1.3.2 upstream)
  • mto: (2.2.3 experimental) (1.5.1)
  • mto: This revision was merged to the branch mainline in revision 53.
  • Revision ID: james.westby@ubuntu.com-20110227154522-dnnoqasv5v3mv42a
Tags: upstream-2.91.5
ImportĀ upstreamĀ versionĀ 2.91.5

Show diffs side-by-side

added added

removed removed

Lines of Context:
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"
36
35
 
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;
54
53
 
55
 
        /* See bluetooth_filter_widget_bind_chooser () */
56
 
        gpointer bindings[8];
57
 
 
58
54
        guint show_device_type : 1;
59
55
        guint show_device_category : 1;
60
56
};
171
167
void
172
168
bluetooth_filter_widget_set_title (BluetoothFilterWidget *self, gchar *title)
173
169
{
 
170
        gchar *markup;
174
171
        BluetoothFilterWidgetPrivate *priv = BLUETOOTH_FILTER_WIDGET_GET_PRIVATE(self);
175
172
 
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);
 
175
        g_free (markup);
 
176
 
177
177
        gtk_label_set_use_markup (GTK_LABEL (priv->title), TRUE);
178
178
}
179
179
 
180
180
static void
181
181
bluetooth_filter_widget_bind_chooser_single (BluetoothFilterWidget *self,
182
182
                                             BluetoothChooser *chooser,
183
 
                                             const char *property,
184
 
                                             guint *i)
 
183
                                             const char *property)
185
184
{
186
 
        BluetoothFilterWidgetPrivate *priv = BLUETOOTH_FILTER_WIDGET_GET_PRIVATE(self);
187
 
 
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);
195
 
        (*i)++;
 
187
         * The bindings will be automatically removed when one of the
 
188
         * objects go away */
 
189
        g_object_bind_property ((gpointer) chooser, property,
 
190
                                (gpointer) self, property,
 
191
                                G_BINDING_BIDIRECTIONAL);
196
192
}
197
193
 
198
194
/**
209
205
void
210
206
bluetooth_filter_widget_bind_filter (BluetoothFilterWidget *self, BluetoothChooser *chooser)
211
207
{
212
 
        guint i;
213
 
 
214
 
        i = 0;
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");
219
212
}
220
213
 
221
214
static void
235
228
        gtk_box_set_spacing (GTK_BOX (self), 6);
236
229
 
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;
262
255
 
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)));
273
266
        }
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)
354
347
{
355
348
        BluetoothFilterWidgetPrivate *priv = BLUETOOTH_FILTER_WIDGET_GET_PRIVATE(object);
356
 
        guint i;
357
349
 
358
350
        if (priv->chooser) {
359
351
                g_object_unref (priv->chooser);
360
352
                priv->chooser = NULL;
361
353
        }
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;
366
 
                }
367
 
        }
368
354
 
369
355
        G_OBJECT_CLASS(bluetooth_filter_widget_parent_class)->dispose(object);
370
356
}
480
466
 
481
467
/**
482
468
 * bluetooth_filter_widget_new:
483
 
 * @chooser: The #BluetoothChooser to filter
484
469
 *
485
 
 * Return value: A #BluetoothFilterWidget widget
486
 
 * 
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.
 
474
 *
 
475
 * Return value: A #BluetoothFilterWidget widget
491
476
 * 
492
477
 * Note: Must call bluetooth_filter_widget_bind_filter () to bind the #BluetoothFilterWidget
493
478
 * to a #BluetoothChooser.