~ubuntu-branches/ubuntu/maverick/evolution-data-server/maverick-proposed

« back to all changes in this revision

Viewing changes to libedataserverui/e-category-completion.c

  • Committer: Bazaar Package Importer
  • Author(s): Didier Roche
  • Date: 2010-05-17 17:02:06 UTC
  • mfrom: (1.1.79 upstream) (1.6.12 experimental)
  • Revision ID: james.westby@ubuntu.com-20100517170206-4ufr52vwrhh26yh0
Tags: 2.30.1-1ubuntu1
* Merge from debian experimental. Remaining change:
  (LP: #42199, #229669, #173703, #360344, #508494)
  + debian/control:
    - add Vcs-Bzr tag
    - don't use libgnome
    - Use Breaks instead of Conflicts against evolution 2.25 and earlier.
  + debian/evolution-data-server.install,
    debian/patches/45_libcamel_providers_version.patch:
    - use the upstream versioning, not a Debian-specific one 
  + debian/libedata-book1.2-dev.install, debian/libebackend-1.2-dev.install,
    debian/libcamel1.2-dev.install, debian/libedataserverui1.2-dev.install:
    - install html documentation
  + debian/rules:
    - don't build documentation it's shipped with the tarball

Show diffs side-by-side

added added

removed removed

Lines of Context:
29
29
        (G_TYPE_INSTANCE_GET_PRIVATE \
30
30
        ((obj), E_TYPE_CATEGORY_COMPLETION, ECategoryCompletionPrivate))
31
31
 
 
32
G_DEFINE_TYPE (ECategoryCompletion, e_category_completion, GTK_TYPE_ENTRY_COMPLETION)
 
33
 
32
34
struct _ECategoryCompletionPrivate {
33
35
        GtkWidget *last_known_entry;
34
36
        gchar *create;
154
156
        /* Complete the partially typed category. */
155
157
        gtk_editable_delete_text (editable, start_pos, end_pos);
156
158
        gtk_editable_insert_text (editable, category, -1, &start_pos);
157
 
        gtk_editable_insert_text (editable, ", ", 2, &start_pos);
 
159
        gtk_editable_insert_text (editable, ",", 1, &start_pos);
158
160
        gtk_editable_set_position (editable, start_pos);
159
161
}
160
162
 
292
294
        g_free (input);
293
295
}
294
296
 
 
297
static gboolean
 
298
category_completion_sanitize_suffix (GtkEntry *entry, GdkEventFocus *event, GtkEntryCompletion *completion)
 
299
{
 
300
        const gchar *text;
 
301
 
 
302
        g_return_val_if_fail (entry != NULL, FALSE);
 
303
        g_return_val_if_fail (completion != NULL, FALSE);
 
304
 
 
305
        text = gtk_entry_get_text (entry);
 
306
        if (text) {
 
307
                gint len = strlen (text), old_len = len;
 
308
 
 
309
                while (len > 0 && (text [len -1] == ' ' || text [len - 1] == ','))
 
310
                        len--;
 
311
 
 
312
                if (old_len != len) {
 
313
                        gchar *tmp = g_strndup (text, len);
 
314
 
 
315
                        gtk_entry_set_text (entry, tmp);
 
316
 
 
317
                        g_free (tmp);
 
318
                }
 
319
        }
 
320
 
 
321
        return FALSE;
 
322
}
 
323
 
295
324
static void
296
325
category_completion_track_entry (GtkEntryCompletion *completion)
297
326
{
323
352
                priv->last_known_entry, "notify::text",
324
353
                G_CALLBACK (category_completion_update_prefix), completion);
325
354
 
 
355
        g_signal_connect (
 
356
                priv->last_known_entry, "focus-out-event",
 
357
                G_CALLBACK (category_completion_sanitize_suffix), completion);
 
358
 
326
359
        category_completion_update_prefix (completion);
327
360
}
328
361
 
393
426
}
394
427
 
395
428
static void
396
 
category_completion_class_init (ECategoryCompletionClass *class)
 
429
e_category_completion_class_init (ECategoryCompletionClass *class)
397
430
{
398
431
        GObjectClass *object_class;
399
432
        GtkEntryCompletionClass *entry_completion_class;
411
444
}
412
445
 
413
446
static void
414
 
category_completion_init (ECategoryCompletion *category_completion)
 
447
e_category_completion_init (ECategoryCompletion *category_completion)
415
448
{
416
449
        GtkCellRenderer *renderer;
417
450
        GtkEntryCompletion *completion;
443
476
        category_completion_build_model (completion);
444
477
}
445
478
 
446
 
GType
447
 
e_category_completion_get_type (void)
448
 
{
449
 
        static GType type = 0;
450
 
 
451
 
        if (G_UNLIKELY (type == 0)) {
452
 
                static const GTypeInfo type_info = {
453
 
                        sizeof (ECategoryCompletionClass),
454
 
                        (GBaseInitFunc) NULL,
455
 
                        (GBaseFinalizeFunc) NULL,
456
 
                        (GClassInitFunc) category_completion_class_init,
457
 
                        (GClassFinalizeFunc) NULL,
458
 
                        NULL,  /* class_data */
459
 
                        sizeof (ECategoryCompletion),
460
 
                        0,     /* n_preallocs */
461
 
                        (GInstanceInitFunc) category_completion_init,
462
 
                        NULL   /* value_table */
463
 
                };
464
 
 
465
 
                type = g_type_register_static (
466
 
                        GTK_TYPE_ENTRY_COMPLETION, "ECategoryCompletion",
467
 
                        &type_info, 0);
468
 
        }
469
 
 
470
 
        return type;
471
 
}
472
 
 
 
479
/**
 
480
 * e_category_completion_new:
 
481
 *
 
482
 * Since: 2.26
 
483
 **/
473
484
GtkEntryCompletion *
474
485
e_category_completion_new (void)
475
486
{