24 #include <glib/gi18n.h>
68 page_label = g_strdup_printf (
"%d", page + 1);
69 retval = g_strcmp0 (page_label, gtk_entry_get_text (GTK_ENTRY (action_widget->entry))) != 0;
84 label_text = g_strdup_printf (
_(
"(%d of %d)"), page + 1, n_pages);
86 label_text = g_strdup_printf (
_(
"of %d"), n_pages);
87 gtk_entry_set_text (GTK_ENTRY (action_widget->
label), label_text);
99 gtk_entry_set_text (GTK_ENTRY (action_widget->
entry), page_label);
100 gtk_editable_set_position (GTK_EDITABLE (action_widget->
entry), -1);
103 gtk_entry_set_text (GTK_ENTRY (action_widget->
entry),
"");
115 gchar *max_page_label;
116 gchar *max_page_numeric_label;
121 max_page_numeric_label = g_strdup_printf (
"%d", n_pages);
123 max_label = g_strdup_printf (
_(
"(%d of %d)"), n_pages, n_pages);
125 max_label_len = g_utf8_strlen (max_label, -1) - 2;
127 max_label = g_strdup_printf (
_(
"of %d"), n_pages);
128 max_label_len = g_utf8_strlen (max_label, -1);
130 g_free (max_page_label);
132 gtk_entry_set_width_chars (GTK_ENTRY (action_widget->
label), max_label_len);
136 gtk_entry_set_width_chars (GTK_ENTRY (action_widget->
entry),
137 CLAMP (max_label_len, strlen (max_page_numeric_label) + 1, 12));
138 g_free (max_page_numeric_label);
157 if ((event->direction == GDK_SCROLL_DOWN) &&
160 if ((event->direction == GDK_SCROLL_UP) && (pageno > 0))
181 text = gtk_entry_get_text (GTK_ENTRY (action_widget->
entry));
185 link_text = g_strdup_printf (
_(
"Page %s"), text);
190 g_object_unref (link_dest);
191 g_object_unref (link_action);
192 g_object_unref (link);
212 GtkStyleContext *style_context;
214 hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
216 style_context = gtk_widget_get_style_context (hbox);
217 gtk_style_context_add_class (style_context, GTK_STYLE_CLASS_RAISED);
218 gtk_style_context_add_class (style_context, GTK_STYLE_CLASS_LINKED);
220 action_widget->
entry = gtk_entry_new ();
221 gtk_widget_add_events (action_widget->
entry,
222 GDK_BUTTON_MOTION_MASK);
223 gtk_entry_set_width_chars (GTK_ENTRY (action_widget->
entry), 5);
224 gtk_entry_set_text (GTK_ENTRY (action_widget->
entry),
"");
225 g_signal_connect_swapped (action_widget->
entry,
"scroll-event",
228 g_signal_connect_swapped (action_widget->
entry,
"activate",
231 g_signal_connect_swapped (action_widget->
entry,
"focus-out-event",
235 obj = gtk_widget_get_accessible (action_widget->
entry);
236 atk_object_set_name (obj,
"page-label-entry");
238 gtk_box_pack_start (GTK_BOX (hbox), action_widget->
entry,
240 gtk_widget_show (action_widget->
entry);
242 action_widget->
label = gtk_entry_new ();
243 gtk_widget_set_sensitive (action_widget->
label,
FALSE);
244 gtk_entry_set_width_chars (GTK_ENTRY (action_widget->
label), 5);
245 gtk_box_pack_start (GTK_BOX (hbox), action_widget->
label,
247 gtk_widget_show (action_widget->
label);
249 gtk_container_add (GTK_CONTAINER (action_widget), hbox);
250 gtk_widget_show (hbox);
252 gtk_widget_set_sensitive (GTK_WIDGET (action_widget),
FALSE);
260 g_object_ref (document);
265 g_signal_handler_disconnect (action_widget->
doc_model,
271 g_object_unref (action_widget->
document);
277 g_signal_connect (action_widget->
doc_model,
300 g_object_remove_weak_pointer (G_OBJECT (action_widget->
doc_model),
304 g_object_add_weak_pointer (G_OBJECT (model),
308 g_signal_connect (model,
"notify::document",
320 g_signal_handler_disconnect (action_widget->
doc_model,
324 g_object_remove_weak_pointer (G_OBJECT (action_widget->
doc_model),
331 G_OBJECT_CLASS (ev_page_action_widget_parent_class)->finalize (
object);
341 *minimum_width = *natural_width = 0;
343 child = gtk_bin_get_child (GTK_BIN (widget));
344 if (!child || !gtk_widget_get_visible (child))
347 gtk_widget_get_preferred_width (child, minimum_width, natural_width);
348 *natural_width = *minimum_width;
354 GObjectClass *object_class = G_OBJECT_CLASS (klass);
355 GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
361 g_signal_new (
"activate_link",
362 G_OBJECT_CLASS_TYPE (object_class),
363 G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
366 g_cclosure_marshal_VOID__OBJECT,
374 GtkTreeModel *filter_model,
375 GtkTreeIter *filter_iter,
381 gtk_tree_model_get (filter_model, filter_iter,
384 gtk_tree_model_get (proxy->
model, iter,
391 g_object_unref (link);
393 gtk_tree_iter_free (iter);
401 GtkCellRenderer *renderer,
402 GtkTreeModel *filter_model,
403 GtkTreeIter *filter_iter,
409 gtk_tree_model_get (filter_model, filter_iter,
412 gtk_tree_model_get (proxy->
model, iter,
419 g_object_unref (link);
421 gtk_tree_iter_free (iter);
427 GtkTreeIter *filter_iter,
432 const gchar *text = NULL;
434 gtk_tree_model_get (gtk_entry_completion_get_model (completion),
438 gtk_tree_model_get (proxy->
model, iter,
445 g_object_unref (link);
448 gtk_tree_iter_free (iter);
451 gchar *normalized_text;
452 gchar *normalized_key;
453 gchar *case_normalized_text;
454 gchar *case_normalized_key;
455 gboolean retval =
FALSE;
457 normalized_text = g_utf8_normalize (text, -1, G_NORMALIZE_ALL);
458 normalized_key = g_utf8_normalize (key, -1, G_NORMALIZE_ALL);
459 case_normalized_text = g_utf8_casefold (normalized_text, -1);
460 case_normalized_key = g_utf8_casefold (normalized_key, -1);
462 if (strstr (case_normalized_text, case_normalized_key))
465 g_free (normalized_text);
466 g_free (normalized_key);
467 g_free (case_normalized_text);
468 g_free (case_normalized_key);
477 #define EPA_FILTER_MODEL_DATA "epa-filter-model"
485 GtkTreeModel *filter_model = GTK_TREE_MODEL (data);
490 gtk_tree_model_get (model, iter,
499 g_object_unref (link);
506 GtkTreeIter filter_iter;
508 gtk_list_store_append (GTK_LIST_STORE (filter_model), &filter_iter);
509 gtk_list_store_set (GTK_LIST_STORE (filter_model), &filter_iter,
514 g_object_unref (link);
519 static GtkTreeModel *
522 GtkTreeModel *filter_model;
526 if (filter_model == NULL) {
527 filter_model = (GtkTreeModel *) gtk_list_store_new (1, GTK_TYPE_TREE_ITER);
529 gtk_tree_model_foreach (model,
542 GtkTreeModel *filter_model;
543 GtkEntryCompletion *completion;
544 GtkCellRenderer *renderer;
546 if (!model || model == proxy->
model)
550 proxy->
model = model;
553 completion = gtk_entry_completion_new ();
554 g_object_set (G_OBJECT (completion),
555 "popup-set-width",
FALSE,
556 "model", filter_model,
559 g_signal_connect (completion,
"match-selected", G_CALLBACK (
match_selected_cb), proxy);
560 gtk_entry_completion_set_match_func (completion,
565 renderer = (GtkCellRenderer *)
566 g_object_new (GTK_TYPE_CELL_RENDERER_TEXT,
567 "ellipsize", PANGO_ELLIPSIZE_END,
570 gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (completion), renderer,
TRUE);
571 gtk_cell_layout_set_cell_data_func (GTK_CELL_LAYOUT (completion),
575 gtk_entry_set_completion (GTK_ENTRY (proxy->
entry), completion);
577 g_object_unref (completion);
583 gtk_widget_grab_focus (proxy->
entry);