24 #include <glib/gi18n.h>
63 #define FIND_PAGE_RATE_REFRESH 100
72 gtk_entry_set_progress_fraction (GTK_ENTRY (priv->
entry), fraction);
86 g_signal_handlers_disconnect_matched (priv->
job, G_SIGNAL_MATCH_DATA, 0, 0, NULL, NULL, box);
87 g_object_unref (priv->
job);
102 gtk_style_context_add_class (gtk_widget_get_style_context (priv->
entry), GTK_STYLE_CLASS_ERROR);
104 gtk_entry_set_icon_from_icon_name (GTK_ENTRY (priv->
entry),
105 GTK_ENTRY_ICON_PRIMARY,
106 "face-uncertain-symbolic");
108 gtk_entry_set_icon_tooltip_text (GTK_ENTRY (priv->
entry),
109 GTK_ENTRY_ICON_PRIMARY,
110 _(
"Not found, click to change search options"));
128 static inline gboolean
153 gtk_widget_set_sensitive (priv->
next_button, has_results);
154 gtk_widget_set_sensitive (priv->
prev_button, has_results);
163 const char *search_string;
173 gtk_style_context_remove_class (gtk_widget_get_style_context (priv->
entry), GTK_STYLE_CLASS_ERROR);
174 gtk_entry_set_icon_from_icon_name (GTK_ENTRY (priv->
entry),
175 GTK_ENTRY_ICON_PRIMARY,
176 "edit-find-symbolic");
178 gtk_entry_set_icon_tooltip_text (GTK_ENTRY (priv->
entry),
179 GTK_ENTRY_ICON_PRIMARY,
180 _(
"Search options"));
183 search_string = gtk_entry_get_text (GTK_ENTRY (entry));
184 if (search_string && search_string[0]) {
193 g_signal_connect (priv->
job,
"finished",
196 g_signal_connect (priv->
job,
"updated",
226 gboolean enable_search_options;
233 g_object_set (priv->
entry,
234 "primary-icon-activatable", enable_search_options,
235 "primary-icon-sensitive", enable_search_options,
236 "primary-icon-tooltip-text", enable_search_options ?
_(
"Search options") : NULL,
246 gtk_widget_set_sensitive (GTK_WIDGET (box),
FALSE);
281 if (gtk_check_menu_item_get_active (menu_item))
294 if (gtk_check_menu_item_get_active (menu_item))
308 GtkWidget *menu_item;
310 menu_item = gtk_check_menu_item_new_with_mnemonic (
_(
"_Whole Words Only"));
311 g_signal_connect (menu_item,
"toggled",
314 gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (menu_item),
316 gtk_menu_shell_prepend (GTK_MENU_SHELL (menu), menu_item);
317 gtk_widget_show (menu_item);
321 GtkWidget *menu_item;
323 menu_item = gtk_check_menu_item_new_with_mnemonic (
_(
"C_ase Sensitive"));
324 g_signal_connect (menu_item,
"toggled",
327 gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (menu_item),
329 gtk_menu_shell_prepend (GTK_MENU_SHELL (menu), menu_item);
330 gtk_widget_show (menu_item);
336 GtkEntryIconPosition icon_pos,
337 GdkEventButton *event,
342 if (event->button != GDK_BUTTON_PRIMARY)
345 if (icon_pos == GTK_ENTRY_ICON_SECONDARY)
348 menu = gtk_menu_new ();
350 gtk_widget_show (menu);
352 gtk_menu_popup (GTK_MENU (menu), NULL, NULL, NULL, NULL,
353 event->button, event->time);
362 GtkWidget *separator;
367 separator = gtk_separator_menu_item_new ();
368 gtk_menu_shell_prepend (GTK_MENU_SHELL (menu), separator);
369 gtk_widget_show (separator);
400 g_object_remove_weak_pointer (G_OBJECT (box->
priv->
model),
404 G_OBJECT_CLASS (ev_search_box_parent_class)->finalize (
object);
414 G_OBJECT_CLASS (ev_search_box_parent_class)->dispose (
object);
427 box->
priv->
model = g_value_get_object (value);
430 G_OBJECT_WARN_INVALID_PROPERTY_ID (
object, prop_id, pspec);
447 G_OBJECT_WARN_INVALID_PROPERTY_ID (
object, prop_id, pspec);
456 G_OBJECT_CLASS (ev_search_box_parent_class)->constructed (
object);
458 g_object_add_weak_pointer (G_OBJECT (box->
priv->
model),
462 g_signal_connect_object (box->
priv->
model,
"notify::document",
472 gtk_widget_grab_focus (box->
priv->
entry);
478 GObjectClass *object_class = G_OBJECT_CLASS (klass);
479 GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
480 GtkBindingSet *binding_set;
490 g_object_class_install_property (object_class,
492 g_param_spec_object (
"document-model",
494 "The document model",
497 G_PARAM_CONSTRUCT_ONLY |
498 G_PARAM_STATIC_STRINGS));
499 g_object_class_install_property (object_class,
501 g_param_spec_flags (
"options",
503 "The search options",
504 EV_TYPE_FIND_OPTIONS,
507 G_PARAM_STATIC_STRINGS));
510 g_signal_new (
"started",
511 G_OBJECT_CLASS_TYPE (object_class),
514 g_cclosure_marshal_VOID__OBJECT,
519 g_signal_new (
"updated",
520 G_OBJECT_CLASS_TYPE (object_class),
523 g_cclosure_marshal_VOID__INT,
527 g_signal_new (
"finished",
528 G_OBJECT_CLASS_TYPE (object_class),
531 g_cclosure_marshal_VOID__VOID,
534 g_signal_new (
"cleared",
535 G_OBJECT_CLASS_TYPE (object_class),
538 g_cclosure_marshal_VOID__VOID,
541 g_signal_new (
"next",
542 G_OBJECT_CLASS_TYPE (object_class),
543 G_SIGNAL_RUN_FIRST | G_SIGNAL_ACTION,
545 g_cclosure_marshal_VOID__VOID,
548 g_signal_new (
"previous",
549 G_OBJECT_CLASS_TYPE (object_class),
550 G_SIGNAL_RUN_FIRST | G_SIGNAL_ACTION,
552 g_cclosure_marshal_VOID__VOID,
557 binding_set = gtk_binding_set_by_class (klass);
558 gtk_binding_entry_add_signal (binding_set, GDK_KEY_Return, GDK_SHIFT_MASK,
560 gtk_binding_entry_add_signal (binding_set, GDK_KEY_ISO_Enter, GDK_SHIFT_MASK,
562 gtk_binding_entry_add_signal (binding_set, GDK_KEY_KP_Enter, GDK_SHIFT_MASK,
564 gtk_binding_entry_add_signal (binding_set, GDK_KEY_Up, GDK_CONTROL_MASK,
566 gtk_binding_entry_add_signal (binding_set, GDK_KEY_Down, GDK_CONTROL_MASK,
574 GtkStyleContext *style_context;
579 gtk_orientable_set_orientation (GTK_ORIENTABLE (box), GTK_ORIENTATION_HORIZONTAL);
580 style_context = gtk_widget_get_style_context (GTK_WIDGET (box));
581 gtk_style_context_add_class (style_context, GTK_STYLE_CLASS_LINKED);
582 gtk_style_context_add_class (style_context, GTK_STYLE_CLASS_RAISED);
584 priv->
entry = gtk_search_entry_new ();
586 gtk_box_pack_start (GTK_BOX (box), priv->
entry,
TRUE,
TRUE, 0);
587 gtk_widget_show (priv->
entry);
589 priv->
prev_button = gtk_button_new_from_icon_name (
"go-up-symbolic", GTK_ICON_SIZE_MENU);
590 gtk_widget_set_tooltip_text (priv->
prev_button,
_(
"Find previous occurrence of the search string"));
593 gtk_container_add (GTK_CONTAINER (box), priv->
prev_button);
596 priv->
next_button = gtk_button_new_from_icon_name (
"go-down-symbolic", GTK_ICON_SIZE_MENU);
597 gtk_widget_set_tooltip_text (priv->
next_button,
_(
"Find next occurrence of the search string"));
600 gtk_container_add (GTK_CONTAINER (box), priv->
next_button);
603 g_signal_connect (priv->
entry,
"search-changed",
606 g_signal_connect (priv->
entry,
"icon-release",
609 g_signal_connect (priv->
entry,
"populate-popup",
612 g_signal_connect (priv->
entry,
"activate",
615 g_signal_connect (priv->
entry,
"next-match",
618 g_signal_connect (priv->
entry,
"previous-match",
635 "document-model", model,
644 return GTK_SEARCH_ENTRY (box->
priv->
entry);