aboutsummaryrefslogtreecommitdiffstats
path: root/addressbook/gui/minicard
diff options
context:
space:
mode:
Diffstat (limited to 'addressbook/gui/minicard')
-rw-r--r--addressbook/gui/minicard/e-minicard-view.c30
-rw-r--r--addressbook/gui/minicard/e-minicard-view.h2
-rw-r--r--addressbook/gui/minicard/e-reflow-sorted.c33
-rw-r--r--addressbook/gui/minicard/e-reflow-sorted.h1
4 files changed, 65 insertions, 1 deletions
diff --git a/addressbook/gui/minicard/e-minicard-view.c b/addressbook/gui/minicard/e-minicard-view.c
index d3acb1ad54..bc2e22fa32 100644
--- a/addressbook/gui/minicard/e-minicard-view.c
+++ b/addressbook/gui/minicard/e-minicard-view.c
@@ -107,7 +107,7 @@ e_minicard_view_init (EMinicardView *view)
view->canvas_destroy_id = 0;
gtk_object_set(GTK_OBJECT(view),
- "empty_message", _("There are no items to show in this view\n\n"
+ "empty_message", _("\n\nThere are no items to show in this view\n\n"
"Double-click here to create a new Contact."),
NULL);
@@ -380,3 +380,31 @@ e_minicard_view_remove_selection(EMinicardView *view,
}
}
}
+
+static int
+compare_to_letter(EMinicard *card, char *letter)
+{
+ g_return_val_if_fail(card != NULL, 0);
+ g_return_val_if_fail(E_IS_MINICARD(card), 0);
+
+ if (card->card) {
+ char *file_as;
+ gtk_object_get(GTK_OBJECT(card->card),
+ "file_as", &file_as,
+ NULL);
+ if (file_as)
+ return strncasecmp(file_as, letter, 1);
+ else
+ return 0;
+ } else {
+ return 0;
+ }
+}
+
+void e_minicard_view_jump_to_letter (EMinicardView *view,
+ char letter)
+{
+ e_reflow_sorted_jump(E_REFLOW_SORTED(view),
+ (GCompareFunc) compare_to_letter,
+ &letter);
+}
diff --git a/addressbook/gui/minicard/e-minicard-view.h b/addressbook/gui/minicard/e-minicard-view.h
index 780b0dde33..a166a6ade1 100644
--- a/addressbook/gui/minicard/e-minicard-view.h
+++ b/addressbook/gui/minicard/e-minicard-view.h
@@ -84,6 +84,8 @@ GtkType e_minicard_view_get_type (void);
void e_minicard_view_remove_selection (EMinicardView *view,
EBookCallback cb,
gpointer closure);
+void e_minicard_view_jump_to_letter (EMinicardView *view,
+ char letter);
#ifdef __cplusplus
}
diff --git a/addressbook/gui/minicard/e-reflow-sorted.c b/addressbook/gui/minicard/e-reflow-sorted.c
index 7205785c6c..c899ccb9a7 100644
--- a/addressbook/gui/minicard/e-reflow-sorted.c
+++ b/addressbook/gui/minicard/e-reflow-sorted.c
@@ -34,6 +34,10 @@ static void e_reflow_sorted_set_arg (GtkObject *o, GtkArg *arg, guint arg_id);
static void e_reflow_sorted_get_arg (GtkObject *object, GtkArg *arg, guint arg_id);
static void e_reflow_sorted_add_item(EReflow *e_reflow, GnomeCanvasItem *item);
+#define E_REFLOW_DIVIDER_WIDTH 2
+#define E_REFLOW_BORDER_WIDTH 7
+#define E_REFLOW_FULL_GUTTER (E_REFLOW_DIVIDER_WIDTH + E_REFLOW_BORDER_WIDTH * 2)
+
static EReflowClass *parent_class = NULL;
/* The arguments we take */
@@ -234,3 +238,32 @@ e_reflow_sorted_add_item(EReflow *reflow, GnomeCanvasItem *item)
}
e_reflow_post_add_item(reflow, item);
}
+
+void e_reflow_sorted_jump (EReflowSorted *sorted,
+ GCompareFunc compare_func,
+ void *value)
+{
+ int columns = 0;
+ EReflow *reflow = E_REFLOW(sorted);
+ GList *list;
+
+ for (list = reflow->columns; list; list = g_list_next(list)) {
+ if (compare_func(((GList *)list->data)->data, value) >= 0) {
+ GList *last = list->prev;
+ GtkAdjustment *adjustment;
+ if (last) {
+ GList *walk;
+ for (walk = last->data; walk != list->data; walk = g_list_next(walk)) {
+ if (compare_func(walk->data, value) >= 0) {
+ columns --;
+ break;
+ }
+ }
+ }
+ adjustment = gtk_layout_get_hadjustment(GTK_LAYOUT(GNOME_CANVAS_ITEM(sorted)->canvas));
+ gtk_adjustment_set_value(adjustment, (reflow->column_width + E_REFLOW_FULL_GUTTER) * columns);
+ return;
+ }
+ columns ++;
+ }
+}
diff --git a/addressbook/gui/minicard/e-reflow-sorted.h b/addressbook/gui/minicard/e-reflow-sorted.h
index d9b4acc747..7adfa2c045 100644
--- a/addressbook/gui/minicard/e-reflow-sorted.h
+++ b/addressbook/gui/minicard/e-reflow-sorted.h
@@ -81,6 +81,7 @@ void e_reflow_sorted_replace_item (EReflowSorted *sorted, GnomeCanvasI
void e_reflow_sorted_reorder_item (EReflowSorted *e_reflow_sorted, const gchar *id);
GnomeCanvasItem *e_reflow_sorted_get_item (EReflowSorted *e_reflow_sorted, const gchar *id);
GtkType e_reflow_sorted_get_type (void);
+void e_reflow_sorted_jump (EReflowSorted *sorted, GCompareFunc compare_func, void *value);
#ifdef __cplusplus
}