![]() |
![]() |
![]() |
Evolution-Data-Server Manual: Address Book Client (libebook) | ![]() |
---|---|---|---|---|
Top | Description | Object Hierarchy | Implemented Interfaces | Properties | Signals |
#include <libebook/libebook.h> struct EBookClientCursor; struct EBookClientCursorClass; struct _EBookClient * e_book_client_cursor_ref_client (EBookClientCursor *cursor
); gint e_book_client_cursor_get_total (EBookClientCursor *cursor
); gint e_book_client_cursor_get_position (EBookClientCursor *cursor
); const gchar * const * e_book_client_cursor_get_alphabet (EBookClientCursor *cursor
,gint *n_labels
,gint *underflow
,gint *inflow
,gint *overflow
); void e_book_client_cursor_set_sexp (EBookClientCursor *cursor
,const gchar *sexp
,GCancellable *cancellable
,GAsyncReadyCallback callback
,gpointer user_data
); gboolean e_book_client_cursor_set_sexp_finish (EBookClientCursor *cursor
,GAsyncResult *result
,GError **error
); gboolean e_book_client_cursor_set_sexp_sync (EBookClientCursor *cursor
,const gchar *sexp
,GCancellable *cancellable
,GError **error
); void e_book_client_cursor_step (EBookClientCursor *cursor
,EBookCursorStepFlags flags
,EBookCursorOrigin origin
,gint count
,GCancellable *cancellable
,GAsyncReadyCallback callback
,gpointer user_data
); gint e_book_client_cursor_step_finish (EBookClientCursor *cursor
,GAsyncResult *result
,GSList **out_contacts
,GError **error
); gint e_book_client_cursor_step_sync (EBookClientCursor *cursor
,EBookCursorStepFlags flags
,EBookCursorOrigin origin
,gint count
,GSList **out_contacts
,GCancellable *cancellable
,GError **error
); void e_book_client_cursor_set_alphabetic_index (EBookClientCursor *cursor
,gint index
,GCancellable *cancellable
,GAsyncReadyCallback callback
,gpointer user_data
); gboolean e_book_client_cursor_set_alphabetic_index_finish (EBookClientCursor *cursor
,GAsyncResult *result
,GError **error
); gboolean e_book_client_cursor_set_alphabetic_index_sync (EBookClientCursor *cursor
,gint index
,GCancellable *cancellable
,GError **error
); gint e_book_client_cursor_get_contact_alphabetic_index (EBookClientCursor *cursor
,EContact *contact
);
"alphabet" GStrv : Read "client" EBookClient* : Read / Write / Construct Only "connection" GDBusConnection* : Write / Construct Only "context" GMainContext* : Write / Construct Only "direct-cursor" EDataBookCursor* : Write / Construct Only "object-path" gchar* : Write / Construct Only "position" gint : Read "sort-fields" GStrv : Write / Construct Only "total" gint : Read
The EBookClientCursor is an iteration based interface for browsing a sorted list of contacts in the addressbook.
When creating the cursor initially with e_book_client_get_cursor()
,
a list of EContactFields must be provided to define the sort order for
the newly created cursor. Only contact fields of type G_TYPE_STRING
can potentially be used to define a cursor's sort order.
Backends which support cursors may refuse to create a cursor based
on the fields specified as sort keys, if this happens then an
E_CLIENT_ERROR_INVALID_QUERY
error will be reported by
e_book_client_get_cursor()
.
The default SQLite backend provided with Evolution Data Server
only supports EContactFields that are specified as summary information
to be used as sort keys. Whether a contact field is configured to
be part of the summary for your addressbook can be verified with
e_source_backend_summary_setup_get_summary_fields()
.
The order of sort keys given to e_book_client_get_cursor()
defines
which sort key will be the primary sort key and which keys will
serve as tie breakers where the previous sort keys are exact matches.
In the following example we create a typical cursor sorted with
E_CONTACT_FAMILY_NAME
as the primary sort key and E_CONTACT_GIVEN_NAME
as a tie breaker.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
EBookClientCursor *cursor = NULL; EContactField sort_fields[] = { E_CONTACT_FAMILY_NAME, E_CONTACT_GIVEN_NAME }; EBookCursorSortType sort_types[] = { E_BOOK_CURSOR_SORT_ASCENDING, E_BOOK_CURSOR_SORT_ASCENDING }; GError *error = NULL; if (e_book_client_get_cursor_sync (book_client, // EBookClient NULL, // Search Expression sort_fields, // Sort Keys sort_types, // Ascending / Descending 2, // Number of keys &cursor, // Return location for cursor NULL, // GCancellable &error)) { // Now we have a cursor ... } |
Sort order is immutable, if you need to browse content in a different order, then you need to create a separate cursor.
At any given time in a cursor's life cycle, a cursor's internal state will refer to a relative position in a sorted list.
There are three basic varieties of cursor states:
Virtual states referring to the beginnng and end of the list.
The beginning state is positioned before any contact in the addressbook.
When the cursor is in this state, a call to e_book_client_cursor_step()
will always start reporting contacts from the beginning of the list.
Similarly when in the end state, stepping in reverse will start
reporting contacts from the end of the list.
The beginning and end states can be reached by stepping off the
end of the list, or by specifying the E_BOOK_CURSOR_ORIGIN_BEGIN
or
E_BOOK_CURSOR_ORIGIN_END
origins to e_book_client_cursor_step()
. The
cursor is also initially positioned before the contact list.
States referring to a specific contact.
A state which refers to a specific contact in the list of
contacts associated with a given cursor. At the end of any
successful call to e_book_client_cursor_step()
with
the E_BOOK_CURSOR_STEP_MOVE
flag specified; the cursor
state is updated with the value of the last result.
States referring to an alphabetic position.
When a state refers to an Alphabetic Index, it refers to a position which is in between contacts. For instance the alphabetic position "E" refers to a position after contacts starting with "D" and before contacts starting with "E".
The "position" and "total" attributes provide feedback about a cursor's position in relation to the addressbook provided the cursor's sort order.
The total reflects that total amount of contacts in the addressbook given the cursor's Search Expression. The position is defined as the number of contacts leading up to the cursor position inclusive of the cursor position.
To help illustrate how the total and position attributes relate to a sorted list of contacts, we've provided the diagram below.
The above diagram shows two representations of a sorted contact list, using
E_CONTACT_FAMILY_NAME
as the primary sort key and E_CONTACT_GIVEN_NAME
as
a secondary sort key. On either side we can see the symbolic positions
E_BOOK_CURSOR_ORIGIN_BEGIN
and E_BOOK_CURSOR_ORIGIN_END
.
For a given cursor state, the position value will be equal to the total
number of contacts leading up to the current cursor state inclusive of the
cursor state itself. In the left hand side of the above diagram the cursor
points to the fourth contact and the cursor position is also 4. An exception
to this is when the cursor state refers to the E_BOOK_CURSOR_ORIGIN_END
position.
When the cursor state refers to the end of list, the position property
will have a value of (total + 1).
Another thing the above diagram illustrates is the effect that an asynchronous addressbook modification has on the cursor. The right hand side of the diagram portrays the result of deleting "Mickey Mouse" from the original list on the left.
The cursor state at this time still litteraly refers to "Mickey Mouse", however the number of contacts leading up to "Mickey Mouse" is now 3 instead of 4. As one might have guessed, any addition of a contact which is considered to be less than or equal to "Mickey Mouse" at this point, will cause the position to increase again. In this way, asynchronous addressbook modification might cause the cursor's position and total values to change, but never effect the cursor's state and it's actual position in relation to other contacts in the sorted list.
The position and total can be useful for various tasks such as determining "Forward" / "Back" button sensitivity in a browser interface, or displaying some indication of the view window's position in the full contact list.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
gint position, total; gdouble percent; // Fetch the position & total position = e_book_client_cursor_get_position (cursor); total = e_book_client_cursor_get_total (cursor); // The position can be total + 1 if we're at the end of the // list, let's ignore that for this calculation. position = CLAMP (position, 0, total); // Calculate the percentage. percent = position * 1.0F / (total - N_DISPLAY_CONTACTS); // Let the user know the percentage of contacts in the list // which are positioned before the view position (the // percentage of the addressbook which the user has seen so far). update_percentage_of_list_browsed (user_interface, percent); |
These total and position values are guaranteed to always be coherent, they are updated synchronously upon successful completion of any of the asynchronous cursor API calls, and also updated asynchronously whenever the addressbook changes and a "refresh" signal is delivered.
Change notifications are guaranteed to only ever be delivered in the GMainContext which was the thread default main context at cursor creation time.
The list of contacts associated to a given cursor can be filtered
with a search expression generated by e_book_query_to_string()
. Since
this effects how the data will be traversed in the backend, seach
expressions come with the same limitation as sort keys. Backends
will report E_CLIENT_ERROR_INVALID_QUERY
for contact fields which
are not supported. For the default local addressbook, any fields
which are configured in the summary can be used to filter cursor
results.
Changing the search expression can be done at any time using
e_book_client_cursor_set_sexp()
.
The cursor position and total
values will be updated synchronously after successfully setting the
search expression at which time you might refresh the current
view, displaying the new filtered list of contacts at the same
cursor position.
The cursor API allows you to iterate through a sorted list of contacts without keeping a potentially large collection of contacts loaded in memory.
Iterating through the contact list is done with e_book_client_cursor_step()
, this
function allows one to move the cursor and fetch the results following the current
cursor position.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
GError *error = NULL; GSList *results = NULL; gint n_results; // Move the cursor forward by 10 contacts and fetch the results. n_results = e_book_client_cursor_step_sync (cursor, E_BOOK_CURSOR_STEP_MOVE | E_BOOK_CURSOR_STEP_FETCH, E_BOOK_CURSOR_ORIGIN_CURRENT, 10, &results, NULL, &error); if (n_results < 0) { if (g_error_matches (error, E_CLIENT_ERROR, E_CLIENT_ERROR_OUT_OF_SYNC)) { // The addressbook has been modified at the same time as // we asked to step. The appropriate thing to do is wait // for the "refresh" signal before trying again. handle_out_of_sync_condition (cursor); } else if (g_error_matches (error, E_CLIENT_ERROR, E_CLIENT_ERROR_QUERY_REFUSED)) { // We asked for 10 contacts but were already positioned // at the end of the list (or we asked for -10 contacts // and were positioned at the beginning). handle_end_of_list_condition (cursor); } else { // Some error actually occurred handle_error_condition (cursor, error); } g_clear_error (&error); } else if (n_results < 10) { // Cursor did not traverse as many contacts as requested. // // This is not an error but rather an indication that // the end of the list was reached. The next attempt to // move the cursor in the same direction will result in // an E_CLIENT_ERROR_QUERY_REFUSED error. } |
In the above example we chose E_BOOK_CURSOR_ORIGIN_CURRENT
as our EBookCursorOrigin so the above
call will traverse 10 contacts following the cursor's current position. One can also choose the
E_BOOK_CURSOR_ORIGIN_BEGIN
or E_BOOK_CURSOR_ORIGIN_END
origin to start at the beginning or end
of the results at any time.
We also specified both of the flags E_BOOK_CURSOR_STEP_MOVE
and E_BOOK_CURSOR_STEP_FETCH
,
this means we want to receive results from the addressbook and we also want to modify
the current cursor state (move the cursor), these operations can however be done
completely independantly of eachother, which is often what is desired for a contact
browsing user interface. It is however recommended to move and fetch
results in a single pass wherever that makes sense in your application.
Because the addressbook might be modified at any time by another application,
it's important to handle the E_CLIENT_ERROR_OUT_OF_SYNC
error. This error will occur
at any time that the cursor detects an addressbook change while trying to step.
Whenever an out of sync condition arises, the cursor should be left alone until the
next "refresh" signal. The "refresh" signal is triggered
any time that the addressbook changes and is the right place to refresh the currently
loaded content, it is also guaranteed to be triggered after any E_CLIENT_ERROR_OUT_OF_SYNC
error.
The diagram below illustrates some scenarios of how the cursor state is updated
in calls to e_book_client_cursor_step()
.
The cursor permits navigation of the sorted contact list in terms of alphabetic positions in the list, allowing one to jump from one letter to the next in the active alphabet.
The active alphabet itself is represented as an array of UTF-8 strings which are
suitable to display a given glyph or alphabetic position in the user's active alphabet.
This array of alphabetic position labels is exposed via the "alphabet"
property and can always be fetched with e_book_client_cursor_get_alphabet()
.
As shown below, each index in the active alphabet array is a potential cursor state which refers to a position before, after or in between contacts in the sorted contact list. Most of the positions in the active alphabet array refer to alphabetic glyhps or positions, however the the 'underflow', 'inflow' and 'overflow' positions represent positions for contacts which sort outside the bounderies of the active alphabet.
The active alphabet is dynamically resolved from the system locale at startup time and whenever a system locale change notification is delivered to Evolution Data Server. If ever the system locale changes at runtime then a change notification will be delivered for the "alphabet" property, this is a good time to refresh the list of alphabetic positions available in a user interface.
Using the active alphabet, one can build a user interface which allows the user
to navigate to a specific letter in the results. To set the cursor's position
directly before any results starting with a specific letter, one can use
e_book_client_cursor_set_alphabetic_index()
.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
GError *error = NULL; gint index = currently_selected_index (user_interface); // At this point 'index' must be a numeric value corresponding // to one of the positions in the array returned by // e_book_client_cursor_get_alphabet(). if (!e_book_client_cursor_set_alphabetic_index_sync (cursor, index, NULL, &error)) { if (g_error_matches (error, E_CLIENT_ERROR, E_CLIENT_ERROR_OUT_OF_SYNC)) { // The system locale has changed at the same time // as we were setting an alphabetic cursor position. handle_out_of_sync_condition (cursor); } else { // Some error actually occurred handle_error_condition (cursor, error); } g_clear_error (&error); } |
After setting the alphabetic index successfully, you can go ahead
and use e_book_client_cursor_step()
to load some contacts at the
beginning of the given letter.
This API can result in an E_CLIENT_ERROR_OUT_OF_SYNC
error. This error will
occur at any time that the cursor tries to set the alphabetic index whilst the
addressbook is changing its active locale setting. In the case of a dynamic locale
change, a change notification will be delivered for the "alphabet"
property at which point the application should reload anything related to the
alphabet (a "refresh" signal will also be delivered at this point).
While moving through the cursor results using e_book_client_cursor_step()
,
it can be useful to know which alphabetic position a given contact sorts
under. This can be useful if your user interface displays an alphabetic
label indicating where the first contact in your view is positioned in
the alphabet.
One can determine the appropriate index for a given EContact by calling
e_book_client_cursor_get_contact_alphabetic_index()
after refreshing
the currently displayed contacts in a view.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
EContact *contact; const gchar * const *alphabet; gint index; // Fetch the first displayed EContact in the view contact = first_contact_in_the_list (user_interface); // Calculate the position in the alphabet for this contact index = e_book_client_cursor_get_contact_alphabetic_index (cursor, contact); // Fetch the alphabet labels alphabet = e_book_client_cursor_get_alphabet (cursor, &n_labels, NULL, NULL, NULL); // Update label in user interface set_alphabetic_position_feedback_text (user_interface, alphabet[index]); |
Evolution Data Server comes with an example implementation of a contact browser using the cursor features, the main portion of this example is included here below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 |
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ /* * Copyright (C) 2013 Intel Corporation * * This program is free software; you can redistribute it and/or * modify it under the terms of version 2 of the GNU Lesser General Public * License as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this program; if not, write to the * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301, USA. * * Author: Tristan Van Berkom <tristanvb@openismus.com> */ #include <libebook/libebook.h> #include "cursor-example.h" #include "cursor-navigator.h" #include "cursor-search.h" #include "cursor-slot.h" #include "cursor-data.h" #include "cursor-slot.h" #define N_SLOTS 10 #define INITIAL_TIMEOUT 600 #define TICK_TIMEOUT 100 #define d(x) typedef enum _TimeoutActivity TimeoutActivity; /* GObjectClass */ static void cursor_example_dispose (GObject *object); /* UI Callbacks */ static gboolean cursor_example_up_button_press (CursorExample *example, GdkEvent *event, GtkButton *button); static gboolean cursor_example_up_button_release (CursorExample *example, GdkEvent *event, GtkButton *button); static gboolean cursor_example_down_button_press (CursorExample *example, GdkEvent *event, GtkButton *button); static gboolean cursor_example_down_button_release (CursorExample *example, GdkEvent *event, GtkButton *button); static void cursor_example_navigator_changed (CursorExample *example, CursorNavigator *navigator); static void cursor_example_sexp_changed (CursorExample *example, GParamSpec *pspec, CursorSearch *search); /* EDS Callbacks */ static void cursor_example_refresh (EBookClientCursor *cursor, CursorExample *example); static void cursor_example_alphabet_changed (EBookClientCursor *cursor, GParamSpec *pspec, CursorExample *example); static void cursor_example_status_changed (EBookClientCursor *cursor, GParamSpec *spec, CursorExample *example); /* Utilities */ static void cursor_example_load_alphabet (CursorExample *example); static gboolean cursor_example_move_cursor (CursorExample *example, EBookCursorOrigin origin, gint count); static gboolean cursor_example_load_page (CursorExample *example, gboolean *full_results); static void cursor_example_update_status (CursorExample *example); static void cursor_example_update_current_index (CursorExample *example, EContact *contact); static void cursor_example_ensure_timeout (CursorExample *example, TimeoutActivity activity); static void cursor_example_cancel_timeout (CursorExample *example); enum _TimeoutActivity { TIMEOUT_NONE = 0, TIMEOUT_UP_INITIAL, TIMEOUT_UP_TICK, TIMEOUT_DOWN_INITIAL, TIMEOUT_DOWN_TICK, }; struct _CursorExamplePrivate { /* Screen widgets */ GtkWidget *browse_up_button; GtkWidget *browse_down_button; GtkWidget *progressbar; GtkWidget *alphabet_label; GtkWidget *slots[N_SLOTS]; CursorNavigator *navigator; /* EDS Resources */ EBookClient *client; EBookClientCursor *cursor; /* Manage the automatic scrolling with button pressed */ guint timeout_id; TimeoutActivity activity; }; G_DEFINE_TYPE_WITH_PRIVATE (CursorExample, cursor_example, GTK_TYPE_WINDOW); /************************************************************************ * GObjectClass * ************************************************************************/ static void cursor_example_class_init (CursorExampleClass *klass) { GObjectClass *object_class; GtkWidgetClass *widget_class; gint i; object_class = G_OBJECT_CLASS (klass); object_class->dispose = cursor_example_dispose; /* Bind to template */ widget_class = GTK_WIDGET_CLASS (klass); gtk_widget_class_set_template_from_resource (widget_class, "/org/gnome/evolution/cursor-example/cursor-example.ui"); gtk_widget_class_bind_template_child_private (widget_class, CursorExample, navigator); gtk_widget_class_bind_template_child_private (widget_class, CursorExample, browse_up_button); gtk_widget_class_bind_template_child_private (widget_class, CursorExample, browse_down_button); gtk_widget_class_bind_template_child_private (widget_class, CursorExample, alphabet_label); gtk_widget_class_bind_template_child_private (widget_class, CursorExample, progressbar); for (i = 0; i < N_SLOTS; i++) { gchar *name = g_strdup_printf ("contact_slot_%d", i + 1); gtk_widget_class_bind_template_child_full (widget_class, name, FALSE, 0); g_free (name); } gtk_widget_class_bind_template_callback (widget_class, cursor_example_navigator_changed); gtk_widget_class_bind_template_callback (widget_class, cursor_example_up_button_press); gtk_widget_class_bind_template_callback (widget_class, cursor_example_up_button_release); gtk_widget_class_bind_template_callback (widget_class, cursor_example_down_button_press); gtk_widget_class_bind_template_callback (widget_class, cursor_example_down_button_release); gtk_widget_class_bind_template_callback (widget_class, cursor_example_sexp_changed); } static void cursor_example_init (CursorExample *example) { CursorExamplePrivate *priv; gint i; example->priv = priv = cursor_example_get_instance_private (example); g_type_ensure (CURSOR_TYPE_NAVIGATOR); g_type_ensure (CURSOR_TYPE_SEARCH); gtk_widget_init_template (GTK_WIDGET (example)); for (i = 0; i < N_SLOTS; i++) { gchar *name = g_strdup_printf ("contact_slot_%d", i + 1); priv->slots[i] = (GtkWidget *)gtk_widget_get_template_child (GTK_WIDGET (example), CURSOR_TYPE_EXAMPLE, name); g_free (name); } } static void cursor_example_dispose (GObject *object) { CursorExample *example = CURSOR_EXAMPLE (object); CursorExamplePrivate *priv = example->priv; cursor_example_cancel_timeout (example); if (priv->client) { g_object_unref (priv->client); priv->client = NULL; } if (priv->cursor) { g_object_unref (priv->cursor); priv->cursor = NULL; } G_OBJECT_CLASS (cursor_example_parent_class)->dispose (object); } /************************************************************************ * UI Callbacks * ************************************************************************/ static gboolean cursor_example_up_button_press (CursorExample *example, GdkEvent *event, GtkButton *button) { d (g_print ("Browse up press\n")); /* Move the cursor backwards by 1 and then refresh the page */ if (cursor_example_move_cursor (example, E_BOOK_CURSOR_ORIGIN_CURRENT, 0 - 1)) cursor_example_load_page (example, NULL); cursor_example_ensure_timeout (example, TIMEOUT_UP_INITIAL); return FALSE; } static gboolean cursor_example_up_button_release (CursorExample *example, GdkEvent *event, GtkButton *button) { d (g_print ("Browse up release\n")); cursor_example_cancel_timeout (example); return FALSE; } static gboolean cursor_example_down_button_press (CursorExample *example, GdkEvent *event, GtkButton *button) { d (g_print ("Browse down press\n")); /* Move the cursor forward by 1 and then refresh the page */ if (cursor_example_move_cursor (example, E_BOOK_CURSOR_ORIGIN_CURRENT, 1)) cursor_example_load_page (example, NULL); cursor_example_ensure_timeout (example, TIMEOUT_DOWN_INITIAL); return FALSE; } static gboolean cursor_example_down_button_release (CursorExample *example, GdkEvent *event, GtkButton *button) { d (g_print ("Browse down released\n")); cursor_example_cancel_timeout (example); return FALSE; } static void cursor_example_navigator_changed (CursorExample *example, CursorNavigator *navigator) { CursorExamplePrivate *priv = example->priv; GError *error = NULL; gint index; gboolean full_results = FALSE; index = cursor_navigator_get_index (priv->navigator); d (g_print ("Alphabet index changed to: %d\n", index)); /* Move to this index */ if (!e_book_client_cursor_set_alphabetic_index_sync (priv->cursor, index, NULL, &error)) { if (g_error_matches (error, E_CLIENT_ERROR, E_CLIENT_ERROR_OUT_OF_SYNC)) { /* Just ignore the error. * * The addressbook locale has recently changed, very * soon we will receive an alphabet change notification * where we will reset the cursor position and reload * the alphabet. */ d (g_print ("Cursor was temporarily out of sync while setting the alphabetic target\n")); } else g_warning ("Failed to move the cursor: %s", error->message); g_clear_error (&error); } /* And load one page full of results starting with this index */ if (!cursor_example_load_page (example, &full_results)) return; /* If we hit the end of the results (less than a full page) then load the last page of results */ if (!full_results) { if (cursor_example_move_cursor (example, E_BOOK_CURSOR_ORIGIN_END, 0 - (N_SLOTS + 1))) { cursor_example_load_page (example, NULL); } } } static void cursor_example_sexp_changed (CursorExample *example, GParamSpec *pspec, CursorSearch *search) { CursorExamplePrivate *priv = example->priv; gboolean full_results = FALSE; GError *error = NULL; const gchar *sexp; sexp = cursor_search_get_sexp (search); d (g_print ("Search expression changed to: '%s'\n", sexp)); /* Set the search expression */ if (!e_book_client_cursor_set_sexp_sync (priv->cursor, sexp, NULL, &error)) { g_warning ("Failed to move the cursor: %s", error->message); g_clear_error (&error); } /* And load one page full of results */ if (!cursor_example_load_page (example, &full_results)) return; /* If we hit the end of the results (less than a full page) then load the last page of results */ if (!full_results) if (cursor_example_move_cursor (example, E_BOOK_CURSOR_ORIGIN_END, 0 - (N_SLOTS + 1))) { cursor_example_load_page (example, NULL); } } /************************************************************************ * EDS Callbacks * ************************************************************************/ static void cursor_example_refresh (EBookClientCursor *cursor, CursorExample *example) { d (g_print ("Cursor refreshed\n")); /* Refresh the page */ if (cursor_example_load_page (example, NULL)) cursor_example_update_status (example); } static void cursor_example_alphabet_changed (EBookClientCursor *cursor, GParamSpec *spec, CursorExample *example) { d (g_print ("Alphabet Changed\n")); cursor_example_load_alphabet (example); /* Get the first page of contacts in the addressbook */ if (cursor_example_move_cursor (example, E_BOOK_CURSOR_ORIGIN_BEGIN, 0)) cursor_example_load_page (example, NULL); } static void cursor_example_status_changed (EBookClientCursor *cursor, GParamSpec *spec, CursorExample *example) { d (g_print ("Status changed\n")); cursor_example_update_status (example); } /************************************************************************ * Utilities * ************************************************************************/ static void cursor_example_load_alphabet (CursorExample *example) { CursorExamplePrivate *priv = example->priv; const gchar *const *alphabet; /* Update the alphabet on the navigator */ alphabet = e_book_client_cursor_get_alphabet (priv->cursor, NULL, NULL, NULL, NULL); cursor_navigator_set_alphabet (priv->navigator, alphabet); /* Reset navigator to the beginning */ g_signal_handlers_block_by_func (priv->navigator, cursor_example_navigator_changed, example); cursor_navigator_set_index (priv->navigator, 0); g_signal_handlers_unblock_by_func (priv->navigator, cursor_example_navigator_changed, example); } static gboolean cursor_example_move_cursor (CursorExample *example, EBookCursorOrigin origin, gint count) { CursorExamplePrivate *priv = example->priv; GError *error = NULL; gint n_results; n_results = e_book_client_cursor_step_sync (priv->cursor, E_BOOK_CURSOR_STEP_MOVE, origin, count, NULL, /* Result list */ NULL, /* GCancellable */ &error); if (n_results < 0) { if (g_error_matches (error, E_CLIENT_ERROR, E_CLIENT_ERROR_OUT_OF_SYNC)) { /* The addressbook has very recently been modified, * very soon we will receive a "refresh" signal and * automatically reload the current page position. */ d (g_print ("Cursor was temporarily out of sync while moving\n")); } else if (g_error_matches (error, E_CLIENT_ERROR, E_CLIENT_ERROR_QUERY_REFUSED)) { d (g_print ("End of list was reached\n")); } else g_warning ("Failed to move the cursor: %s", error->message); g_clear_error (&error); } return n_results >= 0; } /* Loads a page at the current cursor position, returns * FALSE if there was an error. */ static gboolean cursor_example_load_page (CursorExample *example, gboolean *full_results) { CursorExamplePrivate *priv = example->priv; GError *error = NULL; GSList *results = NULL; gint n_results; /* Fetch N_SLOTS contacts after the current cursor position, * without modifying the current cursor position */ n_results = e_book_client_cursor_step_sync (priv->cursor, E_BOOK_CURSOR_STEP_FETCH, E_BOOK_CURSOR_ORIGIN_CURRENT, N_SLOTS, &results, NULL, /* GCancellable */ &error); if (n_results < 0) { if (g_error_matches (error, E_CLIENT_ERROR, E_CLIENT_ERROR_OUT_OF_SYNC)) { /* The addressbook has very recently been modified, * very soon we will receive a "refresh" signal and * automatically reload the current page position. */ d (g_print ("Cursor was temporarily out of sync while loading page\n")); } else if (g_error_matches (error, E_CLIENT_ERROR, E_CLIENT_ERROR_QUERY_REFUSED)) { d (g_print ("End of list was reached\n")); } else g_warning ("Failed to move the cursor: %s", error->message); g_clear_error (&error); } else { /* Display the results */ EContact *contact; gint i; /* Fill the page with results for the current cursor position */ for (i = 0; i < N_SLOTS; i++) { contact = g_slist_nth_data (results, i); /* For the first contact, give some visual feedback about where we * are in the list, which alphabet character we're browsing right now. */ if (i == 0 && contact) cursor_example_update_current_index (example, contact); cursor_slot_set_from_contact (CURSOR_SLOT (priv->slots[i]), contact); } } if (full_results) *full_results = (n_results == N_SLOTS); g_slist_free_full (results, (GDestroyNotify)g_object_unref); return n_results >= 0; } static void cursor_example_update_status (CursorExample *example) { CursorExamplePrivate *priv = example->priv; gint total, position; gchar *txt; gboolean up_sensitive; gboolean down_sensitive; gdouble fraction; total = e_book_client_cursor_get_total (priv->cursor); position = e_book_client_cursor_get_position (priv->cursor); /* Set the label showing the cursor position and total contacts */ txt = g_strdup_printf ("Position %d / Total %d", position, total); gtk_progress_bar_set_text (GTK_PROGRESS_BAR (priv->progressbar), txt); g_free (txt); /* Give visual feedback on how far we are into the contact list */ fraction = position * 1.0F / (total - N_SLOTS); gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR (priv->progressbar), fraction); /* Update sensitivity of buttons */ if (total <= N_SLOTS) { /* If the amount of contacts is less than the amount of visual slots, * then we cannot browse up and down */ up_sensitive = FALSE; down_sensitive = FALSE; } else { /* The cursor is always pointing directly before * the first contact visible in the view, so if the * cursor is passed the first contact we can rewind. */ up_sensitive = position > 0; /* If more than N_SLOTS contacts remain, then * we can still scroll down */ down_sensitive = position < total - N_SLOTS; } gtk_widget_set_sensitive (priv->browse_up_button, up_sensitive); gtk_widget_set_sensitive (priv->browse_down_button, down_sensitive); } /* This is called when refreshing the window contents with * the first contact shown in the window. */ static void cursor_example_update_current_index (CursorExample *example, EContact *contact) { CursorExamplePrivate *priv = example->priv; const gchar *const *labels; gint index; /* Fetch the alphabetic index for this contact */ index = e_book_client_cursor_get_contact_alphabetic_index (priv->cursor, contact); /* Refresh the current alphabet index indicator. * * The index returned by e_book_client_cursor_get_contact_alphabetic_index() is * a valid position into the array returned by e_book_client_cursor_get_alphabet(). */ labels = e_book_client_cursor_get_alphabet (priv->cursor, NULL, NULL, NULL, NULL); gtk_label_set_text (GTK_LABEL (priv->alphabet_label), labels[index]); /* Update the current scroll position (and avoid reacting to the value change) */ if (contact) { g_signal_handlers_block_by_func (priv->navigator, cursor_example_navigator_changed, example); cursor_navigator_set_index (priv->navigator, index); g_signal_handlers_unblock_by_func (priv->navigator, cursor_example_navigator_changed, example); } } static gboolean cursor_example_timeout (CursorExample *example) { CursorExamplePrivate *priv = example->priv; gboolean can_move; switch (priv->activity) { case TIMEOUT_NONE: break; case TIMEOUT_UP_INITIAL: case TIMEOUT_UP_TICK: /* Move the cursor backwards by 1 and then refresh the page */ if (cursor_example_move_cursor (example, E_BOOK_CURSOR_ORIGIN_CURRENT, 0 - 1)) { cursor_example_load_page (example, NULL); cursor_example_ensure_timeout (example, TIMEOUT_UP_TICK); } else cursor_example_cancel_timeout (example); break; case TIMEOUT_DOWN_INITIAL: case TIMEOUT_DOWN_TICK: /* Avoid scrolling past the end of the list - N_SLOTS */ can_move = (e_book_client_cursor_get_position (priv->cursor) < e_book_client_cursor_get_total (priv->cursor) - N_SLOTS); /* Move the cursor forwards by 1 and then refresh the page */ if (can_move && cursor_example_move_cursor (example, E_BOOK_CURSOR_ORIGIN_CURRENT, 1)) { cursor_example_load_page (example, NULL); cursor_example_ensure_timeout (example, TIMEOUT_DOWN_TICK); } else cursor_example_cancel_timeout (example); break; } return FALSE; } static void cursor_example_ensure_timeout (CursorExample *example, TimeoutActivity activity) { CursorExamplePrivate *priv = example->priv; guint timeout = 0; cursor_example_cancel_timeout (example); if (activity == TIMEOUT_UP_INITIAL || activity == TIMEOUT_DOWN_INITIAL) timeout = INITIAL_TIMEOUT; else timeout = TICK_TIMEOUT; priv->activity = activity; priv->timeout_id = g_timeout_add (timeout, (GSourceFunc)cursor_example_timeout, example); } static void cursor_example_cancel_timeout (CursorExample *example) { CursorExamplePrivate *priv = example->priv; if (priv->timeout_id) { g_source_remove (priv->timeout_id); priv->timeout_id = 0; } } /************************************************************************ * API * ************************************************************************/ GtkWidget * cursor_example_new (const gchar *vcard_path) { CursorExample *example; CursorExamplePrivate *priv; example = g_object_new (CURSOR_TYPE_EXAMPLE, NULL); priv = example->priv; priv->client = cursor_load_data (vcard_path, &priv->cursor); cursor_example_load_alphabet (example); /* Load the first page of results */ cursor_example_load_page (example, NULL); cursor_example_update_status (example); g_signal_connect (priv->cursor, "refresh", G_CALLBACK (cursor_example_refresh), example); g_signal_connect (priv->cursor, "notify::alphabet", G_CALLBACK (cursor_example_alphabet_changed), example); g_signal_connect (priv->cursor, "notify::total", G_CALLBACK (cursor_example_status_changed), example); g_signal_connect (priv->cursor, "notify::position", G_CALLBACK (cursor_example_status_changed), example); g_message ("Cursor example started in locale: %s", e_book_client_get_locale (priv->client)); return (GtkWidget *)example; } |
struct EBookClientCursorClass { /* Signals */ void (* refresh) (EBookClientCursor *cursor); };
The cursor class structure.
The class handler for the "refresh" signal |
Since 3.12
struct _EBookClient * e_book_client_cursor_ref_client (EBookClientCursor *cursor
);
Returns the "client" associated with cursor
.
The returned EBookClient is referenced because the cursor does not keep a strong reference to the client.
Unreference the EBookClient with g_object_unref()
when finished with it.
|
an EBookClientCursor |
Returns : |
an EBookClient. [transfer full] |
Since 3.12
gint e_book_client_cursor_get_total (EBookClientCursor *cursor
);
Fetches the total number of contacts in the addressbook
which match cursor
's query
|
an EBookClientCursor |
Returns : |
The total number of contacts matching cursor 's query |
Since 3.12
gint e_book_client_cursor_get_position (EBookClientCursor *cursor
);
Fetches the number of contacts leading up to the current cursor position, inclusive of the current cursor position.
The position value can be anywhere from 0 to the total
number of contacts plus one. A value of 0 indicates
that the cursor is positioned before the contact list in
the symbolic E_BOOK_CURSOR_ORIGIN_BEGIN
state. If
the position is greater than the total, as returned by
e_book_client_cursor_get_total()
, then the cursor is positioned
after the last contact in the symbolic E_BOOK_CURSOR_ORIGIN_END
position.
|
an EBookClientCursor |
Returns : |
The current cursor position |
Since 3.12
const gchar * const * e_book_client_cursor_get_alphabet (EBookClientCursor *cursor
,gint *n_labels
,gint *underflow
,gint *inflow
,gint *overflow
);
Fetches the array of displayable labels for the active alphabet.
The active alphabet is based on the current locale configuration of the addressbook, and can be a different alphabet for locales requiring non-Latin language scripts. These UTF-8 labels are appropriate to display in a user interface to represent the alphabetic position of the cursor in the user's native alphabet.
The underflow
, inflow
and overflow
parameters allow one to observe which
indexes Evolution Data Server is using to store words which sort outside
of the alphabet, for instance words from foreign language scripts and
words which start with numeric characters, or other types of character.
While the underflow
and overflow
are for words which sort below or
above the active alphabets, the inflow
index is for words which sort
in between multiple concurrently active alphabets. The active alphabet
array might contain more than one alphabet for locales where it is
very common or expected to have names in Latin script as well as names
in another script.
|
an EBookClientCursor |
|
The number of labels in the active alphabet. [out][allow-none] |
|
The underflow index, for any words which sort below the active alphabet. [allow-none][out] |
|
The inflow index, for any words which sort between the active alphabets (if there is more than one). [allow-none][out] |
|
The overflow index, for any words which sort above the active alphabet. [allow-none][out] |
Returns : |
The array of displayable labels for each index in the active alphabet. [array zero-terminated=1][element-type utf8][transfer none] |
Since 3.12
void e_book_client_cursor_set_sexp (EBookClientCursor *cursor
,const gchar *sexp
,GCancellable *cancellable
,GAsyncReadyCallback callback
,gpointer user_data
);
Sets the Search Expression for the cursor.
See: e_book_client_cursor_set_sexp_sync()
.
This asynchronous call is completed with a call to
e_book_client_cursor_set_sexp_finish()
from the specified callback
.
|
an EBookClientCursor |
|
the new search expression for cursor
|
|
a GCancellable to optionally cancel this operation while in progress. [allow-none] |
|
callback to call when a result is ready |
|
user data for the callback
|
Since 3.12
gboolean e_book_client_cursor_set_sexp_finish (EBookClientCursor *cursor
,GAsyncResult *result
,GError **error
);
Completes an asynchronous call initiated by e_book_client_cursor_set_sexp()
, reporting
whether the new search expression was accepted.
|
an EBookClientCursor |
|
a GAsyncResult |
|
return location for a GError, or NULL . [out][allow-none]
|
Returns : |
TRUE on success, otherwise FALSE is returned and error is set. |
Since 3.12
gboolean e_book_client_cursor_set_sexp_sync (EBookClientCursor *cursor
,const gchar *sexp
,GCancellable *cancellable
,GError **error
);
Sets the Search Expression for the cursor.
A side effect of setting the search expression is that the position and total properties will be updated.
If this method is called from the same thread context in which the cursor was created, then the updates to the "position" and "total" properties are guaranteed to be delivered synchronously upon successful completion of setting the search expression. Otherwise, notifications will be delivered asynchronously in the cursor's original thread context.
If the backend does not support the given search expression,
an E_CLIENT_ERROR_INVALID_QUERY
error will be set.
|
an EBookClientCursor |
|
the new search expression for cursor
|
|
a GCancellable to optionally cancel this operation while in progress. [allow-none] |
|
return location for a GError, or NULL . [out][allow-none]
|
Returns : |
TRUE on success, otherwise FALSE is returned and error is set. |
Since 3.12
void e_book_client_cursor_step (EBookClientCursor *cursor
,EBookCursorStepFlags flags
,EBookCursorOrigin origin
,gint count
,GCancellable *cancellable
,GAsyncReadyCallback callback
,gpointer user_data
);
Steps the cursor through the results by
a maximum of count
and fetch the results traversed.
See: e_book_client_cursor_step_sync()
.
This asynchronous call is completed with a call to
e_book_client_cursor_step_finish()
from the specified callback
.
|
an EBookClientCursor |
|
The EBookCursorStepFlags for this step |
|
The EBookCursorOrigin from whence to step |
|
a positive or negative amount of contacts to try and fetch |
|
a GCancellable to optionally cancel this operation while in progress. [allow-none] |
|
callback to call when a result is ready |
|
user data for the callback
|
Since 3.12
gint e_book_client_cursor_step_finish (EBookClientCursor *cursor
,GAsyncResult *result
,GSList **out_contacts
,GError **error
);
Completes an asynchronous call initiated by e_book_client_cursor_step()
, fetching
any contacts which might have been returned by the call.
|
an EBookClientCursor |
|
a GAsyncResult |
|
return location for a GSList of EContacts. [element-type EContact][out][transfer full][allow-none] |
|
return location for a GError, or NULL . [out][allow-none]
|
Returns : |
The number of contacts traversed if successful, otherwise -1 is
returned and error is set. |
Since 3.12
gint e_book_client_cursor_step_sync (EBookClientCursor *cursor
,EBookCursorStepFlags flags
,EBookCursorOrigin origin
,gint count
,GSList **out_contacts
,GCancellable *cancellable
,GError **error
);
Steps the cursor through the results by
a maximum of count
and fetch the results traversed.
If count
is negative, then the cursor will move backwards.
If cursor
reaches the beginning or end of the query results, then the
returned list might not contain the amount of desired contacts, or might
return no results if the cursor currently points to the last contact.
Reaching the end of the list is not considered an error condition. Attempts
to step beyond the end of the list after having reached the end of the list
will however trigger an E_CLIENT_ERROR_QUERY_REFUSED
error.
If E_BOOK_CURSOR_STEP_FETCH
is specified in flags
, a pointer to
a NULL
GSList pointer should be provided for the results
parameter.
If E_BOOK_CURSOR_STEP_MOVE
is specified in flags
, then the cursor's
state will be modified and the position
property will be updated as a result.
If this method is called from the same thread context in which the cursor was created, then the updates to the "position" property are guaranteed to be delivered synchronously upon successful completion of moving the cursor. Otherwise, notifications will be delivered asynchronously in the cursor's original thread context.
If this method completes with an E_CLIENT_ERROR_OUT_OF_SYNC
error, it is an
indication that the addressbook has been modified and it would be unsafe to
move the cursor at this time. Any E_CLIENT_ERROR_OUT_OF_SYNC
error is guaranteed
to be followed by an "refresh" signal at which point any content
should be reloaded.
|
an EBookClientCursor |
|
The EBookCursorStepFlags for this step |
|
The EBookCursorOrigin from whence to step |
|
a positive or negative amount of contacts to try and fetch |
|
return location for a GSList of EContacts. [element-type EContact][out][transfer full][allow-none] |
|
a GCancellable to optionally cancel this operation while in progress. [allow-none] |
|
return location for a GError, or NULL . [out][allow-none]
|
Returns : |
The number of contacts traversed if successful, otherwise -1 is
returned and error is set. |
Since 3.12
void e_book_client_cursor_set_alphabetic_index (EBookClientCursor *cursor
,gint index
,GCancellable *cancellable
,GAsyncReadyCallback callback
,gpointer user_data
);
Sets the current cursor position to point to an Alphabetic Index.
See: e_book_client_cursor_set_alphabetic_index_sync()
.
This asynchronous call is completed with a call to
e_book_client_cursor_set_alphabetic_index_finish()
from the specified callback
.
|
an EBookClientCursor |
|
the alphabetic index |
|
a GCancellable to optionally cancel this operation while in progress. [allow-none] |
|
callback to call when a result is ready |
|
user data for the callback
|
Since 3.12
gboolean e_book_client_cursor_set_alphabetic_index_finish (EBookClientCursor *cursor
,GAsyncResult *result
,GError **error
);
Completes an asynchronous call initiated by e_book_client_cursor_set_alphabetic_index()
.
|
an EBookClientCursor |
|
a GAsyncResult |
|
return location for a GError, or NULL . [out][allow-none]
|
Returns : |
TRUE on success, otherwise FALSE is returned and error is set. |
Since 3.12
gboolean e_book_client_cursor_set_alphabetic_index_sync (EBookClientCursor *cursor
,gint index
,GCancellable *cancellable
,GError **error
);
Sets the cursor to point to an Alphabetic Index.
After setting the alphabetic index, for example the
index for letter 'E', then further calls to e_book_client_cursor_step()
will return results starting with the letter 'E' (or results starting
with the last result in 'D' when navigating through cursor results
in reverse).
The passed index must be a valid index into the alphabet parameters
returned by e_book_client_cursor_get_alphabet()
.
If this method is called from the same thread context in which the cursor was created, then the updates to the "position" property are guaranteed to be delivered synchronously upon successful completion of moving the cursor. Otherwise, notifications will be delivered asynchronously in the cursor's original thread context.
If this method completes with an E_CLIENT_ERROR_OUT_OF_SYNC
error, it is an
indication that the addressbook has been set into a new locale and it would be
unsafe to set the alphabetic index at this time. If you receive an out of sync
error from this method, then you should wait until a "alphabet"
property change notification is delivered and then proceed to load the new
alphabet before trying to set any alphabetic index.
|
an EBookClientCursor |
|
the alphabetic index |
|
a GCancellable to optionally cancel this operation while in progress. [allow-none] |
|
return location for a GError, or NULL . [out][allow-none]
|
Returns : |
TRUE on success, otherwise FALSE is returned and error is set. |
Since 3.12
gint e_book_client_cursor_get_contact_alphabetic_index (EBookClientCursor *cursor
,EContact *contact
);
Checks which alphabetic index contact
would be sorted
into according to cursor
.
So long as the active "alphabet" does
not change, the returned index will be a valid position
in the array of labels returned by e_book_client_cursor_get_alphabet()
.
If the index returned by this function is needed for any extended period of time, it should be recalculated whenever the "alphabet" changes.
|
an EBookClientCursor |
|
the EContact to check |
Returns : |
The alphabetic index of contact in cursor . |
Since 3.12
"alphabet"
property "alphabet" GStrv : Read
The currently active alphabet.
The value is a NULL
terminated array of strings,
each string is suitable to display a specific letter
in the active alphabet.
Indexes from this array can later be used with
e_book_client_cursor_set_alphabetic_index()
.
This property will automatically change if the active locale of the addressbook server changes.
Property change notifications are guaranteed to be delivered in the GMainContext which was the thread default context at cursor creation time.
Since 3.12
"client"
property"client" EBookClient* : Read / Write / Construct Only
The EBookClient which this cursor was created for
Since 3.12
"connection"
property "connection" GDBusConnection* : Write / Construct Only
The GDBusConnection to the addressbook server.
This is an internal parameter for constructing the
cursor, to construct the cursor use e_book_client_get_cursor()
.
Since 3.12
"context"
property "context" GMainContext* : Write / Construct Only
The GMainContext in which the EBookClient created this cursor.
This is an internal parameter for constructing the
cursor, to construct the cursor use e_book_client_get_cursor()
.
Since 3.12
"direct-cursor"
property"direct-cursor" EDataBookCursor* : Write / Construct Only
The direct handle to the EDataBookCursor for direct read access mode.
This is an internal parameter for constructing the
cursor, to construct the cursor use e_book_client_get_cursor()
.
Since 3.12
"object-path"
property "object-path" gchar* : Write / Construct Only
The D-Bus object path to find the server side cursor object.
This is an internal parameter for constructing the
cursor, to construct the cursor use e_book_client_get_cursor()
.
Default value: NULL
Since 3.12
"position"
property "position" gint : Read
The current cursor position in the cursor's result list.
More specifically, the cursor position is defined as the number of contacts leading up to the current cursor position, inclusive of the current cursor position.
If the position value is 0
, then the cursor is positioned
before the contact list in the symbolic E_BOOK_CURSOR_ORIGIN_BEGIN
position. If the position value is greater than
"total", this indicates that the cursor is
positioned after the contact list in the symbolic
E_BOOK_CURSOR_ORIGIN_END
position.
Property change notifications are guaranteed to be delivered in the GMainContext which was the thread default context at cursor creation time.
Allowed values: >= 0
Default value: 0
Since 3.12
"sort-fields"
property "sort-fields" GStrv : Write / Construct Only
The EContactField names to sort this cursor with
This is an internal parameter for constructing the
cursor, to construct the cursor use e_book_client_get_cursor()
.
Since 3.12
"refresh"
signalvoid user_function (EBookClientCursor *cursor,
gpointer user_data) : Run Last
Indicates that the addressbook has been modified and that any content currently being displayed from the current cursor position should be reloaded.
This signal is guaranteed to be delivered in the GMainContext which was the thread default context at cursor creation time.
|
The EBookClientCursor which needs to be refreshed |
|
user data set when the signal handler was connected. |
Since 3.12